Submitted by bytes032, also found by J4de.
This issue can lead to extending the reward duration beyond the intended time period, causing rewards to be distributed over a longer duration than initially planned. This could result in users receiving smaller rewards over time, which may not align with the projects goals or user expectations.
The notifyRewardAmount function updates the reward rate and the period finish time for a given rewards token.
It first checks if the current block timestamp is greater than or equal to the period finish time for the given rewards token. If the reward period has passed, the reward rate is set by dividing the reward amount by the rewardsDuration for the rewards token. If the reward period has not yet passed, the remaining time and the leftover reward amount are calculated based on the current reward rate. The new reward rate is then set by adding the leftover amount to the new reward amount and dividing by the rewardsDuration.
Finally, the function then updates the lastUpdateTime for the rewards token to the current block timestamp and increments the periodFinish time by adding the rewardsDuration.
This means if theres an ongoing reward duration and its halfway done, adding new rewards will automatically increase the reward duration by the initial time period.
After discussing with the sponsor, they acknowledged that this behavior was not expected.
Modify the notifyRewardAmount function to only extend the reward duration when necessary.
daoio (Rubicon) confirmed
HickupHH3 (judge) commented:
