@@ -5,7 +5,7 @@ import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initia
55import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol " ;
66import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol " ;
77import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol " ;
8- import {IRewardsCoordinator} from
8+ import {IRewardsCoordinator, IERC20 , OperatorSet } from
99 "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol " ;
1010import {IAllocationManager, IAllocationManagerTypes} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol " ;
1111
@@ -97,6 +97,10 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
9797 _allocationManager.slashOperator (address (this ), params);
9898 }
9999
100+ function _increaseAllowance (IERC20 token , address spender , uint256 amount ) internal {
101+ token.approve (spender, amount + token.allowance (address (this ), spender));
102+ }
103+
100104 /**
101105 * @notice Creates a new rewards submission to the EigenLayer RewardsCoordinator contract, to be split amongst the
102106 * set of stakers delegated to operators who are registered to this `avs`
@@ -112,21 +116,32 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
112116 IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions
113117 ) public virtual onlyRewardsInitiator {
114118 for (uint256 i = 0 ; i < rewardsSubmissions.length ; ++ i) {
115- // transfer token to ServiceManager and approve RewardsCoordinator to transfer again
116- // in createAVSRewardsSubmission() call
117- rewardsSubmissions[i].token.transferFrom (
118- msg .sender , address (this ), rewardsSubmissions[i].amount
119- );
120- uint256 allowance =
121- rewardsSubmissions[i].token.allowance (address (this ), address (_rewardsCoordinator));
122- rewardsSubmissions[i].token.approve (
123- address (_rewardsCoordinator), rewardsSubmissions[i].amount + allowance
124- );
119+ IRewardsCoordinator.RewardsSubmission calldata submission = rewardsSubmissions[i];
120+
121+ submission.token.transferFrom (msg .sender , address (this ), submission.amount);
122+
123+ _increaseAllowance (submission.token, address (_rewardsCoordinator), submission.amount);
125124 }
126125
127126 _rewardsCoordinator.createAVSRewardsSubmission (rewardsSubmissions);
128127 }
129128
129+ function createOperatorDirectedOperatorSetRewardsSubmission (
130+ OperatorSet memory operatorSet ,
131+ IRewardsCoordinator.OperatorDirectedRewardsSubmission[] calldata rewardsSubmissions ,
132+ uint256 [] memory totalAmounts
133+ ) public virtual onlyRewardsInitiator {
134+ for (uint256 i = 0 ; i < rewardsSubmissions.length ; ++ i) {
135+ IRewardsCoordinator.OperatorDirectedRewardsSubmission calldata submission = rewardsSubmissions[i];
136+
137+ submission.token.transferFrom (msg .sender , address (this ), totalAmounts[i]);
138+
139+ _increaseAllowance (submission.token, address (_rewardsCoordinator), totalAmounts[i]);
140+ }
141+
142+ _rewardsCoordinator.createOperatorDirectedOperatorSetRewardsSubmission (operatorSet, rewardsSubmissions);
143+ }
144+
130145 function createOperatorSets (IAllocationManager.CreateSetParams[] memory params ) external onlyRegistryCoordinator {
131146 _allocationManager.createOperatorSets (address (this ), params);
132147 }
0 commit comments