new users will receive points from previous days in the epoch they did not stake in.
fjord points are points that users accrue while staking. Below i will explain how a user will be able to claim points from days in the epoch he did not stake in.
the onstaked function is called when a user stakes in order to start the stake of points for a user.
if we look at the modifiers there is 3 onlyStaking which ensure only the staking contract can call the function, checkDistribution which distributes the points that are pending if enough time (1 epoch/ 1 weeks) has passed, and updatePendingPoints which will update the pendingPoints and the lastPointsPerToken of a user.
The problem occurs in teh distributePoints function which is called in onStaked because of the checkDistribution modifier
The error is in the if statment.
if (block.timestamp < lastDistribution + EPOCH_DURATION) { return;
Therefore if 1 week has not passed then we do not update the PointsPerToken
This allows a user to stake for 1 block and claim the rewards of 1 week/epoch even though he did not stake the entire week.
for example, there is only 1 block left until epoch is completed, this means that distrubutePoints will not pass the first if statement so we will not update pointsPerToken, the user will receive the old pointsPerToken, then the users points per token will be set at the old value before as shown in snippet below
the next block comes and distributePoints is called and a new pointsPerToken is set,
the user may now claim the points for the entire week of staking/ epoch, even if he did not stake the entire epoch/week.
user stakes when there is 1 block left for epoch to finish
the modifier on onStaked calls for distributePoints since epoch has not fully passed we do not update PointsPerToken
users lastPointsPerToken is set to the old value
the next block and distrubiutePoints is called
the pointsPerToken is updated
the user can now claim the points for the entire week, even though he staked for 1 block.
A user who staked for less than the epoch will be rewarded with too many points than they should. Making it unfair for the users who did stake the entire epoch
manual review
pointsPerToken should be incremented slightly every call to distributePoints to avoid this bug
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.