-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: service manager payments (#242)
* feat: service manager payments * test: unit tests * feat: refactor serviceManager interfaces * chore: requested changes
- Loading branch information
Showing
14 changed files
with
869 additions
and
52 deletions.
There are no files selected for viewing
Submodule eigenlayer-contracts
updated
29 files
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 |
---|---|---|
@@ -1,53 +1,26 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity >=0.5.0; | ||
|
||
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol"; | ||
import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; | ||
import {IPaymentCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; | ||
import {IServiceManagerUI} from "./IServiceManagerUI.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 { | ||
interface IServiceManager is IServiceManagerUI { | ||
/** | ||
* @notice Updates the metadata URI for the AVS | ||
* @param _metadataURI is the metadata URI for the AVS | ||
* @notice Creates a new range payment on behalf of an AVS, to be split amongst the | ||
* set of stakers delegated to operators who are registered to the `avs`. | ||
* Note that the owner calling this function must have approved the tokens to be transferred to the ServiceManager | ||
* and of course has the required balances. | ||
* @param rangePayments The range payments being created | ||
* @dev Expected to be called by the ServiceManager of the AVS on behalf of which the payment is being made | ||
* @dev The duration of the `rangePayment` cannot exceed `paymentCoordinator.MAX_PAYMENT_DURATION()` | ||
* @dev The tokens are sent to the `PaymentCoordinator` contract | ||
* @dev Strategies must be in ascending order of addresses to check for duplicates | ||
* @dev This function will revert if the `rangePayment` is malformed, | ||
* e.g. if the `strategies` and `weights` arrays are of non-equal lengths | ||
*/ | ||
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); | ||
function payForRange(IPaymentCoordinator.RangePayment[] calldata rangePayments) 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,62 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity >=0.5.0; | ||
|
||
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol"; | ||
import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; | ||
|
||
/** | ||
* @title Minimal interface for a ServiceManager-type contract that AVS ServiceManager contracts must implement | ||
* for eigenlabs to be able to index their data on the AVS marketplace frontend. | ||
* @author Layr Labs, Inc. | ||
*/ | ||
interface IServiceManagerUI { | ||
/** | ||
* Metadata should follow the format outlined by this example. | ||
{ | ||
"name": "EigenLabs AVS 1", | ||
"website": "https://www.eigenlayer.xyz/", | ||
"description": "This is my 1st AVS", | ||
"logo": "https://holesky-operator-metadata.s3.amazonaws.com/eigenlayer.png", | ||
"twitter": "https://twitter.com/eigenlayer" | ||
} | ||
* @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,66 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.12; | ||
|
||
import "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; | ||
|
||
interface IServiceManagerBaseEvents { | ||
/// PaymentCoordinator EVENTS /// | ||
|
||
/// @notice emitted when an AVS creates a valid RangePayment | ||
event RangePaymentCreated( | ||
address indexed avs, | ||
uint256 indexed paymentNonce, | ||
bytes32 indexed rangePaymentHash, | ||
IPaymentCoordinator.RangePayment rangePayment | ||
); | ||
/// @notice emitted when a valid RangePayment is created for all stakers by a valid submitter | ||
event RangePaymentForAllCreated( | ||
address indexed submitter, | ||
uint256 indexed paymentNonce, | ||
bytes32 indexed rangePaymentHash, | ||
IPaymentCoordinator.RangePayment rangePayment | ||
); | ||
/// @notice paymentUpdater is responsible for submiting DistributionRoots, only owner can set paymentUpdater | ||
event PaymentUpdaterSet(address indexed oldPaymentUpdater, address indexed newPaymentUpdater); | ||
event PayAllForRangeSubmitterSet( | ||
address indexed payAllForRangeSubmitter, | ||
bool indexed oldValue, | ||
bool indexed newValue | ||
); | ||
event ActivationDelaySet(uint32 oldActivationDelay, uint32 newActivationDelay); | ||
event CalculationIntervalSecondsSet(uint32 oldCalculationIntervalSeconds, uint32 newCalculationIntervalSeconds); | ||
event GlobalCommissionBipsSet(uint16 oldGlobalCommissionBips, uint16 newGlobalCommissionBips); | ||
event ClaimerForSet(address indexed earner, address indexed oldClaimer, address indexed claimer); | ||
/// @notice rootIndex is the specific array index of the newly created root in the storage array | ||
event DistributionRootSubmitted( | ||
uint32 indexed rootIndex, | ||
bytes32 indexed root, | ||
uint32 paymentCalculationEndTimestamp, | ||
uint32 activatedAt | ||
); | ||
/// @notice root is one of the submitted distribution roots that was claimed against | ||
event PaymentClaimed( | ||
bytes32 root, | ||
address indexed earner, | ||
address indexed claimer, | ||
IERC20 indexed token, | ||
uint256 claimedAmount | ||
); | ||
|
||
|
||
|
||
/// TOKEN EVENTS FOR TESTING /// | ||
/** | ||
* @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); | ||
} |
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
Oops, something went wrong.