Holesky Testnet

Contract

0x3b24f839f734BD494B1c17AAD2a3f97c1fc31BAd

Overview

ETH Balance

0 ETH

Multichain Info

N/A
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CSAccounting

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 250 runs

Other Settings:
cancun EvmVersion
File 1 of 43 : CSAccounting.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { PausableUntil } from "./lib/utils/PausableUntil.sol";
import { AccessControlEnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import { CSBondCore } from "./abstract/CSBondCore.sol";
import { CSBondCurve } from "./abstract/CSBondCurve.sol";
import { CSBondLock } from "./abstract/CSBondLock.sol";

import { ICSModule } from "./interfaces/ICSModule.sol";
import { ICSAccounting } from "./interfaces/ICSAccounting.sol";
import { ICSFeeDistributor } from "./interfaces/ICSFeeDistributor.sol";
import { AssetRecoverer } from "./abstract/AssetRecoverer.sol";
import { AssetRecovererLib } from "./lib/AssetRecovererLib.sol";

/// @author vgorkavenko
/// @notice This contract stores the Node Operators' bonds in the form of stETH shares,
///         so it should be considered in the recovery process
contract CSAccounting is
    ICSAccounting,
    CSBondCore,
    CSBondCurve,
    CSBondLock,
    PausableUntil,
    AccessControlEnumerableUpgradeable,
    AssetRecoverer
{
    using SafeERC20 for IERC20;

    bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE");
    bytes32 public constant RESUME_ROLE = keccak256("RESUME_ROLE");
    bytes32 public constant ACCOUNTING_MANAGER_ROLE =
        keccak256("ACCOUNTING_MANAGER_ROLE");
    bytes32 public constant MANAGE_BOND_CURVES_ROLE =
        keccak256("MANAGE_BOND_CURVES_ROLE");
    bytes32 public constant SET_BOND_CURVE_ROLE =
        keccak256("SET_BOND_CURVE_ROLE");
    bytes32 public constant RESET_BOND_CURVE_ROLE =
        keccak256("RESET_BOND_CURVE_ROLE");
    bytes32 public constant RECOVERER_ROLE = keccak256("RECOVERER_ROLE");

    ICSModule public immutable CSM;
    ICSFeeDistributor public feeDistributor;
    address public chargePenaltyRecipient;

    event BondLockCompensated(uint256 indexed nodeOperatorId, uint256 amount);
    event ChargePenaltyRecipientSet(address chargePenaltyRecipient);

    error SenderIsNotCSM();
    error ZeroModuleAddress();
    error ZeroAdminAddress();
    error ZeroFeeDistributorAddress();
    error ZeroChargePenaltyRecipientAddress();
    error NodeOperatorDoesNotExist();
    error ElRewardsVaultReceiveFailed();

    modifier onlyCSM() {
        if (msg.sender != address(CSM)) revert SenderIsNotCSM();
        _;
    }

    /// @param lidoLocator Lido locator contract address
    /// @param communityStakingModule Community Staking Module contract address
    /// @param maxCurveLength Max number of the points in the bond curves
    /// @param minBondLockRetentionPeriod Min time in seconds for the bondLock retention period
    /// @param maxBondLockRetentionPeriod Max time in seconds for the bondLock retention period
    constructor(
        address lidoLocator,
        address communityStakingModule,
        uint256 maxCurveLength,
        uint256 minBondLockRetentionPeriod,
        uint256 maxBondLockRetentionPeriod
    )
        CSBondCore(lidoLocator)
        CSBondCurve(maxCurveLength)
        CSBondLock(minBondLockRetentionPeriod, maxBondLockRetentionPeriod)
    {
        if (communityStakingModule == address(0)) {
            revert ZeroModuleAddress();
        }
        CSM = ICSModule(communityStakingModule);

        _disableInitializers();
    }

    /// @param bondCurve Initial bond curve
    /// @param admin Admin role member address
    /// @param _feeDistributor Fee Distributor contract address
    /// @param bondLockRetentionPeriod Retention period for locked bond in seconds
    /// @param _chargePenaltyRecipient Recipient of the charge penalty type
    function initialize(
        uint256[] calldata bondCurve,
        address admin,
        address _feeDistributor,
        uint256 bondLockRetentionPeriod,
        address _chargePenaltyRecipient
    ) external initializer {
        __AccessControlEnumerable_init();
        __CSBondCurve_init(bondCurve);
        __CSBondLock_init(bondLockRetentionPeriod);

        if (admin == address(0)) {
            revert ZeroAdminAddress();
        }
        if (_feeDistributor == address(0)) {
            revert ZeroFeeDistributorAddress();
        }

        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(SET_BOND_CURVE_ROLE, address(CSM));
        _grantRole(RESET_BOND_CURVE_ROLE, address(CSM));

        feeDistributor = ICSFeeDistributor(_feeDistributor);

        _setChargePenaltyRecipient(_chargePenaltyRecipient);

        LIDO.approve(address(WSTETH), type(uint256).max);
        LIDO.approve(address(WITHDRAWAL_QUEUE), type(uint256).max);
        LIDO.approve(LIDO_LOCATOR.burner(), type(uint256).max);
    }

    /// @notice Resume reward claims and deposits
    function resume() external onlyRole(RESUME_ROLE) {
        _resume();
    }

    /// @notice Pause reward claims and deposits for `duration` seconds
    /// @dev Must be called together with `CSModule.pauseFor`
    /// @dev Passing MAX_UINT_256 as `duration` pauses indefinitely
    /// @param duration Duration of the pause in seconds
    function pauseFor(uint256 duration) external onlyRole(PAUSE_ROLE) {
        _pauseFor(duration);
    }

    /// @notice Set charge recipient address
    /// @param _chargePenaltyRecipient Charge recipient address
    function setChargePenaltyRecipient(
        address _chargePenaltyRecipient
    ) external onlyRole(ACCOUNTING_MANAGER_ROLE) {
        _setChargePenaltyRecipient(_chargePenaltyRecipient);
    }

    /// @notice Set bond lock retention period
    /// @param retention Period in seconds to retain bond lock
    function setLockedBondRetentionPeriod(
        uint256 retention
    ) external onlyRole(ACCOUNTING_MANAGER_ROLE) {
        CSBondLock._setBondLockRetentionPeriod(retention);
    }

    /// @notice Add a new bond curve
    /// @param bondCurve Bond curve definition to add
    /// @return id Id of the added curve
    function addBondCurve(
        uint256[] calldata bondCurve
    ) external onlyRole(MANAGE_BOND_CURVES_ROLE) returns (uint256 id) {
        id = CSBondCurve._addBondCurve(bondCurve);
    }

    /// @notice Update existing bond curve
    /// @param curveId Bond curve ID to update
    /// @param bondCurve Bond curve definition
    function updateBondCurve(
        uint256 curveId,
        uint256[] calldata bondCurve
    ) external onlyRole(MANAGE_BOND_CURVES_ROLE) {
        CSBondCurve._updateBondCurve(curveId, bondCurve);
    }

    /// @notice Set the bond curve for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @param curveId ID of the bond curve to set
    function setBondCurve(
        uint256 nodeOperatorId,
        uint256 curveId
    ) external onlyRole(SET_BOND_CURVE_ROLE) {
        _onlyExistingNodeOperator(nodeOperatorId);
        CSBondCurve._setBondCurve(nodeOperatorId, curveId);
    }

    /// @notice Reset bond curve to the default one for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    function resetBondCurve(
        uint256 nodeOperatorId
    ) external onlyRole(RESET_BOND_CURVE_ROLE) {
        _onlyExistingNodeOperator(nodeOperatorId);
        CSBondCurve._resetBondCurve(nodeOperatorId);
    }

    /// @notice Stake user's ETH with Lido and deposit stETH to the bond
    /// @dev Called by CSM exclusively
    /// @param from Address to stake ETH and deposit stETH from
    /// @param nodeOperatorId ID of the Node Operator
    function depositETH(
        address from,
        uint256 nodeOperatorId
    ) external payable whenResumed onlyCSM {
        CSBondCore._depositETH(from, nodeOperatorId);
    }

    /// @notice Deposit user's stETH to the bond for the given Node Operator
    /// @dev Called by CSM exclusively
    /// @param from Address to deposit stETH from
    /// @param nodeOperatorId ID of the Node Operator
    /// @param stETHAmount Amount of stETH to deposit
    /// @param permit stETH permit for the contract
    function depositStETH(
        address from,
        uint256 nodeOperatorId,
        uint256 stETHAmount,
        PermitInput calldata permit
    ) external whenResumed onlyCSM {
        // @dev for some reason foundry coverage consider this if as not fully covered. Check tests to see it is covered indeed
        // preventing revert for already used permit or avoid permit usage in case of value == 0
        if (
            permit.value > 0 &&
            LIDO.allowance(from, address(this)) < permit.value
        ) {
            // solhint-disable-next-line func-named-parameters
            LIDO.permit(
                from,
                address(this),
                permit.value,
                permit.deadline,
                permit.v,
                permit.r,
                permit.s
            );
        }

        CSBondCore._depositStETH(from, nodeOperatorId, stETHAmount);
    }

    /// @notice Unwrap the user's wstETH and deposit stETH to the bond for the given Node Operator
    /// @dev Called by CSM exclusively
    /// @param from Address to unwrap wstETH from
    /// @param nodeOperatorId ID of the Node Operator
    /// @param wstETHAmount Amount of wstETH to deposit
    /// @param permit wstETH permit for the contract
    function depositWstETH(
        address from,
        uint256 nodeOperatorId,
        uint256 wstETHAmount,
        PermitInput calldata permit
    ) external whenResumed onlyCSM {
        // @dev for some reason foundry coverage consider this if as not fully covered. Check tests to see it is covered indeed
        // preventing revert for already used permit or avoid permit usage in case of value == 0
        if (
            permit.value > 0 &&
            WSTETH.allowance(from, address(this)) < permit.value
        ) {
            // solhint-disable-next-line func-named-parameters
            WSTETH.permit(
                from,
                address(this),
                permit.value,
                permit.deadline,
                permit.v,
                permit.r,
                permit.s
            );
        }

        CSBondCore._depositWstETH(from, nodeOperatorId, wstETHAmount);
    }

    /// @notice Claim full reward (fee + bond) in stETH for the given Node Operator with desirable value.
    ///         `rewardsProof` and `cumulativeFeeShares` might be empty in order to claim only excess bond
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    /// @param stETHAmount Amount of stETH to claim
    /// @param rewardAddress Reward address of the node operator
    /// @param cumulativeFeeShares Cumulative fee stETH shares for the Node Operator
    /// @param rewardsProof Merkle proof of the rewards
    function claimRewardsStETH(
        uint256 nodeOperatorId,
        uint256 stETHAmount,
        address rewardAddress,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) external whenResumed onlyCSM {
        if (rewardsProof.length != 0) {
            _pullFeeRewards(nodeOperatorId, cumulativeFeeShares, rewardsProof);
        }
        CSBondCore._claimStETH(nodeOperatorId, stETHAmount, rewardAddress);
    }

    /// @notice Claim full reward (fee + bond) in wstETH for the given Node Operator available for this moment.
    ///         `rewardsProof` and `cumulativeFeeShares` might be empty in order to claim only excess bond
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    /// @param wstETHAmount Amount of wstETH to claim
    /// @param rewardAddress Reward address of the node operator
    /// @param cumulativeFeeShares Cumulative fee stETH shares for the Node Operator
    /// @param rewardsProof Merkle proof of the rewards
    function claimRewardsWstETH(
        uint256 nodeOperatorId,
        uint256 wstETHAmount,
        address rewardAddress,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) external whenResumed onlyCSM {
        if (rewardsProof.length != 0) {
            _pullFeeRewards(nodeOperatorId, cumulativeFeeShares, rewardsProof);
        }
        CSBondCore._claimWstETH(nodeOperatorId, wstETHAmount, rewardAddress);
    }

    /// @notice Request full reward (fee + bond) in Withdrawal NFT (unstETH) for the given Node Operator available for this moment.
    ///         `rewardsProof` and `cumulativeFeeShares` might be empty in order to claim only excess bond
    /// @dev Reverts if amount isn't between `MIN_STETH_WITHDRAWAL_AMOUNT` and `MAX_STETH_WITHDRAWAL_AMOUNT`
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    /// @param stEthAmount Amount of ETH to request
    /// @param rewardAddress Reward address of the node operator
    /// @param cumulativeFeeShares Cumulative fee stETH shares for the Node Operator
    /// @param rewardsProof Merkle proof of the rewards
    function claimRewardsUnstETH(
        uint256 nodeOperatorId,
        uint256 stEthAmount,
        address rewardAddress,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) external whenResumed onlyCSM {
        if (rewardsProof.length != 0) {
            _pullFeeRewards(nodeOperatorId, cumulativeFeeShares, rewardsProof);
        }
        CSBondCore._claimUnstETH(nodeOperatorId, stEthAmount, rewardAddress);
    }

    /// @notice Lock bond in ETH for the given Node Operator
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    /// @param amount Amount to lock in ETH (stETH)
    function lockBondETH(
        uint256 nodeOperatorId,
        uint256 amount
    ) external onlyCSM {
        CSBondLock._lock(nodeOperatorId, amount);
    }

    /// @notice Release locked bond in ETH for the given Node Operator
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    /// @param amount Amount to release in ETH (stETH)
    function releaseLockedBondETH(
        uint256 nodeOperatorId,
        uint256 amount
    ) external onlyCSM {
        CSBondLock._reduceAmount(nodeOperatorId, amount);
    }

    /// @notice Compensate locked bond ETH for the given Node Operator
    //// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    function compensateLockedBondETH(
        uint256 nodeOperatorId
    ) external payable onlyCSM {
        (bool success, ) = LIDO_LOCATOR.elRewardsVault().call{
            value: msg.value
        }("");
        if (!success) revert ElRewardsVaultReceiveFailed();
        CSBondLock._reduceAmount(nodeOperatorId, msg.value);
        emit BondLockCompensated(nodeOperatorId, msg.value);
    }

    /// @notice Settle locked bond ETH for the given Node Operator
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    function settleLockedBondETH(uint256 nodeOperatorId) external onlyCSM {
        uint256 lockedAmount = CSBondLock.getActualLockedBond(nodeOperatorId);
        if (lockedAmount > 0) {
            CSBondCore._burn(nodeOperatorId, lockedAmount);
        }
        // reduce all locked bond even if bond isn't covered lock fully
        CSBondLock._remove(nodeOperatorId);
    }

    /// @notice Penalize bond by burning stETH shares of the given Node Operator
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    /// @param amount Amount to penalize in ETH (stETH)
    function penalize(uint256 nodeOperatorId, uint256 amount) external onlyCSM {
        CSBondCore._burn(nodeOperatorId, amount);
    }

    /// @notice Charge fee from bond by transferring stETH shares of the given Node Operator to the charge recipient
    /// @dev Called by CSM exclusively
    /// @param nodeOperatorId ID of the Node Operator
    /// @param amount Amount to charge in ETH (stETH)
    function chargeFee(
        uint256 nodeOperatorId,
        uint256 amount
    ) external onlyCSM {
        CSBondCore._charge(nodeOperatorId, amount, chargePenaltyRecipient);
    }

    /// @notice Pull fees from CSFeeDistributor to the Node Operator's bond
    /// @dev Permissionless method. Can be called before penalty application to ensure that rewards are also penalized
    /// @param nodeOperatorId ID of the Node Operator
    /// @param cumulativeFeeShares Cumulative fee stETH shares for the Node Operator
    /// @param rewardsProof Merkle proof of the rewards
    function pullFeeRewards(
        uint256 nodeOperatorId,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) external {
        _onlyExistingNodeOperator(nodeOperatorId);
        _pullFeeRewards(nodeOperatorId, cumulativeFeeShares, rewardsProof);
    }

    /// @notice Recover ERC20 tokens from the contract
    /// @param token Address of the ERC20 token to recover
    /// @param amount Amount of the ERC20 token to recover
    function recoverERC20(address token, uint256 amount) external override {
        _onlyRecoverer();
        if (token == address(LIDO)) {
            revert NotAllowedToRecover();
        }
        AssetRecovererLib.recoverERC20(token, amount);
    }

    /// @notice Recover all stETH shares from the contract
    /// @dev Accounts for the bond funds stored during recovery
    function recoverStETHShares() external {
        _onlyRecoverer();
        uint256 shares = LIDO.sharesOf(address(this)) - totalBondShares();
        AssetRecovererLib.recoverStETHShares(address(LIDO), shares);
    }

    /// @notice Service method to update allowance to Burner in case it has changed
    function renewBurnerAllowance() external {
        LIDO.approve(LIDO_LOCATOR.burner(), type(uint256).max);
    }

    /// @notice Get current and required bond amounts in ETH (stETH) for the given Node Operator
    /// @dev To calculate excess bond amount subtract `required` from `current` value.
    ///      To calculate missed bond amount subtract `current` from `required` value
    /// @param nodeOperatorId ID of the Node Operator
    /// @return current Current bond amount in ETH
    /// @return required Required bond amount in ETH
    function getBondSummary(
        uint256 nodeOperatorId
    ) public view returns (uint256 current, uint256 required) {
        unchecked {
            current = CSBondCore.getBond(nodeOperatorId);
            // @dev 'getActualLockedBond' is uint128, so no overflow expected in practice
            required =
                CSBondCurve.getBondAmountByKeysCount(
                    CSM.getNodeOperatorNonWithdrawnKeys(nodeOperatorId),
                    CSBondCurve.getBondCurve(nodeOperatorId)
                ) +
                CSBondLock.getActualLockedBond(nodeOperatorId);
        }
    }

    /// @notice Get current and required bond amounts in stETH shares for the given Node Operator
    /// @dev To calculate excess bond amount subtract `required` from `current` value.
    ///      To calculate missed bond amount subtract `current` from `required` value
    /// @param nodeOperatorId ID of the Node Operator
    /// @return current Current bond amount in stETH shares
    /// @return required Required bond amount in stETH shares
    function getBondSummaryShares(
        uint256 nodeOperatorId
    ) public view returns (uint256 current, uint256 required) {
        unchecked {
            current = CSBondCore.getBondShares(nodeOperatorId);
            // @dev 'getActualLockedBond' is uint128, so no overflow expected in practice
            required = _sharesByEth(
                CSBondCurve.getBondAmountByKeysCount(
                    CSM.getNodeOperatorNonWithdrawnKeys(nodeOperatorId),
                    CSBondCurve.getBondCurve(nodeOperatorId)
                ) + CSBondLock.getActualLockedBond(nodeOperatorId)
            );
        }
    }

    /// @notice Get the number of the unbonded keys
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Unbonded keys count
    function getUnbondedKeysCount(
        uint256 nodeOperatorId
    ) public view returns (uint256) {
        return
            _getUnbondedKeysCount({
                nodeOperatorId: nodeOperatorId,
                accountLockedBond: true
            });
    }

    /// @notice Get the number of the unbonded keys to be ejected using a forcedTargetLimit
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Unbonded keys count
    function getUnbondedKeysCountToEject(
        uint256 nodeOperatorId
    ) public view returns (uint256) {
        return
            _getUnbondedKeysCount({
                nodeOperatorId: nodeOperatorId,
                accountLockedBond: false
            });
    }

    /// @notice Get the required bond in ETH (inc. missed and excess) for the given Node Operator to upload new deposit data
    /// @param nodeOperatorId ID of the Node Operator
    /// @param additionalKeys Number of new keys to add
    /// @return Required bond amount in ETH
    function getRequiredBondForNextKeys(
        uint256 nodeOperatorId,
        uint256 additionalKeys
    ) public view returns (uint256) {
        uint256 current = CSBondCore.getBond(nodeOperatorId);
        uint256 requiredForNewTotalKeys = CSBondCurve.getBondAmountByKeysCount(
            CSM.getNodeOperatorNonWithdrawnKeys(nodeOperatorId) +
                additionalKeys,
            CSBondCurve.getBondCurve(nodeOperatorId)
        );
        uint256 totalRequired = requiredForNewTotalKeys +
            CSBondLock.getActualLockedBond(nodeOperatorId);

        unchecked {
            return totalRequired > current ? totalRequired - current : 0;
        }
    }

    /// @notice Get the bond amount in wstETH required for the `keysCount` keys using the default bond curve
    /// @param keysCount Keys count to calculate the required bond amount
    /// @param curveId Id of the curve to perform calculations against
    /// @return wstETH amount required for the `keysCount`
    function getBondAmountByKeysCountWstETH(
        uint256 keysCount,
        uint256 curveId
    ) public view returns (uint256) {
        return
            _sharesByEth(
                CSBondCurve.getBondAmountByKeysCount(keysCount, curveId)
            );
    }

    /// @notice Get the bond amount in wstETH required for the `keysCount` keys using the custom bond curve
    /// @param keysCount Keys count to calculate the required bond amount
    /// @param curve Bond curve definition.
    ///              Use CSBondCurve.getBondCurve(id) method to get the definition for the exiting curve
    /// @return wstETH amount required for the `keysCount`
    function getBondAmountByKeysCountWstETH(
        uint256 keysCount,
        BondCurve memory curve
    ) public view returns (uint256) {
        return
            _sharesByEth(
                CSBondCurve.getBondAmountByKeysCount(keysCount, curve)
            );
    }

    /// @notice Get the required bond in wstETH (inc. missed and excess) for the given Node Operator to upload new keys
    /// @param nodeOperatorId ID of the Node Operator
    /// @param additionalKeys Number of new keys to add
    /// @return Required bond in wstETH
    function getRequiredBondForNextKeysWstETH(
        uint256 nodeOperatorId,
        uint256 additionalKeys
    ) public view returns (uint256) {
        return
            _sharesByEth(
                getRequiredBondForNextKeys(nodeOperatorId, additionalKeys)
            );
    }

    function _pullFeeRewards(
        uint256 nodeOperatorId,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) internal {
        uint256 distributed = feeDistributor.distributeFees(
            nodeOperatorId,
            cumulativeFeeShares,
            rewardsProof
        );
        CSBondCore._increaseBond(nodeOperatorId, distributed);
    }

    /// @dev Overrides the original implementation to account for a locked bond and withdrawn validators
    function _getClaimableBondShares(
        uint256 nodeOperatorId
    ) internal view override returns (uint256) {
        unchecked {
            uint256 current = CSBondCore.getBondShares(nodeOperatorId);
            uint256 required = _sharesByEth(
                CSBondCurve.getBondAmountByKeysCount(
                    CSM.getNodeOperatorNonWithdrawnKeys(nodeOperatorId),
                    CSBondCurve.getBondCurve(nodeOperatorId)
                ) + CSBondLock.getActualLockedBond(nodeOperatorId)
            );
            return current > required ? current - required : 0;
        }
    }

    /// @dev Unbonded stands for the amount of the keys not fully covered with the bond
    function _getUnbondedKeysCount(
        uint256 nodeOperatorId,
        bool accountLockedBond
    ) internal view returns (uint256) {
        uint256 nonWithdrawnKeys = CSM.getNodeOperatorNonWithdrawnKeys(
            nodeOperatorId
        );
        unchecked {
            /// 10 wei added to account for possible stETH rounding errors
            /// https://github.com/lidofinance/lido-dao/issues/442#issuecomment-1182264205.
            /// Should be sufficient for ~ 40 years
            uint256 currentBond = CSBondCore._ethByShares(
                getBondShares(nodeOperatorId)
            ) + 10 wei;
            if (accountLockedBond) {
                uint256 lockedBond = CSBondLock.getActualLockedBond(
                    nodeOperatorId
                );
                if (currentBond <= lockedBond) return nonWithdrawnKeys;
                currentBond -= lockedBond;
            }
            uint256 bondedKeys = CSBondCurve.getKeysCountByBondAmount(
                currentBond,
                CSBondCurve.getBondCurve(nodeOperatorId)
            );
            return
                nonWithdrawnKeys > bondedKeys
                    ? nonWithdrawnKeys - bondedKeys
                    : 0;
        }
    }

    function _onlyRecoverer() internal view override {
        _checkRole(RECOVERER_ROLE);
    }

    function _onlyExistingNodeOperator(uint256 nodeOperatorId) internal view {
        if (nodeOperatorId < CSM.getNodeOperatorsCount()) return;
        revert NodeOperatorDoesNotExist();
    }

    function _setChargePenaltyRecipient(
        address _chargePenaltyRecipient
    ) private {
        if (_chargePenaltyRecipient == address(0)) {
            revert ZeroChargePenaltyRecipientAddress();
        }
        chargePenaltyRecipient = _chargePenaltyRecipient;
        emit ChargePenaltyRecipientSet(_chargePenaltyRecipient);
    }
}

