@@ -16,6 +16,7 @@ import { ISDUtilityPool, UserData, OperatorLiquidation } from "./interfaces/ISDU
1616import { ISDCollateral } from "./interfaces/SDCollateral/ISDCollateral.sol " ;
1717import { IWETH } from "./interfaces/IWETH.sol " ;
1818import { IStaderOracle } from "../contracts/interfaces/IStaderOracle.sol " ;
19+ import { IPoolUtils } from "../contracts/interfaces/IPoolUtils.sol " ;
1920
2021contract OperatorRewardsCollector is IOperatorRewardsCollector , AccessControlUpgradeable {
2122 IStaderConfig public staderConfig;
@@ -52,10 +53,18 @@ contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpg
5253 * @dev This function first checks for any unpaid liquidations for the operator and repays them if necessary. Then, it transfers any remaining balance to the operator's reward address.
5354 */
5455 function claim () external {
55- claimLiquidation (msg .sender );
56- uint256 amount = balances[msg .sender ] > withdrawableInEth (msg .sender )
57- ? withdrawableInEth (msg .sender )
58- : balances[msg .sender ];
56+ IPoolUtils poolUtils = IPoolUtils (staderConfig.getPoolUtils ());
57+ uint8 poolId = poolUtils.getOperatorPoolId (msg .sender );
58+ address permissionlessNodeRegistry = staderConfig.getPermissionlessNodeRegistry ();
59+ uint256 amount;
60+ if (INodeRegistry (permissionlessNodeRegistry).POOL_ID () == poolId) {
61+ claimLiquidation (msg .sender );
62+ amount = balances[msg .sender ] > withdrawableInEth (msg .sender )
63+ ? withdrawableInEth (msg .sender )
64+ : balances[msg .sender ];
65+ } else {
66+ amount = balances[msg .sender ];
67+ }
5968 _claim (msg .sender , amount);
6069 }
6170
@@ -66,7 +75,17 @@ contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpg
6675 * @param _amount amount of ETH to claim
6776 */
6877 function claimWithAmount (uint256 _amount ) external {
69- claimLiquidation (msg .sender );
78+ IPoolUtils poolUtils = IPoolUtils (staderConfig.getPoolUtils ());
79+ uint8 poolId = poolUtils.getOperatorPoolId (msg .sender );
80+ address permissionlessNodeRegistry = staderConfig.getPermissionlessNodeRegistry ();
81+
82+ if (INodeRegistry (permissionlessNodeRegistry).POOL_ID () == poolId) {
83+ claimLiquidation (msg .sender );
84+ uint256 maxWithdrawableInEth = withdrawableInEth (msg .sender );
85+ if (_amount > maxWithdrawableInEth || _amount > balances[msg .sender ]) revert InsufficientBalance ();
86+ } else {
87+ if (_amount > balances[msg .sender ]) revert InsufficientBalance ();
88+ }
7089 _claim (msg .sender , _amount);
7190 }
7291
@@ -181,9 +200,6 @@ contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpg
181200 * @param amount The amount to be claimed.
182201 */
183202 function _claim (address operator , uint256 amount ) internal {
184- uint256 maxWithdrawableInEth = withdrawableInEth (operator);
185- if (amount > maxWithdrawableInEth || amount > balances[operator]) revert InsufficientBalance ();
186-
187203 balances[operator] -= amount;
188204
189205 // If there's an amount to send, transfer it to the operator's rewards address
0 commit comments