Skip to content

Commit 6efe561

Browse files
committed
fix: review
1 parent 64abb0e commit 6efe561

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

test/base-fork/Morpho.t.sol

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ contract MorphoDepositFailureTests is MorphoBaseTest {
200200
foreignController.depositERC4626(MORPHO_VAULT_USDS, 25_000_000e18, 25_000_000e18 + 1);
201201
}
202202

203+
function test_morpho_deposit_minSharesOutNotMetBoundary() external {
204+
deal(Base.USDS, address(almProxy), 25_000_000e18);
205+
206+
uint256 overBoundaryShares = usdsVault.convertToShares(25_000_000e18 + 1);
207+
uint256 atBoundaryShares = usdsVault.convertToShares(25_000_000e18);
208+
209+
vm.startPrank(relayer);
210+
vm.expectRevert("FC/min-shares-out-not-met");
211+
foreignController.depositERC4626(MORPHO_VAULT_USDS, 25_000_000e18, overBoundaryShares);
212+
213+
foreignController.depositERC4626(MORPHO_VAULT_USDS, 25_000_000e18, atBoundaryShares);
214+
}
215+
203216
}
204217

205218
contract MorphoDepositSuccessTests is MorphoBaseTest {
@@ -318,6 +331,24 @@ contract MorphoWithdrawFailureTests is MorphoBaseTest {
318331
vm.stopPrank();
319332
}
320333

334+
function test_morpho_withdraw_maxSharesInNotMetBoundary() external {
335+
deal(Base.USDS, address(almProxy), 10_000_000e18);
336+
337+
uint256 underBoundaryShares = usdsVault.convertToShares(10_000_000e18) - 1;
338+
uint256 atBoundaryShares = usdsVault.convertToShares(10_000_000e18);
339+
340+
vm.startPrank(relayer);
341+
342+
foreignController.depositERC4626(MORPHO_VAULT_USDS, 10_000_000e18, 0);
343+
344+
vm.expectRevert("FC/max-shares-in-not-met");
345+
foreignController.withdrawERC4626(MORPHO_VAULT_USDS, 10_000_000e18, underBoundaryShares);
346+
347+
foreignController.withdrawERC4626(MORPHO_VAULT_USDS, 10_000_000e18, atBoundaryShares);
348+
vm.stopPrank();
349+
}
350+
351+
321352
}
322353

323354
contract MorphoWithdrawSuccessTests is MorphoBaseTest {
@@ -497,6 +528,23 @@ contract MorphoRedeemFailureTests is MorphoBaseTest {
497528
vm.stopPrank();
498529
}
499530

531+
function test_morpho_redeem_minAssetsOutNotMetBoundary() external {
532+
deal(Base.USDS, address(almProxy), 10_000_000e18);
533+
534+
uint256 overBoundaryAssets = usdsVault.convertToAssets(10_000_000e18) + 1;
535+
uint256 atBoundaryAssets = usdsVault.convertToAssets(10_000_000e18);
536+
537+
vm.startPrank(relayer);
538+
539+
foreignController.depositERC4626(MORPHO_VAULT_USDS, 10_000_000e18, 10_000_000e18);
540+
541+
vm.expectRevert("FC/min-assets-out-not-met");
542+
foreignController.redeemERC4626(MORPHO_VAULT_USDS, 10_000_000e18, overBoundaryAssets);
543+
544+
foreignController.redeemERC4626(MORPHO_VAULT_USDS, 10_000_000e18, atBoundaryAssets);
545+
vm.stopPrank();
546+
}
547+
500548
}
501549

