Goerli Testnet

Contract

0xBFA1AcCfaB60fEF0A992582Efa947AfaA09A4c0C
Source Code

Overview

ETH Balance

0 ETH

Multi Chain

Multichain Addresses

N/A
Transaction Hash
Method
Block
From
To
Value
0x6080604083372722023-01-19 7:53:12249 days 11 hrs ago1674114792IN
 Create: NodeOperatorRegistry
0 ETH0.0370313510

Latest 25 internal transactions (View All)

Advanced mode:
Parent Txn Hash Block From To Value
97525392023-09-24 18:39:361 day 44 mins ago1695580776
0xBFA1Ac...A09A4c0C
0 ETH
97454152023-09-23 12:59:482 days 6 hrs ago1695473988
0xBFA1Ac...A09A4c0C
0 ETH
97454112023-09-23 12:59:002 days 6 hrs ago1695473940
0xBFA1Ac...A09A4c0C
0 ETH
97454062023-09-23 12:57:482 days 6 hrs ago1695473868
0xBFA1Ac...A09A4c0C
0 ETH
97454042023-09-23 12:57:242 days 6 hrs ago1695473844
0xBFA1Ac...A09A4c0C
0 ETH
97454022023-09-23 12:57:002 days 6 hrs ago1695473820
0xBFA1Ac...A09A4c0C
0 ETH
97453962023-09-23 12:55:122 days 6 hrs ago1695473712
0xBFA1Ac...A09A4c0C
0 ETH
97453572023-09-23 12:45:482 days 6 hrs ago1695473148
0xBFA1Ac...A09A4c0C
0 ETH
97453542023-09-23 12:45:002 days 6 hrs ago1695473100
0xBFA1Ac...A09A4c0C
0 ETH
97453522023-09-23 12:44:242 days 6 hrs ago1695473064
0xBFA1Ac...A09A4c0C
0 ETH
97453472023-09-23 12:43:242 days 6 hrs ago1695473004
0xBFA1Ac...A09A4c0C
0 ETH
97397522023-09-22 13:37:243 days 5 hrs ago1695389844
0xBFA1Ac...A09A4c0C
0 ETH
97395972023-09-22 12:58:123 days 6 hrs ago1695387492
0xBFA1Ac...A09A4c0C
0 ETH
97384672023-09-22 8:11:363 days 11 hrs ago1695370296
0xBFA1Ac...A09A4c0C
0 ETH
97343112023-09-21 14:51:244 days 4 hrs ago1695307884
0xBFA1Ac...A09A4c0C
0 ETH
97343052023-09-21 14:49:364 days 4 hrs ago1695307776
0xBFA1Ac...A09A4c0C
0 ETH
97333252023-09-21 10:45:004 days 8 hrs ago1695293100
0xBFA1Ac...A09A4c0C
0 ETH
97333222023-09-21 10:44:244 days 8 hrs ago1695293064
0xBFA1Ac...A09A4c0C
0 ETH
97326502023-09-21 7:56:004 days 11 hrs ago1695282960
0xBFA1Ac...A09A4c0C
0 ETH
97326272023-09-21 7:50:124 days 11 hrs ago1695282612
0xBFA1Ac...A09A4c0C
0 ETH
97326132023-09-21 7:47:004 days 11 hrs ago1695282420
0xBFA1Ac...A09A4c0C
0 ETH
97047812023-09-16 11:18:129 days 8 hrs ago1694863092
0xBFA1Ac...A09A4c0C
0 ETH
97047752023-09-16 11:16:249 days 8 hrs ago1694862984
0xBFA1Ac...A09A4c0C
0 ETH
96989172023-09-15 11:16:1210 days 8 hrs ago1694776572
0xBFA1Ac...A09A4c0C
0 ETH
96469392023-09-06 12:47:4819 days 6 hrs ago1694004468
0xBFA1Ac...A09A4c0C
0 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
NodeOperatorRegistry

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 19 : NodeOperatorRegistry.sol
// SPDX-FileCopyrightText: 2021 ShardLabs
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "./interfaces/IValidatorShare.sol";
import "./interfaces/INodeOperatorRegistry.sol";
import "./interfaces/IStMATIC.sol";

