Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gas metrics #41

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .forge-snapshots/BalancerCompound.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
836719
1 change: 1 addition & 0 deletions .forge-snapshots/GnosisSafe.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
109223
1 change: 1 addition & 0 deletions .forge-snapshots/MakerDAO.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
313172
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,33 @@ repayment approval.

| Lender | Address | Networks | Gas | Fees | Contract |
| ---------------------- | ------------------------------------------ | ------------------------------------------------- | ------- | -------- | --------------------------------------------------------------- |
| Aave v2 | | | 262190 | 0.05% | [AaveWrapper](src/aave/AaveWrapper.sol) |
| Aave v3 | 0x9D4D2C08b29A2Db1c614483cd8971734BFDCC9F2 | Arbitrum One, Optimism, Polygon | 212569 | 0.05% | [AaveWrapper](src/aave/AaveWrapper.sol) |
| Aave v3 (Permissioned) | 0x0c86c636ed5593705b5675d370c831972C787841 | Ethereum, Gnosis | 229742 | 0 | [AaveWrapper](src/aave/AaveWrapper.sol) |
| Spark | 0x8cB701df93f2Dae295aE8D7beE5Aa7e4D40CB397 | Ethereum, Gnosis | 212569 | 0 | [AaveWrapper](src/aave/AaveWrapper.sol) |
| ZeroLend | 0xA48Cc0e4159C51d73B42c824f1444D1C1cbdA531 | Ethereum | 212569 | 0 | [AaveWrapper](src/aave/AaveWrapper.sol) |
| Aerodrome | 0x69b6E55f00d908018E2D745c524995bc231D762b | Base | 163919 | Variable | [SolidlyWrapper](src/solidly/SolidlyWrapper.sol) |
| Balancer v2 | 0x9E092cb431e5F1aa70e47e052773711d2Ba4917E | Ethereum, Arbitrum One, Optimism, Polygon, Gnosis | 113032 | 0 | [BalancerWrapper](src/balancer/BalancerWrapper.sol) |
| Balancer v2 | 0xD534400B0555F8441c5a3e0E9e585615B54fB2F4 | Base | 113032 | 0 | [BalancerWrapper](src/balancer/BalancerWrapper.sol) |
| Uniswap v3 | 0x319300462C37AD2D4f26B584C2b67De51F51f289 | Arbitrum One, Optimism, Polygon, Ethereum | 94720 | Variable | [UniswapV3Wrapper](src/uniswapV3/UniswapV3Wrapper.sol) |
| Balancer + Compound v2 | | | 836719 | 0 | [CompoundWrapper](src/compound/CompoundWrapper.sol) |
| Balancer + Moonwell | 0x6207ec38da68902CC60D3760c9fe3EB64B426207 | Base | 1183309 | 0 | [CompoundWrapper](src/compound/CompoundWrapper.sol) |
| Balancer + Sonne | 0x6412183C579a276f467ad38468D19CC8f1F2b5cb | Optimism | 1040313 | 0 | [CompoundWrapper](src/compound/CompoundWrapper.sol) |
| Balancer + Pendle | 0xC1Ea6a6df39D991006b39706db7C51f5A1819da7 | Arbitrum One | 525422 | 0 | [BalancerPendleWrapper](src/pendle/BalancerPendleWrapper.sol) |
| Balancer + Silo | 0x0F9104Fec1a5C91e63632E215e8F5c57C8f32c77 | Arbitrum One | 1025824 | 1 | [SiloWrapper](src/silo/SiloWrapper.sol) |
| Dolomite | 0x54F1ce5E6bdf027C9a6016C9F52fC5A445b77ed6 | Arbitrum One | 459815 | 0 | [DolomiteWrapper](src/dolomite/DolomiteWrapper.sol) |
| MorphoBlue | 0xa0Cb4e1222d813D6e4dE79f2A7A0B7759209588F | Ethereum | 132114 | 0 | [MorphoBlueWrapper](src/morpho/MorphoBlueWrapper.sol) |
| Balancer + Sonne | 0x6412183C579a276f467ad38468D19CC8f1F2b5cb | Optimism | 1040313 | 0 | [CompoundWrapper](src/compound/CompoundWrapper.sol) |
| Camelot | 0x5E8820B2832aD8451f65Fa2CCe2F3Cef29016D0d | Arbitrum One | 80679 | 0.01% | [AlgebraWrapper](src/algebra/AlgebraWrapper.sol) |
| Camelot + Pendle | 0xC9d66F655b7B35A2B4958bE2FB58E472736Bbc47 | Arbitrum One | 506792 | 0.01% | [AlgebraPendleWrapper](src/pendle/AlgebraPendleWrapper.sol) |
| Balancer + Pendle | 0xC1Ea6a6df39D991006b39706db7C51f5A1819da7 | Arbitrum One | 525422 | 0 | [BalancerPendleWrapper](src/pendle/BalancerPendleWrapper.sol) |
| Dolomite | 0x54F1ce5E6bdf027C9a6016C9F52fC5A445b77ed6 | Arbitrum One | 459815 | 0 | [DolomiteWrapper](src/dolomite/DolomiteWrapper.sol) |
| Gnosis Safe | | | 109223 | Variable | [GnosisSafeWrapper](src/gnosisSafe/GnosisSafeWrapper.sol) |
| MakerDAO | | | 313172 | 0 | [ERC3156Wrapper](src/erc3156/ERC3156Wrapper.sol) |
| MorphoBlue | 0xa0Cb4e1222d813D6e4dE79f2A7A0B7759209588F | Ethereum | 132114 | 0 | [MorphoBlueWrapper](src/morpho/MorphoBlueWrapper.sol) |
| Spark | 0x8cB701df93f2Dae295aE8D7beE5Aa7e4D40CB397 | Ethereum, Gnosis | 212569 | 0 | [AaveWrapper](src/aave/AaveWrapper.sol) |
| Uniswap v3 | 0x319300462C37AD2D4f26B584C2b67De51F51f289 | Arbitrum One, Optimism, Polygon, Ethereum | 94720 | Variable | [UniswapV3Wrapper](src/uniswapV3/UniswapV3Wrapper.sol) |
| Uniswap v3 + Pendle | 0xa353Fd50210786F0E038ddD574A21d0CCefb3163 | Arbitrum One | 497567 | Variable | [UniswapV3PendleWrapper](src/pendle/UniswapV3PendleWrapper.sol) |
| Aerodrome | 0x69b6E55f00d908018E2D745c524995bc231D762b | Base | 163919 | Variable | [SolidlyWrapper](src/solidly/SolidlyWrapper.sol) |
| Velodrome | 0xcF13CDdbA3aEf757c52466deC310F221e06238d6 | Optimism | 163919 | Variable | [SolidlyWrapper](src/solidly/SolidlyWrapper.sol) |
| ZeroLend | 0xA48Cc0e4159C51d73B42c824f1444D1C1cbdA531 | Ethereum | 212569 | 0 | [AaveWrapper](src/aave/AaveWrapper.sol) |

