rewardPerToken sometimes does not update correctly, so the user loses his reward.
background:
The protocol adopts the rewardPerToken model. Before the total reward and total pledge amount change, rewardPerToken and the settlement user’s reward income will be updated first. rewardPerToken represents the cumulative reward of each token in each epoch.
When updating rewardPerToken, it will only be updated if totalStaked>0, and will not be updated if totalStaked==0.
When settling user rewards, if the user's pledge meets the conditions (ud.unredeemedEpoch > 0 && ud.unredeemedEpoch < currentEpoch), the rewards should also be settled.
So assume the following:
The user pledges 100 in the first epoch.
The user claims it rewards in the third epoch. At this time, 2 epochs have passed, so the user should receive the reward.
But in fact, since this is the first time the _checkEpochRollover
function is called after staking, totalStaked is still 0, so rewardPerToken is still 0.
Then execute the _redeem
function. Since rewardPerToken is 0, the calculated result of the calculateReward function must be 0.
In fact, users pledged in epochs 1~3, but did not receive any rewards.
Users may lose part of their rewards.
So the impact is high
Possibility: Since only the first user to call the _checkEpochRollover function will suffer the loss, the possibility is Med/Low.
The final rating I think is H/M.
manual
It is recommended to add newStaked to judge together.
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.