diff --git a/.gitignore b/.gitignore index cb82d385c..3213174f1 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,7 @@ InheritanceGraph.png surya_report.md .idea + +*state.json +deployed_strategies.json +populate_src* \ No newline at end of file diff --git a/.solhintignore b/.solhintignore index 497fd271c..e69de29bb 100644 --- a/.solhintignore +++ b/.solhintignore @@ -1 +0,0 @@ -Slasher.sol \ No newline at end of file diff --git a/certora/harnesses/SlasherHarness.sol b/certora/harnesses/SlasherHarness.sol deleted file mode 100644 index eab81659c..000000000 --- a/certora/harnesses/SlasherHarness.sol +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.27; - -import "../../src/contracts/core/Slasher.sol"; - -contract SlasherHarness is Slasher { - - constructor(IStrategyManager _strategyManager, IDelegationManager _delegation) Slasher(_strategyManager, _delegation) {} - - /// Harnessed functions - function get_is_operator(address staker) public returns (bool) { - return delegation.isOperator(staker); - } - - function get_is_delegated(address staker) public returns (bool) { - return delegation.isDelegated(staker); - } - - - // Linked List Functions - function get_list_exists(address operator) public returns (bool) { - return StructuredLinkedList.listExists(_operatorToWhitelistedContractsByUpdate[operator]); - } - - function get_next_node_exists(address operator, uint256 node) public returns (bool) { - (bool res, ) = StructuredLinkedList.getNextNode(_operatorToWhitelistedContractsByUpdate[operator], node); - return res; - } - - function get_next_node(address operator, uint256 node) public returns (uint256) { - (, uint256 res) = StructuredLinkedList.getNextNode(_operatorToWhitelistedContractsByUpdate[operator], node); - return res; - } - - function get_previous_node_exists(address operator, uint256 node) public returns (bool) { - (bool res, ) = StructuredLinkedList.getPreviousNode(_operatorToWhitelistedContractsByUpdate[operator], node); - return res; - } - - function get_previous_node(address operator, uint256 node) public returns (uint256) { - (, uint256 res) = StructuredLinkedList.getPreviousNode(_operatorToWhitelistedContractsByUpdate[operator], node); - return res; - } - - function get_list_head(address operator) public returns (uint256) { - return StructuredLinkedList.getHead(_operatorToWhitelistedContractsByUpdate[operator]); - } - - function get_lastest_update_block_at_node(address operator, uint256 node) public returns (uint256) { - return _whitelistedContractDetails[operator][_uintToAddress(node)].latestUpdateBlock; - } - - function get_lastest_update_block_at_head(address operator) public returns (uint256) { - return get_lastest_update_block_at_node(operator, get_list_head(operator)); - } - - function get_linked_list_entry(address operator, uint256 node, bool direction) public returns (uint256) { - return (_operatorToWhitelistedContractsByUpdate[operator].list[node][direction]); - } - - // // uses that _HEAD = 0. Similar to StructuredLinkedList.nodeExists but slightly better defined - // function nodeDoesExist(address operator, uint256 node) public returns (bool) { - // if (get_next_node(operator, node) == 0 && get_previous_node(operator, node) == 0) { - // // slightly stricter check than that defined in StructuredLinkedList.nodeExists - // if (get_next_node(operator, 0) == node && get_previous_node(operator, 0) == node) { - // return true; - // } else { - // return false; - // } - // } else { - // return true; - // } - // } - - // // uses that _PREV = false, _NEXT = true - // function nodeIsWellLinked(address operator, uint256 node) public returns (bool) { - // return ( - // // node is not linked to itself - // get_previous_node(operator, node) != node && get_next_node(operator, node) != node - // && - // // node is the previous node's next node and the next node's previous node - // get_linked_list_entry(operator, get_previous_node(operator, node), true) == node && get_linked_list_entry(operator, get_next_node(operator, node), false) == node - // ); - // } -} diff --git a/certora/scripts/core/verifyDelegationManager.sh b/certora/scripts/core/verifyDelegationManager.sh index dfec2c904..d58112103 100644 --- a/certora/scripts/core/verifyDelegationManager.sh +++ b/certora/scripts/core/verifyDelegationManager.sh @@ -8,7 +8,7 @@ solc-select use 0.8.27 certoraRun certora/harnesses/DelegationManagerHarness.sol \ lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol lib/openzeppelin-contracts/contracts/mocks/ERC1271WalletMock.sol \ src/contracts/pods/EigenPodManager.sol src/contracts/pods/EigenPod.sol src/contracts/strategies/StrategyBase.sol src/contracts/core/StrategyManager.sol \ - src/contracts/core/Slasher.sol src/contracts/permissions/PauserRegistry.sol \ + src/contracts/permissions/PauserRegistry.sol \ --verify DelegationManagerHarness:certora/specs/core/DelegationManager.spec \ --solc_via_ir \ --solc_optimize 1 \ diff --git a/certora/scripts/core/verifyStrategyManager.sh b/certora/scripts/core/verifyStrategyManager.sh index 5695ab785..1e404ea4c 100644 --- a/certora/scripts/core/verifyStrategyManager.sh +++ b/certora/scripts/core/verifyStrategyManager.sh @@ -9,7 +9,7 @@ certoraRun certora/harnesses/StrategyManagerHarness.sol \ lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol lib/openzeppelin-contracts/contracts/mocks/ERC1271WalletMock.sol \ src/contracts/pods/EigenPodManager.sol src/contracts/pods/EigenPod.sol \ src/contracts/strategies/StrategyBase.sol src/contracts/core/DelegationManager.sol \ - src/contracts/core/Slasher.sol src/contracts/permissions/PauserRegistry.sol \ + src/contracts/permissions/PauserRegistry.sol \ --verify StrategyManagerHarness:certora/specs/core/StrategyManager.spec \ --solc_via_ir \ --solc_optimize 1 \ diff --git a/certora/scripts/pods/verifyEigenPod.sh b/certora/scripts/pods/verifyEigenPod.sh index e4d7fedb8..812d26bf2 100644 --- a/certora/scripts/pods/verifyEigenPod.sh +++ b/certora/scripts/pods/verifyEigenPod.sh @@ -7,7 +7,7 @@ fi # certoraRun certora/harnesses/EigenPodHarness.sol \ # src/contracts/core/DelegationManager.sol src/contracts/pods/EigenPodManager.sol \ -# src/contracts/core/Slasher.sol src/contracts/permissions/PauserRegistry.sol \ +# src/contracts/permissions/PauserRegistry.sol \ # src/contracts/core/StrategyManager.sol \ # src/contracts/strategies/StrategyBase.sol \ # lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol \ diff --git a/certora/scripts/pods/verifyEigenPodManager.sh b/certora/scripts/pods/verifyEigenPodManager.sh index 9b4a62106..6d0b90e4c 100644 --- a/certora/scripts/pods/verifyEigenPodManager.sh +++ b/certora/scripts/pods/verifyEigenPodManager.sh @@ -7,7 +7,7 @@ fi # certoraRun certora/harnesses/EigenPodManagerHarness.sol \ # src/contracts/core/DelegationManager.sol src/contracts/pods/EigenPod.sol src/contracts/strategies/StrategyBase.sol src/contracts/core/StrategyManager.sol \ -# src/contracts/core/Slasher.sol src/contracts/permissions/PauserRegistry.sol \ +# src/contracts/permissions/PauserRegistry.sol \ # --verify EigenPodManagerHarness:certora/specs/pods/EigenPodManager.spec \ # --optimistic_loop \ # --optimistic_fallback \ diff --git a/certora/scripts/strategies/verifyStrategyBase.sh b/certora/scripts/strategies/verifyStrategyBase.sh index 58514d0dc..8d966e540 100644 --- a/certora/scripts/strategies/verifyStrategyBase.sh +++ b/certora/scripts/strategies/verifyStrategyBase.sh @@ -9,7 +9,6 @@ certoraRun src/contracts/strategies/StrategyBase.sol \ lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol \ src/contracts/core/StrategyManager.sol \ src/contracts/permissions/PauserRegistry.sol \ - src/contracts/core/Slasher.sol \ --verify StrategyBase:certora/specs/strategies/StrategyBase.spec \ --solc_via_ir \ --solc_optimize 1 \ diff --git a/docs/README.md b/docs/README.md index 4e6597b73..41c99908e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -20,7 +20,7 @@ This document provides an overview of system components, contracts, and user rol * [Depositing Into EigenLayer](#depositing-into-eigenlayer) * [Delegating to an Operator](#delegating-to-an-operator) * [Undelegating or Queueing a Withdrawal](#undelegating-or-queueing-a-withdrawal) - * [Completing a Withdrawal as Shares](#completing-a-withdrawal-as-shares) + * [Completing a Withdrawal as OwnedShares](#completing-a-withdrawal-as-shares) * [Completing a Withdrawal as Tokens](#completing-a-withdrawal-as-tokens) * [Withdrawal Processing: Validator Exits](#withdrawal-processing-validator-exits) * [Withdrawal Processing: Partial Beacon Chain Withdrawals](#withdrawal-processing-partial-beacon-chain-withdrawals) @@ -156,7 +156,7 @@ Undelegating from an Operator automatically queues a withdrawal that needs to go ![.](./images/Staker%20Flow%20Diagrams/Queue%20Withdrawal.png) -##### Completing a Withdrawal as Shares +##### Completing a Withdrawal as OwnedShares This flow is mostly useful if a Staker wants to change which Operator they are delegated to. The Staker first needs to undelegate (see above). At this point, they can delegate to a different Operator. However, the new Operator will only be awarded shares once the Staker completes their queued withdrawal "as shares": diff --git a/docs/core/DelegationManager.md b/docs/core/DelegationManager.md index 8569deae4..3bcf64a96 100644 --- a/docs/core/DelegationManager.md +++ b/docs/core/DelegationManager.md @@ -275,9 +275,9 @@ For each strategy/share pair in the `Withdrawal`: `Withdrawals` concerning `EigenPodManager` shares have some additional nuance depending on whether a withdrawal is specified to be received as tokens vs shares (read more about "why" in [`EigenPodManager.md`](./EigenPodManager.md)): * `EigenPodManager` withdrawals received as shares: - * Shares ALWAYS go back to the originator of the withdrawal (rather than the `withdrawer` address). - * Shares are also delegated to the originator's Operator, rather than the `withdrawer's` Operator. - * Shares received by the originator may be lower than the shares originally withdrawn if the originator has debt. + * OwnedShares ALWAYS go back to the originator of the withdrawal (rather than the `withdrawer` address). + * OwnedShares are also delegated to the originator's Operator, rather than the `withdrawer's` Operator. + * OwnedShares received by the originator may be lower than the shares originally withdrawn if the originator has debt. * `EigenPodManager` withdrawals received as tokens: * Before the withdrawal can be completed, the originator needs to prove that a withdrawal occurred on the beacon chain (see [`EigenPod.verifyAndProcessWithdrawals`](./EigenPodManager.md#eigenpodverifyandprocesswithdrawals)). @@ -288,10 +288,10 @@ For each strategy/share pair in the `Withdrawal`: * See [`EigenPodManager.withdrawSharesAsTokens`](./EigenPodManager.md#eigenpodmanagerwithdrawsharesastokens) * If `!receiveAsTokens`: * For `StrategyManager` strategies: - * Shares are awarded to the `withdrawer` and delegated to the `withdrawer's` Operator + * OwnedShares are awarded to the `withdrawer` and delegated to the `withdrawer's` Operator * See [`StrategyManager.addShares`](./StrategyManager.md#addshares) * For the native beacon chain ETH strategy (`EigenPodManager`): - * Shares are awarded to `withdrawal.staker`, and delegated to the Staker's Operator + * OwnedShares are awarded to `withdrawal.staker`, and delegated to the Staker's Operator * See [`EigenPodManager.addShares`](./EigenPodManager.md#eigenpodmanageraddshares) *Requirements*: diff --git a/docs/core/EigenPod.md b/docs/core/EigenPod.md index b33e5d5da..4c80c7fe3 100644 --- a/docs/core/EigenPod.md +++ b/docs/core/EigenPod.md @@ -150,7 +150,7 @@ Checkpoint proofs comprise the bulk of proofs submitted to an `EigenPod`. Comple * when the pod has accumulated fees / partial withdrawals from validators * whether any validators on the beacon chain have increased/decreased in balance -When a checkpoint is completed, shares are updated accordingly for each of these events. Shares can be withdrawn via the `DelegationManager` withdrawal queue (see [DelegationManager: Undelegating and Withdrawing](./DelegationManager.md#undelegating-and-withdrawing)), which means an `EigenPod's` checkpoint proofs also play an important role in allowing Pod Owners to exit funds from the system. +When a checkpoint is completed, shares are updated accordingly for each of these events. OwnedShares can be withdrawn via the `DelegationManager` withdrawal queue (see [DelegationManager: Undelegating and Withdrawing](./DelegationManager.md#undelegating-and-withdrawing)), which means an `EigenPod's` checkpoint proofs also play an important role in allowing Pod Owners to exit funds from the system. _Important Notes:_ * `EigenPods` can only have **one active checkpoint** at a given time, and once started, checkpoints **cannot be cancelled** (only completed) diff --git a/docs/storage-report/AVSDirectory.md b/docs/storage-report/AVSDirectory.md index cf36169ac..2abae63dd 100644 --- a/docs/storage-report/AVSDirectory.md +++ b/docs/storage-report/AVSDirectory.md @@ -1,16 +1,21 @@ -| Name | Type | Slot | Offset | Bytes | Contract | -|---------------------|------------------------------------------------------------------------------------------|------|--------|-------|--------------------------------------------------| -| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| _initializing | bool | 0 | 1 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| _owner | address | 51 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| _DOMAIN_SEPARATOR | bytes32 | 151 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectory.OperatorAVSRegistrationStatus)) | 152 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 153 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| __gap | uint256[47] | 154 | 0 | 1504 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| _status | uint256 | 201 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | -| __gap | uint256[49] | 202 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------|---------------------------------------------------------------------------------------------------------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| _initializing | bool | 0 | 1 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| _owner | address | 51 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| _DOMAIN_SEPARATOR | bytes32 | 151 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectory.OperatorAVSRegistrationStatus)) | 152 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 153 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| isOperatorSetAVS | mapping(address => bool) | 154 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| isOperatorSet | mapping(address => mapping(uint32 => bool)) | 155 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| _operatorSetsMemberOf | mapping(address => struct EnumerableSet.Bytes32Set) | 156 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| _operatorSetMembers | mapping(bytes32 => struct EnumerableSet.AddressSet) | 157 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| operatorSetStatus | mapping(address => mapping(address => mapping(uint32 => struct IAVSDirectory.OperatorSetRegistrationStatus))) | 158 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| __gap | uint256[42] | 159 | 0 | 1344 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| _status | uint256 | 201 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory | +| __gap | uint256[49] | 202 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory | diff --git a/docs/storage-report/AVSDirectoryStorage.md b/docs/storage-report/AVSDirectoryStorage.md index a337342d0..a35572ea5 100644 --- a/docs/storage-report/AVSDirectoryStorage.md +++ b/docs/storage-report/AVSDirectoryStorage.md @@ -1,6 +1,11 @@ -| Name | Type | Slot | Offset | Bytes | Contract | -|---------------------|------------------------------------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------| -| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | -| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectory.OperatorAVSRegistrationStatus)) | 1 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | -| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 2 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | -| __gap | uint256[47] | 3 | 0 | 1504 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------|---------------------------------------------------------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------| +| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectory.OperatorAVSRegistrationStatus)) | 1 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 2 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| isOperatorSetAVS | mapping(address => bool) | 3 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| isOperatorSet | mapping(address => mapping(uint32 => bool)) | 4 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| _operatorSetsMemberOf | mapping(address => struct EnumerableSet.Bytes32Set) | 5 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| _operatorSetMembers | mapping(bytes32 => struct EnumerableSet.AddressSet) | 6 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| operatorSetStatus | mapping(address => mapping(address => mapping(uint32 => struct IAVSDirectory.OperatorSetRegistrationStatus))) | 7 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | +| __gap | uint256[42] | 8 | 0 | 1344 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage | diff --git a/docs/storage-report/AllocationManager.md b/docs/storage-report/AllocationManager.md new file mode 100644 index 000000000..d3182dc95 --- /dev/null +++ b/docs/storage-report/AllocationManager.md @@ -0,0 +1,21 @@ +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------------------|-----------------------------------------------------------------------------------------------------|------|--------|-------|------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _initializing | bool | 0 | 1 | 1 | src/contracts/core/AllocationManager.sol:AllocationManager | +| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _owner | address | 51 | 0 | 20 | src/contracts/core/AllocationManager.sol:AllocationManager | +| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/AllocationManager.sol:AllocationManager | +| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _DOMAIN_SEPARATOR | bytes32 | 151 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 152 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _totalMagnitudeUpdate | mapping(address => mapping(contract IStrategy => struct Snapshots.History)) | 153 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _magnitudeUpdate | mapping(address => mapping(contract IStrategy => mapping(bytes32 => struct Snapshots.History))) | 154 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| operatorMagnitudeInfo | mapping(address => mapping(contract IStrategy => struct IAllocationManager.OperatorMagnitudeInfo)) | 155 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _pendingFreeMagnitude | mapping(address => mapping(contract IStrategy => struct IAllocationManager.PendingFreeMagnitude[])) | 156 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _queuedDeallocationIndices | mapping(address => mapping(contract IStrategy => mapping(bytes32 => uint256[]))) | 157 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _allocationDelayInfo | mapping(address => struct IAllocationManager.AllocationDelayInfo) | 158 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| __gap | uint256[42] | 159 | 0 | 1344 | src/contracts/core/AllocationManager.sol:AllocationManager | +| _status | uint256 | 201 | 0 | 32 | src/contracts/core/AllocationManager.sol:AllocationManager | +| __gap | uint256[49] | 202 | 0 | 1568 | src/contracts/core/AllocationManager.sol:AllocationManager | diff --git a/docs/storage-report/AllocationManagerStorage.md b/docs/storage-report/AllocationManagerStorage.md new file mode 100644 index 000000000..52ad78099 --- /dev/null +++ b/docs/storage-report/AllocationManagerStorage.md @@ -0,0 +1,11 @@ +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------------------|-----------------------------------------------------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------| +| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 1 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| _totalMagnitudeUpdate | mapping(address => mapping(contract IStrategy => struct Snapshots.History)) | 2 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| _magnitudeUpdate | mapping(address => mapping(contract IStrategy => mapping(bytes32 => struct Snapshots.History))) | 3 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| operatorMagnitudeInfo | mapping(address => mapping(contract IStrategy => struct IAllocationManager.OperatorMagnitudeInfo)) | 4 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| _pendingFreeMagnitude | mapping(address => mapping(contract IStrategy => struct IAllocationManager.PendingFreeMagnitude[])) | 5 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| _queuedDeallocationIndices | mapping(address => mapping(contract IStrategy => mapping(bytes32 => uint256[]))) | 6 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| _allocationDelayInfo | mapping(address => struct IAllocationManager.AllocationDelayInfo) | 7 | 0 | 32 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | +| __gap | uint256[42] | 8 | 0 | 1344 | src/contracts/core/AllocationManagerStorage.sol:AllocationManagerStorage | diff --git a/docs/storage-report/DelegationManager.md b/docs/storage-report/DelegationManager.md index 61594f32a..c0f76e259 100644 --- a/docs/storage-report/DelegationManager.md +++ b/docs/storage-report/DelegationManager.md @@ -1,24 +1,25 @@ -| Name | Type | Slot | Offset | Bytes | Contract | -|-------------------------------|---------------------------------------------------------------|------|--------|-------|------------------------------------------------------------| -| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/DelegationManager.sol:DelegationManager | -| _initializing | bool | 0 | 1 | 1 | src/contracts/core/DelegationManager.sol:DelegationManager | -| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/DelegationManager.sol:DelegationManager | -| _owner | address | 51 | 0 | 20 | src/contracts/core/DelegationManager.sol:DelegationManager | -| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/DelegationManager.sol:DelegationManager | -| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/DelegationManager.sol:DelegationManager | -| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/DelegationManager.sol:DelegationManager | -| _DOMAIN_SEPARATOR | bytes32 | 151 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| operatorShares | mapping(address => mapping(contract IStrategy => uint256)) | 152 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| _operatorDetails | mapping(address => struct IDelegationManager.OperatorDetails) | 153 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| delegatedTo | mapping(address => address) | 154 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| stakerNonce | mapping(address => uint256) | 155 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| delegationApproverSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 156 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| minWithdrawalDelayBlocks | uint256 | 157 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| pendingWithdrawals | mapping(bytes32 => bool) | 158 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| cumulativeWithdrawalsQueued | mapping(address => uint256) | 159 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| __deprecated_stakeRegistry | address | 160 | 0 | 20 | src/contracts/core/DelegationManager.sol:DelegationManager | -| strategyWithdrawalDelayBlocks | mapping(contract IStrategy => uint256) | 161 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| __gap | uint256[39] | 162 | 0 | 1248 | src/contracts/core/DelegationManager.sol:DelegationManager | -| _status | uint256 | 201 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | -| __gap | uint256[49] | 202 | 0 | 1568 | src/contracts/core/DelegationManager.sol:DelegationManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------------------------------|---------------------------------------------------------------|------|--------|-------|------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/DelegationManager.sol:DelegationManager | +| _initializing | bool | 0 | 1 | 1 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/DelegationManager.sol:DelegationManager | +| _owner | address | 51 | 0 | 20 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/DelegationManager.sol:DelegationManager | +| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/DelegationManager.sol:DelegationManager | +| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/DelegationManager.sol:DelegationManager | +| _DOMAIN_SEPARATOR | bytes32 | 151 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| operatorScaledShares | mapping(address => mapping(contract IStrategy => uint256)) | 152 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| _operatorDetails | mapping(address => struct IDelegationManager.OperatorDetails) | 153 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| delegatedTo | mapping(address => address) | 154 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| stakerNonce | mapping(address => uint256) | 155 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| delegationApproverSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 156 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __deprecated_minWithdrawalDelayBlocks | uint256 | 157 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| pendingWithdrawals | mapping(bytes32 => bool) | 158 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| cumulativeWithdrawalsQueued | mapping(address => uint256) | 159 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __deprecated_stakeRegistry | address | 160 | 0 | 20 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __deprecated_strategyWithdrawalDelayBlocks | mapping(contract IStrategy => uint256) | 161 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| stakerScalingFactors | mapping(address => mapping(contract IStrategy => uint256)) | 162 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __gap | uint256[38] | 163 | 0 | 1216 | src/contracts/core/DelegationManager.sol:DelegationManager | +| _status | uint256 | 201 | 0 | 32 | src/contracts/core/DelegationManager.sol:DelegationManager | +| __gap | uint256[49] | 202 | 0 | 1568 | src/contracts/core/DelegationManager.sol:DelegationManager | diff --git a/docs/storage-report/DelegationManagerStorage.md b/docs/storage-report/DelegationManagerStorage.md index 2ae1eb04b..6f31d6c99 100644 --- a/docs/storage-report/DelegationManagerStorage.md +++ b/docs/storage-report/DelegationManagerStorage.md @@ -1,14 +1,15 @@ -| Name | Type | Slot | Offset | Bytes | Contract | -|-------------------------------|---------------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------| -| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| operatorShares | mapping(address => mapping(contract IStrategy => uint256)) | 1 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| _operatorDetails | mapping(address => struct IDelegationManager.OperatorDetails) | 2 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| delegatedTo | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| stakerNonce | mapping(address => uint256) | 4 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| delegationApproverSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 5 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| minWithdrawalDelayBlocks | uint256 | 6 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| pendingWithdrawals | mapping(bytes32 => bool) | 7 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| cumulativeWithdrawalsQueued | mapping(address => uint256) | 8 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| __deprecated_stakeRegistry | address | 9 | 0 | 20 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| strategyWithdrawalDelayBlocks | mapping(contract IStrategy => uint256) | 10 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | -| __gap | uint256[39] | 11 | 0 | 1248 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------------------------------|---------------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------| +| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| operatorScaledShares | mapping(address => mapping(contract IStrategy => uint256)) | 1 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| _operatorDetails | mapping(address => struct IDelegationManager.OperatorDetails) | 2 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| delegatedTo | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| stakerNonce | mapping(address => uint256) | 4 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| delegationApproverSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 5 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| __deprecated_minWithdrawalDelayBlocks | uint256 | 6 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| pendingWithdrawals | mapping(bytes32 => bool) | 7 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| cumulativeWithdrawalsQueued | mapping(address => uint256) | 8 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| __deprecated_stakeRegistry | address | 9 | 0 | 20 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| __deprecated_strategyWithdrawalDelayBlocks | mapping(contract IStrategy => uint256) | 10 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| stakerScalingFactors | mapping(address => mapping(contract IStrategy => uint256)) | 11 | 0 | 32 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | +| __gap | uint256[38] | 12 | 0 | 1216 | src/contracts/core/DelegationManagerStorage.sol:DelegationManagerStorage | diff --git a/docs/storage-report/RewardsCoordinator.md b/docs/storage-report/RewardsCoordinator.md index c3ac38649..726906890 100644 --- a/docs/storage-report/RewardsCoordinator.md +++ b/docs/storage-report/RewardsCoordinator.md @@ -1,26 +1,28 @@ -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------------------------|---------------------------------------------------------|------|--------|-------|--------------------------------------------------------------| -| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| _initializing | bool | 0 | 1 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| _owner | address | 51 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| _status | uint256 | 151 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| __gap | uint256[49] | 152 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| _DOMAIN_SEPARATOR | bytes32 | 201 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 202 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| rewardsUpdater | address | 203 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| activationDelay | uint32 | 203 | 20 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| currRewardsCalculationEndTimestamp | uint32 | 203 | 24 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| globalOperatorCommissionBips | uint16 | 203 | 28 | 2 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| claimerFor | mapping(address => address) | 204 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 205 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| submissionNonce | mapping(address => uint256) | 206 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 207 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 208 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| isRewardsForAllSubmitter | mapping(address => bool) | 209 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 210 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | -| __gap | uint256[39] | 211 | 0 | 1248 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|--------|-------|--------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| _initializing | bool | 0 | 1 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| _owner | address | 51 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| _status | uint256 | 151 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| __gap | uint256[49] | 152 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| _DOMAIN_SEPARATOR | bytes32 | 201 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 202 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| rewardsUpdater | address | 203 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| activationDelay | uint32 | 203 | 20 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| currRewardsCalculationEndTimestamp | uint32 | 203 | 24 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| globalOperatorCommissionBips | uint16 | 203 | 28 | 2 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| claimerFor | mapping(address => address) | 204 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 205 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| submissionNonce | mapping(address => uint256) | 206 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 207 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 208 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| isRewardsForAllSubmitter | mapping(address => bool) | 209 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 210 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| isOperatorSetRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 211 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| operatorCommissionUpdates | mapping(address => mapping(address => mapping(uint32 => mapping(enum IRewardsCoordinator.RewardType => struct IRewardsCoordinator.OperatorCommissionUpdate[])))) | 212 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | +| __gap | uint256[37] | 213 | 0 | 1184 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator | diff --git a/docs/storage-report/RewardsCoordinatorStorage.md b/docs/storage-report/RewardsCoordinatorStorage.md index e5f8f26bc..36571b647 100644 --- a/docs/storage-report/RewardsCoordinatorStorage.md +++ b/docs/storage-report/RewardsCoordinatorStorage.md @@ -1,16 +1,18 @@ -| Name | Type | Slot | Offset | Bytes | Contract | -|--------------------------------------|---------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------| -| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 1 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| rewardsUpdater | address | 2 | 0 | 20 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| activationDelay | uint32 | 2 | 20 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| currRewardsCalculationEndTimestamp | uint32 | 2 | 24 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| globalOperatorCommissionBips | uint16 | 2 | 28 | 2 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| claimerFor | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 4 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| submissionNonce | mapping(address => uint256) | 5 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 6 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 7 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| isRewardsForAllSubmitter | mapping(address => bool) | 8 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 9 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | -| __gap | uint256[39] | 10 | 0 | 1248 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------| +| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 1 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| rewardsUpdater | address | 2 | 0 | 20 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| activationDelay | uint32 | 2 | 20 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| currRewardsCalculationEndTimestamp | uint32 | 2 | 24 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| globalOperatorCommissionBips | uint16 | 2 | 28 | 2 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| claimerFor | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 4 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| submissionNonce | mapping(address => uint256) | 5 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 6 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 7 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| isRewardsForAllSubmitter | mapping(address => bool) | 8 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 9 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| isOperatorSetRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 10 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| operatorCommissionUpdates | mapping(address => mapping(address => mapping(uint32 => mapping(enum IRewardsCoordinator.RewardType => struct IRewardsCoordinator.OperatorCommissionUpdate[])))) | 11 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | +| __gap | uint256[37] | 12 | 0 | 1184 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage | diff --git a/docs/storage-report/StrategyManager.md b/docs/storage-report/StrategyManager.md index 8f7e5cb4b..2a489f6cb 100644 --- a/docs/storage-report/StrategyManager.md +++ b/docs/storage-report/StrategyManager.md @@ -20,5 +20,5 @@ | __deprecated_numWithdrawalsQueued | mapping(address => uint256) | 208 | 0 | 32 | src/contracts/core/StrategyManager.sol:StrategyManager | | strategyIsWhitelistedForDeposit | mapping(contract IStrategy => bool) | 209 | 0 | 32 | src/contracts/core/StrategyManager.sol:StrategyManager | | beaconChainETHSharesToDecrementOnWithdrawal | mapping(address => uint256) | 210 | 0 | 32 | src/contracts/core/StrategyManager.sol:StrategyManager | -| thirdPartyTransfersForbidden | mapping(contract IStrategy => bool) | 211 | 0 | 32 | src/contracts/core/StrategyManager.sol:StrategyManager | +| __deprecated_thirdPartyTransfersForbidden | mapping(contract IStrategy => bool) | 211 | 0 | 32 | src/contracts/core/StrategyManager.sol:StrategyManager | | __gap | uint256[39] | 212 | 0 | 1248 | src/contracts/core/StrategyManager.sol:StrategyManager | diff --git a/docs/storage-report/StrategyManagerStorage.md b/docs/storage-report/StrategyManagerStorage.md index 701045da7..d5668278d 100644 --- a/docs/storage-report/StrategyManagerStorage.md +++ b/docs/storage-report/StrategyManagerStorage.md @@ -10,5 +10,5 @@ | __deprecated_numWithdrawalsQueued | mapping(address => uint256) | 7 | 0 | 32 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage | | strategyIsWhitelistedForDeposit | mapping(contract IStrategy => bool) | 8 | 0 | 32 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage | | beaconChainETHSharesToDecrementOnWithdrawal | mapping(address => uint256) | 9 | 0 | 32 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage | -| thirdPartyTransfersForbidden | mapping(contract IStrategy => bool) | 10 | 0 | 32 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage | +| __deprecated_thirdPartyTransfersForbidden | mapping(contract IStrategy => bool) | 10 | 0 | 32 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage | | __gap | uint256[39] | 11 | 0 | 1248 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage | diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts new file mode 160000 index 000000000..3b8b4ba82 --- /dev/null +++ b/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit 3b8b4ba82c880c31cd3b96dd5e15741d7e26658e diff --git a/lib/openzeppelin-contracts-upgradeable b/lib/openzeppelin-contracts-upgradeable new file mode 160000 index 000000000..6b9807b06 --- /dev/null +++ b/lib/openzeppelin-contracts-upgradeable @@ -0,0 +1 @@ +Subproject commit 6b9807b0639e1dd75e07fa062e9432eb3f35dd8c diff --git a/pkg/bindings/Checkpoints/binding.go b/pkg/bindings/Checkpoints/binding.go new file mode 100644 index 000000000..41a27afa8 --- /dev/null +++ b/pkg/bindings/Checkpoints/binding.go @@ -0,0 +1,203 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package Checkpoints + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// CheckpointsMetaData contains all meta data concerning the Checkpoints contract. +var CheckpointsMetaData = &bind.MetaData{ + ABI: "[]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122033cd598fba8494d1a6958a8af518adce5917043f9d96f1543c5e5350d9ce39b364736f6c634300080c0033", +} + +// CheckpointsABI is the input ABI used to generate the binding from. +// Deprecated: Use CheckpointsMetaData.ABI instead. +var CheckpointsABI = CheckpointsMetaData.ABI + +// CheckpointsBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use CheckpointsMetaData.Bin instead. +var CheckpointsBin = CheckpointsMetaData.Bin + +// DeployCheckpoints deploys a new Ethereum contract, binding an instance of Checkpoints to it. +func DeployCheckpoints(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Checkpoints, error) { + parsed, err := CheckpointsMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CheckpointsBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Checkpoints{CheckpointsCaller: CheckpointsCaller{contract: contract}, CheckpointsTransactor: CheckpointsTransactor{contract: contract}, CheckpointsFilterer: CheckpointsFilterer{contract: contract}}, nil +} + +// Checkpoints is an auto generated Go binding around an Ethereum contract. +type Checkpoints struct { + CheckpointsCaller // Read-only binding to the contract + CheckpointsTransactor // Write-only binding to the contract + CheckpointsFilterer // Log filterer for contract events +} + +// CheckpointsCaller is an auto generated read-only Go binding around an Ethereum contract. +type CheckpointsCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// CheckpointsTransactor is an auto generated write-only Go binding around an Ethereum contract. +type CheckpointsTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// CheckpointsFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type CheckpointsFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// CheckpointsSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type CheckpointsSession struct { + Contract *Checkpoints // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// CheckpointsCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type CheckpointsCallerSession struct { + Contract *CheckpointsCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// CheckpointsTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type CheckpointsTransactorSession struct { + Contract *CheckpointsTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// CheckpointsRaw is an auto generated low-level Go binding around an Ethereum contract. +type CheckpointsRaw struct { + Contract *Checkpoints // Generic contract binding to access the raw methods on +} + +// CheckpointsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type CheckpointsCallerRaw struct { + Contract *CheckpointsCaller // Generic read-only contract binding to access the raw methods on +} + +// CheckpointsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type CheckpointsTransactorRaw struct { + Contract *CheckpointsTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewCheckpoints creates a new instance of Checkpoints, bound to a specific deployed contract. +func NewCheckpoints(address common.Address, backend bind.ContractBackend) (*Checkpoints, error) { + contract, err := bindCheckpoints(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Checkpoints{CheckpointsCaller: CheckpointsCaller{contract: contract}, CheckpointsTransactor: CheckpointsTransactor{contract: contract}, CheckpointsFilterer: CheckpointsFilterer{contract: contract}}, nil +} + +// NewCheckpointsCaller creates a new read-only instance of Checkpoints, bound to a specific deployed contract. +func NewCheckpointsCaller(address common.Address, caller bind.ContractCaller) (*CheckpointsCaller, error) { + contract, err := bindCheckpoints(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &CheckpointsCaller{contract: contract}, nil +} + +// NewCheckpointsTransactor creates a new write-only instance of Checkpoints, bound to a specific deployed contract. +func NewCheckpointsTransactor(address common.Address, transactor bind.ContractTransactor) (*CheckpointsTransactor, error) { + contract, err := bindCheckpoints(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &CheckpointsTransactor{contract: contract}, nil +} + +// NewCheckpointsFilterer creates a new log filterer instance of Checkpoints, bound to a specific deployed contract. +func NewCheckpointsFilterer(address common.Address, filterer bind.ContractFilterer) (*CheckpointsFilterer, error) { + contract, err := bindCheckpoints(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &CheckpointsFilterer{contract: contract}, nil +} + +// bindCheckpoints binds a generic wrapper to an already deployed contract. +func bindCheckpoints(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := CheckpointsMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Checkpoints *CheckpointsRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Checkpoints.Contract.CheckpointsCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Checkpoints *CheckpointsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Checkpoints.Contract.CheckpointsTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Checkpoints *CheckpointsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Checkpoints.Contract.CheckpointsTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Checkpoints *CheckpointsCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Checkpoints.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Checkpoints *CheckpointsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Checkpoints.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Checkpoints *CheckpointsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Checkpoints.Contract.contract.Transact(opts, method, params...) +} diff --git a/pkg/bindings/DelayedWithdrawalRouter/binding.go b/pkg/bindings/DelayedWithdrawalRouter/binding.go new file mode 100644 index 000000000..4943de658 --- /dev/null +++ b/pkg/bindings/DelayedWithdrawalRouter/binding.go @@ -0,0 +1,1969 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package DelayedWithdrawalRouter + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// IDelayedWithdrawalRouterDelayedWithdrawal is an auto generated low-level Go binding around an user-defined struct. +type IDelayedWithdrawalRouterDelayedWithdrawal struct { + Amount *big.Int + BlockCreated uint32 +} + +// IDelayedWithdrawalRouterUserDelayedWithdrawals is an auto generated low-level Go binding around an user-defined struct. +type IDelayedWithdrawalRouterUserDelayedWithdrawals struct { + DelayedWithdrawalsCompleted *big.Int + DelayedWithdrawals []IDelayedWithdrawalRouterDelayedWithdrawal +} + +// DelayedWithdrawalRouterMetaData contains all meta data concerning the DelayedWithdrawalRouter contract. +var DelayedWithdrawalRouterMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_eigenPodManager\",\"type\":\"address\",\"internalType\":\"contractIEigenPodManager\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"MAX_WITHDRAWAL_DELAY_BLOCKS\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"canClaimDelayedWithdrawal\",\"inputs\":[{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"index\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"claimDelayedWithdrawals\",\"inputs\":[{\"name\":\"maxNumberOfDelayedWithdrawalsToClaim\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"claimDelayedWithdrawals\",\"inputs\":[{\"name\":\"recipient\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"maxNumberOfDelayedWithdrawalsToClaim\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"createDelayedWithdrawal\",\"inputs\":[{\"name\":\"podOwner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"recipient\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"eigenPodManager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIEigenPodManager\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getClaimableUserDelayedWithdrawals\",\"inputs\":[{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple[]\",\"internalType\":\"structIDelayedWithdrawalRouter.DelayedWithdrawal[]\",\"components\":[{\"name\":\"amount\",\"type\":\"uint224\",\"internalType\":\"uint224\"},{\"name\":\"blockCreated\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getUserDelayedWithdrawals\",\"inputs\":[{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple[]\",\"internalType\":\"structIDelayedWithdrawalRouter.DelayedWithdrawal[]\",\"components\":[{\"name\":\"amount\",\"type\":\"uint224\",\"internalType\":\"uint224\"},{\"name\":\"blockCreated\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"initOwner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_pauserRegistry\",\"type\":\"address\",\"internalType\":\"contractIPauserRegistry\"},{\"name\":\"initPausedStatus\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_withdrawalDelayBlocks\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pause\",\"inputs\":[{\"name\":\"newPausedStatus\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"pauseAll\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[{\"name\":\"index\",\"type\":\"uint8\",\"internalType\":\"uint8\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pauserRegistry\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIPauserRegistry\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setPauserRegistry\",\"inputs\":[{\"name\":\"newPauserRegistry\",\"type\":\"address\",\"internalType\":\"contractIPauserRegistry\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setWithdrawalDelayBlocks\",\"inputs\":[{\"name\":\"newValue\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unpause\",\"inputs\":[{\"name\":\"newPausedStatus\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"userDelayedWithdrawalByIndex\",\"inputs\":[{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"index\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIDelayedWithdrawalRouter.DelayedWithdrawal\",\"components\":[{\"name\":\"amount\",\"type\":\"uint224\",\"internalType\":\"uint224\"},{\"name\":\"blockCreated\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"userWithdrawals\",\"inputs\":[{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIDelayedWithdrawalRouter.UserDelayedWithdrawals\",\"components\":[{\"name\":\"delayedWithdrawalsCompleted\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"delayedWithdrawals\",\"type\":\"tuple[]\",\"internalType\":\"structIDelayedWithdrawalRouter.DelayedWithdrawal[]\",\"components\":[{\"name\":\"amount\",\"type\":\"uint224\",\"internalType\":\"uint224\"},{\"name\":\"blockCreated\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"userWithdrawalsLength\",\"inputs\":[{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"withdrawalDelayBlocks\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"DelayedWithdrawalCreated\",\"inputs\":[{\"name\":\"podOwner\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"recipient\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"index\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"DelayedWithdrawalsClaimed\",\"inputs\":[{\"name\":\"recipient\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"amountClaimed\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"delayedWithdrawalsCompleted\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Paused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newPausedStatus\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"PauserRegistrySet\",\"inputs\":[{\"name\":\"pauserRegistry\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"contractIPauserRegistry\"},{\"name\":\"newPauserRegistry\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"contractIPauserRegistry\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Unpaused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newPausedStatus\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"WithdrawalDelayBlocksSet\",\"inputs\":[{\"name\":\"previousValue\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"newValue\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false}]", + Bin: "0x60a06040523480156200001157600080fd5b5060405162001f0e38038062001f0e8339810160408190526200003491620001a8565b6001600160a01b038116620000cb5760405162461bcd60e51b815260206004820152604c60248201527f44656c617965645769746864726177616c526f757465722e636f6e737472756360448201527f746f723a205f656967656e506f644d616e616765722063616e6e6f742062652060648201526b7a65726f206164647265737360a01b608482015260a4015b60405180910390fd5b6001600160a01b038116608052620000e2620000e9565b50620001da565b600054610100900460ff1615620001535760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608401620000c2565b60005460ff9081161015620001a6576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b600060208284031215620001bb57600080fd5b81516001600160a01b0381168114620001d357600080fd5b9392505050565b608051611d11620001fd600039600081816101fa0152610c000152611d116000f3fe60806040526004361061014b5760003560e01c806385594e58116100b6578063e4f4f8871161006f578063e4f4f887146103cc578063e5db06c014610405578063eb990c5914610425578063ecb7cb1b14610445578063f2fde38b14610472578063fabc1cbc1461049257600080fd5b806385594e5814610317578063886f1195146103445780638da5cb5b14610364578063c0db354c14610382578063ca661c0414610395578063d44e1b76146103ac57600080fd5b806350f73e7c1161010857806350f73e7c14610254578063595c6a67146102785780635ac86ab71461028d5780635c975abb146102cd578063715018a6146102e257806375608896146102f757600080fd5b806310d67a2f14610150578063136439dd146101725780631f39d87f146101925780633e1de008146101c85780634665bcda146101e85780634d50f9a414610234575b600080fd5b34801561015c57600080fd5b5061017061016b36600461196d565b6104b2565b005b34801561017e57600080fd5b5061017061018d366004611991565b61056e565b34801561019e57600080fd5b506101b26101ad36600461196d565b6106ad565b6040516101bf91906119c8565b60405180910390f35b3480156101d457600080fd5b506101b26101e336600461196d565b6108a8565b3480156101f457600080fd5b5061021c7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101bf565b34801561024057600080fd5b5061017061024f366004611991565b6109ee565b34801561026057600080fd5b5061026a60c95481565b6040519081526020016101bf565b34801561028457600080fd5b506101706109ff565b34801561029957600080fd5b506102bd6102a8366004611a15565b609854600160ff9092169190911b9081161490565b60405190151581526020016101bf565b3480156102d957600080fd5b5060985461026a565b3480156102ee57600080fd5b50610170610ac6565b34801561030357600080fd5b506102bd610312366004611a38565b610ada565b34801561032357600080fd5b50610337610332366004611a38565b610b5d565b6040516101bf9190611a64565b34801561035057600080fd5b5060975461021c906001600160a01b031681565b34801561037057600080fd5b506033546001600160a01b031661021c565b610170610390366004611a72565b610bdd565b3480156103a157600080fd5b5061026a62034bc081565b3480156103b857600080fd5b506101706103c7366004611991565b610e9d565b3480156103d857600080fd5b5061026a6103e736600461196d565b6001600160a01b0316600090815260ca602052604090206001015490565b34801561041157600080fd5b50610170610420366004611a38565b610f31565b34801561043157600080fd5b50610170610440366004611aab565b610fc6565b34801561045157600080fd5b5061046561046036600461196d565b6110ee565b6040516101bf9190611af1565b34801561047e57600080fd5b5061017061048d36600461196d565b6111a8565b34801561049e57600080fd5b506101706104ad366004611991565b61121e565b609760009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610505573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105299190611b47565b6001600160a01b0316336001600160a01b0316146105625760405162461bcd60e51b815260040161055990611b64565b60405180910390fd5b61056b8161137a565b50565b60975460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa1580156105b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105da9190611bae565b6105f65760405162461bcd60e51b815260040161055990611bd0565b6098548181161461066f5760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e70617573653a20696e76616c696420617474656d70742060448201527f746f20756e70617573652066756e6374696f6e616c69747900000000000000006064820152608401610559565b609881905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d906020015b60405180910390a250565b6001600160a01b038116600090815260ca6020526040812080546001909101546060926106da8383611c2e565b90508060005b82811015610786576001600160a01b038716600090815260ca6020526040812060010161070d8388611c45565b8154811061071d5761071d611c5d565b6000918252602091829020604080518082019091529101546001600160e01b0381168252600160e01b900463ffffffff1691810182905260c95490925061076391611c45565b4310156107735781925050610786565b508061077e81611c73565b9150506106e0565b508060008167ffffffffffffffff8111156107a3576107a3611c8e565b6040519080825280602002602001820160405280156107e857816020015b60408051808201909152600080825260208201528152602001906001900390816107c15790505b509050811561089d5760005b8281101561089b576001600160a01b038916600090815260ca602052604090206001016108218289611c45565b8154811061083157610831611c5d565b6000918252602091829020604080518082019091529101546001600160e01b0381168252600160e01b900463ffffffff1691810191909152825183908390811061087d5761087d611c5d565b6020026020010181905250808061089390611c73565b9150506107f4565b505b979650505050505050565b6001600160a01b038116600090815260ca6020526040812080546001909101546060926108d58383611c2e565b905060008167ffffffffffffffff8111156108f2576108f2611c8e565b60405190808252806020026020018201604052801561093757816020015b60408051808201909152600080825260208201528152602001906001900390816109105790505b50905060005b828110156109e4576001600160a01b038716600090815260ca6020526040902060010161096a8287611c45565b8154811061097a5761097a611c5d565b6000918252602091829020604080518082019091529101546001600160e01b0381168252600160e01b900463ffffffff169181019190915282518390839081106109c6576109c6611c5d565b602002602001018190525080806109dc90611c73565b91505061093d565b5095945050505050565b6109f6611471565b61056b816114cb565b60975460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa158015610a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6b9190611bae565b610a875760405162461bcd60e51b815260040161055990611bd0565b600019609881905560405190815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a2565b610ace611471565b610ad86000611593565b565b6001600160a01b038216600090815260ca60205260408120548210801590610b54575060c9546001600160a01b038416600090815260ca60205260409020600101805484908110610b2d57610b2d611c5d565b600091825260209091200154610b509190600160e01b900463ffffffff16611c45565b4310155b90505b92915050565b60408051808201909152600080825260208201526001600160a01b038316600090815260ca60205260409020600101805483908110610b9e57610b9e611c5d565b6000918252602091829020604080518082019091529101546001600160e01b0381168252600160e01b900463ffffffff16918101919091529392505050565b60405163a38406a360e01b81526001600160a01b038084166004830152839133917f0000000000000000000000000000000000000000000000000000000000000000169063a38406a390602401602060405180830381865afa158015610c47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6b9190611b47565b6001600160a01b031614610ce75760405162461bcd60e51b815260206004820152603d60248201527f44656c617965645769746864726177616c526f757465722e6f6e6c794569676560448201527f6e506f643a206e6f7420706f644f776e6572277320456967656e506f640000006064820152608401610559565b60985460009060019081161415610d105760405162461bcd60e51b815260040161055990611ca4565b6001600160a01b038316610da65760405162461bcd60e51b815260206004820152605160248201527f44656c617965645769746864726177616c526f757465722e637265617465446560448201527f6c617965645769746864726177616c3a20726563697069656e742063616e6e6f60648201527074206265207a65726f206164647265737360781b608482015260a401610559565b346001600160e01b03811615610e96576040805180820182526001600160e01b03808416825263ffffffff43811660208085019182526001600160a01b038a16600081815260ca8352968720600190810180548083018255818a5293892088519551909616600160e01b029490961693909317939091019290925593525490917fb8f1b14c7caf74150801dcc9bc18d575cbeaf5b421943497e409df92c92e0f5991889188918691610e5791611c2e565b604080516001600160a01b0395861681529490931660208501526001600160e01b039091169183019190915260608201526080015b60405180910390a1505b5050505050565b60026065541415610ef05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610559565b600260655560985460009060019081161415610f1e5760405162461bcd60e51b815260040161055990611ca4565b610f2833836115e5565b50506001606555565b60026065541415610f845760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610559565b600260655560985460009060019081161415610fb25760405162461bcd60e51b815260040161055990611ca4565b610fbc83836115e5565b5050600160655550565b600054610100900460ff1615808015610fe65750600054600160ff909116105b806110005750303b158015611000575060005460ff166001145b6110635760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610559565b6000805460ff191660011790558015611086576000805461ff0019166101001790555b61108f85611593565b6110998484611750565b6110a2826114cb565b8015610e96576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050505050565b6040805180820190915260008152606060208201526001600160a01b038216600090815260ca6020908152604080832081518083018352815481526001820180548451818702810187019095528085529195929486810194939192919084015b8282101561119a57600084815260209081902060408051808201909152908401546001600160e01b0381168252600160e01b900463ffffffff168183015282526001909201910161114e565b505050915250909392505050565b6111b0611471565b6001600160a01b0381166112155760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610559565b61056b81611593565b609760009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112959190611b47565b6001600160a01b0316336001600160a01b0316146112c55760405162461bcd60e51b815260040161055990611b64565b6098541981196098541916146113435760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e756e70617573653a20696e76616c696420617474656d7060448201527f7420746f2070617573652066756e6374696f6e616c69747900000000000000006064820152608401610559565b609881905560405181815233907f3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c906020016106a2565b6001600160a01b0381166114085760405162461bcd60e51b815260206004820152604960248201527f5061757361626c652e5f73657450617573657252656769737472793a206e657760448201527f50617573657252656769737472792063616e6e6f7420626520746865207a65726064820152686f206164647265737360b81b608482015260a401610559565b609754604080516001600160a01b03928316815291831660208301527f6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6910160405180910390a1609780546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b03163314610ad85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610559565b62034bc08111156115525760405162461bcd60e51b815260206004820152604560248201527f44656c617965645769746864726177616c526f757465722e5f7365745769746860448201527f64726177616c44656c6179426c6f636b733a206e657756616c756520746f6f206064820152646c6172676560d81b608482015260a401610559565b60c95460408051918252602082018390527f4ffb00400574147429ee377a5633386321e66d45d8b14676014b5fa393e61e9e910160405180910390a160c955565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600090815260ca602052604081208054600190910154825b848110801561161e57508161161c8285611c45565b105b156116cb576001600160a01b038616600090815260ca602052604081206001016116488386611c45565b8154811061165857611658611c5d565b6000918252602091829020604080518082019091529101546001600160e01b0381168252600160e01b900463ffffffff1691810182905260c95490925061169e91611c45565b4310156116ab57506116cb565b80516116c0906001600160e01b031686611c45565b945050600101611607565b6116d58184611c45565b6001600160a01b038716600090815260ca602052604090205583156116fe576116fe868561183a565b7f6b7151500bd0b5cc211bcc47b3029831b769004df4549e8e1c9a69da05bb0943868561172b8487611c45565b604080516001600160a01b039094168452602084019290925290820152606001610e8c565b6097546001600160a01b031615801561177157506001600160a01b03821615155b6117f35760405162461bcd60e51b815260206004820152604760248201527f5061757361626c652e5f696e697469616c697a655061757365723a205f696e6960448201527f7469616c697a6550617573657228292063616e206f6e6c792062652063616c6c6064820152666564206f6e636560c81b608482015260a401610559565b609881905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a26118368261137a565b5050565b8047101561188a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610559565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146118d7576040519150601f19603f3d011682016040523d82523d6000602084013e6118dc565b606091505b50509050806119535760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610559565b505050565b6001600160a01b038116811461056b57600080fd5b60006020828403121561197f57600080fd5b813561198a81611958565b9392505050565b6000602082840312156119a357600080fd5b5035919050565b80516001600160e01b0316825260209081015163ffffffff16910152565b602080825282518282018190526000919060409081850190868401855b82811015611a08576119f88483516119aa565b92840192908501906001016119e5565b5091979650505050505050565b600060208284031215611a2757600080fd5b813560ff8116811461198a57600080fd5b60008060408385031215611a4b57600080fd5b8235611a5681611958565b946020939093013593505050565b60408101610b5782846119aa565b60008060408385031215611a8557600080fd5b8235611a9081611958565b91506020830135611aa081611958565b809150509250929050565b60008060008060808587031215611ac157600080fd5b8435611acc81611958565b93506020850135611adc81611958565b93969395505050506040820135916060013590565b602080825282518282015282810151604080840181905281516060850181905260009392830191849160808701905b8084101561089b57611b338286516119aa565b938501936001939093019290820190611b20565b600060208284031215611b5957600080fd5b815161198a81611958565b6020808252602a908201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160408201526939903ab73830bab9b2b960b11b606082015260800190565b600060208284031215611bc057600080fd5b8151801515811461198a57600080fd5b60208082526028908201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160408201526739903830bab9b2b960c11b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600082821015611c4057611c40611c18565b500390565b60008219821115611c5857611c58611c18565b500190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415611c8757611c87611c18565b5060010190565b634e487b7160e01b600052604160045260246000fd5b60208082526019908201527f5061757361626c653a20696e646578206973207061757365640000000000000060408201526060019056fea264697066735822122005b0ecc66b0468e43c0d5b0ff9c7b1e449b7556e61ae26d108ff696ed83f730364736f6c634300080c0033", +} + +// DelayedWithdrawalRouterABI is the input ABI used to generate the binding from. +// Deprecated: Use DelayedWithdrawalRouterMetaData.ABI instead. +var DelayedWithdrawalRouterABI = DelayedWithdrawalRouterMetaData.ABI + +// DelayedWithdrawalRouterBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use DelayedWithdrawalRouterMetaData.Bin instead. +var DelayedWithdrawalRouterBin = DelayedWithdrawalRouterMetaData.Bin + +// DeployDelayedWithdrawalRouter deploys a new Ethereum contract, binding an instance of DelayedWithdrawalRouter to it. +func DeployDelayedWithdrawalRouter(auth *bind.TransactOpts, backend bind.ContractBackend, _eigenPodManager common.Address) (common.Address, *types.Transaction, *DelayedWithdrawalRouter, error) { + parsed, err := DelayedWithdrawalRouterMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(DelayedWithdrawalRouterBin), backend, _eigenPodManager) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &DelayedWithdrawalRouter{DelayedWithdrawalRouterCaller: DelayedWithdrawalRouterCaller{contract: contract}, DelayedWithdrawalRouterTransactor: DelayedWithdrawalRouterTransactor{contract: contract}, DelayedWithdrawalRouterFilterer: DelayedWithdrawalRouterFilterer{contract: contract}}, nil +} + +// DelayedWithdrawalRouter is an auto generated Go binding around an Ethereum contract. +type DelayedWithdrawalRouter struct { + DelayedWithdrawalRouterCaller // Read-only binding to the contract + DelayedWithdrawalRouterTransactor // Write-only binding to the contract + DelayedWithdrawalRouterFilterer // Log filterer for contract events +} + +// DelayedWithdrawalRouterCaller is an auto generated read-only Go binding around an Ethereum contract. +type DelayedWithdrawalRouterCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DelayedWithdrawalRouterTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DelayedWithdrawalRouterTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DelayedWithdrawalRouterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DelayedWithdrawalRouterFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DelayedWithdrawalRouterSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DelayedWithdrawalRouterSession struct { + Contract *DelayedWithdrawalRouter // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DelayedWithdrawalRouterCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DelayedWithdrawalRouterCallerSession struct { + Contract *DelayedWithdrawalRouterCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DelayedWithdrawalRouterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DelayedWithdrawalRouterTransactorSession struct { + Contract *DelayedWithdrawalRouterTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DelayedWithdrawalRouterRaw is an auto generated low-level Go binding around an Ethereum contract. +type DelayedWithdrawalRouterRaw struct { + Contract *DelayedWithdrawalRouter // Generic contract binding to access the raw methods on +} + +// DelayedWithdrawalRouterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DelayedWithdrawalRouterCallerRaw struct { + Contract *DelayedWithdrawalRouterCaller // Generic read-only contract binding to access the raw methods on +} + +// DelayedWithdrawalRouterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DelayedWithdrawalRouterTransactorRaw struct { + Contract *DelayedWithdrawalRouterTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDelayedWithdrawalRouter creates a new instance of DelayedWithdrawalRouter, bound to a specific deployed contract. +func NewDelayedWithdrawalRouter(address common.Address, backend bind.ContractBackend) (*DelayedWithdrawalRouter, error) { + contract, err := bindDelayedWithdrawalRouter(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouter{DelayedWithdrawalRouterCaller: DelayedWithdrawalRouterCaller{contract: contract}, DelayedWithdrawalRouterTransactor: DelayedWithdrawalRouterTransactor{contract: contract}, DelayedWithdrawalRouterFilterer: DelayedWithdrawalRouterFilterer{contract: contract}}, nil +} + +// NewDelayedWithdrawalRouterCaller creates a new read-only instance of DelayedWithdrawalRouter, bound to a specific deployed contract. +func NewDelayedWithdrawalRouterCaller(address common.Address, caller bind.ContractCaller) (*DelayedWithdrawalRouterCaller, error) { + contract, err := bindDelayedWithdrawalRouter(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterCaller{contract: contract}, nil +} + +// NewDelayedWithdrawalRouterTransactor creates a new write-only instance of DelayedWithdrawalRouter, bound to a specific deployed contract. +func NewDelayedWithdrawalRouterTransactor(address common.Address, transactor bind.ContractTransactor) (*DelayedWithdrawalRouterTransactor, error) { + contract, err := bindDelayedWithdrawalRouter(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterTransactor{contract: contract}, nil +} + +// NewDelayedWithdrawalRouterFilterer creates a new log filterer instance of DelayedWithdrawalRouter, bound to a specific deployed contract. +func NewDelayedWithdrawalRouterFilterer(address common.Address, filterer bind.ContractFilterer) (*DelayedWithdrawalRouterFilterer, error) { + contract, err := bindDelayedWithdrawalRouter(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterFilterer{contract: contract}, nil +} + +// bindDelayedWithdrawalRouter binds a generic wrapper to an already deployed contract. +func bindDelayedWithdrawalRouter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := DelayedWithdrawalRouterMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DelayedWithdrawalRouter.Contract.DelayedWithdrawalRouterCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.DelayedWithdrawalRouterTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.DelayedWithdrawalRouterTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DelayedWithdrawalRouter.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.contract.Transact(opts, method, params...) +} + +// MAXWITHDRAWALDELAYBLOCKS is a free data retrieval call binding the contract method 0xca661c04. +// +// Solidity: function MAX_WITHDRAWAL_DELAY_BLOCKS() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) MAXWITHDRAWALDELAYBLOCKS(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "MAX_WITHDRAWAL_DELAY_BLOCKS") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MAXWITHDRAWALDELAYBLOCKS is a free data retrieval call binding the contract method 0xca661c04. +// +// Solidity: function MAX_WITHDRAWAL_DELAY_BLOCKS() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) MAXWITHDRAWALDELAYBLOCKS() (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.MAXWITHDRAWALDELAYBLOCKS(&_DelayedWithdrawalRouter.CallOpts) +} + +// MAXWITHDRAWALDELAYBLOCKS is a free data retrieval call binding the contract method 0xca661c04. +// +// Solidity: function MAX_WITHDRAWAL_DELAY_BLOCKS() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) MAXWITHDRAWALDELAYBLOCKS() (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.MAXWITHDRAWALDELAYBLOCKS(&_DelayedWithdrawalRouter.CallOpts) +} + +// CanClaimDelayedWithdrawal is a free data retrieval call binding the contract method 0x75608896. +// +// Solidity: function canClaimDelayedWithdrawal(address user, uint256 index) view returns(bool) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) CanClaimDelayedWithdrawal(opts *bind.CallOpts, user common.Address, index *big.Int) (bool, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "canClaimDelayedWithdrawal", user, index) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// CanClaimDelayedWithdrawal is a free data retrieval call binding the contract method 0x75608896. +// +// Solidity: function canClaimDelayedWithdrawal(address user, uint256 index) view returns(bool) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) CanClaimDelayedWithdrawal(user common.Address, index *big.Int) (bool, error) { + return _DelayedWithdrawalRouter.Contract.CanClaimDelayedWithdrawal(&_DelayedWithdrawalRouter.CallOpts, user, index) +} + +// CanClaimDelayedWithdrawal is a free data retrieval call binding the contract method 0x75608896. +// +// Solidity: function canClaimDelayedWithdrawal(address user, uint256 index) view returns(bool) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) CanClaimDelayedWithdrawal(user common.Address, index *big.Int) (bool, error) { + return _DelayedWithdrawalRouter.Contract.CanClaimDelayedWithdrawal(&_DelayedWithdrawalRouter.CallOpts, user, index) +} + +// EigenPodManager is a free data retrieval call binding the contract method 0x4665bcda. +// +// Solidity: function eigenPodManager() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) EigenPodManager(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "eigenPodManager") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// EigenPodManager is a free data retrieval call binding the contract method 0x4665bcda. +// +// Solidity: function eigenPodManager() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) EigenPodManager() (common.Address, error) { + return _DelayedWithdrawalRouter.Contract.EigenPodManager(&_DelayedWithdrawalRouter.CallOpts) +} + +// EigenPodManager is a free data retrieval call binding the contract method 0x4665bcda. +// +// Solidity: function eigenPodManager() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) EigenPodManager() (common.Address, error) { + return _DelayedWithdrawalRouter.Contract.EigenPodManager(&_DelayedWithdrawalRouter.CallOpts) +} + +// GetClaimableUserDelayedWithdrawals is a free data retrieval call binding the contract method 0x1f39d87f. +// +// Solidity: function getClaimableUserDelayedWithdrawals(address user) view returns((uint224,uint32)[]) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) GetClaimableUserDelayedWithdrawals(opts *bind.CallOpts, user common.Address) ([]IDelayedWithdrawalRouterDelayedWithdrawal, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "getClaimableUserDelayedWithdrawals", user) + + if err != nil { + return *new([]IDelayedWithdrawalRouterDelayedWithdrawal), err + } + + out0 := *abi.ConvertType(out[0], new([]IDelayedWithdrawalRouterDelayedWithdrawal)).(*[]IDelayedWithdrawalRouterDelayedWithdrawal) + + return out0, err + +} + +// GetClaimableUserDelayedWithdrawals is a free data retrieval call binding the contract method 0x1f39d87f. +// +// Solidity: function getClaimableUserDelayedWithdrawals(address user) view returns((uint224,uint32)[]) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) GetClaimableUserDelayedWithdrawals(user common.Address) ([]IDelayedWithdrawalRouterDelayedWithdrawal, error) { + return _DelayedWithdrawalRouter.Contract.GetClaimableUserDelayedWithdrawals(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// GetClaimableUserDelayedWithdrawals is a free data retrieval call binding the contract method 0x1f39d87f. +// +// Solidity: function getClaimableUserDelayedWithdrawals(address user) view returns((uint224,uint32)[]) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) GetClaimableUserDelayedWithdrawals(user common.Address) ([]IDelayedWithdrawalRouterDelayedWithdrawal, error) { + return _DelayedWithdrawalRouter.Contract.GetClaimableUserDelayedWithdrawals(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// GetUserDelayedWithdrawals is a free data retrieval call binding the contract method 0x3e1de008. +// +// Solidity: function getUserDelayedWithdrawals(address user) view returns((uint224,uint32)[]) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) GetUserDelayedWithdrawals(opts *bind.CallOpts, user common.Address) ([]IDelayedWithdrawalRouterDelayedWithdrawal, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "getUserDelayedWithdrawals", user) + + if err != nil { + return *new([]IDelayedWithdrawalRouterDelayedWithdrawal), err + } + + out0 := *abi.ConvertType(out[0], new([]IDelayedWithdrawalRouterDelayedWithdrawal)).(*[]IDelayedWithdrawalRouterDelayedWithdrawal) + + return out0, err + +} + +// GetUserDelayedWithdrawals is a free data retrieval call binding the contract method 0x3e1de008. +// +// Solidity: function getUserDelayedWithdrawals(address user) view returns((uint224,uint32)[]) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) GetUserDelayedWithdrawals(user common.Address) ([]IDelayedWithdrawalRouterDelayedWithdrawal, error) { + return _DelayedWithdrawalRouter.Contract.GetUserDelayedWithdrawals(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// GetUserDelayedWithdrawals is a free data retrieval call binding the contract method 0x3e1de008. +// +// Solidity: function getUserDelayedWithdrawals(address user) view returns((uint224,uint32)[]) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) GetUserDelayedWithdrawals(user common.Address) ([]IDelayedWithdrawalRouterDelayedWithdrawal, error) { + return _DelayedWithdrawalRouter.Contract.GetUserDelayedWithdrawals(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) Owner() (common.Address, error) { + return _DelayedWithdrawalRouter.Contract.Owner(&_DelayedWithdrawalRouter.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) Owner() (common.Address, error) { + return _DelayedWithdrawalRouter.Contract.Owner(&_DelayedWithdrawalRouter.CallOpts) +} + +// Paused is a free data retrieval call binding the contract method 0x5ac86ab7. +// +// Solidity: function paused(uint8 index) view returns(bool) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) Paused(opts *bind.CallOpts, index uint8) (bool, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "paused", index) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Paused is a free data retrieval call binding the contract method 0x5ac86ab7. +// +// Solidity: function paused(uint8 index) view returns(bool) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) Paused(index uint8) (bool, error) { + return _DelayedWithdrawalRouter.Contract.Paused(&_DelayedWithdrawalRouter.CallOpts, index) +} + +// Paused is a free data retrieval call binding the contract method 0x5ac86ab7. +// +// Solidity: function paused(uint8 index) view returns(bool) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) Paused(index uint8) (bool, error) { + return _DelayedWithdrawalRouter.Contract.Paused(&_DelayedWithdrawalRouter.CallOpts, index) +} + +// Paused0 is a free data retrieval call binding the contract method 0x5c975abb. +// +// Solidity: function paused() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) Paused0(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "paused0") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Paused0 is a free data retrieval call binding the contract method 0x5c975abb. +// +// Solidity: function paused() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) Paused0() (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.Paused0(&_DelayedWithdrawalRouter.CallOpts) +} + +// Paused0 is a free data retrieval call binding the contract method 0x5c975abb. +// +// Solidity: function paused() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) Paused0() (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.Paused0(&_DelayedWithdrawalRouter.CallOpts) +} + +// PauserRegistry is a free data retrieval call binding the contract method 0x886f1195. +// +// Solidity: function pauserRegistry() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) PauserRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "pauserRegistry") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// PauserRegistry is a free data retrieval call binding the contract method 0x886f1195. +// +// Solidity: function pauserRegistry() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) PauserRegistry() (common.Address, error) { + return _DelayedWithdrawalRouter.Contract.PauserRegistry(&_DelayedWithdrawalRouter.CallOpts) +} + +// PauserRegistry is a free data retrieval call binding the contract method 0x886f1195. +// +// Solidity: function pauserRegistry() view returns(address) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) PauserRegistry() (common.Address, error) { + return _DelayedWithdrawalRouter.Contract.PauserRegistry(&_DelayedWithdrawalRouter.CallOpts) +} + +// UserDelayedWithdrawalByIndex is a free data retrieval call binding the contract method 0x85594e58. +// +// Solidity: function userDelayedWithdrawalByIndex(address user, uint256 index) view returns((uint224,uint32)) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) UserDelayedWithdrawalByIndex(opts *bind.CallOpts, user common.Address, index *big.Int) (IDelayedWithdrawalRouterDelayedWithdrawal, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "userDelayedWithdrawalByIndex", user, index) + + if err != nil { + return *new(IDelayedWithdrawalRouterDelayedWithdrawal), err + } + + out0 := *abi.ConvertType(out[0], new(IDelayedWithdrawalRouterDelayedWithdrawal)).(*IDelayedWithdrawalRouterDelayedWithdrawal) + + return out0, err + +} + +// UserDelayedWithdrawalByIndex is a free data retrieval call binding the contract method 0x85594e58. +// +// Solidity: function userDelayedWithdrawalByIndex(address user, uint256 index) view returns((uint224,uint32)) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) UserDelayedWithdrawalByIndex(user common.Address, index *big.Int) (IDelayedWithdrawalRouterDelayedWithdrawal, error) { + return _DelayedWithdrawalRouter.Contract.UserDelayedWithdrawalByIndex(&_DelayedWithdrawalRouter.CallOpts, user, index) +} + +// UserDelayedWithdrawalByIndex is a free data retrieval call binding the contract method 0x85594e58. +// +// Solidity: function userDelayedWithdrawalByIndex(address user, uint256 index) view returns((uint224,uint32)) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) UserDelayedWithdrawalByIndex(user common.Address, index *big.Int) (IDelayedWithdrawalRouterDelayedWithdrawal, error) { + return _DelayedWithdrawalRouter.Contract.UserDelayedWithdrawalByIndex(&_DelayedWithdrawalRouter.CallOpts, user, index) +} + +// UserWithdrawals is a free data retrieval call binding the contract method 0xecb7cb1b. +// +// Solidity: function userWithdrawals(address user) view returns((uint256,(uint224,uint32)[])) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) UserWithdrawals(opts *bind.CallOpts, user common.Address) (IDelayedWithdrawalRouterUserDelayedWithdrawals, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "userWithdrawals", user) + + if err != nil { + return *new(IDelayedWithdrawalRouterUserDelayedWithdrawals), err + } + + out0 := *abi.ConvertType(out[0], new(IDelayedWithdrawalRouterUserDelayedWithdrawals)).(*IDelayedWithdrawalRouterUserDelayedWithdrawals) + + return out0, err + +} + +// UserWithdrawals is a free data retrieval call binding the contract method 0xecb7cb1b. +// +// Solidity: function userWithdrawals(address user) view returns((uint256,(uint224,uint32)[])) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) UserWithdrawals(user common.Address) (IDelayedWithdrawalRouterUserDelayedWithdrawals, error) { + return _DelayedWithdrawalRouter.Contract.UserWithdrawals(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// UserWithdrawals is a free data retrieval call binding the contract method 0xecb7cb1b. +// +// Solidity: function userWithdrawals(address user) view returns((uint256,(uint224,uint32)[])) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) UserWithdrawals(user common.Address) (IDelayedWithdrawalRouterUserDelayedWithdrawals, error) { + return _DelayedWithdrawalRouter.Contract.UserWithdrawals(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// UserWithdrawalsLength is a free data retrieval call binding the contract method 0xe4f4f887. +// +// Solidity: function userWithdrawalsLength(address user) view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) UserWithdrawalsLength(opts *bind.CallOpts, user common.Address) (*big.Int, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "userWithdrawalsLength", user) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// UserWithdrawalsLength is a free data retrieval call binding the contract method 0xe4f4f887. +// +// Solidity: function userWithdrawalsLength(address user) view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) UserWithdrawalsLength(user common.Address) (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.UserWithdrawalsLength(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// UserWithdrawalsLength is a free data retrieval call binding the contract method 0xe4f4f887. +// +// Solidity: function userWithdrawalsLength(address user) view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) UserWithdrawalsLength(user common.Address) (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.UserWithdrawalsLength(&_DelayedWithdrawalRouter.CallOpts, user) +} + +// WithdrawalDelayBlocks is a free data retrieval call binding the contract method 0x50f73e7c. +// +// Solidity: function withdrawalDelayBlocks() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCaller) WithdrawalDelayBlocks(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _DelayedWithdrawalRouter.contract.Call(opts, &out, "withdrawalDelayBlocks") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// WithdrawalDelayBlocks is a free data retrieval call binding the contract method 0x50f73e7c. +// +// Solidity: function withdrawalDelayBlocks() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) WithdrawalDelayBlocks() (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.WithdrawalDelayBlocks(&_DelayedWithdrawalRouter.CallOpts) +} + +// WithdrawalDelayBlocks is a free data retrieval call binding the contract method 0x50f73e7c. +// +// Solidity: function withdrawalDelayBlocks() view returns(uint256) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterCallerSession) WithdrawalDelayBlocks() (*big.Int, error) { + return _DelayedWithdrawalRouter.Contract.WithdrawalDelayBlocks(&_DelayedWithdrawalRouter.CallOpts) +} + +// ClaimDelayedWithdrawals is a paid mutator transaction binding the contract method 0xd44e1b76. +// +// Solidity: function claimDelayedWithdrawals(uint256 maxNumberOfDelayedWithdrawalsToClaim) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) ClaimDelayedWithdrawals(opts *bind.TransactOpts, maxNumberOfDelayedWithdrawalsToClaim *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "claimDelayedWithdrawals", maxNumberOfDelayedWithdrawalsToClaim) +} + +// ClaimDelayedWithdrawals is a paid mutator transaction binding the contract method 0xd44e1b76. +// +// Solidity: function claimDelayedWithdrawals(uint256 maxNumberOfDelayedWithdrawalsToClaim) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) ClaimDelayedWithdrawals(maxNumberOfDelayedWithdrawalsToClaim *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.ClaimDelayedWithdrawals(&_DelayedWithdrawalRouter.TransactOpts, maxNumberOfDelayedWithdrawalsToClaim) +} + +// ClaimDelayedWithdrawals is a paid mutator transaction binding the contract method 0xd44e1b76. +// +// Solidity: function claimDelayedWithdrawals(uint256 maxNumberOfDelayedWithdrawalsToClaim) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) ClaimDelayedWithdrawals(maxNumberOfDelayedWithdrawalsToClaim *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.ClaimDelayedWithdrawals(&_DelayedWithdrawalRouter.TransactOpts, maxNumberOfDelayedWithdrawalsToClaim) +} + +// ClaimDelayedWithdrawals0 is a paid mutator transaction binding the contract method 0xe5db06c0. +// +// Solidity: function claimDelayedWithdrawals(address recipient, uint256 maxNumberOfDelayedWithdrawalsToClaim) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) ClaimDelayedWithdrawals0(opts *bind.TransactOpts, recipient common.Address, maxNumberOfDelayedWithdrawalsToClaim *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "claimDelayedWithdrawals0", recipient, maxNumberOfDelayedWithdrawalsToClaim) +} + +// ClaimDelayedWithdrawals0 is a paid mutator transaction binding the contract method 0xe5db06c0. +// +// Solidity: function claimDelayedWithdrawals(address recipient, uint256 maxNumberOfDelayedWithdrawalsToClaim) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) ClaimDelayedWithdrawals0(recipient common.Address, maxNumberOfDelayedWithdrawalsToClaim *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.ClaimDelayedWithdrawals0(&_DelayedWithdrawalRouter.TransactOpts, recipient, maxNumberOfDelayedWithdrawalsToClaim) +} + +// ClaimDelayedWithdrawals0 is a paid mutator transaction binding the contract method 0xe5db06c0. +// +// Solidity: function claimDelayedWithdrawals(address recipient, uint256 maxNumberOfDelayedWithdrawalsToClaim) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) ClaimDelayedWithdrawals0(recipient common.Address, maxNumberOfDelayedWithdrawalsToClaim *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.ClaimDelayedWithdrawals0(&_DelayedWithdrawalRouter.TransactOpts, recipient, maxNumberOfDelayedWithdrawalsToClaim) +} + +// CreateDelayedWithdrawal is a paid mutator transaction binding the contract method 0xc0db354c. +// +// Solidity: function createDelayedWithdrawal(address podOwner, address recipient) payable returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) CreateDelayedWithdrawal(opts *bind.TransactOpts, podOwner common.Address, recipient common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "createDelayedWithdrawal", podOwner, recipient) +} + +// CreateDelayedWithdrawal is a paid mutator transaction binding the contract method 0xc0db354c. +// +// Solidity: function createDelayedWithdrawal(address podOwner, address recipient) payable returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) CreateDelayedWithdrawal(podOwner common.Address, recipient common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.CreateDelayedWithdrawal(&_DelayedWithdrawalRouter.TransactOpts, podOwner, recipient) +} + +// CreateDelayedWithdrawal is a paid mutator transaction binding the contract method 0xc0db354c. +// +// Solidity: function createDelayedWithdrawal(address podOwner, address recipient) payable returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) CreateDelayedWithdrawal(podOwner common.Address, recipient common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.CreateDelayedWithdrawal(&_DelayedWithdrawalRouter.TransactOpts, podOwner, recipient) +} + +// Initialize is a paid mutator transaction binding the contract method 0xeb990c59. +// +// Solidity: function initialize(address initOwner, address _pauserRegistry, uint256 initPausedStatus, uint256 _withdrawalDelayBlocks) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) Initialize(opts *bind.TransactOpts, initOwner common.Address, _pauserRegistry common.Address, initPausedStatus *big.Int, _withdrawalDelayBlocks *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "initialize", initOwner, _pauserRegistry, initPausedStatus, _withdrawalDelayBlocks) +} + +// Initialize is a paid mutator transaction binding the contract method 0xeb990c59. +// +// Solidity: function initialize(address initOwner, address _pauserRegistry, uint256 initPausedStatus, uint256 _withdrawalDelayBlocks) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) Initialize(initOwner common.Address, _pauserRegistry common.Address, initPausedStatus *big.Int, _withdrawalDelayBlocks *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.Initialize(&_DelayedWithdrawalRouter.TransactOpts, initOwner, _pauserRegistry, initPausedStatus, _withdrawalDelayBlocks) +} + +// Initialize is a paid mutator transaction binding the contract method 0xeb990c59. +// +// Solidity: function initialize(address initOwner, address _pauserRegistry, uint256 initPausedStatus, uint256 _withdrawalDelayBlocks) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) Initialize(initOwner common.Address, _pauserRegistry common.Address, initPausedStatus *big.Int, _withdrawalDelayBlocks *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.Initialize(&_DelayedWithdrawalRouter.TransactOpts, initOwner, _pauserRegistry, initPausedStatus, _withdrawalDelayBlocks) +} + +// Pause is a paid mutator transaction binding the contract method 0x136439dd. +// +// Solidity: function pause(uint256 newPausedStatus) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) Pause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "pause", newPausedStatus) +} + +// Pause is a paid mutator transaction binding the contract method 0x136439dd. +// +// Solidity: function pause(uint256 newPausedStatus) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) Pause(newPausedStatus *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.Pause(&_DelayedWithdrawalRouter.TransactOpts, newPausedStatus) +} + +// Pause is a paid mutator transaction binding the contract method 0x136439dd. +// +// Solidity: function pause(uint256 newPausedStatus) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) Pause(newPausedStatus *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.Pause(&_DelayedWithdrawalRouter.TransactOpts, newPausedStatus) +} + +// PauseAll is a paid mutator transaction binding the contract method 0x595c6a67. +// +// Solidity: function pauseAll() returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) PauseAll(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "pauseAll") +} + +// PauseAll is a paid mutator transaction binding the contract method 0x595c6a67. +// +// Solidity: function pauseAll() returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) PauseAll() (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.PauseAll(&_DelayedWithdrawalRouter.TransactOpts) +} + +// PauseAll is a paid mutator transaction binding the contract method 0x595c6a67. +// +// Solidity: function pauseAll() returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) PauseAll() (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.PauseAll(&_DelayedWithdrawalRouter.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) RenounceOwnership() (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.RenounceOwnership(&_DelayedWithdrawalRouter.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.RenounceOwnership(&_DelayedWithdrawalRouter.TransactOpts) +} + +// SetPauserRegistry is a paid mutator transaction binding the contract method 0x10d67a2f. +// +// Solidity: function setPauserRegistry(address newPauserRegistry) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) SetPauserRegistry(opts *bind.TransactOpts, newPauserRegistry common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "setPauserRegistry", newPauserRegistry) +} + +// SetPauserRegistry is a paid mutator transaction binding the contract method 0x10d67a2f. +// +// Solidity: function setPauserRegistry(address newPauserRegistry) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) SetPauserRegistry(newPauserRegistry common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.SetPauserRegistry(&_DelayedWithdrawalRouter.TransactOpts, newPauserRegistry) +} + +// SetPauserRegistry is a paid mutator transaction binding the contract method 0x10d67a2f. +// +// Solidity: function setPauserRegistry(address newPauserRegistry) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) SetPauserRegistry(newPauserRegistry common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.SetPauserRegistry(&_DelayedWithdrawalRouter.TransactOpts, newPauserRegistry) +} + +// SetWithdrawalDelayBlocks is a paid mutator transaction binding the contract method 0x4d50f9a4. +// +// Solidity: function setWithdrawalDelayBlocks(uint256 newValue) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) SetWithdrawalDelayBlocks(opts *bind.TransactOpts, newValue *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "setWithdrawalDelayBlocks", newValue) +} + +// SetWithdrawalDelayBlocks is a paid mutator transaction binding the contract method 0x4d50f9a4. +// +// Solidity: function setWithdrawalDelayBlocks(uint256 newValue) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) SetWithdrawalDelayBlocks(newValue *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.SetWithdrawalDelayBlocks(&_DelayedWithdrawalRouter.TransactOpts, newValue) +} + +// SetWithdrawalDelayBlocks is a paid mutator transaction binding the contract method 0x4d50f9a4. +// +// Solidity: function setWithdrawalDelayBlocks(uint256 newValue) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) SetWithdrawalDelayBlocks(newValue *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.SetWithdrawalDelayBlocks(&_DelayedWithdrawalRouter.TransactOpts, newValue) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.TransferOwnership(&_DelayedWithdrawalRouter.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.TransferOwnership(&_DelayedWithdrawalRouter.TransactOpts, newOwner) +} + +// Unpause is a paid mutator transaction binding the contract method 0xfabc1cbc. +// +// Solidity: function unpause(uint256 newPausedStatus) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactor) Unpause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.contract.Transact(opts, "unpause", newPausedStatus) +} + +// Unpause is a paid mutator transaction binding the contract method 0xfabc1cbc. +// +// Solidity: function unpause(uint256 newPausedStatus) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterSession) Unpause(newPausedStatus *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.Unpause(&_DelayedWithdrawalRouter.TransactOpts, newPausedStatus) +} + +// Unpause is a paid mutator transaction binding the contract method 0xfabc1cbc. +// +// Solidity: function unpause(uint256 newPausedStatus) returns() +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterTransactorSession) Unpause(newPausedStatus *big.Int) (*types.Transaction, error) { + return _DelayedWithdrawalRouter.Contract.Unpause(&_DelayedWithdrawalRouter.TransactOpts, newPausedStatus) +} + +// DelayedWithdrawalRouterDelayedWithdrawalCreatedIterator is returned from FilterDelayedWithdrawalCreated and is used to iterate over the raw logs and unpacked data for DelayedWithdrawalCreated events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterDelayedWithdrawalCreatedIterator struct { + Event *DelayedWithdrawalRouterDelayedWithdrawalCreated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterDelayedWithdrawalCreatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterDelayedWithdrawalCreated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterDelayedWithdrawalCreated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterDelayedWithdrawalCreatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterDelayedWithdrawalCreatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterDelayedWithdrawalCreated represents a DelayedWithdrawalCreated event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterDelayedWithdrawalCreated struct { + PodOwner common.Address + Recipient common.Address + Amount *big.Int + Index *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDelayedWithdrawalCreated is a free log retrieval operation binding the contract event 0xb8f1b14c7caf74150801dcc9bc18d575cbeaf5b421943497e409df92c92e0f59. +// +// Solidity: event DelayedWithdrawalCreated(address podOwner, address recipient, uint256 amount, uint256 index) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterDelayedWithdrawalCreated(opts *bind.FilterOpts) (*DelayedWithdrawalRouterDelayedWithdrawalCreatedIterator, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "DelayedWithdrawalCreated") + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterDelayedWithdrawalCreatedIterator{contract: _DelayedWithdrawalRouter.contract, event: "DelayedWithdrawalCreated", logs: logs, sub: sub}, nil +} + +// WatchDelayedWithdrawalCreated is a free log subscription operation binding the contract event 0xb8f1b14c7caf74150801dcc9bc18d575cbeaf5b421943497e409df92c92e0f59. +// +// Solidity: event DelayedWithdrawalCreated(address podOwner, address recipient, uint256 amount, uint256 index) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchDelayedWithdrawalCreated(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterDelayedWithdrawalCreated) (event.Subscription, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "DelayedWithdrawalCreated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterDelayedWithdrawalCreated) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "DelayedWithdrawalCreated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDelayedWithdrawalCreated is a log parse operation binding the contract event 0xb8f1b14c7caf74150801dcc9bc18d575cbeaf5b421943497e409df92c92e0f59. +// +// Solidity: event DelayedWithdrawalCreated(address podOwner, address recipient, uint256 amount, uint256 index) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParseDelayedWithdrawalCreated(log types.Log) (*DelayedWithdrawalRouterDelayedWithdrawalCreated, error) { + event := new(DelayedWithdrawalRouterDelayedWithdrawalCreated) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "DelayedWithdrawalCreated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DelayedWithdrawalRouterDelayedWithdrawalsClaimedIterator is returned from FilterDelayedWithdrawalsClaimed and is used to iterate over the raw logs and unpacked data for DelayedWithdrawalsClaimed events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterDelayedWithdrawalsClaimedIterator struct { + Event *DelayedWithdrawalRouterDelayedWithdrawalsClaimed // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterDelayedWithdrawalsClaimedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterDelayedWithdrawalsClaimed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterDelayedWithdrawalsClaimed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterDelayedWithdrawalsClaimedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterDelayedWithdrawalsClaimedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterDelayedWithdrawalsClaimed represents a DelayedWithdrawalsClaimed event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterDelayedWithdrawalsClaimed struct { + Recipient common.Address + AmountClaimed *big.Int + DelayedWithdrawalsCompleted *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDelayedWithdrawalsClaimed is a free log retrieval operation binding the contract event 0x6b7151500bd0b5cc211bcc47b3029831b769004df4549e8e1c9a69da05bb0943. +// +// Solidity: event DelayedWithdrawalsClaimed(address recipient, uint256 amountClaimed, uint256 delayedWithdrawalsCompleted) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterDelayedWithdrawalsClaimed(opts *bind.FilterOpts) (*DelayedWithdrawalRouterDelayedWithdrawalsClaimedIterator, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "DelayedWithdrawalsClaimed") + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterDelayedWithdrawalsClaimedIterator{contract: _DelayedWithdrawalRouter.contract, event: "DelayedWithdrawalsClaimed", logs: logs, sub: sub}, nil +} + +// WatchDelayedWithdrawalsClaimed is a free log subscription operation binding the contract event 0x6b7151500bd0b5cc211bcc47b3029831b769004df4549e8e1c9a69da05bb0943. +// +// Solidity: event DelayedWithdrawalsClaimed(address recipient, uint256 amountClaimed, uint256 delayedWithdrawalsCompleted) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchDelayedWithdrawalsClaimed(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterDelayedWithdrawalsClaimed) (event.Subscription, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "DelayedWithdrawalsClaimed") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterDelayedWithdrawalsClaimed) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "DelayedWithdrawalsClaimed", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDelayedWithdrawalsClaimed is a log parse operation binding the contract event 0x6b7151500bd0b5cc211bcc47b3029831b769004df4549e8e1c9a69da05bb0943. +// +// Solidity: event DelayedWithdrawalsClaimed(address recipient, uint256 amountClaimed, uint256 delayedWithdrawalsCompleted) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParseDelayedWithdrawalsClaimed(log types.Log) (*DelayedWithdrawalRouterDelayedWithdrawalsClaimed, error) { + event := new(DelayedWithdrawalRouterDelayedWithdrawalsClaimed) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "DelayedWithdrawalsClaimed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DelayedWithdrawalRouterInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterInitializedIterator struct { + Event *DelayedWithdrawalRouterInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterInitialized represents a Initialized event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterInitialized(opts *bind.FilterOpts) (*DelayedWithdrawalRouterInitializedIterator, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterInitializedIterator{contract: _DelayedWithdrawalRouter.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterInitialized) (event.Subscription, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterInitialized) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParseInitialized(log types.Log) (*DelayedWithdrawalRouterInitialized, error) { + event := new(DelayedWithdrawalRouterInitialized) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DelayedWithdrawalRouterOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterOwnershipTransferredIterator struct { + Event *DelayedWithdrawalRouterOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterOwnershipTransferred represents a OwnershipTransferred event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*DelayedWithdrawalRouterOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterOwnershipTransferredIterator{contract: _DelayedWithdrawalRouter.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterOwnershipTransferred) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParseOwnershipTransferred(log types.Log) (*DelayedWithdrawalRouterOwnershipTransferred, error) { + event := new(DelayedWithdrawalRouterOwnershipTransferred) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DelayedWithdrawalRouterPausedIterator is returned from FilterPaused and is used to iterate over the raw logs and unpacked data for Paused events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterPausedIterator struct { + Event *DelayedWithdrawalRouterPaused // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterPausedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterPaused) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterPaused) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterPausedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterPausedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterPaused represents a Paused event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterPaused struct { + Account common.Address + NewPausedStatus *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterPaused is a free log retrieval operation binding the contract event 0xab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d. +// +// Solidity: event Paused(address indexed account, uint256 newPausedStatus) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterPaused(opts *bind.FilterOpts, account []common.Address) (*DelayedWithdrawalRouterPausedIterator, error) { + + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "Paused", accountRule) + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterPausedIterator{contract: _DelayedWithdrawalRouter.contract, event: "Paused", logs: logs, sub: sub}, nil +} + +// WatchPaused is a free log subscription operation binding the contract event 0xab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d. +// +// Solidity: event Paused(address indexed account, uint256 newPausedStatus) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchPaused(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterPaused, account []common.Address) (event.Subscription, error) { + + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "Paused", accountRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterPaused) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "Paused", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParsePaused is a log parse operation binding the contract event 0xab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d. +// +// Solidity: event Paused(address indexed account, uint256 newPausedStatus) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParsePaused(log types.Log) (*DelayedWithdrawalRouterPaused, error) { + event := new(DelayedWithdrawalRouterPaused) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "Paused", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DelayedWithdrawalRouterPauserRegistrySetIterator is returned from FilterPauserRegistrySet and is used to iterate over the raw logs and unpacked data for PauserRegistrySet events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterPauserRegistrySetIterator struct { + Event *DelayedWithdrawalRouterPauserRegistrySet // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterPauserRegistrySetIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterPauserRegistrySet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterPauserRegistrySet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterPauserRegistrySetIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterPauserRegistrySetIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterPauserRegistrySet represents a PauserRegistrySet event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterPauserRegistrySet struct { + PauserRegistry common.Address + NewPauserRegistry common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterPauserRegistrySet is a free log retrieval operation binding the contract event 0x6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6. +// +// Solidity: event PauserRegistrySet(address pauserRegistry, address newPauserRegistry) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterPauserRegistrySet(opts *bind.FilterOpts) (*DelayedWithdrawalRouterPauserRegistrySetIterator, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "PauserRegistrySet") + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterPauserRegistrySetIterator{contract: _DelayedWithdrawalRouter.contract, event: "PauserRegistrySet", logs: logs, sub: sub}, nil +} + +// WatchPauserRegistrySet is a free log subscription operation binding the contract event 0x6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6. +// +// Solidity: event PauserRegistrySet(address pauserRegistry, address newPauserRegistry) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchPauserRegistrySet(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterPauserRegistrySet) (event.Subscription, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "PauserRegistrySet") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterPauserRegistrySet) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "PauserRegistrySet", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParsePauserRegistrySet is a log parse operation binding the contract event 0x6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6. +// +// Solidity: event PauserRegistrySet(address pauserRegistry, address newPauserRegistry) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParsePauserRegistrySet(log types.Log) (*DelayedWithdrawalRouterPauserRegistrySet, error) { + event := new(DelayedWithdrawalRouterPauserRegistrySet) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "PauserRegistrySet", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DelayedWithdrawalRouterUnpausedIterator is returned from FilterUnpaused and is used to iterate over the raw logs and unpacked data for Unpaused events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterUnpausedIterator struct { + Event *DelayedWithdrawalRouterUnpaused // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterUnpausedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterUnpaused) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterUnpaused) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterUnpausedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterUnpausedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterUnpaused represents a Unpaused event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterUnpaused struct { + Account common.Address + NewPausedStatus *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUnpaused is a free log retrieval operation binding the contract event 0x3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c. +// +// Solidity: event Unpaused(address indexed account, uint256 newPausedStatus) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterUnpaused(opts *bind.FilterOpts, account []common.Address) (*DelayedWithdrawalRouterUnpausedIterator, error) { + + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "Unpaused", accountRule) + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterUnpausedIterator{contract: _DelayedWithdrawalRouter.contract, event: "Unpaused", logs: logs, sub: sub}, nil +} + +// WatchUnpaused is a free log subscription operation binding the contract event 0x3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c. +// +// Solidity: event Unpaused(address indexed account, uint256 newPausedStatus) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchUnpaused(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterUnpaused, account []common.Address) (event.Subscription, error) { + + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "Unpaused", accountRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterUnpaused) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "Unpaused", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUnpaused is a log parse operation binding the contract event 0x3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c. +// +// Solidity: event Unpaused(address indexed account, uint256 newPausedStatus) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParseUnpaused(log types.Log) (*DelayedWithdrawalRouterUnpaused, error) { + event := new(DelayedWithdrawalRouterUnpaused) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "Unpaused", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DelayedWithdrawalRouterWithdrawalDelayBlocksSetIterator is returned from FilterWithdrawalDelayBlocksSet and is used to iterate over the raw logs and unpacked data for WithdrawalDelayBlocksSet events raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterWithdrawalDelayBlocksSetIterator struct { + Event *DelayedWithdrawalRouterWithdrawalDelayBlocksSet // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DelayedWithdrawalRouterWithdrawalDelayBlocksSetIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterWithdrawalDelayBlocksSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DelayedWithdrawalRouterWithdrawalDelayBlocksSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DelayedWithdrawalRouterWithdrawalDelayBlocksSetIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DelayedWithdrawalRouterWithdrawalDelayBlocksSetIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DelayedWithdrawalRouterWithdrawalDelayBlocksSet represents a WithdrawalDelayBlocksSet event raised by the DelayedWithdrawalRouter contract. +type DelayedWithdrawalRouterWithdrawalDelayBlocksSet struct { + PreviousValue *big.Int + NewValue *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterWithdrawalDelayBlocksSet is a free log retrieval operation binding the contract event 0x4ffb00400574147429ee377a5633386321e66d45d8b14676014b5fa393e61e9e. +// +// Solidity: event WithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) FilterWithdrawalDelayBlocksSet(opts *bind.FilterOpts) (*DelayedWithdrawalRouterWithdrawalDelayBlocksSetIterator, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.FilterLogs(opts, "WithdrawalDelayBlocksSet") + if err != nil { + return nil, err + } + return &DelayedWithdrawalRouterWithdrawalDelayBlocksSetIterator{contract: _DelayedWithdrawalRouter.contract, event: "WithdrawalDelayBlocksSet", logs: logs, sub: sub}, nil +} + +// WatchWithdrawalDelayBlocksSet is a free log subscription operation binding the contract event 0x4ffb00400574147429ee377a5633386321e66d45d8b14676014b5fa393e61e9e. +// +// Solidity: event WithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) WatchWithdrawalDelayBlocksSet(opts *bind.WatchOpts, sink chan<- *DelayedWithdrawalRouterWithdrawalDelayBlocksSet) (event.Subscription, error) { + + logs, sub, err := _DelayedWithdrawalRouter.contract.WatchLogs(opts, "WithdrawalDelayBlocksSet") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DelayedWithdrawalRouterWithdrawalDelayBlocksSet) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "WithdrawalDelayBlocksSet", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseWithdrawalDelayBlocksSet is a log parse operation binding the contract event 0x4ffb00400574147429ee377a5633386321e66d45d8b14676014b5fa393e61e9e. +// +// Solidity: event WithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue) +func (_DelayedWithdrawalRouter *DelayedWithdrawalRouterFilterer) ParseWithdrawalDelayBlocksSet(log types.Log) (*DelayedWithdrawalRouterWithdrawalDelayBlocksSet, error) { + event := new(DelayedWithdrawalRouterWithdrawalDelayBlocksSet) + if err := _DelayedWithdrawalRouter.contract.UnpackLog(event, "WithdrawalDelayBlocksSet", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/bindings/MagnitudeCheckpoints/binding.go b/pkg/bindings/MagnitudeCheckpoints/binding.go new file mode 100644 index 000000000..9a5a2ef52 --- /dev/null +++ b/pkg/bindings/MagnitudeCheckpoints/binding.go @@ -0,0 +1,203 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package MagnitudeCheckpoints + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// MagnitudeCheckpointsMetaData contains all meta data concerning the MagnitudeCheckpoints contract. +var MagnitudeCheckpointsMetaData = &bind.MetaData{ + ABI: "[]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d403c7152d652d1a100c83daf55d72392c025180800bf29f79d386c0af19a05d64736f6c634300080c0033", +} + +// MagnitudeCheckpointsABI is the input ABI used to generate the binding from. +// Deprecated: Use MagnitudeCheckpointsMetaData.ABI instead. +var MagnitudeCheckpointsABI = MagnitudeCheckpointsMetaData.ABI + +// MagnitudeCheckpointsBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use MagnitudeCheckpointsMetaData.Bin instead. +var MagnitudeCheckpointsBin = MagnitudeCheckpointsMetaData.Bin + +// DeployMagnitudeCheckpoints deploys a new Ethereum contract, binding an instance of MagnitudeCheckpoints to it. +func DeployMagnitudeCheckpoints(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *MagnitudeCheckpoints, error) { + parsed, err := MagnitudeCheckpointsMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(MagnitudeCheckpointsBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &MagnitudeCheckpoints{MagnitudeCheckpointsCaller: MagnitudeCheckpointsCaller{contract: contract}, MagnitudeCheckpointsTransactor: MagnitudeCheckpointsTransactor{contract: contract}, MagnitudeCheckpointsFilterer: MagnitudeCheckpointsFilterer{contract: contract}}, nil +} + +// MagnitudeCheckpoints is an auto generated Go binding around an Ethereum contract. +type MagnitudeCheckpoints struct { + MagnitudeCheckpointsCaller // Read-only binding to the contract + MagnitudeCheckpointsTransactor // Write-only binding to the contract + MagnitudeCheckpointsFilterer // Log filterer for contract events +} + +// MagnitudeCheckpointsCaller is an auto generated read-only Go binding around an Ethereum contract. +type MagnitudeCheckpointsCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MagnitudeCheckpointsTransactor is an auto generated write-only Go binding around an Ethereum contract. +type MagnitudeCheckpointsTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MagnitudeCheckpointsFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type MagnitudeCheckpointsFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MagnitudeCheckpointsSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type MagnitudeCheckpointsSession struct { + Contract *MagnitudeCheckpoints // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MagnitudeCheckpointsCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type MagnitudeCheckpointsCallerSession struct { + Contract *MagnitudeCheckpointsCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// MagnitudeCheckpointsTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type MagnitudeCheckpointsTransactorSession struct { + Contract *MagnitudeCheckpointsTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MagnitudeCheckpointsRaw is an auto generated low-level Go binding around an Ethereum contract. +type MagnitudeCheckpointsRaw struct { + Contract *MagnitudeCheckpoints // Generic contract binding to access the raw methods on +} + +// MagnitudeCheckpointsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type MagnitudeCheckpointsCallerRaw struct { + Contract *MagnitudeCheckpointsCaller // Generic read-only contract binding to access the raw methods on +} + +// MagnitudeCheckpointsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type MagnitudeCheckpointsTransactorRaw struct { + Contract *MagnitudeCheckpointsTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewMagnitudeCheckpoints creates a new instance of MagnitudeCheckpoints, bound to a specific deployed contract. +func NewMagnitudeCheckpoints(address common.Address, backend bind.ContractBackend) (*MagnitudeCheckpoints, error) { + contract, err := bindMagnitudeCheckpoints(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &MagnitudeCheckpoints{MagnitudeCheckpointsCaller: MagnitudeCheckpointsCaller{contract: contract}, MagnitudeCheckpointsTransactor: MagnitudeCheckpointsTransactor{contract: contract}, MagnitudeCheckpointsFilterer: MagnitudeCheckpointsFilterer{contract: contract}}, nil +} + +// NewMagnitudeCheckpointsCaller creates a new read-only instance of MagnitudeCheckpoints, bound to a specific deployed contract. +func NewMagnitudeCheckpointsCaller(address common.Address, caller bind.ContractCaller) (*MagnitudeCheckpointsCaller, error) { + contract, err := bindMagnitudeCheckpoints(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &MagnitudeCheckpointsCaller{contract: contract}, nil +} + +// NewMagnitudeCheckpointsTransactor creates a new write-only instance of MagnitudeCheckpoints, bound to a specific deployed contract. +func NewMagnitudeCheckpointsTransactor(address common.Address, transactor bind.ContractTransactor) (*MagnitudeCheckpointsTransactor, error) { + contract, err := bindMagnitudeCheckpoints(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &MagnitudeCheckpointsTransactor{contract: contract}, nil +} + +// NewMagnitudeCheckpointsFilterer creates a new log filterer instance of MagnitudeCheckpoints, bound to a specific deployed contract. +func NewMagnitudeCheckpointsFilterer(address common.Address, filterer bind.ContractFilterer) (*MagnitudeCheckpointsFilterer, error) { + contract, err := bindMagnitudeCheckpoints(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &MagnitudeCheckpointsFilterer{contract: contract}, nil +} + +// bindMagnitudeCheckpoints binds a generic wrapper to an already deployed contract. +func bindMagnitudeCheckpoints(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := MagnitudeCheckpointsMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MagnitudeCheckpoints *MagnitudeCheckpointsRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MagnitudeCheckpoints.Contract.MagnitudeCheckpointsCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MagnitudeCheckpoints *MagnitudeCheckpointsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MagnitudeCheckpoints.Contract.MagnitudeCheckpointsTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MagnitudeCheckpoints *MagnitudeCheckpointsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MagnitudeCheckpoints.Contract.MagnitudeCheckpointsTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MagnitudeCheckpoints *MagnitudeCheckpointsCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MagnitudeCheckpoints.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MagnitudeCheckpoints *MagnitudeCheckpointsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MagnitudeCheckpoints.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MagnitudeCheckpoints *MagnitudeCheckpointsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MagnitudeCheckpoints.Contract.contract.Transact(opts, method, params...) +} diff --git a/pkg/bindings/SlashingConstants/binding.go b/pkg/bindings/SlashingConstants/binding.go new file mode 100644 index 000000000..0a9cb4c71 --- /dev/null +++ b/pkg/bindings/SlashingConstants/binding.go @@ -0,0 +1,327 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package SlashingConstants + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// SlashingConstantsMetaData contains all meta data concerning the SlashingConstants contract. +var SlashingConstantsMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"function\",\"name\":\"DEALLOCATION_DELAY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"INITIAL_TOTAL_MAGNITUDE\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"PRECISION_FACTOR\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"PRECISION_FACTOR_SQUARED\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"}]", + Bin: "0x61010561003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060515760003560e01c806321afdf8e1460565780632981eb7714607e5780639a543ca414609b578063ccd34cd51460c1575b600080fd5b606b6ec097ce7bc90715b34b9f100000000081565b6040519081526020015b60405180910390f35b60876217124081565b60405163ffffffff90911681526020016075565b60a9670de0b6b3a764000081565b60405167ffffffffffffffff90911681526020016075565b606b670de0b6b3a76400008156fea264697066735822122051573b877db53ce7fd9202510ed740ac5b29774096c961210de6c69c249f537264736f6c634300080c0033", +} + +// SlashingConstantsABI is the input ABI used to generate the binding from. +// Deprecated: Use SlashingConstantsMetaData.ABI instead. +var SlashingConstantsABI = SlashingConstantsMetaData.ABI + +// SlashingConstantsBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use SlashingConstantsMetaData.Bin instead. +var SlashingConstantsBin = SlashingConstantsMetaData.Bin + +// DeploySlashingConstants deploys a new Ethereum contract, binding an instance of SlashingConstants to it. +func DeploySlashingConstants(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *SlashingConstants, error) { + parsed, err := SlashingConstantsMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(SlashingConstantsBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &SlashingConstants{SlashingConstantsCaller: SlashingConstantsCaller{contract: contract}, SlashingConstantsTransactor: SlashingConstantsTransactor{contract: contract}, SlashingConstantsFilterer: SlashingConstantsFilterer{contract: contract}}, nil +} + +// SlashingConstants is an auto generated Go binding around an Ethereum contract. +type SlashingConstants struct { + SlashingConstantsCaller // Read-only binding to the contract + SlashingConstantsTransactor // Write-only binding to the contract + SlashingConstantsFilterer // Log filterer for contract events +} + +// SlashingConstantsCaller is an auto generated read-only Go binding around an Ethereum contract. +type SlashingConstantsCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SlashingConstantsTransactor is an auto generated write-only Go binding around an Ethereum contract. +type SlashingConstantsTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SlashingConstantsFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SlashingConstantsFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SlashingConstantsSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type SlashingConstantsSession struct { + Contract *SlashingConstants // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SlashingConstantsCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type SlashingConstantsCallerSession struct { + Contract *SlashingConstantsCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// SlashingConstantsTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type SlashingConstantsTransactorSession struct { + Contract *SlashingConstantsTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SlashingConstantsRaw is an auto generated low-level Go binding around an Ethereum contract. +type SlashingConstantsRaw struct { + Contract *SlashingConstants // Generic contract binding to access the raw methods on +} + +// SlashingConstantsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SlashingConstantsCallerRaw struct { + Contract *SlashingConstantsCaller // Generic read-only contract binding to access the raw methods on +} + +// SlashingConstantsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SlashingConstantsTransactorRaw struct { + Contract *SlashingConstantsTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewSlashingConstants creates a new instance of SlashingConstants, bound to a specific deployed contract. +func NewSlashingConstants(address common.Address, backend bind.ContractBackend) (*SlashingConstants, error) { + contract, err := bindSlashingConstants(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &SlashingConstants{SlashingConstantsCaller: SlashingConstantsCaller{contract: contract}, SlashingConstantsTransactor: SlashingConstantsTransactor{contract: contract}, SlashingConstantsFilterer: SlashingConstantsFilterer{contract: contract}}, nil +} + +// NewSlashingConstantsCaller creates a new read-only instance of SlashingConstants, bound to a specific deployed contract. +func NewSlashingConstantsCaller(address common.Address, caller bind.ContractCaller) (*SlashingConstantsCaller, error) { + contract, err := bindSlashingConstants(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &SlashingConstantsCaller{contract: contract}, nil +} + +// NewSlashingConstantsTransactor creates a new write-only instance of SlashingConstants, bound to a specific deployed contract. +func NewSlashingConstantsTransactor(address common.Address, transactor bind.ContractTransactor) (*SlashingConstantsTransactor, error) { + contract, err := bindSlashingConstants(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &SlashingConstantsTransactor{contract: contract}, nil +} + +// NewSlashingConstantsFilterer creates a new log filterer instance of SlashingConstants, bound to a specific deployed contract. +func NewSlashingConstantsFilterer(address common.Address, filterer bind.ContractFilterer) (*SlashingConstantsFilterer, error) { + contract, err := bindSlashingConstants(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &SlashingConstantsFilterer{contract: contract}, nil +} + +// bindSlashingConstants binds a generic wrapper to an already deployed contract. +func bindSlashingConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := SlashingConstantsMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SlashingConstants *SlashingConstantsRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SlashingConstants.Contract.SlashingConstantsCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SlashingConstants *SlashingConstantsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SlashingConstants.Contract.SlashingConstantsTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SlashingConstants *SlashingConstantsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SlashingConstants.Contract.SlashingConstantsTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SlashingConstants *SlashingConstantsCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SlashingConstants.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SlashingConstants *SlashingConstantsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SlashingConstants.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SlashingConstants *SlashingConstantsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SlashingConstants.Contract.contract.Transact(opts, method, params...) +} + +// DEALLOCATIONDELAY is a free data retrieval call binding the contract method 0x2981eb77. +// +// Solidity: function DEALLOCATION_DELAY() view returns(uint32) +func (_SlashingConstants *SlashingConstantsCaller) DEALLOCATIONDELAY(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _SlashingConstants.contract.Call(opts, &out, "DEALLOCATION_DELAY") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// DEALLOCATIONDELAY is a free data retrieval call binding the contract method 0x2981eb77. +// +// Solidity: function DEALLOCATION_DELAY() view returns(uint32) +func (_SlashingConstants *SlashingConstantsSession) DEALLOCATIONDELAY() (uint32, error) { + return _SlashingConstants.Contract.DEALLOCATIONDELAY(&_SlashingConstants.CallOpts) +} + +// DEALLOCATIONDELAY is a free data retrieval call binding the contract method 0x2981eb77. +// +// Solidity: function DEALLOCATION_DELAY() view returns(uint32) +func (_SlashingConstants *SlashingConstantsCallerSession) DEALLOCATIONDELAY() (uint32, error) { + return _SlashingConstants.Contract.DEALLOCATIONDELAY(&_SlashingConstants.CallOpts) +} + +// INITIALTOTALMAGNITUDE is a free data retrieval call binding the contract method 0x9a543ca4. +// +// Solidity: function INITIAL_TOTAL_MAGNITUDE() view returns(uint64) +func (_SlashingConstants *SlashingConstantsCaller) INITIALTOTALMAGNITUDE(opts *bind.CallOpts) (uint64, error) { + var out []interface{} + err := _SlashingConstants.contract.Call(opts, &out, "INITIAL_TOTAL_MAGNITUDE") + + if err != nil { + return *new(uint64), err + } + + out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + + return out0, err + +} + +// INITIALTOTALMAGNITUDE is a free data retrieval call binding the contract method 0x9a543ca4. +// +// Solidity: function INITIAL_TOTAL_MAGNITUDE() view returns(uint64) +func (_SlashingConstants *SlashingConstantsSession) INITIALTOTALMAGNITUDE() (uint64, error) { + return _SlashingConstants.Contract.INITIALTOTALMAGNITUDE(&_SlashingConstants.CallOpts) +} + +// INITIALTOTALMAGNITUDE is a free data retrieval call binding the contract method 0x9a543ca4. +// +// Solidity: function INITIAL_TOTAL_MAGNITUDE() view returns(uint64) +func (_SlashingConstants *SlashingConstantsCallerSession) INITIALTOTALMAGNITUDE() (uint64, error) { + return _SlashingConstants.Contract.INITIALTOTALMAGNITUDE(&_SlashingConstants.CallOpts) +} + +// PRECISIONFACTOR is a free data retrieval call binding the contract method 0xccd34cd5. +// +// Solidity: function PRECISION_FACTOR() view returns(uint256) +func (_SlashingConstants *SlashingConstantsCaller) PRECISIONFACTOR(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SlashingConstants.contract.Call(opts, &out, "PRECISION_FACTOR") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PRECISIONFACTOR is a free data retrieval call binding the contract method 0xccd34cd5. +// +// Solidity: function PRECISION_FACTOR() view returns(uint256) +func (_SlashingConstants *SlashingConstantsSession) PRECISIONFACTOR() (*big.Int, error) { + return _SlashingConstants.Contract.PRECISIONFACTOR(&_SlashingConstants.CallOpts) +} + +// PRECISIONFACTOR is a free data retrieval call binding the contract method 0xccd34cd5. +// +// Solidity: function PRECISION_FACTOR() view returns(uint256) +func (_SlashingConstants *SlashingConstantsCallerSession) PRECISIONFACTOR() (*big.Int, error) { + return _SlashingConstants.Contract.PRECISIONFACTOR(&_SlashingConstants.CallOpts) +} + +// PRECISIONFACTORSQUARED is a free data retrieval call binding the contract method 0x21afdf8e. +// +// Solidity: function PRECISION_FACTOR_SQUARED() view returns(uint256) +func (_SlashingConstants *SlashingConstantsCaller) PRECISIONFACTORSQUARED(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SlashingConstants.contract.Call(opts, &out, "PRECISION_FACTOR_SQUARED") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PRECISIONFACTORSQUARED is a free data retrieval call binding the contract method 0x21afdf8e. +// +// Solidity: function PRECISION_FACTOR_SQUARED() view returns(uint256) +func (_SlashingConstants *SlashingConstantsSession) PRECISIONFACTORSQUARED() (*big.Int, error) { + return _SlashingConstants.Contract.PRECISIONFACTORSQUARED(&_SlashingConstants.CallOpts) +} + +// PRECISIONFACTORSQUARED is a free data retrieval call binding the contract method 0x21afdf8e. +// +// Solidity: function PRECISION_FACTOR_SQUARED() view returns(uint256) +func (_SlashingConstants *SlashingConstantsCallerSession) PRECISIONFACTORSQUARED() (*big.Int, error) { + return _SlashingConstants.Contract.PRECISIONFACTORSQUARED(&_SlashingConstants.CallOpts) +} diff --git a/script/configs/devnet/deploy_from_scratch.anvil.config.json b/script/configs/devnet/deploy_from_scratch.anvil.config.json new file mode 100644 index 000000000..96df127e1 --- /dev/null +++ b/script/configs/devnet/deploy_from_scratch.anvil.config.json @@ -0,0 +1,55 @@ +{ + "maintainer": "samlaf@eigenlabs.org", + "multisig_addresses": { + "operationsMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "communityMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "pauserMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "executorMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "timelock": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + }, + "strategies": [ + { + "token_address": "0x0000000000000000000000000000000000000000", + "token_symbol": "WETH", + "max_per_deposit": 115792089237316195423570985008687907853269984665640564039457584007913129639935, + "max_deposits": 115792089237316195423570985008687907853269984665640564039457584007913129639935 + } + ], + "strategyManager": { + "init_paused_status": 0, + "init_withdrawal_delay_blocks": 1 + }, + "eigenPod": { + "PARTIAL_WITHDRAWAL_FRAUD_PROOF_PERIOD_BLOCKS": 1, + "MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR": "32000000000" + }, + "eigenPodManager": { + "init_paused_status": 30 + }, + "delayedWithdrawalRouter": { + "init_paused_status": 0, + "init_withdrawal_delay_blocks": 1 + }, + "slasher": { + "init_paused_status": 0 + }, + "delegation": { + "init_paused_status": 0, + "init_withdrawal_delay_blocks": 1 + }, + "rewardsCoordinator": { + "init_paused_status": 0, + "CALCULATION_INTERVAL_SECONDS": 604800, + "MAX_REWARDS_DURATION": 6048000, + "MAX_RETROACTIVE_LENGTH": 7776000, + "MAX_FUTURE_LENGTH": 2592000, + "GENESIS_REWARDS_TIMESTAMP": 1710979200, + "rewards_updater_address": "0x18a0f92Ad9645385E8A8f3db7d0f6CF7aBBb0aD4", + "activation_delay": 7200, + "calculation_interval_seconds": 604800, + "global_operator_commission_bips": 1000, + "OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP": 1720656000, + "OPERATOR_SET_MAX_RETROACTIVE_LENGTH": 2592000 + }, + "ethPOSDepositAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa" +} \ No newline at end of file diff --git a/script/configs/devnet/deploy_from_scratch.holesky.config.json b/script/configs/devnet/deploy_from_scratch.holesky.config.json new file mode 100644 index 000000000..3dc1f204d --- /dev/null +++ b/script/configs/devnet/deploy_from_scratch.holesky.config.json @@ -0,0 +1,55 @@ +{ + "maintainer": "samlaf@eigenlabs.org", + "multisig_addresses": { + "operationsMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479", + "communityMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479", + "pauserMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479", + "executorMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479", + "timelock": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479" + }, + "strategies": [ + { + "token_address": "0x0000000000000000000000000000000000000000", + "token_symbol": "WETH", + "max_per_deposit": 115792089237316195423570985008687907853269984665640564039457584007913129639935, + "max_deposits": 115792089237316195423570985008687907853269984665640564039457584007913129639935 + } + ], + "strategyManager": { + "init_paused_status": 0, + "init_withdrawal_delay_blocks": 1 + }, + "eigenPod": { + "PARTIAL_WITHDRAWAL_FRAUD_PROOF_PERIOD_BLOCKS": 1, + "MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR": "32000000000" + }, + "eigenPodManager": { + "init_paused_status": 30 + }, + "delayedWithdrawalRouter": { + "init_paused_status": 0, + "init_withdrawal_delay_blocks": 1 + }, + "slasher": { + "init_paused_status": 0 + }, + "delegation": { + "init_paused_status": 0, + "init_withdrawal_delay_blocks": 1 + }, + "rewardsCoordinator": { + "init_paused_status": 0, + "CALCULATION_INTERVAL_SECONDS": 604800, + "MAX_REWARDS_DURATION": 6048000, + "MAX_RETROACTIVE_LENGTH": 7776000, + "MAX_FUTURE_LENGTH": 2592000, + "GENESIS_REWARDS_TIMESTAMP": 1710979200, + "rewards_updater_address": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479", + "activation_delay": 7200, + "calculation_interval_seconds": 604800, + "global_operator_commission_bips": 1000, + "OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP": 1720656000, + "OPERATOR_SET_MAX_RETROACTIVE_LENGTH": 2592000 + }, + "ethPOSDepositAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa" +} \ No newline at end of file diff --git a/script/configs/holesky/Deploy_RewardsCoordinator.holesky.config.json b/script/configs/holesky/Deploy_RewardsCoordinator.holesky.config.json new file mode 100644 index 000000000..ecd86e029 --- /dev/null +++ b/script/configs/holesky/Deploy_RewardsCoordinator.holesky.config.json @@ -0,0 +1,60 @@ +{ + "chainInfo": { + "chainId": 17000 + }, + "multisig_addresses": { + "pauserMultisig": "0x53410249ec7d3a3F9F1ba3912D50D6A3Df6d10A7", + "communityMultisig": "0xCb8d2f9e55Bc7B1FA9d089f9aC80C583D2BDD5F7", + "operationsMultisig": "0xfaEF7338b7490b9E272d80A1a39f4657cAf2b97d", + "executorMultisig": "0x28Ade60640fdBDb2609D8d8734D1b5cBeFc0C348", + "timelock": "0xcF19CE0561052a7A7Ff21156730285997B350A7D" + }, + "strategies": { + "numStrategies": 0, + "MAX_PER_DEPOSIT": 115792089237316195423570985008687907853269984665640564039457584007913129639935, + "MAX_TOTAL_DEPOSITS": 115792089237316195423570985008687907853269984665640564039457584007913129639935, + "strategiesToDeploy": [] + }, + "strategyManager": { + "init_strategy_whitelister": "0x28Ade60640fdBDb2609D8d8734D1b5cBeFc0C348", + "init_paused_status": 0 + }, + "delegationManager": { + "init_paused_status": 0, + "init_minWithdrawalDelayBlocks": 10 + }, + "rewardsCoordinator": { + "init_paused_status": 0, + "CALCULATION_INTERVAL_SECONDS": 604800, + "MAX_REWARDS_DURATION": 6048000, + "MAX_RETROACTIVE_LENGTH": 7776000, + "MAX_FUTURE_LENGTH": 2592000, + "GENESIS_REWARDS_TIMESTAMP": 1710979200, + "rewards_updater_address": "0x18a0f92Ad9645385E8A8f3db7d0f6CF7aBBb0aD4", + "activation_delay": 7200, + "calculation_interval_seconds": 604800, + "global_operator_commission_bips": 1000, + "OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP": 1720656000, + "OPERATOR_SET_MAX_RETROACTIVE_LENGTH": 2592000 + }, + "avsDirectory": { + "init_paused_status": 0 + }, + "slasher": { + "init_paused_status": 0 + }, + "eigenPod": { + "MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR": 32000000000, + "GENESIS_TIME": 1695902400 + }, + "eigenPodManager": { + "init_paused_status": 0, + "deneb_fork_timestamp": "1707305664" + }, + "delayedWithdrawalRouter": { + "init_paused_status": 0, + "init_withdrawalDelayBlocks": 10 + }, + "ethPOSDepositAddress": "0x4242424242424242424242424242424242424242", + "beaconOracleAddress": "0x4C116BB629bff7A8373c2378bBd919f8349B8f25" +} \ No newline at end of file diff --git a/script/configs/local/deploy_from_scratch.anvil.config.json b/script/configs/local/deploy_from_scratch.anvil.config.json index 96df127e1..ead0a948c 100644 --- a/script/configs/local/deploy_from_scratch.anvil.config.json +++ b/script/configs/local/deploy_from_scratch.anvil.config.json @@ -51,5 +51,10 @@ "OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP": 1720656000, "OPERATOR_SET_MAX_RETROACTIVE_LENGTH": 2592000 }, + "allocationManager": { + "init_paused_status": 0, + "DEALLOCATION_DELAY": 900, + "ALLOCATION_DELAY_CONFIGURATION_DELAY": 1200 + }, "ethPOSDepositAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa" } \ No newline at end of file diff --git a/script/deploy/devnet/Upgrade.s.sol b/script/deploy/devnet/Upgrade.s.sol new file mode 100644 index 000000000..35a5ce9b3 --- /dev/null +++ b/script/deploy/devnet/Upgrade.s.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.27; + +import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol"; +import "../../utils/ExistingDeploymentParser.sol"; + +// # To load the variables in the .env file +// source .env + +// Generic upgrade script, DOES NOT UPDATE IMPLEMENTATION IN OUTPUT FILE +// forge script script/deploy/devnet/Upgrade.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY +contract Upgrade is ExistingDeploymentParser { + + function run() external { + // EDIT this for your script + _parseDeployedContracts("script/output/holesky/pre_preprod_slashing.holesky.json"); + + vm.startBroadcast(); + AVSDirectory newAVSDirectoryImplementation = new AVSDirectory(delegationManager, DEALLOCATION_DELAY); + eigenLayerProxyAdmin.upgrade(ITransparentUpgradeableProxy(payable(address(avsDirectory))), address(newAVSDirectoryImplementation)); + vm.stopBroadcast(); + + } +} \ No newline at end of file diff --git a/script/deploy/holesky/Eigen_Strategy_Deploy.s.sol b/script/deploy/holesky/Eigen_Strategy_Deploy.s.sol index 08123d3aa..c88c766f9 100644 --- a/script/deploy/holesky/Eigen_Strategy_Deploy.s.sol +++ b/script/deploy/holesky/Eigen_Strategy_Deploy.s.sol @@ -58,11 +58,9 @@ contract Eigen_Strategy_Deploy is ExistingDeploymentParser { function _verifyDeployment() internal { IStrategy[] memory strategies = new IStrategy[](1); strategies[0] = eigenStrategy; - bool[] memory thirdPartyTransfersForbiddenValues = new bool[](1); - thirdPartyTransfersForbiddenValues[0] = true; vm.prank(executorMultisig); - strategyManager.addStrategiesToDepositWhitelist(strategies, thirdPartyTransfersForbiddenValues); + strategyManager.addStrategiesToDepositWhitelist(strategies); vm.startPrank(msg.sender); EIGEN.approve(address(strategyManager), type(uint256).max); diff --git a/script/deploy/holesky/M2_Deploy_From_Scratch.s.sol b/script/deploy/holesky/M2_Deploy_From_Scratch.s.sol index bab821a58..6a6bb0a10 100644 --- a/script/deploy/holesky/M2_Deploy_From_Scratch.s.sol +++ b/script/deploy/holesky/M2_Deploy_From_Scratch.s.sol @@ -61,12 +61,13 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser { strategyManager = StrategyManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); - slasher = Slasher( + eigenPodManager = EigenPodManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); - eigenPodManager = EigenPodManager( + allocationManager = AllocationManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); + // Deploy EigenPod Contracts eigenPodImplementation = new EigenPod( IETHPOSDeposit(ETHPOSDepositAddress), @@ -75,17 +76,16 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser { ); eigenPodBeacon = new UpgradeableBeacon(address(eigenPodImplementation)); - avsDirectoryImplementation = new AVSDirectory(delegationManager); - delegationManagerImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager, slasher); - slasherImplementation = new Slasher(strategyManager, delegationManager); + avsDirectoryImplementation = new AVSDirectory(delegationManager, DEALLOCATION_DELAY); + delegationManagerImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, MIN_WITHDRAWAL_DELAY); + strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager, avsDirectory); eigenPodManagerImplementation = new EigenPodManager( IETHPOSDeposit(ETHPOSDepositAddress), eigenPodBeacon, strategyManager, - slasher, delegationManager ); + allocationManagerImplementation = new AllocationManager(delegationManager, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_DELAY_CONFIGURATION_DELAY); // Third, upgrade the proxy contracts to point to the implementations IStrategy[] memory initializeStrategiesToSetDelayBlocks = new IStrategy[](0); @@ -127,17 +127,6 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser { STRATEGY_MANAGER_INIT_PAUSED_STATUS ) ); - // Slasher - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation), - abi.encodeWithSelector( - Slasher.initialize.selector, - executorMultisig, - eigenLayerPauserReg, - SLASHER_INIT_PAUSED_STATUS - ) - ); // EigenPodManager eigenLayerProxyAdmin.upgradeAndCall( ITransparentUpgradeableProxy(payable(address(eigenPodManager))), @@ -149,13 +138,23 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser { EIGENPOD_MANAGER_INIT_PAUSED_STATUS ) ); + // AllocationManager + eigenLayerProxyAdmin.upgradeAndCall( + ITransparentUpgradeableProxy(payable(address(allocationManager))), + address(allocationManagerImplementation), + abi.encodeWithSelector( + AllocationManager.initialize.selector, + msg.sender, // initialOwner is msg.sender for now to set forktimestamp later + eigenLayerPauserReg, + ALLOCATION_MANAGER_INIT_PAUSED_STATUS + ) + ); // Deploy Strategies baseStrategyImplementation = new StrategyBaseTVLLimits(strategyManager); uint256 numStrategiesToDeploy = strategiesToDeploy.length; // whitelist params IStrategy[] memory strategiesToWhitelist = new IStrategy[](numStrategiesToDeploy); - bool[] memory thirdPartyTransfersForbiddenValues = new bool[](numStrategiesToDeploy); for (uint256 i = 0; i < numStrategiesToDeploy; i++) { StrategyUnderlyingTokenConfig memory strategyConfig = strategiesToDeploy[i]; @@ -177,13 +176,12 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser { ); strategiesToWhitelist[i] = strategy; - thirdPartyTransfersForbiddenValues[i] = false; deployedStrategyArray.push(strategy); } // Add strategies to whitelist and set whitelister to STRATEGY_MANAGER_WHITELISTER - strategyManager.addStrategiesToDepositWhitelist(strategiesToWhitelist, thirdPartyTransfersForbiddenValues); + strategyManager.addStrategiesToDepositWhitelist(strategiesToWhitelist); strategyManager.setStrategyWhitelister(STRATEGY_MANAGER_WHITELISTER); // Transfer ownership diff --git a/script/deploy/holesky/v040-holesky-pepe.s.sol b/script/deploy/holesky/v040-holesky-pepe.s.sol index 7e7bf5d12..4ce3bc7e3 100644 --- a/script/deploy/holesky/v040-holesky-pepe.s.sol +++ b/script/deploy/holesky/v040-holesky-pepe.s.sol @@ -33,7 +33,6 @@ contract PEPE_Deploy_Preprod is ExistingDeploymentParser { emit log_named_address("- epm.ethPOS", address(eigenPodManagerImplementation.ethPOS())); emit log_named_address("- epm.eigenPodBeacon", address(eigenPodManagerImplementation.eigenPodBeacon())); emit log_named_address("- epm.strategyManager", address(eigenPodManagerImplementation.strategyManager())); - emit log_named_address("- epm.slasher", address(eigenPodManagerImplementation.slasher())); emit log_named_address("- epm.delegationManager", address(eigenPodManagerImplementation.delegationManager())); // START RECORDING TRANSACTIONS FOR DEPLOYMENT @@ -60,7 +59,6 @@ contract PEPE_Deploy_Preprod is ExistingDeploymentParser { IETHPOSDeposit(ETHPOSDepositAddress), eigenPodBeacon, strategyManager, - slasher, delegationManager ); } diff --git a/script/deploy/local/Deploy_From_Scratch.s.sol b/script/deploy/local/Deploy_From_Scratch.s.sol index 7a046d839..5efb6134a 100644 --- a/script/deploy/local/Deploy_From_Scratch.s.sol +++ b/script/deploy/local/Deploy_From_Scratch.s.sol @@ -9,10 +9,10 @@ import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import "../../../src/contracts/interfaces/IETHPOSDeposit.sol"; import "../../../src/contracts/core/StrategyManager.sol"; -import "../../../src/contracts/core/Slasher.sol"; import "../../../src/contracts/core/DelegationManager.sol"; import "../../../src/contracts/core/AVSDirectory.sol"; import "../../../src/contracts/core/RewardsCoordinator.sol"; +import "../../../src/contracts/core/AllocationManager.sol"; import "../../../src/contracts/strategies/StrategyBaseTVLLimits.sol"; @@ -31,7 +31,7 @@ import "forge-std/Test.sol"; // source .env // # To deploy and verify our contract -// RUST_LOG=forge,foundry=trace forge script script/deploy/local/Deploy_From_Scratch.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --sig "run(string memory configFile)" -- local/deploy_from_scratch.anvil.config.json +// forge script script/deploy/local/Deploy_From_Scratch.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --sig "run(string memory configFile)" -- local/deploy_from_scratch.anvil.config.json contract DeployFromScratch is Script, Test { Vm cheats = Vm(HEVM_ADDRESS); @@ -48,8 +48,6 @@ contract DeployFromScratch is Script, Test { // EigenLayer Contracts ProxyAdmin public eigenLayerProxyAdmin; PauserRegistry public eigenLayerPauserReg; - Slasher public slasher; - Slasher public slasherImplementation; DelegationManager public delegation; DelegationManager public delegationImplementation; StrategyManager public strategyManager; @@ -63,6 +61,8 @@ contract DeployFromScratch is Script, Test { UpgradeableBeacon public eigenPodBeacon; EigenPod public eigenPodImplementation; StrategyBase public baseStrategyImplementation; + AllocationManager public allocationManagerImplementation; + AllocationManager public allocationManager; EmptyContract public emptyContract; @@ -81,11 +81,17 @@ contract DeployFromScratch is Script, Test { // OTHER DEPLOYMENT PARAMETERS uint256 STRATEGY_MANAGER_INIT_PAUSED_STATUS; - uint256 SLASHER_INIT_PAUSED_STATUS; uint256 DELEGATION_INIT_PAUSED_STATUS; uint256 EIGENPOD_MANAGER_INIT_PAUSED_STATUS; uint256 REWARDS_COORDINATOR_INIT_PAUSED_STATUS; + // DelegationManager + uint32 MIN_WITHDRAWAL_DELAY; + + // AllocationManager + uint32 DEALLOCATION_DELAY; + uint32 ALLOCATION_DELAY_CONFIGURATION_DELAY; + // RewardsCoordinator uint32 REWARDS_COORDINATOR_MAX_REWARDS_DURATION; uint32 REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH; @@ -98,6 +104,9 @@ contract DeployFromScratch is Script, Test { uint32 REWARDS_COORDINATOR_OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP; uint32 REWARDS_COORDINATOR_OPERATOR_SET_MAX_RETROACTIVE_LENGTH; + // AllocationManager + uint256 ALLOCATION_MANAGER_INIT_PAUSED_STATUS; + // one week in blocks -- 50400 uint32 STRATEGY_MANAGER_INIT_WITHDRAWAL_DELAY_BLOCKS; uint256 DELEGATION_WITHDRAWAL_DELAY_BLOCKS; @@ -113,7 +122,6 @@ contract DeployFromScratch is Script, Test { // bytes memory parsedData = vm.parseJson(config_data); STRATEGY_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".strategyManager.init_paused_status"); - SLASHER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".slasher.init_paused_status"); DELEGATION_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".delegation.init_paused_status"); DELEGATION_WITHDRAWAL_DELAY_BLOCKS = stdJson.readUint(config_data, ".delegation.init_withdrawal_delay_blocks"); EIGENPOD_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".eigenPodManager.init_paused_status"); @@ -147,6 +155,16 @@ contract DeployFromScratch is Script, Test { stdJson.readUint(config_data, ".strategyManager.init_withdrawal_delay_blocks") ); + ALLOCATION_MANAGER_INIT_PAUSED_STATUS = uint32( + stdJson.readUint(config_data, ".allocationManager.init_paused_status") + ); + DEALLOCATION_DELAY = uint32( + stdJson.readUint(config_data, ".allocationManager.DEALLOCATION_DELAY") + ); + ALLOCATION_DELAY_CONFIGURATION_DELAY = uint32( + stdJson.readUint(config_data, ".allocationManager.ALLOCATION_DELAY_CONFIGURATION_DELAY") + ); + // tokens to deploy strategies for StrategyConfig[] memory strategyConfigs; @@ -189,15 +207,15 @@ contract DeployFromScratch is Script, Test { avsDirectory = AVSDirectory( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); - slasher = Slasher( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); eigenPodManager = EigenPodManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); rewardsCoordinator = RewardsCoordinator( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); + allocationManager = AllocationManager( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); // if on mainnet, use the ETH2 deposit contract address if (chainId == 1) { @@ -215,15 +233,14 @@ contract DeployFromScratch is Script, Test { eigenPodBeacon = new UpgradeableBeacon(address(eigenPodImplementation)); // Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs - delegationImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager, slasher); - avsDirectoryImplementation = new AVSDirectory(delegation); - slasherImplementation = new Slasher(strategyManager, delegation); + + delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, MIN_WITHDRAWAL_DELAY); + strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager, avsDirectory); + avsDirectoryImplementation = new AVSDirectory(delegation, DEALLOCATION_DELAY); eigenPodManagerImplementation = new EigenPodManager( ethPOSDeposit, eigenPodBeacon, strategyManager, - slasher, delegation ); rewardsCoordinatorImplementation = new RewardsCoordinator( @@ -235,6 +252,7 @@ contract DeployFromScratch is Script, Test { REWARDS_COORDINATOR_MAX_FUTURE_LENGTH, REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP ); + allocationManagerImplementation = new AllocationManager(delegation, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_DELAY_CONFIGURATION_DELAY); // Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them. { @@ -265,16 +283,6 @@ contract DeployFromScratch is Script, Test { STRATEGY_MANAGER_INIT_PAUSED_STATUS ) ); - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation), - abi.encodeWithSelector( - Slasher.initialize.selector, - executorMultisig, - eigenLayerPauserReg, - SLASHER_INIT_PAUSED_STATUS - ) - ); eigenLayerProxyAdmin.upgradeAndCall( ITransparentUpgradeableProxy(payable(address(avsDirectory))), address(avsDirectoryImplementation), @@ -304,6 +312,17 @@ contract DeployFromScratch is Script, Test { ) ); + eigenLayerProxyAdmin.upgradeAndCall( + ITransparentUpgradeableProxy(payable(address(allocationManager))), + address(allocationManagerImplementation), + abi.encodeWithSelector( + AllocationManager.initialize.selector, + executorMultisig, + eigenLayerPauserReg, + ALLOCATION_MANAGER_INIT_PAUSED_STATUS + ) + ); + // deploy StrategyBaseTVLLimits contract implementation baseStrategyImplementation = new StrategyBaseTVLLimits(strategyManager); // create upgradeable proxies that each point to the implementation and initialize them @@ -340,14 +359,12 @@ contract DeployFromScratch is Script, Test { _verifyContractsPointAtOneAnother( delegationImplementation, strategyManagerImplementation, - slasherImplementation, eigenPodManagerImplementation, rewardsCoordinatorImplementation ); _verifyContractsPointAtOneAnother( delegation, strategyManager, - slasher, eigenPodManager, rewardsCoordinator ); @@ -375,12 +392,12 @@ contract DeployFromScratch is Script, Test { vm.serializeUint(deployed_addresses, "numStrategiesDeployed", 0); // for compatibility with other scripts vm.serializeAddress(deployed_addresses, "eigenLayerProxyAdmin", address(eigenLayerProxyAdmin)); vm.serializeAddress(deployed_addresses, "eigenLayerPauserReg", address(eigenLayerPauserReg)); - vm.serializeAddress(deployed_addresses, "slasher", address(slasher)); - vm.serializeAddress(deployed_addresses, "slasherImplementation", address(slasherImplementation)); vm.serializeAddress(deployed_addresses, "delegationManager", address(delegation)); vm.serializeAddress(deployed_addresses, "delegationManagerImplementation", address(delegationImplementation)); vm.serializeAddress(deployed_addresses, "avsDirectory", address(avsDirectory)); vm.serializeAddress(deployed_addresses, "avsDirectoryImplementation", address(avsDirectoryImplementation)); + vm.serializeAddress(deployed_addresses, "allocationManager", address(allocationManager)); + vm.serializeAddress(deployed_addresses, "allocationManagerImplementation", address(allocationManagerImplementation)); vm.serializeAddress(deployed_addresses, "strategyManager", address(strategyManager)); vm.serializeAddress( deployed_addresses, @@ -433,29 +450,20 @@ contract DeployFromScratch is Script, Test { string memory finalJson = vm.serializeString(parent_object, parameters, parameters_output); // TODO: should output to different file depending on configFile passed to run() // so that we don't override mainnet output by deploying to goerli for eg. - vm.writeJson(finalJson, "script/output/devnet/local_from_scratch_deployment_data.json"); - - // generate + write eigenpods to file - address podAddress = eigenPodManager.createPod(); - string memory eigenpodStruct = "eigenpodStruct"; - string memory json = vm.serializeAddress(eigenpodStruct, "podAddress", podAddress); - vm.writeJson(json, "script/output/eigenpods.json"); + vm.writeJson(finalJson, "script/output/devnet/M2_from_scratch_deployment_data.json"); } function _verifyContractsPointAtOneAnother( DelegationManager delegationContract, StrategyManager strategyManagerContract, - Slasher /*slasherContract*/, EigenPodManager eigenPodManagerContract, RewardsCoordinator rewardsCoordinatorContract ) internal view { - require(delegationContract.slasher() == slasher, "delegation: slasher address not set correctly"); require( delegationContract.strategyManager() == strategyManager, "delegation: strategyManager address not set correctly" ); - require(strategyManagerContract.slasher() == slasher, "strategyManager: slasher address not set correctly"); require( strategyManagerContract.delegation() == delegation, "strategyManager: delegation address not set correctly" @@ -464,11 +472,6 @@ contract DeployFromScratch is Script, Test { strategyManagerContract.eigenPodManager() == eigenPodManager, "strategyManager: eigenPodManager address not set correctly" ); - - // removing slasher requirements because there is no slasher as part of m2-mainnet release - // require(slasherContract.strategyManager() == strategyManager, "slasher: strategyManager not set correctly"); - // require(slasherContract.delegation() == delegation, "slasher: delegation not set correctly"); - require( eigenPodManagerContract.ethPOS() == ethPOSDeposit, " eigenPodManager: ethPOSDeposit contract address not set correctly" @@ -481,10 +484,6 @@ contract DeployFromScratch is Script, Test { eigenPodManagerContract.strategyManager() == strategyManager, "eigenPodManager: strategyManager contract address not set correctly" ); - require( - eigenPodManagerContract.slasher() == slasher, - "eigenPodManager: slasher contract address not set correctly" - ); require( rewardsCoordinatorContract.delegationManager() == delegation, @@ -509,11 +508,6 @@ contract DeployFromScratch is Script, Test { ) == address(strategyManagerImplementation), "strategyManager: implementation set incorrectly" ); - require( - eigenLayerProxyAdmin.getProxyImplementation(ITransparentUpgradeableProxy(payable(address(slasher)))) == - address(slasherImplementation), - "slasher: implementation set incorrectly" - ); require( eigenLayerProxyAdmin.getProxyImplementation( ITransparentUpgradeableProxy(payable(address(eigenPodManager))) @@ -527,6 +521,13 @@ contract DeployFromScratch is Script, Test { "rewardsCoordinator: implementation set incorrectly" ); + require( + eigenLayerProxyAdmin.getProxyImplementation( + ITransparentUpgradeableProxy(payable(address(allocationManager))) + ) == address(allocationManagerImplementation), + "allocationManager: implementation set incorrectly" + ); + for (uint256 i = 0; i < deployedStrategyArray.length; ++i) { require( eigenLayerProxyAdmin.getProxyImplementation( @@ -545,8 +546,6 @@ contract DeployFromScratch is Script, Test { function _verifyInitialOwners() internal view { require(strategyManager.owner() == executorMultisig, "strategyManager: owner not set correctly"); require(delegation.owner() == executorMultisig, "delegation: owner not set correctly"); - // removing slasher requirements because there is no slasher as part of m2-mainnet release - // require(slasher.owner() == executorMultisig, "slasher: owner not set correctly"); require(eigenPodManager.owner() == executorMultisig, "eigenPodManager: owner not set correctly"); require(eigenLayerProxyAdmin.owner() == executorMultisig, "eigenLayerProxyAdmin: owner not set correctly"); @@ -559,8 +558,6 @@ contract DeployFromScratch is Script, Test { strategyManager.pauserRegistry() == eigenLayerPauserReg, "strategyManager: pauser registry not set correctly" ); - // removing slasher requirements because there is no slasher as part of m2-mainnet release - // require(slasher.pauserRegistry() == eigenLayerPauserReg, "slasher: pauser registry not set correctly"); require( eigenPodManager.pauserRegistry() == eigenLayerPauserReg, "eigenPodManager: pauser registry not set correctly" @@ -589,14 +586,12 @@ contract DeployFromScratch is Script, Test { // // pause *nothing* // uint256 STRATEGY_MANAGER_INIT_PAUSED_STATUS = 0; // // pause *everything* - // uint256 SLASHER_INIT_PAUSED_STATUS = type(uint256).max; // // pause *everything* // uint256 DELEGATION_INIT_PAUSED_STATUS = type(uint256).max; // // pause *all of the proof-related functionality* (everything that can be paused other than creation of EigenPods) // uint256 EIGENPOD_MANAGER_INIT_PAUSED_STATUS = (2**1) + (2**2) + (2**3) + (2**4); /* = 30 */ // // pause *nothing* // require(strategyManager.paused() == 0, "strategyManager: init paused status set incorrectly"); - // require(slasher.paused() == type(uint256).max, "slasher: init paused status set incorrectly"); // require(delegation.paused() == type(uint256).max, "delegation: init paused status set incorrectly"); // require(eigenPodManager.paused() == 30, "eigenPodManager: init paused status set incorrectly"); } diff --git a/script/deploy/local/operatorSets/DeployStrategies.s.sol b/script/deploy/local/operatorSets/DeployStrategies.s.sol new file mode 100644 index 000000000..e2f05e806 --- /dev/null +++ b/script/deploy/local/operatorSets/DeployStrategies.s.sol @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.27; + +import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol"; +import "../../../utils/ExistingDeploymentParser.sol"; + +// # To load the variables in the .env file +// source .env + +// # To deploy and verify our contract +contract DeployStrategies is ExistingDeploymentParser { + + function run() external { + _parseDeployedContracts("script/output/devnet/M2_from_scratch_deployment_data.json"); + + vm.startBroadcast(); + StrategyDeployer strategyDeployer = new StrategyDeployer( + executorMultisig, + address(baseStrategyImplementation) + ); + uint256 batches = 1; + uint256 batchSize = 100; + + IStrategy[] memory strategies = new IStrategy[](batchSize * batches); + + for (uint256 i = 0; i < batches; i++) { + IStrategy[] memory strategiesJustDeployed = strategyDeployer.createManyStrategies(batchSize); + for (uint256 j = 0; j < batchSize; j++) { + strategies[i * batchSize + j] = strategiesJustDeployed[j]; + } + strategyManager.addStrategiesToDepositWhitelist(strategiesJustDeployed); + } + + vm.stopBroadcast(); + + address[] memory strategyAddresses; + assembly { + strategyAddresses := strategies + } + string memory deployed_strategies = vm.serializeAddress("", "strategies", strategyAddresses); + + vm.writeJson(deployed_strategies, "script/output/devnet/deployed_strategies.json"); + } +} + + +contract StrategyDeployer { + address immutable beneficiary; + address immutable baseStrategyImplementation; + + constructor(address _beneficiary, address _baseStrategyImplementation) { + beneficiary = _beneficiary; + baseStrategyImplementation = _baseStrategyImplementation; + } + + function createManyStrategies(uint256 numStrategies) external returns(IStrategy[] memory) { + IStrategy[] memory strategies = new IStrategy[](numStrategies); + for (uint256 i = 0; i < numStrategies; i++) { + // create a strategy + strategies[i] = + StrategyBaseTVLLimits( + address( + new TransparentUpgradeableProxy( + address(baseStrategyImplementation), + address(1), + abi.encodeWithSelector( + StrategyBaseTVLLimits.initialize.selector, + type(uint256).max, + type(uint256).max, + new ERC20PresetFixedSupply("Test", "TST", uint256(type(uint128).max), beneficiary), + address(1) + ) + ) + ) + ); + } + return strategies; + } +} \ No newline at end of file diff --git a/script/deploy/mainnet/Deploy_Strategy_Factory.s.sol b/script/deploy/mainnet/Deploy_Strategy_Factory.s.sol new file mode 100644 index 000000000..fa5d93707 --- /dev/null +++ b/script/deploy/mainnet/Deploy_Strategy_Factory.s.sol @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.27; + +import "@openzeppelin/contracts/utils/Create2.sol"; +import "../../utils/ExistingDeploymentParser.sol"; + +import "../../../src/contracts/strategies/StrategyFactory.sol"; + +/** + * @notice Script used for the first deployment of EigenLayer core contracts to Holesky + * FORK LOCAL + * anvil --fork-url $RPC_MAINNET + * forge script script/deploy/mainnet/Deploy_Strategy_Factory.s.sol:MainnetStrategyFactoryDeploy --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv + * + * MAINNET + * forge script script/deploy/mainnet/Deploy_Strategy_Factory.s.sol:MainnetStrategyFactoryDeploy --rpc-url $RPC_MAINNET --private-key $PRIVATE_KEY --verify --broadcast -vvvv + * + */ + +contract MainnetStrategyFactoryDeploy is ExistingDeploymentParser { + function run() external virtual { + // Use rewards config + _parseInitialDeploymentParams( + "script/configs/mainnet/v0.3.0-mainnet-rewards.config.json" + ); + _parseDeployedContracts( + "script/configs/mainnet/Mainnet_curent_deployment.config.json" + ); + + // START RECORDING TRANSACTIONS FOR DEPLOYMENT + vm.startBroadcast(); + + emit log_named_address("Deployer Address", msg.sender); + + _deployStrategyFactory(); + + // STOP RECORDING TRANSACTIONS FOR DEPLOYMENT + vm.stopBroadcast(); + + // Sanity Checks + _verifyContractPointers(); + _verifyImplementations(); + _verifyContractsInitialized(); + _verifyInitializationParams(); + + logAndOutputContractAddresses("script/output/mainnet/v0.3.2-mainnet-strategy-factory.output.json"); + } + + /** + * @notice Deploy StrategyFactory for Mainnet + */ + + function _deployStrategyFactory() internal { + strategyFactoryImplementation = new StrategyFactory( + strategyManager + ); + + + + } +} \ No newline at end of file diff --git a/script/deploy/mainnet/EigenPod_Minor_Upgrade_Deploy.s.sol b/script/deploy/mainnet/EigenPod_Minor_Upgrade_Deploy.s.sol index 9f0ac1d4a..f4cb4967b 100644 --- a/script/deploy/mainnet/EigenPod_Minor_Upgrade_Deploy.s.sol +++ b/script/deploy/mainnet/EigenPod_Minor_Upgrade_Deploy.s.sol @@ -9,7 +9,6 @@ import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import "../../../src/contracts/interfaces/IETHPOSDeposit.sol"; import "../../../src/contracts/core/StrategyManager.sol"; -import "../../../src/contracts/core/Slasher.sol"; import "../../../src/contracts/core/DelegationManager.sol"; import "../../../src/contracts/pods/EigenPod.sol"; @@ -32,7 +31,6 @@ contract EigenPod_Minor_Upgrade_Deploy is Script, Test { string public freshOutputPath; // EigenLayer core contracts - ISlasher public slasher; IDelegationManager public delegation; DelegationManager public delegationImplementation; IStrategyManager public strategyManager; @@ -70,7 +68,6 @@ contract EigenPod_Minor_Upgrade_Deploy is Script, Test { // Read json data string memory deployment_data = vm.readFile(m2DeploymentOutputPath); - slasher = Slasher(stdJson.readAddress(deployment_data, ".addresses.slasher")); delegation = DelegationManager(stdJson.readAddress(deployment_data, ".addresses.delegationManager")); strategyManager = DelegationManager(address(delegation)).strategyManager(); eigenPodManager = strategyManager.eigenPodManager(); diff --git a/script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol b/script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol deleted file mode 100644 index 47f127b05..000000000 --- a/script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol +++ /dev/null @@ -1,337 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.27; - -import "../../utils/ExistingDeploymentParser.sol"; -import "../../utils/TimelockEncoding.sol"; -import "../../utils/Multisend.sol"; - -import "../../../src/contracts/interfaces/IPausable.sol"; - -/** - * @notice Script used for the first deployment of EigenLayer core contracts to Holesky - * anvil --fork-url $RPC_MAINNET - * forge script script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol:M2_Mainnet_Upgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv - * - * forge script script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol:M2_Mainnet_Upgrade --rpc-url $RPC_MAINNET --private-key $PRIVATE_KEY --broadcast -vvvv - * - */ -contract M2_Mainnet_Upgrade is ExistingDeploymentParser { - function run() external virtual { - _parseDeployedContracts("script/output/mainnet/M1_deployment_mainnet_2023_6_9.json"); - _parseInitialDeploymentParams("script/configs/mainnet/M2_mainnet_upgrade.config.json"); - - // START RECORDING TRANSACTIONS FOR DEPLOYMENT - vm.startBroadcast(); - - emit log_named_address("Deployer Address", msg.sender); - - _deployImplementationContracts(); - - // STOP RECORDING TRANSACTIONS FOR DEPLOYMENT - vm.stopBroadcast(); - - // Simulate upgrade of contracts to new implementations - _simulateUpgrade(); - - // Sanity Checks - _verifyContractPointers(); - _verifyImplementations(); - _verifyContractsInitialized(); - _verifyInitializationParams(); - - logAndOutputContractAddresses("script/output/mainnet/M2_mainnet_upgrade.output.json"); - } - - /** - * @notice Deploy EigenLayer contracts from scratch for Holesky - */ - function _deployImplementationContracts() internal { - // 1. Deploy New TUPS - avsDirectoryImplementation = new AVSDirectory(delegationManager); - avsDirectory = AVSDirectory( - address( - new TransparentUpgradeableProxy( - address(avsDirectoryImplementation), - address(eigenLayerProxyAdmin), - abi.encodeWithSelector( - AVSDirectory.initialize.selector, - executorMultisig, // initialOwner - eigenLayerPauserReg, - AVS_DIRECTORY_INIT_PAUSED_STATUS - ) - ) - ) - ); - - // 2. Deploy Implementations - eigenPodImplementation = new EigenPod( - IETHPOSDeposit(ETHPOSDepositAddress), - eigenPodManager, - EIGENPOD_GENESIS_TIME - ); - delegationManagerImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager, slasher); - slasherImplementation = new Slasher(strategyManager, delegationManager); - eigenPodManagerImplementation = new EigenPodManager( - IETHPOSDeposit(ETHPOSDepositAddress), - eigenPodBeacon, - strategyManager, - slasher, - delegationManager - ); - } - - function _simulateUpgrade() internal { - - vm.startPrank(executorMultisig); - - // First, upgrade the proxy contracts to point to the implementations - // AVSDirectory - // eigenLayerProxyAdmin.upgrade( - // ITransparentUpgradeableProxy(payable(address(avsDirectory))), - // address(avsDirectoryImplementation) - // ); - // DelegationManager - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(delegationManager))), - address(delegationManagerImplementation) - ); - // StrategyManager - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(strategyManager))), - address(strategyManagerImplementation) - ); - // Slasher - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation) - ); - // EigenPodManager - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(eigenPodManager))), - address(eigenPodManagerImplementation) - ); - - // Second, configure additional settings and paused statuses - delegationManager.setMinWithdrawalDelayBlocks(DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS); - delegationManager.unpause(0); - eigenPodManager.unpause(0); - - eigenPodBeacon.upgradeTo(address(eigenPodImplementation)); - - vm.stopPrank(); - } -} - -// forge t --mt test_queueUpgrade --fork-url $RPC_MAINNET -vvvv -contract Queue_M2_Upgrade is M2_Mainnet_Upgrade, TimelockEncoding { - Vm cheats = Vm(HEVM_ADDRESS); - - // Thurs Apr 08 2024 12:00:00 GMT-0700 (Pacific Daylight Time) - uint256 timelockEta = 1712559600; - - function test_queueUpgrade() external { - _parseDeployedContracts("script/output/mainnet/M2_mainnet_upgrade.output.json"); - _parseInitialDeploymentParams("script/configs/mainnet/M2_mainnet_upgrade.config.json"); - - Tx[] memory txs = new Tx[](11); - // upgrade the DelegationManager, Slasher, StrategyManager, DelayedWithdrawalRouter, EigenPodManager, & EigenPod contracts - txs[0] = Tx( - address(eigenLayerProxyAdmin), - 0, - abi.encodeWithSelector( - ProxyAdmin.upgrade.selector, - ITransparentUpgradeableProxy(payable(address(delegationManager))), - delegationManagerImplementation - ) - ); - - txs[1] = Tx( - address(eigenLayerProxyAdmin), - 0, - abi.encodeWithSelector( - ProxyAdmin.upgrade.selector, - ITransparentUpgradeableProxy(payable(address(slasher))), - slasherImplementation - ) - ); - - txs[2] = Tx( - address(eigenLayerProxyAdmin), - 0, - abi.encodeWithSelector( - ProxyAdmin.upgrade.selector, - ITransparentUpgradeableProxy(payable(address(strategyManager))), - strategyManagerImplementation - ) - ); - - // txs[3] = Tx( - // address(eigenLayerProxyAdmin), - // 0, - // abi.encodeWithSelector( - // ProxyAdmin.upgrade.selector, - // ITransparentUpgradeableProxy(payable(address(delayedWithdrawalRouter))), - // delayedWithdrawalRouterImplementation - // ) - // ); - - txs[4] = Tx( - address(eigenLayerProxyAdmin), - 0, - abi.encodeWithSelector( - ProxyAdmin.upgrade.selector, - ITransparentUpgradeableProxy(payable(address(eigenPodManager))), - eigenPodManagerImplementation - ) - ); - - txs[5] = Tx( - address(eigenPodBeacon), - 0, - abi.encodeWithSelector( - UpgradeableBeacon.upgradeTo.selector, - eigenPodImplementation - ) - ); - - // set the min withdrawal delay blocks on the DelegationManager - txs[6] = Tx( - address(delegationManager), - 0, // value - abi.encodeWithSelector(DelegationManager.setMinWithdrawalDelayBlocks.selector, DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS) - ); - - // set beacon chain oracle on EigenPodManager - // txs[7] = Tx( - // address(eigenPodManager), - // 0, // value - // abi.encodeWithSelector(EigenPodManager.updateBeaconChainOracle.selector, beaconOracle) - // ); - - // set Deneb fork timestamp on EigenPodManager - // txs[8] = Tx( - // address(eigenPodManager), - // 0, // value - // abi.encodeWithSelector(EigenPodManager.setDenebForkTimestamp.selector, EIGENPOD_MANAGER_DENEB_FORK_TIMESTAMP) - // ); - - // unpause everything on DelegationManager - txs[9] = Tx( - address(delegationManager), - 0, // value - abi.encodeWithSelector(Pausable.unpause.selector, 0) - ); - - // unpause everything on EigenPodManager - txs[10] = Tx( - address(eigenPodManager), - 0, // value - abi.encodeWithSelector(Pausable.unpause.selector, 0) - ); - - bytes memory calldata_to_multisend_contract = abi.encodeWithSelector(MultiSendCallOnly.multiSend.selector, encodeMultisendTxs(txs)); - emit log_named_bytes("calldata_to_multisend_contract", calldata_to_multisend_contract); - - bytes memory final_calldata_to_executor_multisig = encodeForExecutor({ - // call to executor will be from the timelock - from: timelock, - // performing many operations at the same time - to: multiSendCallOnly, - // value to send in tx - value: 0, - // calldata for the operation - data: calldata_to_multisend_contract, - // operation type (for performing many operations at the same time) - operation: ISafe.Operation.DelegateCall - }); - - (bytes memory calldata_to_timelock_queuing_action, bytes memory calldata_to_timelock_executing_action) = encodeForTimelock({ - // address to be called from the timelock - to: executorMultisig, - // value to send in tx - value: 0, - // calldata for the operation - data: final_calldata_to_executor_multisig, - // time at which the tx will become executable - timelockEta: timelockEta - }); - - bytes32 expectedTxHash = getTxHash({ - target: executorMultisig, - _value: 0, - _data: final_calldata_to_executor_multisig, - eta: timelockEta - }); - emit log_named_bytes32("expectedTxHash", expectedTxHash); - - cheats.prank(operationsMultisig); - (bool success, ) = timelock.call(calldata_to_timelock_queuing_action); - require(success, "call to timelock queuing action failed"); - - require(ITimelock(timelock).queuedTransactions(expectedTxHash), "expectedTxHash not queued"); - - // test performing the upgrade - cheats.warp(timelockEta); - cheats.prank(operationsMultisig); - (success, ) = timelock.call(calldata_to_timelock_executing_action); - require(success, "call to timelock executing action failed"); - - // Check correctness after upgrade - _verifyContractPointers(); - _verifyImplementations(); - _verifyContractsInitialized(); - _verifyInitializationParams(); - _postUpgradeChecks(); - } - - function _postUpgradeChecks() internal { - // check that LST deposits are paused - address rETH = 0xae78736Cd615f374D3085123A210448E74Fc6393; - address rETH_Strategy = 0x1BeE69b7dFFfA4E2d53C2a2Df135C388AD25dCD2; - uint256 amount = 1e18; - cheats.prank(rETH); - // this works because rETH has more than 1 ETH of its own token at its address :) - IERC20(rETH).transfer(address(this), amount); - IERC20(rETH).approve(address(strategyManager), amount); - cheats.expectRevert(IPausable.CurrentlyPaused.selector); - strategyManager.depositIntoStrategy({ - strategy: IStrategy(rETH_Strategy), - token: IERC20(rETH), - amount: amount - }); - - // unpause LST deposits and check that a deposit works - cheats.prank(executorMultisig); - strategyManager.unpause(0); - strategyManager.depositIntoStrategy({ - strategy: IStrategy(rETH_Strategy), - token: IERC20(rETH), - amount: amount - }); - - // check that EigenPod proofs are live (although this still reverts later in the call) - EigenPod existingEigenPod = EigenPod(payable(0x0b347D5E38296277E829CE1D8C6b82e4c63C2Df3)); - BeaconChainProofs.StateRootProof memory stateRootProof; - uint40[] memory validatorIndices; - bytes[] memory validatorFieldsProofs; - bytes32[][] memory validatorFields; - cheats.startPrank(existingEigenPod.podOwner()); - existingEigenPod.startCheckpoint(false); - cheats.expectRevert("EigenPodManager.getBlockRootAtTimestamp: state root at timestamp not yet finalized"); - existingEigenPod.verifyWithdrawalCredentials( - uint64(block.timestamp), - stateRootProof, - validatorIndices, - validatorFieldsProofs, - validatorFields - ); - } - - function getTxHash(address target, uint256 _value, bytes memory _data, uint256 eta) public pure returns (bytes32) { - // empty bytes - bytes memory signature; - bytes32 txHash = keccak256(abi.encode(target, _value, signature, _data, eta)); - return txHash; - } -} diff --git a/script/deploy/mainnet/v0.4.2-mainnet-pepe.s.sol b/script/deploy/mainnet/v0.4.2-mainnet-pepe.s.sol index 8efb0ed32..066eb0863 100644 --- a/script/deploy/mainnet/v0.4.2-mainnet-pepe.s.sol +++ b/script/deploy/mainnet/v0.4.2-mainnet-pepe.s.sol @@ -58,7 +58,6 @@ contract MainnetPEPEDeploy is ExistingDeploymentParser { IETHPOSDeposit(ETHPOSDepositAddress), eigenPodBeacon, strategyManager, - slasher, delegationManager ); } diff --git a/script/utils/ExistingDeploymentParser.sol b/script/utils/ExistingDeploymentParser.sol index 63ff88ea4..447bde76b 100644 --- a/script/utils/ExistingDeploymentParser.sol +++ b/script/utils/ExistingDeploymentParser.sol @@ -6,10 +6,10 @@ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.so import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import "../../src/contracts/core/StrategyManager.sol"; -import "../../src/contracts/core/Slasher.sol"; import "../../src/contracts/core/DelegationManager.sol"; import "../../src/contracts/core/AVSDirectory.sol"; import "../../src/contracts/core/RewardsCoordinator.sol"; +import "../../src/contracts/core/AllocationManager.sol"; import "../../src/contracts/strategies/StrategyFactory.sol"; import "../../src/contracts/strategies/StrategyBase.sol"; @@ -45,8 +45,6 @@ contract ExistingDeploymentParser is Script, Test { // EigenLayer Contracts ProxyAdmin public eigenLayerProxyAdmin; PauserRegistry public eigenLayerPauserReg; - Slasher public slasher; - Slasher public slasherImplementation; AVSDirectory public avsDirectory; AVSDirectory public avsDirectoryImplementation; DelegationManager public delegationManager; @@ -62,6 +60,8 @@ contract ExistingDeploymentParser is Script, Test { StrategyBase public baseStrategyImplementation; StrategyFactory public strategyFactory; StrategyFactory public strategyFactoryImplementation; + AllocationManager public allocationManager; + AllocationManager public allocationManagerImplementation; UpgradeableBeacon public strategyBeacon; StrategyBase public strategyFactoryBeaconImplementation; @@ -100,11 +100,10 @@ contract ExistingDeploymentParser is Script, Test { // StrategyManager uint256 STRATEGY_MANAGER_INIT_PAUSED_STATUS; address STRATEGY_MANAGER_WHITELISTER; - // SLasher - uint256 SLASHER_INIT_PAUSED_STATUS; // DelegationManager uint256 DELEGATION_MANAGER_INIT_PAUSED_STATUS; uint256 DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS; + uint32 MIN_WITHDRAWAL_DELAY; // AVSDirectory uint256 AVS_DIRECTORY_INIT_PAUSED_STATUS; // RewardsCoordinator @@ -117,8 +116,14 @@ contract ExistingDeploymentParser is Script, Test { uint32 REWARDS_COORDINATOR_ACTIVATION_DELAY; uint32 REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS; uint32 REWARDS_COORDINATOR_GLOBAL_OPERATOR_COMMISSION_BIPS; + uint32 REWARDS_COORDINATOR_OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP; + uint32 REWARDS_COORDINATOR_OPERATOR_SET_MAX_RETROACTIVE_LENGTH; // EigenPodManager uint256 EIGENPOD_MANAGER_INIT_PAUSED_STATUS; + // AllocationManager + uint256 ALLOCATION_MANAGER_INIT_PAUSED_STATUS; + uint32 DEALLOCATION_DELAY; + uint32 ALLOCATION_DELAY_CONFIGURATION_DELAY; // EigenPod uint64 EIGENPOD_GENESIS_TIME; uint64 EIGENPOD_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR; @@ -157,10 +162,6 @@ contract ExistingDeploymentParser is Script, Test { eigenLayerPauserReg = PauserRegistry( stdJson.readAddress(existingDeploymentData, ".addresses.eigenLayerPauserReg") ); - slasher = Slasher(stdJson.readAddress(existingDeploymentData, ".addresses.slasher")); - slasherImplementation = Slasher( - stdJson.readAddress(existingDeploymentData, ".addresses.slasherImplementation") - ); delegationManager = DelegationManager( stdJson.readAddress(existingDeploymentData, ".addresses.delegationManager") ); @@ -288,8 +289,6 @@ contract ExistingDeploymentParser is Script, Test { initialDeploymentData, ".strategyManager.init_strategy_whitelister" ); - // Slasher - SLASHER_INIT_PAUSED_STATUS = stdJson.readUint(initialDeploymentData, ".slasher.init_paused_status"); // DelegationManager DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS = stdJson.readUint( initialDeploymentData, @@ -314,6 +313,12 @@ contract ExistingDeploymentParser is Script, Test { REWARDS_COORDINATOR_GLOBAL_OPERATOR_COMMISSION_BIPS = uint32( stdJson.readUint(initialDeploymentData, ".rewardsCoordinator.global_operator_commission_bips") ); + REWARDS_COORDINATOR_OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP = uint32( + stdJson.readUint(initialDeploymentData, ".rewardsCoordinator.OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP") + ); + REWARDS_COORDINATOR_OPERATOR_SET_MAX_RETROACTIVE_LENGTH = uint32( + stdJson.readUint(initialDeploymentData, ".rewardsCoordinator.OPERATOR_SET_MAX_RETROACTIVE_LENGTH") + ); // AVSDirectory AVS_DIRECTORY_INIT_PAUSED_STATUS = stdJson.readUint(initialDeploymentData, ".avsDirectory.init_paused_status"); // EigenPodManager @@ -321,6 +326,11 @@ contract ExistingDeploymentParser is Script, Test { initialDeploymentData, ".eigenPodManager.init_paused_status" ); + // AllocationManager + ALLOCATION_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint( + initialDeploymentData, + ".allocationManager.init_paused_status" + ); // EigenPod EIGENPOD_GENESIS_TIME = uint64(stdJson.readUint(initialDeploymentData, ".eigenPod.GENESIS_TIME")); ETHPOSDepositAddress = stdJson.readAddress(initialDeploymentData, ".ethPOSDepositAddress"); @@ -345,7 +355,6 @@ contract ExistingDeploymentParser is Script, Test { "rewardsCoordinator: strategyManager address not set correctly" ); // DelegationManager - require(delegationManager.slasher() == slasher, "delegationManager: slasher address not set correctly"); require( delegationManager.strategyManager() == strategyManager, "delegationManager: strategyManager address not set correctly" @@ -355,7 +364,6 @@ contract ExistingDeploymentParser is Script, Test { "delegationManager: eigenPodManager address not set correctly" ); // StrategyManager - require(strategyManager.slasher() == slasher, "strategyManager: slasher address not set correctly"); require( strategyManager.delegation() == delegationManager, "strategyManager: delegationManager address not set correctly" @@ -377,7 +385,6 @@ contract ExistingDeploymentParser is Script, Test { eigenPodManager.strategyManager() == strategyManager, "eigenPodManager: strategyManager contract address not set correctly" ); - require(eigenPodManager.slasher() == slasher, "eigenPodManager: slasher contract address not set correctly"); require( eigenPodManager.delegationManager() == delegationManager, "eigenPodManager: delegationManager contract address not set correctly" @@ -409,11 +416,6 @@ contract ExistingDeploymentParser is Script, Test { ) == address(strategyManagerImplementation), "strategyManager: implementation set incorrectly" ); - require( - eigenLayerProxyAdmin.getProxyImplementation(ITransparentUpgradeableProxy(payable(address(slasher)))) == - address(slasherImplementation), - "slasher: implementation set incorrectly" - ); require( eigenLayerProxyAdmin.getProxyImplementation( ITransparentUpgradeableProxy(payable(address(eigenPodManager))) @@ -461,10 +463,7 @@ contract ExistingDeploymentParser is Script, Test { delegationManager.initialize( address(0), eigenLayerPauserReg, - 0, - 0, // minWithdrawalDelayBLocks - initializeStrategiesToSetDelayBlocks, - initializeWithdrawalDelayBlocks + 0 ); // StrategyManager vm.expectRevert(bytes("Initializable: contract is already initialized")); @@ -555,10 +554,6 @@ contract ExistingDeploymentParser is Script, Test { delegationManager.paused() == DELEGATION_MANAGER_INIT_PAUSED_STATUS, "delegationManager: init paused status set incorrectly" ); - require( - delegationManager.minWithdrawalDelayBlocks() == DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS, - "delegationManager: minWithdrawalDelayBlocks not set correctly" - ); // StrategyManager require( strategyManager.pauserRegistry() == eigenLayerPauserReg, @@ -639,7 +634,6 @@ contract ExistingDeploymentParser is Script, Test { emit log_named_uint("STRATEGY_MANAGER_INIT_PAUSED_STATUS", STRATEGY_MANAGER_INIT_PAUSED_STATUS); emit log_named_address("STRATEGY_MANAGER_WHITELISTER", STRATEGY_MANAGER_WHITELISTER); - emit log_named_uint("SLASHER_INIT_PAUSED_STATUS", SLASHER_INIT_PAUSED_STATUS); emit log_named_uint( "DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS", DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS @@ -690,8 +684,6 @@ contract ExistingDeploymentParser is Script, Test { string memory deployed_addresses = "addresses"; vm.serializeAddress(deployed_addresses, "eigenLayerProxyAdmin", address(eigenLayerProxyAdmin)); vm.serializeAddress(deployed_addresses, "eigenLayerPauserReg", address(eigenLayerPauserReg)); - vm.serializeAddress(deployed_addresses, "slasher", address(slasher)); - vm.serializeAddress(deployed_addresses, "slasherImplementation", address(slasherImplementation)); vm.serializeAddress(deployed_addresses, "avsDirectory", address(avsDirectory)); vm.serializeAddress(deployed_addresses, "avsDirectoryImplementation", address(avsDirectoryImplementation)); vm.serializeAddress(deployed_addresses, "delegationManager", address(delegationManager)); diff --git a/script/whitelist/delegationFaucet/DelegationFaucet.sol b/script/whitelist/delegationFaucet/DelegationFaucet.sol deleted file mode 100644 index 0466fa686..000000000 --- a/script/whitelist/delegationFaucet/DelegationFaucet.sol +++ /dev/null @@ -1,216 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.27; - -import "src/contracts/interfaces/IStrategyManager.sol"; -import "src/contracts/interfaces/IStrategy.sol"; -import "src/contracts/interfaces/IDelegationManager.sol"; -import "src/contracts/interfaces/IDelegationFaucet.sol"; -import "script/whitelist/delegationFaucet/DelegationFaucetStaker.sol"; - -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/utils/Create2.sol"; -import "@openzeppelin/contracts/utils/Address.sol"; - -import "../ERC20PresetMinterPauser.sol"; - -/** - * @title DelegationFaucet for M2 - * @author Layr Labs, Inc. - * @notice Faucet contract setup with a dummy ERC20 token and strategy for M2 testnet release. - * Each operator address gets a staker contract assigned to them deterministically. - * This contract assumes minting role of the ERC20 token and that the ERC20 token has a whitelisted strategy. - */ -contract DelegationFaucet is IDelegationFaucet, Ownable { - IStrategyManager immutable strategyManager; - ERC20PresetMinterPauser immutable stakeToken; - IStrategy immutable stakeStrategy; - IDelegationManager immutable delegation; - - uint256 public constant DEFAULT_AMOUNT = 100e18; - - constructor( - IStrategyManager _strategyManager, - IDelegationManager _delegation, - ERC20PresetMinterPauser _token, - IStrategy _strategy - ) { - strategyManager = _strategyManager; - delegation = _delegation; - stakeToken = _token; - stakeStrategy = _strategy; - } - - /** - * Deploys a DelegationFaucetStaker contract if not already deployed for operator. DelegationFaucetStaker gets minted _depositAmount or - * DEFAULT_AMOUNT if _depositAmount is 0. Then DelegationFaucetStaker contract deposits into the strategy and delegates to operator. - * @param _operator The operator to delegate to - * @param _approverSignatureAndExpiry Verifies the operator approves of this delegation - * @param _approverSalt A unique single use value tied to an individual signature. - * @param _depositAmount The amount to deposit into the strategy - */ - function mintDepositAndDelegate( - address _operator, - IDelegationManager.SignatureWithExpiry memory _approverSignatureAndExpiry, - bytes32 _approverSalt, - uint256 _depositAmount - ) public onlyOwner { - // Operator must be registered - require(delegation.isOperator(_operator), "DelegationFaucet: Operator not registered"); - address staker = getStaker(_operator); - // Set deposit amount - if (_depositAmount == 0) { - _depositAmount = DEFAULT_AMOUNT; - } - - // Deploy staker address if not already deployed, staker constructor will approve the StrategyManager to spend the stakeToken - if (!Address.isContract(staker)) { - Create2.deploy( - 0, - bytes32(uint256(uint160(_operator))), - abi.encodePacked(type(DelegationFaucetStaker).creationCode, abi.encode(strategyManager, stakeToken)) - ); - } - - // mint stakeToken to staker - stakeToken.mint(staker, _depositAmount); - // deposit into stakeToken strategy, which will increase delegated shares to operator if already delegated - _depositIntoStrategy(staker, stakeStrategy, stakeToken, _depositAmount); - // delegateTo operator if not delegated - if (!delegation.isDelegated(staker)) { - delegateTo(_operator, _approverSignatureAndExpiry, _approverSalt); - } - } - - /** - * Calls staker contract to deposit into designated strategy, mints staked token if stakeToken and stakeStrategy - * are specified. - * @param _staker address of staker contract for operator - * @param _strategy StakeToken strategy contract - * @param _token StakeToken - * @param _amount amount to get minted and to deposit - */ - function depositIntoStrategy( - address _staker, - IStrategy _strategy, - IERC20 _token, - uint256 _amount - ) public onlyOwner returns (bytes memory) { - // mint stakeToken to staker - if (_token == stakeToken && _strategy == stakeStrategy) { - stakeToken.mint(_staker, _amount); - } - return _depositIntoStrategy(_staker, _strategy, _token, _amount); - } - - /** - * Call staker to delegate to operator - * @param _operator operator to get staker address from and delegate to - * @param _approverSignatureAndExpiry Verifies the operator approves of this delegation - * @param _approverSalt A unique single use value tied to an individual signature. - */ - function delegateTo( - address _operator, - IDelegationManager.SignatureWithExpiry memory _approverSignatureAndExpiry, - bytes32 _approverSalt - ) public onlyOwner returns (bytes memory) { - bytes memory data = abi.encodeWithSelector( - IDelegationManager.delegateTo.selector, - _operator, - _approverSignatureAndExpiry, - _approverSalt - ); - return DelegationFaucetStaker(getStaker(_operator)).callAddress(address(delegation), data); - } - - /** - * Call queueWithdrawal through staker contract - */ - function queueWithdrawal( - address staker, - IDelegationManager.QueuedWithdrawalParams[] calldata queuedWithdrawalParams - ) public onlyOwner returns (bytes memory) { - bytes memory data = abi.encodeWithSelector( - IDelegationManager.queueWithdrawals.selector, - queuedWithdrawalParams - ); - return DelegationFaucetStaker(staker).callAddress(address(delegation), data); - } - - /** - * Call completeQueuedWithdrawal through staker contract - */ - function completeQueuedWithdrawal( - address staker, - IDelegationManager.Withdrawal calldata queuedWithdrawal, - IERC20[] calldata tokens, - uint256 middlewareTimesIndex, - bool receiveAsTokens - ) public onlyOwner returns (bytes memory) { - bytes memory data = abi.encodeWithSelector( - IDelegationManager.completeQueuedWithdrawal.selector, - queuedWithdrawal, - tokens, - middlewareTimesIndex, - receiveAsTokens - ); - return DelegationFaucetStaker(staker).callAddress(address(delegation), data); - } - - /** - * Transfers tokens from staker contract to designated address - * @param staker staker contract to transfer from - * @param token ERC20 token - * @param to the to address - * @param amount transfer amount - */ - function transfer( - address staker, - address token, - address to, - uint256 amount - ) public onlyOwner returns (bytes memory) { - bytes memory data = abi.encodeWithSelector(IERC20.transfer.selector, to, amount); - return DelegationFaucetStaker(staker).callAddress(token, data); - } - - function callAddress(address to, bytes memory data) public payable onlyOwner returns (bytes memory) { - (bool ok, bytes memory res) = payable(to).call{value: msg.value}(data); - if (!ok) { - revert(string(res)); - } - return res; - } - - /** - * @notice Returns the deterministic staker contract address for the operator - * @param _operator The operator to get the staker contract address for - */ - function getStaker(address _operator) public view returns (address) { - return - Create2.computeAddress( - bytes32(uint256(uint160(_operator))), //salt - keccak256( - abi.encodePacked(type(DelegationFaucetStaker).creationCode, abi.encode(strategyManager, stakeToken)) - ) - ); - } - - /** - * @notice Internal function to deposit into a strategy, has same function signature as StrategyManager.depositIntoStrategy - */ - function _depositIntoStrategy( - address _staker, - IStrategy _strategy, - IERC20 _token, - uint256 _amount - ) internal returns (bytes memory) { - bytes memory data = abi.encodeWithSelector( - IStrategyManager.depositIntoStrategy.selector, - _strategy, - _token, - _amount - ); - return DelegationFaucetStaker(_staker).callAddress(address(strategyManager), data); - } -} diff --git a/script/whitelist/delegationFaucet/DelegationFaucetStaker.sol b/script/whitelist/delegationFaucet/DelegationFaucetStaker.sol deleted file mode 100644 index 8eed644a6..000000000 --- a/script/whitelist/delegationFaucet/DelegationFaucetStaker.sol +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.27; - -import "src/contracts/interfaces/IStrategyManager.sol"; - -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; -import "forge-std/Test.sol"; - -contract DelegationFaucetStaker is Ownable { - constructor(IStrategyManager strategyManager, IERC20 token) Ownable() { - token.approve(address(strategyManager), type(uint256).max); - } - - function callAddress(address implementation, bytes memory data) external onlyOwner returns (bytes memory) { - uint256 length = data.length; - bytes memory returndata; - assembly { - let result := call(gas(), implementation, callvalue(), add(data, 32), length, 0, 0) - mstore(returndata, returndatasize()) - returndatacopy(add(returndata, 32), 0, returndatasize()) - } - - return returndata; - } -} diff --git a/script/whitelist/delegationFaucet/DeployDelegationFaucet.sol b/script/whitelist/delegationFaucet/DeployDelegationFaucet.sol deleted file mode 100644 index f901c7e51..000000000 --- a/script/whitelist/delegationFaucet/DeployDelegationFaucet.sol +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.27; - -import "src/contracts/interfaces/IDelegationManager.sol"; -import "src/contracts/interfaces/IStrategyManager.sol"; -import "src/contracts/strategies/StrategyBase.sol"; -import "src/contracts/permissions/PauserRegistry.sol"; - -import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; - -import "./DelegationFaucet.sol"; - -import "forge-std/Script.sol"; -import "forge-std/StdJson.sol"; - -/** - * @notice Deploys the following contracts: - * - ERC20 Dummy token for testing - * - StrategyBase to be added to the StrategyManager whitelist - * - DelegationFaucet contract - */ -contract DeployDelegationFaucet is Script, DSTest { - // EigenLayer contracts - ProxyAdmin public eigenLayerProxyAdmin; - PauserRegistry public eigenLayerPauserReg; - IDelegationManager public delegation; - IStrategyManager public strategyManager; - - DelegationFaucet public delegationFaucet; - - // M2 testing/mock contracts - ERC20PresetMinterPauser public stakeToken; - StrategyBase public stakeTokenStrat; - StrategyBase public baseStrategyImplementation; - - address eigenLayerProxyAdminAddress; - address eigenLayerPauserRegAddress; - address delegationAddress; - address strategyManagerAddress; - address operationsMultisig; - address executorMultisig; - - bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); - - function run() external { - string memory goerliDeploymentConfig = vm.readFile("script/output/M1_deployment_goerli_2023_3_23.json"); - _setAddresses(goerliDeploymentConfig); - - vm.startBroadcast(); - // Deploy ERC20 stakeToken - stakeToken = new ERC20PresetMinterPauser("StakeToken", "STK"); - - // Deploy StrategyBase for stakeToken & whitelist it - baseStrategyImplementation = new StrategyBase(strategyManager); - stakeTokenStrat = StrategyBase( - address( - new TransparentUpgradeableProxy( - address(baseStrategyImplementation), - eigenLayerProxyAdminAddress, - abi.encodeWithSelector(StrategyBase.initialize.selector, stakeToken, eigenLayerPauserRegAddress) - ) - ) - ); - - // Needs to be strategyManager.strategyWhitelister() to add STK strategy - // IStrategy[] memory _strategy = new IStrategy[](1); - // _strategy[0] = stakeTokenStrat; - // strategyManager.addStrategiesToDepositWhitelist(_strategy); - - // Deploy DelegationFaucet, grant it admin/mint/pauser roles, etc. - delegationFaucet = new DelegationFaucet(strategyManager, delegation, stakeToken, stakeTokenStrat); - stakeToken.grantRole(MINTER_ROLE, address(delegationFaucet)); - vm.stopBroadcast(); - } - - function _setAddresses(string memory config) internal { - eigenLayerProxyAdminAddress = stdJson.readAddress(config, ".addresses.eigenLayerProxyAdmin"); - eigenLayerPauserRegAddress = stdJson.readAddress(config, ".addresses.eigenLayerPauserReg"); - delegationAddress = stdJson.readAddress(config, ".addresses.delegation"); - strategyManagerAddress = stdJson.readAddress(config, ".addresses.strategyManager"); - operationsMultisig = stdJson.readAddress(config, ".parameters.operationsMultisig"); - executorMultisig = stdJson.readAddress(config, ".parameters.executorMultisig"); - } -} diff --git a/src/contracts/core/AVSDirectory.sol b/src/contracts/core/AVSDirectory.sol index e9bd70119..ce20f74a9 100644 --- a/src/contracts/core/AVSDirectory.sol +++ b/src/contracts/core/AVSDirectory.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.27; import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol"; + import "../permissions/Pausable.sol"; import "../libraries/EIP1271SignatureUtils.sol"; import "./AVSDirectoryStorage.sol"; @@ -15,11 +16,8 @@ contract AVSDirectory is AVSDirectoryStorage, ReentrancyGuardUpgradeable { - // @dev Index for flag that pauses operator register/deregister to avs when set. - uint8 internal constant PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS = 0; - - // @dev Chain ID at the time of contract deployment - uint256 internal immutable ORIGINAL_CHAIN_ID; + using EnumerableSet for EnumerableSet.Bytes32Set; + using EnumerableSet for EnumerableSet.AddressSet; /** * @@ -28,14 +26,14 @@ contract AVSDirectory is */ /** - * @dev Initializes the immutable addresses of the strategy mananger, delegationManager, slasher, + * @dev Initializes the immutable addresses of the strategy mananger, delegationManager, * and eigenpodManager contracts */ constructor( - IDelegationManager _delegation - ) AVSDirectoryStorage(_delegation) { + IDelegationManager _delegation, + uint32 _DEALLOCATION_DELAY + ) AVSDirectoryStorage(_delegation, _DEALLOCATION_DELAY) { _disableInitializers(); - ORIGINAL_CHAIN_ID = block.chainid; } /** @@ -54,67 +52,277 @@ contract AVSDirectory is /** * - * EXTERNAL FUNCTIONS + * EXTERNAL FUNCTIONS + * + */ + + /** + * @notice Called by an AVS to create a list of new operatorSets. + * + * @param operatorSetIds The IDs of the operator set to initialize. + * + * @dev msg.sender must be the AVS. + * @dev The AVS may create operator sets before it becomes an operator set AVS. + */ + function createOperatorSets( + uint32[] calldata operatorSetIds + ) external { + for (uint256 i = 0; i < operatorSetIds.length; ++i) { + require(!isOperatorSet[msg.sender][operatorSetIds[i]], InvalidOperatorSet()); + isOperatorSet[msg.sender][operatorSetIds[i]] = true; + emit OperatorSetCreated(OperatorSet({avs: msg.sender, operatorSetId: operatorSetIds[i]})); + } + } + + /** + * @notice Sets the AVS as an operator set AVS, preventing legacy M2 operator registrations. * + * @dev msg.sender must be the AVS. */ + function becomeOperatorSetAVS() external { + require(!isOperatorSetAVS[msg.sender], InvalidAVS()); + isOperatorSetAVS[msg.sender] = true; + emit AVSMigratedToOperatorSets(msg.sender); + } /** - * @notice Called by the AVS's service manager contract to register an operator with the avs. - * @param operator The address of the operator to register. - * @param operatorSignature The signature, salt, and expiry of the operator's signature. + * @notice Called by an AVS to migrate operators that have a legacy M2 registration to operator sets. + * + * @param operators The list of operators to migrate + * @param operatorSetIds The list of operatorSets to migrate the operators to + * + * @dev The msg.sender used is the AVS + * @dev The operator can only be migrated at most once per AVS + * @dev The AVS can no longer register operators via the legacy M2 registration path once it begins migration + * @dev The operator is deregistered from the M2 legacy AVS once migrated + */ + function migrateOperatorsToOperatorSets( + address[] calldata operators, + uint32[][] calldata operatorSetIds + ) external override onlyWhenNotPaused(PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION) { + // Assert that the AVS is an operator set AVS. + require(isOperatorSetAVS[msg.sender], InvalidAVS()); + + for (uint256 i = 0; i < operators.length; i++) { + // Assert that the operator is registered & has not been migrated. + require( + avsOperatorStatus[msg.sender][operators[i]] == OperatorAVSRegistrationStatus.REGISTERED, + InvalidOperator() + ); + + // Migrate operator to operator sets. + _registerToOperatorSets(operators[i], msg.sender, operatorSetIds[i]); + + // Deregister operator from AVS - this prevents the operator from being migrated again since + // the AVS can no longer use the legacy M2 registration path + avsOperatorStatus[msg.sender][operators[i]] = OperatorAVSRegistrationStatus.UNREGISTERED; + emit OperatorAVSRegistrationStatusUpdated( + operators[i], msg.sender, OperatorAVSRegistrationStatus.UNREGISTERED + ); + emit OperatorMigratedToOperatorSets(operators[i], msg.sender, operatorSetIds[i]); + } + } + + /** + * @notice Called by AVSs to add an operator to a list of operatorSets. + * + * @param operator The address of the operator to be added to the operator set. + * @param operatorSetIds The IDs of the operator sets. + * @param operatorSignature The signature of the operator on their intent to register. + * + * @dev msg.sender is used as the AVS. + * @dev The operator must not have a pending deregistration from the operator set. + */ + function registerOperatorToOperatorSets( + address operator, + uint32[] calldata operatorSetIds, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external override onlyWhenNotPaused(PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION) { + // Assert operator's signature has not expired. + require(operatorSignature.expiry >= block.timestamp, SignatureExpired()); + // Assert `operator` is actually an operator. + require(delegation.isOperator(operator), OperatorNotRegistered()); + // Assert that the AVS is an operator set AVS. + require(isOperatorSetAVS[msg.sender], InvalidAVS()); + // Assert operator's signature `salt` has not already been spent. + require(!operatorSaltIsSpent[operator][operatorSignature.salt], SaltSpent()); + + // Assert that `operatorSignature.signature` is a valid signature for operator set registrations. + EIP1271SignatureUtils.checkSignature_EIP1271( + operator, + calculateOperatorSetRegistrationDigestHash({ + avs: msg.sender, + operatorSetIds: operatorSetIds, + salt: operatorSignature.salt, + expiry: operatorSignature.expiry + }), + operatorSignature.signature + ); + + // Mutate `operatorSaltIsSpent` to `true` to prevent future respending. + operatorSaltIsSpent[operator][operatorSignature.salt] = true; + + _registerToOperatorSets(operator, msg.sender, operatorSetIds); + } + + /** + * @notice Called by an operator to deregister from an operator set + * + * @param operator The operator to deregister from the operatorSets. + * @param avs The address of the AVS to deregister the operator from. + * @param operatorSetIds The IDs of the operator sets. + * @param operatorSignature the signature of the operator on their intent to deregister or empty if the operator itself is calling + * + * @dev if the operatorSignature is empty, the caller must be the operator + * @dev this will likely only be called in case the AVS contracts are in a state that prevents operators from deregistering + */ + function forceDeregisterFromOperatorSets( + address operator, + address avs, + uint32[] calldata operatorSetIds, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external override onlyWhenNotPaused(PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION) { + if (operatorSignature.signature.length == 0) { + require(msg.sender == operator, InvalidOperator()); + } else { + // Assert operator's signature has not expired. + require(operatorSignature.expiry >= block.timestamp, SignatureExpired()); + // Assert operator's signature `salt` has not already been spent. + require(!operatorSaltIsSpent[operator][operatorSignature.salt], SaltSpent()); + + // Assert that `operatorSignature.signature` is a valid signature for operator set deregistrations. + EIP1271SignatureUtils.checkSignature_EIP1271( + operator, + calculateOperatorSetForceDeregistrationTypehash({ + avs: avs, + operatorSetIds: operatorSetIds, + salt: operatorSignature.salt, + expiry: operatorSignature.expiry + }), + operatorSignature.signature + ); + + // Mutate `operatorSaltIsSpent` to `true` to prevent future respending. + operatorSaltIsSpent[operator][operatorSignature.salt] = true; + } + _deregisterFromOperatorSets(avs, operator, operatorSetIds); + } + + /** + * @notice Called by AVSs to remove an operator from an operator set. + * + * @param operator The address of the operator to be removed from the operator set. + * @param operatorSetIds The IDs of the operator sets. + * + * @dev msg.sender is used as the AVS. + */ + function deregisterOperatorFromOperatorSets( + address operator, + uint32[] calldata operatorSetIds + ) external override onlyWhenNotPaused(PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION) { + _deregisterFromOperatorSets(msg.sender, operator, operatorSetIds); + } + + /** + * @notice Called by an AVS to emit an `AVSMetadataURIUpdated` event indicating the information has updated. + * + * @param metadataURI The URI for metadata associated with an AVS. + * + * @dev Note that the `metadataURI` is *never stored* and is only emitted in the `AVSMetadataURIUpdated` event. + */ + function updateAVSMetadataURI( + string calldata metadataURI + ) external override { + emit AVSMetadataURIUpdated(msg.sender, metadataURI); + } + + /** + * @notice Called by an operator to cancel a salt that has been used to register with an AVS. + * + * @param salt A unique and single use value associated with the approver signature. + */ + function cancelSalt( + bytes32 salt + ) external override { + // Mutate `operatorSaltIsSpent` to `true` to prevent future spending. + operatorSaltIsSpent[msg.sender][salt] = true; + } + + /** + * + * LEGACY EXTERNAL FUNCTIONS - SUPPORT DEPRECATED IN FUTURE RELEASE AFTER SLASHING RELEASE + * + */ + + /** + * @notice Legacy function called by the AVS's service manager contract + * to register an operator with the AVS. NOTE: this function will be deprecated in a future release + * after the slashing release. New AVSs should use `registerOperatorToOperatorSets` instead. + * + * @param operator The address of the operator to register. + * @param operatorSignature The signature, salt, and expiry of the operator's signature. + * + * @dev msg.sender must be the AVS. + * @dev Only used by legacy M2 AVSs that have not integrated with operator sets. */ function registerOperatorToAVS( address operator, ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature - ) external onlyWhenNotPaused(PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS) { + ) external override onlyWhenNotPaused(PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS) { // Assert `operatorSignature.expiry` has not elapsed. require(operatorSignature.expiry >= block.timestamp, SignatureExpired()); + + // Assert that the AVS is not an operator set AVS. + require(!isOperatorSetAVS[msg.sender], InvalidAVS()); + // Assert that the `operator` is not actively registered to the AVS. - require( - avsOperatorStatus[msg.sender][operator] != OperatorAVSRegistrationStatus.REGISTERED, - OperatorAlreadyRegistered() - ); + require(avsOperatorStatus[msg.sender][operator] != OperatorAVSRegistrationStatus.REGISTERED, InvalidOperator()); + // Assert `operator` has not already spent `operatorSignature.salt`. - require(!operatorSaltIsSpent[operator][operatorSignature.salt], SignatureSaltSpent()); + require(!operatorSaltIsSpent[operator][operatorSignature.salt], SaltSpent()); + // Assert `operator` is a registered operator. require(delegation.isOperator(operator), OperatorDoesNotExist()); - // Calculate the digest hash - bytes32 operatorRegistrationDigestHash = calculateOperatorAVSRegistrationDigestHash({ - operator: operator, - avs: msg.sender, - salt: operatorSignature.salt, - expiry: operatorSignature.expiry + // Assert that `operatorSignature.signature` is a valid signature for the operator AVS registration. + EIP1271SignatureUtils.checkSignature_EIP1271({ + signer: operator, + digestHash: calculateOperatorAVSRegistrationDigestHash({ + operator: operator, + avs: msg.sender, + salt: operatorSignature.salt, + expiry: operatorSignature.expiry + }), + signature: operatorSignature.signature }); - // forgefmt: disable-next-item - // Check that the signature is valid - EIP1271SignatureUtils.checkSignature_EIP1271( - operator, - operatorRegistrationDigestHash, - operatorSignature.signature - ); + // Mutate `operatorSaltIsSpent` to `true` to prevent future respending. + operatorSaltIsSpent[operator][operatorSignature.salt] = true; // Set the operator as registered avsOperatorStatus[msg.sender][operator] = OperatorAVSRegistrationStatus.REGISTERED; - // Mark the salt as spent - operatorSaltIsSpent[operator][operatorSignature.salt] = true; - emit OperatorAVSRegistrationStatusUpdated(operator, msg.sender, OperatorAVSRegistrationStatus.REGISTERED); } /** - * @notice Called by an avs to deregister an operator with the avs. - * @param operator The address of the operator to deregister. + * @notice Legacy function called by an AVS to deregister an operator from the AVS. + * NOTE: this function will be deprecated in a future release after the slashing release. + * New AVSs integrating should use `deregisterOperatorFromOperatorSets` instead. + * + * @param operator The address of the operator to deregister. + * + * @dev Only used by legacy M2 AVSs that have not integrated with operator sets. */ function deregisterOperatorFromAVS( address operator - ) external onlyWhenNotPaused(PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS) { + ) external override onlyWhenNotPaused(PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS) { // Assert that operator is registered for the AVS. require( avsOperatorStatus[msg.sender][operator] == OperatorAVSRegistrationStatus.REGISTERED, OperatorNotRegistered() ); + // Assert that the AVS is not an operator set AVS. + require(!isOperatorSetAVS[msg.sender], InvalidAVS()); // Set the operator as deregistered avsOperatorStatus[msg.sender][operator] = OperatorAVSRegistrationStatus.UNREGISTERED; @@ -123,23 +331,61 @@ contract AVSDirectory is } /** - * @notice Called by an avs to emit an `AVSMetadataURIUpdated` event indicating the information has updated. - * @param metadataURI The URI for metadata associated with an avs + * + * INTERNAL FUNCTIONS + * */ - function updateAVSMetadataURI( - string calldata metadataURI - ) external { - emit AVSMetadataURIUpdated(msg.sender, metadataURI); + + /** + * @notice Helper function used by migration & registration functions to register an operator to operator sets. + * @param avs The AVS that the operator is registering to. + * @param operator The operator to register. + * @param operatorSetIds The IDs of the operator sets. + */ + function _registerToOperatorSets(address operator, address avs, uint32[] calldata operatorSetIds) internal { + // Loop over `operatorSetIds` array and register `operator` for each item. + for (uint256 i = 0; i < operatorSetIds.length; ++i) { + OperatorSet memory operatorSet = OperatorSet(avs, operatorSetIds[i]); + + require(isOperatorSet[avs][operatorSetIds[i]], InvalidOperatorSet()); + + bytes32 encodedOperatorSet = _encodeOperatorSet(operatorSet); + + require(_operatorSetsMemberOf[operator].add(encodedOperatorSet), InvalidOperator()); + + _operatorSetMembers[encodedOperatorSet].add(operator); + + OperatorSetRegistrationStatus storage registrationStatus = + operatorSetStatus[avs][operator][operatorSetIds[i]]; + + require(!registrationStatus.registered, InvalidOperator()); + + registrationStatus.registered = true; + + emit OperatorAddedToOperatorSet(operator, operatorSet); + } } /** - * @notice Called by an operator to cancel a salt that has been used to register with an AVS. - * @param salt A unique and single use value associated with the approver signature. + * @notice Internal function to deregister an operator from an operator set. + * + * @param avs The AVS that the operator is deregistering from. + * @param operator The operator to deregister. + * @param operatorSetIds The IDs of the operator sets. */ - function cancelSalt( - bytes32 salt - ) external { - operatorSaltIsSpent[msg.sender][salt] = true; + function _deregisterFromOperatorSets(address avs, address operator, uint32[] calldata operatorSetIds) internal { + // Loop over `operatorSetIds` array and deregister `operator` for each item. + for (uint256 i = 0; i < operatorSetIds.length; ++i) { + OperatorSet memory operatorSet = OperatorSet(avs, operatorSetIds[i]); + + bytes32 encodedOperatorSet = _encodeOperatorSet(operatorSet); + + require(_operatorSetsMemberOf[operator].remove(encodedOperatorSet), InvalidOperator()); + + _operatorSetMembers[encodedOperatorSet].remove(operator); + + emit OperatorRemovedFromOperatorSet(operator, operatorSet); + } } /** @@ -149,39 +395,206 @@ contract AVSDirectory is */ /** - * @notice Calculates the digest hash to be signed by an operator to register with an AVS - * @param operator The account registering as an operator - * @param avs The address of the service manager contract for the AVS that the operator is registering to - * @param salt A unique and single use value associated with the approver signature. - * @param expiry Time after which the approver's signature becomes invalid + * @notice Returns operatorSet an operator is registered to in the order they were registered. + * @param operator The operator address to query. + * @param index The index of the enumerated list of operator sets. + */ + function operatorSetsMemberOfAtIndex(address operator, uint256 index) external view returns (OperatorSet memory) { + return _decodeOperatorSet(_operatorSetsMemberOf[operator].at(index)); + } + + /** + * @notice Returns the operator registered to an operatorSet in the order that it was registered. + * @param operatorSet The operatorSet to query. + * @param index The index of the enumerated list of operators. + */ + function operatorSetMemberAtIndex(OperatorSet memory operatorSet, uint256 index) external view returns (address) { + return _operatorSetMembers[_encodeOperatorSet(operatorSet)].at(index); + } + + /** + * @notice Returns an array of operator sets an operator is registered to. + * @param operator The operator address to query. + * @param start The starting index of the array to query. + * @param length The amount of items of the array to return. + */ + function getOperatorSetsOfOperator( + address operator, + uint256 start, + uint256 length + ) public view returns (OperatorSet[] memory operatorSets) { + uint256 maxLength = _operatorSetsMemberOf[operator].length() - start; + if (length > maxLength) length = maxLength; + operatorSets = new OperatorSet[](length); + for (uint256 i; i < length; ++i) { + operatorSets[i] = _decodeOperatorSet(_operatorSetsMemberOf[operator].at(start + i)); + } + } + + /** + * @notice Returns an array of operators registered to the operatorSet. + * @param operatorSet The operatorSet to query. + * @param start The starting index of the array to query. + * @param length The amount of items of the array to return. + */ + function getOperatorsInOperatorSet( + OperatorSet memory operatorSet, + uint256 start, + uint256 length + ) external view returns (address[] memory operators) { + bytes32 encodedOperatorSet = _encodeOperatorSet(operatorSet); + uint256 maxLength = _operatorSetMembers[encodedOperatorSet].length() - start; + if (length > maxLength) length = maxLength; + operators = new address[](length); + for (uint256 i; i < length; ++i) { + operators[i] = _operatorSetMembers[encodedOperatorSet].at(start + i); + } + } + + /** + * @notice Returns the number of operators registered to an operatorSet. + * @param operatorSet The operatorSet to get the member count for + */ + function getNumOperatorsInOperatorSet( + OperatorSet memory operatorSet + ) external view returns (uint256) { + return _operatorSetMembers[_encodeOperatorSet(operatorSet)].length(); + } + + /** + * @notice Returns the total number of operator sets an operator is registered to. + * @param operator The operator address to query. + */ + function inTotalOperatorSets( + address operator + ) external view returns (uint256) { + return _operatorSetsMemberOf[operator].length(); + } + + /** + * @notice Returns whether or not an operator is registered to an operator set. + * @param operator The operator address to query. + * @param operatorSet The `OperatorSet` to query. + */ + function isMember(address operator, OperatorSet memory operatorSet) public view returns (bool) { + return _operatorSetsMemberOf[operator].contains(_encodeOperatorSet(operatorSet)); + } + + /// @notice operator is slashable by operatorSet if currently registered OR last deregistered within 21 days + function isOperatorSlashable(address operator, OperatorSet memory operatorSet) public view returns (bool) { + if (isMember(operator, operatorSet)) return true; + + OperatorSetRegistrationStatus memory status = + operatorSetStatus[operatorSet.avs][operator][operatorSet.operatorSetId]; + + return block.timestamp < status.lastDeregisteredTimestamp + DEALLOCATION_DELAY; + } + + /// @notice Returns true if all provided operator sets are valid. + function isOperatorSetBatch( + OperatorSet[] calldata operatorSets + ) public view returns (bool) { + for (uint256 i = 0; i < operatorSets.length; ++i) { + if (!isOperatorSet[operatorSets[i].avs][operatorSets[i].operatorSetId]) return false; + } + return true; + } + + /** + * @notice Calculates the digest hash to be signed by an operator to register with an AVS. + * + * @param operator The account registering as an operator. + * @param avs The AVS the operator is registering with. + * @param salt A unique and single-use value associated with the approver's signature. + * @param expiry The time after which the approver's signature becomes invalid. */ function calculateOperatorAVSRegistrationDigestHash( address operator, address avs, bytes32 salt, uint256 expiry - ) public view returns (bytes32) { - // calculate the struct hash - bytes32 structHash = keccak256(abi.encode(OPERATOR_AVS_REGISTRATION_TYPEHASH, operator, avs, salt, expiry)); - // calculate the digest hash - bytes32 digestHash = keccak256(abi.encodePacked("\x19\x01", domainSeparator(), structHash)); - return digestHash; + ) public view override returns (bytes32) { + return + _calculateDigestHash(keccak256(abi.encode(OPERATOR_AVS_REGISTRATION_TYPEHASH, operator, avs, salt, expiry))); + } + + /** + * @notice Calculates the digest hash to be signed by an operator to register with an operator set. + * + * @param avs The AVS that operator is registering to operator sets for. + * @param operatorSetIds An array of operator set IDs the operator is registering to. + * @param salt A unique and single use value associated with the approver signature. + * @param expiry Time after which the approver's signature becomes invalid. + */ + function calculateOperatorSetRegistrationDigestHash( + address avs, + uint32[] calldata operatorSetIds, + bytes32 salt, + uint256 expiry + ) public view override returns (bytes32) { + return _calculateDigestHash( + keccak256(abi.encode(OPERATOR_SET_REGISTRATION_TYPEHASH, avs, operatorSetIds, salt, expiry)) + ); } /** - * @notice Getter function for the current EIP-712 domain separator for this contract. - * @dev The domain separator will change in the event of a fork that changes the ChainID. + * @notice Calculates the digest hash to be signed by an operator to force deregister from an operator set. + * + * @param avs The AVS that operator is deregistering from. + * @param operatorSetIds An array of operator set IDs the operator is deregistering from. + * @param salt A unique and single use value associated with the approver signature. + * @param expiry Time after which the approver's signature becomes invalid. */ - function domainSeparator() public view returns (bytes32) { + function calculateOperatorSetForceDeregistrationTypehash( + address avs, + uint32[] calldata operatorSetIds, + bytes32 salt, + uint256 expiry + ) public view returns (bytes32) { + return _calculateDigestHash( + keccak256(abi.encode(OPERATOR_SET_FORCE_DEREGISTRATION_TYPEHASH, avs, operatorSetIds, salt, expiry)) + ); + } + + /// @notice Getter function for the current EIP-712 domain separator for this contract. + /// @dev The domain separator will change in the event of a fork that changes the ChainID. + function domainSeparator() public view override returns (bytes32) { + return _calculateDomainSeparator(); + } + + /// @notice Internal function for calculating the current domain separator of this contract + function _calculateDomainSeparator() internal view returns (bytes32) { if (block.chainid == ORIGINAL_CHAIN_ID) { return _DOMAIN_SEPARATOR; } else { - return _calculateDomainSeparator(); + return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("EigenLayer")), block.chainid, address(this))); } } - // @notice Internal function for calculating the current domain separator of this contract - function _calculateDomainSeparator() internal view returns (bytes32) { - return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("EigenLayer")), block.chainid, address(this))); + /// @notice Returns an EIP-712 encoded hash struct. + function _calculateDigestHash( + bytes32 structHash + ) internal view returns (bytes32) { + return keccak256(abi.encodePacked("\x19\x01", _calculateDomainSeparator(), structHash)); + } + + /// @dev Returns an `OperatorSet` encoded into a 32-byte value. + /// @param operatorSet The `OperatorSet` to encode. + function _encodeOperatorSet( + OperatorSet memory operatorSet + ) internal pure returns (bytes32) { + return bytes32(abi.encodePacked(operatorSet.avs, uint96(operatorSet.operatorSetId))); + } + + /// @dev Returns an `OperatorSet` decoded from an encoded 32-byte value. + /// @param encoded The encoded `OperatorSet` to decode. + /// @dev Assumes `encoded` is encoded via `_encodeOperatorSet(operatorSet)`. + function _decodeOperatorSet( + bytes32 encoded + ) internal pure returns (OperatorSet memory) { + return OperatorSet({ + avs: address(uint160(uint256(encoded) >> 96)), + operatorSetId: uint32(uint256(encoded) & type(uint96).max) + }); } } diff --git a/src/contracts/core/AVSDirectoryStorage.sol b/src/contracts/core/AVSDirectoryStorage.sol index 836c954b6..a835aa8dc 100644 --- a/src/contracts/core/AVSDirectoryStorage.sol +++ b/src/contracts/core/AVSDirectoryStorage.sol @@ -1,10 +1,17 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; +import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; + import "../interfaces/IAVSDirectory.sol"; import "../interfaces/IDelegationManager.sol"; abstract contract AVSDirectoryStorage is IAVSDirectory { + using EnumerableSet for EnumerableSet.Bytes32Set; + using EnumerableSet for EnumerableSet.AddressSet; + + // Constants + /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); @@ -13,9 +20,39 @@ abstract contract AVSDirectoryStorage is IAVSDirectory { bytes32 public constant OPERATOR_AVS_REGISTRATION_TYPEHASH = keccak256("OperatorAVSRegistration(address operator,address avs,bytes32 salt,uint256 expiry)"); + /// @notice The EIP-712 typehash for the `OperatorSetRegistration` struct used by the contract + bytes32 public constant OPERATOR_SET_REGISTRATION_TYPEHASH = + keccak256("OperatorSetRegistration(address avs,uint32[] operatorSetIds,bytes32 salt,uint256 expiry)"); + + /// @notice The EIP-712 typehash for the `OperatorSetMembership` struct used by the contract + bytes32 public constant OPERATOR_SET_FORCE_DEREGISTRATION_TYPEHASH = + keccak256("OperatorSetForceDeregistration(address avs,uint32[] operatorSetIds,bytes32 salt,uint256 expiry)"); + + /// @notice The EIP-712 typehash for the `MagnitudeAdjustments` struct used by the contract + bytes32 public constant MAGNITUDE_ADJUSTMENT_TYPEHASH = keccak256( + "MagnitudeAdjustments(address operator,MagnitudeAdjustment(address strategy, OperatorSet(address avs, uint32 operatorSetId)[], uint64[] magnitudeDiffs)[],bytes32 salt,uint256 expiry)" + ); + + /// @dev Index for flag that pauses operator register/deregister to avs when set. + uint8 internal constant PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS = 0; + + /// @dev Index for flag that pauses operator register/deregister to operator sets when set. + uint8 internal constant PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION = 1; + + // Immutables + /// @notice The DelegationManager contract for EigenLayer IDelegationManager public immutable delegation; + /// @notice Delay before deallocations are completable and can be added back into freeMagnitude + /// In this window, deallocations still remain slashable by the operatorSet they were allocated to. + uint32 public immutable DEALLOCATION_DELAY; + + /// @dev Returns the chain ID from the time the contract was deployed. + uint256 internal immutable ORIGINAL_CHAIN_ID; + + // Mutatables + /** * @notice Original EIP-712 Domain separator for this contract. * @dev The domain separator may change in the event of a fork that modifies the ChainID. @@ -23,17 +60,36 @@ abstract contract AVSDirectoryStorage is IAVSDirectory { */ bytes32 internal _DOMAIN_SEPARATOR; - /// @notice Mapping: AVS => operator => enum of operator status to the AVS + /// @notice Mapping: avs => operator => OperatorAVSRegistrationStatus struct + /// @dev This storage will be deprecated once M2 based deregistration is deprecated. mapping(address => mapping(address => OperatorAVSRegistrationStatus)) public avsOperatorStatus; - /// @notice Mapping: operator => 32-byte salt => whether or not the salt has already been used by the operator. - /// @dev Salt is used in the `registerOperatorToAVS` function. + /// @notice Mapping: operator => salt => Whether the salt has been used or not. mapping(address => mapping(bytes32 => bool)) public operatorSaltIsSpent; - constructor( - IDelegationManager _delegation - ) { + /// @notice Mapping: avs => Whether it is a an operator set AVS or not. + mapping(address => bool) public isOperatorSetAVS; + + /// @notice Mapping: avs => operatorSetId => Whether or not an operator set is valid. + mapping(address => mapping(uint32 => bool)) public isOperatorSet; + + /// @notice Mapping: operator => List of operator sets that operator is registered to. + /// @dev Each item is formatted as such: bytes32(abi.encodePacked(avs, uint96(operatorSetId))) + mapping(address => EnumerableSet.Bytes32Set) internal _operatorSetsMemberOf; + + /// @notice Mapping: operatorSet => List of operators that are registered to the operatorSet + /// @dev Each key is formatted as such: bytes32(abi.encodePacked(avs, uint96(operatorSetId))) + mapping(bytes32 => EnumerableSet.AddressSet) internal _operatorSetMembers; + + /// @notice Mapping: operator => avs => operatorSetId => operator registration status + mapping(address => mapping(address => mapping(uint32 => OperatorSetRegistrationStatus))) public operatorSetStatus; + + // Construction + + constructor(IDelegationManager _delegation, uint32 _DEALLOCATION_DELAY) { delegation = _delegation; + DEALLOCATION_DELAY = _DEALLOCATION_DELAY; + ORIGINAL_CHAIN_ID = block.chainid; } /** @@ -41,5 +97,5 @@ abstract contract AVSDirectoryStorage is IAVSDirectory { * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ - uint256[47] private __gap; + uint256[42] private __gap; } diff --git a/src/contracts/core/AllocationManager.sol b/src/contracts/core/AllocationManager.sol new file mode 100644 index 000000000..8748c860b --- /dev/null +++ b/src/contracts/core/AllocationManager.sol @@ -0,0 +1,617 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.27; + +import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; +import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; +import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol"; + +import "../permissions/Pausable.sol"; +import "../libraries/EIP1271SignatureUtils.sol"; +import "../libraries/SlashingLib.sol"; +import "./AllocationManagerStorage.sol"; + +contract AllocationManager is + Initializable, + OwnableUpgradeable, + Pausable, + AllocationManagerStorage, + ReentrancyGuardUpgradeable +{ + using Snapshots for Snapshots.History; + + /** + * + * INITIALIZING FUNCTIONS + * + */ + + /** + * @dev Initializes the immutable addresses of the strategy mananger, delegationManage, + * and eigenpodManager contracts + */ + constructor( + IDelegationManager _delegation, + IAVSDirectory _avsDirectory, + uint32 _DEALLOCATION_DELAY, + uint32 _ALLOCATION_CONFIGURATION_DELAY + ) AllocationManagerStorage(_delegation, _avsDirectory, _DEALLOCATION_DELAY, _ALLOCATION_CONFIGURATION_DELAY) { + _disableInitializers(); + } + + /** + * @dev Initializes the addresses of the initial owner, pauser registry, and paused status. + * minWithdrawalDelayBlocks is set only once here + */ + function initialize( + address initialOwner, + IPauserRegistry _pauserRegistry, + uint256 initialPausedStatus + ) external initializer { + _initializePauser(_pauserRegistry, initialPausedStatus); + _DOMAIN_SEPARATOR = _calculateDomainSeparator(); + _transferOwnership(initialOwner); + } + + /** + * @notice Called by the delagation manager to set delay when operators register. + * @param operator The operator to set the delay on behalf of. + * @param delay The allocation delay in seconds. + * @dev msg.sender is assumed to be the delegation manager. + */ + function setAllocationDelay(address operator, uint32 delay) external { + require(msg.sender == address(delegation), OnlyDelegationManager()); + _setAllocationDelay(operator, delay); + } + + /** + * @notice Called by operators to set their allocation delay. + * @param delay the allocation delay in seconds + * @dev msg.sender is assumed to be the operator + */ + function setAllocationDelay( + uint32 delay + ) external { + require(delegation.isOperator(msg.sender), OperatorNotRegistered()); + _setAllocationDelay(msg.sender, delay); + } + + /** + * @notice For all pending deallocations that have become completable, their pending free magnitude can be + * added back to the free magnitude of the (operator, strategy) amount. This function takes a list of strategies + * and adds all completable deallocations for each strategy, updating the freeMagnitudes of the operator + * + * @param operator address to complete deallocations for + * @param strategies a list of strategies to complete deallocations for + * @param numToComplete a list of number of pending free magnitude deallocations to complete for each strategy + * + * @dev can be called permissionlessly by anyone + */ + function completePendingDeallocations( + address operator, + IStrategy[] calldata strategies, + uint16[] calldata numToComplete + ) external onlyWhenNotPaused(PAUSED_STAKE_ALLOCATIONS_AND_DEALLOCATIONS) { + require(strategies.length == numToComplete.length, InputArrayLengthMismatch()); + require(delegation.isOperator(operator), OperatorNotRegistered()); + for (uint256 i = 0; i < strategies.length; ++i) { + _completePendingDeallocations({operator: operator, strategy: strategies[i], numToComplete: numToComplete[i]}); + } + } + + /** + * @notice Modifies the propotions of slashable stake allocated to a list of operatorSets for a set of strategies + * @param operator address to modify allocations for + * @param allocations array of magnitude adjustments for multiple strategies and corresponding operator sets + * @param operatorSignature signature of the operator if msg.sender is not the operator + * @dev Updates freeMagnitude for the updated strategies + * @dev Must be called by the operator or with a valid operator signature + * @dev For each allocation, allocation.operatorSets MUST be ordered in ascending order according to the + * encoding of the operatorSet. This is to prevent duplicate operatorSets being passed in. The easiest way to ensure + * ordering is to sort allocated operatorSets by address first, and then sort for each avs by ascending operatorSetIds. + */ + function modifyAllocations( + address operator, + MagnitudeAllocation[] calldata allocations, + SignatureWithSaltAndExpiry calldata operatorSignature + ) external onlyWhenNotPaused(PAUSED_STAKE_ALLOCATIONS_AND_DEALLOCATIONS) { + if (msg.sender != operator) { + _verifyOperatorSignature(operator, allocations, operatorSignature); + } + require(delegation.isOperator(operator), OperatorNotRegistered()); + + (bool isSet, uint32 operatorAllocationDelay) = allocationDelay(operator); + require(isSet, UninitializedAllocationDelay()); + + for (uint256 i = 0; i < allocations.length; ++i) { + MagnitudeAllocation calldata allocation = allocations[i]; + require(allocation.operatorSets.length == allocation.magnitudes.length, InputArrayLengthMismatch()); + require(avsDirectory.isOperatorSetBatch(allocation.operatorSets), InvalidOperatorSet()); + + // 1. For the given (operator,strategy) complete any pending deallocations to update free magnitude + _completePendingDeallocations({ + operator: operator, + strategy: allocation.strategy, + numToComplete: type(uint16).max + }); + + { + // 2. Check current totalMagnitude matches expected value. This is to check for slashing race conditions + // where an operator gets slashed from an operatorSet and as a result all the configured allocations have larger + // proprtional magnitudes relative to each other. + + // Load the operator's total magnitude for the strategy. + (bool exists,, uint224 currentTotalMagnitude) = + _totalMagnitudeUpdate[operator][allocation.strategy].latestSnapshot(); + + // If the operator has no total magnitude snapshot, set it to WAD, which denotes an unslashed operator. + if (!exists) { + currentTotalMagnitude = WAD; + _totalMagnitudeUpdate[operator][allocation.strategy].push({ + key: uint32(block.timestamp), + value: currentTotalMagnitude + }); + operatorFreeMagnitudeInfo[operator][allocation.strategy].freeMagnitude = + uint64(currentTotalMagnitude); + } + + // 3. set allocations for the strategy after updating freeMagnitude + require( + uint64(currentTotalMagnitude) == allocation.expectedTotalMagnitude, InvalidExpectedTotalMagnitude() + ); + } + + for (uint256 j = 0; j < allocation.operatorSets.length; ++j) { + // Check that there are no pending allocations & deallocations for the operator, operatorSet, strategy + MagnitudeInfo memory mInfo = _getCurrentEffectiveMagnitude( + operator, allocation.strategy, _encodeOperatorSet(allocation.operatorSets[j]) + ); + require(block.timestamp >= mInfo.effectTimestamp, ModificationAlreadyPending()); + + // Calculate the new pending diff with this modification + mInfo.pendingMagnitudeDiff = + int128(uint128(allocation.magnitudes[j])) - int128(uint128(mInfo.currentMagnitude)); + require(mInfo.pendingMagnitudeDiff != 0, SameMagnitude()); + + // Handle deallocation/allocation and modification effect timestamp + if (mInfo.pendingMagnitudeDiff < 0) { + // This is a deallocation + + // 1. push PendingFreeMagnitude and respective array index into (op,opSet,Strategy) queued deallocations + deallocationQueue[operator][allocation.strategy].push( + _encodeOperatorSet(allocation.operatorSets[j]) + ); + + // 2. Update the effect timestamp for the deallocation + mInfo.effectTimestamp = uint32(block.timestamp) + DEALLOCATION_DELAY; + } else if (mInfo.pendingMagnitudeDiff > 0) { + // This is an allocation + + // 1. decrement free magnitude by incremented amount + uint64 magnitudeToAllocate = uint64(uint128(mInfo.pendingMagnitudeDiff)); + FreeMagnitudeInfo memory freeInfo = operatorFreeMagnitudeInfo[operator][allocation.strategy]; + require(freeInfo.freeMagnitude >= magnitudeToAllocate, InsufficientAllocatableMagnitude()); + freeInfo.freeMagnitude -= magnitudeToAllocate; + + // 2. Update the effectTimestamp for the allocation + mInfo.effectTimestamp = uint32(block.timestamp) + operatorAllocationDelay; + + operatorFreeMagnitudeInfo[operator][allocation.strategy] = freeInfo; + } + + // Allocate magnitude which will take effect at the `effectTimestamp` + _operatorMagnitudeInfo[operator][allocation.strategy][_encodeOperatorSet(allocation.operatorSets[j])] = + mInfo; + } + } + } + + /** + * @notice Called by an AVS to slash an operator for given operatorSetId, list of strategies, and bipsToSlash. + * For each given (operator, operatorSetId, strategy) tuple, bipsToSlash + * bips of the operatorSet's slashable stake allocation will be slashed + * + * @param operator the address to slash + * @param operatorSetId the ID of the operatorSet the operator is being slashed on behalf of + * @param strategies the set of strategies to slash + * @param bipsToSlash the number of bips to slash, this will be proportional to the + * operator's slashable stake allocation for the operatorSet + */ + function slashOperator( + address operator, + uint32 operatorSetId, + IStrategy[] calldata strategies, + uint16 bipsToSlash + ) external onlyWhenNotPaused(PAUSED_OPERATOR_SLASHING) { + require(0 < bipsToSlash && bipsToSlash <= BIPS_FACTOR, InvalidBipsToSlash()); + OperatorSet memory operatorSet = OperatorSet({avs: msg.sender, operatorSetId: operatorSetId}); + require(avsDirectory.isOperatorSlashable(operator, operatorSet), InvalidOperator()); + bytes32 operatorSetKey = _encodeOperatorSet(operatorSet); + + for (uint256 i = 0; i < strategies.length; ++i) { + // 1. Slash from pending deallocations and allocations + MagnitudeInfo memory mInfo = _getCurrentEffectiveMagnitude(operator, strategies[i], operatorSetKey); + + uint64 slashedMagnitude = uint64(mInfo.currentMagnitude * bipsToSlash / BIPS_FACTOR); + mInfo.currentMagnitude -= slashedMagnitude; + // if there is a pending deallocation, slash pending deallocation proportionally + if (mInfo.pendingMagnitudeDiff < 0) { + uint128 slashedPending = uint128(uint128(-mInfo.pendingMagnitudeDiff) * bipsToSlash / BIPS_FACTOR); + mInfo.pendingMagnitudeDiff += int128(slashedPending); + } + // update operatorMagnitudeInfo + _operatorMagnitudeInfo[operator][strategies[i]][operatorSetKey] = mInfo; + + // 2. update totalMagnitude, get total magnitude and subtract slashedMagnitude + // this will be reflected in the conversion of delegatedShares to shares in the DM + Snapshots.History storage totalMagnitudes = _totalMagnitudeUpdate[operator][strategies[i]]; + totalMagnitudes.push({key: uint32(block.timestamp), value: totalMagnitudes.latest() - slashedMagnitude}); + } + } + + /** + * @notice Called by an operator to cancel a salt that has been used to register with an AVS. + * + * @param salt A unique and single use value associated with the approver signature. + */ + function cancelSalt( + bytes32 salt + ) external override { + // Mutate `operatorSaltIsSpent` to `true` to prevent future spending. + operatorSaltIsSpent[msg.sender][salt] = true; + } + + /** + * @notice Helper for setting an operators allocation delay. + * @param operator The operator to set the delay on behalf of. + * @param delay The allocation delay in seconds. + */ + function _setAllocationDelay(address operator, uint32 delay) internal { + require(delay != 0, InvalidDelay()); + + AllocationDelayInfo memory info = _allocationDelayInfo[operator]; + + if (info.pendingDelay != 0 && block.timestamp >= info.pendingDelayEffectTimestamp) { + info.delay = info.pendingDelay; + } + + info.pendingDelay = delay; + info.pendingDelayEffectTimestamp = uint32(block.timestamp + ALLOCATION_CONFIGURATION_DELAY); + + _allocationDelayInfo[operator] = info; + emit AllocationDelaySet(operator, delay); + } + + /** + * @notice For a single strategy, complete pending deallocations and free up their magnitude + * @param operator address to update freeMagnitude for + * @param strategy the strategy to update freeMagnitude for + * @param numToComplete the number of pending free magnitudes deallocations to complete + * @dev read through pending free magnitudes and add to freeMagnitude if completableTimestamp is >= block timestamp + * In addition to updating freeMagnitude, updates next starting index to read from for pending free magnitudes after completing + */ + function _completePendingDeallocations(address operator, IStrategy strategy, uint16 numToComplete) internal { + FreeMagnitudeInfo memory freeInfo = operatorFreeMagnitudeInfo[operator][strategy]; + + uint256 numDeallocations = deallocationQueue[operator][strategy].length; + uint256 completed; + + while (freeInfo.nextPendingIndex < numDeallocations && completed < numToComplete) { + bytes32 opsetKey = deallocationQueue[operator][strategy][freeInfo.nextPendingIndex]; + MagnitudeInfo memory mInfo = _operatorMagnitudeInfo[operator][strategy][opsetKey]; + + // deallocationQueue is ordered by `effectTimestamp`. If we reach a pending deallocation + // that cannot be completed, we're done. + if (block.timestamp < mInfo.effectTimestamp) { + break; + } + + // We know that this is a deallocation because this `opsetKey` was in the pending deallocation set + // Therefore, `pendingMagnitudeDiff` MUST be negative. + uint64 freeMagnitudeToAdd = uint64(uint128(-mInfo.pendingMagnitudeDiff)); + mInfo.pendingMagnitudeDiff = 0; + mInfo.currentMagnitude -= freeMagnitudeToAdd; + + // Add newly-freed magnitude to FreeMagnitudeInfo + freeInfo.freeMagnitude += freeMagnitudeToAdd; + freeInfo.nextPendingIndex++; + ++completed; + + // Update MagnitudeInfo in storage + _operatorMagnitudeInfo[operator][strategy][opsetKey] = mInfo; + } + + operatorFreeMagnitudeInfo[operator][strategy] = freeInfo; + } + + /// @dev Fetch the operator's current magnitude, applying a pending diff if the effect timestamp is passed + /// @notice This may return something that is not recorded in state. Remember to store this updated value if needed! + function _getCurrentEffectiveMagnitude( + address operator, + IStrategy strategy, + bytes32 operatorSetKey + ) internal view returns (MagnitudeInfo memory) { + MagnitudeInfo memory mInfo = _operatorMagnitudeInfo[operator][strategy][operatorSetKey]; + + // If the magnitude change is not yet in effect, return unaltered + if (block.timestamp < mInfo.effectTimestamp) { + return mInfo; + } + + // Otherwise, calculate the new current magnitude and return the modified struct + if (mInfo.pendingMagnitudeDiff >= 0) { + mInfo.currentMagnitude += uint64(uint128(mInfo.pendingMagnitudeDiff)); + } else { + mInfo.currentMagnitude -= uint64(uint128(-mInfo.pendingMagnitudeDiff)); + } + + mInfo.pendingMagnitudeDiff = 0; + return mInfo; + } + + /** + * @notice Returns the allocation delay of an operator + * @param operator The operator to get the allocation delay for + */ + function allocationDelay( + address operator + ) public view returns (bool isSet, uint32 delay) { + AllocationDelayInfo memory info = _allocationDelayInfo[operator]; + + if (info.pendingDelay != 0 && block.timestamp >= info.pendingDelayEffectTimestamp) { + return (true, info.pendingDelay); + } else { + return (info.delay != 0, info.delay); + } + } + + /** + * @param operator the operator to get the slashable magnitude for + * @param strategies the strategies to get the slashable magnitude for + * + * @return operatorSets the operator sets the operator is a member of and the current slashable magnitudes for each strategy + */ + function getSlashableMagnitudes( + address operator, + IStrategy[] calldata strategies + ) external view returns (OperatorSet[] memory, uint64[][] memory) { + OperatorSet[] memory operatorSets = avsDirectory.getOperatorSetsOfOperator(operator, 0, type(uint256).max); + uint64[][] memory slashableMagnitudes = new uint64[][](strategies.length); + for (uint256 i = 0; i < strategies.length; ++i) { + slashableMagnitudes[i] = new uint64[](operatorSets.length); + for (uint256 j = 0; j < operatorSets.length; ++j) { + MagnitudeInfo memory mInfo = + _getCurrentEffectiveMagnitude(operator, strategies[i], _encodeOperatorSet(operatorSets[j])); + slashableMagnitudes[i][j] = mInfo.currentMagnitude; + } + } + return (operatorSets, slashableMagnitudes); + } + + /** + * @notice Get the allocatable magnitude for an operator and strategy based on number of pending deallocations + * that could be completed at the same time. This is the sum of freeMagnitude and the sum of all pending completable deallocations. + * @param operator the operator to get the allocatable magnitude for + * @param strategy the strategy to get the allocatable magnitude for + */ + function getAllocatableMagnitude(address operator, IStrategy strategy) external view returns (uint64) { + FreeMagnitudeInfo memory info = operatorFreeMagnitudeInfo[operator][strategy]; + uint256 numDeallocations = deallocationQueue[operator][strategy].length; + uint64 freeMagnitudeToAdd = 0; + for (uint192 i = info.nextPendingIndex; i < numDeallocations; ++i) { + bytes32 opsetKey = deallocationQueue[operator][strategy][i]; + MagnitudeInfo memory opsetMagnitudeInfo = _operatorMagnitudeInfo[operator][strategy][opsetKey]; + if (block.timestamp < opsetMagnitudeInfo.effectTimestamp) { + break; + } + freeMagnitudeToAdd += uint64(uint128(-opsetMagnitudeInfo.pendingMagnitudeDiff)); + } + return info.freeMagnitude + freeMagnitudeToAdd; + } + + /** + * @notice Returns the current total magnitudes of an operator for a given set of strategies + * @param operator the operator to get the total magnitude for + * @param strategies the strategies to get the total magnitudes for + * @return totalMagnitudes the total magnitudes for each strategy + */ + function getTotalMagnitudes( + address operator, + IStrategy[] calldata strategies + ) external view returns (uint64[] memory) { + uint64[] memory totalMagnitudes = new uint64[](strategies.length); + for (uint256 i = 0; i < strategies.length; ++i) { + (bool exists,, uint224 value) = _totalMagnitudeUpdate[operator][strategies[i]].latestSnapshot(); + if (!exists) { + totalMagnitudes[i] = WAD; + } else { + totalMagnitudes[i] = uint64(value); + } + } + return totalMagnitudes; + } + + /** + * @notice Returns the total magnitudes of an operator for a given set of strategies at a given timestamp + * @param operator the operator to get the total magnitude for + * @param strategies the strategies to get the total magnitudes for + * @param timestamp the timestamp to get the total magnitudes at + * @return totalMagnitudes the total magnitudes for each strategy + */ + function getTotalMagnitudesAtTimestamp( + address operator, + IStrategy[] calldata strategies, + uint32 timestamp + ) external view returns (uint64[] memory) { + uint64[] memory totalMagnitudes = new uint64[](strategies.length); + for (uint256 i = 0; i < strategies.length; ++i) { + (uint224 value, uint256 pos) = _totalMagnitudeUpdate[operator][strategies[i]].upperLookupWithPos(timestamp); + // if there is no existing total magnitude snapshot + if (value == 0 && pos == 0) { + totalMagnitudes[i] = WAD; + } else { + totalMagnitudes[i] = uint64(value); + } + } + return totalMagnitudes; + } + + /** + * @notice Returns the current total magnitude of an operator for a given strategy + * @param operator the operator to get the total magnitude for + * @param strategy the strategy to get the total magnitude for + * @return totalMagnitude the total magnitude for the strategy + */ + function getTotalMagnitude(address operator, IStrategy strategy) external view returns (uint64) { + uint64 totalMagnitude; + (bool exists,, uint224 value) = _totalMagnitudeUpdate[operator][strategy].latestSnapshot(); + if (!exists) { + totalMagnitude = WAD; + } else { + totalMagnitude = uint64(value); + } + return totalMagnitude; + } + + /** + * @notice Returns the latest pending allocation of an operator for a given strategy and operatorSets. + * One of the assumptions here is we don't allow more than one pending allocation for an operatorSet at a time. + * If that changes, we would need to change this function to return all pending allocations for an operatorSet. + * @param operator the operator to get the pending allocations for + * @param strategy the strategy to get the pending allocations for + * @param operatorSets the operatorSets to get the pending allocations for + * @return pendingMagnitudes the pending allocations for each operatorSet + * @return timestamps the timestamps for each pending allocation + */ + function getPendingAllocations( + address operator, + IStrategy strategy, + OperatorSet[] calldata operatorSets + ) external view returns (uint64[] memory pendingMagnitudes, uint32[] memory timestamps) { + pendingMagnitudes = new uint64[](operatorSets.length); + timestamps = new uint32[](operatorSets.length); + for (uint256 i = 0; i < operatorSets.length; ++i) { + MagnitudeInfo memory opsetMagnitudeInfo = + _operatorMagnitudeInfo[operator][strategy][_encodeOperatorSet(operatorSets[i])]; + + if (opsetMagnitudeInfo.effectTimestamp < block.timestamp && opsetMagnitudeInfo.pendingMagnitudeDiff > 0) { + pendingMagnitudes[i] = + opsetMagnitudeInfo.currentMagnitude + uint64(uint128(opsetMagnitudeInfo.pendingMagnitudeDiff)); + timestamps[i] = opsetMagnitudeInfo.effectTimestamp; + } else { + pendingMagnitudes[i] = 0; + timestamps[i] = 0; + } + } + } + + /** + * @notice Returns the pending deallocations of an operator for a given strategy and operatorSets. + * One of the assumptions here is we don't allow more than one pending deallocation for an operatorSet at a time. + * If that changes, we would need to change this function to return all pending deallocations for an operatorSet. + * @param operator the operator to get the pending deallocations for + * @param strategy the strategy to get the pending deallocations for + * @param operatorSets the operatorSets to get the pending deallocations for + * @return pendingMagnitudeDiffs the pending deallocation diffs for each operatorSet + * @return timestamps the timestamps for each pending dealloction + */ + function getPendingDeallocations( + address operator, + IStrategy strategy, + OperatorSet[] calldata operatorSets + ) external view returns (uint64[] memory pendingMagnitudeDiffs, uint32[] memory timestamps) { + pendingMagnitudeDiffs = new uint64[](operatorSets.length); + timestamps = new uint32[](operatorSets.length); + + for (uint256 i = 0; i < operatorSets.length; ++i) { + MagnitudeInfo memory opsetMagnitudeInfo = + _operatorMagnitudeInfo[operator][strategy][_encodeOperatorSet(operatorSets[i])]; + + if (opsetMagnitudeInfo.effectTimestamp < block.timestamp && opsetMagnitudeInfo.pendingMagnitudeDiff < 0) { + pendingMagnitudeDiffs[i] = uint64(uint128(-opsetMagnitudeInfo.pendingMagnitudeDiff)); + timestamps[i] = opsetMagnitudeInfo.effectTimestamp; + pendingMagnitudeDiffs[i] = 0; + } + } + } + + /// @dev Verify operator's signature and spend salt + function _verifyOperatorSignature( + address operator, + MagnitudeAllocation[] calldata allocations, + SignatureWithSaltAndExpiry calldata operatorSignature + ) internal { + // check the signature expiry + require(operatorSignature.expiry >= block.timestamp, SignatureExpired()); + // Assert operator's signature cannot be replayed. + require(!avsDirectory.operatorSaltIsSpent(operator, operatorSignature.salt), SaltSpent()); + + bytes32 digestHash = calculateMagnitudeAllocationDigestHash( + operator, allocations, operatorSignature.salt, operatorSignature.expiry + ); + + // Assert operator's signature is valid. + EIP1271SignatureUtils.checkSignature_EIP1271(operator, digestHash, operatorSignature.signature); + // Spend salt. + operatorSaltIsSpent[operator][operatorSignature.salt] = true; + } + + /** + * @notice Calculates the digest hash to be signed by an operator to modify magnitude allocations + * @param operator The operator to allocate or deallocate magnitude for. + * @param allocations The magnitude allocations/deallocations to be made. + * @param salt A unique and single use value associated with the approver signature. + * @param expiry Time after which the approver's signature becomes invalid. + */ + function calculateMagnitudeAllocationDigestHash( + address operator, + MagnitudeAllocation[] calldata allocations, + bytes32 salt, + uint256 expiry + ) public view returns (bytes32) { + return _calculateDigestHash( + keccak256(abi.encode(MAGNITUDE_ADJUSTMENT_TYPEHASH, operator, allocations, salt, expiry)) + ); + } + + /// @notice Getter function for the current EIP-712 domain separator for this contract. + /// @dev The domain separator will change in the event of a fork that changes the ChainID. + function domainSeparator() public view override returns (bytes32) { + return _calculateDomainSeparator(); + } + + /// @notice Internal function for calculating the current domain separator of this contract + function _calculateDomainSeparator() internal view returns (bytes32) { + if (block.chainid == ORIGINAL_CHAIN_ID) { + return _DOMAIN_SEPARATOR; + } else { + return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("EigenLayer")), block.chainid, address(this))); + } + } + + /// @notice Returns an EIP-712 encoded hash struct. + function _calculateDigestHash( + bytes32 structHash + ) internal view returns (bytes32) { + return keccak256(abi.encodePacked("\x19\x01", _calculateDomainSeparator(), structHash)); + } + + /// @dev Returns an `OperatorSet` encoded into a 32-byte value. + /// @param operatorSet The `OperatorSet` to encode. + function _encodeOperatorSet( + OperatorSet memory operatorSet + ) internal pure returns (bytes32) { + return bytes32(abi.encodePacked(operatorSet.avs, uint96(operatorSet.operatorSetId))); + } + + /// @dev Returns an `OperatorSet` decoded from an encoded 32-byte value. + /// @param encoded The encoded `OperatorSet` to decode. + /// @dev Assumes `encoded` is encoded via `_encodeOperatorSet(operatorSet)`. + function _decodeOperatorSet( + bytes32 encoded + ) internal pure returns (OperatorSet memory) { + return OperatorSet({ + avs: address(uint160(uint256(encoded) >> 96)), + operatorSetId: uint32(uint256(encoded) & type(uint96).max) + }); + } +} diff --git a/src/contracts/core/AllocationManagerStorage.sol b/src/contracts/core/AllocationManagerStorage.sol new file mode 100644 index 000000000..b9087f429 --- /dev/null +++ b/src/contracts/core/AllocationManagerStorage.sol @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.27; + +import "../interfaces/IAllocationManager.sol"; +import "../interfaces/IAVSDirectory.sol"; +import "../interfaces/IDelegationManager.sol"; +import {Snapshots} from "../libraries/Snapshots.sol"; + +abstract contract AllocationManagerStorage is IAllocationManager { + using Snapshots for Snapshots.History; + + // Constants + + /// @notice The EIP-712 typehash for the contract's domain + bytes32 public constant DOMAIN_TYPEHASH = + keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); + + /// @notice The EIP-712 typehash for the `MagnitudeAdjustments` struct used by the contract + bytes32 public constant MAGNITUDE_ADJUSTMENT_TYPEHASH = keccak256( + "MagnitudeAdjustments(address operator,MagnitudeAdjustment(address strategy, OperatorSet(address avs, uint32 operatorSetId)[], uint64[] magnitudeDiffs)[],bytes32 salt,uint256 expiry)" + ); + + /// @dev Index for flag that pauses operator allocations/deallocations when set. + uint8 internal constant PAUSED_STAKE_ALLOCATIONS_AND_DEALLOCATIONS = 0; + + /// @dev Index for flag that pauses operator register/deregister to operator sets when set. + uint8 internal constant PAUSED_OPERATOR_SLASHING = 1; + + /// @dev BIPS factor for slashable bips + uint256 internal constant BIPS_FACTOR = 10_000; + + /// @dev Maximum number of pending updates that can be queued for allocations/deallocations + uint256 internal constant MAX_PENDING_UPDATES = 1; + + // Immutables + + /// @notice The DelegationManager contract for EigenLayer + IDelegationManager public immutable delegation; + + /// @notice The AVSDirectory contract for EigenLayer + IAVSDirectory public immutable avsDirectory; + + /// @notice Delay before deallocations are completable and can be added back into freeMagnitude + /// In this window, deallocations still remain slashable by the operatorSet they were allocated to. + uint32 public immutable DEALLOCATION_DELAY; + + /// @dev Delay before alloaction delay modifications take effect. + uint32 public immutable ALLOCATION_CONFIGURATION_DELAY; // QUESTION: 21 days? + + /// @dev Returns the chain ID from the time the contract was deployed. + uint256 internal immutable ORIGINAL_CHAIN_ID; + + // Mutatables + + /** + * @notice Original EIP-712 Domain separator for this contract. + * @dev The domain separator may change in the event of a fork that modifies the ChainID. + * Use the getter function `domainSeparator` to get the current domain separator for this contract. + */ + bytes32 internal _DOMAIN_SEPARATOR; + + /// @notice Mapping: operator => salt => Whether the salt has been used or not. + mapping(address => mapping(bytes32 => bool)) public operatorSaltIsSpent; + + /// @notice Mapping: operator => strategy => snapshotted totalMagnitude + /// Note that totalMagnitude is monotonically decreasing and only gets updated upon slashing + mapping(address => mapping(IStrategy => Snapshots.History)) internal _totalMagnitudeUpdate; + + /// @notice Mapping: operator => strategy => OperatorMagnitudeInfo to keep track of info regarding pending magnitude allocations. + mapping(address => mapping(IStrategy => FreeMagnitudeInfo)) public operatorFreeMagnitudeInfo; + + /// @notice Mapping: operator => strategy => operatorSet (encoded) => MagnitudeInfo + mapping(address => mapping(IStrategy => mapping(bytes32 => MagnitudeInfo))) internal _operatorMagnitudeInfo; + + /// @notice Mapping: operator => strategy => operatorSet[] (encoded) to keep track of pending free magnitude for operatorSet from deallocations + mapping(address => mapping(IStrategy => bytes32[])) internal deallocationQueue; + + /// @notice Mapping: operator => allocation delay (in seconds) for the operator. + /// This determines how long it takes for allocations to take effect in the future. + mapping(address => AllocationDelayInfo) internal _allocationDelayInfo; + + // Construction + + constructor( + IDelegationManager _delegation, + IAVSDirectory _avsDirectory, + uint32 _DEALLOCATION_DELAY, + uint32 _ALLOCATION_CONFIGURATION_DELAY + ) { + delegation = _delegation; + avsDirectory = _avsDirectory; + DEALLOCATION_DELAY = _DEALLOCATION_DELAY; + ALLOCATION_CONFIGURATION_DELAY = _ALLOCATION_CONFIGURATION_DELAY; + ORIGINAL_CHAIN_ID = block.chainid; + } + + /** + * @dev This empty reserved space is put in place to allow future versions to add new + * variables without shifting down storage in the inheritance chain. + * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps + */ + uint256[44] private __gap; +} diff --git a/src/contracts/core/DelegationManager.sol b/src/contracts/core/DelegationManager.sol index 770811ede..559202130 100644 --- a/src/contracts/core/DelegationManager.sol +++ b/src/contracts/core/DelegationManager.sol @@ -4,8 +4,10 @@ pragma solidity ^0.8.27; import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol"; + import "../permissions/Pausable.sol"; import "../libraries/EIP1271SignatureUtils.sol"; +import "../libraries/SlashingLib.sol"; import "./DelegationManagerStorage.sol"; /** @@ -25,27 +27,19 @@ contract DelegationManager is DelegationManagerStorage, ReentrancyGuardUpgradeable { - // @dev Index for flag that pauses new delegations when set - uint8 internal constant PAUSED_NEW_DELEGATION = 0; - - // @dev Index for flag that pauses queuing new withdrawals when set. - uint8 internal constant PAUSED_ENTER_WITHDRAWAL_QUEUE = 1; - - // @dev Index for flag that pauses completing existing withdrawals when set. - uint8 internal constant PAUSED_EXIT_WITHDRAWAL_QUEUE = 2; - - // @dev Chain ID at the time of contract deployment - uint256 internal immutable ORIGINAL_CHAIN_ID; - - // @dev Maximum Value for `stakerOptOutWindowBlocks`. Approximately equivalent to 6 months in blocks. - uint256 public constant MAX_STAKER_OPT_OUT_WINDOW_BLOCKS = (180 days) / 12; - - /// @notice Canonical, virtual beacon chain ETH strategy - IStrategy public constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0); + using SlashingLib for *; // @notice Simple permission for functions that are only callable by the StrategyManager contract OR by the EigenPodManagerContract modifier onlyStrategyManagerOrEigenPodManager() { - require(msg.sender == address(strategyManager) || msg.sender == address(eigenPodManager), UnauthorizedCaller()); + require( + (msg.sender == address(strategyManager) || msg.sender == address(eigenPodManager)), + OnlyStrategyManagerOrEigenPodManager() + ); + _; + } + + modifier onlyEigenPodManager() { + require(msg.sender == address(eigenPodManager), OnlyEigenPodManager()); _; } @@ -56,15 +50,24 @@ contract DelegationManager is */ /** - * @dev Initializes the immutable addresses of the strategy mananger and slasher. + * @dev Initializes the immutable addresses of the strategy mananger, eigenpod manager, and allocation manager. */ constructor( + IAVSDirectory _avsDirectory, IStrategyManager _strategyManager, - ISlasher _slasher, - IEigenPodManager _eigenPodManager - ) DelegationManagerStorage(_strategyManager, _slasher, _eigenPodManager) { + IEigenPodManager _eigenPodManager, + IAllocationManager _allocationManager, + uint32 _MIN_WITHDRAWAL_DELAY + ) + DelegationManagerStorage( + _avsDirectory, + _strategyManager, + _eigenPodManager, + _allocationManager, + _MIN_WITHDRAWAL_DELAY + ) + { _disableInitializers(); - ORIGINAL_CHAIN_ID = block.chainid; } /** @@ -74,16 +77,11 @@ contract DelegationManager is function initialize( address initialOwner, IPauserRegistry _pauserRegistry, - uint256 initialPausedStatus, - uint256 _minWithdrawalDelayBlocks, - IStrategy[] calldata _strategies, - uint256[] calldata _withdrawalDelayBlocks + uint256 initialPausedStatus ) external initializer { _initializePauser(_pauserRegistry, initialPausedStatus); _DOMAIN_SEPARATOR = _calculateDomainSeparator(); _transferOwnership(initialOwner); - _setMinWithdrawalDelayBlocks(_minWithdrawalDelayBlocks); - _setStrategyWithdrawalDelayBlocks(_strategies, _withdrawalDelayBlocks); } /** @@ -95,6 +93,7 @@ contract DelegationManager is /** * @notice Registers the caller as an operator in EigenLayer. * @param registeringOperatorDetails is the `OperatorDetails` for the operator. + * @param allocationDelay The delay before allocations take effect. * @param metadataURI is a URI for the operator's metadata, i.e. a link providing more details on the operator. * * @dev Once an operator is registered, they cannot 'deregister' as an operator, and they will forever be considered "delegated to themself". @@ -103,9 +102,11 @@ contract DelegationManager is */ function registerAsOperator( OperatorDetails calldata registeringOperatorDetails, + uint32 allocationDelay, string calldata metadataURI ) external { - require(!isDelegated(msg.sender), AlreadyDelegated()); + require(!isDelegated(msg.sender), ActivelyDelegated()); + allocationManager.setAllocationDelay(msg.sender, allocationDelay); _setOperatorDetails(msg.sender, registeringOperatorDetails); SignatureWithExpiry memory emptySignatureAndExpiry; // delegate from the operator to themselves @@ -124,7 +125,7 @@ contract DelegationManager is function modifyOperatorDetails( OperatorDetails calldata newOperatorDetails ) external { - require(isOperator(msg.sender), OperatorDoesNotExist()); + require(isOperator(msg.sender), OperatorNotRegistered()); _setOperatorDetails(msg.sender, newOperatorDetails); } @@ -135,7 +136,7 @@ contract DelegationManager is function updateOperatorMetadataURI( string calldata metadataURI ) external { - require(isOperator(msg.sender), OperatorDoesNotExist()); + require(isOperator(msg.sender), OperatorNotRegistered()); emit OperatorMetadataURIUpdated(msg.sender, metadataURI); } @@ -157,8 +158,8 @@ contract DelegationManager is SignatureWithExpiry memory approverSignatureAndExpiry, bytes32 approverSalt ) external { - require(!isDelegated(msg.sender), AlreadyDelegated()); - require(isOperator(operator), OperatorDoesNotExist()); + require(!isDelegated(msg.sender), ActivelyDelegated()); + require(isOperator(operator), OperatorNotRegistered()); // go through the internal delegation flow, checking the `approverSignatureAndExpiry` if applicable _delegate(msg.sender, operator, approverSignatureAndExpiry, approverSalt); } @@ -189,8 +190,8 @@ contract DelegationManager is ) external { // check the signature expiry require(stakerSignatureAndExpiry.expiry >= block.timestamp, SignatureExpired()); - require(!isDelegated(staker), AlreadyDelegated()); - require(isOperator(operator), OperatorDoesNotExist()); + require(!isDelegated(staker), ActivelyDelegated()); + require(isOperator(operator), OperatorNotRegistered()); // calculate the digest hash, then increment `staker`'s nonce uint256 currentStakerNonce = stakerNonce[staker]; @@ -215,19 +216,19 @@ contract DelegationManager is function undelegate( address staker ) external onlyWhenNotPaused(PAUSED_ENTER_WITHDRAWAL_QUEUE) returns (bytes32[] memory withdrawalRoots) { - require(isDelegated(staker), NotCurrentlyDelegated()); + require(isDelegated(staker), NotActivelyDelegated()); require(!isOperator(staker), OperatorsCannotUndelegate()); require(staker != address(0), InputAddressZero()); address operator = delegatedTo[staker]; require( msg.sender == staker || msg.sender == operator || msg.sender == _operatorDetails[operator].delegationApprover, - UnauthorizedCaller() + CallerCannotUndelegate() ); - // Gather strategies and shares to remove from staker/operator during undelegation + // Gather strategies and shares from the staker. Calculate delegatedShares to remove from operator during undelegation // Undelegation removes ALL currently-active strategies and shares - (IStrategy[] memory strategies, uint256[] memory shares) = getDelegatableShares(staker); + (IStrategy[] memory strategies, OwnedShares[] memory ownedShares) = getDelegatableShares(staker); // emit an event if this action was not initiated by the staker themselves if (msg.sender != staker) { @@ -243,19 +244,27 @@ contract DelegationManager is withdrawalRoots = new bytes32[](0); } else { withdrawalRoots = new bytes32[](strategies.length); + uint64[] memory totalMagnitudes = allocationManager.getTotalMagnitudes(operator, strategies); + for (uint256 i = 0; i < strategies.length; i++) { IStrategy[] memory singleStrategy = new IStrategy[](1); - uint256[] memory singleShare = new uint256[](1); + OwnedShares[] memory singleOwnedShare = new OwnedShares[](1); + uint64[] memory singleTotalMagnitude = new uint64[](1); singleStrategy[0] = strategies[i]; - singleShare[0] = shares[i]; + singleOwnedShare[0] = ownedShares[i]; + singleTotalMagnitude[0] = totalMagnitudes[i]; withdrawalRoots[i] = _removeSharesAndQueueWithdrawal({ staker: staker, operator: operator, - withdrawer: staker, strategies: singleStrategy, - shares: singleShare + ownedSharesToWithdraw: singleOwnedShare, + totalMagnitudes: singleTotalMagnitude }); + + // all shares and queued withdrawn and no delegated operator + // reset staker's depositScalingFactor to default + stakerScalingFactors[staker][strategies[i]].depositScalingFactor = WAD; } } @@ -277,20 +286,23 @@ contract DelegationManager is for (uint256 i = 0; i < queuedWithdrawalParams.length; i++) { require( - queuedWithdrawalParams[i].strategies.length == queuedWithdrawalParams[i].shares.length, + queuedWithdrawalParams[i].strategies.length == queuedWithdrawalParams[i].ownedShares.length, InputArrayLengthMismatch() ); require(queuedWithdrawalParams[i].withdrawer == msg.sender, WithdrawerNotStaker()); + uint64[] memory totalMagnitudes = + allocationManager.getTotalMagnitudes(operator, queuedWithdrawalParams[i].strategies); + // Remove shares from staker's strategies and place strategies/shares in queue. // If the staker is delegated to an operator, the operator's delegated shares are also reduced // NOTE: This will fail if the staker doesn't have the shares implied by the input parameters withdrawalRoots[i] = _removeSharesAndQueueWithdrawal({ staker: msg.sender, operator: operator, - withdrawer: queuedWithdrawalParams[i].withdrawer, strategies: queuedWithdrawalParams[i].strategies, - shares: queuedWithdrawalParams[i].shares + ownedSharesToWithdraw: queuedWithdrawalParams[i].ownedShares, + totalMagnitudes: totalMagnitudes }); } return withdrawalRoots; @@ -300,12 +312,9 @@ contract DelegationManager is * @notice Used to complete the specified `withdrawal`. The caller must match `withdrawal.withdrawer` * @param withdrawal The Withdrawal to complete. * @param tokens Array in which the i-th entry specifies the `token` input to the 'withdraw' function of the i-th Strategy in the `withdrawal.strategies` array. - * This input can be provided with zero length if `receiveAsTokens` is set to 'false' (since in that case, this input will be unused) - * @param middlewareTimesIndex is the index in the operator that the staker who triggered the withdrawal was delegated to's middleware times array * @param receiveAsTokens If true, the shares specified in the withdrawal will be withdrawn from the specified strategies themselves * and sent to the caller, through calls to `withdrawal.strategies[i].withdraw`. If false, then the shares in the specified strategies * will simply be transferred to the caller directly. - * @dev middlewareTimesIndex is unused, but will be used in the Slasher eventually * @dev beaconChainETHStrategy shares are non-transferrable, so if `receiveAsTokens = false` and `withdrawal.withdrawer != withdrawal.staker`, note that * any beaconChainETHStrategy shares in the `withdrawal` will be _returned to the staker_, rather than transferred to the withdrawer, unlike shares in * any other strategies, which will be transferred to the withdrawer. @@ -313,10 +322,9 @@ contract DelegationManager is function completeQueuedWithdrawal( Withdrawal calldata withdrawal, IERC20[] calldata tokens, - uint256 middlewareTimesIndex, bool receiveAsTokens ) external onlyWhenNotPaused(PAUSED_EXIT_WITHDRAWAL_QUEUE) nonReentrant { - _completeQueuedWithdrawal(withdrawal, tokens, middlewareTimesIndex, receiveAsTokens); + _completeQueuedWithdrawal(withdrawal, tokens, receiveAsTokens); } /** @@ -324,97 +332,94 @@ contract DelegationManager is * Used to complete the specified `withdrawals`. The function caller must match `withdrawals[...].withdrawer` * @param withdrawals The Withdrawals to complete. * @param tokens Array of tokens for each Withdrawal. See `completeQueuedWithdrawal` for the usage of a single array. - * @param middlewareTimesIndexes One index to reference per Withdrawal. See `completeQueuedWithdrawal` for the usage of a single index. * @param receiveAsTokens Whether or not to complete each withdrawal as tokens. See `completeQueuedWithdrawal` for the usage of a single boolean. * @dev See `completeQueuedWithdrawal` for relevant dev tags */ function completeQueuedWithdrawals( Withdrawal[] calldata withdrawals, IERC20[][] calldata tokens, - uint256[] calldata middlewareTimesIndexes, bool[] calldata receiveAsTokens ) external onlyWhenNotPaused(PAUSED_EXIT_WITHDRAWAL_QUEUE) nonReentrant { for (uint256 i = 0; i < withdrawals.length; ++i) { - _completeQueuedWithdrawal(withdrawals[i], tokens[i], middlewareTimesIndexes[i], receiveAsTokens[i]); + _completeQueuedWithdrawal(withdrawals[i], tokens[i], receiveAsTokens[i]); } } /** - * @notice Increases a staker's delegated share balance in a strategy. + * @notice Increases a staker's delegated share balance in a strategy. Note that before adding to operator shares, + * the delegated delegatedShares. The staker's depositScalingFactor is updated here. * @param staker The address to increase the delegated shares for their operator. * @param strategy The strategy in which to increase the delegated shares. - * @param shares The number of shares to increase. + * @param existingShares The number of deposit shares the staker already has in the strategy. This is the shares amount stored in the + * StrategyManager/EigenPodManager for the staker's shares. + * @param addedOwnedShares The number of shares to added to the staker's shares in the strategy * - * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing. + * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated delegatedShares in `strategy`. + * Otherwise does nothing. * @dev Callable only by the StrategyManager or EigenPodManager. */ function increaseDelegatedShares( address staker, IStrategy strategy, - uint256 shares + Shares existingShares, + OwnedShares addedOwnedShares ) external onlyStrategyManagerOrEigenPodManager { // if the staker is delegated to an operator if (isDelegated(staker)) { address operator = delegatedTo[staker]; + uint64 totalMagnitude = allocationManager.getTotalMagnitude(operator, strategy); - // add strategy shares to delegate's shares - _increaseOperatorShares({operator: operator, staker: staker, strategy: strategy, shares: shares}); + // add deposit shares to operator's stake shares and update the staker's depositScalingFactor + _increaseDelegation({ + operator: operator, + staker: staker, + strategy: strategy, + existingShares: existingShares, + addedOwnedShares: addedOwnedShares, + totalMagnitude: totalMagnitude + }); } } /** - * @notice Decreases a staker's delegated share balance in a strategy. - * @param staker The address to increase the delegated shares for their operator. - * @param strategy The strategy in which to decrease the delegated shares. - * @param shares The number of shares to decrease. + * @notice Decreases a native restaker's delegated share balance in a strategy due to beacon chain slashing. This updates their beaconChainScalingFactor. + * Their operator's stakeShares are also updated (if they are delegated). + * @param staker The address to increase the delegated stakeShares for their operator. + * @param existingShares The number of shares the staker already has in the EPM. This does not change upon decreasing shares. + * @param proportionOfOldBalance The current pod owner shares proportion of the previous pod owner shares * - * @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing. - * @dev Callable only by the StrategyManager or EigenPodManager. + * @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated stakeShares in `strategy` by `proportionPodBalanceDecrease` proportion. Otherwise does nothing. + * @dev Callable only by the EigenPodManager. */ - function decreaseDelegatedShares( + function decreaseBeaconChainScalingFactor( address staker, - IStrategy strategy, - uint256 shares - ) external onlyStrategyManagerOrEigenPodManager { - // if the staker is delegated to an operator + Shares existingShares, + uint64 proportionOfOldBalance + ) external onlyEigenPodManager { + DelegatedShares delegatedSharesBefore = + existingShares.toDelegatedShares(stakerScalingFactors[staker][beaconChainETHStrategy]); + + // decrease the staker's beaconChainScalingFactor proportionally + // forgefmt: disable-next-item + stakerScalingFactors[staker][beaconChainETHStrategy].decreaseBeaconChainScalingFactor(proportionOfOldBalance); + + DelegatedShares delegatedSharesAfter = + existingShares.toDelegatedShares(stakerScalingFactors[staker][beaconChainETHStrategy]); + + // if the staker is delegated to an operators if (isDelegated(staker)) { address operator = delegatedTo[staker]; - // forgefmt: disable-next-item - // subtract strategy shares from delegate's shares - _decreaseOperatorShares({ - operator: operator, - staker: staker, - strategy: strategy, - shares: shares + // subtract strategy shares from delegated scaled shares + _decreaseDelegation({ + operator: operator, + staker: staker, + strategy: beaconChainETHStrategy, + delegatedShares: delegatedSharesBefore.sub(delegatedSharesAfter) }); } } - /** - * @notice Owner-only function for modifying the value of the `minWithdrawalDelayBlocks` variable. - * @param newMinWithdrawalDelayBlocks new value of `minWithdrawalDelayBlocks`. - */ - function setMinWithdrawalDelayBlocks( - uint256 newMinWithdrawalDelayBlocks - ) external onlyOwner { - _setMinWithdrawalDelayBlocks(newMinWithdrawalDelayBlocks); - } - - /** - * @notice Called by owner to set the minimum withdrawal delay blocks for each passed in strategy - * Note that the min number of blocks to complete a withdrawal of a strategy is - * MAX(minWithdrawalDelayBlocks, strategyWithdrawalDelayBlocks[strategy]) - * @param strategies The strategies to set the minimum withdrawal delay blocks for - * @param withdrawalDelayBlocks The minimum withdrawal delay blocks to set for each strategy - */ - function setStrategyWithdrawalDelayBlocks( - IStrategy[] calldata strategies, - uint256[] calldata withdrawalDelayBlocks - ) external onlyOwner { - _setStrategyWithdrawalDelayBlocks(strategies, withdrawalDelayBlocks); - } - /** * * INTERNAL FUNCTIONS @@ -427,14 +432,6 @@ contract DelegationManager is * @param newOperatorDetails The new parameters for the operator */ function _setOperatorDetails(address operator, OperatorDetails calldata newOperatorDetails) internal { - require( - newOperatorDetails.stakerOptOutWindowBlocks <= MAX_STAKER_OPT_OUT_WINDOW_BLOCKS, - StakerOptOutWindowBlocksExceedsMax() - ); - require( - newOperatorDetails.stakerOptOutWindowBlocks >= _operatorDetails[operator].stakerOptOutWindowBlocks, - StakerOptOutWindowBlocksCannotDecrease() - ); _operatorDetails[operator] = newOperatorDetails; emit OperatorDetailsModified(msg.sender, newOperatorDetails); } @@ -469,7 +466,7 @@ contract DelegationManager is // check the signature expiry require(approverSignatureAndExpiry.expiry >= block.timestamp, SignatureExpired()); // check that the salt hasn't been used previously, then mark the salt as spent - require(!delegationApproverSaltIsSpent[_delegationApprover][approverSalt], SignatureSaltSpent()); + require(!delegationApproverSaltIsSpent[_delegationApprover][approverSalt], SaltSpent()); delegationApproverSaltIsSpent[_delegationApprover][approverSalt] = true; // forgefmt: disable-next-item @@ -495,187 +492,187 @@ contract DelegationManager is delegatedTo[staker] = operator; emit StakerDelegated(staker, operator); - (IStrategy[] memory strategies, uint256[] memory shares) = getDelegatableShares(staker); + // read staker's delegatable shares and strategies to add to operator's delegatedShares + // and also update the staker depositScalingFactor for each strategy + (IStrategy[] memory strategies, OwnedShares[] memory ownedShares) = getDelegatableShares(staker); + uint64[] memory totalMagnitudes = allocationManager.getTotalMagnitudes(operator, strategies); - for (uint256 i = 0; i < strategies.length;) { + for (uint256 i = 0; i < strategies.length; ++i) { // forgefmt: disable-next-item - _increaseOperatorShares({ + _increaseDelegation({ operator: operator, staker: staker, - strategy: strategies[i], - shares: shares[i] + strategy: strategies[i], + existingShares: uint256(0).wrapShares(), + addedOwnedShares: ownedShares[i], + totalMagnitude: totalMagnitudes[i] }); - - unchecked { - ++i; - } } } /** - * @dev commented-out param (middlewareTimesIndex) is the index in the operator that the staker who triggered the withdrawal was delegated to's middleware times array - * This param is intended to be passed on to the Slasher contract, but is unused in the M2 release of these contracts, and is thus commented-out. + * @dev This function completes a queued withdrawal for a staker. + * This will apply any slashing that has occurred since the the withdrawal was queued. By multiplying the withdrawl's + * delegatedShares by the operator's total magnitude for each strategy + * If receiveAsTokens is true, then these shares will be withdrawn as tokens. + * If receiveAsTokens is false, then they will be redeposited according to the current operator the staker is delegated to, + * and added back to the operator's delegatedShares. */ function _completeQueuedWithdrawal( Withdrawal calldata withdrawal, IERC20[] calldata tokens, - uint256, /*middlewareTimesIndex*/ bool receiveAsTokens ) internal { + require(tokens.length == withdrawal.strategies.length, InputArrayLengthMismatch()); + require(msg.sender == withdrawal.withdrawer, WithdrawerNotCaller()); bytes32 withdrawalRoot = calculateWithdrawalRoot(withdrawal); + require(pendingWithdrawals[withdrawalRoot], WithdrawalNotQueued()); + + // TODO: is there a cleaner way to do this? + uint32 completableTimestamp = _checkCompletability(withdrawal.startTimestamp); + // read delegated operator's totalMagnitudes at time of withdrawal to convert the delegatedShares to shared + // factoring in slashing that occured during withdrawal delay + uint64[] memory totalMagnitudes = allocationManager.getTotalMagnitudesAtTimestamp({ + operator: withdrawal.delegatedTo, + strategies: withdrawal.strategies, + timestamp: completableTimestamp + }); - require(pendingWithdrawals[withdrawalRoot], WithdrawalDoesNotExist()); - - require(withdrawal.startBlock + minWithdrawalDelayBlocks <= block.number, WithdrawalDelayNotElapsed()); - - require(msg.sender == withdrawal.withdrawer, UnauthorizedCaller()); - - if (receiveAsTokens) { - require(tokens.length == withdrawal.strategies.length, InputArrayLengthMismatch()); - } - - // Remove `withdrawalRoot` from pending roots - delete pendingWithdrawals[withdrawalRoot]; - - if (receiveAsTokens) { - // Finalize action by converting shares to tokens for each strategy, or - // by re-awarding shares in each strategy. - for (uint256 i = 0; i < withdrawal.strategies.length;) { - require( - withdrawal.startBlock + strategyWithdrawalDelayBlocks[withdrawal.strategies[i]] <= block.number, - WithdrawalDelayNotElapsed() - ); - - _withdrawSharesAsTokens({ + for (uint256 i = 0; i < withdrawal.strategies.length; i++) { + IShareManager shareManager = _getShareManager(withdrawal.strategies[i]); + OwnedShares ownedSharesToWithdraw = withdrawal.delegatedShares[i].scaleForCompleteWithdrawal( + stakerScalingFactors[withdrawal.staker][withdrawal.strategies[i]] + ).toOwnedShares(totalMagnitudes[i]); + + if (receiveAsTokens) { + // Withdraws `shares` in `strategy` to `withdrawer`. If the shares are virtual beaconChainETH shares, + // then a call is ultimately forwarded to the `staker`s EigenPod; otherwise a call is ultimately forwarded + // to the `strategy` with info on the `token`. + shareManager.withdrawSharesAsTokens({ staker: withdrawal.staker, - withdrawer: msg.sender, strategy: withdrawal.strategies[i], - shares: withdrawal.shares[i], - token: tokens[i] + token: tokens[i], + ownedShares: ownedSharesToWithdraw + }); + } else { + // Award shares back in StrategyManager/EigenPodManager. + shareManager.addOwnedShares({ + staker: withdrawal.staker, + strategy: withdrawal.strategies[i], + token: tokens[i], + ownedShares: ownedSharesToWithdraw }); - unchecked { - ++i; - } - } - } else { - // Award shares back in StrategyManager/EigenPodManager. - // If withdrawer is delegated, increase the shares delegated to the operator. - address currentOperator = delegatedTo[msg.sender]; - for (uint256 i = 0; i < withdrawal.strategies.length;) { - require( - withdrawal.startBlock + strategyWithdrawalDelayBlocks[withdrawal.strategies[i]] <= block.number, - WithdrawalDelayNotElapsed() - ); - - /** - * When awarding podOwnerShares in EigenPodManager, we need to be sure to only give them back to the original podOwner. - * Other strategy shares can + will be awarded to the withdrawer. - */ - if (withdrawal.strategies[i] == beaconChainETHStrategy) { - address staker = withdrawal.staker; - /** - * Update shares amount depending upon the returned value. - * The return value will be lower than the input value in the case where the staker has an existing share deficit - */ - uint256 increaseInDelegateableShares = - eigenPodManager.addShares({podOwner: staker, shares: withdrawal.shares[i]}); - address podOwnerOperator = delegatedTo[staker]; - // Similar to `isDelegated` logic - if (podOwnerOperator != address(0)) { - _increaseOperatorShares({ - operator: podOwnerOperator, - // the 'staker' here is the address receiving new shares - staker: staker, - strategy: withdrawal.strategies[i], - shares: increaseInDelegateableShares - }); - } - } else { - strategyManager.addShares(msg.sender, tokens[i], withdrawal.strategies[i], withdrawal.shares[i]); - // Similar to `isDelegated` logic - if (currentOperator != address(0)) { - _increaseOperatorShares({ - operator: currentOperator, - // the 'staker' here is the address receiving new shares - staker: msg.sender, - strategy: withdrawal.strategies[i], - shares: withdrawal.shares[i] - }); - } - } - unchecked { - ++i; - } } } + // Remove `withdrawalRoot` from pending roots + delete pendingWithdrawals[withdrawalRoot]; emit WithdrawalCompleted(withdrawalRoot); } - // @notice Increases `operator`s delegated shares in `strategy` by `shares` and emits an `OperatorSharesIncreased` event - function _increaseOperatorShares(address operator, address staker, IStrategy strategy, uint256 shares) internal { - operatorShares[operator][strategy] += shares; - emit OperatorSharesIncreased(operator, staker, strategy, shares); + /** + * @notice Increases `operator`s delegated delegatedShares in `strategy` based on staker's added shares and operator's totalMagnitude + * and increases the staker's depositScalingFactor for the strategy. + * @param operator The operator to increase the delegated delegatedShares for + * @param staker The staker to increase the depositScalingFactor for + * @param strategy The strategy to increase the delegated delegatedShares and the depositScalingFactor for + * @param existingShares The number of deposit shares the staker already has in the strategy. + * @param addedOwnedShares The shares added to the staker in the StrategyManager/EigenPodManager + * @param totalMagnitude The current total magnitude of the operator for the strategy + */ + function _increaseDelegation( + address operator, + address staker, + IStrategy strategy, + Shares existingShares, + OwnedShares addedOwnedShares, + uint64 totalMagnitude + ) internal { + _updateDepositScalingFactor({ + staker: staker, + strategy: strategy, + existingShares: existingShares, + addedOwnedShares: addedOwnedShares, + totalMagnitude: totalMagnitude + }); + + // based on total magnitude, update operators delegatedShares + DelegatedShares delegatedShares = addedOwnedShares.toDelegatedShares(totalMagnitude); + // forgefmt: disable-next-line + operatorDelegatedShares[operator][strategy] = operatorDelegatedShares[operator][strategy].add(delegatedShares); + + // TODO: What to do about event wrt scaling? + emit OperatorSharesIncreased(operator, staker, strategy, delegatedShares); } - // @notice Decreases `operator`s delegated shares in `strategy` by `shares` and emits an `OperatorSharesDecreased` event - function _decreaseOperatorShares(address operator, address staker, IStrategy strategy, uint256 shares) internal { - // This will revert on underflow, so no check needed - operatorShares[operator][strategy] -= shares; - emit OperatorSharesDecreased(operator, staker, strategy, shares); + /** + * @notice Decreases `operator`s delegated delegatedShares in `strategy` based on staker's removed shares and operator's totalMagnitude + * @param operator The operator to decrease the delegated delegated shares for + * @param staker The staker to decrease the delegated delegated shares for + * @param strategy The strategy to decrease the delegated delegated shares for + * @param delegatedShares The delegatedShares to remove from the operator's delegated shares + */ + function _decreaseDelegation( + address operator, + address staker, + IStrategy strategy, + DelegatedShares delegatedShares + ) internal { + // based on total magnitude, decrement operator's delegatedShares + operatorDelegatedShares[operator][strategy] = operatorDelegatedShares[operator][strategy].sub(delegatedShares); + + // TODO: What to do about event wrt scaling? + emit OperatorSharesDecreased(operator, staker, strategy, delegatedShares); } /** - * @notice Removes `shares` in `strategies` from `staker` who is currently delegated to `operator` and queues a withdrawal to the `withdrawer`. + * @notice Removes `sharesToWithdraw` in `strategies` from `staker` who is currently delegated to `operator` and queues a withdrawal to the `withdrawer`. * @dev If the `operator` is indeed an operator, then the operator's delegated shares in the `strategies` are also decreased appropriately. - * @dev If `withdrawer` is not the same address as `staker`, then thirdPartyTransfersForbidden[strategy] must be set to false in the StrategyManager. + * @dev If `withdrawer` is not the same address as `staker` */ function _removeSharesAndQueueWithdrawal( address staker, address operator, - address withdrawer, IStrategy[] memory strategies, - uint256[] memory shares + OwnedShares[] memory ownedSharesToWithdraw, + uint64[] memory totalMagnitudes ) internal returns (bytes32) { require(staker != address(0), InputAddressZero()); require(strategies.length != 0, InputArrayLengthZero()); + DelegatedShares[] memory delegatedSharesToWithdraw = new DelegatedShares[](strategies.length); // Remove shares from staker and operator // Each of these operations fail if we attempt to remove more shares than exist - for (uint256 i = 0; i < strategies.length;) { + for (uint256 i = 0; i < strategies.length; ++i) { + IShareManager shareManager = _getShareManager(strategies[i]); + + // delegatedShares for staker to place into queueWithdrawal + DelegatedShares delegatedSharesToRemove = ownedSharesToWithdraw[i].toDelegatedShares(totalMagnitudes[i]); + // TODO: should this include beaconChainScalingFactor? + Shares sharesToWithdraw = delegatedSharesToRemove.toShares(stakerScalingFactors[staker][strategies[i]]); + // TODO: maybe have a getter to get shares for all strategies, like getDelegatableShares + // check sharesToWithdraw is valid + // but for inputted strategies + Shares sharesWithdrawable = shareManager.stakerStrategyShares(staker, strategies[i]); + require(sharesToWithdraw.unwrap() <= sharesWithdrawable.unwrap(), WithdrawalExeedsMax()); + // Similar to `isDelegated` logic if (operator != address(0)) { // forgefmt: disable-next-item - _decreaseOperatorShares({ + _decreaseDelegation({ operator: operator, staker: staker, strategy: strategies[i], - shares: shares[i] + delegatedShares: delegatedSharesToRemove }); } + delegatedSharesToWithdraw[i] = + delegatedSharesToRemove.scaleForQueueWithdrawal(stakerScalingFactors[staker][strategies[i]]); // Remove active shares from EigenPodManager/StrategyManager - if (strategies[i] == beaconChainETHStrategy) { - /** - * This call will revert if it would reduce the Staker's virtual beacon chain ETH shares below zero. - * This behavior prevents a Staker from queuing a withdrawal which improperly removes excessive - * shares from the operator to whom the staker is delegated. - * It will also revert if the share amount being withdrawn is not a whole Gwei amount. - */ - eigenPodManager.removeShares(staker, shares[i]); - } else { - // If thirdPartyTransfersForbidden is set, withdrawer and staker must be the same address - require( - staker == withdrawer || !strategyManager.thirdPartyTransfersForbidden(strategies[i]), - WithdrawerNotStaker() - ); - // this call will revert if `shares[i]` exceeds the Staker's current shares in `strategies[i]` - strategyManager.removeShares(staker, strategies[i], shares[i]); - } - - unchecked { - ++i; - } + // EigenPodManager: this call will revert if it would reduce the Staker's virtual beacon chain ETH shares below zero + // StrategyManager: this call will revert if `sharesToDecrement` exceeds the Staker's current deposit shares in `strategies[i]` + shareManager.removeShares(staker, strategies[i], sharesToWithdraw); } // Create queue entry and increment withdrawal nonce @@ -685,11 +682,11 @@ contract DelegationManager is Withdrawal memory withdrawal = Withdrawal({ staker: staker, delegatedTo: operator, - withdrawer: withdrawer, + withdrawer: staker, nonce: nonce, - startBlock: uint32(block.number), + startTimestamp: uint32(block.timestamp), strategies: strategies, - shares: shares + delegatedShares: delegatedSharesToWithdraw }); bytes32 withdrawalRoot = calculateWithdrawalRoot(withdrawal); @@ -701,54 +698,78 @@ contract DelegationManager is return withdrawalRoot; } + /// @dev check whether the withdrawal delay has elapsed (handles both legacy and post-slashing-release withdrawals) and returns the completable timestamp + function _checkCompletability( + uint32 startTimestamp + ) internal view returns (uint32 completableTimestamp) { + if (startTimestamp < LEGACY_WITHDRAWALS_TIMESTAMP) { + // this is a legacy M2 withdrawal using blocknumbers. + // It would take up to 600+ years for the blocknumber to reach the LEGACY_WITHDRAWALS_TIMESTAMP, so this is a safe check. + require(startTimestamp + LEGACY_MIN_WITHDRAWAL_DELAY_BLOCKS <= block.number, WithdrawalDelayNotElapsed()); + // sourcing the magnitudes from time=0, will always give us WAD, which doesn't factor in slashing + completableTimestamp = 0; + } else { + // this is a post Slashing release withdrawal using timestamps + require(startTimestamp + MIN_WITHDRAWAL_DELAY <= block.timestamp, WithdrawalDelayNotElapsed()); + // source magnitudes from the time of completability + completableTimestamp = startTimestamp + MIN_WITHDRAWAL_DELAY; + } + } + /** - * @notice Withdraws `shares` in `strategy` to `withdrawer`. If the shares are virtual beaconChainETH shares, then a call is ultimately forwarded to the - * `staker`s EigenPod; otherwise a call is ultimately forwarded to the `strategy` with info on the `token`. + * + * SHARES CONVERSION FUNCTIONS + * + */ + + /** + * @notice helper to calculate the new depositScalingFactor after adding shares. This is only used + * when a staker is depositing through the StrategyManager or EigenPodManager. A staker's depositScalingFactor + * is only updated when they have new deposits and their shares are being increased. */ - function _withdrawSharesAsTokens( + function _updateDepositScalingFactor( address staker, - address withdrawer, IStrategy strategy, - uint256 shares, - IERC20 token + uint64 totalMagnitude, + Shares existingShares, + OwnedShares addedOwnedShares ) internal { - if (strategy == beaconChainETHStrategy) { - eigenPodManager.withdrawSharesAsTokens({podOwner: staker, destination: withdrawer, shares: shares}); + uint256 newDepositScalingFactor; + if (existingShares.unwrap() == 0) { + newDepositScalingFactor = WAD / totalMagnitude; } else { - strategyManager.withdrawSharesAsTokens(withdrawer, strategy, shares, token); + // otherwise since + // + // newShares + // = existingShares + addedShares + // = existingPrincipalShares.toDelegatedShares(stakerScalingFactors[staker][strategy).toOwnedShares(totalMagnitude) + addedShares + // + // and it also is + // + // newShares + // = newPrincipalShares.toDelegatedShares(stakerScalingFactors[staker][strategy).toOwnedShares(totalMagnitude) + // = newPrincipalShares * newDepositScalingFactor / WAD * beaonChainScalingFactor / WAD * totalMagnitude / WAD + // = (existingPrincipalShares + addedShares) * newDepositScalingFactor / WAD * beaonChainScalingFactor / WAD * totalMagnitude / WAD + // + // we can solve for + // + OwnedShares existingOwnedShares = + existingShares.toDelegatedShares(stakerScalingFactors[staker][strategy]).toOwnedShares(totalMagnitude); + newDepositScalingFactor = existingOwnedShares.add(addedOwnedShares).unwrap().divWad( + existingShares.unwrap() + addedOwnedShares.unwrap() + ).divWad(stakerScalingFactors[staker][strategy].getBeaconChainScalingFactor()).divWad(totalMagnitude); } - } - function _setMinWithdrawalDelayBlocks( - uint256 _minWithdrawalDelayBlocks - ) internal { - require(_minWithdrawalDelayBlocks <= MAX_WITHDRAWAL_DELAY_BLOCKS, WithdrawalDelayExceedsMax()); - emit MinWithdrawalDelayBlocksSet(minWithdrawalDelayBlocks, _minWithdrawalDelayBlocks); - minWithdrawalDelayBlocks = _minWithdrawalDelayBlocks; + // update the staker's depositScalingFactor + stakerScalingFactors[staker][strategy].depositScalingFactor = newDepositScalingFactor; } - /** - * @notice Sets the withdrawal delay blocks for each strategy in `_strategies` to `_withdrawalDelayBlocks`. - * gets called when initializing contract or by calling `setStrategyWithdrawalDelayBlocks` - */ - function _setStrategyWithdrawalDelayBlocks( - IStrategy[] calldata _strategies, - uint256[] calldata _withdrawalDelayBlocks - ) internal { - require(_strategies.length == _withdrawalDelayBlocks.length, InputArrayLengthMismatch()); - uint256 numStrats = _strategies.length; - for (uint256 i = 0; i < numStrats; ++i) { - IStrategy strategy = _strategies[i]; - uint256 prevStrategyWithdrawalDelayBlocks = strategyWithdrawalDelayBlocks[strategy]; - uint256 newStrategyWithdrawalDelayBlocks = _withdrawalDelayBlocks[i]; - require(newStrategyWithdrawalDelayBlocks <= MAX_WITHDRAWAL_DELAY_BLOCKS, WithdrawalDelayExceedsMax()); - - // set the new withdrawal delay blocks - strategyWithdrawalDelayBlocks[strategy] = newStrategyWithdrawalDelayBlocks; - emit StrategyWithdrawalDelayBlocksSet( - strategy, prevStrategyWithdrawalDelayBlocks, newStrategyWithdrawalDelayBlocks - ); - } + function _getShareManager( + IStrategy strategy + ) internal view returns (IShareManager) { + return strategy == beaconChainETHStrategy + ? IShareManager(address(eigenPodManager)) + : IShareManager(address(strategyManager)); } /** @@ -817,16 +838,43 @@ contract DelegationManager is return _operatorDetails[operator].stakerOptOutWindowBlocks; } - /// @notice Given array of strategies, returns array of shares for the operator - function getOperatorShares( - address operator, + /// @notice a legacy function that returns the total delegated shares for an operator and strategy + function operatorShares(address operator, IStrategy strategy) public view returns (uint256) { + uint64 totalMagnitude = allocationManager.getTotalMagnitude(operator, strategy); + return operatorDelegatedShares[operator][strategy].toOwnedShares(totalMagnitude).unwrap(); + } + + /** + * @notice Given a staker and a set of strategies, return the shares they can queue for withdrawal. + * This value depends on which operator the staker is delegated to. + * The shares amount returned is the actual amount of Strategy shares the staker would receive (subject + * to each strategy's underlying shares to token ratio). + */ + function getDelegatableShares( + address staker, IStrategy[] memory strategies - ) public view returns (uint256[] memory) { - uint256[] memory shares = new uint256[](strategies.length); + ) public view returns (OwnedShares[] memory ownedShares) { + address operator = delegatedTo[staker]; for (uint256 i = 0; i < strategies.length; ++i) { - shares[i] = operatorShares[operator][strategies[i]]; + IShareManager shareManager = _getShareManager(strategies[i]); + // TODO: batch call for strategyManager shares? + // 1. read strategy deposit shares + + // forgefmt: disable-next-item + Shares shares = shareManager.stakerStrategyShares(staker, strategies[i]); + + // 2. if the staker is delegated, actual withdrawable shares can be different from what is stored + // in the StrategyManager/EigenPodManager because they could have been slashed + if (operator != address(0)) { + uint64 totalMagnitude = allocationManager.getTotalMagnitude(operator, strategies[i]); + + // forgefmt: disable-next-item + ownedShares[i] = shares + .toDelegatedShares(stakerScalingFactors[staker][strategies[i]]) + .toOwnedShares(totalMagnitude); + } } - return shares; + return ownedShares; } /** @@ -835,69 +883,30 @@ contract DelegationManager is */ function getDelegatableShares( address staker - ) public view returns (IStrategy[] memory, uint256[] memory) { - // Get currently active shares and strategies for `staker` - int256 podShares = eigenPodManager.podOwnerShares(staker); - (IStrategy[] memory strategyManagerStrats, uint256[] memory strategyManagerShares) = - strategyManager.getDeposits(staker); - - // Has no shares in EigenPodManager, but potentially some in StrategyManager - if (podShares <= 0) { - return (strategyManagerStrats, strategyManagerShares); + ) public view returns (IStrategy[] memory, OwnedShares[] memory) { + // Get a list of all the strategies to check + IStrategy[] memory strategies = strategyManager.getStakerStrategyList(staker); + // resize and add beaconChainETH to the end + assembly { + mstore(strategies, add(mload(strategies), 1)) } + strategies[strategies.length - 1] = beaconChainETHStrategy; - IStrategy[] memory strategies; - uint256[] memory shares; - - if (strategyManagerStrats.length == 0) { - // Has shares in EigenPodManager, but not in StrategyManager - strategies = new IStrategy[](1); - shares = new uint256[](1); - strategies[0] = beaconChainETHStrategy; - shares[0] = uint256(podShares); - } else { - // Has shares in both - - // 1. Allocate return arrays - strategies = new IStrategy[](strategyManagerStrats.length + 1); - shares = new uint256[](strategies.length); + // get the delegatable shares for each strategy + OwnedShares[] memory shares = getDelegatableShares(staker, strategies); - // 2. Place StrategyManager strats/shares in return arrays - for (uint256 i = 0; i < strategyManagerStrats.length;) { - strategies[i] = strategyManagerStrats[i]; - shares[i] = strategyManagerShares[i]; - - unchecked { - ++i; - } + // if the last shares are 0, remove them + if (shares[strategies.length - 1].unwrap() == 0) { + // resize the arrays + assembly { + mstore(strategies, sub(mload(strategies), 1)) + mstore(shares, sub(mload(shares), 1)) } - - // 3. Place EigenPodManager strat/shares in return arrays - strategies[strategies.length - 1] = beaconChainETHStrategy; - shares[strategies.length - 1] = uint256(podShares); } return (strategies, shares); } - /** - * @notice Given a list of strategies, return the minimum number of blocks that must pass to withdraw - * from all the inputted strategies. Return value is >= minWithdrawalDelayBlocks as this is the global min withdrawal delay. - * @param strategies The strategies to check withdrawal delays for - */ - function getWithdrawalDelay( - IStrategy[] calldata strategies - ) public view returns (uint256) { - uint256 withdrawalDelay = minWithdrawalDelayBlocks; - for (uint256 i = 0; i < strategies.length; ++i) { - uint256 currWithdrawalDelay = strategyWithdrawalDelayBlocks[strategies[i]]; - if (currWithdrawalDelay > withdrawalDelay) { - withdrawalDelay = currWithdrawalDelay; - } - } - return withdrawalDelay; - } - /// @notice Returns the keccak256 hash of `withdrawal`. function calculateWithdrawalRoot( Withdrawal memory withdrawal diff --git a/src/contracts/core/DelegationManagerStorage.sol b/src/contracts/core/DelegationManagerStorage.sol index 3af7b64fe..f54570e85 100644 --- a/src/contracts/core/DelegationManagerStorage.sol +++ b/src/contracts/core/DelegationManagerStorage.sol @@ -1,10 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import "../interfaces/IStrategyManager.sol"; +import "../libraries/SlashingLib.sol"; import "../interfaces/IDelegationManager.sol"; -import "../interfaces/ISlasher.sol"; +import "../interfaces/IAVSDirectory.sol"; import "../interfaces/IEigenPodManager.sol"; +import "../interfaces/IAllocationManager.sol"; /** * @title Storage variables for the `DelegationManager` contract. @@ -13,6 +14,8 @@ import "../interfaces/IEigenPodManager.sol"; * @notice This storage contract is separate from the logic to simplify the upgrade process. */ abstract contract DelegationManagerStorage is IDelegationManager { + // Constants + /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); @@ -26,33 +29,66 @@ abstract contract DelegationManagerStorage is IDelegationManager { "DelegationApproval(address delegationApprover,address staker,address operator,bytes32 salt,uint256 expiry)" ); - /** - * @notice Original EIP-712 Domain separator for this contract. - * @dev The domain separator may change in the event of a fork that modifies the ChainID. - * Use the getter function `domainSeparator` to get the current domain separator for this contract. - */ - bytes32 internal _DOMAIN_SEPARATOR; + /// @dev Index for flag that pauses new delegations when set + uint8 internal constant PAUSED_NEW_DELEGATION = 0; + + /// @dev Index for flag that pauses queuing new withdrawals when set. + uint8 internal constant PAUSED_ENTER_WITHDRAWAL_QUEUE = 1; + + /// @dev Index for flag that pauses completing existing withdrawals when set. + uint8 internal constant PAUSED_EXIT_WITHDRAWAL_QUEUE = 2; + + /// @notice The minimum number of blocks to complete a withdrawal of a strategy. 50400 * 12 seconds = 1 week + uint256 public constant LEGACY_MIN_WITHDRAWAL_DELAY_BLOCKS = 50_400; + + /// @notice Wed Jan 01 2025 17:00:00 GMT+0000, timestamp used to check whether a pending withdrawal + /// should be processed as legacy M2 or with slashing considered. + uint32 public constant LEGACY_WITHDRAWALS_TIMESTAMP = 1_735_750_800; + + /// @notice Canonical, virtual beacon chain ETH strategy + IStrategy public constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0); + + // Immutables + + /// @notice The AVSDirectory contract for EigenLayer + IAVSDirectory public immutable avsDirectory; + + // TODO: Switch these to ShareManagers, but this breaks a lot of tests /// @notice The StrategyManager contract for EigenLayer IStrategyManager public immutable strategyManager; - /// @notice The Slasher contract for EigenLayer - ISlasher public immutable slasher; - /// @notice The EigenPodManager contract for EigenLayer IEigenPodManager public immutable eigenPodManager; - // the number of 12-second blocks in 30 days (60 * 60 * 24 * 30 / 12 = 216,000) - uint256 public constant MAX_WITHDRAWAL_DELAY_BLOCKS = 216_000; + /// @notice The AllocationManager contract for EigenLayer + IAllocationManager public immutable allocationManager; + + /// @notice Minimum withdrawal delay in seconds until all queued withdrawals can be completed. + uint32 public immutable MIN_WITHDRAWAL_DELAY; + + /// @dev Chain ID at the time of contract deployment + uint256 internal immutable ORIGINAL_CHAIN_ID; + + // Mutatables /** - * @notice returns the total number of shares in `strategy` that are delegated to `operator`. - * @notice Mapping: operator => strategy => total number of shares in the strategy delegated to the operator. + * @notice Original EIP-712 Domain separator for this contract. + * @dev The domain separator may change in the event of a fork that modifies the ChainID. + * Use the getter function `domainSeparator` to get the current domain separator for this contract. + */ + bytes32 internal _DOMAIN_SEPARATOR; + + /** + * @notice returns the total number of delegatedShares (i.e. shares divided by the `operator`'s + * totalMagnitude) in `strategy` that are delegated to `operator`. + * @notice Mapping: operator => strategy => total number of delegatedShares in the strategy delegated to the operator. * @dev By design, the following invariant should hold for each Strategy: - * (operator's shares in delegation manager) = sum (shares above zero of all stakers delegated to operator) - * = sum (delegateable shares of all stakers delegated to the operator) + * (operator's delegatedShares in delegation manager) = sum (delegatedShares above zero of all stakers delegated to operator) + * = sum (delegateable delegatedShares of all stakers delegated to the operator) + * @dev FKA `operatorShares` */ - mapping(address => mapping(IStrategy => uint256)) public operatorShares; + mapping(address => mapping(IStrategy => DelegatedShares)) public operatorDelegatedShares; /** * @notice Mapping: operator => OperatorDetails struct @@ -83,7 +119,7 @@ abstract contract DelegationManagerStorage is IDelegationManager { * To withdraw from a strategy, max(minWithdrawalDelayBlocks, strategyWithdrawalDelayBlocks[strategy]) number of blocks must have passed. * See mapping strategyWithdrawalDelayBlocks below for per-strategy withdrawal delays. */ - uint256 public minWithdrawalDelayBlocks; + uint256 private __deprecated_minWithdrawalDelayBlocks; /// @notice Mapping: hash of withdrawal inputs, aka 'withdrawalRoot' => whether the withdrawal is pending mapping(bytes32 => bool) public pendingWithdrawals; @@ -100,12 +136,31 @@ abstract contract DelegationManagerStorage is IDelegationManager { * @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner, * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced). */ - mapping(IStrategy => uint256) public strategyWithdrawalDelayBlocks; - - constructor(IStrategyManager _strategyManager, ISlasher _slasher, IEigenPodManager _eigenPodManager) { + mapping(IStrategy => uint256) private __deprecated_strategyWithdrawalDelayBlocks; + + /// @notice Mapping: staker => strategy => + /// ( + /// scaling factor used to calculate the staker's shares in the strategy, + /// beacon chain scaling factor used to calculate the staker's withdrawable shares in the strategy. + /// ) + /// Note that we don't need the beaconChainScalingFactor for non beaconChainETHStrategy strategies, but it's nicer syntactically to keep it. + mapping(address => mapping(IStrategy => StakerScalingFactors)) public stakerScalingFactors; + + // Construction + + constructor( + IAVSDirectory _avsDirectory, + IStrategyManager _strategyManager, + IEigenPodManager _eigenPodManager, + IAllocationManager _allocationManager, + uint32 _MIN_WITHDRAWAL_DELAY + ) { + avsDirectory = _avsDirectory; strategyManager = _strategyManager; eigenPodManager = _eigenPodManager; - slasher = _slasher; + allocationManager = _allocationManager; + MIN_WITHDRAWAL_DELAY = _MIN_WITHDRAWAL_DELAY; + ORIGINAL_CHAIN_ID = block.chainid; } /** @@ -113,5 +168,5 @@ abstract contract DelegationManagerStorage is IDelegationManager { * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ - uint256[39] private __gap; + uint256[38] private __gap; } diff --git a/src/contracts/core/RewardsCoordinator.sol b/src/contracts/core/RewardsCoordinator.sol index 5e636fa76..736dea9ed 100644 --- a/src/contracts/core/RewardsCoordinator.sol +++ b/src/contracts/core/RewardsCoordinator.sol @@ -6,6 +6,7 @@ import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../libraries/Merkle.sol"; +import "../interfaces/IStrategyManager.sol"; import "../permissions/Pausable.sol"; import "./RewardsCoordinatorStorage.sol"; @@ -27,33 +28,6 @@ contract RewardsCoordinator is { using SafeERC20 for IERC20; - /// @notice The EIP-712 typehash for the contract's domain - bytes32 internal constant DOMAIN_TYPEHASH = - keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); - /// @dev Chain ID at the time of contract deployment - uint256 internal immutable ORIGINAL_CHAIN_ID; - /// @notice The maximum rewards token amount for a single rewards submission, constrained by off-chain calculation - uint256 internal constant MAX_REWARDS_AMOUNT = 1e38 - 1; - - /// @dev Index for flag that pauses calling createAVSRewardsSubmission - uint8 internal constant PAUSED_AVS_REWARDS_SUBMISSION = 0; - /// @dev Index for flag that pauses calling createRewardsForAllSubmission - uint8 internal constant PAUSED_REWARDS_FOR_ALL_SUBMISSION = 1; - /// @dev Index for flag that pauses calling processClaim - uint8 internal constant PAUSED_PROCESS_CLAIM = 2; - /// @dev Index for flag that pauses submitRoots and disableRoot - uint8 internal constant PAUSED_SUBMIT_DISABLE_ROOTS = 3; - /// @dev Index for flag that pauses calling rewardAllStakersAndOperators - uint8 internal constant PAUSED_REWARD_ALL_STAKERS_AND_OPERATORS = 4; - - /// @dev Salt for the earner leaf, meant to distinguish from tokenLeaf since they have the same sized data - uint8 internal constant EARNER_LEAF_SALT = 0; - /// @dev Salt for the token leaf, meant to distinguish from earnerLeaf since they have the same sized data - uint8 internal constant TOKEN_LEAF_SALT = 1; - - /// @notice Canonical, virtual beacon chain ETH strategy - IStrategy public constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0); - modifier onlyRewardsUpdater() { require(msg.sender == rewardsUpdater, UnauthorizedCaller()); _; @@ -72,7 +46,7 @@ contract RewardsCoordinator is uint32 _MAX_REWARDS_DURATION, uint32 _MAX_RETROACTIVE_LENGTH, uint32 _MAX_FUTURE_LENGTH, - uint32 __GENESIS_REWARDS_TIMESTAMP + uint32 _GENESIS_REWARDS_TIMESTAMP ) RewardsCoordinatorStorage( _delegationManager, @@ -81,11 +55,10 @@ contract RewardsCoordinator is _MAX_REWARDS_DURATION, _MAX_RETROACTIVE_LENGTH, _MAX_FUTURE_LENGTH, - __GENESIS_REWARDS_TIMESTAMP + _GENESIS_REWARDS_TIMESTAMP ) { _disableInitializers(); - ORIGINAL_CHAIN_ID = block.chainid; } /** diff --git a/src/contracts/core/RewardsCoordinatorStorage.sol b/src/contracts/core/RewardsCoordinatorStorage.sol index 253398d42..be8bd6014 100644 --- a/src/contracts/core/RewardsCoordinatorStorage.sol +++ b/src/contracts/core/RewardsCoordinatorStorage.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import "../interfaces/IStrategyManager.sol"; -import "../interfaces/IDelegationManager.sol"; import "../interfaces/IRewardsCoordinator.sol"; +import "../interfaces/IDelegationManager.sol"; +import "../interfaces/IStrategyManager.sol"; /** * @title Storage variables for the `RewardsCoordinator` contract. @@ -12,11 +12,41 @@ import "../interfaces/IRewardsCoordinator.sol"; * @notice This storage contract is separate from the logic to simplify the upgrade process. */ abstract contract RewardsCoordinatorStorage is IRewardsCoordinator { - /** - * - * CONSTANTS AND IMMUTABLES - * - */ + // Constants + + /// @notice The EIP-712 typehash for the contract's domain + bytes32 internal constant DOMAIN_TYPEHASH = + keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); + + /// @notice The maximum rewards token amount for a single rewards submission, constrained by off-chain calculation + uint256 internal constant MAX_REWARDS_AMOUNT = 1e38 - 1; + + /// @dev Index for flag that pauses calling createAVSRewardsSubmission + uint8 internal constant PAUSED_AVS_REWARDS_SUBMISSION = 0; + /// @dev Index for flag that pauses calling createRewardsForAllSubmission + uint8 internal constant PAUSED_REWARDS_FOR_ALL_SUBMISSION = 1; + /// @dev Index for flag that pauses calling processClaim + uint8 internal constant PAUSED_PROCESS_CLAIM = 2; + /// @dev Index for flag that pauses submitRoots and disableRoot + uint8 internal constant PAUSED_SUBMIT_DISABLE_ROOTS = 3; + /// @dev Index for flag that pauses calling rewardAllStakersAndOperators + uint8 internal constant PAUSED_REWARD_ALL_STAKERS_AND_OPERATORS = 4; + + /// @dev Salt for the earner leaf, meant to distinguish from tokenLeaf since they have the same sized data + uint8 internal constant EARNER_LEAF_SALT = 0; + /// @dev Salt for the token leaf, meant to distinguish from earnerLeaf since they have the same sized data + uint8 internal constant TOKEN_LEAF_SALT = 1; + + /// @notice Canonical, virtual beacon chain ETH strategy + IStrategy public constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0); + + // Immtuables + + /// @notice The DelegationManager contract for EigenLayer + IDelegationManager public immutable delegationManager; + + /// @notice The StrategyManager contract for EigenLayer + IStrategyManager public immutable strategyManager; /// @notice The interval in seconds at which the calculation for rewards distribution is done. /// @dev RewardsSubmission durations must be multiples of this interval. This is going to be configured to 1 week @@ -32,17 +62,10 @@ abstract contract RewardsCoordinatorStorage is IRewardsCoordinator { /// @notice The cadence at which a snapshot is taken offchain for calculating rewards distributions uint32 internal constant SNAPSHOT_CADENCE = 1 days; - /// @notice The DelegationManager contract for EigenLayer - IDelegationManager public immutable delegationManager; - - /// @notice The StrategyManager contract for EigenLayer - IStrategyManager public immutable strategyManager; + /// @dev Chain ID at the time of contract deployment + uint256 internal immutable ORIGINAL_CHAIN_ID; - /** - * - * STORAGE - * - */ + // Mutatables /** * @notice Original EIP-712 Domain separator for this contract. @@ -89,6 +112,8 @@ abstract contract RewardsCoordinatorStorage is IRewardsCoordinator { /// if rewards submission hash for all stakers and operators has been submitted mapping(address => mapping(bytes32 => bool)) public isRewardsSubmissionForAllEarnersHash; + // Construction + constructor( IDelegationManager _delegationManager, IStrategyManager _strategyManager, @@ -99,13 +124,9 @@ abstract contract RewardsCoordinatorStorage is IRewardsCoordinator { uint32 _GENESIS_REWARDS_TIMESTAMP ) { require( - _GENESIS_REWARDS_TIMESTAMP % _CALCULATION_INTERVAL_SECONDS == 0, - "RewardsCoordinator: GENESIS_REWARDS_TIMESTAMP must be a multiple of CALCULATION_INTERVAL_SECONDS" - ); - require( - _CALCULATION_INTERVAL_SECONDS % SNAPSHOT_CADENCE == 0, - "RewardsCoordinator: CALCULATION_INTERVAL_SECONDS must be a multiple of SNAPSHOT_CADENCE" + _GENESIS_REWARDS_TIMESTAMP % _CALCULATION_INTERVAL_SECONDS == 0, InvalidGenesisRewardsTimestampRemainder() ); + require(_CALCULATION_INTERVAL_SECONDS % SNAPSHOT_CADENCE == 0, InvalidCalculationIntervalSecondsRemainder()); delegationManager = _delegationManager; strategyManager = _strategyManager; CALCULATION_INTERVAL_SECONDS = _CALCULATION_INTERVAL_SECONDS; @@ -113,6 +134,7 @@ abstract contract RewardsCoordinatorStorage is IRewardsCoordinator { MAX_RETROACTIVE_LENGTH = _MAX_RETROACTIVE_LENGTH; MAX_FUTURE_LENGTH = _MAX_FUTURE_LENGTH; GENESIS_REWARDS_TIMESTAMP = _GENESIS_REWARDS_TIMESTAMP; + ORIGINAL_CHAIN_ID = block.chainid; } /** diff --git a/src/contracts/core/Slasher.sol b/src/contracts/core/Slasher.sol deleted file mode 100644 index 85cc9a2ae..000000000 --- a/src/contracts/core/Slasher.sol +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.27; - -import "../interfaces/ISlasher.sol"; -import "../interfaces/IDelegationManager.sol"; -import "../interfaces/IStrategyManager.sol"; -import "../permissions/Pausable.sol"; -import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; -import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; - -/** - * @notice This contract is not in use as of the Eigenlayer M2 release. - * - * Although many contracts reference it as an immutable variable, they do not - * interact with it and it is effectively dead code. The Slasher was originally - * deployed during Eigenlayer M1, but remained paused and unused for the duration - * of that release as well. - * - * Eventually, slashing design will be finalized and the Slasher will be finished - * and more fully incorporated into the core contracts. For now, you can ignore this - * file. If you really want to see what the deployed M1 version looks like, check - * out the `init-mainnet-deployment` branch under "releases". - * - * This contract is a stub that maintains its original interface for use in testing - * and deploy scripts. Otherwise, it does nothing. - */ -contract Slasher is Initializable, OwnableUpgradeable, ISlasher, Pausable { - constructor(IStrategyManager, IDelegationManager) {} - - function initialize(address, IPauserRegistry, uint256) external {} - - function optIntoSlashing( - address - ) external {} - - function freezeOperator( - address - ) external {} - - function resetFrozenStatus( - address[] calldata - ) external {} - - function recordFirstStakeUpdate(address, uint32) external {} - - function recordStakeUpdate(address, uint32, uint32, uint256) external {} - - function recordLastStakeUpdateAndRevokeSlashingAbility(address, uint32) external {} - - function strategyManager() external view returns (IStrategyManager) {} - - function delegation() external view returns (IDelegationManager) {} - - function isFrozen( - address - ) external view returns (bool) {} - - function canSlash(address, address) external view returns (bool) {} - - function contractCanSlashOperatorUntilBlock(address, address) external view returns (uint32) {} - - function latestUpdateBlock(address, address) external view returns (uint32) {} - - function getCorrectValueForInsertAfter(address, uint32) external view returns (uint256) {} - - function canWithdraw(address, uint32, uint256) external returns (bool) {} - - function operatorToMiddlewareTimes(address, uint256) external view returns (MiddlewareTimes memory) {} - - function middlewareTimesLength( - address - ) external view returns (uint256) {} - - function getMiddlewareTimesIndexStalestUpdateBlock(address, uint32) external view returns (uint32) {} - - function getMiddlewareTimesIndexServeUntilBlock(address, uint32) external view returns (uint32) {} - - function operatorWhitelistedContractsLinkedListSize( - address - ) external view returns (uint256) {} - - function operatorWhitelistedContractsLinkedListEntry( - address, - address - ) external view returns (bool, uint256, uint256) {} - - function whitelistedContractDetails(address, address) external view returns (MiddlewareDetails memory) {} -} diff --git a/src/contracts/core/StrategyManager.sol b/src/contracts/core/StrategyManager.sol index 70cb217ad..7c965647b 100644 --- a/src/contracts/core/StrategyManager.sol +++ b/src/contracts/core/StrategyManager.sol @@ -5,6 +5,7 @@ import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; + import "../interfaces/IEigenPodManager.sol"; import "../permissions/Pausable.sol"; import "./StrategyManagerStorage.sol"; @@ -26,16 +27,11 @@ contract StrategyManager is Pausable, StrategyManagerStorage { + using SlashingLib for *; using SafeERC20 for IERC20; - // index for flag that pauses deposits when set - uint8 internal constant PAUSED_DEPOSITS = 0; - - // chain id at the time of contract deployment - uint256 internal immutable ORIGINAL_CHAIN_ID; - modifier onlyStrategyWhitelister() { - require(msg.sender == strategyWhitelister, UnauthorizedCaller()); + require(msg.sender == strategyWhitelister, OnlyStrategyWhitelister()); _; } @@ -47,22 +43,20 @@ contract StrategyManager is } modifier onlyDelegationManager() { - require(msg.sender == address(delegation), UnauthorizedCaller()); + require(msg.sender == address(delegation), OnlyDelegationManager()); _; } /** * @param _delegation The delegation contract of EigenLayer. - * @param _slasher The primary slashing contract of EigenLayer. * @param _eigenPodManager The contract that keeps track of EigenPod stakes for restaking beacon chain ether. */ constructor( IDelegationManager _delegation, IEigenPodManager _eigenPodManager, - ISlasher _slasher - ) StrategyManagerStorage(_delegation, _eigenPodManager, _slasher) { + IAVSDirectory _avsDirectory + ) StrategyManagerStorage(_delegation, _eigenPodManager, _avsDirectory) { _disableInitializers(); - ORIGINAL_CHAIN_ID = block.chainid; } // EXTERNAL FUNCTIONS @@ -102,7 +96,7 @@ contract StrategyManager is IStrategy strategy, IERC20 token, uint256 amount - ) external onlyWhenNotPaused(PAUSED_DEPOSITS) nonReentrant returns (uint256 shares) { + ) external onlyWhenNotPaused(PAUSED_DEPOSITS) nonReentrant returns (OwnedShares shares) { shares = _depositIntoStrategy(msg.sender, strategy, token, amount); } @@ -122,7 +116,6 @@ contract StrategyManager is * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf. * @dev A signature is required for this function to eliminate the possibility of griefing attacks, specifically those * targeting stakers who may be attempting to undelegate. - * @dev Cannot be called if thirdPartyTransfersForbidden is set to true for this strategy * * WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended. This can lead to attack vectors * where the token balance and corresponding strategy shares are not in sync upon reentrancy @@ -134,8 +127,7 @@ contract StrategyManager is address staker, uint256 expiry, bytes memory signature - ) external onlyWhenNotPaused(PAUSED_DEPOSITS) nonReentrant returns (uint256 shares) { - require(!thirdPartyTransfersForbidden[strategy], ThirdPartyTransfersDisabled()); + ) external onlyWhenNotPaused(PAUSED_DEPOSITS) nonReentrant returns (OwnedShares shares) { require(expiry >= block.timestamp, SignatureExpired()); // calculate struct hash, then increment `staker`'s nonce uint256 nonce = nonces[staker]; @@ -160,39 +152,30 @@ contract StrategyManager is } /// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue - function removeShares(address staker, IStrategy strategy, uint256 shares) external onlyDelegationManager { + function removeShares(address staker, IStrategy strategy, Shares shares) external onlyDelegationManager { _removeShares(staker, strategy, shares); } /// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue - function addShares( + function addOwnedShares( address staker, - IERC20 token, IStrategy strategy, - uint256 shares + IERC20 token, + OwnedShares ownedShares ) external onlyDelegationManager { - _addShares(staker, token, strategy, shares); + _addOwnedShares(staker, token, strategy, ownedShares); } /// @notice Used by the DelegationManager to convert withdrawn shares to tokens and send them to a recipient + /// Assumes that shares being passed in have already been accounted for any slashing + /// and are the `real` shares in the strategy to withdraw function withdrawSharesAsTokens( - address recipient, + address staker, IStrategy strategy, - uint256 shares, - IERC20 token + IERC20 token, + OwnedShares ownedShares ) external onlyDelegationManager { - strategy.withdraw(recipient, token, shares); - } - - /** - * If true for a strategy, a user cannot depositIntoStrategyWithSignature into that strategy for another staker - * and also when performing DelegationManager.queueWithdrawals, a staker can only withdraw to themselves. - * Defaulted to false for all existing strategies. - * @param strategy The strategy to set `thirdPartyTransfersForbidden` value to - * @param value bool value to set `thirdPartyTransfersForbidden` to - */ - function setThirdPartyTransfersForbidden(IStrategy strategy, bool value) external onlyStrategyWhitelister { - _setThirdPartyTransfersForbidden(strategy, value); + strategy.withdraw(staker, token, ownedShares.unwrap()); } /** @@ -208,23 +191,16 @@ contract StrategyManager is /** * @notice Owner-only function that adds the provided Strategies to the 'whitelist' of strategies that stakers can deposit into * @param strategiesToWhitelist Strategies that will be added to the `strategyIsWhitelistedForDeposit` mapping (if they aren't in it already) - * @param thirdPartyTransfersForbiddenValues bool values to set `thirdPartyTransfersForbidden` to for each strategy */ function addStrategiesToDepositWhitelist( - IStrategy[] calldata strategiesToWhitelist, - bool[] calldata thirdPartyTransfersForbiddenValues + IStrategy[] calldata strategiesToWhitelist ) external onlyStrategyWhitelister { - require(strategiesToWhitelist.length == thirdPartyTransfersForbiddenValues.length, InputArrayLengthMismatch()); uint256 strategiesToWhitelistLength = strategiesToWhitelist.length; - for (uint256 i = 0; i < strategiesToWhitelistLength;) { + for (uint256 i = 0; i < strategiesToWhitelistLength; ++i) { // change storage and emit event only if strategy is not already in whitelist if (!strategyIsWhitelistedForDeposit[strategiesToWhitelist[i]]) { strategyIsWhitelistedForDeposit[strategiesToWhitelist[i]] = true; emit StrategyAddedToDepositWhitelist(strategiesToWhitelist[i]); - _setThirdPartyTransfersForbidden(strategiesToWhitelist[i], thirdPartyTransfersForbiddenValues[i]); - } - unchecked { - ++i; } } } @@ -237,16 +213,11 @@ contract StrategyManager is IStrategy[] calldata strategiesToRemoveFromWhitelist ) external onlyStrategyWhitelister { uint256 strategiesToRemoveFromWhitelistLength = strategiesToRemoveFromWhitelist.length; - for (uint256 i = 0; i < strategiesToRemoveFromWhitelistLength;) { + for (uint256 i = 0; i < strategiesToRemoveFromWhitelistLength; ++i) { // change storage and emit event only if strategy is already in whitelist if (strategyIsWhitelistedForDeposit[strategiesToRemoveFromWhitelist[i]]) { strategyIsWhitelistedForDeposit[strategiesToRemoveFromWhitelist[i]] = false; emit StrategyRemovedFromDepositWhitelist(strategiesToRemoveFromWhitelist[i]); - // Set mapping value to default false value - _setThirdPartyTransfersForbidden(strategiesToRemoveFromWhitelist[i], false); - } - unchecked { - ++i; } } } @@ -258,26 +229,36 @@ contract StrategyManager is * @param staker The address to add shares to * @param token The token that is being deposited (used for indexing) * @param strategy The Strategy in which the `staker` is receiving shares - * @param shares The amount of shares to grant to the `staker` + * @param ownedShares The amount of ownedShares to grant to the `staker` * @dev In particular, this function calls `delegation.increaseDelegatedShares(staker, strategy, shares)` to ensure that all * delegated shares are tracked, increases the stored share amount in `stakerStrategyShares[staker][strategy]`, and adds `strategy` * to the `staker`'s list of strategies, if it is not in the list already. */ - function _addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) internal { + function _addOwnedShares(address staker, IERC20 token, IStrategy strategy, OwnedShares ownedShares) internal { // sanity checks on inputs require(staker != address(0), StakerAddressZero()); - require(shares != 0, SharesAmountZero()); + require(ownedShares.unwrap() != 0, SharesAmountZero()); + + Shares existingShares = stakerStrategyShares[staker][strategy]; - // if they dont have existing shares of this strategy, add it to their strats - if (stakerStrategyShares[staker][strategy] == 0) { + // if they dont have existing ownedShares of this strategy, add it to their strats + if (existingShares.unwrap() == 0) { require(stakerStrategyList[staker].length < MAX_STAKER_STRATEGY_LIST_LENGTH, MaxStrategiesExceeded()); stakerStrategyList[staker].push(strategy); } - // add the returned shares to their existing shares for this strategy - stakerStrategyShares[staker][strategy] += shares; + // add the returned ownedShares to their existing shares for this strategy + stakerStrategyShares[staker][strategy] = existingShares.add(ownedShares.unwrap()).wrapShares(); - emit Deposit(staker, token, strategy, shares); + // Increase shares delegated to operator, if needed + delegation.increaseDelegatedShares({ + staker: staker, + strategy: strategy, + existingShares: existingShares, + addedOwnedShares: ownedShares + }); + + emit Deposit(staker, token, strategy, ownedShares); } /** @@ -287,27 +268,24 @@ contract StrategyManager is * @param strategy The Strategy contract to deposit into. * @param token The ERC20 token to deposit. * @param amount The amount of `token` to deposit. - * @return shares The amount of *new* shares in `strategy` that have been credited to the `staker`. + * @return ownedShares The amount of *new* ownedShares in `strategy` that have been credited to the `staker`. */ function _depositIntoStrategy( address staker, IStrategy strategy, IERC20 token, uint256 amount - ) internal onlyStrategiesWhitelistedForDeposit(strategy) returns (uint256 shares) { + ) internal onlyStrategiesWhitelistedForDeposit(strategy) returns (OwnedShares ownedShares) { // transfer tokens from the sender to the strategy token.safeTransferFrom(msg.sender, address(strategy), amount); // deposit the assets into the specified strategy and get the equivalent amount of shares in that strategy - shares = strategy.deposit(token, amount); + ownedShares = strategy.deposit(token, amount).wrapOwned(); // add the returned shares to the staker's existing shares for this strategy - _addShares(staker, token, strategy, shares); + _addOwnedShares(staker, token, strategy, ownedShares); - // Increase shares delegated to operator, if needed - delegation.increaseDelegatedShares(staker, strategy, shares); - - return shares; + return ownedShares; } /** @@ -318,24 +296,22 @@ contract StrategyManager is * @dev If the amount of shares represents all of the staker`s shares in said strategy, * then the strategy is removed from stakerStrategyList[staker] and 'true' is returned. Otherwise 'false' is returned. */ - function _removeShares(address staker, IStrategy strategy, uint256 shareAmount) internal returns (bool) { + function _removeShares(address staker, IStrategy strategy, Shares shareAmount) internal returns (bool) { // sanity checks on inputs - require(shareAmount != 0, SharesAmountZero()); + require(shareAmount.unwrap() != 0, SharesAmountZero()); //check that the user has sufficient shares - uint256 userShares = stakerStrategyShares[staker][strategy]; + Shares userShares = stakerStrategyShares[staker][strategy]; - require(shareAmount <= userShares, InsufficientShares()); - //unchecked arithmetic since we just checked this above - unchecked { - userShares = userShares - shareAmount; - } + require(shareAmount.unwrap() <= userShares.unwrap(), SharesAmountTooHigh()); + + userShares = userShares.sub(shareAmount.unwrap()).wrapShares(); // subtract the shares from the staker's existing shares for this strategy stakerStrategyShares[staker][strategy] = userShares; // if no existing shares, remove the strategy from the staker's dynamic array of strategies - if (userShares == 0) { + if (userShares.unwrap() == 0) { _removeStrategyFromStakerStrategyList(staker, strategy); // return true in the event that the strategy was removed from stakerStrategyList[staker] @@ -354,15 +330,12 @@ contract StrategyManager is //loop through all of the strategies, find the right one, then replace uint256 stratsLength = stakerStrategyList[staker].length; uint256 j = 0; - for (; j < stratsLength;) { + for (; j < stratsLength; ++j) { if (stakerStrategyList[staker][j] == strategy) { //replace the strategy with the last strategy in the list stakerStrategyList[staker][j] = stakerStrategyList[staker][stakerStrategyList[staker].length - 1]; break; } - unchecked { - ++j; - } } // if we didn't find the strategy, revert require(j != stratsLength, StrategyNotFound()); @@ -370,17 +343,6 @@ contract StrategyManager is stakerStrategyList[staker].pop(); } - /** - * @notice Internal function for modifying `thirdPartyTransfersForbidden`. - * Used inside of the `setThirdPartyTransfersForbidden` and `addStrategiesToDepositWhitelist` functions. - * @param strategy The strategy to set `thirdPartyTransfersForbidden` value to - * @param value bool value to set `thirdPartyTransfersForbidden` to - */ - function _setThirdPartyTransfersForbidden(IStrategy strategy, bool value) internal { - emit UpdatedThirdPartyTransfersForbidden(strategy, value); - thirdPartyTransfersForbidden[strategy] = value; - } - /** * @notice Internal function for modifying the `strategyWhitelister`. Used inside of the `setStrategyWhitelister` and `initialize` functions. * @param newStrategyWhitelister The new address for the `strategyWhitelister` to take. @@ -393,6 +355,7 @@ contract StrategyManager is } // VIEW FUNCTIONS + /** * @notice Get all details on the staker's deposits and corresponding shares * @param staker The staker of interest, whose deposits this function will fetch @@ -400,19 +363,22 @@ contract StrategyManager is */ function getDeposits( address staker - ) external view returns (IStrategy[] memory, uint256[] memory) { + ) external view returns (IStrategy[] memory, Shares[] memory) { uint256 strategiesLength = stakerStrategyList[staker].length; - uint256[] memory shares = new uint256[](strategiesLength); + Shares[] memory shares = new Shares[](strategiesLength); - for (uint256 i = 0; i < strategiesLength;) { + for (uint256 i = 0; i < strategiesLength; ++i) { shares[i] = stakerStrategyShares[staker][stakerStrategyList[staker][i]]; - unchecked { - ++i; - } } return (stakerStrategyList[staker], shares); } + function getStakerStrategyList( + address staker + ) external view returns (IStrategy[] memory) { + return stakerStrategyList[staker]; + } + /// @notice Simple getter function that returns `stakerStrategyList[staker].length`. function stakerStrategyListLength( address staker diff --git a/src/contracts/core/StrategyManagerStorage.sol b/src/contracts/core/StrategyManagerStorage.sol index 1a0e5963d..a4d3fa0d4 100644 --- a/src/contracts/core/StrategyManagerStorage.sol +++ b/src/contracts/core/StrategyManagerStorage.sol @@ -5,7 +5,7 @@ import "../interfaces/IStrategyManager.sol"; import "../interfaces/IStrategy.sol"; import "../interfaces/IEigenPodManager.sol"; import "../interfaces/IDelegationManager.sol"; -import "../interfaces/ISlasher.sol"; +import "../interfaces/IAVSDirectory.sol"; /** * @title Storage variables for the `StrategyManager` contract. @@ -14,19 +14,32 @@ import "../interfaces/ISlasher.sol"; * @notice This storage contract is separate from the logic to simplify the upgrade process. */ abstract contract StrategyManagerStorage is IStrategyManager { + // Constants + /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the deposit struct used by the contract bytes32 public constant DEPOSIT_TYPEHASH = keccak256("Deposit(address staker,address strategy,address token,uint256 amount,uint256 nonce,uint256 expiry)"); + // maximum length of dynamic arrays in `stakerStrategyList` mapping, for sanity's sake uint8 internal constant MAX_STAKER_STRATEGY_LIST_LENGTH = 32; - // system contracts + // index for flag that pauses deposits when set + uint8 internal constant PAUSED_DEPOSITS = 0; + + // Immutables + IDelegationManager public immutable delegation; + IEigenPodManager public immutable eigenPodManager; - ISlasher public immutable slasher; + + IAVSDirectory public immutable avsDirectory; + + uint256 internal immutable ORIGINAL_CHAIN_ID; + + // Mutatables /** * @notice Original EIP-712 Domain separator for this contract. @@ -34,19 +47,25 @@ abstract contract StrategyManagerStorage is IStrategyManager { * Use the getter function `domainSeparator` to get the current domain separator for this contract. */ bytes32 internal _DOMAIN_SEPARATOR; + // staker => number of signed deposit nonce (used in depositIntoStrategyWithSignature) mapping(address => uint256) public nonces; + /// @notice Permissioned role, which can be changed by the contract owner. Has the ability to edit the strategy whitelist address public strategyWhitelister; + /* * Reserved space previously used by the deprecated storage variable `withdrawalDelayBlocks. * This variable was migrated to the DelegationManager instead. */ uint256 private __deprecated_withdrawalDelayBlocks; + /// @notice Mapping: staker => Strategy => number of shares which they currently hold - mapping(address => mapping(IStrategy => uint256)) public stakerStrategyShares; + mapping(address => mapping(IStrategy => Shares)) public stakerStrategyShares; + /// @notice Mapping: staker => array of strategies in which they have nonzero shares mapping(address => IStrategy[]) public stakerStrategyList; + /// @notice *Deprecated* mapping: hash of withdrawal inputs, aka 'withdrawalRoot' => whether the withdrawal is pending /// @dev This mapping is preserved to allow the migration of withdrawals to the DelegationManager contract. mapping(bytes32 => bool) private __deprecated_withdrawalRootPending; @@ -56,6 +75,7 @@ abstract contract StrategyManagerStorage is IStrategyManager { * Withdrawals are now initiated in the DlegationManager, so the mapping has moved to that contract. */ mapping(address => uint256) private __deprecated_numWithdrawalsQueued; + /// @notice Mapping: strategy => whether or not stakers are allowed to deposit into it mapping(IStrategy => bool) public strategyIsWhitelistedForDeposit; /* @@ -70,12 +90,19 @@ abstract contract StrategyManagerStorage is IStrategyManager { * if true for a strategy, a user cannot depositIntoStrategyWithSignature into that strategy for another staker * and also when performing queueWithdrawals, a staker can only withdraw to themselves */ - mapping(IStrategy => bool) public thirdPartyTransfersForbidden; + mapping(IStrategy => bool) private __deprecated_thirdPartyTransfersForbidden; + + // Construction - constructor(IDelegationManager _delegation, IEigenPodManager _eigenPodManager, ISlasher _slasher) { + /** + * @param _delegation The delegation contract of EigenLayer. + * @param _eigenPodManager The contract that keeps track of EigenPod stakes for restaking beacon chain ether. + */ + constructor(IDelegationManager _delegation, IEigenPodManager _eigenPodManager, IAVSDirectory _avsDirectory) { delegation = _delegation; eigenPodManager = _eigenPodManager; - slasher = _slasher; + avsDirectory = _avsDirectory; + ORIGINAL_CHAIN_ID = block.chainid; } /** diff --git a/src/contracts/interfaces/IAVSDirectory.sol b/src/contracts/interfaces/IAVSDirectory.sol index 87ce2ca7c..af73613c6 100644 --- a/src/contracts/interfaces/IAVSDirectory.sol +++ b/src/contracts/interfaces/IAVSDirectory.sol @@ -3,24 +3,36 @@ pragma solidity >=0.5.0; import "./ISignatureUtils.sol"; +/// @notice Struct representing an operator set +struct OperatorSet { + address avs; + uint32 operatorSetId; +} + interface IAVSDirectory is ISignatureUtils { /// Operator Status /// @dev Thrown when an operator does not exist in the DelegationManager error OperatorDoesNotExist(); - /// @dev Thrown when `operator` is not registered to the AVS. - error OperatorNotRegistered(); /// @dev Thrown when `operator` is already registered to the AVS. error OperatorAlreadyRegistered(); - /// Signatures - + /// @notice Enum representing the status of an operator's registration with an AVS + /// @dev Thrown when an invalid AVS is provided. + error InvalidAVS(); + /// @dev Thrown when an invalid operator is provided. + error InvalidOperator(); + /// @dev Thrown when an invalid operator set is provided. + error InvalidOperatorSet(); + /// @dev Thrown when `operator` is not a registered operator. + error OperatorNotRegistered(); /// @dev Thrown when attempting to spend a spent eip-712 salt. - error SignatureSaltSpent(); + error SaltSpent(); /// @dev Thrown when attempting to use an expired eip-712 signature. error SignatureExpired(); - /// @notice Enum representing the status of an operator's registration with an AVS + /// @notice Enum representing the registration status of an operator with an AVS. + /// @notice Only used by legacy M2 AVSs that have not integrated with operatorSets. enum OperatorAVSRegistrationStatus { UNREGISTERED, // Operator not registered to AVS REGISTERED // Operator registered to AVS @@ -28,20 +40,138 @@ interface IAVSDirectory is ISignatureUtils { } /** - * @notice Emitted when @param avs indicates that they are updating their MetadataURI string - * @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing + * @notice Struct representing the registration status of an operator with an operator set. + * Keeps track of last deregistered timestamp for slashability concerns. + * @param registered whether the operator is registered with the operator set + * @param lastDeregisteredTimestamp the timestamp at which the operator was last deregistered */ - event AVSMetadataURIUpdated(address indexed avs, string metadataURI); + struct OperatorSetRegistrationStatus { + bool registered; + uint32 lastDeregisteredTimestamp; + } + + /// @notice Emitted when an operator set is created by an AVS. + event OperatorSetCreated(OperatorSet operatorSet); - /// @notice Emitted when an operator's registration status for an AVS is updated + /** + * @notice Emitted when an operator's registration status with an AVS id udpated + * @notice Only used by legacy M2 AVSs that have not integrated with operatorSets. + */ event OperatorAVSRegistrationStatusUpdated( address indexed operator, address indexed avs, OperatorAVSRegistrationStatus status ); + /// @notice Emitted when an operator is added to an operator set. + event OperatorAddedToOperatorSet(address indexed operator, OperatorSet operatorSet); + + /// @notice Emitted when an operator is removed from an operator set. + event OperatorRemovedFromOperatorSet(address indexed operator, OperatorSet operatorSet); + + /// @notice Emitted when an AVS updates their metadata URI (Uniform Resource Identifier). + /// @dev The URI is never stored; it is simply emitted through an event for off-chain indexing. + event AVSMetadataURIUpdated(address indexed avs, string metadataURI); + + /// @notice Emitted when an AVS migrates to using operator sets. + event AVSMigratedToOperatorSets(address indexed avs); + + /// @notice Emitted when an operator is migrated from M2 registration to operator sets. + event OperatorMigratedToOperatorSets(address indexed operator, address indexed avs, uint32[] operatorSetIds); + /** - * @notice Called by an avs to register an operator with the avs. - * @param operator The address of the operator to register. - * @param operatorSignature The signature, salt, and expiry of the operator's signature. + * + * EXTERNAL FUNCTIONS + * + */ + + /** + * @notice Called by an AVS to create a list of new operatorSets. + * + * @param operatorSetIds The IDs of the operator set to initialize. + * + * @dev msg.sender must be the AVS. + * @dev The AVS may create operator sets before it becomes an operator set AVS. + */ + function createOperatorSets( + uint32[] calldata operatorSetIds + ) external; + + /** + * @notice Sets the AVS as an operator set AVS, preventing legacy M2 operator registrations. + * + * @dev msg.sender must be the AVS. + */ + function becomeOperatorSetAVS() external; + + /** + * @notice Called by an AVS to migrate operators that have a legacy M2 registration to operator sets. + * + * @param operators The list of operators to migrate + * @param operatorSetIds The list of operatorSets to migrate the operators to + * + * @dev The msg.sender used is the AVS + * @dev The operator can only be migrated at most once per AVS + * @dev The AVS can no longer register operators via the legacy M2 registration path once it begins migration + * @dev The operator is deregistered from the M2 legacy AVS once migrated + */ + function migrateOperatorsToOperatorSets( + address[] calldata operators, + uint32[][] calldata operatorSetIds + ) external; + + /** + * @notice Called by AVSs to add an operator to list of operatorSets. + * + * @param operator The address of the operator to be added to the operator set. + * @param operatorSetIds The IDs of the operator sets. + * @param operatorSignature The signature of the operator on their intent to register. + * + * @dev msg.sender is used as the AVS. + * @dev The operator must not have a pending deregistration from the operator set. + */ + function registerOperatorToOperatorSets( + address operator, + uint32[] calldata operatorSetIds, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external; + + /** + * @notice Called by AVSs to remove an operator from an operator set. + * + * @param operator The address of the operator to be removed from the operator set. + * @param operatorSetIds The IDs of the operator sets. + * + * @dev msg.sender is used as the AVS. + */ + function deregisterOperatorFromOperatorSets(address operator, uint32[] calldata operatorSetIds) external; + + /** + * @notice Called by an operator to deregister from an operator set + * + * @param operator The operator to deregister from the operatorSets. + * @param avs The address of the AVS to deregister the operator from. + * @param operatorSetIds The IDs of the operator sets. + * @param operatorSignature the signature of the operator on their intent to deregister or empty if the operator itself is calling + * + * @dev if the operatorSignature is empty, the caller must be the operator + * @dev this will likely only be called in case the AVS contracts are in a state that prevents operators from deregistering + */ + function forceDeregisterFromOperatorSets( + address operator, + address avs, + uint32[] calldata operatorSetIds, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external; + + /** + * @notice Legacy function called by the AVS's service manager contract + * to register an operator with the AVS. NOTE: this function will be deprecated in a future release + * after the slashing release. New AVSs should use `registerOperatorToOperatorSets` instead. + * + * @param operator The address of the operator to register. + * @param operatorSignature The signature, salt, and expiry of the operator's signature. + * + * @dev msg.sender must be the AVS. + * @dev Only used by legacy M2 AVSs that have not integrated with operator sets. */ function registerOperatorToAVS( address operator, @@ -49,34 +179,128 @@ interface IAVSDirectory is ISignatureUtils { ) external; /** - * @notice Called by an avs to deregister an operator with the avs. - * @param operator The address of the operator to deregister. + * @notice Legacy function called by an AVS to deregister an operator from the AVS. + * NOTE: this function will be deprecated in a future release after the slashing release. + * New AVSs integrating should use `deregisterOperatorFromOperatorSets` instead. + * + * @param operator The address of the operator to deregister. + * + * @dev Only used by legacy M2 AVSs that have not integrated with operator sets. */ function deregisterOperatorFromAVS( address operator ) external; /** - * @notice Called by an AVS to emit an `AVSMetadataURIUpdated` event indicating the information has updated. - * @param metadataURI The URI for metadata associated with an AVS - * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `AVSMetadataURIUpdated` event + * @notice Called by an AVS to emit an `AVSMetadataURIUpdated` event indicating the information has updated. + * + * @param metadataURI The URI for metadata associated with an AVS. + * + * @dev Note that the `metadataURI` is *never stored* and is only emitted in the `AVSMetadataURIUpdated` event. */ function updateAVSMetadataURI( string calldata metadataURI ) external; /** - * @notice Returns whether or not the salt has already been used by the operator. - * @dev Salts is used in the `registerOperatorToAVS` function. + * @notice Called by an operator to cancel a salt that has been used to register with an AVS. + * + * @param salt A unique and single use value associated with the approver signature. + */ + function cancelSalt( + bytes32 salt + ) external; + + /** + * + * VIEW FUNCTIONS + * */ function operatorSaltIsSpent(address operator, bytes32 salt) external view returns (bool); + function isMember(address operator, OperatorSet memory operatorSet) external view returns (bool); + /** - * @notice Calculates the digest hash to be signed by an operator to register with an AVS - * @param operator The account registering as an operator - * @param avs The AVS the operator is registering to - * @param salt A unique and single use value associated with the approver signature. - * @param expiry Time after which the approver's signature becomes invalid + * @notice operator is slashable by operatorSet if currently registered OR last deregistered within 21 days + * @param operator the operator to check slashability for + * @param operatorSet the operatorSet to check slashability for + * @return bool if the operator is slashable by the operatorSet + */ + function isOperatorSlashable(address operator, OperatorSet memory operatorSet) external view returns (bool); + + function isOperatorSetAVS( + address avs + ) external view returns (bool); + + /// @notice Returns true if the operator set is valid. + function isOperatorSet(address avs, uint32 operatorSetId) external view returns (bool); + + /// @notice Returns true if all provided operator sets are valid. + function isOperatorSetBatch( + OperatorSet[] calldata operatorSets + ) external view returns (bool); + + /** + * @notice Returns operator set an operator is registered to in the order they were registered. + * @param operator The operator address to query. + * @param index The index of the enumerated list of operator sets. + */ + function operatorSetsMemberOfAtIndex(address operator, uint256 index) external view returns (OperatorSet memory); + + /** + * @notice Retursn the operator registered to an operatorSet in the order that it was registered. + * @param operatorSet The operatorSet to query. + * @param index The index of the enumerated list of operators. + */ + function operatorSetMemberAtIndex(OperatorSet memory operatorSet, uint256 index) external view returns (address); + + /** + * @notice Returns an array of operator sets an operator is registered to. + * @param operator The operator address to query. + * @param start The starting index of the array to query. + * @param length The amount of items of the array to return. + */ + function getOperatorSetsOfOperator( + address operator, + uint256 start, + uint256 length + ) external view returns (OperatorSet[] memory operatorSets); + + /** + * @notice Returns an array of operators registered to the operatorSet. + * @param operatorSet The operatorSet to query. + * @param start The starting index of the array to query. + * @param length The amount of items of the array to return. + */ + function getOperatorsInOperatorSet( + OperatorSet memory operatorSet, + uint256 start, + uint256 length + ) external view returns (address[] memory operators); + + /** + * @notice Returns the number of operators registered to an operatorSet. + * @param operatorSet The operatorSet to get the member count for + */ + function getNumOperatorsInOperatorSet( + OperatorSet memory operatorSet + ) external view returns (uint256); + + /** + * @notice Returns the total number of operator sets an operator is registered to. + * @param operator The operator address to query. + */ + function inTotalOperatorSets( + address operator + ) external view returns (uint256); + + /** + * @notice Calculates the digest hash to be signed by an operator to register with an AVS. + * + * @param operator The account registering as an operator. + * @param avs The AVS the operator is registering with. + * @param salt A unique and single-use value associated with the approver's signature. + * @param expiry The time after which the approver's signature becomes invalid. */ function calculateOperatorAVSRegistrationDigestHash( address operator, @@ -85,6 +309,49 @@ interface IAVSDirectory is ISignatureUtils { uint256 expiry ) external view returns (bytes32); - /// @notice The EIP-712 typehash for the Registration struct used by the contract + /** + * @notice Calculates the digest hash to be signed by an operator to register with an operator set. + * + * @param avs The AVS that operator is registering to operator sets for. + * @param operatorSetIds An array of operator set IDs the operator is registering to. + * @param salt A unique and single use value associated with the approver signature. + * @param expiry Time after which the approver's signature becomes invalid. + */ + function calculateOperatorSetRegistrationDigestHash( + address avs, + uint32[] calldata operatorSetIds, + bytes32 salt, + uint256 expiry + ) external view returns (bytes32); + + /** + * @notice Calculates the digest hash to be signed by an operator to force deregister from an operator set. + * + * @param avs The AVS that operator is deregistering from. + * @param operatorSetIds An array of operator set IDs the operator is deregistering from. + * @param salt A unique and single use value associated with the approver signature. + * @param expiry Time after which the approver's signature becomes invalid. + */ + function calculateOperatorSetForceDeregistrationTypehash( + address avs, + uint32[] calldata operatorSetIds, + bytes32 salt, + uint256 expiry + ) external view returns (bytes32); + + /// @notice Getter function for the current EIP-712 domain separator for this contract. + /// @dev The domain separator will change in the event of a fork that changes the ChainID. + function domainSeparator() external view returns (bytes32); + + /// @notice The EIP-712 typehash for the Registration struct used by the contract. function OPERATOR_AVS_REGISTRATION_TYPEHASH() external view returns (bytes32); + + /// @notice The EIP-712 typehash for the OperatorSetRegistration struct used by the contract. + function OPERATOR_SET_REGISTRATION_TYPEHASH() external view returns (bytes32); + + function operatorSetStatus( + address avs, + address operator, + uint32 operatorSetId + ) external view returns (bool registered, uint32 lastDeregisteredTimestamp); } diff --git a/src/contracts/interfaces/IAllocationManager.sol b/src/contracts/interfaces/IAllocationManager.sol new file mode 100644 index 000000000..6e1fbe6e6 --- /dev/null +++ b/src/contracts/interfaces/IAllocationManager.sol @@ -0,0 +1,325 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity >=0.5.0; + +import {OperatorSet} from "./IAVSDirectory.sol"; +import "./IStrategy.sol"; +import "./ISignatureUtils.sol"; + +interface IAllocationManager is ISignatureUtils { + /// @dev Thrown when `bipsToSlash` is greater than 10,000 bips (100%), or zero. + error InvalidBipsToSlash(); + /// @dev Thrown when `operator` is not a registered operator. + error OperatorNotRegistered(); + /// @dev Thrown when two array parameters have mismatching lengths. + error InputArrayLengthMismatch(); + /// @dev Thrown when an operator attempts to set their allocation delay to 0 + error InvalidDelay(); + /// @dev Thrown when an operator's allocation delay has yet to be set. + error UninitializedAllocationDelay(); + /// @dev Thrown when provided `expectedTotalMagnitude` for a given allocation does not match `currentTotalMagnitude`. + error InvalidExpectedTotalMagnitude(); + /// @dev Thrown when an invalid operator set is provided. + error InvalidOperatorSet(); + /// @dev Thrown when an invalid operator is provided. + error InvalidOperator(); + /// @dev Thrown when caller is not the delegation manager. + error OnlyDelegationManager(); + /// @dev Thrown when an operator attempts to set their allocation for an operatorSet to the same value + error SameMagnitude(); + /// @dev Thrown when an allocation is attempted for a given operator when they have pending allocations or deallocations. + error ModificationAlreadyPending(); + /// @dev Thrown when an allocation is attempted that exceeds a given operators total allocatable magnitude. + error InsufficientAllocatableMagnitude(); + /// @dev Thrown when attempting to use an expired eip-712 signature. + error SignatureExpired(); + /// @dev Thrown when attempting to spend a spent eip-712 salt. + error SaltSpent(); + + /** + * @notice struct used to modify the allocation of slashable magnitude to list of operatorSets + * @param strategy the strategy to allocate magnitude for + * @param expectedTotalMagnitude the expected total magnitude of the operator used to combat against race conditions with slashing + * @param operatorSets the operatorSets to allocate magnitude for + * @param magnitudes the magnitudes to allocate for each operatorSet + */ + struct MagnitudeAllocation { + IStrategy strategy; + uint64 expectedTotalMagnitude; + OperatorSet[] operatorSets; + uint64[] magnitudes; + } + + /** + * @notice struct used for pending free magnitude. Stored in (operator, strategy, operatorSet) mapping + * to be used in completeDeallocations. + * @param magnitudeDiff the amount of magnitude to deallocate + * @param completableTimestamp the timestamp at which the deallocation can be completed, 21 days from when queued + */ + // struct PendingFreeMagnitude { + // uint64 magnitudeDiff; + // uint32 completableTimestamp; + // } + + /** + * @notice struct used for operator magnitude updates. Stored in _operatorMagnitudeInfo mapping + * @param currentMagnitude the current magnitude of the operator + * @param pendingMagnitudeIdff the pending magnitude difference of the operator + * @param effectTimestamp the timestamp at which the pending magnitude will take effect + */ + struct MagnitudeInfo { + int128 pendingMagnitudeDiff; + uint64 currentMagnitude; + uint32 effectTimestamp; + } + + /** + * @notice Struct containing info regarding free allocatable magnitude. + * @param nextPendingIndex The next available update index. + * @param freeMagnitude The total amount of free allocatable magnitude. + */ + struct FreeMagnitudeInfo { + uint192 nextPendingIndex; + uint64 freeMagnitude; + } + + /** + * @notice Struct containing allocation delay metadata for a given operator. + * @param delay Current allocation delay if `pendingDelay` is non-zero and `pendingDelayEffectTimestamp` has elapsed. + * @param pendingDelay Current allocation delay if it's non-zero and `pendingDelayEffectTimestamp` has elapsed. + * @param pendingDelayEffectTimestamp The timestamp for which `pendingDelay` becomes the curren allocation delay. + */ + struct AllocationDelayInfo { + uint32 delay; + uint32 pendingDelay; + uint32 pendingDelayEffectTimestamp; + } + + /// @notice Emitted when operator updates their allocation delay. + event AllocationDelaySet(address operator, uint32 delay); + + /// @notice Emitted when an operator set is created by an AVS. + event OperatorSetCreated(OperatorSet operatorSet); + + /// @notice Emitted when an operator allocates slashable magnitude to an operator set + event MagnitudeAllocated( + address operator, + IStrategy strategy, + OperatorSet operatorSet, + uint64 magnitudeToAllocate, + uint32 effectTimestamp + ); + + /// @notice Emitted when an operator queues deallocations of slashable magnitude from an operator set + event MagnitudeQueueDeallocated( + address operator, + IStrategy strategy, + OperatorSet operatorSet, + uint64 magnitudeToDeallocate, + uint32 completableTimestamp + ); + + /// @notice Emitted when an operator completes deallocations of slashable magnitude from an operator set + /// and adds back magnitude to free allocatable magnitude + event MagnitudeDeallocationCompleted( + address operator, IStrategy strategy, OperatorSet operatorSet, uint64 freeMagnitudeAdded + ); + + /// @notice Emitted when an operator is slashed by an operator set for a strategy + event OperatorSlashed(address operator, uint32 operatorSetId, IStrategy strategy, uint16 bipsToSlash); + + /** + * + * EXTERNAL FUNCTIONS + * + */ + + /** + * @notice Called by the delagation manager to set delay when operators register. + * @param operator The operator to set the delay on behalf of. + * @param delay The allocation delay in seconds. + * @dev msg.sender is assumed to be the delegation manager. + */ + function setAllocationDelay(address operator, uint32 delay) external; + + /** + * @notice Called by operators to set their allocation delay. + * @param delay the allocation delay in seconds + * @dev msg.sender is assumed to be the operator + */ + function setAllocationDelay( + uint32 delay + ) external; + + /** + * @notice Modifies the propotions of slashable stake allocated to a list of operatorSets for a set of strategies + * @param operator address to modify allocations for + * @param allocations array of magnitude adjustments for multiple strategies and corresponding operator sets + * @param operatorSignature signature of the operator if msg.sender is not the operator + * @dev updates freeMagnitude for the updated strategies + * @dev must be called by the operator + */ + function modifyAllocations( + address operator, + MagnitudeAllocation[] calldata allocations, + SignatureWithSaltAndExpiry calldata operatorSignature + ) external; + + /** + * @notice For all pending deallocations that have become completable, their pending free magnitude can be + * added back to the free magnitude of the (operator, strategy) amount. This function takes a list of strategies + * and adds all completable deallocations for each strategy, updating the freeMagnitudes of the operator + * + * @param operator address to complete deallocations for + * @param strategies a list of strategies to complete deallocations for + * + * @dev can be called permissionlessly by anyone + */ + function completePendingDeallocations( + address operator, + IStrategy[] calldata strategies, + uint16[] calldata numToComplete + ) external; + + /** + * @notice Called by an AVS to slash an operator for given operatorSetId, list of strategies, and bipsToSlash. + * For each given (operator, operatorSetId, strategy) tuple, bipsToSlash + * bips of the operatorSet's slashable stake allocation will be slashed + * + * @param operator the address to slash + * @param operatorSetId the ID of the operatorSet the operator is being slashed on behalf of + * @param strategies the set of strategies to slash + * @param bipsToSlash the number of bips to slash, this will be proportional to the + * operator's slashable stake allocation for the operatorSet + */ + function slashOperator( + address operator, + uint32 operatorSetId, + IStrategy[] calldata strategies, + uint16 bipsToSlash + ) external; + + /** + * @notice Called by an operator to cancel a salt that has been used to register with an AVS. + * + * @param salt A unique and single use value associated with the approver signature. + */ + function cancelSalt( + bytes32 salt + ) external; + + /** + * + * VIEW FUNCTIONS + * + */ + + /** + * @notice Returns the allocation delay of an operator + * @param operator The operator to get the allocation delay for + * @dev Defaults to `DEFAULT_ALLOCATION_DELAY` if none is set + */ + function allocationDelay( + address operator + ) external view returns (bool isSet, uint32 delay); + + /** + * @notice Get the allocatable magnitude for an operator and strategy based on number of pending deallocations + * that could be completed at the same time. This is the sum of freeMagnitude and the sum of all pending completable deallocations. + * @param operator the operator to get the allocatable magnitude for + * @param strategy the strategy to get the allocatable magnitude for + */ + function getAllocatableMagnitude(address operator, IStrategy strategy) external view returns (uint64); + + /** + * @notice Returns the pending allocations of an operator for a given strategy and operatorSets + * One of the assumptions here is we don't allow more than one pending allocation for an operatorSet at a time. + * If that changes, we would need to change this function to return all pending allocations for an operatorSet. + * @param operator the operator to get the pending allocations for + * @param strategy the strategy to get the pending allocations for + * @param operatorSets the operatorSets to get the pending allocations for + * @return pendingMagnitude the pending allocations for each operatorSet + * @return timestamps the timestamps for each pending allocation + */ + function getPendingAllocations( + address operator, + IStrategy strategy, + OperatorSet[] calldata operatorSets + ) external view returns (uint64[] memory, uint32[] memory); + + /** + * @notice Returns the pending deallocations of an operator for a given strategy and operatorSets. + * One of the assumptions here is we don't allow more than one pending deallocation for an operatorSet at a time. + * If that changes, we would need to change this function to return all pending deallocations for an operatorSet. + * @param operator the operator to get the pending deallocations for + * @param strategy the strategy to get the pending deallocations for + * @param operatorSets the operatorSets to get the pending deallocations for + * @return pendingMagnitudeDiffs the pending deallocation diffs for each operatorSet + * @return timestamps the timestamps for each pending dealloction + */ + function getPendingDeallocations( + address operator, + IStrategy strategy, + OperatorSet[] calldata operatorSets + ) external view returns (uint64[] memory, uint32[] memory); + + /** + * @param operator the operator to get the slashable magnitude for + * @param strategies the strategies to get the slashable magnitude for + * + * @return operatorSets the operator sets the operator is a member of and the current slashable magnitudes for each strategy + */ + function getSlashableMagnitudes( + address operator, + IStrategy[] calldata strategies + ) external view returns (OperatorSet[] memory, uint64[][] memory); + + /** + * @notice Returns the current total magnitudes of an operator for a given set of strategies + * @param operator the operator to get the total magnitude for + * @param strategies the strategies to get the total magnitudes for + * @return totalMagnitudes the total magnitudes for each strategy + */ + function getTotalMagnitudes( + address operator, + IStrategy[] calldata strategies + ) external view returns (uint64[] memory); + + /** + * @notice Returns the total magnitudes of an operator for a given set of strategies at a given timestamp + * @param operator the operator to get the total magnitude for + * @param strategies the strategies to get the total magnitudes for + * @param timestamp the timestamp to get the total magnitudes at + * @return totalMagnitudes the total magnitudes for each strategy + */ + function getTotalMagnitudesAtTimestamp( + address operator, + IStrategy[] calldata strategies, + uint32 timestamp + ) external view returns (uint64[] memory); + + /** + * @notice Returns the current total magnitude of an operator for a given strategy + * @param operator the operator to get the total magnitude for + * @param strategy the strategy to get the total magnitude for + * @return totalMagnitude the total magnitude for the strategy + */ + function getTotalMagnitude(address operator, IStrategy strategy) external view returns (uint64); + + /** + * @notice Calculates the digest hash to be signed by an operator to modify magnitude allocations + * @param operator The operator to allocate or deallocate magnitude for. + * @param allocations The magnitude allocations/deallocations to be made. + * @param salt A unique and single use value associated with the approver signature. + * @param expiry Time after which the approver's signature becomes invalid. + */ + function calculateMagnitudeAllocationDigestHash( + address operator, + MagnitudeAllocation[] calldata allocations, + bytes32 salt, + uint256 expiry + ) external view returns (bytes32); + + /// @notice Getter function for the current EIP-712 domain separator for this contract. + /// @dev The domain separator will change in the event of a fork that changes the ChainID. + function domainSeparator() external view returns (bytes32); +} diff --git a/src/contracts/interfaces/IDelegationManager.sol b/src/contracts/interfaces/IDelegationManager.sol index e7d9f44d9..cb8648b37 100644 --- a/src/contracts/interfaces/IDelegationManager.sol +++ b/src/contracts/interfaces/IDelegationManager.sol @@ -3,6 +3,7 @@ pragma solidity >=0.5.0; import "./IStrategy.sol"; import "./ISignatureUtils.sol"; +import "../libraries/SlashingLib.sol"; /** * @title DelegationManager @@ -17,6 +18,8 @@ import "./ISignatureUtils.sol"; interface IDelegationManager is ISignatureUtils { /// @dev Thrown when msg.sender is not allowed to call a function error UnauthorizedCaller(); + /// @dev Thrown when msg.sender is not the EigenPodManager + error OnlyEigenPodManager(); /// Delegation Status @@ -31,10 +34,25 @@ interface IDelegationManager is ISignatureUtils { /// Invalid Inputs + /// @dev Thrown when an account is actively delegated. + error ActivelyDelegated(); + /// @dev Thrown when attempting to execute an action that was not queued. + error WithdrawalNotQueued(); + /// @dev Thrown when provided delay exceeds maximum. + error AllocationDelaySet(); + /// @dev Thrown when caller cannot undelegate on behalf of a staker. + error CallerCannotUndelegate(); /// @dev Thrown when two array parameters have mismatching lengths. error InputArrayLengthMismatch(); /// @dev Thrown when input arrays length is zero. error InputArrayLengthZero(); + /// @dev Thrown when `operator` is not a registered operator. + error OperatorNotRegistered(); + /// @dev Thrown when caller is neither the StrategyManager or EigenPodManager contract. + error OnlyStrategyManagerOrEigenPodManager(); + + /// @dev Thrown when an account is not actively delegated. + error NotActivelyDelegated(); /// @dev Thrown when provided `stakerOptOutWindowBlocks` cannot decrease. error StakerOptOutWindowBlocksCannotDecrease(); /// @dev Thrown when provided `stakerOptOutWindowBlocks` exceeds maximum. @@ -45,7 +63,7 @@ interface IDelegationManager is ISignatureUtils { /// Signatures /// @dev Thrown when attempting to spend a spent eip-712 salt. - error SignatureSaltSpent(); + error SaltSpent(); /// @dev Thrown when attempting to use an expired eip-712 signature. error SignatureExpired(); @@ -55,6 +73,12 @@ interface IDelegationManager is ISignatureUtils { error WithdrawalDoesNotExist(); /// @dev Thrown when attempting to withdraw before delay has elapsed. error WithdrawalDelayNotElapsed(); + /// @dev Thrown when provided delay exceeds maximum. + error WithdrawalDelayExeedsMax(); + /// @dev Thrown when a withdraw amount larger than max is attempted. + error WithdrawalExeedsMax(); + /// @dev Thrown when withdrawer is not the current caller. + error WithdrawerNotCaller(); /// @dev Thrown when `withdrawer` is not staker. error WithdrawerNotStaker(); @@ -125,19 +149,24 @@ interface IDelegationManager is ISignatureUtils { address withdrawer; // Nonce used to guarantee that otherwise identical withdrawals have unique hashes uint256 nonce; - // Block number when the Withdrawal was created - uint32 startBlock; + // Timestamp when the Withdrawal was created. + // NOTE this used to be `startBlock` but changedto timestamps in the Slashing release. This has no effect + // on the hash of this struct but we do need to know when to handle blocknumbers vs timestamps depending on + // if the withdrawal was created before or after the Slashing release. + uint32 startTimestamp; // Array of strategies that the Withdrawal contains IStrategy[] strategies; - // Array containing the amount of shares in each Strategy in the `strategies` array - uint256[] shares; + // Array containing the amount of staker's delegatedShares for withdrawal in each Strategy in the `strategies` array + // Note that these shares need to be multiplied by the operator's totalMagnitude at completion to include + // slashing occurring during the queue withdrawal delay + DelegatedShares[] delegatedShares; } struct QueuedWithdrawalParams { // Array of strategies that the QueuedWithdrawal contains IStrategy[] strategies; - // Array containing the amount of shares in each Strategy in the `strategies` array - uint256[] shares; + // Array containing the amount of withdrawable shares for withdrawal in each Strategy in the `strategies` array + OwnedShares[] ownedShares; // The address of the withdrawer address withdrawer; } @@ -155,10 +184,14 @@ interface IDelegationManager is ISignatureUtils { event OperatorMetadataURIUpdated(address indexed operator, string metadataURI); /// @notice Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares. - event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares); + event OperatorSharesIncreased( + address indexed operator, address staker, IStrategy strategy, DelegatedShares delegatedShares + ); /// @notice Emitted whenever an operator's shares are decreased for a given strategy. Note that shares is the delta in the operator's shares. - event OperatorSharesDecreased(address indexed operator, address staker, IStrategy strategy, uint256 shares); + event OperatorSharesDecreased( + address indexed operator, address staker, IStrategy strategy, DelegatedShares delegatedShares + ); /// @notice Emitted when @param staker delegates to @param operator. event StakerDelegated(address indexed staker, address indexed operator); @@ -179,15 +212,10 @@ interface IDelegationManager is ISignatureUtils { /// @notice Emitted when a queued withdrawal is completed event WithdrawalCompleted(bytes32 withdrawalRoot); - /// @notice Emitted when the `minWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`. - event MinWithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue); - - /// @notice Emitted when the `strategyWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`. - event StrategyWithdrawalDelayBlocksSet(IStrategy strategy, uint256 previousValue, uint256 newValue); - /** * @notice Registers the caller as an operator in EigenLayer. * @param registeringOperatorDetails is the `OperatorDetails` for the operator. + * @param allocationDelay The delay before allocations take effect. * @param metadataURI is a URI for the operator's metadata, i.e. a link providing more details on the operator. * * @dev Once an operator is registered, they cannot 'deregister' as an operator, and they will forever be considered "delegated to themself". @@ -195,6 +223,7 @@ interface IDelegationManager is ISignatureUtils { */ function registerAsOperator( OperatorDetails calldata registeringOperatorDetails, + uint32 allocationDelay, string calldata metadataURI ) external; @@ -290,12 +319,9 @@ interface IDelegationManager is ISignatureUtils { * @notice Used to complete the specified `withdrawal`. The caller must match `withdrawal.withdrawer` * @param withdrawal The Withdrawal to complete. * @param tokens Array in which the i-th entry specifies the `token` input to the 'withdraw' function of the i-th Strategy in the `withdrawal.strategies` array. - * This input can be provided with zero length if `receiveAsTokens` is set to 'false' (since in that case, this input will be unused) - * @param middlewareTimesIndex is the index in the operator that the staker who triggered the withdrawal was delegated to's middleware times array * @param receiveAsTokens If true, the shares specified in the withdrawal will be withdrawn from the specified strategies themselves * and sent to the caller, through calls to `withdrawal.strategies[i].withdraw`. If false, then the shares in the specified strategies * will simply be transferred to the caller directly. - * @dev middlewareTimesIndex should be calculated off chain before calling this function by finding the first index that satisfies `slasher.canWithdraw` * @dev beaconChainETHStrategy shares are non-transferrable, so if `receiveAsTokens = false` and `withdrawal.withdrawer != withdrawal.staker`, note that * any beaconChainETHStrategy shares in the `withdrawal` will be _returned to the staker_, rather than transferred to the withdrawer, unlike shares in * any other strategies, which will be transferred to the withdrawer. @@ -303,7 +329,6 @@ interface IDelegationManager is ISignatureUtils { function completeQueuedWithdrawal( Withdrawal calldata withdrawal, IERC20[] calldata tokens, - uint256 middlewareTimesIndex, bool receiveAsTokens ) external; @@ -312,38 +337,52 @@ interface IDelegationManager is ISignatureUtils { * Used to complete the specified `withdrawals`. The function caller must match `withdrawals[...].withdrawer` * @param withdrawals The Withdrawals to complete. * @param tokens Array of tokens for each Withdrawal. See `completeQueuedWithdrawal` for the usage of a single array. - * @param middlewareTimesIndexes One index to reference per Withdrawal. See `completeQueuedWithdrawal` for the usage of a single index. * @param receiveAsTokens Whether or not to complete each withdrawal as tokens. See `completeQueuedWithdrawal` for the usage of a single boolean. * @dev See `completeQueuedWithdrawal` for relevant dev tags */ function completeQueuedWithdrawals( Withdrawal[] calldata withdrawals, IERC20[][] calldata tokens, - uint256[] calldata middlewareTimesIndexes, bool[] calldata receiveAsTokens ) external; /** - * @notice Increases a staker's delegated share balance in a strategy. + * @notice Increases a staker's delegated share balance in a strategy. Note that before adding to operator shares, + * the delegated shares are scaled according to the operator's total magnitude as part of slashing accounting. + * The staker's depositScalingFactor is updated here. * @param staker The address to increase the delegated shares for their operator. * @param strategy The strategy in which to increase the delegated shares. - * @param shares The number of shares to increase. + * @param existingShares The number of deposit shares the staker already has in the strategy. This is the shares amount stored in the + * StrategyManager/EigenPodManager for the staker's shares. + * @param addedOwnedShares The number of shares to added to the staker's shares in the strategy. This amount will be scaled prior to adding + * to the operator's scaled shares. * - * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing. + * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated scaled shares in `strategy`. + * Otherwise does nothing. * @dev Callable only by the StrategyManager or EigenPodManager. */ - function increaseDelegatedShares(address staker, IStrategy strategy, uint256 shares) external; + function increaseDelegatedShares( + address staker, + IStrategy strategy, + Shares existingShares, + OwnedShares addedOwnedShares + ) external; /** - * @notice Decreases a staker's delegated share balance in a strategy. - * @param staker The address to increase the delegated shares for their operator. - * @param strategy The strategy in which to decrease the delegated shares. - * @param shares The number of shares to decrease. + * @notice Decreases a native restaker's delegated share balance in a strategy due to beacon chain slashing. This updates their beaconChainScalingFactor. + * Their operator's stakeShares are also updated (if they are delegated). + * @param staker The address to increase the delegated stakeShares for their operator. + * @param existingShares The number of shares the staker already has in the EPM. This does not change upon decreasing shares. + * @param proportionOfOldBalance The current pod owner shares proportion of the previous pod owner shares * - * @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing. - * @dev Callable only by the StrategyManager or EigenPodManager. + * @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated stakeShares in `strategy` by `proportionPodBalanceDecrease` proportion. Otherwise does nothing. + * @dev Callable only by the EigenPodManager. */ - function decreaseDelegatedShares(address staker, IStrategy strategy, uint256 shares) external; + function decreaseBeaconChainScalingFactor( + address staker, + Shares existingShares, + uint64 proportionOfOldBalance + ) external; /** * @notice returns the address of the operator that `staker` is delegated to. @@ -376,30 +415,15 @@ interface IDelegationManager is ISignatureUtils { ) external view returns (uint256); /** - * @notice Given array of strategies, returns array of shares for the operator - */ - function getOperatorShares( - address operator, - IStrategy[] memory strategies - ) external view returns (uint256[] memory); - - /** - * @notice Given a list of strategies, return the minimum number of blocks that must pass to withdraw - * from all the inputted strategies. Return value is >= minWithdrawalDelayBlocks as this is the global min withdrawal delay. - * @param strategies The strategies to check withdrawal delays for - */ - function getWithdrawalDelay( - IStrategy[] calldata strategies - ) external view returns (uint256); - - /** - * @notice returns the total number of shares in `strategy` that are delegated to `operator`. - * @notice Mapping: operator => strategy => total number of shares in the strategy delegated to the operator. + * @notice returns the total number of delegatedShares (i.e. shares divided by the `operator`'s + * totalMagnitude) in `strategy` that are delegated to `operator`. + * @notice Mapping: operator => strategy => total number of delegatedShares in the strategy delegated to the operator. * @dev By design, the following invariant should hold for each Strategy: - * (operator's shares in delegation manager) = sum (shares above zero of all stakers delegated to operator) - * = sum (delegateable shares of all stakers delegated to the operator) + * (operator's delegatedShares in delegation manager) = sum (delegatedShares above zero of all stakers delegated to operator) + * = sum (delegateable delegatedShares of all stakers delegated to the operator) + * @dev FKA `operatorShares` */ - function operatorShares(address operator, IStrategy strategy) external view returns (uint256); + function operatorDelegatedShares(address operator, IStrategy strategy) external view returns (DelegatedShares); /** * @notice Returns 'true' if `staker` *is* actively delegated, and 'false' otherwise. @@ -427,22 +451,6 @@ interface IDelegationManager is ISignatureUtils { */ function delegationApproverSaltIsSpent(address _delegationApprover, bytes32 salt) external view returns (bool); - /** - * @notice Minimum delay enforced by this contract for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner, - * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced). - * Note that strategies each have a separate withdrawal delay, which can be greater than this value. So the minimum number of blocks that must pass - * to withdraw a strategy is MAX(minWithdrawalDelayBlocks, strategyWithdrawalDelayBlocks[strategy]) - */ - function minWithdrawalDelayBlocks() external view returns (uint256); - - /** - * @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner, - * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced). - */ - function strategyWithdrawalDelayBlocks( - IStrategy strategy - ) external view returns (uint256); - /// @notice return address of the beaconChainETHStrategy function beaconChainETHStrategy() external view returns (IStrategy); diff --git a/src/contracts/interfaces/IEigenPod.sol b/src/contracts/interfaces/IEigenPod.sol index 8701d26b7..638cda018 100644 --- a/src/contracts/interfaces/IEigenPod.sol +++ b/src/contracts/interfaces/IEigenPod.sol @@ -13,8 +13,12 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; * to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts */ interface IEigenPod { - /// @dev Thrown when msg.sender is not allowed to call a function - error UnauthorizedCaller(); + /// @dev Thrown when msg.sender is not the EPM. + error OnlyEigenPodManager(); + /// @dev Thrown when msg.sender is not the pod owner. + error OnlyEigenPodOwner(); + /// @dev Thrown when msg.sender is not owner or the proof submitter. + error OnlyEigenPodOwnerOrProofSubmitter(); /// @dev Thrown when attempting an action that is currently paused. error CurrentlyPaused(); @@ -98,7 +102,14 @@ interface IEigenPod { bytes32 beaconBlockRoot; uint24 proofsRemaining; uint64 podBalanceGwei; - int128 balanceDeltasGwei; + // this used to be an int128 before the slashing release + // now it is an int64. (2^63 - 1) gwei * 1e-9 eth/gwei = 9_223_372_036.85 eth = 9 billion eth + int64 balanceDeltasGwei; + uint64 beaconChainBalanceBeforeGwei; + } + + struct ExtendedCheckpoint { + uint128 beaconChainBalanceBefore; } /** diff --git a/src/contracts/interfaces/IEigenPodManager.sol b/src/contracts/interfaces/IEigenPodManager.sol index 286089ba9..854a9179e 100644 --- a/src/contracts/interfaces/IEigenPodManager.sol +++ b/src/contracts/interfaces/IEigenPodManager.sol @@ -5,8 +5,8 @@ import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol"; import "./IETHPOSDeposit.sol"; import "./IStrategyManager.sol"; import "./IEigenPod.sol"; +import "./IShareManager.sol"; import "./IPausable.sol"; -import "./ISlasher.sol"; import "./IStrategy.sol"; /** @@ -14,16 +14,22 @@ import "./IStrategy.sol"; * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service */ -interface IEigenPodManager is IPausable { - /// @dev Thrown when msg.sender is not allowed to call a function - error UnauthorizedCaller(); - +interface IEigenPodManager is IShareManager, IPausable { + /// @dev Thrown when caller is not a EigenPod. + error OnlyEigenPod(); + /// @dev Thrown when caller is not DelegationManager. + error OnlyDelegationManager(); /// @dev Thrown when caller already has an EigenPod. error EigenPodAlreadyExists(); /// @dev Thrown when shares is not a multiple of gwei. error SharesNotMultipleOfGwei(); /// @dev Thrown when shares would result in a negative integer. error SharesNegative(); + /// @dev Thrown when the strategy is not the beaconChainETH strategy. + error InvalidStrategy(); + /// @dev Thrown when the pods shares are negative and a beacon chain balance update is attempted. + /// The podOwner should complete legacy withdrawal first. + error LegacyWithdrawalsNotCompleted(); /// @notice Emitted to notify the deployment of an EigenPod event PodDeployed(address indexed eigenPod, address indexed podOwner); @@ -68,10 +74,15 @@ interface IEigenPodManager is IPausable { * to ensure that delegated shares are also tracked correctly * @param podOwner is the pod owner whose balance is being updated. * @param sharesDelta is the change in podOwner's beaconChainETHStrategy shares + * @param proportionPodBalanceDecrease is the proportion (of WAD) of the podOwner's balance that has changed * @dev Callable only by the podOwner's EigenPod contract. * @dev Reverts if `sharesDelta` is not a whole Gwei amount */ - function recordBeaconChainETHBalanceUpdate(address podOwner, int256 sharesDelta) external; + function recordBeaconChainETHBalanceUpdate( + address podOwner, + int256 sharesDelta, + uint64 proportionPodBalanceDecrease + ) external; /// @notice Returns the address of the `podOwner`'s EigenPod if it has been deployed. function ownerToPod( @@ -92,9 +103,6 @@ interface IEigenPodManager is IPausable { /// @notice EigenLayer's StrategyManager contract function strategyManager() external view returns (IStrategyManager); - /// @notice EigenLayer's Slasher contract - function slasher() external view returns (ISlasher); - /// @notice Returns 'true' if the `podOwner` has created an EigenPod, and 'false' otherwise. function hasPod( address podOwner @@ -117,30 +125,4 @@ interface IEigenPodManager is IPausable { /// @notice returns canonical, virtual beaconChainETH strategy function beaconChainETHStrategy() external view returns (IStrategy); - - /** - * @notice Used by the DelegationManager to remove a pod owner's shares while they're in the withdrawal queue. - * Simply decreases the `podOwner`'s shares by `shares`, down to a minimum of zero. - * @dev This function reverts if it would result in `podOwnerShares[podOwner]` being less than zero, i.e. it is forbidden for this function to - * result in the `podOwner` incurring a "share deficit". This behavior prevents a Staker from queuing a withdrawal which improperly removes excessive - * shares from the operator to whom the staker is delegated. - * @dev Reverts if `shares` is not a whole Gwei amount - */ - function removeShares(address podOwner, uint256 shares) external; - - /** - * @notice Increases the `podOwner`'s shares by `shares`, paying off deficit if possible. - * Used by the DelegationManager to award a pod owner shares on exiting the withdrawal queue - * @dev Returns the number of shares added to `podOwnerShares[podOwner]` above zero, which will be less than the `shares` input - * in the event that the podOwner has an existing shares deficit (i.e. `podOwnerShares[podOwner]` starts below zero) - * @dev Reverts if `shares` is not a whole Gwei amount - */ - function addShares(address podOwner, uint256 shares) external returns (uint256); - - /** - * @notice Used by the DelegationManager to complete a withdrawal, sending tokens to some destination address - * @dev Prioritizes decreasing the podOwner's share deficit, if they have one - * @dev Reverts if `shares` is not a whole Gwei amount - */ - function withdrawSharesAsTokens(address podOwner, address destination, uint256 shares) external; } diff --git a/src/contracts/interfaces/IRewardsCoordinator.sol b/src/contracts/interfaces/IRewardsCoordinator.sol index 9adec6f8c..4bc2c2ef3 100644 --- a/src/contracts/interfaces/IRewardsCoordinator.sol +++ b/src/contracts/interfaces/IRewardsCoordinator.sol @@ -42,6 +42,10 @@ interface IRewardsCoordinator { error DurationExceedsMax(); /// @dev Thrown when input `duration` is not evenly divisble by CALCULATION_INTERVAL_SECONDS. error InvalidDurationRemainder(); + /// @dev Thrown when GENESIS_REWARDS_TIMESTAMP is not evenly divisble by CALCULATION_INTERVAL_SECONDS. + error InvalidGenesisRewardsTimestampRemainder(); + /// @dev Thrown when CALCULATION_INTERVAL_SECONDS is not evenly divisble by SNAPSHOT_CADENCE. + error InvalidCalculationIntervalSecondsRemainder(); /// @dev Thrown when `startTimestamp` is not evenly divisble by CALCULATION_INTERVAL_SECONDS. error InvalidStartTimestampRemainder(); /// @dev Thrown when `startTimestamp` is too far in the future. diff --git a/src/contracts/interfaces/IShareManager.sol b/src/contracts/interfaces/IShareManager.sol new file mode 100644 index 000000000..b9f3eb666 --- /dev/null +++ b/src/contracts/interfaces/IShareManager.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.27; + +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "../libraries/SlashingLib.sol"; +import "./IStrategy.sol"; + +/** + * @title Interface for a `IShareManager` contract. + * @author Layr Labs, Inc. + * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service + * @notice This contract is used by the DelegationManager as a unified interface to interact with the EigenPodManager and StrategyManager + */ +interface IShareManager { + /// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue + /// @dev strategy must be beaconChainETH when talking to the EigenPodManager + function removeShares(address staker, IStrategy strategy, Shares shares) external; + + /// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue + /// @dev strategy must be beaconChainETH when talking to the EigenPodManager + /// @dev token is not validated when talking to the EigenPodManager + function addOwnedShares(address staker, IStrategy strategy, IERC20 token, OwnedShares ownedShares) external; + + /// @notice Used by the DelegationManager to convert withdrawn descaled shares to tokens and send them to a staker + /// @dev strategy must be beaconChainETH when talking to the EigenPodManager + /// @dev token is not validated when talking to the EigenPodManager + function withdrawSharesAsTokens( + address staker, + IStrategy strategy, + IERC20 token, + OwnedShares ownedShares + ) external; + + /// @notice Returns the current shares of `user` in `strategy` + /// @dev strategy must be beaconChainETH when talking to the EigenPodManager + /// @dev returns 0 if the user has negative shares + function stakerStrategyShares(address user, IStrategy strategy) external view returns (Shares shares); +} diff --git a/src/contracts/interfaces/ISlasher.sol b/src/contracts/interfaces/ISlasher.sol deleted file mode 100644 index 1cd77b996..000000000 --- a/src/contracts/interfaces/ISlasher.sol +++ /dev/null @@ -1,202 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity >=0.5.0; - -import "./IStrategyManager.sol"; -import "./IDelegationManager.sol"; - -/** - * @title Interface for the primary 'slashing' contract for EigenLayer. - * @author Layr Labs, Inc. - * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service - * @notice See the `Slasher` contract itself for implementation details. - */ -interface ISlasher { - // struct used to store information about the current state of an operator's obligations to middlewares they are serving - struct MiddlewareTimes { - // The update block for the middleware whose most recent update was earliest, i.e. the 'stalest' update out of all middlewares the operator is serving - uint32 stalestUpdateBlock; - // The latest 'serveUntilBlock' from all of the middleware that the operator is serving - uint32 latestServeUntilBlock; - } - - // struct used to store details relevant to a single middleware that an operator has opted-in to serving - struct MiddlewareDetails { - // the block at which the contract begins being able to finalize the operator's registration with the service via calling `recordFirstStakeUpdate` - uint32 registrationMayBeginAtBlock; - // the block before which the contract is allowed to slash the user - uint32 contractCanSlashOperatorUntilBlock; - // the block at which the middleware's view of the operator's stake was most recently updated - uint32 latestUpdateBlock; - } - - /// @notice Emitted when a middleware times is added to `operator`'s array. - event MiddlewareTimesAdded( - address operator, uint256 index, uint32 stalestUpdateBlock, uint32 latestServeUntilBlock - ); - - /// @notice Emitted when `operator` begins to allow `contractAddress` to slash them. - event OptedIntoSlashing(address indexed operator, address indexed contractAddress); - - /// @notice Emitted when `contractAddress` signals that it will no longer be able to slash `operator` after the `contractCanSlashOperatorUntilBlock`. - event SlashingAbilityRevoked( - address indexed operator, address indexed contractAddress, uint32 contractCanSlashOperatorUntilBlock - ); - - /** - * @notice Emitted when `slashingContract` 'freezes' the `slashedOperator`. - * @dev The `slashingContract` must have permission to slash the `slashedOperator`, i.e. `canSlash(slasherOperator, slashingContract)` must return 'true'. - */ - event OperatorFrozen(address indexed slashedOperator, address indexed slashingContract); - - /// @notice Emitted when `previouslySlashedAddress` is 'unfrozen', allowing them to again move deposited funds within EigenLayer. - event FrozenStatusReset(address indexed previouslySlashedAddress); - - /** - * @notice Gives the `contractAddress` permission to slash the funds of the caller. - * @dev Typically, this function must be called prior to registering for a middleware. - */ - function optIntoSlashing( - address contractAddress - ) external; - - /** - * @notice Used for 'slashing' a certain operator. - * @param toBeFrozen The operator to be frozen. - * @dev Technically the operator is 'frozen' (hence the name of this function), and then subject to slashing pending a decision by a human-in-the-loop. - * @dev The operator must have previously given the caller (which should be a contract) the ability to slash them, through a call to `optIntoSlashing`. - */ - function freezeOperator( - address toBeFrozen - ) external; - - /** - * @notice Removes the 'frozen' status from each of the `frozenAddresses` - * @dev Callable only by the contract owner (i.e. governance). - */ - function resetFrozenStatus( - address[] calldata frozenAddresses - ) external; - - /** - * @notice this function is a called by middlewares during an operator's registration to make sure the operator's stake at registration - * is slashable until serveUntil - * @param operator the operator whose stake update is being recorded - * @param serveUntilBlock the block until which the operator's stake at the current block is slashable - * @dev adds the middleware's slashing contract to the operator's linked list - */ - function recordFirstStakeUpdate(address operator, uint32 serveUntilBlock) external; - - /** - * @notice this function is a called by middlewares during a stake update for an operator (perhaps to free pending withdrawals) - * to make sure the operator's stake at updateBlock is slashable until serveUntil - * @param operator the operator whose stake update is being recorded - * @param updateBlock the block for which the stake update is being recorded - * @param serveUntilBlock the block until which the operator's stake at updateBlock is slashable - * @param insertAfter the element of the operators linked list that the currently updating middleware should be inserted after - * @dev insertAfter should be calculated offchain before making the transaction that calls this. this is subject to race conditions, - * but it is anticipated to be rare and not detrimental. - */ - function recordStakeUpdate( - address operator, - uint32 updateBlock, - uint32 serveUntilBlock, - uint256 insertAfter - ) external; - - /** - * @notice this function is a called by middlewares during an operator's deregistration to make sure the operator's stake at deregistration - * is slashable until serveUntil - * @param operator the operator whose stake update is being recorded - * @param serveUntilBlock the block until which the operator's stake at the current block is slashable - * @dev removes the middleware's slashing contract to the operator's linked list and revokes the middleware's (i.e. caller's) ability to - * slash `operator` once `serveUntil` is reached - */ - function recordLastStakeUpdateAndRevokeSlashingAbility(address operator, uint32 serveUntilBlock) external; - - /// @notice The StrategyManager contract of EigenLayer - function strategyManager() external view returns (IStrategyManager); - - /// @notice The DelegationManager contract of EigenLayer - function delegation() external view returns (IDelegationManager); - - /** - * @notice Used to determine whether `staker` is actively 'frozen'. If a staker is frozen, then they are potentially subject to - * slashing of their funds, and cannot cannot deposit or withdraw from the strategyManager until the slashing process is completed - * and the staker's status is reset (to 'unfrozen'). - * @param staker The staker of interest. - * @return Returns 'true' if `staker` themselves has their status set to frozen, OR if the staker is delegated - * to an operator who has their status set to frozen. Otherwise returns 'false'. - */ - function isFrozen( - address staker - ) external view returns (bool); - - /// @notice Returns true if `slashingContract` is currently allowed to slash `toBeSlashed`. - function canSlash(address toBeSlashed, address slashingContract) external view returns (bool); - - /// @notice Returns the block until which `serviceContract` is allowed to slash the `operator`. - function contractCanSlashOperatorUntilBlock( - address operator, - address serviceContract - ) external view returns (uint32); - - /// @notice Returns the block at which the `serviceContract` last updated its view of the `operator`'s stake - function latestUpdateBlock(address operator, address serviceContract) external view returns (uint32); - - /// @notice A search routine for finding the correct input value of `insertAfter` to `recordStakeUpdate` / `_updateMiddlewareList`. - function getCorrectValueForInsertAfter(address operator, uint32 updateBlock) external view returns (uint256); - - /** - * @notice Returns 'true' if `operator` can currently complete a withdrawal started at the `withdrawalStartBlock`, with `middlewareTimesIndex` used - * to specify the index of a `MiddlewareTimes` struct in the operator's list (i.e. an index in `operatorToMiddlewareTimes[operator]`). The specified - * struct is consulted as proof of the `operator`'s ability (or lack thereof) to complete the withdrawal. - * This function will return 'false' if the operator cannot currently complete a withdrawal started at the `withdrawalStartBlock`, *or* in the event - * that an incorrect `middlewareTimesIndex` is supplied, even if one or more correct inputs exist. - * @param operator Either the operator who queued the withdrawal themselves, or if the withdrawing party is a staker who delegated to an operator, - * this address is the operator *who the staker was delegated to* at the time of the `withdrawalStartBlock`. - * @param withdrawalStartBlock The block number at which the withdrawal was initiated. - * @param middlewareTimesIndex Indicates an index in `operatorToMiddlewareTimes[operator]` to consult as proof of the `operator`'s ability to withdraw - * @dev The correct `middlewareTimesIndex` input should be computable off-chain. - */ - function canWithdraw( - address operator, - uint32 withdrawalStartBlock, - uint256 middlewareTimesIndex - ) external returns (bool); - - /** - * operator => - * [ - * ( - * the least recent update block of all of the middlewares it's serving/served, - * latest time that the stake bonded at that update needed to serve until - * ) - * ] - */ - function operatorToMiddlewareTimes( - address operator, - uint256 arrayIndex - ) external view returns (MiddlewareTimes memory); - - /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator].length` - function middlewareTimesLength( - address operator - ) external view returns (uint256); - - /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].stalestUpdateBlock`. - function getMiddlewareTimesIndexStalestUpdateBlock(address operator, uint32 index) external view returns (uint32); - - /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].latestServeUntil`. - function getMiddlewareTimesIndexServeUntilBlock(address operator, uint32 index) external view returns (uint32); - - /// @notice Getter function for fetching `_operatorToWhitelistedContractsByUpdate[operator].size`. - function operatorWhitelistedContractsLinkedListSize( - address operator - ) external view returns (uint256); - - /// @notice Getter function for fetching a single node in the operator's linked list (`_operatorToWhitelistedContractsByUpdate[operator]`). - function operatorWhitelistedContractsLinkedListEntry( - address operator, - address node - ) external view returns (bool, uint256, uint256); -} diff --git a/src/contracts/interfaces/IStrategy.sol b/src/contracts/interfaces/IStrategy.sol index 7ef40d982..ff918efb6 100644 --- a/src/contracts/interfaces/IStrategy.sol +++ b/src/contracts/interfaces/IStrategy.sol @@ -2,6 +2,7 @@ pragma solidity >=0.5.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "../libraries/SlashingLib.sol"; /** * @title Minimal interface for an `Strategy` contract. @@ -10,11 +11,8 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; * @notice Custom `Strategy` implementations may expand extensively on this interface. */ interface IStrategy { - /// @dev Thrown when msg.sender is not allowed to call a function - error UnauthorizedCaller(); - - /// StrategyBase - + /// @dev Thrown when called by an account that is not strategy manager. + error OnlyStrategyManager(); /// @dev Thrown when new shares value is zero. error NewSharesZero(); /// @dev Thrown when total shares exceeds max. diff --git a/src/contracts/interfaces/IStrategyFactory.sol b/src/contracts/interfaces/IStrategyFactory.sol index c0e274c4f..137659cc3 100644 --- a/src/contracts/interfaces/IStrategyFactory.sol +++ b/src/contracts/interfaces/IStrategyFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BUSL-1.1 -pragma solidity >=0.5.0; +pragma solidity ^0.8.27; import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -50,15 +50,9 @@ interface IStrategyFactory { * @notice Owner-only function to pass through a call to `StrategyManager.addStrategiesToDepositWhitelist` */ function whitelistStrategies( - IStrategy[] calldata strategiesToWhitelist, - bool[] calldata thirdPartyTransfersForbiddenValues + IStrategy[] calldata strategiesToWhitelist ) external; - /** - * @notice Owner-only function to pass through a call to `StrategyManager.setThirdPartyTransfersForbidden` - */ - function setThirdPartyTransfersForbidden(IStrategy strategy, bool value) external; - /** * @notice Owner-only function to pass through a call to `StrategyManager.removeStrategiesFromDepositWhitelist` */ diff --git a/src/contracts/interfaces/IStrategyManager.sol b/src/contracts/interfaces/IStrategyManager.sol index eb9cef610..61515f033 100644 --- a/src/contracts/interfaces/IStrategyManager.sol +++ b/src/contracts/interfaces/IStrategyManager.sol @@ -2,7 +2,7 @@ pragma solidity >=0.5.0; import "./IStrategy.sol"; -import "./ISlasher.sol"; +import "./IShareManager.sol"; import "./IDelegationManager.sol"; import "./IEigenPodManager.sol"; @@ -12,36 +12,27 @@ import "./IEigenPodManager.sol"; * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service * @notice See the `StrategyManager` contract itself for implementation details. */ -interface IStrategyManager { - /// @dev Thrown when msg.sender is not allowed to call a function - error UnauthorizedCaller(); - /// @dev Thrown when attempting to use an expired eip-712 signature. - error SignatureExpired(); - - /// Invalid Inputs - +interface IStrategyManager is IShareManager { + /// @dev Thrown when total strategies deployed exceeds max. + error MaxStrategiesExceeded(); /// @dev Thrown when two array parameters have mismatching lengths. error InputArrayLengthMismatch(); - - /// Adding and Removing Shares - - /// @dev Thrown when provided `staker` address is null. - error StakerAddressZero(); + /// @dev Thrown when call attempted from address that's not delegation manager. + error OnlyDelegationManager(); + /// @dev Thrown when call attempted from address that's not strategy whitelister. + error OnlyStrategyWhitelister(); + /// @dev Thrown when provided `shares` amount is too high. + error SharesAmountTooHigh(); /// @dev Thrown when provided `shares` amount is zero. error SharesAmountZero(); - /// @dev Thrown when staker does not have enough shares - error InsufficientShares(); - - /// Strategy-Specific - + /// @dev Thrown when attempting to use an expired eip-712 signature. + error SignatureExpired(); + /// @dev Thrown when provided `staker` address is null. + error StakerAddressZero(); /// @dev Thrown when provided `strategy` not found. error StrategyNotFound(); - /// @dev Thrown when total strategies deployed exceeds max. - error MaxStrategiesExceeded(); /// @dev Thrown when attempting to deposit to a non-whitelisted strategy. error StrategyNotWhitelisted(); - /// @dev Thrown when attempting a third party transfer from a strategy that's disabled it. - error ThirdPartyTransfersDisabled(); /** * @notice Emitted when a new deposit occurs on behalf of `staker`. @@ -50,10 +41,7 @@ interface IStrategyManager { * @param token Is the token that `staker` deposited. * @param shares Is the number of new shares `staker` has been granted in `strategy`. */ - event Deposit(address staker, IERC20 token, IStrategy strategy, uint256 shares); - - /// @notice Emitted when `thirdPartyTransfersForbidden` is updated for a strategy and value by the owner - event UpdatedThirdPartyTransfersForbidden(IStrategy strategy, bool value); + event Deposit(address staker, IERC20 token, IStrategy strategy, OwnedShares shares); /// @notice Emitted when the `strategyWhitelister` is changed event StrategyWhitelisterChanged(address previousAddress, address newAddress); @@ -76,7 +64,11 @@ interface IStrategyManager { * WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended. This can lead to attack vectors * where the token balance and corresponding strategy shares are not in sync upon reentrancy. */ - function depositIntoStrategy(IStrategy strategy, IERC20 token, uint256 amount) external returns (uint256 shares); + function depositIntoStrategy( + IStrategy strategy, + IERC20 token, + uint256 amount + ) external returns (OwnedShares shares); /** * @notice Used for depositing an asset into the specified strategy with the resultant shares credited to `staker`, @@ -94,7 +86,6 @@ interface IStrategyManager { * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf. * @dev A signature is required for this function to eliminate the possibility of griefing attacks, specifically those * targeting stakers who may be attempting to undelegate. - * @dev Cannot be called if thirdPartyTransfersForbidden is set to true for this strategy * * WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended. This can lead to attack vectors * where the token balance and corresponding strategy shares are not in sync upon reentrancy @@ -106,19 +97,7 @@ interface IStrategyManager { address staker, uint256 expiry, bytes memory signature - ) external returns (uint256 shares); - - /// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue - function removeShares(address staker, IStrategy strategy, uint256 shares) external; - - /// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue - function addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) external; - - /// @notice Used by the DelegationManager to convert withdrawn shares to tokens and send them to a recipient - function withdrawSharesAsTokens(address recipient, IStrategy strategy, uint256 shares, IERC20 token) external; - - /// @notice Returns the current shares of `user` in `strategy` - function stakerStrategyShares(address user, IStrategy strategy) external view returns (uint256 shares); + ) external returns (OwnedShares shares); /** * @notice Get all details on the staker's deposits and corresponding shares @@ -126,7 +105,11 @@ interface IStrategyManager { */ function getDeposits( address staker - ) external view returns (IStrategy[] memory, uint256[] memory); + ) external view returns (IStrategy[] memory, Shares[] memory); + + function getStakerStrategyList( + address staker + ) external view returns (IStrategy[] memory); /// @notice Simple getter function that returns `stakerStrategyList[staker].length`. function stakerStrategyListLength( @@ -136,11 +119,9 @@ interface IStrategyManager { /** * @notice Owner-only function that adds the provided Strategies to the 'whitelist' of strategies that stakers can deposit into * @param strategiesToWhitelist Strategies that will be added to the `strategyIsWhitelistedForDeposit` mapping (if they aren't in it already) - * @param thirdPartyTransfersForbiddenValues bool values to set `thirdPartyTransfersForbidden` to for each strategy */ function addStrategiesToDepositWhitelist( - IStrategy[] calldata strategiesToWhitelist, - bool[] calldata thirdPartyTransfersForbiddenValues + IStrategy[] calldata strategiesToWhitelist ) external; /** @@ -151,21 +132,9 @@ interface IStrategyManager { IStrategy[] calldata strategiesToRemoveFromWhitelist ) external; - /** - * If true for a strategy, a user cannot depositIntoStrategyWithSignature into that strategy for another staker - * and also when performing DelegationManager.queueWithdrawals, a staker can only withdraw to themselves. - * Defaulted to false for all existing strategies. - * @param strategy The strategy to set `thirdPartyTransfersForbidden` value to - * @param value bool value to set `thirdPartyTransfersForbidden` to - */ - function setThirdPartyTransfersForbidden(IStrategy strategy, bool value) external; - /// @notice Returns the single, central Delegation contract of EigenLayer function delegation() external view returns (IDelegationManager); - /// @notice Returns the single, central Slasher contract of EigenLayer - function slasher() external view returns (ISlasher); - /// @notice Returns the EigenPodManager contract of EigenLayer function eigenPodManager() external view returns (IEigenPodManager); @@ -176,12 +145,4 @@ interface IStrategyManager { function strategyIsWhitelistedForDeposit( IStrategy strategy ) external view returns (bool); - - /** - * @notice Returns bool for whether or not `strategy` enables credit transfers. i.e enabling - * depositIntoStrategyWithSignature calls or queueing withdrawals to a different address than the staker. - */ - function thirdPartyTransfersForbidden( - IStrategy strategy - ) external view returns (bool); } diff --git a/src/contracts/libraries/SlashingLib.sol b/src/contracts/libraries/SlashingLib.sol new file mode 100644 index 000000000..e6814d6aa --- /dev/null +++ b/src/contracts/libraries/SlashingLib.sol @@ -0,0 +1,220 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.27; + +import "@openzeppelin/contracts/utils/math/Math.sol"; + +/// @dev the stakerScalingFactor and totalMagnitude have initial default values to 1e18 as "1" +/// to preserve precision with uint256 math. We use `WAD` where these variables are used +/// and divide to represent as 1 +uint64 constant WAD = 1e18; + +/* + * There are 3 types of shares: + * 1. ownedShares + * - These can be converted to an amount of tokens given a strategy + * - by calling `sharesToUnderlying` on the strategy address (they're already tokens + * in the case of EigenPods) + * - These are comparable between operators and stakers. + * - These live in the storage of StrategyManager strategies: + * - `totalShares` is the total amount of shares delegated to a strategy + * 2. delegatedShares + * - These can be converted to shares given an operator and a strategy + * - by multiplying by the operator's totalMagnitude for the strategy + * - These values automatically update their conversion into tokens + * - when the operator's total magnitude for the strategy is decreased upon slashing + * - These live in the storage of the DelegationManager: + * - `delegatedShares` is the total amount of delegatedShares delegated to an operator for a strategy + * - `withdrawal.delegatedShares` is the amount of delegatedShares in a withdrawal + * 3. shares + * - These can be converted into delegatedShares given a staker and a strategy + * - by multiplying by the staker's depositScalingFactor for the strategy + * - These values automatically update their conversion into tokens + * - when the staker's depositScalingFactor for the strategy is increased upon new deposits + * - or when the staker's operator's total magnitude for the strategy is decreased upon slashing + * - These represent the total amount of shares the staker would have of a strategy if they were never slashed + * - These live in the storage of the StrategyManager/EigenPodManager + * - `stakerStrategyShares` in the SM is the staker's shares that have not been queued for withdrawal in a strategy + * - `podOwnerShares` in the EPM is the staker's shares that have not been queued for withdrawal in the beaconChainETHStrategy + * + * Note that `withdrawal.delegatedShares` is scaled for the beaconChainETHStrategy to divide by the beaconChainScalingFactor upon queueing + * and multiply by the beaconChainScalingFactor upon withdrawal + */ + +type OwnedShares is uint256; + +type DelegatedShares is uint256; + +type Shares is uint256; + +struct StakerScalingFactors { + uint256 depositScalingFactor; + // we need to know if the beaconChainScalingFactor is set because it can be set to 0 through 100% slashing + bool isBeaconChainScalingFactorSet; + uint64 beaconChainScalingFactor; +} + +using SlashingLib for OwnedShares global; +using SlashingLib for DelegatedShares global; +using SlashingLib for Shares global; +using SlashingLib for StakerScalingFactors global; + +// TODO: validate order of operations everywhere +library SlashingLib { + using Math for uint256; + using SlashingLib for uint256; + + // MATH + + function add(Shares x, uint256 y) internal pure returns (uint256) { + return x.unwrap() + y; + } + + function add(DelegatedShares x, uint256 y) internal pure returns (uint256) { + return x.unwrap() + y; + } + + function add(DelegatedShares x, DelegatedShares y) internal pure returns (DelegatedShares) { + return (x.unwrap() + y.unwrap()).wrapDelegated(); + } + + function add(OwnedShares x, uint256 y) internal pure returns (uint256) { + return x.unwrap() + y; + } + + function add(OwnedShares x, OwnedShares y) internal pure returns (OwnedShares) { + return (x.unwrap() + y.unwrap()).wrapOwned(); + } + + function sub(Shares x, uint256 y) internal pure returns (uint256) { + return x.unwrap() - y; + } + + function sub(DelegatedShares x, uint256 y) internal pure returns (uint256) { + return x.unwrap() - y; + } + + function sub(DelegatedShares x, DelegatedShares y) internal pure returns (DelegatedShares) { + return (x.unwrap() - y.unwrap()).wrapDelegated(); + } + + function sub(OwnedShares x, uint256 y) internal pure returns (uint256) { + return x.unwrap() - y; + } + + /// @dev beaconChainScalingFactor = 0 -> WAD for all non beaconChainETH strategies + function toShares( + DelegatedShares delegatedShares, + StakerScalingFactors storage ssf + ) internal view returns (Shares) { + return delegatedShares.unwrap().divWad(ssf.getDepositScalingFactor()).divWad(ssf.getBeaconChainScalingFactor()) + .wrapShares(); + } + + function toDelegatedShares(OwnedShares shares, uint256 magnitude) internal pure returns (DelegatedShares) { + // forgefmt: disable-next-item + return shares + .unwrap() + .divWad(magnitude) + .wrapDelegated(); + } + + function toOwnedShares(DelegatedShares delegatedShares, uint256 magnitude) internal view returns (OwnedShares) { + return delegatedShares.unwrap().mulWad(magnitude).wrapOwned(); + } + + function scaleForQueueWithdrawal( + DelegatedShares delegatedShares, + StakerScalingFactors storage ssf + ) internal view returns (DelegatedShares) { + return delegatedShares.unwrap().divWad(ssf.getBeaconChainScalingFactor()).wrapDelegated(); + } + + function scaleForCompleteWithdrawal( + DelegatedShares delegatedShares, + StakerScalingFactors storage ssf + ) internal view returns (DelegatedShares) { + return delegatedShares.unwrap().mulWad(ssf.getBeaconChainScalingFactor()).wrapDelegated(); + } + + function decreaseBeaconChainScalingFactor( + StakerScalingFactors storage ssf, + uint64 proportionOfOldBalance + ) internal { + ssf.beaconChainScalingFactor = uint64(uint256(ssf.beaconChainScalingFactor).mulWad(proportionOfOldBalance)); + ssf.isBeaconChainScalingFactorSet = true; + } + + /// @dev beaconChainScalingFactor = 0 -> WAD for all non beaconChainETH strategies + function toDelegatedShares( + Shares shares, + StakerScalingFactors storage ssf + ) internal view returns (DelegatedShares) { + return shares.unwrap().mulWad(ssf.getDepositScalingFactor()).mulWad(ssf.getBeaconChainScalingFactor()) + .wrapDelegated(); + } + + function toDelegatedShares(Shares shares, uint256 magnitude) internal view returns (DelegatedShares) { + return shares.unwrap().mulWad(magnitude).wrapDelegated(); + } + + // WAD MATH + + function mulWad(uint256 x, uint256 y) internal pure returns (uint256) { + return x.mulDiv(y, WAD); + } + + function divWad(uint256 x, uint256 y) internal pure returns (uint256) { + return x.mulDiv(WAD, y); + } + + // TYPE CASTING + + function unwrap( + Shares x + ) internal pure returns (uint256) { + return Shares.unwrap(x); + } + + function unwrap( + DelegatedShares x + ) internal pure returns (uint256) { + return DelegatedShares.unwrap(x); + } + + function unwrap( + OwnedShares x + ) internal pure returns (uint256) { + return OwnedShares.unwrap(x); + } + + function wrapShares( + uint256 x + ) internal pure returns (Shares) { + return Shares.wrap(x); + } + + function wrapDelegated( + uint256 x + ) internal pure returns (DelegatedShares) { + return DelegatedShares.wrap(x); + } + + function wrapOwned( + uint256 x + ) internal pure returns (OwnedShares) { + return OwnedShares.wrap(x); + } + + function getDepositScalingFactor( + StakerScalingFactors storage ssf + ) internal view returns (uint256) { + return ssf.depositScalingFactor == 0 ? WAD : ssf.depositScalingFactor; + } + + function getBeaconChainScalingFactor( + StakerScalingFactors storage ssf + ) internal view returns (uint64) { + return + !ssf.isBeaconChainScalingFactorSet && ssf.beaconChainScalingFactor == 0 ? WAD : ssf.beaconChainScalingFactor; + } +} diff --git a/src/contracts/libraries/Snapshots.sol b/src/contracts/libraries/Snapshots.sol new file mode 100644 index 000000000..c71dcfd3d --- /dev/null +++ b/src/contracts/libraries/Snapshots.sol @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "@openzeppelin-upgrades/contracts/utils/math/MathUpgradeable.sol"; +import "@openzeppelin-upgrades/contracts/utils/math/SafeCastUpgradeable.sol"; + +/** + * @title Library for handling snapshots as part of allocating and slashing. + * @notice This library is using OpenZeppelin's CheckpointsUpgradeable library (v4.9.0) + * and removes structs and functions that are unessential. + * Interfaces and structs are renamed for clarity and usage (timestamps, etc). + * Some additional functions have also been added for convenience. + * @dev This library defines the `History` struct, for snapshotting values as they change at different points in + * time, and later looking up past values by block number. See {Votes} as an example. + * + * To create a history of snapshots define a variable type `Snapshots.History` in your contract, and store a new + * snapshot for the current transaction block using the {push} function. + * + * _Available since v4.5._ + */ +library Snapshots { + struct History { + Snapshot[] _snapshots; + } + + struct Snapshot { + uint32 _key; + uint224 _value; + } + + /** + * @dev Pushes a (`key`, `value`) pair into a History so that it is stored as the snapshot. + * + * Returns previous value and new value. + */ + function push(History storage self, uint32 key, uint224 value) internal returns (uint224, uint224) { + return _insert(self._snapshots, key, value); + } + + /** + * @dev Returns the value in the first (oldest) snapshot with key greater or equal than the search key, or zero if there is none. + */ + function lowerLookup(History storage self, uint32 key) internal view returns (uint224) { + uint256 len = self._snapshots.length; + uint256 pos = _lowerBinaryLookup(self._snapshots, key, 0, len); + return pos == len ? 0 : _unsafeAccess(self._snapshots, pos)._value; + } + + /** + * @dev Returns the value in the last (most recent) snapshot with key lower or equal than the search key, or zero if there is none. + */ + function upperLookup(History storage self, uint32 key) internal view returns (uint224) { + uint256 len = self._snapshots.length; + uint256 pos = _upperBinaryLookup(self._snapshots, key, 0, len); + return pos == 0 ? 0 : _unsafeAccess(self._snapshots, pos - 1)._value; + } + + /** + * @dev Returns the value in the last (most recent) snapshot with key lower or equal than the search key, or zero if there is none. + * + * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" snapshot (snapshots with high keys). + */ + function upperLookupRecent(History storage self, uint32 key) internal view returns (uint224) { + uint256 len = self._snapshots.length; + + uint256 low = 0; + uint256 high = len; + + if (len > 5) { + uint256 mid = len - MathUpgradeable.sqrt(len); + if (key < _unsafeAccess(self._snapshots, mid)._key) { + high = mid; + } else { + low = mid + 1; + } + } + + uint256 pos = _upperBinaryLookup(self._snapshots, key, low, high); + + return pos == 0 ? 0 : _unsafeAccess(self._snapshots, pos - 1)._value; + } + + /** + * @dev Returns the value in the most recent snapshot, or zero if there are no snapshots. + */ + function latest( + History storage self + ) internal view returns (uint224) { + uint256 pos = self._snapshots.length; + return pos == 0 ? 0 : _unsafeAccess(self._snapshots, pos - 1)._value; + } + + /** + * @dev Returns whether there is a snapshot in the structure (i.e. it is not empty), and if so the key and value + * in the most recent snapshot. + */ + function latestSnapshot( + History storage self + ) internal view returns (bool exists, uint32 _key, uint224 _value) { + uint256 pos = self._snapshots.length; + if (pos == 0) { + return (false, 0, 0); + } else { + Snapshot memory ckpt = _unsafeAccess(self._snapshots, pos - 1); + return (true, ckpt._key, ckpt._value); + } + } + + /** + * @dev Returns the number of snapshot. + */ + function length( + History storage self + ) internal view returns (uint256) { + return self._snapshots.length; + } + + /** + * @dev Pushes a (`key`, `value`) pair into an ordered list of snapshots, either by inserting a new snapshot, + * or by updating the last one. + */ + function _insert(Snapshot[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { + uint256 pos = self.length; + + if (pos > 0) { + // Copying to memory is important here. + Snapshot memory last = _unsafeAccess(self, pos - 1); + + // Snapshot keys must be non-decreasing. + require(last._key <= key, "Snapshot: decreasing keys"); + + // Update or push new snapshot + if (last._key == key) { + _unsafeAccess(self, pos - 1)._value = value; + } else { + self.push(Snapshot({_key: key, _value: value})); + } + return (last._value, value); + } else { + self.push(Snapshot({_key: key, _value: value})); + return (0, value); + } + } + + /** + * @dev Return the index of the last (most recent) snapshot with key lower or equal than the search key, or `high` if there is none. + * `low` and `high` define a section where to do the search, with inclusive `low` and exclusive `high`. + * + * WARNING: `high` should not be greater than the array's length. + */ + function _upperBinaryLookup( + Snapshot[] storage self, + uint32 key, + uint256 low, + uint256 high + ) private view returns (uint256) { + while (low < high) { + uint256 mid = MathUpgradeable.average(low, high); + if (_unsafeAccess(self, mid)._key > key) { + high = mid; + } else { + low = mid + 1; + } + } + return high; + } + + /** + * @dev Return the index of the first (oldest) snapshot with key is greater or equal than the search key, or `high` if there is none. + * `low` and `high` define a section where to do the search, with inclusive `low` and exclusive `high`. + * + * WARNING: `high` should not be greater than the array's length. + */ + function _lowerBinaryLookup( + Snapshot[] storage self, + uint32 key, + uint256 low, + uint256 high + ) private view returns (uint256) { + while (low < high) { + uint256 mid = MathUpgradeable.average(low, high); + if (_unsafeAccess(self, mid)._key < key) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + + /** + * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. + */ + function _unsafeAccess(Snapshot[] storage self, uint256 pos) private pure returns (Snapshot storage result) { + assembly { + mstore(0, self.slot) + result.slot := add(keccak256(0, 0x20), pos) + } + } + + /** + * + * ADDITIONAL FUNCTIONS FROM EIGEN-LABS + * + */ + + /** + * @dev Returns the value in the last (most recent) snapshot with key lower or equal than the search key, or zero if there is none. + * This function is a linear search for keys that are close to the end of the array. + */ + function upperLookupLinear(History storage self, uint32 key) internal view returns (uint224) { + uint256 len = self._snapshots.length; + for (uint256 i = len; i > 0; --i) { + Snapshot storage current = _unsafeAccess(self._snapshots, i - 1); + if (current._key <= key) { + return current._value; + } + } + return 0; + } + + /** + * @dev Returns the value in the last (most recent) snapshot with key lower or equal than the search key, or zero if there is none. + * In addition, returns the position of the snapshot in the array. + * + * NOTE: That if value != 0 && pos == 0, then that means the value is the first snapshot and actually exists + * a snapshot DNE iff value == 0 && pos == 0 + */ + function upperLookupWithPos(History storage self, uint32 key) internal view returns (uint224, uint256) { + uint256 len = self._snapshots.length; + uint256 pos = _upperBinaryLookup(self._snapshots, key, 0, len); + return pos == 0 ? (0, 0) : (_unsafeAccess(self._snapshots, pos - 1)._value, pos - 1); + } + + /** + * @dev Returns the value in the last (most recent) snapshot with key lower or equal than the search key, or zero if there is none. + * In addition, returns the position of the snapshot in the array. + * + * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" snapshot (snapshots with high keys). + * NOTE: That if value != 0 && pos == 0, then that means the value is the first snapshot and actually exists + * a snapshot DNE iff value == 0 && pos == 0 => value == 0 + */ + function upperLookupRecentWithPos( + History storage self, + uint32 key + ) internal view returns (uint224, uint256, uint256) { + uint256 len = self._snapshots.length; + + uint256 low = 0; + uint256 high = len; + + if (len > 5) { + uint256 mid = len - MathUpgradeable.sqrt(len); + if (key < _unsafeAccess(self._snapshots, mid)._key) { + high = mid; + } else { + low = mid + 1; + } + } + + uint256 pos = _upperBinaryLookup(self._snapshots, key, low, high); + + return pos == 0 ? (0, 0, len) : (_unsafeAccess(self._snapshots, pos - 1)._value, pos - 1, len); + } + + /// @notice WARNING: this function is only used because of the invariant property + /// that from the current key, all future snapshotted magnitude values are strictly > current value. + /// Use function with extreme care for other situations. + function decrementAtAndFutureSnapshots(History storage self, uint32 key, uint224 decrementValue) internal { + (uint224 value, uint256 pos, uint256 len) = upperLookupRecentWithPos(self, key); + + // if there is no snapshot, return + if (value == 0 && pos == 0) { + pos = type(uint256).max; + } + + while (pos < len) { + Snapshot storage current = _unsafeAccess(self._snapshots, pos); + + // reverts from underflow. Expected to never happen in our usage + current._value -= decrementValue; + + unchecked { + ++pos; + } + } + } +} diff --git a/src/contracts/libraries/StructuredLinkedList.sol b/src/contracts/libraries/StructuredLinkedList.sol deleted file mode 100644 index dc7a63450..000000000 --- a/src/contracts/libraries/StructuredLinkedList.sol +++ /dev/null @@ -1,268 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.27; - -/** - * @title StructuredLinkedList - * @author Vittorio Minacori (https://github.com/vittominacori) - * @dev An utility library for using sorted linked list data structures in your Solidity project. - * @notice Adapted from https://github.com/vittominacori/solidity-linked-list/blob/master/contracts/StructuredLinkedList.sol - */ -library StructuredLinkedList { - uint256 private constant _NULL = 0; - uint256 private constant _HEAD = 0; - - bool private constant _PREV = false; - bool private constant _NEXT = true; - - struct List { - uint256 size; - mapping(uint256 => mapping(bool => uint256)) list; - } - - /** - * @dev Checks if the list exists - * @param self stored linked list from contract - * @return bool true if list exists, false otherwise - */ - function listExists( - List storage self - ) internal view returns (bool) { - // if the head nodes previous or next pointers both point to itself, then there are no items in the list - if (self.list[_HEAD][_PREV] != _HEAD || self.list[_HEAD][_NEXT] != _HEAD) { - return true; - } else { - return false; - } - } - - /** - * @dev Checks if the node exists - * @param self stored linked list from contract - * @param _node a node to search for - * @return bool true if node exists, false otherwise - */ - function nodeExists(List storage self, uint256 _node) internal view returns (bool) { - if (self.list[_node][_PREV] == _HEAD && self.list[_node][_NEXT] == _HEAD) { - if (self.list[_HEAD][_NEXT] == _node) { - return true; - } else { - return false; - } - } else { - return true; - } - } - - /** - * @dev Returns the number of elements in the list - * @param self stored linked list from contract - * @return uint256 - */ - function sizeOf( - List storage self - ) internal view returns (uint256) { - return self.size; - } - - /** - * @dev Gets the head of the list - * @param self stored linked list from contract - * @return uint256 the head of the list - */ - function getHead( - List storage self - ) internal view returns (uint256) { - return self.list[_HEAD][_NEXT]; - } - - /** - * @dev Returns the links of a node as a tuple - * @param self stored linked list from contract - * @param _node id of the node to get - * @return bool, uint256, uint256 true if node exists or false otherwise, previous node, next node - */ - function getNode(List storage self, uint256 _node) internal view returns (bool, uint256, uint256) { - if (!nodeExists(self, _node)) { - return (false, 0, 0); - } else { - return (true, self.list[_node][_PREV], self.list[_node][_NEXT]); - } - } - - /** - * @dev Returns the link of a node `_node` in direction `_direction`. - * @param self stored linked list from contract - * @param _node id of the node to step from - * @param _direction direction to step in - * @return bool, uint256 true if node exists or false otherwise, node in _direction - */ - function getAdjacent(List storage self, uint256 _node, bool _direction) internal view returns (bool, uint256) { - if (!nodeExists(self, _node)) { - return (false, 0); - } else { - uint256 adjacent = self.list[_node][_direction]; - return (adjacent != _HEAD, adjacent); - } - } - - /** - * @dev Returns the link of a node `_node` in direction `_NEXT`. - * @param self stored linked list from contract - * @param _node id of the node to step from - * @return bool, uint256 true if node exists or false otherwise, next node - */ - function getNextNode(List storage self, uint256 _node) internal view returns (bool, uint256) { - return getAdjacent(self, _node, _NEXT); - } - - /** - * @dev Returns the link of a node `_node` in direction `_PREV`. - * @param self stored linked list from contract - * @param _node id of the node to step from - * @return bool, uint256 true if node exists or false otherwise, previous node - */ - function getPreviousNode(List storage self, uint256 _node) internal view returns (bool, uint256) { - return getAdjacent(self, _node, _PREV); - } - - /** - * @dev Insert node `_new` beside existing node `_node` in direction `_NEXT`. - * @param self stored linked list from contract - * @param _node existing node - * @param _new new node to insert - * @return bool true if success, false otherwise - */ - function insertAfter(List storage self, uint256 _node, uint256 _new) internal returns (bool) { - return _insert(self, _node, _new, _NEXT); - } - - /** - * @dev Insert node `_new` beside existing node `_node` in direction `_PREV`. - * @param self stored linked list from contract - * @param _node existing node - * @param _new new node to insert - * @return bool true if success, false otherwise - */ - function insertBefore(List storage self, uint256 _node, uint256 _new) internal returns (bool) { - return _insert(self, _node, _new, _PREV); - } - - /** - * @dev Removes an entry from the linked list - * @param self stored linked list from contract - * @param _node node to remove from the list - * @return uint256 the removed node - */ - function remove(List storage self, uint256 _node) internal returns (uint256) { - if ((_node == _NULL) || (!nodeExists(self, _node))) { - return 0; - } - _createLink(self, self.list[_node][_PREV], self.list[_node][_NEXT], _NEXT); - delete self.list[_node][_PREV]; - delete self.list[_node][_NEXT]; - - self.size -= 1; // NOT: SafeMath library should be used here to decrement. - - return _node; - } - - /** - * @dev Pushes an entry to the head of the linked list - * @param self stored linked list from contract - * @param _node new entry to push to the head - * @return bool true if success, false otherwise - */ - function pushFront(List storage self, uint256 _node) internal returns (bool) { - return _push(self, _node, _NEXT); - } - - /** - * @dev Pushes an entry to the tail of the linked list - * @param self stored linked list from contract - * @param _node new entry to push to the tail - * @return bool true if success, false otherwise - */ - function pushBack(List storage self, uint256 _node) internal returns (bool) { - return _push(self, _node, _PREV); - } - - /** - * @dev Pops the first entry from the head of the linked list - * @param self stored linked list from contract - * @return uint256 the removed node - */ - function popFront( - List storage self - ) internal returns (uint256) { - return _pop(self, _NEXT); - } - - /** - * @dev Pops the first entry from the tail of the linked list - * @param self stored linked list from contract - * @return uint256 the removed node - */ - function popBack( - List storage self - ) internal returns (uint256) { - return _pop(self, _PREV); - } - - /** - * @dev Pushes an entry to the head of the linked list - * @param self stored linked list from contract - * @param _node new entry to push to the head - * @param _direction push to the head (_NEXT) or tail (_PREV) - * @return bool true if success, false otherwise - */ - function _push(List storage self, uint256 _node, bool _direction) private returns (bool) { - return _insert(self, _HEAD, _node, _direction); - } - - /** - * @dev Pops the first entry from the linked list - * @param self stored linked list from contract - * @param _direction pop from the head (_NEXT) or the tail (_PREV) - * @return uint256 the removed node - */ - function _pop(List storage self, bool _direction) private returns (uint256) { - uint256 adj; - (, adj) = getAdjacent(self, _HEAD, _direction); - return remove(self, adj); - } - - /** - * @dev Insert node `_new` beside existing node `_node` in direction `_direction`. - * @param self stored linked list from contract - * @param _node existing node - * @param _new new node to insert - * @param _direction direction to insert node in - * @return bool true if success, false otherwise - */ - function _insert(List storage self, uint256 _node, uint256 _new, bool _direction) private returns (bool) { - if (!nodeExists(self, _new) && nodeExists(self, _node)) { - uint256 c = self.list[_node][_direction]; - _createLink(self, _node, _new, _direction); - _createLink(self, _new, c, _direction); - - self.size += 1; // NOT: SafeMath library should be used here to increment. - - return true; - } - - return false; - } - - /** - * @dev Creates a bidirectional link between two nodes on direction `_direction` - * @param self stored linked list from contract - * @param _node existing node - * @param _link node to link to in the _direction - * @param _direction direction to insert node in - */ - function _createLink(List storage self, uint256 _node, uint256 _link, bool _direction) private { - self.list[_link][!_direction] = _node; - self.list[_node][_direction] = _link; - } -} diff --git a/src/contracts/pods/EigenPod.sol b/src/contracts/pods/EigenPod.sol index cfcc88eec..d92631e34 100644 --- a/src/contracts/pods/EigenPod.sol +++ b/src/contracts/pods/EigenPod.sol @@ -61,19 +61,19 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC /// @notice Callable only by the EigenPodManager modifier onlyEigenPodManager() { - require(msg.sender == address(eigenPodManager), UnauthorizedCaller()); + require(msg.sender == address(eigenPodManager), OnlyEigenPodManager()); _; } /// @notice Callable only by the pod's owner modifier onlyEigenPodOwner() { - require(msg.sender == podOwner, UnauthorizedCaller()); + require(msg.sender == podOwner, OnlyEigenPodOwner()); _; } /// @notice Callable only by the pod's owner or proof submitter modifier onlyOwnerOrProofSubmitter() { - require(msg.sender == podOwner || msg.sender == proofSubmitter, UnauthorizedCaller()); + require(msg.sender == podOwner || msg.sender == proofSubmitter, OnlyEigenPodOwnerOrProofSubmitter()); _; } @@ -189,7 +189,7 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC // If the proof shows the validator has a balance of 0, they are marked `WITHDRAWN`. // The assumption is that if this is the case, any withdrawn ETH was already in // the pod when `startCheckpoint` was originally called. - (int128 balanceDeltaGwei, uint64 exitedBalanceGwei) = _verifyCheckpointProof({ + (uint64 prevBalanceGwei, int64 balanceDeltaGwei, uint64 exitedBalanceGwei) = _verifyCheckpointProof({ validatorInfo: validatorInfo, checkpointTimestamp: checkpointTimestamp, balanceContainerRoot: balanceContainerProof.balanceContainerRoot, @@ -197,6 +197,7 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC }); checkpoint.proofsRemaining--; + checkpoint.beaconChainBalanceBeforeGwei += prevBalanceGwei; checkpoint.balanceDeltasGwei += balanceDeltaGwei; exitedBalancesGwei += exitedBalanceGwei; @@ -260,8 +261,12 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC ); } + if (currentCheckpointTimestamp != 0) { + _currentCheckpoint.beaconChainBalanceBeforeGwei += uint64(totalAmountToBeRestakedWei / GWEI_TO_WEI); + } + // Update the EigenPodManager on this pod's new balance - eigenPodManager.recordBeaconChainETHBalanceUpdate(podOwner, int256(totalAmountToBeRestakedWei)); + eigenPodManager.recordBeaconChainETHBalanceUpdate(podOwner, int256(totalAmountToBeRestakedWei), 0); // no decrease } /** @@ -490,8 +495,10 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC // purpose of `lastCheckpointedAt` is to enforce that newly-verified validators are not // eligible to progress already-existing checkpoints - however in this case, no checkpoints exist. activeValidatorCount++; - uint64 lastCheckpointedAt = - currentCheckpointTimestamp == 0 ? lastCheckpointTimestamp : currentCheckpointTimestamp; + uint64 lastCheckpointedAt = lastCheckpointTimestamp; + if (currentCheckpointTimestamp != 0) { + lastCheckpointedAt = currentCheckpointTimestamp; + } // Proofs complete - create the validator in state _validatorPubkeyHashToInfo[pubkeyHash] = ValidatorInfo({ @@ -511,11 +518,11 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC uint64 checkpointTimestamp, bytes32 balanceContainerRoot, BeaconChainProofs.BalanceProof calldata proof - ) internal returns (int128 balanceDeltaGwei, uint64 exitedBalanceGwei) { + ) internal returns (uint64 prevBalanceGwei, int64 balanceDeltaGwei, uint64 exitedBalanceGwei) { uint40 validatorIndex = uint40(validatorInfo.validatorIndex); // Verify validator balance against `balanceContainerRoot` - uint64 prevBalanceGwei = validatorInfo.restakedBalanceGwei; + prevBalanceGwei = validatorInfo.restakedBalanceGwei; uint64 newBalanceGwei = BeaconChainProofs.verifyValidatorBalance({ balanceContainerRoot: balanceContainerRoot, validatorIndex: validatorIndex, @@ -542,12 +549,12 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC validatorInfo.status = VALIDATOR_STATUS.WITHDRAWN; // If we reach this point, `balanceDeltaGwei` should always be negative, // so this should be a safe conversion - exitedBalanceGwei = uint64(uint128(-balanceDeltaGwei)); + exitedBalanceGwei = uint64(-balanceDeltaGwei); emit ValidatorWithdrawn(checkpointTimestamp, validatorIndex); } - return (balanceDeltaGwei, exitedBalanceGwei); + return (prevBalanceGwei, balanceDeltaGwei, exitedBalanceGwei); } /** @@ -598,7 +605,8 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC beaconBlockRoot: getParentBlockRoot(uint64(block.timestamp)), proofsRemaining: uint24(activeValidatorCount), podBalanceGwei: podBalanceGwei, - balanceDeltasGwei: 0 + balanceDeltasGwei: 0, + beaconChainBalanceBeforeGwei: 0 }); // Place checkpoint in storage. If `proofsRemaining` is 0, the checkpoint @@ -633,8 +641,17 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC delete currentCheckpointTimestamp; delete _currentCheckpoint; + // Calculate the slashing proportion + uint64 proportionOfOldBalance = 0; + if (totalShareDeltaWei < 0) { + uint256 totalRestakedBeforeWei = + (withdrawableRestakedExecutionLayerGwei + checkpoint.beaconChainBalanceBeforeGwei) * GWEI_TO_WEI; + proportionOfOldBalance = + uint64((totalRestakedBeforeWei + uint256(-totalShareDeltaWei)) * WAD / totalRestakedBeforeWei); + } + // Update pod owner's shares - eigenPodManager.recordBeaconChainETHBalanceUpdate(podOwner, totalShareDeltaWei); + eigenPodManager.recordBeaconChainETHBalanceUpdate(podOwner, totalShareDeltaWei, proportionOfOldBalance); emit CheckpointFinalized(lastCheckpointTimestamp, totalShareDeltaWei); } else { _currentCheckpoint = checkpoint; @@ -654,8 +671,8 @@ contract EigenPod is Initializable, ReentrancyGuardUpgradeable, EigenPodPausingC } /// @dev Calculates the delta between two Gwei amounts and returns as an int256 - function _calcBalanceDelta(uint64 newAmountGwei, uint64 previousAmountGwei) internal pure returns (int128) { - return int128(uint128(newAmountGwei)) - int128(uint128(previousAmountGwei)); + function _calcBalanceDelta(uint64 newAmountGwei, uint64 previousAmountGwei) internal pure returns (int64) { + return int64(newAmountGwei) - int64(previousAmountGwei); } /** diff --git a/src/contracts/pods/EigenPodManager.sol b/src/contracts/pods/EigenPodManager.sol index b9e889c27..8d099ad56 100644 --- a/src/contracts/pods/EigenPodManager.sol +++ b/src/contracts/pods/EigenPodManager.sol @@ -6,6 +6,7 @@ import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol"; +import "../libraries/SlashingLib.sol"; import "../permissions/Pausable.sol"; import "./EigenPodPausingConstants.sol"; import "./EigenPodManagerStorage.sol"; @@ -28,15 +29,17 @@ contract EigenPodManager is EigenPodManagerStorage, ReentrancyGuardUpgradeable { + using SlashingLib for *; + modifier onlyEigenPod( address podOwner ) { - require(address(ownerToPod[podOwner]) == msg.sender, UnauthorizedCaller()); + require(address(ownerToPod[podOwner]) == msg.sender, OnlyEigenPod()); _; } modifier onlyDelegationManager() { - require(msg.sender == address(delegationManager), UnauthorizedCaller()); + require(msg.sender == address(delegationManager), OnlyDelegationManager()); _; } @@ -44,9 +47,8 @@ contract EigenPodManager is IETHPOSDeposit _ethPOS, IBeacon _eigenPodBeacon, IStrategyManager _strategyManager, - ISlasher _slasher, IDelegationManager _delegationManager - ) EigenPodManagerStorage(_ethPOS, _eigenPodBeacon, _strategyManager, _slasher, _delegationManager) { + ) EigenPodManagerStorage(_ethPOS, _eigenPodBeacon, _strategyManager, _delegationManager) { _disableInitializers(); } @@ -97,42 +99,29 @@ contract EigenPodManager is * to ensure that delegated shares are also tracked correctly * @param podOwner is the pod owner whose balance is being updated. * @param sharesDelta is the change in podOwner's beaconChainETHStrategy shares + * @param proportionOfOldBalance is the proportion (of WAD) of the podOwner's previous balance before the delta * @dev Callable only by the podOwner's EigenPod contract. * @dev Reverts if `sharesDelta` is not a whole Gwei amount */ function recordBeaconChainETHBalanceUpdate( address podOwner, - int256 sharesDelta + int256 sharesDelta, + uint64 proportionOfOldBalance ) external onlyEigenPod(podOwner) nonReentrant { require(podOwner != address(0), InputAddressZero()); require(sharesDelta % int256(GWEI_TO_WEI) == 0, SharesNotMultipleOfGwei()); - int256 currentPodOwnerShares = podOwnerShares[podOwner]; - int256 updatedPodOwnerShares = currentPodOwnerShares + sharesDelta; - podOwnerShares[podOwner] = updatedPodOwnerShares; - - // inform the DelegationManager of the change in delegateable shares - int256 changeInDelegatableShares = _calculateChangeInDelegatableShares({ - sharesBefore: currentPodOwnerShares, - sharesAfter: updatedPodOwnerShares - }); - // skip making a call to the DelegationManager if there is no change in delegateable shares - if (changeInDelegatableShares != 0) { - if (changeInDelegatableShares < 0) { - delegationManager.decreaseDelegatedShares({ - staker: podOwner, - strategy: beaconChainETHStrategy, - shares: uint256(-changeInDelegatableShares) - }); - } else { - delegationManager.increaseDelegatedShares({ - staker: podOwner, - strategy: beaconChainETHStrategy, - shares: uint256(changeInDelegatableShares) - }); - } + // shares can only be negative if they were due to negative shareDeltas after queued withdrawals in before + // the slashing upgrade. Make people complete queued withdrawals before completing any further checkpoints. + // the only effects podOwner UX, not AVS UX, since the podOwner already has 0 shares in the DM if they + // have a negative shares in EPM. + require(podOwnerShares[podOwner] >= 0, LegacyWithdrawalsNotCompleted()); + if (sharesDelta > 0) { + _addOwnedShares(podOwner, uint256(sharesDelta).wrapOwned()); + } else if (sharesDelta < 0 && podOwnerShares[podOwner] > 0) { + delegationManager.decreaseBeaconChainScalingFactor( + podOwner, uint256(podOwnerShares[podOwner]).wrapShares(), proportionOfOldBalance + ); } - emit PodSharesUpdated(podOwner, sharesDelta); - emit NewTotalShares(podOwner, updatedPodOwnerShares); } /** @@ -144,40 +133,33 @@ contract EigenPodManager is * @dev Reverts if `shares` is not a whole Gwei amount * @dev The delegation manager validates that the podOwner is not address(0) */ - function removeShares(address podOwner, uint256 shares) external onlyDelegationManager { - require(int256(shares) >= 0, SharesNegative()); - require(shares % GWEI_TO_WEI == 0, SharesNotMultipleOfGwei()); - int256 updatedPodOwnerShares = podOwnerShares[podOwner] - int256(shares); - require(updatedPodOwnerShares >= 0, SharesNegative()); - podOwnerShares[podOwner] = updatedPodOwnerShares; + function removeShares(address staker, IStrategy strategy, Shares shares) external onlyDelegationManager { + require(strategy == beaconChainETHStrategy, InvalidStrategy()); + require(int256(shares.unwrap()) >= 0, SharesNegative()); + require(shares.unwrap() % GWEI_TO_WEI == 0, SharesNotMultipleOfGwei()); + int256 updatedShares = podOwnerShares[staker] - int256(shares.unwrap()); + require(updatedShares >= 0, SharesNegative()); + podOwnerShares[staker] = updatedShares; - emit NewTotalShares(podOwner, updatedPodOwnerShares); + emit NewTotalShares(staker, updatedShares); } /** * @notice Increases the `podOwner`'s shares by `shares`, paying off deficit if possible. * Used by the DelegationManager to award a pod owner shares on exiting the withdrawal queue * @dev Returns the number of shares added to `podOwnerShares[podOwner]` above zero, which will be less than the `shares` input - * in the event that the podOwner has an existing shares deficit (i.e. `podOwnerShares[podOwner]` starts below zero) + * in the event that the podOwner has an existing shares deficit (i.e. `podOwnerShares[podOwner]` starts below zero). + * Also returns existingPodShares prior to adding shares, this is returned as 0 if the existing podOwnerShares is negative * @dev Reverts if `shares` is not a whole Gwei amount */ - function addShares(address podOwner, uint256 shares) external onlyDelegationManager returns (uint256) { - require(podOwner != address(0), InputAddressZero()); - require(int256(shares) >= 0, SharesNegative()); - require(shares % GWEI_TO_WEI == 0, SharesNotMultipleOfGwei()); - int256 currentPodOwnerShares = podOwnerShares[podOwner]; - int256 updatedPodOwnerShares = currentPodOwnerShares + int256(shares); - podOwnerShares[podOwner] = updatedPodOwnerShares; - - emit PodSharesUpdated(podOwner, int256(shares)); - emit NewTotalShares(podOwner, updatedPodOwnerShares); - - return uint256( - _calculateChangeInDelegatableShares({ - sharesBefore: currentPodOwnerShares, - sharesAfter: updatedPodOwnerShares - }) - ); + function addOwnedShares( + address staker, + IStrategy strategy, + IERC20, + OwnedShares shares + ) external onlyDelegationManager { + require(strategy == beaconChainETHStrategy, InvalidStrategy()); + _addOwnedShares(staker, shares); } /** @@ -188,37 +170,46 @@ contract EigenPodManager is * we do not need to update the podOwnerShares if `currentPodOwnerShares` is positive */ function withdrawSharesAsTokens( - address podOwner, - address destination, - uint256 shares + address staker, + IStrategy strategy, + IERC20, + OwnedShares shares ) external onlyDelegationManager { - require(podOwner != address(0), InputAddressZero()); - require(destination != address(0), InputAddressZero()); - require(int256(shares) >= 0, SharesNegative()); - require(shares % GWEI_TO_WEI == 0, SharesNotMultipleOfGwei()); - int256 currentPodOwnerShares = podOwnerShares[podOwner]; + // require(strategy == beaconChainETHStrategy, InvalidStrategy()); + // require(staker != address(0), InputAddressZero()); + // require(int256(shares.unwrap()) >= 0, SharesNegative()); + // require(shares.unwrap() % GWEI_TO_WEI == 0, SharesNotMultipleOfGwei()); + // int256 currentShares = podOwnerShares[staker]; - // if there is an existing shares deficit, prioritize decreasing the deficit first - if (currentPodOwnerShares < 0) { - uint256 currentShareDeficit = uint256(-currentPodOwnerShares); + // // if there is an existing shares deficit, prioritize decreasing the deficit first + // if (currentShares < 0) { + // uint256 currentShareDeficit = uint256(-currentShares); - if (shares > currentShareDeficit) { - // get rid of the whole deficit if possible, and pass any remaining shares onto destination - podOwnerShares[podOwner] = 0; - shares -= currentShareDeficit; - emit PodSharesUpdated(podOwner, int256(currentShareDeficit)); - emit NewTotalShares(podOwner, 0); - } else { - // otherwise get rid of as much deficit as possible, and return early, since there is nothing left over to forward on - int256 updatedPodOwnerShares = podOwnerShares[podOwner] + int256(shares); - podOwnerShares[podOwner] = updatedPodOwnerShares; - emit PodSharesUpdated(podOwner, int256(shares)); - emit NewTotalShares(podOwner, updatedPodOwnerShares); - return; - } - } - // Actually withdraw to the destination - ownerToPod[podOwner].withdrawRestakedBeaconChainETH(destination, shares); + // if (shares.unwrap() > currentShareDeficit) { + // // get rid of the whole deficit if possible, and pass any remaining shares onto destination + // podOwnerShares[staker] = 0; + // shares = shares.sub(currentShareDeficit).wrapWithdrawable(); + // emit PodSharesUpdated(staker, int256(currentShareDeficit)); + // emit NewTotalShares(staker, 0); + // } else { + // // otherwise get rid of as much deficit as possible, and return early, since there is nothing left over to forward on + // int256 updatedShares = podOwnerShares[staker] + int256(shares.unwrap()); + // podOwnerShares[staker] = updatedShares; + // emit PodSharesUpdated(staker, int256(shares.unwrap())); + // emit NewTotalShares(staker, updatedShares); + // return; + // } + // } + // // Actually withdraw to the destination + // ownerToPod[staker].withdrawRestakedBeaconChainETH(staker, shares.unwrap()); + } + + /// @notice Returns the current shares of `user` in `strategy` + /// @dev strategy must be beaconChainETH when talking to the EigenPodManager + /// @dev returns 0 if the user has negative shares + function stakerStrategyShares(address user, IStrategy strategy) public view returns (Shares shares) { + require(strategy == beaconChainETHStrategy, InvalidStrategy()); + return (podOwnerShares[user] < 0 ? 0 : uint256(podOwnerShares[user])).wrapShares(); } // INTERNAL FUNCTIONS @@ -241,31 +232,25 @@ contract EigenPodManager is return pod; } - /** - * @notice Calculates the change in a pod owner's delegateable shares as a result of their beacon chain ETH shares changing - * from `sharesBefore` to `sharesAfter`. The key concept here is that negative/"deficit" shares are not delegateable. - */ - function _calculateChangeInDelegatableShares( - int256 sharesBefore, - int256 sharesAfter - ) internal pure returns (int256) { - if (sharesBefore <= 0) { - if (sharesAfter <= 0) { - // if the shares started negative and stayed negative, then there cannot have been an increase in delegateable shares - return 0; - } else { - // if the shares started negative and became positive, then the increase in delegateable shares is the ending share amount - return sharesAfter; - } - } else { - if (sharesAfter <= 0) { - // if the shares started positive and became negative, then the decrease in delegateable shares is the starting share amount - return (-sharesBefore); - } else { - // if the shares started positive and stayed positive, then the change in delegateable shares - // is the difference between starting and ending amounts - return (sharesAfter - sharesBefore); - } + function _addOwnedShares(address staker, OwnedShares ownedShares) internal { + require(staker != address(0), InputAddressZero()); + + int256 addedOwnedShares = int256(ownedShares.unwrap()); + int256 currentShares = podOwnerShares[staker]; + int256 updatedShares = currentShares + addedOwnedShares; + podOwnerShares[staker] = updatedShares; + + emit PodSharesUpdated(staker, addedOwnedShares); + emit NewTotalShares(staker, updatedShares); + + if (updatedShares > 0) { + delegationManager.increaseDelegatedShares({ + staker: staker, + strategy: beaconChainETHStrategy, + // existing shares from standpoint of the DelegationManager + existingShares: currentShares < 0 ? Shares.wrap(0) : uint256(currentShares).wrapShares(), + addedOwnedShares: ownedShares + }); } } diff --git a/src/contracts/pods/EigenPodManagerStorage.sol b/src/contracts/pods/EigenPodManagerStorage.sol index 76b140846..60170eff0 100644 --- a/src/contracts/pods/EigenPodManagerStorage.sol +++ b/src/contracts/pods/EigenPodManagerStorage.sol @@ -26,9 +26,6 @@ abstract contract EigenPodManagerStorage is IEigenPodManager { /// @notice EigenLayer's StrategyManager contract IStrategyManager public immutable strategyManager; - /// @notice EigenLayer's Slasher contract - ISlasher public immutable slasher; - /// @notice EigenLayer's DelegationManager contract IDelegationManager public immutable delegationManager; @@ -83,13 +80,11 @@ abstract contract EigenPodManagerStorage is IEigenPodManager { IETHPOSDeposit _ethPOS, IBeacon _eigenPodBeacon, IStrategyManager _strategyManager, - ISlasher _slasher, IDelegationManager _delegationManager ) { ethPOS = _ethPOS; eigenPodBeacon = _eigenPodBeacon; strategyManager = _strategyManager; - slasher = _slasher; delegationManager = _delegationManager; } diff --git a/src/contracts/pods/EigenPodStorage.sol b/src/contracts/pods/EigenPodStorage.sol index 096bf539c..07feb1862 100644 --- a/src/contracts/pods/EigenPodStorage.sol +++ b/src/contracts/pods/EigenPodStorage.sol @@ -76,10 +76,13 @@ abstract contract EigenPodStorage is IEigenPod { /// @dev If this address is NOT set, only the podOwner can call `startCheckpoint` and `verifyWithdrawalCredentials` address public proofSubmitter; + /// @notice The total balance of the pod before the current checkpoint + uint128 public beaconChainBalanceBeforeCurrentCheckpoint; + /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ - uint256[36] private __gap; + uint256[35] private __gap; } diff --git a/src/contracts/strategies/StrategyBase.sol b/src/contracts/strategies/StrategyBase.sol index c98568fef..3907b1583 100644 --- a/src/contracts/strategies/StrategyBase.sol +++ b/src/contracts/strategies/StrategyBase.sol @@ -64,7 +64,7 @@ contract StrategyBase is Initializable, Pausable, IStrategy { /// @notice Simply checks that the `msg.sender` is the `strategyManager`, which is an address stored immutably at construction. modifier onlyStrategyManager() { - require(msg.sender == address(strategyManager), UnauthorizedCaller()); + require(msg.sender == address(strategyManager), OnlyStrategyManager()); _; } @@ -302,7 +302,7 @@ contract StrategyBase is Initializable, Pausable, IStrategy { function shares( address user ) public view virtual returns (uint256) { - return strategyManager.stakerStrategyShares(user, IStrategy(address(this))); + return strategyManager.stakerStrategyShares(user, IStrategy(address(this))).unwrap(); } /// @notice Internal function used to fetch this contract's current balance of `underlyingToken`. diff --git a/src/contracts/strategies/StrategyFactory.sol b/src/contracts/strategies/StrategyFactory.sol index 6491b1d7a..ec44527ae 100644 --- a/src/contracts/strategies/StrategyFactory.sol +++ b/src/contracts/strategies/StrategyFactory.sol @@ -60,10 +60,8 @@ contract StrategyFactory is StrategyFactoryStorage, OwnableUpgradeable, Pausable ); _setStrategyForToken(token, strategy); IStrategy[] memory strategiesToWhitelist = new IStrategy[](1); - bool[] memory thirdPartyTransfersForbiddenValues = new bool[](1); strategiesToWhitelist[0] = strategy; - thirdPartyTransfersForbiddenValues[0] = false; - strategyManager.addStrategiesToDepositWhitelist(strategiesToWhitelist, thirdPartyTransfersForbiddenValues); + strategyManager.addStrategiesToDepositWhitelist(strategiesToWhitelist); return strategy; } @@ -106,17 +104,9 @@ contract StrategyFactory is StrategyFactoryStorage, OwnableUpgradeable, Pausable * @notice Owner-only function to pass through a call to `StrategyManager.addStrategiesToDepositWhitelist` */ function whitelistStrategies( - IStrategy[] calldata strategiesToWhitelist, - bool[] calldata thirdPartyTransfersForbiddenValues + IStrategy[] calldata strategiesToWhitelist ) external onlyOwner { - strategyManager.addStrategiesToDepositWhitelist(strategiesToWhitelist, thirdPartyTransfersForbiddenValues); - } - - /** - * @notice Owner-only function to pass through a call to `StrategyManager.setThirdPartyTransfersForbidden` - */ - function setThirdPartyTransfersForbidden(IStrategy strategy, bool value) external onlyOwner { - strategyManager.setThirdPartyTransfersForbidden(strategy, value); + strategyManager.addStrategiesToDepositWhitelist(strategiesToWhitelist); } /** diff --git a/src/contracts/utils/UpgradeableSignatureCheckingUtils.sol b/src/contracts/utils/UpgradeableSignatureCheckingUtils.sol deleted file mode 100644 index 562ccd495..000000000 --- a/src/contracts/utils/UpgradeableSignatureCheckingUtils.sol +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.27; - -import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; - -/** - * @title Abstract contract that implements minimal signature-related storage & functionality for upgradeable contracts. - * @author Layr Labs, Inc. - * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service - */ -abstract contract UpgradeableSignatureCheckingUtils is Initializable { - /// @notice The EIP-712 typehash for the contract's domain - bytes32 public constant DOMAIN_TYPEHASH = - keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); - - // chain id at the time of contract deployment - uint256 internal immutable ORIGINAL_CHAIN_ID; - - /** - * @notice Original EIP-712 Domain separator for this contract. - * @dev The domain separator may change in the event of a fork that modifies the ChainID. - * Use the getter function `domainSeparator` to get the current domain separator for this contract. - */ - bytes32 internal _DOMAIN_SEPARATOR; - - // INITIALIZING FUNCTIONS - constructor() { - ORIGINAL_CHAIN_ID = block.chainid; - } - - function _initializeSignatureCheckingUtils() internal onlyInitializing { - _DOMAIN_SEPARATOR = _calculateDomainSeparator(); - } - - // VIEW FUNCTIONS - /** - * @notice Getter function for the current EIP-712 domain separator for this contract. - * @dev The domain separator will change in the event of a fork that changes the ChainID. - */ - function domainSeparator() public view returns (bytes32) { - if (block.chainid == ORIGINAL_CHAIN_ID) { - return _DOMAIN_SEPARATOR; - } else { - return _calculateDomainSeparator(); - } - } - - // @notice Internal function for calculating the current domain separator of this contract - function _calculateDomainSeparator() internal view returns (bytes32) { - return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("EigenLayer")), block.chainid, address(this))); - } -} diff --git a/src/test/DepositWithdraw.t.sol b/src/test/DepositWithdraw.t.sol index 3a369a706..b39857e4c 100644 --- a/src/test/DepositWithdraw.t.sol +++ b/src/test/DepositWithdraw.t.sol @@ -357,9 +357,6 @@ contract DepositWithdrawTests is EigenLayerTestHelper { strategyManager = StrategyManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); - slasher = Slasher( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); eigenPodManager = EigenPodManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); @@ -370,10 +367,10 @@ contract DepositWithdrawTests is EigenLayerTestHelper { eigenPodBeacon = new UpgradeableBeacon(address(pod)); // Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs - DelegationManager delegationImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - StrategyManager strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager, slasher); + DelegationManager delegationImplementation = new DelegationManager(strategyManager, eigenPodManager); + StrategyManager strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager); Slasher slasherImplementation = new Slasher(strategyManager, delegation); - EigenPodManager eigenPodManagerImplementation = new EigenPodManager(ethPOSDeposit, eigenPodBeacon, strategyManager, slasher, delegation); + EigenPodManager eigenPodManagerImplementation = new EigenPodManager(ethPOSDeposit, eigenPodBeacon, strategyManager, delegation); // Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them. eigenLayerProxyAdmin.upgradeAndCall( ITransparentUpgradeableProxy(payable(address(delegation))), @@ -399,16 +396,6 @@ contract DepositWithdrawTests is EigenLayerTestHelper { 0/*initialPausedStatus*/ ) ); - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation), - abi.encodeWithSelector( - Slasher.initialize.selector, - eigenLayerReputedMultisig, - eigenLayerPauserReg, - 0/*initialPausedStatus*/ - ) - ); eigenLayerProxyAdmin.upgradeAndCall( ITransparentUpgradeableProxy(payable(address(eigenPodManager))), address(eigenPodManagerImplementation), diff --git a/src/test/EigenLayerDeployer.t.sol b/src/test/EigenLayerDeployer.t.sol index 9eb5afe6d..0122c2e20 100644 --- a/src/test/EigenLayerDeployer.t.sol +++ b/src/test/EigenLayerDeployer.t.sol @@ -14,7 +14,6 @@ import "../contracts/interfaces/IETHPOSDeposit.sol"; import "../contracts/core/StrategyManager.sol"; import "../contracts/strategies/StrategyBase.sol"; -import "../contracts/core/Slasher.sol"; import "../contracts/pods/EigenPod.sol"; import "../contracts/pods/EigenPodManager.sol"; @@ -36,7 +35,6 @@ contract EigenLayerDeployer is Operators { ProxyAdmin public eigenLayerProxyAdmin; PauserRegistry public eigenLayerPauserReg; - Slasher public slasher; DelegationManager public delegation; StrategyManager public strategyManager; EigenPodManager public eigenPodManager; @@ -129,7 +127,6 @@ contract EigenLayerDeployer is Operators { fuzzedAddressMapping[address(strategyManager)] = true; fuzzedAddressMapping[address(eigenPodManager)] = true; fuzzedAddressMapping[address(delegation)] = true; - fuzzedAddressMapping[address(slasher)] = true; } function _deployEigenLayerContractsLocal() internal { @@ -154,9 +151,6 @@ contract EigenLayerDeployer is Operators { strategyManager = StrategyManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); - slasher = Slasher( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); eigenPodManager = EigenPodManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); @@ -170,14 +164,12 @@ contract EigenLayerDeployer is Operators { eigenPodBeacon = new UpgradeableBeacon(address(pod)); // Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs - DelegationManager delegationImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - StrategyManager strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager, slasher); - Slasher slasherImplementation = new Slasher(strategyManager, delegation); + DelegationManager delegationImplementation = new DelegationManager(strategyManager, eigenPodManager); + StrategyManager strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager); EigenPodManager eigenPodManagerImplementation = new EigenPodManager( ethPOSDeposit, eigenPodBeacon, strategyManager, - slasher, delegation ); @@ -206,16 +198,6 @@ contract EigenLayerDeployer is Operators { 0 /*initialPausedStatus*/ ) ); - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation), - abi.encodeWithSelector( - Slasher.initialize.selector, - eigenLayerReputedMultisig, - eigenLayerPauserReg, - 0 /*initialPausedStatus*/ - ) - ); eigenLayerProxyAdmin.upgradeAndCall( ITransparentUpgradeableProxy(payable(address(eigenPodManager))), address(eigenPodManagerImplementation), @@ -263,7 +245,6 @@ contract EigenLayerDeployer is Operators { eigenLayerPauserRegAddress = stdJson.readAddress(config, ".addresses.eigenLayerPauserReg"); delegationAddress = stdJson.readAddress(config, ".addresses.delegation"); strategyManagerAddress = stdJson.readAddress(config, ".addresses.strategyManager"); - slasherAddress = stdJson.readAddress(config, ".addresses.slasher"); eigenPodManagerAddress = stdJson.readAddress(config, ".addresses.eigenPodManager"); emptyContractAddress = stdJson.readAddress(config, ".addresses.emptyContract"); operationsMultisig = stdJson.readAddress(config, ".parameters.operationsMultisig"); diff --git a/src/test/integration/IntegrationDeployer.t.sol b/src/test/integration/IntegrationDeployer.t.sol index 0fc4b9e81..0ec633827 100644 --- a/src/test/integration/IntegrationDeployer.t.sol +++ b/src/test/integration/IntegrationDeployer.t.sol @@ -11,7 +11,6 @@ import "forge-std/Test.sol"; import "src/contracts/core/DelegationManager.sol"; import "src/contracts/core/StrategyManager.sol"; -import "src/contracts/core/Slasher.sol"; import "src/contracts/strategies/StrategyFactory.sol"; import "src/contracts/strategies/StrategyBase.sol"; import "src/contracts/strategies/StrategyBaseTVLLimits.sol"; @@ -233,9 +232,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { strategyManager = StrategyManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); - slasher = Slasher( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); eigenPodManager = EigenPodManager( address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); @@ -256,14 +252,12 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { eigenPodBeacon = new UpgradeableBeacon(address(eigenPodImplementation)); // Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs - delegationManagerImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager, slasher); - slasherImplementation = new Slasher(strategyManager, delegationManager); + delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager); + strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager); eigenPodManagerImplementation = new EigenPodManager( ethPOSDeposit, eigenPodBeacon, strategyManager, - slasher, delegationManager ); avsDirectoryImplementation = new AVSDirectory(delegationManager); @@ -299,17 +293,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { 0 // initialPausedStatus ) ); - // Slasher - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation), - abi.encodeWithSelector( - Slasher.initialize.selector, - eigenLayerReputedMultisig, - eigenLayerPauserReg, - 0 // initialPausedStatus - ) - ); // EigenPodManager eigenLayerProxyAdmin.upgradeAndCall( ITransparentUpgradeableProxy(payable(address(eigenPodManager))), @@ -399,14 +382,13 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ); // First, deploy the *implementation* contracts, using the *proxy contracts* as inputs - delegationManagerImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager, slasher); + delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager); + strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager); slasherImplementation = new Slasher(strategyManager, delegationManager); eigenPodManagerImplementation = new EigenPodManager( ethPOSDeposit, eigenPodBeacon, strategyManager, - slasher, delegationManager ); avsDirectoryImplementation = new AVSDirectory(delegationManager); @@ -422,11 +404,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ITransparentUpgradeableProxy(payable(address(strategyManager))), address(strategyManagerImplementation) ); - // Slasher - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation) - ); // EigenPodManager eigenLayerProxyAdmin.upgrade( ITransparentUpgradeableProxy(payable(address(eigenPodManager))), @@ -493,14 +470,13 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ); // First, deploy the *implementation* contracts, using the *proxy contracts* as inputs - delegationManagerImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager, slasher); + delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager); + strategyManagerImplementation = new StrategyManager(delegationManager, eigenPodManager); slasherImplementation = new Slasher(strategyManager, delegationManager); eigenPodManagerImplementation = new EigenPodManager( ethPOSDeposit, eigenPodBeacon, strategyManager, - slasher, delegationManager ); avsDirectoryImplementation = new AVSDirectory(delegationManager); @@ -516,11 +492,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ITransparentUpgradeableProxy(payable(address(strategyManager))), address(strategyManagerImplementation) ); - // Slasher - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(slasher))), - address(slasherImplementation) - ); // EigenPodManager eigenLayerProxyAdmin.upgrade( ITransparentUpgradeableProxy(payable(address(eigenPodManager))), diff --git a/src/test/integration/tests/Upgrade_Setup.t.sol b/src/test/integration/tests/Upgrade_Setup.t.sol index dbde22584..0e07c2a0e 100644 --- a/src/test/integration/tests/Upgrade_Setup.t.sol +++ b/src/test/integration/tests/Upgrade_Setup.t.sol @@ -68,7 +68,6 @@ contract IntegrationMainnetFork_UpgradeSetup is IntegrationCheckUtils { "avsDirectory: delegationManager address not set correctly" ); // DelegationManager - require(delegationManager.slasher() == slasher, "delegationManager: slasher address not set correctly"); require( delegationManager.strategyManager() == strategyManager, "delegationManager: strategyManager address not set correctly" @@ -78,7 +77,6 @@ contract IntegrationMainnetFork_UpgradeSetup is IntegrationCheckUtils { "delegationManager: eigenPodManager address not set correctly" ); // StrategyManager - require(strategyManager.slasher() == slasher, "strategyManager: slasher address not set correctly"); require( strategyManager.delegation() == delegationManager, "strategyManager: delegationManager address not set correctly" @@ -96,7 +94,6 @@ contract IntegrationMainnetFork_UpgradeSetup is IntegrationCheckUtils { eigenPodManager.strategyManager() == strategyManager, "eigenPodManager: strategyManager contract address not set correctly" ); - require(eigenPodManager.slasher() == slasher, "eigenPodManager: slasher contract address not set correctly"); require( eigenPodManager.delegationManager() == delegationManager, "eigenPodManager: delegationManager contract address not set correctly" diff --git a/src/test/mocks/AVSDirectoryMock.sol b/src/test/mocks/AVSDirectoryMock.sol new file mode 100644 index 000000000..01661f0a4 --- /dev/null +++ b/src/test/mocks/AVSDirectoryMock.sol @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.9; + +import "forge-std/Test.sol"; +import "../../contracts/interfaces/IAVSDirectory.sol"; +import "../../contracts/interfaces/IStrategy.sol"; + +contract AVSDirectoryMock is IAVSDirectory, Test { + function createOperatorSets(uint32[] calldata operatorSetIds) external {} + + function becomeOperatorSetAVS() external {} + + function migrateOperatorsToOperatorSets( + address[] calldata operators, + uint32[][] calldata operatorSetIds + ) external {} + + function registerOperatorToOperatorSets( + address operator, + uint32[] calldata operatorSetIds, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external {} + + function deregisterOperatorFromOperatorSets(address operator, uint32[] calldata operatorSetIds) external {} + + function forceDeregisterFromOperatorSets( + address operator, + address avs, + uint32[] calldata operatorSetIds, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external {} + + function registerOperatorToAVS( + address operator, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external {} + + function deregisterOperatorFromAVS(address operator) external {} + + function updateFreeMagnitude( + address operator, + IStrategy[] calldata strategies, + uint16[] calldata freeMagnitudes + ) external {} + + function slashOperator( + address operator, + uint32 operatorSetId, + IStrategy[] calldata strategies, + uint16 bipsToSlash + ) external {} + + function updateAVSMetadataURI(string calldata metadataURI) external {} + + function cancelSalt(bytes32 salt) external {} + + function operatorSaltIsSpent(address operator, bytes32 salt) external view returns (bool) {} + + function isMember(address avs, address operator, uint32 operatorSetId) external view returns (bool) {} + + function isOperatorSetAVS(address avs) external view returns (bool) {} + + function isOperatorSet(address avs, uint32 operatorSetId) external view returns (bool) {} + + function isOperatorSetBatch(OperatorSet[] calldata operatorSets) public view returns (bool) {} + + function isOperatorSlashable(address operator, OperatorSet memory operatorSet) external view returns (bool) {} + + function operatorSetMemberCount(address avs, uint32 operatorSetId) external view returns (uint256) {} + + function calculateOperatorAVSRegistrationDigestHash( + address operator, + address avs, + bytes32 salt, + uint256 expiry + ) external view returns (bytes32) {} + + function calculateOperatorSetRegistrationDigestHash( + address avs, + uint32[] calldata operatorSetIds, + bytes32 salt, + uint256 expiry + ) external view returns (bytes32) {} + + function calculateOperatorSetForceDeregistrationTypehash( + address avs, + uint32[] calldata operatorSetIds, + bytes32 salt, + uint256 expiry + ) external view returns (bytes32) {} + + /// @notice Getter function for the current EIP-712 domain separator for this contract. + /// @dev The domain separator will change in the event of a fork that changes the ChainID. + function domainSeparator() external view returns (bytes32) {} + + /// @notice The EIP-712 typehash for the Registration struct used by the contract. + function OPERATOR_AVS_REGISTRATION_TYPEHASH() external view returns (bytes32) {} + + /// @notice The EIP-712 typehash for the OperatorSetRegistration struct used by the contract. + function OPERATOR_SET_REGISTRATION_TYPEHASH() external view returns (bytes32) {} + + function isMember(address operator, OperatorSet memory operatorSet) external view returns (bool) {} + + function operatorSetsMemberOfAtIndex(address operator, uint256 index) external view returns (OperatorSet memory) {} + + function operatorSetMemberAtIndex(OperatorSet memory operatorSet, uint256 index) external view returns (address) {} + + function getOperatorSetsOfOperator( + address operator, + uint256 start, + uint256 length + ) external view returns (OperatorSet[] memory operatorSets) {} + + function getOperatorsInOperatorSet( + OperatorSet memory operatorSet, + uint256 start, + uint256 length + ) external view returns (address[] memory operators) {} + + function getNumOperatorsInOperatorSet(OperatorSet memory operatorSet) external view returns (uint256) {} + + function inTotalOperatorSets(address operator) external view returns (uint256) {} + + function operatorSetStatus( + address avs, + address operator, + uint32 operatorSetId + ) external view returns (bool registered, uint32 lastDeregisteredTimestamp) {} +} \ No newline at end of file diff --git a/src/test/mocks/EigenPodManagerMock.sol b/src/test/mocks/EigenPodManagerMock.sol index 127fcc49a..43a13f614 100644 --- a/src/test/mocks/EigenPodManagerMock.sol +++ b/src/test/mocks/EigenPodManagerMock.sol @@ -17,8 +17,6 @@ contract EigenPodManagerMock is IEigenPodManager, Test, Pausable { _initializePauser(_pauserRegistry, 0); } - function slasher() external view returns(ISlasher) {} - function createPod() external returns(address) {} function stake(bytes calldata /*pubkey*/, bytes calldata /*signature*/, bytes32 /*depositDataRoot*/) external payable {} diff --git a/src/test/mocks/StrategyManagerMock.sol b/src/test/mocks/StrategyManagerMock.sol index d0bbc87a6..21e8f6ea7 100644 --- a/src/test/mocks/StrategyManagerMock.sol +++ b/src/test/mocks/StrategyManagerMock.sol @@ -24,7 +24,6 @@ contract StrategyManagerMock is IDelegationManager public delegation; IEigenPodManager public eigenPodManager; - ISlasher public slasher; address public strategyWhitelister; mapping(address => IStrategy[]) public strategiesToReturn; @@ -37,10 +36,9 @@ contract StrategyManagerMock is mapping(IStrategy => bool) public thirdPartyTransfersForbidden; - function setAddresses(IDelegationManager _delegation, IEigenPodManager _eigenPodManager, ISlasher _slasher) external + function setAddresses(IDelegationManager _delegation, IEigenPodManager _eigenPodManager) external { delegation = _delegation; - slasher = _slasher; eigenPodManager = _eigenPodManager; } diff --git a/src/test/unit/AVSDirectoryUnit.t.sol b/src/test/unit/AVSDirectoryUnit.t.sol index 5229781f8..a8c64ab74 100644 --- a/src/test/unit/AVSDirectoryUnit.t.sol +++ b/src/test/unit/AVSDirectoryUnit.t.sol @@ -4,11 +4,14 @@ pragma solidity ^0.8.27; import "@openzeppelin/contracts/mocks/ERC1271WalletMock.sol"; import "src/contracts/core/DelegationManager.sol"; +import "src/contracts/core/AllocationManager.sol"; import "src/contracts/core/AVSDirectory.sol"; import "src/test/events/IAVSDirectoryEvents.sol"; import "src/test/utils/EigenLayerUnitTestSetup.sol"; +contract EmptyContract {} + /** * @notice Unit testing of the AVSDirectory contract. An AVSs' service manager contract will * call this to register an operator with the AVS. @@ -16,6 +19,10 @@ import "src/test/utils/EigenLayerUnitTestSetup.sol"; * Contracts not mocked: DelegationManager */ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { + uint256 internal constant MAX_PRIVATE_KEY = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140; + + EmptyContract emptyContract; + // Contract under test AVSDirectory avsDirectory; AVSDirectory avsDirectoryImplementation; @@ -23,6 +30,8 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { // Contract dependencies DelegationManager delegationManager; DelegationManager delegationManagerImplementation; + AllocationManager allocationManager; + AllocationManager allocationManagerImplementation; // Delegation signer uint256 delegationSignerPrivateKey = uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); @@ -34,12 +43,19 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { // reused in various tests. in storage to help handle stack-too-deep errors address defaultAVS = address(this); + // deallocation delay in AllocationManager + uint32 DEALLOCATION_DELAY = 17.5 days; + uint32 ALLOCATION_CONFIGURATION_DELAY = 21 days; + // withdrawal delay in DelegationManager + uint32 MIN_WITHDRAWAL_DELAY = 17.5 days; uint256 minWithdrawalDelayBlocks = 216_000; IStrategy[] public initializeStrategiesToSetDelayBlocks; uint256[] public initializeWithdrawalDelayBlocks; // Index for flag that pauses registering/deregistering for AVSs uint8 internal constant PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS = 0; + // Index for flag that pauses operator register/deregister to operator sets when set. + uint8 internal constant PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION = 1; function setUp() public virtual override { // Setup @@ -48,7 +64,32 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { // Deploy DelegationManager implmentation and proxy initializeStrategiesToSetDelayBlocks = new IStrategy[](0); initializeWithdrawalDelayBlocks = new uint256[](0); - delegationManagerImplementation = new DelegationManager(strategyManagerMock, slasherMock, eigenPodManagerMock); + + emptyContract = new EmptyContract(); + + avsDirectory = AVSDirectory( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + delegationManager = DelegationManager( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + allocationManager = AllocationManager( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + + allocationManagerImplementation = new AllocationManager(delegationManager, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY); + + delegationManagerImplementation = new DelegationManager( + strategyManagerMock, + slasherMock, + eigenPodManagerMock, + avsDirectory, + allocationManager, + MIN_WITHDRAWAL_DELAY + ); + + avsDirectoryImplementation = new AVSDirectory(delegationManager); + delegationManager = DelegationManager( address( new TransparentUpgradeableProxy( @@ -67,8 +108,6 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { ) ); - // Deploy AVSDirectory implmentation and proxy - avsDirectoryImplementation = new AVSDirectory(delegationManager); avsDirectory = AVSDirectory( address( new TransparentUpgradeableProxy( @@ -93,11 +132,11 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { */ /** - * @notice internal function for calculating a signature from the operator corresponding to `_operatorPrivateKey`, delegating them to + * @notice internal function for calculating a signature from the operator corresponding to `operatorPk`, delegating them to * the `operator`, and expiring at `expiry`. */ - function _getOperatorSignature( - uint256 _operatorPrivateKey, + function _getOperatorAVSRegistrationSignature( + uint256 operatorPk, address operator, address avs, bytes32 salt, @@ -107,7 +146,7 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { operatorSignature.salt = salt; { bytes32 digestHash = avsDirectory.calculateOperatorAVSRegistrationDigestHash(operator, avs, salt, expiry); - (uint8 v, bytes32 r, bytes32 s) = cheats.sign(_operatorPrivateKey, digestHash); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign(operatorPk, digestHash); operatorSignature.signature = abi.encodePacked(r, s, v); } return operatorSignature; @@ -156,7 +195,7 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { ) internal filterFuzzedAddressInputs(operator) { _filterOperatorDetails(operator, operatorDetails); cheats.prank(operator); - delegationManager.registerAsOperator(operatorDetails, metadataURI); + delegationManager.registerAsOperator(operatorDetails, 0, metadataURI); } function _filterOperatorDetails( @@ -165,24 +204,1088 @@ contract AVSDirectoryUnitTests is EigenLayerUnitTestSetup, IAVSDirectoryEvents { ) internal view { // filter out zero address since people can't delegate to the zero address and operators are delegated to themselves cheats.assume(operator != address(0)); - // filter out disallowed stakerOptOutWindowBlocks values - cheats.assume(operatorDetails.stakerOptOutWindowBlocks <= delegationManager.MAX_STAKER_OPT_OUT_WINDOW_BLOCKS()); + } + + function _registerOperatorToOperatorSet( + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) internal virtual { + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + _registerOperatorToOperatorSets(operatorPk, oids, salt, expiry); + } + + function _registerOperatorToOperatorSets( + uint256 operatorPk, + uint32[] memory operatorSetIds, + bytes32 salt, + uint256 expiry + ) internal virtual { + expiry = bound(expiry, 1, type(uint256).max); + cheats.warp(0); + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, + avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), operatorSetIds, salt, expiry) + ); + + // Set AVS as operator set avs + avsDirectory.becomeOperatorSetAVS(); + + _registerOperatorWithBaseDetails(operator); + + avsDirectory.registerOperatorToOperatorSets( + operator, + operatorSetIds, + ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + } + + function _createOperatorSet(uint32 operatorSetId) internal { + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + avsDirectory.createOperatorSets(oids); + } + + function _createOperatorSets(uint32[] memory operatorSetIds) internal { + avsDirectory.createOperatorSets(operatorSetIds); + } +} + +contract AVSDirectoryUnitTests_initialize is AVSDirectoryUnitTests { + function testFuzz_Correctness( + address delegationManager, + address owner, + address pauserRegistry, + uint256 initialPausedStatus + ) public virtual { + AVSDirectory dir = new AVSDirectory(IDelegationManager(delegationManager)); + + assertEq(address(dir.delegation()), delegationManager); + + cheats.expectRevert("Initializable: contract is already initialized"); + dir.initialize(owner, IPauserRegistry(pauserRegistry), initialPausedStatus); + } +} + +contract AVSDirectoryUnitTests_domainSeparator is AVSDirectoryUnitTests { + function test_domainSeparator() public virtual { + // This is just to get coverage up. + avsDirectory.domainSeparator(); + cheats.chainId(0xC0FFEE); + avsDirectory.domainSeparator(); + } +} + +contract AVSDirectoryUnitTests_registerOperatorToOperatorSet is AVSDirectoryUnitTests { + function testFuzz_revert_SignatureIsExpired( + address operator, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + expiry = bound(expiry, 0, type(uint256).max - 1); + cheats.warp(type(uint256).max); + + _createOperatorSet(operatorSetId); + + _registerOperatorWithBaseDetails(operator); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + cheats.expectRevert("AVSDirectory.registerOperatorToOperatorSets: operator signature expired"); + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(new bytes(0), salt, expiry) + ); + } + + function testFuzz_revert_notOperatorSetAVS( + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + _createOperatorSet(operatorSetId); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + cheats.expectRevert("AVSDirectory.registerOperatorToOperatorSets: AVS is not an operator set AVS"); + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + } + + function testFuzz_revert_OperatorRegistered( + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + avsDirectory.becomeOperatorSetAVS(); + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + _createOperatorSet(operatorSetId); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + + (v, r, s) = cheats.sign( + operatorPk, + avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, keccak256(""), expiry) + ); + + cheats.expectRevert("AVSDirectory._registerOperatorToOperatorSets: operator already registered to operator set"); + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), keccak256(""), expiry) + ); + } + + function testFuzz_revert_OperatorNotRegistered( + address operator, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + avsDirectory.becomeOperatorSetAVS(); + cheats.assume(operator != address(0)); + expiry = bound(expiry, 1, type(uint256).max); + cheats.warp(0); + + _createOperatorSet(operatorSetId); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + cheats.expectRevert("AVSDirectory.registerOperatorToOperatorSets: operator not registered to EigenLayer yet"); + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(new bytes(0), salt, expiry) + ); + } + + function testFuzz_revert_SaltSpent( + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + avsDirectory.becomeOperatorSetAVS(); + operatorSetId = uint32(bound(operatorSetId, 1, type(uint32).max)); + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + _createOperatorSet(operatorSetId); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + + cheats.expectRevert("AVSDirectory.registerOperatorToOperatorSets: salt already spent"); + avsDirectory.registerOperatorToOperatorSets( + operator, new uint32[](0), ISignatureUtils.SignatureWithSaltAndExpiry(new bytes(0), salt, expiry) + ); + } + + function testFuzz_revert_WrongAVS( + address badAvs, + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + cheats.assume(badAvs != address(this)); + + operatorSetId = uint32(bound(operatorSetId, 1, type(uint32).max)); + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + _createOperatorSet(operatorSetId); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + address operator = cheats.addr(operatorPk); + + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + cheats.startPrank(badAvs); + avsDirectory.becomeOperatorSetAVS(); + cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer"); + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + cheats.stopPrank(); + } + + function testFuzz_revert_invalidOperatorSet( + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + avsDirectory.becomeOperatorSetAVS(); + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + cheats.expectRevert("AVSDirectory._registerOperatorToOperatorSets: invalid operator set"); + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + } + + function testFuzz_MultipleCorrectness( + uint256 operatorPk, + uint256 totalSets, + bytes32 salt, + uint256 expiry + ) public virtual { + avsDirectory.becomeOperatorSetAVS(); + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + totalSets = bound(totalSets, 1, 64); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + uint32[] memory oids = new uint32[](totalSets); + for (uint256 i; i < oids.length; ++i) { + oids[i] = uint32(uint256(keccak256(abi.encodePacked(i))) % type(uint32).max); + _createOperatorSet(oids[i]); + } + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + for (uint256 i; i < oids.length; ++i) { + cheats.expectEmit(true, false, false, false, address(avsDirectory)); + emit OperatorAddedToOperatorSet(operator, OperatorSet(address(this), oids[i])); + } + + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + + OperatorSet[] memory operatorSets = + avsDirectory.getOperatorSetsOfOperator(operator, 0, type(uint256).max); + + for (uint256 i; i < oids.length; ++i) { + assertTrue(avsDirectory.isMember(operator, OperatorSet(address(this), oids[i]))); + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), oids[i])), 1); + assertEq(operatorSets[i].avs, address(this)); + assertEq(operatorSets[i].operatorSetId, oids[i]); + } + + for (uint256 i; i < oids.length; ++i) { + address[] memory operators = avsDirectory.getOperatorsInOperatorSet(OperatorSet(address(this), oids[i]), 0, type(uint256).max); + assertEq(operators.length, 1); + assertEq(operators[0], operator); + } + + assertEq(operatorSets.length, totalSets); + assertEq(avsDirectory.inTotalOperatorSets(operator), totalSets); + assertTrue(avsDirectory.operatorSaltIsSpent(operator, salt)); + } + + function testFuzz_Correctness( + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + avsDirectory.becomeOperatorSetAVS(); + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + _createOperatorSet(operatorSetId); + + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + cheats.expectEmit(true, false, false, false, address(avsDirectory)); + emit OperatorAddedToOperatorSet(operator, OperatorSet(address(this), operatorSetId)); + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + + assertTrue(avsDirectory.isMember(operator, OperatorSet(address(this), operatorSetId))); + + OperatorSet memory operatorSet = avsDirectory.operatorSetsMemberOfAtIndex(operator, 0); + + assertEq(operatorSet.avs, address(this)); + assertEq(operatorSet.operatorSetId, oids[0]); + + address operatorInSet = avsDirectory.operatorSetMemberAtIndex(OperatorSet(address(this), operatorSetId), 0); + assertEq(operator, operatorInSet); + + assertEq(avsDirectory.inTotalOperatorSets(operator), 1); + assertTrue(avsDirectory.operatorSaltIsSpent(operator, salt)); + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), operatorSetId)), 1); + } + + function testFuzz_Correctness_MultipleSets( + uint256 operatorPk, + uint256 totalSets, + bytes32 salt, + uint256 expiry + ) public virtual { + avsDirectory.becomeOperatorSetAVS(); + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + totalSets = bound(totalSets, 1, 64); + expiry = bound(expiry, 1, type(uint256).max); + + cheats.warp(0); + + uint32[] memory oids = new uint32[](totalSets); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + _createOperatorSet(i); + oids[i - 1] = i; + } + + address operator = cheats.addr(operatorPk); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + operatorPk, avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), oids, salt, expiry) + ); + + _registerOperatorWithBaseDetails(operator); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + cheats.expectEmit(true, false, false, false, address(avsDirectory)); + emit OperatorAddedToOperatorSet(operator, OperatorSet(address(this), i)); + } + + avsDirectory.registerOperatorToOperatorSets( + operator, oids, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt, expiry) + ); + + OperatorSet[] memory operatorSets = + avsDirectory.getOperatorSetsOfOperator(operator, 0, type(uint256).max); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + assertTrue(avsDirectory.isMember(operator, OperatorSet(address(this), i))); + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), i)), 1); + + assertEq(operatorSets[i - 1].avs, address(this)); + assertEq(operatorSets[i - 1].operatorSetId, i); + } + + for(uint32 i = 1; i < totalSets + 1; ++i) { + address[] memory operators = avsDirectory.getOperatorsInOperatorSet(OperatorSet(address(this), i), 0, type(uint256).max); + assertEq(operators.length, 1); + assertEq(operators[0], operator); + } + + assertEq(avsDirectory.inTotalOperatorSets(operator), totalSets); + assertTrue(avsDirectory.operatorSaltIsSpent(operator, salt)); + + assertEq(operatorSets.length, totalSets); + } +} + +contract AVSDirectoryUnitTests_forceDeregisterFromOperatorSets is AVSDirectoryUnitTests { + function testFuzz_revert_OperatorNotInOperatorSet(uint256 operatorPk, uint32 operatorSetId) public virtual { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + + address operator = cheats.addr(operatorPk); + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + _createOperatorSet(operatorSetId); + + ISignatureUtils.SignatureWithSaltAndExpiry memory emptySig; + + cheats.prank(operator); + cheats.expectRevert("AVSDirectory._deregisterOperatorFromOperatorSet: operator not registered for operator set"); + + avsDirectory.forceDeregisterFromOperatorSets(operator, address(this), oids, emptySig); + } + + function testFuzz_revert_operatorNotCaller(uint256 operatorPk, uint32 operatorSetId) public { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + + address operator = cheats.addr(operatorPk); + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + _createOperatorSet(operatorSetId); + + ISignatureUtils.SignatureWithSaltAndExpiry memory emptySig; + + cheats.expectRevert("AVSDirectory.forceDeregisterFromOperatorSets: caller must be operator"); + avsDirectory.forceDeregisterFromOperatorSets(operator, address(this), oids, emptySig); + } + + function testFuzz_forceDeregisterFromOperatorSets( + uint256 operatorPk, + uint32 operatorSetId, + uint8 operatorSetsToAdd, + bytes32 salt + ) public { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + operatorSetsToAdd = uint8(bound(operatorSetsToAdd, 1, 64)); + address operator = cheats.addr(operatorPk); + + // Create operator sets + operatorSetId = uint32(bound(operatorSetId, 1, type(uint32).max - uint32(operatorSetsToAdd))); + uint32[] memory oids = new uint32[](operatorSetsToAdd); + for (uint32 i = 0; i < operatorSetsToAdd; i++) { + oids[i] = operatorSetId + i; + _createOperatorSet(oids[i]); + } + + // Register operator to operator sets + _registerOperatorToOperatorSets(operatorPk, oids, salt, type(uint256).max); + + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), operatorSetId)), 1); + + // Deregister operator from operator sets + ISignatureUtils.SignatureWithSaltAndExpiry memory emptySig; + cheats.prank(operator); + for (uint256 i = 0; i < oids.length; i++) { + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorRemovedFromOperatorSet(operator, OperatorSet(address(this), oids[i])); + } + avsDirectory.forceDeregisterFromOperatorSets(operator, address(this), oids, emptySig); + + for (uint32 i = 0; i < operatorSetsToAdd; i++) { + assertFalse( + avsDirectory.isMember(operator, OperatorSet(address(this), oids[i])), + "operator still in operator set" + ); + + address[] memory operators = avsDirectory.getOperatorsInOperatorSet(OperatorSet(address(this), oids[i]), 0, type(uint256).max); + assertEq(operators.length, 0); + } + + OperatorSet[] memory operatorSets = + avsDirectory.getOperatorSetsOfOperator(operator, 0, type(uint256).max); + + assertEq(operatorSets.length, 0); + assertEq(avsDirectory.inTotalOperatorSets(operator), 0); + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), operatorSetId)), 0); + } + + function testFuzz_revert_sigExpired(uint256 operatorPk, uint32 operatorSetId, bytes32 salt) public { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + + address operator = cheats.addr(operatorPk); + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + _createOperatorSet(operatorSetId); + + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSig = + _createForceDeregSignature(operatorPk, address(this), oids, 0, salt); + + cheats.warp(type(uint256).max); + cheats.expectRevert("AVSDirectory.forceDeregisterFromOperatorSets: operator signature expired"); + avsDirectory.forceDeregisterFromOperatorSets(operator, address(this), oids, operatorSig); + } + + function testFuzz_revert_saltAlreadySpent(uint256 operatorPk, uint32 operatorSetId, bytes32 salt) public { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + + address operator = cheats.addr(operatorPk); + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + // Register operator to operator sets + _createOperatorSet(operatorSetId); + _registerOperatorToOperatorSets(operatorPk, oids, salt, type(uint256).max); + + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSig = + _createForceDeregSignature(operatorPk, address(this), oids, type(uint256).max, salt); + + cheats.expectRevert("AVSDirectory.forceDeregisterFromOperatorSets: salt already spent"); + avsDirectory.forceDeregisterFromOperatorSets(operator, address(this), oids, operatorSig); + } + + function testFuzz_forceDeregisterFromOperatorSets_onBehalf( + uint256 operatorPk, + uint32 operatorSetId, + uint8 operatorSetsToAdd, + bytes32 salt1, + bytes32 salt2 + ) public { + cheats.assume(salt1 != salt2); + + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + operatorSetsToAdd = uint8(bound(operatorSetsToAdd, 1, 64)); + address operator = cheats.addr(operatorPk); + + // Create operator sets + operatorSetId = uint32(bound(operatorSetId, 1, type(uint32).max - uint32(operatorSetsToAdd))); + uint32[] memory oids = new uint32[](operatorSetsToAdd); + for (uint32 i = 0; i < oids.length; i++) { + oids[i] = operatorSetId + i; + _createOperatorSet(oids[i]); + } + + // Register operator to operator sets + _registerOperatorToOperatorSets(operatorPk, oids, salt1, type(uint256).max); + + // Deregister operator from operator sets + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSig = + _createForceDeregSignature(operatorPk, address(this), oids, type(uint256).max, salt2); + + for (uint256 i = 0; i < oids.length; i++) { + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorRemovedFromOperatorSet(operator, OperatorSet(address(this), oids[i])); + } + + avsDirectory.forceDeregisterFromOperatorSets(operator, address(this), oids, operatorSig); + + for (uint32 i = 0; i < operatorSetsToAdd; i++) { + assertFalse(avsDirectory.isMember(operator, OperatorSet(address(this), oids[i]))); + } + } + + function _createForceDeregSignature( + uint256 operatorPk, + address avs, + uint32[] memory oids, + uint256 expiry, + bytes32 salt + ) internal view returns (ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature) { + operatorSignature.expiry = expiry; + operatorSignature.salt = salt; + { + bytes32 digestHash = avsDirectory.calculateOperatorSetForceDeregistrationTypehash(avs, oids, salt, expiry); + (uint8 v, bytes32 r, bytes32 s) = cheats.sign(operatorPk, digestHash); + operatorSignature.signature = abi.encodePacked(r, s, v); + } + return operatorSignature; + } +} + +contract AVSDirectoryUnitTests_deregisterOperatorFromOperatorSets is AVSDirectoryUnitTests { + function testFuzz_revert_OperatorNotInOperatorSet(uint256 operatorPk, uint32 operatorSetId) public virtual { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + + _createOperatorSet(operatorSetId); + + address operator = cheats.addr(operatorPk); + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + cheats.expectRevert("AVSDirectory._deregisterOperatorFromOperatorSet: operator not registered for operator set"); + avsDirectory.deregisterOperatorFromOperatorSets(operator, oids); + } + + function testFuzz_Correctness( + uint256 operatorPk, + uint32 operatorSetId, + bytes32 salt, + uint256 expiry + ) public virtual { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + + _createOperatorSet(operatorSetId); + + _registerOperatorToOperatorSet(operatorPk, operatorSetId, salt, expiry); + + address operator = cheats.addr(operatorPk); + uint32[] memory oids = new uint32[](1); + oids[0] = operatorSetId; + + // sanity + assertEq(avsDirectory.inTotalOperatorSets(operator), 1); + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), operatorSetId)), 1); + + cheats.expectEmit(true, false, false, false, address(avsDirectory)); + emit OperatorRemovedFromOperatorSet(operator, OperatorSet(address(this), operatorSetId)); + + avsDirectory.deregisterOperatorFromOperatorSets(operator, oids); + + // out of bounds array access + vm.expectRevert(); + avsDirectory.operatorSetsMemberOfAtIndex(operator, 0); + + assertEq(avsDirectory.inTotalOperatorSets(operator), 0); + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), operatorSetId)), 0); + assertEq(avsDirectory.isMember(operator, OperatorSet(address(this), operatorSetId)), false); + } + + function testFuzz_Correctness_MultipleSets( + uint256 operatorPk, + uint256 totalSets, + bytes32 salt, + uint256 expiry + ) public virtual { + operatorPk = bound(operatorPk, 1, MAX_PRIVATE_KEY); + totalSets = bound(totalSets, 1, 64); + + uint32[] memory oids = new uint32[](totalSets); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + _createOperatorSet(i); + oids[i - 1] = i; + } + + _registerOperatorToOperatorSets(operatorPk, oids, salt, expiry); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), i)), 1); + } + + address operator = cheats.addr(operatorPk); + + // sanity + assertEq(avsDirectory.inTotalOperatorSets(operator), totalSets); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + cheats.expectEmit(true, false, false, false, address(avsDirectory)); + emit OperatorRemovedFromOperatorSet(operator, OperatorSet(address(this), i)); + } + + avsDirectory.deregisterOperatorFromOperatorSets(operator, oids); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), i)), 0); + assertEq(avsDirectory.isMember(operator, OperatorSet(address(this), i)), false); + } + + OperatorSet[] memory operatorSets = + avsDirectory.getOperatorSetsOfOperator(operator, 0, type(uint256).max); + + assertEq(operatorSets.length, 0); + assertEq(avsDirectory.inTotalOperatorSets(operator), 0); + } +} + +contract AVSDirectoryUnitTests_createOperatorSet is AVSDirectoryUnitTests { + function testFuzz_createOperatorSet(uint256 totalSets) public { + totalSets = bound(totalSets, 1, 64); + + uint32[] memory oids = new uint32[](totalSets); + + for (uint32 i; i < totalSets; ++i) { + oids[i] = i + 1; + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorSetCreated(OperatorSet({avs: address(this), operatorSetId: i + 1})); + } + + avsDirectory.createOperatorSets(oids); + + for (uint32 i = 1; i < totalSets + 1; ++i) { + assertTrue(avsDirectory.isOperatorSet(address(this), i)); + } + } + + function test_revert_operatorSetExists() public { + _createOperatorSet(1); + cheats.expectRevert("AVSDirectory.createOperatorSet: operator set already exists"); + _createOperatorSet(1); } } -contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUnitTests { +contract AVSDirectoryUnitTests_becomeOperatorSetAVS is AVSDirectoryUnitTests { + function test_becomeOperatorSetAVS() public { + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit AVSMigratedToOperatorSets(address(this)); + + avsDirectory.becomeOperatorSetAVS(); + + assertTrue(avsDirectory.isOperatorSetAVS(address(this))); + } + + function test_revert_alreadyOperatorSetAVS() public { + avsDirectory.becomeOperatorSetAVS(); + cheats.expectRevert("AVSDirectory.becomeOperatorSetAVS: already an operator set AVS"); + avsDirectory.becomeOperatorSetAVS(); + } +} + +contract AVSDirectoryUnitTests_migrateOperatorsToOperatorSets is AVSDirectoryUnitTests { + address[] operators = new address[](1); + uint32[][] operatorSetIds = new uint32[][](1); + + function test_revert_paused() public { + cheats.prank(pauser); + avsDirectory.pause(2 ** PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION); + + operators = new address[](1); + operatorSetIds = new uint32[][](1); + + cheats.expectRevert("Pausable: index is paused"); + cheats.prank(defaultAVS); + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + } + + function test_revert_notOperatorSetAVS() public { + cheats.expectRevert("AVSDirectory.migrateOperatorsToOperatorSets: AVS is not an operator set AVS"); + cheats.prank(defaultAVS); + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + } + + function test_revert_operatorNotM2Registered() public { + address operator = cheats.addr(delegationSignerPrivateKey); + operators = new address[](1); + operators[0] = operator; + + avsDirectory.becomeOperatorSetAVS(); + cheats.expectRevert( + "AVSDirectory.migrateOperatorsToOperatorSets: operator already migrated or not a legacy registered operator" + ); + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + } + + function test_revert_operatorAlreadyMigrated(bytes32 salt) public { + // Register Operator to M2 + address operator = cheats.addr(delegationSignerPrivateKey); + _registerOperatorLegacyM2(delegationSignerPrivateKey, salt); + + // Format calldata + operators = new address[](1); + operators[0] = operator; + operatorSetIds = new uint32[][](1); + operatorSetIds[0] = new uint32[](1); + operatorSetIds[0][0] = 1; + + // Setup Operator Sets + _createOperatorSet(1); + avsDirectory.becomeOperatorSetAVS(); + + // Migrate Operator + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + + // Revert when trying to migrate operator again + cheats.expectRevert( + "AVSDirectory.migrateOperatorsToOperatorSets: operator already migrated or not a legacy registered operator" + ); + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + } + + function testFuzz_revert_invalidOperatorSet(bytes32 salt) public { + // Register Operator to M2 + address operator = cheats.addr(delegationSignerPrivateKey); + _registerOperatorLegacyM2(delegationSignerPrivateKey, salt); + + // Format calldata + operators = new address[](1); + operators[0] = operator; + operatorSetIds = new uint32[][](1); + operatorSetIds[0] = new uint32[](1); + operatorSetIds[0][0] = 1; + + // Become operator set AVS + avsDirectory.becomeOperatorSetAVS(); + + // Revert + cheats.expectRevert("AVSDirectory._registerOperatorToOperatorSets: invalid operator set"); + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + } + + function testFuzz_revert_operatorAlreadyRegisteredFromMigration(bytes32 salt) public { + // Register Operator to M2 + address operator = cheats.addr(delegationSignerPrivateKey); + _registerOperatorLegacyM2(delegationSignerPrivateKey, salt); + + // Format calldata + operators = new address[](1); + operators[0] = operator; + operatorSetIds = new uint32[][](1); + operatorSetIds[0] = new uint32[](2); + operatorSetIds[0][0] = 1; + operatorSetIds[0][1] = 1; + + // Become operator set AVS + _createOperatorSet(1); + avsDirectory.becomeOperatorSetAVS(); + + // Revert + cheats.expectRevert("AVSDirectory._registerOperatorToOperatorSets: operator already registered to operator set"); + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + } + + function testFuzz_revert_operatorAlreadyRegisteredFromNormalReg(bytes32 salt1, bytes32 salt2) public { + // Register Operator to M2 + address operator = cheats.addr(delegationSignerPrivateKey); + _registerOperatorLegacyM2(delegationSignerPrivateKey, salt1); + + // Format calldata + operators = new address[](1); + operators[0] = operator; + operatorSetIds = new uint32[][](1); + operatorSetIds[0] = new uint32[](1); + operatorSetIds[0][0] = 1; + + // Register Operator To Operator Set - cannot use helper method since it re-registers operator in DM + avsDirectory.becomeOperatorSetAVS(); + _createOperatorSet(1); + uint256 expiry = type(uint256).max; + (uint8 v, bytes32 r, bytes32 s) = cheats.sign( + delegationSignerPrivateKey, + avsDirectory.calculateOperatorSetRegistrationDigestHash(address(this), operatorSetIds[0], salt2, expiry) + ); + avsDirectory.registerOperatorToOperatorSets( + operator, + operatorSetIds[0], + ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), salt2, expiry) + ); + + // Revert + cheats.expectRevert("AVSDirectory._registerOperatorToOperatorSets: operator already registered to operator set"); + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + } + + function testFuzz_Correctness(bytes32 salt) public { + // Register Operator to M2 + address operator = cheats.addr(delegationSignerPrivateKey); + _registerOperatorLegacyM2(delegationSignerPrivateKey, salt); + + // Format calldata + operators = new address[](1); + operators[0] = operator; + operatorSetIds = new uint32[][](1); + operatorSetIds[0] = new uint32[](1); + operatorSetIds[0][0] = 1; + + // Become operator set AVS + avsDirectory.becomeOperatorSetAVS(); + _createOperatorSet(1); + + // Expect Emits + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorAddedToOperatorSet(operator, OperatorSet(address(this), 1)); + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorAVSRegistrationStatusUpdated( + operator, address(this), IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED + ); + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorMigratedToOperatorSets(operator, address(this), operatorSetIds[0]); + + // Migrate + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + + // Checks + assertTrue(avsDirectory.isMember(operator, OperatorSet(address(this), 1))); + assertTrue( + avsDirectory.avsOperatorStatus(address(this), operator) + == IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED + ); + assertEq(avsDirectory.getNumOperatorsInOperatorSet(OperatorSet(address(this), 1)), 1); + } + + function testFuzz_correctness_multiple( + uint256 privateKey, + uint8 numOperators, + bytes32 salt, + uint8 numOids + ) public { + numOperators = uint8(bound(numOperators, 1, 64)); + numOids = uint8(bound(numOids, 1, 32)); + + // Create Operator Set IDs + uint32[] memory oids = new uint32[](numOids); + for (uint32 i = 0; i < numOids; i++) { + oids[i] = i; + } + + // Create Operators, Initailize Calldata, Register Operators + privateKey = bound(privateKey, 1, MAX_PRIVATE_KEY - numOperators); + operators = new address[](numOperators); + operatorSetIds = new uint32[][](numOperators); + for (uint256 i = 0; i < numOperators; i++) { + _registerOperatorLegacyM2(privateKey + i, salt); + operators[i] = cheats.addr(privateKey + i); + operatorSetIds[i] = oids; + } + + // Become operator set AVS + avsDirectory.becomeOperatorSetAVS(); + _createOperatorSets(oids); + + // Expect Emits + for (uint256 i = 0; i < numOperators; i++) { + for (uint256 j = 0; j < oids.length; j++) { + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorAddedToOperatorSet(operators[i], OperatorSet(address(this), oids[j])); + } + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorAVSRegistrationStatusUpdated( + operators[i], address(this), IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED + ); + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorMigratedToOperatorSets(operators[i], address(this), operatorSetIds[i]); + } + + // Migrate + avsDirectory.migrateOperatorsToOperatorSets(operators, operatorSetIds); + + // Checks + for (uint256 i = 0; i < numOperators; i++) { + for (uint256 j = 0; j < oids.length; j++) { + assertTrue(avsDirectory.isMember(operators[i], OperatorSet(address(this), oids[j]))); + } + assertTrue( + avsDirectory.avsOperatorStatus(address(this), operators[i]) + == IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED + ); + + OperatorSet[] memory opSets = avsDirectory.getOperatorSetsOfOperator(operators[i], 0, type(uint256).max); + assertEq(oids.length, opSets.length); + } + + for(uint256 i = 0; i < oids.length; i++) { + address[] memory operatorsInSet = avsDirectory.getOperatorsInOperatorSet(OperatorSet(address(this), oids[i]), 0, type(uint256).max); + assertEq(operatorsInSet.length, operators.length); + } + } + + function _registerOperatorLegacyM2(uint256 privateKey, bytes32 salt) internal { + address operator = cheats.addr(privateKey); + _registerOperatorWithBaseDetails(operator); + + uint256 expiry = type(uint256).max; + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = + _getOperatorAVSRegistrationSignature(privateKey, operator, address(this), salt, expiry); + + avsDirectory.registerOperatorToAVS(operator, operatorSignature); + } +} + +contract AVSDirectoryUnitTests_legacyOperatorAVSRegistration is AVSDirectoryUnitTests { function test_revert_whenRegisterDeregisterToAVSPaused() public { // set the pausing flag cheats.prank(pauser); avsDirectory.pause(2 ** PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS); - cheats.expectRevert(IPausable.CurrentlyPaused.selector); - avsDirectory.registerOperatorToAVS(address(0), ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(""), 0, 0)); + cheats.expectRevert("Pausable: index is paused"); + avsDirectory.registerOperatorToAVS( + address(0), ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(""), 0, 0) + ); + + cheats.expectRevert("Pausable: index is paused"); + avsDirectory.deregisterOperatorFromAVS(address(0)); + } - cheats.expectRevert(IPausable.CurrentlyPaused.selector); + function test_revert_deregisterOperatorFromAVS_operatorNotRegistered() public { + cheats.expectRevert("AVSDirectory.deregisterOperatorFromAVS: operator not registered"); avsDirectory.deregisterOperatorFromAVS(address(0)); } + function test_revert_deregisterOperatorFromAVS_whenAVSISOperatorSetAVS() public { + // Register operator + bytes32 salt = bytes32(0); + address operator = cheats.addr(delegationSignerPrivateKey); + assertFalse(delegationManager.isOperator(operator), "bad test setup"); + _registerOperatorWithBaseDetails(operator); + + uint256 expiry = type(uint256).max; + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + + cheats.startPrank(defaultAVS); + avsDirectory.registerOperatorToAVS(operator, operatorSignature); + + // Become operator set AVS + avsDirectory.becomeOperatorSetAVS(); + + // Deregister operator + cheats.expectRevert("AVSDirectory.deregisterOperatorFromAVS: AVS is an operator set AVS"); + avsDirectory.deregisterOperatorFromAVS(operator); + } + + function testFuzz_deregisterOperatorFromAVS(bytes32 salt) public { + address operator = cheats.addr(delegationSignerPrivateKey); + assertFalse(delegationManager.isOperator(operator), "bad test setup"); + _registerOperatorWithBaseDetails(operator); + + uint256 expiry = type(uint256).max; + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + + cheats.prank(defaultAVS); + avsDirectory.registerOperatorToAVS(operator, operatorSignature); + + cheats.expectEmit(true, true, true, true, address(avsDirectory)); + emit OperatorAVSRegistrationStatusUpdated( + operator, defaultAVS, IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED + ); + + cheats.prank(defaultAVS); + avsDirectory.deregisterOperatorFromAVS(operator); + + assertTrue( + avsDirectory.avsOperatorStatus(defaultAVS, operator) + == IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED + ); + } + // @notice Tests that an avs who calls `updateAVSMetadataURI` will correctly see an `AVSMetadataURIUpdated` event emitted with their input function testFuzz_UpdateAVSMetadataURI(string memory metadataURI) public { // call `updateAVSMetadataURI` and check for event @@ -192,6 +1295,25 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni avsDirectory.updateAVSMetadataURI(metadataURI); } + function testFuzz_revert_whenAVSIsOperatorSetAVS(bytes32 salt) public { + // set the AVS to be an operator set AVS + cheats.prank(defaultAVS); + avsDirectory.becomeOperatorSetAVS(); + + // Register Operator to EigenLayer + address operator = cheats.addr(delegationSignerPrivateKey); + assertFalse(delegationManager.isOperator(operator), "bad test setup"); + _registerOperatorWithBaseDetails(operator); + + uint256 expiry = type(uint256).max; + + cheats.prank(defaultAVS); + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + cheats.expectRevert("AVSDirectory.registerOperatorToAVS: AVS is an operator set AVS"); + avsDirectory.registerOperatorToAVS(operator, operatorSignature); + } + // @notice Verifies an operator registers successfull to avs and see an `OperatorAVSRegistrationStatusUpdated` event emitted function testFuzz_registerOperatorToAVS(bytes32 salt) public { address operator = cheats.addr(delegationSignerPrivateKey); @@ -207,9 +1329,14 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni cheats.prank(defaultAVS); ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); avsDirectory.registerOperatorToAVS(operator, operatorSignature); + + assertTrue( + avsDirectory.avsOperatorStatus(defaultAVS, operator) + == IAVSDirectory.OperatorAVSRegistrationStatus.REGISTERED + ); } // @notice Verifies an operator registers successfull to avs and see an `OperatorAVSRegistrationStatusUpdated` event emitted @@ -220,9 +1347,9 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni cheats.prank(defaultAVS); uint256 expiry = type(uint256).max; ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); - cheats.expectRevert(IAVSDirectory.OperatorDoesNotExist.selector); + cheats.expectRevert("AVSDirectory.registerOperatorToAVS: operator not registered to EigenLayer yet"); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } @@ -234,21 +1361,21 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni uint256 expiry = type(uint256).max; ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); - cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEOA.selector); + cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer"); cheats.prank(operator); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } // @notice Verifies an operator registers fails when the signature expiry already expires - function testFuzz_revert_whenExpiryHasExpired( - ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature - ) public { + function testFuzz_revert_whenExpiryHasExpired(ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature) + public + { address operator = cheats.addr(delegationSignerPrivateKey); operatorSignature.expiry = bound(operatorSignature.expiry, 0, block.timestamp - 1); - cheats.expectRevert(IAVSDirectory.SignatureExpired.selector); + cheats.expectRevert("AVSDirectory.registerOperatorToAVS: operator signature expired"); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } @@ -260,12 +1387,12 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni uint256 expiry = type(uint256).max; ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); cheats.startPrank(defaultAVS); avsDirectory.registerOperatorToAVS(operator, operatorSignature); - cheats.expectRevert(IAVSDirectory.OperatorAlreadyRegistered.selector); + cheats.expectRevert("AVSDirectory.registerOperatorToAVS: operator already registered"); avsDirectory.registerOperatorToAVS(operator, operatorSignature); cheats.stopPrank(); } @@ -283,10 +1410,14 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni avsDirectory.cancelSalt(salt); assertTrue(avsDirectory.operatorSaltIsSpent(operator, salt), "salt was not successfully cancelled"); - assertFalse(avsDirectory.operatorSaltIsSpent(defaultAVS, salt), "salt should only be cancelled for the operator"); + assertFalse( + avsDirectory.operatorSaltIsSpent(defaultAVS, salt), "salt should only be cancelled for the operator" + ); - bytes32 newSalt; - unchecked { newSalt = bytes32(uint(salt) + 1); } + bytes32 newSalt; + unchecked { + newSalt = bytes32(uint256(salt) + 1); + } assertFalse(salt == newSalt, "bad test setup"); @@ -305,12 +1436,26 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni uint256 expiry = type(uint256).max; ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); cheats.prank(operator); avsDirectory.cancelSalt(salt); - cheats.expectRevert(IAVSDirectory.SignatureSaltSpent.selector); + cheats.expectRevert("AVSDirectory.registerOperatorToAVS: salt already spent"); + cheats.prank(defaultAVS); + avsDirectory.registerOperatorToAVS(operator, operatorSignature); + } + + /// @notice Verifies that an operator cannot cancel the same salt twice + function testFuzz_revert_whenCancellingSaltUsedToRegister(bytes32 salt) public { + address operator = cheats.addr(delegationSignerPrivateKey); + assertFalse(delegationManager.isOperator(operator), "bad test setup"); + _registerOperatorWithBaseDetails(operator); + + uint256 expiry = type(uint256).max; + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = + _getOperatorAVSRegistrationSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + cheats.prank(defaultAVS); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } diff --git a/src/test/unit/DelegationUnit.t.sol b/src/test/unit/DelegationUnit.t.sol index 67b74a9bd..b12a59635 100644 --- a/src/test/unit/DelegationUnit.t.sol +++ b/src/test/unit/DelegationUnit.t.sol @@ -523,11 +523,6 @@ contract DelegationManagerUnitTests_Initialization_Setters is DelegationManagerU address(strategyManagerMock), "constructor / initializer incorrect, strategyManager set wrong" ); - assertEq( - address(delegationManager.slasher()), - address(slasherMock), - "constructor / initializer incorrect, slasher set wrong" - ); assertEq( address(delegationManager.pauserRegistry()), address(pauserRegistry), diff --git a/src/test/unit/EigenPodManagerUnit.t.sol b/src/test/unit/EigenPodManagerUnit.t.sol index b86eddb41..989f8a3c2 100644 --- a/src/test/unit/EigenPodManagerUnit.t.sol +++ b/src/test/unit/EigenPodManagerUnit.t.sol @@ -117,7 +117,6 @@ contract EigenPodManagerUnitTests_Initialization_Setters is EigenPodManagerUnitT assertEq(address(eigenPodManager.ethPOS()), address(ethPOSMock), "Initialization: ethPOS incorrect"); assertEq(address(eigenPodManager.eigenPodBeacon()), address(eigenPodBeacon), "Initialization: eigenPodBeacon incorrect"); assertEq(address(eigenPodManager.strategyManager()), address(strategyManagerMock), "Initialization: strategyManager incorrect"); - assertEq(address(eigenPodManager.slasher()), address(slasherMock), "Initialization: slasher incorrect"); assertEq(address(eigenPodManager.delegationManager()), address(delegationManagerMock), "Initialization: delegationManager incorrect"); }