Description: In the current implementation of the Staking.sol
contract, there is an issue where user funds could become stuck due to the contract attempting to distribute more staking rewards than the balance it holds. The contract calculates rewards based on the number of tokens staked and the time they have been staked, without adequately checking whether sufficient funds are available to cover these rewards.
Impact: If the contract's balance is insufficient to cover the calculated rewards, any call to the claimRewards
function will fail, preventing the claiming of rewards.
Proof of concept: Add this function to the existing StakingTest.t.sol
file.
Recommended mitigation: To prevent this issue, the Staking contract should implement a check before attempting to distribute rewards to ensure that the contract's balance is sufficient to cover the rewards. If the balance is not sufficient, the contract could proportionally reduce the rewards to match the available balance or prevent the reward claim until the balance is replenished.
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.