@@ -658,6 +658,11 @@ def test_vote(helpers, accounts, ldo_holder, vote_ids_from_env, stranger, dual_g
658658 two_phase_frame_config_update_revert_wrong_slot_test (stranger )
659659 chain .revert ()
660660
661+ # Test external share limit
662+ chain .snapshot ()
663+ external_share_limit_test (stranger )
664+ chain .revert ()
665+
661666
662667def register_groups_in_operator_grid_test (easy_track , trusted_address , stranger , operator_grid ):
663668
@@ -1221,3 +1226,30 @@ def two_phase_frame_config_update_revert_no_permission_test(stranger):
12211226 # Even with correct slot, should revert due to missing permission (AccessControlUnauthorizedAccount)
12221227 with reverts (encode_error ("AccessControlUnauthorizedAccount(address,bytes32)" , [C .TWO_PHASE_FRAME_CONFIG_UPDATE .lower (), bytes (manage_frame_config_role )])):
12231228 two_phase_update .executeOffsetPhase ({"from" : stranger })
1229+
1230+
1231+ def external_share_limit_test (stranger ):
1232+ lido = interface .Lido (C .LIDO )
1233+
1234+ # Verify max external ratio is 30%
1235+ max_external_ratio_bp = lido .getMaxExternalRatioBP ()
1236+ assert max_external_ratio_bp == 3000 , f"Max external ratio should be 30% (3000 BP), got { max_external_ratio_bp } "
1237+
1238+ # Get current shares state
1239+ total_shares = lido .getTotalShares ()
1240+ external_shares = lido .getExternalShares ()
1241+
1242+ # Calculate max mintable:
1243+ # (external_shares + x) / (total_shares + x) <= max_external_ratio_bp / 10000
1244+ # Solving for x: x <= (total_shares * max_external_ratio_bp - external_shares * 10000) / (10000 - max_external_ratio_bp)
1245+ max_mintable = (total_shares * max_external_ratio_bp - external_shares * 10000 ) // (10000 - max_external_ratio_bp )
1246+ assert max_mintable == lido .getMaxMintableExternalShares (), "External calculation should match internal calculation"
1247+
1248+ # Impersonate VaultHub address (which has permission to mint external shares)
1249+ vault_hub_account = accounts .at (C .VAULT_HUB , force = True )
1250+
1251+ # Attempting to mint more than allowed should revert
1252+ excessive_amount = max_mintable + 1
1253+
1254+ with reverts ("EXTERNAL_BALANCE_LIMIT_EXCEEDED" ):
1255+ lido .mintExternalShares (stranger , excessive_amount , {"from" : vault_hub_account })
0 commit comments