File 2 of 43 : PausableUntil.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.24;

import { UnstructuredStorage } from "../UnstructuredStorage.sol";

contract PausableUntil {
    using UnstructuredStorage for bytes32;

    /// Contract resume/pause control storage slot
    bytes32 internal constant RESUME_SINCE_TIMESTAMP_POSITION =
        keccak256("lido.PausableUntil.resumeSinceTimestamp");
    /// Special value for the infinite pause
    uint256 public constant PAUSE_INFINITELY = type(uint256).max;

    /// @notice Emitted when paused by the `pauseFor` or `pauseUntil` call
    event Paused(uint256 duration);
    /// @notice Emitted when resumed by the `resume` call
    event Resumed();

    error ZeroPauseDuration();
    error PausedExpected();
    error ResumedExpected();
    error PauseUntilMustBeInFuture();

    /// @notice Reverts when resumed
    modifier whenPaused() {
        _checkPaused();
        _;
    }

    /// @notice Reverts when paused
    modifier whenResumed() {
        _checkResumed();
        _;
    }

    /// @notice Returns one of:
    ///  - PAUSE_INFINITELY if paused infinitely returns
    ///  - first second when get contract get resumed if paused for specific duration
    ///  - some timestamp in past if not paused
    function getResumeSinceTimestamp() external view returns (uint256) {
        return RESUME_SINCE_TIMESTAMP_POSITION.getStorageUint256();
    }

    /// @notice Returns whether the contract is paused
    function isPaused() public view returns (bool) {
        return
            block.timestamp <
            RESUME_SINCE_TIMESTAMP_POSITION.getStorageUint256();
    }

    function _resume() internal {
        _checkPaused();
        RESUME_SINCE_TIMESTAMP_POSITION.setStorageUint256(block.timestamp);
        emit Resumed();
    }

    function _pauseFor(uint256 duration) internal {
        _checkResumed();
        if (duration == 0) revert ZeroPauseDuration();

        uint256 resumeSince;
        if (duration == PAUSE_INFINITELY) {
            resumeSince = PAUSE_INFINITELY;
        } else {
            resumeSince = block.timestamp + duration;
        }
        _setPausedState(resumeSince);
    }

    function _pauseUntil(uint256 pauseUntilInclusive) internal {
        _checkResumed();
        if (pauseUntilInclusive < block.timestamp)
            revert PauseUntilMustBeInFuture();

        uint256 resumeSince;
        if (pauseUntilInclusive != PAUSE_INFINITELY) {
            resumeSince = pauseUntilInclusive + 1;
        } else {
            resumeSince = PAUSE_INFINITELY;
        }
        _setPausedState(resumeSince);
    }

    function _setPausedState(uint256 resumeSince) internal {
        RESUME_SINCE_TIMESTAMP_POSITION.setStorageUint256(resumeSince);
        if (resumeSince == PAUSE_INFINITELY) {
            emit Paused(PAUSE_INFINITELY);
        } else {
            emit Paused(resumeSince - block.timestamp);
        }
    }

    function _checkPaused() internal view {
        if (!isPaused()) {
            revert PausedExpected();
        }
    }

    function _checkResumed() internal view {
        if (isPaused()) {
            revert ResumedExpected();
        }
    }
}

File 3 of 43 : AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)

pragma solidity ^0.8.20;

