diff --git a/.forge-snapshots/BalancerCompound.snap b/.forge-snapshots/BalancerCompound.snap new file mode 100644 index 0000000..c005b7d --- /dev/null +++ b/.forge-snapshots/BalancerCompound.snap @@ -0,0 +1 @@ +836719 \ No newline at end of file diff --git a/.forge-snapshots/GnosisSafe.snap b/.forge-snapshots/GnosisSafe.snap new file mode 100644 index 0000000..be826eb --- /dev/null +++ b/.forge-snapshots/GnosisSafe.snap @@ -0,0 +1 @@ +109223 \ No newline at end of file diff --git a/.forge-snapshots/MakerDAO.snap b/.forge-snapshots/MakerDAO.snap new file mode 100644 index 0000000..61ad86f --- /dev/null +++ b/.forge-snapshots/MakerDAO.snap @@ -0,0 +1 @@ +313172 \ No newline at end of file diff --git a/README.md b/README.md index f9c3d4b..9d72405 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/test/AlgebraWrapper.Camelot.t.sol b/test/AlgebraWrapper.Camelot.t.sol index f9d237f..039669f 100644 --- a/test/AlgebraWrapper.Camelot.t.sol +++ b/test/AlgebraWrapper.Camelot.t.sol @@ -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; diff --git a/test/CompoundWrapper.erc20.t.sol b/test/CompoundWrapper.erc20.t.sol index 62e55ea..1371265 100644 --- a/test/CompoundWrapper.erc20.t.sol +++ b/test/CompoundWrapper.erc20.t.sol @@ -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"); + } } diff --git a/test/ERC3156Wrapper.t.sol b/test/ERC3156Wrapper.t.sol index c277d22..5ea474b 100644 --- a/test/ERC3156Wrapper.t.sol +++ b/test/ERC3156Wrapper.t.sol @@ -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"); + } } diff --git a/test/GnosisSafeWrapper.t.sol b/test/GnosisSafeWrapper.t.sol index 04c6825..d182140 100644 --- a/test/GnosisSafeWrapper.t.sol +++ b/test/GnosisSafeWrapper.t.sol @@ -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"); + } }