In PriorityPool.sol, lets refer to the _deposit function which is called by deposit.
As we can see, the order of the code when there is no queue in the PriorityPool is to
Check whether it can "swap tokens" with withdraw orders sitting in the WithdrawalPool's queue.
Check if user can directly deposit into StakingPool through checking against limit stakingPool.canDeposit()
However, functions like addStrategy could have been called slightly before. That increase may cause StakingPool's totalStaked to fall below the new getMinDeposits(), because the new strategies added will increase getMinDeposits().
Currently StakingPool has 500 tokens. (And getMinDeposits() = 500)
The deposit queue in PriorityPool is currently empty.
Alice who is a staker in StakingPool, wants to withdraw 100 of her tokens.
Since canWithdraw() of StakingPool.sol is 0, Alice's order to withdraw 100 tokens will be sent to queue in WithdrawalPool
A new strategy is added to StakingPool, raising getMinDeposits() to 600.
Bob is a fan of the new strategy and decides to deposit 100 tokens to the pool. (He has to go through PriorityPool which is the only way to deposit)
PriorityPool's deposit calls internal function _deposit which "swaps" Bob's 100 tokens with Alice's withdrawal order, wrongly allowing Alice to withdraw.
After accepting Bob as a new staker and mistakenly allowing Alice to withdraw, StakingPool's tokens remain at 500, which is below the new getMinDeposits() when it should not have been.
The purpose of the WithdrawalPool in this protocol is such that users who's withdrawal order will cause the balance to dip below getMinDeposits() will have to wait for new depositors to come and balance out their order such that they are only able to withdraw while not causing balance to drop below getMinDeposits().
The purpose of such a feature (which can be found in the documentation) is to ensure the pool enjoy continously and uninterrupted yield.
Hence, when such a senario occurs, it breaks the protocol's intended invariant.
Limit the amount to swap with the withdrawal queue to stakingPool.totalStaked - stakingPool.getMinDeposits().
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.