import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol";
import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerable, AccessControlUpgradeable {
    using EnumerableSet for EnumerableSet.AddressSet;

    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControlEnumerable
    struct AccessControlEnumerableStorage {
        mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlEnumerable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlEnumerableStorageLocation = 0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000;

    function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $) {
        assembly {
            $.slot := AccessControlEnumerableStorageLocation
        }
    }

    function __AccessControlEnumerable_init() internal onlyInitializing {
    }

    function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {
        AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
        return $._roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {
        AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
        return $._roleMembers[role].length();
    }

    /**
     * @dev Overload {AccessControl-_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
        AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
        bool granted = super._grantRole(role, account);
        if (granted) {
            $._roleMembers[role].add(account);
        }
        return granted;
    }

    /**
     * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
        AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
        bool revoked = super._revokeRole(role, account);
        if (revoked) {
            $._roleMembers[role].remove(account);
        }
        return revoked;
    }
}

File 4 of 43 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

File 5 of 43 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

File 6 of 43 : CSBondCore.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { ILidoLocator } from "../interfaces/ILidoLocator.sol";
import { ILido } from "../interfaces/ILido.sol";
import { IBurner } from "../interfaces/IBurner.sol";
import { IWstETH } from "../interfaces/IWstETH.sol";
import { IWithdrawalQueue } from "../interfaces/IWithdrawalQueue.sol";
import { ICSBondCore } from "../interfaces/ICSBondCore.sol";

/// @dev Bond core mechanics abstract contract
///
/// It gives basic abilities to manage bond shares (stETH) of the Node Operator.
///
/// It contains:
///  - store bond shares (stETH)
///  - get bond shares (stETH) and bond amount
///  - deposit ETH/stETH/wstETH
///  - claim ETH/stETH/wstETH
///  - burn
///
/// Should be inherited by Module contract, or Module-related contract.
/// Internal non-view methods should be used in Module contract with additional requirements (if any).
///
/// @author vgorkavenko
abstract contract CSBondCore is ICSBondCore {
    /// @custom:storage-location erc7201:CSAccounting.CSBondCore
    struct CSBondCoreStorage {
        mapping(uint256 nodeOperatorId => uint256 shares) bondShares;
        uint256 totalBondShares;
    }

    ILidoLocator public immutable LIDO_LOCATOR;
    ILido public immutable LIDO;
    IWithdrawalQueue public immutable WITHDRAWAL_QUEUE;
    IWstETH public immutable WSTETH;

    // keccak256(abi.encode(uint256(keccak256("CSBondCore")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant CS_BOND_CORE_STORAGE_LOCATION =
        0x23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec92100;

    event BondDepositedETH(
        uint256 indexed nodeOperatorId,
        address from,
        uint256 amount
    );
    event BondDepositedStETH(
        uint256 indexed nodeOperatorId,
        address from,
        uint256 amount
    );
    event BondDepositedWstETH(
        uint256 indexed nodeOperatorId,
        address from,
        uint256 amount
    );
    event BondClaimedUnstETH(
        uint256 indexed nodeOperatorId,
        address to,
        uint256 amount,
        uint256 requestId
    );
    event BondClaimedStETH(
        uint256 indexed nodeOperatorId,
        address to,
        uint256 amount
    );
    event BondClaimedWstETH(
        uint256 indexed nodeOperatorId,
        address to,
        uint256 amount
    );
    event BondBurned(
        uint256 indexed nodeOperatorId,
        uint256 toBurnAmount,
        uint256 burnedAmount
    );
    event BondCharged(
        uint256 indexed nodeOperatorId,
        uint256 toChargeAmount,
        uint256 chargedAmount
    );

    error ZeroLocatorAddress();
    error NothingToClaim();

    constructor(address lidoLocator) {
        if (lidoLocator == address(0)) {
            revert ZeroLocatorAddress();
        }
        LIDO_LOCATOR = ILidoLocator(lidoLocator);
        LIDO = ILido(LIDO_LOCATOR.lido());
        WITHDRAWAL_QUEUE = IWithdrawalQueue(LIDO_LOCATOR.withdrawalQueue());
        WSTETH = IWstETH(WITHDRAWAL_QUEUE.WSTETH());
    }

    /// @notice Get total bond shares (stETH) stored on the contract
    /// @return Total bond shares (stETH)
    function totalBondShares() public view returns (uint256) {
        return _getCSBondCoreStorage().totalBondShares;
    }

    /// @notice Get bond shares (stETH) for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Bond in stETH shares
    function getBondShares(
        uint256 nodeOperatorId
    ) public view returns (uint256) {
        return _getCSBondCoreStorage().bondShares[nodeOperatorId];
    }

    /// @notice Get bond amount in ETH (stETH) for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Bond amount in ETH (stETH)
    function getBond(uint256 nodeOperatorId) public view returns (uint256) {
        return _ethByShares(getBondShares(nodeOperatorId));
    }

    /// @dev Stake user's ETH with Lido and stores stETH shares as Node Operator's bond shares
    function _depositETH(address from, uint256 nodeOperatorId) internal {
        if (msg.value == 0) return;
        uint256 shares = LIDO.submit{ value: msg.value }({
            _referal: address(0)
        });
        _increaseBond(nodeOperatorId, shares);
        emit BondDepositedETH(nodeOperatorId, from, msg.value);
    }

    /// @dev Transfer user's stETH to the contract and stores stETH shares as Node Operator's bond shares
    function _depositStETH(
        address from,
        uint256 nodeOperatorId,
        uint256 amount
    ) internal {
        if (amount == 0) return;
        uint256 shares = _sharesByEth(amount);
        LIDO.transferSharesFrom(from, address(this), shares);
        _increaseBond(nodeOperatorId, shares);
        emit BondDepositedStETH(nodeOperatorId, from, amount);
    }

    /// @dev Transfer user's wstETH to the contract, unwrap and store stETH shares as Node Operator's bond shares
    function _depositWstETH(
        address from,
        uint256 nodeOperatorId,
        uint256 amount
    ) internal {
        if (amount == 0) return;
        WSTETH.transferFrom(from, address(this), amount);
        uint256 sharesBefore = LIDO.sharesOf(address(this));
        WSTETH.unwrap(amount);
        uint256 sharesAfter = LIDO.sharesOf(address(this));
        unchecked {
            _increaseBond(nodeOperatorId, sharesAfter - sharesBefore);
        }
        emit BondDepositedWstETH(nodeOperatorId, from, amount);
    }

    function _increaseBond(uint256 nodeOperatorId, uint256 shares) internal {
        if (shares == 0) return;
        CSBondCoreStorage storage $ = _getCSBondCoreStorage();
        unchecked {
            $.bondShares[nodeOperatorId] += shares;
            $.totalBondShares += shares;
        }
    }

    /// @dev Claim Node Operator's excess bond shares (stETH) in ETH by requesting withdrawal from the protocol
    ///      As a usual withdrawal request, this claim might be processed on the next stETH rebase
    function _claimUnstETH(
        uint256 nodeOperatorId,
        uint256 requestedAmountToClaim,
        address to
    ) internal {
        uint256 claimableShares = _getClaimableBondShares(nodeOperatorId);
        uint256 sharesToClaim = requestedAmountToClaim <
            _ethByShares(claimableShares)
            ? _sharesByEth(requestedAmountToClaim)
            : claimableShares;
        if (sharesToClaim == 0) revert NothingToClaim();

        uint256[] memory amounts = new uint256[](1);
        amounts[0] = _ethByShares(sharesToClaim);
        uint256 sharesBefore = LIDO.sharesOf(address(this));
        uint256[] memory requestIds = WITHDRAWAL_QUEUE.requestWithdrawals(
            amounts,
            to
        );
        uint256 sharesAfter = LIDO.sharesOf(address(this));
        unchecked {
            _unsafeReduceBond(nodeOperatorId, sharesBefore - sharesAfter);
        }
        emit BondClaimedUnstETH(nodeOperatorId, to, amounts[0], requestIds[0]);
    }

    /// @dev Claim Node Operator's excess bond shares (stETH) in stETH by transferring shares from the contract
    function _claimStETH(
        uint256 nodeOperatorId,
        uint256 requestedAmountToClaim,
        address to
    ) internal {
        uint256 claimableShares = _getClaimableBondShares(nodeOperatorId);
        uint256 sharesToClaim = requestedAmountToClaim <
            _ethByShares(claimableShares)
            ? _sharesByEth(requestedAmountToClaim)
            : claimableShares;
        if (sharesToClaim == 0) revert NothingToClaim();
        _unsafeReduceBond(nodeOperatorId, sharesToClaim);

        uint256 ethAmount = LIDO.transferShares(to, sharesToClaim);
        emit BondClaimedStETH(nodeOperatorId, to, ethAmount);
    }

    /// @dev Claim Node Operator's excess bond shares (stETH) in wstETH by wrapping stETH from the contract and transferring wstETH
    function _claimWstETH(
        uint256 nodeOperatorId,
        uint256 requestedAmountToClaim,
        address to
    ) internal {
        uint256 claimableShares = _getClaimableBondShares(nodeOperatorId);
        uint256 sharesToClaim = requestedAmountToClaim < claimableShares
            ? requestedAmountToClaim
            : claimableShares;
        if (sharesToClaim == 0) revert NothingToClaim();
        uint256 sharesBefore = LIDO.sharesOf(address(this));
        uint256 amount = WSTETH.wrap(_ethByShares(sharesToClaim));
        uint256 sharesAfter = LIDO.sharesOf(address(this));
        unchecked {
            _unsafeReduceBond(nodeOperatorId, sharesBefore - sharesAfter);
        }
        WSTETH.transfer(to, amount);
        emit BondClaimedWstETH(nodeOperatorId, to, amount);
    }

    /// @dev Burn Node Operator's bond shares (stETH). Shares will be burned on the next stETH rebase
    /// @dev The method sender should be granted as `Burner.REQUEST_BURN_SHARES_ROLE` and make stETH allowance for `Burner`
    /// @param amount Bond amount to burn in ETH (stETH)
    function _burn(uint256 nodeOperatorId, uint256 amount) internal {
        uint256 toBurnShares = _sharesByEth(amount);
        uint256 burnedShares = _reduceBond(nodeOperatorId, toBurnShares);
        // If no bond already
        if (burnedShares == 0) return;

        IBurner(LIDO_LOCATOR.burner()).requestBurnShares(
            address(this),
            burnedShares
        );
        emit BondBurned(
            nodeOperatorId,
            _ethByShares(toBurnShares),
            _ethByShares(burnedShares)
        );
    }

    /// @dev Transfer Node Operator's bond shares (stETH) to charge recipient to pay some fee
    /// @param amount Bond amount to charge in ETH (stETH)
    function _charge(
        uint256 nodeOperatorId,
        uint256 amount,
        address recipient
    ) internal returns (uint256 chargedShares) {
        uint256 toChargeShares = _sharesByEth(amount);
        chargedShares = _reduceBond(nodeOperatorId, toChargeShares);
        uint256 chargedEth = LIDO.transferShares(recipient, chargedShares);
        emit BondCharged(
            nodeOperatorId,
            _ethByShares(toChargeShares),
            chargedEth
        );
    }

    /// @dev Must be overridden in case of additional restrictions on a claimable bond amount
    function _getClaimableBondShares(
        uint256 nodeOperatorId
    ) internal view virtual returns (uint256) {
        return _getCSBondCoreStorage().bondShares[nodeOperatorId];
    }

    /// @dev Shortcut for Lido's getSharesByPooledEth
    function _sharesByEth(uint256 ethAmount) internal view returns (uint256) {
        if (ethAmount == 0) return 0;
        return LIDO.getSharesByPooledEth(ethAmount);
    }

    /// @dev Shortcut for Lido's getPooledEthByShares
    function _ethByShares(uint256 shares) internal view returns (uint256) {
        if (shares == 0) return 0;
        return LIDO.getPooledEthByShares(shares);
    }

    /// @dev Unsafe reduce bond shares (stETH) (possible underflow). Safety checks should be done outside
    function _unsafeReduceBond(uint256 nodeOperatorId, uint256 shares) private {
        CSBondCoreStorage storage $ = _getCSBondCoreStorage();
        unchecked {
            $.bondShares[nodeOperatorId] -= shares;
            $.totalBondShares -= shares;
        }
    }

    /// @dev Safe reduce bond shares (stETH). The maximum shares to reduce is the current bond shares
    function _reduceBond(
        uint256 nodeOperatorId,
        uint256 shares
    ) private returns (uint256 reducedShares) {
        uint256 currentShares = getBondShares(nodeOperatorId);
        reducedShares = shares < currentShares ? shares : currentShares;
        _unsafeReduceBond(nodeOperatorId, reducedShares);
    }

    function _getCSBondCoreStorage()
        private
        pure
        returns (CSBondCoreStorage storage $)
    {
        assembly {
            $.slot := CS_BOND_CORE_STORAGE_LOCATION
        }
    }
}

File 7 of 43 : CSBondCurve.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { Arrays } from "@openzeppelin/contracts/utils/Arrays.sol";
import { ICSBondCurve } from "../interfaces/ICSBondCurve.sol";

/// @dev Bond curve mechanics abstract contract
///
/// It gives the ability to build bond curves for flexible bond math.
/// There is a default bond curve for all Node Operators, which might be 'overridden' for a particular Node Operator.
///
/// It contains:
///  - add bond curve
///  - get bond curve info
///  - set default bond curve
///  - set bond curve for the given Node Operator
///  - get bond curve for the given Node Operator
///  - get required bond amount for the given keys count
///  - get keys count for the given bond amount
///
/// It should be inherited by a module contract or a module-related contract.
/// Internal non-view methods should be used in the Module contract with additional requirements (if any).
///
/// @author vgorkavenko
abstract contract CSBondCurve is ICSBondCurve, Initializable {
    using Arrays for uint256[];

    /// @custom:storage-location erc7201:CSAccounting.CSBondCurve
    struct CSBondCurveStorage {
        BondCurve[] bondCurves;
        /// @dev Mapping of Node Operator id to bond curve id
        mapping(uint256 nodeOperatorId => uint256 bondCurveId) operatorBondCurveId;
    }

    // keccak256(abi.encode(uint256(keccak256("CSBondCurve")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant CS_BOND_CURVE_STORAGE_LOCATION =
        0x8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe1500;

    uint256 public constant MIN_CURVE_LENGTH = 1;
    uint256 public constant DEFAULT_BOND_CURVE_ID = 0;
    uint256 public immutable MAX_CURVE_LENGTH;

    event BondCurveAdded(uint256[] bondCurve);
    event BondCurveUpdated(uint256 indexed curveId, uint256[] bondCurve);
    event BondCurveSet(uint256 indexed nodeOperatorId, uint256 curveId);

    error InvalidBondCurveLength();
    error InvalidBondCurveMaxLength();
    error InvalidBondCurveValues();
    error InvalidBondCurveId();
    error InvalidInitialisationCurveId();

    constructor(uint256 maxCurveLength) {
        if (maxCurveLength < MIN_CURVE_LENGTH)
            revert InvalidBondCurveMaxLength();
        MAX_CURVE_LENGTH = maxCurveLength;
    }

    /// @dev Get default bond curve info if `curveId` is `0` or invalid
    /// @notice Return bond curve for the given curve id
    /// @param curveId Curve id to get bond curve for
    /// @return Bond curve
    function getCurveInfo(
        uint256 curveId
    ) public view returns (BondCurve memory) {
        return _getCSBondCurveStorage().bondCurves[curveId];
    }

    /// @notice Get bond curve for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Bond curve
    function getBondCurve(
        uint256 nodeOperatorId
    ) public view returns (BondCurve memory) {
        return getCurveInfo(getBondCurveId(nodeOperatorId));
    }

    /// @notice Get bond curve ID for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Bond curve ID
    function getBondCurveId(
        uint256 nodeOperatorId
    ) public view returns (uint256) {
        return _getCSBondCurveStorage().operatorBondCurveId[nodeOperatorId];
    }

    /// @notice Get required bond in ETH for the given number of keys for default bond curve
    /// @dev To calculate the amount for the new keys 2 calls are required:
    ///      getBondAmountByKeysCount(newTotal) - getBondAmountByKeysCount(currentTotal)
    /// @param keys Number of keys to get required bond for
    /// @param curveId Id of the curve to perform calculations against
    /// @return Amount for particular keys count
    function getBondAmountByKeysCount(
        uint256 keys,
        uint256 curveId
    ) public view returns (uint256) {
        return getBondAmountByKeysCount(keys, getCurveInfo(curveId));
    }

    /// @notice Get keys count for the given bond amount with default bond curve
    /// @param amount Bond amount in ETH (stETH)to get keys count for
    /// @param curveId Id of the curve to perform calculations against
    /// @return Keys count
    function getKeysCountByBondAmount(
        uint256 amount,
        uint256 curveId
    ) public view returns (uint256) {
        return getKeysCountByBondAmount(amount, getCurveInfo(curveId));
    }

    /// @notice Get required bond in ETH for the given number of keys for particular bond curve.
    /// @dev To calculate the amount for the new keys 2 calls are required:
    ///      getBondAmountByKeysCount(newTotal, curve) - getBondAmountByKeysCount(currentTotal, curve)
    /// @param keys Number of keys to get required bond for
    /// @param curve Bond curve to perform calculations against
    /// @return Required bond amount in ETH (stETH) for particular keys count
    function getBondAmountByKeysCount(
        uint256 keys,
        BondCurve memory curve
    ) public pure returns (uint256) {
        if (keys == 0) return 0;
        uint256 len = curve.points.length;
        return
            keys > len
                ? curve.points.unsafeMemoryAccess(len - 1) +
                    (keys - len) *
                    curve.trend
                : curve.points.unsafeMemoryAccess(keys - 1);
    }

    /// @notice Get keys count for the given bond amount for particular bond curve.
    /// @param amount Bond amount to get keys count for
    /// @param curve Bond curve to perform calculations against
    /// @return Keys count
    function getKeysCountByBondAmount(
        uint256 amount,
        BondCurve memory curve
    ) public pure returns (uint256) {
        if (amount < curve.points.unsafeMemoryAccess(0)) return 0;
        uint256 len = curve.points.length;
        uint256 maxCurveAmount = curve.points.unsafeMemoryAccess(len - 1);
        unchecked {
            return
                amount < maxCurveAmount
                    ? _searchKeysCount(amount, curve.points)
                    : len + (amount - maxCurveAmount) / curve.trend;
        }
    }

    // solhint-disable-next-line func-name-mixedcase
    function __CSBondCurve_init(
        uint256[] calldata defaultBondCurvePoints
    ) internal onlyInitializing {
        uint256 addedId = _addBondCurve(defaultBondCurvePoints);
        if (addedId != DEFAULT_BOND_CURVE_ID)
            revert InvalidInitialisationCurveId();
    }

    /// @dev Add a new bond curve to the array
    function _addBondCurve(
        uint256[] calldata curvePoints
    ) internal returns (uint256) {
        CSBondCurveStorage storage $ = _getCSBondCurveStorage();

        _checkBondCurve(curvePoints);
        unchecked {
            uint256 curveTrend = curvePoints[curvePoints.length - 1] -
                // if the curve length is 1, then 0 is used as the previous value to calculate the trend
                (
                    curvePoints.length > 1
                        ? curvePoints[curvePoints.length - 2]
                        : 0
                );
            $.bondCurves.push(
                BondCurve({ points: curvePoints, trend: curveTrend })
            );
            emit BondCurveAdded(curvePoints);
            return $.bondCurves.length - 1;
        }
    }

    /// @dev Update existing bond curve
    function _updateBondCurve(
        uint256 curveId,
        uint256[] calldata curvePoints
    ) internal {
        CSBondCurveStorage storage $ = _getCSBondCurveStorage();
        unchecked {
            if (curveId > $.bondCurves.length - 1) revert InvalidBondCurveId();

            _checkBondCurve(curvePoints);

            uint256 curveTrend = curvePoints[curvePoints.length - 1] -
                // if the curve length is 1, then 0 is used as the previous value to calculate the trend
                (
                    curvePoints.length > 1
                        ? curvePoints[curvePoints.length - 2]
                        : 0
                );
            $.bondCurves[curveId] = BondCurve({
                points: curvePoints,
                trend: curveTrend
            });
        }
        emit BondCurveUpdated(curveId, curvePoints);
    }

    /// @dev Sets bond curve for the given Node Operator
    ///      It will be used for the Node Operator instead of the previously set curve
    function _setBondCurve(uint256 nodeOperatorId, uint256 curveId) internal {
        CSBondCurveStorage storage $ = _getCSBondCurveStorage();
        unchecked {
            if (curveId > $.bondCurves.length - 1) revert InvalidBondCurveId();
        }
        $.operatorBondCurveId[nodeOperatorId] = curveId;
        emit BondCurveSet(nodeOperatorId, curveId);
    }

    /// @dev Reset bond curve for the given Node Operator to default.
    ///      (for example, because of breaking the rules by Node Operator)
    function _resetBondCurve(uint256 nodeOperatorId) internal {
        CSBondCurveStorage storage $ = _getCSBondCurveStorage();
        if ($.operatorBondCurveId[nodeOperatorId] == DEFAULT_BOND_CURVE_ID)
            return;

        $.operatorBondCurveId[nodeOperatorId] = DEFAULT_BOND_CURVE_ID;
        emit BondCurveSet(nodeOperatorId, DEFAULT_BOND_CURVE_ID);
    }

    function _checkBondCurve(uint256[] calldata curvePoints) private view {
        if (
            curvePoints.length < MIN_CURVE_LENGTH ||
            curvePoints.length > MAX_CURVE_LENGTH
        ) revert InvalidBondCurveLength();
        if (curvePoints[0] == 0) revert InvalidBondCurveValues();
        for (uint256 i = 1; i < curvePoints.length; ++i) {
            unchecked {
                if (curvePoints[i] <= curvePoints[i - 1])
                    revert InvalidBondCurveValues();
            }
        }
    }

    function _searchKeysCount(
        uint256 amount,
        uint256[] memory curvePoints
    ) private pure returns (uint256) {
        unchecked {
            uint256 low;
            // @dev Curves of a length = 1 are handled in the parent method
            uint256 high = curvePoints.length - 2;
            uint256 mid;
            uint256 midAmount;
            while (low <= high) {
                mid = (low + high) / 2;
                midAmount = curvePoints.unsafeMemoryAccess(mid);
                if (amount == midAmount) {
                    return mid + 1;
                }
                // underflow is excluded by the conditions in the parent method
                if (amount < midAmount) {
                    high = mid - 1;
                } else if (amount > midAmount) {
                    low = mid + 1;
                }
            }
            return low;
        }
    }

    function _getCSBondCurveStorage()
        private
        pure
        returns (CSBondCurveStorage storage $)
    {
        assembly {
            $.slot := CS_BOND_CURVE_STORAGE_LOCATION
        }
    }
}

File 8 of 43 : CSBondLock.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { ICSBondLock } from "../interfaces/ICSBondLock.sol";

/// @dev Bond lock mechanics abstract contract.
///
/// It gives the ability to lock the bond amount of the Node Operator.
/// There is a period of time during which the module can settle the lock in any way (for example, by penalizing the bond).
/// After that period, the lock is removed, and the bond amount is considered unlocked.
///
/// The contract contains:
///  - set default bond lock retention period
///  - get default bond lock retention period
///  - lock bond
///  - get locked bond info
///  - get actual locked bond amount
///  - reduce locked bond amount
///  - remove bond lock
///
/// It should be inherited by a module contract or a module-related contract.
/// Internal non-view methods should be used in the Module contract with additional requirements (if any).
///
/// @author vgorkavenko
abstract contract CSBondLock is ICSBondLock, Initializable {
    using SafeCast for uint256;

    /// @custom:storage-location erc7201:CSAccounting.CSBondLock
    struct CSBondLockStorage {
        /// @dev Default bond lock retention period for all locks
        ///      After this period the bond lock is removed and no longer valid
        uint256 bondLockRetentionPeriod;
        /// @dev Mapping of the Node Operator id to the bond lock
        mapping(uint256 nodeOperatorId => BondLock) bondLock;
    }

    // keccak256(abi.encode(uint256(keccak256("CSBondLock")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant CS_BOND_LOCK_STORAGE_LOCATION =
        0x78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f00;

    uint256 public immutable MIN_BOND_LOCK_RETENTION_PERIOD;
    uint256 public immutable MAX_BOND_LOCK_RETENTION_PERIOD;

    event BondLockChanged(
        uint256 indexed nodeOperatorId,
        uint256 newAmount,
        uint256 retentionUntil
    );
    event BondLockRemoved(uint256 indexed nodeOperatorId);

    event BondLockRetentionPeriodChanged(uint256 retentionPeriod);

    error InvalidBondLockRetentionPeriod();
    error InvalidBondLockAmount();

    constructor(
        uint256 minBondLockRetentionPeriod,
        uint256 maxBondLockRetentionPeriod
    ) {
        if (minBondLockRetentionPeriod > maxBondLockRetentionPeriod) {
            revert InvalidBondLockRetentionPeriod();
        }
        // retention period can not be more than type(uint64).max to avoid overflow when setting bond lock
        if (maxBondLockRetentionPeriod > type(uint64).max) {
            revert InvalidBondLockRetentionPeriod();
        }
        MIN_BOND_LOCK_RETENTION_PERIOD = minBondLockRetentionPeriod;
        MAX_BOND_LOCK_RETENTION_PERIOD = maxBondLockRetentionPeriod;
    }

    /// @notice Get default bond lock retention period
    /// @return Default bond lock retention period
    function getBondLockRetentionPeriod() external view returns (uint256) {
        return _getCSBondLockStorage().bondLockRetentionPeriod;
    }

    /// @notice Get information about the locked bond for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Locked bond info
    function getLockedBondInfo(
        uint256 nodeOperatorId
    ) public view returns (BondLock memory) {
        return _getCSBondLockStorage().bondLock[nodeOperatorId];
    }

    /// @notice Get amount of the locked bond in ETH (stETH) by the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Amount of the actual locked bond
    function getActualLockedBond(
        uint256 nodeOperatorId
    ) public view returns (uint256) {
        BondLock storage bondLock = _getCSBondLockStorage().bondLock[
            nodeOperatorId
        ];
        return bondLock.retentionUntil > block.timestamp ? bondLock.amount : 0;
    }

    /// @dev Lock bond amount for the given Node Operator until the retention period.
    function _lock(uint256 nodeOperatorId, uint256 amount) internal {
        CSBondLockStorage storage $ = _getCSBondLockStorage();
        if (amount == 0) {
            revert InvalidBondLockAmount();
        }
        if ($.bondLock[nodeOperatorId].retentionUntil > block.timestamp) {
            amount += $.bondLock[nodeOperatorId].amount;
        }
        _changeBondLock({
            nodeOperatorId: nodeOperatorId,
            amount: amount,
            retentionUntil: block.timestamp + $.bondLockRetentionPeriod
        });
    }

    /// @dev Reduce locked bond amount for the given Node Operator without changing retention period
    function _reduceAmount(uint256 nodeOperatorId, uint256 amount) internal {
        uint256 blocked = getActualLockedBond(nodeOperatorId);
        if (amount == 0) {
            revert InvalidBondLockAmount();
        }
        if (blocked < amount) {
            revert InvalidBondLockAmount();
        }
        unchecked {
            _changeBondLock(
                nodeOperatorId,
                blocked - amount,
                _getCSBondLockStorage().bondLock[nodeOperatorId].retentionUntil
            );
        }
    }

    /// @dev Remove bond lock for the given Node Operator
    function _remove(uint256 nodeOperatorId) internal {
        delete _getCSBondLockStorage().bondLock[nodeOperatorId];
        emit BondLockRemoved(nodeOperatorId);
    }

    // solhint-disable-next-line func-name-mixedcase
    function __CSBondLock_init(
        uint256 retentionPeriod
    ) internal onlyInitializing {
        _setBondLockRetentionPeriod(retentionPeriod);
    }

    /// @dev Set default bond lock retention period. That period will be sum with the current block timestamp of lock tx
    function _setBondLockRetentionPeriod(uint256 retentionPeriod) internal {
        if (
            retentionPeriod < MIN_BOND_LOCK_RETENTION_PERIOD ||
            retentionPeriod > MAX_BOND_LOCK_RETENTION_PERIOD
        ) {
            revert InvalidBondLockRetentionPeriod();
        }
        _getCSBondLockStorage().bondLockRetentionPeriod = retentionPeriod;
        emit BondLockRetentionPeriodChanged(retentionPeriod);
    }

    function _changeBondLock(
        uint256 nodeOperatorId,
        uint256 amount,
        uint256 retentionUntil
    ) private {
        if (amount == 0) {
            _remove(nodeOperatorId);
            return;
        }
        _getCSBondLockStorage().bondLock[nodeOperatorId] = BondLock({
            amount: amount.toUint128(),
            retentionUntil: retentionUntil.toUint128()
        });
        emit BondLockChanged(nodeOperatorId, amount, retentionUntil);
    }

    function _getCSBondLockStorage()
        private
        pure
        returns (CSBondLockStorage storage $)
    {
        assembly {
            $.slot := CS_BOND_LOCK_STORAGE_LOCATION
        }
    }
}

File 9 of 43 : ICSModule.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { IStakingModule } from "./IStakingModule.sol";
import { ICSAccounting } from "./ICSAccounting.sol";
import { IQueueLib } from "../lib/QueueLib.sol";
import { INOAddresses } from "../lib/NOAddresses.sol";
import { IAssetRecovererLib } from "../lib/AssetRecovererLib.sol";

struct NodeOperator {
    // All the counters below are used together e.g. in the _updateDepositableValidatorsCount
    /* 1 */ uint32 totalAddedKeys; // @dev increased and decreased when removed
    /* 1 */ uint32 totalWithdrawnKeys; // @dev only increased
    /* 1 */ uint32 totalDepositedKeys; // @dev only increased
    /* 1 */ uint32 totalVettedKeys; // @dev both increased and decreased
    /* 1 */ uint32 stuckValidatorsCount; // @dev both increased and decreased
    /* 1 */ uint32 depositableValidatorsCount; // @dev any value
    /* 1 */ uint32 targetLimit;
    /* 1 */ uint8 targetLimitMode;
    /* 2 */ uint32 totalExitedKeys; // @dev only increased
    /* 2 */ uint32 enqueuedCount; // Tracks how many places are occupied by the node operator's keys in the queue.
    /* 2 */ address managerAddress;
    /* 3 */ address proposedManagerAddress;
    /* 4 */ address rewardAddress;
    /* 5 */ address proposedRewardAddress;
    /* 5 */ bool extendedManagerPermissions;
}

struct NodeOperatorManagementProperties {
    address managerAddress;
    address rewardAddress;
    bool extendedManagerPermissions;
}

/// @title Lido's Community Staking Module interface
interface ICSModule is
    IStakingModule,
    IQueueLib,
    INOAddresses,
    IAssetRecovererLib
{
    error NodeOperatorDoesNotExist();
    error ZeroRewardAddress();

    /// @notice Gets node operator non-withdrawn keys
    /// @param nodeOperatorId ID of the node operator
    /// @return Non-withdrawn keys count
    function getNodeOperatorNonWithdrawnKeys(
        uint256 nodeOperatorId
    ) external view returns (uint256);

    /// @notice Returns the node operator by id
    /// @param nodeOperatorId Node Operator id
    function getNodeOperator(
        uint256 nodeOperatorId
    ) external view returns (NodeOperator memory);

    /// @notice Gets node operator signing keys
    /// @param nodeOperatorId ID of the node operator
    /// @param startIndex Index of the first key
    /// @param keysCount Count of keys to get
    /// @return Signing keys
    function getSigningKeys(
        uint256 nodeOperatorId,
        uint256 startIndex,
        uint256 keysCount
    ) external view returns (bytes memory);

    /// @notice Gets node operator signing keys with signatures
    /// @param nodeOperatorId ID of the node operator
    /// @param startIndex Index of the first key
    /// @param keysCount Count of keys to get
    /// @return keys Signing keys
    /// @return signatures Signatures of (deposit_message, domain) tuples
    function getSigningKeysWithSignatures(
        uint256 nodeOperatorId,
        uint256 startIndex,
        uint256 keysCount
    ) external view returns (bytes memory keys, bytes memory signatures);

    /// @notice Report node operator's key as slashed and apply initial slashing penalty.
    /// @param nodeOperatorId Operator ID in the module.
    /// @param keyIndex Index of the slashed key in the node operator's keys.
    function submitInitialSlashing(
        uint256 nodeOperatorId,
        uint256 keyIndex
    ) external;

    /// @notice Report node operator's key as withdrawn and settle withdrawn amount.
    /// @param nodeOperatorId Operator ID in the module.
    /// @param keyIndex Index of the withdrawn key in the node operator's keys.
    /// @param amount Amount of withdrawn ETH in wei.
    /// @param isSlashed Validator is slashed or not
    function submitWithdrawal(
        uint256 nodeOperatorId,
        uint256 keyIndex,
        uint256 amount,
        bool isSlashed
    ) external;

    function depositWstETH(
        uint256 nodeOperatorId,
        uint256 wstETHAmount,
        ICSAccounting.PermitInput calldata permit
    ) external;

    function depositStETH(
        uint256 nodeOperatorId,
        uint256 stETHAmount,
        ICSAccounting.PermitInput calldata permit
    ) external;

    function depositETH(uint256 nodeOperatorId) external payable;
}

File 10 of 43 : ICSAccounting.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { ICSBondCore } from "./ICSBondCore.sol";
import { ICSBondCurve } from "./ICSBondCurve.sol";
import { ICSBondLock } from "./ICSBondLock.sol";
import { ICSFeeDistributor } from "./ICSFeeDistributor.sol";
import { IAssetRecovererLib } from "../lib/AssetRecovererLib.sol";

interface ICSAccounting is
    ICSBondCore,
    ICSBondCurve,
    ICSBondLock,
    IAssetRecovererLib
{
    struct PermitInput {
        uint256 value;
        uint256 deadline;
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    function feeDistributor() external view returns (ICSFeeDistributor);

    function chargePenaltyRecipient() external view returns (address);

    function getRequiredBondForNextKeys(
        uint256 nodeOperatorId,
        uint256 additionalKeys
    ) external view returns (uint256);

    function getBondAmountByKeysCountWstETH(
        uint256 keysCount,
        uint256 curveId
    ) external view returns (uint256);

    function getBondAmountByKeysCountWstETH(
        uint256 keysCount,
        BondCurve memory curve
    ) external view returns (uint256);

    function getRequiredBondForNextKeysWstETH(
        uint256 nodeOperatorId,
        uint256 additionalKeys
    ) external view returns (uint256);

    function getUnbondedKeysCount(
        uint256 nodeOperatorId
    ) external view returns (uint256);

    function getUnbondedKeysCountToEject(
        uint256 nodeOperatorId
    ) external view returns (uint256);

    function depositWstETH(
        address from,
        uint256 nodeOperatorId,
        uint256 wstETHAmount,
        PermitInput calldata permit
    ) external;

    function depositStETH(
        address from,
        uint256 nodeOperatorId,
        uint256 stETHAmount,
        PermitInput calldata permit
    ) external;

    function depositETH(address from, uint256 nodeOperatorId) external payable;

    function claimRewardsStETH(
        uint256 nodeOperatorId,
        uint256 stETHAmount,
        address rewardAddress,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) external;

    function claimRewardsWstETH(
        uint256 nodeOperatorId,
        uint256 wstETHAmount,
        address rewardAddress,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) external;

    function claimRewardsUnstETH(
        uint256 nodeOperatorId,
        uint256 stEthAmount,
        address rewardAddress,
        uint256 cumulativeFeeShares,
        bytes32[] calldata rewardsProof
    ) external;

    function lockBondETH(uint256 nodeOperatorId, uint256 amount) external;

    function releaseLockedBondETH(
        uint256 nodeOperatorId,
        uint256 amount
    ) external;

    function settleLockedBondETH(uint256 nodeOperatorId) external;

    function compensateLockedBondETH(uint256 nodeOperatorId) external payable;

    function setBondCurve(uint256 nodeOperatorId, uint256 curveId) external;

    function resetBondCurve(uint256 nodeOperatorId) external;

    function penalize(uint256 nodeOperatorId, uint256 amount) external;

    function chargeFee(uint256 nodeOperatorId, uint256 amount) external;
}

File 11 of 43 : ICSFeeDistributor.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

import { IAssetRecovererLib } from "../lib/AssetRecovererLib.sol";

pragma solidity 0.8.24;

interface ICSFeeDistributor is IAssetRecovererLib {
    function getFeesToDistribute(
        uint256 nodeOperatorId,
        uint256 shares,
        bytes32[] calldata proof
    ) external view returns (uint256);

    function distributeFees(
        uint256 nodeOperatorId,
        uint256 shares,
        bytes32[] calldata proof
    ) external returns (uint256);

    function processOracleReport(
        bytes32 _treeRoot,
        string calldata _treeCid,
        uint256 _distributedShares
    ) external;

    /// @notice Returns the amount of shares that are pending to be distributed
    function pendingSharesToDistribute() external view returns (uint256);
}

File 12 of 43 : AssetRecoverer.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { AssetRecovererLib } from "../lib/AssetRecovererLib.sol";

/// @title AssetRecoverer
/// @dev Abstract contract providing mechanisms for recovering various asset types (ETH, ERC20, ERC721, ERC1155) from a contract.
///      This contract is designed to allow asset recovery by an authorized address by implementing the onlyRecovererRole guardian
/// @notice Assets can be sent only to the `msg.sender`
abstract contract AssetRecoverer {
    /// @dev Allows sender to recover Ether held by the contract
    /// Emits an EtherRecovered event upon success
    function recoverEther() external {
        _onlyRecoverer();
        AssetRecovererLib.recoverEther();
    }

    /// @dev Allows sender to recover ERC20 tokens held by the contract
    /// @param token The address of the ERC20 token to recover
    /// Emits an ERC20Recovered event upon success
    /// Optionally, the inheriting contract can override this function to add additional restrictions
    function recoverERC20(address token, uint256 amount) external virtual {
        _onlyRecoverer();
        AssetRecovererLib.recoverERC20(token, amount);
    }

    /// @dev Allows sender to recover ERC721 tokens held by the contract
    /// @param token The address of the ERC721 token to recover
    /// @param tokenId The token ID of the ERC721 token to recover
    /// Emits an ERC721Recovered event upon success
    function recoverERC721(address token, uint256 tokenId) external {
        _onlyRecoverer();
        AssetRecovererLib.recoverERC721(token, tokenId);
    }

    /// @dev Allows sender to recover ERC1155 tokens held by the contract.
    /// @param token The address of the ERC1155 token to recover.
    /// @param tokenId The token ID of the ERC1155 token to recover.
    /// Emits an ERC1155Recovered event upon success.
    function recoverERC1155(address token, uint256 tokenId) external {
        _onlyRecoverer();
        AssetRecovererLib.recoverERC1155(token, tokenId);
    }

    /// @dev Guardian to restrict access to the recover methods.
    ///      Should be implemented by the inheriting contract
    function _onlyRecoverer() internal view virtual;
}

File 13 of 43 : AssetRecovererLib.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.24;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ILido } from "../interfaces/ILido.sol";

interface IAssetRecovererLib {
    event EtherRecovered(address indexed recipient, uint256 amount);
    event ERC20Recovered(
        address indexed token,
        address indexed recipient,
        uint256 amount
    );
    event StETHSharesRecovered(address indexed recipient, uint256 shares);
    event ERC721Recovered(
        address indexed token,
        uint256 tokenId,
        address indexed recipient
    );
    event ERC1155Recovered(
        address indexed token,
        uint256 tokenId,
        address indexed recipient,
        uint256 amount
    );

    error FailedToSendEther();
    error NotAllowedToRecover();
}

/*
 * @title AssetRecovererLib
 * @dev Library providing mechanisms for recovering various asset types (ETH, ERC20, ERC721, ERC1155).
 * This library is designed to be used by a contract that implements the AssetRecoverer interface.
 */
library AssetRecovererLib {
    using SafeERC20 for IERC20;

    /**
     * @dev Allows the sender to recover Ether held by the contract.
     * Emits an EtherRecovered event upon success.
     */
    function recoverEther() external {
        uint256 amount = address(this).balance;
        (bool success, ) = msg.sender.call{ value: amount }("");
        if (!success) revert IAssetRecovererLib.FailedToSendEther();
        emit IAssetRecovererLib.EtherRecovered(msg.sender, amount);
    }

    /**
     * @dev Allows the sender to recover ERC20 tokens held by the contract.
     * @param token The address of the ERC20 token to recover.
     * @param amount The amount of the ERC20 token to recover.
     * Emits an ERC20Recovered event upon success.
     */
    function recoverERC20(address token, uint256 amount) external {
        IERC20(token).safeTransfer(msg.sender, amount);
        emit IAssetRecovererLib.ERC20Recovered(token, msg.sender, amount);
    }

    /**
     * @dev Allows the sender to recover stETH shares held by the contract.
     * The use of a separate method for stETH is to avoid rounding problems when converting shares to stETH.
     * @param lido The address of the Lido contract.
     * @param shares The amount of stETH shares to recover.
     * Emits an StETHRecovered event upon success.
     */
    function recoverStETHShares(address lido, uint256 shares) external {
        ILido(lido).transferShares(msg.sender, shares);
        emit IAssetRecovererLib.StETHSharesRecovered(msg.sender, shares);
    }

    /**
     * @dev Allows the sender to recover ERC721 tokens held by the contract.
     * @param token The address of the ERC721 token to recover.
     * @param tokenId The token ID of the ERC721 token to recover.
     * Emits an ERC721Recovered event upon success.
     */
    function recoverERC721(address token, uint256 tokenId) external {
        IERC721(token).safeTransferFrom(address(this), msg.sender, tokenId);
        emit IAssetRecovererLib.ERC721Recovered(token, tokenId, msg.sender);
    }

    /**
     * @dev Allows the sender to recover ERC1155 tokens held by the contract.
     * @param token The address of the ERC1155 token to recover.
     * @param tokenId The token ID of the ERC1155 token to recover.
     * Emits an ERC1155Recovered event upon success.
     */
    function recoverERC1155(address token, uint256 tokenId) external {
        uint256 amount = IERC1155(token).balanceOf(address(this), tokenId);
        IERC1155(token).safeTransferFrom({
            from: address(this),
            to: msg.sender,
            id: tokenId,
            value: amount,
            data: ""
        });
        emit IAssetRecovererLib.ERC1155Recovered(
            token,
            tokenId,
            msg.sender,
            amount
        );
    }
}

File 14 of 43 : UnstructuredStorage.sol
/*
 * SPDX-License-Identifier: MIT
 */

pragma solidity 0.8.24;

/**
 * @notice Aragon Unstructured Storage library
 */
library UnstructuredStorage {
    function setStorageAddress(bytes32 position, address data) internal {
        assembly {
            sstore(position, data)
        }
    }

    function setStorageUint256(bytes32 position, uint256 data) internal {
        assembly {
            sstore(position, data)
        }
    }

    function getStorageAddress(
        bytes32 position
    ) internal view returns (address data) {
        assembly {
            data := sload(position)
        }
    }

    function getStorageUint256(
        bytes32 position
    ) internal view returns (uint256 data) {
        assembly {
            data := sload(position)
        }
    }
}

File 15 of 43 : IAccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "../IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 16 of 43 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;


    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
    struct AccessControlStorage {
        mapping(bytes32 role => RoleData) _roles;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;

    function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
        assembly {
            $.slot := AccessControlStorageLocation
        }
    }

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        return $._roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        return $._roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        AccessControlStorage storage $ = _getAccessControlStorage();
        bytes32 previousAdminRole = getRoleAdmin(role);
        $._roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (!hasRole(role, account)) {
            $._roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (hasRole(role, account)) {
            $._roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

File 17 of 43 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position is the index of the value in the `values` array plus 1.
        // Position 0 is used to mean a value is not in the set.
        mapping(bytes32 value => uint256) _positions;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._positions[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We cache the value's position to prevent multiple reads from the same storage slot
        uint256 position = set._positions[value];

        if (position != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 valueIndex = position - 1;
            uint256 lastIndex = set._values.length - 1;

            if (valueIndex != lastIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._positions[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 18 of 43 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

File 19 of 43 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 20 of 43 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

File 21 of 43 : ILidoLocator.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

interface ILidoLocator {
    error ZeroAddress();

    function accountingOracle() external view returns (address);

    function burner() external view returns (address);

    function coreComponents()
        external
        view
        returns (address, address, address, address, address, address);

    function depositSecurityModule() external view returns (address);

    function elRewardsVault() external view returns (address);

    function legacyOracle() external view returns (address);

    function lido() external view returns (address);

    function oracleDaemonConfig() external view returns (address);

    function oracleReportComponentsForLido()
        external
        view
        returns (address, address, address, address, address, address, address);

    function oracleReportSanityChecker() external view returns (address);

    function postTokenRebaseReceiver() external view returns (address);

    function stakingRouter() external view returns (address payable);

    function treasury() external view returns (address);

    function validatorsExitBusOracle() external view returns (address);

    function withdrawalQueue() external view returns (address);

    function withdrawalVault() external view returns (address);
}

File 22 of 43 : ILido.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { IStETH } from "./IStETH.sol";

/**
 * @title Interface defining Lido contract
 */
interface ILido is IStETH {
    function STAKING_CONTROL_ROLE() external view returns (bytes32);

    function submit(address _referal) external payable returns (uint256);

    function deposit(
        uint256 _maxDepositsCount,
        uint256 _stakingModuleId,
        bytes calldata _depositCalldata
    ) external;

    function removeStakingLimit() external;

    function kernel() external returns (address);

    function sharesOf(address _account) external view returns (uint256);
}

File 23 of 43 : IBurner.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

interface IBurner {
    function REQUEST_BURN_SHARES_ROLE() external view returns (bytes32);

    function DEFAULT_ADMIN_ROLE() external view returns (bytes32);

    function getRoleMember(
        bytes32 role,
        uint256 index
    ) external view returns (address);

    function grantRole(bytes32 role, address account) external;

    function hasRole(
        bytes32 role,
        address account
    ) external view returns (bool);

    function requestBurnShares(
        address _from,
        uint256 _sharesAmountToBurn
    ) external;
}

File 24 of 43 : IWstETH.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

interface IWstETH {
    function balanceOf(address account) external view returns (uint256);

    function approve(address _spender, uint256 _amount) external returns (bool);

    function wrap(uint256 _stETHAmount) external returns (uint256);

    function unwrap(uint256 _wstETHAmount) external returns (uint256);

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external;

    function transfer(address recipient, uint256 amount) external;

    function getStETHByWstETH(
        uint256 _wstETHAmount
    ) external view returns (uint256);

    function getWstETHByStETH(
        uint256 _stETHAmount
    ) external view returns (uint256);

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    function allowance(
        address _owner,
        address _spender
    ) external view returns (uint256);
}

File 25 of 43 : IWithdrawalQueue.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

interface IWithdrawalQueue {
    struct WithdrawalRequestStatus {
        /// @notice stETH token amount that was locked on withdrawal queue for this request
        uint256 amountOfStETH;
        /// @notice amount of stETH shares locked on withdrawal queue for this request
        uint256 amountOfShares;
        /// @notice address that can claim or transfer this request
        address owner;
        /// @notice timestamp of when the request was created, in seconds
        uint256 timestamp;
        /// @notice true, if request is finalized
        bool isFinalized;
        /// @notice true, if request is claimed. Request is claimable if (isFinalized && !isClaimed)
        bool isClaimed;
    }

    function ORACLE_ROLE() external view returns (bytes32);

    function getRoleMember(
        bytes32 role,
        uint256 index
    ) external view returns (address);

    function WSTETH() external view returns (address);

    /// @notice minimal amount of stETH that is possible to withdraw
    function MIN_STETH_WITHDRAWAL_AMOUNT() external view returns (uint256);

    /// @notice maximum amount of stETH that is possible to withdraw by a single request
    /// Prevents accumulating too much funds per single request fulfillment in the future.
    /// @dev To withdraw larger amounts, it's recommended to split it to several requests
    function MAX_STETH_WITHDRAWAL_AMOUNT() external view returns (uint256);

    function requestWithdrawals(
        uint256[] calldata _amounts,
        address _owner
    ) external returns (uint256[] memory requestIds);

    function getWithdrawalStatus(
        uint256[] calldata _requestIds
    ) external view returns (WithdrawalRequestStatus[] memory statuses);

    function getWithdrawalRequests(
        address _owner
    ) external view returns (uint256[] memory requestsIds);

    function isBunkerModeActive() external view returns (bool);

    function onOracleReport(
        bool _isBunkerModeNow,
        uint256 _bunkerStartTimestamp,
        uint256 _currentReportTimestamp
    ) external;
}

File 26 of 43 : ICSBondCore.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

interface ICSBondCore {
    function totalBondShares() external view returns (uint256);

    function getBondShares(
        uint256 nodeOperatorId
    ) external view returns (uint256);

    function getBond(uint256 nodeOperatorId) external view returns (uint256);
}

File 27 of 43 : Arrays.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol)

pragma solidity ^0.8.20;

import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";

/**
 * @dev Collection of functions related to array types.
 */
library Arrays {
    using StorageSlot for bytes32;

    /**
     * @dev Searches a sorted `array` and returns the first index that contains
     * a value greater or equal to `element`. If no such index exists (i.e. all
     * values in the array are strictly less than `element`), the array length is
     * returned. Time complexity O(log n).
     *
     * `array` is expected to be sorted in ascending order, and to contain no
     * repeated elements.
     */
    function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
        uint256 low = 0;
        uint256 high = array.length;

        if (high == 0) {
            return 0;
        }

        while (low < high) {
            uint256 mid = Math.average(low, high);

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because Math.average rounds towards zero (it does integer division with truncation).
            if (unsafeAccess(array, mid).value > element) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
        if (low > 0 && unsafeAccess(array, low - 1).value == element) {
            return low - 1;
        } else {
            return low;
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getAddressSlot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getBytes32Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getUint256Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }
}

File 28 of 43 : ICSBondCurve.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

interface ICSBondCurve {
    /// @dev Bond curve structure.
    /// It contains:
    ///  - points |> total bond amount for particular keys count
    ///  - trend  |> value for the next keys after described points
    ///
    /// For example, how the curve points look like:
    ///   Points Array Index  |>       0          1          2          i
    ///   Bond Amount         |>   [ 2 ETH ] [ 3.9 ETH ] [ 5.7 ETH ] [ ... ]
    ///   Keys Count          |>       1          2          3        i + 1
    ///
    ///   Bond Amount (ETH)
    ///       ^
    ///       |
    ///     6 -
    ///       | ------------------ 5.7 ETH --> .
    ///   5.5 -                              ..^
    ///       |                             .  |
    ///     5 -                            .   |
    ///       |                           .    |
    ///   4.5 -                          .     |
    ///       |                         .      |
    ///     4 -                       ..       |
    ///       | ------- 3.9 ETH --> ..         |
    ///   3.5 -                    .^          |
    ///       |                  .. |          |
    ///     3 -                ..   |          |
    ///       |               .     |          |
    ///   2.5 -              .      |          |
    ///       |            ..       |          |
    ///     2 - -------->..         |          |
    ///       |          ^          |          |
    ///       |----------|----------|----------|----------|----> Keys Count
    ///       |          1          2          3          i
    ///
    struct BondCurve {
        uint256[] points;
        uint256 trend;
    }

    // solhint-disable-next-line
    function DEFAULT_BOND_CURVE_ID() external view returns (uint256);

    function getCurveInfo(
        uint256 curveId
    ) external view returns (BondCurve memory);

    function getBondCurve(
        uint256 nodeOperatorId
    ) external view returns (BondCurve memory);

    function getBondCurveId(
        uint256 nodeOperatorId
    ) external view returns (uint256);

    function getBondAmountByKeysCount(
        uint256 keys,
        uint256 curveId
    ) external view returns (uint256);

    function getBondAmountByKeysCount(
        uint256 keys,
        BondCurve memory curve
    ) external view returns (uint256);

    function getKeysCountByBondAmount(
        uint256 amount,
        uint256 curveId
    ) external view returns (uint256);

    function getKeysCountByBondAmount(
        uint256 amount,
        BondCurve memory curve
    ) external view returns (uint256);
}

File 29 of 43 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }
}

File 30 of 43 : ICSBondLock.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

interface ICSBondLock {
    /// @dev Bond lock structure.
    /// It contains:
    ///  - amount         |> amount of locked bond
    ///  - retentionUntil |> timestamp until locked bond is retained
    struct BondLock {
        uint128 amount;
        uint128 retentionUntil;
    }

    function getBondLockRetentionPeriod()
        external
        view
        returns (uint256 retention);

    function getLockedBondInfo(
        uint256 nodeOperatorId
    ) external view returns (BondLock memory);

    function getActualLockedBond(
        uint256 nodeOperatorId
    ) external view returns (uint256);
}

File 31 of 43 : IStakingModule.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

/// @title Lido's Staking Module interface
interface IStakingModule {
    /// @notice Returns the type of the staking module
    function getType() external view returns (bytes32);

    /// @notice Returns all-validators summary in the staking module
    /// @return totalExitedValidators total number of validators in the EXITED state
    ///     on the Consensus Layer. This value can't decrease in normal conditions
    /// @return totalDepositedValidators total number of validators deposited via the
    ///     official Deposit Contract. This value is a cumulative counter: even when the validator
    ///     goes into EXITED state this counter is not decreasing
    /// @return depositableValidatorsCount number of validators in the set available for deposit
    function getStakingModuleSummary()
        external
        view
        returns (
            uint256 totalExitedValidators,
            uint256 totalDepositedValidators,
            uint256 depositableValidatorsCount
        );

    /// @notice Returns all-validators summary belonging to the node operator with the given id
    /// @param _nodeOperatorId id of the operator to return report for
    /// @return targetLimitMode shows whether the current target limit applied to the node operator (1 = soft mode, 2 = forced mode)
    /// @return targetValidatorsCount relative target active validators limit for operator
    /// @return stuckValidatorsCount number of validators with an expired request to exit time
    /// @return refundedValidatorsCount number of validators that can't be withdrawn, but deposit
    ///     costs were compensated to the Lido by the node operator
    /// @return stuckPenaltyEndTimestamp time when the penalty for stuck validators stops applying
    ///     to node operator rewards
    /// @return totalExitedValidators total number of validators in the EXITED state
    ///     on the Consensus Layer. This value can't decrease in normal conditions
    /// @return totalDepositedValidators total number of validators deposited via the official
    ///     Deposit Contract. This value is a cumulative counter: even when the validator goes into
    ///     EXITED state this counter is not decreasing
    /// @return depositableValidatorsCount number of validators in the set available for deposit
    function getNodeOperatorSummary(
        uint256 _nodeOperatorId
    )
        external
        view
        returns (
            uint256 targetLimitMode,
            uint256 targetValidatorsCount,
            uint256 stuckValidatorsCount,
            uint256 refundedValidatorsCount,
            uint256 stuckPenaltyEndTimestamp,
            uint256 totalExitedValidators,
            uint256 totalDepositedValidators,
            uint256 depositableValidatorsCount
        );

    /// @notice Returns a counter that MUST change its value whenever the deposit data set changes.
    ///     Below is the typical list of actions that requires an update of the nonce:
    ///     1. a node operator's deposit data is added
    ///     2. a node operator's deposit data is removed
    ///     3. a node operator's ready-to-deposit data size is changed
    ///     4. a node operator was activated/deactivated
    ///     5. a node operator's deposit data is used for the deposit
    ///     Note: Depending on the StakingModule implementation above list might be extended
    /// @dev In some scenarios, it's allowed to update nonce without actual change of the deposit
    ///      data subset, but it MUST NOT lead to the DOS of the staking module via continuous
    ///      update of the nonce by the malicious actor
    function getNonce() external view returns (uint256);

    /// @notice Returns total number of node operators
    function getNodeOperatorsCount() external view returns (uint256);

    /// @notice Returns number of active node operators
    function getActiveNodeOperatorsCount() external view returns (uint256);

    /// @notice Returns if the node operator with given id is active
    /// @param _nodeOperatorId Id of the node operator
    function getNodeOperatorIsActive(
        uint256 _nodeOperatorId
    ) external view returns (bool);

    /// @notice Returns up to `_limit` node operator ids starting from the `_offset`. The order of
    ///     the returned ids is not defined and might change between calls.
    /// @dev This view must not revert in case of invalid data passed. When `_offset` exceeds the
    ///     total node operators count or when `_limit` is equal to 0 MUST be returned empty array.
    function getNodeOperatorIds(
        uint256 _offset,
        uint256 _limit
    ) external view returns (uint256[] memory nodeOperatorIds);

    /// @notice Called by StakingRouter to signal that stETH rewards were minted for this module.
    /// @param _totalShares Amount of stETH shares that were minted to reward all node operators.
    /// @dev IMPORTANT: this method SHOULD revert with empty error data ONLY because of "out of gas".
    ///      Details about error data: https://docs.soliditylang.org/en/v0.8.9/control-structures.html#error-handling-assert-require-revert-and-exceptions
    function onRewardsMinted(uint256 _totalShares) external;

    /// @notice Called by StakingRouter to decrease the number of vetted keys for node operator with given id
    /// @param _nodeOperatorIds bytes packed array of the node operators id
    /// @param _vettedSigningKeysCounts bytes packed array of the new number of vetted keys for the node operators
    function decreaseVettedSigningKeysCount(
        bytes calldata _nodeOperatorIds,
        bytes calldata _vettedSigningKeysCounts
    ) external;

    /// @notice Updates the number of the validators of the given node operator that were requested
    ///         to exit but failed to do so in the max allowed time
    /// @param _nodeOperatorIds bytes packed array of the node operators id
    /// @param _stuckValidatorsCounts bytes packed array of the new number of STUCK validators for the node operators
    function updateStuckValidatorsCount(
        bytes calldata _nodeOperatorIds,
        bytes calldata _stuckValidatorsCounts
    ) external;

    /// @notice Updates the number of the validators in the EXITED state for node operator with given id
    /// @param _nodeOperatorIds bytes packed array of the node operators id
    /// @param _exitedValidatorsCounts bytes packed array of the new number of EXITED validators for the node operators
    function updateExitedValidatorsCount(
        bytes calldata _nodeOperatorIds,
        bytes calldata _exitedValidatorsCounts
    ) external;

    /// @notice Updates the number of the refunded validators for node operator with the given id
    /// @param _nodeOperatorId Id of the node operator
    /// @param _refundedValidatorsCount New number of refunded validators of the node operator
    function updateRefundedValidatorsCount(
        uint256 _nodeOperatorId,
        uint256 _refundedValidatorsCount
    ) external;

    /// @notice Updates the limit of the validators that can be used for deposit
    /// @param _nodeOperatorId Id of the node operator
    /// @param _targetLimitMode target limit mode
    /// @param _targetLimit Target limit of the node operator
    function updateTargetValidatorsLimits(
        uint256 _nodeOperatorId,
        uint256 _targetLimitMode,
        uint256 _targetLimit
    ) external;

    /// @notice Unsafely updates the number of validators in the EXITED/STUCK states for node operator with given id
    ///      'unsafely' means that this method can both increase and decrease exited and stuck counters
    /// @param _nodeOperatorId Id of the node operator
    /// @param _exitedValidatorsCount New number of EXITED validators for the node operator
    /// @param _stuckValidatorsCount New number of STUCK validator for the node operator
    function unsafeUpdateValidatorsCount(
        uint256 _nodeOperatorId,
        uint256 _exitedValidatorsCount,
        uint256 _stuckValidatorsCount
    ) external;

    /// @notice Obtains deposit data to be used by StakingRouter to deposit to the Ethereum Deposit
    ///     contract
    /// @dev The method MUST revert when the staking module has not enough deposit data items
    /// @param _depositsCount Number of deposits to be done
    /// @param _depositCalldata Staking module defined data encoded as bytes.
    ///        IMPORTANT: _depositCalldata MUST NOT modify the deposit data set of the staking module
    /// @return publicKeys Batch of the concatenated public validators keys
    /// @return signatures Batch of the concatenated deposit signatures for returned public keys
    function obtainDepositData(
        uint256 _depositsCount,
        bytes calldata _depositCalldata
    ) external returns (bytes memory publicKeys, bytes memory signatures);

    /// @notice Called by StakingRouter after it finishes updating exited and stuck validators
    /// counts for this module's node operators.
    ///
    /// Guaranteed to be called after an oracle report is applied, regardless of whether any node
    /// operator in this module has actually received any updated counts as a result of the report
    /// but given that the total number of exited validators returned from getStakingModuleSummary
    /// is the same as StakingRouter expects based on the total count received from the oracle.
    ///
    /// @dev IMPORTANT: this method SHOULD revert with empty error data ONLY because of "out of gas".
    ///      Details about error data: https://docs.soliditylang.org/en/v0.8.9/control-structures.html#error-handling-assert-require-revert-and-exceptions
    function onExitedAndStuckValidatorsCountsUpdated() external;

    /// @notice Called by StakingRouter when withdrawal credentials are changed.
    /// @dev This method MUST discard all StakingModule's unused deposit data cause they become
    ///      invalid after the withdrawal credentials are changed
    ///
    /// @dev IMPORTANT: this method SHOULD revert with empty error data ONLY because of "out of gas".
    ///      Details about error data: https://docs.soliditylang.org/en/v0.8.9/control-structures.html#error-handling-assert-require-revert-and-exceptions
    function onWithdrawalCredentialsChanged() external;

    /// @dev Event to be emitted on StakingModule's nonce change
    event NonceChanged(uint256 nonce);

    /// @dev Event to be emitted when a signing key is added to the StakingModule
    event SigningKeyAdded(uint256 indexed nodeOperatorId, bytes pubkey);

    /// @dev Event to be emitted when a signing key is removed from the StakingModule
    event SigningKeyRemoved(uint256 indexed nodeOperatorId, bytes pubkey);
}

File 32 of 43 : QueueLib.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.24;

import { NodeOperator } from "../interfaces/ICSModule.sol";
import { TransientUintUintMap, TransientUintUintMapLib } from "./TransientUintUintMapLib.sol";

// Batch is an uint256 as it's the internal data type used by solidity.
// Batch is a packed value, consisting of the following fields:
//    - uint64  nodeOperatorId
//    - uint64  keysCount -- count of keys enqueued by the batch
//    - uint128 next -- index of the next batch in the queue
type Batch is uint256;

/// @notice Batch of the operator with index 0, with no keys in it and the next Batch' index 0 is meaningless.
function isNil(Batch self) pure returns (bool) {
    return Batch.unwrap(self) == 0;
}

/// @dev Syntactic sugar for the type.
function unwrap(Batch self) pure returns (uint256) {
    return Batch.unwrap(self);
}

function noId(Batch self) pure returns (uint64 n) {
    assembly {
        n := shr(192, self)
    }
}

function keys(Batch self) pure returns (uint64 n) {
    assembly {
        n := shl(64, self)
        n := shr(192, n)
    }
}

function next(Batch self) pure returns (uint128 n) {
    assembly {
        n := self // uint128(self)
    }
}

/// @dev keys count cast is unsafe
function setKeys(Batch self, uint256 keysCount) pure returns (Batch) {
    assembly {
        self := or(
            and(
                self,
                0xffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffff
            ),
            shl(128, and(keysCount, 0xffffffffffffffff))
        ) // self.keys = keysCount
    }

    return self;
}

/// @dev can be unsafe if the From batch is previous to the self
function setNext(Batch self, Batch from) pure returns (Batch) {
    assembly {
        self := or(
            and(
                self,
                0xffffffffffffffffffffffffffffffff00000000000000000000000000000000
            ),
            and(
                from,
                0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff
            )
        ) // self.next = from.next
    }
    return self;
}

/// @dev Instantiate a new Batch to be added to the queue. The `next` field will be determined upon the enqueue.
/// @dev Parameters are uint256 to make usage easier.
function createBatch(
    uint256 nodeOperatorId,
    uint256 keysCount
) pure returns (Batch item) {
    // NOTE: No need to safe cast due to internal logic.
    nodeOperatorId = uint64(nodeOperatorId);
    keysCount = uint64(keysCount);

    assembly {
        item := shl(128, keysCount) // `keysCount` in [64:127]
        item := or(item, shl(192, nodeOperatorId)) // `nodeOperatorId` in [0:63]
    }
}

using { noId, keys, setKeys, setNext, next, isNil, unwrap } for Batch global;
using QueueLib for QueueLib.Queue;

interface IQueueLib {
    event BatchEnqueued(uint256 indexed nodeOperatorId, uint256 count);

    error QueueIsEmpty();
    error QueueLookupNoLimit();
}

/// @author madlabman
library QueueLib {
    struct Queue {
        // Pointer to the item to be dequeued.
        uint128 head;
        // Tracks the total number of batches ever enqueued.
        uint128 tail;
        // Mapping saves a little in costs and allows easily fallback to a zeroed batch on out-of-bounds access.
        mapping(uint128 => Batch) queue;
    }

    //////
    /// External methods
    //////
    function normalize(
        Queue storage self,
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 nodeOperatorId
    ) external {
        NodeOperator storage no = nodeOperators[nodeOperatorId];
        uint32 depositable = no.depositableValidatorsCount;
        uint32 enqueued = no.enqueuedCount;

        if (enqueued < depositable) {
            uint32 count;
            unchecked {
                count = depositable - enqueued;
            }
            no.enqueuedCount = depositable;
            self.enqueue(nodeOperatorId, count);
        }
    }

    function clean(
        Queue storage self,
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 maxItems
    ) external returns (uint256 removed, uint256 lastRemovedAtDepth) {
        if (maxItems == 0) revert IQueueLib.QueueLookupNoLimit();

        Batch prev;
        uint128 indexOfPrev;

        uint128 head = self.head;
        uint128 curr = head;

        TransientUintUintMap queueLookup = TransientUintUintMapLib.create();

        for (uint256 i; i < maxItems; ++i) {
            Batch item = self.queue[curr];
            if (item.isNil()) {
                break;
            }

            NodeOperator storage no = nodeOperators[item.noId()];
            if (queueLookup.get(item.noId()) >= no.depositableValidatorsCount) {
                // NOTE: Since we reached that point there's no way for a Node Operator to have a depositable batch
                // later in the queue, and hence we don't update _queueLookup for the Node Operator.
                if (curr == head) {
                    self.dequeue();
                    head = self.head;
                } else {
                    // There's no `prev` item while we call `dequeue`, and removing an item will keep the `prev` intact
                    // other than changing its `next` field.
                    prev = prev.setNext(item);
                    self.queue[indexOfPrev] = prev;
                }

                // We assume that the invariant `enqueuedCount` >= `keys` is kept.
                // NOTE: No need to safe cast due to internal logic.
                no.enqueuedCount -= uint32(item.keys());

                unchecked {
                    lastRemovedAtDepth = i + 1;
                    ++removed;
                }
            } else {
                queueLookup.add(item.noId(), item.keys());
                indexOfPrev = curr;
                prev = item;
            }

            curr = item.next();
        }
    }

    /////
    /// Internal methods
    /////
    function enqueue(
        Queue storage self,
        uint256 nodeOperatorId,
        uint256 keysCount
    ) internal returns (Batch item) {
        uint128 tail = self.tail;
        item = createBatch(nodeOperatorId, keysCount);

        assembly {
            item := or(
                and(
                    item,
                    0xffffffffffffffffffffffffffffffff00000000000000000000000000000000
                ),
                add(tail, 1)
            ) // item.next = self.tail + 1;
        }

        self.queue[tail] = item;
        unchecked {
            ++self.tail;
        }
        emit IQueueLib.BatchEnqueued(nodeOperatorId, keysCount);
    }

    function dequeue(Queue storage self) internal returns (Batch item) {
        item = peek(self);

        if (item.isNil()) {
            revert IQueueLib.QueueIsEmpty();
        }

        self.head = item.next();
    }

    function peek(Queue storage self) internal view returns (Batch) {
        return self.queue[self.head];
    }

    function at(
        Queue storage self,
        uint128 index
    ) internal view returns (Batch) {
        return self.queue[index];
    }
}

File 33 of 43 : NOAddresses.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.24;

import { NodeOperator, ICSModule } from "../interfaces/ICSModule.sol";

/// Library for changing and reset node operator's manager and reward addresses
/// @dev the only use of this to be a library is to save CSModule contract size via delegatecalls
interface INOAddresses {
    event NodeOperatorManagerAddressChangeProposed(
        uint256 indexed nodeOperatorId,
        address indexed oldProposedAddress,
        address indexed newProposedAddress
    );
    event NodeOperatorRewardAddressChangeProposed(
        uint256 indexed nodeOperatorId,
        address indexed oldProposedAddress,
        address indexed newProposedAddress
    );
    // args order as in https://github.com/OpenZeppelin/openzeppelin-contracts/blob/11dc5e3809ebe07d5405fe524385cbe4f890a08b/contracts/access/Ownable.sol#L33
    event NodeOperatorManagerAddressChanged(
        uint256 indexed nodeOperatorId,
        address indexed oldAddress,
        address indexed newAddress
    );
    event NodeOperatorRewardAddressChanged(
        uint256 indexed nodeOperatorId,
        address indexed oldAddress,
        address indexed newAddress
    );

    error AlreadyProposed();
    error SameAddress();
    error SenderIsNotManagerAddress();
    error SenderIsNotRewardAddress();
    error SenderIsNotProposedAddress();
    error MethodCallIsNotAllowed();
}

library NOAddresses {
    /// @notice Propose a new manager address for the Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @param proposedAddress Proposed manager address
    function proposeNodeOperatorManagerAddressChange(
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 nodeOperatorId,
        address proposedAddress
    ) external {
        NodeOperator storage no = nodeOperators[nodeOperatorId];
        if (no.managerAddress == address(0))
            revert ICSModule.NodeOperatorDoesNotExist();
        if (no.managerAddress != msg.sender)
            revert INOAddresses.SenderIsNotManagerAddress();
        if (no.managerAddress == proposedAddress)
            revert INOAddresses.SameAddress();
        if (no.proposedManagerAddress == proposedAddress)
            revert INOAddresses.AlreadyProposed();

        address oldProposedAddress = no.proposedManagerAddress;
        no.proposedManagerAddress = proposedAddress;

        emit INOAddresses.NodeOperatorManagerAddressChangeProposed(
            nodeOperatorId,
            oldProposedAddress,
            proposedAddress
        );
    }

    /// @notice Confirm a new manager address for the Node Operator.
    ///         Should be called from the currently proposed address
    /// @param nodeOperatorId ID of the Node Operator
    function confirmNodeOperatorManagerAddressChange(
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 nodeOperatorId
    ) external {
        NodeOperator storage no = nodeOperators[nodeOperatorId];
        if (no.managerAddress == address(0))
            revert ICSModule.NodeOperatorDoesNotExist();
        if (no.proposedManagerAddress != msg.sender)
            revert INOAddresses.SenderIsNotProposedAddress();

        address oldAddress = no.managerAddress;
        no.managerAddress = msg.sender;
        delete no.proposedManagerAddress;

        emit INOAddresses.NodeOperatorManagerAddressChanged(
            nodeOperatorId,
            oldAddress,
            msg.sender
        );
    }

    /// @notice Propose a new reward address for the Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @param proposedAddress Proposed reward address
    function proposeNodeOperatorRewardAddressChange(
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 nodeOperatorId,
        address proposedAddress
    ) external {
        NodeOperator storage no = nodeOperators[nodeOperatorId];
        if (no.rewardAddress == address(0))
            revert ICSModule.NodeOperatorDoesNotExist();
        if (no.rewardAddress != msg.sender)
            revert INOAddresses.SenderIsNotRewardAddress();
        if (no.rewardAddress == proposedAddress)
            revert INOAddresses.SameAddress();
        if (no.proposedRewardAddress == proposedAddress)
            revert INOAddresses.AlreadyProposed();

        address oldProposedAddress = no.proposedRewardAddress;
        no.proposedRewardAddress = proposedAddress;

        emit INOAddresses.NodeOperatorRewardAddressChangeProposed(
            nodeOperatorId,
            oldProposedAddress,
            proposedAddress
        );
    }

    /// @notice Confirm a new reward address for the Node Operator.
    ///         Should be called from the currently proposed address
    /// @param nodeOperatorId ID of the Node Operator
    function confirmNodeOperatorRewardAddressChange(
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 nodeOperatorId
    ) external {
        NodeOperator storage no = nodeOperators[nodeOperatorId];
        if (no.rewardAddress == address(0))
            revert ICSModule.NodeOperatorDoesNotExist();
        if (no.proposedRewardAddress != msg.sender)
            revert INOAddresses.SenderIsNotProposedAddress();

        address oldAddress = no.rewardAddress;
        no.rewardAddress = msg.sender;
        delete no.proposedRewardAddress;

        emit INOAddresses.NodeOperatorRewardAddressChanged(
            nodeOperatorId,
            oldAddress,
            msg.sender
        );
    }

    /// @notice Reset the manager address to the reward address.
    ///         Should be called from the reward address
    /// @param nodeOperatorId ID of the Node Operator
    function resetNodeOperatorManagerAddress(
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 nodeOperatorId
    ) external {
        NodeOperator storage no = nodeOperators[nodeOperatorId];
        if (no.rewardAddress == address(0))
            revert ICSModule.NodeOperatorDoesNotExist();
        if (no.extendedManagerPermissions)
            revert INOAddresses.MethodCallIsNotAllowed();
        if (no.rewardAddress != msg.sender)
            revert INOAddresses.SenderIsNotRewardAddress();
        if (no.managerAddress == no.rewardAddress)
            revert INOAddresses.SameAddress();
        address previousManagerAddress = no.managerAddress;

        no.managerAddress = no.rewardAddress;
        // @dev Gas golfing
        if (no.proposedManagerAddress != address(0))
            delete no.proposedManagerAddress;

        emit INOAddresses.NodeOperatorManagerAddressChanged(
            nodeOperatorId,
            previousManagerAddress,
            no.rewardAddress
        );
    }

    /// @notice Change rewardAddress if extendedManagerPermissions is enabled for the Node Operator.
    ///         Should be called from the current manager address
    /// @param nodeOperatorId ID of the Node Operator
    /// @param newAddress New reward address
    function changeNodeOperatorRewardAddress(
        mapping(uint256 => NodeOperator) storage nodeOperators,
        uint256 nodeOperatorId,
        address newAddress
    ) external {
        NodeOperator storage no = nodeOperators[nodeOperatorId];
        if (no.managerAddress == address(0))
            revert ICSModule.NodeOperatorDoesNotExist();
        if (!no.extendedManagerPermissions)
            revert INOAddresses.MethodCallIsNotAllowed();
        if (no.managerAddress != msg.sender)
            revert INOAddresses.SenderIsNotManagerAddress();

        address oldAddress = no.rewardAddress;
        no.rewardAddress = newAddress;
        // @dev Gas golfing
        if (no.proposedRewardAddress != address(0))
            delete no.proposedRewardAddress;

        emit INOAddresses.NodeOperatorRewardAddressChanged(
            nodeOperatorId,
            oldAddress,
            newAddress
        );
    }
}

File 34 of 43 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 35 of 43 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the value of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}

File 36 of 43 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

File 37 of 43 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 38 of 43 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165Upgradeable is Initializable, IERC165 {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 39 of 43 : IStETH.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

/**
 * @title Interface defining ERC20-compatible StETH token
 */
interface IStETH {
    /**
     * @notice Get stETH amount by the provided shares amount
     * @param _sharesAmount shares amount
     * @dev dual to `getSharesByPooledEth`.
     */
    function getPooledEthByShares(
        uint256 _sharesAmount
    ) external view returns (uint256);

    /**
     * @notice Get shares amount by the provided stETH amount
     * @param _pooledEthAmount stETH amount
     * @dev dual to `getPooledEthByShares`.
     */
    function getSharesByPooledEth(
        uint256 _pooledEthAmount
    ) external view returns (uint256);

    /**
     * @notice Get shares amount of the provided account
     * @param _account provided account address.
     */
    function sharesOf(address _account) external view returns (uint256);

    function balanceOf(address _account) external view returns (uint256);

    /**
     * @notice Transfer `_sharesAmount` stETH shares from `_sender` to `_receiver` using allowance.
     */
    function transferSharesFrom(
        address _sender,
        address _recipient,
        uint256 _sharesAmount
    ) external returns (uint256);

    /**
     * @notice Moves `_sharesAmount` token shares from the caller's account to the `_recipient` account.
     */
    function transferShares(
        address _recipient,
        uint256 _sharesAmount
    ) external returns (uint256);

    /**
     * @notice Moves `_pooledEthAmount` stETH from the caller's account to the `_recipient` account.
     */
    function transfer(
        address _recipient,
        uint256 _amount
    ) external returns (bool);

    /**
     * @notice Moves `_pooledEthAmount` stETH from the `_sender` account to the `_recipient` account.
     */
    function transferFrom(
        address _sender,
        address _recipient,
        uint256 _amount
    ) external returns (bool);

    function approve(address _spender, uint256 _amount) external returns (bool);

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    function allowance(
        address _owner,
        address _spender
    ) external view returns (uint256);
}

File 40 of 43 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

File 41 of 43 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 42 of 43 : TransientUintUintMapLib.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

type TransientUintUintMap is uint256;

using TransientUintUintMapLib for TransientUintUintMap global;

library TransientUintUintMapLib {
    function create() internal returns (TransientUintUintMap self) {
        // keccak256(abi.encode(uint256(keccak256("TransientUintUintMap")) - 1)) & ~bytes32(uint256(0xff))
        uint256 anchor = 0x6e38e7eaa4307e6ee6c66720337876ca65012869fbef035f57219354c1728400;

        // `anchor` slot in the transient storage tracks the "address" of the last created object.
        // The next address is being computed as keccak256(`anchor` . `prev`).
        assembly ("memory-safe") {
            let prev := tload(anchor)
            mstore(0x00, anchor)
            mstore(0x20, prev)
            self := keccak256(0x00, 0x40)
            tstore(anchor, self)
        }
    }

    function add(
        TransientUintUintMap self,
        uint256 key,
        uint256 value
    ) internal {
        uint256 slot = _slot(self, key);
        assembly ("memory-safe") {
            let v := tload(slot)
            // NOTE: Here's no overflow check.
            v := add(v, value)
            tstore(slot, v)
        }
    }

    function get(
        TransientUintUintMap self,
        uint256 key
    ) internal view returns (uint256 v) {
        uint256 slot = _slot(self, key);
        assembly ("memory-safe") {
            v := tload(slot)
        }
    }

    function _slot(
        TransientUintUintMap self,
        uint256 key
    ) internal pure returns (uint256 slot) {
        // Compute an address in the transient storage in the same manner it works for storage mappings.
        // `slot` = keccak256(`self` . `key`)
        assembly ("memory-safe") {
            mstore(0x00, self)
            mstore(0x20, key)
            slot := keccak256(0x00, 0x40)
        }
    }
}

File 43 of 43 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
    "forge-std/=node_modules/forge-std/src/",
    "ds-test/=node_modules/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin-contracts-v4.4/=lib/openzeppelin-contracts-v4.4/contracts/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 250
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "none",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": false,
  "libraries": {
    "src/lib/AssetRecovererLib.sol": {
      "AssetRecovererLib": "0xD72E84a64b676097254cDA079d8B7b63C7988ECa"
    },
    "src/lib/NOAddresses.sol": {
      "NOAddresses": "0x449581f92CaB1c84e210a2304E041E116f5f8D69"
    },
    "src/lib/QueueLib.sol": {
      "QueueLib": "0x06AA73BAbC9c8bb8c7C2bee1f714a399d49b81bc"
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"lidoLocator","type":"address"},{"internalType":"address","name":"communityStakingModule","type":"address"},{"internalType":"uint256","name":"maxCurveLength","type":"uint256"},{"internalType":"uint256","name":"minBondLockRetentionPeriod","type":"uint256"},{"internalType":"uint256","name":"maxBondLockRetentionPeriod","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ElRewardsVaultReceiveFailed","type":"error"},{"inputs":[],"name":"FailedToSendEther","type":"error"},{"inputs":[],"name":"InvalidBondCurveId","type":"error"},{"inputs":[],"name":"InvalidBondCurveLength","type":"error"},{"inputs":[],"name":"InvalidBondCurveMaxLength","type":"error"},{"inputs":[],"name":"InvalidBondCurveValues","type":"error"},{"inputs":[],"name":"InvalidBondLockAmount","type":"error"},{"inputs":[],"name":"InvalidBondLockRetentionPeriod","type":"error"},{"inputs":[],"name":"InvalidInitialisationCurveId","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NodeOperatorDoesNotExist","type":"error"},{"inputs":[],"name":"NotAllowedToRecover","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NothingToClaim","type":"error"},{"inputs":[],"name":"PauseUntilMustBeInFuture","type":"error"},{"inputs":[],"name":"PausedExpected","type":"error"},{"inputs":[],"name":"ResumedExpected","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"SenderIsNotCSM","type":"error"},{"inputs":[],"name":"ZeroAdminAddress","type":"error"},{"inputs":[],"name":"ZeroChargePenaltyRecipientAddress","type":"error"},{"inputs":[],"name":"ZeroFeeDistributorAddress","type":"error"},{"inputs":[],"name":"ZeroLocatorAddress","type":"error"},{"inputs":[],"name":"ZeroModuleAddress","type":"error"},{"inputs":[],"name":"ZeroPauseDuration","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toBurnAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"burnedAmount","type":"uint256"}],"name":"BondBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toChargeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"chargedAmount","type":"uint256"}],"name":"BondCharged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BondClaimedStETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"BondClaimedUnstETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BondClaimedWstETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"bondCurve","type":"uint256[]"}],"name":"BondCurveAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"curveId","type":"uint256"}],"name":"BondCurveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"curveId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"bondCurve","type":"uint256[]"}],"name":"BondCurveUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BondDepositedETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BondDepositedStETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BondDepositedWstETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"retentionUntil","type":"uint256"}],"name":"BondLockChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BondLockCompensated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"BondLockRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"retentionPeriod","type":"uint256"}],"name":"BondLockRetentionPeriodChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"chargePenaltyRecipient","type":"address"}],"name":"ChargePenaltyRecipientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC1155Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"ERC721Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EtherRecovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[],"name":"Resumed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"StETHSharesRecovered","type":"event"},{"inputs":[],"name":"ACCOUNTING_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CSM","outputs":[{"internalType":"contract ICSModule","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_BOND_CURVE_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIDO","outputs":[{"internalType":"contract ILido","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIDO_LOCATOR","outputs":[{"internalType":"contract ILidoLocator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_BOND_CURVES_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_BOND_LOCK_RETENTION_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_CURVE_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_BOND_LOCK_RETENTION_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_CURVE_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSE_INFINITELY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RECOVERER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESET_BOND_CURVE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESUME_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_BOND_CURVE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWAL_QUEUE","outputs":[{"internalType":"contract IWithdrawalQueue","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WSTETH","outputs":[{"internalType":"contract IWstETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"bondCurve","type":"uint256[]"}],"name":"addBondCurve","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"chargeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"chargePenaltyRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"stETHAmount","type":"uint256"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"uint256","name":"cumulativeFeeShares","type":"uint256"},{"internalType":"bytes32[]","name":"rewardsProof","type":"bytes32[]"}],"name":"claimRewardsStETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"stEthAmount","type":"uint256"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"uint256","name":"cumulativeFeeShares","type":"uint256"},{"internalType":"bytes32[]","name":"rewardsProof","type":"bytes32[]"}],"name":"claimRewardsUnstETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"wstETHAmount","type":"uint256"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"uint256","name":"cumulativeFeeShares","type":"uint256"},{"internalType":"bytes32[]","name":"rewardsProof","type":"bytes32[]"}],"name":"claimRewardsWstETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"compensateLockedBondETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"stETHAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ICSAccounting.PermitInput","name":"permit","type":"tuple"}],"name":"depositStETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"wstETHAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ICSAccounting.PermitInput","name":"permit","type":"tuple"}],"name":"depositWstETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeDistributor","outputs":[{"internalType":"contract ICSFeeDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getActualLockedBond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getBond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"keys","type":"uint256"},{"components":[{"internalType":"uint256[]","name":"points","type":"uint256[]"},{"internalType":"uint256","name":"trend","type":"uint256"}],"internalType":"struct ICSBondCurve.BondCurve","name":"curve","type":"tuple"}],"name":"getBondAmountByKeysCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"keys","type":"uint256"},{"internalType":"uint256","name":"curveId","type":"uint256"}],"name":"getBondAmountByKeysCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"keysCount","type":"uint256"},{"internalType":"uint256","name":"curveId","type":"uint256"}],"name":"getBondAmountByKeysCountWstETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"keysCount","type":"uint256"},{"components":[{"internalType":"uint256[]","name":"points","type":"uint256[]"},{"internalType":"uint256","name":"trend","type":"uint256"}],"internalType":"struct ICSBondCurve.BondCurve","name":"curve","type":"tuple"}],"name":"getBondAmountByKeysCountWstETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getBondCurve","outputs":[{"components":[{"internalType":"uint256[]","name":"points","type":"uint256[]"},{"internalType":"uint256","name":"trend","type":"uint256"}],"internalType":"struct ICSBondCurve.BondCurve","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getBondCurveId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBondLockRetentionPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getBondShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getBondSummary","outputs":[{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getBondSummaryShares","outputs":[{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"curveId","type":"uint256"}],"name":"getCurveInfo","outputs":[{"components":[{"internalType":"uint256[]","name":"points","type":"uint256[]"},{"internalType":"uint256","name":"trend","type":"uint256"}],"internalType":"struct ICSBondCurve.BondCurve","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"uint256[]","name":"points","type":"uint256[]"},{"internalType":"uint256","name":"trend","type":"uint256"}],"internalType":"struct ICSBondCurve.BondCurve","name":"curve","type":"tuple"}],"name":"getKeysCountByBondAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"curveId","type":"uint256"}],"name":"getKeysCountByBondAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getLockedBondInfo","outputs":[{"components":[{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint128","name":"retentionUntil","type":"uint128"}],"internalType":"struct ICSBondLock.BondLock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"additionalKeys","type":"uint256"}],"name":"getRequiredBondForNextKeys","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"additionalKeys","type":"uint256"}],"name":"getRequiredBondForNextKeysWstETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getResumeSinceTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getUnbondedKeysCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"getUnbondedKeysCountToEject","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"bondCurve","type":"uint256[]"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"_feeDistributor","type":"address"},{"internalType":"uint256","name":"bondLockRetentionPeriod","type":"uint256"},{"internalType":"address","name":"_chargePenaltyRecipient","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"lockBondETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"pauseFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"penalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"cumulativeFeeShares","type":"uint256"},{"internalType":"bytes32[]","name":"rewardsProof","type":"bytes32[]"}],"name":"pullFeeRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"recoverERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"recoverERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"recoverEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"recoverStETHShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"releaseLockedBondETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renewBurnerAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"resetBondCurve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resume","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"curveId","type":"uint256"}],"name":"setBondCurve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_chargePenaltyRecipient","type":"address"}],"name":"setChargePenaltyRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"retention","type":"uint256"}],"name":"setLockedBondRetentionPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"}],"name":"settleLockedBondETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBondShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"curveId","type":"uint256"},{"internalType":"uint256[]","name":"bondCurve","type":"uint256[]"}],"name":"updateBondCurve","outputs":[],"stateMutability":"nonpayable","type":"function"}]

