Period finish function always increases the period end timestamp even after the period has ended which leads to incorrect distribution of the rewards.
Following is what period finish returns
Error is how lastUpdateTime is used here because lastUpdateTime is always increased whenver update reward call is made for any user
last time reward applicable call is made in order to check if the period has ended or not so that if period is ended there cannot be more distriution of the rewards.
Suppose rewards are notified
It is clear that amount is divided by period duration therefore when time enough time has passed then reward distribution should stop. Precisely when period duration is over then reward distribution should stop.
Suppose period duration is 7 days.
Current day is t=0 Days.
Rewards are notified.
reward rate is amount/7 (days)
Now what period finish function does is even if current timestamp is greater than the t+7 days it will not indicate that the period has finished because it will add period duration to the current timestamp and it will appera that still 7 days are left and will allow distribution of the rewards. So essentially amount/7 (days) can even get mulitplied by 14 days (just for example) so 2*amount will be distributed even when there is only amount tokens in the gauge.
last update time is always updated whenver rewards are updated for any user
Due to this last update time can be greater than t=0 days due to which last update time + period duration will give period finish time to be greater than t=7 days.
Wrong distribution of the rewards
Manual
Do not use lastupdatetime in period finish function instead intialize a variable when rewarda were notified.
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.