The canDeposit() function in the StakingPool contract is intended to return the total available deposit room, accounting for unused deposits sitting in the pool, as indicated by the inline documentation. However, the current implementation does not account for these unused deposits, leading to potentially inefficient capital utilization. This discrepancy between the intended functionality and the actual implementation can result in fewer tokens being deposited into the pool than expected, affecting the protocol's efficiency.
The inline documentation suggests that canDeposit() should account for unused deposits, as seen below:
However, the current implementation only calculates the available deposit room based on the totalStaked tokens and does not consider any unused deposits that are sitting in the pool outside of a strategy. This unused deposit amount is represented by the getUnusedDeposits() function, which is used to retrieve the amount of unused deposits:
As we can see from the docs of the getUnusedDeposits function it is mentioned that the tokens sitting in the pool outside a strategy will be deposited ASAP on the next call to _depositLiquidity (which happens when PriorityPool::deposit() is triggered, provided there is available space in the StakingPool).
By ignoring unused deposits, the protocol's deposit logic will fail to deposit the optimal amount, leading to capital inefficiency.
The issue becomes more severe in the PriorityPool contract, where the canDeposit() function is used to determine how much can be deposited into the StakingPool:
Due to the current incorrect logic of canDeposit(), fewer tokens will be deposited into the pool than expected, leading to suboptimal utilization of capital.
The protocol is not functioning as expected, leading to capital inefficiencies. Users and external protocols relying on canDeposit() to account for unused deposits may be misled about the protocol's actual behavior, potentially causing confusion and financial losses.
Manual code review
Modify the canDeposit() function to account for unused deposits in the calculation of the available deposit room.
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.