Skip to content

Commit

Permalink
fix(rewardManager): add stackerSeenByEpoch mapping to avoid multipl…
Browse files Browse the repository at this point in the history
…e register/claims
  • Loading branch information
Oghma committed Mar 1, 2024
1 parent 32901e3 commit ed974b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contracts/core/RewardsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contract RewardsManager is IRewardsManager, Initializable, UUPSUpgradeable, Acce
mapping(uint16 => uint256) public claimedAmountByEpoch;
mapping(uint16 => uint256) public unclaimableAmountByEpoch;
mapping(uint16 => mapping(address => uint256)) public lockedRewardByEpoch;
mapping(uint16 => mapping(address => bool)) public stakerSeenByEpoch;

event RewardRegistered(uint16 indexed epoch, address indexed staker, uint256 amount);

Expand Down Expand Up @@ -90,14 +91,16 @@ contract RewardsManager is IRewardsManager, Initializable, UUPSUpgradeable, Acce
if (epoch >= currentEpoch) revert Errors.InvalidEpoch();
(bool[] memory hasVoted, uint256[] memory amounts) = _getVotesAndBalancesForEpoch(epoch, stakers);
for (uint256 i = 0; i < stakers.length; i++) {
if (lockedRewardByEpoch[epoch][stakers[i]] > 0) continue;
if (stakerSeenByEpoch[epoch][stakers[i]]) continue;
uint256 amount = amounts[i];
if (hasVoted[i] && amount > 0) {
lockedRewardByEpoch[epoch][stakers[i]] = amount;
ITokenManager(tokenManager).mint(stakers[i], amount);
stakerSeenByEpoch[epoch][stakers[i]] = true;
emit RewardRegistered(epoch, stakers[i], amount);
} else if (amount > 0) {
unclaimableAmountByEpoch[epoch] += amount;
stakerSeenByEpoch[epoch][stakers[i]] = true;
}
}
_checkTotalSupply();
Expand Down

0 comments on commit ed974b8

Please sign in to comment.