Could someone explain to me like I'm 5 the purpose of the notifyRewardAmount()
function on the Synthetix's StakingRewards
contract please?
I think it's connected to modifying the rewards campaign's finish time if there are still more rewards to distribute, but I can't seem to wrap my head around the purpose of the function in a clear way.
function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) {
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(rewardsDuration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(rewardsDuration);
}
uint balance = rewardsToken.balanceOf(address(this));
require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high");
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(rewardsDuration);
emit RewardAdded(reward);
}
Full contract here.