IDelegationManager
Inherits: ISignatureUtils
Author: Layr Labs, Inc.
Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
This is the contract for delegation in EigenLayer. The main functionalities of this contract are
enabling anyone to register as an operator in EigenLayer
allowing operators to specify parameters related to stakers who delegate to them
enabling any staker to delegate its stake to the operator of its choice (a given staker can only delegate to a single operator at a time)
enabling a staker to undelegate its assets from the operator it is delegated to (performed as part of the withdrawal process, initiated through the StrategyManager)
Functions
registerAsOperator
Registers the caller as an operator in EigenLayer.
Once an operator is registered, they cannot 'deregister' as an operator, and they will forever be considered "delegated to themself".
This function will revert if the caller attempts to set their earningsReceiver
to address(0).
*Note that the metadataURI
is never stored * and is only emitted in the OperatorMetadataURIUpdated
event
Parameters
modifyOperatorDetails
Updates an operator's stored OperatorDetails
.
The caller must have previously registered as an operator in EigenLayer.
This function will revert if the caller attempts to set their earningsReceiver
to address(0).
Parameters
updateOperatorMetadataURI
Called by an operator to emit an OperatorMetadataURIUpdated
event indicating the information has updated.
Parameters
delegateTo
Caller delegates their stake to an operator.
*The approverSignatureAndExpiry is used in the event that:
the operator's
delegationApprover
address is set to a non-zero value. ANDneither the operator nor their
delegationApprover
is themsg.sender
, since in the event that the operator or their delegationApprover is themsg.sender
, then approval is assumed.*
In the event that approverSignatureAndExpiry
is not checked, its content is ignored entirely; it's recommended to use an empty input in this case to save on complexity + gas costs
Parameters
delegateToBySignature
Caller delegates a staker's stake to an operator with valid signatures from both parties.
If staker
is an EOA, then stakerSignature
is verified to be a valid ECDSA stakerSignature from staker
, indicating their intention for this action.
If staker
is a contract, then stakerSignature
will be checked according to EIP-1271.
the operator's delegationApprover
address is set to a non-zero value.
neither the operator nor their delegationApprover
is the msg.sender
, since in the event that the operator or their delegationApprover is the msg.sender
, then approval is assumed.
This function will revert if the current block.timestamp
is equal to or exceeds the expiry
In the case that approverSignatureAndExpiry
is not checked, its content is ignored entirely; it's recommended to use an empty input in this case to save on complexity + gas costs
Parameters
undelegate
Undelegates the staker from the operator who they are delegated to. Puts the staker into the "undelegation limbo" mode of the EigenPodManager and queues a withdrawal of all of the staker's shares in the StrategyManager (to the staker), if necessary.
Reverts if the staker
is also an operator, since operators are not allowed to undelegate from themselves.
Reverts if the caller is not the staker, nor the operator who the staker is delegated to, nor the operator's specified "delegationApprover"
Reverts if the staker
is already undelegated.
Parameters
Returns
queueWithdrawals
Allows a staker to withdraw some shares. Withdrawn shares/strategies are immediately removed from the staker. If the staker is delegated, withdrawn shares/strategies are also removed from their operator. All withdrawn shares/strategies are placed in a queue and can be fully withdrawn after a delay.
completeQueuedWithdrawal
Used to complete the specified withdrawal
. The caller must match withdrawal.withdrawer
middlewareTimesIndex should be calculated off chain before calling this function by finding the first index that satisfies slasher.canWithdraw
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.
Parameters
completeQueuedWithdrawals
Array-ified version of completeQueuedWithdrawal
. Used to complete the specified withdrawals
. The function caller must match withdrawals[...].withdrawer
See completeQueuedWithdrawal
for relevant dev tags
Parameters
increaseDelegatedShares
Increases a staker's delegated share balance in a strategy.
If the staker is actively delegated, then increases the staker
's delegated shares in strategy
by shares
. Otherwise does nothing.
Callable only by the StrategyManager or EigenPodManager.
Parameters
decreaseDelegatedShares
Decreases a staker's delegated share balance in a strategy.
If the staker is actively delegated, then decreases the staker
's delegated shares in strategy
by shares
. Otherwise does nothing.
Callable only by the StrategyManager or EigenPodManager.
Parameters
stakeRegistry
the address of the StakeRegistry contract to call for stake updates when operator shares are changed
delegatedTo
returns the address of the operator that staker
is delegated to.
Mapping: staker => operator whom the staker is currently delegated to.
Note that returning address(0) indicates that the staker is not actively delegated to any operator.
operatorDetails
Returns the OperatorDetails struct associated with an operator
.
earningsReceiver
Returns the earnings receiver address for an operator
delegationApprover
Returns the delegationApprover account for an operator
stakerOptOutWindowBlocks
Returns the stakerOptOutWindowBlocks for an operator
operatorShares
returns the total number of shares in strategy
that are delegated to operator
.
Mapping: operator => strategy => total number of shares in the strategy delegated to the operator.
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)
isDelegated
Returns 'true' if staker
is actively delegated, and 'false' otherwise.
isOperator
Returns true is an operator has previously registered for delegation.
stakerNonce
Mapping: staker => number of signed delegation nonces (used in delegateToBySignature
) from the staker that the contract has already checked
delegationApproverSaltIsSpent
Mapping: delegationApprover => 32-byte salt => whether or not the salt has already been used by the delegationApprover.
Salts are used in the delegateTo
and delegateToBySignature
functions. Note that these functions only process the delegationApprover's signature + the provided salt if the operator being delegated to has specified a nonzero address as their delegationApprover
.
calculateCurrentStakerDelegationDigestHash
Calculates the digestHash for a staker
to sign to delegate to an operator
Parameters
calculateStakerDelegationDigestHash
Calculates the digest hash to be signed and used in the delegateToBySignature
function
Parameters
calculateDelegationApprovalDigestHash
Calculates the digest hash to be signed by the operator's delegationApprove and used in the delegateTo
and delegateToBySignature
functions.
Parameters
DOMAIN_TYPEHASH
The EIP-712 typehash for the contract's domain
STAKER_DELEGATION_TYPEHASH
The EIP-712 typehash for the StakerDelegation struct used by the contract
DELEGATION_APPROVAL_TYPEHASH
The EIP-712 typehash for the DelegationApproval struct used by the contract
domainSeparator
Getter function for the current EIP-712 domain separator for this contract.
The domain separator will change in the event of a fork that changes the ChainID.
By introducing a domain separator the DApp developers are guaranteed that there can be no signature collision. for more detailed information please read EIP-712.
cumulativeWithdrawalsQueued
Mapping: staker => cumulative number of queued withdrawals they have ever initiated.
This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes.
calculateWithdrawalRoot
Returns the keccak256 hash of withdrawal
.
Events
StakeRegistrySet
Emitted when the StakeRegistry is set
OperatorRegistered
Emitted when a new operator registers in EigenLayer and provides their OperatorDetails.
OperatorDetailsModified
Emitted when an operator updates their OperatorDetails to @param newOperatorDetails
OperatorMetadataURIUpdated
Emitted when @param operator indicates that they are updating their MetadataURI string
Note that these strings are never stored in storage and are instead purely emitted in events for off-chain indexing
OperatorSharesIncreased
Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares.
OperatorSharesDecreased
Emitted whenever an operator's shares are decreased for a given strategy. Note that shares is the delta in the operator's shares.
StakerDelegated
Emitted when @param staker delegates to @param operator.
StakerUndelegated
Emitted when @param staker undelegates from @param operator.
StakerForceUndelegated
Emitted when @param staker is undelegated via a call not originating from the staker themself
WithdrawalQueued
Emitted when a new withdrawal is queued.
Parameters
WithdrawalCompleted
Emitted when a queued withdrawal is completed
WithdrawalMigrated
Emitted when a queued withdrawal is migrated from the StrategyManager to the DelegationManager
WithdrawalDelayBlocksSet
Emitted when the withdrawalDelayBlocks
variable is modified from previousValue
to newValue
.
Structs
OperatorDetails
Struct used for storing information about a single operator who has registered with EigenLayer
StakerDelegation
Abstract struct used in calculating an EIP712 signature for a staker to approve that they (the staker themselves) delegate to a specific operator.
Used in computing the STAKER_DELEGATION_TYPEHASH
and as a reference in the computation of the stakerDigestHash in the delegateToBySignature
function.
DelegationApproval
Abstract struct used in calculating an EIP712 signature for an operator's delegationApprover to approve that a specific staker delegate to the operator.
Used in computing the DELEGATION_APPROVAL_TYPEHASH
and as a reference in the computation of the approverDigestHash in the _delegate
function.
Withdrawal
Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored. In functions that operate on existing queued withdrawals -- e.g. completeQueuedWithdrawal, the data is resubmitted and the hash of the submitted data is computed by
calculateWithdrawalRoot` and checked against the stored hash in order to confirm the integrity of the submitted data.
QueuedWithdrawalParams
Last updated