Skip to content

Commit

Permalink
Claim available amount
Browse files Browse the repository at this point in the history
  • Loading branch information
dulguun-staderlabs committed Jan 7, 2024
1 parent fe32591 commit f79c803
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion contracts/OperatorRewardsCollector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpg
* @param operator The address of the operator for whom the claim is being made.
*/
function claimFor(address operator, uint256 amount) public override {
if (amount == 0) amount = balances[operator]; // If no amount is specified, claim the full balance
if (amount == 0)
amount = balances[operator] > withdrawableInEth(operator)
? withdrawableInEth(operator)
: balances[operator]; // If no amount is specified, claim the available full balance

_completeLiquidationIfExists(operator);
_transferBackUtilizedSD(operator);
Expand Down
6 changes: 5 additions & 1 deletion test/foundry_tests/SDIncentiveController.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ contract SDIncentiveControllerTest is Test {
vm.stopPrank();

vm.roll(block.number + duration);
assertApproxEqAbs(earned + sdIncentiveController.earned(user2) + sdIncentiveController.earned(user), incentiveAmount, 1e9);
uint256 preEarned = earned + sdIncentiveController.earned(user2) + sdIncentiveController.earned(user);
assertApproxEqAbs(preEarned, incentiveAmount, 1e9);

vm.roll(block.number + duration*10);
assertEq(earned + sdIncentiveController.earned(user2) + sdIncentiveController.earned(user), preEarned);
}
}

0 comments on commit f79c803

Please sign in to comment.