Submitted by WatchPug
In Gauge.sol#notifyRewardAmount(), the updated rewardRate for the token: rewardRate[token] is calculated based on the newly added amount of tokens (amount), the remaining amount of existing rewards (_left), and the DURATION.
While the DURATION is 5 days, the period from the current time to periodFinish[token] is much longer.
rewardPerToken() is calculated based on the current time, lastUpdateTime[token], and rewardRate[token].
Gauge.sol#L375-L380
lastUpdateTime[token] will frequently be updated to the current timestamp by _updateRewardForAllTokens().
See: Gauge.sol#L460-L469
As a result, rewardPerToken() can be much higher than expected, which makes the total amount of reward tokens less than the total amount of rewards accumulated by all the users.
This makes the users who claim the rewards later unable to retrieve their rewards as the balance can be insufficient.
Consider calculating rewardRate base on timeUntilNextPeriodFinish to next period finish:
pooltypes (Velodrome) acknowledged
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
