Future stakers are always vested FjordPoints using the total pointsPerToken without properly deducting how much pointsPerToken has already been accumulated before they stake.
Any new staker will be rewarded with pointsPerToken that have been accumulated since the creation of the contract. This means that a user who hasn't been staking from the beginning will be rewarded the same as a user who has been staking since the beginning and even more.
Every time a user stakes in the FjordStaking contract, the FjordPoints::onStaked(...) function gets executed, which starts accumulating FjordPoints. This function, on the other hand, updates the user's pending points and properly distributes them based on how much time has passed. The same things happens when users claim their FjordPoints:
The problem arises when a current stake period ends and users unstake and claim their FjordPoints and FjordTokens, and new users start staking. When the new users come in the initial pointsPerToken they will get assigned will be equal to the accumulated pointsPerToken from the previous users (which will be the pointsPerToken from the beginning of the contract). When they go and claim their tokens, they won't have a proper reward debt, and the protocol will award them as if they have been staking from the very beginning:
For the following explanation let's assume that two initial users have staked, unstaked, and claimed rewards and have set pointsPerToken to be 35e17 before the new user comes in. The new user stakes 1e18, a new epoch is then started and a reward of 1e18 has been added, after which he/she claims FjordPoints. The pointsPerEpoch are 1e18.
And now when the points are updated:
I have created my test suit, to use proper contract and no mock as in the original one.
Stakers who join the protocol at a later stage get more rewards than the early adopters, making it unfair for anyone who wants to start early.
Manual review
Modify the point distribution in FjordPoints so that when a new user joins, his reward debt properly accounts for how much time has passed, and he/she does not get accredited for any reward accumulated before he/she joins. A good idea could be to track at which point a user enters the FjordPoints contract so that his/her pointsPerTokens do not get multiplied by the whole contract timespan.
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.