Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MachServiceManager
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: UNLICENSED
// SEE LICENSE IN https://files.altlayer.io/Alt-Research-License-1.md
// Copyright Alt Research Ltd. 2023. All rights reserved.
//
// You acknowledge and agree that Alt Research Ltd. ("Alt Research") (or Alt
// Research's licensors) own all legal rights, titles and interests in and to the
// work, software, application, source code, documentation and any other documents
pragma solidity =0.8.12;
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Pausable} from "eigenlayer-core/contracts/permissions/Pausable.sol";
import {IRewardsCoordinator} from "eigenlayer-core/contracts/interfaces/IRewardsCoordinator.sol";
import {IAVSDirectory} from "eigenlayer-core/contracts/interfaces/IAVSDirectory.sol";
import {ISignatureUtils} from "eigenlayer-core/contracts/interfaces/ISignatureUtils.sol";
import {IPauserRegistry} from "eigenlayer-core/contracts/interfaces/IPauserRegistry.sol";
import {IServiceManager, IServiceManagerUI} from "eigenlayer-middleware/interfaces/IServiceManager.sol";
import {IStakeRegistry} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";
import {IRegistryCoordinator} from "eigenlayer-middleware/interfaces/IRegistryCoordinator.sol";
import {IBLSSignatureChecker} from "eigenlayer-middleware/interfaces/IBLSSignatureChecker.sol";
import {ServiceManagerBase} from "eigenlayer-middleware/ServiceManagerBase.sol";
import {MachServiceManagerStorage} from "./MachServiceManagerStorage.sol";
import {
InvalidConfirmer,
NotWhitelister,
ZeroAddress,
AlreadyInAllowlist,
NotAdded,
NoStatusChange,
InvalidRollupChainID,
InvalidReferenceBlockNum,
InsufficientThreshold,
InvalidStartIndex,
InsufficientThresholdPercentages,
InvalidSender,
InvalidQuorumParam,
InvalidQuorumThresholdPercentage,
AlreadyAdded,
ResolvedAlert,
AlreadyEnabled,
AlreadyDisabled
} from "../error/Errors.sol";
import {IMachServiceManager} from "../interfaces/IMachServiceManager.sol";
contract ReservedStorageGap {
// This is a placeholder to ensure that the storage layout of the contract
// is compatible with the original contract.
uint256[50] private __GAP;
}
/**
* @title Primary entrypoint for procuring services from Altlayer Mach Service.
* @author Altlayer, Inc.
* @notice This contract is used for:
* - whitelisting operators
* - confirming the alert store by the aggregator with inferred aggregated signatures of the quorum
*/
contract MachServiceManager is
IMachServiceManager,
MachServiceManagerStorage,
ServiceManagerBase,
ReservedStorageGap,
Pausable
{
using EnumerableSet for EnumerableSet.Bytes32Set;
using EnumerableSet for EnumerableSet.AddressSet;
// Add IBLSSignatureChecker as a state variable
IBLSSignatureChecker public immutable signatureChecker;
/**
* @dev Ensures that the function is only callable by the `alertConfirmer`.
*/
modifier onlyAlertConfirmer() {
if (_msgSender() != alertConfirmer) {
revert InvalidConfirmer();
}
_;
}
/**
* @dev Ensures that the function is only callable by the `whitelister`.
*/
modifier onlyWhitelister() {
if (_msgSender() != whitelister) {
revert NotWhitelister();
}
_;
}
/**
* @dev Ensures that the `rollupChainID` is valid.
*/
modifier onlyValidRollupChainID(uint256 rollupChainID) {
if (!rollupChainIDs[rollupChainID]) {
revert InvalidRollupChainID();
}
_;
}
constructor(
IAVSDirectory __avsDirectory,
IRewardsCoordinator __rewardsCoordinator,
IRegistryCoordinator __registryCoordinator,
IStakeRegistry __stakeRegistry,
IBLSSignatureChecker __signatureChecker
) ServiceManagerBase(__avsDirectory, __rewardsCoordinator, __registryCoordinator, __stakeRegistry) {
signatureChecker = __signatureChecker;
_disableInitializers();
}
function initialize(
IPauserRegistry pauserRegistry_,
uint256 initialPausedStatus_,
address initialOwner_,
address rewardsInitiator_,
address alertConfirmer_,
address whitelister_,
uint256[] calldata rollupChainIDs_
) public initializer {
_initializePauser(pauserRegistry_, initialPausedStatus_);
__ServiceManagerBase_init(initialOwner_, rewardsInitiator_);
_setAlertConfirmer(alertConfirmer_);
_setWhitelister(whitelister_);
for (uint256 i; i < rollupChainIDs_.length; ++i) {
_setRollupChainID(rollupChainIDs_[i], true);
}
allowlistEnabled = true;
quorumThresholdPercentage = 66;
}
//////////////////////////////////////////////////////////////////////////////
// Admin Functions //
//////////////////////////////////////////////////////////////////////////////
function setAllowlist(address[] calldata operators, bool[] calldata status) external onlyWhitelister {
require(operators.length == status.length, "Input arrays length mismatch");
for (uint256 i = 0; i < operators.length; ++i) {
address operator = operators[i];
if (operator == address(0)) {
revert ZeroAddress();
}
if (status[i]) {
_allowlist.add(operator);
} else {
_allowlist.remove(operator);
}
}
emit AllowlistUpdated(operators, status);
}
/**
* @inheritdoc IMachServiceManager
*/
function enableAllowlist() external onlyOwner {
if (allowlistEnabled) {
revert AlreadyEnabled();
} else {
allowlistEnabled = true;
emit AllowlistEnabled();
}
}
/**
* @inheritdoc IMachServiceManager
*/
function disableAllowlist() external onlyOwner {
if (!allowlistEnabled) {
revert AlreadyDisabled();
} else {
allowlistEnabled = false;
emit AllowlistDisabled();
}
}
/**
* @inheritdoc IMachServiceManager
*/
function setConfirmer(address confirmer) external onlyOwner {
_setAlertConfirmer(confirmer);
}
/**
* @inheritdoc IMachServiceManager
*/
function setWhitelister(address whitelister) external onlyOwner {
_setWhitelister(whitelister);
}
/**
* @inheritdoc IMachServiceManager
*/
function setRollupChainID(uint256 rollupChainId, bool status) external onlyOwner {
_setRollupChainID(rollupChainId, status);
}
/**
* @inheritdoc IMachServiceManager
*/
function removeAlert(uint256 rollupChainId, bytes32 messageHash)
external
onlyValidRollupChainID(rollupChainId)
onlyOwner
{
bool ret = _messageHashes[rollupChainId].remove(messageHash);
if (ret) {
_resolvedMessageHashes[rollupChainId].add(messageHash);
emit AlertRemoved(messageHash, _msgSender());
}
}
/**
* @inheritdoc IMachServiceManager
*/
function updateQuorumThresholdPercentage(uint8 thresholdPercentage) external onlyOwner {
if (thresholdPercentage > 100) {
revert InvalidQuorumThresholdPercentage();
}
quorumThresholdPercentage = thresholdPercentage;
emit QuorumThresholdPercentageChanged(thresholdPercentage);
}
//////////////////////////////////////////////////////////////////////////////
// Operator Registration //
//////////////////////////////////////////////////////////////////////////////
/**
* @inheritdoc IServiceManagerUI
*/
function registerOperatorToAVS(
address operator,
ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature
) public override(ServiceManagerBase, IServiceManagerUI) whenNotPaused onlyRegistryCoordinator {
if (allowlistEnabled && !isOperatorAllowed(operator)) {
revert NotAdded();
}
// Stake requirement for quorum is checked in StakeRegistry.sol
// https://github.com/Layr-Labs/eigenlayer-middleware/blob/dev/src/RegistryCoordinator.sol#L488
// https://github.com/Layr-Labs/eigenlayer-middleware/blob/dev/src/StakeRegistry.sol#L84
_avsDirectory.registerOperatorToAVS(operator, operatorSignature);
}
/**
* @inheritdoc IServiceManagerUI
*/
function deregisterOperatorFromAVS(address operator)
public
override(ServiceManagerBase, IServiceManagerUI)
whenNotPaused
onlyRegistryCoordinator
{
_avsDirectory.deregisterOperatorFromAVS(operator);
}
//////////////////////////////////////////////////////////////////////////////
// Alert Functions //
//////////////////////////////////////////////////////////////////////////////
/**
* @inheritdoc IMachServiceManager
*/
function confirmAlert(
AlertHeader calldata alertHeader,
IBLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature
) external whenNotPaused onlyAlertConfirmer onlyValidRollupChainID(alertHeader.rollupChainID) {
// make sure the information needed to derive the non-signers and batch is in calldata to avoid emitting events
if (tx.origin != msg.sender) {
revert InvalidSender();
}
// check is it is the resolved alert before
if (_resolvedMessageHashes[alertHeader.rollupChainID].contains(alertHeader.messageHash)) {
revert ResolvedAlert();
}
// make sure the stakes against which the Batch is being confirmed are not stale
if (alertHeader.referenceBlockNumber >= block.number) {
revert InvalidReferenceBlockNum();
}
bytes32 hashedHeader = _hashAlertHeader(alertHeader);
// check quorum parameters
if (alertHeader.quorumNumbers.length != alertHeader.quorumThresholdPercentages.length) {
revert InvalidQuorumParam();
}
(IBLSSignatureChecker.QuorumStakeTotals memory quorumStakeTotals, /* bytes32 signatoryRecordHash */ ) =
signatureChecker.checkSignatures(
hashedHeader, alertHeader.quorumNumbers, alertHeader.referenceBlockNumber, nonSignerStakesAndSignature
);
// check that signatories own at least a threshold percentage of each quourm
for (uint256 i = 0; i < alertHeader.quorumThresholdPercentages.length; i++) {
// signed stake > total stake
// signedStakeForQuorum[i] / totalStakeForQuorum[i] * THRESHOLD_DENOMINATOR >= quorumThresholdPercentages[i]
// => signedStakeForQuorum[i] * THRESHOLD_DENOMINATOR >= totalStakeForQuorum[i] * quorumThresholdPercentages[i]
uint8 currentQuorumThresholdPercentages = uint8(alertHeader.quorumThresholdPercentages[i]);
if (currentQuorumThresholdPercentages > 100) {
revert InvalidQuorumThresholdPercentage();
}
if (currentQuorumThresholdPercentages < quorumThresholdPercentage) {
revert InsufficientThresholdPercentages();
}
if (
quorumStakeTotals.signedStakeForQuorum[i] * THRESHOLD_DENOMINATOR
< quorumStakeTotals.totalStakeForQuorum[i] * currentQuorumThresholdPercentages
) {
revert InsufficientThreshold();
}
}
// store alert
bool success = _messageHashes[alertHeader.rollupChainID].add(alertHeader.messageHash);
if (!success) {
revert AlreadyAdded();
}
emit AlertConfirmed(hashedHeader, alertHeader.messageHash);
}
//////////////////////////////////////////////////////////////////////////////
// View Functions //
//////////////////////////////////////////////////////////////////////////////
/**
* @inheritdoc IMachServiceManager
*/
function totalAlerts(uint256 rollupChainId) external view returns (uint256) {
return _messageHashes[rollupChainId].length();
}
/**
* @inheritdoc IMachServiceManager
*/
function contains(uint256 rollupChainId, bytes32 messageHash) external view returns (bool) {
return _messageHashes[rollupChainId].contains(messageHash);
}
/**
* @inheritdoc IMachServiceManager
*/
function queryMessageHashes(uint256 rollupChainId, uint256 start, uint256 querySize)
external
view
returns (bytes32[] memory)
{
uint256 length = _messageHashes[rollupChainId].length();
if (start >= length) {
revert InvalidStartIndex();
}
uint256 end = start + querySize;
if (end > length) {
end = length;
}
bytes32[] memory output = new bytes32[](end - start);
for (uint256 i = start; i < end; ++i) {
output[i - start] = _messageHashes[rollupChainId].at(i);
}
return output;
}
function isOperatorAllowed(address operator) public view returns (bool) {
return _allowlist.contains(operator);
}
function getAllowlistSize() public view returns (uint256) {
return _allowlist.length();
}
function getAllowlistAtIndex(uint256 index) public view returns (address) {
return _allowlist.at(index);
}
//////////////////////////////////////////////////////////////////////////////
// Internal Functions //
//////////////////////////////////////////////////////////////////////////////
/**
* @dev Hashes an alert header
*/
function _hashAlertHeader(AlertHeader calldata alertHeader) internal pure returns (bytes32) {
return keccak256(abi.encode(_convertAlertHeaderToReducedAlertHeader(alertHeader)));
}
/**
* @dev Changes the alert confirmer
*/
function _setAlertConfirmer(address _alertConfirmer) internal {
address previousBatchConfirmer = alertConfirmer;
alertConfirmer = _alertConfirmer;
emit AlertConfirmerChanged(previousBatchConfirmer, alertConfirmer);
}
/**
* @dev Changes the whitelister
*/
function _setWhitelister(address _whitelister) internal {
address previousWhitelister = whitelister;
whitelister = _whitelister;
emit WhitelisterChanged(previousWhitelister, _whitelister);
}
/**
* @dev Converts an alert header to a reduced alert header
* @param alertHeader the alert header to convert
*/
function _convertAlertHeaderToReducedAlertHeader(AlertHeader calldata alertHeader)
internal
pure
returns (ReducedAlertHeader memory)
{
return ReducedAlertHeader({
messageHash: alertHeader.messageHash,
referenceBlockNumber: alertHeader.referenceBlockNumber,
rollupChainID: alertHeader.rollupChainID
});
}
function _setRollupChainID(uint256 rollupChainId, bool status) internal {
if (rollupChainId < 1) {
revert InvalidRollupChainID();
}
if (rollupChainIDs[rollupChainId] == status) {
revert NoStatusChange();
}
rollupChainIDs[rollupChainId] = status;
emit RollupChainIDUpdated(rollupChainId, status);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import "../interfaces/IPausable.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
*/
contract Pausable is IPausable {
/// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing).
IPauserRegistry public pauserRegistry;
/// @dev whether or not the contract is currently paused
uint256 private _paused;
uint256 internal constant UNPAUSE_ALL = 0;
uint256 internal constant PAUSE_ALL = type(uint256).max;
/// @notice
modifier onlyPauser() {
require(pauserRegistry.isPauser(msg.sender), "msg.sender is not permissioned as pauser");
_;
}
modifier onlyUnpauser() {
require(msg.sender == pauserRegistry.unpauser(), "msg.sender is not permissioned as unpauser");
_;
}
/// @notice Throws if the contract is paused, i.e. if any of the bits in `_paused` is flipped to 1.
modifier whenNotPaused() {
require(_paused == 0, "Pausable: contract is paused");
_;
}
/// @notice Throws if the `indexed`th bit of `_paused` is 1, i.e. if the `index`th pause switch is flipped.
modifier onlyWhenNotPaused(uint8 index) {
require(!paused(index), "Pausable: index is paused");
_;
}
/// @notice One-time function for setting the `pauserRegistry` and initializing the value of `_paused`.
function _initializePauser(IPauserRegistry _pauserRegistry, uint256 initPausedStatus) internal {
require(
address(pauserRegistry) == address(0) && address(_pauserRegistry) != address(0),
"Pausable._initializePauser: _initializePauser() can only be called once"
);
_paused = initPausedStatus;
emit Paused(msg.sender, initPausedStatus);
_setPauserRegistry(_pauserRegistry);
}
/**
* @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 onlyPauser {
// verify that the `newPausedStatus` does not *unflip* any bits (i.e. doesn't unpause anything, all 1 bits remain)
require((_paused & newPausedStatus) == _paused, "Pausable.pause: invalid attempt to unpause functionality");
_paused = newPausedStatus;
emit Paused(msg.sender, newPausedStatus);
}
/**
* @notice Alias for `pause(type(uint256).max)`.
*/
function pauseAll() external onlyPauser {
_paused = type(uint256).max;
emit Paused(msg.sender, type(uint256).max);
}
/**
* @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 onlyUnpauser {
// verify that the `newPausedStatus` does not *flip* any bits (i.e. doesn't pause anything, all 0 bits remain)
require(
((~_paused) & (~newPausedStatus)) == (~_paused), "Pausable.unpause: invalid attempt to pause functionality"
);
_paused = newPausedStatus;
emit Unpaused(msg.sender, newPausedStatus);
}
/// @notice Returns the current paused status as a uint256.
function paused() public view virtual returns (uint256) {
return _paused;
}
/// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise
function paused(uint8 index) public view virtual returns (bool) {
uint256 mask = 1 << index;
return ((_paused & mask) == mask);
}
/// @notice Allows the unpauser to set a new pauser registry
function setPauserRegistry(IPauserRegistry newPauserRegistry) external onlyUnpauser {
_setPauserRegistry(newPauserRegistry);
}
/// internal function for setting pauser registry
function _setPauserRegistry(IPauserRegistry newPauserRegistry) internal {
require(
address(newPauserRegistry) != address(0),
"Pausable._setPauserRegistry: newPauserRegistry cannot be the zero address"
);
emit PauserRegistrySet(pauserRegistry, newPauserRegistry);
pauserRegistry = newPauserRegistry;
}
/**
* @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[48] private __gap;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./IStrategy.sol";
/**
* @title Interface for the `IRewardsCoordinator` contract.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice Allows AVSs to make "Rewards Submissions", which get distributed amongst the AVSs' confirmed
* Operators and the Stakers delegated to those Operators.
* Calculations are performed based on the completed RewardsSubmission, with the results posted in
* a Merkle root against which Stakers & Operators can make claims.
*/
interface IRewardsCoordinator {
/// STRUCTS ///
/**
* @notice A linear combination of strategies and multipliers for AVSs to weigh
* EigenLayer strategies.
* @param strategy The EigenLayer strategy to be used for the rewards submission
* @param multiplier The weight of the strategy in the rewards submission
*/
struct StrategyAndMultiplier {
IStrategy strategy;
uint96 multiplier;
}
/**
* @notice A reward struct for an operator
* @param operator The operator to be rewarded
* @param amount The reward amount for the operator
*/
struct OperatorReward {
address operator;
uint256 amount;
}
/**
* @notice A split struct for an Operator
* @param oldSplitBips The old split in basis points. This is the split that is active if `block.timestamp < activatedAt`
* @param newSplitBips The new split in basis points. This is the split that is active if `block.timestamp >= activatedAt`
* @param activatedAt The timestamp at which the split will be activated
*/
struct OperatorSplit {
uint16 oldSplitBips;
uint16 newSplitBips;
uint32 activatedAt;
}
/**
* Sliding Window for valid RewardsSubmission startTimestamp
*
* Scenario A: GENESIS_REWARDS_TIMESTAMP IS WITHIN RANGE
* <-----MAX_RETROACTIVE_LENGTH-----> t (block.timestamp) <---MAX_FUTURE_LENGTH--->
* <--------------------valid range for startTimestamp------------------------>
* ^
* GENESIS_REWARDS_TIMESTAMP
*
*
* Scenario B: GENESIS_REWARDS_TIMESTAMP IS OUT OF RANGE
* <-----MAX_RETROACTIVE_LENGTH-----> t (block.timestamp) <---MAX_FUTURE_LENGTH--->
* <------------------------valid range for startTimestamp------------------------>
* ^
* GENESIS_REWARDS_TIMESTAMP
* @notice RewardsSubmission struct submitted by AVSs when making rewards for their operators and stakers
* RewardsSubmission can be for a time range within the valid window for startTimestamp and must be within max duration.
* See `createAVSRewardsSubmission()` for more details.
* @param strategiesAndMultipliers The strategies and their relative weights
* cannot have duplicate strategies and need to be sorted in ascending address order
* @param token The rewards token to be distributed
* @param amount The total amount of tokens to be distributed
* @param startTimestamp The timestamp (seconds) at which the submission range is considered for distribution
* could start in the past or in the future but within a valid range. See the diagram above.
* @param duration The duration of the submission range in seconds. Must be <= MAX_REWARDS_DURATION
*/
struct RewardsSubmission {
StrategyAndMultiplier[] strategiesAndMultipliers;
IERC20 token;
uint256 amount;
uint32 startTimestamp;
uint32 duration;
}
/**
* @notice OperatorDirectedRewardsSubmission struct submitted by AVSs when making operator-directed rewards for their operators and stakers.
* @param strategiesAndMultipliers The strategies and their relative weights.
* @param token The rewards token to be distributed.
* @param operatorRewards The rewards for the operators.
* @param startTimestamp The timestamp (seconds) at which the submission range is considered for distribution.
* @param duration The duration of the submission range in seconds.
* @param description Describes what the rewards submission is for.
*/
struct OperatorDirectedRewardsSubmission {
StrategyAndMultiplier[] strategiesAndMultipliers;
IERC20 token;
OperatorReward[] operatorRewards;
uint32 startTimestamp;
uint32 duration;
string description;
}
/**
* @notice A distribution root is a merkle root of the distribution of earnings for a given period.
* The RewardsCoordinator stores all historical distribution roots so that earners can claim their earnings against older roots
* if they wish but the merkle tree contains the cumulative earnings of all earners and tokens for a given period so earners (or their claimers if set)
* only need to claim against the latest root to claim all available earnings.
* @param root The merkle root of the distribution
* @param rewardsCalculationEndTimestamp The timestamp (seconds) until which rewards have been calculated
* @param activatedAt The timestamp (seconds) at which the root can be claimed against
*/
struct DistributionRoot {
bytes32 root;
uint32 rewardsCalculationEndTimestamp;
uint32 activatedAt;
bool disabled;
}
/**
* @notice Internal leaf in the merkle tree for the earner's account leaf
* @param earner The address of the earner
* @param earnerTokenRoot The merkle root of the earner's token subtree
* Each leaf in the earner's token subtree is a TokenTreeMerkleLeaf
*/
struct EarnerTreeMerkleLeaf {
address earner;
bytes32 earnerTokenRoot;
}
/**
* @notice The actual leaves in the distribution merkle tree specifying the token earnings
* for the respective earner's subtree. Each leaf is a claimable amount of a token for an earner.
* @param token The token for which the earnings are being claimed
* @param cumulativeEarnings The cumulative earnings of the earner for the token
*/
struct TokenTreeMerkleLeaf {
IERC20 token;
uint256 cumulativeEarnings;
}
/**
* @notice A claim against a distribution root called by an
* earners claimer (could be the earner themselves). Each token claim will claim the difference
* between the cumulativeEarnings of the earner and the cumulativeClaimed of the claimer.
* Each claim can specify which of the earner's earned tokens they want to claim.
* See `processClaim()` for more details.
* @param rootIndex The index of the root in the list of DistributionRoots
* @param earnerIndex The index of the earner's account root in the merkle tree
* @param earnerTreeProof The proof of the earner's EarnerTreeMerkleLeaf against the merkle root
* @param earnerLeaf The earner's EarnerTreeMerkleLeaf struct, providing the earner address and earnerTokenRoot
* @param tokenIndices The indices of the token leaves in the earner's subtree
* @param tokenTreeProofs The proofs of the token leaves against the earner's earnerTokenRoot
* @param tokenLeaves The token leaves to be claimed
* @dev The merkle tree is structured with the merkle root at the top and EarnerTreeMerkleLeaf as internal leaves
* in the tree. Each earner leaf has its own subtree with TokenTreeMerkleLeaf as leaves in the subtree.
* To prove a claim against a specified rootIndex(which specifies the distributionRoot being used),
* the claim will first verify inclusion of the earner leaf in the tree against _distributionRoots[rootIndex].root.
* Then for each token, it will verify inclusion of the token leaf in the earner's subtree against the earner's earnerTokenRoot.
*/
struct RewardsMerkleClaim {
uint32 rootIndex;
uint32 earnerIndex;
bytes earnerTreeProof;
EarnerTreeMerkleLeaf earnerLeaf;
uint32[] tokenIndices;
bytes[] tokenTreeProofs;
TokenTreeMerkleLeaf[] tokenLeaves;
}
/// EVENTS ///
/// @notice emitted when an AVS creates a valid RewardsSubmission
event AVSRewardsSubmissionCreated(
address indexed avs,
uint256 indexed submissionNonce,
bytes32 indexed rewardsSubmissionHash,
RewardsSubmission rewardsSubmission
);
/// @notice emitted when a valid RewardsSubmission is created for all stakers by a valid submitter
event RewardsSubmissionForAllCreated(
address indexed submitter,
uint256 indexed submissionNonce,
bytes32 indexed rewardsSubmissionHash,
RewardsSubmission rewardsSubmission
);
/// @notice emitted when a valid RewardsSubmission is created when rewardAllStakersAndOperators is called
event RewardsSubmissionForAllEarnersCreated(
address indexed tokenHopper,
uint256 indexed submissionNonce,
bytes32 indexed rewardsSubmissionHash,
RewardsSubmission rewardsSubmission
);
/**
* @notice Emitted when an AVS creates a valid `OperatorDirectedRewardsSubmission`
* @param caller The address calling `createOperatorDirectedAVSRewardsSubmission`.
* @param avs The avs on behalf of which the operator-directed rewards are being submitted.
* @param operatorDirectedRewardsSubmissionHash Keccak256 hash of (`avs`, `submissionNonce` and `operatorDirectedRewardsSubmission`).
* @param submissionNonce Current nonce of the avs. Used to generate a unique submission hash.
* @param operatorDirectedRewardsSubmission The Operator-Directed Rewards Submission. Contains the token, start timestamp, duration, operator rewards, description and, strategy and multipliers.
*/
event OperatorDirectedAVSRewardsSubmissionCreated(
address indexed caller,
address indexed avs,
bytes32 indexed operatorDirectedRewardsSubmissionHash,
uint256 submissionNonce,
OperatorDirectedRewardsSubmission operatorDirectedRewardsSubmission
);
/// @notice rewardsUpdater is responsible for submiting DistributionRoots, only owner can set rewardsUpdater
event RewardsUpdaterSet(address indexed oldRewardsUpdater, address indexed newRewardsUpdater);
event RewardsForAllSubmitterSet(
address indexed rewardsForAllSubmitter,
bool indexed oldValue,
bool indexed newValue
);
event ActivationDelaySet(uint32 oldActivationDelay, uint32 newActivationDelay);
event DefaultOperatorSplitBipsSet(uint16 oldDefaultOperatorSplitBips, uint16 newDefaultOperatorSplitBips);
/**
* @notice Emitted when the operator split for an AVS is set.
* @param caller The address calling `setOperatorAVSSplit`.
* @param operator The operator on behalf of which the split is being set.
* @param avs The avs for which the split is being set by the operator.
* @param activatedAt The timestamp at which the split will be activated.
* @param oldOperatorAVSSplitBips The old split for the operator for the AVS.
* @param newOperatorAVSSplitBips The new split for the operator for the AVS.
*/
event OperatorAVSSplitBipsSet(
address indexed caller,
address indexed operator,
address indexed avs,
uint32 activatedAt,
uint16 oldOperatorAVSSplitBips,
uint16 newOperatorAVSSplitBips
);
/**
* @notice Emitted when the operator split for Programmatic Incentives is set.
* @param caller The address calling `setOperatorPISplit`.
* @param operator The operator on behalf of which the split is being set.
* @param activatedAt The timestamp at which the split will be activated.
* @param oldOperatorPISplitBips The old split for the operator for Programmatic Incentives.
* @param newOperatorPISplitBips The new split for the operator for Programmatic Incentives.
*/
event OperatorPISplitBipsSet(
address indexed caller,
address indexed operator,
uint32 activatedAt,
uint16 oldOperatorPISplitBips,
uint16 newOperatorPISplitBips
);
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 indexed rewardsCalculationEndTimestamp,
uint32 activatedAt
);
event DistributionRootDisabled(uint32 indexed rootIndex);
/// @notice root is one of the submitted distribution roots that was claimed against
event RewardsClaimed(
bytes32 root,
address indexed earner,
address indexed claimer,
address indexed recipient,
IERC20 token,
uint256 claimedAmount
);
/**
*
* VIEW FUNCTIONS
*
*/
/// @notice The address of the entity that can update the contract with new merkle roots
function rewardsUpdater() external view returns (address);
/**
* @notice The interval in seconds at which the calculation for a RewardsSubmission distribution is done.
* @dev Rewards Submission durations must be multiples of this interval.
*/
function CALCULATION_INTERVAL_SECONDS() external view returns (uint32);
/// @notice The maximum amount of time (seconds) that a RewardsSubmission can span over
function MAX_REWARDS_DURATION() external view returns (uint32);
/// @notice max amount of time (seconds) that a submission can start in the past
function MAX_RETROACTIVE_LENGTH() external view returns (uint32);
/// @notice max amount of time (seconds) that a submission can start in the future
function MAX_FUTURE_LENGTH() external view returns (uint32);
/// @notice absolute min timestamp (seconds) that a submission can start at
function GENESIS_REWARDS_TIMESTAMP() external view returns (uint32);
/// @notice Delay in timestamp (seconds) before a posted root can be claimed against
function activationDelay() external view returns (uint32);
/// @notice Mapping: earner => the address of the entity who can call `processClaim` on behalf of the earner
function claimerFor(address earner) external view returns (address);
/// @notice Mapping: claimer => token => total amount claimed
function cumulativeClaimed(address claimer, IERC20 token) external view returns (uint256);
/// @notice the defautl split for all operators across all avss
function defaultOperatorSplitBips() external view returns (uint16);
/// @notice the split for a specific `operator` for a specific `avs`
function getOperatorAVSSplit(address operator, address avs) external view returns (uint16);
/// @notice the split for a specific `operator` for Programmatic Incentives
function getOperatorPISplit(address operator) external view returns (uint16);
/// @notice return the hash of the earner's leaf
function calculateEarnerLeafHash(EarnerTreeMerkleLeaf calldata leaf) external pure returns (bytes32);
/// @notice returns the hash of the earner's token leaf
function calculateTokenLeafHash(TokenTreeMerkleLeaf calldata leaf) external pure returns (bytes32);
/// @notice returns 'true' if the claim would currently pass the check in `processClaims`
/// but will revert if not valid
function checkClaim(RewardsMerkleClaim calldata claim) external view returns (bool);
/// @notice The timestamp until which RewardsSubmissions have been calculated
function currRewardsCalculationEndTimestamp() external view returns (uint32);
/// @notice returns the number of distribution roots posted
function getDistributionRootsLength() external view returns (uint256);
/// @notice returns the distributionRoot at the specified index
function getDistributionRootAtIndex(uint256 index) external view returns (DistributionRoot memory);
/// @notice returns the current distributionRoot
function getCurrentDistributionRoot() external view returns (DistributionRoot memory);
/// @notice loop through the distribution roots from reverse and get latest root that is not disabled and activated
/// i.e. a root that can be claimed against
function getCurrentClaimableDistributionRoot() external view returns (DistributionRoot memory);
/// @notice loop through distribution roots from reverse and return index from hash
function getRootIndexFromHash(bytes32 rootHash) external view returns (uint32);
/**
*
* EXTERNAL FUNCTIONS
*
*/
/**
* @notice Creates a new rewards submission on behalf of an AVS, to be split amongst the
* set of stakers delegated to operators who are registered to the `avs`
* @param rewardsSubmissions The rewards submissions being created
* @dev Expected to be called by the ServiceManager of the AVS on behalf of which the submission is being made
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`
* @dev The tokens are sent to the `RewardsCoordinator` contract
* @dev Strategies must be in ascending order of addresses to check for duplicates
* @dev This function will revert if the `rewardsSubmission` is malformed,
* e.g. if the `strategies` and `weights` arrays are of non-equal lengths
*/
function createAVSRewardsSubmission(RewardsSubmission[] calldata rewardsSubmissions) external;
/**
* @notice similar to `createAVSRewardsSubmission` except the rewards are split amongst *all* stakers
* rather than just those delegated to operators who are registered to a single avs and is
* a permissioned call based on isRewardsForAllSubmitter mapping.
* @param rewardsSubmission The rewards submission being created
*/
function createRewardsForAllSubmission(RewardsSubmission[] calldata rewardsSubmission) external;
/**
* @notice Creates a new rewards submission for all earners across all AVSs.
* Earners in this case indicating all operators and their delegated stakers. Undelegated stake
* is not rewarded from this RewardsSubmission. This interface is only callable
* by the token hopper contract from the Eigen Foundation
* @param rewardsSubmissions The rewards submissions being created
*/
function createRewardsForAllEarners(RewardsSubmission[] calldata rewardsSubmissions) external;
/**
* @notice Creates a new operator-directed rewards submission on behalf of an AVS, to be split amongst the operators and
* set of stakers delegated to operators who are registered to the `avs`.
* @param avs The AVS on behalf of which the reward is being submitted
* @param operatorDirectedRewardsSubmissions The operator-directed rewards submissions being created
* @dev Expected to be called by the ServiceManager of the AVS on behalf of which the submission is being made
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`
* @dev The tokens are sent to the `RewardsCoordinator` contract
* @dev The `RewardsCoordinator` contract needs a token approval of sum of all `operatorRewards` in the `operatorDirectedRewardsSubmissions`, before calling this function.
* @dev Strategies must be in ascending order of addresses to check for duplicates
* @dev Operators must be in ascending order of addresses to check for duplicates.
* @dev This function will revert if the `operatorDirectedRewardsSubmissions` is malformed.
*/
function createOperatorDirectedAVSRewardsSubmission(
address avs,
OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions
) external;
/**
* @notice Claim rewards against a given root (read from _distributionRoots[claim.rootIndex]).
* Earnings are cumulative so earners don't have to claim against all distribution roots they have earnings for,
* they can simply claim against the latest root and the contract will calculate the difference between
* their cumulativeEarnings and cumulativeClaimed. This difference is then transferred to recipient address.
* @param claim The RewardsMerkleClaim to be processed.
* Contains the root index, earner, token leaves, and required proofs
* @param recipient The address recipient that receives the ERC20 rewards
* @dev only callable by the valid claimer, that is
* if claimerFor[claim.earner] is address(0) then only the earner can claim, otherwise only
* claimerFor[claim.earner] can claim the rewards.
*/
function processClaim(RewardsMerkleClaim calldata claim, address recipient) external;
/**
* @notice Batch claim rewards against a given root (read from _distributionRoots[claim.rootIndex]).
* Earnings are cumulative so earners don't have to claim against all distribution roots they have earnings for,
* they can simply claim against the latest root and the contract will calculate the difference between
* their cumulativeEarnings and cumulativeClaimed. This difference is then transferred to recipient address.
* @param claims The RewardsMerkleClaims to be processed.
* Contains the root index, earner, token leaves, and required proofs
* @param recipient The address recipient that receives the ERC20 rewards
* @dev only callable by the valid claimer, that is
* if claimerFor[claim.earner] is address(0) then only the earner can claim, otherwise only
* claimerFor[claim.earner] can claim the rewards.
*/
function processClaims(RewardsMerkleClaim[] calldata claims, address recipient) external;
/**
* @notice Creates a new distribution root. activatedAt is set to block.timestamp + activationDelay
* @param root The merkle root of the distribution
* @param rewardsCalculationEndTimestamp The timestamp until which rewards have been calculated
* @dev Only callable by the rewardsUpdater
*/
function submitRoot(bytes32 root, uint32 rewardsCalculationEndTimestamp) external;
/**
* @notice allow the rewardsUpdater to disable/cancel a pending root submission in case of an error
* @param rootIndex The index of the root to be disabled
*/
function disableRoot(uint32 rootIndex) external;
/**
* @notice Sets the address of the entity that can call `processClaim` on behalf of the earner (msg.sender)
* @param claimer The address of the entity that can call `processClaim` on behalf of the earner
* @dev Only callable by the `earner`
*/
function setClaimerFor(address claimer) external;
/**
* @notice Sets the delay in timestamp before a posted root can be claimed against
* @dev Only callable by the contract owner
* @param _activationDelay The new value for activationDelay
*/
function setActivationDelay(uint32 _activationDelay) external;
/**
* @notice Sets the default split for all operators across all avss.
* @param split The default split for all operators across all avss in bips.
* @dev Only callable by the contract owner.
*/
function setDefaultOperatorSplit(uint16 split) external;
/**
* @notice Sets the split for a specific operator for a specific avs
* @param operator The operator who is setting the split
* @param avs The avs for which the split is being set by the operator
* @param split The split for the operator for the specific avs in bips.
* @dev Only callable by the operator
* @dev Split has to be between 0 and 10000 bips (inclusive)
* @dev The split will be activated after the activation delay
*/
function setOperatorAVSSplit(address operator, address avs, uint16 split) external;
/**
* @notice Sets the split for a specific operator for Programmatic Incentives.
* @param operator The operator on behalf of which the split is being set.
* @param split The split for the operator for Programmatic Incentives in bips.
* @dev Only callable by the operator
* @dev Split has to be between 0 and 10000 bips (inclusive)
* @dev The split will be activated after the activation delay
*/
function setOperatorPISplit(address operator, uint16 split) external;
/**
* @notice Sets the permissioned `rewardsUpdater` address which can post new roots
* @dev Only callable by the contract owner
* @param _rewardsUpdater The address of the new rewardsUpdater
*/
function setRewardsUpdater(address _rewardsUpdater) external;
/**
* @notice Sets the permissioned `rewardsForAllSubmitter` address which can submit createRewardsForAllSubmission
* @dev Only callable by the contract owner
* @param _submitter The address of the rewardsForAllSubmitter
* @param _newValue The new value for isRewardsForAllSubmitter
*/
function setRewardsForAllSubmitter(address _submitter, bool _newValue) external;
/**
* @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);
}// 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 the AVS's service manager contract 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 address of the service manager contract for the AVS that 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);
/**
* @notice Called by an operator to cancel a salt that has been used to register with an AVS.
* @param salt A unique and single use value associated with the approver signature.
*/
function cancelSalt(bytes32 salt) external;
/**
* @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);
}// 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;
/**
* @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: BUSL-1.1
pragma solidity >=0.5.0;
import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.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 is IServiceManagerUI {
/**
* @notice Creates a new rewards submission to the EigenLayer RewardsCoordinator contract, to be split amongst the
* set of stakers delegated to operators who are registered to this `avs`
* @param rewardsSubmissions The rewards submissions being created
* @dev Only callable by the permissioned rewardsInitiator address
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`
* @dev The tokens are sent to the `RewardsCoordinator` contract
* @dev Strategies must be in ascending order of addresses to check for duplicates
* @dev This function will revert if the `rewardsSubmission` is malformed,
* e.g. if the `strategies` and `weights` arrays are of non-equal lengths
*/
function createAVSRewardsSubmission(
IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions
) external;
/**
* @notice Creates a new operator-directed rewards submission on behalf of an AVS, to be split amongst the operators and
* set of stakers delegated to operators who are registered to the `avs`.
* @param operatorDirectedRewardsSubmissions The operator-directed rewards submissions being created
* @dev Only callable by the permissioned rewardsInitiator address
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`
* @dev The tokens are sent to the `RewardsCoordinator` contract
* @dev This contract needs a token approval of sum of all `operatorRewards` in the `operatorDirectedRewardsSubmissions`, before calling this function.
* @dev Strategies must be in ascending order of addresses to check for duplicates
* @dev Operators must be in ascending order of addresses to check for duplicates.
* @dev This function will revert if the `operatorDirectedRewardsSubmissions` is malformed.
*/
function createOperatorDirectedAVSRewardsSubmission(
IRewardsCoordinator.OperatorDirectedRewardsSubmission[]
calldata operatorDirectedRewardsSubmissions
) external;
/**
* @notice Forwards a call to Eigenlayer's RewardsCoordinator contract to set the address of the entity that can call `processClaim` on behalf of this contract.
* @param claimer The address of the entity that can call `processClaim` on behalf of the earner
* @dev Only callable by the owner.
*/
function setClaimerFor(address claimer) external;
// EVENTS
event RewardsInitiatorUpdated(
address prevRewardsInitiator,
address newRewardsInitiator
);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol";
import {IRegistry} from "./IRegistry.sol";
/**
* @title Interface for a `Registry` that keeps track of stakes of operators for up to 256 quorums.
* @author Layr Labs, Inc.
*/
interface IStakeRegistry is IRegistry {
// DATA STRUCTURES
/// @notice struct used to store the stakes of an individual operator or the sum of all operators' stakes, for storage
struct StakeUpdate {
// the block number at which the stake amounts were updated and stored
uint32 updateBlockNumber;
// the block number at which the *next update* occurred.
/// @notice This entry has the value **0** until another update takes place.
uint32 nextUpdateBlockNumber;
// stake weight for the quorum
uint96 stake;
}
/**
* @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;
}
// EVENTS
/// @notice emitted whenever the stake of `operator` is updated
event OperatorStakeUpdate(
bytes32 indexed operatorId,
uint8 quorumNumber,
uint96 stake
);
/// @notice emitted when the minimum stake for a quorum is updated
event MinimumStakeForQuorumUpdated(uint8 indexed quorumNumber, uint96 minimumStake);
/// @notice emitted when a new quorum is created
event QuorumCreated(uint8 indexed quorumNumber);
/// @notice emitted when `strategy` has been added to the array at `strategyParams[quorumNumber]`
event StrategyAddedToQuorum(uint8 indexed quorumNumber, IStrategy strategy);
/// @notice emitted when `strategy` has removed from the array at `strategyParams[quorumNumber]`
event StrategyRemovedFromQuorum(uint8 indexed quorumNumber, IStrategy strategy);
/// @notice emitted when `strategy` has its `multiplier` updated in the array at `strategyParams[quorumNumber]`
event StrategyMultiplierUpdated(uint8 indexed quorumNumber, IStrategy strategy, uint256 multiplier);
/**
* @notice Registers the `operator` with `operatorId` for the specified `quorumNumbers`.
* @param operator The address of the operator to register.
* @param operatorId The id of the operator to register.
* @param quorumNumbers The quorum numbers the operator is registering for, where each byte is an 8 bit integer quorumNumber.
* @return The operator's current stake for each quorum, and the total stake for each quorum
* @dev access restricted to the RegistryCoordinator
* @dev Preconditions (these are assumed, not validated in this contract):
* 1) `quorumNumbers` has no duplicates
* 2) `quorumNumbers.length` != 0
* 3) `quorumNumbers` is ordered in ascending order
* 4) the operator is not already registered
*/
function registerOperator(
address operator,
bytes32 operatorId,
bytes memory quorumNumbers
) external returns (uint96[] memory, uint96[] memory);
/**
* @notice Deregisters the operator with `operatorId` for the specified `quorumNumbers`.
* @param operatorId The id of the operator to deregister.
* @param quorumNumbers The quorum numbers the operator is deregistering from, where each byte is an 8 bit integer quorumNumber.
* @dev access restricted to the RegistryCoordinator
* @dev Preconditions (these are assumed, not validated in this contract):
* 1) `quorumNumbers` has no duplicates
* 2) `quorumNumbers.length` != 0
* 3) `quorumNumbers` is ordered in ascending order
* 4) the operator is not already deregistered
* 5) `quorumNumbers` is a subset of the quorumNumbers that the operator is registered for
*/
function deregisterOperator(bytes32 operatorId, bytes memory quorumNumbers) external;
/**
* @notice Initialize a new quorum created by the registry coordinator by setting strategies, weights, and minimum stake
*/
function initializeQuorum(uint8 quorumNumber, uint96 minimumStake, StrategyParams[] memory strategyParams) external;
/// @notice Adds new strategies and the associated multipliers to the @param quorumNumber.
function addStrategies(
uint8 quorumNumber,
StrategyParams[] memory strategyParams
) external;
/**
* @notice This function is used for removing strategies and their associated weights from the
* mapping strategyParams for a specific @param quorumNumber.
* @dev higher indices should be *first* in the list of @param indicesToRemove, since otherwise
* the removal of lower index entries will cause a shift in the indices of the other strategiesToRemove
*/
function removeStrategies(uint8 quorumNumber, uint256[] calldata indicesToRemove) external;
/**
* @notice This function is used for modifying the weights of strategies that are already in the
* mapping strategyParams for a specific
* @param quorumNumber is the quorum number to change the strategy for
* @param strategyIndices are the indices of the strategies to change
* @param newMultipliers are the new multipliers for the strategies
*/
function modifyStrategyParams(
uint8 quorumNumber,
uint256[] calldata strategyIndices,
uint96[] calldata newMultipliers
) external;
/// @notice Constant used as a divisor in calculating weights.
function WEIGHTING_DIVISOR() external pure returns (uint256);
/// @notice Returns the EigenLayer delegation manager contract.
function delegation() external view returns (IDelegationManager);
/// @notice In order to register for a quorum i, an operator must have at least `minimumStakeForQuorum[i]`
function minimumStakeForQuorum(uint8 quorumNumber) external view returns (uint96);
/// @notice Returns the length of the dynamic array stored in `strategyParams[quorumNumber]`.
function strategyParamsLength(uint8 quorumNumber) external view returns (uint256);
/// @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);
/**
* @notice This function computes the total weight of the @param operator in the quorum @param quorumNumber.
* @dev reverts in the case that `quorumNumber` is greater than or equal to `quorumCount`
*/
function weightOfOperatorForQuorum(uint8 quorumNumber, address operator) external view returns (uint96);
/**
* @notice Returns the entire `operatorIdToStakeHistory[operatorId][quorumNumber]` array.
* @param operatorId The id of the operator of interest.
* @param quorumNumber The quorum number to get the stake for.
*/
function getStakeHistory(bytes32 operatorId, uint8 quorumNumber) external view returns (StakeUpdate[] memory);
function getTotalStakeHistoryLength(uint8 quorumNumber) external view returns (uint256);
/**
* @notice Returns the `index`-th entry in the dynamic array of total stake, `totalStakeHistory` for quorum `quorumNumber`.
* @param quorumNumber The quorum number to get the stake for.
* @param index Array index for lookup, within the dynamic array `totalStakeHistory[quorumNumber]`.
*/
function getTotalStakeUpdateAtIndex(uint8 quorumNumber, uint256 index) external view returns (StakeUpdate memory);
/// @notice Returns the indices of the operator stakes for the provided `quorumNumber` at the given `blockNumber`
function getStakeUpdateIndexAtBlockNumber(bytes32 operatorId, uint8 quorumNumber, uint32 blockNumber)
external
view
returns (uint32);
/// @notice Returns the indices of the total stakes for the provided `quorumNumbers` at the given `blockNumber`
function getTotalStakeIndicesAtBlockNumber(uint32 blockNumber, bytes calldata quorumNumbers) external view returns(uint32[] memory) ;
/**
* @notice Returns the `index`-th entry in the `operatorIdToStakeHistory[operatorId][quorumNumber]` array.
* @param quorumNumber The quorum number to get the stake for.
* @param operatorId The id of the operator of interest.
* @param index Array index for lookup, within the dynamic array `operatorIdToStakeHistory[operatorId][quorumNumber]`.
* @dev Function will revert if `index` is out-of-bounds.
*/
function getStakeUpdateAtIndex(uint8 quorumNumber, bytes32 operatorId, uint256 index)
external
view
returns (StakeUpdate memory);
/**
* @notice Returns the most recent stake weight for the `operatorId` for a certain quorum
* @dev Function returns an StakeUpdate struct with **every entry equal to 0** in the event that the operator has no stake history
*/
function getLatestStakeUpdate(bytes32 operatorId, uint8 quorumNumber) external view returns (StakeUpdate memory);
/**
* @notice Returns the stake weight corresponding to `operatorId` for quorum `quorumNumber`, at the
* `index`-th entry in the `operatorIdToStakeHistory[operatorId][quorumNumber]` array if the entry
* corresponds to the operator's stake at `blockNumber`. Reverts otherwise.
* @param quorumNumber The quorum number to get the stake for.
* @param operatorId The id of the operator of interest.
* @param index Array index for lookup, within the dynamic array `operatorIdToStakeHistory[operatorId][quorumNumber]`.
* @param blockNumber Block number to make sure the stake is from.
* @dev Function will revert if `index` is out-of-bounds.
* @dev used the BLSSignatureChecker to get past stakes of signing operators
*/
function getStakeAtBlockNumberAndIndex(uint8 quorumNumber, uint32 blockNumber, bytes32 operatorId, uint256 index)
external
view
returns (uint96);
/**
* @notice Returns the total stake weight for quorum `quorumNumber`, at the `index`-th entry in the
* `totalStakeHistory[quorumNumber]` array if the entry corresponds to the total stake at `blockNumber`.
* Reverts otherwise.
* @param quorumNumber The quorum number to get the stake for.
* @param index Array index for lookup, within the dynamic array `totalStakeHistory[quorumNumber]`.
* @param blockNumber Block number to make sure the stake is from.
* @dev Function will revert if `index` is out-of-bounds.
* @dev used the BLSSignatureChecker to get past stakes of signing operators
*/
function getTotalStakeAtBlockNumberFromIndex(uint8 quorumNumber, uint32 blockNumber, uint256 index) external view returns (uint96);
/**
* @notice Returns the most recent stake weight for the `operatorId` for quorum `quorumNumber`
* @dev Function returns weight of **0** in the event that the operator has no stake history
*/
function getCurrentStake(bytes32 operatorId, uint8 quorumNumber) external view returns (uint96);
/// @notice Returns the stake of the operator for the provided `quorumNumber` at the given `blockNumber`
function getStakeAtBlockNumber(bytes32 operatorId, uint8 quorumNumber, uint32 blockNumber)
external
view
returns (uint96);
/**
* @notice Returns the stake weight from the latest entry in `_totalStakeHistory` for quorum `quorumNumber`.
* @dev Will revert if `_totalStakeHistory[quorumNumber]` is empty.
*/
function getCurrentTotalStake(uint8 quorumNumber) external view returns (uint96);
/**
* @notice Called by the registry coordinator to update an operator's stake for one
* or more quorums.
*
* If the operator no longer has the minimum stake required for a quorum, they are
* added to the
* @return A bitmap of quorums where the operator no longer meets the minimum stake
* and should be deregistered.
*/
function updateOperatorStake(
address operator,
bytes32 operatorId,
bytes calldata quorumNumbers
) external returns (uint192);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {IBLSApkRegistry} from "./IBLSApkRegistry.sol";
import {IStakeRegistry} from "./IStakeRegistry.sol";
import {IIndexRegistry} from "./IIndexRegistry.sol";
import {BN254} from "../libraries/BN254.sol";
/**
* @title Interface for a contract that coordinates between various registries for an AVS.
* @author Layr Labs, Inc.
*/
interface IRegistryCoordinator {
// EVENTS
/// Emits when an operator is registered
event OperatorRegistered(address indexed operator, bytes32 indexed operatorId);
/// Emits when an operator is deregistered
event OperatorDeregistered(address indexed operator, bytes32 indexed operatorId);
event OperatorSetParamsUpdated(uint8 indexed quorumNumber, OperatorSetParam operatorSetParams);
event ChurnApproverUpdated(address prevChurnApprover, address newChurnApprover);
event EjectorUpdated(address prevEjector, address newEjector);
event OperatorSocketUpdate(bytes32 indexed operatorId, string socket);
/// @notice emitted when all the operators for a quorum are updated at once
event QuorumBlockNumberUpdated(uint8 indexed quorumNumber, uint256 blocknumber);
// DATA STRUCTURES
enum OperatorStatus
{
// default is NEVER_REGISTERED
NEVER_REGISTERED,
REGISTERED,
DEREGISTERED
}
// STRUCTS
/**
* @notice Data structure for storing info on operators
*/
struct OperatorInfo {
// the id of the operator, which is likely the keccak256 hash of the operator's public key if using BLSRegistry
bytes32 operatorId;
// indicates whether the operator is actively registered for serving the middleware or not
OperatorStatus status;
}
/**
* @notice Data structure for storing info on quorum bitmap updates where the `quorumBitmap` is the bitmap of the
* quorums the operator is registered for starting at (inclusive)`updateBlockNumber` and ending at (exclusive) `nextUpdateBlockNumber`
* @dev nextUpdateBlockNumber is initialized to 0 for the latest update
*/
struct QuorumBitmapUpdate {
uint32 updateBlockNumber;
uint32 nextUpdateBlockNumber;
uint192 quorumBitmap;
}
/**
* @notice Data structure for storing operator set params for a given quorum. Specifically the
* `maxOperatorCount` is the maximum number of operators that can be registered for the quorum,
* `kickBIPsOfOperatorStake` is the basis points of a new operator needs to have of an operator they are trying to kick from the quorum,
* and `kickBIPsOfTotalStake` is the basis points of the total stake of the quorum that an operator needs to be below to be kicked.
*/
struct OperatorSetParam {
uint32 maxOperatorCount;
uint16 kickBIPsOfOperatorStake;
uint16 kickBIPsOfTotalStake;
}
/**
* @notice Data structure for the parameters needed to kick an operator from a quorum with number `quorumNumber`, used during registration churn.
* `operator` is the address of the operator to kick
*/
struct OperatorKickParam {
uint8 quorumNumber;
address operator;
}
/// @notice Returns the operator set params for the given `quorumNumber`
function getOperatorSetParams(uint8 quorumNumber) external view returns (OperatorSetParam memory);
/// @notice the Stake registry contract that will keep track of operators' stakes
function stakeRegistry() external view returns (IStakeRegistry);
/// @notice the BLS Aggregate Pubkey Registry contract that will keep track of operators' BLS aggregate pubkeys per quorum
function blsApkRegistry() external view returns (IBLSApkRegistry);
/// @notice the index Registry contract that will keep track of operators' indexes
function indexRegistry() external view returns (IIndexRegistry);
/**
* @notice Ejects the provided operator from the provided quorums from the AVS
* @param operator is the operator to eject
* @param quorumNumbers are the quorum numbers to eject the operator from
*/
function ejectOperator(
address operator,
bytes calldata quorumNumbers
) external;
/// @notice Returns the number of quorums the registry coordinator has created
function quorumCount() external view returns (uint8);
/// @notice Returns the operator struct for the given `operator`
function getOperator(address operator) external view returns (OperatorInfo memory);
/// @notice Returns the operatorId for the given `operator`
function getOperatorId(address operator) external view returns (bytes32);
/// @notice Returns the operator address for the given `operatorId`
function getOperatorFromId(bytes32 operatorId) external view returns (address operator);
/// @notice Returns the status for the given `operator`
function getOperatorStatus(address operator) external view returns (IRegistryCoordinator.OperatorStatus);
/// @notice Returns the indices of the quorumBitmaps for the provided `operatorIds` at the given `blockNumber`
function getQuorumBitmapIndicesAtBlockNumber(uint32 blockNumber, bytes32[] memory operatorIds) external view returns (uint32[] memory);
/**
* @notice Returns the quorum bitmap for the given `operatorId` at the given `blockNumber` via the `index`
* @dev reverts if `index` is incorrect
*/
function getQuorumBitmapAtBlockNumberByIndex(bytes32 operatorId, uint32 blockNumber, uint256 index) external view returns (uint192);
/// @notice Returns the `index`th entry in the operator with `operatorId`'s bitmap history
function getQuorumBitmapUpdateByIndex(bytes32 operatorId, uint256 index) external view returns (QuorumBitmapUpdate memory);
/// @notice Returns the current quorum bitmap for the given `operatorId`
function getCurrentQuorumBitmap(bytes32 operatorId) external view returns (uint192);
/// @notice Returns the length of the quorum bitmap history for the given `operatorId`
function getQuorumBitmapHistoryLength(bytes32 operatorId) external view returns (uint256);
/// @notice Returns the registry at the desired index
function registries(uint256) external view returns (address);
/// @notice Returns the number of registries
function numRegistries() external view returns (uint256);
/**
* @notice Returns the message hash that an operator must sign to register their BLS public key.
* @param operator is the address of the operator registering their BLS public key
*/
function pubkeyRegistrationMessageHash(address operator) external view returns (BN254.G1Point memory);
/// @notice returns the blocknumber the quorum was last updated all at once for all operators
function quorumUpdateBlockNumber(uint8 quorumNumber) external view returns (uint256);
/// @notice The owner of the registry coordinator
function owner() external view returns (address);
/**
* @notice Updates the socket of the msg.sender given they are a registered operator
* @param socket is the new socket of the operator
*/
function updateSocket(string memory socket) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {IRegistryCoordinator} from "./IRegistryCoordinator.sol";
import {IBLSApkRegistry} from "./IBLSApkRegistry.sol";
import {IStakeRegistry, IDelegationManager} from "./IStakeRegistry.sol";
import {BN254} from "../libraries/BN254.sol";
/**
* @title Used for checking BLS aggregate signatures from the operators of a EigenLayer AVS with the RegistryCoordinator/BLSApkRegistry/StakeRegistry architechture.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice This is the contract for checking the validity of aggregate operator signatures.
*/
interface IBLSSignatureChecker {
// DATA STRUCTURES
struct NonSignerStakesAndSignature {
uint32[] nonSignerQuorumBitmapIndices; // is the indices of all nonsigner quorum bitmaps
BN254.G1Point[] nonSignerPubkeys; // is the G1 pubkeys of all nonsigners
BN254.G1Point[] quorumApks; // is the aggregate G1 pubkey of each quorum
BN254.G2Point apkG2; // is the aggregate G2 pubkey of all signers
BN254.G1Point sigma; // is the aggregate G1 signature of all signers
uint32[] quorumApkIndices; // is the indices of each quorum aggregate pubkey
uint32[] totalStakeIndices; // is the indices of each quorums total stake
uint32[][] nonSignerStakeIndices; // is the indices of each non signers stake within a quorum
}
/**
* @notice this data structure is used for recording the details on the total stake of the registered
* operators and those operators who are part of the quorum for a particular taskNumber
*/
struct QuorumStakeTotals {
// total stake of the operators in each quorum
uint96[] signedStakeForQuorum;
// total amount staked by all operators in each quorum
uint96[] totalStakeForQuorum;
}
// EVENTS
/// @notice Emitted when `staleStakesForbiddenUpdate` is set
event StaleStakesForbiddenUpdate(bool value);
// CONSTANTS & IMMUTABLES
function registryCoordinator() external view returns (IRegistryCoordinator);
function stakeRegistry() external view returns (IStakeRegistry);
function blsApkRegistry() external view returns (IBLSApkRegistry);
function delegation() external view returns (IDelegationManager);
/**
* @notice This function is called by disperser when it has aggregated all the signatures of the operators
* that are part of the quorum for a particular taskNumber and is asserting them into onchain. The function
* checks that the claim for aggregated signatures are valid.
*
* The thesis of this procedure entails:
* - getting the aggregated pubkey of all registered nodes at the time of pre-commit by the
* disperser (represented by apk in the parameters),
* - subtracting the pubkeys of all the signers not in the quorum (nonSignerPubkeys) and storing
* the output in apk to get aggregated pubkey of all operators that are part of quorum.
* - use this aggregated pubkey to verify the aggregated signature under BLS scheme.
*
* @dev Before signature verification, the function verifies operator stake information. This includes ensuring that the provided `referenceBlockNumber`
* is correct, i.e., ensure that the stake returned from the specified block number is recent enough and that the stake is either the most recent update
* for the total stake (or the operator) or latest before the referenceBlockNumber.
*/
function checkSignatures(
bytes32 msgHash,
bytes calldata quorumNumbers,
uint32 referenceBlockNumber,
NonSignerStakesAndSignature memory nonSignerStakesAndSignature
)
external
view
returns (
QuorumStakeTotals memory,
bytes32
);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol";
import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {ServiceManagerBaseStorage} from "./ServiceManagerBaseStorage.sol";
import {IServiceManager} from "./interfaces/IServiceManager.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";
import {BitmapUtils} from "./libraries/BitmapUtils.sol";
/**
* @title Minimal implementation of a ServiceManager-type contract.
* This contract can be inherited from or simply used as a point-of-reference.
* @author Layr Labs, Inc.
*/
abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
using SafeERC20 for IERC20;
using BitmapUtils for *;
/// @notice when applied to a function, only allows the RegistryCoordinator to call it
modifier onlyRegistryCoordinator() {
require(
msg.sender == address(_registryCoordinator),
"ServiceManagerBase.onlyRegistryCoordinator: caller is not the registry coordinator"
);
_;
}
/// @notice only rewardsInitiator can call createAVSRewardsSubmission
modifier onlyRewardsInitiator() {
_checkRewardsInitiator();
_;
}
function _checkRewardsInitiator() internal view {
require(
msg.sender == rewardsInitiator,
"ServiceManagerBase.onlyRewardsInitiator: caller is not the rewards initiator"
);
}
/// @notice Sets the (immutable) `_registryCoordinator` address
constructor(
IAVSDirectory __avsDirectory,
IRewardsCoordinator __rewardsCoordinator,
IRegistryCoordinator __registryCoordinator,
IStakeRegistry __stakeRegistry
)
ServiceManagerBaseStorage(
__avsDirectory,
__rewardsCoordinator,
__registryCoordinator,
__stakeRegistry
)
{
_disableInitializers();
}
function __ServiceManagerBase_init(
address initialOwner,
address _rewardsInitiator
) internal virtual onlyInitializing {
_transferOwnership(initialOwner);
_setRewardsInitiator(_rewardsInitiator);
}
/**
* @notice Updates the metadata URI for the AVS
* @param _metadataURI is the metadata URI for the AVS
* @dev only callable by the owner
*/
function updateAVSMetadataURI(
string memory _metadataURI
) public virtual onlyOwner {
_avsDirectory.updateAVSMetadataURI(_metadataURI);
}
/**
* @notice Creates a new rewards submission to the EigenLayer RewardsCoordinator contract, to be split amongst the
* set of stakers delegated to operators who are registered to this `avs`
* @param rewardsSubmissions The rewards submissions being created
* @dev Only callable by the permissioned rewardsInitiator address
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`
* @dev The tokens are sent to the `RewardsCoordinator` contract
* @dev Strategies must be in ascending order of addresses to check for duplicates
* @dev This function will revert if the `rewardsSubmission` is malformed,
* e.g. if the `strategies` and `weights` arrays are of non-equal lengths
* @dev This function may fail to execute with a large number of submissions due to gas limits. Use a
* smaller array of submissions if necessary.
*/
function createAVSRewardsSubmission(
IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions
) public virtual onlyRewardsInitiator {
for (uint256 i = 0; i < rewardsSubmissions.length; ++i) {
// transfer token to ServiceManager and approve RewardsCoordinator to transfer again
// in createAVSRewardsSubmission() call
rewardsSubmissions[i].token.safeTransferFrom(
msg.sender,
address(this),
rewardsSubmissions[i].amount
);
rewardsSubmissions[i].token.safeIncreaseAllowance(
address(_rewardsCoordinator),
rewardsSubmissions[i].amount
);
}
_rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions);
}
/**
* @notice Creates a new operator-directed rewards submission, to be split amongst the operators and
* set of stakers delegated to operators who are registered to this `avs`.
* @param operatorDirectedRewardsSubmissions The operator-directed rewards submissions being created.
* @dev Only callable by the permissioned rewardsInitiator address
* @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION`
* @dev The tokens are sent to the `RewardsCoordinator` contract
* @dev This contract needs a token approval of sum of all `operatorRewards` in the `operatorDirectedRewardsSubmissions`, before calling this function.
* @dev Strategies must be in ascending order of addresses to check for duplicates
* @dev Operators must be in ascending order of addresses to check for duplicates.
* @dev This function will revert if the `operatorDirectedRewardsSubmissions` is malformed.
* @dev This function may fail to execute with a large number of submissions due to gas limits. Use a
* smaller array of submissions if necessary.
*/
function createOperatorDirectedAVSRewardsSubmission(
IRewardsCoordinator.OperatorDirectedRewardsSubmission[]
calldata operatorDirectedRewardsSubmissions
) public virtual onlyRewardsInitiator {
for (
uint256 i = 0;
i < operatorDirectedRewardsSubmissions.length;
++i
) {
// Calculate total amount of token to transfer
uint256 totalAmount = 0;
for (
uint256 j = 0;
j <
operatorDirectedRewardsSubmissions[i].operatorRewards.length;
++j
) {
totalAmount += operatorDirectedRewardsSubmissions[i]
.operatorRewards[j]
.amount;
}
// Transfer token to ServiceManager and approve RewardsCoordinator to transfer again
// in createOperatorDirectedAVSRewardsSubmission() call
operatorDirectedRewardsSubmissions[i].token.safeTransferFrom(
msg.sender,
address(this),
totalAmount
);
operatorDirectedRewardsSubmissions[i].token.safeIncreaseAllowance(
address(_rewardsCoordinator),
totalAmount
);
}
_rewardsCoordinator.createOperatorDirectedAVSRewardsSubmission(
address(this),
operatorDirectedRewardsSubmissions
);
}
/**
* @notice Forwards a call to Eigenlayer's RewardsCoordinator contract to set the address of the entity that can call `processClaim` on behalf of this contract.
* @param claimer The address of the entity that can call `processClaim` on behalf of the earner
* @dev Only callable by the owner.
*/
function setClaimerFor(address claimer) public virtual onlyOwner {
_rewardsCoordinator.setClaimerFor(claimer);
}
/**
* @notice Forwards a call to EigenLayer's AVSDirectory 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
) public virtual onlyRegistryCoordinator {
_avsDirectory.registerOperatorToAVS(operator, operatorSignature);
}
/**
* @notice Forwards a call to EigenLayer's AVSDirectory contract to confirm operator deregistration from the AVS
* @param operator The address of the operator to deregister.
*/
function deregisterOperatorFromAVS(
address operator
) public virtual onlyRegistryCoordinator {
_avsDirectory.deregisterOperatorFromAVS(operator);
}
/**
* @notice Sets the rewards initiator address
* @param newRewardsInitiator The new rewards initiator address
* @dev only callable by the owner
*/
function setRewardsInitiator(
address newRewardsInitiator
) external onlyOwner {
_setRewardsInitiator(newRewardsInitiator);
}
function _setRewardsInitiator(address newRewardsInitiator) internal {
emit RewardsInitiatorUpdated(rewardsInitiator, newRewardsInitiator);
rewardsInitiator = newRewardsInitiator;
}
/**
* @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
virtual
returns (address[] memory)
{
uint256 quorumCount = _registryCoordinator.quorumCount();
if (quorumCount == 0) {
return new address[](0);
}
uint256 strategyCount;
for (uint256 i = 0; i < quorumCount; i++) {
strategyCount += _stakeRegistry.strategyParamsLength(uint8(i));
}
address[] memory restakedStrategies = new address[](strategyCount);
uint256 index = 0;
for (uint256 i = 0; i < _registryCoordinator.quorumCount(); i++) {
uint256 strategyParamsLength = _stakeRegistry.strategyParamsLength(
uint8(i)
);
for (uint256 j = 0; j < strategyParamsLength; j++) {
restakedStrategies[index] = address(
_stakeRegistry.strategyParamsByIndex(uint8(i), j).strategy
);
index++;
}
}
return restakedStrategies;
}
/**
* @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 virtual returns (address[] memory) {
bytes32 operatorId = _registryCoordinator.getOperatorId(operator);
uint192 operatorBitmap = _registryCoordinator.getCurrentQuorumBitmap(
operatorId
);
if (operatorBitmap == 0 || _registryCoordinator.quorumCount() == 0) {
return new address[](0);
}
// Get number of strategies for each quorum in operator bitmap
bytes memory operatorRestakedQuorums = BitmapUtils.bitmapToBytesArray(
operatorBitmap
);
uint256 strategyCount;
for (uint256 i = 0; i < operatorRestakedQuorums.length; i++) {
strategyCount += _stakeRegistry.strategyParamsLength(
uint8(operatorRestakedQuorums[i])
);
}
// Get strategies for each quorum in operator bitmap
address[] memory restakedStrategies = new address[](strategyCount);
uint256 index = 0;
for (uint256 i = 0; i < operatorRestakedQuorums.length; i++) {
uint8 quorum = uint8(operatorRestakedQuorums[i]);
uint256 strategyParamsLength = _stakeRegistry.strategyParamsLength(
quorum
);
for (uint256 j = 0; j < strategyParamsLength; j++) {
restakedStrategies[index] = address(
_stakeRegistry.strategyParamsByIndex(quorum, j).strategy
);
index++;
}
}
return restakedStrategies;
}
/// @notice Returns the EigenLayer AVSDirectory contract.
function avsDirectory() external view override returns (address) {
return address(_avsDirectory);
}
}// SPDX-License-Identifier: UNLICENSED
// SEE LICENSE IN https://files.altlayer.io/Alt-Research-License-1.md
// Copyright Alt Research Ltd. 2023. All rights reserved.
//
// You acknowledge and agree that Alt Research Ltd. ("Alt Research") (or Alt
// Research's licensors) own all legal rights, titles and interests in and to the
// work, software, application, source code, documentation and any other documents
pragma solidity =0.8.12;
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
abstract contract MachServiceManagerStorage {
// CONSTANTS
uint256 public constant THRESHOLD_DENOMINATOR = 100;
// slot 0
/// @notice Allowed rollup chain IDs
mapping(uint256 => bool) public rollupChainIDs;
// Slot 1
mapping(uint256 => EnumerableSet.Bytes32Set) internal _messageHashes;
// Slot 2, 3, 4
bytes32 private __DEPRECATED_SLOT2;
bytes32 private __DEPRECATED_SLOT3;
bytes32 private __DEPRECATED_SLOT4;
// Slot 5
/// @notice address that is permissioned to confirm alerts
address public alertConfirmer;
/// @notice Whether or not the allowlist is enabled
bool public allowlistEnabled;
/// @notice Minimal quorum threshold percentage
uint8 public quorumThresholdPercentage;
// slot 6
/// @notice Resolved message hashes, prevent aggregator from replay any resolved alert
mapping(uint256 => EnumerableSet.Bytes32Set) internal _resolvedMessageHashes;
// slot 7
bytes32 private __DEPRECATED_SLOT7;
// slot 8
/// @notice Role for whitelisting operators
address public whitelister;
/// @notice Set of operators that are allowed to register
EnumerableSet.AddressSet internal _allowlist;
// storage gap for upgradeability
// slither-disable-next-line shadowing-state
uint256[42] private __GAP;
}// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.12; error ZeroAddress(); error InvalidStartIndex(); error InvalidConfirmer(); error NotWhitelister(); error InvalidSender(); error NoStatusChange(); error InvalidRollupChainID(); error InvalidReferenceBlockNum(); error InsufficientThreshold(); error InsufficientThresholdPercentages(); error InvalidQuorumParam(); error InvalidQuorumThresholdPercentage(); error AlreadyInAllowlist(); error NotAdded(); error AlreadyAdded(); error ResolvedAlert(); error AlreadyEnabled(); error AlreadyDisabled(); // Common error AlreadyInitialized(); error NotInitialized(); error ZeroValue(); error UselessAlert(); error InvalidAlert(); error InvalidAlertType(); error InvalidProvedIndex(); error InvalidCheckpoint(); error InvalidIndex(); error ProveImageIdMismatch(); error ProveBlockNumberMismatch(); error ProveOutputRootMismatch(); error ParentCheckpointNumberMismatch(); error ParentCheckpointOutputRootMismatch(); error ProveVerifyFailed(); error InvalidJournal(); error NoAlert(); error NotOperator();
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.12;
import {IServiceManager} from "eigenlayer-middleware/interfaces/IServiceManager.sol";
import {BLSSignatureChecker} from "eigenlayer-middleware/BLSSignatureChecker.sol";
import {IMachOptimism} from "../interfaces/IMachOptimism.sol";
interface ITotalAlertsLegacy {
// Legacy
/// @notice Returns the length of total alerts
function totalAlerts() external view returns (uint256);
}
interface ITotalAlerts {
/// @notice Returns the length of total alerts
function totalAlerts(uint256 rollupChainId) external view returns (uint256);
}
/**
* @title Interface for the MachServiceManager contract.
* @author Altlayer, Inc.
*/
interface IMachServiceManager is IServiceManager {
struct AlertHeader {
bytes32 messageHash;
// for BLS verification
bytes quorumNumbers; // each byte is a different quorum number
bytes quorumThresholdPercentages; // every bytes is an amount less than 100 specifying the percentage of stake
// the must have signed in the corresponding quorum in `quorumNumbers`
uint32 referenceBlockNumber;
uint256 rollupChainID;
}
struct ReducedAlertHeader {
bytes32 messageHash;
uint32 referenceBlockNumber;
uint256 rollupChainID;
}
event AllowlistUpdated(address[] operators, bool[] status);
/**
* @notice Emitted when the alert confirmer is changed.
* @param previousAddress The address of the previous alert confirmer
* @param newAddress The address of the new alert confirmer
*/
event AlertConfirmerChanged(address previousAddress, address newAddress);
/**
* @notice Emitted when the whitelister is changed.
* @param previousAddress The address of the previous whitelister
* @param newAddress The address of the new whitelister
*/
event WhitelisterChanged(address previousAddress, address newAddress);
/**
* @notice Emitted when the quorum threshold percentage is changed.
* @param thresholdPercentages The new quorum threshold percentage
*/
event QuorumThresholdPercentageChanged(uint8 thresholdPercentages);
/**
* @notice Emitted when an operator is added to the allowlist.
* @param operator The operator
*/
event OperatorAllowed(address operator);
/**
* @notice Emitted when an operator is removed from the allowlist.
* @param operator The operator
*/
event OperatorDisallowed(address operator);
/**
* @notice Emitted when the allowlist is enabled.
*/
event AllowlistEnabled();
/**
* @notice Emitted when the allowlist is disabled.
*/
event AllowlistDisabled();
/**
* @notice Emitted when rollup chain id is updated
*/
event RollupChainIDUpdated(uint256 rollupChainId, bool status);
/**
* @notice Emitted when an Alert is confirmed.
* @param alertHeaderHash The hash of the alert header
* @param messageHash The message hash
*/
event AlertConfirmed(bytes32 indexed alertHeaderHash, bytes32 messageHash);
/**
* @notice Emitted when an Alert is removed.
* @param messageHash The message hash
* @param messageHash The sender address
*/
event AlertRemoved(bytes32 messageHash, address sender);
/**
* @notice Enable the allowlist.
*/
function enableAllowlist() external;
/**
* @notice Disable the allowlist.
*/
function disableAllowlist() external;
/**
* @notice Set confirmer address.
*/
function setConfirmer(address confirmer) external;
/**
* @notice Set whitelister address.
*/
function setWhitelister(address whitelister) external;
/**
* @notice Set the status of a rollup chain ID
* @param rollupChainId The ID of the rollup chain to be updated
* @param status The new status for the rollup chain ID (true for active, false for inactive)
*/
function setRollupChainID(uint256 rollupChainId, bool status) external;
/**
* @notice Remove an Alert.
* @param messageHash The message hash of the alert
*/
function removeAlert(uint256 rollupChainId, bytes32 messageHash) external;
/**
* @notice Update quorum threshold percentage
* @param thresholdPercentage The new quorum threshold percentage
*/
function updateQuorumThresholdPercentage(uint8 thresholdPercentage) external;
/**
* @notice This function is used for
* - submitting alert,
* - check that the aggregate signature is valid,
* - and check whether quorum has been achieved or not.
*/
function confirmAlert(
AlertHeader calldata alertHeader,
BLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature
) external;
/// @notice Returns the length of total alerts
function totalAlerts(uint256 rollupChainId) external view returns (uint256);
/// @notice Checks if messageHash exists
function contains(uint256 rollupChainId, bytes32 messageHash) external view returns (bool);
/// @notice Returns an array of messageHash
function queryMessageHashes(uint256 rollupChainId, uint256 start, uint256 querySize)
external
view
returns (bytes32[] memory);
}// 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: 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: 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 emit an event for the exchange rate between 1 share and underlying token in a strategy contract
* @param rate is the exchange rate in wad 18 decimals
* @dev Tokens that do not have 18 decimals must have offchain services scale the exchange rate by the proper magnitude
*/
event ExchangeRateEmitted(uint256 rate);
/**
* Used to emit the underlying token and its decimals on strategy creation
* @notice token
* @param token is the ERC20 token of the strategy
* @param decimals are the decimals of the ERC20 token in the strategy
*/
event StrategyTokenSet(IERC20 token, uint8 decimals);
/**
* @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: BUSL-1.1
pragma solidity >=0.5.0;
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.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 AVSDirectory 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 AVSDirectory 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);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "./IStrategy.sol";
import "./ISignatureUtils.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 DEPRECATED -- this field is no longer used, payments are handled in PaymentCoordinator.sol
address __deprecated_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 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 is already delegated to an operator.
* @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.
*/
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 is unused, but will be used in the Slasher eventually
* @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 Owner-only function for modifying the value of the `minWithdrawalDelayBlocks` variable.
* @param newMinWithdrawalDelayBlocks new value of `minWithdrawalDelayBlocks`.
*/
function setMinWithdrawalDelayBlocks(uint256 newMinWithdrawalDelayBlocks) external;
/**
* @notice Called by owner to set the minimum withdrawal delay blocks for each passed in strategy
* Note that the min number of blocks to complete a withdrawal of a strategy is
* MAX(minWithdrawalDelayBlocks, strategyWithdrawalDelayBlocks[strategy])
* @param strategies The strategies to set the minimum withdrawal delay blocks for
* @param withdrawalDelayBlocks The minimum withdrawal delay blocks to set for each strategy
*/
function setStrategyWithdrawalDelayBlocks(IStrategy[] calldata strategies, uint256[] calldata withdrawalDelayBlocks) 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 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 the number of actively-delegatable shares a staker has across all strategies.
* @dev Returns two empty arrays in the case that the Staker has no actively-delegateable shares.
*/
function getDelegatableShares(address staker) external view returns (IStrategy[] memory, uint256[] memory);
/**
* @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 return address of the beaconChainETHStrategy
function beaconChainETHStrategy() external view returns (IStrategy);
/**
* @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);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
/**
* @title Minimal interface for a `Registry`-type contract.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice Functions related to the registration process itself have been intentionally excluded
* because their function signatures may vary significantly.
*/
interface IRegistry {
function registryCoordinator() external view returns (address);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {IRegistry} from "./IRegistry.sol";
import {BN254} from "../libraries/BN254.sol";
/**
* @title Minimal interface for a registry that keeps track of aggregate operator public keys across many quorums.
* @author Layr Labs, Inc.
*/
interface IBLSApkRegistry is IRegistry {
// STRUCTS
/// @notice Data structure used to track the history of the Aggregate Public Key of all operators
struct ApkUpdate {
// first 24 bytes of keccak256(apk_x0, apk_x1, apk_y0, apk_y1)
bytes24 apkHash;
// block number at which the update occurred
uint32 updateBlockNumber;
// block number at which the next update occurred
uint32 nextUpdateBlockNumber;
}
/**
* @notice Struct used when registering a new public key
* @param pubkeyRegistrationSignature is the registration message signed by the private key of the operator
* @param pubkeyG1 is the corresponding G1 public key of the operator
* @param pubkeyG2 is the corresponding G2 public key of the operator
*/
struct PubkeyRegistrationParams {
BN254.G1Point pubkeyRegistrationSignature;
BN254.G1Point pubkeyG1;
BN254.G2Point pubkeyG2;
}
// EVENTS
/// @notice Emitted when `operator` registers with the public keys `pubkeyG1` and `pubkeyG2`.
event NewPubkeyRegistration(address indexed operator, BN254.G1Point pubkeyG1, BN254.G2Point pubkeyG2);
// @notice Emitted when a new operator pubkey is registered for a set of quorums
event OperatorAddedToQuorums(
address operator,
bytes32 operatorId,
bytes quorumNumbers
);
// @notice Emitted when an operator pubkey is removed from a set of quorums
event OperatorRemovedFromQuorums(
address operator,
bytes32 operatorId,
bytes quorumNumbers
);
/**
* @notice Registers the `operator`'s pubkey for the specified `quorumNumbers`.
* @param operator The address of the operator to register.
* @param quorumNumbers The quorum numbers the operator is registering for, where each byte is an 8 bit integer quorumNumber.
* @dev access restricted to the RegistryCoordinator
* @dev Preconditions (these are assumed, not validated in this contract):
* 1) `quorumNumbers` has no duplicates
* 2) `quorumNumbers.length` != 0
* 3) `quorumNumbers` is ordered in ascending order
* 4) the operator is not already registered
*/
function registerOperator(address operator, bytes calldata quorumNumbers) external;
/**
* @notice Deregisters the `operator`'s pubkey for the specified `quorumNumbers`.
* @param operator The address of the operator to deregister.
* @param quorumNumbers The quorum numbers the operator is deregistering from, where each byte is an 8 bit integer quorumNumber.
* @dev access restricted to the RegistryCoordinator
* @dev Preconditions (these are assumed, not validated in this contract):
* 1) `quorumNumbers` has no duplicates
* 2) `quorumNumbers.length` != 0
* 3) `quorumNumbers` is ordered in ascending order
* 4) the operator is not already deregistered
* 5) `quorumNumbers` is a subset of the quorumNumbers that the operator is registered for
*/
function deregisterOperator(address operator, bytes calldata quorumNumbers) external;
/**
* @notice Initializes a new quorum by pushing its first apk update
* @param quorumNumber The number of the new quorum
*/
function initializeQuorum(uint8 quorumNumber) external;
/**
* @notice mapping from operator address to pubkey hash.
* Returns *zero* if the `operator` has never registered, and otherwise returns the hash of the public key of the operator.
*/
function operatorToPubkeyHash(address operator) external view returns (bytes32);
/**
* @notice mapping from pubkey hash to operator address.
* Returns *zero* if no operator has ever registered the public key corresponding to `pubkeyHash`,
* and otherwise returns the (unique) registered operator who owns the BLS public key that is the preimage of `pubkeyHash`.
*/
function pubkeyHashToOperator(bytes32 pubkeyHash) external view returns (address);
/**
* @notice Called by the RegistryCoordinator register an operator as the owner of a BLS public key.
* @param operator is the operator for whom the key is being registered
* @param params contains the G1 & G2 public keys of the operator, and a signature proving their ownership
* @param pubkeyRegistrationMessageHash is a hash that the operator must sign to prove key ownership
*/
function registerBLSPublicKey(
address operator,
PubkeyRegistrationParams calldata params,
BN254.G1Point calldata pubkeyRegistrationMessageHash
) external returns (bytes32 operatorId);
/**
* @notice Returns the pubkey and pubkey hash of an operator
* @dev Reverts if the operator has not registered a valid pubkey
*/
function getRegisteredPubkey(address operator) external view returns (BN254.G1Point memory, bytes32);
/// @notice Returns the current APK for the provided `quorumNumber `
function getApk(uint8 quorumNumber) external view returns (BN254.G1Point memory);
/// @notice Returns the index of the quorumApk index at `blockNumber` for the provided `quorumNumber`
function getApkIndicesAtBlockNumber(bytes calldata quorumNumbers, uint256 blockNumber) external view returns(uint32[] memory);
/// @notice Returns the `ApkUpdate` struct at `index` in the list of APK updates for the `quorumNumber`
function getApkUpdateAtIndex(uint8 quorumNumber, uint256 index) external view returns (ApkUpdate memory);
/// @notice Returns the operator address for the given `pubkeyHash`
function getOperatorFromPubkeyHash(bytes32 pubkeyHash) external view returns (address);
/**
* @notice get 24 byte hash of the apk of `quorumNumber` at `blockNumber` using the provided `index`;
* called by checkSignatures in BLSSignatureChecker.sol.
* @param quorumNumber is the quorum whose ApkHash is being retrieved
* @param blockNumber is the number of the block for which the latest ApkHash will be retrieved
* @param index is the index of the apkUpdate being retrieved from the list of quorum apkUpdates in storage
*/
function getApkHashAtBlockNumberAndIndex(uint8 quorumNumber, uint32 blockNumber, uint256 index) external view returns (bytes24);
/// @notice returns the ID used to identify the `operator` within this AVS.
/// @dev Returns zero in the event that the `operator` has never registered for the AVS
function getOperatorId(address operator) external view returns (bytes32);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {IRegistry} from "./IRegistry.sol";
/**
* @title Interface for a `Registry`-type contract that keeps track of an ordered list of operators for up to 256 quorums.
* @author Layr Labs, Inc.
*/
interface IIndexRegistry is IRegistry {
// EVENTS
// emitted when an operator's index in the ordered operator list for the quorum with number `quorumNumber` is updated
event QuorumIndexUpdate(bytes32 indexed operatorId, uint8 quorumNumber, uint32 newOperatorIndex);
// DATA STRUCTURES
// struct used to give definitive ordering to operators at each blockNumber.
struct OperatorUpdate {
// blockNumber number from which `operatorIndex` was the operators index
// the operator's index is the first entry such that `blockNumber >= entry.fromBlockNumber`
uint32 fromBlockNumber;
// the operator at this index
bytes32 operatorId;
}
// struct used to denote the number of operators in a quorum at a given blockNumber
struct QuorumUpdate {
// The total number of operators at a `blockNumber` is the first entry such that `blockNumber >= entry.fromBlockNumber`
uint32 fromBlockNumber;
// The number of operators at `fromBlockNumber`
uint32 numOperators;
}
/**
* @notice Registers the operator with the specified `operatorId` for the quorums specified by `quorumNumbers`.
* @param operatorId is the id of the operator that is being registered
* @param quorumNumbers is the quorum numbers the operator is registered for
* @return numOperatorsPerQuorum is a list of the number of operators (including the registering operator) in each of the quorums the operator is registered for
* @dev access restricted to the RegistryCoordinator
* @dev Preconditions (these are assumed, not validated in this contract):
* 1) `quorumNumbers` has no duplicates
* 2) `quorumNumbers.length` != 0
* 3) `quorumNumbers` is ordered in ascending order
* 4) the operator is not already registered
*/
function registerOperator(bytes32 operatorId, bytes calldata quorumNumbers) external returns(uint32[] memory);
/**
* @notice Deregisters the operator with the specified `operatorId` for the quorums specified by `quorumNumbers`.
* @param operatorId is the id of the operator that is being deregistered
* @param quorumNumbers is the quorum numbers the operator is deregistered for
* @dev access restricted to the RegistryCoordinator
* @dev Preconditions (these are assumed, not validated in this contract):
* 1) `quorumNumbers` has no duplicates
* 2) `quorumNumbers.length` != 0
* 3) `quorumNumbers` is ordered in ascending order
* 4) the operator is not already deregistered
* 5) `quorumNumbers` is a subset of the quorumNumbers that the operator is registered for
*/
function deregisterOperator(bytes32 operatorId, bytes calldata quorumNumbers) external;
/**
* @notice Initialize a quorum by pushing its first quorum update
* @param quorumNumber The number of the new quorum
*/
function initializeQuorum(uint8 quorumNumber) external;
/// @notice Returns the OperatorUpdate entry for the specified `operatorIndex` and `quorumNumber` at the specified `arrayIndex`
function getOperatorUpdateAtIndex(
uint8 quorumNumber,
uint32 operatorIndex,
uint32 arrayIndex
) external view returns (OperatorUpdate memory);
/// @notice Returns the QuorumUpdate entry for the specified `quorumNumber` at the specified `quorumIndex`
function getQuorumUpdateAtIndex(uint8 quorumNumber, uint32 quorumIndex) external view returns (QuorumUpdate memory);
/// @notice Returns the most recent OperatorUpdate entry for the specified quorumNumber and operatorIndex
function getLatestOperatorUpdate(uint8 quorumNumber, uint32 operatorIndex) external view returns (OperatorUpdate memory);
/// @notice Returns the most recent QuorumUpdate entry for the specified quorumNumber
function getLatestQuorumUpdate(uint8 quorumNumber) external view returns (QuorumUpdate memory);
/// @notice Returns the current number of operators of this service for `quorumNumber`.
function totalOperatorsForQuorum(uint8 quorumNumber) external view returns (uint32);
/// @notice Returns an ordered list of operators of the services for the given `quorumNumber` at the given `blockNumber`
function getOperatorListAtBlockNumber(uint8 quorumNumber, uint32 blockNumber) external view returns (bytes32[] memory);
}// SPDX-License-Identifier: MIT
// several functions are taken or adapted from https://github.com/HarryR/solcrypto/blob/master/contracts/altbn128.sol (MIT license):
// Copyright 2017 Christian Reitwiessner
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
// The remainder of the code in this library is written by LayrLabs Inc. and is also under an MIT license
pragma solidity ^0.8.12;
/**
* @title Library for operations on the BN254 elliptic curve.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice Contains BN254 parameters, common operations (addition, scalar mul, pairing), and BLS signature functionality.
*/
library BN254 {
// modulus for the underlying field F_p of the elliptic curve
uint256 internal constant FP_MODULUS =
21888242871839275222246405745257275088696311157297823662689037894645226208583;
// modulus for the underlying field F_r of the elliptic curve
uint256 internal constant FR_MODULUS =
21888242871839275222246405745257275088548364400416034343698204186575808495617;
struct G1Point {
uint256 X;
uint256 Y;
}
// Encoding of field elements is: X[1] * i + X[0]
struct G2Point {
uint256[2] X;
uint256[2] Y;
}
function generatorG1() internal pure returns (G1Point memory) {
return G1Point(1, 2);
}
// generator of group G2
/// @dev Generator point in F_q2 is of the form: (x0 + ix1, y0 + iy1).
uint256 internal constant G2x1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 internal constant G2x0 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 internal constant G2y1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
uint256 internal constant G2y0 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
/// @notice returns the G2 generator
/// @dev mind the ordering of the 1s and 0s!
/// this is because of the (unknown to us) convention used in the bn254 pairing precompile contract
/// "Elements a * i + b of F_p^2 are encoded as two elements of F_p, (a, b)."
/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-197.md#encoding
function generatorG2() internal pure returns (G2Point memory) {
return G2Point([G2x1, G2x0], [G2y1, G2y0]);
}
// negation of the generator of group G2
/// @dev Generator point in F_q2 is of the form: (x0 + ix1, y0 + iy1).
uint256 internal constant nG2x1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 internal constant nG2x0 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 internal constant nG2y1 = 17805874995975841540914202342111839520379459829704422454583296818431106115052;
uint256 internal constant nG2y0 = 13392588948715843804641432497768002650278120570034223513918757245338268106653;
function negGeneratorG2() internal pure returns (G2Point memory) {
return G2Point([nG2x1, nG2x0], [nG2y1, nG2y0]);
}
bytes32 internal constant powersOfTauMerkleRoot =
0x22c998e49752bbb1918ba87d6d59dd0e83620a311ba91dd4b2cc84990b31b56f;
/**
* @param p Some point in G1.
* @return The negation of `p`, i.e. p.plus(p.negate()) should be zero.
*/
function negate(G1Point memory p) internal pure returns (G1Point memory) {
// The prime q in the base field F_q for G1
if (p.X == 0 && p.Y == 0) {
return G1Point(0, 0);
} else {
return G1Point(p.X, FP_MODULUS - (p.Y % FP_MODULUS));
}
}
/**
* @return r the sum of two points of G1
*/
function plus(G1Point memory p1, G1Point memory p2) internal view returns (G1Point memory r) {
uint256[4] memory input;
input[0] = p1.X;
input[1] = p1.Y;
input[2] = p2.X;
input[3] = p2.Y;
bool success;
// solium-disable-next-line security/no-inline-assembly
assembly {
success := staticcall(sub(gas(), 2000), 6, input, 0x80, r, 0x40)
// Use "invalid" to make gas estimation work
switch success
case 0 {
invalid()
}
}
require(success, "ec-add-failed");
}
/**
* @notice an optimized ecMul implementation that takes O(log_2(s)) ecAdds
* @param p the point to multiply
* @param s the scalar to multiply by
* @dev this function is only safe to use if the scalar is 9 bits or less
*/
function scalar_mul_tiny(BN254.G1Point memory p, uint16 s) internal view returns (BN254.G1Point memory) {
require(s < 2**9, "scalar-too-large");
// if s is 1 return p
if(s == 1) {
return p;
}
// the accumulated product to return
BN254.G1Point memory acc = BN254.G1Point(0, 0);
// the 2^n*p to add to the accumulated product in each iteration
BN254.G1Point memory p2n = p;
// value of most significant bit
uint16 m = 1;
// index of most significant bit
uint8 i = 0;
//loop until we reach the most significant bit
while(s >= m){
unchecked {
// if the current bit is 1, add the 2^n*p to the accumulated product
if ((s >> i) & 1 == 1) {
acc = plus(acc, p2n);
}
// double the 2^n*p for the next iteration
p2n = plus(p2n, p2n);
// increment the index and double the value of the most significant bit
m <<= 1;
++i;
}
}
// return the accumulated product
return acc;
}
/**
* @return r the product of a point on G1 and a scalar, i.e.
* p == p.scalar_mul(1) and p.plus(p) == p.scalar_mul(2) for all
* points p.
*/
function scalar_mul(G1Point memory p, uint256 s) internal view returns (G1Point memory r) {
uint256[3] memory input;
input[0] = p.X;
input[1] = p.Y;
input[2] = s;
bool success;
// solium-disable-next-line security/no-inline-assembly
assembly {
success := staticcall(sub(gas(), 2000), 7, input, 0x60, r, 0x40)
// Use "invalid" to make gas estimation work
switch success
case 0 {
invalid()
}
}
require(success, "ec-mul-failed");
}
/**
* @return The result of computing the pairing check
* e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1
* For example,
* pairing([P1(), P1().negate()], [P2(), P2()]) should return true.
*/
function pairing(
G1Point memory a1,
G2Point memory a2,
G1Point memory b1,
G2Point memory b2
) internal view returns (bool) {
G1Point[2] memory p1 = [a1, b1];
G2Point[2] memory p2 = [a2, b2];
uint256[12] memory input;
for (uint256 i = 0; i < 2; i++) {
uint256 j = i * 6;
input[j + 0] = p1[i].X;
input[j + 1] = p1[i].Y;
input[j + 2] = p2[i].X[0];
input[j + 3] = p2[i].X[1];
input[j + 4] = p2[i].Y[0];
input[j + 5] = p2[i].Y[1];
}
uint256[1] memory out;
bool success;
// solium-disable-next-line security/no-inline-assembly
assembly {
success := staticcall(sub(gas(), 2000), 8, input, mul(12, 0x20), out, 0x20)
// Use "invalid" to make gas estimation work
switch success
case 0 {
invalid()
}
}
require(success, "pairing-opcode-failed");
return out[0] != 0;
}
/**
* @notice This function is functionally the same as pairing(), however it specifies a gas limit
* the user can set, as a precompile may use the entire gas budget if it reverts.
*/
function safePairing(
G1Point memory a1,
G2Point memory a2,
G1Point memory b1,
G2Point memory b2,
uint256 pairingGas
) internal view returns (bool, bool) {
G1Point[2] memory p1 = [a1, b1];
G2Point[2] memory p2 = [a2, b2];
uint256[12] memory input;
for (uint256 i = 0; i < 2; i++) {
uint256 j = i * 6;
input[j + 0] = p1[i].X;
input[j + 1] = p1[i].Y;
input[j + 2] = p2[i].X[0];
input[j + 3] = p2[i].X[1];
input[j + 4] = p2[i].Y[0];
input[j + 5] = p2[i].Y[1];
}
uint256[1] memory out;
bool success;
// solium-disable-next-line security/no-inline-assembly
assembly {
success := staticcall(pairingGas, 8, input, mul(12, 0x20), out, 0x20)
}
//Out is the output of the pairing precompile, either 0 or 1 based on whether the two pairings are equal.
//Success is true if the precompile actually goes through (aka all inputs are valid)
return (success, out[0] != 0);
}
/// @return hashedG1 the keccak256 hash of the G1 Point
/// @dev used for BLS signatures
function hashG1Point(BN254.G1Point memory pk) internal pure returns (bytes32 hashedG1) {
assembly {
mstore(0, mload(pk))
mstore(0x20, mload(add(0x20, pk)))
hashedG1 := keccak256(0, 0x40)
}
}
/// @return the keccak256 hash of the G2 Point
/// @dev used for BLS signatures
function hashG2Point(
BN254.G2Point memory pk
) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(pk.X[0], pk.X[1], pk.Y[0], pk.Y[1]));
}
/**
* @notice adapted from https://github.com/HarryR/solcrypto/blob/master/contracts/altbn128.sol
*/
function hashToG1(bytes32 _x) internal view returns (G1Point memory) {
uint256 beta = 0;
uint256 y = 0;
uint256 x = uint256(_x) % FP_MODULUS;
while (true) {
(beta, y) = findYFromX(x);
// y^2 == beta
if( beta == mulmod(y, y, FP_MODULUS) ) {
return G1Point(x, y);
}
x = addmod(x, 1, FP_MODULUS);
}
return G1Point(0, 0);
}
/**
* Given X, find Y
*
* where y = sqrt(x^3 + b)
*
* Returns: (x^3 + b), y
*/
function findYFromX(uint256 x) internal view returns (uint256, uint256) {
// beta = (x^3 + b) % p
uint256 beta = addmod(mulmod(mulmod(x, x, FP_MODULUS), x, FP_MODULUS), 3, FP_MODULUS);
// y^2 = x^3 + b
// this acts like: y = sqrt(beta) = beta^((p+1) / 4)
uint256 y = expMod(beta, 0xc19139cb84c680a6e14116da060561765e05aa45a1c72a34f082305b61f3f52, FP_MODULUS);
return (beta, y);
}
function expMod(uint256 _base, uint256 _exponent, uint256 _modulus) internal view returns (uint256 retval) {
bool success;
uint256[1] memory output;
uint[6] memory input;
input[0] = 0x20; // baseLen = new(big.Int).SetBytes(getData(input, 0, 32))
input[1] = 0x20; // expLen = new(big.Int).SetBytes(getData(input, 32, 32))
input[2] = 0x20; // modLen = new(big.Int).SetBytes(getData(input, 64, 32))
input[3] = _base;
input[4] = _exponent;
input[5] = _modulus;
assembly {
success := staticcall(sub(gas(), 2000), 5, input, 0xc0, output, 0x20)
// Use "invalid" to make gas estimation work
switch success
case 0 {
invalid()
}
}
require(success, "BN254.expMod: call failure");
return output[0];
}
}// 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: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
import {IServiceManager} from "./interfaces/IServiceManager.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";
import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
/**
* @title Storage variables for the `ServiceManagerBase` contract.
* @author Layr Labs, Inc.
* @notice This storage contract is separate from the logic to simplify the upgrade process.
*/
abstract contract ServiceManagerBaseStorage is IServiceManager, OwnableUpgradeable {
/**
*
* CONSTANTS AND IMMUTABLES
*
*/
IAVSDirectory internal immutable _avsDirectory;
IRewardsCoordinator internal immutable _rewardsCoordinator;
IRegistryCoordinator internal immutable _registryCoordinator;
IStakeRegistry internal immutable _stakeRegistry;
/**
*
* STATE VARIABLES
*
*/
/// @notice The address of the entity that can initiate rewards
address public rewardsInitiator;
/// @notice Sets the (immutable) `_avsDirectory`, `_rewardsCoordinator`, `_registryCoordinator`, and `_stakeRegistry` addresses
constructor(
IAVSDirectory __avsDirectory,
IRewardsCoordinator __rewardsCoordinator,
IRegistryCoordinator __registryCoordinator,
IStakeRegistry __stakeRegistry
) {
_avsDirectory = __avsDirectory;
_rewardsCoordinator = __rewardsCoordinator;
_registryCoordinator = __registryCoordinator;
_stakeRegistry = __stakeRegistry;
}
// storage gap for upgradeability
uint256[49] private __GAP;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;
/**
* @title Library for Bitmap utilities such as converting between an array of bytes and a bitmap and finding the number of 1s in a bitmap.
* @author Layr Labs, Inc.
*/
library BitmapUtils {
/**
* @notice Byte arrays are meant to contain unique bytes.
* If the array length exceeds 256, then it's impossible for all entries to be unique.
* This constant captures the max allowed array length (inclusive, i.e. 256 is allowed).
*/
uint256 internal constant MAX_BYTE_ARRAY_LENGTH = 256;
/**
* @notice Converts an ordered array of bytes into a bitmap.
* @param orderedBytesArray The array of bytes to convert/compress into a bitmap. Must be in strictly ascending order.
* @return The resulting bitmap.
* @dev Each byte in the input is processed as indicating a single bit to flip in the bitmap.
* @dev This function will eventually revert in the event that the `orderedBytesArray` is not properly ordered (in ascending order).
* @dev This function will also revert if the `orderedBytesArray` input contains any duplicate entries (i.e. duplicate bytes).
*/
function orderedBytesArrayToBitmap(bytes memory orderedBytesArray) internal pure returns (uint256) {
// sanity-check on input. a too-long input would fail later on due to having duplicate entry(s)
require(orderedBytesArray.length <= MAX_BYTE_ARRAY_LENGTH,
"BitmapUtils.orderedBytesArrayToBitmap: orderedBytesArray is too long");
// return empty bitmap early if length of array is 0
if (orderedBytesArray.length == 0) {
return uint256(0);
}
// initialize the empty bitmap, to be built inside the loop
uint256 bitmap;
// initialize an empty uint256 to be used as a bitmask inside the loop
uint256 bitMask;
// perform the 0-th loop iteration with the ordering check *omitted* (since it is unnecessary / will always pass)
// construct a single-bit mask from the numerical value of the 0th byte of the array, and immediately add it to the bitmap
bitmap = uint256(1 << uint8(orderedBytesArray[0]));
// loop through each byte in the array to construct the bitmap
for (uint256 i = 1; i < orderedBytesArray.length; ++i) {
// construct a single-bit mask from the numerical value of the next byte of the array
bitMask = uint256(1 << uint8(orderedBytesArray[i]));
// check strictly ascending array ordering by comparing the mask to the bitmap so far (revert if mask isn't greater than bitmap)
require(bitMask > bitmap, "BitmapUtils.orderedBytesArrayToBitmap: orderedBytesArray is not ordered");
// add the entry to the bitmap
bitmap = (bitmap | bitMask);
}
return bitmap;
}
/**
* @notice Converts an ordered byte array to a bitmap, validating that all bits are less than `bitUpperBound`
* @param orderedBytesArray The array to convert to a bitmap; must be in strictly ascending order
* @param bitUpperBound The exclusive largest bit. Each bit must be strictly less than this value.
* @dev Reverts if bitmap contains a bit greater than or equal to `bitUpperBound`
*/
function orderedBytesArrayToBitmap(bytes memory orderedBytesArray, uint8 bitUpperBound) internal pure returns (uint256) {
uint256 bitmap = orderedBytesArrayToBitmap(orderedBytesArray);
require((1 << bitUpperBound) > bitmap,
"BitmapUtils.orderedBytesArrayToBitmap: bitmap exceeds max value"
);
return bitmap;
}
/**
* @notice Utility function for checking if a bytes array is strictly ordered, in ascending order.
* @param bytesArray the bytes array of interest
* @return Returns 'true' if the array is ordered in strictly ascending order, and 'false' otherwise.
* @dev This function returns 'true' for the edge case of the `bytesArray` having zero length.
* It also returns 'false' early for arrays with length in excess of MAX_BYTE_ARRAY_LENGTH (i.e. so long that they cannot be strictly ordered)
*/
function isArrayStrictlyAscendingOrdered(bytes calldata bytesArray) internal pure returns (bool) {
// Return early if the array is too long, or has a length of 0
if (bytesArray.length > MAX_BYTE_ARRAY_LENGTH) {
return false;
}
if (bytesArray.length == 0) {
return true;
}
// Perform the 0-th loop iteration by pulling the 0th byte out of the array
bytes1 singleByte = bytesArray[0];
// For each byte, validate that each entry is *strictly greater than* the previous
// If it isn't, return false as the array is not ordered
for (uint256 i = 1; i < bytesArray.length; ++i) {
if (uint256(uint8(bytesArray[i])) <= uint256(uint8(singleByte))) {
return false;
}
// Pull the next byte out of the array
singleByte = bytesArray[i];
}
return true;
}
/**
* @notice Converts a bitmap into an array of bytes.
* @param bitmap The bitmap to decompress/convert to an array of bytes.
* @return bytesArray The resulting bitmap array of bytes.
* @dev Each byte in the input is processed as indicating a single bit to flip in the bitmap
*/
function bitmapToBytesArray(uint256 bitmap) internal pure returns (bytes memory /*bytesArray*/) {
// initialize an empty uint256 to be used as a bitmask inside the loop
uint256 bitMask;
// allocate only the needed amount of memory
bytes memory bytesArray = new bytes(countNumOnes(bitmap));
// track the array index to assign to
uint256 arrayIndex = 0;
/**
* loop through each index in the bitmap to construct the array,
* but short-circuit the loop if we reach the number of ones and thus are done
* assigning to memory
*/
for (uint256 i = 0; (arrayIndex < bytesArray.length) && (i < 256); ++i) {
// construct a single-bit mask for the i-th bit
bitMask = uint256(1 << i);
// check if the i-th bit is flipped in the bitmap
if (bitmap & bitMask != 0) {
// if the i-th bit is flipped, then add a byte encoding the value 'i' to the `bytesArray`
bytesArray[arrayIndex] = bytes1(uint8(i));
// increment the bytesArray slot since we've assigned one more byte of memory
unchecked{ ++arrayIndex; }
}
}
return bytesArray;
}
/// @return count number of ones in binary representation of `n`
function countNumOnes(uint256 n) internal pure returns (uint16) {
uint16 count = 0;
while (n > 0) {
n &= (n - 1); // Clear the least significant bit (turn off the rightmost set bit).
count++; // Increment the count for each cleared bit (each one encountered).
}
return count; // Return the total count of ones in the binary representation of n.
}
/// @notice Returns `true` if `bit` is in `bitmap`. Returns `false` otherwise.
function isSet(uint256 bitmap, uint8 bit) internal pure returns (bool) {
return 1 == ((bitmap >> bit) & 1);
}
/**
* @notice Returns a copy of `bitmap` with `bit` set.
* @dev IMPORTANT: we're dealing with stack values here, so this doesn't modify
* the original bitmap. Using this correctly requires an assignment statement:
* `bitmap = bitmap.setBit(bit);`
*/
function setBit(uint256 bitmap, uint8 bit) internal pure returns (uint256) {
return bitmap | (1 << bit);
}
/**
* @notice Returns true if `bitmap` has no set bits
*/
function isEmpty(uint256 bitmap) internal pure returns (bool) {
return bitmap == 0;
}
/**
* @notice Returns true if `a` and `b` have no common set bits
*/
function noBitsInCommon(uint256 a, uint256 b) internal pure returns (bool) {
return a & b == 0;
}
/**
* @notice Returns true if `a` is a subset of `b`: ALL of the bits in `a` are also in `b`
*/
function isSubsetOf(uint256 a, uint256 b) internal pure returns (bool) {
return a & b == a;
}
/**
* @notice Returns a new bitmap that contains all bits set in either `a` or `b`
* @dev Result is the union of `a` and `b`
*/
function plus(uint256 a, uint256 b) internal pure returns (uint256) {
return a | b;
}
/**
* @notice Returns a new bitmap that clears all set bits of `b` from `a`
* @dev Negates `b` and returns the intersection of the result with `a`
*/
function minus(uint256 a, uint256 b) internal pure returns (uint256) {
return a & ~b;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
import {IBLSSignatureChecker} from "./interfaces/IBLSSignatureChecker.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol";
import {IStakeRegistry, IDelegationManager} from "./interfaces/IStakeRegistry.sol";
import {BitmapUtils} from "./libraries/BitmapUtils.sol";
import {BN254} from "./libraries/BN254.sol";
/**
* @title Used for checking BLS aggregate signatures from the operators of a `BLSRegistry`.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice This is the contract for checking the validity of aggregate operator signatures.
*/
contract BLSSignatureChecker is IBLSSignatureChecker {
using BN254 for BN254.G1Point;
// CONSTANTS & IMMUTABLES
// gas cost of multiplying 2 pairings
uint256 internal constant PAIRING_EQUALITY_CHECK_GAS = 120_000;
IRegistryCoordinator public immutable registryCoordinator;
IStakeRegistry public immutable stakeRegistry;
IBLSApkRegistry public immutable blsApkRegistry;
IDelegationManager public immutable delegation;
/// @notice If true, check the staleness of the operator stakes and that its within the delegation withdrawalDelayBlocks window.
bool public staleStakesForbidden;
modifier onlyCoordinatorOwner() {
require(
msg.sender == registryCoordinator.owner(),
"BLSSignatureChecker.onlyCoordinatorOwner: caller is not the owner of the registryCoordinator"
);
_;
}
constructor(IRegistryCoordinator _registryCoordinator) {
registryCoordinator = _registryCoordinator;
stakeRegistry = _registryCoordinator.stakeRegistry();
blsApkRegistry = _registryCoordinator.blsApkRegistry();
delegation = stakeRegistry.delegation();
}
/**
* /**
* RegistryCoordinator owner can either enforce or not that operator stakes are staler
* than the delegation.minWithdrawalDelayBlocks() window.
* @param value to toggle staleStakesForbidden
*/
function setStaleStakesForbidden(bool value) external onlyCoordinatorOwner {
_setStaleStakesForbidden(value);
}
struct NonSignerInfo {
uint256[] quorumBitmaps;
bytes32[] pubkeyHashes;
}
/**
* @notice This function is called by disperser when it has aggregated all the signatures of the operators
* that are part of the quorum for a particular taskNumber and is asserting them into onchain. The function
* checks that the claim for aggregated signatures are valid.
*
* The thesis of this procedure entails:
* - getting the aggregated pubkey of all registered nodes at the time of pre-commit by the
* disperser (represented by apk in the parameters),
* - subtracting the pubkeys of all the signers not in the quorum (nonSignerPubkeys) and storing
* the output in apk to get aggregated pubkey of all operators that are part of quorum.
* - use this aggregated pubkey to verify the aggregated signature under BLS scheme.
*
* @dev Before signature verification, the function verifies operator stake information. This includes ensuring that the provided `referenceBlockNumber`
* is correct, i.e., ensure that the stake returned from the specified block number is recent enough and that the stake is either the most recent update
* for the total stake (of the operator) or latest before the referenceBlockNumber.
* @param msgHash is the hash being signed
* @dev NOTE: Be careful to ensure `msgHash` is collision-resistant! This method does not hash
* `msgHash` in any way, so if an attacker is able to pass in an arbitrary value, they may be able
* to tamper with signature verification.
* @param quorumNumbers is the bytes array of quorum numbers that are being signed for
* @param referenceBlockNumber is the block number at which the stake information is being verified
* @param params is the struct containing information on nonsigners, stakes, quorum apks, and the aggregate signature
* @return quorumStakeTotals is the struct containing the total and signed stake for each quorum
* @return signatoryRecordHash is the hash of the signatory record, which is used for fraud proofs
*/
function checkSignatures(
bytes32 msgHash,
bytes calldata quorumNumbers,
uint32 referenceBlockNumber,
NonSignerStakesAndSignature memory params
) public view returns (QuorumStakeTotals memory, bytes32) {
require(
quorumNumbers.length != 0,
"BLSSignatureChecker.checkSignatures: empty quorum input"
);
require(
(quorumNumbers.length == params.quorumApks.length) &&
(quorumNumbers.length == params.quorumApkIndices.length) &&
(quorumNumbers.length == params.totalStakeIndices.length) &&
(quorumNumbers.length == params.nonSignerStakeIndices.length),
"BLSSignatureChecker.checkSignatures: input quorum length mismatch"
);
require(
params.nonSignerPubkeys.length ==
params.nonSignerQuorumBitmapIndices.length,
"BLSSignatureChecker.checkSignatures: input nonsigner length mismatch"
);
require(
referenceBlockNumber < uint32(block.number),
"BLSSignatureChecker.checkSignatures: invalid reference block"
);
// This method needs to calculate the aggregate pubkey for all signing operators across
// all signing quorums. To do that, we can query the aggregate pubkey for each quorum
// and subtract out the pubkey for each nonsigning operator registered to that quorum.
//
// In practice, we do this in reverse - calculating an aggregate pubkey for all nonsigners,
// negating that pubkey, then adding the aggregate pubkey for each quorum.
BN254.G1Point memory apk = BN254.G1Point(0, 0);
// For each quorum, we're also going to query the total stake for all registered operators
// at the referenceBlockNumber, and derive the stake held by signers by subtracting out
// stakes held by nonsigners.
QuorumStakeTotals memory stakeTotals;
stakeTotals.totalStakeForQuorum = new uint96[](quorumNumbers.length);
stakeTotals.signedStakeForQuorum = new uint96[](quorumNumbers.length);
NonSignerInfo memory nonSigners;
nonSigners.quorumBitmaps = new uint256[](
params.nonSignerPubkeys.length
);
nonSigners.pubkeyHashes = new bytes32[](params.nonSignerPubkeys.length);
{
// Get a bitmap of the quorums signing the message, and validate that
// quorumNumbers contains only unique, valid quorum numbers
uint256 signingQuorumBitmap = BitmapUtils.orderedBytesArrayToBitmap(
quorumNumbers,
registryCoordinator.quorumCount()
);
for (uint256 j = 0; j < params.nonSignerPubkeys.length; j++) {
// The nonsigner's pubkey hash doubles as their operatorId
// The check below validates that these operatorIds are sorted (and therefore
// free of duplicates)
nonSigners.pubkeyHashes[j] = params
.nonSignerPubkeys[j]
.hashG1Point();
if (j != 0) {
require(
uint256(nonSigners.pubkeyHashes[j]) >
uint256(nonSigners.pubkeyHashes[j - 1]),
"BLSSignatureChecker.checkSignatures: nonSignerPubkeys not sorted"
);
}
// Get the quorums the nonsigner was registered for at referenceBlockNumber
nonSigners.quorumBitmaps[j] = registryCoordinator
.getQuorumBitmapAtBlockNumberByIndex({
operatorId: nonSigners.pubkeyHashes[j],
blockNumber: referenceBlockNumber,
index: params.nonSignerQuorumBitmapIndices[j]
});
// Add the nonsigner's pubkey to the total apk, multiplied by the number
// of quorums they have in common with the signing quorums, because their
// public key will be a part of each signing quorum's aggregate pubkey
apk = apk.plus(
params.nonSignerPubkeys[j].scalar_mul_tiny(
BitmapUtils.countNumOnes(
nonSigners.quorumBitmaps[j] & signingQuorumBitmap
)
)
);
}
}
// Negate the sum of the nonsigner aggregate pubkeys - from here, we'll add the
// total aggregate pubkey from each quorum. Because the nonsigners' pubkeys are
// in these quorums, this initial negation ensures they're cancelled out
apk = apk.negate();
/**
* For each quorum (at referenceBlockNumber):
* - add the apk for all registered operators
* - query the total stake for each quorum
* - subtract the stake for each nonsigner to calculate the stake belonging to signers
*/
{
bool _staleStakesForbidden = staleStakesForbidden;
uint256 withdrawalDelayBlocks = _staleStakesForbidden
? delegation.minWithdrawalDelayBlocks()
: 0;
for (uint256 i = 0; i < quorumNumbers.length; i++) {
// If we're disallowing stale stake updates, check that each quorum's last update block
// is within withdrawalDelayBlocks
if (_staleStakesForbidden) {
require(
registryCoordinator.quorumUpdateBlockNumber(
uint8(quorumNumbers[i])
) +
withdrawalDelayBlocks >
referenceBlockNumber,
"BLSSignatureChecker.checkSignatures: StakeRegistry updates must be within withdrawalDelayBlocks window"
);
}
// Validate params.quorumApks is correct for this quorum at the referenceBlockNumber,
// then add it to the total apk
require(
bytes24(params.quorumApks[i].hashG1Point()) ==
blsApkRegistry.getApkHashAtBlockNumberAndIndex({
quorumNumber: uint8(quorumNumbers[i]),
blockNumber: referenceBlockNumber,
index: params.quorumApkIndices[i]
}),
"BLSSignatureChecker.checkSignatures: quorumApk hash in storage does not match provided quorum apk"
);
apk = apk.plus(params.quorumApks[i]);
// Get the total and starting signed stake for the quorum at referenceBlockNumber
stakeTotals.totalStakeForQuorum[i] = stakeRegistry
.getTotalStakeAtBlockNumberFromIndex({
quorumNumber: uint8(quorumNumbers[i]),
blockNumber: referenceBlockNumber,
index: params.totalStakeIndices[i]
});
stakeTotals.signedStakeForQuorum[i] = stakeTotals
.totalStakeForQuorum[i];
// Keep track of the nonSigners index in the quorum
uint256 nonSignerForQuorumIndex = 0;
// loop through all nonSigners, checking that they are a part of the quorum via their quorumBitmap
// if so, load their stake at referenceBlockNumber and subtract it from running stake signed
for (uint256 j = 0; j < params.nonSignerPubkeys.length; j++) {
// if the nonSigner is a part of the quorum, subtract their stake from the running total
if (
BitmapUtils.isSet(
nonSigners.quorumBitmaps[j],
uint8(quorumNumbers[i])
)
) {
stakeTotals.signedStakeForQuorum[i] -= stakeRegistry
.getStakeAtBlockNumberAndIndex({
quorumNumber: uint8(quorumNumbers[i]),
blockNumber: referenceBlockNumber,
operatorId: nonSigners.pubkeyHashes[j],
index: params.nonSignerStakeIndices[i][
nonSignerForQuorumIndex
]
});
unchecked {
++nonSignerForQuorumIndex;
}
}
}
}
}
{
// verify the signature
(
bool pairingSuccessful,
bool signatureIsValid
) = trySignatureAndApkVerification(
msgHash,
apk,
params.apkG2,
params.sigma
);
require(
pairingSuccessful,
"BLSSignatureChecker.checkSignatures: pairing precompile call failed"
);
require(
signatureIsValid,
"BLSSignatureChecker.checkSignatures: signature is invalid"
);
}
// set signatoryRecordHash variable used for fraudproofs
bytes32 signatoryRecordHash = keccak256(
abi.encodePacked(referenceBlockNumber, nonSigners.pubkeyHashes)
);
// return the total stakes that signed for each quorum, and a hash of the information required to prove the exact signers and stake
return (stakeTotals, signatoryRecordHash);
}
/**
* trySignatureAndApkVerification verifies a BLS aggregate signature and the veracity of a calculated G1 Public key
* @param msgHash is the hash being signed
* @param apk is the claimed G1 public key
* @param apkG2 is provided G2 public key
* @param sigma is the G1 point signature
* @return pairingSuccessful is true if the pairing precompile call was successful
* @return siganatureIsValid is true if the signature is valid
*/
function trySignatureAndApkVerification(
bytes32 msgHash,
BN254.G1Point memory apk,
BN254.G2Point memory apkG2,
BN254.G1Point memory sigma
) public view returns (bool pairingSuccessful, bool siganatureIsValid) {
// gamma = keccak256(abi.encodePacked(msgHash, apk, apkG2, sigma))
uint256 gamma = uint256(
keccak256(
abi.encodePacked(
msgHash,
apk.X,
apk.Y,
apkG2.X[0],
apkG2.X[1],
apkG2.Y[0],
apkG2.Y[1],
sigma.X,
sigma.Y
)
)
) % BN254.FR_MODULUS;
// verify the signature
(pairingSuccessful, siganatureIsValid) = BN254.safePairing(
sigma.plus(apk.scalar_mul(gamma)),
BN254.negGeneratorG2(),
BN254.hashToG1(msgHash).plus(BN254.generatorG1().scalar_mul(gamma)),
apkG2,
PAIRING_EQUALITY_CHECK_GAS
);
}
function _setStaleStakesForbidden(bool value) internal {
staleStakesForbidden = value;
emit StaleStakesForbiddenUpdate(value);
}
// storage gap for upgradeability
// slither-disable-next-line shadowing-state
uint256[49] private __GAP;
}// SPDX-License-Identifier: UNLICENSED
// SEE LICENSE IN https://files.altlayer.io/Alt-Research-License-1.md
// Copyright Alt Research Ltd. 2023. All rights reserved.
//
// You acknowledge and agree that Alt Research Ltd. ("Alt Research") (or Alt
// Research's licensors) own all legal rights, titles and interests in and to the
// work, software, application, source code, documentation and any other documents
pragma solidity ^0.8.12;
import {IRiscZeroVerifier} from "./IRiscZeroVerifier.sol";
import {CallbackAuthorization} from "./IBonsaiRelay.sol";
/// @title IMachOptimism
/// @notice The Interface for a Mach optimism contract.
interface IMachOptimism {
event AlertBlockMismatch(bytes32 invalidOutputRoot, bytes32 expectOutputRoot, uint256 indexed l2BlockNumber);
event AlertBlockOutputOracleMismatch(
uint256 indexed invalidOutputIndex,
bytes32 invalidOutputRoot,
bytes32 expectOutputRoot,
uint256 indexed l2BlockNumber
);
event SubmittedBlockProve(uint256 indexed invalidOutputIndex, bytes32 OutputRoot, uint256 indexed l2BlockNumber);
event AlertDelete(
uint256 indexed invalidOutputIndex,
bytes32 expectOutputRoot,
bytes32 OutputRoot,
uint256 indexed l2BlockNumber,
address indexed submitter
);
event AlertReset(
uint256 indexed invalidOutputIndex,
bytes32 invalidOutputRoot,
bytes32 expectOutputRoot,
uint256 indexed l2BlockNumber,
address fromSubmitter,
address indexed toSubmitter
);
/**
* @notice Emitted when an operator is added to the MachServiceManagerAVS.
* @param operator The address of the operator
*/
event OperatorAdded(address indexed operator);
/**
* @notice Emitted when an operator is removed from the MachServiceManagerAVS.
* @param operator The address of the operator
*/
event OperatorRemoved(address indexed operator);
/**
* @notice Emitted when an operator is added to the allowlist.
* @param operator The operator
*/
event OperatorAllowed(address operator);
/**
* @notice Emitted when an operator is removed from the allowlist.
* @param operator The operator
*/
event OperatorDisallowed(address operator);
/**
* @notice Emitted when the allowlist is enabled.
*/
event AllowlistEnabled();
/**
* @notice Emitted when the allowlist is disabled.
*/
event AllowlistDisabled();
struct L2OutputAlert {
uint256 l2BlockNumber;
uint256 invalidOutputIndex;
bytes32 invalidOutputRoot;
bytes32 expectOutputRoot;
address submitter;
}
/// Returns the datas for alert by its index.
function getAlert(uint256 index) external view returns (L2OutputAlert memory);
/// @notice Return the latest alert 's block number, if not exist, just return 0.
/// TODO: we can add more view functions to get details info about alert.
/// This function just used for verifier check if need commit more
/// alerts to contract.
function latestAlertBlockNumber() external view returns (uint256);
/// @notice Return the latest no proved alert 's block number, if not exist, just return 0.
function latestUnprovedBlockNumber() external view returns (uint256);
/// @notice Submit alert for verifier found a op block output mismatch.
/// It just a warning without any prove, the prover verifier should
/// submit a prove to ensure the alert is valid.
/// This alert can for the blocks which had not proposal its output
/// root to layer1, this block may not the checkpoint.
/// @param invalidOutputRoot the invalid output root verifier got from op-devnet.
/// @param expectOutputRoot the output root calc by verifier.
/// @param l2BlockNumber the layer2 block 's number.
function alertBlockMismatch(bytes32 invalidOutputRoot, bytes32 expectOutputRoot, uint256 l2BlockNumber) external;
/// @notice Submit alert for verifier found a op block output root mismatch.
/// It just a warning without any prove, the prover verifier should
/// submit a prove to ensure the alert is valid.
/// This alert only for the proposed output root by proposer,
/// so we just submit the index for this output root.
/// @param invalidOutputIndex the invalid output root index.
/// @param expectOutputRoot the output root calc by verifier.
function alertBlockOutputOracleMismatch(uint256 invalidOutputIndex, bytes32 expectOutputRoot) external;
/// @notice Submit a bonsai prove receipt to mach contract.
function submitProve(
bytes32 imageId_,
bytes calldata journal,
bytes calldata seal,
bytes32 postStateDigest,
uint256 perL2OutputIndex
) external;
}// 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: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// 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 Address {
/**
* @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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(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: 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;
}// Copyright 2024 RISC Zero, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.12;
/// @notice Public claims about a zkVM guest execution, such as the journal committed to by the guest.
/// @dev Also includes important information such as the exit code and the starting and ending system
/// state (i.e. the state of memory). `ReceiptClaim` is a "Merkle-ized struct" supporting
/// partial openings of the underlying fields from a hash commitment to the full structure.
struct ReceiptClaim {
/// @notice Digest of the SystemState just before execution has begun.
bytes32 preStateDigest;
/// @notice Digest of the SystemState just after execution has completed.
bytes32 postStateDigest;
/// @notice The exit code for the execution.
ExitCode exitCode;
/// @notice A digest of the input to the guest.
/// @dev This field is currently unused and must be set to the zero digest.
bytes32 input;
/// @notice Digest of the Output of the guest, including the journal
/// and assumptions set during execution.
bytes32 output;
}
library ReceiptClaimLib {
bytes32 constant TAG_DIGEST = sha256("risc0.ReceiptClaim");
function digest(ReceiptClaim memory claim) internal pure returns (bytes32) {
return sha256(
abi.encodePacked(
TAG_DIGEST,
// down
claim.input,
claim.preStateDigest,
claim.postStateDigest,
claim.output,
// data
uint32(claim.exitCode.system) << 24,
uint32(claim.exitCode.user) << 24,
// down.length
uint16(4) << 8
)
);
}
}
/// @notice Exit condition indicated by the zkVM at the end of the guest execution.
/// @dev Exit codes have a "system" part and a "user" part. Semantically, the system part is set to
/// indicate the type of exit (e.g. halt, pause, or system split) and is directly controlled by the
/// zkVM. The user part is an exit code, similar to exit codes used in Linux, chosen by the guest
/// program to indicate additional information (e.g. 0 to indicate success or 1 to indicate an
/// error).
struct ExitCode {
SystemExitCode system;
uint8 user;
}
/// @notice Exit condition indicated by the zkVM at the end of the execution covered by this proof.
/// @dev
/// `Halted` indicates normal termination of a program with an interior exit code returned from the
/// guest program. A halted program cannot be resumed.
///
/// `Paused` indicates the execution ended in a paused state with an interior exit code set by the
/// guest program. A paused program can be resumed such that execution picks up where it left
/// of, with the same memory state.
///
/// `SystemSplit` indicates the execution ended on a host-initiated system split. System split is
/// mechanism by which the host can temporarily stop execution of the execution ended in a system
/// split has no output and no conclusions can be drawn about whether the program will eventually
/// halt. System split is used in continuations to split execution into individually provable segments.
enum SystemExitCode {
Halted,
Paused,
SystemSplit
}
/// @notice Output field in the `ReceiptClaim`, committing to a claimed journal and assumptions list.
struct Output {
/// @notice Digest of the journal committed to by the guest execution.
bytes32 journalDigest;
/// @notice Digest of the ordered list of `ReceiptClaim` digests corresponding to the
/// calls to `env::verify` and `env::verify_integrity`.
/// @dev Verifying the integrity of a `Receipt` corresponding to a `ReceiptClaim` with a
/// non-empty assumptions list does not guarantee unconditionally any of the claims over the
/// guest execution (i.e. if the assumptions list is non-empty, then the journal digest cannot
/// be trusted to correspond to a genuine execution). The claims can be checked by additional
/// verifying a `Receipt` for every digest in the assumptions list.
bytes32 assumptionsDigest;
}
library OutputLib {
bytes32 constant TAG_DIGEST = sha256("risc0.Output");
function digest(Output memory output) internal pure returns (bytes32) {
return sha256(
abi.encodePacked(
TAG_DIGEST,
// down
output.journalDigest,
output.assumptionsDigest,
// down.length
uint16(2) << 8
)
);
}
}
/// @notice A receipt attesting to the execution of a guest program.
/// @dev A receipt contains two parts: a seal and a claim. The seal is a zero-knowledge proof
/// attesting to knowledge of a zkVM execution resulting the claim. The claim is a set of public
/// outputs for the execution. Crucially, the claim includes the journal and the image ID. The
/// image ID identifies the program that was executed, and the journal is the public data written
/// by the program.
struct Receipt {
bytes seal;
ReceiptClaim claim;
}
/// @notice Verifier interface for RISC Zero receipts of execution.
interface IRiscZeroVerifier {
/// @notice Verify that the given seal is a valid RISC Zero proof of execution with the
/// given image ID, post-state digest, and journal digest.
/// @dev This method additionally ensures that the input hash is all-zeros (i.e. no
/// committed input), the exit code is (Halted, 0), and there are no assumptions (i.e. the
/// receipt is unconditional).
/// @param seal The encoded cryptographic proof (i.e. SNARK).
/// @param imageId The identifier for the guest program.
/// @param postStateDigest A hash of the final memory state. Required to run the verifier, but
/// otherwise can be left unconstrained for most use cases.
/// @param journalDigest The SHA-256 digest of the journal bytes.
/// @return true if the receipt passes the verification checks. The return code must be checked.
function verify(bytes calldata seal, bytes32 imageId, bytes32 postStateDigest, bytes32 journalDigest)
external
view
returns (bool);
/// @notice Verify that the given receipt is a valid RISC Zero receipt, ensuring the `seal` is
/// valid a cryptographic proof of the execution with the given `claim`.
/// @param receipt The receipt to be verified.
/// @return true if the receipt passes the verification checks. The return code must be checked.
function verify_integrity(Receipt calldata receipt) external view returns (bool);
}// Copyright 2023 RISC Zero, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.12;
/// @notice Data required to authorize a callback to be sent through the relay.
struct CallbackAuthorization {
/// @notice SNARK proof acting as the cryptographic seal over the execution results.
bytes seal;
/// @notice Digest of the zkVM SystemState after execution.
/// @dev The relay does not additionally check any property of this digest, but needs the
/// digest in order to reconstruct the ReceiptMetadata hash to which the proof is linked.
bytes32 postStateDigest;
}
/// @notice Callback data, provided by the Relay service.
struct Callback {
CallbackAuthorization auth;
/// @notice address of the contract to receive the callback.
address callbackContract;
/// @notice payload containing the callback function selector, journal bytes, and image ID.
/// @dev payload is destructured and checked against the authorization data to ensure that
/// the journal is a valid execution result of the zkVM guest defined by the image ID.
/// The payload is then used directly as the calldata for the callback.
bytes payload;
/// @notice maximum amount of gas the callback function may use.
uint64 gasLimit;
}
/// @notice The interface for the Bonsai relay contract
interface IBonsaiRelay {
/// @notice Event emitted upon receiving a callback request through requestCallback.
event CallbackRequest(
address account,
bytes32 imageId,
bytes input,
address callbackContract,
bytes4 functionSelector,
uint64 gasLimit
);
/// @notice Submit request to receive a callback.
/// @dev This function will usually be called be the Bonsai user's application contract, and
/// will log an event that the Bonsai Relay will detect and respond to.
function requestCallback(
bytes32 imageId,
bytes calldata input,
address callbackContract,
bytes4 functionSelector,
uint64 gasLimit
) external;
/// @notice Determines if the given authorization is valid for the image ID and journal.
/// @dev A (imageId, journal) pair should be valid, and the respective callback authorized, if
/// and only if the journal is the result of the correct execution of the zkVM guest.
function callbackIsAuthorized(bytes32 imageId, bytes calldata journal, CallbackAuthorization calldata auth)
external
view
returns (bool);
/// @notice Submit a batch of callbacks, authorized by an attached SNARK proof.
/// @dev This function is usually called by the Bonsai Relay. Note that this function does not
/// revert when one of the inner callbacks reverts.
/// @return invocationResults a list of booleans indicated if the calldata succeeded or failed.
function invokeCallbacks(Callback[] calldata callbacks) external returns (bool[] memory invocationResults);
/// @notice Submit a single callback, authorized by an attached SNARK proof.
/// @dev This function is usually called by the Bonsai Relay. This function reverts if the callback fails.
function invokeCallback(Callback calldata callback) 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;
}{
"remappings": [
"forge-std/=lib/forge-std/src/",
"eigenlayer-middleware/=lib/eigenlayer-middleware/src/",
"eigenlayer-core/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/src/",
"eigenlayer-middleware-test/=lib/eigenlayer-middleware/test/",
"@openzeppelin-upgrades-v4.9.0/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable-v4.9.0/",
"@openzeppelin-upgrades/=lib/eigenlayer-middleware/lib/openzeppelin-contracts-upgradeable/",
"@openzeppelin-v4.9.0/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/lib/openzeppelin-contracts-v4.9.0/",
"@openzeppelin/=lib/eigenlayer-middleware/lib/openzeppelin-contracts/",
"ds-test/=lib/eigenlayer-middleware/lib/ds-test/src/",
"eigenlayer-contracts/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/",
"erc4626-tests/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable-v4.9.0/lib/erc4626-tests/",
"openzeppelin-contracts-upgradeable-v4.9.0/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable-v4.9.0/",
"openzeppelin-contracts-upgradeable/=lib/eigenlayer-middleware/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts-v4.9.0/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/lib/openzeppelin-contracts-v4.9.0/",
"openzeppelin-contracts/=lib/eigenlayer-middleware/lib/openzeppelin-contracts/",
"openzeppelin/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable-v4.9.0/contracts/",
"zeus-templates/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/lib/zeus-templates/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IAVSDirectory","name":"__avsDirectory","type":"address"},{"internalType":"contract IRewardsCoordinator","name":"__rewardsCoordinator","type":"address"},{"internalType":"contract IRegistryCoordinator","name":"__registryCoordinator","type":"address"},{"internalType":"contract IStakeRegistry","name":"__stakeRegistry","type":"address"},{"internalType":"contract IBLSSignatureChecker","name":"__signatureChecker","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyAdded","type":"error"},{"inputs":[],"name":"AlreadyDisabled","type":"error"},{"inputs":[],"name":"AlreadyEnabled","type":"error"},{"inputs":[],"name":"InsufficientThreshold","type":"error"},{"inputs":[],"name":"InsufficientThresholdPercentages","type":"error"},{"inputs":[],"name":"InvalidConfirmer","type":"error"},{"inputs":[],"name":"InvalidQuorumParam","type":"error"},{"inputs":[],"name":"InvalidQuorumThresholdPercentage","type":"error"},{"inputs":[],"name":"InvalidReferenceBlockNum","type":"error"},{"inputs":[],"name":"InvalidRollupChainID","type":"error"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidStartIndex","type":"error"},{"inputs":[],"name":"NoStatusChange","type":"error"},{"inputs":[],"name":"NotAdded","type":"error"},{"inputs":[],"name":"NotWhitelister","type":"error"},{"inputs":[],"name":"ResolvedAlert","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"alertHeaderHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"AlertConfirmed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"AlertConfirmerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"messageHash","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"AlertRemoved","type":"event"},{"anonymous":false,"inputs":[],"name":"AllowlistDisabled","type":"event"},{"anonymous":false,"inputs":[],"name":"AllowlistEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"operators","type":"address[]"},{"indexed":false,"internalType":"bool[]","name":"status","type":"bool[]"}],"name":"AllowlistUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorAllowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorDisallowed","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":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IPauserRegistry","name":"pauserRegistry","type":"address"},{"indexed":false,"internalType":"contract IPauserRegistry","name":"newPauserRegistry","type":"address"}],"name":"PauserRegistrySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"thresholdPercentages","type":"uint8"}],"name":"QuorumThresholdPercentageChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"prevRewardsInitiator","type":"address"},{"indexed":false,"internalType":"address","name":"newRewardsInitiator","type":"address"}],"name":"RewardsInitiatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rollupChainId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"RollupChainIDUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"WhitelisterChanged","type":"event"},{"inputs":[],"name":"THRESHOLD_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"alertConfirmer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowlistEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"avsDirectory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"messageHash","type":"bytes32"},{"internalType":"bytes","name":"quorumNumbers","type":"bytes"},{"internalType":"bytes","name":"quorumThresholdPercentages","type":"bytes"},{"internalType":"uint32","name":"referenceBlockNumber","type":"uint32"},{"internalType":"uint256","name":"rollupChainID","type":"uint256"}],"internalType":"struct IMachServiceManager.AlertHeader","name":"alertHeader","type":"tuple"},{"components":[{"internalType":"uint32[]","name":"nonSignerQuorumBitmapIndices","type":"uint32[]"},{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct BN254.G1Point[]","name":"nonSignerPubkeys","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct BN254.G1Point[]","name":"quorumApks","type":"tuple[]"},{"components":[{"internalType":"uint256[2]","name":"X","type":"uint256[2]"},{"internalType":"uint256[2]","name":"Y","type":"uint256[2]"}],"internalType":"struct BN254.G2Point","name":"apkG2","type":"tuple"},{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct BN254.G1Point","name":"sigma","type":"tuple"},{"internalType":"uint32[]","name":"quorumApkIndices","type":"uint32[]"},{"internalType":"uint32[]","name":"totalStakeIndices","type":"uint32[]"},{"internalType":"uint32[][]","name":"nonSignerStakeIndices","type":"uint32[][]"}],"internalType":"struct IBLSSignatureChecker.NonSignerStakesAndSignature","name":"nonSignerStakesAndSignature","type":"tuple"}],"name":"confirmAlert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rollupChainId","type":"uint256"},{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"contains","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"uint96","name":"multiplier","type":"uint96"}],"internalType":"struct IRewardsCoordinator.StrategyAndMultiplier[]","name":"strategiesAndMultipliers","type":"tuple[]"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint32","name":"startTimestamp","type":"uint32"},{"internalType":"uint32","name":"duration","type":"uint32"}],"internalType":"struct IRewardsCoordinator.RewardsSubmission[]","name":"rewardsSubmissions","type":"tuple[]"}],"name":"createAVSRewardsSubmission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"uint96","name":"multiplier","type":"uint96"}],"internalType":"struct IRewardsCoordinator.StrategyAndMultiplier[]","name":"strategiesAndMultipliers","type":"tuple[]"},{"internalType":"contract IERC20","name":"token","type":"address"},{"components":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct IRewardsCoordinator.OperatorReward[]","name":"operatorRewards","type":"tuple[]"},{"internalType":"uint32","name":"startTimestamp","type":"uint32"},{"internalType":"uint32","name":"duration","type":"uint32"},{"internalType":"string","name":"description","type":"string"}],"internalType":"struct IRewardsCoordinator.OperatorDirectedRewardsSubmission[]","name":"operatorDirectedRewardsSubmissions","type":"tuple[]"}],"name":"createOperatorDirectedAVSRewardsSubmission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"deregisterOperatorFromAVS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableAllowlist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableAllowlist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getAllowlistAtIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllowlistSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"contract IPauserRegistry","name":"pauserRegistry_","type":"address"},{"internalType":"uint256","name":"initialPausedStatus_","type":"uint256"},{"internalType":"address","name":"initialOwner_","type":"address"},{"internalType":"address","name":"rewardsInitiator_","type":"address"},{"internalType":"address","name":"alertConfirmer_","type":"address"},{"internalType":"address","name":"whitelister_","type":"address"},{"internalType":"uint256[]","name":"rollupChainIDs_","type":"uint256[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"isOperatorAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauserRegistry","outputs":[{"internalType":"contract IPauserRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rollupChainId","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"querySize","type":"uint256"}],"name":"queryMessageHashes","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quorumThresholdPercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","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":"uint256","name":"rollupChainId","type":"uint256"},{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"removeAlert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardsInitiator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rollupChainIDs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"operators","type":"address[]"},{"internalType":"bool[]","name":"status","type":"bool[]"}],"name":"setAllowlist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"claimer","type":"address"}],"name":"setClaimerFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"confirmer","type":"address"}],"name":"setConfirmer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPauserRegistry","name":"newPauserRegistry","type":"address"}],"name":"setPauserRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRewardsInitiator","type":"address"}],"name":"setRewardsInitiator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rollupChainId","type":"uint256"},{"internalType":"bool","name":"status","type":"bool"}],"name":"setRollupChainID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"whitelister","type":"address"}],"name":"setWhitelister","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signatureChecker","outputs":[{"internalType":"contract IBLSSignatureChecker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rollupChainId","type":"uint256"}],"name":"totalAlerts","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":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_metadataURI","type":"string"}],"name":"updateAVSMetadataURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"thresholdPercentage","type":"uint8"}],"name":"updateQuorumThresholdPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"whitelister","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6101206040523480156200001257600080fd5b50604051620047c5380380620047c5833981016040819052620000359162000164565b6001600160a01b0380861660805280851660a05280841660c052821660e052848484846200006262000089565b5050506001600160a01b03821661010052506200007e62000089565b5050505050620001e4565b603554610100900460ff1615620000f65760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60355460ff908116101562000149576035805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6001600160a01b03811681146200016157600080fd5b50565b600080600080600060a086880312156200017d57600080fd5b85516200018a816200014b565b60208701519095506200019d816200014b565b6040870151909450620001b0816200014b565b6060870151909350620001c3816200014b565b6080870151909250620001d6816200014b565b809150509295509295909350565b60805160a05160c05160e05161010051614517620002ae6000396000818161058d0152610785015260008181610f66015281816110c10152818161115801528181611cd701528181611e5a0152611ef9015260008181610d9101528181610e2001528181610ea00152818161158c01528181611a1a01528181611c150152611db50152600081816117bb01528181611928015281816119b6015281816122d1015261236401526000818161040b0152818161161d01528181611a760152611ac401526145176000f3fe608060405234801561001057600080fd5b50600436106102745760003560e01c806394c8e4ff11610151578063d1907419116100c3578063efb2bfd311610087578063efb2bfd314610588578063f2fde38b146105af578063f98f5b92146105c2578063fabc1cbc146105d5578063fc299dee146105e8578063fce36c7d146105fb57600080fd5b8063d19074191461053f578063e0e387ab14610552578063e481af9d14610565578063edaa410e1461056d578063ef0244581461058057600080fd5b8063a20b99bf11610115578063a20b99bf146104e3578063a364f4da146104f6578063a98fb35514610509578063b733cc771461051c578063c6a2aac81461052f578063cf8e629a1461053757600080fd5b806394c8e4ff146104815780639925378f146104955780639926ee7d1461049d5780639d81ceba146104b0578063a0169ddd146104d057600080fd5b80634c6b05d9116101ea5780636b3aa72e116101ae5780636b3aa72e14610409578063715018a61461042f57806372faa8df1461043757806375ccc1321461044a578063886f11951461045d5780638da5cb5b1461047057600080fd5b80634c6b05d9146103765780634deabc21146103a9578063595c6a67146103cf5780635ac86ab7146103d75780635c975abb146103f757600080fd5b80632f640a091161023c5780632f640a09146102f757806333cfb7b71461030a57806339bc68e71461032a5780633bc28c8c1461033d5780633deebb6914610350578063429d5bf01461036357600080fd5b80630898f07f146102795780630d1bc8931461028e57806310d67a2f146102a1578063136439dd146102b457806322758a4a146102c7575b600080fd5b61028c610287366004613315565b61060e565b005b61028c61029c3660046134ec565b6109de565b61028c6102af366004613595565b610b69565b61028c6102c23660046135b2565b610c1c565b6008546102da906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61028c610305366004613595565b610d5b565b61031d610318366004613595565b610d6c565b6040516102ee91906135cb565b6005546102da906001600160a01b031681565b61028c61034b366004613595565b61123b565b61028c61035e366004613626565b61124c565b61028c610371366004613665565b611262565b6103996103843660046135b2565b60006020819052908152604090205460ff1681565b60405190151581526020016102ee565b6005546103bd90600160a81b900460ff1681565b60405160ff90911681526020016102ee565b61028c6112e3565b6103996103e5366004613665565b60ff80546001919092161b9081161490565b60ff545b6040519081526020016102ee565b7f00000000000000000000000000000000000000000000000000000000000000006102da565b61028c6113aa565b61028c610445366004613682565b6113be565b610399610458366004613595565b61153d565b60fe546102da906001600160a01b031681565b6068546001600160a01b03166102da565b60055461039990600160a01b900460ff1681565b6103fb611550565b61028c6104ab366004613744565b611561565b6104c36104be3660046137ee565b61168a565b6040516102ee919061381a565b61028c6104de366004613595565b611794565b61028c6104f1366004613852565b61181b565b61028c610504366004613595565b6119ef565b61028c610517366004613893565b611aa5565b6103fb61052a3660046135b2565b611af9565b61028c611b10565b61028c611b81565b6102da61054d3660046135b2565b611bea565b6103996105603660046138db565b611bf7565b61031d611c0f565b61028c61057b3660046138db565b611fd8565b6103fb606481565b6102da7f000000000000000000000000000000000000000000000000000000000000000081565b61028c6105bd366004613595565b612085565b61028c6105d0366004613595565b6120fb565b61028c6105e33660046135b2565b61210c565b609a546102da906001600160a01b031681565b61028c610609366004613852565b612268565b60ff54156106375760405162461bcd60e51b815260040161062e906138fd565b60405180910390fd5b6005546001600160a01b0316336001600160a01b03161461066b5760405163fc4a01bd60e01b815260040160405180910390fd5b608082013560008181526020819052604090205460ff1661069f5760405163daf4a8a360e01b815260040160405180910390fd5b3233146106bf57604051636edaef2f60e11b815260040160405180910390fd5b608083013560009081526006602052604090206106dd90843561239b565b156106fb5760405163939bc9df60e01b815260040160405180910390fd5b4361070c6080850160608601613934565b63ffffffff16106107305760405163c15ef5b560e01b815260040160405180910390fd5b600061073b846123b3565b905061074a604085018561394f565b9050610759602086018661394f565b9050146107795760405163c9df75a560e01b815260040160405180910390fd5b60006001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016636efb4636836107b8602089018961394f565b6107c860808b0160608c01613934565b896040518663ffffffff1660e01b81526004016107e9959493929190613ad8565b600060405180830381865afa158015610806573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261082e9190810190613c4f565b50905060005b610841604087018761394f565b9050811015610961576000610859604088018861394f565b8381811061086957610869613ceb565b919091013560f81c91505060648111156108965760405163048278b760e41b815260040160405180910390fd5b60055460ff600160a81b909104811690821610156108c75760405163bbf727c160e01b815260040160405180910390fd5b8060ff16836020015183815181106108e1576108e1613ceb565b60200260200101516108f39190613d17565b6001600160601b031660648460000151848151811061091457610914613ceb565b60200260200101516001600160601b031661092f9190613d46565b101561094e57604051633916714960e21b815260040160405180910390fd5b508061095981613d65565b915050610834565b5060808501356000908152600160205260408120610980908735612402565b9050806109a05760405163f411c32760e01b815260040160405180910390fd5b6040518635815283907ffdda6f7d4825a4f1e4e97b50a26a69a8bcc3f4fcb1113cc14ce8e7098ca636659060200160405180910390a2505050505050565b603554610100900460ff16158080156109fe5750603554600160ff909116105b80610a185750303b158015610a18575060355460ff166001145b610a7b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161062e565b6035805460ff191660011790558015610a9e576035805461ff0019166101001790555b610aa8898961240e565b610ab287876124f4565b610abb85612571565b610ac4846125d3565b60005b82811015610b0257610af2848483818110610ae457610ae4613ceb565b90506020020135600161262d565b610afb81613d65565b9050610ac7565b506005805461ffff60a01b191661420160a01b1790558015610b5e576035805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b60fe60009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be09190613d80565b6001600160a01b0316336001600160a01b031614610c105760405162461bcd60e51b815260040161062e90613d9d565b610c19816126d5565b50565b60fe5460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa158015610c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c889190613de7565b610ca45760405162461bcd60e51b815260040161062e90613e04565b60ff5481811614610d1d5760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e70617573653a20696e76616c696420617474656d70742060448201527f746f20756e70617573652066756e6374696f6e616c6974790000000000000000606482015260840161062e565b60ff81905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d906020015b60405180910390a250565b610d636127cc565b610c1981612571565b6040516309aa152760e11b81526001600160a01b0382811660048301526060916000917f000000000000000000000000000000000000000000000000000000000000000016906313542a4e90602401602060405180830381865afa158015610dd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfc9190613e4c565b60405163871ef04960e01b8152600481018290529091506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063871ef04990602401602060405180830381865afa158015610e67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8b9190613e65565b90506001600160c01b0381161580610f2557507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639aa1653d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610efc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f209190613e8e565b60ff16155b15610f4157505060408051600081526020810190915292915050565b6000610f55826001600160c01b0316612826565b90506000805b825181101561102b577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ca5a5f5848381518110610fa557610fa5613ceb565b01602001516040516001600160e01b031960e084901b16815260f89190911c6004820152602401602060405180830381865afa158015610fe9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100d9190613e4c565b6110179083613eab565b91508061102381613d65565b915050610f5b565b506000816001600160401b0381111561104657611046613011565b60405190808252806020026020018201604052801561106f578160200160208202803683370190505b5090506000805b845181101561122e57600085828151811061109357611093613ceb565b0160200151604051633ca5a5f560e01b815260f89190911c6004820181905291506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633ca5a5f590602401602060405180830381865afa158015611108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112c9190613e4c565b905060005b81811015611218576040516356e4026d60e11b815260ff84166004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063adc804da906044016040805180830381865afa1580156111a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ca9190613ec3565b600001518686815181106111e0576111e0613ceb565b6001600160a01b03909216602092830291909101909101528461120281613d65565b955050808061121090613d65565b915050611131565b505050808061122690613d65565b915050611076565b5090979650505050505050565b6112436127cc565b610c19816128e8565b6112546127cc565b61125e828261262d565b5050565b61126a6127cc565b60648160ff16111561128f5760405163048278b760e41b815260040160405180910390fd5b6005805460ff60a81b1916600160a81b60ff8416908102919091179091556040519081527fc3acdc4f4bc283baa27c4207eb2c32954fbb26960847c9e15c2f7c89701342449060200160405180910390a150565b60fe5460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa15801561132b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134f9190613de7565b61136b5760405162461bcd60e51b815260040161062e90613e04565b60001960ff81905560405190815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a2565b6113b26127cc565b6113bc6000612951565b565b6008546001600160a01b0316336001600160a01b0316146113f25760405163b8088f8760e01b815260040160405180910390fd5b8281146114415760405162461bcd60e51b815260206004820152601c60248201527f496e70757420617272617973206c656e677468206d69736d6174636800000000604482015260640161062e565b60005b838110156114f957600085858381811061146057611460613ceb565b90506020020160208101906114759190613595565b90506001600160a01b03811661149e5760405163d92e233d60e01b815260040160405180910390fd5b8383838181106114b0576114b0613ceb565b90506020020160208101906114c59190613f04565b156114db576114d56009826129a3565b506114e8565b6114e66009826129b8565b505b506114f281613d65565b9050611444565b507f9fbe9a594da1fe3606c91442c9f6caaa2aba26087872d8373187473f11efd40b8484848460405161152f9493929190613f21565b60405180910390a150505050565b600061154a6009836129cd565b92915050565b600061155c60096129ef565b905090565b60ff54156115815760405162461bcd60e51b815260040161062e906138fd565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146115c95760405162461bcd60e51b815260040161062e90613fb1565b600554600160a01b900460ff1680156115e857506115e68261153d565b155b1561160657604051634414c63360e01b815260040160405180910390fd5b604051639926ee7d60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639926ee7d906116549085908590600401614081565b600060405180830381600087803b15801561166e57600080fd5b505af1158015611682573d6000803e3d6000fd5b505050505050565b6000838152600160205260408120606091906116a5906129ef565b90508084106116c7576040516392c4425960e01b815260040160405180910390fd5b60006116d38486613eab565b9050818111156116e05750805b60006116ec86836140cc565b6001600160401b0381111561170357611703613011565b60405190808252806020026020018201604052801561172c578160200160208202803683370190505b509050855b8281101561178757600088815260016020526040902061175190826129f9565b8261175c89846140cc565b8151811061176c5761176c613ceb565b602090810291909101015261178081613d65565b9050611731565b50925050505b9392505050565b61179c6127cc565b60405163a0169ddd60e01b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063a0169ddd906024015b600060405180830381600087803b15801561180057600080fd5b505af1158015611814573d6000803e3d6000fd5b5050505050565b611823612a05565b60005b8181101561199e576000805b84848481811061184457611844613ceb565b905060200281019061185691906140e3565b611864906040810190614103565b90508110156118d65784848481811061187f5761187f613ceb565b905060200281019061189191906140e3565b61189f906040810190614103565b828181106118af576118af613ceb565b90506040020160200135826118c49190613eab565b91506118cf81613d65565b9050611832565b506119233330838787878181106118ef576118ef613ceb565b905060200281019061190191906140e3565b611912906040810190602001613595565b6001600160a01b0316929190612a9a565b61198d7f00000000000000000000000000000000000000000000000000000000000000008286868681811061195a5761195a613ceb565b905060200281019061196c91906140e3565b61197d906040810190602001613595565b6001600160a01b03169190612b05565b5061199781613d65565b9050611826565b50604051634e5cd2fd60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639cb9a5fa9061165490309086908690600401614234565b60ff5415611a0f5760405162461bcd60e51b815260040161062e906138fd565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611a575760405162461bcd60e51b815260040161062e90613fb1565b6040516351b27a6d60e11b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063a364f4da906024016117e6565b611aad6127cc565b60405163a98fb35560e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a98fb355906117e6908490600401614390565b600081815260016020526040812061154a906129ef565b611b186127cc565b600554600160a01b900460ff1615611b4357604051637952fbad60e11b815260040160405180910390fd5b6005805460ff60a01b1916600160a01b1790556040517f8a943acd5f4e6d3df7565a4a08a93f6b04cc31bb6c01ca4aef7abd6baf455ec390600090a1565b611b896127cc565b600554600160a01b900460ff16611bb257604051625ecddb60e01b815260040160405180910390fd5b6005805460ff60a01b191690556040517f2d35c8d348a345fd7b3b03b7cfcf7ad0b60c2d46742d5ca536342e4185becb0790600090a1565b600061154a6009836129f9565b600082815260016020526040812061178d908361239b565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639aa1653d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c959190613e8e565b60ff16905080611cb357505060408051600081526020810190915290565b6000805b82811015611d6857604051633ca5a5f560e01b815260ff821660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690633ca5a5f590602401602060405180830381865afa158015611d26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4a9190613e4c565b611d549083613eab565b915080611d6081613d65565b915050611cb7565b506000816001600160401b03811115611d8357611d83613011565b604051908082528060200260200182016040528015611dac578160200160208202803683370190505b5090506000805b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639aa1653d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e359190613e8e565b60ff16811015611fce57604051633ca5a5f560e01b815260ff821660048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690633ca5a5f590602401602060405180830381865afa158015611ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecd9190613e4c565b905060005b81811015611fb9576040516356e4026d60e11b815260ff84166004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063adc804da906044016040805180830381865afa158015611f47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6b9190613ec3565b60000151858581518110611f8157611f81613ceb565b6001600160a01b039092166020928302919091019091015283611fa381613d65565b9450508080611fb190613d65565b915050611ed2565b50508080611fc690613d65565b915050611db3565b5090949350505050565b600082815260208190526040902054829060ff166120095760405163daf4a8a360e01b815260040160405180910390fd5b6120116127cc565b60008381526001602052604081206120299084612bb7565b9050801561207f5760008481526006602052604090206120499084612402565b50604080518481523360208201527f1bdeffc0337373bf2f6fd4219080133eeaaee0554206d9bb24a019d96973c1eb910161152f565b50505050565b61208d6127cc565b6001600160a01b0381166120f25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161062e565b610c1981612951565b6121036127cc565b610c19816125d3565b60fe60009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561215f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121839190613d80565b6001600160a01b0316336001600160a01b0316146121b35760405162461bcd60e51b815260040161062e90613d9d565b60ff5419811960ff541916146122315760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e756e70617573653a20696e76616c696420617474656d7060448201527f7420746f2070617573652066756e6374696f6e616c6974790000000000000000606482015260840161062e565b60ff81905560405181815233907f3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c90602001610d50565b612270612a05565b60005b8181101561234c576122cc333085858581811061229257612292613ceb565b90506020028101906122a491906143a3565b604001358686868181106122ba576122ba613ceb565b905060200281019061190191906143a3565b61233c7f000000000000000000000000000000000000000000000000000000000000000084848481811061230257612302613ceb565b905060200281019061231491906143a3565b6040013585858581811061232a5761232a613ceb565b905060200281019061196c91906143a3565b61234581613d65565b9050612273565b5060405163fce36c7d60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fce36c7d9061165490859085906004016143b9565b6000818152600183016020526040812054151561178d565b60006123be82612bc3565b60408051825160208083019190915283015163ffffffff16818301529101516060820152608001604051602081830303815290604052805190602001209050919050565b600061178d8383612c22565b60fe546001600160a01b031615801561242f57506001600160a01b03821615155b6124b15760405162461bcd60e51b815260206004820152604760248201527f5061757361626c652e5f696e697469616c697a655061757365723a205f696e6960448201527f7469616c697a6550617573657228292063616e206f6e6c792062652063616c6c6064820152666564206f6e636560c81b608482015260a40161062e565b60ff81905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a261125e826126d5565b603554610100900460ff1661255f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161062e565b61256882612951565b61125e816128e8565b600580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f175f27847b3568e0da876ffca3dc0bb52db4e6556346aedb530c6fe86610da2791015b60405180910390a15050565b600880546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f1d7f4da50d8af7a6cea3e56e235c952f5a92d4c862da2d587f7b67f6d0156bb291016125c7565b600182101561264f5760405163daf4a8a360e01b815260040160405180910390fd5b60008281526020819052604090205460ff161515811515141561268557604051631cf3d59360e31b815260040160405180910390fd5b60008281526020818152604091829020805460ff19168415159081179091558251858152918201527fe6dc5430aa4f5f1f54e9c1a3698de870c829afe22acf2737d45f109b82881b1e91016125c7565b6001600160a01b0381166127635760405162461bcd60e51b815260206004820152604960248201527f5061757361626c652e5f73657450617573657252656769737472793a206e657760448201527f50617573657252656769737472792063616e6e6f7420626520746865207a65726064820152686f206164647265737360b81b608482015260a40161062e565b60fe54604080516001600160a01b03928316815291831660208301527f6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6910160405180910390a160fe80546001600160a01b0319166001600160a01b0392909216919091179055565b6068546001600160a01b031633146113bc5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161062e565b606060008061283484612c71565b61ffff166001600160401b0381111561284f5761284f613011565b6040519080825280601f01601f191660200182016040528015612879576020820181803683370190505b5090506000805b825182108015612891575061010081105b15611fce576001811b9350858416156128d8578060f81b8383815181106128ba576128ba613ceb565b60200101906001600160f81b031916908160001a9053508160010191505b6128e181613d65565b9050612880565b609a54604080516001600160a01b03928316815291831660208301527fe11cddf1816a43318ca175bbc52cd0185436e9cbead7c83acc54a73e461717e3910160405180910390a1609a80546001600160a01b0319166001600160a01b0392909216919091179055565b606880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061178d836001600160a01b038416612c22565b600061178d836001600160a01b038416612c9c565b6001600160a01b0381166000908152600183016020526040812054151561178d565b600061154a825490565b600061178d8383612d8f565b609a546001600160a01b031633146113bc5760405162461bcd60e51b815260206004820152604c60248201527f536572766963654d616e61676572426173652e6f6e6c7952657761726473496e60448201527f69746961746f723a2063616c6c6572206973206e6f742074686520726577617260648201526b32399034b734ba34b0ba37b960a11b608482015260a40161062e565b6040516001600160a01b038085166024830152831660448201526064810182905261207f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612db9565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b7a9190613e4c565b612b849190613eab565b6040516001600160a01b03851660248201526044810182905290915061207f90859063095ea7b360e01b90606401612ace565b600061178d8383612c9c565b6040805160608101825260008082526020820181905291810191909152604051806060016040528083600001358152602001836060016020810190612c089190613934565b63ffffffff16815260200183608001358152509050919050565b6000818152600183016020526040812054612c695750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561154a565b50600061154a565b6000805b821561154a57612c866001846140cc565b9092169180612c9481614497565b915050612c75565b60008181526001830160205260408120548015612d85576000612cc06001836140cc565b8554909150600090612cd4906001906140cc565b9050818114612d39576000866000018281548110612cf457612cf4613ceb565b9060005260206000200154905080876000018481548110612d1757612d17613ceb565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612d4a57612d4a6144b9565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061154a565b600091505061154a565b6000826000018281548110612da657612da6613ceb565b9060005260206000200154905092915050565b6000612e0e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e909092919063ffffffff16565b805190915015612e8b5780806020019051810190612e2c9190613de7565b612e8b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161062e565b505050565b6060612e9f8484600085612ea7565b949350505050565b606082471015612f085760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161062e565b6001600160a01b0385163b612f5f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161062e565b600080866001600160a01b03168587604051612f7b91906144cf565b60006040518083038185875af1925050503d8060008114612fb8576040519150601f19603f3d011682016040523d82523d6000602084013e612fbd565b606091505b5091509150612fcd828286612fd8565b979650505050505050565b60608315612fe757508161178d565b825115612ff75782518084602001fd5b8160405162461bcd60e51b815260040161062e9190614390565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b038111828210171561304957613049613011565b60405290565b60405161010081016001600160401b038111828210171561304957613049613011565b604051606081016001600160401b038111828210171561304957613049613011565b604051601f8201601f191681016001600160401b03811182821017156130bc576130bc613011565b604052919050565b60006001600160401b038211156130dd576130dd613011565b5060051b60200190565b803563ffffffff811681146130fb57600080fd5b919050565b600082601f83011261311157600080fd5b81356020613126613121836130c4565b613094565b82815260059290921b8401810191818101908684111561314557600080fd5b8286015b848110156131675761315a816130e7565b8352918301918301613149565b509695505050505050565b60006040828403121561318457600080fd5b61318c613027565b9050813581526020820135602082015292915050565b600082601f8301126131b357600080fd5b813560206131c3613121836130c4565b82815260069290921b840181019181810190868411156131e257600080fd5b8286015b84811015613167576131f88882613172565b8352918301916040016131e6565b600082601f83011261321757600080fd5b61321f613027565b80604084018581111561323157600080fd5b845b8181101561324b578035845260209384019301613233565b509095945050505050565b60006080828403121561326857600080fd5b613270613027565b905061327c8383613206565b815261328b8360408401613206565b602082015292915050565b600082601f8301126132a757600080fd5b813560206132b7613121836130c4565b82815260059290921b840181019181810190868411156132d657600080fd5b8286015b848110156131675780356001600160401b038111156132f95760008081fd5b6133078986838b0101613100565b8452509183019183016132da565b6000806040838503121561332857600080fd5b82356001600160401b038082111561333f57600080fd5b9084019060a0828703121561335357600080fd5b9092506020840135908082111561336957600080fd5b90840190610180828703121561337e57600080fd5b61338661304f565b82358281111561339557600080fd5b6133a188828601613100565b8252506020830135828111156133b657600080fd5b6133c2888286016131a2565b6020830152506040830135828111156133da57600080fd5b6133e6888286016131a2565b6040830152506133f98760608501613256565b606082015261340b8760e08501613172565b60808201526101208301358281111561342357600080fd5b61342f88828601613100565b60a0830152506101408301358281111561344857600080fd5b61345488828601613100565b60c0830152506101608301358281111561346d57600080fd5b61347988828601613296565b60e0830152508093505050509250929050565b6001600160a01b0381168114610c1957600080fd5b60008083601f8401126134b357600080fd5b5081356001600160401b038111156134ca57600080fd5b6020830191508360208260051b85010111156134e557600080fd5b9250929050565b60008060008060008060008060e0898b03121561350857600080fd5b88356135138161348c565b975060208901359650604089013561352a8161348c565b9550606089013561353a8161348c565b9450608089013561354a8161348c565b935060a089013561355a8161348c565b925060c08901356001600160401b0381111561357557600080fd5b6135818b828c016134a1565b999c989b5096995094979396929594505050565b6000602082840312156135a757600080fd5b813561178d8161348c565b6000602082840312156135c457600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b8181101561360c5783516001600160a01b0316835292840192918401916001016135e7565b50909695505050505050565b8015158114610c1957600080fd5b6000806040838503121561363957600080fd5b82359150602083013561364b81613618565b809150509250929050565b60ff81168114610c1957600080fd5b60006020828403121561367757600080fd5b813561178d81613656565b6000806000806040858703121561369857600080fd5b84356001600160401b03808211156136af57600080fd5b6136bb888389016134a1565b909650945060208701359150808211156136d457600080fd5b506136e1878288016134a1565b95989497509550505050565b60006001600160401b0383111561370657613706613011565b613719601f8401601f1916602001613094565b905082815283838301111561372d57600080fd5b828260208301376000602084830101529392505050565b6000806040838503121561375757600080fd5b82356137628161348c565b915060208301356001600160401b038082111561377e57600080fd5b908401906060828703121561379257600080fd5b61379a613072565b8235828111156137a957600080fd5b83019150601f820187136137bc57600080fd5b6137cb878335602085016136ed565b815260208301356020820152604083013560408201528093505050509250929050565b60008060006060848603121561380357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b8181101561360c57835183529284019291840191600101613836565b6000806020838503121561386557600080fd5b82356001600160401b0381111561387b57600080fd5b613887858286016134a1565b90969095509350505050565b6000602082840312156138a557600080fd5b81356001600160401b038111156138bb57600080fd5b8201601f810184136138cc57600080fd5b612e9f848235602084016136ed565b600080604083850312156138ee57600080fd5b50508035926020909101359150565b6020808252601c908201527f5061757361626c653a20636f6e74726163742069732070617573656400000000604082015260600190565b60006020828403121561394657600080fd5b61178d826130e7565b6000808335601e1984360301811261396657600080fd5b8301803591506001600160401b0382111561398057600080fd5b6020019150368190038213156134e557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600081518084526020808501945080840160005b838110156139f457815163ffffffff16875295820195908201906001016139d2565b509495945050505050565b600081518084526020808501945080840160005b838110156139f457613a3087835180518252602090810151910152565b6040969096019590820190600101613a13565b8060005b600281101561207f578151845260209384019390910190600101613a47565b613a71828251613a43565b6020810151612e8b6040840182613a43565b600081518084526020808501808196508360051b8101915082860160005b85811015613acb578284038952613ab98483516139be565b98850198935090840190600101613aa1565b5091979650505050505050565b858152608060208201526000613af2608083018688613995565b63ffffffff8516604084015282810360608401526101808451818352613b1a828401826139be565b91505060208501518282036020840152613b3482826139ff565b91505060408501518282036040840152613b4e82826139ff565b9150506060850151613b636060840182613a66565b506080850151805160e08401526020015161010083015260a0850151828203610120840152613b9282826139be565b91505060c0850151828203610140840152613bad82826139be565b91505060e0850151828203610160840152613bc88282613a83565b9a9950505050505050505050565b6001600160601b0381168114610c1957600080fd5b600082601f830112613bfc57600080fd5b81516020613c0c613121836130c4565b82815260059290921b84018101918181019086841115613c2b57600080fd5b8286015b84811015613167578051613c4281613bd6565b8352918301918301613c2f565b60008060408385031215613c6257600080fd5b82516001600160401b0380821115613c7957600080fd5b9084019060408287031215613c8d57600080fd5b613c95613027565b825182811115613ca457600080fd5b613cb088828601613beb565b825250602083015182811115613cc557600080fd5b613cd188828601613beb565b602083015250809450505050602083015190509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001600160601b0380831681851681830481118215151615613d3d57613d3d613d01565b02949350505050565b6000816000190483118215151615613d6057613d60613d01565b500290565b6000600019821415613d7957613d79613d01565b5060010190565b600060208284031215613d9257600080fd5b815161178d8161348c565b6020808252602a908201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160408201526939903ab73830bab9b2b960b11b606082015260800190565b600060208284031215613df957600080fd5b815161178d81613618565b60208082526028908201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160408201526739903830bab9b2b960c11b606082015260800190565b600060208284031215613e5e57600080fd5b5051919050565b600060208284031215613e7757600080fd5b81516001600160c01b038116811461178d57600080fd5b600060208284031215613ea057600080fd5b815161178d81613656565b60008219821115613ebe57613ebe613d01565b500190565b600060408284031215613ed557600080fd5b613edd613027565b8251613ee88161348c565b81526020830151613ef881613bd6565b60208201529392505050565b600060208284031215613f1657600080fd5b813561178d81613618565b6040808252810184905260008560608301825b87811015613f64578235613f478161348c565b6001600160a01b0316825260209283019290910190600101613f34565b5083810360208581019190915285825291508590820160005b86811015613fa4578235613f9081613618565b151582529183019190830190600101613f7d565b5098975050505050505050565b60208082526052908201527f536572766963654d616e61676572426173652e6f6e6c7952656769737472794360408201527f6f6f7264696e61746f723a2063616c6c6572206973206e6f742074686520726560608201527133b4b9ba393c9031b7b7b93234b730ba37b960711b608082015260a00190565b60005b8381101561404457818101518382015260200161402c565b8381111561207f5750506000910152565b6000815180845261406d816020860160208601614029565b601f01601f19169290920160200192915050565b60018060a01b03831681526040602082015260008251606060408401526140ab60a0840182614055565b90506020840151606084015260408401516080840152809150509392505050565b6000828210156140de576140de613d01565b500390565b6000823560be198336030181126140f957600080fd5b9190910192915050565b6000808335601e1984360301811261411a57600080fd5b8301803591506001600160401b0382111561413457600080fd5b6020019150600681901b36038213156134e557600080fd5b6000808335601e1984360301811261416357600080fd5b83016020810192503590506001600160401b0381111561418257600080fd5b8060061b36038313156134e557600080fd5b8183526000602080850194508260005b858110156139f45781356141b78161348c565b6001600160a01b03168752818301356141cf81613bd6565b6001600160601b03168784015260409687019691909101906001016141a4565b6000808335601e1984360301811261420657600080fd5b83016020810192503590506001600160401b0381111561422557600080fd5b8036038313156134e557600080fd5b6001600160a01b03848116825260406020808401829052838201859052600092606091828601600588901b8701840189875b8a81101561437f57898303605f190184528135368d900360be1901811261428c57600080fd5b8c0160c061429a828061414c565b8287526142aa8388018284614194565b92505050868201356142bb8161348c565b8816858801526142cd828b018361414c565b8683038c88015280835290916000919089015b818310156143115783356142f38161348c565b8b168152838a01358a820152928c0192600192909201918c016142e0565b61431c8c86016130e7565b63ffffffff168c890152608093506143358585016130e7565b63ffffffff811689860152925060a09350614352848601866141ef565b9550925087810384890152614368818685613995565b988a01989750505093870193505050600101614266565b50909b9a5050505050505050505050565b60208152600061178d6020830184614055565b60008235609e198336030181126140f957600080fd5b60208082528181018390526000906040808401600586901b850182018785805b8981101561448857888403603f190185528235368c9003609e190181126143fe578283fd5b8b0160a061440c828061414c565b82885261441c8389018284614194565b925050508882013561442d8161348c565b6001600160a01b0316868a01528188013588870152606061444f8184016130e7565b63ffffffff808216838a0152608092508061446b8487016130e7565b1698909201979097525095880195945050918601916001016143d9565b50919998505050505050505050565b600061ffff808316818114156144af576144af613d01565b6001019392505050565b634e487b7160e01b600052603160045260246000fd5b600082516140f981846020870161402956fea26469706673582212203d97121ceb68f9359b60f408c7def9dd24cbfe31a197d73fd62c6f4736ddac1964736f6c634300080c0033000000000000000000000000135dda560e946695d6f155dacafc6f1f25c1f5af0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d67000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a800000000000000000000000085814b3ff84da95363c15879b605f3c47fa6a762
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102745760003560e01c806394c8e4ff11610151578063d1907419116100c3578063efb2bfd311610087578063efb2bfd314610588578063f2fde38b146105af578063f98f5b92146105c2578063fabc1cbc146105d5578063fc299dee146105e8578063fce36c7d146105fb57600080fd5b8063d19074191461053f578063e0e387ab14610552578063e481af9d14610565578063edaa410e1461056d578063ef0244581461058057600080fd5b8063a20b99bf11610115578063a20b99bf146104e3578063a364f4da146104f6578063a98fb35514610509578063b733cc771461051c578063c6a2aac81461052f578063cf8e629a1461053757600080fd5b806394c8e4ff146104815780639925378f146104955780639926ee7d1461049d5780639d81ceba146104b0578063a0169ddd146104d057600080fd5b80634c6b05d9116101ea5780636b3aa72e116101ae5780636b3aa72e14610409578063715018a61461042f57806372faa8df1461043757806375ccc1321461044a578063886f11951461045d5780638da5cb5b1461047057600080fd5b80634c6b05d9146103765780634deabc21146103a9578063595c6a67146103cf5780635ac86ab7146103d75780635c975abb146103f757600080fd5b80632f640a091161023c5780632f640a09146102f757806333cfb7b71461030a57806339bc68e71461032a5780633bc28c8c1461033d5780633deebb6914610350578063429d5bf01461036357600080fd5b80630898f07f146102795780630d1bc8931461028e57806310d67a2f146102a1578063136439dd146102b457806322758a4a146102c7575b600080fd5b61028c610287366004613315565b61060e565b005b61028c61029c3660046134ec565b6109de565b61028c6102af366004613595565b610b69565b61028c6102c23660046135b2565b610c1c565b6008546102da906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61028c610305366004613595565b610d5b565b61031d610318366004613595565b610d6c565b6040516102ee91906135cb565b6005546102da906001600160a01b031681565b61028c61034b366004613595565b61123b565b61028c61035e366004613626565b61124c565b61028c610371366004613665565b611262565b6103996103843660046135b2565b60006020819052908152604090205460ff1681565b60405190151581526020016102ee565b6005546103bd90600160a81b900460ff1681565b60405160ff90911681526020016102ee565b61028c6112e3565b6103996103e5366004613665565b60ff80546001919092161b9081161490565b60ff545b6040519081526020016102ee565b7f000000000000000000000000135dda560e946695d6f155dacafc6f1f25c1f5af6102da565b61028c6113aa565b61028c610445366004613682565b6113be565b610399610458366004613595565b61153d565b60fe546102da906001600160a01b031681565b6068546001600160a01b03166102da565b60055461039990600160a01b900460ff1681565b6103fb611550565b61028c6104ab366004613744565b611561565b6104c36104be3660046137ee565b61168a565b6040516102ee919061381a565b61028c6104de366004613595565b611794565b61028c6104f1366004613852565b61181b565b61028c610504366004613595565b6119ef565b61028c610517366004613893565b611aa5565b6103fb61052a3660046135b2565b611af9565b61028c611b10565b61028c611b81565b6102da61054d3660046135b2565b611bea565b6103996105603660046138db565b611bf7565b61031d611c0f565b61028c61057b3660046138db565b611fd8565b6103fb606481565b6102da7f00000000000000000000000085814b3ff84da95363c15879b605f3c47fa6a76281565b61028c6105bd366004613595565b612085565b61028c6105d0366004613595565b6120fb565b61028c6105e33660046135b2565b61210c565b609a546102da906001600160a01b031681565b61028c610609366004613852565b612268565b60ff54156106375760405162461bcd60e51b815260040161062e906138fd565b60405180910390fd5b6005546001600160a01b0316336001600160a01b03161461066b5760405163fc4a01bd60e01b815260040160405180910390fd5b608082013560008181526020819052604090205460ff1661069f5760405163daf4a8a360e01b815260040160405180910390fd5b3233146106bf57604051636edaef2f60e11b815260040160405180910390fd5b608083013560009081526006602052604090206106dd90843561239b565b156106fb5760405163939bc9df60e01b815260040160405180910390fd5b4361070c6080850160608601613934565b63ffffffff16106107305760405163c15ef5b560e01b815260040160405180910390fd5b600061073b846123b3565b905061074a604085018561394f565b9050610759602086018661394f565b9050146107795760405163c9df75a560e01b815260040160405180910390fd5b60006001600160a01b037f00000000000000000000000085814b3ff84da95363c15879b605f3c47fa6a76216636efb4636836107b8602089018961394f565b6107c860808b0160608c01613934565b896040518663ffffffff1660e01b81526004016107e9959493929190613ad8565b600060405180830381865afa158015610806573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261082e9190810190613c4f565b50905060005b610841604087018761394f565b9050811015610961576000610859604088018861394f565b8381811061086957610869613ceb565b919091013560f81c91505060648111156108965760405163048278b760e41b815260040160405180910390fd5b60055460ff600160a81b909104811690821610156108c75760405163bbf727c160e01b815260040160405180910390fd5b8060ff16836020015183815181106108e1576108e1613ceb565b60200260200101516108f39190613d17565b6001600160601b031660648460000151848151811061091457610914613ceb565b60200260200101516001600160601b031661092f9190613d46565b101561094e57604051633916714960e21b815260040160405180910390fd5b508061095981613d65565b915050610834565b5060808501356000908152600160205260408120610980908735612402565b9050806109a05760405163f411c32760e01b815260040160405180910390fd5b6040518635815283907ffdda6f7d4825a4f1e4e97b50a26a69a8bcc3f4fcb1113cc14ce8e7098ca636659060200160405180910390a2505050505050565b603554610100900460ff16158080156109fe5750603554600160ff909116105b80610a185750303b158015610a18575060355460ff166001145b610a7b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161062e565b6035805460ff191660011790558015610a9e576035805461ff0019166101001790555b610aa8898961240e565b610ab287876124f4565b610abb85612571565b610ac4846125d3565b60005b82811015610b0257610af2848483818110610ae457610ae4613ceb565b90506020020135600161262d565b610afb81613d65565b9050610ac7565b506005805461ffff60a01b191661420160a01b1790558015610b5e576035805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b60fe60009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be09190613d80565b6001600160a01b0316336001600160a01b031614610c105760405162461bcd60e51b815260040161062e90613d9d565b610c19816126d5565b50565b60fe5460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa158015610c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c889190613de7565b610ca45760405162461bcd60e51b815260040161062e90613e04565b60ff5481811614610d1d5760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e70617573653a20696e76616c696420617474656d70742060448201527f746f20756e70617573652066756e6374696f6e616c6974790000000000000000606482015260840161062e565b60ff81905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d906020015b60405180910390a250565b610d636127cc565b610c1981612571565b6040516309aa152760e11b81526001600160a01b0382811660048301526060916000917f0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d6716906313542a4e90602401602060405180830381865afa158015610dd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfc9190613e4c565b60405163871ef04960e01b8152600481018290529091506000906001600160a01b037f0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d67169063871ef04990602401602060405180830381865afa158015610e67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8b9190613e65565b90506001600160c01b0381161580610f2557507f0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d676001600160a01b0316639aa1653d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610efc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f209190613e8e565b60ff16155b15610f4157505060408051600081526020810190915292915050565b6000610f55826001600160c01b0316612826565b90506000805b825181101561102b577f000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a86001600160a01b0316633ca5a5f5848381518110610fa557610fa5613ceb565b01602001516040516001600160e01b031960e084901b16815260f89190911c6004820152602401602060405180830381865afa158015610fe9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100d9190613e4c565b6110179083613eab565b91508061102381613d65565b915050610f5b565b506000816001600160401b0381111561104657611046613011565b60405190808252806020026020018201604052801561106f578160200160208202803683370190505b5090506000805b845181101561122e57600085828151811061109357611093613ceb565b0160200151604051633ca5a5f560e01b815260f89190911c6004820181905291506000906001600160a01b037f000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a81690633ca5a5f590602401602060405180830381865afa158015611108573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112c9190613e4c565b905060005b81811015611218576040516356e4026d60e11b815260ff84166004820152602481018290527f000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a86001600160a01b03169063adc804da906044016040805180830381865afa1580156111a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ca9190613ec3565b600001518686815181106111e0576111e0613ceb565b6001600160a01b03909216602092830291909101909101528461120281613d65565b955050808061121090613d65565b915050611131565b505050808061122690613d65565b915050611076565b5090979650505050505050565b6112436127cc565b610c19816128e8565b6112546127cc565b61125e828261262d565b5050565b61126a6127cc565b60648160ff16111561128f5760405163048278b760e41b815260040160405180910390fd5b6005805460ff60a81b1916600160a81b60ff8416908102919091179091556040519081527fc3acdc4f4bc283baa27c4207eb2c32954fbb26960847c9e15c2f7c89701342449060200160405180910390a150565b60fe5460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa15801561132b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134f9190613de7565b61136b5760405162461bcd60e51b815260040161062e90613e04565b60001960ff81905560405190815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a2565b6113b26127cc565b6113bc6000612951565b565b6008546001600160a01b0316336001600160a01b0316146113f25760405163b8088f8760e01b815260040160405180910390fd5b8281146114415760405162461bcd60e51b815260206004820152601c60248201527f496e70757420617272617973206c656e677468206d69736d6174636800000000604482015260640161062e565b60005b838110156114f957600085858381811061146057611460613ceb565b90506020020160208101906114759190613595565b90506001600160a01b03811661149e5760405163d92e233d60e01b815260040160405180910390fd5b8383838181106114b0576114b0613ceb565b90506020020160208101906114c59190613f04565b156114db576114d56009826129a3565b506114e8565b6114e66009826129b8565b505b506114f281613d65565b9050611444565b507f9fbe9a594da1fe3606c91442c9f6caaa2aba26087872d8373187473f11efd40b8484848460405161152f9493929190613f21565b60405180910390a150505050565b600061154a6009836129cd565b92915050565b600061155c60096129ef565b905090565b60ff54156115815760405162461bcd60e51b815260040161062e906138fd565b336001600160a01b037f0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d6716146115c95760405162461bcd60e51b815260040161062e90613fb1565b600554600160a01b900460ff1680156115e857506115e68261153d565b155b1561160657604051634414c63360e01b815260040160405180910390fd5b604051639926ee7d60e01b81526001600160a01b037f000000000000000000000000135dda560e946695d6f155dacafc6f1f25c1f5af1690639926ee7d906116549085908590600401614081565b600060405180830381600087803b15801561166e57600080fd5b505af1158015611682573d6000803e3d6000fd5b505050505050565b6000838152600160205260408120606091906116a5906129ef565b90508084106116c7576040516392c4425960e01b815260040160405180910390fd5b60006116d38486613eab565b9050818111156116e05750805b60006116ec86836140cc565b6001600160401b0381111561170357611703613011565b60405190808252806020026020018201604052801561172c578160200160208202803683370190505b509050855b8281101561178757600088815260016020526040902061175190826129f9565b8261175c89846140cc565b8151811061176c5761176c613ceb565b602090810291909101015261178081613d65565b9050611731565b50925050505b9392505050565b61179c6127cc565b60405163a0169ddd60e01b81526001600160a01b0382811660048301527f0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda169063a0169ddd906024015b600060405180830381600087803b15801561180057600080fd5b505af1158015611814573d6000803e3d6000fd5b5050505050565b611823612a05565b60005b8181101561199e576000805b84848481811061184457611844613ceb565b905060200281019061185691906140e3565b611864906040810190614103565b90508110156118d65784848481811061187f5761187f613ceb565b905060200281019061189191906140e3565b61189f906040810190614103565b828181106118af576118af613ceb565b90506040020160200135826118c49190613eab565b91506118cf81613d65565b9050611832565b506119233330838787878181106118ef576118ef613ceb565b905060200281019061190191906140e3565b611912906040810190602001613595565b6001600160a01b0316929190612a9a565b61198d7f0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda8286868681811061195a5761195a613ceb565b905060200281019061196c91906140e3565b61197d906040810190602001613595565b6001600160a01b03169190612b05565b5061199781613d65565b9050611826565b50604051634e5cd2fd60e11b81526001600160a01b037f0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda1690639cb9a5fa9061165490309086908690600401614234565b60ff5415611a0f5760405162461bcd60e51b815260040161062e906138fd565b336001600160a01b037f0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d671614611a575760405162461bcd60e51b815260040161062e90613fb1565b6040516351b27a6d60e11b81526001600160a01b0382811660048301527f000000000000000000000000135dda560e946695d6f155dacafc6f1f25c1f5af169063a364f4da906024016117e6565b611aad6127cc565b60405163a98fb35560e01b81526001600160a01b037f000000000000000000000000135dda560e946695d6f155dacafc6f1f25c1f5af169063a98fb355906117e6908490600401614390565b600081815260016020526040812061154a906129ef565b611b186127cc565b600554600160a01b900460ff1615611b4357604051637952fbad60e11b815260040160405180910390fd5b6005805460ff60a01b1916600160a01b1790556040517f8a943acd5f4e6d3df7565a4a08a93f6b04cc31bb6c01ca4aef7abd6baf455ec390600090a1565b611b896127cc565b600554600160a01b900460ff16611bb257604051625ecddb60e01b815260040160405180910390fd5b6005805460ff60a01b191690556040517f2d35c8d348a345fd7b3b03b7cfcf7ad0b60c2d46742d5ca536342e4185becb0790600090a1565b600061154a6009836129f9565b600082815260016020526040812061178d908361239b565b606060007f0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d676001600160a01b0316639aa1653d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c959190613e8e565b60ff16905080611cb357505060408051600081526020810190915290565b6000805b82811015611d6857604051633ca5a5f560e01b815260ff821660048201527f000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a86001600160a01b031690633ca5a5f590602401602060405180830381865afa158015611d26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4a9190613e4c565b611d549083613eab565b915080611d6081613d65565b915050611cb7565b506000816001600160401b03811115611d8357611d83613011565b604051908082528060200260200182016040528015611dac578160200160208202803683370190505b5090506000805b7f0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d676001600160a01b0316639aa1653d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e359190613e8e565b60ff16811015611fce57604051633ca5a5f560e01b815260ff821660048201526000907f000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a86001600160a01b031690633ca5a5f590602401602060405180830381865afa158015611ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecd9190613e4c565b905060005b81811015611fb9576040516356e4026d60e11b815260ff84166004820152602481018290527f000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a86001600160a01b03169063adc804da906044016040805180830381865afa158015611f47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6b9190613ec3565b60000151858581518110611f8157611f81613ceb565b6001600160a01b039092166020928302919091019091015283611fa381613d65565b9450508080611fb190613d65565b915050611ed2565b50508080611fc690613d65565b915050611db3565b5090949350505050565b600082815260208190526040902054829060ff166120095760405163daf4a8a360e01b815260040160405180910390fd5b6120116127cc565b60008381526001602052604081206120299084612bb7565b9050801561207f5760008481526006602052604090206120499084612402565b50604080518481523360208201527f1bdeffc0337373bf2f6fd4219080133eeaaee0554206d9bb24a019d96973c1eb910161152f565b50505050565b61208d6127cc565b6001600160a01b0381166120f25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161062e565b610c1981612951565b6121036127cc565b610c19816125d3565b60fe60009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561215f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121839190613d80565b6001600160a01b0316336001600160a01b0316146121b35760405162461bcd60e51b815260040161062e90613d9d565b60ff5419811960ff541916146122315760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e756e70617573653a20696e76616c696420617474656d7060448201527f7420746f2070617573652066756e6374696f6e616c6974790000000000000000606482015260840161062e565b60ff81905560405181815233907f3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c90602001610d50565b612270612a05565b60005b8181101561234c576122cc333085858581811061229257612292613ceb565b90506020028101906122a491906143a3565b604001358686868181106122ba576122ba613ceb565b905060200281019061190191906143a3565b61233c7f0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda84848481811061230257612302613ceb565b905060200281019061231491906143a3565b6040013585858581811061232a5761232a613ceb565b905060200281019061196c91906143a3565b61234581613d65565b9050612273565b5060405163fce36c7d60e01b81526001600160a01b037f0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda169063fce36c7d9061165490859085906004016143b9565b6000818152600183016020526040812054151561178d565b60006123be82612bc3565b60408051825160208083019190915283015163ffffffff16818301529101516060820152608001604051602081830303815290604052805190602001209050919050565b600061178d8383612c22565b60fe546001600160a01b031615801561242f57506001600160a01b03821615155b6124b15760405162461bcd60e51b815260206004820152604760248201527f5061757361626c652e5f696e697469616c697a655061757365723a205f696e6960448201527f7469616c697a6550617573657228292063616e206f6e6c792062652063616c6c6064820152666564206f6e636560c81b608482015260a40161062e565b60ff81905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a261125e826126d5565b603554610100900460ff1661255f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161062e565b61256882612951565b61125e816128e8565b600580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f175f27847b3568e0da876ffca3dc0bb52db4e6556346aedb530c6fe86610da2791015b60405180910390a15050565b600880546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f1d7f4da50d8af7a6cea3e56e235c952f5a92d4c862da2d587f7b67f6d0156bb291016125c7565b600182101561264f5760405163daf4a8a360e01b815260040160405180910390fd5b60008281526020819052604090205460ff161515811515141561268557604051631cf3d59360e31b815260040160405180910390fd5b60008281526020818152604091829020805460ff19168415159081179091558251858152918201527fe6dc5430aa4f5f1f54e9c1a3698de870c829afe22acf2737d45f109b82881b1e91016125c7565b6001600160a01b0381166127635760405162461bcd60e51b815260206004820152604960248201527f5061757361626c652e5f73657450617573657252656769737472793a206e657760448201527f50617573657252656769737472792063616e6e6f7420626520746865207a65726064820152686f206164647265737360b81b608482015260a40161062e565b60fe54604080516001600160a01b03928316815291831660208301527f6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6910160405180910390a160fe80546001600160a01b0319166001600160a01b0392909216919091179055565b6068546001600160a01b031633146113bc5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161062e565b606060008061283484612c71565b61ffff166001600160401b0381111561284f5761284f613011565b6040519080825280601f01601f191660200182016040528015612879576020820181803683370190505b5090506000805b825182108015612891575061010081105b15611fce576001811b9350858416156128d8578060f81b8383815181106128ba576128ba613ceb565b60200101906001600160f81b031916908160001a9053508160010191505b6128e181613d65565b9050612880565b609a54604080516001600160a01b03928316815291831660208301527fe11cddf1816a43318ca175bbc52cd0185436e9cbead7c83acc54a73e461717e3910160405180910390a1609a80546001600160a01b0319166001600160a01b0392909216919091179055565b606880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061178d836001600160a01b038416612c22565b600061178d836001600160a01b038416612c9c565b6001600160a01b0381166000908152600183016020526040812054151561178d565b600061154a825490565b600061178d8383612d8f565b609a546001600160a01b031633146113bc5760405162461bcd60e51b815260206004820152604c60248201527f536572766963654d616e61676572426173652e6f6e6c7952657761726473496e60448201527f69746961746f723a2063616c6c6572206973206e6f742074686520726577617260648201526b32399034b734ba34b0ba37b960a11b608482015260a40161062e565b6040516001600160a01b038085166024830152831660448201526064810182905261207f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612db9565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b7a9190613e4c565b612b849190613eab565b6040516001600160a01b03851660248201526044810182905290915061207f90859063095ea7b360e01b90606401612ace565b600061178d8383612c9c565b6040805160608101825260008082526020820181905291810191909152604051806060016040528083600001358152602001836060016020810190612c089190613934565b63ffffffff16815260200183608001358152509050919050565b6000818152600183016020526040812054612c695750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561154a565b50600061154a565b6000805b821561154a57612c866001846140cc565b9092169180612c9481614497565b915050612c75565b60008181526001830160205260408120548015612d85576000612cc06001836140cc565b8554909150600090612cd4906001906140cc565b9050818114612d39576000866000018281548110612cf457612cf4613ceb565b9060005260206000200154905080876000018481548110612d1757612d17613ceb565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612d4a57612d4a6144b9565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061154a565b600091505061154a565b6000826000018281548110612da657612da6613ceb565b9060005260206000200154905092915050565b6000612e0e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e909092919063ffffffff16565b805190915015612e8b5780806020019051810190612e2c9190613de7565b612e8b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161062e565b505050565b6060612e9f8484600085612ea7565b949350505050565b606082471015612f085760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161062e565b6001600160a01b0385163b612f5f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161062e565b600080866001600160a01b03168587604051612f7b91906144cf565b60006040518083038185875af1925050503d8060008114612fb8576040519150601f19603f3d011682016040523d82523d6000602084013e612fbd565b606091505b5091509150612fcd828286612fd8565b979650505050505050565b60608315612fe757508161178d565b825115612ff75782518084602001fd5b8160405162461bcd60e51b815260040161062e9190614390565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b038111828210171561304957613049613011565b60405290565b60405161010081016001600160401b038111828210171561304957613049613011565b604051606081016001600160401b038111828210171561304957613049613011565b604051601f8201601f191681016001600160401b03811182821017156130bc576130bc613011565b604052919050565b60006001600160401b038211156130dd576130dd613011565b5060051b60200190565b803563ffffffff811681146130fb57600080fd5b919050565b600082601f83011261311157600080fd5b81356020613126613121836130c4565b613094565b82815260059290921b8401810191818101908684111561314557600080fd5b8286015b848110156131675761315a816130e7565b8352918301918301613149565b509695505050505050565b60006040828403121561318457600080fd5b61318c613027565b9050813581526020820135602082015292915050565b600082601f8301126131b357600080fd5b813560206131c3613121836130c4565b82815260069290921b840181019181810190868411156131e257600080fd5b8286015b84811015613167576131f88882613172565b8352918301916040016131e6565b600082601f83011261321757600080fd5b61321f613027565b80604084018581111561323157600080fd5b845b8181101561324b578035845260209384019301613233565b509095945050505050565b60006080828403121561326857600080fd5b613270613027565b905061327c8383613206565b815261328b8360408401613206565b602082015292915050565b600082601f8301126132a757600080fd5b813560206132b7613121836130c4565b82815260059290921b840181019181810190868411156132d657600080fd5b8286015b848110156131675780356001600160401b038111156132f95760008081fd5b6133078986838b0101613100565b8452509183019183016132da565b6000806040838503121561332857600080fd5b82356001600160401b038082111561333f57600080fd5b9084019060a0828703121561335357600080fd5b9092506020840135908082111561336957600080fd5b90840190610180828703121561337e57600080fd5b61338661304f565b82358281111561339557600080fd5b6133a188828601613100565b8252506020830135828111156133b657600080fd5b6133c2888286016131a2565b6020830152506040830135828111156133da57600080fd5b6133e6888286016131a2565b6040830152506133f98760608501613256565b606082015261340b8760e08501613172565b60808201526101208301358281111561342357600080fd5b61342f88828601613100565b60a0830152506101408301358281111561344857600080fd5b61345488828601613100565b60c0830152506101608301358281111561346d57600080fd5b61347988828601613296565b60e0830152508093505050509250929050565b6001600160a01b0381168114610c1957600080fd5b60008083601f8401126134b357600080fd5b5081356001600160401b038111156134ca57600080fd5b6020830191508360208260051b85010111156134e557600080fd5b9250929050565b60008060008060008060008060e0898b03121561350857600080fd5b88356135138161348c565b975060208901359650604089013561352a8161348c565b9550606089013561353a8161348c565b9450608089013561354a8161348c565b935060a089013561355a8161348c565b925060c08901356001600160401b0381111561357557600080fd5b6135818b828c016134a1565b999c989b5096995094979396929594505050565b6000602082840312156135a757600080fd5b813561178d8161348c565b6000602082840312156135c457600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b8181101561360c5783516001600160a01b0316835292840192918401916001016135e7565b50909695505050505050565b8015158114610c1957600080fd5b6000806040838503121561363957600080fd5b82359150602083013561364b81613618565b809150509250929050565b60ff81168114610c1957600080fd5b60006020828403121561367757600080fd5b813561178d81613656565b6000806000806040858703121561369857600080fd5b84356001600160401b03808211156136af57600080fd5b6136bb888389016134a1565b909650945060208701359150808211156136d457600080fd5b506136e1878288016134a1565b95989497509550505050565b60006001600160401b0383111561370657613706613011565b613719601f8401601f1916602001613094565b905082815283838301111561372d57600080fd5b828260208301376000602084830101529392505050565b6000806040838503121561375757600080fd5b82356137628161348c565b915060208301356001600160401b038082111561377e57600080fd5b908401906060828703121561379257600080fd5b61379a613072565b8235828111156137a957600080fd5b83019150601f820187136137bc57600080fd5b6137cb878335602085016136ed565b815260208301356020820152604083013560408201528093505050509250929050565b60008060006060848603121561380357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b8181101561360c57835183529284019291840191600101613836565b6000806020838503121561386557600080fd5b82356001600160401b0381111561387b57600080fd5b613887858286016134a1565b90969095509350505050565b6000602082840312156138a557600080fd5b81356001600160401b038111156138bb57600080fd5b8201601f810184136138cc57600080fd5b612e9f848235602084016136ed565b600080604083850312156138ee57600080fd5b50508035926020909101359150565b6020808252601c908201527f5061757361626c653a20636f6e74726163742069732070617573656400000000604082015260600190565b60006020828403121561394657600080fd5b61178d826130e7565b6000808335601e1984360301811261396657600080fd5b8301803591506001600160401b0382111561398057600080fd5b6020019150368190038213156134e557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600081518084526020808501945080840160005b838110156139f457815163ffffffff16875295820195908201906001016139d2565b509495945050505050565b600081518084526020808501945080840160005b838110156139f457613a3087835180518252602090810151910152565b6040969096019590820190600101613a13565b8060005b600281101561207f578151845260209384019390910190600101613a47565b613a71828251613a43565b6020810151612e8b6040840182613a43565b600081518084526020808501808196508360051b8101915082860160005b85811015613acb578284038952613ab98483516139be565b98850198935090840190600101613aa1565b5091979650505050505050565b858152608060208201526000613af2608083018688613995565b63ffffffff8516604084015282810360608401526101808451818352613b1a828401826139be565b91505060208501518282036020840152613b3482826139ff565b91505060408501518282036040840152613b4e82826139ff565b9150506060850151613b636060840182613a66565b506080850151805160e08401526020015161010083015260a0850151828203610120840152613b9282826139be565b91505060c0850151828203610140840152613bad82826139be565b91505060e0850151828203610160840152613bc88282613a83565b9a9950505050505050505050565b6001600160601b0381168114610c1957600080fd5b600082601f830112613bfc57600080fd5b81516020613c0c613121836130c4565b82815260059290921b84018101918181019086841115613c2b57600080fd5b8286015b84811015613167578051613c4281613bd6565b8352918301918301613c2f565b60008060408385031215613c6257600080fd5b82516001600160401b0380821115613c7957600080fd5b9084019060408287031215613c8d57600080fd5b613c95613027565b825182811115613ca457600080fd5b613cb088828601613beb565b825250602083015182811115613cc557600080fd5b613cd188828601613beb565b602083015250809450505050602083015190509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001600160601b0380831681851681830481118215151615613d3d57613d3d613d01565b02949350505050565b6000816000190483118215151615613d6057613d60613d01565b500290565b6000600019821415613d7957613d79613d01565b5060010190565b600060208284031215613d9257600080fd5b815161178d8161348c565b6020808252602a908201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160408201526939903ab73830bab9b2b960b11b606082015260800190565b600060208284031215613df957600080fd5b815161178d81613618565b60208082526028908201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160408201526739903830bab9b2b960c11b606082015260800190565b600060208284031215613e5e57600080fd5b5051919050565b600060208284031215613e7757600080fd5b81516001600160c01b038116811461178d57600080fd5b600060208284031215613ea057600080fd5b815161178d81613656565b60008219821115613ebe57613ebe613d01565b500190565b600060408284031215613ed557600080fd5b613edd613027565b8251613ee88161348c565b81526020830151613ef881613bd6565b60208201529392505050565b600060208284031215613f1657600080fd5b813561178d81613618565b6040808252810184905260008560608301825b87811015613f64578235613f478161348c565b6001600160a01b0316825260209283019290910190600101613f34565b5083810360208581019190915285825291508590820160005b86811015613fa4578235613f9081613618565b151582529183019190830190600101613f7d565b5098975050505050505050565b60208082526052908201527f536572766963654d616e61676572426173652e6f6e6c7952656769737472794360408201527f6f6f7264696e61746f723a2063616c6c6572206973206e6f742074686520726560608201527133b4b9ba393c9031b7b7b93234b730ba37b960711b608082015260a00190565b60005b8381101561404457818101518382015260200161402c565b8381111561207f5750506000910152565b6000815180845261406d816020860160208601614029565b601f01601f19169290920160200192915050565b60018060a01b03831681526040602082015260008251606060408401526140ab60a0840182614055565b90506020840151606084015260408401516080840152809150509392505050565b6000828210156140de576140de613d01565b500390565b6000823560be198336030181126140f957600080fd5b9190910192915050565b6000808335601e1984360301811261411a57600080fd5b8301803591506001600160401b0382111561413457600080fd5b6020019150600681901b36038213156134e557600080fd5b6000808335601e1984360301811261416357600080fd5b83016020810192503590506001600160401b0381111561418257600080fd5b8060061b36038313156134e557600080fd5b8183526000602080850194508260005b858110156139f45781356141b78161348c565b6001600160a01b03168752818301356141cf81613bd6565b6001600160601b03168784015260409687019691909101906001016141a4565b6000808335601e1984360301811261420657600080fd5b83016020810192503590506001600160401b0381111561422557600080fd5b8036038313156134e557600080fd5b6001600160a01b03848116825260406020808401829052838201859052600092606091828601600588901b8701840189875b8a81101561437f57898303605f190184528135368d900360be1901811261428c57600080fd5b8c0160c061429a828061414c565b8287526142aa8388018284614194565b92505050868201356142bb8161348c565b8816858801526142cd828b018361414c565b8683038c88015280835290916000919089015b818310156143115783356142f38161348c565b8b168152838a01358a820152928c0192600192909201918c016142e0565b61431c8c86016130e7565b63ffffffff168c890152608093506143358585016130e7565b63ffffffff811689860152925060a09350614352848601866141ef565b9550925087810384890152614368818685613995565b988a01989750505093870193505050600101614266565b50909b9a5050505050505050505050565b60208152600061178d6020830184614055565b60008235609e198336030181126140f957600080fd5b60208082528181018390526000906040808401600586901b850182018785805b8981101561448857888403603f190185528235368c9003609e190181126143fe578283fd5b8b0160a061440c828061414c565b82885261441c8389018284614194565b925050508882013561442d8161348c565b6001600160a01b0316868a01528188013588870152606061444f8184016130e7565b63ffffffff808216838a0152608092508061446b8487016130e7565b1698909201979097525095880195945050918601916001016143d9565b50919998505050505050505050565b600061ffff808316818114156144af576144af613d01565b6001019392505050565b634e487b7160e01b600052603160045260246000fd5b600082516140f981846020870161402956fea26469706673582212203d97121ceb68f9359b60f408c7def9dd24cbfe31a197d73fd62c6f4736ddac1964736f6c634300080c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000135dda560e946695d6f155dacafc6f1f25c1f5af0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d67000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a800000000000000000000000085814b3ff84da95363c15879b605f3c47fa6a762
-----Decoded View---------------
Arg [0] : __avsDirectory (address): 0x135DDa560e946695d6f155dACaFC6f1F25C1F5AF
Arg [1] : __rewardsCoordinator (address): 0x7750d328b314EfFa365A0402CcfD489B80B0adda
Arg [2] : __registryCoordinator (address): 0x2c23CF71C023CBA700E379c8E73f040c70211D67
Arg [3] : __stakeRegistry (address): 0xCD923EFCac76b82686f9729356bC9d88080666A8
Arg [4] : __signatureChecker (address): 0x85814b3ff84DA95363C15879B605F3C47fA6A762
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000135dda560e946695d6f155dacafc6f1f25c1f5af
Arg [1] : 0000000000000000000000007750d328b314effa365a0402ccfd489b80b0adda
Arg [2] : 0000000000000000000000002c23cf71c023cba700e379c8e73f040c70211d67
Arg [3] : 000000000000000000000000cd923efcac76b82686f9729356bc9d88080666a8
Arg [4] : 00000000000000000000000085814b3ff84da95363c15879b605f3c47fa6a762
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
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.