/// @title NodeOperatorRegistry
/// @author 2021 ShardLabs.
/// @notice NodeOperatorRegistry is the main contract that manage operators.
contract NodeOperatorRegistry is
    INodeOperatorRegistry,
    PausableUpgradeable,
    AccessControlUpgradeable,
    ReentrancyGuardUpgradeable
{
    /// @notice stakeManager interface.
    IStakeManager public stakeManager;

    /// @notice stMatic interface.
    IStMATIC public stMATIC;

    /// @notice contract version.
    string public version;

    /// @notice all the roles.
    bytes32 public constant DAO_ROLE = keccak256("LIDO_DAO");
    bytes32 public constant PAUSE_ROLE = keccak256("LIDO_PAUSE_OPERATOR");
    bytes32 public constant UNPAUSE_ROLE = keccak256("LIDO_UNPAUSE_OPERATOR");
    bytes32 public constant ADD_NODE_OPERATOR_ROLE =
        keccak256("ADD_NODE_OPERATOR_ROLE");
    bytes32 public constant REMOVE_NODE_OPERATOR_ROLE =
        keccak256("REMOVE_NODE_OPERATOR_ROLE");

    /// @notice The min percent to recognize the system as balanced.
    uint256 public DISTANCE_THRESHOLD_PERCENTS;

    /// @notice The maximum percentage withdraw per system rebalance.
    uint256 public MAX_WITHDRAW_PERCENTAGE_PER_REBALANCE;

    /// @notice Allows to increse the number of validators to request withdraw from
    /// when the system is balanced.
    uint8 public MIN_REQUEST_WITHDRAW_RANGE_PERCENTS;

    /// @notice all the validators ids.
    uint256[] public validatorIds;

    /// @notice Mapping of all owners with node operator id. Mapping is used to be able to
    /// extend the struct.
    mapping(uint256 => address) public validatorIdToRewardAddress;

    /// @notice Mapping of validator reward address to validator Id. Mapping is used to be able to
    /// extend the struct.
    mapping(address => uint256) public validatorRewardAddressToId;

    /// @notice Initialize the NodeOperatorRegistry contract.
    function initialize(
        IStakeManager _stakeManager,
        IStMATIC _stMATIC,
        address _dao
    ) external initializer {
        __Pausable_init_unchained();
        __AccessControl_init_unchained();
        __ReentrancyGuard_init_unchained();

        stakeManager = _stakeManager;
        stMATIC = _stMATIC;

        DISTANCE_THRESHOLD_PERCENTS = 120;
        MAX_WITHDRAW_PERCENTAGE_PER_REBALANCE = 20;
        MIN_REQUEST_WITHDRAW_RANGE_PERCENTS = 15;

        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(PAUSE_ROLE, msg.sender);
        _grantRole(UNPAUSE_ROLE, _dao);
        _grantRole(DAO_ROLE, _dao);
        _grantRole(ADD_NODE_OPERATOR_ROLE, _dao);
        _grantRole(REMOVE_NODE_OPERATOR_ROLE, _dao);
        version = "2.0.0";
    }

    /// @notice Add a new node operator to the system.
    /// ONLY ADD_NODE_OPERATOR_ROLE can execute this function.
    /// @param _validatorId the validator id on stakeManager.
    /// @param _rewardAddress the reward address.
    function addNodeOperator(uint256 _validatorId, address _rewardAddress)
        external
        override
        onlyRole(ADD_NODE_OPERATOR_ROLE)
        nonReentrant
    {
        require(_validatorId != 0, "ValidatorId=0");
        require(
            validatorIdToRewardAddress[_validatorId] == address(0),
            "Validator exists"
        );
        require(
            validatorRewardAddressToId[_rewardAddress] == 0,
            "Reward Address already used"
        );
        require(_rewardAddress != address(0), "Invalid reward address");

        IStakeManager.Validator memory validator = stakeManager.validators(
            _validatorId
        );

        require(
            validator.status == IStakeManager.Status.Active &&
                validator.deactivationEpoch == 0,
            "Validator isn't ACTIVE"
        );

        require(
            validator.contractAddress != address(0),
            "Validator has no ValidatorShare"
        );

        require(
            IValidatorShare(validator.contractAddress).delegation(),
            "Delegation is disabled"
        );

        validatorIdToRewardAddress[_validatorId] = _rewardAddress;
        validatorRewardAddressToId[_rewardAddress] = _validatorId;
        validatorIds.push(_validatorId);

        emit AddNodeOperator(_validatorId, _rewardAddress);
    }

    /// @notice Exit the node operator registry
    /// ONLY the owner of the node operator can call this function
    function exitNodeOperatorRegistry() external override nonReentrant {
        uint256 validatorId = validatorRewardAddressToId[msg.sender];
        address rewardAddress = validatorIdToRewardAddress[validatorId];
        require(rewardAddress == msg.sender, "Unauthorized");

        IStakeManager.Validator memory validator = stakeManager.validators(
            validatorId
        );
        _removeOperator(validatorId, validator.contractAddress, rewardAddress);
        emit ExitNodeOperator(validatorId, rewardAddress);
    }

    /// @notice Remove a node operator from the system and withdraw total delegated tokens to it.
    /// ONLY DAO can execute this function.
    /// withdraw delegated tokens from it.
    /// @param _validatorId the validator id on stakeManager.
    function removeNodeOperator(uint256 _validatorId)
        external
        override
        onlyRole(REMOVE_NODE_OPERATOR_ROLE)
        nonReentrant
    {
        address rewardAddress = validatorIdToRewardAddress[_validatorId];
        require(rewardAddress != address(0), "Validator doesn't exist");

        IStakeManager.Validator memory validator = stakeManager.validators(
            _validatorId
        );

        _removeOperator(_validatorId, validator.contractAddress, rewardAddress);

        emit RemoveNodeOperator(_validatorId, rewardAddress);
    }

    /// @notice Remove a node operator from the system if it fails to meet certain conditions.
    /// If the Node Operator is either Unstaked or Ejected.
    /// @param _validatorId the validator id on stakeManager.
    function removeInvalidNodeOperator(uint256 _validatorId)
        external
        override
        whenNotPaused
        nonReentrant
    {
        (
            NodeOperatorRegistryStatus operatorStatus,
            IStakeManager.Validator memory validator
        ) = _getOperatorStatusAndValidator(_validatorId);

        require(
            operatorStatus == NodeOperatorRegistryStatus.UNSTAKED ||
                operatorStatus == NodeOperatorRegistryStatus.EJECTED,
            "Cannot remove valid operator."
        );
        address rewardAddress = validatorIdToRewardAddress[_validatorId];

        _removeOperator(_validatorId, validator.contractAddress, rewardAddress);

        emit RemoveInvalidNodeOperator(_validatorId, rewardAddress);
    }

    function _removeOperator(
        uint256 _validatorId,
        address _contractAddress,
        address _rewardAddress
    ) private {
        uint256 length = validatorIds.length;
        for (uint256 idx = 0; idx < length - 1; idx++) {
            if (_validatorId == validatorIds[idx]) {
                validatorIds[idx] = validatorIds[validatorIds.length - 1];
                break;
            }
        }
        validatorIds.pop();
        stMATIC.withdrawTotalDelegated(_contractAddress);
        delete validatorIdToRewardAddress[_validatorId];
        delete validatorRewardAddressToId[_rewardAddress];
    }

    ////////////////////////////////////////////////////////////
    /////                                                    ///
    /////                 ***Setters***                      ///
    /////                                                    ///
    ////////////////////////////////////////////////////////////

    /// @notice Set StMatic address.
    /// ONLY DAO can call this function
    /// @param _newStMatic new stMatic address.
    function setStMaticAddress(address _newStMatic)
        external
        override
        onlyRole(DAO_ROLE)
    {
        require(_newStMatic != address(0), "Invalid stMatic address");

        address oldStMATIC = address(stMATIC);
        stMATIC = IStMATIC(_newStMatic);

        emit SetStMaticAddress(oldStMATIC, _newStMatic);
    }

    /// @notice Update the reward address of a Node Operator.
    /// ONLY Operator owner can call this function
    /// @param _newRewardAddress the new reward address.
    function setRewardAddress(address _newRewardAddress)
        external
        override
        whenNotPaused
    {
        uint256 validatorId = validatorRewardAddressToId[msg.sender];
        address oldRewardAddress = validatorIdToRewardAddress[validatorId];
        require(oldRewardAddress == msg.sender, "Unauthorized");
        require(_newRewardAddress != address(0), "Invalid reward address");

        validatorIdToRewardAddress[validatorId] = _newRewardAddress;
        validatorRewardAddressToId[_newRewardAddress] = validatorId;
        delete validatorRewardAddressToId[msg.sender];

        emit SetRewardAddress(validatorId, oldRewardAddress, _newRewardAddress);
    }

    /// @notice set DISTANCE_THRESHOLD_PERCENTS
    /// ONLY DAO can call this function
    /// @param _newDistanceThreshold the min rebalance threshold to include
    /// a validator in the delegation process.
    function setDistanceThreshold(uint256 _newDistanceThreshold)
        external
        override
        onlyRole(DAO_ROLE)
    {
        require(_newDistanceThreshold >= 100, "Invalid distance threshold");
        uint256 _oldDistanceThreshold = DISTANCE_THRESHOLD_PERCENTS;
        DISTANCE_THRESHOLD_PERCENTS = _newDistanceThreshold;

        emit SetDistanceThreshold(_oldDistanceThreshold, _newDistanceThreshold);
    }

    /// @notice set MIN_REQUEST_WITHDRAW_RANGE_PERCENTS
    /// ONLY DAO can call this function
    /// @param _newMinRequestWithdrawRangePercents the min request withdraw range percents.
    function setMinRequestWithdrawRange(
        uint8 _newMinRequestWithdrawRangePercents
    ) external override onlyRole(DAO_ROLE) {
        require(
            _newMinRequestWithdrawRangePercents <= 100,
            "Invalid minRequestWithdrawRange"
        );
        uint8 _oldMinRequestWithdrawRange = MIN_REQUEST_WITHDRAW_RANGE_PERCENTS;
        MIN_REQUEST_WITHDRAW_RANGE_PERCENTS = _newMinRequestWithdrawRangePercents;

        emit SetMinRequestWithdrawRange(
            _oldMinRequestWithdrawRange,
            _newMinRequestWithdrawRangePercents
        );
    }

    /// @notice set MAX_WITHDRAW_PERCENTAGE_PER_REBALANCE
    /// ONLY DAO can call this function
    /// @param _newMaxWithdrawPercentagePerRebalance the max withdraw percentage to
    /// withdraw from a validator per rebalance.
    function setMaxWithdrawPercentagePerRebalance(
        uint256 _newMaxWithdrawPercentagePerRebalance
    ) external override onlyRole(DAO_ROLE) {
        require(
            _newMaxWithdrawPercentagePerRebalance <= 100,
            "Invalid maxWithdrawPercentagePerRebalance"
        );
        uint256 _oldMaxWithdrawPercentagePerRebalance = MAX_WITHDRAW_PERCENTAGE_PER_REBALANCE;
        MAX_WITHDRAW_PERCENTAGE_PER_REBALANCE = _newMaxWithdrawPercentagePerRebalance;

        emit SetMaxWithdrawPercentagePerRebalance(
            _oldMaxWithdrawPercentagePerRebalance,
            _newMaxWithdrawPercentagePerRebalance
        );
    }

    /// @notice Allows to pause the contract.
    /// @param _newVersion contract version.
    function setVersion(string memory _newVersion)
        external
        override
        onlyRole(DAO_ROLE)
    {
        string memory oldVersion = version;
        version = _newVersion;
        emit SetVersion(oldVersion, _newVersion);
    }

    /// @notice Pauses the contract
    function pause() external onlyRole(PAUSE_ROLE) {
        _pause();
    }

    /// @notice Unpauses the contract
    function unpause() external onlyRole(UNPAUSE_ROLE) {
        _unpause();
    }

    ////////////////////////////////////////////////////////////
    /////                                                    ///
    /////                 ***Getters***                      ///
    /////                                                    ///
    ////////////////////////////////////////////////////////////

    /// @notice List all the ACTIVE operators on the stakeManager.
    /// @return activeNodeOperators a list of ACTIVE node operator.
    /// @return totalActiveNodeOperators total active node operators.
    function listDelegatedNodeOperators()
        external
        view
        override
        returns (ValidatorData[] memory, uint256)
    {
        uint256 totalActiveNodeOperators = 0;
        IStakeManager.Validator memory validator;
        NodeOperatorRegistryStatus operatorStatus;
        ValidatorData[] memory activeValidators = new ValidatorData[](validatorIds.length);

        for (uint256 i = 0; i < validatorIds.length; i++) {
            (operatorStatus, validator) = _getOperatorStatusAndValidator(
                validatorIds[i]
            );
            if (operatorStatus == NodeOperatorRegistryStatus.ACTIVE) {
                if (!IValidatorShare(validator.contractAddress).delegation())
                    continue;

                activeValidators[totalActiveNodeOperators] = ValidatorData(
                    validator.contractAddress,
                    validatorIdToRewardAddress[validatorIds[i]]
                );
                totalActiveNodeOperators++;
            }
        }
        return (activeValidators, totalActiveNodeOperators);
    }

    /// @notice List all the operators on the stakeManager that can be withdrawn from this
    /// includes ACTIVE, JAILED, ejected, and UNSTAKED operators.
    /// @return nodeOperators a list of ACTIVE, JAILED, EJECTED or UNSTAKED node operator.
    /// @return totalNodeOperators total number of node operators.
    function listWithdrawNodeOperators()
        external
        view
        override
        returns (ValidatorData[] memory, uint256)
    {
        uint256 totalNodeOperators = 0;
        uint256[] memory memValidatorIds = validatorIds;
        uint256 length = memValidatorIds.length;
        IStakeManager.Validator memory validator;
        NodeOperatorRegistryStatus operatorStatus;
        ValidatorData[] memory withdrawValidators = new ValidatorData[](length);

        for (uint256 i = 0; i < length; i++) {
            (operatorStatus, validator) = _getOperatorStatusAndValidator(
                memValidatorIds[i]
            );
            if (operatorStatus == NodeOperatorRegistryStatus.INACTIVE) continue;

            withdrawValidators[totalNodeOperators] = ValidatorData(
                validator.contractAddress,
                validatorIdToRewardAddress[memValidatorIds[i]]
            );
            totalNodeOperators++;
        }

        return (withdrawValidators, totalNodeOperators);
    }

    /// @notice Returns operators delegation infos.
    /// @return validators all active node operators.
    /// @return activeOperatorCount count only active validators.
    /// @return stakePerOperator amount staked in each validator.
    /// @return totalStaked the total amount staked in all validators.
    /// @return distanceThreshold the distance between the min and max amount staked in a validator.
    function _getValidatorsDelegationInfos()
        private
        view
        returns (
            ValidatorData[] memory validators,
            uint256 activeOperatorCount,
            uint256[] memory stakePerOperator,
            uint256 totalStaked,
            uint256 distanceThreshold
        )
    {
        uint256 length = validatorIds.length;
        validators = new ValidatorData[](length);
        stakePerOperator = new uint256[](length);

        uint256 validatorId;
        IStakeManager.Validator memory validator;
        NodeOperatorRegistryStatus status;

        uint256 maxAmount;
        uint256 minAmount;

        for (uint256 i = 0; i < length; i++) {
            validatorId = validatorIds[i];
            (status, validator) = _getOperatorStatusAndValidator(validatorId);
            if (status == NodeOperatorRegistryStatus.INACTIVE) continue;

            require(
                !(status == NodeOperatorRegistryStatus.EJECTED),
                "Could not calculate the stake data, an operator was EJECTED"
            );

            require(
                !(status == NodeOperatorRegistryStatus.UNSTAKED),
                "Could not calculate the stake data, an operator was UNSTAKED"
            );

            // Get the total staked tokens by the StMatic contract in a validatorShare.
            (uint256 amount, ) = IValidatorShare(validator.contractAddress)
                .getTotalStake(address(stMATIC));

            totalStaked += amount;

            if (maxAmount < amount) {
                maxAmount = amount;
            }

            if (minAmount > amount || minAmount == 0) {
                minAmount = amount;
            }

            bool isDelegationEnabled = IValidatorShare(
                validator.contractAddress
            ).delegation();

            if (
                status == NodeOperatorRegistryStatus.ACTIVE &&
                isDelegationEnabled
            ) {
                stakePerOperator[activeOperatorCount] = amount;

                validators[activeOperatorCount] = ValidatorData(
                    validator.contractAddress,
                    validatorIdToRewardAddress[validatorIds[i]]
                );

                activeOperatorCount++;
            }
        }

        require(activeOperatorCount > 0, "There are no active validator");

        // The max amount is multiplied by 100 to have a precise value.
        minAmount = minAmount == 0 ? 1 : minAmount;
        distanceThreshold = ((maxAmount * 100) / minAmount);
    }

    /// @notice  Calculate how total buffered should be delegated between the active validators,
    /// depending on if the system is balanced or not. If validators are in EJECTED or UNSTAKED
    /// status the function will revert.
    /// @param _amountToDelegate The total that can be delegated.
    /// @return validators all active node operators.
    /// @return totalActiveNodeOperator total active node operators.
    /// @return operatorRatios a list of operator's ratio. It will be calculated if the system is not balanced.
    /// @return totalRatio the total ratio. If ZERO that means the system is balanced.
    ///  It will be calculated if the system is not balanced.
    function getValidatorsDelegationAmount(uint256 _amountToDelegate)
        external
        view
        override
        returns (
            ValidatorData[] memory validators,
            uint256 totalActiveNodeOperator,
            uint256[] memory operatorRatios,
            uint256 totalRatio
        )
    {
        require(validatorIds.length > 0, "Not enough operators to delegate");
        uint256[] memory stakePerOperator;
        uint256 totalStaked;
        uint256 distanceThreshold;
        (
            validators,
            totalActiveNodeOperator,
            stakePerOperator,
            totalStaked,
            distanceThreshold
        ) = _getValidatorsDelegationInfos();

        uint256 distanceThresholdPercents = DISTANCE_THRESHOLD_PERCENTS;
        bool isTheSystemBalanced = distanceThreshold <=
            distanceThresholdPercents;
        if (isTheSystemBalanced) {
            return (
                validators,
                totalActiveNodeOperator,
                operatorRatios,
                totalRatio
            );
        }

        // If the system is not balanced calculate ratios
        operatorRatios = new uint256[](totalActiveNodeOperator);
        uint256 rebalanceTarget = (totalStaked + _amountToDelegate) /
            totalActiveNodeOperator;

        uint256 operatorRatioToDelegate;

        for (uint256 idx = 0; idx < totalActiveNodeOperator; idx++) {
            operatorRatioToDelegate = stakePerOperator[idx] >= rebalanceTarget
                ? 0
                : rebalanceTarget - stakePerOperator[idx];

            if (operatorRatioToDelegate != 0 && stakePerOperator[idx] != 0) {
                operatorRatioToDelegate = (rebalanceTarget * 100) /
                    stakePerOperator[idx] >=
                    distanceThresholdPercents
                    ? operatorRatioToDelegate
                    : 0;
            }

            operatorRatios[idx] = operatorRatioToDelegate;
            totalRatio += operatorRatioToDelegate;
        }
    }

    /// @notice  Calculate how the system could be rebalanced depending on the current
    /// buffered tokens. If validators are in EJECTED or UNSTAKED status the function will revert.
    /// If the system is balanced the function will revert.
    /// @notice Calculate the operator ratios to rebalance the system.
    /// @param _amountToReDelegate The total amount to redelegate in Matic.
    /// @return validators all active node operators.
    /// @return totalActiveNodeOperator total active node operators.
    /// @return operatorRatios is a list of operator's ratio.
    /// @return totalRatio the total ratio. If ZERO that means the system is balanced.
    /// @return totalToWithdraw the total amount to withdraw.
    function getValidatorsRebalanceAmount(uint256 _amountToReDelegate)
        external
        view
        override
        returns (
            ValidatorData[] memory validators,
            uint256 totalActiveNodeOperator,
            uint256[] memory operatorRatios,
            uint256 totalRatio,
            uint256 totalToWithdraw
        )
    {
        require(validatorIds.length > 1, "Not enough operator to rebalance");
        uint256[] memory stakePerOperator;
        uint256 totalStaked;
        uint256 distanceThreshold;
        (
            validators,
            totalActiveNodeOperator,
            stakePerOperator,
            totalStaked,
            distanceThreshold
        ) = _getValidatorsDelegationInfos();

        require(
            totalActiveNodeOperator > 1,
            "Not enough active operators to rebalance"
        );

        uint256 distanceThresholdPercents = DISTANCE_THRESHOLD_PERCENTS;
        require(
            distanceThreshold >= distanceThresholdPercents && totalStaked > 0,
            "The system is balanced"
        );

        operatorRatios = new uint256[](totalActiveNodeOperator);
        uint256 rebalanceTarget = totalStaked / totalActiveNodeOperator;
        uint256 operatorRatioToRebalance;

        for (uint256 idx = 0; idx < totalActiveNodeOperator; idx++) {
            operatorRatioToRebalance = stakePerOperator[idx] > rebalanceTarget
                ? stakePerOperator[idx] - rebalanceTarget
                : 0;

            operatorRatioToRebalance = (stakePerOperator[idx] * 100) /
                rebalanceTarget >=
                distanceThresholdPercents
                ? operatorRatioToRebalance
                : 0;

            operatorRatios[idx] = operatorRatioToRebalance;
            totalRatio += operatorRatioToRebalance;
        }
        totalToWithdraw = totalRatio > _amountToReDelegate
            ? totalRatio - _amountToReDelegate
            : 0;

        totalToWithdraw =
            (totalToWithdraw * MAX_WITHDRAW_PERCENTAGE_PER_REBALANCE) /
            100;
        require(totalToWithdraw > 0, "Zero total to withdraw");
    }

    /// @notice Returns operators info.
    /// @return nonInactiveValidators all no inactive node operators.
    /// @return stakePerOperator amount staked in each validator.
    /// @return totalDelegated the total amount delegated to all validators.
    /// @return minAmount the distance between the min and max amount staked in a validator.
    /// @return maxAmount the distance between the min and max amount staked in a validator.
    function _getValidatorsRequestWithdraw()
        private
        view
        returns (
            ValidatorData[] memory nonInactiveValidators,
            uint256[] memory stakePerOperator,
            uint256 totalDelegated,
            uint256 minAmount,
            uint256 maxAmount
        )
    {
        uint256 length = validatorIds.length;
        nonInactiveValidators = new ValidatorData[](length);
        stakePerOperator = new uint256[](length);

        uint256 validatorId;
        IStakeManager.Validator memory validator;

        for (uint256 i = 0; i < length; i++) {
            validatorId = validatorIds[i];
            (, validator) = _getOperatorStatusAndValidator(validatorId);

            // Get the total staked tokens by the StMatic contract in a validatorShare.
            (uint256 amount, ) = IValidatorShare(validator.contractAddress)
                .getTotalStake(address(stMATIC));

            stakePerOperator[i] = amount;
            totalDelegated += amount;

            if (maxAmount < amount) {
                maxAmount = amount;
            }

            if ((minAmount > amount && amount != 0) || minAmount == 0) {
                minAmount = amount;
            }

            nonInactiveValidators[i] = ValidatorData(
                validator.contractAddress,
                validatorIdToRewardAddress[validatorIds[i]]
            );
        }
        minAmount = minAmount == 0 ? 1 : minAmount;
    }

    /// @notice Calculate the validators to request withdrawal from depending if the system is balalnced or not.
    /// @param _withdrawAmount The amount to withdraw.
    /// @return validators all node operators.
    /// @return totalDelegated total amount delegated.
    /// @return bigNodeOperatorLength number of ids bigNodeOperatorIds.
    /// @return bigNodeOperatorIds stores the ids of node operators that amount delegated to it is greater than the average delegation.
    /// @return smallNodeOperatorLength number of ids smallNodeOperatorIds.
    /// @return smallNodeOperatorIds stores the ids of node operators that amount delegated to it is less than the average delegation.
    /// @return operatorAmountCanBeRequested amount that can be requested from a spécific validator when the system is not balanced.
    /// @return totalValidatorToWithdrawFrom the number of validator to withdraw from when the system is balanced.
    function getValidatorsRequestWithdraw(uint256 _withdrawAmount)
        external
        view
        override
        returns (
            ValidatorData[] memory validators,
            uint256 totalDelegated,
            uint256 bigNodeOperatorLength,
            uint256[] memory bigNodeOperatorIds,
            uint256 smallNodeOperatorLength,
            uint256[] memory smallNodeOperatorIds,
            uint256[] memory operatorAmountCanBeRequested,
            uint256 totalValidatorToWithdrawFrom
        )
    {
        if (validatorIds.length == 0) {
            return (
                validators,
                totalDelegated,
                bigNodeOperatorLength,
                bigNodeOperatorIds,
                smallNodeOperatorLength,
                smallNodeOperatorIds,
                operatorAmountCanBeRequested,
                totalValidatorToWithdrawFrom
            );
        }
        uint256[] memory stakePerOperator;
        uint256 minAmount;
        uint256 maxAmount;

        (
            validators,
            stakePerOperator,
            totalDelegated,
            minAmount,
            maxAmount
        ) = _getValidatorsRequestWithdraw();

        if (totalDelegated == 0) {
            return (
                validators,
                totalDelegated,
                bigNodeOperatorLength,
                bigNodeOperatorIds,
                smallNodeOperatorLength,
                smallNodeOperatorIds,
                operatorAmountCanBeRequested,
                totalValidatorToWithdrawFrom
            );
        }

        uint256 length = validators.length;
        uint256 withdrawAmountPercentage = (_withdrawAmount * 100) /
            totalDelegated;

        totalValidatorToWithdrawFrom =
            (((withdrawAmountPercentage + MIN_REQUEST_WITHDRAW_RANGE_PERCENTS) *
                length) / 100) +
            1;

        totalValidatorToWithdrawFrom = totalValidatorToWithdrawFrom > length
            ? length
            : totalValidatorToWithdrawFrom;

        if (
            (maxAmount * 100) / minAmount <= DISTANCE_THRESHOLD_PERCENTS &&
            minAmount * totalValidatorToWithdrawFrom >= _withdrawAmount
        ) {
            return (
                validators,
                totalDelegated,
                bigNodeOperatorLength,
                bigNodeOperatorIds,
                smallNodeOperatorLength,
                smallNodeOperatorIds,
                operatorAmountCanBeRequested,
                totalValidatorToWithdrawFrom
            );
        }
        totalValidatorToWithdrawFrom = 0;
        operatorAmountCanBeRequested = new uint256[](length);
        withdrawAmountPercentage = withdrawAmountPercentage == 0
            ? 1
            : withdrawAmountPercentage;
        uint256 rebalanceTarget = totalDelegated > _withdrawAmount
            ? (totalDelegated - _withdrawAmount) / length
            : 0;

        rebalanceTarget = rebalanceTarget > minAmount
            ? minAmount
            : rebalanceTarget;

        uint256 averageTarget = totalDelegated / length;
        bigNodeOperatorIds = new uint256[](length);
        smallNodeOperatorIds = new uint256[](length);

        for (uint256 idx = 0; idx < length; idx++) {
            if (stakePerOperator[idx] > averageTarget) {
                bigNodeOperatorIds[bigNodeOperatorLength] = idx;
                bigNodeOperatorLength++;
            } else {
                smallNodeOperatorIds[smallNodeOperatorLength] = idx;
                smallNodeOperatorLength++;
            }

            uint256 operatorRatioToRebalance = stakePerOperator[idx] != 0 &&
                stakePerOperator[idx] > rebalanceTarget
                ? stakePerOperator[idx] - rebalanceTarget
                : 0;
            operatorAmountCanBeRequested[idx] = operatorRatioToRebalance;
        }
    }

    /// @notice Returns a node operator.
    /// @param _validatorId the validator id on stakeManager.
    /// @return nodeOperator Returns a node operator.
    function getNodeOperator(uint256 _validatorId)
        external
        view
        override
        returns (FullNodeOperatorRegistry memory nodeOperator)
    {
        (
            NodeOperatorRegistryStatus operatorStatus,
            IStakeManager.Validator memory validator
        ) = _getOperatorStatusAndValidator(_validatorId);
        nodeOperator.validatorShare = validator.contractAddress;
        nodeOperator.validatorId = _validatorId;
        nodeOperator.rewardAddress = validatorIdToRewardAddress[_validatorId];
        nodeOperator.status = operatorStatus;
        nodeOperator.commissionRate = validator.commissionRate;
    }

    /// @notice Returns a node operator.
    /// @param _rewardAddress the reward address.
    /// @return nodeOperator Returns a node operator.
    function getNodeOperator(address _rewardAddress)
        external
        view
        override
        returns (FullNodeOperatorRegistry memory nodeOperator)
    {
        uint256 validatorId = validatorRewardAddressToId[_rewardAddress];
        (
            NodeOperatorRegistryStatus operatorStatus,
            IStakeManager.Validator memory validator
        ) = _getOperatorStatusAndValidator(validatorId);

        nodeOperator.status = operatorStatus;
        nodeOperator.rewardAddress = _rewardAddress;
        nodeOperator.validatorId = validatorId;
        nodeOperator.validatorShare = validator.contractAddress;
        nodeOperator.commissionRate = validator.commissionRate;
    }

    /// @notice Returns a node operator status.
    /// @param  _validatorId is the id of the node operator.
    /// @return operatorStatus Returns a node operator status.
    function getNodeOperatorStatus(uint256 _validatorId)
        external
        view
        override
        returns (NodeOperatorRegistryStatus operatorStatus)
    {
        (operatorStatus, ) = _getOperatorStatusAndValidator(_validatorId);
    }

    /// @notice Returns a node operator status.
    /// @param  _validatorId is the id of the node operator.
    /// @return operatorStatus is the operator status.
    /// @return validator is the validator info.
    function _getOperatorStatusAndValidator(uint256 _validatorId)
        private
        view
        returns (
            NodeOperatorRegistryStatus operatorStatus,
            IStakeManager.Validator memory validator
        )
    {
        address rewardAddress = validatorIdToRewardAddress[_validatorId];
        require(rewardAddress != address(0), "Operator not found");
        validator = stakeManager.validators(_validatorId);

        if (
            validator.status == IStakeManager.Status.Active &&
            validator.deactivationEpoch == 0
        ) {
            operatorStatus = NodeOperatorRegistryStatus.ACTIVE;
        } else if (
            validator.status == IStakeManager.Status.Locked &&
            validator.deactivationEpoch == 0
        ) {
            operatorStatus = NodeOperatorRegistryStatus.JAILED;
        } else if (
            (validator.status == IStakeManager.Status.Active ||
                validator.status == IStakeManager.Status.Locked) &&
            validator.deactivationEpoch != 0
        ) {
            operatorStatus = NodeOperatorRegistryStatus.EJECTED;
        } else if ((validator.status == IStakeManager.Status.Unstaked)) {
            operatorStatus = NodeOperatorRegistryStatus.UNSTAKED;
        } else {
            operatorStatus = NodeOperatorRegistryStatus.INACTIVE;
        }

        return (operatorStatus, validator);
    }

    /// @notice Return a list of all validator ids in the system.
    function getValidatorIds()
        external
        view
        override
        returns (uint256[] memory)
    {
        return validatorIds;
    }

    /// @notice Return the statistics about the protocol as a list
    /// @return isBalanced if the system is balanced or not.
    /// @return distanceThreshold the distance threshold
    /// @return minAmount min amount delegated to a validator.
    /// @return maxAmount max amount delegated to a validator.
    function getProtocolStats()
        external
        view
        override
        returns (
            bool isBalanced,
            uint256 distanceThreshold,
            uint256 minAmount,
            uint256 maxAmount
        )
    {
        uint256 length = validatorIds.length;
        uint256 validatorId;
        for (uint256 i = 0; i < length; i++) {
            validatorId = validatorIds[i];
            (
                ,
                IStakeManager.Validator memory validator
            ) = _getOperatorStatusAndValidator(validatorId);

            (uint256 amount, ) = IValidatorShare(validator.contractAddress)
                .getTotalStake(address(stMATIC));
            if (maxAmount < amount) {
                maxAmount = amount;
            }

            if (minAmount > amount || minAmount == 0) {
                minAmount = amount;
            }
        }

        uint256 min = minAmount == 0 ? 1 : minAmount;
        distanceThreshold = ((maxAmount * 100) / min);
        isBalanced = distanceThreshold <= DISTANCE_THRESHOLD_PERCENTS;
    }

    /// @notice List all the node operator statuses in the system.
    /// @return inactiveNodeOperator the number of inactive operators.
    /// @return activeNodeOperator the number of active operators.
    /// @return jailedNodeOperator the number of jailed operators.
    /// @return ejectedNodeOperator the number of ejected operators.
    /// @return unstakedNodeOperator the number of unstaked operators.
    function getStats()
        external
        view
        override
        returns (
            uint256 inactiveNodeOperator,
            uint256 activeNodeOperator,
            uint256 jailedNodeOperator,
            uint256 ejectedNodeOperator,
            uint256 unstakedNodeOperator
        )
    {
        uint256 length = validatorIds.length;
        for (uint256 idx = 0; idx < length; idx++) {
            (
                NodeOperatorRegistryStatus operatorStatus,

            ) = _getOperatorStatusAndValidator(validatorIds[idx]);
            if (operatorStatus == NodeOperatorRegistryStatus.ACTIVE) {
                activeNodeOperator++;
            } else if (operatorStatus == NodeOperatorRegistryStatus.JAILED) {
                jailedNodeOperator++;
            } else if (operatorStatus == NodeOperatorRegistryStatus.EJECTED) {
                ejectedNodeOperator++;
            } else if (operatorStatus == NodeOperatorRegistryStatus.UNSTAKED) {
                unstakedNodeOperator++;
            } else {
                inactiveNodeOperator++;
            }
        }
    }
}

