Skip to content

Commit 16e832a

Browse files
0xClandestine0xrajath
authored andcommitted
feat: rewards v2.1 (#1011)
* feat: rewards v2.1 feat: operator centric rewards feat: add new interfaces feat(wip): implement `createOperatorSetPerformanceRewardsSubmission` chore: forge fmt fix: compile feat(wip): implement `setOperatorSetOperatorSplit` fix: review changes fix: add missing `onlyWhenPaused` + `checkCanCall` feat(wip): add missing `getOperatorSetPerformanceSplit` + rename internals test(wip): `setOperatorSetPerformanceSplit` test(wip): `createOperatorSetPerformanceRewardsSubmission` - some failing chore: forge fmt refactor: renaming chore: storage report refactor: review changes refactor: review changes fix: gap refactor: review changes * fix: storage layout * chore: make storage-report * docs: natspec * refactor: review changes * refactor: review changes * refactor: review changes * feat: rewards v2.1 bindings * fix: not index operatorSet in events * refactor: forge fmt * docs: updated storage reports * chore: updated bindings --------- Co-authored-by: 0xrajath <[email protected]>
1 parent 1dce4ed commit 16e832a

File tree

10 files changed

+2653
-87
lines changed

10 files changed

+2653
-87
lines changed

docs/storage-report/RewardsCoordinator.md

Lines changed: 63 additions & 29 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
1-
| Name | Type | Slot | Offset | Bytes | Contract |
2-
|--------------------------------------------|---------------------------------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------|
3-
| __deprecated_DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
4-
| _distributionRoots | struct IRewardsCoordinatorTypes.DistributionRoot[] | 1 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
5-
| rewardsUpdater | address | 2 | 0 | 20 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
6-
| activationDelay | uint32 | 2 | 20 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
7-
| currRewardsCalculationEndTimestamp | uint32 | 2 | 24 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
8-
| defaultOperatorSplitBips | uint16 | 2 | 28 | 2 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
9-
| claimerFor | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
10-
| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 4 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
11-
| submissionNonce | mapping(address => uint256) | 5 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
12-
| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 6 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
13-
| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 7 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
14-
| isRewardsForAllSubmitter | mapping(address => bool) | 8 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
15-
| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 9 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
16-
| isOperatorDirectedAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 10 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
17-
| operatorAVSSplitBips | mapping(address => mapping(address => struct IRewardsCoordinatorTypes.OperatorSplit)) | 11 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
18-
| operatorPISplitBips | mapping(address => struct IRewardsCoordinatorTypes.OperatorSplit) | 12 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
19-
| __gap | uint256[37] | 13 | 0 | 1184 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
1+
2+
╭----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------╮
3+
| Name | Type | Slot | Offset | Bytes | Contract |
4+
+=================================================================================================================================================================================================================================================+
5+
| __deprecated_DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
6+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
7+
| _distributionRoots | struct IRewardsCoordinatorTypes.DistributionRoot[] | 1 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
8+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
9+
| rewardsUpdater | address | 2 | 0 | 20 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
10+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
11+
| activationDelay | uint32 | 2 | 20 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
12+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
13+
| currRewardsCalculationEndTimestamp | uint32 | 2 | 24 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
14+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
15+
| defaultOperatorSplitBips | uint16 | 2 | 28 | 2 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
16+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
17+
| claimerFor | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
18+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
19+
| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 4 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
20+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
21+
| submissionNonce | mapping(address => uint256) | 5 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
22+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
23+
| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 6 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
24+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
25+
| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 7 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
26+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
27+
| isRewardsForAllSubmitter | mapping(address => bool) | 8 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
28+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
29+
| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 9 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
30+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
31+
| isOperatorDirectedAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 10 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
32+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
33+
| _operatorAVSSplitBips | mapping(address => mapping(address => struct IRewardsCoordinatorTypes.OperatorSplit)) | 11 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
34+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
35+
| _operatorPISplitBips | mapping(address => struct IRewardsCoordinatorTypes.OperatorSplit) | 12 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
36+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
37+
| _operatorSetSplitBips | mapping(address => mapping(bytes32 => struct IRewardsCoordinatorTypes.OperatorSplit)) | 13 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
38+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
39+
| isOperatorDirectedOperatorSetRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 14 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
40+
|----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------|
41+
| __gap | uint256[35] | 15 | 0 | 1120 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
42+
╰----------------------------------------------------+---------------------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------------╯
43+

pkg/bindings/IRewardsCoordinator/binding.go

Lines changed: 393 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/RewardsCoordinator/binding.go

Lines changed: 434 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/RewardsCoordinatorStorage/binding.go

Lines changed: 433 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/contracts/core/RewardsCoordinator.sol

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ contract RewardsCoordinator is
2929
PermissionControllerMixin
3030
{
3131
using SafeERC20 for IERC20;
32+
using OperatorSetLib for OperatorSet;
3233

3334
modifier onlyRewardsUpdater() {
3435
require(msg.sender == rewardsUpdater, UnauthorizedCaller());
@@ -177,6 +178,37 @@ contract RewardsCoordinator is
177178
}
178179
}
179180

181+
/// @inheritdoc IRewardsCoordinator
182+
function createOperatorDirectedOperatorSetRewardsSubmission(
183+
OperatorSet calldata operatorSet,
184+
OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions
185+
)
186+
external
187+
onlyWhenNotPaused(PAUSED_OPERATOR_DIRECTED_OPERATOR_SET_REWARDS_SUBMISSION)
188+
checkCanCall(operatorSet.avs)
189+
nonReentrant
190+
{
191+
require(allocationManager.isOperatorSet(operatorSet), InvalidOperatorSet());
192+
for (uint256 i = 0; i < operatorDirectedRewardsSubmissions.length; i++) {
193+
OperatorDirectedRewardsSubmission calldata operatorDirectedRewardsSubmission =
194+
operatorDirectedRewardsSubmissions[i];
195+
uint256 nonce = submissionNonce[operatorSet.avs];
196+
bytes32 operatorDirectedRewardsSubmissionHash =
197+
keccak256(abi.encode(operatorSet.avs, nonce, operatorDirectedRewardsSubmission));
198+
199+
uint256 totalAmount = _validateOperatorDirectedRewardsSubmission(operatorDirectedRewardsSubmission);
200+
201+
isOperatorDirectedOperatorSetRewardsSubmissionHash[operatorSet.avs][operatorDirectedRewardsSubmissionHash] =
202+
true;
203+
submissionNonce[operatorSet.avs] = nonce + 1;
204+
205+
emit OperatorDirectedOperatorSetRewardsSubmissionCreated(
206+
msg.sender, operatorDirectedRewardsSubmissionHash, operatorSet, nonce, operatorDirectedRewardsSubmission
207+
);
208+
operatorDirectedRewardsSubmission.token.safeTransferFrom(msg.sender, address(this), totalAmount);
209+
}
210+
}
211+
180212
/// @inheritdoc IRewardsCoordinator
181213
function processClaim(
182214
RewardsMerkleClaim calldata claim,
@@ -268,8 +300,8 @@ contract RewardsCoordinator is
268300
uint16 split
269301
) external onlyWhenNotPaused(PAUSED_OPERATOR_AVS_SPLIT) checkCanCall(operator) {
270302
uint32 activatedAt = uint32(block.timestamp) + activationDelay;
271-
uint16 oldSplit = _getOperatorSplit(operatorAVSSplitBips[operator][avs]);
272-
_setOperatorSplit(operatorAVSSplitBips[operator][avs], split, activatedAt);
303+
uint16 oldSplit = _getOperatorSplit(_operatorAVSSplitBips[operator][avs]);
304+
_setOperatorSplit(_operatorAVSSplitBips[operator][avs], split, activatedAt);
273305

274306
emit OperatorAVSSplitBipsSet(msg.sender, operator, avs, activatedAt, oldSplit, split);
275307
}
@@ -280,12 +312,27 @@ contract RewardsCoordinator is
280312
uint16 split
281313
) external onlyWhenNotPaused(PAUSED_OPERATOR_PI_SPLIT) checkCanCall(operator) {
282314
uint32 activatedAt = uint32(block.timestamp) + activationDelay;
283-
uint16 oldSplit = _getOperatorSplit(operatorPISplitBips[operator]);
284-
_setOperatorSplit(operatorPISplitBips[operator], split, activatedAt);
315+
uint16 oldSplit = _getOperatorSplit(_operatorPISplitBips[operator]);
316+
_setOperatorSplit(_operatorPISplitBips[operator], split, activatedAt);
285317

286318
emit OperatorPISplitBipsSet(msg.sender, operator, activatedAt, oldSplit, split);
287319
}
288320

