The _redeem
function resets the unredeemedEpoch
wrongly, causing users to lose their rewards.
Whenever a staking operation occurs—whether staking or unstaking—the _redeem
function is invoked to calculate the pending reward for the user for the current _epoch period. However, it fails to account for any potential epochs that might have been skipped since the last time it was called. This oversight can result in potential reward losses for the user due to premature resets.
Here's a sample scenario:
At 1 epoch, Jake stakes 100 tokens.
Jake then stakes 100 token when epoch 5. At the same time, he gets 100 reward tokens. And we know his unredeemedEpoch
= 10. That is, if Jake performs a staking operation (staking/unstaking) when epoch is greater than 5, the tokens he staked at epoch 5 will be rewarded.
Jake unstake his all tokens with epoch 1. So the unredeemedEpoch
will be 0.
After a period of time, for example epoch 10, Jake want to claimReward. However, his reward is still 100 reward tokens with no accrue as unredeemedEpoch
is 0.
A user may lose their portion of rewards due to improper handling during the unstaking process.
Manual Review
Never reset the unclaimedRewards
without fully checking all previous epoch.
Check if the _epoch
is equal to currentEpoch
.
Users that try to unstake tokens from an earlier epoch after they staked in the current epoch will have their ` unredeemedEpoch` set to 0, leading to them being unable to access the newly staked tokens. Impact: High – Tokens are lost Likelihood: Medium – It happens every time a user performs the respective sequence of calls. It’s not always but it’s also not a low likelihood scenario. It’s normal usage of the protocol, that doesn’t necessarily require special conditions.
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.