Skip to content

Commit 315bfb1

Browse files
committed
feat: updated IServiceManager
1 parent eb15225 commit 315bfb1

File tree

3 files changed

+93
-3
lines changed

3 files changed

+93
-3
lines changed

src/ServiceManagerBase.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
114114
}
115115

116116
/**
117-
* @notice Creates a new performance-based rewards submission, to be split amongst the operators and set of stakers delegated to operators who are registered to this `avs`.
117+
* @notice Creates a new performance-based rewards submission, to be split amongst the operators and
118+
* set of stakers delegated to operators who are registered to this `avs`.
118119
* @param performanceRewardsSubmissions The performance rewards submissions being created.
119120
* @dev Only callabe by the permissioned rewardsInitiator address
120121
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`

src/interfaces/IServiceManager.sol

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,37 @@ interface IServiceManager is IServiceManagerUI {
2020
* @dev This function will revert if the `rewardsSubmission` is malformed,
2121
* e.g. if the `strategies` and `weights` arrays are of non-equal lengths
2222
*/
23-
function createAVSRewardsSubmission(IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions) external;
23+
function createAVSRewardsSubmission(
24+
IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions
25+
) external;
26+
27+
/**
28+
* @notice Creates a new performance-based rewards submission on behalf of an AVS, to be split amongst the operators and
29+
* set of stakers delegated to operators who are registered to the `avs`.
30+
* @param performanceRewardsSubmissions The performance rewards submissions being created
31+
* @dev Only callabe by the permissioned rewardsInitiator address
32+
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`
33+
* @dev The tokens are sent to the `RewardsCoordinator` contract
34+
* @dev This contract needs a token approval of sum of all `operatorRewards` in the `performanceRewardsSubmissions`, before calling this function.
35+
* @dev Strategies must be in ascending order of addresses to check for duplicates
36+
* @dev Operators must be in ascending order of addresses to check for duplicates.
37+
* @dev This function will revert if the `performanceRewardsSubmissions` is malformed.
38+
*/
39+
function createAVSPerformanceRewardsSubmission(
40+
IRewardsCoordinator.PerformanceRewardsSubmission[]
41+
calldata performanceRewardsSubmissions
42+
) external;
43+
44+
/**
45+
* @notice Forwards a call to Eigenlayer's RewardsCoordinator contract to set the address of the entity that can call `processClaim` on behalf of this contract.
46+
* @param claimer The address of the entity that can call `processClaim` on behalf of the earner
47+
* @dev Only callabe by the permissioned rewardsInitiator address
48+
*/
49+
function setClaimerFor(address claimer) external;
2450

2551
// EVENTS
26-
event RewardsInitiatorUpdated(address prevRewardsInitiator, address newRewardsInitiator);
52+
event RewardsInitiatorUpdated(
53+
address prevRewardsInitiator,
54+
address newRewardsInitiator
55+
);
2756
}

src/unaudited/ECDSAServiceManagerBase.sol

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ abstract contract ECDSAServiceManagerBase is
106106
_createAVSRewardsSubmission(rewardsSubmissions);
107107
}
108108

109+
/// @inheritdoc IServiceManager
110+
function createAVSPerformanceRewardsSubmission(
111+
IRewardsCoordinator.PerformanceRewardsSubmission[]
112+
calldata performanceRewardsSubmissions
113+
) external virtual onlyRewardsInitiator {
114+
_createAVSPerformanceRewardsSubmission(performanceRewardsSubmissions);
115+
}
116+
117+
/// @inheritdoc IServiceManager
118+
function setClaimerFor(
119+
address claimer
120+
) public virtual onlyRewardsInitiator {
121+
IRewardsCoordinator(rewardsCoordinator).setClaimerFor(claimer);
122+
}
123+
109124
/// @inheritdoc IServiceManagerUI
110125
function registerOperatorToAVS(
111126
address operator,
@@ -203,6 +218,51 @@ abstract contract ECDSAServiceManagerBase is
203218
);
204219
}
205220

221+
/**
222+
* @notice Creates a new performance-based rewards submission, to be split amongst the operators and
223+
* set of stakers delegated to operators who are registered to this `avs`.
224+
* @param performanceRewardsSubmissions The performance rewards submissions being created.
225+
*/
226+
function _createAVSPerformanceRewardsSubmission(
227+
IRewardsCoordinator.PerformanceRewardsSubmission[]
228+
calldata performanceRewardsSubmissions
229+
) internal virtual {
230+
for (uint256 i = 0; i < performanceRewardsSubmissions.length; ++i) {
231+
// Calculate total amount of token to transfer
232+
uint256 totalAmount = 0;
233+
for (
234+
uint256 j = 0;
235+
j < performanceRewardsSubmissions[i].operatorRewards.length;
236+
++j
237+
) {
238+
totalAmount += performanceRewardsSubmissions[i]
239+
.operatorRewards[j]
240+
.amount;
241+
}
242+
243+
// Transfer token to ServiceManager and approve RewardsCoordinator to transfer again
244+
// in createAVSPerformanceRewardsSubmission() call
245+
performanceRewardsSubmissions[i].token.transferFrom(
246+
msg.sender,
247+
address(this),
248+
totalAmount
249+
);
250+
uint256 allowance = performanceRewardsSubmissions[i]
251+
.token
252+
.allowance(address(this), rewardsCoordinator);
253+
performanceRewardsSubmissions[i].token.approve(
254+
rewardsCoordinator,
255+
totalAmount + allowance
256+
);
257+
}
258+
259+
IRewardsCoordinator(rewardsCoordinator)
260+
.createAVSPerformanceRewardsSubmission(
261+
address(this),
262+
performanceRewardsSubmissions
263+
);
264+
}
265+
206266
/**
207267
* @notice Retrieves the addresses of all strategies that are part of the current quorum.
208268
* @dev Fetches the quorum configuration from the ECDSAStakeRegistry and extracts the strategy addresses.

0 commit comments

Comments
 (0)