Skip to content

Commit

Permalink
Update OperatorRewardsCollector.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
dulguun-staderlabs committed Nov 20, 2023
1 parent ca9aba3 commit b48b3eb
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions contracts/OperatorRewardsCollector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpg

mapping(address => uint256) public balances;

mapping(address => uint256)[] public owedAmounts;
mapping(address => uint256)[] public owedAmounts;
mapping(address => uint256)[] public claimableAmounts;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
Expand Down Expand Up @@ -51,16 +52,24 @@ contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpg
function claimFor(address operator) external {
uint256 toSendAmount;
for (uint256 i = 0; i < owedAmounts[operator].length; i++) {
if (balancer[operator] >= owedAmounts[operator][i]) {
if (balances[operator] >= owedAmounts[operator][i]) {
toSendAmount = owedAmounts[operator][i];
balances[operator] -= owedAmounts[operator][i];
claimableAmounts[operator][i] = owedAmounts[operator][i];
owedAmounts[operator][i] = 0;
} else {
toSendAmount = balancer[operator];
owedAmounts[operator][i] -= balancer[operator];
toSendAmount = balances[operator];
owedAmounts[operator][i] -= balances[operator];
claimableAmounts[operator][i] = balances[operator];
balances[operator] = 0;
break;
}
}

if (balances[operator] > 0) {
address operatorRewardsAddr = UtilLib.getOperatorRewardAddress(operator, staderConfig);
UtilLib.sendValue(operatorRewardsAddr, owedAmounts[operator][i]);
emit Claimed(operatorRewardsAddr, owedAmounts[operator][i]);
UtilLib.sendValue(operatorRewardsAddr, balances[operator]);
emit Claimed(operatorRewardsAddr, balances[operator]);
}
}

Expand Down

0 comments on commit b48b3eb

Please sign in to comment.