Disclaimer: The gas costs are calculated for calling `flashLoan` on each wrapper for an arbitrarily chosen token and
loan amount. Calling the underlying flash lender directly may have larger gas savings in some instances than others.
Requesting loans for different tokens or amounts might have different gas costs. For AMMs the fees often vary according
to pool parameters and state.
loan amount. Gas refunds are not taken into account and might be significant in some cases. Calling the underlying flash
lender directly may have larger gas savings in some instances than others. Requesting loans for different tokens or
amounts might have different gas costs. For AMMs the fees often vary according to pool parameters and state.

## Gnosis Safe Wrapper

Expand Down
2 changes: 1 addition & 1 deletion test/AlgebraWrapper.Camelot.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contract AlgebraWrapperCamelotTest is Test {
wrapper.algebraFlashCallback({ fee0: 0, fee1: 0, params: abi.encode(weth, usdc, 0, "") });
}

function test_measureFlashLoanGas() public {
function test_measureFlashLoanGasDebug() public {
console2.log("test_measureFlashLoanGas");
address token = wsteth;
uint256 loan = 1e18;
Expand Down
9 changes: 9 additions & 0 deletions test/CompoundWrapper.erc20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,13 @@ contract CompoundWrapperTest is Test {

wrapper.setCToken(IERC20(dai), ICToken(address(0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643)));
}

function test_measureFlashLoanGas() public {
console2.log("test_measureFlashLoanGas");
address token = dai;
uint256 loan = 1e18;
uint256 fee = wrapper.flashFee(token, loan);
deal(address(token), address(borrower), fee);
borrower.flashBorrowMeasureGas(token, loan, "BalancerCompound");
}
}
9 changes: 9 additions & 0 deletions test/ERC3156Wrapper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ contract ERC3156WrapperTest is Test {
// borrowed
assertEq(borrower.flashFee(), fee);
}

function test_measureFlashLoanGas() public {
console2.log("test_measureFlashLoanGas");
address token = dai;
uint256 loan = 1e18;
uint256 fee = wrapper.flashFee(token, loan);
deal(address(token), address(borrower), fee);
borrower.flashBorrowMeasureGas(token, loan, "MakerDAO");
}
}
9 changes: 9 additions & 0 deletions test/GnosisSafeWrapper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,13 @@ contract GnosisSafeWrapperWithWrapperTest is GnosisSafeWrapperWithWrapper {
vm.expectRevert(abi.encodeWithSelector(GnosisSafeWrapper.UnsupportedAsset.selector, USDT));
borrower.flashBorrow(USDT, 1);
}

function test_measureFlashLoanGas() public {
console2.log("test_measureFlashLoanGas");
address token = USDT;
uint256 loan = 10e18;
uint256 fee = wrapper.flashFee(token, loan);
deal(address(token), address(borrower), fee);
borrower.flashBorrowMeasureGas(token, loan, "GnosisSafe");
}
}
Loading