Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: high
Invalid

stakingPool:canDeposit() is broken

Summary

stakingPool:canDeposit() is broken

Vulnerability Details

When a user deposits asset token to priority pool, it checks canDeposit() of staking pool. it returns the room available to deposit ie totalStaked in strategy & unusedDepositLimit.

function canDeposit() external view returns (uint256) {
uint256 max = getMaxDeposits();
if (max <= totalStaked) {
return 0;
} else {
return max - totalStaked;
}
}

The issue is canDeposit() only returns the totalStaked in strategy but not the unusedDepositLimit because getMaxDeposits() only returns the max token that can be deposited into strategy.

function getMaxDeposits() public view returns (uint256) {
uint256 max;
for (uint256 i = 0; i < strategies.length; i++) {
uint strategyMax = IStrategy(strategies[i]).getMaxDeposits();
if (strategyMax >= type(uint256).max - max) {
return type(uint256).max;
}
max += strategyMax;
}
return max;
}

Impact

unusedDepositLimit of stakingPool will not be fully utilised due to wrong calculation in canDeposit()

Tools Used

VS code

Recommendations

Include unusedDepositLimit while calculating canDeposit()

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.