From c6bfcc8a1b1365a5cdfa0113dbfe13408aec62b6 Mon Sep 17 00:00:00 2001 From: arigatodl <99845398+dulguun-staderlabs@users.noreply.github.com> Date: Sat, 9 Dec 2023 19:00:56 +0800 Subject: [PATCH] Claim rewards during requestWithdraw --- contracts/SDIncentiveController.sol | 5 +---- contracts/SDUtilityPool.sol | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/contracts/SDIncentiveController.sol b/contracts/SDIncentiveController.sol index 06df67ff..02822864 100644 --- a/contracts/SDIncentiveController.sol +++ b/contracts/SDIncentiveController.sol @@ -61,11 +61,8 @@ contract SDIncentiveController is ISDIncentiveController, AccessControlUpgradeab updateReward(account); uint256 reward = rewards[account]; - if (reward == 0) { - revert NoRewardsToClaim(); - } rewards[account] = 0; - IERC20(staderConfig.getStaderToken()).transfer(account, reward); + if (reward > 0) IERC20(staderConfig.getStaderToken()).transfer(account, reward); emit RewardClaimed(account, reward); } diff --git a/contracts/SDUtilityPool.sol b/contracts/SDUtilityPool.sol index 37baeb61..73a3d199 100644 --- a/contracts/SDUtilityPool.sol +++ b/contracts/SDUtilityPool.sol @@ -770,6 +770,7 @@ contract SDUtilityPool is ISDUtilityPool, AccessControlUpgradeable, PausableUpgr if (requestIdsByDelegatorAddress[msg.sender].length + 1 > maxNonRedeemedDelegatorRequestCount) { revert MaxLimitOnWithdrawRequestCountReached(); } + ISDIncentiveController(staderConfig.getSDIncentiveController()).claim(msg.sender); sdRequestedForWithdraw += _sdAmountToWithdraw; delegatorWithdrawRequests[nextRequestId] = DelegatorWithdrawInfo( msg.sender,