When users stake in epoch X, they typically expect to receive rewards in epoch X+1. However, this expectation is not met for users who stake during the first epoch. In the current protocol implementation, any amounts staked in the first epoch are not included in the reward calculations for the second epoch. As a result, these users must wait until the third epoch to claim their rewards, causing an unintended delay in receiving their rewards.
In the _checkEpochRollover()
function, the rewardPerToken
for the current epoch is only updated when totalStaked > 0
. If totalStaked
is 0, rewardPerToken
is simply set to the rewardPerToken
value from the last rewarded epoch. Since totalStaked
is updated at the end of the function, it will always be 0 during epoch 1, meaning no rewards are distributed for that epoch.
_redeem()
function, which is used to calculate the rewards for user, will fail to calculate the unclaimed rewards as the rewardPerToken
for epoch 1 will be equal to 0.
You can add the following test in stake.t.sol
and run forge test -vv --mt test_Stake_IsRewardFromFirstEpochAccounted
The impact of this issue is considered low because it affects the core functionality of the protocol only temporarily—until the third epoch, at which point rewards will be calculated correctly. However, the likelihood of this issue occurring is high, as it will inevitably happen to all users who stake during the first epoch. Given that the issue disrupts user expectations and the protocol's intended reward distribution for a short period, it can be classified as Medium severity.
Manual review, Foundry.
To mitigate this issue, one approach could be explicitly handling the transition from epoch 1 to epoch 2 by calculating rewardPerToken
using newStaked
and newVestedStaked
values. Another option is to adjust the calculateRewards()
function to account for this specific edge case, ensuring accurate reward distribution from the first epoch.
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.