@@ -36,14 +36,17 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
3636 uint256 private constant FIXED_POINT_PRECISION = 1e18 ;
3737
3838 /// @dev Maximum number of simultaneous stake thaw requests (per provision) or undelegations (per delegation)
39- uint256 private constant MAX_THAW_REQUESTS = 100 ;
39+ uint256 private constant MAX_THAW_REQUESTS = 1_000 ;
4040
4141 /// @dev Address of the staking extension contract
4242 address private immutable STAKING_EXTENSION_ADDRESS;
4343
4444 /// @dev Minimum amount of delegation.
4545 uint256 private constant MIN_DELEGATION = 1e18 ;
4646
47+ /// @dev Minimum amount of undelegation with beneficiary.
48+ uint256 private constant MIN_UNDELEGATION_WITH_BENEFICIARY = 10e18 ;
49+
4750 /**
4851 * @notice Checks that the caller is authorized to operate over a provision.
4952 * @param serviceProvider The address of the service provider.
@@ -931,6 +934,17 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
931934 // delegation pool shares -> delegation pool tokens -> thawing pool shares
932935 // Thawing pool is reset/initialized when the pool is empty: prov.tokensThawing == 0
933936 uint256 tokens = (_shares * (pool.tokens - pool.tokensThawing)) / pool.shares;
937+
938+ // Since anyone can undelegate for any beneficiary, we require a minimum amount to prevent
939+ // malicious actors from flooding the thaw request list with tiny amounts and causing a
940+ // denial of service attack by hitting the MAX_THAW_REQUESTS limit
941+ if (_requestType == ThawRequestType.DelegationWithBeneficiary) {
942+ require (
943+ tokens >= MIN_UNDELEGATION_WITH_BENEFICIARY,
944+ HorizonStakingInsufficientUndelegationTokens (tokens, MIN_UNDELEGATION_WITH_BENEFICIARY)
945+ );
946+ }
947+
934948 // Thawing shares are rounded down to protect the pool and avoid taking extra tokens from other participants.
935949 uint256 thawingShares = pool.tokensThawing == 0 ? tokens : ((tokens * pool.sharesThawing) / pool.tokensThawing);
936950 uint64 thawingUntil = uint64 (block .timestamp + uint256 (_provisions[_serviceProvider][_verifier].thawingPeriod));
0 commit comments