321+
/// @inheritdoc IRewardsCoordinator
322+
function setOperatorSetSplit(
323+
address operator,
324+
OperatorSet calldata operatorSet,
325+
uint16 split
326+
) external onlyWhenNotPaused(PAUSED_OPERATOR_SET_SPLIT) checkCanCall(operator) {
327+
require(allocationManager.isOperatorSet(operatorSet), InvalidOperatorSet());
328+
329+
uint32 activatedAt = uint32(block.timestamp) + activationDelay;
330+
uint16 oldSplit = _getOperatorSplit(_operatorSetSplitBips[operator][operatorSet.key()]);
331+
_setOperatorSplit(_operatorSetSplitBips[operator][operatorSet.key()], split, activatedAt);
332+
333+
emit OperatorSetSplitBipsSet(msg.sender, operator, operatorSet, activatedAt, oldSplit, split);
334+
}
335+
289336
/// @inheritdoc IRewardsCoordinator
290337
function setRewardsUpdater(
291338
address _rewardsUpdater
@@ -602,14 +649,19 @@ contract RewardsCoordinator is
602649

603650
/// @inheritdoc IRewardsCoordinator
604651
function getOperatorAVSSplit(address operator, address avs) external view returns (uint16) {
605-
return _getOperatorSplit(operatorAVSSplitBips[operator][avs]);
652+
return _getOperatorSplit(_operatorAVSSplitBips[operator][avs]);
606653
}
607654

608655
/// @inheritdoc IRewardsCoordinator
609656
function getOperatorPISplit(
610657
address operator
611658
) external view returns (uint16) {
612-
return _getOperatorSplit(operatorPISplitBips[operator]);
659+
return _getOperatorSplit(_operatorPISplitBips[operator]);
660+
}
661+
662+
/// @inheritdoc IRewardsCoordinator
663+
function getOperatorSetSplit(address operator, OperatorSet calldata operatorSet) external view returns (uint16) {
664+
return _getOperatorSplit(_operatorSetSplitBips[operator][operatorSet.key()]);
613665
}
614666

615667
/// @inheritdoc IRewardsCoordinator

0 commit comments

Comments
 (0)