In FjordStaking.sol, users can stake an amount of the FjordToken and are supposed to be ELIGIBLE to claimReward after at least an epoch has passed (though early claiming is penalized). But the current implementation denies them.
Assuming that a bunch of stakers stake on the very first epoch just after the protocol is deployed. Because they just staked their stake will initially be newStaked and totalStaked will remain 0. This is good so far.
But as per the current design, the protocol expects some activity from users to happen (in a different epoch) so that totalStaked will be updated so that eventually the stakers will be able to claim rewards.
Say no activity happened, the stakers wait for several epochs and they call the function claimReward. It will revert!
The root cause of this is analyzed below;
When claimReward is called;
user's unclaimedRewards is not updated correctly.
when we evaluate the calculateReward function, we notice it is using rewardPerToken for reward amount calculation
Evaluating rewardPerToken shows that it is updated to new value only when totalStaked > 0 in _checkEpochRollover. But remember that at this point there was no other activity in different epoch so totalStaked remained at 0 thus rewardPerToken for all the epochs remains 0
totalStaked is updated too late and therefore since rewardPerToken for the epochs are used in the calculation of the reward, the unclaimedRewards is evaluated to zero thus claimReward reverts
Manual Review, Foundry
Consider the edge case when no activity happens after users stake their tokens and when they claim their reward update their rewards accordingly.
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.