61018060405234801562000011575f80fd5b50604051620058a6380380620058a6833981016040819052620000349162000360565b818184876001600160a01b0381166200006057604051630f05a38b60e41b815260040160405180910390fd5b6001600160a01b0381166080819052604080516323509a2d60e01b815290516323509a2d916004808201926020929091908290030181865afa158015620000a9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620000cf9190620003af565b6001600160a01b031660a0816001600160a01b0316815250506080516001600160a01b03166337d5fe996040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000127573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200014d9190620003af565b6001600160a01b031660c081905260408051636cfdb21d60e11b8152905163d9fb643a916004808201926020929091908290030181865afa15801562000195573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620001bb9190620003af565b6001600160a01b031660e052506001811015620001eb57604051633ccaf40160e01b815260040160405180910390fd5b6101005280821115620002115760405163dee7108760e01b815260040160405180910390fd5b6001600160401b038111156200023a5760405163dee7108760e01b815260040160405180910390fd5b61012091909152610140526001600160a01b0384166200026d576040516378bc317d60e01b815260040160405180910390fd5b6001600160a01b038416610160526200028562000290565b5050505050620003d2565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620002e15760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620003415780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b80516001600160a01b03811681146200035b575f80fd5b919050565b5f805f805f60a0868803121562000375575f80fd5b620003808662000344565b9450620003906020870162000344565b6040870151606088015160809098015196999198509695945092505050565b5f60208284031215620003c0575f80fd5b620003cb8262000344565b9392505050565b60805160a05160c05160e051610100516101205161014051610160516152e9620005bd5f395f8181610af801528181611165015281816112fb015281816114290152818161149f0152818161195701528181611a0c01528181611b3701528181611ca101528181611ed101528181611f5c0152818161208f015281816120f0015281816121430152818161234201528181612512015281816126be0152818161270901528181612ba80152818161304e015261478e01525f818161085501526139cc01525f8181610c9301526139a301525f81816107e401526143ca01525f8181610e24015281816123b30152818161242f01528181612768015281816136a5015281816137f801528181613fad01526140a501525f8181610921015281816128190152613c0201525f8181610ac5015281816115100152818161158c0152818161176f0152818161180101528181611a6d015281816121e10152818161279701528181612848015281816128b501528181612d2201528181612e6d0152818161334e0152818161362f0152818161375b015281816138df01528181613b8c01528181613cb201528181613e460152818161401a0152818161412f015261427801525f8181610e57015281816111a601528181612210015281816128e4015261319f01526152e95ff3fe608060405260043610610463575f3560e01c80638980f11f11610241578063cb11c52711610134578063dcab7f83116100b3578063f3f449c711610078578063f3f449c714610f3c578063f7966efe14610f5b578063f939122314610f7a578063fab382f114610f99578063fee6380514610fb8575f80fd5b8063dcab7f8314610e98578063def82d0214610eb7578063e5220e3f14610eea578063ead42a6914610f09578063f3efecc414610f28575f80fd5b8063d8fe7642116100f9578063d8fe764214610dd5578063d963ae5514610df4578063d9fb643a14610e13578063dbba4b4814610e46578063dc38ea3d14610e79575f80fd5b8063cb11c52714610d45578063cc810cb914610d59578063ce19793f14610d78578063d2fa16a614610d97578063d547741f14610db6575f80fd5b80639c516102116101c0578063b148db6a11610185578063b148db6a14610cb5578063b187bd2614610cd4578063b2d03e4d14610ce8578063b5b624bf14610d07578063ca15c87314610d26575f80fd5b80639c51610214610c1c578063a217fddf146107a1578063a302ee3814610c3b578063acf1c94814610c4f578063ae84975614610c82575f80fd5b80639010d07c116102065780639010d07c14610b8157806391d1485414610ba05780639996522514610bbf5780639a4df8f014610bde5780639b4c6c2714610bfd575f80fd5b80638980f11f14610a955780638b21f17014610ab45780638de2b27214610ae75780638ed5c5d714610b1a5780638f6549ae14610b4d575f80fd5b80634342b3c111610359578063589ff76c116102d857806370903eb91161029d57806370903eb91461096f57806374d70aea1461098e578063819d4cc6146109c157806383316184146109e0578063881fa03c14610a76575f80fd5b8063589ff76c146108c95780635a73bdc8146108dd5780635c654ad9146108f1578063699340f4146109105780636e13f09914610943575f80fd5b80634c7ed3d21161031e5780634c7ed3d214610825578063526352fc1461084457806352d8bfc214610877578063546da24f1461088b578063573b6245146108aa575f80fd5b80634342b3c11461076e578063443fbfef146107a1578063449add1b146107b45780634b2ce9fe146107d35780634bb22a7214610806575f80fd5b8063165123dd116103e55780632e599054116103aa5780632e599054146106cb5780632f2ff15d146106de57806336568abe146106fd578063389ed2671461071c578063433cd6c31461074f575f80fd5b8063165123dd146105ed57806321d439d51461060c578063248a9ca31461063f57806328846981146106795780632de03aa114610698575f80fd5b806306cd0e901161042b57806306cd0e90146105475780630d43e8ad146105665780630f23e7421461059c57806313d1234b146105bb57806315b5c477146105da575f80fd5b8063019c1a4f1461046757806301a5e9e31461048857806301ffc9a7146104ba578063046f7da2146104e95780630569b947146104fd575b5f80fd5b348015610472575f80fd5b50610486610481366004614b81565b610feb565b005b348015610493575f80fd5b506104a76104a2366004614bc9565b611026565b6040519081526020015b60405180910390f35b3480156104c5575f80fd5b506104d96104d4366004614be0565b611038565b60405190151581526020016104b1565b3480156104f4575f80fd5b5061048661105c565b348015610508575f80fd5b506104a7610517366004614bc9565b5f9081527f8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe1501602052604090205490565b348015610552575f80fd5b506104a7610561366004614bc9565b611091565b348015610571575f80fd5b505f54610584906001600160a01b031681565b6040516001600160a01b0390911681526020016104b1565b3480156105a7575f80fd5b506104a76105b6366004614c98565b6110c1565b3480156105c6575f80fd5b506104a76105d5366004614d6d565b611140565b6104866105e8366004614bc9565b61115a565b3480156105f8575f80fd5b50600154610584906001600160a01b031681565b348015610617575f80fd5b506104a77fb5dffea014b759c493d63b1edaceb942631d6468998125e1b4fe427c9908213481565b34801561064a575f80fd5b506104a7610659366004614bc9565b5f9081525f805160206152bd833981519152602052604090206001015490565b348015610684575f80fd5b506104a7610693366004614d6d565b6112da565b3480156106a3575f80fd5b506104a77f2fc10cc8ae19568712f7a176fb4978616a610650813c9d05326c34abb62749c781565b6104866106d9366004614da1565b6112e8565b3480156106e9575f80fd5b506104866106f8366004614dcb565b611347565b348015610708575f80fd5b50610486610717366004614dcb565b611377565b348015610727575f80fd5b506104a77f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d81565b34801561075a575f80fd5b50610486610769366004614df9565b6113af565b348015610779575f80fd5b506104a77f645c9e6d2a86805cb5a28b1e4751c0dab493df7cf935070ce405489ba1a7bf7281565b3480156107ac575f80fd5b506104a75f81565b3480156107bf575f80fd5b506104866107ce366004614bc9565b6113e2565b3480156107de575f80fd5b506104a77f000000000000000000000000000000000000000000000000000000000000000081565b348015610811575f80fd5b50610486610820366004614bc9565b61141e565b348015610830575f80fd5b5061048661083f366004614e14565b61148c565b34801561084f575f80fd5b506104a77f000000000000000000000000000000000000000000000000000000000000000081565b348015610882575f80fd5b5061048661165c565b348015610896575f80fd5b506104a76108a5366004614d6d565b6116b8565b3480156108b5575f80fd5b506104a76108c4366004614e63565b6116c6565b3480156108d4575f80fd5b506104a76116fb565b3480156108e8575f80fd5b50610486611729565b3480156108fc575f80fd5b5061048661090b366004614da1565b61187e565b34801561091b575f80fd5b506105847f000000000000000000000000000000000000000000000000000000000000000081565b34801561094e575f80fd5b5061096261095d366004614bc9565b6118f9565b6040516104b19190614ea2565b34801561097a575f80fd5b50610486610989366004614efd565b611944565b348015610999575f80fd5b507f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec92101546104a7565b3480156109cc575f80fd5b506104866109db366004614da1565b6119b2565b3480156109eb575f80fd5b50610a4f6109fa366004614bc9565b6040805180820182525f80825260209182018190529283525f8051602061529d8339815191528152918190208151808301909252546001600160801b038082168352600160801b909104169181019190915290565b6040805182516001600160801b0390811682526020938401511692810192909252016104b1565b348015610a81575f80fd5b50610486610a90366004614d6d565b611a01565b348015610aa0575f80fd5b50610486610aaf366004614da1565b611a63565b348015610abf575f80fd5b506105847f000000000000000000000000000000000000000000000000000000000000000081565b348015610af2575f80fd5b506105847f000000000000000000000000000000000000000000000000000000000000000081565b348015610b25575f80fd5b506104a77f40579467dba486691cc62fd8536d22c6d4dc9cdc7bc716ef2518422aa554c09881565b348015610b58575f80fd5b50610b6c610b67366004614bc9565b611b04565b604080519283526020830191909152016104b1565b348015610b8c575f80fd5b50610584610b9b366004614d6d565b611bbe565b348015610bab575f80fd5b506104d9610bba366004614dcb565b611bf6565b348015610bca575f80fd5b50610486610bd9366004614bc9565b611c2c565b348015610be9575f80fd5b506104a7610bf8366004614c98565b611c5f565b348015610c08575f80fd5b50610486610c17366004614f6b565b611c6d565b348015610c27575f80fd5b506104a7610c36366004614bc9565b611c82565b348015610c46575f80fd5b506104a75f1981565b348015610c5a575f80fd5b506104a77fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc81565b348015610c8d575f80fd5b506104a77f000000000000000000000000000000000000000000000000000000000000000081565b348015610cc0575f80fd5b506104a7610ccf366004614d6d565b611c8d565b348015610cdf575f80fd5b506104d9611d69565b348015610cf3575f80fd5b50610486610d02366004614d6d565b611d99565b348015610d12575f80fd5b50610962610d21366004614bc9565b611dd6565b348015610d31575f80fd5b506104a7610d40366004614bc9565b611e87565b348015610d50575f80fd5b506104a7600181565b348015610d64575f80fd5b50610486610d73366004614efd565b611ebe565b348015610d83575f80fd5b50610b6c610d92366004614bc9565b611f2c565b348015610da2575f80fd5b506104a7610db1366004614c98565b611fde565b348015610dc1575f80fd5b50610486610dd0366004614dcb565b612042565b348015610de0575f80fd5b506104a7610def366004614bc9565b612072565b348015610dff575f80fd5b50610486610e0e366004614d6d565b612084565b348015610e1e575f80fd5b506105847f000000000000000000000000000000000000000000000000000000000000000081565b348015610e51575f80fd5b506105847f000000000000000000000000000000000000000000000000000000000000000081565b348015610e84575f80fd5b506104a7610e93366004614d6d565b6120d7565b348015610ea3575f80fd5b50610486610eb2366004614d6d565b6120e5565b348015610ec2575f80fd5b507f78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f00546104a7565b348015610ef5575f80fd5b50610486610f04366004614d6d565b612138565b348015610f14575f80fd5b506104a7610f23366004614bc9565b61218b565b348015610f33575f80fd5b506104866121df565b348015610f47575f80fd5b50610486610f56366004614bc9565b6122fc565b348015610f66575f80fd5b50610486610f75366004614e14565b61232f565b348015610f85575f80fd5b50610486610f94366004614efd565b6124ff565b348015610fa4575f80fd5b50610486610fb3366004614fba565b61256d565b348015610fc3575f80fd5b506104a77fd35e4a788498271198ec69c34f1dc762a1eee8200c111f598da1b3dde946783d81565b7fd35e4a788498271198ec69c34f1dc762a1eee8200c111f598da1b3dde946783d61101581612a24565b611020848484612a2e565b50505050565b5f611032826001612b86565b92915050565b5f6001600160e01b03198216635a05180f60e01b1480611032575061103282612c74565b7f2fc10cc8ae19568712f7a176fb4978616a610650813c9d05326c34abb62749c761108681612a24565b61108e612ca8565b50565b5f9081527f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec92100602052604090205490565b5f825f036110d057505f611032565b8151518084116110fa576110f56110e860018661504e565b8451602091820201015190565b611138565b6020830151611109828661504e565b6111139190615061565b61112e61112160018461504e565b8551602091820201015190565b6111389190615078565b949350505050565b5f61115361114e84846116b8565b612cfd565b9392505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146111a357604051633bebb4c160e11b815260040160405180910390fd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e441d25f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611200573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611224919061508b565b6001600160a01b0316346040515f6040518083038185875af1925050503d805f811461126b576040519150601f19603f3d011682016040523d82523d5f602084013e611270565b606091505b5050905080611292576040516324f09be760e21b815260040160405180910390fd5b61129c8234612d94565b817fb6ee6e3aae6776519627b46786a622b642c38cabfe4c97cb34054fd63fc11a23346040516112ce91815260200190565b60405180910390a25050565b5f61115361114e8484611c8d565b6112f0612e1a565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461133957604051633bebb4c160e11b815260040160405180910390fd5b6113438282612e42565b5050565b5f8281525f805160206152bd833981519152602052604090206001015461136d81612a24565b6110208383612f2f565b6001600160a01b03811633146113a05760405163334bd91960e11b815260040160405180910390fd5b6113aa8282612f84565b505050565b7f40579467dba486691cc62fd8536d22c6d4dc9cdc7bc716ef2518422aa554c0986113d981612a24565b61134382612fd0565b7fb5dffea014b759c493d63b1edaceb942631d6468998125e1b4fe427c9908213461140c81612a24565b6114158261304c565b611343826130ef565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461146757604051633bebb4c160e11b815260040160405180910390fd5b5f6114718261218b565b90508015611483576114838282613177565b611343826132c3565b611494612e1a565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146114dd57604051633bebb4c160e11b815260040160405180910390fd5b80351580159061157d5750604051636eb1769f60e11b81526001600160a01b0385811660048301523060248301528235917f00000000000000000000000000000000000000000000000000000000000000009091169063dd62ed3e90604401602060405180830381865afa158015611557573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061157b91906150a6565b105b15611651576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663d505accf8530843560208601356115ca60608801604089016150bd565b6040516001600160e01b031960e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606084013560a4820152608084013560c482015260e4015f604051808303815f87803b15801561163a575f80fd5b505af115801561164c573d5f803e3d5ffd5b505050505b611020848484613309565b611664613406565b73d72e84a64b676097254cda079d8b7b63c7988eca6352d8bfc26040518163ffffffff1660e01b81526004015f6040518083038186803b1580156116a6575f80fd5b505af4158015611020573d5f803e3d5ffd5b5f611153836105b684611dd6565b5f7fd35e4a788498271198ec69c34f1dc762a1eee8200c111f598da1b3dde946783d6116f181612a24565b611138848461342f565b5f6117247fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a025490565b905090565b611731613406565b5f61175a7f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec921015490565b604051633d7ad0b760e21b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f5eb42dc90602401602060405180830381865afa1580156117bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117e091906150a6565b6117ea919061504e565b6040516389ad944360e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001660048201526024810182905290915073d72e84a64b676097254cda079d8b7b63c7988eca906389ad9443906044015f6040518083038186803b158015611865575f80fd5b505af4158015611877573d5f803e3d5ffd5b5050505050565b611886613406565b604051635c654ad960e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90635c654ad9906044015b5f6040518083038186803b1580156118df575f80fd5b505af41580156118f1573d5f803e3d5ffd5b505050505050565b60408051808201909152606081525f6020820152611032610d21835f9081527f8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe1501602052604090205490565b61194c612e1a565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461199557604051633bebb4c160e11b815260040160405180910390fd5b80156119a7576119a786848484613558565b6118f18686866135da565b6119ba613406565b6040516340cea66360e11b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca9063819d4cc6906044016118c9565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611a4a57604051633bebb4c160e11b815260040160405180910390fd5b6001546113aa90839083906001600160a01b031661389d565b611a6b613406565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603611abd576040516319efe5d760e21b815260040160405180910390fd5b604051638980f11f60e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90638980f11f906044016118c9565b5f80611b0f83611091565b9150611bb7611b1d8461218b565b6040516311d8d20560e31b815260048101869052611bb1907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638ec6902890602401602060405180830381865afa158015611b84573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ba891906150a6565b6105b6876118f9565b01612cfd565b9050915091565b5f8281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320006020819052604082206111389084613996565b5f9182525f805160206152bd833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b7f40579467dba486691cc62fd8536d22c6d4dc9cdc7bc716ef2518422aa554c098611c5681612a24565b611343826139a1565b5f61115361114e84846110c1565b611c768461304c565b61102084848484613558565b5f611032825f612b86565b5f80611c9884612072565b90505f611d36847f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638ec69028886040518263ffffffff1660e01b8152600401611ced91815260200190565b602060405180830381865afa158015611d08573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d2c91906150a6565b611ba89190615078565b90505f611d428661218b565b611d4c9083615078565b9050828111611d5b575f611d5f565b8281035b9695505050505050565b5f611d927fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a025490565b4210905090565b7f645c9e6d2a86805cb5a28b1e4751c0dab493df7cf935070ce405489ba1a7bf72611dc381612a24565b611dcc8361304c565b6113aa8383613a5f565b60408051808201909152606081525f60208201525f8051602061527d833981519152805483908110611e0a57611e0a6150dd565b905f5260205f2090600202016040518060400160405290815f8201805480602002602001604051908101604052809291908181526020018280548015611e6d57602002820191905f5260205f20905b815481526020019060010190808311611e59575b505050505081526020016001820154815250509050919050565b5f8181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200060208190526040822061115390613ad8565b611ec6612e1a565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611f0f57604051633bebb4c160e11b815260040160405180910390fd5b8015611f2157611f2186848484613558565b6118f1868686613ae1565b5f80611f3783612072565b9150611f428361218b565b6040516311d8d20560e31b815260048101859052611fd6907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638ec6902890602401602060405180830381865afa158015611fa9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fcd91906150a6565b6105b6866118f9565b019050915091565b8051602001515f90831015611ff457505f611032565b8151515f61200661112160018461504e565b905080851061202c57836020015181860381612024576120246150f1565b048201612039565b61203985855f0151613db5565b95945050505050565b5f8281525f805160206152bd833981519152602052604090206001015461206881612a24565b6110208383612f84565b5f61103261207f83611091565b613e21565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146120cd57604051633bebb4c160e11b815260040160405180910390fd5b6113438282612d94565b5f61115383610db184611dd6565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461212e57604051633bebb4c160e11b815260040160405180910390fd5b6113438282613e7d565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461218157604051633bebb4c160e11b815260040160405180910390fd5b6113438282613177565b5f8181525f8051602061529d83398151915260205260408120805442600160801b9091046001600160801b0316116121c3575f6121cf565b80546001600160801b03165b6001600160801b03169392505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663095ea7b37f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166327810b6e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561226a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061228e919061508b565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201525f1960248201526044016020604051808303815f875af11580156122d8573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061108e9190615105565b7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d61232681612a24565b61134382613f26565b612337612e1a565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461238057604051633bebb4c160e11b815260040160405180910390fd5b8035158015906124205750604051636eb1769f60e11b81526001600160a01b0385811660048301523060248301528235917f00000000000000000000000000000000000000000000000000000000000000009091169063dd62ed3e90604401602060405180830381865afa1580156123fa573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061241e91906150a6565b105b156124f4576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663d505accf85308435602086013561246d60608801604089016150bd565b6040516001600160e01b031960e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606084013560a4820152608084013560c482015260e4015f604051808303815f87803b1580156124dd575f80fd5b505af11580156124ef573d5f803e3d5ffd5b505050505b611020848484613f75565b612507612e1a565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461255057604051633bebb4c160e11b815260040160405180910390fd5b80156125625761256286848484613558565b6118f18686866141f9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f811580156125b25750825b90505f8267ffffffffffffffff1660011480156125ce5750303b155b9050811580156125dc575080155b156125fa5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561262457845460ff60401b1916600160401b1785555b61262c614333565b6126368b8b61433b565b61263f8761436f565b6001600160a01b03891661266657604051633ef39b8160e01b815260040160405180910390fd5b6001600160a01b03881661268d5760405163658b92ad60e11b815260040160405180910390fd5b6126975f8a612f2f565b506126e27f645c9e6d2a86805cb5a28b1e4751c0dab493df7cf935070ce405489ba1a7bf727f0000000000000000000000000000000000000000000000000000000000000000612f2f565b5061272d7fb5dffea014b759c493d63b1edaceb942631d6468998125e1b4fe427c990821347f0000000000000000000000000000000000000000000000000000000000000000612f2f565b505f80546001600160a01b0319166001600160a01b038a1617905561275186612fd0565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301525f1960248301527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303815f875af11580156127dd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128019190615105565b5060405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301525f1960248301527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303815f875af115801561288e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128b29190615105565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663095ea7b37f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166327810b6e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561293e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612962919061508b565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201525f1960248201526044016020604051808303815f875af11580156129ac573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129d09190615105565b508315612a1757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b61108e8133614380565b5f8051602061527d83398151915280545f1901841115612a61576040516331e784e960e11b815260040160405180910390fd5b612a6b83836143be565b5f60018311612a7a575f612a98565b83836001198101818110612a9057612a906150dd565b905060200201355b84845f198101818110612aad57612aad6150dd565b9050602002013503905060405180604001604052808585808060200260200160405190810160405280939291908181526020018383602002808284375f920191909152505050908252506020018290528254839087908110612b1157612b116150dd565b905f5260205f2090600202015f820151815f019080519060200190612b37929190614ae5565b506020820151816001015590505050837f53da7af401538204fd91f2946f2fe85d05224d2cc766fd7aa9fbd8bf4fb4ce9f8484604051612b78929190615154565b60405180910390a250505050565b6040516311d8d20560e31b8152600481018390525f9081906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638ec6902890602401602060405180830381865afa158015612bed573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c1191906150a6565b90505f612c2061207f86611091565b600a0190508315612c4c575f612c358661218b565b9050808211612c4957829350505050611032565b90035b5f612c5a82610db1886118f9565b9050808311612c69575f611d5f565b909103949350505050565b5f6001600160e01b03198216637965db0b60e01b148061103257506301ffc9a760e01b6001600160e01b0319831614611032565b612cb06144a8565b427fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a02556040517f62451d457bc659158be6e6247f56ec1df424a5c7597f71c20c2bc44e0965c8f9905f90a1565b5f815f03612d0c57505f919050565b604051631920845160e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906319208451906024015b602060405180830381865afa158015612d70573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061103291906150a6565b5f612d9e8361218b565b9050815f03612dc057604051633649e09760e11b815260040160405180910390fd5b81811015612de157604051633649e09760e11b815260040160405180910390fd5b5f8381525f8051602061529d83398151915260205260409020546113aa90849084840390600160801b90046001600160801b03166144cd565b612e22611d69565b15612e4057604051630286f07360e31b815260040160405180910390fd5b565b345f03612e4d575050565b60405163a1903eab60e01b81525f60048201819052906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a1903eab90349060240160206040518083038185885af1158015612eb5573d5f803e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190612eda91906150a6565b9050612ee68282614581565b604080516001600160a01b038516815234602082015283917f16ec5116295424dec7fd52c87d9971a963ea7f59f741ad9ad468f0312055dc4991015b60405180910390a2505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081612f5c85856145e9565b90508015611138575f858152602083905260409020612f7b9085614691565b50949350505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081612fb185856146a5565b90508015611138575f858152602083905260409020612f7b908561471e565b6001600160a01b038116612ff757604051631279f7c160e21b815260040160405180910390fd5b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f4beaaee83871b066b675515d6a53567e76411f60266703cef934a01905a4d832906020015b60405180910390a150565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a70c70e46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130cc91906150a6565b8110156130d65750565b604051633ed893db60e21b815260040160405180910390fd5b5f8181527f8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe150160205260409020545f8051602061527d83398151915290613133575050565b5f8281526001820160205260408082208290555183917f4642db1736894887bc907d721f20af84d3e585a0a3cea90f41b78b2aa906541b916112ce91815260200190565b5f61318182612cfd565b90505f61318e8483614732565b9050805f0361319d5750505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166327810b6e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131f9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061321d919061508b565b6040516308c2292560e31b8152306004820152602481018390526001600160a01b0391909116906346114928906044015f604051808303815f87803b158015613264575f80fd5b505af1158015613276573d5f803e3d5ffd5b50505050837f4da924ae7845fe96897faab524b536685b8bbc4d82fbb45c10d941e0f86ade0f6132a584613e21565b6132ae84613e21565b60408051928352602083019190915201612b78565b5f8181525f8051602061529d83398151915260205260408082208290555182917f844ae6b00e8a437dcdde1a634feab3273e08bb5c274a4be3b195b308ae0ba20a91a250565b805f0361331557505050565b5f61331f82612cfd565b604051636d78045960e01b81526001600160a01b038681166004830152306024830152604482018390529192507f000000000000000000000000000000000000000000000000000000000000000090911690636d780459906064016020604051808303815f875af1158015613396573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906133ba91906150a6565b506133c58382614581565b604080516001600160a01b03861681526020810184905284917fee31ebba29fd5471227e42fd8ca621a892d689901892cb8febb03fe802c3214b9101612b78565b612e407fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc612a24565b5f5f8051602061527d83398151915261344884846143be565b5f60018411613457575f613475565b8484600119810181811061346d5761346d6150dd565b905060200201355b85855f19810181811061348a5761348a6150dd565b90506020020135039050815f0160405180604001604052808787808060200260200160405190810160405280939291908181526020018383602002808284375f92018290525093855250505060209182018590528354600181018555938152819020825180519394600202909101926135069284920190614ae5565b506020820151816001015550507f1fb1d9b944dd7015e95b7b7a9623c45792e4532badcf9c6e7a284d7d4d0570f08585604051613544929190615154565b60405180910390a150545f19019392505050565b5f80546040516321893f7b60e01b81526001600160a01b03909116906321893f7b9061358e908890889088908890600401615167565b6020604051808303815f875af11580156135aa573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906135ce91906150a6565b90506118778582614581565b5f6135e48461475a565b90505f8184106135f457816135f6565b835b9050805f03613618576040516312d37ee560e31b815260040160405180910390fd5b604051633d7ad0b760e21b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f5eb42dc90602401602060405180830381865afa15801561367c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906136a091906150a6565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ea598cb06136db85613e21565b6040518263ffffffff1660e01b81526004016136f991815260200190565b6020604051808303815f875af1158015613715573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061373991906150a6565b604051633d7ad0b760e21b81523060048201529091505f906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f5eb42dc90602401602060405180830381865afa1580156137a0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906137c491906150a6565b90506137d28882850361481f565b60405163a9059cbb60e01b81526001600160a01b038781166004830152602482018490527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044015f604051808303815f87803b158015613839575f80fd5b505af115801561384b573d5f803e3d5ffd5b5050604080516001600160a01b038a168152602081018690528b93507fe6a8c06447e05a412e5e9581e088941f3994db3d8a9bfd3275b38d77acacafac92500160405180910390a25050505050505050565b5f806138a884612cfd565b90506138b48582614732565b604051638fcb4e5b60e01b81526001600160a01b038581166004830152602482018390529193505f917f00000000000000000000000000000000000000000000000000000000000000001690638fcb4e5b906044016020604051808303815f875af1158015613925573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061394991906150a6565b9050857f8615528474a7bb3a28d9971535d956b79242b8e8fcfb27f3e331270fff088afd61397684613e21565b60408051918252602082018590520160405180910390a250509392505050565b5f611153838361487e565b7f00000000000000000000000000000000000000000000000000000000000000008110806139ee57507f000000000000000000000000000000000000000000000000000000000000000081115b15613a0c5760405163dee7108760e01b815260040160405180910390fd5b807f78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f00556040518181527fdaf5eddbe9ed0768e54cc8f739a9cb86c57fc70da07eff01d9ba886f21a7a4b390602001613041565b5f8051602061527d83398151915280545f1901821115613a92576040516331e784e960e11b815260040160405180910390fd5b5f838152600182016020526040908190208390555183907f4642db1736894887bc907d721f20af84d3e585a0a3cea90f41b78b2aa906541b90612f229085815260200190565b5f611032825490565b5f613aeb8461475a565b90505f613af782613e21565b8410613b035781613b0c565b613b0c84612cfd565b9050805f03613b2e576040516312d37ee560e31b815260040160405180910390fd5b6040805160018082528183019092525f9160208083019080368337019050509050613b5882613e21565b815f81518110613b6a57613b6a6150dd565b6020908102919091010152604051633d7ad0b760e21b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f5eb42dc90602401602060405180830381865afa158015613bd9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613bfd91906150a6565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d668104284886040518363ffffffff1660e01b8152600401613c4e929190615186565b5f604051808303815f875af1158015613c69573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052613c9091908101906151dc565b604051633d7ad0b760e21b81523060048201529091505f906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f5eb42dc90602401602060405180830381865afa158015613cf7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613d1b91906150a6565b9050613d298982850361481f565b887f26673a9d018b21192d08ee14377b798f11b9e5b15ea1559c110265716b8985b588865f81518110613d5e57613d5e6150dd565b6020026020010151855f81518110613d7857613d786150dd565b602090810291909101810151604080516001600160a01b0390951685529184019290925282015260600160405180910390a2505050505050505050565b80515f9081906001190181805b828411613e16575050600282820104602081810286010151808703613def57506001019250611032915050565b80871015613e0257600182039250613dc2565b80871115613e11578160010193505b613dc2565b509195945050505050565b5f815f03613e3057505f919050565b604051630f451f7160e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637a28fb8890602401612d55565b7f78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f005f829003613ebf57604051633649e09760e11b815260040160405180910390fd5b5f83815260018201602052604090205442600160801b9091046001600160801b03161115613f0d575f838152600182016020526040902054613f0a906001600160801b031683615078565b91505b6113aa8383835f015442613f219190615078565b6144cd565b613f2e612e1a565b805f03613f4e5760405163ad58bfc760e01b815260040160405180910390fd5b5f5f198203613f5f57505f19613f6c565b613f698242615078565b90505b611343816148a4565b805f03613f8157505050565b6040516323b872dd60e01b81526001600160a01b038481166004830152306024830152604482018390527f000000000000000000000000000000000000000000000000000000000000000016906323b872dd906064015f604051808303815f87803b158015613fee575f80fd5b505af1158015614000573d5f803e3d5ffd5b5050604051633d7ad0b760e21b81523060048201525f92507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316915063f5eb42dc90602401602060405180830381865afa158015614068573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061408c91906150a6565b604051636f074d1f60e11b8152600481018490529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063de0e9a3e906024016020604051808303815f875af11580156140f3573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061411791906150a6565b50604051633d7ad0b760e21b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f5eb42dc90602401602060405180830381865afa15801561417c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906141a091906150a6565b90506141ae84838303614581565b604080516001600160a01b03871681526020810185905285917f6576bbc9c5b478bf9717dc3d2bcb485e5ff0727df77c72558727597f3609d3f1910160405180910390a25050505050565b5f6142038461475a565b90505f61420f82613e21565b841061421b5781614224565b61422484612cfd565b9050805f03614246576040516312d37ee560e31b815260040160405180910390fd5b614250858261481f565b604051638fcb4e5b60e01b81526001600160a01b038481166004830152602482018390525f917f000000000000000000000000000000000000000000000000000000000000000090911690638fcb4e5b906044016020604051808303815f875af11580156142c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906142e491906150a6565b604080516001600160a01b03871681526020810183905291925087917f3e3a1398fe71575ed0c17a80cd9d46ad684c2c75c2fad7b0e7dde15e78ab22d3910160405180910390a2505050505050565b612e4061493f565b61434361493f565b5f61434e838361342f565b905080156113aa57604051634273eaaf60e11b815260040160405180910390fd5b61437761493f565b61108e816139a1565b61438a8282611bf6565b6113435760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044015b60405180910390fd5b60018110806143ec57507f000000000000000000000000000000000000000000000000000000000000000081115b1561440a57604051638326bf5360e01b815260040160405180910390fd5b81815f81811061441c5761441c6150dd565b905060200201355f03614442576040516302527aef60e21b815260040160405180910390fd5b60015b818110156113aa57828260018303818110614462576144626150dd565b9050602002013583838381811061447b5761447b6150dd565b90506020020135116144a0576040516302527aef60e21b815260040160405180910390fd5b600101614445565b6144b0611d69565b612e405760405163b047186b60e01b815260040160405180910390fd5b815f036144dd576113aa836132c3565b60405180604001604052806144f184614988565b6001600160801b0316815260200161450883614988565b6001600160801b039081169091525f8581525f8051602061529d83398151915260209081526040918290208451948201518416600160801b029490931693909317909155805184815291820183905284917f69a153d448f54b17f05cf3b268a2efab87c94a4727d108c4ca4aa3e5d65113de9101612f22565b805f0361458c575050565b5f9182527f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec9210060205260409091208054820190557f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec9210180549091019055565b5f5f805160206152bd8339815191526146028484611bf6565b614681575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556146373390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050611032565b5f915050611032565b5092915050565b5f611153836001600160a01b0384166149bf565b5f5f805160206152bd8339815191526146be8484611bf6565b15614681575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050611032565b5f611153836001600160a01b038416614a0b565b5f8061473d84611091565b905080831061474c578061474e565b825b915061468a848361481f565b5f8061476583611091565b90505f6148086147748561218b565b6040516311d8d20560e31b815260048101879052611bb1907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638ec6902890602401602060405180830381865afa1580156147db573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906147ff91906150a6565b6105b6886118f9565b9050808211614817575f611138565b900392915050565b5f9182527f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec921006020526040909120805482900390557f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec921018054919091039055565b5f825f018281548110614893576148936150dd565b905f5260205f200154905092915050565b6148cd7fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a02829055565b5f198103614906576040515f1981527f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e90602001613041565b7f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e614931428361504e565b604051908152602001613041565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16612e4057604051631afcd79f60e31b815260040160405180910390fd5b5f6001600160801b038211156149bb576040516306dfcc6560e41b815260806004820152602481018390526044016143b5565b5090565b5f818152600183016020526040812054614a0457508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155611032565b505f611032565b5f8181526001830160205260408120548015614681575f614a2d60018361504e565b85549091505f90614a409060019061504e565b9050808214614a9f575f865f018281548110614a5e57614a5e6150dd565b905f5260205f200154905080875f018481548110614a7e57614a7e6150dd565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080614ab057614ab0615268565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050611032565b828054828255905f5260205f20908101928215614b1e579160200282015b82811115614b1e578251825591602001919060010190614b03565b506149bb9291505b808211156149bb575f8155600101614b26565b5f8083601f840112614b49575f80fd5b50813567ffffffffffffffff811115614b60575f80fd5b6020830191508360208260051b8501011115614b7a575f80fd5b9250929050565b5f805f60408486031215614b93575f80fd5b83359250602084013567ffffffffffffffff811115614bb0575f80fd5b614bbc86828701614b39565b9497909650939450505050565b5f60208284031215614bd9575f80fd5b5035919050565b5f60208284031215614bf0575f80fd5b81356001600160e01b031981168114611153575f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040805190810167ffffffffffffffff81118282101715614c3e57614c3e614c07565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715614c6d57614c6d614c07565b604052919050565b5f67ffffffffffffffff821115614c8e57614c8e614c07565b5060051b60200190565b5f8060408385031215614ca9575f80fd5b8235915060208084013567ffffffffffffffff80821115614cc8575f80fd5b9085019060408288031215614cdb575f80fd5b614ce3614c1b565b823582811115614cf1575f80fd5b83019150601f82018813614d03575f80fd5b8135614d16614d1182614c75565b614c44565b81815260059190911b8301850190858101908a831115614d34575f80fd5b938601935b82851015614d5257843582529386019390860190614d39565b83525050918301359282019290925292959294509192505050565b5f8060408385031215614d7e575f80fd5b50508035926020909101359150565b6001600160a01b038116811461108e575f80fd5b5f8060408385031215614db2575f80fd5b8235614dbd81614d8d565b946020939093013593505050565b5f8060408385031215614ddc575f80fd5b823591506020830135614dee81614d8d565b809150509250929050565b5f60208284031215614e09575f80fd5b813561115381614d8d565b5f805f80848603610100811215614e29575f80fd5b8535614e3481614d8d565b9450602086013593506040860135925060a0605f1982011215614e55575f80fd5b509295919450926060019150565b5f8060208385031215614e74575f80fd5b823567ffffffffffffffff811115614e8a575f80fd5b614e9685828601614b39565b90969095509350505050565b602080825282516040838301528051606084018190525f9291820190839060808601905b80831015614ee65783518252928401926001929092019190840190614ec6565b508387015160408701528094505050505092915050565b5f805f805f8060a08789031215614f12575f80fd5b86359550602087013594506040870135614f2b81614d8d565b935060608701359250608087013567ffffffffffffffff811115614f4d575f80fd5b614f5989828a01614b39565b979a9699509497509295939492505050565b5f805f8060608587031215614f7e575f80fd5b8435935060208501359250604085013567ffffffffffffffff811115614fa2575f80fd5b614fae87828801614b39565b95989497509550505050565b5f805f805f8060a08789031215614fcf575f80fd5b863567ffffffffffffffff811115614fe5575f80fd5b614ff189828a01614b39565b909750955050602087013561500581614d8d565b9350604087013561501581614d8d565b925060608701359150608087013561502c81614d8d565b809150509295509295509295565b634e487b7160e01b5f52601160045260245ffd5b818103818111156110325761103261503a565b80820281158282048414176110325761103261503a565b808201808211156110325761103261503a565b5f6020828403121561509b575f80fd5b815161115381614d8d565b5f602082840312156150b6575f80fd5b5051919050565b5f602082840312156150cd575f80fd5b813560ff81168114611153575f80fd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601260045260245ffd5b5f60208284031215615115575f80fd5b81518015158114611153575f80fd5b8183525f6001600160fb1b0383111561513b575f80fd5b8260051b80836020870137939093016020019392505050565b602081525f611138602083018486615124565b848152836020820152606060408201525f611d5f606083018486615124565b604080825283519082018190525f906020906060840190828701845b828110156151be578151845292840192908401906001016151a2565b50505080925050506001600160a01b03831660208301529392505050565b5f60208083850312156151ed575f80fd5b825167ffffffffffffffff811115615203575f80fd5b8301601f81018513615213575f80fd5b8051615221614d1182614c75565b81815260059190911b8201830190838101908783111561523f575f80fd5b928401925b8284101561525d57835182529284019290840190615244565b979650505050505050565b634e487b7160e01b5f52603160045260245ffdfe8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe150078c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f0102dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800a164736f6c6343000818000a00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef80000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e13380

