Skip to content

Commit

Permalink
update collectRewards
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jul 1, 2024
1 parent 8e087f5 commit b28e7bf
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/RewardsDistributor.sol
Original file line number Diff line number Diff line change
@@ -76,20 +76,17 @@ contract RewardsDistributor is Ownable2Step, IRewardsDistributor {
// difference in time since last update
uint256 timeDelta = block.timestamp - rewardConfiguration.lastUpdate;

if (rewardConfiguration.emissionRate == 0 || timeDelta == 0) {
// nothing to do
return 0;
}

rewards = rewardConfiguration.emissionRate * timeDelta;
if (rewardConfiguration.emissionRate != 0 && timeDelta != 0) {
rewards = rewardConfiguration.emissionRate * timeDelta;

// update the last update timestamp
rewardConfiguration.lastUpdate = block.timestamp;
// update the last update timestamp
rewardConfiguration.lastUpdate = block.timestamp;

// transfer the reward
rewardToken.safeTransfer(receiver, rewards);
// transfer the reward
rewardToken.safeTransfer(receiver, rewards);

emit RewardCollected(receiver, rewards);
emit RewardCollected(receiver, rewards);
}
}

/// @notice Add a reward configuration

0 comments on commit b28e7bf

Please sign in to comment.