Skip to content

Commit 37f4549

Browse files
committed
feat: add createOperatorDirectedOperatorSetRewardsSubmission to SMB
1 parent 72515c3 commit 37f4549

File tree

5 files changed

+67
-14
lines changed

5 files changed

+67
-14
lines changed

src/ServiceManagerBase.sol

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initia
55
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol";
66
import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
77
import {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";
1010
import {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
}

test/integration/User.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ contract User is Test {
271271
params[0] = IDelegationManagerTypes.QueuedWithdrawalParams({
272272
strategies: strategies,
273273
depositShares: shares,
274-
withdrawer: address(this)
274+
__deprecated_withdrawer: address(this)
275275
});
276276

277277
delegationManager.queueWithdrawals(params);

test/mocks/DelegationMock.sol

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ contract DelegationIntermediate is IDelegationManager {
1818
uint256 initialPausedStatus
1919
) external virtual {}
2020

21+
function convertToDepositShares(
22+
address staker,
23+
IStrategy[] memory strategies,
24+
uint256[] memory withdrawableShares
25+
) external view returns (uint256[] memory) {}
26+
27+
2128
function registerAsOperator(
2229
OperatorDetails calldata registeringOperatorDetails,
2330
uint32 allocationDelay,
@@ -239,6 +246,25 @@ contract DelegationIntermediate is IDelegationManager {
239246
) external virtual {}
240247

241248
function minWithdrawalDelayBlocks() external view virtual override returns (uint32) {}
249+
250+
/// @notice Returns the Withdrawal associated with a `withdrawalRoot`, if it exists. NOTE that
251+
/// withdrawals queued before the slashing release can NOT be queried with this method.
252+
function getQueuedWithdrawal(
253+
bytes32 withdrawalRoot
254+
) external virtual override view returns (Withdrawal memory) {}
255+
256+
/// @notice Returns a list of queued withdrawal roots for the `staker`.
257+
/// NOTE that this only returns withdrawals queued AFTER the slashing release.
258+
function getQueuedWithdrawalRoots(
259+
address staker
260+
) external virtual override view returns (bytes32[] memory) {}
261+
262+
function slashOperatorShares(
263+
address operator,
264+
IStrategy strategy,
265+
uint64 prevMaxMagnitude,
266+
uint64 newMaxMagnitude
267+
) external virtual override {}
242268
}
243269

244270
contract DelegationMock is DelegationIntermediate {

test/mocks/EigenPodManagerMock.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ contract EigenPodManagerMock is Test, Pausable, IEigenPodManager {
1515
_setPausedStatus(0);
1616
}
1717

18+
function burnableETHShares() external view returns (uint256) {}
19+
20+
function increaseBurnableShares(IStrategy strategy, uint256 addedSharesToBurn) external {}
21+
1822
function podOwnerShares(address podOwner) external view returns (int256) {
1923
return podShares[podOwner];
2024
}

test/mocks/RewardsCoordinatorMock.sol

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ contract RewardsCoordinatorMock is IRewardsCoordinator {
3030

3131
function createOperatorDirectedAVSRewardsSubmission(
3232
address avs,
33-
OperatorDirectedRewardsSubmission[]
34-
calldata operatorDirectedRewardsSubmissions
33+
OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions
3534
) external override {}
3635

36+
function createOperatorDirectedOperatorSetRewardsSubmission(
37+
OperatorSet calldata operatorSet,
38+
OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions
39+
) external override {}
40+
41+
function getOperatorSetSplit(address operator, OperatorSet calldata operatorSet) external override view returns (uint16) {}
42+
43+
function setOperatorSetSplit(address operator, OperatorSet calldata operatorSet, uint16 split) external override {}
44+
3745
function processClaim(
3846
RewardsMerkleClaim calldata claim,
3947
address recipient

0 commit comments

Comments
 (0)