Skip to content

Commit b4d4d12

Browse files
committed
feat: zero rate deposit failure tests
1 parent 4ab5f1c commit b4d4d12

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

test/base-fork/Morpho.t.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ contract MorphoDepositFailureTests is MorphoBaseTest {
181181
foreignController.depositERC4626(MORPHO_VAULT_USDS, 25_000_000e18);
182182
}
183183

184+
function test_morpho_usdc_deposit_zeroExchangeRate() external {
185+
deal(Base.USDS, address(almProxy), 25_000_000e18);
186+
187+
vm.prank(Base.SPARK_EXECUTOR);
188+
foreignController.setMaxExchangeRate(MORPHO_VAULT_USDS, 0, 0);
189+
190+
vm.prank(relayer);
191+
vm.expectRevert("FC/exchange-rate-too-high");
192+
foreignController.depositERC4626(MORPHO_VAULT_USDS, 1e18);
193+
}
194+
184195
}
185196

186197
contract MorphoDepositSuccessTests is MorphoBaseTest {

test/mainnet-fork/4626Calls.t.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ contract MainnetControllerDepositERC4626FailureTests is SUSDSTestBase {
106106
mainnetController.depositERC4626(address(susds), 5_000_000e18);
107107
}
108108

109+
function test_depositERC4626_zeroExchangeRate() external {
110+
vm.prank(relayer);
111+
mainnetController.mintUSDS(5_000_000e18);
112+
113+
vm.prank(Ethereum.SPARK_PROXY);
114+
mainnetController.setMaxExchangeRate(address(susds), 0, 0);
115+
116+
vm.prank(relayer);
117+
vm.expectRevert("MC/exchange-rate-too-high");
118+
mainnetController.depositERC4626(address(susds), 5_000_000e18);
119+
}
120+
109121
}
110122

111123
contract MainnetControllerDepositERC4626Tests is SUSDSTestBase {

test/mainnet-fork/ERC4626DonationAttack.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ contract ERC4626DonationAttack is ERC4626DonationAttackTestBase {
8686

8787
function test_depositERC4626_donationAttackFailure() external {
8888
vm.startPrank(Ethereum.SPARK_PROXY);
89-
mainnetController.setMaxExchangeRate(address(morphoVault), morphoVault.convertToShares(1e18), 1.2e18);
89+
mainnetController.setMaxExchangeRate(address(morphoVault), 1e18, 10e18);
9090
vm.stopPrank();
9191

9292
_doAttack();

test/mainnet-fork/Maple.t.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ contract MainnetControllerDepositERC4626MapleFailureTests is MapleTestBase {
145145
mainnetController.depositERC4626(address(syrup), 1_000_000e6);
146146
}
147147

148+
function test_depositERC4626_maple_zeroExchangeRate() external {
149+
deal(address(usdc), address(almProxy), 1_000_000e6);
150+
151+
vm.prank(Ethereum.SPARK_PROXY);
152+
mainnetController.setMaxExchangeRate(address(syrup), 0, 0);
153+
154+
vm.prank(relayer);
155+
vm.expectRevert("MC/exchange-rate-too-high");
156+
mainnetController.depositERC4626(address(syrup), 1_000_000e6);
157+
}
158+
148159
}
149160

150161
contract MainnetControllerDepositERC4626Tests is MapleTestBase {

0 commit comments

Comments
 (0)