canDeposit() doesn't include unusedDepositLimit in StakingPool.sol
stakingPool::canDeposit() returns the total deposit room available for deposit in the pool. Now the total deposit room for the pool will be totalStaked + unusedDepositLimit, but the problem is canDeposit() only includes the totalStaked while returning the depositRoom available for deposit.
If you see the getMaxDeposits(), it returns the max token that can be deposited in the strategy. This max amount is compared with totalStaked only in canDeposit() ie it doesn't include the unusedDepositLimit that stakingPool have.
Lets see how this works(very simple example):
Suppose we have one strategy ie strategyA, which has maxDeposit of 100e18 tokens & we have unusedDepositLimit of 20e18 tokens
User deposited 110e18 tokens in the priorityPool:deposit() with _shouldQueue = true.
Now, 100e18 tokens should be deposited to strategyA & 10e18 tokens should be available in stakingPool as unusedDepositLimit.
How many tokens will be deposited to stakingPool is calculated by canDeposit(). So lets see, how many tokens canDeposit() returns: getMaxDeposits() will return 100e18 tokens & this is compared with totalStaked(which is 0 at this point) ie 100e18 <= 0. As result, max - totalStaked is returned ie 100e18 - 0 = 100e18 tokens
As we see above, canDeposit() will only return 100e18. So priorityPool will send 100e18 tokens to the stakinPool & 10e18 will be queued in the priorityPool itself instead of sending it to the stakingPool as unusedDepositLimit
unusedDepositLimit will never be used/filled
Manual Review
Use unusedDepositLimit in canDeposit(), which calculates how many tokens can be deposited in the strategy & sit in the pool as unusedDepositLimit
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.