Deployed Bytecode

0x608060405260043610610463575f3560e01c80638980f11f11610241578063cb11c52711610134578063dcab7f83116100b3578063f3f449c711610078578063f3f449c714610f3c578063f7966efe14610f5b578063f939122314610f7a578063fab382f114610f99578063fee6380514610fb8575f80fd5b8063dcab7f8314610e98578063def82d0214610eb7578063e5220e3f14610eea578063ead42a6914610f09578063f3efecc414610f28575f80fd5b8063d8fe7642116100f9578063d8fe764214610dd5578063d963ae5514610df4578063d9fb643a14610e13578063dbba4b4814610e46578063dc38ea3d14610e79575f80fd5b8063cb11c52714610d45578063cc810cb914610d59578063ce19793f14610d78578063d2fa16a614610d97578063d547741f14610db6575f80fd5b80639c516102116101c0578063b148db6a11610185578063b148db6a14610cb5578063b187bd2614610cd4578063b2d03e4d14610ce8578063b5b624bf14610d07578063ca15c87314610d26575f80fd5b80639c51610214610c1c578063a217fddf146107a1578063a302ee3814610c3b578063acf1c94814610c4f578063ae84975614610c82575f80fd5b80639010d07c116102065780639010d07c14610b8157806391d1485414610ba05780639996522514610bbf5780639a4df8f014610bde5780639b4c6c2714610bfd575f80fd5b80638980f11f14610a955780638b21f17014610ab45780638de2b27214610ae75780638ed5c5d714610b1a5780638f6549ae14610b4d575f80fd5b80634342b3c111610359578063589ff76c116102d857806370903eb91161029d57806370903eb91461096f57806374d70aea1461098e578063819d4cc6146109c157806383316184146109e0578063881fa03c14610a76575f80fd5b8063589ff76c146108c95780635a73bdc8146108dd5780635c654ad9146108f1578063699340f4146109105780636e13f09914610943575f80fd5b80634c7ed3d21161031e5780634c7ed3d214610825578063526352fc1461084457806352d8bfc214610877578063546da24f1461088b578063573b6245146108aa575f80fd5b80634342b3c11461076e578063443fbfef146107a1578063449add1b146107b45780634b2ce9fe146107d35780634bb22a7214610806575f80fd5b8063165123dd116103e55780632e599054116103aa5780632e599054146106cb5780632f2ff15d146106de57806336568abe146106fd578063389ed2671461071c578063433cd6c31461074f575f80fd5b8063165123dd146105ed57806321d439d51461060c578063248a9ca31461063f57806328846981146106795780632de03aa114610698575f80fd5b806306cd0e901161042b57806306cd0e90146105475780630d43e8ad146105665780630f23e7421461059c57806313d1234b146105bb57806315b5c477146105da575f80fd5b8063019c1a4f1461046757806301a5e9e31461048857806301ffc9a7146104ba578063046f7da2146104e95780630569b947146104fd575b5f80fd5b348015610472575f80fd5b50610486610481366004614b81565b610feb565b005b348015610493575f80fd5b506104a76104a2366004614bc9565b611026565b6040519081526020015b60405180910390f35b3480156104c5575f80fd5b506104d96104d4366004614be0565b611038565b60405190151581526020016104b1565b3480156104f4575f80fd5b5061048661105c565b348015610508575f80fd5b506104a7610517366004614bc9565b5f9081527f8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe1501602052604090205490565b348015610552575f80fd5b506104a7610561366004614bc9565b611091565b348015610571575f80fd5b505f54610584906001600160a01b031681565b6040516001600160a01b0390911681526020016104b1565b3480156105a7575f80fd5b506104a76105b6366004614c98565b6110c1565b3480156105c6575f80fd5b506104a76105d5366004614d6d565b611140565b6104866105e8366004614bc9565b61115a565b3480156105f8575f80fd5b50600154610584906001600160a01b031681565b348015610617575f80fd5b506104a77fb5dffea014b759c493d63b1edaceb942631d6468998125e1b4fe427c9908213481565b34801561064a575f80fd5b506104a7610659366004614bc9565b5f9081525f805160206152bd833981519152602052604090206001015490565b348015610684575f80fd5b506104a7610693366004614d6d565b6112da565b3480156106a3575f80fd5b506104a77f2fc10cc8ae19568712f7a176fb4978616a610650813c9d05326c34abb62749c781565b6104866106d9366004614da1565b6112e8565b3480156106e9575f80fd5b506104866106f8366004614dcb565b611347565b348015610708575f80fd5b50610486610717366004614dcb565b611377565b348015610727575f80fd5b506104a77f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d81565b34801561075a575f80fd5b50610486610769366004614df9565b6113af565b348015610779575f80fd5b506104a77f645c9e6d2a86805cb5a28b1e4751c0dab493df7cf935070ce405489ba1a7bf7281565b3480156107ac575f80fd5b506104a75f81565b3480156107bf575f80fd5b506104866107ce366004614bc9565b6113e2565b3480156107de575f80fd5b506104a77f000000000000000000000000000000000000000000000000000000000000000a81565b348015610811575f80fd5b50610486610820366004614bc9565b61141e565b348015610830575f80fd5b5061048661083f366004614e14565b61148c565b34801561084f575f80fd5b506104a77f0000000000000000000000000000000000000000000000000000000001e1338081565b348015610882575f80fd5b5061048661165c565b348015610896575f80fd5b506104a76108a5366004614d6d565b6116b8565b3480156108b5575f80fd5b506104a76108c4366004614e63565b6116c6565b3480156108d4575f80fd5b506104a76116fb565b3480156108e8575f80fd5b50610486611729565b3480156108fc575f80fd5b5061048661090b366004614da1565b61187e565b34801561091b575f80fd5b506105847f000000000000000000000000c7cc160b58f8bb0bac94b80847e2cf2800565c5081565b34801561094e575f80fd5b5061096261095d366004614bc9565b6118f9565b6040516104b19190614ea2565b34801561097a575f80fd5b50610486610989366004614efd565b611944565b348015610999575f80fd5b507f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec92101546104a7565b3480156109cc575f80fd5b506104866109db366004614da1565b6119b2565b3480156109eb575f80fd5b50610a4f6109fa366004614bc9565b6040805180820182525f80825260209182018190529283525f8051602061529d8339815191528152918190208151808301909252546001600160801b038082168352600160801b909104169181019190915290565b6040805182516001600160801b0390811682526020938401511692810192909252016104b1565b348015610a81575f80fd5b50610486610a90366004614d6d565b611a01565b348015610aa0575f80fd5b50610486610aaf366004614da1565b611a63565b348015610abf575f80fd5b506105847f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c9503481565b348015610af2575f80fd5b506105847f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f81565b348015610b25575f80fd5b506104a77f40579467dba486691cc62fd8536d22c6d4dc9cdc7bc716ef2518422aa554c09881565b348015610b58575f80fd5b50610b6c610b67366004614bc9565b611b04565b604080519283526020830191909152016104b1565b348015610b8c575f80fd5b50610584610b9b366004614d6d565b611bbe565b348015610bab575f80fd5b506104d9610bba366004614dcb565b611bf6565b348015610bca575f80fd5b50610486610bd9366004614bc9565b611c2c565b348015610be9575f80fd5b506104a7610bf8366004614c98565b611c5f565b348015610c08575f80fd5b50610486610c17366004614f6b565b611c6d565b348015610c27575f80fd5b506104a7610c36366004614bc9565b611c82565b348015610c46575f80fd5b506104a75f1981565b348015610c5a575f80fd5b506104a77fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc81565b348015610c8d575f80fd5b506104a77f000000000000000000000000000000000000000000000000000000000000000081565b348015610cc0575f80fd5b506104a7610ccf366004614d6d565b611c8d565b348015610cdf575f80fd5b506104d9611d69565b348015610cf3575f80fd5b50610486610d02366004614d6d565b611d99565b348015610d12575f80fd5b50610962610d21366004614bc9565b611dd6565b348015610d31575f80fd5b506104a7610d40366004614bc9565b611e87565b348015610d50575f80fd5b506104a7600181565b348015610d64575f80fd5b50610486610d73366004614efd565b611ebe565b348015610d83575f80fd5b50610b6c610d92366004614bc9565b611f2c565b348015610da2575f80fd5b506104a7610db1366004614c98565b611fde565b348015610dc1575f80fd5b50610486610dd0366004614dcb565b612042565b348015610de0575f80fd5b506104a7610def366004614bc9565b612072565b348015610dff575f80fd5b50610486610e0e366004614d6d565b612084565b348015610e1e575f80fd5b506105847f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d81565b348015610e51575f80fd5b506105847f00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef881565b348015610e84575f80fd5b506104a7610e93366004614d6d565b6120d7565b348015610ea3575f80fd5b50610486610eb2366004614d6d565b6120e5565b348015610ec2575f80fd5b507f78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f00546104a7565b348015610ef5575f80fd5b50610486610f04366004614d6d565b612138565b348015610f14575f80fd5b506104a7610f23366004614bc9565b61218b565b348015610f33575f80fd5b506104866121df565b348015610f47575f80fd5b50610486610f56366004614bc9565b6122fc565b348015610f66575f80fd5b50610486610f75366004614e14565b61232f565b348015610f85575f80fd5b50610486610f94366004614efd565b6124ff565b348015610fa4575f80fd5b50610486610fb3366004614fba565b61256d565b348015610fc3575f80fd5b506104a77fd35e4a788498271198ec69c34f1dc762a1eee8200c111f598da1b3dde946783d81565b7fd35e4a788498271198ec69c34f1dc762a1eee8200c111f598da1b3dde946783d61101581612a24565b611020848484612a2e565b50505050565b5f611032826001612b86565b92915050565b5f6001600160e01b03198216635a05180f60e01b1480611032575061103282612c74565b7f2fc10cc8ae19568712f7a176fb4978616a610650813c9d05326c34abb62749c761108681612a24565b61108e612ca8565b50565b5f9081527f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec92100602052604090205490565b5f825f036110d057505f611032565b8151518084116110fa576110f56110e860018661504e565b8451602091820201015190565b611138565b6020830151611109828661504e565b6111139190615061565b61112e61112160018461504e565b8551602091820201015190565b6111389190615078565b949350505050565b5f61115361114e84846116b8565b612cfd565b9392505050565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f16146111a357604051633bebb4c160e11b815260040160405180910390fd5b5f7f00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef86001600160a01b031663e441d25f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611200573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611224919061508b565b6001600160a01b0316346040515f6040518083038185875af1925050503d805f811461126b576040519150601f19603f3d011682016040523d82523d5f602084013e611270565b606091505b5050905080611292576040516324f09be760e21b815260040160405180910390fd5b61129c8234612d94565b817fb6ee6e3aae6776519627b46786a622b642c38cabfe4c97cb34054fd63fc11a23346040516112ce91815260200190565b60405180910390a25050565b5f61115361114e8484611c8d565b6112f0612e1a565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f161461133957604051633bebb4c160e11b815260040160405180910390fd5b6113438282612e42565b5050565b5f8281525f805160206152bd833981519152602052604090206001015461136d81612a24565b6110208383612f2f565b6001600160a01b03811633146113a05760405163334bd91960e11b815260040160405180910390fd5b6113aa8282612f84565b505050565b7f40579467dba486691cc62fd8536d22c6d4dc9cdc7bc716ef2518422aa554c0986113d981612a24565b61134382612fd0565b7fb5dffea014b759c493d63b1edaceb942631d6468998125e1b4fe427c9908213461140c81612a24565b6114158261304c565b611343826130ef565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f161461146757604051633bebb4c160e11b815260040160405180910390fd5b5f6114718261218b565b90508015611483576114838282613177565b611343826132c3565b611494612e1a565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f16146114dd57604051633bebb4c160e11b815260040160405180910390fd5b80351580159061157d5750604051636eb1769f60e11b81526001600160a01b0385811660048301523060248301528235917f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950349091169063dd62ed3e90604401602060405180830381865afa158015611557573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061157b91906150a6565b105b15611651576001600160a01b037f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950341663d505accf8530843560208601356115ca60608801604089016150bd565b6040516001600160e01b031960e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606084013560a4820152608084013560c482015260e4015f604051808303815f87803b15801561163a575f80fd5b505af115801561164c573d5f803e3d5ffd5b505050505b611020848484613309565b611664613406565b73d72e84a64b676097254cda079d8b7b63c7988eca6352d8bfc26040518163ffffffff1660e01b81526004015f6040518083038186803b1580156116a6575f80fd5b505af4158015611020573d5f803e3d5ffd5b5f611153836105b684611dd6565b5f7fd35e4a788498271198ec69c34f1dc762a1eee8200c111f598da1b3dde946783d6116f181612a24565b611138848461342f565b5f6117247fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a025490565b905090565b611731613406565b5f61175a7f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec921015490565b604051633d7ad0b760e21b81523060048201527f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b03169063f5eb42dc90602401602060405180830381865afa1580156117bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117e091906150a6565b6117ea919061504e565b6040516389ad944360e01b81526001600160a01b037f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950341660048201526024810182905290915073d72e84a64b676097254cda079d8b7b63c7988eca906389ad9443906044015f6040518083038186803b158015611865575f80fd5b505af4158015611877573d5f803e3d5ffd5b5050505050565b611886613406565b604051635c654ad960e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90635c654ad9906044015b5f6040518083038186803b1580156118df575f80fd5b505af41580156118f1573d5f803e3d5ffd5b505050505050565b60408051808201909152606081525f6020820152611032610d21835f9081527f8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe1501602052604090205490565b61194c612e1a565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f161461199557604051633bebb4c160e11b815260040160405180910390fd5b80156119a7576119a786848484613558565b6118f18686866135da565b6119ba613406565b6040516340cea66360e11b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca9063819d4cc6906044016118c9565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f1614611a4a57604051633bebb4c160e11b815260040160405180910390fd5b6001546113aa90839083906001600160a01b031661389d565b611a6b613406565b7f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b0316826001600160a01b031603611abd576040516319efe5d760e21b815260040160405180910390fd5b604051638980f11f60e01b81526001600160a01b03831660048201526024810182905273d72e84a64b676097254cda079d8b7b63c7988eca90638980f11f906044016118c9565b5f80611b0f83611091565b9150611bb7611b1d8461218b565b6040516311d8d20560e31b815260048101869052611bb1907f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f6001600160a01b031690638ec6902890602401602060405180830381865afa158015611b84573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ba891906150a6565b6105b6876118f9565b01612cfd565b9050915091565b5f8281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320006020819052604082206111389084613996565b5f9182525f805160206152bd833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b7f40579467dba486691cc62fd8536d22c6d4dc9cdc7bc716ef2518422aa554c098611c5681612a24565b611343826139a1565b5f61115361114e84846110c1565b611c768461304c565b61102084848484613558565b5f611032825f612b86565b5f80611c9884612072565b90505f611d36847f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f6001600160a01b0316638ec69028886040518263ffffffff1660e01b8152600401611ced91815260200190565b602060405180830381865afa158015611d08573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d2c91906150a6565b611ba89190615078565b90505f611d428661218b565b611d4c9083615078565b9050828111611d5b575f611d5f565b8281035b9695505050505050565b5f611d927fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a025490565b4210905090565b7f645c9e6d2a86805cb5a28b1e4751c0dab493df7cf935070ce405489ba1a7bf72611dc381612a24565b611dcc8361304c565b6113aa8383613a5f565b60408051808201909152606081525f60208201525f8051602061527d833981519152805483908110611e0a57611e0a6150dd565b905f5260205f2090600202016040518060400160405290815f8201805480602002602001604051908101604052809291908181526020018280548015611e6d57602002820191905f5260205f20905b815481526020019060010190808311611e59575b505050505081526020016001820154815250509050919050565b5f8181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200060208190526040822061115390613ad8565b611ec6612e1a565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f1614611f0f57604051633bebb4c160e11b815260040160405180910390fd5b8015611f2157611f2186848484613558565b6118f1868686613ae1565b5f80611f3783612072565b9150611f428361218b565b6040516311d8d20560e31b815260048101859052611fd6907f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f6001600160a01b031690638ec6902890602401602060405180830381865afa158015611fa9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fcd91906150a6565b6105b6866118f9565b019050915091565b8051602001515f90831015611ff457505f611032565b8151515f61200661112160018461504e565b905080851061202c57836020015181860381612024576120246150f1565b048201612039565b61203985855f0151613db5565b95945050505050565b5f8281525f805160206152bd833981519152602052604090206001015461206881612a24565b6110208383612f84565b5f61103261207f83611091565b613e21565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f16146120cd57604051633bebb4c160e11b815260040160405180910390fd5b6113438282612d94565b5f61115383610db184611dd6565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f161461212e57604051633bebb4c160e11b815260040160405180910390fd5b6113438282613e7d565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f161461218157604051633bebb4c160e11b815260040160405180910390fd5b6113438282613177565b5f8181525f8051602061529d83398151915260205260408120805442600160801b9091046001600160801b0316116121c3575f6121cf565b80546001600160801b03165b6001600160801b03169392505050565b7f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b031663095ea7b37f00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef86001600160a01b03166327810b6e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561226a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061228e919061508b565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201525f1960248201526044016020604051808303815f875af11580156122d8573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061108e9190615105565b7f139c2898040ef16910dc9f44dc697df79363da767d8bc92f2e310312b816e46d61232681612a24565b61134382613f26565b612337612e1a565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f161461238057604051633bebb4c160e11b815260040160405180910390fd5b8035158015906124205750604051636eb1769f60e11b81526001600160a01b0385811660048301523060248301528235917f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d9091169063dd62ed3e90604401602060405180830381865afa1580156123fa573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061241e91906150a6565b105b156124f4576001600160a01b037f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d1663d505accf85308435602086013561246d60608801604089016150bd565b6040516001600160e01b031960e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606084013560a4820152608084013560c482015260e4015f604051808303815f87803b1580156124dd575f80fd5b505af11580156124ef573d5f803e3d5ffd5b505050505b611020848484613f75565b612507612e1a565b336001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f161461255057604051633bebb4c160e11b815260040160405180910390fd5b80156125625761256286848484613558565b6118f18686866141f9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f811580156125b25750825b90505f8267ffffffffffffffff1660011480156125ce5750303b155b9050811580156125dc575080155b156125fa5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561262457845460ff60401b1916600160401b1785555b61262c614333565b6126368b8b61433b565b61263f8761436f565b6001600160a01b03891661266657604051633ef39b8160e01b815260040160405180910390fd5b6001600160a01b03881661268d5760405163658b92ad60e11b815260040160405180910390fd5b6126975f8a612f2f565b506126e27f645c9e6d2a86805cb5a28b1e4751c0dab493df7cf935070ce405489ba1a7bf727f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f612f2f565b5061272d7fb5dffea014b759c493d63b1edaceb942631d6468998125e1b4fe427c990821347f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f612f2f565b505f80546001600160a01b0319166001600160a01b038a1617905561275186612fd0565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d811660048301525f1960248301527f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034169063095ea7b3906044016020604051808303815f875af11580156127dd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128019190615105565b5060405163095ea7b360e01b81526001600160a01b037f000000000000000000000000c7cc160b58f8bb0bac94b80847e2cf2800565c50811660048301525f1960248301527f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034169063095ea7b3906044016020604051808303815f875af115801561288e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128b29190615105565b507f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b031663095ea7b37f00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef86001600160a01b03166327810b6e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561293e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612962919061508b565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201525f1960248201526044016020604051808303815f875af11580156129ac573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129d09190615105565b508315612a1757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b61108e8133614380565b5f8051602061527d83398151915280545f1901841115612a61576040516331e784e960e11b815260040160405180910390fd5b612a6b83836143be565b5f60018311612a7a575f612a98565b83836001198101818110612a9057612a906150dd565b905060200201355b84845f198101818110612aad57612aad6150dd565b9050602002013503905060405180604001604052808585808060200260200160405190810160405280939291908181526020018383602002808284375f920191909152505050908252506020018290528254839087908110612b1157612b116150dd565b905f5260205f2090600202015f820151815f019080519060200190612b37929190614ae5565b506020820151816001015590505050837f53da7af401538204fd91f2946f2fe85d05224d2cc766fd7aa9fbd8bf4fb4ce9f8484604051612b78929190615154565b60405180910390a250505050565b6040516311d8d20560e31b8152600481018390525f9081906001600160a01b037f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f1690638ec6902890602401602060405180830381865afa158015612bed573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c1191906150a6565b90505f612c2061207f86611091565b600a0190508315612c4c575f612c358661218b565b9050808211612c4957829350505050611032565b90035b5f612c5a82610db1886118f9565b9050808311612c69575f611d5f565b909103949350505050565b5f6001600160e01b03198216637965db0b60e01b148061103257506301ffc9a760e01b6001600160e01b0319831614611032565b612cb06144a8565b427fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a02556040517f62451d457bc659158be6e6247f56ec1df424a5c7597f71c20c2bc44e0965c8f9905f90a1565b5f815f03612d0c57505f919050565b604051631920845160e01b8152600481018390527f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b0316906319208451906024015b602060405180830381865afa158015612d70573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061103291906150a6565b5f612d9e8361218b565b9050815f03612dc057604051633649e09760e11b815260040160405180910390fd5b81811015612de157604051633649e09760e11b815260040160405180910390fd5b5f8381525f8051602061529d83398151915260205260409020546113aa90849084840390600160801b90046001600160801b03166144cd565b612e22611d69565b15612e4057604051630286f07360e31b815260040160405180910390fd5b565b345f03612e4d575050565b60405163a1903eab60e01b81525f60048201819052906001600160a01b037f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034169063a1903eab90349060240160206040518083038185885af1158015612eb5573d5f803e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190612eda91906150a6565b9050612ee68282614581565b604080516001600160a01b038516815234602082015283917f16ec5116295424dec7fd52c87d9971a963ea7f59f741ad9ad468f0312055dc4991015b60405180910390a2505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081612f5c85856145e9565b90508015611138575f858152602083905260409020612f7b9085614691565b50949350505050565b5f7fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081612fb185856146a5565b90508015611138575f858152602083905260409020612f7b908561471e565b6001600160a01b038116612ff757604051631279f7c160e21b815260040160405180910390fd5b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f4beaaee83871b066b675515d6a53567e76411f60266703cef934a01905a4d832906020015b60405180910390a150565b7f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f6001600160a01b031663a70c70e46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130cc91906150a6565b8110156130d65750565b604051633ed893db60e21b815260040160405180910390fd5b5f8181527f8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe150160205260409020545f8051602061527d83398151915290613133575050565b5f8281526001820160205260408082208290555183917f4642db1736894887bc907d721f20af84d3e585a0a3cea90f41b78b2aa906541b916112ce91815260200190565b5f61318182612cfd565b90505f61318e8483614732565b9050805f0361319d5750505050565b7f00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef86001600160a01b03166327810b6e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131f9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061321d919061508b565b6040516308c2292560e31b8152306004820152602481018390526001600160a01b0391909116906346114928906044015f604051808303815f87803b158015613264575f80fd5b505af1158015613276573d5f803e3d5ffd5b50505050837f4da924ae7845fe96897faab524b536685b8bbc4d82fbb45c10d941e0f86ade0f6132a584613e21565b6132ae84613e21565b60408051928352602083019190915201612b78565b5f8181525f8051602061529d83398151915260205260408082208290555182917f844ae6b00e8a437dcdde1a634feab3273e08bb5c274a4be3b195b308ae0ba20a91a250565b805f0361331557505050565b5f61331f82612cfd565b604051636d78045960e01b81526001600160a01b038681166004830152306024830152604482018390529192507f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c9503490911690636d780459906064016020604051808303815f875af1158015613396573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906133ba91906150a6565b506133c58382614581565b604080516001600160a01b03861681526020810184905284917fee31ebba29fd5471227e42fd8ca621a892d689901892cb8febb03fe802c3214b9101612b78565b612e407fb3e25b5404b87e5a838579cb5d7481d61ad96ee284d38ec1e97c07ba64e7f6fc612a24565b5f5f8051602061527d83398151915261344884846143be565b5f60018411613457575f613475565b8484600119810181811061346d5761346d6150dd565b905060200201355b85855f19810181811061348a5761348a6150dd565b90506020020135039050815f0160405180604001604052808787808060200260200160405190810160405280939291908181526020018383602002808284375f92018290525093855250505060209182018590528354600181018555938152819020825180519394600202909101926135069284920190614ae5565b506020820151816001015550507f1fb1d9b944dd7015e95b7b7a9623c45792e4532badcf9c6e7a284d7d4d0570f08585604051613544929190615154565b60405180910390a150545f19019392505050565b5f80546040516321893f7b60e01b81526001600160a01b03909116906321893f7b9061358e908890889088908890600401615167565b6020604051808303815f875af11580156135aa573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906135ce91906150a6565b90506118778582614581565b5f6135e48461475a565b90505f8184106135f457816135f6565b835b9050805f03613618576040516312d37ee560e31b815260040160405180910390fd5b604051633d7ad0b760e21b81523060048201525f907f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b03169063f5eb42dc90602401602060405180830381865afa15801561367c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906136a091906150a6565b90505f7f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d6001600160a01b031663ea598cb06136db85613e21565b6040518263ffffffff1660e01b81526004016136f991815260200190565b6020604051808303815f875af1158015613715573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061373991906150a6565b604051633d7ad0b760e21b81523060048201529091505f906001600160a01b037f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034169063f5eb42dc90602401602060405180830381865afa1580156137a0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906137c491906150a6565b90506137d28882850361481f565b60405163a9059cbb60e01b81526001600160a01b038781166004830152602482018490527f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d169063a9059cbb906044015f604051808303815f87803b158015613839575f80fd5b505af115801561384b573d5f803e3d5ffd5b5050604080516001600160a01b038a168152602081018690528b93507fe6a8c06447e05a412e5e9581e088941f3994db3d8a9bfd3275b38d77acacafac92500160405180910390a25050505050505050565b5f806138a884612cfd565b90506138b48582614732565b604051638fcb4e5b60e01b81526001600160a01b038581166004830152602482018390529193505f917f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950341690638fcb4e5b906044016020604051808303815f875af1158015613925573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061394991906150a6565b9050857f8615528474a7bb3a28d9971535d956b79242b8e8fcfb27f3e331270fff088afd61397684613e21565b60408051918252602082018590520160405180910390a250509392505050565b5f611153838361487e565b7f00000000000000000000000000000000000000000000000000000000000000008110806139ee57507f0000000000000000000000000000000000000000000000000000000001e1338081115b15613a0c5760405163dee7108760e01b815260040160405180910390fd5b807f78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f00556040518181527fdaf5eddbe9ed0768e54cc8f739a9cb86c57fc70da07eff01d9ba886f21a7a4b390602001613041565b5f8051602061527d83398151915280545f1901821115613a92576040516331e784e960e11b815260040160405180910390fd5b5f838152600182016020526040908190208390555183907f4642db1736894887bc907d721f20af84d3e585a0a3cea90f41b78b2aa906541b90612f229085815260200190565b5f611032825490565b5f613aeb8461475a565b90505f613af782613e21565b8410613b035781613b0c565b613b0c84612cfd565b9050805f03613b2e576040516312d37ee560e31b815260040160405180910390fd5b6040805160018082528183019092525f9160208083019080368337019050509050613b5882613e21565b815f81518110613b6a57613b6a6150dd565b6020908102919091010152604051633d7ad0b760e21b81523060048201525f907f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b03169063f5eb42dc90602401602060405180830381865afa158015613bd9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613bfd91906150a6565b90505f7f000000000000000000000000c7cc160b58f8bb0bac94b80847e2cf2800565c506001600160a01b031663d668104284886040518363ffffffff1660e01b8152600401613c4e929190615186565b5f604051808303815f875af1158015613c69573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052613c9091908101906151dc565b604051633d7ad0b760e21b81523060048201529091505f906001600160a01b037f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c95034169063f5eb42dc90602401602060405180830381865afa158015613cf7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613d1b91906150a6565b9050613d298982850361481f565b887f26673a9d018b21192d08ee14377b798f11b9e5b15ea1559c110265716b8985b588865f81518110613d5e57613d5e6150dd565b6020026020010151855f81518110613d7857613d786150dd565b602090810291909101810151604080516001600160a01b0390951685529184019290925282015260600160405180910390a2505050505050505050565b80515f9081906001190181805b828411613e16575050600282820104602081810286010151808703613def57506001019250611032915050565b80871015613e0257600182039250613dc2565b80871115613e11578160010193505b613dc2565b509195945050505050565b5f815f03613e3057505f919050565b604051630f451f7160e31b8152600481018390527f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b031690637a28fb8890602401612d55565b7f78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f005f829003613ebf57604051633649e09760e11b815260040160405180910390fd5b5f83815260018201602052604090205442600160801b9091046001600160801b03161115613f0d575f838152600182016020526040902054613f0a906001600160801b031683615078565b91505b6113aa8383835f015442613f219190615078565b6144cd565b613f2e612e1a565b805f03613f4e5760405163ad58bfc760e01b815260040160405180910390fd5b5f5f198203613f5f57505f19613f6c565b613f698242615078565b90505b611343816148a4565b805f03613f8157505050565b6040516323b872dd60e01b81526001600160a01b038481166004830152306024830152604482018390527f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d16906323b872dd906064015f604051808303815f87803b158015613fee575f80fd5b505af1158015614000573d5f803e3d5ffd5b5050604051633d7ad0b760e21b81523060048201525f92507f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b0316915063f5eb42dc90602401602060405180830381865afa158015614068573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061408c91906150a6565b604051636f074d1f60e11b8152600481018490529091507f0000000000000000000000008d09a4502cc8cf1547ad300e066060d043f6982d6001600160a01b03169063de0e9a3e906024016020604051808303815f875af11580156140f3573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061411791906150a6565b50604051633d7ad0b760e21b81523060048201525f907f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c950346001600160a01b03169063f5eb42dc90602401602060405180830381865afa15801561417c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906141a091906150a6565b90506141ae84838303614581565b604080516001600160a01b03871681526020810185905285917f6576bbc9c5b478bf9717dc3d2bcb485e5ff0727df77c72558727597f3609d3f1910160405180910390a25050505050565b5f6142038461475a565b90505f61420f82613e21565b841061421b5781614224565b61422484612cfd565b9050805f03614246576040516312d37ee560e31b815260040160405180910390fd5b614250858261481f565b604051638fcb4e5b60e01b81526001600160a01b038481166004830152602482018390525f917f0000000000000000000000003f1c547b21f65e10480de3ad8e19faac46c9503490911690638fcb4e5b906044016020604051808303815f875af11580156142c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906142e491906150a6565b604080516001600160a01b03871681526020810183905291925087917f3e3a1398fe71575ed0c17a80cd9d46ad684c2c75c2fad7b0e7dde15e78ab22d3910160405180910390a2505050505050565b612e4061493f565b61434361493f565b5f61434e838361342f565b905080156113aa57604051634273eaaf60e11b815260040160405180910390fd5b61437761493f565b61108e816139a1565b61438a8282611bf6565b6113435760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044015b60405180910390fd5b60018110806143ec57507f000000000000000000000000000000000000000000000000000000000000000a81115b1561440a57604051638326bf5360e01b815260040160405180910390fd5b81815f81811061441c5761441c6150dd565b905060200201355f03614442576040516302527aef60e21b815260040160405180910390fd5b60015b818110156113aa57828260018303818110614462576144626150dd565b9050602002013583838381811061447b5761447b6150dd565b90506020020135116144a0576040516302527aef60e21b815260040160405180910390fd5b600101614445565b6144b0611d69565b612e405760405163b047186b60e01b815260040160405180910390fd5b815f036144dd576113aa836132c3565b60405180604001604052806144f184614988565b6001600160801b0316815260200161450883614988565b6001600160801b039081169091525f8581525f8051602061529d83398151915260209081526040918290208451948201518416600160801b029490931693909317909155805184815291820183905284917f69a153d448f54b17f05cf3b268a2efab87c94a4727d108c4ca4aa3e5d65113de9101612f22565b805f0361458c575050565b5f9182527f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec9210060205260409091208054820190557f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec9210180549091019055565b5f5f805160206152bd8339815191526146028484611bf6565b614681575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556146373390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050611032565b5f915050611032565b5092915050565b5f611153836001600160a01b0384166149bf565b5f5f805160206152bd8339815191526146be8484611bf6565b15614681575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050611032565b5f611153836001600160a01b038416614a0b565b5f8061473d84611091565b905080831061474c578061474e565b825b915061468a848361481f565b5f8061476583611091565b90505f6148086147748561218b565b6040516311d8d20560e31b815260048101879052611bb1907f0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f6001600160a01b031690638ec6902890602401602060405180830381865afa1580156147db573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906147ff91906150a6565b6105b6886118f9565b9050808211614817575f611138565b900392915050565b5f9182527f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec921006020526040909120805482900390557f23f334b9eb5378c2a1573857b8f9d9ca79959360a69e73d3f16848e56ec921018054919091039055565b5f825f018281548110614893576148936150dd565b905f5260205f200154905092915050565b6148cd7fe8b012900cb200ee5dfc3b895a32791b67d12891b09f117814f167a237783a02829055565b5f198103614906576040515f1981527f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e90602001613041565b7f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e614931428361504e565b604051908152602001613041565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16612e4057604051631afcd79f60e31b815260040160405180910390fd5b5f6001600160801b038211156149bb576040516306dfcc6560e41b815260806004820152602481018390526044016143b5565b5090565b5f818152600183016020526040812054614a0457508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155611032565b505f611032565b5f8181526001830160205260408120548015614681575f614a2d60018361504e565b85549091505f90614a409060019061504e565b9050808214614a9f575f865f018281548110614a5e57614a5e6150dd565b905f5260205f200154905080875f018481548110614a7e57614a7e6150dd565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080614ab057614ab0615268565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050611032565b828054828255905f5260205f20908101928215614b1e579160200282015b82811115614b1e578251825591602001919060010190614b03565b506149bb9291505b808211156149bb575f8155600101614b26565b5f8083601f840112614b49575f80fd5b50813567ffffffffffffffff811115614b60575f80fd5b6020830191508360208260051b8501011115614b7a575f80fd5b9250929050565b5f805f60408486031215614b93575f80fd5b83359250602084013567ffffffffffffffff811115614bb0575f80fd5b614bbc86828701614b39565b9497909650939450505050565b5f60208284031215614bd9575f80fd5b5035919050565b5f60208284031215614bf0575f80fd5b81356001600160e01b031981168114611153575f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040805190810167ffffffffffffffff81118282101715614c3e57614c3e614c07565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715614c6d57614c6d614c07565b604052919050565b5f67ffffffffffffffff821115614c8e57614c8e614c07565b5060051b60200190565b5f8060408385031215614ca9575f80fd5b8235915060208084013567ffffffffffffffff80821115614cc8575f80fd5b9085019060408288031215614cdb575f80fd5b614ce3614c1b565b823582811115614cf1575f80fd5b83019150601f82018813614d03575f80fd5b8135614d16614d1182614c75565b614c44565b81815260059190911b8301850190858101908a831115614d34575f80fd5b938601935b82851015614d5257843582529386019390860190614d39565b83525050918301359282019290925292959294509192505050565b5f8060408385031215614d7e575f80fd5b50508035926020909101359150565b6001600160a01b038116811461108e575f80fd5b5f8060408385031215614db2575f80fd5b8235614dbd81614d8d565b946020939093013593505050565b5f8060408385031215614ddc575f80fd5b823591506020830135614dee81614d8d565b809150509250929050565b5f60208284031215614e09575f80fd5b813561115381614d8d565b5f805f80848603610100811215614e29575f80fd5b8535614e3481614d8d565b9450602086013593506040860135925060a0605f1982011215614e55575f80fd5b509295919450926060019150565b5f8060208385031215614e74575f80fd5b823567ffffffffffffffff811115614e8a575f80fd5b614e9685828601614b39565b90969095509350505050565b602080825282516040838301528051606084018190525f9291820190839060808601905b80831015614ee65783518252928401926001929092019190840190614ec6565b508387015160408701528094505050505092915050565b5f805f805f8060a08789031215614f12575f80fd5b86359550602087013594506040870135614f2b81614d8d565b935060608701359250608087013567ffffffffffffffff811115614f4d575f80fd5b614f5989828a01614b39565b979a9699509497509295939492505050565b5f805f8060608587031215614f7e575f80fd5b8435935060208501359250604085013567ffffffffffffffff811115614fa2575f80fd5b614fae87828801614b39565b95989497509550505050565b5f805f805f8060a08789031215614fcf575f80fd5b863567ffffffffffffffff811115614fe5575f80fd5b614ff189828a01614b39565b909750955050602087013561500581614d8d565b9350604087013561501581614d8d565b925060608701359150608087013561502c81614d8d565b809150509295509295509295565b634e487b7160e01b5f52601160045260245ffd5b818103818111156110325761103261503a565b80820281158282048414176110325761103261503a565b808201808211156110325761103261503a565b5f6020828403121561509b575f80fd5b815161115381614d8d565b5f602082840312156150b6575f80fd5b5051919050565b5f602082840312156150cd575f80fd5b813560ff81168114611153575f80fd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601260045260245ffd5b5f60208284031215615115575f80fd5b81518015158114611153575f80fd5b8183525f6001600160fb1b0383111561513b575f80fd5b8260051b80836020870137939093016020019392505050565b602081525f611138602083018486615124565b848152836020820152606060408201525f611d5f606083018486615124565b604080825283519082018190525f906020906060840190828701845b828110156151be578151845292840192908401906001016151a2565b50505080925050506001600160a01b03831660208301529392505050565b5f60208083850312156151ed575f80fd5b825167ffffffffffffffff811115615203575f80fd5b8301601f81018513615213575f80fd5b8051615221614d1182614c75565b81815260059190911b8201830190838101908783111561523f575f80fd5b928401925b8284101561525d57835182529284019290840190615244565b979650505050505050565b634e487b7160e01b5f52603160045260245ffdfe8f22e270e477f5becb8793b61d439ab7ae990ed8eba045eb72061c0e6cfe150078c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f0102dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800a164736f6c6343000818000a

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef80000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e13380

-----Decoded View---------------
Arg [0] : lidoLocator (address): 0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8
Arg [1] : communityStakingModule (address): 0x4562c3e63c2e586cD1651B958C22F88135aCAd4f
Arg [2] : maxCurveLength (uint256): 10
Arg [3] : minBondLockRetentionPeriod (uint256): 0
Arg [4] : maxBondLockRetentionPeriod (uint256): 31536000

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef8
Arg [1] : 0000000000000000000000004562c3e63c2e586cd1651b958c22f88135acad4f
Arg [2] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 0000000000000000000000000000000000000000000000000000000001e13380


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.