-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01b1940
commit 317d814
Showing
9 changed files
with
276 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity >=0.5.0; | ||
|
||
import {IStrategy} from "./IStrategy.sol"; | ||
|
||
struct StrategyParams { | ||
IStrategy strategy; // The strategy contract reference | ||
uint96 multiplier; // The multiplier applied to the strategy | ||
} | ||
|
||
struct Quorum { | ||
StrategyParams[] strategies; // An array of strategy parameters to define the quorum | ||
} | ||
|
||
interface IECDSAStakeRegistry { | ||
function quorum() external view returns (Quorum memory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity >=0.5.0; | ||
|
||
import {ISignatureUtils} from "./ISignatureUtils.sol"; | ||
|
||
/** | ||
* @title Minimal interface for a ServiceManager-type contract that forms the single point for an AVS to push updates to EigenLayer | ||
* @author Layr Labs, Inc. | ||
*/ | ||
interface IServiceManager { | ||
/** | ||
* @notice Updates the metadata URI for the AVS | ||
* @param _metadataURI is the metadata URI for the AVS | ||
*/ | ||
function updateAVSMetadataURI(string memory _metadataURI) external; | ||
|
||
/** | ||
* @notice Forwards a call to EigenLayer's DelegationManager contract to confirm operator registration 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 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 Returns the EigenLayer AVSDirectory contract. | ||
function avsDirectory() external view returns (address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity >=0.5.0; | ||
|
||
/** | ||
* @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 { | ||
/** | ||
* @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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters