{"sources":{"contracts/EigenpieStaking.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\nimport { UtilLib } from \"./utils/UtilLib.sol\";\nimport { TransferHelper } from \"./utils/TransferHelper.sol\";\nimport { EigenpieConstants } from \"./utils/EigenpieConstants.sol\";\nimport { SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport { EigenpieConfigRoleChecker, IEigenpieConfig } from \"./utils/EigenpieConfigRoleChecker.sol\";\nimport { IMintableERC20 } from \"./interfaces/IMintableERC20.sol\";\nimport { INodeDelegator } from \"./interfaces/INodeDelegator.sol\";\nimport { IEigenpieStaking } from \"./interfaces/IEigenpieStaking.sol\";\nimport { IMLRT } from \"./interfaces/IMLRT.sol\";\nimport { IEigenpiePreDepositHelper } from \"./interfaces/IEigenpiePreDepositHelper.sol\";\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { PausableUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\n\n/// @title EigenpieStaking - Deposit Pool Contract for LSTs\n/// @notice Handles LST asset deposits\ncontract EigenpieStaking is\n    IEigenpieStaking,\n    EigenpieConfigRoleChecker,\n    PausableUpgradeable,\n    ReentrancyGuardUpgradeable\n{\n    using SafeERC20 for IERC20;\n\n    uint256 public maxNodeDelegatorLimit;\n    uint256 public minAmountToDeposit;\n\n    mapping(address => uint256) public isNodeDelegator; // 0: not a node delegator, 1: is a node delegator\n    address[] public nodeDelegatorQueue;\n    //1st upgrade\n    bool public isPreDeposit;\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    receive() external payable { }\n\n    /// @dev Initializes the contract\n    /// @param eigenpieConfigAddr eigenpieConfig address\n    function initialize(address eigenpieConfigAddr) external initializer {\n        UtilLib.checkNonZeroAddress(eigenpieConfigAddr);\n\n        __Pausable_init();\n        __ReentrancyGuard_init();\n\n        maxNodeDelegatorLimit = 10;\n        eigenpieConfig = IEigenpieConfig(eigenpieConfigAddr);\n\n        emit UpdatedEigenpieConfig(eigenpieConfigAddr);\n    }\n\n    modifier onlyEigenpieWithdrawManager() {\n        address eigenpieWithdrawManager = eigenpieConfig.getContract(EigenpieConstants.EIGENPIE_WITHDRAW_MANAGER);\n        if (msg.sender != eigenpieWithdrawManager) revert InvalidCaller();\n        _;\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            view functions\n    //////////////////////////////////////////////////////////////*/\n    /// @notice gets the total asset present in protocol\n    /// @param asset Asset address\n    /// @return totalAssetDeposit total asset present in protocol\n    function getTotalAssetDeposits(address asset) public view override returns (uint256 totalAssetDeposit) {\n        (\n            uint256 assetLyingInDepositPool,\n            uint256 assetLyingInNDCs,\n            uint256 assetStakedInEigenLayer,\n            uint256 assetLyingInEWD\n        ) = getAssetDistributionData(asset);\n        return (assetLyingInDepositPool + assetLyingInNDCs + assetStakedInEigenLayer + assetLyingInEWD);\n    }\n\n    /// @notice gets the current limit of asset deposit\n    /// @param asset Asset address\n    /// @return currentLimit Current limit of asset deposit\n    function getAssetCurrentLimit(address asset) public view override returns (uint256) {\n        uint256 totalDeposits = getTotalAssetDeposits(asset);\n        uint256 depositLimit = eigenpieConfig.depositLimitByAsset(asset);\n\n        if (totalDeposits > depositLimit) {\n            return 0;\n        }\n\n        return depositLimit - totalDeposits;\n    }\n\n    /// @dev get node delegator queue\n    /// @return nodeDelegatorQueue Array of node delegator contract addresses\n    function getNodeDelegatorQueue() external view override returns (address[] memory) {\n        return nodeDelegatorQueue;\n    }\n\n    /// @dev provides asset amount distribution data among depositPool, NDCs and eigenLayer\n    /// @param asset the asset to get the total amount of\n    /// @return assetLyingInDepositPool asset amount lying in this EigenpieStaking contract\n    /// @return assetLyingInNDCs asset amount sum lying in all NDC contract\n    /// @return assetStakedInEigenLayer asset amount deposited in eigen layer strategies through all NDCs\n    /// @return assetLyingInEWD asset amount sum lying in all eigenpieWithdrawManager contract\n    function getAssetDistributionData(address asset)\n        public\n        view\n        override\n        onlySupportedAsset(asset)\n        returns (\n            uint256 assetLyingInDepositPool,\n            uint256 assetLyingInNDCs,\n            uint256 assetStakedInEigenLayer,\n            uint256 assetLyingInEWD\n        )\n    {\n        assetLyingInDepositPool = TransferHelper.balanceOf(asset, address(this));\n\n        if (asset == EigenpieConstants.PLATFORM_TOKEN_ADDRESS) {\n            address eigenpieWithdrawManager = eigenpieConfig.getContract(EigenpieConstants.EIGENPIE_WITHDRAW_MANAGER);\n            assetLyingInEWD = TransferHelper.balanceOf(asset, eigenpieWithdrawManager);\n        }\n\n        uint256 ndcsCount = nodeDelegatorQueue.length;\n        for (uint256 i; i < ndcsCount;) {\n            assetLyingInNDCs += TransferHelper.balanceOf(asset, nodeDelegatorQueue[i]);\n            assetStakedInEigenLayer += INodeDelegator(nodeDelegatorQueue[i]).getAssetBalance(asset);\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /// @notice View amount of mLRT to mint for given asset amount\n    /// @param asset Asset address\n    /// @param amount Asset amount\n    /// @return mLRTAmountToMint Amount of mLRT to mint\n    /// @return mLRTReceipt reciept token to mint\n    function getMLRTAmountToMint(\n        address asset,\n        uint256 amount\n    )\n        public\n        view\n        returns (uint256 mLRTAmountToMint, address mLRTReceipt)\n    {\n        address receipt = eigenpieConfig.mLRTReceiptByAsset(asset);\n\n        uint256 rate = IMLRT(receipt).exchangeRateToLST();\n\n        return ((amount * 1 ether) / rate, receipt);\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            write functions\n    //////////////////////////////////////////////////////////////*/\n    /// @notice helps user stake LST to the protocol\n    /// @param asset LST asset address to stake\n    /// @param minRec min amount of mLRT Receipt to receive\n    /// @param depositAmount LST asset amount to stake\n    function depositAsset(\n        address asset,\n        uint256 depositAmount,\n        uint256 minRec,\n        address referral\n    )\n        external\n        payable\n        whenNotPaused\n        nonReentrant\n        onlySupportedAsset(asset)\n    {\n        // checks\n        bool isNative = UtilLib.isNativeToken(asset);\n\n        // If the asset is NOT native, but msg.value > 0 (ETH sent), revert the transaction\n        if (!isNative && msg.value > 0) {\n            revert IncorrectAssetForNativeToken();\n        }\n\n        if (isNative && msg.value != depositAmount) {\n            revert InvalidAmountToDeposit();\n        }\n\n        if (depositAmount == 0 || depositAmount < minAmountToDeposit) {\n            revert InvalidAmountToDeposit();\n        }\n\n        if (depositAmount > getAssetCurrentLimit(asset)) {\n            revert MaximumDepositLimitReached();\n        }\n\n        uint256 mintedAmount;\n\n        if (isPreDeposit && !isNative) {\n            // only when not native and in pre deposit phase, we don't min receipt token to users\n            address eigenpiePreDepositHelper = eigenpieConfig.getContract(EigenpieConstants.EIGENPIE_PREDEPOSITHELPER);\n            mintedAmount = _mintMLRT(address(eigenpiePreDepositHelper), asset, depositAmount);\n            IEigenpiePreDepositHelper(eigenpiePreDepositHelper).feedUserDeposit(msg.sender, asset, mintedAmount);\n        } else {\n            // mint receipt\n            mintedAmount = _mintMLRT(msg.sender, asset, depositAmount);\n        }\n\n        if (mintedAmount < minRec) {\n            revert MinimumAmountToReceiveNotMet();\n        }\n\n        if (!isNative) {\n            IERC20(asset).safeTransferFrom(msg.sender, address(this), depositAmount);\n        }\n\n        emit AssetDeposit(msg.sender, asset, depositAmount, referral, mintedAmount, isPreDeposit);\n    }\n\n    // TODO don't open this as we need to avoid exchange rate manipulation.\n    function withdrawFromPreDeposit(\n        uint256 cycle,\n        address asset,\n        uint256 mLRTAmount\n    )\n        external\n        whenNotPaused\n        nonReentrant\n    {\n    //     if (cycle <= 0) revert InvalidCycle();\n\n    //     IEigenpiePreDepositHelper preDepositHelper =\n    //         IEigenpiePreDepositHelper(eigenpieConfig.getContract(EigenpieConstants.EIGENPIE_PREDEPOSITHELPER));\n\n    //     /* if the cycle becomes claimmable for mlrt receipt, that means underlying LST already depositted into\n    //     Eigenlayer,\n    //     hence, withdraw from the preDeposit cycle is not allowed anymore, have to go through normal withdraw flow*/\n    //     if (preDepositHelper.claimableCycles(cycle)) revert OnlyWhenPredeposit();\n\n    //     address mLRT = eigenpieConfig.mLRTReceiptByAsset(asset);\n    //     uint256 rate = IMLRT(mLRT).exchangeRateToLST();\n    //     uint256 assetToReturn = mLRTAmount * rate / 1 ether;\n\n    //     preDepositHelper.withdraw(cycle, msg.sender, asset, mLRT, mLRTAmount);\n\n    //     TransferHelper.safeTransferToken(asset, msg.sender, assetToReturn);\n    }\n\n    /// @notice add new node delegator contract addresses\n    /// @dev only callable by Eigenpie default\n    /// @param nodeDelegatorContracts Array of NodeDelegator contract addresses\n    function addNodeDelegatorContractToQueue(address[] calldata nodeDelegatorContracts) external onlyDefaultAdmin {\n        uint256 length = nodeDelegatorContracts.length;\n\n        // Loop through the input array first to check and add unique NodeDelegators\n        for (uint256 i; i < length;) {\n            UtilLib.checkNonZeroAddress(nodeDelegatorContracts[i]);\n\n            // If the NodeDelegator is not already added, mark it as added\n            if (isNodeDelegator[nodeDelegatorContracts[i]] == 0) {\n                nodeDelegatorQueue.push(nodeDelegatorContracts[i]);\n                isNodeDelegator[nodeDelegatorContracts[i]] = 1;\n            }\n\n            unchecked {\n                ++i;\n            }\n        }\n\n        // After the loop, check if the total number of NodeDelegators exceeds the limit\n        if (nodeDelegatorQueue.length > maxNodeDelegatorLimit) {\n            revert MaximumNodeDelegatorLimitReached();\n        }\n\n        emit NodeDelegatorAddedinQueue(nodeDelegatorContracts);\n    }\n\n    /// @notice transfers asset lying in this DepositPool to node delegator contract\n    /// @dev only callable by Eigenpie manager\n    /// @param ndcIndex Index of NodeDelegator contract address in nodeDelegatorQueue\n    /// @param asset Asset address\n    /// @param amount Asset amount to transfer\n\n    function transferAssetToNodeDelegator(\n        uint256 ndcIndex,\n        address asset,\n        uint256 amount\n    )\n        external\n        whenNotPaused\n        nonReentrant\n        onlyEigenpieManager\n        onlySupportedAsset(asset)\n    {\n        if (ndcIndex >= nodeDelegatorQueue.length) revert InvalidIndex();\n        address nodeDelegator = nodeDelegatorQueue[ndcIndex];\n\n        TransferHelper.safeTransferToken(asset, nodeDelegator, amount);\n    }\n\n    /// @notice update max node delegator count\n    /// @dev only callable by Eigenpie default\n    /// @param maxNodeDelegatorLimit_ Maximum count of node delegator\n    function updateMaxNodeDelegatorLimit(uint256 maxNodeDelegatorLimit_) external onlyDefaultAdmin {\n        if (maxNodeDelegatorLimit_ < nodeDelegatorQueue.length) {\n            revert InvalidMaximumNodeDelegatorLimit();\n        }\n\n        maxNodeDelegatorLimit = maxNodeDelegatorLimit_;\n        emit MaxNodeDelegatorLimitUpdated(maxNodeDelegatorLimit);\n    }\n\n    /// @notice update min amount to deposit\n    /// @dev only callable by Eigenpie default\n    /// @param minAmountToDeposit_ Minimum amount to deposit\n    function setMinAmountToDeposit(uint256 minAmountToDeposit_) external onlyDefaultAdmin {\n        minAmountToDeposit = minAmountToDeposit_;\n        emit MinAmountToDepositUpdated(minAmountToDeposit_);\n    }\n\n    /// @dev Triggers stopped state. Contract must not be paused.\n    function pause() external onlyEigenpieManager {\n        _pause();\n    }\n\n    /// @dev Returns to normal state. Contract must be paused\n    function unpause() external onlyDefaultAdmin {\n        _unpause();\n    }\n\n    function setIsPreDeposit(bool _isPreDeposit) external onlyDefaultAdmin {\n        isPreDeposit = _isPreDeposit;\n        emit PreDepositStatusChanged(_isPreDeposit);\n    }\n\n    function _mintMLRT(address _for, address asset, uint256 depositAmount) private returns (uint256 mintedMLRTAmount) {\n        (uint256 toMint, address receipt) = getMLRTAmountToMint(asset, depositAmount);\n\n        IMintableERC20(receipt).mint(_for, toMint);\n\n        return toMint;\n    }\n}"},"contracts/utils/UtilLib.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\nimport { EigenpieConstants } from \"./EigenpieConstants.sol\";\n\n/// @title UtilLib - Utility library\n/// @notice Utility functions\nlibrary UtilLib {\n    error ZeroAddressNotAllowed();\n\n    /// @dev zero address check modifier\n    /// @param address_ address to check\n    function checkNonZeroAddress(address address_) internal pure {\n        if (address_ == address(0)) revert ZeroAddressNotAllowed();\n    }\n\n    function isNativeToken(address addr) internal pure returns (bool) {\n        return addr == EigenpieConstants.PLATFORM_TOKEN_ADDRESS;\n    }\n}\n"},"contracts/utils/TransferHelper.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.21;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./UtilLib.sol\";\n\nlibrary TransferHelper {\n    using UtilLib for address;\n\n    function safeTransferToken(address token, address to, uint256 value) internal {\n        if (token.isNativeToken()) {\n            safeTransferETH(to, value);\n        } else {\n            safeTransfer(IERC20(token), to, value);\n        }\n    }\n\n    function safeTransferETH(address to, uint256 value) internal {\n        (bool success,) = address(to).call{ value: value }(\"\");\n        require(success, \"TransferHelper: Sending ETH failed\");\n    }\n\n    function balanceOf(address token, address addr) internal view returns (uint256) {\n        if (token.isNativeToken()) {\n            return addr.balance;\n        } else {\n            return IERC20(token).balanceOf(addr);\n        }\n    }\n\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        // bytes4(keccak256(bytes('transfer(address,uint256)'))) -> 0xa9059cbb\n        (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(0xa9059cbb, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))), \"TransferHelper::safeTransfer: transfer failed\"\n        );\n    }\n\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))) -> 0x23b872dd\n        (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(0x23b872dd, from, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            \"TransferHelper::safeTransferFrom: transfer failed\"\n        );\n    }\n}\n"},"contracts/utils/EigenpieConstants.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\nlibrary EigenpieConstants {\n    //contracts\n    bytes32 public constant EIGENPIE_STAKING = keccak256(\"EIGENPIE_STAKING\");\n    bytes32 public constant EIGEN_STRATEGY_MANAGER = keccak256(\"EIGEN_STRATEGY_MANAGER\");\n    bytes32 public constant EIGEN_DELEGATION_MANAGER = keccak256(\"EIGEN_DELEGATION_MANAGER\");\n    bytes32 public constant PRICE_PROVIDER = keccak256(\"PRICE_PROVIDER\");\n    bytes32 public constant BEACON_DEPOSIT = keccak256(\"BEACON_DEPOSIT\");\n    bytes32 public constant EIGENPOD_MANAGER = keccak256(\"EIGENPOD_MANAGER\");\n    bytes32 public constant EIGENPIE_PREDEPOSITHELPER = keccak256(\"EIGENPIE_PREDEPOSITHELPER\");\n    bytes32 public constant EIGENPIE_REWADR_DISTRIBUTOR = keccak256(\"EIGENPIE_REWADR_DISTRIBUTOR\");\n    bytes32 public constant EIGENPIE_DWR = keccak256(\"EIGENPIE_DWR\");\n    bytes32 public constant MLRT_ADAPTER = keccak256(\"MLRT_ADAPTER\");\n\n    bytes32 public constant SSVNETWORK_ENTRY = keccak256(\"SSVNETWORK_ENTRY\");\n    bytes32 public constant SSV_TOKEN = keccak256(\"SSV_TOKEN\");\n    bytes32 public constant REWARD_COORDINATOR = keccak256(\"REWARD_COORDINATOR\");\n    bytes32 public constant VAULT_LRT_SQUARED = keccak256(\"VAULT_LRT_SQUARED\");\n\n    //Roles\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n    bytes32 public constant MANAGER = keccak256(\"MANAGER\");\n    bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n    bytes32 public constant BURNER_ROLE = keccak256(\"BURNER_ROLE\");\n    bytes32 public constant EGP_MINTER_ROLE = keccak256(\"EGP_MINTER_ROLE\");\n    bytes32 public constant EGP_BURNER_ROLE = keccak256(\"EGP_BURNER_ROLE\");\n    bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n    bytes32 public constant ORACLE_ROLE = keccak256(\"ORACLE_ROLE\");\n    bytes32 public constant ORACLE_ADMIN_ROLE = keccak256(\"ORACLE_ADMIN_ROLE\");\n    bytes32 public constant PRICE_PROVIDER_ROLE = keccak256(\"PRICE_PROVIDER_ROLE\");\n\n    bytes32 public constant ALLOWED_BOT_ROLE = keccak256(\"ALLOWED_BOT_ROLE\");\n\n    // For Native Restaking\n    uint256 constant PUBKEY_LENGTH = 48;\n    uint256 constant SIGNATURE_LENGTH = 96;\n    uint256 constant MAX_VALIDATORS = 100;\n    uint256 constant DEPOSIT_AMOUNT = 32 ether;\n    uint256 constant GWEI_TO_WEI = 1e9;\n\n    // For layerzero bridging\n    uint32 constant LZ_ZIRCUIT_DESTINATION_ID = 30_303;\n    uint32 constant LZ_ETHEREUM_DESTINATION_ID = 30_101;\n\n    uint256 public constant DENOMINATOR = 10_000;\n    address public constant PLATFORM_TOKEN_ADDRESS = 0xeFEfeFEfeFeFEFEFEfefeFeFefEfEfEfeFEFEFEf;\n    bytes32 public constant EIGENPIE_WITHDRAW_MANAGER = keccak256(\"EIGENPIE_WITHDRAW_MANAGER\");\n\n    // External Defi\n    bytes32 public constant ZIRCUIT_ZSTAKIGPOOL = keccak256(\"ZIRCUIT_ZSTAKIGPOOL\");\n    bytes32 public constant SWELL_SIMPLE_STAKING = keccak256(\"SWELL_SIMPLE_STAKING\");\n    bytes32 public constant ZSTAKIGPOOL_ZIRCUIT_CHAIN = keccak256(\"ZSTAKIGPOOL_ZIRCUIT_CHAIN\");\n\n    bytes public constant BeaconProxyBytecode =\n        hex\"608060405260405161090e38038061090e83398101604081905261002291610460565b61002e82826000610035565b505061058a565b61003e83610100565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a260008251118061007f5750805b156100fb576100f9836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e99190610520565b836102a360201b6100291760201c565b505b505050565b610113816102cf60201b6100551760201c565b6101725760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6101e6816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d79190610520565b6102cf60201b6100551760201c565b61024b5760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401610169565b806102827fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5060001b6102de60201b6100641760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606102c883836040518060600160405280602781526020016108e7602791396102e1565b9392505050565b6001600160a01b03163b151590565b90565b6060600080856001600160a01b0316856040516102fe919061053b565b600060405180830381855af49150503d8060008114610339576040519150601f19603f3d011682016040523d82523d6000602084013e61033e565b606091505b5090925090506103508683838761035a565b9695505050505050565b606083156103c65782516103bf576001600160a01b0385163b6103bf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610169565b50816103d0565b6103d083836103d8565b949350505050565b8151156103e85781518083602001fd5b8060405162461bcd60e51b81526004016101699190610557565b80516001600160a01b038116811461041957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561044f578181015183820152602001610437565b838111156100f95750506000910152565b6000806040838503121561047357600080fd5b61047c83610402565b60208401519092506001600160401b038082111561049957600080fd5b818501915085601f8301126104ad57600080fd5b8151818111156104bf576104bf61041e565b604051601f8201601f19908116603f011681019083821181831017156104e7576104e761041e565b8160405282815288602084870101111561050057600080fd5b610511836020830160208801610434565b80955050505050509250929050565b60006020828403121561053257600080fd5b6102c882610402565b6000825161054d818460208701610434565b9190910192915050565b6020815260008251806020840152610576816040850160208701610434565b601f01601f19169190910160400192915050565b61034e806105996000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610067565b610100565b565b606061004e83836040518060600160405280602781526020016102f260279139610124565b9392505050565b6001600160a01b03163b151590565b90565b600061009a7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50546001600160a01b031690565b6001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100fb9190610249565b905090565b3660008037600080366000845af43d6000803e80801561011f573d6000f35b3d6000fd5b6060600080856001600160a01b03168560405161014191906102a2565b600060405180830381855af49150503d806000811461017c576040519150601f19603f3d011682016040523d82523d6000602084013e610181565b606091505b50915091506101928683838761019c565b9695505050505050565b6060831561020d578251610206576001600160a01b0385163b6102065760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610217565b610217838361021f565b949350505050565b81511561022f5781518083602001fd5b8060405162461bcd60e51b81526004016101fd91906102be565b60006020828403121561025b57600080fd5b81516001600160a01b038116811461004e57600080fd5b60005b8381101561028d578181015183820152602001610275565b8381111561029c576000848401525b50505050565b600082516102b4818460208701610272565b9190910192915050565b60208152600082518060208401526102dd816040850160208701610272565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d51e81d3bc5ed20a26aeb05dce7e825c503b2061aa78628027300c8d65b9d89a64736f6c634300080c0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564\";\n}\n"},"lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n    }\n}\n"},"contracts/utils/EigenpieConfigRoleChecker.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\nimport { UtilLib } from \"./UtilLib.sol\";\nimport { EigenpieConstants } from \"./EigenpieConstants.sol\";\n\nimport { IEigenpieConfig } from \"../interfaces/IEigenpieConfig.sol\";\n\nimport { IAccessControl } from \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\n/// @title EigenpieConfigRoleChecker - Eigenpie Config Role Checker Contract\n/// @notice Handles Eigenpie config role checks\nabstract contract EigenpieConfigRoleChecker {\n    IEigenpieConfig public eigenpieConfig;\n\n    uint256[49] private __gap; // reserve for upgrade\n\n    // events\n    event UpdatedEigenpieConfig(address indexed eigenpieConfig);\n\n    // modifiers\n    modifier onlyRole(bytes32 role) {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(role, msg.sender)) {\n            string memory roleStr = string(abi.encodePacked(role));\n            revert IEigenpieConfig.CallerNotEigenpieConfigAllowedRole(roleStr);\n        }\n        _;\n    }\n\n    modifier onlyEigenpieManager() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.MANAGER, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigManager();\n        }\n        _;\n    }\n\n    modifier onlyPriceProvider() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.PRICE_PROVIDER_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigPriceProvider();\n        }\n        _;\n    }\n\n    modifier onlyDefaultAdmin() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.DEFAULT_ADMIN_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigAdmin();\n        }\n        _;\n    }\n\n    modifier onlyOracleAdmin() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.ORACLE_ADMIN_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigOracleAdmin();\n        }\n        _;\n    }\n\n    modifier onlyOracle() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.ORACLE_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigOracle();\n        }\n        _;\n    }\n\n    modifier onlyMinter() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.MINTER_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigMinter();\n        }\n        _;\n    }\n\n    modifier onlyEGPMinter() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.EGP_MINTER_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigMinter();\n        }\n        _;\n    }\n\n    modifier onlyBurner() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.BURNER_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigBurner();\n        }\n        _;\n    }\n\n    modifier onlyEGPBurner() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.EGP_BURNER_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigBurner();\n        }\n        _;\n    }\n\n    modifier onlyPauser() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.PAUSER_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpiePauser();\n        }\n        _;\n    }\n\n    modifier onlySupportedAsset(address asset) {\n        if (!eigenpieConfig.isSupportedAsset(asset)) {\n            revert IEigenpieConfig.AssetNotSupported();\n        }\n        _;\n    }\n\n    modifier onlyAllowedBot() {\n        if (!IAccessControl(address(eigenpieConfig)).hasRole(EigenpieConstants.ALLOWED_BOT_ROLE, msg.sender)) {\n            revert IEigenpieConfig.CallerNotEigenpieConfigAllowedBot();\n        }\n        _;\n    }\n\n    // setters\n\n    /// @notice Updates the Eigenpie config contract\n    /// @dev only callable by Eigenpie default\n    /// @param eigenpieConfigAddr the new Eigenpie config contract Address\n    function updateEigenpieConfig(address eigenpieConfigAddr) external virtual onlyDefaultAdmin {\n        UtilLib.checkNonZeroAddress(eigenpieConfigAddr);\n        eigenpieConfig = IEigenpieConfig(eigenpieConfigAddr);\n        emit UpdatedEigenpieConfig(eigenpieConfigAddr);\n    }\n}\n"},"contracts/interfaces/IMintableERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)\n\npragma solidity 0.8.21;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IMintableERC20 {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, uint256 amount) external returns (bool);\n\n    function symbol() external view returns (string memory);\n\n    function decimals() external view returns (uint8);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n    function mint(address, uint256) external;\n\n    function faucet(uint256) external;\n\n    function burnFrom(address account, uint256 amount) external;\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"},"contracts/interfaces/INodeDelegator.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\nimport \"./eigenlayer/IStrategy.sol\";\nimport \"./ssvNetwork/ISSVNetworkCore.sol\";\n\ninterface INodeDelegator {\n    // struct\n    struct DepositData {\n        bytes[] publicKeys;\n        bytes[] signatures;\n        bytes32[] depositDataRoots;\n    }\n\n    struct SSVPayload {\n        uint64[] operatorIds;\n        bytes[] sharesData;\n        uint256 amount;\n        ISSVNetworkCore.Cluster cluster;\n    }\n\n    // event\n    event AssetDepositIntoStrategy(address indexed asset, address indexed strategy, uint256 depositAmount);\n    event EigenPodCreated(address indexed createdEigenPod);\n    event RewardsForwarded(address indexed destinatino, uint256 amount);\n    event WithdrawalQueuedToEigenLayer(\n        bytes32[] withdrawalRoot,\n        IStrategy[] strategies,\n        address[] assets,\n        uint256[] withdrawalAmounts,\n        uint256 startBlock\n    );\n    event DelegationAddressUpdated(address delegate);\n    event GasSpent(address indexed spender, uint256 gasUsed);\n    event GasRefunded(address indexed receiver, uint256 gasRefund);\n    event NewProofSubmitter(address indexed oldProofSubmitter, address indexed _newProofSubmitter);\n    event AVSRewardClaimerUpdated(address indexed _prevClaimer, address indexed _newClaimer);\n    event BufferFilled(uint256 amount);\n\n    // errors\n    error TokenTransferFailed();\n    error StrategyIsNotSetForAsset();\n    error NoPubKeysProvided();\n    error EigenPodExisted();\n    error EigenPodDoesNotExist();\n    error InvalidCall();\n    error InvalidCaller();\n    error AtLeastOneValidator();\n    error MaxValidatorsInput();\n    error PublicKeyNotMatch();\n    error SignaturesNotMatch();\n    error DelegateAddressAlreadySet();\n    error InvalidAmount();\n\n    // methods\n    function depositAssetIntoStrategy(address asset) external;\n\n    function maxApproveToEigenStrategyManager(address asset) external;\n\n    function getAssetBalances() external view returns (address[] memory, uint256[] memory);\n\n    function getAssetBalance(address asset) external view returns (uint256);\n\n    function getEthBalance() external view returns (uint256);\n\n    function createEigenPod() external;\n\n    function queueWithdrawalToEigenLayer(address[] memory assets, uint256[] memory amount) external;\n}\n"},"contracts/interfaces/IEigenpieStaking.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\ninterface IEigenpieStaking {\n    //errors\n    error TokenTransferFailed();\n    error InvalidAmountToDeposit();\n    error NotEnoughAssetToTransfer();\n    error MaximumDepositLimitReached();\n    error MaximumNodeDelegatorLimitReached();\n    error InvalidMaximumNodeDelegatorLimit();\n    error MinimumAmountToReceiveNotMet();\n    error InvalidIndex();\n    error NativeTokenTransferFailed();\n    error InvalidCaller();\n    error LengthMismatch();\n    error OnlyWhenPredeposit();\n    error IncorrectAssetForNativeToken();\n    error InvalidCycle();\n\n    //events\n    event MaxNodeDelegatorLimitUpdated(uint256 maxNodeDelegatorLimit);\n    event NodeDelegatorAddedinQueue(address[] nodeDelegatorContracts);\n    event AssetDeposit(\n        address indexed depositor,\n        address indexed asset,\n        uint256 depositAmount,\n        address indexed referral,\n        uint256 mintedAmount,\n        bool isPreDepsoit\n    );\n\n    event MinAmountToDepositUpdated(uint256 minAmountToDeposit);\n    event PreDepositHelperChanged(address oldPreDepositHelper, address newPreDepositHelper);\n    event PreDepositStatusChanged(bool newIsPreDeposit);\n\n    struct PoolInfo {\n        address mlrtReceipt;\n    }\n\n    function depositAsset(address asset, uint256 depositAmount, uint256 minRec, address referral) external payable;\n\n    function getTotalAssetDeposits(address asset) external view returns (uint256);\n\n    function getAssetCurrentLimit(address asset) external view returns (uint256);\n\n    function addNodeDelegatorContractToQueue(address[] calldata nodeDelegatorContract) external;\n\n    function transferAssetToNodeDelegator(uint256 ndcIndex, address asset, uint256 amount) external;\n\n    function updateMaxNodeDelegatorLimit(uint256 maxNodeDelegatorLimit) external;\n\n    function getNodeDelegatorQueue() external view returns (address[] memory);\n\n    function getAssetDistributionData(address asset)\n        external\n        view\n        returns (\n            uint256 assetLyingInDepositPool,\n            uint256 assetLyingInNDCs,\n            uint256 assetStakedInEigenLayer,\n            uint256 assetLyingInEWD\n        );\n}\n"},"contracts/interfaces/IMLRT.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IMLRT is IERC20 {\n    function updateExchangeRateToLST(uint256 _newRate) external;\n\n    function exchangeRateToLST() external view returns (uint256);\n\n    function underlyingAsset() external view returns (address);\n\n    function mint(address to, uint256 amount) external;\n\n    function burnFrom(address account, uint256 amount) external;\n}\n"},"contracts/interfaces/IEigenpiePreDepositHelper.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\ninterface IEigenpiePreDepositHelper {\n    function feedUserDeposit(address user, address asset, uint256 mintedAmount) external;\n    function withdraw(uint256 _cycle, address _user, address _asset, address _receipt, uint256 _mlrtAmount) external;\n\n    function claimableCycles(uint256 cycle) external returns (bool isClaimmable);\n}\n"},"lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"},"lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"},"lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == _ENTERED;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"},"lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"},"lib/openzeppelin-contracts/contracts/utils/Address.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"},"contracts/interfaces/IEigenpieConfig.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\ninterface IEigenpieConfig {\n    // Errors\n    error ValueAlreadyInUse();\n    error AssetAlreadySupported();\n    error AssetNotSupported();\n    error CallerNotEigenpieConfigAdmin();\n    error CallerNotEigenpieConfigManager();\n    error CallerNotEigenpieConfigOracle();\n    error CallerNotEigenpieConfigOracleAdmin();\n    error CallerNotEigenpieConfigPriceProvider();\n    error CallerNotEigenpieConfigMinter();\n    error CallerNotEigenpieConfigBurner();\n    error CallerNotEigenpiePauser();\n    error CallerNotEigenpieConfigAllowedRole(string role);\n    error CallerNotEigenpieConfigAllowedBot();\n\n    // Events\n    event SetContract(bytes32 key, address indexed contractAddr);\n    event AddedNewSupportedAsset(address indexed asset, address indexed receipt, uint256 depositLimit);\n    event ReceiptTokenUpdated(address indexed asset, address indexed receipt);\n    event RemovedSupportedAsset(address indexed asset);\n    event AssetDepositLimitUpdate(address indexed asset, uint256 depositLimit);\n    event AssetStrategyUpdate(address indexed asset, address indexed strategy);\n    event AssetBoostUpdate(address indexed asset, uint256 newBoost);\n    event ReferralUpdate(address indexed me, address indexed myReferral);\n    event MLRTBridgeUpdated(address indexed receipt, address indexed mlrtBridge);\n    event BaseGasAmountSpentUpdated(uint256 newBaseGasAmountSpent);\n\n    // methods\n    function baseGasAmountSpent() external returns (uint256);\n\n    function assetStrategy(address asset) external view returns (address);\n\n    function boostByAsset(address) external view returns (uint256);\n\n    function mLRTReceiptByAsset(address) external view returns (address);\n\n    function isSupportedAsset(address asset) external view returns (bool);\n\n    function getContract(bytes32 contractId) external view returns (address);\n\n    function getSupportedAssetList() external view returns (address[] memory);\n\n    function depositLimitByAsset(address asset) external view returns (uint256);\n\n    function getMLRTBridgeByReceipt(address receipt) external view returns (address);\n}\n"},"lib/openzeppelin-contracts/contracts/access/IAccessControl.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"},"contracts/interfaces/eigenlayer/IStrategy.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.21;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/**\n * @title Minimal interface for an `Strategy` contract.\n * @author Layr Labs, Inc.\n * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service\n * @notice Custom `Strategy` implementations may expand extensively on this interface.\n */\ninterface IStrategy {\n    /**\n     * @notice Used to deposit tokens into this Strategy\n     * @param token is the ERC20 token being deposited\n     * @param amount is the amount of token being deposited\n     * @dev This function is only callable by the strategyManager contract. It is invoked inside of the\n     * strategyManager's\n     * `depositIntoStrategy` function, and individual share balances are recorded in the strategyManager as well.\n     * @return newShares is the number of new shares issued at the current exchange ratio.\n     */\n    function deposit(IERC20 token, uint256 amount) external returns (uint256);\n\n    /**\n     * @notice Used to withdraw tokens from this Strategy, to the `recipient`'s address\n     * @param recipient is the address to receive the withdrawn funds\n     * @param token is the ERC20 token being transferred out\n     * @param amountShares is the amount of shares being withdrawn\n     * @dev This function is only callable by the strategyManager contract. It is invoked inside of the\n     * strategyManager's\n     * other functions, and individual share balances are recorded in the strategyManager as well.\n     */\n    function withdraw(address recipient, IERC20 token, uint256 amountShares) external;\n\n    /**\n     * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.\n     * @notice In contrast to `sharesToUnderlyingView`, this function **may** make state modifications\n     * @param amountShares is the amount of shares to calculate its conversion into the underlying token\n     * @return The amount of underlying tokens corresponding to the input `amountShares`\n     * @dev Implementation for these functions in particular may vary significantly for different strategies\n     */\n    function sharesToUnderlying(uint256 amountShares) external returns (uint256);\n\n    /**\n     * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.\n     * @notice In contrast to `underlyingToSharesView`, this function **may** make state modifications\n     * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares\n     * @return The amount of underlying tokens corresponding to the input `amountShares`\n     * @dev Implementation for these functions in particular may vary significantly for different strategies\n     */\n    function underlyingToShares(uint256 amountUnderlying) external returns (uint256);\n\n    /**\n     * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in\n     * this strategy. In contrast to `userUnderlyingView`, this function **may** make state modifications\n     */\n    function userUnderlying(address user) external returns (uint256);\n\n    /**\n     * @notice convenience function for fetching the current total shares of `user` in this strategy, by\n     * querying the `strategyManager` contract\n     */\n    function shares(address user) external view returns (uint256);\n\n    /**\n     * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.\n     * @notice In contrast to `sharesToUnderlying`, this function guarantees no state modifications\n     * @param amountShares is the amount of shares to calculate its conversion into the underlying token\n     * @return The amount of shares corresponding to the input `amountUnderlying`\n     * @dev Implementation for these functions in particular may vary significantly for different strategies\n     */\n    function sharesToUnderlyingView(uint256 amountShares) external view returns (uint256);\n\n    /**\n     * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.\n     * @notice In contrast to `underlyingToShares`, this function guarantees no state modifications\n     * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares\n     * @return The amount of shares corresponding to the input `amountUnderlying`\n     * @dev Implementation for these functions in particular may vary significantly for different strategies\n     */\n    function underlyingToSharesView(uint256 amountUnderlying) external view returns (uint256);\n\n    /**\n     * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in\n     * this strategy. In contrast to `userUnderlying`, this function guarantees no state modifications\n     */\n    function userUnderlyingView(address user) external view returns (uint256);\n\n    /// @notice The underlying token for shares in this Strategy\n    function underlyingToken() external view returns (IERC20);\n\n    /// @notice The total number of extant shares in this Strategy\n    function totalShares() external view returns (uint256);\n\n    /// @notice Returns either a brief string explaining the strategy's goal & purpose, or a link to metadata that\n    /// explains in more detail.\n    function explanation() external view returns (string memory);\n}\n"},"contracts/interfaces/ssvNetwork/ISSVNetworkCore.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.21;\n\ninterface ISSVNetworkCore {\n    /**\n     *\n     */\n    /* Structs */\n    /**\n     *\n     */\n\n    /// @notice Represents a snapshot of an operator's or a DAO's state at a certain block\n    struct Snapshot {\n        /// @dev The block number when the snapshot was taken\n        uint32 block;\n        /// @dev The last index calculated by the formula index += (currentBlock - block) * fee\n        uint64 index;\n        /// @dev Total accumulated earnings calculated by the formula accumulated + lastIndex * validatorCount\n        uint64 balance;\n    }\n\n    /// @notice Represents an SSV operator\n    struct Operator {\n        /// @dev The number of validators associated with this operator\n        uint32 validatorCount;\n        /// @dev The fee charged by the operator, set to zero for private operators and cannot be increased once set\n        uint64 fee;\n        /// @dev The address of the operator's owner\n        address owner;\n        /// @dev Whitelisted flag for this operator\n        bool whitelisted;\n        /// @dev The state snapshot of the operator\n        Snapshot snapshot;\n    }\n\n    /// @notice Represents a request to change an operator's fee\n    struct OperatorFeeChangeRequest {\n        /// @dev The new fee proposed by the operator\n        uint64 fee;\n        /// @dev The time when the approval period for the fee change begins\n        uint64 approvalBeginTime;\n        /// @dev The time when the approval period for the fee change ends\n        uint64 approvalEndTime;\n    }\n\n    /// @notice Represents a cluster of validators\n    struct Cluster {\n        /// @dev The number of validators in the cluster\n        uint32 validatorCount;\n        /// @dev The index of network fees related to this cluster\n        uint64 networkFeeIndex;\n        /// @dev The last index calculated for the cluster\n        uint64 index;\n        /// @dev Flag indicating whether the cluster is active\n        bool active;\n        /// @dev The balance of the cluster\n        uint256 balance;\n    }\n\n    /**\n     *\n     */\n    /* Errors */\n    /**\n     *\n     */\n    error CallerNotOwner(); // 0x5cd83192\n    error CallerNotWhitelisted(); // 0x8c6e5d71\n    error FeeTooLow(); // 0x732f9413\n    error FeeExceedsIncreaseLimit(); // 0x958065d9\n    error NoFeeDeclared(); // 0x1d226c30\n    error ApprovalNotWithinTimeframe(); // 0x97e4b518\n    error OperatorDoesNotExist(); // 0x961e3e8c\n    error InsufficientBalance(); // 0xf4d678b8\n    error ValidatorDoesNotExist(); // 0xe51315d2\n    error ClusterNotLiquidatable(); // 0x60300a8d\n    error InvalidPublicKeyLength(); // 0x637297a4\n    error InvalidOperatorIdsLength(); // 0x38186224\n    error ClusterAlreadyEnabled(); // 0x3babafd2\n    error ClusterIsLiquidated(); // 0x95a0cf33\n    error ClusterDoesNotExists(); // 0x185e2b16\n    error IncorrectClusterState(); // 0x12e04c87\n    error UnsortedOperatorsList(); // 0xdd020e25\n    error NewBlockPeriodIsBelowMinimum(); // 0x6e6c9cac\n    error ExceedValidatorLimit(); // 0x6df5ab76\n    error TokenTransferFailed(); // 0x045c4b02\n    error SameFeeChangeNotAllowed(); // 0xc81272f8\n    error FeeIncreaseNotAllowed(); // 0x410a2b6c\n    error NotAuthorized(); // 0xea8e4eb5\n    error OperatorsListNotUnique(); // 0xa5a1ff5d\n    error OperatorAlreadyExists(); // 0x289c9494\n    error TargetModuleDoesNotExist(); // 0x8f9195fb\n    error MaxValueExceeded(); // 0x91aa3017\n    error FeeTooHigh(); // 0xcd4e6167\n    error PublicKeysSharesLengthMismatch(); // 0x9ad467b8\n    error IncorrectValidatorStateWithData(bytes publicKey); // 0x89307938\n    error ValidatorAlreadyExistsWithData(bytes publicKey); // 0x388e7999\n\n    // legacy errors\n    error ValidatorAlreadyExists(); // 0x8d09a73e\n    error IncorrectValidatorState(); // 0x2feda3c1\n}\n"},"lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized != type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"},"lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"}},"matchId":"5851072","creationMatch":"exact_match","runtimeMatch":"exact_match","verifiedAt":"2024-12-28T19:49:04Z","match":"exact_match","chainId":"1","address":"0x3B6E006ea31DE8de9518b2168AA5084179b14fDE"}