Skip to content

Commit

Permalink
add: EigenLayer dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinj615 committed Jun 11, 2024
1 parent 2af5f88 commit 1900e8c
Show file tree
Hide file tree
Showing 23 changed files with 3,278 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contracts/EigenLayer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Note

This is the M2 (second mainnet release) of the EigenLayer contracts.

This is copied from the EL repo for convenience from master at the initial build phase.
Once this repo is tagged with a final release or a public NPM package is published, those versions should be used instead.
Another possibility is to use a git submodule

The commit used is
https://github.com/Layr-Labs/eigenlayer-contracts/commit/90a0f6aee79b4a38e1b63b32f9627f21b1162fbb
71 changes: 71 additions & 0 deletions contracts/EigenLayer/interfaces/IAVSDirectory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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);
}
12 changes: 12 additions & 0 deletions contracts/EigenLayer/interfaces/IBeaconChainOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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);
}
90 changes: 90 additions & 0 deletions contracts/EigenLayer/interfaces/IDelayedWithdrawalRouter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;

interface IDelayedWithdrawalRouter {
// struct used to pack data into a single storage slot
struct DelayedWithdrawal {
uint224 amount;
uint32 blockCreated;
}

// struct used to store a single users delayedWithdrawal data
struct UserDelayedWithdrawals {
uint256 delayedWithdrawalsCompleted;
DelayedWithdrawal[] delayedWithdrawals;
}

/// @notice event for delayedWithdrawal creation
event DelayedWithdrawalCreated(
address podOwner,
address recipient,
uint256 amount,
uint256 index
);

/// @notice event for the claiming of delayedWithdrawals
event DelayedWithdrawalsClaimed(
address recipient,
uint256 amountClaimed,
uint256 delayedWithdrawalsCompleted
);

/// @notice Emitted when the `withdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
event WithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue);

/**
* @notice Creates an delayed withdrawal for `msg.value` to the `recipient`.
* @dev Only callable by the `podOwner`'s EigenPod contract.
*/
function createDelayedWithdrawal(address podOwner, address recipient) external payable;

/**
* @notice Called in order to withdraw delayed withdrawals made to the `recipient` that have passed the `withdrawalDelayBlocks` period.
* @param recipient The address to claim delayedWithdrawals for.
* @param maxNumberOfWithdrawalsToClaim Used to limit the maximum number of withdrawals to loop through claiming.
*/
function claimDelayedWithdrawals(
address recipient,
uint256 maxNumberOfWithdrawalsToClaim
) external;

/**
* @notice Called in order to withdraw delayed withdrawals made to the caller that have passed the `withdrawalDelayBlocks` period.
* @param maxNumberOfWithdrawalsToClaim Used to limit the maximum number of withdrawals to loop through claiming.
*/
function claimDelayedWithdrawals(uint256 maxNumberOfWithdrawalsToClaim) external;

/// @notice Owner-only function for modifying the value of the `withdrawalDelayBlocks` variable.
function setWithdrawalDelayBlocks(uint256 newValue) external;

/// @notice Getter function for the mapping `_userWithdrawals`
function userWithdrawals(address user) external view returns (UserDelayedWithdrawals memory);

/// @notice Getter function to get all delayedWithdrawals of the `user`
function getUserDelayedWithdrawals(
address user
) external view returns (DelayedWithdrawal[] memory);

/// @notice Getter function to get all delayedWithdrawals that are currently claimable by the `user`
function getClaimableUserDelayedWithdrawals(
address user
) external view returns (DelayedWithdrawal[] memory);

/// @notice Getter function for fetching the delayedWithdrawal at the `index`th entry from the `_userWithdrawals[user].delayedWithdrawals` array
function userDelayedWithdrawalByIndex(
address user,
uint256 index
) external view returns (DelayedWithdrawal memory);

/// @notice Getter function for fetching the length of the delayedWithdrawals array of a specific user
function userWithdrawalsLength(address user) external view returns (uint256);

/// @notice Convenience function for checking whether or not the delayedWithdrawal at the `index`th entry from the `_userWithdrawals[user].delayedWithdrawals` array is currently claimable
function canClaimDelayedWithdrawal(address user, uint256 index) external view returns (bool);

/**
* @notice Delay enforced by this contract for completing any delayedWithdrawal. 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 withdrawalDelayBlocks() external view returns (uint256);
}
47 changes: 47 additions & 0 deletions contracts/EigenLayer/interfaces/IDelegationFaucet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;

import "./IStrategyManager.sol";
import "./IDelegationManager.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IDelegationFaucet {
function mintDepositAndDelegate(
address _operator,
IDelegationManager.SignatureWithExpiry memory approverSignatureAndExpiry,
bytes32 approverSalt,
uint256 _depositAmount
) external;

function getStaker(address operator) external returns (address);

function depositIntoStrategy(
address staker,
IStrategy strategy,
IERC20 token,
uint256 amount
) external returns (bytes memory);

function queueWithdrawal(
address staker,
IDelegationManager.QueuedWithdrawalParams[] calldata queuedWithdrawalParams
) external returns (bytes memory);

function completeQueuedWithdrawal(
address staker,
IDelegationManager.Withdrawal calldata queuedWithdrawal,
IERC20[] calldata tokens,
uint256 middlewareTimesIndex,
bool receiveAsTokens
) external returns (bytes memory);

function transfer(
address staker,
address token,
address to,
uint256 amount
) external returns (bytes memory);

function callAddress(address to, bytes memory data) external payable returns (bytes memory);
}
Loading

0 comments on commit 1900e8c

Please sign in to comment.