Skip to content

Commit

Permalink
fix(rewards-manager): add stackerSeenByEpoch mapping to avoid multi…
Browse files Browse the repository at this point in the history
…ple register/claims
  • Loading branch information
Oghma authored and oliviera9 committed Mar 1, 2024
1 parent 060ffea commit 5b49598
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 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,7 +91,8 @@ 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;
stakerSeenByEpoch[epoch][stakers[i]] = true;
uint256 amount = amounts[i];
if (hasVoted[i] && amount > 0) {
lockedRewardByEpoch[epoch][stakers[i]] = amount;
Expand Down

0 comments on commit 5b49598

Please sign in to comment.