From c8e0278391133b694c70a765bfb0056990e4f093 Mon Sep 17 00:00:00 2001 From: mkflow27 Date: Tue, 7 Jan 2025 17:33:01 +0100 Subject: [PATCH] Morpho 1.1 tests (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Bruno --- test/ERC4626WrapperBase.t.sol | 19 +++++++++++++------ .../ERC4626MainnetMorphoSteakhouseUSDC.t.sol | 7 ++++--- .../ERC4626MainnetMorphoSteakhouseWUSDL.t.sol | 5 +++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/test/ERC4626WrapperBase.t.sol b/test/ERC4626WrapperBase.t.sol index 3fceec9..bd126f5 100644 --- a/test/ERC4626WrapperBase.t.sol +++ b/test/ERC4626WrapperBase.t.sol @@ -22,11 +22,15 @@ abstract contract ERC4626WrapperBaseTest is Test { // Variables to be defined by setUpForkTestVariables(). string internal network; - uint256 internal blockNumber; + // Use overrideBlockNumber to specify a block number in a specific test. + uint256 internal overrideBlockNumber; IERC4626 internal wrapper; address internal underlyingDonor; uint256 internal amountToDonate; + // blockNumber is used by the base test. To override it, please use overrideBlockNumber. + uint256 internal blockNumber; + IBufferRouter internal bufferRouter; IVaultForERC4626Test internal vault; IPermit2 internal permit2; @@ -77,8 +81,9 @@ abstract contract ERC4626WrapperBaseTest is Test { } /** - * @notice Defines network, blockNumber, wrapper, underlyingDonor and amountToDonate. - * @dev Make sure the underlyingDonor has at least amountToDonate underlying tokens. + * @notice Defines network, overrideBlockNumber, wrapper, underlyingDonor and amountToDonate. + * @dev Make sure the underlyingDonor has at least amountToDonate underlying tokens, and that the buffer was not + * initialized for the ERC4626 token in the current block number. */ function setUpForkTestVariables() internal virtual; @@ -409,19 +414,21 @@ abstract contract ERC4626WrapperBaseTest is Test { function _configurePermit2AndBufferToNetwork() private { // Block Numbers are based on the deployment of BufferRouter. + // IMPORTANT: If a test requires a new blockNumber, change `overrideBlockNumber` in the test itself using the + // function `setUpForkTestVariables()`. Do not change the values below, since all tests depend on it. if (_compareStrings(network, "mainnet")) { - blockNumber = 21339384; + blockNumber = overrideBlockNumber != 0 ? overrideBlockNumber : 21339384; permit2 = IPermit2(0x000000000022D473030F116dDEE9F6B43aC78BA3); bufferRouter = IBufferRouter(0x9179C06629ef7f17Cb5759F501D89997FE0E7b45); vault = IVaultForERC4626Test(0xbA1333333333a1BA1108E8412f11850A5C319bA9); } else if (_compareStrings(network, "gnosis")) { - blockNumber = 37377481; + blockNumber = overrideBlockNumber != 0 ? overrideBlockNumber : 37377481; permit2 = IPermit2(0x000000000022D473030F116dDEE9F6B43aC78BA3); bufferRouter = IBufferRouter(0x86e67E115f96DF37239E0479441303De0de7bc2b); vault = IVaultForERC4626Test(0xbA1333333333a1BA1108E8412f11850A5C319bA9); } else if (_compareStrings(network, "sepolia")) { - blockNumber = 7219291; + blockNumber = overrideBlockNumber != 0 ? overrideBlockNumber : 7219291; permit2 = IPermit2(0x000000000022D473030F116dDEE9F6B43aC78BA3); bufferRouter = IBufferRouter(0xb5F3A41515457CC6E2716c62a011D260441CcfC9); vault = IVaultForERC4626Test(0xbA1333333333a1BA1108E8412f11850A5C319bA9); diff --git a/test/mainnet/ERC4626MainnetMorphoSteakhouseUSDC.t.sol b/test/mainnet/ERC4626MainnetMorphoSteakhouseUSDC.t.sol index 9ab0ea8..e0621dd 100644 --- a/test/mainnet/ERC4626MainnetMorphoSteakhouseUSDC.t.sol +++ b/test/mainnet/ERC4626MainnetMorphoSteakhouseUSDC.t.sol @@ -15,11 +15,12 @@ contract ERC4626MainnetMorphoSteakhouseUsdcTest is ERC4626WrapperBaseTest { function setUpForkTestVariables() internal override { network = "mainnet"; + overrideBlockNumber = 21537026; // Morpho's Steakhouse USDC - wrapper = IERC4626(0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB); + wrapper = IERC4626(0x7204B7Dbf9412567835633B6F00C3Edc3a8D6330); // Donor of USDC tokens - underlyingDonor = 0x4B16c5dE96EB2117bBE5fd171E4d203624B014aa; - amountToDonate = 1e6 * 1e6; + underlyingDonor = 0x37305B1cD40574E4C5Ce33f8e8306Be057fD7341; + amountToDonate = 10_000 * 1e6; } } diff --git a/test/mainnet/ERC4626MainnetMorphoSteakhouseWUSDL.t.sol b/test/mainnet/ERC4626MainnetMorphoSteakhouseWUSDL.t.sol index ee85176..b0393ee 100644 --- a/test/mainnet/ERC4626MainnetMorphoSteakhouseWUSDL.t.sol +++ b/test/mainnet/ERC4626MainnetMorphoSteakhouseWUSDL.t.sol @@ -15,11 +15,12 @@ contract ERC4626MainnetMorphoSteakhouseWUSDLTest is ERC4626WrapperBaseTest { function setUpForkTestVariables() internal override { network = "mainnet"; + overrideBlockNumber = 21537026; // Morpho's Steakhouse wUSDL - wrapper = IERC4626(0xbEEFC01767ed5086f35deCb6C00e6C12bc7476C1); + wrapper = IERC4626(0xbEeFc011e94f43b8B7b455eBaB290C7Ab4E216f1); // Donor of wUSDL tokens underlyingDonor = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb; - amountToDonate = 1e6 * 1e18; + amountToDonate = 10_000 * 1e18; } }