Donating tokens as soon as the StakingPool contract is deployed will disrupt the minting system.
The StakingPool::donateTokens function allows anyone to donate tokens to the staking pool, but if a malicous actor donates tokens as soon as the StakingPool contract is deployed it can deny genuine users from staking tokens via StakingPool::deposit and also disrupt the working of _updateStrategyRewards.
This happens because as soon as the contract is deployed and donateTokens is called, the totalStaked which was 0 will increase.
Now, if a genuine user tries to deposit tokens via StakingPool::deposit, which would eventaully call the StakingRewardsPool::_mint
This function will further calculate shares via getSharesByStake which will always return 0 as totalShares was never increased.
Hence, the _mintShares function will be passed on a amount as 0. This would lead to a revert as we try to remove DEAD_SHARES from the _amount.
Similarly, the StakingPool::_updateStrategyRewards will also get disrupted as sharesToMint will resolve to 0 as totalShares are 0.
The below test was added in staking-pool.test.ts file.
Firstly ensuring that we remove the deposit from deployFixture function of the test suite.
Test Case:
Disrupts the entire minting system and denies users from depositing tokens.
Manual review
Hardhat
Add a check in the donateTokens function to check if the quantity of totalShares is greater than 0.
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.