Description: The contract doesn't check to make sure that it has enough balance to pay out the rewards before allowing users to deposit their tokens. This ties somehow to the first reported bug [H-1].
Impact: The contract allows a user to deposit tokens as long as the balance of stakingVault
is not 0. This means that if the vault has 1000 tokens left, and a user deposits 1001, then this user will not be able to use the claimRewards
function, as this will revert, making the staking feature worthless.
Proof of concept: Add this function to the existing StakingTest.t.sol
file.
Recommended mitigation: To prevent this issue, the Staking.sol::deposit
function should check to make sure that at the time of depositing, it has enough rewards to repay the amount. Also, I recommend implementing a mechanism for auto-replenishing once in a while so that the balance of the staking contract never runs out of funds to send out rewards.
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.