Skip to content

Commit

Permalink
fix(rewards-manager): add stakerSeenByEpoch mapping to avoid multip…
Browse files Browse the repository at this point in the history
…le register/claims
  • Loading branch information
Oghma committed Mar 1, 2024
1 parent 060ffea commit a77cbee
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)) private _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 a77cbee

Please sign in to comment.