File 2 of 19 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 3 of 19 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 4 of 19 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../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:
 *
 * ```
 * 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}:
 *
 * ```
 * 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.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

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

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

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @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 override returns (bytes32) {
        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.
     */
    function grantRole(bytes32 role, address account) public virtual override 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.
     */
    function revokeRole(bytes32 role, address account) public virtual override 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 `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

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

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 5 of 19 : IValidatorShare.sol
// SPDX-FileCopyrightText: 2021 ShardLabs
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

/// @title Polygon validator share interface.
/// @dev https://github.com/maticnetwork/contracts/blob/v0.3.0-backport/contracts/staking/validatorShare/ValidatorShare.sol
/// @author 2021 ShardLabs
interface IValidatorShare {
    struct DelegatorUnbond {
        uint256 shares;
        uint256 withdrawEpoch;
    }

    function unbondNonces(address _address) external view returns (uint256);

    function activeAmount() external view returns (uint256);

    function validatorId() external view returns (uint256);

    function withdrawExchangeRate() external view returns (uint256);

    function withdrawRewards() external;

    function unstakeClaimTokens() external;

    function minAmount() external view returns (uint256);

    function getLiquidRewards(address user) external view returns (uint256);

    function delegation() external view returns (bool);

    function updateDelegation(bool _delegation) external;

    function buyVoucher(uint256 _amount, uint256 _minSharesToMint)
        external
        returns (uint256);

    function sellVoucher_new(uint256 claimAmount, uint256 maximumSharesToBurn)
        external;

    function unstakeClaimTokens_new(uint256 unbondNonce) external;

    function unbonds_new(address _address, uint256 _unbondNonce)
        external
        view
        returns (DelegatorUnbond memory);

    function getTotalStake(address user)
        external
        view
        returns (uint256, uint256);

    function owner() external view returns (address);

    function restake() external returns (uint256, uint256);

    function unlock() external;

    function lock() external;

    function drain(
        address token,
        address payable destination,
        uint256 amount
    ) external;

    function slash(uint256 _amount) external;

    function migrateOut(address user, uint256 amount) external;

    function migrateIn(address user, uint256 amount) external;

    function exchangeRate() external view returns (uint256);
}

File 6 of 19 : INodeOperatorRegistry.sol
// SPDX-FileCopyrightText: 2021 ShardLabs
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

/// @title INodeOperatorRegistry
/// @author 2021 ShardLabs
/// @notice Node operator registry interface
interface INodeOperatorRegistry {
    /// @notice Node Operator Registry Statuses
    /// StakeManager statuses: https://github.com/maticnetwork/contracts/blob/v0.3.0-backport/contracts/staking/stakeManager/StakeManagerStorage.sol#L13
    /// ACTIVE: (validator.status == status.Active && validator.deactivationEpoch == 0)
    /// JAILED: (validator.status == status.Locked && validator.deactivationEpoch == 0)
    /// EJECTED: ((validator.status == status.Active || validator.status == status.Locked) && validator.deactivationEpoch != 0)
    /// UNSTAKED: (validator.status == status.Unstaked)
    enum NodeOperatorRegistryStatus {
        INACTIVE,
        ACTIVE,
        JAILED,
        EJECTED,
        UNSTAKED
    }

    /// @notice The full node operator struct.
    /// @param validatorId the validator id on stakeManager.
    /// @param commissionRate rate of each operator
    /// @param validatorShare the validator share address of the validator.
    /// @param rewardAddress the reward address.
    /// @param delegation delegation.
    /// @param status the status of the node operator in the stake manager.
    struct FullNodeOperatorRegistry {
        uint256 validatorId;
        uint256 commissionRate;
        address validatorShare;
        address rewardAddress;
        bool delegation;
        NodeOperatorRegistryStatus status;
    }

    /// @notice The node operator struct
    /// @param validatorShare the validator share address of the validator.
    /// @param rewardAddress the reward address.
    struct ValidatorData {
        address validatorShare;
        address rewardAddress;
    }

    /// @notice Add a new node operator to the system.
    /// ONLY DAO can execute this function.
    /// @param validatorId the validator id on stakeManager.
    /// @param rewardAddress the reward address.
    function addNodeOperator(uint256 validatorId, address rewardAddress)
        external;

    /// @notice Exit the node operator registry
    /// ONLY the owner of the node operator can call this function
    function exitNodeOperatorRegistry() external;

    /// @notice Remove a node operator from the system and withdraw total delegated tokens to it.
    /// ONLY DAO can execute this function.
    /// withdraw delegated tokens from it.
    /// @param validatorId the validator id on stakeManager.
    function removeNodeOperator(uint256 validatorId) external;

    /// @notice Remove a node operator from the system if it fails to meet certain conditions.
    /// 1. If the commission of the Node Operator is less than the standard commission.
    /// 2. If the Node Operator is either Unstaked or Ejected.
    /// @param validatorId the validator id on stakeManager.
    function removeInvalidNodeOperator(uint256 validatorId) external;

    /// @notice Set StMatic address.
    /// ONLY DAO can call this function
    /// @param newStMatic new stMatic address.
    function setStMaticAddress(address newStMatic) external;

    /// @notice Update reward address of a Node Operator.
    /// ONLY Operator owner can call this function
    /// @param newRewardAddress the new reward address.
    function setRewardAddress(address newRewardAddress) external;

    /// @notice set DISTANCETHRESHOLD
    /// ONLY DAO can call this function
    /// @param distanceThreshold the min rebalance threshold to include
    /// a validator in the delegation process.
    function setDistanceThreshold(uint256 distanceThreshold) external;

    /// @notice set MINREQUESTWITHDRAWRANGE
    /// ONLY DAO can call this function
    /// @param minRequestWithdrawRange the min request withdraw range.
    function setMinRequestWithdrawRange(uint8 minRequestWithdrawRange) external;

    /// @notice set MAXWITHDRAWPERCENTAGEPERREBALANCE
    /// ONLY DAO can call this function
    /// @param maxWithdrawPercentagePerRebalance the max withdraw percentage to
    /// withdraw from a validator per rebalance.
    function setMaxWithdrawPercentagePerRebalance(
        uint256 maxWithdrawPercentagePerRebalance
    ) external;

    /// @notice Allows to set new version.
    /// @param _newVersion new contract version.
    function setVersion(string memory _newVersion) external;

    /// @notice List all the ACTIVE operators on the stakeManager.
    /// @return activeNodeOperators a list of ACTIVE node operator.
    /// @return totalActiveNodeOperators total active node operators.
    function listDelegatedNodeOperators()
        external
        view
        returns (ValidatorData[] memory, uint256);

    /// @notice List all the operators on the stakeManager that can be withdrawn from this includes ACTIVE, JAILED, and
    /// @notice UNSTAKED operators.
    /// @return nodeOperators a list of ACTIVE, JAILED or UNSTAKED node operator.
    /// @return totalNodeOperators total number of node operators.
    function listWithdrawNodeOperators()
        external
        view
        returns (ValidatorData[] memory, uint256);

    /// @notice  Calculate how total buffered should be delegated between the active validators,
    /// depending on if the system is balanced or not. If validators are in EJECTED or UNSTAKED
    /// status the function will revert.
    /// @param amountToDelegate The total that can be delegated.
    /// @return validators all active node operators.
    /// @return totalActiveNodeOperator total active node operators.
    /// @return operatorRatios a list of operator's ratio. It will be calculated if the system is not balanced.
    /// @return totalRatio the total ratio. If ZERO that means the system is balanced.
    ///  It will be calculated if the system is not balanced.
    function getValidatorsDelegationAmount(uint256 amountToDelegate)
        external
        view
        returns (
            ValidatorData[] memory validators,
            uint256 totalActiveNodeOperator,
            uint256[] memory operatorRatios,
            uint256 totalRatio
        );

    /// @notice  Calculate how the system could be rebalanced depending on the current
    /// buffered tokens. If validators are in EJECTED or UNSTAKED status the function will revert.
    /// If the system is balanced the function will revert.
    /// @notice Calculate the operator ratios to rebalance the system.
    /// @param totalBuffered The total amount buffered in stMatic.
    /// @return validators all active node operators.
    /// @return totalActiveNodeOperator total active node operators.
    /// @return operatorRatios is a list of operator's ratio.
    /// @return totalRatio the total ratio. If ZERO that means the system is balanced.
    /// @return totalToWithdraw the total amount to withdraw.
    function getValidatorsRebalanceAmount(uint256 totalBuffered)
        external
        view
        returns (
            ValidatorData[] memory validators,
            uint256 totalActiveNodeOperator,
            uint256[] memory operatorRatios,
            uint256 totalRatio,
            uint256 totalToWithdraw
        );

    /// @notice Calculate the validators to request withdrawal from depending if the system is balalnced or not.
    /// @param _withdrawAmount The amount to withdraw.
    /// @return validators all node operators.
    /// @return totalDelegated total amount delegated.
    /// @return bigNodeOperatorLength number of ids bigNodeOperatorIds.
    /// @return bigNodeOperatorIds stores the ids of node operators that amount delegated to it is greater than the average delegation.
    /// @return smallNodeOperatorLength number of ids smallNodeOperatorIds.
    /// @return smallNodeOperatorIds stores the ids of node operators that amount delegated to it is less than the average delegation.
    /// @return operatorAmountCanBeRequested amount that can be requested from a spécific validator when the system is not balanced.
    /// @return totalValidatorToWithdrawFrom the number of validator to withdraw from when the system is balanced.
    function getValidatorsRequestWithdraw(uint256 _withdrawAmount)
        external
        view
        returns (
            ValidatorData[] memory validators,
            uint256 totalDelegated,
            uint256 bigNodeOperatorLength,
            uint256[] memory bigNodeOperatorIds,
            uint256 smallNodeOperatorLength,
            uint256[] memory smallNodeOperatorIds,
            uint256[] memory operatorAmountCanBeRequested,
            uint256 totalValidatorToWithdrawFrom
        );

    /// @notice Returns a node operator.
    /// @param validatorId the validator id on stakeManager.
    /// @return operatorStatus a node operator.
    function getNodeOperator(uint256 validatorId)
        external
        view
        returns (FullNodeOperatorRegistry memory operatorStatus);

    /// @notice Returns a node operator.
    /// @param rewardAddress the reward address.
    /// @return operatorStatus a node operator.
    function getNodeOperator(address rewardAddress)
        external
        view
        returns (FullNodeOperatorRegistry memory operatorStatus);

    /// @notice Returns a node operator status.
    /// @param  validatorId is the id of the node operator.
    /// @return operatorStatus Returns a node operator status.
    function getNodeOperatorStatus(uint256 validatorId)
        external
        view
        returns (NodeOperatorRegistryStatus operatorStatus);

    /// @notice Return a list of all validator ids in the system.
    function getValidatorIds() external view returns (uint256[] memory);

    /// @notice Explain to an end user what this does
    /// @return isBalanced if the system is balanced or not.
    /// @return distanceThreshold the distance threshold
    /// @return minAmount min amount delegated to a validator.
    /// @return maxAmount max amount delegated to a validator.
    function getProtocolStats()
        external
        view
        returns (
            bool isBalanced,
            uint256 distanceThreshold,
            uint256 minAmount,
            uint256 maxAmount
        );

    /// @notice List all the node operator statuses in the system.
    /// @return inactiveNodeOperator the number of inactive operators.
    /// @return activeNodeOperator the number of active operators.
    /// @return jailedNodeOperator the number of jailed operators.
    /// @return ejectedNodeOperator the number of ejected operators.
    /// @return unstakedNodeOperator the number of unstaked operators.
    function getStats()
        external
        view
        returns (
            uint256 inactiveNodeOperator,
            uint256 activeNodeOperator,
            uint256 jailedNodeOperator,
            uint256 ejectedNodeOperator,
            uint256 unstakedNodeOperator
        );

    ////////////////////////////////////////////////////////////
    /////                                                    ///
    /////                 ***EVENTS***                       ///
    /////                                                    ///
    ////////////////////////////////////////////////////////////

    /// @notice Add Node Operator event
    /// @param validatorId validator id.
    /// @param rewardAddress reward address.
    event AddNodeOperator(uint256 validatorId, address rewardAddress);

    /// @notice Remove Node Operator event.
    /// @param validatorId validator id.
    /// @param rewardAddress reward address.
    event RemoveNodeOperator(uint256 validatorId, address rewardAddress);

    /// @notice Remove Invalid Node Operator event.
    /// @param validatorId validator id.
    /// @param rewardAddress reward address.
    event RemoveInvalidNodeOperator(uint256 validatorId, address rewardAddress);

    /// @notice Set StMatic address event.
    /// @param oldStMatic old stMatic address.
    /// @param newStMatic new stMatic address.
    event SetStMaticAddress(address oldStMatic, address newStMatic);

    /// @notice Set reward address event.
    /// @param validatorId the validator id.
    /// @param oldRewardAddress old reward address.
    /// @param newRewardAddress new reward address.
    event SetRewardAddress(
        uint256 validatorId,
        address oldRewardAddress,
        address newRewardAddress
    );

    /// @notice Emit when the distance threshold is changed.
    /// @param oldDistanceThreshold the old distance threshold.
    /// @param newDistanceThreshold the new distance threshold.
    event SetDistanceThreshold(
        uint256 oldDistanceThreshold,
        uint256 newDistanceThreshold
    );

    /// @notice Emit when the min request withdraw range is changed.
    /// @param oldMinRequestWithdrawRange the old min request withdraw range.
    /// @param newMinRequestWithdrawRange the new min request withdraw range.
    event SetMinRequestWithdrawRange(
        uint8 oldMinRequestWithdrawRange,
        uint8 newMinRequestWithdrawRange
    );

    /// @notice Emit when the max withdraw percentage per rebalance is changed.
    /// @param oldMaxWithdrawPercentagePerRebalance the old max withdraw percentage per rebalance.
    /// @param newMaxWithdrawPercentagePerRebalance the new max withdraw percentage per rebalance.
    event SetMaxWithdrawPercentagePerRebalance(
        uint256 oldMaxWithdrawPercentagePerRebalance,
        uint256 newMaxWithdrawPercentagePerRebalance
    );

    /// @notice Emit when set new version.
    /// @param oldVersion the old version.
    /// @param newVersion the new version.
    event SetVersion(string oldVersion, string newVersion);

    /// @notice Emit when the node operator exits the registry
    /// @param validatorId node operator id
    /// @param rewardAddress node operator reward address
    event ExitNodeOperator(uint256 validatorId, address rewardAddress);
}

File 7 of 19 : IStMATIC.sol
// SPDX-FileCopyrightText: 2021 ShardLabs
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

import "./IValidatorShare.sol";
import "./INodeOperatorRegistry.sol";
import "./IStakeManager.sol";
import "./IPoLidoNFT.sol";
import "./IFxStateRootTunnel.sol";

/// @title StMATIC interface.
/// @author 2021 ShardLabs
interface IStMATIC is IERC20Upgradeable {
    /// @notice The request withdraw struct.
    /// @param amount2WithdrawFromStMATIC amount in Matic.
    /// @param validatorNonce validator nonce.
    /// @param requestTime request epoch.
    /// @param validatorAddress validator share address.
    struct RequestWithdraw {
        uint256 amount2WithdrawFromStMATIC;
        uint256 validatorNonce;
        uint256 requestTime;
        address validatorAddress;
    }

    /// @notice The fee distribution struct.
    /// @param dao dao fee.
    /// @param operators operators fee.
    /// @param insurance insurance fee.
    struct FeeDistribution {
        uint8 dao;
        uint8 operators;
        uint8 insurance;
    }

    /// @notice node operator registry interface.
    function nodeOperator()
        external
        view
        returns (INodeOperatorRegistry);

    /// @notice The fee distribution.
    /// @return dao dao fee.
    /// @return operators operators fee.
    /// @return insurance insurance fee.
    function entityFees()
        external
        view
        returns (
            uint8,
            uint8,
            uint8
        );

    /// @notice StakeManager interface.
    function stakeManager() external view returns (IStakeManager);

    /// @notice LidoNFT interface.
    function poLidoNFT() external view returns (IPoLidoNFT);

    /// @notice fxStateRootTunnel interface.
    function fxStateRootTunnel() external view returns (IFxStateRootTunnel);

    /// @notice contract version.
    function version() external view returns (string memory);

    /// @notice dao address.
    function dao() external view returns (address);

    /// @notice insurance address.
    function insurance() external view returns (address);

    /// @notice Matic ERC20 token.
    function token() external view returns (address);

    /// @notice Matic ERC20 token address NOT USED IN V2.
    function lastWithdrawnValidatorId() external view returns (uint256);

    /// @notice total buffered Matic in the contract.
    function totalBuffered() external view returns (uint256);

    /// @notice delegation lower bound.
    function delegationLowerBound() external view returns (uint256);

    /// @notice reward distribution lower bound.
    function rewardDistributionLowerBound() external view returns (uint256);

    /// @notice reserved funds in Matic.
    function reservedFunds() external view returns (uint256);

    /// @notice submit threshold NOT USED in V2.
    function submitThreshold() external view returns (uint256);

    /// @notice submit handler NOT USED in V2.
    function submitHandler() external view returns (bool);

    /// @notice token to WithdrawRequest mapping.
    function token2WithdrawRequest(uint256 _requestId)
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            address
        );

    /// @notice DAO Role.
    function DAO() external view returns (bytes32);

    /// @notice PAUSE_ROLE Role.
    function PAUSE_ROLE() external view returns (bytes32);

    /// @notice UNPAUSE_ROLE Role.
    function UNPAUSE_ROLE() external view returns (bytes32);

    /// @notice Protocol Fee.
    function protocolFee() external view returns (uint8);

    /// @param _nodeOperatorRegistry - Address of the node operator registry
    /// @param _token - Address of MATIC token on Ethereum Mainnet
    /// @param _dao - Address of the DAO
    /// @param _insurance - Address of the insurance
    /// @param _stakeManager - Address of the stake manager
    /// @param _poLidoNFT - Address of the stMATIC NFT
    /// @param _fxStateRootTunnel - Address of the FxStateRootTunnel
    function initialize(
        address _nodeOperatorRegistry,
        address _token,
        address _dao,
        address _insurance,
        address _stakeManager,
        address _poLidoNFT,
        address _fxStateRootTunnel
    ) external;

    /// @notice Send funds to StMATIC contract and mints StMATIC to msg.sender
    /// @notice Requires that msg.sender has approved _amount of MATIC to this contract
    /// @param _amount - Amount of MATIC sent from msg.sender to this contract
    /// @param _referral - referral address.
    /// @return Amount of StMATIC shares generated
    function submit(uint256 _amount, address _referral) external returns (uint256);

    /// @notice Stores users request to withdraw into a RequestWithdraw struct
    /// @param _amount - Amount of StMATIC that is requested to withdraw
    /// @param _referral - referral address.
    /// @return NFT token id.
    function requestWithdraw(uint256 _amount, address _referral) external returns (uint256);

    /// @notice This will be included in the cron job
    /// @notice Delegates tokens to validator share contract
    function delegate() external;

    /// @notice Claims tokens from validator share and sends them to the
    /// StMATIC contract
    /// @param _tokenId - Id of the token that is supposed to be claimed
    function claimTokens(uint256 _tokenId) external;

    /// @notice Distributes rewards claimed from validator shares based on fees defined
    /// in entityFee.
    function distributeRewards() external;

    /// @notice withdraw total delegated
    /// @param _validatorShare validator share address.
    function withdrawTotalDelegated(address _validatorShare) external;

    /// @notice Claims tokens from validator share and sends them to the
    /// StMATIC contract
    /// @param _tokenId - Id of the token that is supposed to be claimed
    function claimTokensFromValidatorToContract(uint256 _tokenId) external;

    /// @notice Rebalane the system by request withdraw from the validators that contains
    /// more token delegated to them.
    function rebalanceDelegatedTokens() external;

    /// @notice Helper function for that returns total pooled MATIC
    /// @return Total pooled MATIC
    function getTotalStake(IValidatorShare _validatorShare)
        external
        view
        returns (uint256, uint256);

    /// @notice API for liquid rewards of this contract from validatorShare
    /// @param _validatorShare - Address of validatorShare contract
    /// @return Liquid rewards of this contract
    function getLiquidRewards(IValidatorShare _validatorShare)
        external
        view
        returns (uint256);

    /// @notice Helper function for that returns total pooled MATIC
    /// @return Total pooled MATIC
    function getTotalStakeAcrossAllValidators() external view returns (uint256);

    /// @notice Function that calculates total pooled Matic
    /// @return Total pooled Matic
    function getTotalPooledMatic() external view returns (uint256);

    /// @notice get Matic from token id.
    /// @param _tokenId NFT token id.
    /// @return total the amount in Matic.
    function getMaticFromTokenId(uint256 _tokenId)
        external
        view
        returns (uint256);

    /// @notice calculate the total amount stored in all the NFTs owned by
    /// stMatic contract.
    /// @return pendingBufferedTokens the total pending amount for stMatic.
    function calculatePendingBufferedTokens() external view returns(uint256);

    /// @notice Function that converts arbitrary stMATIC to Matic
    /// @param _amountInStMatic - Amount of stMATIC to convert to Matic
    /// @return amountInMatic - Amount of Matic after conversion,
    /// @return totalStMaticAmount - Total StMatic in the contract,
    /// @return totalPooledMatic - Total Matic in the staking pool
    function convertStMaticToMatic(uint256 _amountInStMatic)
        external
        view
        returns (
            uint256 amountInMatic,
            uint256 totalStMaticAmount,
            uint256 totalPooledMatic
        );

    /// @notice Function that converts arbitrary Matic to stMATIC
    /// @param _amountInMatic - Amount of Matic to convert to stMatic
    /// @return amountInStMatic - Amount of Matic to converted to stMatic
    /// @return totalStMaticSupply - Total amount of StMatic in the contract
    /// @return totalPooledMatic - Total amount of Matic in the staking pool
    function convertMaticToStMatic(uint256 _amountInMatic)
        external
        view
        returns (
            uint256 amountInStMatic,
            uint256 totalStMaticSupply,
            uint256 totalPooledMatic
        );

    /// @notice Allows to set fees.
    /// @param _daoFee the new daoFee
    /// @param _operatorsFee the new operatorsFee
    /// @param _insuranceFee the new insuranceFee
    function setFees(
        uint8 _daoFee,
        uint8 _operatorsFee,
        uint8 _insuranceFee
    ) external;

    /// @notice Function that sets protocol fee
    /// @param _newProtocolFee - Insurance fee in %
    function setProtocolFee(uint8 _newProtocolFee) external;

    /// @notice Allows to set DaoAddress.
    /// @param _newDaoAddress new DaoAddress.
    function setDaoAddress(address _newDaoAddress) external;

    /// @notice Allows to set InsuranceAddress.
    /// @param _newInsuranceAddress new InsuranceAddress.
    function setInsuranceAddress(address _newInsuranceAddress) external;

    /// @notice Allows to set NodeOperatorRegistryAddress.
    /// @param _newNodeOperatorRegistry new NodeOperatorRegistryAddress.
    function setNodeOperatorRegistryAddress(address _newNodeOperatorRegistry)
        external;

    /// @notice Allows to set delegationLowerBound.
    /// @param _delegationLowerBound new delegationLowerBound.
    function setDelegationLowerBound(uint256 _delegationLowerBound) external;

    /// @notice Allows to set setRewardDistributionLowerBound.
    /// @param _rewardDistributionLowerBound new setRewardDistributionLowerBound.
    function setRewardDistributionLowerBound(
        uint256 _rewardDistributionLowerBound
    ) external;

    /// @notice Allows to set LidoNFT.
    /// @param _poLidoNFT new LidoNFT.
    function setPoLidoNFT(address _poLidoNFT) external;

    /// @notice Allows to set fxStateRootTunnel.
    /// @param _fxStateRootTunnel new fxStateRootTunnel.
    function setFxStateRootTunnel(address _fxStateRootTunnel) external;

    /// @notice Allows to set new version.
    /// @param _newVersion new contract version.
    function setVersion(string calldata _newVersion) external;

    ////////////////////////////////////////////////////////////
    /////                                                    ///
    /////                 ***EVENTS***                       ///
    /////                                                    ///
    ////////////////////////////////////////////////////////////

    /// @notice Emit when submit.
    /// @param _from msg.sender.
    /// @param _amount amount.
    /// @param _referral - referral address.
    event SubmitEvent(address indexed _from, uint256 _amount, address indexed _referral);

    /// @notice Emit when request withdraw.
    /// @param _from msg.sender.
    /// @param _amount amount.
    /// @param _referral - referral address.
    event RequestWithdrawEvent(address indexed _from, uint256 _amount, address indexed _referral);

    /// @notice Emit when distribute rewards.
    /// @param _amount amount.
    event DistributeRewardsEvent(uint256 indexed _amount);

    /// @notice Emit when withdraw total delegated.
    /// @param _from msg.sender.
    /// @param _amount amount.
    event WithdrawTotalDelegatedEvent(
        address indexed _from,
        uint256 indexed _amount
    );

    /// @notice Emit when delegate.
    /// @param _amountDelegated amount to delegate.
    /// @param _remainder remainder.
    event DelegateEvent(
        uint256 indexed _amountDelegated,
        uint256 indexed _remainder
    );

    /// @notice Emit when ClaimTokens.
    /// @param _from msg.sender.
    /// @param _id token id.
    /// @param _amountClaimed amount Claimed.
    /// @param _amountBurned amount Burned.
    event ClaimTokensEvent(
        address indexed _from,
        uint256 indexed _id,
        uint256 indexed _amountClaimed,
        uint256 _amountBurned
    );

    /// @notice Emit when set new InsuranceAddress.
    /// @param _newInsuranceAddress the new InsuranceAddress.
    event SetInsuranceAddress(address indexed _newInsuranceAddress);

    /// @notice Emit when set new NodeOperatorRegistryAddress.
    /// @param _newNodeOperatorRegistryAddress the new NodeOperatorRegistryAddress.
    event SetNodeOperatorRegistryAddress(
        address indexed _newNodeOperatorRegistryAddress
    );

    /// @notice Emit when set new SetDelegationLowerBound.
    /// @param _delegationLowerBound the old DelegationLowerBound.
    event SetDelegationLowerBound(uint256 indexed _delegationLowerBound);

    /// @notice Emit when set new RewardDistributionLowerBound.
    /// @param oldRewardDistributionLowerBound the old RewardDistributionLowerBound.
    /// @param newRewardDistributionLowerBound the new RewardDistributionLowerBound.
    event SetRewardDistributionLowerBound(
        uint256 oldRewardDistributionLowerBound,
        uint256 newRewardDistributionLowerBound
    );

    /// @notice Emit when set new LidoNFT.
    /// @param oldLidoNFT the old oldLidoNFT.
    /// @param newLidoNFT the new newLidoNFT.
    event SetLidoNFT(address oldLidoNFT, address newLidoNFT);

    /// @notice Emit when set new FxStateRootTunnel.
    /// @param oldFxStateRootTunnel the old FxStateRootTunnel.
    /// @param newFxStateRootTunnel the new FxStateRootTunnel.
    event SetFxStateRootTunnel(
        address oldFxStateRootTunnel,
        address newFxStateRootTunnel
    );

    /// @notice Emit when set new DAO.
    /// @param oldDaoAddress the old DAO.
    /// @param newDaoAddress the new DAO.
    event SetDaoAddress(address oldDaoAddress, address newDaoAddress);

    /// @notice Emit when set fees.
    /// @param daoFee the new daoFee
    /// @param operatorsFee the new operatorsFee
    /// @param insuranceFee the new insuranceFee
    event SetFees(uint256 daoFee, uint256 operatorsFee, uint256 insuranceFee);

    /// @notice Emit when set ProtocolFee.
    /// @param oldProtocolFee the new ProtocolFee
    /// @param newProtocolFee the new ProtocolFee
    event SetProtocolFee(uint8 oldProtocolFee, uint8 newProtocolFee);

    /// @notice Emit when set ProtocolFee.
    /// @param validatorShare vaidatorshare address.
    /// @param amountClaimed amount claimed.
    event ClaimTotalDelegatedEvent(
        address indexed validatorShare,
        uint256 indexed amountClaimed
    );

    /// @notice Emit when set version.
    /// @param oldVersion old.
    /// @param newVersion new.
    event Version(
        string oldVersion,
        string indexed newVersion
    );
}

File 8 of 19 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * 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 initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 9 of 19 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 10 of 19 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 11 of 19 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @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.
     *
     * _Available since v3.1._
     */
    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 `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 12 of 19 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 13 of 19 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../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);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 14 of 19 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @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 IERC165Upgradeable {
    /**
     * @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);
}

File 15 of 19 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @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);
}

File 16 of 19 : IStakeManager.sol
// SPDX-FileCopyrightText: 2021 ShardLabs
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

/// @title polygon stake manager interface.
/// @author 2021 ShardLabs
interface IStakeManager {
    /// @dev Plygon stakeManager status and Validator struct
    /// https://github.com/maticnetwork/contracts/blob/v0.3.0-backport/contracts/staking/stakeManager/StakeManagerStorage.sol
    enum Status {
        Inactive,
        Active,
        Locked,
        Unstaked
    }

    struct Validator {
        uint256 amount;
        uint256 reward;
        uint256 activationEpoch;
        uint256 deactivationEpoch;
        uint256 jailTime;
        address signer;
        address contractAddress;
        Status status;
        uint256 commissionRate;
        uint256 lastCommissionUpdate;
        uint256 delegatorsReward;
        uint256 delegatedAmount;
        uint256 initialRewardPerStake;
    }

    /// @notice get the validator contract used for delegation.
    /// @param validatorId validator id.
    /// @return return the address of the validator contract.
    function getValidatorContract(uint256 validatorId)
        external
        view
        returns (address);

    /// @notice Transfers amount from delegator
    function delegationDeposit(
        uint256 validatorId,
        uint256 amount,
        address delegator
    ) external returns (bool);

    function epoch() external view returns (uint256);

    function validators(uint256 _index)
        external
        view
        returns (Validator memory);

    /// @notice Returns a withdrawal delay.
    function withdrawalDelay() external  view returns (uint256);
}

File 17 of 19 : IPoLidoNFT.sol
// SPDX-FileCopyrightText: 2021 ShardLabs
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";

/// @title PoLidoNFT interface.
/// @author 2021 ShardLabs
interface IPoLidoNFT is IERC721Upgradeable {
    
    /// @notice Mint a new Lido NFT for a _to address.
    /// @param _to owner of the NFT.
    /// @return tokenId returns the token id.
    function mint(address _to) external returns (uint256);

    /// @notice Burn a Lido NFT for a _to address.
    /// @param _tokenId the token id.
    function burn(uint256 _tokenId) external;

    /// @notice Check if the spender is the owner of the NFT or it was approved to it.
    /// @param _spender the spender address.
    /// @param _tokenId the token id.
    /// @return result return if the token is owned or approved to/by the spender.
    function isApprovedOrOwner(address _spender, uint256 _tokenId)
        external
        view
        returns (bool);

    /// @notice Set stMatic address.
    /// @param _stMATIC new stMatic address.
    function setStMATIC(address _stMATIC) external;

    /// @notice List all the tokens owned by an address.
    /// @param _owner the owner address.
    /// @return result return a list of token ids.
    function getOwnedTokens(address _owner) external view returns (uint256[] memory);

    /// @notice toggle pause/unpause the contract
    function togglePause() external;

    /// @notice Allows to set new version.
    /// @param _newVersion new contract version.
    function setVersion(string calldata _newVersion) external;
}

File 18 of 19 : IFxStateRootTunnel.sol
// SPDX-FileCopyrightText: 2021 ShardLabs
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

interface IFxStateRootTunnel {

    /// @notice send message to child
    /// @param _message message
    function sendMessageToChild(bytes memory _message) external;

    /// @notice Set stMatic address.
    /// @param _newStMATIC the new stMatic address.
    function setStMATIC(address _newStMATIC) external;
}

File 19 of 19 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @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 caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @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);

    /**
     * @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;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"validatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"rewardAddress","type":"address"}],"name":"AddNodeOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"validatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"rewardAddress","type":"address"}],"name":"ExitNodeOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"validatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"rewardAddress","type":"address"}],"name":"RemoveInvalidNodeOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"validatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"rewardAddress","type":"address"}],"name":"RemoveNodeOperator","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":false,"internalType":"uint256","name":"oldDistanceThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newDistanceThreshold","type":"uint256"}],"name":"SetDistanceThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxWithdrawPercentagePerRebalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxWithdrawPercentagePerRebalance","type":"uint256"}],"name":"SetMaxWithdrawPercentagePerRebalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"oldMinRequestWithdrawRange","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"newMinRequestWithdrawRange","type":"uint8"}],"name":"SetMinRequestWithdrawRange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"validatorId","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldRewardAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newRewardAddress","type":"address"}],"name":"SetRewardAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldStMatic","type":"address"},{"indexed":false,"internalType":"address","name":"newStMatic","type":"address"}],"name":"SetStMaticAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"oldVersion","type":"string"},{"indexed":false,"internalType":"string","name":"newVersion","type":"string"}],"name":"SetVersion","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ADD_NODE_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DAO_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DISTANCE_THRESHOLD_PERCENTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WITHDRAW_PERCENTAGE_PER_REBALANCE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_REQUEST_WITHDRAW_RANGE_PERCENTS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REMOVE_NODE_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNPAUSE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_validatorId","type":"uint256"},{"internalType":"address","name":"_rewardAddress","type":"address"}],"name":"addNodeOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exitNodeOperatorRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_rewardAddress","type":"address"}],"name":"getNodeOperator","outputs":[{"components":[{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"commissionRate","type":"uint256"},{"internalType":"address","name":"validatorShare","type":"address"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"bool","name":"delegation","type":"bool"},{"internalType":"enum INodeOperatorRegistry.NodeOperatorRegistryStatus","name":"status","type":"uint8"}],"internalType":"struct INodeOperatorRegistry.FullNodeOperatorRegistry","name":"nodeOperator","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_validatorId","type":"uint256"}],"name":"getNodeOperator","outputs":[{"components":[{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"commissionRate","type":"uint256"},{"internalType":"address","name":"validatorShare","type":"address"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"bool","name":"delegation","type":"bool"},{"internalType":"enum INodeOperatorRegistry.NodeOperatorRegistryStatus","name":"status","type":"uint8"}],"internalType":"struct INodeOperatorRegistry.FullNodeOperatorRegistry","name":"nodeOperator","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_validatorId","type":"uint256"}],"name":"getNodeOperatorStatus","outputs":[{"internalType":"enum INodeOperatorRegistry.NodeOperatorRegistryStatus","name":"operatorStatus","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProtocolStats","outputs":[{"internalType":"bool","name":"isBalanced","type":"bool"},{"internalType":"uint256","name":"distanceThreshold","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","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":[],"name":"getStats","outputs":[{"internalType":"uint256","name":"inactiveNodeOperator","type":"uint256"},{"internalType":"uint256","name":"activeNodeOperator","type":"uint256"},{"internalType":"uint256","name":"jailedNodeOperator","type":"uint256"},{"internalType":"uint256","name":"ejectedNodeOperator","type":"uint256"},{"internalType":"uint256","name":"unstakedNodeOperator","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getValidatorIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToDelegate","type":"uint256"}],"name":"getValidatorsDelegationAmount","outputs":[{"components":[{"internalType":"address","name":"validatorShare","type":"address"},{"internalType":"address","name":"rewardAddress","type":"address"}],"internalType":"struct INodeOperatorRegistry.ValidatorData[]","name":"validators","type":"tuple[]"},{"internalType":"uint256","name":"totalActiveNodeOperator","type":"uint256"},{"internalType":"uint256[]","name":"operatorRatios","type":"uint256[]"},{"internalType":"uint256","name":"totalRatio","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToReDelegate","type":"uint256"}],"name":"getValidatorsRebalanceAmount","outputs":[{"components":[{"internalType":"address","name":"validatorShare","type":"address"},{"internalType":"address","name":"rewardAddress","type":"address"}],"internalType":"struct INodeOperatorRegistry.ValidatorData[]","name":"validators","type":"tuple[]"},{"internalType":"uint256","name":"totalActiveNodeOperator","type":"uint256"},{"internalType":"uint256[]","name":"operatorRatios","type":"uint256[]"},{"internalType":"uint256","name":"totalRatio","type":"uint256"},{"internalType":"uint256","name":"totalToWithdraw","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawAmount","type":"uint256"}],"name":"getValidatorsRequestWithdraw","outputs":[{"components":[{"internalType":"address","name":"validatorShare","type":"address"},{"internalType":"address","name":"rewardAddress","type":"address"}],"internalType":"struct INodeOperatorRegistry.ValidatorData[]","name":"validators","type":"tuple[]"},{"internalType":"uint256","name":"totalDelegated","type":"uint256"},{"internalType":"uint256","name":"bigNodeOperatorLength","type":"uint256"},{"internalType":"uint256[]","name":"bigNodeOperatorIds","type":"uint256[]"},{"internalType":"uint256","name":"smallNodeOperatorLength","type":"uint256"},{"internalType":"uint256[]","name":"smallNodeOperatorIds","type":"uint256[]"},{"internalType":"uint256[]","name":"operatorAmountCanBeRequested","type":"uint256[]"},{"internalType":"uint256","name":"totalValidatorToWithdrawFrom","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":"contract IStakeManager","name":"_stakeManager","type":"address"},{"internalType":"contract IStMATIC","name":"_stMATIC","type":"address"},{"internalType":"address","name":"_dao","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"listDelegatedNodeOperators","outputs":[{"components":[{"internalType":"address","name":"validatorShare","type":"address"},{"internalType":"address","name":"rewardAddress","type":"address"}],"internalType":"struct INodeOperatorRegistry.ValidatorData[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"listWithdrawNodeOperators","outputs":[{"components":[{"internalType":"address","name":"validatorShare","type":"address"},{"internalType":"address","name":"rewardAddress","type":"address"}],"internalType":"struct INodeOperatorRegistry.ValidatorData[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_validatorId","type":"uint256"}],"name":"removeInvalidNodeOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_validatorId","type":"uint256"}],"name":"removeNodeOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newDistanceThreshold","type":"uint256"}],"name":"setDistanceThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMaxWithdrawPercentagePerRebalance","type":"uint256"}],"name":"setMaxWithdrawPercentagePerRebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_newMinRequestWithdrawRangePercents","type":"uint8"}],"name":"setMinRequestWithdrawRange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newRewardAddress","type":"address"}],"name":"setRewardAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newStMatic","type":"address"}],"name":"setStMaticAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newVersion","type":"string"}],"name":"setVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stMATIC","outputs":[{"internalType":"contract IStMATIC","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakeManager","outputs":[{"internalType":"contract IStakeManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"validatorIdToRewardAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"validatorIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"validatorRewardAddressToId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50614204806100206000396000f3fe608060405234801561001057600080fd5b506004361061028a5760003560e01c80636dd8d46d1161015c578063a217fddf116100ce578063c983550011610087578063c98355001461067a578063d547741f14610683578063d789976a14610696578063e405746e146106a9578063e9c26518146106cc578063f52ff13a146106e157600080fd5b8063a217fddf146105ea578063a3353859146105f2578063ad8c3762146105fa578063ae544a591461060d578063c0c53b8b14610637578063c59d48471461064a57600080fd5b8063788bc78c11610120578063788bc78c146105705780638456cb5914610583578063919165aa1461058b57806391d148541461059e5780639552d81d146105b15780639a57bd93146105d557600080fd5b80636dd8d46d146104f05780637294d68514610503578063734083ca1461052a5780637542ff9514610533578063771aceef1461054657600080fd5b806336568abe1161020057806354fd4d50116101b957806354fd4d501461046c57806355954bf9146104815780635c975abb146104945780635cd6ea361461049f5780635e00e679146104ca57806365c14dc7146104dd57600080fd5b806336568abe146103ee578063389ed267146104015780633f4ba83a146104285780634b325f93146104305780634ef4f7b01461043857806352d664b81461045957600080fd5b80630e2c0b10116102525780630e2c0b101461032a5780630f4c758e1461034a57806322c5b7d41461036a578063248a9ca3146103915780632f2ff15d146103b4578063309756fb146103c757600080fd5b806301ffc9a71461028f5780630536bdde146102b757806307187f4c146102cc5780630926efe4146103015780630b8c298a14610317575b600080fd5b6102a261029d366004613a12565b610701565b60405190151581526020015b60405180910390f35b6102ca6102c53660046139c9565b610738565b005b6102f37f82d86c6aefada641b4f7bc3890d09be435efa38474b4088a85ac454bcd0e34e881565b6040519081526020016102ae565b6103096108d6565b6040516102ae929190613d7e565b6102ca6103253660046139e2565b610a9f565b61033d61033836600461398a565b610ee2565b6040516102ae9190613fa3565b610100546103589060ff1681565b60405160ff90911681526020016102ae565b61037d6103783660046139c9565b610f9e565b6040516102ae989796959493929190613e1d565b6102f361039f3660046139c9565b60009081526097602052604090206001015490565b6102ca6103c23660046139e2565b6112f8565b6102f37f393844199e3a43d3188fd97ec9bbfa35b6225814ddc4b40ea4237512887cfc2281565b6102ca6103fc3660046139e2565b611323565b6102f37ff6242721b06fefc650a24712f3590e1f7a66d3e4695d678965bdb1c332b04d1481565b6102ca6113a1565b6102ca6113d7565b6102f361044636600461398a565b6101036020526000908152604090205481565b6102ca6104673660046139c9565b611545565b6104746115f6565b6040516102ae9190613eb6565b6102ca61048f366004613c15565b611684565b60335460ff166102a2565b60fc546104b2906001600160a01b031681565b6040516001600160a01b0390911681526020016102ae565b6102ca6104d836600461398a565b611740565b61033d6104eb3660046139c9565b6118a4565b6102ca6104fe36600461398a565b611956565b6102f37fe9367af2d321a2fc8d9c8f1e67f0fc1e2adf2f9844fb89ffa212619c713685b281565b6102f360fe5481565b60fb546104b2906001600160a01b031681565b61054e611a1f565b60408051941515855260208501939093529183015260608201526080016102ae565b6102ca61057e366004613a87565b611b5f565b6102ca611c4e565b6102f36105993660046139c9565b611c81565b6102a26105ac3660046139e2565b611ca3565b6105c46105bf3660046139c9565b611cce565b6040516102ae959493929190613ddd565b6105dd611fb9565b6040516102ae9190613e95565b6102f3600081565b610309612012565b6102ca6106083660046139c9565b612202565b6104b261061b3660046139c9565b610102602052600090815260409020546001600160a01b031681565b6102ca610645366004613a3c565b612346565b61065261255a565b604080519586526020860194909452928401919091526060830152608082015260a0016102ae565b6102f360ff5481565b6102ca6106913660046139e2565b612669565b6102ca6106a43660046139c9565b61268f565b6106bc6106b73660046139c9565b612749565b6040516102ae9493929190613da0565b6102f36000805160206141af83398151915281565b6106f46106ef3660046139c9565b61294e565b6040516102ae9190613ea8565b60006001600160e01b03198216637965db0b60e01b148061073257506301ffc9a760e01b6001600160e01b03198316145b92915050565b7f82d86c6aefada641b4f7bc3890d09be435efa38474b4088a85ac454bcd0e34e86107638133612960565b600260c954141561078f5760405162461bcd60e51b815260040161078690613f6c565b60405180910390fd5b600260c955600082815261010260205260409020546001600160a01b0316806107fa5760405162461bcd60e51b815260206004820152601760248201527f56616c696461746f7220646f65736e27742065786973740000000000000000006044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018590526000916001600160a01b0316906335aa2e44906024016101a06040518083038186803b15801561084057600080fd5b505afa158015610854573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108789190613b37565b9050610889848260c00151846129c4565b604080518581526001600160a01b03841660208201527fc4f0c2458a6d8b89f193ccfbc04faaf8481460fe27342149e87d8d3be7e5f1ad91015b60405180910390a15050600160c9555050565b606060008060009050600061010180548060200260200160405190810160405280929190818152602001828054801561092e57602002820191906000526020600020905b81548152602001906001019080831161091a575b50505050509050600081519050610943613847565b600080836001600160401b0381111561095e5761095e614183565b6040519080825280602002602001820160405280156109a357816020015b604080518082019091526000808252602082015281526020019060019003908161097c5790505b50905060005b84811015610a91576109d38682815181106109c6576109c661416d565b6020026020010151612b2d565b9450925060008360048111156109eb576109eb614141565b14156109f657610a7f565b60405180604001604052808560c001516001600160a01b031681526020016101026000898581518110610a2b57610a2b61416d565b6020908102919091018101518252810191909152604001600020546001600160a01b031690528251839089908110610a6557610a6561416d565b60200260200101819052508680610a7b90614110565b9750505b80610a8981614110565b9150506109a9565b509794965093945050505050565b7fe9367af2d321a2fc8d9c8f1e67f0fc1e2adf2f9844fb89ffa212619c713685b2610aca8133612960565b600260c9541415610aed5760405162461bcd60e51b815260040161078690613f6c565b600260c95582610b2f5760405162461bcd60e51b815260206004820152600d60248201526c056616c696461746f7249643d3609c1b6044820152606401610786565b600083815261010260205260409020546001600160a01b031615610b885760405162461bcd60e51b815260206004820152601060248201526f56616c696461746f722065786973747360801b6044820152606401610786565b6001600160a01b0382166000908152610103602052604090205415610bef5760405162461bcd60e51b815260206004820152601b60248201527f526577617264204164647265737320616c7265616479207573656400000000006044820152606401610786565b6001600160a01b038216610c3e5760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420726577617264206164647265737360501b6044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018590526000916001600160a01b0316906335aa2e44906024016101a06040518083038186803b158015610c8457600080fd5b505afa158015610c98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbc9190613b37565b905060018160e001516003811115610cd657610cd6614141565b148015610ce557506060810151155b610d2a5760405162461bcd60e51b815260206004820152601660248201527556616c696461746f722069736e27742041435449564560501b6044820152606401610786565b60c08101516001600160a01b0316610d845760405162461bcd60e51b815260206004820152601f60248201527f56616c696461746f7220686173206e6f2056616c696461746f725368617265006044820152606401610786565b8060c001516001600160a01b031663df5cf7236040518163ffffffff1660e01b815260040160206040518083038186803b158015610dc157600080fd5b505afa158015610dd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df991906139a7565b610e3e5760405162461bcd60e51b815260206004820152601660248201527511195b1959d85d1a5bdb881a5cc8191a5cd8589b195960521b6044820152606401610786565b60008481526101026020908152604080832080546001600160a01b0319166001600160a01b0388169081179091558084526101038352818420889055610101805460018101825594527f109ea3cebb188b9c1b9fc5bb3920be60dfdc8699098dff92f3d80daaca7476899093018790558051878152918201929092527fd37fab16e3de663ea8481ee997edf00871079ed2cb2762ae63ed1bdec8ffe69a91016108c3565b610f186040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b6001600160a01b038216600090815261010360205260408120549080610f3d83612b2d565b91509150818460a001906004811115610f5857610f58614141565b90816004811115610f6b57610f6b614141565b9052506001600160a01b0394851660608501529183525060c0810151909216604082015261010090910151602082015290565b60606000806060600060608060006101018054905060001415610fc0576112ed565b6060600080610fcd612d03565b939e50909c509094509250905089610fe7575050506112ed565b8a5160008b610ff78f606461405c565b611001919061403a565b61010054909150606490839061101a9060ff1684614022565b611024919061405c565b61102e919061403a565b611039906001614022565b9550818611611048578561104a565b815b60fe549096508461105c85606461405c565b611066919061403a565b1115801561107d57508d61107a878661405c565b10155b1561108c5750505050506112ed565b60009550816001600160401b038111156110a8576110a8614183565b6040519080825280602002602001820160405280156110d1578160200160208202803683370190505b50965080156110e057806110e3565b60015b905060008e8d116110f557600061110c565b828f8e611102919061407b565b61110c919061403a565b905084811161111b578061111d565b845b9050600061112b848f61403a565b9050836001600160401b0381111561114557611145614183565b60405190808252806020026020018201604052801561116e578160200160208202803683370190505b509b50836001600160401b0381111561118957611189614183565b6040519080825280602002602001820160405280156111b2578160200160208202803683370190505b50995060005b848110156112e457818882815181106111d3576111d361416d565b6020026020010151111561121157808d8f815181106111f4576111f461416d565b60209081029190910101528d61120981614110565b9e505061123d565b808b8d815181106112245761122461416d565b60209081029190910101528b61123981614110565b9c50505b60008882815181106112515761125161416d565b60200260200101516000141580156112815750838983815181106112775761127761416d565b6020026020010151115b61128c5760006112b1565b8389838151811061129f5761129f61416d565b60200260200101516112b1919061407b565b9050808b83815181106112c6576112c661416d565b602090810291909101015250806112dc81614110565b9150506111b8565b50505050505050505b919395975091939597565b6000828152609760205260409020600101546113148133612960565b61131e8383612f82565b505050565b6001600160a01b03811633146113935760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610786565b61139d8282613008565b5050565b7f393844199e3a43d3188fd97ec9bbfa35b6225814ddc4b40ea4237512887cfc226113cc8133612960565b6113d461306f565b50565b600260c95414156113fa5760405162461bcd60e51b815260040161078690613f6c565b600260c95533600081815261010360209081526040808320548084526101029092529091205490916001600160a01b0390911690811461146b5760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018490526000916001600160a01b0316906335aa2e44906024016101a06040518083038186803b1580156114b157600080fd5b505afa1580156114c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e99190613b37565b90506114fa838260c00151846129c4565b604080518481526001600160a01b03841660208201527f527053781427e37eeb44a69b3938ea3f9ed9bc9bed336b2487d014fb1aa7e530910160405180910390a15050600160c95550565b6000805160206141af83398151915261155e8133612960565b60648210156115af5760405162461bcd60e51b815260206004820152601a60248201527f496e76616c69642064697374616e6365207468726573686f6c640000000000006044820152606401610786565b60fe80549083905560408051828152602081018590527fe76888e2fe473bd0ea545fcd55bc7c861cf90200fe97e7893a5f82f5f3d4869791015b60405180910390a1505050565b60fd8054611603906140d5565b80601f016020809104026020016040519081016040528092919081815260200182805461162f906140d5565b801561167c5780601f106116515761010080835404028352916020019161167c565b820191906000526020600020905b81548152906001019060200180831161165f57829003601f168201915b505050505081565b6000805160206141af83398151915261169d8133612960565b60648260ff1611156116f15760405162461bcd60e51b815260206004820152601f60248201527f496e76616c6964206d696e52657175657374576974686472617752616e6765006044820152606401610786565b610100805460ff84811660ff1983168117909355604080519190921680825260208201939093527f8e154623abe8ce57c417452e7f33dcab23da5b57af4a3ccb8440b451549cbdf791016115e9565b60335460ff16156117635760405162461bcd60e51b815260040161078690613ef7565b33600081815261010360209081526040808320548084526101029092529091205490916001600160a01b039091169081146117cf5760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610786565b6001600160a01b03831661181e5760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420726577617264206164647265737360501b6044820152606401610786565b60008281526101026020908152604080832080546001600160a01b0319166001600160a01b038881169182179092558085526101038452828520879055338552828520949094558151868152908516928101929092528101919091527f6f135ea8885bb4007106f50d1491ceebc2e201523b854c8d1b522c3b5f53abaa906060016115e9565b6118da6040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b6000806118e684612b2d565b60c08101516001600160a01b0390811660408088019190915287875260008881526101026020522054166060860152909250905060a0830182600481111561193057611930614141565b9081600481111561194357611943614141565b9052506101000151602083015250919050565b6000805160206141af83398151915261196f8133612960565b6001600160a01b0382166119c55760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642073744d6174696320616464726573730000000000000000006044820152606401610786565b60fc80546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f4e3fd6a41d37a065c658e782115adde3f817fbe8da2e0ebc2e4423b2d45e529291016115e9565b6101015460009081908190819081805b82811015611b22576101018181548110611a4b57611a4b61416d565b906000526020600020015491506000611a6383612b2d565b60c081015160fc54604051630f3ffc7b60e11b81526001600160a01b039182166004820152929450600093501690631e7ff8f690602401604080518083038186803b158015611ab157600080fd5b505afa158015611ac5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae99190613bf1565b50905080861015611af8578095505b80871180611b04575086155b15611b0d578096505b50508080611b1a90614110565b915050611a2f565b5060008415611b315784611b34565b60015b905080611b4285606461405c565b611b4c919061403a565b955060fe54861115965050505090919293565b6000805160206141af833981519152611b788133612960565b600060fd8054611b87906140d5565b80601f0160208091040260200160405190810160405280929190818152602001828054611bb3906140d5565b8015611c005780601f10611bd557610100808354040283529160200191611c00565b820191906000526020600020905b815481529060010190602001808311611be357829003601f168201915b50508651939450611c1c9360fd935060208801925090506138d2565b507f57bf82e6bee2564cd715c672b3eb2dde40acc34f41cc7fbb7af1a4f5359d78b181846040516115e9929190613ec9565b7ff6242721b06fefc650a24712f3590e1f7a66d3e4695d678965bdb1c332b04d14611c798133612960565b6113d4613102565b6101018181548110611c9257600080fd5b600091825260209091200154905081565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606000606060008060016101018054905011611d2d5760405162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f756768206f70657261746f7220746f20726562616c616e63656044820152606401610786565b6060600080611d3a61315a565b939b5091995094509250905060018711611da75760405162461bcd60e51b815260206004820152602860248201527f4e6f7420656e6f75676820616374697665206f70657261746f727320746f20726044820152676562616c616e636560c01b6064820152608401610786565b60fe54808210801590611dba5750600083115b611dff5760405162461bcd60e51b8152602060048201526016602482015275151a19481cde5cdd195b481a5cc818985b185b98d95960521b6044820152606401610786565b876001600160401b03811115611e1757611e17614183565b604051908082528060200260200182016040528015611e40578160200160208202803683370190505b5096506000611e4f898561403a565b90506000805b8a811015611f2a5782878281518110611e7057611e7061416d565b602002602001015111611e84576000611ea9565b82878281518110611e9757611e9761416d565b6020026020010151611ea9919061407b565b91508383888381518110611ebf57611ebf61416d565b60200260200101516064611ed3919061405c565b611edd919061403a565b1015611eea576000611eec565b815b9150818a8281518110611f0157611f0161416d565b6020908102919091010152611f16828a614022565b985080611f2281614110565b915050611e55565b508b8811611f39576000611f43565b611f438c8961407b565b9650606460ff5488611f55919061405c565b611f5f919061403a565b965060008711611faa5760405162461bcd60e51b81526020600482015260166024820152755a65726f20746f74616c20746f20776974686472617760501b6044820152606401610786565b50505050505091939590929450565b606061010180548060200260200160405190810160405280929190818152602001828054801561200857602002820191906000526020600020905b815481526020019060010190808311611ff4575b5050505050905090565b606060008061201f613847565b6101015460009081906001600160401b0381111561203f5761203f614183565b60405190808252806020026020018201604052801561208457816020015b604080518082019091526000808252602082015281526020019060019003908161205d5790505b50905060005b610101548110156121f6576120bc61010182815481106120ac576120ac61416d565b9060005260206000200154612b2d565b9450925060018360048111156120d4576120d4614141565b14156121e4578360c001516001600160a01b031663df5cf7236040518163ffffffff1660e01b815260040160206040518083038186803b15801561211757600080fd5b505afa15801561212b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214f91906139a7565b612158576121e4565b60405180604001604052808560c001516001600160a01b031681526020016101026000610101858154811061218f5761218f61416d565b600091825260208083209091015483528201929092526040019020546001600160a01b0316905282518390879081106121ca576121ca61416d565b602002602001018190525084806121e090614110565b9550505b806121ee81614110565b91505061208a565b50959294509192505050565b60335460ff16156122255760405162461bcd60e51b815260040161078690613ef7565b600260c95414156122485760405162461bcd60e51b815260040161078690613f6c565b600260c95560008061225983612b2d565b9092509050600482600481111561227257612272614141565b148061228f5750600382600481111561228d5761228d614141565b145b6122db5760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742072656d6f76652076616c6964206f70657261746f722e0000006044820152606401610786565b6000838152610102602052604090205460c08201516001600160a01b0390911690612308908590836129c4565b604080518581526001600160a01b03831660208201527f83fe82652ac7e65478c5786c98ac0dcfa7de288d620cb64c83b55cd2f96b1c5191016108c3565b600054610100900460ff166123615760005460ff1615612365565b303b155b6123c85760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610786565b600054610100900460ff161580156123ea576000805461ffff19166101011790555b6123f261361b565b6123fa61364e565b612402613677565b60fb80546001600160a01b038087166001600160a01b03199283161790925560fc805492861692909116919091179055607860fe55601460ff55610100805460ff1916600f179055612455600033612f82565b61247f7ff6242721b06fefc650a24712f3590e1f7a66d3e4695d678965bdb1c332b04d1433612f82565b6124a97f393844199e3a43d3188fd97ec9bbfa35b6225814ddc4b40ea4237512887cfc2283612f82565b6124c16000805160206141af83398151915283612f82565b6124eb7fe9367af2d321a2fc8d9c8f1e67f0fc1e2adf2f9844fb89ffa212619c713685b283612f82565b6125157f82d86c6aefada641b4f7bc3890d09be435efa38474b4088a85ac454bcd0e34e883612f82565b604080518082019091526005808252640322e302e360dc1b60209092019182526125419160fd916138d2565b508015612554576000805461ff00191690555b50505050565b610101546000908190819081908190815b8181101561266057600061258c61010183815481106120ac576120ac61416d565b50905060018160048111156125a3576125a3614141565b14156125bb57866125b381614110565b97505061264d565b60028160048111156125cf576125cf614141565b14156125e757856125df81614110565b96505061264d565b60038160048111156125fb576125fb614141565b1415612613578461260b81614110565b95505061264d565b600481600481111561262757612627614141565b141561263f578361263781614110565b94505061264d565b8761264981614110565b9850505b508061265881614110565b91505061256b565b50509091929394565b6000828152609760205260409020600101546126858133612960565b61131e8383613008565b6000805160206141af8339815191526126a88133612960565b606482111561270b5760405162461bcd60e51b815260206004820152602960248201527f496e76616c6964206d6178576974686472617750657263656e74616765506572604482015268526562616c616e636560b81b6064820152608401610786565b60ff80549083905560408051828152602081018590527ff80b5a55a2072c336bb389e3f61590cc80541f4dfd51ba88b0d07da3f4c1d8fd91016115e9565b60606000606060008061010180549050116127a65760405162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f756768206f70657261746f727320746f2064656c65676174656044820152606401610786565b60606000806127b361315a565b60fe54949b50929950909550935091508082118015906127d7575050505050612947565b876001600160401b038111156127ef576127ef614183565b604051908082528060200260200182016040528015612818578160200160208202803683370190505b5096506000886128288c87614022565b612832919061403a565b90506000805b8a81101561293e57828882815181106128535761285361416d565b6020026020010151101561288b578781815181106128735761287361416d565b602002602001015183612886919061407b565b61288e565b60005b915081158015906128b957508781815181106128ac576128ac61416d565b6020026020010151600014155b1561290257848882815181106128d1576128d161416d565b60200260200101518460646128e6919061405c565b6128f0919061403a565b10156128fd5760006128ff565b815b91505b818a82815181106129155761291561416d565b602090810291909101015261292a828a614022565b98508061293681614110565b915050612838565b50505050505050505b9193509193565b600061295982612b2d565b5092915050565b61296a8282611ca3565b61139d57612982816001600160a01b031660146136a5565b61298d8360206136a5565b60405160200161299e929190613d09565b60408051601f198184030181529082905262461bcd60e51b825261078691600401613eb6565b6101015460005b6129d660018361407b565b811015612a665761010181815481106129f1576129f161416d565b9060005260206000200154851415612a54576101018054612a149060019061407b565b81548110612a2457612a2461416d565b90600052602060002001546101018281548110612a4357612a4361416d565b600091825260209091200155612a66565b80612a5e81614110565b9150506129cb565b50610101805480612a7957612a79614157565b60008281526020812060001990830181019190915501905560fc546040516363af3c1960e11b81526001600160a01b0385811660048301529091169063c75e783290602401600060405180830381600087803b158015612ad857600080fd5b505af1158015612aec573d6000803e3d6000fd5b505050600094855250506101026020908152604080852080546001600160a01b03191690556001600160a01b03929092168452610103905282209190915550565b6000612b37613847565b600083815261010260205260409020546001600160a01b031680612b925760405162461bcd60e51b815260206004820152601260248201527113dc195c985d1bdc881b9bdd08199bdd5b9960721b6044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018690526001600160a01b03909116906335aa2e44906024016101a06040518083038186803b158015612bd757600080fd5b505afa158015612beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c0f9190613b37565b915060018260e001516003811115612c2957612c29614141565b148015612c3857506060820151155b15612c465760019250612cfd565b60028260e001516003811115612c5e57612c5e614141565b148015612c6d57506060820151155b15612c7b5760029250612cfd565b60018260e001516003811115612c9357612c93614141565b1480612cb4575060028260e001516003811115612cb257612cb2614141565b145b8015612cc35750606082015115155b15612cd15760039250612cfd565b60038260e001516003811115612ce957612ce9614141565b1415612cf85760049250612cfd565b600092505b50915091565b61010154606090819060009081908190806001600160401b03811115612d2b57612d2b614183565b604051908082528060200260200182016040528015612d7057816020015b6040805180820190915260008082526020820152815260200190600190039081612d495790505b509550806001600160401b03811115612d8b57612d8b614183565b604051908082528060200260200182016040528015612db4578160200160208202803683370190505b5094506000612dc1613847565b60005b83811015612f66576101018181548110612de057612de061416d565b90600052602060002001549250612df683612b2d565b60c081015160fc54604051630f3ffc7b60e11b81526001600160a01b039182166004820152929550600093501690631e7ff8f690602401604080518083038186803b158015612e4457600080fd5b505afa158015612e58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e7c9190613bf1565b50905080898381518110612e9257612e9261416d565b6020908102919091010152612ea78189614022565b975080861015612eb5578095505b8087118015612ec357508015155b80612ecc575086155b15612ed5578096505b60405180604001604052808460c001516001600160a01b0316815260200161010260006101018681548110612f0c57612f0c61416d565b600091825260208083209091015483528201929092526040019020546001600160a01b031690528a518b9084908110612f4757612f4761416d565b6020026020010181905250508080612f5e90614110565b915050612dc4565b508415612f735784612f76565b60015b94505050509091929394565b612f8c8282611ca3565b61139d5760008281526097602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612fc43390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6130128282611ca3565b1561139d5760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60335460ff166130b85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610786565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60335460ff16156131255760405162461bcd60e51b815260040161078690613ef7565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586130e53390565b61010154606090600090829082908190806001600160401b0381111561318257613182614183565b6040519080825280602002602001820160405280156131c757816020015b60408051808201909152600080825260208201528152602001906001900390816131a05790505b509550806001600160401b038111156131e2576131e2614183565b60405190808252806020026020018201604052801561320b578160200160208202803683370190505b5093506000613218613847565b60008080805b8681101561359457610101818154811061323a5761323a61416d565b9060005260206000200154955061325086612b2d565b95509350600084600481111561326857613268614141565b141561327357613582565b600384600481111561328757613287614141565b14156132fb5760405162461bcd60e51b815260206004820152603b60248201527f436f756c64206e6f742063616c63756c61746520746865207374616b6520646160448201527f74612c20616e206f70657261746f722077617320454a454354454400000000006064820152608401610786565b600484600481111561330f5761330f614141565b14156133835760405162461bcd60e51b815260206004820152603c60248201527f436f756c64206e6f742063616c63756c61746520746865207374616b6520646160448201527f74612c20616e206f70657261746f722077617320554e5354414b4544000000006064820152608401610786565b60c085015160fc54604051630f3ffc7b60e11b81526001600160a01b0391821660048201526000929190911690631e7ff8f690602401604080518083038186803b1580156133d057600080fd5b505afa1580156133e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134089190613bf1565b509050613415818b614022565b995080841015613423578093505b8083118061342f575082155b15613438578092505b60008660c001516001600160a01b031663df5cf7236040518163ffffffff1660e01b815260040160206040518083038186803b15801561347757600080fd5b505afa15801561348b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134af91906139a7565b905060018660048111156134c5576134c5614141565b1480156134cf5750805b1561357f57818c8e815181106134e7576134e761416d565b60200260200101818152505060405180604001604052808860c001516001600160a01b031681526020016101026000610101878154811061352a5761352a61416d565b600091825260208083209091015483528201929092526040019020546001600160a01b031690528e518f908f9081106135655761356561416d565b60200260200101819052508c8061357b90614110565b9d50505b50505b8061358c81614110565b91505061321e565b5060008a116135e55760405162461bcd60e51b815260206004820152601d60248201527f546865726520617265206e6f206163746976652076616c696461746f720000006044820152606401610786565b80156135f157806135f4565b60015b90508061360283606461405c565b61360c919061403a565b96505050505050509091929394565b600054610100900460ff166136425760405162461bcd60e51b815260040161078690613f21565b6033805460ff19169055565b600054610100900460ff166136755760405162461bcd60e51b815260040161078690613f21565b565b600054610100900460ff1661369e5760405162461bcd60e51b815260040161078690613f21565b600160c955565b606060006136b483600261405c565b6136bf906002614022565b6001600160401b038111156136d6576136d6614183565b6040519080825280601f01601f191660200182016040528015613700576020820181803683370190505b509050600360fc1b8160008151811061371b5761371b61416d565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061374a5761374a61416d565b60200101906001600160f81b031916908160001a905350600061376e84600261405c565b613779906001614022565b90505b60018111156137f1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106137ad576137ad61416d565b1a60f81b8282815181106137c3576137c361416d565b60200101906001600160f81b031916908160001a90535060049490941c936137ea816140be565b905061377c565b5083156138405760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610786565b9392505050565b604051806101a00160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600060038111156138a9576138a9614141565b815260200160008152602001600081526020016000815260200160008152602001600081525090565b8280546138de906140d5565b90600052602060002090601f0160209004810192826139005760008555613946565b82601f1061391957805160ff1916838001178555613946565b82800160010185558215613946579182015b8281111561394657825182559160200191906001019061392b565b50613952929150613956565b5090565b5b808211156139525760008155600101613957565b805161397681614199565b919050565b80516004811061397657600080fd5b60006020828403121561399c57600080fd5b813561384081614199565b6000602082840312156139b957600080fd5b8151801515811461384057600080fd5b6000602082840312156139db57600080fd5b5035919050565b600080604083850312156139f557600080fd5b823591506020830135613a0781614199565b809150509250929050565b600060208284031215613a2457600080fd5b81356001600160e01b03198116811461384057600080fd5b600080600060608486031215613a5157600080fd5b8335613a5c81614199565b92506020840135613a6c81614199565b91506040840135613a7c81614199565b809150509250925092565b600060208284031215613a9957600080fd5b81356001600160401b0380821115613ab057600080fd5b818401915084601f830112613ac457600080fd5b813581811115613ad657613ad6614183565b604051601f8201601f19908116603f01168101908382118183101715613afe57613afe614183565b81604052828152876020848701011115613b1757600080fd5b826020860160208301376000928101602001929092525095945050505050565b60006101a08284031215613b4a57600080fd5b613b52613ff9565b8251815260208301516020820152604083015160408201526060830151606082015260808301516080820152613b8a60a0840161396b565b60a0820152613b9b60c0840161396b565b60c0820152613bac60e0840161397b565b60e08201526101008381015190820152610120808401519082015261014080840151908201526101608084015190820152610180928301519281019290925250919050565b60008060408385031215613c0457600080fd5b505080516020909101519092909150565b600060208284031215613c2757600080fd5b813560ff8116811461384057600080fd5b600081518084526020808501945080840160005b83811015613c8057815180516001600160a01b03908116895290840151168388015260409096019590820190600101613c4c565b509495945050505050565b600081518084526020808501945080840160005b83811015613c8057815187529582019590820190600101613c9f565b60058110613cd957634e487b7160e01b600052602160045260246000fd5b9052565b60008151808452613cf5816020860160208601614092565b601f01601f19169290920160200192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613d41816017850160208801614092565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613d72816028840160208801614092565b01602801949350505050565b604081526000613d916040830185613c38565b90508260208301529392505050565b608081526000613db36080830187613c38565b8560208401528281036040840152613dcb8186613c8b565b91505082606083015295945050505050565b60a081526000613df060a0830188613c38565b8660208401528281036040840152613e088187613c8b565b60608401959095525050608001529392505050565b6000610100808352613e318184018c613c38565b90508960208401528860408401528281036060840152613e518189613c8b565b905086608084015282810360a0840152613e6b8187613c8b565b905082810360c0840152613e7f8186613c8b565b9150508260e08301529998505050505050505050565b6020815260006138406020830184613c8b565b602081016107328284613cbb565b6020815260006138406020830184613cdd565b604081526000613edc6040830185613cdd565b8281036020840152613eee8185613cdd565b95945050505050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060c0820190508251825260208301516020830152604083015160018060a01b038082166040850152806060860151166060850152505060808301511515608083015260a083015161295960a0840182613cbb565b6040516101a081016001600160401b038111828210171561401c5761401c614183565b60405290565b600082198211156140355761403561412b565b500190565b60008261405757634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156140765761407661412b565b500290565b60008282101561408d5761408d61412b565b500390565b60005b838110156140ad578181015183820152602001614095565b838111156125545750506000910152565b6000816140cd576140cd61412b565b506000190190565b600181811c908216806140e957607f821691505b6020821081141561410a57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156141245761412461412b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146113d457600080fdfe5dfbc033a771e47196819dc2abbb370160d9edb780ccfa0fc3dff94ae417be9ba264697066735822122043c129ec159bb7043fa97a1bb62c29de1d7782398da17084707774787220f7e664736f6c63430008070033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061028a5760003560e01c80636dd8d46d1161015c578063a217fddf116100ce578063c983550011610087578063c98355001461067a578063d547741f14610683578063d789976a14610696578063e405746e146106a9578063e9c26518146106cc578063f52ff13a146106e157600080fd5b8063a217fddf146105ea578063a3353859146105f2578063ad8c3762146105fa578063ae544a591461060d578063c0c53b8b14610637578063c59d48471461064a57600080fd5b8063788bc78c11610120578063788bc78c146105705780638456cb5914610583578063919165aa1461058b57806391d148541461059e5780639552d81d146105b15780639a57bd93146105d557600080fd5b80636dd8d46d146104f05780637294d68514610503578063734083ca1461052a5780637542ff9514610533578063771aceef1461054657600080fd5b806336568abe1161020057806354fd4d50116101b957806354fd4d501461046c57806355954bf9146104815780635c975abb146104945780635cd6ea361461049f5780635e00e679146104ca57806365c14dc7146104dd57600080fd5b806336568abe146103ee578063389ed267146104015780633f4ba83a146104285780634b325f93146104305780634ef4f7b01461043857806352d664b81461045957600080fd5b80630e2c0b10116102525780630e2c0b101461032a5780630f4c758e1461034a57806322c5b7d41461036a578063248a9ca3146103915780632f2ff15d146103b4578063309756fb146103c757600080fd5b806301ffc9a71461028f5780630536bdde146102b757806307187f4c146102cc5780630926efe4146103015780630b8c298a14610317575b600080fd5b6102a261029d366004613a12565b610701565b60405190151581526020015b60405180910390f35b6102ca6102c53660046139c9565b610738565b005b6102f37f82d86c6aefada641b4f7bc3890d09be435efa38474b4088a85ac454bcd0e34e881565b6040519081526020016102ae565b6103096108d6565b6040516102ae929190613d7e565b6102ca6103253660046139e2565b610a9f565b61033d61033836600461398a565b610ee2565b6040516102ae9190613fa3565b610100546103589060ff1681565b60405160ff90911681526020016102ae565b61037d6103783660046139c9565b610f9e565b6040516102ae989796959493929190613e1d565b6102f361039f3660046139c9565b60009081526097602052604090206001015490565b6102ca6103c23660046139e2565b6112f8565b6102f37f393844199e3a43d3188fd97ec9bbfa35b6225814ddc4b40ea4237512887cfc2281565b6102ca6103fc3660046139e2565b611323565b6102f37ff6242721b06fefc650a24712f3590e1f7a66d3e4695d678965bdb1c332b04d1481565b6102ca6113a1565b6102ca6113d7565b6102f361044636600461398a565b6101036020526000908152604090205481565b6102ca6104673660046139c9565b611545565b6104746115f6565b6040516102ae9190613eb6565b6102ca61048f366004613c15565b611684565b60335460ff166102a2565b60fc546104b2906001600160a01b031681565b6040516001600160a01b0390911681526020016102ae565b6102ca6104d836600461398a565b611740565b61033d6104eb3660046139c9565b6118a4565b6102ca6104fe36600461398a565b611956565b6102f37fe9367af2d321a2fc8d9c8f1e67f0fc1e2adf2f9844fb89ffa212619c713685b281565b6102f360fe5481565b60fb546104b2906001600160a01b031681565b61054e611a1f565b60408051941515855260208501939093529183015260608201526080016102ae565b6102ca61057e366004613a87565b611b5f565b6102ca611c4e565b6102f36105993660046139c9565b611c81565b6102a26105ac3660046139e2565b611ca3565b6105c46105bf3660046139c9565b611cce565b6040516102ae959493929190613ddd565b6105dd611fb9565b6040516102ae9190613e95565b6102f3600081565b610309612012565b6102ca6106083660046139c9565b612202565b6104b261061b3660046139c9565b610102602052600090815260409020546001600160a01b031681565b6102ca610645366004613a3c565b612346565b61065261255a565b604080519586526020860194909452928401919091526060830152608082015260a0016102ae565b6102f360ff5481565b6102ca6106913660046139e2565b612669565b6102ca6106a43660046139c9565b61268f565b6106bc6106b73660046139c9565b612749565b6040516102ae9493929190613da0565b6102f36000805160206141af83398151915281565b6106f46106ef3660046139c9565b61294e565b6040516102ae9190613ea8565b60006001600160e01b03198216637965db0b60e01b148061073257506301ffc9a760e01b6001600160e01b03198316145b92915050565b7f82d86c6aefada641b4f7bc3890d09be435efa38474b4088a85ac454bcd0e34e86107638133612960565b600260c954141561078f5760405162461bcd60e51b815260040161078690613f6c565b60405180910390fd5b600260c955600082815261010260205260409020546001600160a01b0316806107fa5760405162461bcd60e51b815260206004820152601760248201527f56616c696461746f7220646f65736e27742065786973740000000000000000006044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018590526000916001600160a01b0316906335aa2e44906024016101a06040518083038186803b15801561084057600080fd5b505afa158015610854573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108789190613b37565b9050610889848260c00151846129c4565b604080518581526001600160a01b03841660208201527fc4f0c2458a6d8b89f193ccfbc04faaf8481460fe27342149e87d8d3be7e5f1ad91015b60405180910390a15050600160c9555050565b606060008060009050600061010180548060200260200160405190810160405280929190818152602001828054801561092e57602002820191906000526020600020905b81548152602001906001019080831161091a575b50505050509050600081519050610943613847565b600080836001600160401b0381111561095e5761095e614183565b6040519080825280602002602001820160405280156109a357816020015b604080518082019091526000808252602082015281526020019060019003908161097c5790505b50905060005b84811015610a91576109d38682815181106109c6576109c661416d565b6020026020010151612b2d565b9450925060008360048111156109eb576109eb614141565b14156109f657610a7f565b60405180604001604052808560c001516001600160a01b031681526020016101026000898581518110610a2b57610a2b61416d565b6020908102919091018101518252810191909152604001600020546001600160a01b031690528251839089908110610a6557610a6561416d565b60200260200101819052508680610a7b90614110565b9750505b80610a8981614110565b9150506109a9565b509794965093945050505050565b7fe9367af2d321a2fc8d9c8f1e67f0fc1e2adf2f9844fb89ffa212619c713685b2610aca8133612960565b600260c9541415610aed5760405162461bcd60e51b815260040161078690613f6c565b600260c95582610b2f5760405162461bcd60e51b815260206004820152600d60248201526c056616c696461746f7249643d3609c1b6044820152606401610786565b600083815261010260205260409020546001600160a01b031615610b885760405162461bcd60e51b815260206004820152601060248201526f56616c696461746f722065786973747360801b6044820152606401610786565b6001600160a01b0382166000908152610103602052604090205415610bef5760405162461bcd60e51b815260206004820152601b60248201527f526577617264204164647265737320616c7265616479207573656400000000006044820152606401610786565b6001600160a01b038216610c3e5760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420726577617264206164647265737360501b6044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018590526000916001600160a01b0316906335aa2e44906024016101a06040518083038186803b158015610c8457600080fd5b505afa158015610c98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbc9190613b37565b905060018160e001516003811115610cd657610cd6614141565b148015610ce557506060810151155b610d2a5760405162461bcd60e51b815260206004820152601660248201527556616c696461746f722069736e27742041435449564560501b6044820152606401610786565b60c08101516001600160a01b0316610d845760405162461bcd60e51b815260206004820152601f60248201527f56616c696461746f7220686173206e6f2056616c696461746f725368617265006044820152606401610786565b8060c001516001600160a01b031663df5cf7236040518163ffffffff1660e01b815260040160206040518083038186803b158015610dc157600080fd5b505afa158015610dd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df991906139a7565b610e3e5760405162461bcd60e51b815260206004820152601660248201527511195b1959d85d1a5bdb881a5cc8191a5cd8589b195960521b6044820152606401610786565b60008481526101026020908152604080832080546001600160a01b0319166001600160a01b0388169081179091558084526101038352818420889055610101805460018101825594527f109ea3cebb188b9c1b9fc5bb3920be60dfdc8699098dff92f3d80daaca7476899093018790558051878152918201929092527fd37fab16e3de663ea8481ee997edf00871079ed2cb2762ae63ed1bdec8ffe69a91016108c3565b610f186040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b6001600160a01b038216600090815261010360205260408120549080610f3d83612b2d565b91509150818460a001906004811115610f5857610f58614141565b90816004811115610f6b57610f6b614141565b9052506001600160a01b0394851660608501529183525060c0810151909216604082015261010090910151602082015290565b60606000806060600060608060006101018054905060001415610fc0576112ed565b6060600080610fcd612d03565b939e50909c509094509250905089610fe7575050506112ed565b8a5160008b610ff78f606461405c565b611001919061403a565b61010054909150606490839061101a9060ff1684614022565b611024919061405c565b61102e919061403a565b611039906001614022565b9550818611611048578561104a565b815b60fe549096508461105c85606461405c565b611066919061403a565b1115801561107d57508d61107a878661405c565b10155b1561108c5750505050506112ed565b60009550816001600160401b038111156110a8576110a8614183565b6040519080825280602002602001820160405280156110d1578160200160208202803683370190505b50965080156110e057806110e3565b60015b905060008e8d116110f557600061110c565b828f8e611102919061407b565b61110c919061403a565b905084811161111b578061111d565b845b9050600061112b848f61403a565b9050836001600160401b0381111561114557611145614183565b60405190808252806020026020018201604052801561116e578160200160208202803683370190505b509b50836001600160401b0381111561118957611189614183565b6040519080825280602002602001820160405280156111b2578160200160208202803683370190505b50995060005b848110156112e457818882815181106111d3576111d361416d565b6020026020010151111561121157808d8f815181106111f4576111f461416d565b60209081029190910101528d61120981614110565b9e505061123d565b808b8d815181106112245761122461416d565b60209081029190910101528b61123981614110565b9c50505b60008882815181106112515761125161416d565b60200260200101516000141580156112815750838983815181106112775761127761416d565b6020026020010151115b61128c5760006112b1565b8389838151811061129f5761129f61416d565b60200260200101516112b1919061407b565b9050808b83815181106112c6576112c661416d565b602090810291909101015250806112dc81614110565b9150506111b8565b50505050505050505b919395975091939597565b6000828152609760205260409020600101546113148133612960565b61131e8383612f82565b505050565b6001600160a01b03811633146113935760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610786565b61139d8282613008565b5050565b7f393844199e3a43d3188fd97ec9bbfa35b6225814ddc4b40ea4237512887cfc226113cc8133612960565b6113d461306f565b50565b600260c95414156113fa5760405162461bcd60e51b815260040161078690613f6c565b600260c95533600081815261010360209081526040808320548084526101029092529091205490916001600160a01b0390911690811461146b5760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018490526000916001600160a01b0316906335aa2e44906024016101a06040518083038186803b1580156114b157600080fd5b505afa1580156114c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e99190613b37565b90506114fa838260c00151846129c4565b604080518481526001600160a01b03841660208201527f527053781427e37eeb44a69b3938ea3f9ed9bc9bed336b2487d014fb1aa7e530910160405180910390a15050600160c95550565b6000805160206141af83398151915261155e8133612960565b60648210156115af5760405162461bcd60e51b815260206004820152601a60248201527f496e76616c69642064697374616e6365207468726573686f6c640000000000006044820152606401610786565b60fe80549083905560408051828152602081018590527fe76888e2fe473bd0ea545fcd55bc7c861cf90200fe97e7893a5f82f5f3d4869791015b60405180910390a1505050565b60fd8054611603906140d5565b80601f016020809104026020016040519081016040528092919081815260200182805461162f906140d5565b801561167c5780601f106116515761010080835404028352916020019161167c565b820191906000526020600020905b81548152906001019060200180831161165f57829003601f168201915b505050505081565b6000805160206141af83398151915261169d8133612960565b60648260ff1611156116f15760405162461bcd60e51b815260206004820152601f60248201527f496e76616c6964206d696e52657175657374576974686472617752616e6765006044820152606401610786565b610100805460ff84811660ff1983168117909355604080519190921680825260208201939093527f8e154623abe8ce57c417452e7f33dcab23da5b57af4a3ccb8440b451549cbdf791016115e9565b60335460ff16156117635760405162461bcd60e51b815260040161078690613ef7565b33600081815261010360209081526040808320548084526101029092529091205490916001600160a01b039091169081146117cf5760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610786565b6001600160a01b03831661181e5760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420726577617264206164647265737360501b6044820152606401610786565b60008281526101026020908152604080832080546001600160a01b0319166001600160a01b038881169182179092558085526101038452828520879055338552828520949094558151868152908516928101929092528101919091527f6f135ea8885bb4007106f50d1491ceebc2e201523b854c8d1b522c3b5f53abaa906060016115e9565b6118da6040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b6000806118e684612b2d565b60c08101516001600160a01b0390811660408088019190915287875260008881526101026020522054166060860152909250905060a0830182600481111561193057611930614141565b9081600481111561194357611943614141565b9052506101000151602083015250919050565b6000805160206141af83398151915261196f8133612960565b6001600160a01b0382166119c55760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642073744d6174696320616464726573730000000000000000006044820152606401610786565b60fc80546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f4e3fd6a41d37a065c658e782115adde3f817fbe8da2e0ebc2e4423b2d45e529291016115e9565b6101015460009081908190819081805b82811015611b22576101018181548110611a4b57611a4b61416d565b906000526020600020015491506000611a6383612b2d565b60c081015160fc54604051630f3ffc7b60e11b81526001600160a01b039182166004820152929450600093501690631e7ff8f690602401604080518083038186803b158015611ab157600080fd5b505afa158015611ac5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae99190613bf1565b50905080861015611af8578095505b80871180611b04575086155b15611b0d578096505b50508080611b1a90614110565b915050611a2f565b5060008415611b315784611b34565b60015b905080611b4285606461405c565b611b4c919061403a565b955060fe54861115965050505090919293565b6000805160206141af833981519152611b788133612960565b600060fd8054611b87906140d5565b80601f0160208091040260200160405190810160405280929190818152602001828054611bb3906140d5565b8015611c005780601f10611bd557610100808354040283529160200191611c00565b820191906000526020600020905b815481529060010190602001808311611be357829003601f168201915b50508651939450611c1c9360fd935060208801925090506138d2565b507f57bf82e6bee2564cd715c672b3eb2dde40acc34f41cc7fbb7af1a4f5359d78b181846040516115e9929190613ec9565b7ff6242721b06fefc650a24712f3590e1f7a66d3e4695d678965bdb1c332b04d14611c798133612960565b6113d4613102565b6101018181548110611c9257600080fd5b600091825260209091200154905081565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606000606060008060016101018054905011611d2d5760405162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f756768206f70657261746f7220746f20726562616c616e63656044820152606401610786565b6060600080611d3a61315a565b939b5091995094509250905060018711611da75760405162461bcd60e51b815260206004820152602860248201527f4e6f7420656e6f75676820616374697665206f70657261746f727320746f20726044820152676562616c616e636560c01b6064820152608401610786565b60fe54808210801590611dba5750600083115b611dff5760405162461bcd60e51b8152602060048201526016602482015275151a19481cde5cdd195b481a5cc818985b185b98d95960521b6044820152606401610786565b876001600160401b03811115611e1757611e17614183565b604051908082528060200260200182016040528015611e40578160200160208202803683370190505b5096506000611e4f898561403a565b90506000805b8a811015611f2a5782878281518110611e7057611e7061416d565b602002602001015111611e84576000611ea9565b82878281518110611e9757611e9761416d565b6020026020010151611ea9919061407b565b91508383888381518110611ebf57611ebf61416d565b60200260200101516064611ed3919061405c565b611edd919061403a565b1015611eea576000611eec565b815b9150818a8281518110611f0157611f0161416d565b6020908102919091010152611f16828a614022565b985080611f2281614110565b915050611e55565b508b8811611f39576000611f43565b611f438c8961407b565b9650606460ff5488611f55919061405c565b611f5f919061403a565b965060008711611faa5760405162461bcd60e51b81526020600482015260166024820152755a65726f20746f74616c20746f20776974686472617760501b6044820152606401610786565b50505050505091939590929450565b606061010180548060200260200160405190810160405280929190818152602001828054801561200857602002820191906000526020600020905b815481526020019060010190808311611ff4575b5050505050905090565b606060008061201f613847565b6101015460009081906001600160401b0381111561203f5761203f614183565b60405190808252806020026020018201604052801561208457816020015b604080518082019091526000808252602082015281526020019060019003908161205d5790505b50905060005b610101548110156121f6576120bc61010182815481106120ac576120ac61416d565b9060005260206000200154612b2d565b9450925060018360048111156120d4576120d4614141565b14156121e4578360c001516001600160a01b031663df5cf7236040518163ffffffff1660e01b815260040160206040518083038186803b15801561211757600080fd5b505afa15801561212b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214f91906139a7565b612158576121e4565b60405180604001604052808560c001516001600160a01b031681526020016101026000610101858154811061218f5761218f61416d565b600091825260208083209091015483528201929092526040019020546001600160a01b0316905282518390879081106121ca576121ca61416d565b602002602001018190525084806121e090614110565b9550505b806121ee81614110565b91505061208a565b50959294509192505050565b60335460ff16156122255760405162461bcd60e51b815260040161078690613ef7565b600260c95414156122485760405162461bcd60e51b815260040161078690613f6c565b600260c95560008061225983612b2d565b9092509050600482600481111561227257612272614141565b148061228f5750600382600481111561228d5761228d614141565b145b6122db5760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742072656d6f76652076616c6964206f70657261746f722e0000006044820152606401610786565b6000838152610102602052604090205460c08201516001600160a01b0390911690612308908590836129c4565b604080518581526001600160a01b03831660208201527f83fe82652ac7e65478c5786c98ac0dcfa7de288d620cb64c83b55cd2f96b1c5191016108c3565b600054610100900460ff166123615760005460ff1615612365565b303b155b6123c85760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610786565b600054610100900460ff161580156123ea576000805461ffff19166101011790555b6123f261361b565b6123fa61364e565b612402613677565b60fb80546001600160a01b038087166001600160a01b03199283161790925560fc805492861692909116919091179055607860fe55601460ff55610100805460ff1916600f179055612455600033612f82565b61247f7ff6242721b06fefc650a24712f3590e1f7a66d3e4695d678965bdb1c332b04d1433612f82565b6124a97f393844199e3a43d3188fd97ec9bbfa35b6225814ddc4b40ea4237512887cfc2283612f82565b6124c16000805160206141af83398151915283612f82565b6124eb7fe9367af2d321a2fc8d9c8f1e67f0fc1e2adf2f9844fb89ffa212619c713685b283612f82565b6125157f82d86c6aefada641b4f7bc3890d09be435efa38474b4088a85ac454bcd0e34e883612f82565b604080518082019091526005808252640322e302e360dc1b60209092019182526125419160fd916138d2565b508015612554576000805461ff00191690555b50505050565b610101546000908190819081908190815b8181101561266057600061258c61010183815481106120ac576120ac61416d565b50905060018160048111156125a3576125a3614141565b14156125bb57866125b381614110565b97505061264d565b60028160048111156125cf576125cf614141565b14156125e757856125df81614110565b96505061264d565b60038160048111156125fb576125fb614141565b1415612613578461260b81614110565b95505061264d565b600481600481111561262757612627614141565b141561263f578361263781614110565b94505061264d565b8761264981614110565b9850505b508061265881614110565b91505061256b565b50509091929394565b6000828152609760205260409020600101546126858133612960565b61131e8383613008565b6000805160206141af8339815191526126a88133612960565b606482111561270b5760405162461bcd60e51b815260206004820152602960248201527f496e76616c6964206d6178576974686472617750657263656e74616765506572604482015268526562616c616e636560b81b6064820152608401610786565b60ff80549083905560408051828152602081018590527ff80b5a55a2072c336bb389e3f61590cc80541f4dfd51ba88b0d07da3f4c1d8fd91016115e9565b60606000606060008061010180549050116127a65760405162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f756768206f70657261746f727320746f2064656c65676174656044820152606401610786565b60606000806127b361315a565b60fe54949b50929950909550935091508082118015906127d7575050505050612947565b876001600160401b038111156127ef576127ef614183565b604051908082528060200260200182016040528015612818578160200160208202803683370190505b5096506000886128288c87614022565b612832919061403a565b90506000805b8a81101561293e57828882815181106128535761285361416d565b6020026020010151101561288b578781815181106128735761287361416d565b602002602001015183612886919061407b565b61288e565b60005b915081158015906128b957508781815181106128ac576128ac61416d565b6020026020010151600014155b1561290257848882815181106128d1576128d161416d565b60200260200101518460646128e6919061405c565b6128f0919061403a565b10156128fd5760006128ff565b815b91505b818a82815181106129155761291561416d565b602090810291909101015261292a828a614022565b98508061293681614110565b915050612838565b50505050505050505b9193509193565b600061295982612b2d565b5092915050565b61296a8282611ca3565b61139d57612982816001600160a01b031660146136a5565b61298d8360206136a5565b60405160200161299e929190613d09565b60408051601f198184030181529082905262461bcd60e51b825261078691600401613eb6565b6101015460005b6129d660018361407b565b811015612a665761010181815481106129f1576129f161416d565b9060005260206000200154851415612a54576101018054612a149060019061407b565b81548110612a2457612a2461416d565b90600052602060002001546101018281548110612a4357612a4361416d565b600091825260209091200155612a66565b80612a5e81614110565b9150506129cb565b50610101805480612a7957612a79614157565b60008281526020812060001990830181019190915501905560fc546040516363af3c1960e11b81526001600160a01b0385811660048301529091169063c75e783290602401600060405180830381600087803b158015612ad857600080fd5b505af1158015612aec573d6000803e3d6000fd5b505050600094855250506101026020908152604080852080546001600160a01b03191690556001600160a01b03929092168452610103905282209190915550565b6000612b37613847565b600083815261010260205260409020546001600160a01b031680612b925760405162461bcd60e51b815260206004820152601260248201527113dc195c985d1bdc881b9bdd08199bdd5b9960721b6044820152606401610786565b60fb54604051630d6a8b9160e21b8152600481018690526001600160a01b03909116906335aa2e44906024016101a06040518083038186803b158015612bd757600080fd5b505afa158015612beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c0f9190613b37565b915060018260e001516003811115612c2957612c29614141565b148015612c3857506060820151155b15612c465760019250612cfd565b60028260e001516003811115612c5e57612c5e614141565b148015612c6d57506060820151155b15612c7b5760029250612cfd565b60018260e001516003811115612c9357612c93614141565b1480612cb4575060028260e001516003811115612cb257612cb2614141565b145b8015612cc35750606082015115155b15612cd15760039250612cfd565b60038260e001516003811115612ce957612ce9614141565b1415612cf85760049250612cfd565b600092505b50915091565b61010154606090819060009081908190806001600160401b03811115612d2b57612d2b614183565b604051908082528060200260200182016040528015612d7057816020015b6040805180820190915260008082526020820152815260200190600190039081612d495790505b509550806001600160401b03811115612d8b57612d8b614183565b604051908082528060200260200182016040528015612db4578160200160208202803683370190505b5094506000612dc1613847565b60005b83811015612f66576101018181548110612de057612de061416d565b90600052602060002001549250612df683612b2d565b60c081015160fc54604051630f3ffc7b60e11b81526001600160a01b039182166004820152929550600093501690631e7ff8f690602401604080518083038186803b158015612e4457600080fd5b505afa158015612e58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e7c9190613bf1565b50905080898381518110612e9257612e9261416d565b6020908102919091010152612ea78189614022565b975080861015612eb5578095505b8087118015612ec357508015155b80612ecc575086155b15612ed5578096505b60405180604001604052808460c001516001600160a01b0316815260200161010260006101018681548110612f0c57612f0c61416d565b600091825260208083209091015483528201929092526040019020546001600160a01b031690528a518b9084908110612f4757612f4761416d565b6020026020010181905250508080612f5e90614110565b915050612dc4565b508415612f735784612f76565b60015b94505050509091929394565b612f8c8282611ca3565b61139d5760008281526097602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612fc43390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6130128282611ca3565b1561139d5760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60335460ff166130b85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610786565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60335460ff16156131255760405162461bcd60e51b815260040161078690613ef7565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586130e53390565b61010154606090600090829082908190806001600160401b0381111561318257613182614183565b6040519080825280602002602001820160405280156131c757816020015b60408051808201909152600080825260208201528152602001906001900390816131a05790505b509550806001600160401b038111156131e2576131e2614183565b60405190808252806020026020018201604052801561320b578160200160208202803683370190505b5093506000613218613847565b60008080805b8681101561359457610101818154811061323a5761323a61416d565b9060005260206000200154955061325086612b2d565b95509350600084600481111561326857613268614141565b141561327357613582565b600384600481111561328757613287614141565b14156132fb5760405162461bcd60e51b815260206004820152603b60248201527f436f756c64206e6f742063616c63756c61746520746865207374616b6520646160448201527f74612c20616e206f70657261746f722077617320454a454354454400000000006064820152608401610786565b600484600481111561330f5761330f614141565b14156133835760405162461bcd60e51b815260206004820152603c60248201527f436f756c64206e6f742063616c63756c61746520746865207374616b6520646160448201527f74612c20616e206f70657261746f722077617320554e5354414b4544000000006064820152608401610786565b60c085015160fc54604051630f3ffc7b60e11b81526001600160a01b0391821660048201526000929190911690631e7ff8f690602401604080518083038186803b1580156133d057600080fd5b505afa1580156133e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134089190613bf1565b509050613415818b614022565b995080841015613423578093505b8083118061342f575082155b15613438578092505b60008660c001516001600160a01b031663df5cf7236040518163ffffffff1660e01b815260040160206040518083038186803b15801561347757600080fd5b505afa15801561348b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134af91906139a7565b905060018660048111156134c5576134c5614141565b1480156134cf5750805b1561357f57818c8e815181106134e7576134e761416d565b60200260200101818152505060405180604001604052808860c001516001600160a01b031681526020016101026000610101878154811061352a5761352a61416d565b600091825260208083209091015483528201929092526040019020546001600160a01b031690528e518f908f9081106135655761356561416d565b60200260200101819052508c8061357b90614110565b9d50505b50505b8061358c81614110565b91505061321e565b5060008a116135e55760405162461bcd60e51b815260206004820152601d60248201527f546865726520617265206e6f206163746976652076616c696461746f720000006044820152606401610786565b80156135f157806135f4565b60015b90508061360283606461405c565b61360c919061403a565b96505050505050509091929394565b600054610100900460ff166136425760405162461bcd60e51b815260040161078690613f21565b6033805460ff19169055565b600054610100900460ff166136755760405162461bcd60e51b815260040161078690613f21565b565b600054610100900460ff1661369e5760405162461bcd60e51b815260040161078690613f21565b600160c955565b606060006136b483600261405c565b6136bf906002614022565b6001600160401b038111156136d6576136d6614183565b6040519080825280601f01601f191660200182016040528015613700576020820181803683370190505b509050600360fc1b8160008151811061371b5761371b61416d565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061374a5761374a61416d565b60200101906001600160f81b031916908160001a905350600061376e84600261405c565b613779906001614022565b90505b60018111156137f1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106137ad576137ad61416d565b1a60f81b8282815181106137c3576137c361416d565b60200101906001600160f81b031916908160001a90535060049490941c936137ea816140be565b905061377c565b5083156138405760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610786565b9392505050565b604051806101a00160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600060038111156138a9576138a9614141565b815260200160008152602001600081526020016000815260200160008152602001600081525090565b8280546138de906140d5565b90600052602060002090601f0160209004810192826139005760008555613946565b82601f1061391957805160ff1916838001178555613946565b82800160010185558215613946579182015b8281111561394657825182559160200191906001019061392b565b50613952929150613956565b5090565b5b808211156139525760008155600101613957565b805161397681614199565b919050565b80516004811061397657600080fd5b60006020828403121561399c57600080fd5b813561384081614199565b6000602082840312156139b957600080fd5b8151801515811461384057600080fd5b6000602082840312156139db57600080fd5b5035919050565b600080604083850312156139f557600080fd5b823591506020830135613a0781614199565b809150509250929050565b600060208284031215613a2457600080fd5b81356001600160e01b03198116811461384057600080fd5b600080600060608486031215613a5157600080fd5b8335613a5c81614199565b92506020840135613a6c81614199565b91506040840135613a7c81614199565b809150509250925092565b600060208284031215613a9957600080fd5b81356001600160401b0380821115613ab057600080fd5b818401915084601f830112613ac457600080fd5b813581811115613ad657613ad6614183565b604051601f8201601f19908116603f01168101908382118183101715613afe57613afe614183565b81604052828152876020848701011115613b1757600080fd5b826020860160208301376000928101602001929092525095945050505050565b60006101a08284031215613b4a57600080fd5b613b52613ff9565b8251815260208301516020820152604083015160408201526060830151606082015260808301516080820152613b8a60a0840161396b565b60a0820152613b9b60c0840161396b565b60c0820152613bac60e0840161397b565b60e08201526101008381015190820152610120808401519082015261014080840151908201526101608084015190820152610180928301519281019290925250919050565b60008060408385031215613c0457600080fd5b505080516020909101519092909150565b600060208284031215613c2757600080fd5b813560ff8116811461384057600080fd5b600081518084526020808501945080840160005b83811015613c8057815180516001600160a01b03908116895290840151168388015260409096019590820190600101613c4c565b509495945050505050565b600081518084526020808501945080840160005b83811015613c8057815187529582019590820190600101613c9f565b60058110613cd957634e487b7160e01b600052602160045260246000fd5b9052565b60008151808452613cf5816020860160208601614092565b601f01601f19169290920160200192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613d41816017850160208801614092565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613d72816028840160208801614092565b01602801949350505050565b604081526000613d916040830185613c38565b90508260208301529392505050565b608081526000613db36080830187613c38565b8560208401528281036040840152613dcb8186613c8b565b91505082606083015295945050505050565b60a081526000613df060a0830188613c38565b8660208401528281036040840152613e088187613c8b565b60608401959095525050608001529392505050565b6000610100808352613e318184018c613c38565b90508960208401528860408401528281036060840152613e518189613c8b565b905086608084015282810360a0840152613e6b8187613c8b565b905082810360c0840152613e7f8186613c8b565b9150508260e08301529998505050505050505050565b6020815260006138406020830184613c8b565b602081016107328284613cbb565b6020815260006138406020830184613cdd565b604081526000613edc6040830185613cdd565b8281036020840152613eee8185613cdd565b95945050505050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060c0820190508251825260208301516020830152604083015160018060a01b038082166040850152806060860151166060850152505060808301511515608083015260a083015161295960a0840182613cbb565b6040516101a081016001600160401b038111828210171561401c5761401c614183565b60405290565b600082198211156140355761403561412b565b500190565b60008261405757634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156140765761407661412b565b500290565b60008282101561408d5761408d61412b565b500390565b60005b838110156140ad578181015183820152602001614095565b838111156125545750506000910152565b6000816140cd576140cd61412b565b506000190190565b600181811c908216806140e957607f821691505b6020821081141561410a57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156141245761412461412b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146113d457600080fdfe5dfbc033a771e47196819dc2abbb370160d9edb780ccfa0fc3dff94ae417be9ba264697066735822122043c129ec159bb7043fa97a1bb62c29de1d7782398da17084707774787220f7e664736f6c63430008070033

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

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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.