In the current logic of WithdrawalPool, when it calls the PriorityPool::canWithdraw function, the _account parameter passed is the address of WithdrawalPool. However, the system calculates the balance based on shares allocated in StakingPool. Since WithdrawalPool itself has not earned any shares, the balance query result is always zero, preventing the correct determination of withdrawal amounts and blocking the normal execution of WithdrawalPool::performUpkeep function.
In WithdrawalPool, two key functions: checkUpkeep and performUpkeep both call the PriorityPool::canWithdraw function to determine if withdrawal conditions are met. When calling PriorityPool::canWithdraw, the _account parameter passed is the address of WithdrawalPool, which is then passed to the StakingPool::balanceOf function.
The inheritance structure of StakingPool is as follows:
The balanceOf function is defined in the base contract ERC20Upgradeable:
This function is overridden in the derived contract StakingRewardsPool:
Thus, the stakingPool.balanceOf function called in PriorityPool::canWithdraw is actually the one from StakingRewardsPool. This version calculates the balance based on shares[_account]. However, since WithdrawalPool itself has not participated in the staking process, its corresponding shares are always zero (shares[withdrawalPool.address] == 0). This results in a balance query for the WithdrawalPool address returning zero.
Additionally, the PriorityPool::getQueuedTokens function returns the amount of tokens queued for staking by the user. In this function, the _account parameter passed is also the address of WithdrawalPool, resulting in a return value of zero. Therefore, due to these parameter-passing errors, the PriorityPool::canWithdraw function always returns zero, preventing the normal triggering of the WithdrawalPool::performUpkeep function, making withdrawal operations inoperable.
Due to this issue, the performUpkeep function in WithdrawalPool cannot be triggered normally, preventing users from withdrawing funds from the pool, which can hinder normal user operations and potentially impact the overall stability of the staking and withdrawal process.
Manual audit.
Enhance Withdrawal Logic: Implement logic in WithdrawalPool to accurately track user shares and balances, allowing for correct determination of withdrawal amounts based on actual user contributions and staked shares.
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.