502550
contract MorphoRedeemSuccessTests is MorphoBaseTest {

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,21 @@ contract MainnetControllerDepositERC4626FailureTests is SUSDSTestBase {
135135
mainnetController.depositERC4626(address(susds), 1e18, 1e18);
136136
}
137137

138+
function test_depositERC4626_minSharesOutNotMetBoundary() external {
139+
uint256 overBoundaryShares = susds.convertToShares(5_000_000e18 + 1);
140+
uint256 atBoundaryShares = susds.convertToShares(5_000_000e18);
141+
142+
vm.startPrank(relayer);
143+
144+
mainnetController.mintUSDS(5_000_000e18);
145+
146+
vm.expectRevert("MC/min-shares-out-not-met");
147+
mainnetController.depositERC4626(address(susds), 5_000_000e18, overBoundaryShares);
148+
149+
mainnetController.depositERC4626(address(susds), 5_000_000e18, atBoundaryShares);
150+
vm.stopPrank();
151+
}
152+
138153
}
139154

140155
contract MainnetControllerDepositERC4626Tests is SUSDSTestBase {
@@ -232,6 +247,24 @@ contract MainnetControllerWithdrawERC4626FailureTests is SUSDSTestBase {
232247
vm.stopPrank();
233248
}
234249

250+
function test_withdrawERC4626_maxSharesInNotMetBoundary() external {
251+
// Because of rounding 1_000_000e18 is under boundary, 1_000_000e18 + 1 is at boundary
252+
253+
uint256 underBoundaryShares = susds.convertToShares(1_000_000e18);
254+
uint256 atBoundaryShares = susds.convertToShares(1_000_000e18 + 1);
255+
256+
vm.startPrank(relayer);
257+
258+
mainnetController.mintUSDS(2_000_000e18);
259+
mainnetController.depositERC4626(address(susds), 2_000_000e18, 0);
260+
261+
vm.expectRevert("MC/max-shares-in-not-met");
262+
mainnetController.withdrawERC4626(address(susds), 1_000_000e18, underBoundaryShares);
263+
264+
mainnetController.withdrawERC4626(address(susds), 1_000_000e18, atBoundaryShares);
265+
vm.stopPrank();
266+
}
267+
235268
}
236269

237270
contract MainnetControllerWithdrawERC4626Tests is SUSDSTestBase {
@@ -370,6 +403,24 @@ contract MainnetControllerRedeemERC4626FailureTests is SUSDSTestBase {
370403
vm.stopPrank();
371404
}
372405

406+
function test_redeemERC4626_minAssetsOutNotMetBoundary() external {
407+
vm.startPrank(relayer);
408+
409+
mainnetController.mintUSDS(2_000_000e18);
410+
mainnetController.depositERC4626(address(susds), 2_000_000e18, 0);
411+
412+
uint256 shares = susds.convertToShares(2_000_000e18);
413+
414+
uint256 overBoundaryAssets = susds.convertToAssets(shares) + 1;
415+
uint256 atBoundaryAssets = susds.convertToAssets(shares);
416+
417+
vm.expectRevert("MC/min-assets-out-not-met");
418+
mainnetController.redeemERC4626(address(susds), shares, overBoundaryAssets);
419+
420+
mainnetController.redeemERC4626(address(susds), shares, atBoundaryAssets);
421+
vm.stopPrank();
422+
}
423+
373424
}
374425

375426
contract MainnetControllerRedeemERC4626Tests is SUSDSTestBase {

test/mainnet-fork/Maple.t.sol

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ contract MainnetControllerDepositERC4626MapleFailureTests is MapleTestBase {
156156
mainnetController.depositERC4626(address(syrup), 1_000_000e6, 0);
157157
}
158158

159+
function test_depositERC4626_maple_minSharesOutNotMetBoundary() external {
160+
deal(address(usdc), address(almProxy), 1_000_000e6);
161+
162+
uint256 overBoundaryShares = syrup.convertToShares(1_000_000e6 + 1);
163+
uint256 atBoundaryShares = syrup.convertToShares(1_000_000e6);
164+
165+
vm.startPrank(relayer);
166+
vm.expectRevert("MC/min-shares-out-not-met");
167+
mainnetController.depositERC4626(address(syrup), 1_000_000e6, overBoundaryShares);
168+
169+
mainnetController.depositERC4626(address(syrup), 1_000_000e6, atBoundaryShares);
170+
}
171+
159172
}
160173

161174
contract MainnetControllerDepositERC4626Tests is MapleTestBase {

0 commit comments

Comments
 (0)