Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
CSFeeDistributor
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 250 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.24; import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import { AccessControlEnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol"; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { ICSFeeDistributor } from "./interfaces/ICSFeeDistributor.sol"; import { IStETH } from "./interfaces/IStETH.sol"; import { AssetRecoverer } from "./abstract/AssetRecoverer.sol"; import { AssetRecovererLib } from "./lib/AssetRecovererLib.sol"; /// @author madlabman contract CSFeeDistributor is ICSFeeDistributor, Initializable, AccessControlEnumerableUpgradeable, AssetRecoverer { bytes32 public constant RECOVERER_ROLE = keccak256("RECOVERER_ROLE"); IStETH public immutable STETH; address public immutable ACCOUNTING; address public immutable ORACLE; /// @notice Merkle Tree root bytes32 public treeRoot; /// @notice CID of the published Merkle tree string public treeCid; /// @notice Amount of stETH shares sent to the Accounting in favor of the NO mapping(uint256 => uint256) public distributedShares; /// @notice Total Amount of stETH shares available for claiming by NOs uint256 public totalClaimableShares; /// @dev Emitted when fees are distributed event FeeDistributed(uint256 indexed nodeOperatorId, uint256 shares); /// @dev Emitted when distribution data is updated event DistributionDataUpdated( uint256 totalClaimableShares, bytes32 treeRoot, string treeCid ); error ZeroAccountingAddress(); error ZeroStEthAddress(); error ZeroAdminAddress(); error ZeroOracleAddress(); error NotAccounting(); error NotOracle(); error InvalidTreeRoot(); error InvalidTreeCID(); error InvalidShares(); error InvalidProof(); error FeeSharesDecrease(); error NotEnoughShares(); constructor(address stETH, address accounting, address oracle) { if (accounting == address(0)) revert ZeroAccountingAddress(); if (oracle == address(0)) revert ZeroOracleAddress(); if (stETH == address(0)) revert ZeroStEthAddress(); ACCOUNTING = accounting; STETH = IStETH(stETH); ORACLE = oracle; _disableInitializers(); } function initialize(address admin) external initializer { __AccessControlEnumerable_init(); if (admin == address(0)) revert ZeroAdminAddress(); _grantRole(DEFAULT_ADMIN_ROLE, admin); } /// @notice Distribute fees to the Accounting in favor of the Node Operator /// @param nodeOperatorId ID of the Node Operator /// @param shares Total Amount of stETH shares earned as fees /// @param proof Merkle proof of the leaf /// @return sharesToDistribute Amount of stETH shares distributed function distributeFees( uint256 nodeOperatorId, uint256 shares, bytes32[] calldata proof ) external returns (uint256 sharesToDistribute) { if (msg.sender != ACCOUNTING) revert NotAccounting(); sharesToDistribute = getFeesToDistribute(nodeOperatorId, shares, proof); if (sharesToDistribute == 0) { return 0; } if (totalClaimableShares < sharesToDistribute) { revert NotEnoughShares(); } unchecked { totalClaimableShares -= sharesToDistribute; distributedShares[nodeOperatorId] += sharesToDistribute; } STETH.transferShares(ACCOUNTING, sharesToDistribute); emit FeeDistributed(nodeOperatorId, sharesToDistribute); } /// @notice Receive the data of the Merkle tree from the Oracle contract and process it function processOracleReport( bytes32 _treeRoot, string calldata _treeCid, uint256 distributed ) external { if (msg.sender != ORACLE) revert NotOracle(); if ( totalClaimableShares + distributed > STETH.sharesOf(address(this)) ) { revert InvalidShares(); } if (distributed > 0) { if (bytes(_treeCid).length == 0) revert InvalidTreeCID(); if (keccak256(bytes(_treeCid)) == keccak256(bytes(treeCid))) revert InvalidTreeCID(); if (_treeRoot == bytes32(0)) revert InvalidTreeRoot(); if (_treeRoot == treeRoot) revert InvalidTreeRoot(); // Doesn't overflow because of the very first check. unchecked { totalClaimableShares += distributed; } treeRoot = _treeRoot; treeCid = _treeCid; emit DistributionDataUpdated( totalClaimableShares, _treeRoot, _treeCid ); } } /// @notice Recover ERC20 tokens (except for stETH) from the contract /// @dev Any stETH transferred to feeDistributor is treated as a donation and can not be recovered /// @param token Address of the ERC20 token to recover /// @param amount Amount of the ERC20 token to recover function recoverERC20(address token, uint256 amount) external override { _onlyRecoverer(); if (token == address(STETH)) { revert NotAllowedToRecover(); } AssetRecovererLib.recoverERC20(token, amount); } /// @notice Get the Amount of stETH shares that are pending to be distributed /// @return pendingShares Amount shares that are pending to distribute function pendingSharesToDistribute() external view returns (uint256) { return STETH.sharesOf(address(this)) - totalClaimableShares; } /// @notice Get the Amount of stETH shares that can be distributed in favor of the Node Operator /// @param nodeOperatorId ID of the Node Operator /// @param shares Total Amount of stETH shares earned as fees /// @param proof Merkle proof of the leaf /// @return sharesToDistribute Amount of stETH shares that can be distributed function getFeesToDistribute( uint256 nodeOperatorId, uint256 shares, bytes32[] calldata proof ) public view returns (uint256 sharesToDistribute) { bool isValid = MerkleProof.verifyCalldata( proof, treeRoot, hashLeaf(nodeOperatorId, shares) ); if (!isValid) revert InvalidProof(); uint256 _distributedShares = distributedShares[nodeOperatorId]; if (_distributedShares > shares) { // This error means the fee oracle brought invalid data. revert FeeSharesDecrease(); } unchecked { sharesToDistribute = shares - _distributedShares; } } /// @notice Get a hash of a leaf /// @param nodeOperatorId ID of the Node Operator /// @param shares Amount of stETH shares /// @return Hash of the leaf /// @dev Double hash the leaf to prevent second preimage attacks function hashLeaf( uint256 nodeOperatorId, uint256 shares ) public pure returns (bytes32) { return keccak256( bytes.concat(keccak256(abi.encode(nodeOperatorId, shares))) ); } function _onlyRecoverer() internal view override { _checkRole(RECOVERER_ROLE); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.20; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the Merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates Merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** *@dev The multiproof provided is not valid. */ error MerkleProofInvalidMultiproof(); /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. if (leavesLen + proofLen != totalHashes + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { if (proofPos != proofLen) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. if (leavesLen + proofLen != totalHashes + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { if (proofPos != proofLen) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Sorts the pair (a, b) and hashes the result. */ function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } /** * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory. */ function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol"; import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerable, AccessControlUpgradeable { using EnumerableSet for EnumerableSet.AddressSet; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControlEnumerable struct AccessControlEnumerableStorage { mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlEnumerable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlEnumerableStorageLocation = 0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000; function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $) { assembly { $.slot := AccessControlEnumerableStorageLocation } } function __AccessControlEnumerable_init() internal onlyInitializing { } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); return $._roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); return $._roleMembers[role].length(); } /** * @dev Overload {AccessControl-_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); bool granted = super._grantRole(role, account); if (granted) { $._roleMembers[role].add(account); } return granted; } /** * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage(); bool revoked = super._revokeRole(role, account); if (revoked) { $._roleMembers[role].remove(account); } return revoked; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @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] * ```solidity * 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 Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 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. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._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. * * 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. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * 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. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._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() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @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. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 import { IAssetRecovererLib } from "../lib/AssetRecovererLib.sol"; pragma solidity 0.8.24; interface ICSFeeDistributor is IAssetRecovererLib { function getFeesToDistribute( uint256 nodeOperatorId, uint256 shares, bytes32[] calldata proof ) external view returns (uint256); function distributeFees( uint256 nodeOperatorId, uint256 shares, bytes32[] calldata proof ) external returns (uint256); function processOracleReport( bytes32 _treeRoot, string calldata _treeCid, uint256 _distributedShares ) external; /// @notice Returns the amount of shares that are pending to be distributed function pendingSharesToDistribute() external view returns (uint256); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.24; /** * @title Interface defining ERC20-compatible StETH token */ interface IStETH { /** * @notice Get stETH amount by the provided shares amount * @param _sharesAmount shares amount * @dev dual to `getSharesByPooledEth`. */ function getPooledEthByShares( uint256 _sharesAmount ) external view returns (uint256); /** * @notice Get shares amount by the provided stETH amount * @param _pooledEthAmount stETH amount * @dev dual to `getPooledEthByShares`. */ function getSharesByPooledEth( uint256 _pooledEthAmount ) external view returns (uint256); /** * @notice Get shares amount of the provided account * @param _account provided account address. */ function sharesOf(address _account) external view returns (uint256); function balanceOf(address _account) external view returns (uint256); /** * @notice Transfer `_sharesAmount` stETH shares from `_sender` to `_receiver` using allowance. */ function transferSharesFrom( address _sender, address _recipient, uint256 _sharesAmount ) external returns (uint256); /** * @notice Moves `_sharesAmount` token shares from the caller's account to the `_recipient` account. */ function transferShares( address _recipient, uint256 _sharesAmount ) external returns (uint256); /** * @notice Moves `_pooledEthAmount` stETH from the caller's account to the `_recipient` account. */ function transfer( address _recipient, uint256 _amount ) external returns (bool); /** * @notice Moves `_pooledEthAmount` stETH from the `_sender` account to the `_recipient` account. */ function transferFrom( address _sender, address _recipient, uint256 _amount ) external returns (bool); function approve(address _spender, uint256 _amount) external returns (bool); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; function allowance( address _owner, address _spender ) external view returns (uint256); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.24; import { AssetRecovererLib } from "../lib/AssetRecovererLib.sol"; /// @title AssetRecoverer /// @dev Abstract contract providing mechanisms for recovering various asset types (ETH, ERC20, ERC721, ERC1155) from a contract. /// This contract is designed to allow asset recovery by an authorized address by implementing the onlyRecovererRole guardian /// @notice Assets can be sent only to the `msg.sender` abstract contract AssetRecoverer { /// @dev Allows sender to recover Ether held by the contract /// Emits an EtherRecovered event upon success function recoverEther() external { _onlyRecoverer(); AssetRecovererLib.recoverEther(); } /// @dev Allows sender to recover ERC20 tokens held by the contract /// @param token The address of the ERC20 token to recover /// Emits an ERC20Recovered event upon success /// Optionally, the inheriting contract can override this function to add additional restrictions function recoverERC20(address token, uint256 amount) external virtual { _onlyRecoverer(); AssetRecovererLib.recoverERC20(token, amount); } /// @dev Allows sender to recover ERC721 tokens held by the contract /// @param token The address of the ERC721 token to recover /// @param tokenId The token ID of the ERC721 token to recover /// Emits an ERC721Recovered event upon success function recoverERC721(address token, uint256 tokenId) external { _onlyRecoverer(); AssetRecovererLib.recoverERC721(token, tokenId); } /// @dev Allows sender to recover ERC1155 tokens held by the contract. /// @param token The address of the ERC1155 token to recover. /// @param tokenId The token ID of the ERC1155 token to recover. /// Emits an ERC1155Recovered event upon success. function recoverERC1155(address token, uint256 tokenId) external { _onlyRecoverer(); AssetRecovererLib.recoverERC1155(token, tokenId); } /// @dev Guardian to restrict access to the recover methods. /// Should be implemented by the inheriting contract function _onlyRecoverer() internal view virtual; }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.24; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { ILido } from "../interfaces/ILido.sol"; interface IAssetRecovererLib { event EtherRecovered(address indexed recipient, uint256 amount); event ERC20Recovered( address indexed token, address indexed recipient, uint256 amount ); event StETHSharesRecovered(address indexed recipient, uint256 shares); event ERC721Recovered( address indexed token, uint256 tokenId, address indexed recipient ); event ERC1155Recovered( address indexed token, uint256 tokenId, address indexed recipient, uint256 amount ); error FailedToSendEther(); error NotAllowedToRecover(); } /* * @title AssetRecovererLib * @dev Library providing mechanisms for recovering various asset types (ETH, ERC20, ERC721, ERC1155). * This library is designed to be used by a contract that implements the AssetRecoverer interface. */ library AssetRecovererLib { using SafeERC20 for IERC20; /** * @dev Allows the sender to recover Ether held by the contract. * Emits an EtherRecovered event upon success. */ function recoverEther() external { uint256 amount = address(this).balance; (bool success, ) = msg.sender.call{ value: amount }(""); if (!success) revert IAssetRecovererLib.FailedToSendEther(); emit IAssetRecovererLib.EtherRecovered(msg.sender, amount); } /** * @dev Allows the sender to recover ERC20 tokens held by the contract. * @param token The address of the ERC20 token to recover. * @param amount The amount of the ERC20 token to recover. * Emits an ERC20Recovered event upon success. */ function recoverERC20(address token, uint256 amount) external { IERC20(token).safeTransfer(msg.sender, amount); emit IAssetRecovererLib.ERC20Recovered(token, msg.sender, amount); } /** * @dev Allows the sender to recover stETH shares held by the contract. * The use of a separate method for stETH is to avoid rounding problems when converting shares to stETH. * @param lido The address of the Lido contract. * @param shares The amount of stETH shares to recover. * Emits an StETHRecovered event upon success. */ function recoverStETHShares(address lido, uint256 shares) external { ILido(lido).transferShares(msg.sender, shares); emit IAssetRecovererLib.StETHSharesRecovered(msg.sender, shares); } /** * @dev Allows the sender to recover ERC721 tokens held by the contract. * @param token The address of the ERC721 token to recover. * @param tokenId The token ID of the ERC721 token to recover. * Emits an ERC721Recovered event upon success. */ function recoverERC721(address token, uint256 tokenId) external { IERC721(token).safeTransferFrom(address(this), msg.sender, tokenId); emit IAssetRecovererLib.ERC721Recovered(token, tokenId, msg.sender); } /** * @dev Allows the sender to recover ERC1155 tokens held by the contract. * @param token The address of the ERC1155 token to recover. * @param tokenId The token ID of the ERC1155 token to recover. * Emits an ERC1155Recovered event upon success. */ function recoverERC1155(address token, uint256 tokenId) external { uint256 amount = IERC1155(token).balanceOf(address(this), tokenId); IERC1155(token).safeTransferFrom({ from: address(this), to: msg.sender, id: tokenId, value: amount, data: "" }); emit IAssetRecovererLib.ERC1155Recovered( token, tokenId, msg.sender, amount ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @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. * * ```solidity * 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 is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @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._positions[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 cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 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 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[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._positions[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) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // 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 in 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: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../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; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @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); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.24; import { IStETH } from "./IStETH.sol"; /** * @title Interface defining Lido contract */ interface ILido is IStETH { function STAKING_CONTROL_ROLE() external view returns (bytes32); function submit(address _referal) external payable returns (uint256); function deposit( uint256 _maxDepositsCount, uint256 _stakingModuleId, bytes calldata _depositCalldata ) external; function removeStakingLimit() external; function kernel() external returns (address); function sharesOf(address _account) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @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. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ 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]. * * CAUTION: See Security Considerations above. */ 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 v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // 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 FailedInnerCall(); } } }
{ "remappings": [ "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/", "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/", "forge-std/=node_modules/forge-std/src/", "ds-test/=node_modules/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "openzeppelin-contracts-v4.4/=lib/openzeppelin-contracts-v4.4/contracts/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 250 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": { "src/lib/AssetRecovererLib.sol": { "AssetRecovererLib": "0xD72E84a64b676097254cDA079d8B7b63C7988ECa" }, "src/lib/NOAddresses.sol": { "NOAddresses": "0x449581f92CaB1c84e210a2304E041E116f5f8D69" }, "src/lib/QueueLib.sol": { "QueueLib": "0x06AA73BAbC9c8bb8c7C2bee1f714a399d49b81bc" } } }
[{"inputs":[{"internalType":"address","name":"stETH","type":"address"},{"internalType":"address","name":"accounting","type":"address"},{"internalType":"address","name":"oracle","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"FailedToSendEther","type":"error"},{"inputs":[],"name":"FeeSharesDecrease","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"InvalidShares","type":"error"},{"inputs":[],"name":"InvalidTreeCID","type":"error"},{"inputs":[],"name":"InvalidTreeRoot","type":"error"},{"inputs":[],"name":"NotAccounting","type":"error"},{"inputs":[],"name":"NotAllowedToRecover","type":"error"},{"inputs":[],"name":"NotEnoughShares","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotOracle","type":"error"},{"inputs":[],"name":"ZeroAccountingAddress","type":"error"},{"inputs":[],"name":"ZeroAdminAddress","type":"error"},{"inputs":[],"name":"ZeroOracleAddress","type":"error"},{"inputs":[],"name":"ZeroStEthAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalClaimableShares","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"treeRoot","type":"bytes32"},{"indexed":false,"internalType":"string","name":"treeCid","type":"string"}],"name":"DistributionDataUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC1155Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"ERC721Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EtherRecovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"FeeDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"StETHSharesRecovered","type":"event"},{"inputs":[],"name":"ACCOUNTING","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ORACLE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RECOVERER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STETH","outputs":[{"internalType":"contract IStETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"distributeFees","outputs":[{"internalType":"uint256","name":"sharesToDistribute","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"distributedShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"getFeesToDistribute","outputs":[{"internalType":"uint256","name":"sharesToDistribute","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"hashLeaf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pendingSharesToDistribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_treeRoot","type":"bytes32"},{"internalType":"string","name":"_treeCid","type":"string"},{"internalType":"uint256","name":"distributed","type":"uint256"}],"name":"processOracleReport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"recoverERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"recoverERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"recoverEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalClaimableShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treeCid","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treeRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60e060405234801562000010575f80fd5b5060405162001a0f38038062001a0f8339810160408190526200003391620001a7565b6001600160a01b0382166200005b576040516368ea2bc160e01b815260040160405180910390fd5b6001600160a01b038116620000835760405163dc6d352160e01b815260040160405180910390fd5b6001600160a01b038316620000ab5760405163349b663960e21b815260040160405180910390fd5b6001600160a01b0380831660a052838116608052811660c052620000ce620000d7565b505050620001ee565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620001285760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620001885780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b80516001600160a01b0381168114620001a2575f80fd5b919050565b5f805f60608486031215620001ba575f80fd5b620001c5846200018b565b9250620001d5602085016200018b565b9150620001e5604085016200018b565b90509250925092565b60805160a05160c0516117c56200024a5f395f8181610251015261095a01525f81816102c70152818161045b015261050b01525f81816103cf0152818161053a0152818161084a015281816109ad0152610cfa01526117c55ff3fe608060405234801561000f575f80fd5b50600436106101a1575f3560e01c8063819d4cc6116100f3578063c4d66de811610093578063d547741f1161006e578063d547741f146103b7578063e00bfe50146103ca578063ea6301ab146103f1578063fe3c9b9b14610410575f80fd5b8063c4d66de814610389578063ca15c8731461039c578063d257cf2a146103af575f80fd5b806391d14854116100ce57806391d1485414610335578063a217fddf14610348578063acf1c9481461034f578063b66cf05814610376575f80fd5b8063819d4cc6146102fc5780638980f11f1461030f5780639010d07c14610322575f80fd5b806338013f021161015e5780635c654ad9116101395780635c654ad91461029c5780635e8e8f6f146102af5780636dc3f2bd146102c25780637e9f27ad146102e9575f80fd5b806338013f021461024c57806347d17d9d1461028b57806352d8bfc214610294575f80fd5b806301ffc9a7146101a557806314dc6c14146101cd57806321893f7b146101e3578063248a9ca3146101f65780632f2ff15d1461022457806336568abe14610239575b5f80fd5b6101b86101b33660046112ea565b610425565b60405190151581526020015b60405180910390f35b6101d55f5481565b6040519081526020016101c4565b6101d56101f1366004611311565b61044f565b6101d561020436600461138d565b5f9081525f80516020611799833981519152602052604090206001015490565b6102376102323660046113bf565b6105e8565b005b6102376102473660046113bf565b61061e565b6102737f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101c4565b6101d560035481565b610237610656565b6102376102aa3660046113e9565b6106b2565b6101d56102bd366004611311565b61072d565b6102737f000000000000000000000000000000000000000000000000000000000000000081565b6101d56102f7366004611411565b6107a0565b61023761030a3660046113e9565b6107f1565b61023761031d3660046113e9565b610840565b610273610330366004611411565b6108e1565b6101b86103433660046113bf565b610919565b6101d55f81565b6101d57fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc81565b610237610384366004611431565b61094f565b6102376103973660046114ac565b610b5b565b6101d56103aa36600461138d565b610c99565b6101d5610cd7565b6102376103c53660046113bf565b610d72565b6102737f000000000000000000000000000000000000000000000000000000000000000081565b6101d56103ff36600461138d565b60026020525f908152604090205481565b610418610da2565b6040516101c491906114c5565b5f6001600160e01b03198216635a05180f60e01b1480610449575061044982610e2e565b92915050565b5f336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610499576040516318d9f40960e31b815260040160405180910390fd5b6104a58585858561072d565b9050805f036104b557505f6105e0565b8060035410156104d857604051633c57b48560e21b815260040160405180910390fd5b6003805482900390555f858152600260205260409081902080548301905551638fcb4e5b60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f00000000000000000000000000000000000000000000000000000000000000001690638fcb4e5b906044016020604051808303815f875af1158015610580573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105a49190611511565b50847f61930a6c1553eab59d5766da6e1bab8eba982aec848ae7683452f4a6423b6e4a826040516105d791815260200190565b60405180910390a25b949350505050565b5f8281525f80516020611799833981519152602052604090206001015461060e81610e62565b6106188383610e6f565b50505050565b6001600160a01b03811633146106475760405163334bd91960e11b815260040160405180910390fd5b6106518282610ec4565b505050565b61065e610f10565b73d72e84a64b676097254cda079d8b7b63c7988eca6352d8bfc26040518163ffffffff1660e01b81526004015f6040518083038186803b1580156106a0575f80fd5b505af4158015610618573d5f803e3d5ffd5b6106ba610f10565b604051635c654ad960e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90635c654ad9906044015b5f6040518083038186803b158015610713575f80fd5b505af4158015610725573d5f803e3d5ffd5b505050505050565b5f8061074584845f546107408a8a6107a0565b610f3b565b905080610765576040516309bde33960e01b815260040160405180910390fd5b5f868152600260205260409020548581111561079457604051636096ce8160e11b815260040160405180910390fd5b90940395945050505050565b60408051602081018490529081018290525f9060600160408051601f198184030181528282528051602091820120908301520160405160208183030381529060405280519060200120905092915050565b6107f9610f10565b6040516340cea66360e11b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca9063819d4cc6906044016106fd565b610848610f10565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361089a576040516319efe5d760e21b815260040160405180910390fd5b604051638980f11f60e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90638980f11f906044016106fd565b5f8281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320006020819052604082206105e09084610f52565b5f9182525f80516020611799833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461099857604051631bc2178f60e01b815260040160405180910390fd5b604051633d7ad0b760e21b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f5eb42dc90602401602060405180830381865afa1580156109fa573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a1e9190611511565b81600354610a2c919061153c565b1115610a4b57604051636edcc52360e01b815260040160405180910390fd5b8015610618575f829003610a71576040516272916d60e51b815260040160405180910390fd5b6001604051610a809190611587565b60405180910390208383604051610a989291906115f9565b604051809103902003610abd576040516272916d60e51b815260040160405180910390fd5b83610adb576040516357e86a3360e01b815260040160405180910390fd5b5f548403610afc576040516357e86a3360e01b815260040160405180910390fd5b60038054820190555f8490556001610b15838583611667565b507f26dec7cc117e9b3907dc1f90d2dc5f6e04dbb9f285f5898be2c82ec524dcd424600354858585604051610b4d9493929190611721565b60405180910390a150505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610ba05750825b90505f8267ffffffffffffffff166001148015610bbc5750303b155b905081158015610bca575080155b15610be85760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c1257845460ff60401b1916600160401b1785555b610c1a610f5d565b6001600160a01b038616610c4157604051633ef39b8160e01b815260040160405180910390fd5b610c4b5f87610e6f565b50831561072557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a1505050505050565b5f8181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000602081905260408220610cd090610f65565b9392505050565b600354604051633d7ad0b760e21b81523060048201525f91906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f5eb42dc90602401602060405180830381865afa158015610d3f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d639190611511565b610d6d919061175d565b905090565b5f8281525f805160206117998339815191526020526040902060010154610d9881610e62565b6106188383610ec4565b60018054610daf9061154f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ddb9061154f565b8015610e265780601f10610dfd57610100808354040283529160200191610e26565b820191905f5260205f20905b815481529060010190602001808311610e0957829003601f168201915b505050505081565b5f6001600160e01b03198216637965db0b60e01b148061044957506301ffc9a760e01b6001600160e01b0319831614610449565b610e6c8133610f6e565b50565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081610e9c8585610faf565b905080156105e0575f858152602083905260409020610ebb9085611050565b50949350505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081610ef18585611064565b905080156105e0575f858152602083905260409020610ebb90856110dd565b610f397fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc610e62565b565b5f82610f488686856110f1565b1495945050505050565b5f610cd08383611129565b610f3961114f565b5f610449825490565b610f788282610919565b610fab5760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440160405180910390fd5b5050565b5f5f80516020611799833981519152610fc88484610919565b611047575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055610ffd3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610449565b5f915050610449565b5f610cd0836001600160a01b038416611198565b5f5f8051602061179983398151915261107d8484610919565b15611047575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610449565b5f610cd0836001600160a01b0384166111e4565b5f81815b84811015610ebb5761111f8287878481811061111357611113611770565b905060200201356112be565b91506001016110f5565b5f825f01828154811061113e5761113e611770565b905f5260205f200154905092915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610f3957604051631afcd79f60e31b815260040160405180910390fd5b5f8181526001830160205260408120546111dd57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610449565b505f610449565b5f8181526001830160205260408120548015611047575f61120660018361175d565b85549091505f906112199060019061175d565b9050808214611278575f865f01828154811061123757611237611770565b905f5260205f200154905080875f01848154811061125757611257611770565b5f918252602080832090910192909255918252600188019052604090208390555b855486908061128957611289611784565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610449565b5f8183106112d8575f828152602084905260409020610cd0565b5f838152602083905260409020610cd0565b5f602082840312156112fa575f80fd5b81356001600160e01b031981168114610cd0575f80fd5b5f805f8060608587031215611324575f80fd5b8435935060208501359250604085013567ffffffffffffffff80821115611349575f80fd5b818701915087601f83011261135c575f80fd5b81358181111561136a575f80fd5b8860208260051b850101111561137e575f80fd5b95989497505060200194505050565b5f6020828403121561139d575f80fd5b5035919050565b80356001600160a01b03811681146113ba575f80fd5b919050565b5f80604083850312156113d0575f80fd5b823591506113e0602084016113a4565b90509250929050565b5f80604083850312156113fa575f80fd5b611403836113a4565b946020939093013593505050565b5f8060408385031215611422575f80fd5b50508035926020909101359150565b5f805f8060608587031215611444575f80fd5b84359350602085013567ffffffffffffffff80821115611462575f80fd5b818701915087601f830112611475575f80fd5b813581811115611483575f80fd5b886020828501011115611494575f80fd5b95986020929092019750949560400135945092505050565b5f602082840312156114bc575f80fd5b610cd0826113a4565b5f602080835283518060208501525f5b818110156114f1578581018301518582016040015282016114d5565b505f604082860101526040601f19601f8301168501019250505092915050565b5f60208284031215611521575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561044957610449611528565b600181811c9082168061156357607f821691505b60208210810361158157634e487b7160e01b5f52602260045260245ffd5b50919050565b5f8083546115948161154f565b600182811680156115ac57600181146115c1576115ed565b60ff19841687528215158302870194506115ed565b875f526020805f205f5b858110156115e45781548a8201529084019082016115cb565b50505082870194505b50929695505050505050565b818382375f9101908152919050565b634e487b7160e01b5f52604160045260245ffd5b601f82111561065157805f5260205f20601f840160051c810160208510156116415750805b601f840160051c820191505b81811015611660575f815560010161164d565b5050505050565b67ffffffffffffffff83111561167f5761167f611608565b6116938361168d835461154f565b8361161c565b5f601f8411600181146116c4575f85156116ad5750838201355b5f19600387901b1c1916600186901b178355611660565b5f83815260208120601f198716915b828110156116f357868501358255602094850194600190920191016116d3565b508682101561170f575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b84815283602082015260606040820152816060820152818360808301375f818301608090810191909152601f909201601f191601019392505050565b8181038181111561044957610449611528565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52603160045260245ffdfe02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800a164736f6c6343000818000a0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034000000000000000000000000c093e53e8f4b55a223c18a2da6fa00e60dd5efe1000000000000000000000000af57326c7d513085051b50912d51809ecc5d98ee
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106101a1575f3560e01c8063819d4cc6116100f3578063c4d66de811610093578063d547741f1161006e578063d547741f146103b7578063e00bfe50146103ca578063ea6301ab146103f1578063fe3c9b9b14610410575f80fd5b8063c4d66de814610389578063ca15c8731461039c578063d257cf2a146103af575f80fd5b806391d14854116100ce57806391d1485414610335578063a217fddf14610348578063acf1c9481461034f578063b66cf05814610376575f80fd5b8063819d4cc6146102fc5780638980f11f1461030f5780639010d07c14610322575f80fd5b806338013f021161015e5780635c654ad9116101395780635c654ad91461029c5780635e8e8f6f146102af5780636dc3f2bd146102c25780637e9f27ad146102e9575f80fd5b806338013f021461024c57806347d17d9d1461028b57806352d8bfc214610294575f80fd5b806301ffc9a7146101a557806314dc6c14146101cd57806321893f7b146101e3578063248a9ca3146101f65780632f2ff15d1461022457806336568abe14610239575b5f80fd5b6101b86101b33660046112ea565b610425565b60405190151581526020015b60405180910390f35b6101d55f5481565b6040519081526020016101c4565b6101d56101f1366004611311565b61044f565b6101d561020436600461138d565b5f9081525f80516020611799833981519152602052604090206001015490565b6102376102323660046113bf565b6105e8565b005b6102376102473660046113bf565b61061e565b6102737f000000000000000000000000af57326c7d513085051b50912d51809ecc5d98ee81565b6040516001600160a01b0390911681526020016101c4565b6101d560035481565b610237610656565b6102376102aa3660046113e9565b6106b2565b6101d56102bd366004611311565b61072d565b6102737f000000000000000000000000c093e53e8f4b55a223c18a2da6fa00e60dd5efe181565b6101d56102f7366004611411565b6107a0565b61023761030a3660046113e9565b6107f1565b61023761031d3660046113e9565b610840565b610273610330366004611411565b6108e1565b6101b86103433660046113bf565b610919565b6101d55f81565b6101d57fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc81565b610237610384366004611431565b61094f565b6102376103973660046114ac565b610b5b565b6101d56103aa36600461138d565b610c99565b6101d5610cd7565b6102376103c53660046113bf565b610d72565b6102737f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c9503481565b6101d56103ff36600461138d565b60026020525f908152604090205481565b610418610da2565b6040516101c491906114c5565b5f6001600160e01b03198216635a05180f60e01b1480610449575061044982610e2e565b92915050565b5f336001600160a01b037f000000000000000000000000c093e53e8f4b55a223c18a2da6fa00e60dd5efe11614610499576040516318d9f40960e31b815260040160405180910390fd5b6104a58585858561072d565b9050805f036104b557505f6105e0565b8060035410156104d857604051633c57b48560e21b815260040160405180910390fd5b6003805482900390555f858152600260205260409081902080548301905551638fcb4e5b60e01b81526001600160a01b037f000000000000000000000000c093e53e8f4b55a223c18a2da6fa00e60dd5efe181166004830152602482018390527f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950341690638fcb4e5b906044016020604051808303815f875af1158015610580573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105a49190611511565b50847f61930a6c1553eab59d5766da6e1bab8eba982aec848ae7683452f4a6423b6e4a826040516105d791815260200190565b60405180910390a25b949350505050565b5f8281525f80516020611799833981519152602052604090206001015461060e81610e62565b6106188383610e6f565b50505050565b6001600160a01b03811633146106475760405163334bd91960e11b815260040160405180910390fd5b6106518282610ec4565b505050565b61065e610f10565b73d72e84a64b676097254cda079d8b7b63c7988eca6352d8bfc26040518163ffffffff1660e01b81526004015f6040518083038186803b1580156106a0575f80fd5b505af4158015610618573d5f803e3d5ffd5b6106ba610f10565b604051635c654ad960e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90635c654ad9906044015b5f6040518083038186803b158015610713575f80fd5b505af4158015610725573d5f803e3d5ffd5b505050505050565b5f8061074584845f546107408a8a6107a0565b610f3b565b905080610765576040516309bde33960e01b815260040160405180910390fd5b5f868152600260205260409020548581111561079457604051636096ce8160e11b815260040160405180910390fd5b90940395945050505050565b60408051602081018490529081018290525f9060600160408051601f198184030181528282528051602091820120908301520160405160208183030381529060405280519060200120905092915050565b6107f9610f10565b6040516340cea66360e11b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca9063819d4cc6906044016106fd565b610848610f10565b7f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b0316826001600160a01b03160361089a576040516319efe5d760e21b815260040160405180910390fd5b604051638980f11f60e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90638980f11f906044016106fd565b5f8281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320006020819052604082206105e09084610f52565b5f9182525f80516020611799833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b336001600160a01b037f000000000000000000000000af57326c7d513085051b50912d51809ecc5d98ee161461099857604051631bc2178f60e01b815260040160405180910390fd5b604051633d7ad0b760e21b81523060048201527f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b03169063f5eb42dc90602401602060405180830381865afa1580156109fa573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a1e9190611511565b81600354610a2c919061153c565b1115610a4b57604051636edcc52360e01b815260040160405180910390fd5b8015610618575f829003610a71576040516272916d60e51b815260040160405180910390fd5b6001604051610a809190611587565b60405180910390208383604051610a989291906115f9565b604051809103902003610abd576040516272916d60e51b815260040160405180910390fd5b83610adb576040516357e86a3360e01b815260040160405180910390fd5b5f548403610afc576040516357e86a3360e01b815260040160405180910390fd5b60038054820190555f8490556001610b15838583611667565b507f26dec7cc117e9b3907dc1f90d2dc5f6e04dbb9f285f5898be2c82ec524dcd424600354858585604051610b4d9493929190611721565b60405180910390a150505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610ba05750825b90505f8267ffffffffffffffff166001148015610bbc5750303b155b905081158015610bca575080155b15610be85760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c1257845460ff60401b1916600160401b1785555b610c1a610f5d565b6001600160a01b038616610c4157604051633ef39b8160e01b815260040160405180910390fd5b610c4b5f87610e6f565b50831561072557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a1505050505050565b5f8181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000602081905260408220610cd090610f65565b9392505050565b600354604051633d7ad0b760e21b81523060048201525f91906001600160a01b037f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034169063f5eb42dc90602401602060405180830381865afa158015610d3f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d639190611511565b610d6d919061175d565b905090565b5f8281525f805160206117998339815191526020526040902060010154610d9881610e62565b6106188383610ec4565b60018054610daf9061154f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ddb9061154f565b8015610e265780601f10610dfd57610100808354040283529160200191610e26565b820191905f5260205f20905b815481529060010190602001808311610e0957829003601f168201915b505050505081565b5f6001600160e01b03198216637965db0b60e01b148061044957506301ffc9a760e01b6001600160e01b0319831614610449565b610e6c8133610f6e565b50565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081610e9c8585610faf565b905080156105e0575f858152602083905260409020610ebb9085611050565b50949350505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081610ef18585611064565b905080156105e0575f858152602083905260409020610ebb90856110dd565b610f397fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc610e62565b565b5f82610f488686856110f1565b1495945050505050565b5f610cd08383611129565b610f3961114f565b5f610449825490565b610f788282610919565b610fab5760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440160405180910390fd5b5050565b5f5f80516020611799833981519152610fc88484610919565b611047575f848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055610ffd3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610449565b5f915050610449565b5f610cd0836001600160a01b038416611198565b5f5f8051602061179983398151915261107d8484610919565b15611047575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610449565b5f610cd0836001600160a01b0384166111e4565b5f81815b84811015610ebb5761111f8287878481811061111357611113611770565b905060200201356112be565b91506001016110f5565b5f825f01828154811061113e5761113e611770565b905f5260205f200154905092915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610f3957604051631afcd79f60e31b815260040160405180910390fd5b5f8181526001830160205260408120546111dd57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610449565b505f610449565b5f8181526001830160205260408120548015611047575f61120660018361175d565b85549091505f906112199060019061175d565b9050808214611278575f865f01828154811061123757611237611770565b905f5260205f200154905080875f01848154811061125757611257611770565b5f918252602080832090910192909255918252600188019052604090208390555b855486908061128957611289611784565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610449565b5f8183106112d8575f828152602084905260409020610cd0565b5f838152602083905260409020610cd0565b5f602082840312156112fa575f80fd5b81356001600160e01b031981168114610cd0575f80fd5b5f805f8060608587031215611324575f80fd5b8435935060208501359250604085013567ffffffffffffffff80821115611349575f80fd5b818701915087601f83011261135c575f80fd5b81358181111561136a575f80fd5b8860208260051b850101111561137e575f80fd5b95989497505060200194505050565b5f6020828403121561139d575f80fd5b5035919050565b80356001600160a01b03811681146113ba575f80fd5b919050565b5f80604083850312156113d0575f80fd5b823591506113e0602084016113a4565b90509250929050565b5f80604083850312156113fa575f80fd5b611403836113a4565b946020939093013593505050565b5f8060408385031215611422575f80fd5b50508035926020909101359150565b5f805f8060608587031215611444575f80fd5b84359350602085013567ffffffffffffffff80821115611462575f80fd5b818701915087601f830112611475575f80fd5b813581811115611483575f80fd5b886020828501011115611494575f80fd5b95986020929092019750949560400135945092505050565b5f602082840312156114bc575f80fd5b610cd0826113a4565b5f602080835283518060208501525f5b818110156114f1578581018301518582016040015282016114d5565b505f604082860101526040601f19601f8301168501019250505092915050565b5f60208284031215611521575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561044957610449611528565b600181811c9082168061156357607f821691505b60208210810361158157634e487b7160e01b5f52602260045260245ffd5b50919050565b5f8083546115948161154f565b600182811680156115ac57600181146115c1576115ed565b60ff19841687528215158302870194506115ed565b875f526020805f205f5b858110156115e45781548a8201529084019082016115cb565b50505082870194505b50929695505050505050565b818382375f9101908152919050565b634e487b7160e01b5f52604160045260245ffd5b601f82111561065157805f5260205f20601f840160051c810160208510156116415750805b601f840160051c820191505b81811015611660575f815560010161164d565b5050505050565b67ffffffffffffffff83111561167f5761167f611608565b6116938361168d835461154f565b8361161c565b5f601f8411600181146116c4575f85156116ad5750838201355b5f19600387901b1c1916600186901b178355611660565b5f83815260208120601f198716915b828110156116f357868501358255602094850194600190920191016116d3565b508682101561170f575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b84815283602082015260606040820152816060820152818360808301375f818301608090810191909152601f909201601f191601019392505050565b8181038181111561044957610449611528565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52603160045260245ffdfe02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800a164736f6c6343000818000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034000000000000000000000000c093e53e8f4b55a223c18a2da6fa00e60dd5efe1000000000000000000000000af57326c7d513085051b50912d51809ecc5d98ee
-----Decoded View---------------
Arg [0] : stETH (address): 0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034
Arg [1] : accounting (address): 0xc093e53e8F4b55A223c18A2Da6fA00e60DD5EFE1
Arg [2] : oracle (address): 0xaF57326C7d513085051b50912D51809ECC5d98Ee
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034
Arg [1] : 000000000000000000000000c093e53e8f4b55a223c18a2da6fa00e60dd5efe1
Arg [2] : 000000000000000000000000af57326c7d513085051b50912d51809ecc5d98ee
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.