Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x0F21C25f...f9Aa5183a The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
ServiceManager
Compiler Version
v0.8.12+commit.f00d7308
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.12; import {OwnableUpgradeable} from "openzeppelin-upgradeable/access/OwnableUpgradeable.sol"; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {ECDSA} from "openzeppelin/utils/cryptography/ECDSA.sol"; import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; import {IServiceManager, DTMTaskParams, STMTaskParams} from "./interfaces/IServiceManager.sol"; contract ServiceManager is IServiceManager, OwnableUpgradeable { error ServiceManager__Unauthorized(); error ServiceManager__InvalidOperator(); error ServiceManager__InvalidStrategy(); error ServiceManager__InvalidTask(); error ServiceManager__InvalidPolicy(); error ServiceManager__CallFailed(); error ServiceManager__ArrayLengthMismatch(); enum OperatorStatus { NEVER_REGISTERED, // default is NEVER_REGISTERED REGISTERED, DEREGISTERED } struct OperatorInfo { uint256 totalStake; OperatorStatus status; } uint256 public taskCounter; uint256 public thresholdStake; address public aggregator; address public delegationManager; address public stakeRegistry; address public avsDirectory; address[] public strategies; mapping(address => bool) public operatorCanRegister; mapping(address => OperatorInfo) public operators; mapping(bytes32 => bool) public pendingTasks; mapping(address => mapping(string => bool)) public clientToPolicy; mapping(string => string) public idToPolicy; string[] public deployedPolicies; mapping(string => string) public idToSocialGraph; string[] public socialGraphIDs; mapping(address => address) public signingKeyToOperator; event SetPolicy(address indexed client, string indexed policyID); event DeployedPolicy(string indexed policyID, string policy); event RemovedPolicy(address indexed client, string indexed policyID); event OperatorRegistered(address indexed operator); event OperatorRemoved(address indexed operator); event StrategyAdded(address indexed strategy); event StrategyRemoved(address indexed strategy); event TaskExecuted(bytes32 indexed taskHash); event NewTask(address indexed sender, uint256 indexed taskID, DTMTaskParams params); event OperatorsStakesUpdated(address[][] indexed operatorsPerQuorum, bytes indexed quorumNumbers); event NonCompliantTask(uint256 indexed taskID); event AggregatorUpdated(address indexed aggregator); event AVSDirectoryUpdated(address indexed avsDirectory); event ThresholdStakeUpdated(uint256 indexed thresholdStake); event DelegationManagerUpdated(address indexed delegationManager); event StakeRegistryUpdated(address indexed stakeRegistry); event SocialGraphDeployed(string indexed socialGraphID, string socialGraphConfig); modifier onlyAggregator() { if (msg.sender != aggregator) { revert ServiceManager__Unauthorized(); } _; } constructor() { _disableInitializers(); } function initialize( address _owner, address _aggregator, address _delegationManager, address _stakeRegistry, address _avsDirectory, uint256 _thresholdStake ) public initializer { _transferOwnership(_owner); aggregator = _aggregator; delegationManager = _delegationManager; stakeRegistry = _stakeRegistry; avsDirectory = _avsDirectory; thresholdStake = _thresholdStake; } /** * @notice Sets the aggregator address on contracts * @param _aggregator is the aggregator that can execute the callback * @dev only callable by the owner */ function setAggregator(address _aggregator) public virtual onlyOwner { aggregator = _aggregator; emit AggregatorUpdated(aggregator); } /** * @notice Sets the delegationManager contract address * @param _delegationManager is the delegationManager on the eigenlayer contracts * @dev only callable by the owner */ function setDelegationManager(address _delegationManager) public virtual onlyOwner { delegationManager = _delegationManager; emit DelegationManagerUpdated(delegationManager); } /** * @notice Sets the stakeRegistry contract address * @param _stakeRegistry is the stakeRegistry on the eigenlayer contracts * @dev only callable by the owner */ function setStakeRegistry(address _stakeRegistry) public virtual onlyOwner { stakeRegistry = _stakeRegistry; emit StakeRegistryUpdated(stakeRegistry); } /** * @notice Sets the avsDirectory contract address * @param _avsDirectory is the avsDirectory on the eigenlayer contracts * @dev only callable by the owner */ function setAVSDirectory(address _avsDirectory) public virtual onlyOwner { avsDirectory = _avsDirectory; emit AVSDirectoryUpdated(avsDirectory); } /** * @notice Sets threshold stake. * @dev Has modifiers: onlyOwner. * @param _thresholdStake The threshold stake (uint256). */ function setThresholdStake(uint256 _thresholdStake) external onlyOwner { thresholdStake = _thresholdStake; emit ThresholdStakeUpdated(thresholdStake); } /** * @notice Sets the metadata URI for the AVS * @param _metadataURI is the metadata URI for the AVS * @dev only callable by the owner */ function setMetadataURI(string memory _metadataURI) public virtual onlyOwner { IAVSDirectory(avsDirectory).updateAVSMetadataURI(_metadataURI); } /** * @notice Enables the rotation of Aethos Signing Key for an operator * @param _operator address of the operator to rotate the signing key for * @param _oldSigningKey address of the old signing key to remove * @param _newSigningKey address of the new signing key to add */ function rotateAethosSigningKey( address _operator, address _oldSigningKey, address _newSigningKey ) external onlyOwner { require( operators[_operator].status == OperatorStatus.REGISTERED, "ServiceManager.rotateAethosSigningKey: operator is not registered" ); delete signingKeyToOperator[_oldSigningKey]; signingKeyToOperator[_newSigningKey] = _operator; } /** * @notice Registers a new operator * @param _operatorSigningKey address of the operator signing key * @param _operatorSignature signature used for validation */ function registerOperatorToAVS( address _operatorSigningKey, ISignatureUtils.SignatureWithSaltAndExpiry memory _operatorSignature ) external { uint256 totalStake; for (uint256 i; i != strategies.length;) { totalStake += IDelegationManager(delegationManager).operatorShares(msg.sender, IStrategy(strategies[i])); unchecked { ++i; } } if (totalStake >= thresholdStake) { operators[msg.sender] = OperatorInfo(totalStake, OperatorStatus.REGISTERED); signingKeyToOperator[_operatorSigningKey] = msg.sender; IAVSDirectory(avsDirectory).registerOperatorToAVS(msg.sender, _operatorSignature); emit OperatorRegistered(msg.sender); } } /** * @notice Removes an operator * @param _operator the address of the operator to be removed */ function deregisterOperatorFromAVS(address _operator) external onlyOwner { require( operators[_operator].status != OperatorStatus.NEVER_REGISTERED, "ServiceManager.deregisterOperatorFromAVS: operator is not registered" ); operators[_operator] = OperatorInfo(0, OperatorStatus.DEREGISTERED); IAVSDirectory(avsDirectory).deregisterOperatorFromAVS(_operator); emit OperatorRemoved(_operator); } /** * @notice Deploys a policy for which clients can use * @param _policyID is a unique identifier * @param _policy is set of formatted rules */ function deployPolicy(string memory _policyID, string memory _policy) external onlyOwner { require(bytes(idToPolicy[_policyID]).length == 0, "ServiceManager.deployPolicy: policy exists"); idToPolicy[_policyID] = _policy; deployedPolicies.push(_policyID); emit DeployedPolicy(_policyID, _policy); } /** * @notice Deploys a social graph which clients can use in policy * @param _socialGraphID is a unique identifier * @param _socialGraphConfig is the config for the social graph */ function deploySocialGraph(string memory _socialGraphID, string memory _socialGraphConfig) external onlyOwner { require( bytes(idToSocialGraph[_socialGraphID]).length == 0, "ServiceManager.deploySocialGraph: social graph exists" ); idToSocialGraph[_socialGraphID] = _socialGraphConfig; socialGraphIDs.push(_socialGraphID); emit SocialGraphDeployed(_socialGraphID, _socialGraphConfig); } /** * @notice Gets array of deployed policies * @return array of deployed policies */ function getDeployedPolicies() external view returns (string[] memory) { return deployedPolicies; } /** * @notice Gets array of social graph IDs * @return array of social graph IDs */ function getSocialGraphIDs() external view returns (string[] memory) { return socialGraphIDs; } /** * @notice Sets a policy for a client * @param _policyID address of the Pod */ function setPolicy(string memory _policyID) external { clientToPolicy[msg.sender][_policyID] = true; emit SetPolicy(msg.sender, _policyID); } /** * @notice Removes a policy for a client * @param _policyID address of the Pod */ function removePolicy(string memory _policyID) external { clientToPolicy[msg.sender][_policyID] = false; emit RemovedPolicy(msg.sender, _policyID); } /** * @notice Submits task to be executed by operators * @param _params parameters of the task * @return taskID the id of the new task */ function submitTask(DTMTaskParams calldata _params) external returns (uint256 taskID) { bool hasPolicy = clientToPolicy[msg.sender][_params.policyID]; if (!hasPolicy) { revert ServiceManager__InvalidPolicy(); } taskID = ++taskCounter; pendingTasks[hashTask(taskID, _params)] = true; emit NewTask(msg.sender, taskID, _params); } /** * @notice Executes task submitted by client and validated by operators * @param _params the params of the task * @param _taskID the id of the task to be executed * @param signatures the signatures of the operators */ function executeTask( DTMTaskParams calldata _params, uint256 _taskID, bytes[] memory signatures ) external onlyAggregator { bytes32 taskHash = hashTask(_taskID, _params); if (pendingTasks[taskHash] == false || !_validateSignaturesDTM(_params, signatures, taskHash)) { revert ServiceManager__InvalidTask(); } bytes memory callData = abi.encodePacked(_params.functionSig, _params.functionArgs); (bool success,) = _params.target.call(callData); if (!success) { revert ServiceManager__CallFailed(); } pendingTasks[taskHash] = false; emit TaskExecuted(taskHash); } /** * @notice Executes noncompliant task submitted by client and validated by operators * @param _params the params of the task * @param _taskID the id of the task to be executed * @param signatures the signatures of the operators */ function recordNonCompliantTask( DTMTaskParams calldata _params, uint256 _taskID, bytes[] memory signatures ) external onlyAggregator { bytes32 taskHash = hashTask(_taskID, _params); if (pendingTasks[taskHash] == false || !_validateSignaturesDTM(_params, signatures, taskHash)) { revert ServiceManager__InvalidTask(); } pendingTasks[taskHash] = false; emit NonCompliantTask(_taskID); } /** * @notice Validates signatures using the OpenZeppelin ECDSA library for the Aethos Dual Transaction Model * @param _params the params of the task * @param signatures the signatures of the operators */ function _validateSignaturesDTM( DTMTaskParams memory _params, bytes[] memory signatures, bytes32 taskHash ) internal view returns (bool) { for (uint256 i; i != _params.quorumThresholdCount;) { address recoveredSigner = ECDSA.recover(taskHash, signatures[i]); address operator = signingKeyToOperator[recoveredSigner]; require(operators[operator].status == OperatorStatus.REGISTERED, "Signer is not a registered operator"); unchecked { ++i; } } return true; } /** * @notice Validates signatures using the OpenZeppelin ECDSA library for the Aethos Single Transaction Model * @param _params the params of the task * @param signerAddresses the addresses of the operators * @param signatures the signatures of the operators */ function validateSignaturesSTM( STMTaskParams calldata _params, address[] memory signerAddresses, bytes[] memory signatures ) external view returns (bool isVerified) { require(signerAddresses.length == signatures.length, "Mismatch between signers and signatures"); require(block.number <= _params.expireByBlockNumber, "ServiceManager.AethosVerified: transaction expired"); bytes32 messageHash = hashTaskWithExpiry(_params); for (uint256 i = 0; i < _params.quorumThresholdCount;) { if (i > 0 && uint160(signerAddresses[i]) <= uint160(signerAddresses[i - 1])) { revert("Signer addresses must be unique and sorted"); } address recoveredSigner = ECDSA.recover(messageHash, signatures[i]); require(recoveredSigner == signerAddresses[i], "Invalid signature"); address operator = signingKeyToOperator[recoveredSigner]; require(operators[operator].status == OperatorStatus.REGISTERED, "Signer is not a registered operator"); unchecked { ++i; } } return true; } /** * @notice Adds a new strategy * @param _strategy address of the strategy to add * @param quorumNumber uint8 denoting the quorum number * @param index uint256 denoting the index for the strategy */ function addStrategy(address _strategy, uint8 quorumNumber, uint256 index) external onlyOwner { IStakeRegistry.StrategyParams memory strategyParams = IStakeRegistry(stakeRegistry).strategyParamsByIndex(quorumNumber, index); if (address(strategyParams.strategy) != _strategy) { revert ServiceManager__InvalidStrategy(); } strategies.push(_strategy); emit StrategyAdded(_strategy); } /** * @notice Removes a strategy * @param _strategy address of the strategy to be removed */ function removeStrategy(address _strategy) external onlyOwner { for (uint256 i = 0; i != strategies.length;) { if (strategies[i] == _strategy) { strategies[i] = strategies[strategies.length - 1]; strategies.pop(); emit StrategyRemoved(_strategy); break; } unchecked { ++i; } } } /** * @notice Performs the hashing of a DTM task * @param _taskID id of the task * @param _params parameters of the task * @return taskHash the hash of the task */ function hashTask(uint256 _taskID, DTMTaskParams calldata _params) public pure returns (bytes32) { return keccak256( abi.encode( _taskID, _params.msgSender, _params.target, _params.functionSig, _params.functionArgs, _params.policyID, _params.quorumThresholdCount ) ); } /** * @notice Performs the hashing of an STM task * @param _params parameters of the task * @return taskHash the hash of the task */ function hashTaskWithExpiry(STMTaskParams calldata _params) public pure returns (bytes32) { return keccak256( abi.encode( _params.taskId, _params.msgSender, _params.target, _params.functionSig, _params.functionArgs, _params.policyID, _params.quorumThresholdCount, _params.expireByBlockNumber ) ); } /** * @notice Returns the list of strategies that the AVS supports for restaking * @dev This function is intended to be called off-chain * @dev No guarantee is made on uniqueness of each element in the returned array. * The off-chain service should do that validation separately */ function getRestakeableStrategies() external view returns (address[] memory) { return strategies; } /** * @notice Returns the list of strategies that the operator has potentially restaked on the AVS * @param operator The address of the operator to get restaked strategies for * @dev This function is intended to be called off-chain * @dev No guarantee is made on whether the operator has shares for a strategy in a quorum or uniqueness * of each element in the returned array. The off-chain service should do that validation separately */ function getOperatorRestakedStrategies(address operator) external view returns (address[] memory) { address[] memory restakedStrategies = new address[](strategies.length); uint256 index = 0; for (uint256 i = 0; i < strategies.length; i++) { if (IDelegationManager(delegationManager).operatorShares(operator, IStrategy(strategies[i])) > 0) { restakedStrategies[index] = strategies[i]; index++; } } return restakedStrategies; } /** * @notice Updates the stakes of all operators for each of the specified quorums in the StakeRegistry. Each quorum also * has their quorumUpdateBlockNumber updated. which is meant to keep track of when operators were last all updated at once. * @param operatorsPerQuorum is an array of arrays of operators to update for each quorum. Note that each nested array * of operators must be sorted in ascending address order to ensure that all operators in the quorum are updated * @param quorumNumbers is an array of quorum numbers to update * @dev This method is used to update the stakes of all operators in a quorum at once, rather than individually. Performs * sanitization checks on the input array lengths, quorumNumbers existing, and that quorumNumbers are ordered. Function must * also not be paused by the PAUSED_UPDATE_OPERATOR flag. */ function updateOperatorsForQuorum(address[][] calldata operatorsPerQuorum, bytes calldata quorumNumbers) external { if (operatorsPerQuorum.length != quorumNumbers.length) { revert ServiceManager__ArrayLengthMismatch(); } address[] memory currQuorumOperators; address currOperatorAddress; OperatorInfo storage currOperator; for (uint256 i; i != quorumNumbers.length;) { currQuorumOperators = operatorsPerQuorum[i]; for (uint256 j; j < currQuorumOperators.length;) { currOperatorAddress = currQuorumOperators[j]; currOperator = operators[currOperatorAddress]; if (currOperator.status == OperatorStatus.NEVER_REGISTERED) { revert ServiceManager__InvalidOperator(); } // for all strategies calculate the new stake uint256 totalStake; for (uint256 k; k != strategies.length;) { totalStake += IDelegationManager(delegationManager).operatorShares( currOperatorAddress, IStrategy(strategies[k]) ); unchecked { ++k; } } currOperator.totalStake = totalStake; currOperator.status = totalStake < thresholdStake ? OperatorStatus.DEREGISTERED : OperatorStatus.REGISTERED; unchecked { ++j; } } unchecked { ++i; } } emit OperatorsStakesUpdated(operatorsPerQuorum, quorumNumbers); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @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[49] private __gap; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "./IStrategy.sol"; import "./ISignatureUtils.sol"; import "./IStrategyManager.sol"; /** * @title DelegationManager * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service * @notice 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) */ interface IDelegationManager is ISignatureUtils { // @notice Struct used for storing information about a single operator who has registered with EigenLayer struct OperatorDetails { // @notice address to receive the rewards that the operator earns via serving applications built on EigenLayer. address earningsReceiver; /** * @notice Address to verify signatures when a staker wishes to delegate to the operator, as well as controlling "forced undelegations". * @dev Signature verification follows these rules: * 1) If this address is left as address(0), then any staker will be free to delegate to the operator, i.e. no signature verification will be performed. * 2) If this address is an EOA (i.e. it has no code), then we follow standard ECDSA signature verification for delegations to the operator. * 3) If this address is a contract (i.e. it has code) then we forward a call to the contract and verify that it returns the correct EIP-1271 "magic value". */ address delegationApprover; /** * @notice A minimum delay -- measured in blocks -- enforced between: * 1) the operator signalling their intent to register for a service, via calling `Slasher.optIntoSlashing` * and * 2) the operator completing registration for the service, via the service ultimately calling `Slasher.recordFirstStakeUpdate` * @dev note that for a specific operator, this value *cannot decrease*, i.e. if the operator wishes to modify their OperatorDetails, * then they are only allowed to either increase this value or keep it the same. */ uint32 stakerOptOutWindowBlocks; } /** * @notice Abstract struct used in calculating an EIP712 signature for a staker to approve that they (the staker themselves) delegate to a specific operator. * @dev Used in computing the `STAKER_DELEGATION_TYPEHASH` and as a reference in the computation of the stakerDigestHash in the `delegateToBySignature` function. */ struct StakerDelegation { // the staker who is delegating address staker; // the operator being delegated to address operator; // the staker's nonce uint256 nonce; // the expiration timestamp (UTC) of the signature uint256 expiry; } /** * @notice Abstract struct used in calculating an EIP712 signature for an operator's delegationApprover to approve that a specific staker delegate to the operator. * @dev Used in computing the `DELEGATION_APPROVAL_TYPEHASH` and as a reference in the computation of the approverDigestHash in the `_delegate` function. */ struct DelegationApproval { // the staker who is delegating address staker; // the operator being delegated to address operator; // the operator's provided salt bytes32 salt; // the expiration timestamp (UTC) of the signature uint256 expiry; } /** * 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. */ struct Withdrawal { // The address that originated the Withdrawal address staker; // The address that the staker was delegated to at the time that the Withdrawal was created address delegatedTo; // The address that can complete the Withdrawal + will receive funds when completing the withdrawal address withdrawer; // Nonce used to guarantee that otherwise identical withdrawals have unique hashes uint256 nonce; // Block number when the Withdrawal was created uint32 startBlock; // Array of strategies that the Withdrawal contains IStrategy[] strategies; // Array containing the amount of shares in each Strategy in the `strategies` array uint256[] shares; } 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; // The address of the withdrawer address withdrawer; } // @notice Emitted when a new operator registers in EigenLayer and provides their OperatorDetails. event OperatorRegistered(address indexed operator, OperatorDetails operatorDetails); /// @notice Emitted when an operator updates their OperatorDetails to @param newOperatorDetails event OperatorDetailsModified(address indexed operator, OperatorDetails newOperatorDetails); /** * @notice Emitted when @param operator 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 */ 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); /// @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); /// @notice Emitted when @param staker delegates to @param operator. event StakerDelegated(address indexed staker, address indexed operator); /// @notice Emitted when @param staker undelegates from @param operator. event StakerUndelegated(address indexed staker, address indexed operator); /// @notice Emitted when @param staker is undelegated via a call not originating from the staker themself event StakerForceUndelegated(address indexed staker, address indexed operator); /** * @notice Emitted when a new withdrawal is queued. * @param withdrawalRoot Is the hash of the `withdrawal`. * @param withdrawal Is the withdrawal itself. */ event WithdrawalQueued(bytes32 withdrawalRoot, Withdrawal withdrawal); /// @notice Emitted when a queued withdrawal is completed event WithdrawalCompleted(bytes32 withdrawalRoot); /// @notice Emitted when a queued withdrawal is *migrated* from the StrategyManager to the DelegationManager event WithdrawalMigrated(bytes32 oldWithdrawalRoot, bytes32 newWithdrawalRoot); /// @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 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". * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0). * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event */ function registerAsOperator( OperatorDetails calldata registeringOperatorDetails, string calldata metadataURI ) external; /** * @notice Updates an operator's stored `OperatorDetails`. * @param newOperatorDetails is the updated `OperatorDetails` for the operator, to replace their current OperatorDetails`. * * @dev The caller must have previously registered as an operator in EigenLayer. * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0). */ function modifyOperatorDetails(OperatorDetails calldata newOperatorDetails) external; /** * @notice Called by an operator to emit an `OperatorMetadataURIUpdated` event indicating the information has updated. * @param metadataURI The URI for metadata associated with an operator * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event */ function updateOperatorMetadataURI(string calldata metadataURI) external; /** * @notice Caller delegates their stake to an operator. * @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer. * @param approverSignatureAndExpiry Verifies the operator approves of this delegation * @param approverSalt A unique single use value tied to an individual signature. * @dev The approverSignatureAndExpiry is used in the event that: * 1) the operator's `delegationApprover` address is set to a non-zero value. * AND * 2) 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. * @dev 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 */ function delegateTo( address operator, SignatureWithExpiry memory approverSignatureAndExpiry, bytes32 approverSalt ) external; /** * @notice Caller delegates a staker's stake to an operator with valid signatures from both parties. * @param staker The account delegating stake to an `operator` account * @param operator The account (`staker`) is delegating its assets to for use in serving applications built on EigenLayer. * @param stakerSignatureAndExpiry Signed data from the staker authorizing delegating stake to an operator * @param approverSignatureAndExpiry is a parameter that will be used for verifying that the operator approves of this delegation action in the event that: * @param approverSalt Is a salt used to help guarantee signature uniqueness. Each salt can only be used once by a given approver. * * @dev If `staker` is an EOA, then `stakerSignature` is verified to be a valid ECDSA stakerSignature from `staker`, indicating their intention for this action. * @dev If `staker` is a contract, then `stakerSignature` will be checked according to EIP-1271. * @dev the operator's `delegationApprover` address is set to a non-zero value. * @dev 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. * @dev This function will revert if the current `block.timestamp` is equal to or exceeds the expiry * @dev 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 */ function delegateToBySignature( address staker, address operator, SignatureWithExpiry memory stakerSignatureAndExpiry, SignatureWithExpiry memory approverSignatureAndExpiry, bytes32 approverSalt ) external; /** * @notice 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. * @param staker The account to be undelegated. * @return withdrawalRoot The root of the newly queued withdrawal, if a withdrawal was queued. Otherwise just bytes32(0). * * @dev Reverts if the `staker` is also an operator, since operators are not allowed to undelegate from themselves. * @dev Reverts if the caller is not the staker, nor the operator who the staker is delegated to, nor the operator's specified "delegationApprover" * @dev Reverts if the `staker` is already undelegated. */ function undelegate(address staker) external returns (bytes32[] memory withdrawalRoot); /** * 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. */ function queueWithdrawals( QueuedWithdrawalParams[] calldata queuedWithdrawalParams ) external returns (bytes32[] memory); /** * @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. */ function completeQueuedWithdrawal( Withdrawal calldata withdrawal, IERC20[] calldata tokens, uint256 middlewareTimesIndex, bool receiveAsTokens ) external; /** * @notice Array-ified version of `completeQueuedWithdrawal`. * 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. * @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. * * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing. * @dev Callable only by the StrategyManager or EigenPodManager. */ function increaseDelegatedShares( address staker, IStrategy strategy, uint256 shares ) 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. * * @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. */ function decreaseDelegatedShares( address staker, IStrategy strategy, uint256 shares ) external; /** * @notice returns the address of the operator that `staker` is delegated to. * @notice Mapping: staker => operator whom the staker is currently delegated to. * @dev Note that returning address(0) indicates that the staker is not actively delegated to any operator. */ function delegatedTo(address staker) external view returns (address); /** * @notice Returns the OperatorDetails struct associated with an `operator`. */ function operatorDetails(address operator) external view returns (OperatorDetails memory); /* * @notice Returns the earnings receiver address for an operator */ function earningsReceiver(address operator) external view returns (address); /** * @notice Returns the delegationApprover account for an operator */ function delegationApprover(address operator) external view returns (address); /** * @notice Returns the stakerOptOutWindowBlocks for an operator */ function stakerOptOutWindowBlocks(address operator) 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. * @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) */ function operatorShares(address operator, IStrategy strategy) external view returns (uint256); /** * @notice Returns 'true' if `staker` *is* actively delegated, and 'false' otherwise. */ function isDelegated(address staker) external view returns (bool); /** * @notice Returns true is an operator has previously registered for delegation. */ function isOperator(address operator) external view returns (bool); /// @notice Mapping: staker => number of signed delegation nonces (used in `delegateToBySignature`) from the staker that the contract has already checked function stakerNonce(address staker) external view returns (uint256); /** * @notice Mapping: delegationApprover => 32-byte salt => whether or not the salt has already been used by the delegationApprover. * @dev 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`. */ 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 Calculates the digestHash for a `staker` to sign to delegate to an `operator` * @param staker The signing staker * @param operator The operator who is being delegated to * @param expiry The desired expiry time of the staker's signature */ function calculateCurrentStakerDelegationDigestHash( address staker, address operator, uint256 expiry ) external view returns (bytes32); /** * @notice Calculates the digest hash to be signed and used in the `delegateToBySignature` function * @param staker The signing staker * @param _stakerNonce The nonce of the staker. In practice we use the staker's current nonce, stored at `stakerNonce[staker]` * @param operator The operator who is being delegated to * @param expiry The desired expiry time of the staker's signature */ function calculateStakerDelegationDigestHash( address staker, uint256 _stakerNonce, address operator, uint256 expiry ) external view returns (bytes32); /** * @notice Calculates the digest hash to be signed by the operator's delegationApprove and used in the `delegateTo` and `delegateToBySignature` functions. * @param staker The account delegating their stake * @param operator The account receiving delegated stake * @param _delegationApprover the operator's `delegationApprover` who will be signing the delegationHash (in general) * @param approverSalt A unique and single use value associated with the approver signature. * @param expiry Time after which the approver's signature becomes invalid */ function calculateDelegationApprovalDigestHash( address staker, address operator, address _delegationApprover, bytes32 approverSalt, uint256 expiry ) external view returns (bytes32); /// @notice The EIP-712 typehash for the contract's domain function DOMAIN_TYPEHASH() external view returns (bytes32); /// @notice The EIP-712 typehash for the StakerDelegation struct used by the contract function STAKER_DELEGATION_TYPEHASH() external view returns (bytes32); /// @notice The EIP-712 typehash for the DelegationApproval struct used by the contract function DELEGATION_APPROVAL_TYPEHASH() 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. * @dev 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. */ function domainSeparator() external view returns (bytes32); /// @notice Mapping: staker => cumulative number of queued withdrawals they have ever initiated. /// @dev This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes. function cumulativeWithdrawalsQueued(address staker) external view returns (uint256); /// @notice Returns the keccak256 hash of `withdrawal`. function calculateWithdrawalRoot(Withdrawal memory withdrawal) external pure returns (bytes32); function migrateQueuedWithdrawals(IStrategyManager.DeprecatedStruct_QueuedWithdrawal[] memory withdrawalsToQueue) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "./ISignatureUtils.sol"; interface IAVSDirectory is ISignatureUtils { /// @notice Enum representing the status of an operator's registration with an AVS enum OperatorAVSRegistrationStatus { UNREGISTERED, // Operator not registered to AVS REGISTERED // Operator registered to AVS } /** * @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 */ event AVSMetadataURIUpdated(address indexed avs, string metadataURI); /// @notice Emitted when an operator's registration status for an AVS is updated event OperatorAVSRegistrationStatusUpdated(address indexed operator, address indexed avs, OperatorAVSRegistrationStatus status); /** * @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. */ function registerOperatorToAVS( address operator, ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature ) external; /** * @notice Called by an avs to deregister an operator with the avs. * @param operator The address of the operator to deregister. */ 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 */ 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. */ function operatorSaltIsSpent(address operator, bytes32 salt) 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 */ function calculateOperatorAVSRegistrationDigestHash( address operator, address avs, bytes32 salt, uint256 expiry ) 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); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; /** * @title The interface for common signature utilities. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service */ interface ISignatureUtils { // @notice Struct that bundles together a signature and an expiration time for the signature. Used primarily for stack management. struct SignatureWithExpiry { // the signature itself, formatted as a single bytes object bytes signature; // the expiration timestamp (UTC) of the signature uint256 expiry; } // @notice Struct that bundles together a signature, a salt for uniqueness, and an expiration time for the signature. Used primarily for stack management. struct SignatureWithSaltAndExpiry { // the signature itself, formatted as a single bytes object bytes signature; // the salt used to generate the signature bytes32 salt; // the expiration timestamp (UTC) of the signature uint256 expiry; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title Minimal interface for an `Strategy` contract. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service * @notice Custom `Strategy` implementations may expand extensively on this interface. */ interface IStrategy { /** * @notice Used to deposit tokens into this Strategy * @param token is the ERC20 token being deposited * @param amount is the amount of token being deposited * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's * `depositIntoStrategy` function, and individual share balances are recorded in the strategyManager as well. * @return newShares is the number of new shares issued at the current exchange ratio. */ function deposit(IERC20 token, uint256 amount) external returns (uint256); /** * @notice Used to withdraw tokens from this Strategy, to the `recipient`'s address * @param recipient is the address to receive the withdrawn funds * @param token is the ERC20 token being transferred out * @param amountShares is the amount of shares being withdrawn * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's * other functions, and individual share balances are recorded in the strategyManager as well. */ function withdraw(address recipient, IERC20 token, uint256 amountShares) external; /** * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy. * @notice In contrast to `sharesToUnderlyingView`, this function **may** make state modifications * @param amountShares is the amount of shares to calculate its conversion into the underlying token * @return The amount of underlying tokens corresponding to the input `amountShares` * @dev Implementation for these functions in particular may vary significantly for different strategies */ function sharesToUnderlying(uint256 amountShares) external returns (uint256); /** * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy. * @notice In contrast to `underlyingToSharesView`, this function **may** make state modifications * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares * @return The amount of underlying tokens corresponding to the input `amountShares` * @dev Implementation for these functions in particular may vary significantly for different strategies */ function underlyingToShares(uint256 amountUnderlying) external returns (uint256); /** * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in * this strategy. In contrast to `userUnderlyingView`, this function **may** make state modifications */ function userUnderlying(address user) external returns (uint256); /** * @notice convenience function for fetching the current total shares of `user` in this strategy, by * querying the `strategyManager` contract */ function shares(address user) external view returns (uint256); /** * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy. * @notice In contrast to `sharesToUnderlying`, this function guarantees no state modifications * @param amountShares is the amount of shares to calculate its conversion into the underlying token * @return The amount of shares corresponding to the input `amountUnderlying` * @dev Implementation for these functions in particular may vary significantly for different strategies */ function sharesToUnderlyingView(uint256 amountShares) external view returns (uint256); /** * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy. * @notice In contrast to `underlyingToShares`, this function guarantees no state modifications * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares * @return The amount of shares corresponding to the input `amountUnderlying` * @dev Implementation for these functions in particular may vary significantly for different strategies */ function underlyingToSharesView(uint256 amountUnderlying) external view returns (uint256); /** * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in * this strategy. In contrast to `userUnderlying`, this function guarantees no state modifications */ function userUnderlyingView(address user) external view returns (uint256); /// @notice The underlying token for shares in this Strategy function underlyingToken() external view returns (IERC20); /// @notice The total number of extant shares in this Strategy function totalShares() external view returns (uint256); /// @notice Returns either a brief string explaining the strategy's goal & purpose, or a link to metadata that explains in more detail. function explanation() external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.12; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; /** * @title Interface for a `Registry` that keeps track of stakes of operators for up to 256 quorums. * @author Layr Labs, Inc. */ interface IStakeRegistry { /** * @notice In weighing a particular strategy, the amount of underlying asset for that strategy is * multiplied by its multiplier, then divided by WEIGHTING_DIVISOR */ struct StrategyParams { IStrategy strategy; uint96 multiplier; } /// @notice Returns the strategy and weight multiplier for the `index`'th strategy in the quorum `quorumNumber` function strategyParamsByIndex(uint8 quorumNumber, uint256 index) external view returns (StrategyParams memory); }
// SPDX-License-Identifier: MIT pragma solidity =0.8.12; import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol"; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; struct DTMTaskParams { address msgSender; address target; bytes4 functionSig; bytes functionArgs; string policyID; uint32 quorumThresholdCount; } struct STMTaskParams { string taskId; address msgSender; address target; bytes4 functionSig; bytes functionArgs; string policyID; uint32 quorumThresholdCount; uint256 expireByBlockNumber; } /** * @title Minimal interface for a ServiceManager-type contract that forms the single point for an AVS to push updates to EigenLayer * @author Aethos Labs, Inc */ interface IServiceManager { /** * @notice Sets the metadata URI for the AVS * @param _metadataURI is the metadata URI for the AVS */ function setMetadataURI(string memory _metadataURI) external; /** * @notice Forwards a call to EigenLayer's DelegationManager contract to confirm operator registration with the AVS * @param operatorSigningKey The address of the operator's signing key. * @param operatorSignature The signature, salt, and expiry of the operator's signature. */ function registerOperatorToAVS( address operatorSigningKey, ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature ) external; /** * @notice Forwards a call to EigenLayer's DelegationManager contract to confirm operator deregistration from the AVS * @param operator The address of the operator to deregister. */ function deregisterOperatorFromAVS(address operator) external; /** * @notice Returns the list of strategies that the operator has potentially restaked on the AVS * @param operator The address of the operator to get restaked strategies for * @dev This function is intended to be called off-chain * @dev No guarantee is made on whether the operator has shares for a strategy in a quorum or uniqueness * of each element in the returned array. The off-chain service should do that validation separately */ function getOperatorRestakedStrategies(address operator) external view returns (address[] memory); /** * @notice Returns the list of strategies that the AVS supports for restaking * @dev This function is intended to be called off-chain * @dev No guarantee is made on uniqueness of each element in the returned array. * The off-chain service should do that validation separately */ function getRestakeableStrategies() external view returns (address[] memory); /** * @notice Sets a policy ID for the sender, defining execution rules or parameters for tasks * @param policyID string pointing to the policy details * @dev Only callable by client contracts or EOAs to associate a policy with their address * @dev Emits a SetPolicy event upon successful association */ function setPolicy(string memory policyID) external; /** * @notice Removes a policy ID for the sender, removing execution rules or parameters for tasks * @param policyID string pointing to the policy details * @dev Only callable by client contracts or EOAs to disassociate a policy with their address * @dev Emits a RemovedPolicy event upon successful association */ function removePolicy(string memory policyID) external; /** * @notice Deploys a policy with ID with execution rules or parameters for tasks * @param _policyID string pointing to the policy details * @param _policy string containing the policy details * @dev Only callable by service manager deployer * @dev Emits a DeployedPolicy event upon successful deployment */ function deployPolicy(string memory _policyID, string memory _policy) external; /** * @notice Gets array of deployed policies */ function getDeployedPolicies() external view returns (string[] memory); /** * @notice Deploys a social graph which clients can use in policy * @param _socialGraphID is a unique identifier * @param _socialGraphConfig is the config for the social graph * @dev Only callable by service manager deployer * @dev Emits a SocialGraphDeployed event upon successful deployment */ function deploySocialGraph(string memory _socialGraphID, string memory _socialGraphConfig) external; /** * @notice Returns the list of social graph IDs that the AVS supports */ function getSocialGraphIDs() external view returns (string[] memory); /** * @notice Submits a new task for execution by the network operators, subject to the specified policy * @param params Struct containing task parameters including sender, target contract, function signature, and arguments * @return taskID A unique identifier for the submitted task * @dev Tasks are validated and executed based on compliance with the associated policy and sufficient operator signatures * @dev Emits a NewTask event upon task submission */ function submitTask(DTMTaskParams memory params) external returns (uint256 taskID); /** * @notice Verifies if a task is authorized by the required number of operators * @param _params Parameters of the task including sender, target, function signature, arguments, quorum count, and expiry block * @param signerAddresses Array of addresses of the operators who signed the task * @param signatures Array of signatures from the operators authorizing the task * @return isVerified Boolean indicating if the task has been verified by the required number of operators * @dev This function checks the signatures against the hash of the task parameters to ensure task authenticity and authorization */ function validateSignaturesSTM( STMTaskParams memory _params, address[] memory signerAddresses, bytes[] memory signatures ) external returns (bool isVerified); /** * @notice Adds a new strategy to the Service Manager * @dev Only callable by the contract owner. Adds a strategy that operators can stake on. * @param _strategy The address of the strategy contract to add * @param quorumNumber The quorum number associated with the strategy * @param index The index of the strategy within the quorum * @dev Emits a StrategyAdded event upon successful addition of the strategy * @dev Reverts if the strategy does not exist or is already added */ function addStrategy(address _strategy, uint8 quorumNumber, uint256 index) external; /** * @notice Removes an existing strategy from the Service Manager * @dev Only callable by the contract owner. Removes a strategy that operators are currently able to stake on. * @param _strategy The address of the strategy contract to remove * @dev Emits a StrategyRemoved event upon successful removal of the strategy * @dev Reverts if the strategy is not currently added or if the address is invalid */ function removeStrategy(address _strategy) external; /** * @notice Enables the rotation of Aethos Signing Key for an operator * @param _operator address of the operator to rotate the signing key for * @param _oldSigningKey address of the old signing key to remove * @param _newSigningKey address of the new signing key to add */ function rotateAethosSigningKey(address _operator, address _oldSigningKey, address _newSigningKey) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @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[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "./IStrategy.sol"; import "./ISlasher.sol"; import "./IDelegationManager.sol"; import "./IEigenPodManager.sol"; /** * @title Interface for the primary entrypoint for funds into EigenLayer. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service * @notice See the `StrategyManager` contract itself for implementation details. */ interface IStrategyManager { /** * @notice Emitted when a new deposit occurs on behalf of `staker`. * @param staker Is the staker who is depositing funds into EigenLayer. * @param strategy Is the strategy that `staker` has deposited into. * @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); /// @notice Emitted when the `strategyWhitelister` is changed event StrategyWhitelisterChanged(address previousAddress, address newAddress); /// @notice Emitted when a strategy is added to the approved list of strategies for deposit event StrategyAddedToDepositWhitelist(IStrategy strategy); /// @notice Emitted when a strategy is removed from the approved list of strategies for deposit event StrategyRemovedFromDepositWhitelist(IStrategy strategy); /** * @notice Deposits `amount` of `token` into the specified `strategy`, with the resultant shares credited to `msg.sender` * @param strategy is the specified strategy where deposit is to be made, * @param token is the denomination in which the deposit is to be made, * @param amount is the amount of token to be deposited in the strategy by the staker * @return shares The amount of new shares in the `strategy` created as part of the action. * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf. * @dev Cannot be called by an address that is 'frozen' (this function will revert if the `msg.sender` is frozen). * * 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); /** * @notice Used for depositing an asset into the specified strategy with the resultant shares credited to `staker`, * who must sign off on the action. * Note that the assets are transferred out/from the `msg.sender`, not from the `staker`; this function is explicitly designed * purely to help one address deposit 'for' another. * @param strategy is the specified strategy where deposit is to be made, * @param token is the denomination in which the deposit is to be made, * @param amount is the amount of token to be deposited in the strategy by the staker * @param staker the staker that the deposited assets will be credited to * @param expiry the timestamp at which the signature expires * @param signature is a valid signature from the `staker`. either an ECDSA signature if the `staker` is an EOA, or data to forward * following EIP-1271 if the `staker` is a contract * @return shares The amount of new shares in the `strategy` created as part of the action. * @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 */ function depositIntoStrategyWithSignature( IStrategy strategy, IERC20 token, uint256 amount, 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); /** * @notice Get all details on the staker's deposits and corresponding shares * @return (staker's strategies, shares in these strategies) */ function getDeposits(address staker) external view returns (IStrategy[] memory, uint256[] memory); /// @notice Simple getter function that returns `stakerStrategyList[staker].length`. function stakerStrategyListLength(address staker) external view returns (uint256); /** * @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 ) external; /** * @notice Owner-only function that removes the provided Strategies from the 'whitelist' of strategies that stakers can deposit into * @param strategiesToRemoveFromWhitelist Strategies that will be removed to the `strategyIsWhitelistedForDeposit` mapping (if they are in it) */ function removeStrategiesFromDepositWhitelist(IStrategy[] calldata strategiesToRemoveFromWhitelist) 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); /// @notice Returns the address of the `strategyWhitelister` function strategyWhitelister() external view returns (address); /** * @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); // LIMITED BACKWARDS-COMPATIBILITY FOR DEPRECATED FUNCTIONALITY // packed struct for queued withdrawals; helps deal with stack-too-deep errors struct DeprecatedStruct_WithdrawerAndNonce { address withdrawer; uint96 nonce; } /** * 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. `startQueuedWithdrawalWaitingPeriod` or `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. */ struct DeprecatedStruct_QueuedWithdrawal { IStrategy[] strategies; uint256[] shares; address staker; DeprecatedStruct_WithdrawerAndNonce withdrawerAndNonce; uint32 withdrawalStartBlock; address delegatedAddress; } function migrateQueuedWithdrawal(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external returns (bool, bytes32); function calculateWithdrawalRoot(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external pure returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// 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); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol"; import "./IETHPOSDeposit.sol"; import "./IStrategyManager.sol"; import "./IEigenPod.sol"; import "./IBeaconChainOracle.sol"; import "./IPausable.sol"; import "./ISlasher.sol"; import "./IStrategy.sol"; /** * @title Interface for factory that creates and manages solo staking pods that have their withdrawal credentials pointed to EigenLayer. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service */ interface IEigenPodManager is IPausable { /// @notice Emitted to notify the update of the beaconChainOracle address event BeaconOracleUpdated(address indexed newOracleAddress); /// @notice Emitted to notify the deployment of an EigenPod event PodDeployed(address indexed eigenPod, address indexed podOwner); /// @notice Emitted to notify a deposit of beacon chain ETH recorded in the strategy manager event BeaconChainETHDeposited(address indexed podOwner, uint256 amount); /// @notice Emitted when the balance of an EigenPod is updated event PodSharesUpdated(address indexed podOwner, int256 sharesDelta); /// @notice Emitted when a withdrawal of beacon chain ETH is completed event BeaconChainETHWithdrawalCompleted( address indexed podOwner, uint256 shares, uint96 nonce, address delegatedAddress, address withdrawer, bytes32 withdrawalRoot ); event DenebForkTimestampUpdated(uint64 newValue); /** * @notice Creates an EigenPod for the sender. * @dev Function will revert if the `msg.sender` already has an EigenPod. * @dev Returns EigenPod address */ function createPod() external returns (address); /** * @notice Stakes for a new beacon chain validator on the sender's EigenPod. * Also creates an EigenPod for the sender if they don't have one already. * @param pubkey The 48 bytes public key of the beacon chain validator. * @param signature The validator's signature of the deposit data. * @param depositDataRoot The root/hash of the deposit data for the validator's deposit. */ function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable; /** * @notice Changes the `podOwner`'s shares by `sharesDelta` and performs a call to the DelegationManager * 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 * @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; /** * @notice Updates the oracle contract that provides the beacon chain state root * @param newBeaconChainOracle is the new oracle contract being pointed to * @dev Callable only by the owner of this contract (i.e. governance) */ function updateBeaconChainOracle(IBeaconChainOracle newBeaconChainOracle) external; /// @notice Returns the address of the `podOwner`'s EigenPod if it has been deployed. function ownerToPod(address podOwner) external view returns (IEigenPod); /// @notice Returns the address of the `podOwner`'s EigenPod (whether it is deployed yet or not). function getPod(address podOwner) external view returns (IEigenPod); /// @notice The ETH2 Deposit Contract function ethPOS() external view returns (IETHPOSDeposit); /// @notice Beacon proxy to which the EigenPods point function eigenPodBeacon() external view returns (IBeacon); /// @notice Oracle contract that provides updates to the beacon chain's state function beaconChainOracle() external view returns (IBeaconChainOracle); /// @notice Returns the beacon block root at `timestamp`. Reverts if the Beacon block root at `timestamp` has not yet been finalized. function getBlockRootAtTimestamp(uint64 timestamp) external view returns (bytes32); /// @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) external view returns (bool); /// @notice Returns the number of EigenPods that have been created function numPods() external view returns (uint256); /** * @notice Mapping from Pod owner owner to the number of shares they have in the virtual beacon chain ETH strategy. * @dev The share amount can become negative. This is necessary to accommodate the fact that a pod owner's virtual beacon chain ETH shares can * decrease between the pod owner queuing and completing a withdrawal. * When the pod owner's shares would otherwise increase, this "deficit" is decreased first _instead_. * Likewise, when a withdrawal is completed, this "deficit" is decreased and the withdrawal amount is decreased; We can think of this * as the withdrawal "paying off the deficit". */ function podOwnerShares(address podOwner) external view returns (int256); /// @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; /** * @notice the deneb hard fork timestamp used to determine which proof path to use for proving a withdrawal */ function denebForkTimestamp() external view returns (uint64); /** * setting the deneb hard fork timestamp by the eigenPodManager owner * @dev this function is designed to be called twice. Once, it is set to type(uint64).max * prior to the actual deneb fork timestamp being set, and then the second time it is set * to the actual deneb fork timestamp. */ function setDenebForkTimestamp(uint64 newDenebForkTimestamp) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// ┏━━━┓━┏┓━┏┓━━┏━━━┓━━┏━━━┓━━━━┏━━━┓━━━━━━━━━━━━━━━━━━━┏┓━━━━━┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━━┏┓━ // ┃┏━━┛┏┛┗┓┃┃━━┃┏━┓┃━━┃┏━┓┃━━━━┗┓┏┓┃━━━━━━━━━━━━━━━━━━┏┛┗┓━━━━┃┏━┓┃━━━━━━━━┏┛┗┓━━━━━━━━━━━━┏┛┗┓ // ┃┗━━┓┗┓┏┛┃┗━┓┗┛┏┛┃━━┃┃━┃┃━━━━━┃┃┃┃┏━━┓┏━━┓┏━━┓┏━━┓┏┓┗┓┏┛━━━━┃┃━┗┛┏━━┓┏━┓━┗┓┏┛┏━┓┏━━┓━┏━━┓┗┓┏┛ // ┃┏━━┛━┃┃━┃┏┓┃┏━┛┏┛━━┃┃━┃┃━━━━━┃┃┃┃┃┏┓┃┃┏┓┃┃┏┓┃┃━━┫┣┫━┃┃━━━━━┃┃━┏┓┃┏┓┃┃┏┓┓━┃┃━┃┏┛┗━┓┃━┃┏━┛━┃┃━ // ┃┗━━┓━┃┗┓┃┃┃┃┃┃┗━┓┏┓┃┗━┛┃━━━━┏┛┗┛┃┃┃━┫┃┗┛┃┃┗┛┃┣━━┃┃┃━┃┗┓━━━━┃┗━┛┃┃┗┛┃┃┃┃┃━┃┗┓┃┃━┃┗┛┗┓┃┗━┓━┃┗┓ // ┗━━━┛━┗━┛┗┛┗┛┗━━━┛┗┛┗━━━┛━━━━┗━━━┛┗━━┛┃┏━┛┗━━┛┗━━┛┗┛━┗━┛━━━━┗━━━┛┗━━┛┗┛┗┛━┗━┛┗┛━┗━━━┛┗━━┛━┗━┛ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┗┛━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // SPDX-License-Identifier: CC0-1.0 pragma solidity >=0.5.0; // This interface is designed to be compatible with the Vyper version. /// @notice This is the Ethereum 2.0 deposit contract interface. /// For more information see the Phase 0 specification under https://github.com/ethereum/eth2.0-specs interface IETHPOSDeposit { /// @notice A processed deposit event. event DepositEvent(bytes pubkey, bytes withdrawal_credentials, bytes amount, bytes signature, bytes index); /// @notice Submit a Phase 0 DepositData object. /// @param pubkey A BLS12-381 public key. /// @param withdrawal_credentials Commitment to a public key for withdrawals. /// @param signature A BLS12-381 signature. /// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object. /// Used as a protection against malformed input. function deposit( bytes calldata pubkey, bytes calldata withdrawal_credentials, bytes calldata signature, bytes32 deposit_data_root ) external payable; /// @notice Query the current deposit root hash. /// @return The deposit root hash. function get_deposit_root() external view returns (bytes32); /// @notice Query the current deposit count. /// @return The deposit count encoded as a little endian 64-bit number. function get_deposit_count() external view returns (bytes memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "../libraries/BeaconChainProofs.sol"; import "./IEigenPodManager.sol"; import "./IBeaconChainOracle.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title The implementation contract used for restaking beacon chain ETH on EigenLayer * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service * @notice The main functionalities are: * - creating new ETH validators with their withdrawal credentials pointed to this contract * - proving from beacon chain state roots that withdrawal credentials are pointed to this contract * - proving from beacon chain state roots the balances of ETH validators with their withdrawal credentials * pointed to this contract * - updating aggregate balances in the EigenPodManager * - withdrawing eth when withdrawals are initiated * @dev Note that all beacon chain balances are stored as gwei within the beacon chain datastructures. We choose * to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts */ interface IEigenPod { enum VALIDATOR_STATUS { INACTIVE, // doesnt exist ACTIVE, // staked on ethpos and withdrawal credentials are pointed to the EigenPod WITHDRAWN // withdrawn from the Beacon Chain } struct ValidatorInfo { // index of the validator in the beacon chain uint64 validatorIndex; // amount of beacon chain ETH restaked on EigenLayer in gwei uint64 restakedBalanceGwei; //timestamp of the validator's most recent balance update uint64 mostRecentBalanceUpdateTimestamp; // status of the validator VALIDATOR_STATUS status; } /** * @notice struct used to store amounts related to proven withdrawals in memory. Used to help * manage stack depth and optimize the number of external calls, when batching withdrawal operations. */ struct VerifiedWithdrawal { // amount to send to a podOwner from a proven withdrawal uint256 amountToSendGwei; // difference in shares to be recorded in the eigenPodManager, as a result of the withdrawal int256 sharesDeltaGwei; } enum PARTIAL_WITHDRAWAL_CLAIM_STATUS { REDEEMED, PENDING, FAILED } /// @notice Emitted when an ETH validator stakes via this eigenPod event EigenPodStaked(bytes pubkey); /// @notice Emitted when an ETH validator's withdrawal credentials are successfully verified to be pointed to this eigenPod event ValidatorRestaked(uint40 validatorIndex); /// @notice Emitted when an ETH validator's balance is proven to be updated. Here newValidatorBalanceGwei // is the validator's balance that is credited on EigenLayer. event ValidatorBalanceUpdated(uint40 validatorIndex, uint64 balanceTimestamp, uint64 newValidatorBalanceGwei); /// @notice Emitted when an ETH validator is prove to have withdrawn from the beacon chain event FullWithdrawalRedeemed( uint40 validatorIndex, uint64 withdrawalTimestamp, address indexed recipient, uint64 withdrawalAmountGwei ); /// @notice Emitted when a partial withdrawal claim is successfully redeemed event PartialWithdrawalRedeemed( uint40 validatorIndex, uint64 withdrawalTimestamp, address indexed recipient, uint64 partialWithdrawalAmountGwei ); /// @notice Emitted when restaked beacon chain ETH is withdrawn from the eigenPod. event RestakedBeaconChainETHWithdrawn(address indexed recipient, uint256 amount); /// @notice Emitted when podOwner enables restaking event RestakingActivated(address indexed podOwner); /// @notice Emitted when ETH is received via the `receive` fallback event NonBeaconChainETHReceived(uint256 amountReceived); /// @notice Emitted when ETH that was previously received via the `receive` fallback is withdrawn event NonBeaconChainETHWithdrawn(address indexed recipient, uint256 amountWithdrawn); /// @notice The max amount of eth, in gwei, that can be restaked per validator function MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() external view returns (uint64); /// @notice the amount of execution layer ETH in this contract that is staked in EigenLayer (i.e. withdrawn from beaconchain but not EigenLayer), function withdrawableRestakedExecutionLayerGwei() external view returns (uint64); /// @notice any ETH deposited into the EigenPod contract via the `receive` fallback function function nonBeaconChainETHBalanceWei() external view returns (uint256); /// @notice Used to initialize the pointers to contracts crucial to the pod's functionality, in beacon proxy construction from EigenPodManager function initialize(address owner) external; /// @notice Called by EigenPodManager when the owner wants to create another ETH validator. function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable; /** * @notice Transfers `amountWei` in ether from this contract to the specified `recipient` address * @notice Called by EigenPodManager to withdrawBeaconChainETH that has been added to the EigenPod's balance due to a withdrawal from the beacon chain. * @dev The podOwner must have already proved sufficient withdrawals, so that this pod's `withdrawableRestakedExecutionLayerGwei` exceeds the * `amountWei` input (when converted to GWEI). * @dev Reverts if `amountWei` is not a whole Gwei amount */ function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external; /// @notice The single EigenPodManager for EigenLayer function eigenPodManager() external view returns (IEigenPodManager); /// @notice The owner of this EigenPod function podOwner() external view returns (address); /// @notice an indicator of whether or not the podOwner has ever "fully restaked" by successfully calling `verifyCorrectWithdrawalCredentials`. function hasRestaked() external view returns (bool); /** * @notice The latest timestamp at which the pod owner withdrew the balance of the pod, via calling `withdrawBeforeRestaking`. * @dev This variable is only updated when the `withdrawBeforeRestaking` function is called, which can only occur before `hasRestaked` is set to true for this pod. * Proofs for this pod are only valid against Beacon Chain state roots corresponding to timestamps after the stored `mostRecentWithdrawalTimestamp`. */ function mostRecentWithdrawalTimestamp() external view returns (uint64); /// @notice Returns the validatorInfo struct for the provided pubkeyHash function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view returns (ValidatorInfo memory); /// @notice Returns the validatorInfo struct for the provided pubkey function validatorPubkeyToInfo(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory); ///@notice mapping that tracks proven withdrawals function provenWithdrawal(bytes32 validatorPubkeyHash, uint64 slot) external view returns (bool); /// @notice This returns the status of a given validator function validatorStatus(bytes32 pubkeyHash) external view returns (VALIDATOR_STATUS); /// @notice This returns the status of a given validator pubkey function validatorStatus(bytes calldata validatorPubkey) external view returns (VALIDATOR_STATUS); /** * @notice This function verifies that the withdrawal credentials of validator(s) owned by the podOwner are pointed to * this contract. It also verifies the effective balance of the validator. It verifies the provided proof of the ETH validator against the beacon chain state * root, marks the validator as 'active' in EigenLayer, and credits the restaked ETH in Eigenlayer. * @param oracleTimestamp is the Beacon Chain timestamp whose state root the `proof` will be proven against. * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs * @param withdrawalCredentialProofs is an array of proofs, where each proof proves each ETH validator's balance and withdrawal credentials * against a beacon chain state root * @param validatorFields are the fields of the "Validator Container", refer to consensus specs * for details: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator */ function verifyWithdrawalCredentials( uint64 oracleTimestamp, BeaconChainProofs.StateRootProof calldata stateRootProof, uint40[] calldata validatorIndices, bytes[] calldata withdrawalCredentialProofs, bytes32[][] calldata validatorFields ) external; /** * @notice This function records an update (either increase or decrease) in the pod's balance in the StrategyManager. It also verifies a merkle proof of the validator's current beacon chain balance. * @param oracleTimestamp The oracleTimestamp whose state root the `proof` will be proven against. * Must be within `VERIFY_BALANCE_UPDATE_WINDOW_SECONDS` of the current block. * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs * @param validatorFieldsProofs proofs against the `beaconStateRoot` for each validator in `validatorFields` * @param validatorFields are the fields of the "Validator Container", refer to consensus specs * @dev For more details on the Beacon Chain spec, see: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator */ function verifyBalanceUpdates( uint64 oracleTimestamp, uint40[] calldata validatorIndices, BeaconChainProofs.StateRootProof calldata stateRootProof, bytes[] calldata validatorFieldsProofs, bytes32[][] calldata validatorFields ) external; /** * @notice This function records full and partial withdrawals on behalf of one of the Ethereum validators for this EigenPod * @param oracleTimestamp is the timestamp of the oracle slot that the withdrawal is being proven against * @param withdrawalProofs is the information needed to check the veracity of the block numbers and withdrawals being proven * @param validatorFieldsProofs is the proof of the validator's fields' in the validator tree * @param withdrawalFields are the fields of the withdrawals being proven * @param validatorFields are the fields of the validators being proven */ function verifyAndProcessWithdrawals( uint64 oracleTimestamp, BeaconChainProofs.StateRootProof calldata stateRootProof, BeaconChainProofs.WithdrawalProof[] calldata withdrawalProofs, bytes[] calldata validatorFieldsProofs, bytes32[][] calldata validatorFields, bytes32[][] calldata withdrawalFields ) external; /** * @notice Called by the pod owner to activate restaking by withdrawing * all existing ETH from the pod and preventing further withdrawals via * "withdrawBeforeRestaking()" */ function activateRestaking() external; /// @notice Called by the pod owner to withdraw the balance of the pod when `hasRestaked` is set to false function withdrawBeforeRestaking() external; /// @notice Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei function withdrawNonBeaconChainETHBalanceWei(address recipient, uint256 amountToWithdraw) external; /// @notice called by owner of a pod to remove any ERC20s deposited in the pod function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; /** * @title Interface for the BeaconStateOracle contract. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service */ interface IBeaconChainOracle { /// @notice The block number to state root mapping. function timestampToBlockRoot(uint256 timestamp) external view returns (bytes32); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "../interfaces/IPauserRegistry.sol"; /** * @title Adds pausability to a contract, with pausing & unpausing controlled by the `pauser` and `unpauser` of a PauserRegistry contract. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service * @notice Contracts that inherit from this contract may define their own `pause` and `unpause` (and/or related) functions. * These functions should be permissioned as "onlyPauser" which defers to a `PauserRegistry` for determining access control. * @dev Pausability is implemented using a uint256, which allows up to 256 different single bit-flags; each bit can potentially pause different functionality. * Inspiration for this was taken from the NearBridge design here https://etherscan.io/address/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873#code. * For the `pause` and `unpause` functions we've implemented, if you pause, you can only flip (any number of) switches to on/1 (aka "paused"), and if you unpause, * you can only flip (any number of) switches to off/0 (aka "paused"). * If you want a pauseXYZ function that just flips a single bit / "pausing flag", it will: * 1) 'bit-wise and' (aka `&`) a flag with the current paused state (as a uint256) * 2) update the paused state to this new value * @dev We note as well that we have chosen to identify flags by their *bit index* as opposed to their numerical value, so, e.g. defining `DEPOSITS_PAUSED = 3` * indicates specifically that if the *third bit* of `_paused` is flipped -- i.e. it is a '1' -- then deposits should be paused */ interface IPausable { /// @notice Emitted when the `pauserRegistry` is set to `newPauserRegistry`. event PauserRegistrySet(IPauserRegistry pauserRegistry, IPauserRegistry newPauserRegistry); /// @notice Emitted when the pause is triggered by `account`, and changed to `newPausedStatus`. event Paused(address indexed account, uint256 newPausedStatus); /// @notice Emitted when the pause is lifted by `account`, and changed to `newPausedStatus`. event Unpaused(address indexed account, uint256 newPausedStatus); /// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing). function pauserRegistry() external view returns (IPauserRegistry); /** * @notice This function is used to pause an EigenLayer contract's functionality. * It is permissioned to the `pauser` address, which is expected to be a low threshold multisig. * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once. * @dev This function can only pause functionality, and thus cannot 'unflip' any bit in `_paused` from 1 to 0. */ function pause(uint256 newPausedStatus) external; /** * @notice Alias for `pause(type(uint256).max)`. */ function pauseAll() external; /** * @notice This function is used to unpause an EigenLayer contract's functionality. * It is permissioned to the `unpauser` address, which is expected to be a high threshold multisig or governance contract. * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once. * @dev This function can only unpause functionality, and thus cannot 'flip' any bit in `_paused` from 0 to 1. */ function unpause(uint256 newPausedStatus) external; /// @notice Returns the current paused status as a uint256. function paused() external view returns (uint256); /// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise function paused(uint8 index) external view returns (bool); /// @notice Allows the unpauser to set a new pauser registry function setPauserRegistry(IPauserRegistry newPauserRegistry) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./Merkle.sol"; import "../libraries/Endian.sol"; //Utility library for parsing and PHASE0 beacon chain block headers //SSZ Spec: https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#merkleization //BeaconBlockHeader Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader //BeaconState Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconstate library BeaconChainProofs { // constants are the number of fields and the heights of the different merkle trees used in merkleizing beacon chain containers uint256 internal constant BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT = 3; uint256 internal constant BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT = 4; uint256 internal constant BEACON_STATE_FIELD_TREE_HEIGHT = 5; uint256 internal constant VALIDATOR_FIELD_TREE_HEIGHT = 3; //Note: changed in the deneb hard fork from 4->5 uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_DENEB = 5; uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_CAPELLA = 4; // SLOTS_PER_HISTORICAL_ROOT = 2**13, so tree height is 13 uint256 internal constant BLOCK_ROOTS_TREE_HEIGHT = 13; //HISTORICAL_ROOTS_LIMIT = 2**24, so tree height is 24 uint256 internal constant HISTORICAL_SUMMARIES_TREE_HEIGHT = 24; //Index of block_summary_root in historical_summary container uint256 internal constant BLOCK_SUMMARY_ROOT_INDEX = 0; // tree height for hash tree of an individual withdrawal container uint256 internal constant WITHDRAWAL_FIELD_TREE_HEIGHT = 2; uint256 internal constant VALIDATOR_TREE_HEIGHT = 40; // MAX_WITHDRAWALS_PER_PAYLOAD = 2**4, making tree height = 4 uint256 internal constant WITHDRAWALS_TREE_HEIGHT = 4; //in beacon block body https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconblockbody uint256 internal constant EXECUTION_PAYLOAD_INDEX = 9; // in beacon block header https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader uint256 internal constant SLOT_INDEX = 0; uint256 internal constant STATE_ROOT_INDEX = 3; uint256 internal constant BODY_ROOT_INDEX = 4; // in beacon state https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconstate uint256 internal constant VALIDATOR_TREE_ROOT_INDEX = 11; uint256 internal constant HISTORICAL_SUMMARIES_INDEX = 27; // in validator https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator uint256 internal constant VALIDATOR_PUBKEY_INDEX = 0; uint256 internal constant VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1; uint256 internal constant VALIDATOR_BALANCE_INDEX = 2; uint256 internal constant VALIDATOR_WITHDRAWABLE_EPOCH_INDEX = 7; // in execution payload header uint256 internal constant TIMESTAMP_INDEX = 9; //in execution payload uint256 internal constant WITHDRAWALS_INDEX = 14; // in withdrawal uint256 internal constant WITHDRAWAL_VALIDATOR_INDEX_INDEX = 1; uint256 internal constant WITHDRAWAL_VALIDATOR_AMOUNT_INDEX = 3; //Misc Constants /// @notice The number of slots each epoch in the beacon chain uint64 internal constant SLOTS_PER_EPOCH = 32; /// @notice The number of seconds in a slot in the beacon chain uint64 internal constant SECONDS_PER_SLOT = 12; /// @notice Number of seconds per epoch: 384 == 32 slots/epoch * 12 seconds/slot uint64 internal constant SECONDS_PER_EPOCH = SLOTS_PER_EPOCH * SECONDS_PER_SLOT; bytes8 internal constant UINT64_MASK = 0xffffffffffffffff; /// @notice This struct contains the merkle proofs and leaves needed to verify a partial/full withdrawal struct WithdrawalProof { bytes withdrawalProof; bytes slotProof; bytes executionPayloadProof; bytes timestampProof; bytes historicalSummaryBlockRootProof; uint64 blockRootIndex; uint64 historicalSummaryIndex; uint64 withdrawalIndex; bytes32 blockRoot; bytes32 slotRoot; bytes32 timestampRoot; bytes32 executionPayloadRoot; } /// @notice This struct contains the root and proof for verifying the state root against the oracle block root struct StateRootProof { bytes32 beaconStateRoot; bytes proof; } /** * @notice This function verifies merkle proofs of the fields of a certain validator against a beacon chain state root * @param validatorIndex the index of the proven validator * @param beaconStateRoot is the beacon chain state root to be proven against. * @param validatorFieldsProof is the data used in proving the validator's fields * @param validatorFields the claimed fields of the validator */ function verifyValidatorFields( bytes32 beaconStateRoot, bytes32[] calldata validatorFields, bytes calldata validatorFieldsProof, uint40 validatorIndex ) internal view { require( validatorFields.length == 2 ** VALIDATOR_FIELD_TREE_HEIGHT, "BeaconChainProofs.verifyValidatorFields: Validator fields has incorrect length" ); /** * Note: the length of the validator merkle proof is BeaconChainProofs.VALIDATOR_TREE_HEIGHT + 1. * There is an additional layer added by hashing the root with the length of the validator list */ require( validatorFieldsProof.length == 32 * ((VALIDATOR_TREE_HEIGHT + 1) + BEACON_STATE_FIELD_TREE_HEIGHT), "BeaconChainProofs.verifyValidatorFields: Proof has incorrect length" ); uint256 index = (VALIDATOR_TREE_ROOT_INDEX << (VALIDATOR_TREE_HEIGHT + 1)) | uint256(validatorIndex); // merkleize the validatorFields to get the leaf to prove bytes32 validatorRoot = Merkle.merkleizeSha256(validatorFields); // verify the proof of the validatorRoot against the beaconStateRoot require( Merkle.verifyInclusionSha256({ proof: validatorFieldsProof, root: beaconStateRoot, leaf: validatorRoot, index: index }), "BeaconChainProofs.verifyValidatorFields: Invalid merkle proof" ); } /** * @notice This function verifies the latestBlockHeader against the state root. the latestBlockHeader is * a tracked in the beacon state. * @param beaconStateRoot is the beacon chain state root to be proven against. * @param stateRootProof is the provided merkle proof * @param latestBlockRoot is hashtree root of the latest block header in the beacon state */ function verifyStateRootAgainstLatestBlockRoot( bytes32 latestBlockRoot, bytes32 beaconStateRoot, bytes calldata stateRootProof ) internal view { require( stateRootProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT), "BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Proof has incorrect length" ); //Next we verify the slot against the blockRoot require( Merkle.verifyInclusionSha256({ proof: stateRootProof, root: latestBlockRoot, leaf: beaconStateRoot, index: STATE_ROOT_INDEX }), "BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Invalid latest block header root merkle proof" ); } /** * @notice This function verifies the slot and the withdrawal fields for a given withdrawal * @param withdrawalProof is the provided set of merkle proofs * @param withdrawalFields is the serialized withdrawal container to be proven */ function verifyWithdrawal( bytes32 beaconStateRoot, bytes32[] calldata withdrawalFields, WithdrawalProof calldata withdrawalProof, uint64 denebForkTimestamp ) internal view { require( withdrawalFields.length == 2 ** WITHDRAWAL_FIELD_TREE_HEIGHT, "BeaconChainProofs.verifyWithdrawal: withdrawalFields has incorrect length" ); require( withdrawalProof.blockRootIndex < 2 ** BLOCK_ROOTS_TREE_HEIGHT, "BeaconChainProofs.verifyWithdrawal: blockRootIndex is too large" ); require( withdrawalProof.withdrawalIndex < 2 ** WITHDRAWALS_TREE_HEIGHT, "BeaconChainProofs.verifyWithdrawal: withdrawalIndex is too large" ); require( withdrawalProof.historicalSummaryIndex < 2 ** HISTORICAL_SUMMARIES_TREE_HEIGHT, "BeaconChainProofs.verifyWithdrawal: historicalSummaryIndex is too large" ); //Note: post deneb hard fork, the number of exection payload header fields increased from 15->17, adding an extra level to the tree height uint256 executionPayloadHeaderFieldTreeHeight = (getWithdrawalTimestamp(withdrawalProof) < denebForkTimestamp) ? EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_CAPELLA : EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_DENEB; require( withdrawalProof.withdrawalProof.length == 32 * (executionPayloadHeaderFieldTreeHeight + WITHDRAWALS_TREE_HEIGHT + 1), "BeaconChainProofs.verifyWithdrawal: withdrawalProof has incorrect length" ); require( withdrawalProof.executionPayloadProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT + BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT), "BeaconChainProofs.verifyWithdrawal: executionPayloadProof has incorrect length" ); require( withdrawalProof.slotProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT), "BeaconChainProofs.verifyWithdrawal: slotProof has incorrect length" ); require( withdrawalProof.timestampProof.length == 32 * (executionPayloadHeaderFieldTreeHeight), "BeaconChainProofs.verifyWithdrawal: timestampProof has incorrect length" ); require( withdrawalProof.historicalSummaryBlockRootProof.length == 32 * (BEACON_STATE_FIELD_TREE_HEIGHT + (HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) + 1 + (BLOCK_ROOTS_TREE_HEIGHT)), "BeaconChainProofs.verifyWithdrawal: historicalSummaryBlockRootProof has incorrect length" ); /** * Note: Here, the "1" in "1 + (BLOCK_ROOTS_TREE_HEIGHT)" signifies that extra step of choosing the "block_root_summary" within the individual * "historical_summary". Everywhere else it signifies merkelize_with_mixin, where the length of an array is hashed with the root of the array, * but not here. */ uint256 historicalBlockHeaderIndex = (HISTORICAL_SUMMARIES_INDEX << ((HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) + 1 + (BLOCK_ROOTS_TREE_HEIGHT))) | (uint256(withdrawalProof.historicalSummaryIndex) << (1 + (BLOCK_ROOTS_TREE_HEIGHT))) | (BLOCK_SUMMARY_ROOT_INDEX << (BLOCK_ROOTS_TREE_HEIGHT)) | uint256(withdrawalProof.blockRootIndex); require( Merkle.verifyInclusionSha256({ proof: withdrawalProof.historicalSummaryBlockRootProof, root: beaconStateRoot, leaf: withdrawalProof.blockRoot, index: historicalBlockHeaderIndex }), "BeaconChainProofs.verifyWithdrawal: Invalid historicalsummary merkle proof" ); //Next we verify the slot against the blockRoot require( Merkle.verifyInclusionSha256({ proof: withdrawalProof.slotProof, root: withdrawalProof.blockRoot, leaf: withdrawalProof.slotRoot, index: SLOT_INDEX }), "BeaconChainProofs.verifyWithdrawal: Invalid slot merkle proof" ); { // Next we verify the executionPayloadRoot against the blockRoot uint256 executionPayloadIndex = (BODY_ROOT_INDEX << (BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT)) | EXECUTION_PAYLOAD_INDEX; require( Merkle.verifyInclusionSha256({ proof: withdrawalProof.executionPayloadProof, root: withdrawalProof.blockRoot, leaf: withdrawalProof.executionPayloadRoot, index: executionPayloadIndex }), "BeaconChainProofs.verifyWithdrawal: Invalid executionPayload merkle proof" ); } // Next we verify the timestampRoot against the executionPayload root require( Merkle.verifyInclusionSha256({ proof: withdrawalProof.timestampProof, root: withdrawalProof.executionPayloadRoot, leaf: withdrawalProof.timestampRoot, index: TIMESTAMP_INDEX }), "BeaconChainProofs.verifyWithdrawal: Invalid timestamp merkle proof" ); { /** * Next we verify the withdrawal fields against the executionPayloadRoot: * First we compute the withdrawal_index, then we merkleize the * withdrawalFields container to calculate the withdrawalRoot. * * Note: Merkleization of the withdrawals root tree uses MerkleizeWithMixin, i.e., the length of the array is hashed with the root of * the array. Thus we shift the WITHDRAWALS_INDEX over by WITHDRAWALS_TREE_HEIGHT + 1 and not just WITHDRAWALS_TREE_HEIGHT. */ uint256 withdrawalIndex = (WITHDRAWALS_INDEX << (WITHDRAWALS_TREE_HEIGHT + 1)) | uint256(withdrawalProof.withdrawalIndex); bytes32 withdrawalRoot = Merkle.merkleizeSha256(withdrawalFields); require( Merkle.verifyInclusionSha256({ proof: withdrawalProof.withdrawalProof, root: withdrawalProof.executionPayloadRoot, leaf: withdrawalRoot, index: withdrawalIndex }), "BeaconChainProofs.verifyWithdrawal: Invalid withdrawal merkle proof" ); } } /** * @notice This function replicates the ssz hashing of a validator's pubkey, outlined below: * hh := ssz.NewHasher() * hh.PutBytes(validatorPubkey[:]) * validatorPubkeyHash := hh.Hash() * hh.Reset() */ function hashValidatorBLSPubkey(bytes memory validatorPubkey) internal pure returns (bytes32 pubkeyHash) { require(validatorPubkey.length == 48, "Input should be 48 bytes in length"); return sha256(abi.encodePacked(validatorPubkey, bytes16(0))); } /** * @dev Retrieve the withdrawal timestamp */ function getWithdrawalTimestamp(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) { return Endian.fromLittleEndianUint64(withdrawalProof.timestampRoot); } /** * @dev Converts the withdrawal's slot to an epoch */ function getWithdrawalEpoch(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) { return Endian.fromLittleEndianUint64(withdrawalProof.slotRoot) / SLOTS_PER_EPOCH; } /** * Indices for validator fields (refer to consensus specs): * 0: pubkey * 1: withdrawal credentials * 2: effective balance * 3: slashed? * 4: activation elligibility epoch * 5: activation epoch * 6: exit epoch * 7: withdrawable epoch */ /** * @dev Retrieves a validator's pubkey hash */ function getPubkeyHash(bytes32[] memory validatorFields) internal pure returns (bytes32) { return validatorFields[VALIDATOR_PUBKEY_INDEX]; } function getWithdrawalCredentials(bytes32[] memory validatorFields) internal pure returns (bytes32) { return validatorFields[VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX]; } /** * @dev Retrieves a validator's effective balance (in gwei) */ function getEffectiveBalanceGwei(bytes32[] memory validatorFields) internal pure returns (uint64) { return Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_BALANCE_INDEX]); } /** * @dev Retrieves a validator's withdrawable epoch */ function getWithdrawableEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) { return Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_WITHDRAWABLE_EPOCH_INDEX]); } /** * Indices for withdrawal fields (refer to consensus specs): * 0: withdrawal index * 1: validator index * 2: execution address * 3: withdrawal amount */ /** * @dev Retrieves a withdrawal's validator index */ function getValidatorIndex(bytes32[] memory withdrawalFields) internal pure returns (uint40) { return uint40(Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_INDEX_INDEX])); } /** * @dev Retrieves a withdrawal's withdrawal amount (in gwei) */ function getWithdrawalAmountGwei(bytes32[] memory withdrawalFields) internal pure returns (uint64) { return Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_AMOUNT_INDEX]); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; /** * @title Interface for the `PauserRegistry` contract. * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service */ interface IPauserRegistry { event PauserStatusChanged(address pauser, bool canPause); event UnpauserChanged(address previousUnpauser, address newUnpauser); /// @notice Mapping of addresses to whether they hold the pauser role. function isPauser(address pauser) external view returns (bool); /// @notice Unique address that holds the unpauser role. Capable of changing *both* the pauser and unpauser addresses. function unpauser() external view returns (address); }
// SPDX-License-Identifier: MIT // Adapted from OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library Merkle { /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. The tree is built assuming `leaf` is * the 0 indexed `index`'th leaf from the bottom left of the tree. * * Note this is for a Merkle tree using the keccak/sha3 hash function */ function verifyInclusionKeccak( bytes memory proof, bytes32 root, bytes32 leaf, uint256 index ) internal pure returns (bool) { return processInclusionProofKeccak(proof, leaf, index) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. The tree is built assuming `leaf` is * the 0 indexed `index`'th leaf from the bottom left of the tree. * * _Available since v4.4._ * * Note this is for a Merkle tree using the keccak/sha3 hash function */ function processInclusionProofKeccak( bytes memory proof, bytes32 leaf, uint256 index ) internal pure returns (bytes32) { require( proof.length != 0 && proof.length % 32 == 0, "Merkle.processInclusionProofKeccak: proof length should be a non-zero multiple of 32" ); bytes32 computedHash = leaf; for (uint256 i = 32; i <= proof.length; i += 32) { if (index % 2 == 0) { // if ith bit of index is 0, then computedHash is a left sibling assembly { mstore(0x00, computedHash) mstore(0x20, mload(add(proof, i))) computedHash := keccak256(0x00, 0x40) index := div(index, 2) } } else { // if ith bit of index is 1, then computedHash is a right sibling assembly { mstore(0x00, mload(add(proof, i))) mstore(0x20, computedHash) computedHash := keccak256(0x00, 0x40) index := div(index, 2) } } } return computedHash; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. The tree is built assuming `leaf` is * the 0 indexed `index`'th leaf from the bottom left of the tree. * * Note this is for a Merkle tree using the sha256 hash function */ function verifyInclusionSha256( bytes memory proof, bytes32 root, bytes32 leaf, uint256 index ) internal view returns (bool) { return processInclusionProofSha256(proof, leaf, index) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. The tree is built assuming `leaf` is * the 0 indexed `index`'th leaf from the bottom left of the tree. * * _Available since v4.4._ * * Note this is for a Merkle tree using the sha256 hash function */ function processInclusionProofSha256( bytes memory proof, bytes32 leaf, uint256 index ) internal view returns (bytes32) { require( proof.length != 0 && proof.length % 32 == 0, "Merkle.processInclusionProofSha256: proof length should be a non-zero multiple of 32" ); bytes32[1] memory computedHash = [leaf]; for (uint256 i = 32; i <= proof.length; i += 32) { if (index % 2 == 0) { // if ith bit of index is 0, then computedHash is a left sibling assembly { mstore(0x00, mload(computedHash)) mstore(0x20, mload(add(proof, i))) if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) { revert(0, 0) } index := div(index, 2) } } else { // if ith bit of index is 1, then computedHash is a right sibling assembly { mstore(0x00, mload(add(proof, i))) mstore(0x20, mload(computedHash)) if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) { revert(0, 0) } index := div(index, 2) } } } return computedHash[0]; } /** @notice this function returns the merkle root of a tree created from a set of leaves using sha256 as its hash function @param leaves the leaves of the merkle tree @return The computed Merkle root of the tree. @dev A pre-condition to this function is that leaves.length is a power of two. If not, the function will merkleize the inputs incorrectly. */ function merkleizeSha256(bytes32[] memory leaves) internal pure returns (bytes32) { //there are half as many nodes in the layer above the leaves uint256 numNodesInLayer = leaves.length / 2; //create a layer to store the internal nodes bytes32[] memory layer = new bytes32[](numNodesInLayer); //fill the layer with the pairwise hashes of the leaves for (uint256 i = 0; i < numNodesInLayer; i++) { layer[i] = sha256(abi.encodePacked(leaves[2 * i], leaves[2 * i + 1])); } //the next layer above has half as many nodes numNodesInLayer /= 2; //while we haven't computed the root while (numNodesInLayer != 0) { //overwrite the first numNodesInLayer nodes in layer with the pairwise hashes of their children for (uint256 i = 0; i < numNodesInLayer; i++) { layer[i] = sha256(abi.encodePacked(layer[2 * i], layer[2 * i + 1])); } //the next layer above has half as many nodes numNodesInLayer /= 2; } //the first node in the layer is the root return layer[0]; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library Endian { /** * @notice Converts a little endian-formatted uint64 to a big endian-formatted uint64 * @param lenum little endian-formatted uint64 input, provided as 'bytes32' type * @return n The big endian-formatted uint64 * @dev Note that the input is formatted as a 'bytes32' type (i.e. 256 bits), but it is immediately truncated to a uint64 (i.e. 64 bits) * through a right-shift/shr operation. */ function fromLittleEndianUint64(bytes32 lenum) internal pure returns (uint64 n) { // the number needs to be stored in little-endian encoding (ie in bytes 0-8) n = uint64(uint256(lenum >> 192)); return (n >> 56) | ((0x00FF000000000000 & n) >> 40) | ((0x0000FF0000000000 & n) >> 24) | ((0x000000FF00000000 & n) >> 8) | ((0x00000000FF000000 & n) << 8) | ((0x0000000000FF0000 & n) << 24) | ((0x000000000000FF00 & n) << 40) | ((0x00000000000000FF & n) << 56); } }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "openzeppelin/=lib/openzeppelin-contracts/contracts/", "openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "eigenlayer-contracts/=lib/eigenlayer-contracts/", "@openzeppelin-upgrades-v4.9.0/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable-v4.9.0/", "@openzeppelin-upgrades/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable/", "@openzeppelin-v4.9.0/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-v4.9.0/", "@openzeppelin/=lib/eigenlayer-contracts/lib/openzeppelin-contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "eigenlayer-middleware/=lib/eigenlayer-middleware/", "erc4626-tests/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable-v4.9.0/lib/erc4626-tests/", "openzeppelin-contracts-upgradeable-v4.9.0/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable-v4.9.0/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts-v4.9.0/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-v4.9.0/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "viaIR": false, "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ServiceManager__ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"ServiceManager__CallFailed","type":"error"},{"inputs":[],"name":"ServiceManager__InvalidOperator","type":"error"},{"inputs":[],"name":"ServiceManager__InvalidPolicy","type":"error"},{"inputs":[],"name":"ServiceManager__InvalidStrategy","type":"error"},{"inputs":[],"name":"ServiceManager__InvalidTask","type":"error"},{"inputs":[],"name":"ServiceManager__Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"avsDirectory","type":"address"}],"name":"AVSDirectoryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"aggregator","type":"address"}],"name":"AggregatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegationManager","type":"address"}],"name":"DelegationManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"policyID","type":"string"},{"indexed":false,"internalType":"string","name":"policy","type":"string"}],"name":"DeployedPolicy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"taskID","type":"uint256"},{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"functionSig","type":"bytes4"},{"internalType":"bytes","name":"functionArgs","type":"bytes"},{"internalType":"string","name":"policyID","type":"string"},{"internalType":"uint32","name":"quorumThresholdCount","type":"uint32"}],"indexed":false,"internalType":"struct DTMTaskParams","name":"params","type":"tuple"}],"name":"NewTask","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"taskID","type":"uint256"}],"name":"NonCompliantTask","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address[][]","name":"operatorsPerQuorum","type":"address[][]"},{"indexed":true,"internalType":"bytes","name":"quorumNumbers","type":"bytes"}],"name":"OperatorsStakesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"client","type":"address"},{"indexed":true,"internalType":"string","name":"policyID","type":"string"}],"name":"RemovedPolicy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"client","type":"address"},{"indexed":true,"internalType":"string","name":"policyID","type":"string"}],"name":"SetPolicy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"socialGraphID","type":"string"},{"indexed":false,"internalType":"string","name":"socialGraphConfig","type":"string"}],"name":"SocialGraphDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stakeRegistry","type":"address"}],"name":"StakeRegistryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"}],"name":"StrategyAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"}],"name":"StrategyRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"taskHash","type":"bytes32"}],"name":"TaskExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"thresholdStake","type":"uint256"}],"name":"ThresholdStakeUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"},{"internalType":"uint8","name":"quorumNumber","type":"uint8"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"addStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"avsDirectory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"clientToPolicy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegationManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_policyID","type":"string"},{"internalType":"string","name":"_policy","type":"string"}],"name":"deployPolicy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_socialGraphID","type":"string"},{"internalType":"string","name":"_socialGraphConfig","type":"string"}],"name":"deploySocialGraph","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"deployedPolicies","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"deregisterOperatorFromAVS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"functionSig","type":"bytes4"},{"internalType":"bytes","name":"functionArgs","type":"bytes"},{"internalType":"string","name":"policyID","type":"string"},{"internalType":"uint32","name":"quorumThresholdCount","type":"uint32"}],"internalType":"struct DTMTaskParams","name":"_params","type":"tuple"},{"internalType":"uint256","name":"_taskID","type":"uint256"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"executeTask","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDeployedPolicies","outputs":[{"internalType":"string[]","name":"","type":"string[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"getOperatorRestakedStrategies","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRestakeableStrategies","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSocialGraphIDs","outputs":[{"internalType":"string[]","name":"","type":"string[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_taskID","type":"uint256"},{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"functionSig","type":"bytes4"},{"internalType":"bytes","name":"functionArgs","type":"bytes"},{"internalType":"string","name":"policyID","type":"string"},{"internalType":"uint32","name":"quorumThresholdCount","type":"uint32"}],"internalType":"struct DTMTaskParams","name":"_params","type":"tuple"}],"name":"hashTask","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"taskId","type":"string"},{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"functionSig","type":"bytes4"},{"internalType":"bytes","name":"functionArgs","type":"bytes"},{"internalType":"string","name":"policyID","type":"string"},{"internalType":"uint32","name":"quorumThresholdCount","type":"uint32"},{"internalType":"uint256","name":"expireByBlockNumber","type":"uint256"}],"internalType":"struct STMTaskParams","name":"_params","type":"tuple"}],"name":"hashTaskWithExpiry","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"idToPolicy","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"idToSocialGraph","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_aggregator","type":"address"},{"internalType":"address","name":"_delegationManager","type":"address"},{"internalType":"address","name":"_stakeRegistry","type":"address"},{"internalType":"address","name":"_avsDirectory","type":"address"},{"internalType":"uint256","name":"_thresholdStake","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"operatorCanRegister","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"operators","outputs":[{"internalType":"uint256","name":"totalStake","type":"uint256"},{"internalType":"enum ServiceManager.OperatorStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"pendingTasks","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"functionSig","type":"bytes4"},{"internalType":"bytes","name":"functionArgs","type":"bytes"},{"internalType":"string","name":"policyID","type":"string"},{"internalType":"uint32","name":"quorumThresholdCount","type":"uint32"}],"internalType":"struct DTMTaskParams","name":"_params","type":"tuple"},{"internalType":"uint256","name":"_taskID","type":"uint256"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"recordNonCompliantTask","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operatorSigningKey","type":"address"},{"components":[{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"internalType":"struct ISignatureUtils.SignatureWithSaltAndExpiry","name":"_operatorSignature","type":"tuple"}],"name":"registerOperatorToAVS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_policyID","type":"string"}],"name":"removePolicy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"removeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_oldSigningKey","type":"address"},{"internalType":"address","name":"_newSigningKey","type":"address"}],"name":"rotateAethosSigningKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_avsDirectory","type":"address"}],"name":"setAVSDirectory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"}],"name":"setAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegationManager","type":"address"}],"name":"setDelegationManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_metadataURI","type":"string"}],"name":"setMetadataURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_policyID","type":"string"}],"name":"setPolicy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakeRegistry","type":"address"}],"name":"setStakeRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_thresholdStake","type":"uint256"}],"name":"setThresholdStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"signingKeyToOperator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"socialGraphIDs","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakeRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"strategies","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"functionSig","type":"bytes4"},{"internalType":"bytes","name":"functionArgs","type":"bytes"},{"internalType":"string","name":"policyID","type":"string"},{"internalType":"uint32","name":"quorumThresholdCount","type":"uint32"}],"internalType":"struct DTMTaskParams","name":"_params","type":"tuple"}],"name":"submitTask","outputs":[{"internalType":"uint256","name":"taskID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"taskCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"thresholdStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[][]","name":"operatorsPerQuorum","type":"address[][]"},{"internalType":"bytes","name":"quorumNumbers","type":"bytes"}],"name":"updateOperatorsForQuorum","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"taskId","type":"string"},{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"functionSig","type":"bytes4"},{"internalType":"bytes","name":"functionArgs","type":"bytes"},{"internalType":"string","name":"policyID","type":"string"},{"internalType":"uint32","name":"quorumThresholdCount","type":"uint32"},{"internalType":"uint256","name":"expireByBlockNumber","type":"uint256"}],"internalType":"struct STMTaskParams","name":"_params","type":"tuple"},{"internalType":"address[]","name":"signerAddresses","type":"address[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"validateSignaturesSTM","outputs":[{"internalType":"bool","name":"isVerified","type":"bool"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061028a5760003560e01c80638da5cb5b1161015c578063d574ea3d116100ce578063e4a62b6011610087578063e4a62b6014610624578063ea4d3c9b14610647578063f22cd8e71461065a578063f2fde38b1461066d578063f40643e714610680578063f9120af61461069357600080fd5b8063d574ea3d146105bd578063d9d4e99f146105d0578063ddf6a51b146105e3578063df935065146105f6578063e3b05f2f14610609578063e481af9d1461061c57600080fd5b8063ad091f7611610120578063ad091f7614610556578063b02ea5a314610569578063c82787901461057c578063cff702dd1461058f578063d18a1325146105a2578063d20e78c9146105aa57600080fd5b80638da5cb5b146104f957806395b6ef0c1461050a5780639926ee7d1461051d578063a364f4da14610530578063aceae5b31461054357600080fd5b80634987bfd0116102005780636b4c991b116101b95780636b4c991b14610485578063715018a614610498578063750521f5146104a0578063862621ef146104b35780638890533f146104c65780638ad96602146104e657600080fd5b80634987bfd01461040d5780635140a54814610430578063586717301461044357806366f17e731461044c578063683048351461045f5780636b3aa72e1461047257600080fd5b80631a8d0de2116102525780631a8d0de21461038a5780631b72a50c1461039d57806320af7390146103be578063245a7bfc146103c757806333cfb7b7146103da57806334099ba1146103fa57600080fd5b80630b3ce0151461028f5780630ff26fd1146102ad57806313e7c9d8146102ee578063140a16bc14610326578063175188e814610375575b600080fd5b6102976106a6565b6040516102a49190612998565b60405180910390f35b6102d66102bb366004612a1f565b6074602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016102a4565b6103186102fc366004612a1f565b606d602052600090815260409020805460019091015460ff1682565b6040516102a4929190612a59565b610365610334366004612b68565b606f602090815260009283526040909220815180830184018051928152908401929093019190912091525460ff1681565b60405190151581526020016102a4565b610388610383366004612a1f565b61077f565b005b610388610398366004612a1f565b6108bc565b6103b06103ab366004612bcf565b61090e565b6040519081526020016102a4565b6103b060665481565b6067546102d6906001600160a01b031681565b6103ed6103e8366004612a1f565b61099e565b6040516102a49190612c0b565b610388610408366004612c58565b610b2a565b61036561041b366004612a1f565b606c6020526000908152604090205460ff1681565b61038861043e366004612c94565b610ba8565b6103b060655481565b61038861045a366004612d58565b610e24565b6069546102d6906001600160a01b031681565b606a546102d6906001600160a01b031681565b610388610493366004612c58565b610f55565b610388610fd8565b6103886104ae366004612c58565b610fec565b6103886104c1366004612a1f565b611059565b6104d96104d4366004612d9f565b6110ab565b6040516102a49190612db8565b6103886104f4366004612d9f565b611157565b6033546001600160a01b03166102d6565b610388610518366004612dcb565b611192565b61038861052b366004612e44565b6112fe565b61038861053e366004612a1f565b6114dd565b610388610551366004612fa1565b61168f565b6103b061056436600461300d565b61182c565b610388610577366004613041565b61191e565b61038861058a366004612fa1565b611a79565b61036561059d3660046130ad565b611b3b565b610297611e0d565b6103886105b8366004613041565b611edd565b6102d66105cb366004612d9f565b612037565b6104d96105de366004612c58565b612061565b6104d96105f1366004612c58565b612085565b6104d9610604366004612d9f565b6120a9565b610388610617366004612a1f565b6120b9565b6103ed61210b565b610365610632366004612d9f565b606e6020526000908152604090205460ff1681565b6068546102d6906001600160a01b031681565b6103b061066836600461317a565b61216d565b61038861067b366004612a1f565b61220f565b61038861068e3660046131ae565b612288565b6103886106a1366004612a1f565b612381565b60606071805480602002602001604051908101604052809291908181526020016000905b828210156107765783829060005260206000200180546106e9906131f9565b80601f0160208091040260200160405190810160405280929190818152602001828054610715906131f9565b80156107625780601f1061073757610100808354040283529160200191610762565b820191906000526020600020905b81548152906001019060200180831161074557829003601f168201915b5050505050815260200190600101906106ca565b50505050905090565b6107876123d3565b60005b606b5481146108b857816001600160a01b0316606b82815481106107b0576107b061322e565b6000918252602090912001546001600160a01b031614156108b057606b80546107db9060019061325a565b815481106107eb576107eb61322e565b600091825260209091200154606b80546001600160a01b0390921691839081106108175761081761322e565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550606b80548061085657610856613271565b600082815260208120820160001990810180546001600160a01b03191690559091019091556040516001600160a01b038416917f09a1db4b80c32706328728508c941a6b954f31eb5affd32f236c1fd405f8fea491a25050565b60010161078a565b5050565b6108c46123d3565b606880546001600160a01b0319166001600160a01b0383169081179091556040517fa1b8fcd417a2bb56a91d1fc6708faf8283b5730e55821393e70303e544aeec9290600090a250565b60008261091e6020840184612a1f565b61092e6040850160208601612a1f565b61093e606086016040870161329f565b61094b60608701876132ba565b61095860808901896132ba565b61096860c08b0160a08c01613314565b60405160200161098099989796959493929190613358565b60405160208183030381529060405280519060200120905092915050565b606b546060906000906001600160401b038111156109be576109be612a8b565b6040519080825280602002602001820160405280156109e7578160200160208202803683370190505b5090506000805b606b54811015610b2157606854606b80546000926001600160a01b03169163778e55f39189919086908110610a2557610a2561322e565b60009182526020909120015460405160e084901b6001600160e01b03191681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610a7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa091906133cb565b1115610b0f57606b8181548110610ab957610ab961322e565b9060005260206000200160009054906101000a90046001600160a01b0316838381518110610ae957610ae961322e565b6001600160a01b039092166020928302919091019091015281610b0b816133e4565b9250505b80610b19816133e4565b9150506109ee565b50909392505050565b336000908152606f60205260408082209051610b479084906133ff565b908152604051908190036020018120805492151560ff1990931692909217909155610b739082906133ff565b6040519081900381209033907f64296597d208d70296fadc8eb749ff22ab651c8e6e455f35ee8ed66b74d1f77590600090a350565b828114610bc85760405163371821d760e21b815260040160405180910390fd5b606060008060005b808514610dc257878782818110610be957610be961322e565b9050602002810190610bfb919061341b565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509397505050505b8451811015610db957848181518110610c4a57610c4a61322e565b6020908102919091018101516001600160a01b0381166000908152606d909252604082209095509350600184015460ff166002811115610c8c57610c8c612a43565b1415610cab5760405163ba6435f160e01b815260040160405180910390fd5b6000805b606b548114610d7257606854606b80546001600160a01b039092169163778e55f391899185908110610ce357610ce361322e565b60009182526020909120015460405160e084901b6001600160e01b03191681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5e91906133cb565b610d689083613464565b9150600101610caf565b508084556066548110610d86576001610d89565b60025b60018086018054909160ff1990911690836002811115610dab57610dab612a43565b021790555050600101610c2f565b50600101610bd0565b508484604051610dd392919061347c565b60405180910390208787604051610deb92919061348c565b604051908190038120907ff3fcd2dadc5f6ebf9c1e9310a9e986a14079afc7ecf26784853ea9a3ac90721b90600090a350505050505050565b610e2c6123d3565b6069546040516356e4026d60e11b815260ff84166004820152602481018390526000916001600160a01b03169063adc804da906044016040805180830381865afa158015610e7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea2919061352d565b9050836001600160a01b031681600001516001600160a01b031614610eda5760405163a4e34a6960e01b815260040160405180910390fd5b606b805460018101825560009182527fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b40180546001600160a01b0319166001600160a01b03871690811790915560405190917f3f008fd510eae7a9e7bee13513d7b83bef8003d488b5a3d0b0da4de71d6846f191a250505050565b336000908152606f602052604090819020905160019190610f779084906133ff565b908152604051908190036020018120805492151560ff1990931692909217909155610fa39082906133ff565b6040519081900381209033907ffbc30d1514eac402cb2045f1dd80ec75fbc997db6f719421b6d7490f4bfb779d90600090a350565b610fe06123d3565b610fea600061242d565b565b610ff46123d3565b606a5460405163a98fb35560e01b81526001600160a01b039091169063a98fb35590611024908490600401612db8565b600060405180830381600087803b15801561103e57600080fd5b505af1158015611052573d6000803e3d6000fd5b5050505050565b6110616123d3565b606a80546001600160a01b0319166001600160a01b0383169081179091556040517f2a623245c0f1c5741f2a4c247a58842872f1fdf8a31e66d031dd1cd1532e89a790600090a250565b607181815481106110bb57600080fd5b9060005260206000200160009150905080546110d6906131f9565b80601f0160208091040260200160405190810160405280929190818152602001828054611102906131f9565b801561114f5780601f106111245761010080835404028352916020019161114f565b820191906000526020600020905b81548152906001019060200180831161113257829003601f168201915b505050505081565b61115f6123d3565b606681905560405181907f76f50103a7b1e136f23c29045235143c62e36705e8253019cb1253d9062bc6d490600090a250565b600054610100900460ff16158080156111b25750600054600160ff909116105b806111cc5750303b1580156111cc575060005460ff166001145b6112345760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015611257576000805461ff0019166101001790555b6112608761242d565b606780546001600160a01b038089166001600160a01b0319928316179092556068805488841690831617905560698054878416908316179055606a805492861692909116919091179055606682905580156112f5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6000805b606b5481146113c557606854606b80546001600160a01b039092169163778e55f3913391859081106113365761133661322e565b60009182526020909120015460405160e084901b6001600160e01b03191681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561138d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b191906133cb565b6113bb9083613464565b9150600101611302565b5060665481106114d85760408051808201825282815260016020808301828152336000908152606d90925293902082518155925183820180549394939192909160ff19169083600281111561141c5761141c612a43565b021790555050506001600160a01b038084166000908152607460205260409081902080546001600160a01b03191633908117909155606a549151639926ee7d60e01b81529190921691639926ee7d9161147a9190869060040161359c565b600060405180830381600087803b15801561149457600080fd5b505af11580156114a8573d6000803e3d6000fd5b50506040513392507f4d0eb1f4bac8744fd2be119845e23b3befc88094b42bcda1204c65694a00f9e59150600090a25b505050565b6114e56123d3565b6001600160a01b0381166000908152606d602052604081206001015460ff16600281111561151557611515612a43565b14156115975760405162461bcd60e51b8152602060048201526044602482018190527f536572766963654d616e616765722e646572656769737465724f70657261746f908201527f7246726f6d4156533a206f70657261746f72206973206e6f7420726567697374606482015263195c995960e21b608482015260a40161122b565b604080518082019091526000815260208101600290526001600160a01b0382166000908152606d60209081526040909120825181559082015160018083018054909160ff19909116908360028111156115f2576115f2612a43565b021790555050606a546040516351b27a6d60e11b81526001600160a01b038481166004830152909116915063a364f4da90602401600060405180830381600087803b15801561164057600080fd5b505af1158015611654573d6000803e3d6000fd5b50506040516001600160a01b03841692507f80c0b871b97b595b16a7741c1b06fed0c6f6f558639f18ccbce50724325dc40d9150600090a250565b6067546001600160a01b031633146116ba576040516332c5b57b60e11b815260040160405180910390fd5b60006116c6838561090e565b6000818152606e602052604090205490915060ff1615806116f757506116f56116ee856135e7565b838361247f565b155b156117155760405163d08f561d60e01b815260040160405180910390fd5b6000611727606086016040870161329f565b61173460608701876132ba565b60405160200161174693929190613697565b6040516020818303038152906040529050600085602001602081019061176c9190612a1f565b6001600160a01b03168260405161178391906133ff565b6000604051808303816000865af19150503d80600081146117c0576040519150601f19603f3d011682016040523d82523d6000602084013e6117c5565b606091505b50509050806117e75760405163cbe015c760e01b815260040160405180910390fd5b6000838152606e6020526040808220805460ff191690555184917f3a04c0621dfd116e61ea63184b2b9c8cf514b0075675645493095b7be2e492d591a2505050505050565b336000908152606f60205260408120819061184a60808501856132ba565b60405161185892919061347c565b9081526040519081900360200190205460ff1690508061188b57604051637cb4fb9160e11b815260040160405180910390fd5b60656000815461189a906133e4565b918290555091506001606e60006118b1858761090e565b815260200190815260200160002060006101000a81548160ff02191690831515021790555081336001600160a01b03167fa6e3626c59b3a0d9d9b8bb807b8760e546ba3281e6b711a29f292756858f94f4856040516119109190613700565b60405180910390a350919050565b6119266123d3565b60708260405161193691906133ff565b9081526020016040518091039020805461194f906131f9565b1590506119b15760405162461bcd60e51b815260206004820152602a60248201527f536572766963654d616e616765722e6465706c6f79506f6c6963793a20706f6c6044820152696963792065786973747360b01b606482015260840161122b565b806070836040516119c291906133ff565b908152602001604051809103902090805190602001906119e39291906128a3565b50607180546001810182556000919091528251611a27917fa1fcd19bfe8c32a61095b6bfbb2664842857e148fcbb5188386c8cd40348d5b6019060208501906128a3565b5081604051611a3691906133ff565b60405180910390207fb6487025b06543ad686bdaa829e2b07863fd163cacd2e0f031340308ec09584e82604051611a6d9190612db8565b60405180910390a25050565b6067546001600160a01b03163314611aa4576040516332c5b57b60e11b815260040160405180910390fd5b6000611ab0838561090e565b6000818152606e602052604090205490915060ff161580611ada5750611ad86116ee856135e7565b155b15611af85760405163d08f561d60e01b815260040160405180910390fd5b6000818152606e6020526040808220805460ff191690555184917f2a8b097d3dd38ed5fe131a385c16133baae1d9bd3d75f3576068b9211dfd7b5c91a250505050565b60008151835114611b9e5760405162461bcd60e51b815260206004820152602760248201527f4d69736d61746368206265747765656e207369676e65727320616e64207369676044820152666e61747572657360c81b606482015260840161122b565b8360e00135431115611c0d5760405162461bcd60e51b815260206004820152603260248201527f536572766963654d616e616765722e416574686f7356657269666965643a20746044820152711c985b9cd858dd1a5bdb88195e1c1a5c995960721b606482015260840161122b565b6000611c188561216d565b905060005b611c2d60e0870160c08801613314565b63ffffffff16811015611e0157600081118015611c98575084611c5160018361325a565b81518110611c6157611c6161322e565b60200260200101516001600160a01b0316858281518110611c8457611c8461322e565b60200260200101516001600160a01b031611155b15611cf85760405162461bcd60e51b815260206004820152602a60248201527f5369676e657220616464726573736573206d75737420626520756e6971756520604482015269185b99081cdbdc9d195960b21b606482015260840161122b565b6000611d1d83868481518110611d1057611d1061322e565b602002602001015161252e565b9050858281518110611d3157611d3161322e565b60200260200101516001600160a01b0316816001600160a01b031614611d8d5760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b604482015260640161122b565b6001600160a01b038082166000908152607460205260409020541660016001600160a01b0382166000908152606d602052604090206001015460ff166002811115611dda57611dda612a43565b14611df75760405162461bcd60e51b815260040161122b906137c5565b5050600101611c1d565b50600195945050505050565b60606073805480602002602001604051908101604052809291908181526020016000905b82821015610776578382906000526020600020018054611e50906131f9565b80601f0160208091040260200160405190810160405280929190818152602001828054611e7c906131f9565b8015611ec95780601f10611e9e57610100808354040283529160200191611ec9565b820191906000526020600020905b815481529060010190602001808311611eac57829003601f168201915b505050505081526020019060010190611e31565b611ee56123d3565b607282604051611ef591906133ff565b90815260200160405180910390208054611f0e906131f9565b159050611f7b5760405162461bcd60e51b815260206004820152603560248201527f536572766963654d616e616765722e6465706c6f79536f6369616c47726170686044820152743a20736f6369616c2067726170682065786973747360581b606482015260840161122b565b80607283604051611f8c91906133ff565b90815260200160405180910390209080519060200190611fad9291906128a3565b50607380546001810182556000919091528251611ff1917ff79bde9ddd17963ebce6f7d021d60de7c2bd0db944d23c900c0c0e775f530052019060208501906128a3565b508160405161200091906133ff565b60405180910390207f0547683ac2bbf227b34fe50fb3ef0f2b8a67dfad502dc794e7a69b0a8dd3e68082604051611a6d9190612db8565b606b818154811061204757600080fd5b6000918252602090912001546001600160a01b0316905081565b8051602081830181018051607082529282019190930120915280546110d6906131f9565b8051602081830181018051607282529282019190930120915280546110d6906131f9565b607381815481106110bb57600080fd5b6120c16123d3565b606980546001600160a01b0319166001600160a01b0383169081179091556040517fcb08c26360210256eb3fd98640509ba95a8a716bc3aa4aadc738e333102de73790600090a250565b6060606b80548060200260200160405190810160405280929190818152602001828054801561216357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612145575b5050505050905090565b600061217982806132ba565b6121896040850160208601612a1f565b6121996060860160408701612a1f565b6121a9608087016060880161329f565b6121b660808801886132ba565b6121c360a08a018a6132ba565b6121d360e08c0160c08d01613314565b8b60e001356040516020016121f29b9a99989796959493929190613808565b604051602081830303815290604052805190602001209050919050565b6122176123d3565b6001600160a01b03811661227c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161122b565b6122858161242d565b50565b6122906123d3565b60016001600160a01b0384166000908152606d602052604090206001015460ff1660028111156122c2576122c2612a43565b1461233f5760405162461bcd60e51b815260206004820152604160248201527f536572766963654d616e616765722e726f74617465416574686f735369676e6960448201527f6e674b65793a206f70657261746f72206973206e6f74207265676973746572656064820152601960fa1b608482015260a40161122b565b6001600160a01b0391821660009081526074602052604080822080546001600160a01b0319908116909155928416825290208054939092169216919091179055565b6123896123d3565b606780546001600160a01b0319166001600160a01b0383169081179091556040517f602cec4b1583b07d071161da5eb9589444d2459201e2fab7753dc941e9351c2190600090a250565b6033546001600160a01b03163314610fea5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161122b565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000805b8460a0015163ffffffff1681146125235760006124ac84868481518110611d1057611d1061322e565b6001600160a01b038082166000908152607460205260409020549192501660016001600160a01b0382166000908152606d602052604090206001015460ff1660028111156124fc576124fc612a43565b146125195760405162461bcd60e51b815260040161122b906137c5565b5050600101612483565b506001949350505050565b600080600061253d8585612552565b9150915061254a816125c2565b509392505050565b6000808251604114156125895760208301516040840151606085015160001a61257d8782858561277d565b945094505050506125bb565b8251604014156125b357602083015160408401516125a886838361286a565b9350935050506125bb565b506000905060025b9250929050565b60008160048111156125d6576125d6612a43565b14156125df5750565b60018160048111156125f3576125f3612a43565b14156126415760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161122b565b600281600481111561265557612655612a43565b14156126a35760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161122b565b60038160048111156126b7576126b7612a43565b14156127105760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161122b565b600481600481111561272457612724612a43565b14156122855760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161122b565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156127b45750600090506003612861565b8460ff16601b141580156127cc57508460ff16601c14155b156127dd5750600090506004612861565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612831573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661285a57600060019250925050612861565b9150600090505b94509492505050565b6000806001600160ff1b0383168161288760ff86901c601b613464565b90506128958782888561277d565b935093505050935093915050565b8280546128af906131f9565b90600052602060002090601f0160209004810192826128d15760008555612917565b82601f106128ea57805160ff1916838001178555612917565b82800160010185558215612917579182015b828111156129175782518255916020019190600101906128fc565b50612923929150612927565b5090565b5b808211156129235760008155600101612928565b60005b8381101561295757818101518382015260200161293f565b83811115612966576000848401525b50505050565b6000815180845261298481602086016020860161293c565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156129ed57603f198886030184526129db85835161296c565b945092850192908501906001016129bf565b5092979650505050505050565b6001600160a01b038116811461228557600080fd5b8035612a1a816129fa565b919050565b600060208284031215612a3157600080fd5b8135612a3c816129fa565b9392505050565b634e487b7160e01b600052602160045260246000fd5b8281526040810160038310612a7e57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b634e487b7160e01b600052604160045260246000fd5b60405160c081016001600160401b0381118282101715612ac357612ac3612a8b565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612af157612af1612a8b565b604052919050565b600082601f830112612b0a57600080fd5b81356001600160401b03811115612b2357612b23612a8b565b612b36601f8201601f1916602001612ac9565b818152846020838601011115612b4b57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060408385031215612b7b57600080fd5b8235612b86816129fa565b915060208301356001600160401b03811115612ba157600080fd5b612bad85828601612af9565b9150509250929050565b600060c08284031215612bc957600080fd5b50919050565b60008060408385031215612be257600080fd5b8235915060208301356001600160401b03811115612bff57600080fd5b612bad85828601612bb7565b6020808252825182820181905260009190848201906040850190845b81811015612c4c5783516001600160a01b031683529284019291840191600101612c27565b50909695505050505050565b600060208284031215612c6a57600080fd5b81356001600160401b03811115612c8057600080fd5b612c8c84828501612af9565b949350505050565b60008060008060408587031215612caa57600080fd5b84356001600160401b0380821115612cc157600080fd5b818701915087601f830112612cd557600080fd5b813581811115612ce457600080fd5b8860208260051b8501011115612cf957600080fd5b602092830196509450908601359080821115612d1457600080fd5b818701915087601f830112612d2857600080fd5b813581811115612d3757600080fd5b886020828501011115612d4957600080fd5b95989497505060200194505050565b600080600060608486031215612d6d57600080fd5b8335612d78816129fa565b9250602084013560ff81168114612d8e57600080fd5b929592945050506040919091013590565b600060208284031215612db157600080fd5b5035919050565b602081526000612a3c602083018461296c565b60008060008060008060c08789031215612de457600080fd5b8635612def816129fa565b95506020870135612dff816129fa565b94506040870135612e0f816129fa565b93506060870135612e1f816129fa565b92506080870135612e2f816129fa565b8092505060a087013590509295509295509295565b60008060408385031215612e5757600080fd5b8235612e62816129fa565b915060208301356001600160401b0380821115612e7e57600080fd5b9084019060608287031215612e9257600080fd5b604051606081018181108382111715612ead57612ead612a8b565b604052823582811115612ebf57600080fd5b612ecb88828601612af9565b82525060208301356020820152604083013560408201528093505050509250929050565b60006001600160401b03821115612f0857612f08612a8b565b5060051b60200190565b600082601f830112612f2357600080fd5b81356020612f38612f3383612eef565b612ac9565b82815260059290921b84018101918181019086841115612f5757600080fd5b8286015b84811015612f965780356001600160401b03811115612f7a5760008081fd5b612f888986838b0101612af9565b845250918301918301612f5b565b509695505050505050565b600080600060608486031215612fb657600080fd5b83356001600160401b0380821115612fcd57600080fd5b612fd987838801612bb7565b9450602086013593506040860135915080821115612ff657600080fd5b5061300386828701612f12565b9150509250925092565b60006020828403121561301f57600080fd5b81356001600160401b0381111561303557600080fd5b612c8c84828501612bb7565b6000806040838503121561305457600080fd5b82356001600160401b038082111561306b57600080fd5b61307786838701612af9565b9350602085013591508082111561308d57600080fd5b50612bad85828601612af9565b60006101008284031215612bc957600080fd5b6000806000606084860312156130c257600080fd5b83356001600160401b03808211156130d957600080fd5b6130e58783880161309a565b94506020915081860135818111156130fc57600080fd5b8601601f8101881361310d57600080fd5b803561311b612f3382612eef565b81815260059190911b8201840190848101908a83111561313a57600080fd5b928501925b82841015613161578335613152816129fa565b8252928501929085019061313f565b96505050506040860135915080821115612ff657600080fd5b60006020828403121561318c57600080fd5b81356001600160401b038111156131a257600080fd5b612c8c8482850161309a565b6000806000606084860312156131c357600080fd5b83356131ce816129fa565b925060208401356131de816129fa565b915060408401356131ee816129fa565b809150509250925092565b600181811c9082168061320d57607f821691505b60208210811415612bc957634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008282101561326c5761326c613244565b500390565b634e487b7160e01b600052603160045260246000fd5b80356001600160e01b031981168114612a1a57600080fd5b6000602082840312156132b157600080fd5b612a3c82613287565b6000808335601e198436030181126132d157600080fd5b8301803591506001600160401b038211156132eb57600080fd5b6020019150368190038213156125bb57600080fd5b803563ffffffff81168114612a1a57600080fd5b60006020828403121561332657600080fd5b612a3c82613300565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8981526001600160a01b038981166020830152881660408201526001600160e01b03198716606082015260e06080820181905260009061339b908301878961332f565b82810360a08401526133ae81868861332f565b91505063ffffffff831660c08301529a9950505050505050505050565b6000602082840312156133dd57600080fd5b5051919050565b60006000198214156133f8576133f8613244565b5060010190565b6000825161341181846020870161293c565b9190910192915050565b6000808335601e1984360301811261343257600080fd5b8301803591506001600160401b0382111561344c57600080fd5b6020019150600581901b36038213156125bb57600080fd5b6000821982111561347757613477613244565b500190565b8183823760009101908152919050565b60008184825b85811015613522578135601e198836030181126134ae57600080fd5b8701803560206001600160401b038211156134c857600080fd5b8160051b36038a13156134da57600080fd5b918201918560005b838110156135105784356134f5816129fa565b6001600160a01b0316825293820193908201906001016134e2565b50955093909301925050600101613492565b509095945050505050565b60006040828403121561353f57600080fd5b604051604081018181106001600160401b038211171561356157613561612a8b565b604052825161356f816129fa565b815260208301516bffffffffffffffffffffffff8116811461359057600080fd5b60208201529392505050565b60018060a01b03831681526040602082015260008251606060408401526135c660a084018261296c565b90506020840151606084015260408401516080840152809150509392505050565b600060c082360312156135f957600080fd5b613601612aa1565b61360a83612a0f565b815261361860208401612a0f565b602082015261362960408401613287565b604082015260608301356001600160401b038082111561364857600080fd5b61365436838701612af9565b6060840152608085013591508082111561366d57600080fd5b5061367a36828601612af9565b60808301525061368c60a08401613300565b60a082015292915050565b6001600160e01b031984168152818360048301376000910160040190815292915050565b6000808335601e198436030181126136d257600080fd5b83016020810192503590506001600160401b038111156136f157600080fd5b8036038313156125bb57600080fd5b6020815260008235613711816129fa565b6001600160a01b0390811660208481019190915284013590613732826129fa565b166040838101919091526001600160e01b031990613751908501613287565b16606083015261376460608401846136bb565b60c0608085015261377960e08501828461332f565b91505061378960808501856136bb565b848303601f190160a08601526137a083828461332f565b9250505063ffffffff6137b560a08601613300565b1660c08401528091505092915050565b60208082526023908201527f5369676e6572206973206e6f7420612072656769737465726564206f706572616040820152623a37b960e91b606082015260800190565b6101008152600061381e61010083018d8f61332f565b6001600160a01b038c811660208501528b1660408401526001600160e01b03198a166060840152828103608084015261385881898b61332f565b905082810360a084015261386d81878961332f565b63ffffffff9590951660c0840152505060e00152999850505050505050505056fea26469706673582212202b419b42deb0858532d32959747a64c5c840e041b144198c5f7ba607debfd66064736f6c634300080c0033
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.