@@ -36,6 +36,7 @@ contract sGhoTest is TestnetProcedures {
3636 address internal yManager; // Yield manager user
3737
3838 uint256 internal constant MAX_TARGET_RATE = 5000 ; // 50%
39+ uint256 internal constant SUPPLY_CAP = 1_000_000 ether ; // 1M GHO
3940
4041 // Permit constants
4142 string internal constant VERSION = '1 ' ; // Matches sGHO constructor
@@ -66,7 +67,8 @@ contract sGhoTest is TestnetProcedures {
6667 sGHO.initialize.selector ,
6768 address (gho),
6869 address (contracts.aclManager),
69- MAX_TARGET_RATE
70+ MAX_TARGET_RATE,
71+ SUPPLY_CAP
7072 )
7173 )
7274 )
@@ -302,18 +304,28 @@ contract sGhoTest is TestnetProcedures {
302304 }
303305
304306 function test_4626_maxMethods () external {
305- // Deposit max checks (no limits implemented in this sGHO version)
306- assertEq (sgho.maxDeposit (user1), type (uint256 ).max, 'maxDeposit should be max ' );
307- assertEq (sgho.maxMint (user1), type (uint256 ).max, 'maxMint should be max ' );
307+ // Max deposit should be the supply cap initially
308+ assertEq (sgho.maxDeposit (user1), SUPPLY_CAP, 'maxDeposit should be supply cap ' );
308309
309- // Withdraw max checks
310+ // Max mint should correspond to the supply cap
311+ uint256 expectedMaxMint = sgho.convertToShares (SUPPLY_CAP);
312+ assertEq (sgho.maxMint (user1), expectedMaxMint, 'maxMint should be supply cap in shares ' );
313+
314+ // Deposit some amount and check max withdraw/redeem
310315 vm.startPrank (user1);
311316 uint256 depositAmount = 100 ether ;
312317 sgho.deposit (depositAmount, user1);
313318 uint256 shares = sgho.balanceOf (user1);
314319
315320 assertEq (sgho.maxWithdraw (user1), depositAmount, 'maxWithdraw mismatch ' );
316321 assertEq (sgho.maxRedeem (user1), shares, 'maxRedeem mismatch ' );
322+
323+ // Max deposit should be reduced by the deposited amount
324+ assertEq (
325+ sgho.maxDeposit (user1),
326+ SUPPLY_CAP - depositAmount,
327+ 'maxDeposit should be reduced '
328+ );
317329 vm.stopPrank ();
318330 }
319331
@@ -359,6 +371,51 @@ contract sGhoTest is TestnetProcedures {
359371 vm.stopPrank ();
360372 }
361373
374+ // --- Supply Cap Tests ---
375+ function test_revert_deposit_exceedsCap () external {
376+ vm.startPrank (user1);
377+ uint256 amount = SUPPLY_CAP + 1 ;
378+ vm.expectRevert (
379+ abi.encodeWithSelector (
380+ ERC4626 .ERC4626ExceededMaxDeposit .selector ,
381+ user1,
382+ amount,
383+ SUPPLY_CAP
384+ )
385+ );
386+ sgho.deposit (amount, user1);
387+ vm.stopPrank ();
388+ }
389+
390+ function test_revert_mint_exceedsCap () external {
391+ vm.startPrank (user1);
392+ uint256 shares = sgho.convertToShares (SUPPLY_CAP) + 1 ;
393+ uint256 maxShares = sgho.maxMint (user1);
394+ vm.expectRevert (
395+ abi.encodeWithSelector (
396+ ERC4626 .ERC4626ExceededMaxMint .selector ,
397+ user1,
398+ shares,
399+ maxShares
400+ )
401+ );
402+ sgho.mint (shares, user1);
403+ vm.stopPrank ();
404+ }
405+
406+ function test_deposit_atCap () external {
407+ vm.startPrank (user1);
408+ sgho.deposit (SUPPLY_CAP, user1);
409+ assertEq (sgho.totalAssets (), SUPPLY_CAP, 'Total assets should equal supply cap ' );
410+ // The contract balance will be the supply cap plus the 1 GHO donated in setUp
411+ assertEq (
412+ gho.balanceOf (address (sgho)),
413+ SUPPLY_CAP + 1 ether,
414+ 'Contract balance should be supply cap + initial donation '
415+ );
416+ vm.stopPrank ();
417+ }
418+
362419 // --- Yield Integration Tests (_updateVault) ---
363420
364421 function test_yield_claimSavingsIntegration (uint256 depositAmount , uint64 timeSkip ) external {
@@ -790,7 +847,8 @@ contract sGhoTest is TestnetProcedures {
790847 sGHO.initialize.selector ,
791848 address (gho),
792849 address (contracts.aclManager),
793- MAX_TARGET_RATE
850+ MAX_TARGET_RATE,
851+ SUPPLY_CAP
794852 )
795853 )
796854 )
@@ -811,15 +869,21 @@ contract sGhoTest is TestnetProcedures {
811869 sGHO.initialize.selector ,
812870 address (gho),
813871 address (contracts.aclManager),
814- MAX_TARGET_RATE
872+ MAX_TARGET_RATE,
873+ SUPPLY_CAP
815874 )
816875 );
817876
818877 sGHO newSgho = sGHO (payable (address (proxy)));
819878
820879 // Should revert on second initialization via proxy
821880 vm.expectRevert ();
822- newSgho.initialize (address (gho), address (contracts.aclManager), MAX_TARGET_RATE);
881+ newSgho.initialize (
882+ address (gho),
883+ address (contracts.aclManager),
884+ MAX_TARGET_RATE,
885+ SUPPLY_CAP
886+ );
823887 }
824888
825889 function _wadPow (uint256 base , uint256 exp ) internal pure returns (uint256 ) {
0 commit comments