distributeRewards()
distributes TempleGold rewards to stakers and starts a new epoch, potentially elongating the periodFinish. In some scenarios, this can decrease the reward rate, resulting in suboptimal rewards for stakers.
distributeRewards()
calls _notifyReward
to update the reward rate and other parameters used in computing TempleGold rewards:
Suppose the previous reward rate is r
, remaining time is t
, and reward duration is T
. The new reward rate will be calculated as (amount + r*t)/T
, which can be less than the previous rate r
. In such cases, the resulting rate will be lower, and stakers will receive fewer rewards than they should
The issue arises Since instead of vesting the notified amount
for the next rewardDuration
, it streams the leftover + amount
for the next rewardDuration. If distributionStarter is set to the zero address, anyone can call distributeRewards()
, leading to the to above issue.
Example:
TGLD rewards = 100,000
Duration for rewards = 1,000 seconds
At t = 0:
First _notifyReward():
r = 100,000 / 1,000 = 100
At t = 900:
Second _notifyReward() adds 80,000 rewards:
leftover = 100 * 100 = 10,000
r = (80,000 + 10,000) / 1,000 = 90
A staker who expected to receive rewards at a rate of 100 will now receive rewards at a rate of 90
Suboptimal rewardrate implementation
Manual
Reward rate should not decrease after adding rewards.
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.