From b28e7bf9ff39583544d4678acef2dfb7dac8cd68 Mon Sep 17 00:00:00 2001 From: Ana Julia Date: Mon, 1 Jul 2024 08:52:27 -0300 Subject: [PATCH] update collectRewards --- src/RewardsDistributor.sol | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/RewardsDistributor.sol b/src/RewardsDistributor.sol index 1da8d2e..78481a2 100644 --- a/src/RewardsDistributor.sol +++ b/src/RewardsDistributor.sol @@ -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