ETH Price: $2,454.23 (-5.67%)

Contract

0x177EaFe0f1F3359375B1728dae0530a75C83E154
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60a06040188178182023-12-19 5:06:35287 days ago1702962395IN
 Create: RootERC20BridgeFlowRate
0 ETH0.157499341.02356363

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RootERC20BridgeFlowRate

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 28 : RootERC20BridgeFlowRate.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import "./FlowRateDetection.sol";
import "./FlowRateWithdrawalQueue.sol";
import "../RootERC20Bridge.sol";

import {
    IRootERC20BridgeFlowRateEvents,
    IRootERC20BridgeFlowRateErrors
} from "../../interfaces/root/flowrate/IRootERC20BridgeFlowRate.sol";

/**
 * @title  Root ERC 20 Bridge Flow Rate
 * @author Immutable Pty Ltd (Peter Robinson @drinkcoffee, Craig MacGregor @proletesseract)
 * @notice Adds security features to the `RootERC20Bridge` implementation help prevent or reduce the scope of attacks.
 * @dev    Features: In addition the features of the `RootERC20Bridge`, this contract adds the following capabilities:
 *         - A withdrawal queue is defined. In certain situations, a crosschain transfer results
 *           in a withdrawal being put in a "queue". Users can withdraw the amount after a delay.
 *           The default delay is one day. The queue is implemented as an array. Users can choose
 *           which queued withdrawals they want to process.
 *         - An account with `RATE` role can enable or disable the withdrawal queue, and configure
 *           parameters for each token related to the withdrawal queue.
 *         - Withdrawals of tokens whose amount is greater than a token specific threshold are
 *           put into the withdrawal queue. This just affects an individual withdrawal. It does
 *           not affect other withdrawals by that user or by any other user.
 *         - Withdrawals are put into the withdrawal queue when no thresholds have been defined
 *           for the token being withdrawn. This just affects an individual withdrawal. It does
 *           not affect other withdrawals by that user or by any other user.
 *         - If the rate of withdrawal of any token is over a token specific threshold, then all
 *           withdrwals are put into the withdrawal queue.
 *
 *         Almost all users will be unaffected by these changes, and for them the bridge will
 *         appear to operate as if `RootERC20Bridge` contract had been deployed. That is,
 *         almost all withdrawals will not go into a withdrawal queue if the
 *         RootERC20BridgeFlowRate contract has been configured for all tokens
 *         that are likely to be used on the bridge with appropriate thresholds.
 *
 *         Note: This is an upgradeable contract that should be operated behind OpenZeppelin's
 *               TransparentUpgradeableProxy.sol.
 *         Note: The initialize function is susceptible to front running. To prevent this,
 *               call the function when TransparentUpgradeableProxy.sol is deployed by passing
 *               in the function call data in TransparentUpgradeableProxy's constructor.
 *               Alternatively, deploy TransparentUpgradeableProxy, call initialize, and then
 *               check the contract's configuration. If the initialize call has been front run,
 *               deploy a new instance of TransparentUpgradeableProxy and repeat the process.
 *         Note: Administrators should take care when configuring flow rate values for tokens.
 *               The configuration should be reviewed from time to time. For example, an
 *               attacker could cheaply trigger the withdrawal queue if one token has a flow rate
 *               configuration (capacity and refill rate) that has a substantially lower value
 *               than other tokens. The attacker could trigger the withdrawal queue, hope that
 *               administrators will reduce the withdrawal delay, to expedite the clearance of
 *               legitimate transactions in the withdrawal queue, and then execute their main
 *               attack, withdrawing a large sum via some other unrelated bridge attack. The
 *               way to protect against this is to have flow rate configurations for all
 *               configured tokens to be for similar amounts and be wary of reducing the withdrawal
 *               delay.
 *               Another consideration is that an attacker could observe pending withdrawals,
 *               and grief a legitimate user's withdrawal. They could do this by withdrawing a
 *               sum, which when combined with the users, is just about the flow rate that will
 *               trigger the withdrawal queue, immediately before the legitimate user. The
 *               legitimate user's withdrawal would then trigger the withdrawal queue. The
 *               mitigation for this is to make the flow rate configurations such that an
 *               attacker would need to invest substantial amounts to attack the system in
 *               this way. This requires monitoring what typical bridge flows are, and
 *               understanding how they change with time.
 */
contract RootERC20BridgeFlowRate is
    RootERC20Bridge,
    FlowRateDetection,
    FlowRateWithdrawalQueue,
    IRootERC20BridgeFlowRateEvents,
    IRootERC20BridgeFlowRateErrors
{
    // Constants used for access control
    bytes32 private constant RATE_CONTROL_ROLE = keccak256("RATE");

    // Threshold for large transfers
    // Map ERC 20 token address to threshold
    mapping(address => uint256) public largeTransferThresholds;

    constructor(address _initializerAddress) RootERC20Bridge(_initializerAddress) {}

    function initialize(
        InitializationRoles memory newRoles,
        address newRootBridgeAdaptor,
        address newChildERC20Bridge,
        address newChildTokenTemplate,
        address newRootIMXToken,
        address newRootWETHToken,
        uint256 newImxCumulativeDepositLimit,
        address rateAdmin
    ) external initializer {
        if (rateAdmin == address(0)) {
            revert ZeroAddress();
        }

        __RootERC20Bridge_init(
            newRoles,
            newRootBridgeAdaptor,
            newChildERC20Bridge,
            newChildTokenTemplate,
            newRootIMXToken,
            newRootWETHToken,
            newImxCumulativeDepositLimit
        );

        __FlowRateWithdrawalQueue_init();
        _grantRole(RATE_CONTROL_ROLE, rateAdmin);
    }

    // Ensure initialize from RootERC20Bridge can not be called.
    function initialize(InitializationRoles memory, address, address, address, address, address, uint256)
        external
        pure
        override
    {
        revert WrongInitializer();
    }

    /**
     * @notice Activate the withdrawal queue for all tokens.
     * @dev This function manually activates the withdrawal queue. However the
     *      queue is automatically activated when the flow rate detection code
     *      determines that there is a large outflow of any token.
     *      Only RATE role.
     */
    function activateWithdrawalQueue() external onlyRole(RATE_CONTROL_ROLE) {
        _activateWithdrawalQueue();
    }

    /**
     * @notice Deactivate the withdrawal queue for all tokens.
     * @dev This function manually deactivates the withdrawal queue.
     *      Only RATE role.
     */
    function deactivateWithdrawalQueue() external onlyRole(RATE_CONTROL_ROLE) {
        _deactivateWithdrawalQueue();
    }

    /**
     * @notice Set the time in the queue for queued withdrawals.
     * @param delay The number of seconds between when the AxelarAdapter is called to
     *         complete a crosschain transfer.
     * @dev Only RATE role.
     * NOTE: There is no range checking on delay. Delay could be inadvertently be set to
     *       a very large value, representing a large delay. If this is done, the withdrawal
     *       delay should be set again.
     *       Another possible scenario is that the withdrawal queue has been enabled
     *       inadvertently. In this case, the withdrawal queue could be disabled,
     *       and the withdrawal delay could be set to 0, the queued withdrawals could
     *       all be finalised, and then the withdrawal delay could be set to the desired
     *       value.
     */
    function setWithdrawalDelay(uint256 delay) external onlyRole(RATE_CONTROL_ROLE) {
        _setWithdrawalDelay(delay);
    }

    /**
     * @notice Set the thresholds to use for a certain token.
     * @param token The token to apply the thresholds to.
     * @param capacity The size of the bucket in tokens.
     * @param refillRate How quickly the bucket refills in tokens per second.
     * @param largeTransferThreshold Threshold over which a withdrawal is deemed to be large,
     *         and will be put in the withdrawal queue.
     * @dev Only RATE role.
     *
     * Example parameter values:
     *  Assume the desired configuration is:
     *  - large transfer threshold is 100,000 IMX.
     *  - high flow rate threshold is 1,000,000 IMX per hour.
     *  Further assume the ERC 20 contract has been configured with 18 decimals. This is true
     *  for IMX and MATIC.
     *
     *  The capacity should be set to the flow rate number. In this example, 1,000,000 IMX.
     *  The refill rate should be the capacity divided by the flow rate period in seconds.
     *   In this example, 1,000,000 IMX divided by 3600 seconds in an hour.
     *
     *  Hence, the configuration should be set to:
     *  - capacity = 1,000,000,000,000,000,000,000,000
     *  - refillRate =     277,777,777,777,777,777,777
     *  - largeTransferThreshold = 100,000,000,000,000,000,000,000
     *
     * NOTE: Beyond checking that capacity and refillRate are not zero, no range checking is
     *       undertaken on capacity, refillRate, or largeTransferThreshold. Setting
     *       largeTransferThreshold to zero (or a very low value) would cause all (or most)
     *       withdrawals to be put the with withdrawal queue. Having a very large value for
     *       largeTransferThreshold or capacity will either reduce the effectiveness of
     *       the flow rate detection mechanism or prevent it from working altogether. As such,
     *       the values of capacity, refillRate and largeTransferThreshold should be chosen
     *       carefully.
     */
    function setRateControlThreshold(
        address token,
        uint256 capacity,
        uint256 refillRate,
        uint256 largeTransferThreshold
    ) external onlyRole(RATE_CONTROL_ROLE) {
        uint256 previousCapacity = flowRateBuckets[token].capacity;
        uint256 previousRefillRate = flowRateBuckets[token].refillRate;
        uint256 previousLargeTransferThreshold = largeTransferThresholds[token];
        _setFlowRateThreshold(token, capacity, refillRate);
        largeTransferThresholds[token] = largeTransferThreshold;
        emit RateControlThresholdSet(
            token,
            capacity,
            refillRate,
            largeTransferThreshold,
            previousCapacity,
            previousRefillRate,
            previousLargeTransferThreshold
        );
    }

    /**
     * @notice Complete crosschain transfer of funds.
     * @param data Contains the crosschain transfer information:
     *         - token: Token address on the root chain.
     *         - withdrawer: Account that initiated the transfer on the child chain.
     *         - receiver: Account to transfer tokens to.
     *         - amount: The number of tokens to transfer.
     * @dev Called by the AxelarAdapter.
     *      Only when not paused.
     */
    function _withdraw(bytes memory data) internal override {
        (address rootToken, address childToken, address withdrawer, address receiver, uint256 amount) =
            _decodeAndValidateWithdrawal(data);

        // Update the flow rate checking. Delay the withdrawal if the request was
        // for a token that has not been configured.
        bool delayWithdrawalUnknownToken = _updateFlowRateBucket(rootToken, amount);
        bool delayWithdrawalLargeAmount = false;

        // Delay the withdrawal if the amount is greater than the threshold.
        if (!delayWithdrawalUnknownToken) {
            delayWithdrawalLargeAmount = (amount >= largeTransferThresholds[rootToken]);
        }

        // Ensure storage variable is cached on the stack.
        bool queueActivated = withdrawalQueueActivated;

        if (delayWithdrawalLargeAmount || delayWithdrawalUnknownToken || queueActivated) {
            _enqueueWithdrawal(receiver, withdrawer, rootToken, amount);
            emit QueuedWithdrawal(
                rootToken,
                withdrawer,
                receiver,
                amount,
                delayWithdrawalLargeAmount,
                delayWithdrawalUnknownToken,
                queueActivated
            );
        } else {
            _executeTransfer(rootToken, childToken, withdrawer, receiver, amount);
        }
    }

    /**
     * @notice Withdraw a queued withdrawal.
     * @param receiver Address to withdraw value for.
     * @param index Offset into array of queued withdrawals.
     * @dev Only when not paused.
     */
    function finaliseQueuedWithdrawal(address receiver, uint256 index) external nonReentrant {
        (address withdrawer, address token, uint256 amount) = _processWithdrawal(receiver, index);
        address childToken = rootTokenToChildToken[token];
        _executeTransfer(token, childToken, withdrawer, receiver, amount);
    }

    /**
     * @notice Withdraw one or more queued withdrawals for a specific token, aggregating the amounts.
     * @param receiver Address to withdraw value for.
     * @param token Token to do the aggregated withdrawal for.
     * @param indices Offsets into array of queued withdrawals.
     * @dev Only when not paused.
     *   Note that withdrawer in the ERC20Withdraw event emitted in the _executeTransfer function
     *   will represent the withdrawer of the last bridge transfer.
     */
    function finaliseQueuedWithdrawalsAggregated(address receiver, address token, uint256[] calldata indices)
        external
        nonReentrant
    {
        if (indices.length == 0) {
            revert ProvideAtLeastOneIndex();
        }
        uint256 total = 0;
        address withdrawer = address(0);
        for (uint256 i = 0; i < indices.length; i++) {
            address actualToken;
            uint256 amount;
            (withdrawer, actualToken, amount) = _processWithdrawal(receiver, indices[i]);
            if (actualToken != token) {
                revert MixedTokens(token, actualToken);
            }
            total += amount;
        }
        address childToken = rootTokenToChildToken[token];
        _executeTransfer(token, childToken, withdrawer, receiver, total);
    }

    // slither-disable-next-line unused-state,naming-convention
    uint256[50] private __gapRootERC20BridgeFlowRate;
}

File 2 of 28 : FlowRateDetection.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

/**
 * @title  Flow Rate Detection
 * @author Immutable Pty Ltd (Peter Robinson @drinkcoffee and Zhenyang Shi @wcgcyx)
 * @notice Detects large flows of tokens using a bucket system.
 * @dev    Each token has a bucket. The bucket is filled at a constant rate: a number of
 *         tokens per second. The bucket empties each time there is a withdrawal. Withdrawal
 *         requests for tokens that don't have a configured bucket are delayed.
 *         Note: This code is part of RootERC20BridgeFlowRate. It has been separated out
 *         to make it easier to understand and test the functionality.
 *         Note that this contract is upgradeable.
 */
abstract contract FlowRateDetection {
    // Holds flow rate information for a single token.
    struct Bucket {
        // The number of tokens that can fit in the bucket.
        // A capacity of zero indicates that flow rate detection is not configured for the token.
        uint256 capacity;
        // The number of tokens in the bucket.
        uint256 depth;
        // The last time the bucket was updated.
        uint256 refillTime;
        // The number of tokens added per second.
        uint256 refillRate;
    }

    // Map ERC 20 token address to buckets
    mapping(address => Bucket) public flowRateBuckets;

    // True if all tokens should be put in the withdrawal queue.
    bool public withdrawalQueueActivated;

    // Emitted when there is a withdrawal request for a token for which there is no bucket.
    event WithdrawalForNonFlowRatedToken(address indexed token, uint256 amount);
    // Emitted when queue activated or deactivated
    event AutoActivatedWithdrawalQueue();
    event ActivatedWithdrawalQueue(address who);
    event DeactivatedWithdrawalQueue(address who);

    error InvalidToken();
    error InvalidCapacity();
    error InvalidRefillRate();

    /**
     * @notice Activate the withdrawal queue for all tokens.
     */
    function _activateWithdrawalQueue() internal {
        withdrawalQueueActivated = true;
        emit ActivatedWithdrawalQueue(msg.sender);
    }

    /**
     * @notice Deactivate the withdrawal queue for all tokens.
     * @dev This does not affect withdrawals already in the queue.
     */
    function _deactivateWithdrawalQueue() internal {
        withdrawalQueueActivated = false;
        emit DeactivatedWithdrawalQueue(msg.sender);
    }

    /**
     * @notice Initialise or update a bucket for a token.
     * @param token Address of the token to configure the bucket for.
     * @param capacity The number of tokens before the bucket overflows.
     * @param refillRate The number of tokens added to the bucket each second.
     * @dev If this is a new bucket, then the depth is the capacity. If the bucket is existing, then
     *      the depth is not altered.
     */
    function _setFlowRateThreshold(address token, uint256 capacity, uint256 refillRate) internal {
        if (token == address(0)) {
            revert InvalidToken();
        }
        if (capacity == 0) {
            revert InvalidCapacity();
        }
        if (refillRate == 0) {
            revert InvalidRefillRate();
        }
        Bucket storage bucket = flowRateBuckets[token];
        if (bucket.capacity == 0) {
            bucket.depth = capacity;
        }
        bucket.capacity = capacity;
        bucket.refillRate = refillRate;
    }

    /**
     * @notice Update the flow rate measurement for a token.
     * @param token Address of token being withdrawn.
     * @param amount The number of tokens being withdrawn.
     * @return delayWithdrawal Delay this withdrawal because it is for an unconfigured token.
     */
    function _updateFlowRateBucket(address token, uint256 amount) internal returns (bool delayWithdrawal) {
        Bucket storage bucket = flowRateBuckets[token];

        uint256 capacity = bucket.capacity;
        if (capacity == 0) {
            emit WithdrawalForNonFlowRatedToken(token, amount);
            return true;
        }

        // Calculate the depth assuming no withdrawal.
        // slither-disable-next-line timestamp
        uint256 depth = bucket.depth + (block.timestamp - bucket.refillTime) * bucket.refillRate;
        // slither-disable-next-line timestamp
        bucket.refillTime = block.timestamp;
        // slither-disable-next-line timestamp
        if (depth > capacity) {
            depth = capacity;
        }

        // slither-disable-next-line timestamp
        if (amount >= depth) {
            // The bucket is empty indicating the flow rate is high. Automatically
            // enable the withdrawal queue.
            emit AutoActivatedWithdrawalQueue();
            withdrawalQueueActivated = true;
            bucket.depth = 0;
        } else {
            bucket.depth = depth - amount;
        }
        return false;
    }

    // slither-disable-next-line unused-state,naming-convention
    uint256[50] private __gapFlowRateDetection;
}

File 3 of 28 : FlowRateWithdrawalQueue.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import {
    IFlowRateWithdrawalQueueEvents,
    IFlowRateWithdrawalQueueErrors
} from "../../interfaces/root/flowrate/IFlowRateWithdrawalQueue.sol";

/**
 * @title  Flow Rate Withdrawal Queue
 * @author Immutable Pty Ltd (Peter Robinson @drinkcoffee)
 * @notice Queue for withdrawals from the RootERC20BridgeFlowRate.
 * @dev    When withdrawals are delayed, they are put in the queue defined in this contract.
 *         The "queue" is actually a per-user array that gets bigger each time a withdrawal
 *         is added. Users can choose which withdrawals they are interested in and process
 *         just those withdrawals.
 *         Note: This code is part of RootERC20BridgeFlowRate. It has been separated out
 *         to make it easier to understand the functionality.
 *         Note that this contract is upgradeable.
 */
abstract contract FlowRateWithdrawalQueue is IFlowRateWithdrawalQueueEvents, IFlowRateWithdrawalQueueErrors {
    // One day in seconds.
    uint256 private constant DEFAULT_WITHDRAW_DELAY = 1 days;

    // A single token withdrawal for a user.
    struct PendingWithdrawal {
        // The account that initiated the crosschain transfer on the child chain.
        address withdrawer;
        // The token being withdrawn.
        address token;
        // The number of tokens.
        uint256 amount;
        // The time when the withdraw was requested. The pending withdrawal can be
        // withdrawn at time timestamp + withdrawalDelay. Note that it is possible
        // that the withdrawalDelay is updated while the withdrawal is still pending.
        uint256 timestamp;
    }
    // Mapping of user addresses to withdrawal queue.

    mapping(address => PendingWithdrawal[]) private pendingWithdrawals;

    // Information found in a search.
    struct FindPendingWithdrawal {
        // Index into array.
        uint256 index;
        // The number of tokens.
        uint256 amount;
        // The time when the withdraw was requested. The pending withdrawal can be
        // withdrawn at time timestamp + withdrawalDelay. Note that it is possible
        // that the withdrawalDelay is updated while the withdrawal is still pending.
        uint256 timestamp;
    }

    // The amount of time between a withdrawal request and a user being allowed to withdraw.
    uint256 public withdrawalDelay;

    /**
     * @notice Initialization function for FlowRateWithdrawalQueue
     */
    // slither-disable-next-line naming-convention
    function __FlowRateWithdrawalQueue_init() internal {
        _setWithdrawalDelay(DEFAULT_WITHDRAW_DELAY);
    }

    /**
     * @notice Set the delay in seconds between when a withdrawal is requested and
     *         when it can be withdrawn.
     * @param delay Withdrawal delay in seconds.
     */
    function _setWithdrawalDelay(uint256 delay) internal {
        uint256 previousDelay = withdrawalDelay;
        withdrawalDelay = delay;
        emit WithdrawalDelayUpdated(delay, previousDelay);
    }

    /**
     * @notice Add a withdrawal request to the queue.
     * @param receiver The account that the tokens should be transferred to.
     * @param withdrawer The account that initiated the crosschain transfer on the child chain.
     * @param token The token to withdraw.
     * @param amount The amount to withdraw.
     */
    function _enqueueWithdrawal(address receiver, address withdrawer, address token, uint256 amount) internal {
        // @TODO look at using a mapping instead of an array to make the withdraw function simpler
        if (token == address(0)) {
            revert TokenIsZero(receiver);
        }
        // solhint-disable-next-line not-rely-on-time
        PendingWithdrawal memory newPendingWithdrawal = PendingWithdrawal(withdrawer, token, amount, block.timestamp);
        uint256 index = pendingWithdrawals[receiver].length;
        pendingWithdrawals[receiver].push(newPendingWithdrawal);
        // solhint-disable-next-line not-rely-on-time
        emit EnQueuedWithdrawal(token, withdrawer, receiver, amount, block.timestamp, index);
    }

    /**
     * @notice Fetch a withdrawal request from the queue / array.
     * @param receiver The account that the tokens should be transferred to.
     * @return withdrawer The account on the child chain that initiated the crosschain transfer.
     * @return token The token to transfer to the receiver.
     * @return amount The number of tokens to transfer to the receiver.
     */
    function _processWithdrawal(address receiver, uint256 index)
        internal
        returns (address withdrawer, address token, uint256 amount)
    {
        PendingWithdrawal[] storage withdrawals = pendingWithdrawals[receiver];
        // Check if the request is beyond the end of the array.
        uint256 length = pendingWithdrawals[receiver].length;
        if (index >= pendingWithdrawals[receiver].length) {
            revert IndexOutsideWithdrawalQueue(length, index);
        }
        PendingWithdrawal storage withdrawal = withdrawals[index];

        withdrawer = withdrawal.withdrawer;
        token = withdrawal.token;
        amount = withdrawal.amount;

        if (token == address(0)) {
            revert WithdrawalAlreadyProcessed(receiver, index);
        }

        // Note: Add the withdrawal delay here, and not when enqueuing to allow changes
        // to withdrawal delay to have effect on in progress withdrawals.
        uint256 withdrawalTime = withdrawal.timestamp + withdrawalDelay;
        // slither-disable-next-line timestamp
        if (block.timestamp < withdrawalTime) {
            // solhint-disable-next-line not-rely-on-time
            revert WithdrawalRequestTooEarly(block.timestamp, withdrawalTime);
        }

        // Zeroize the old queue item to save some gas.
        delete withdrawals[index];

        emit ProcessedWithdrawal(token, withdrawer, receiver, amount, block.timestamp, index);
    }

    /**
     * @notice Fetch the length of the pending withdrawals array for an address.
     * @param receiver The account to fetch the queue for.
     * @return length Length of array of pending withdrawals array.
     */
    function getPendingWithdrawalsLength(address receiver) external view returns (uint256 length) {
        length = pendingWithdrawals[receiver].length;
    }

    /**
     * @notice Fetch the queue of pending withdrawals for an address.
     * @param receiver The account to fetch the queue for.
     * @param indices Offsets into withdrawal queue to fetch information for.
     * @return pending Array of pending withdrawals. Zero fill are returned if the index is beyond the end of the queue.
     */
    function getPendingWithdrawals(address receiver, uint256[] calldata indices)
        external
        view
        returns (PendingWithdrawal[] memory pending)
    {
        PendingWithdrawal[] storage withdrawals = pendingWithdrawals[receiver];
        uint256 withdrawalsLength = withdrawals.length;
        pending = new PendingWithdrawal[](indices.length);
        for (uint256 i = 0; i < pending.length; i++) {
            if (indices[i] >= withdrawalsLength) {
                pending[i] = PendingWithdrawal(address(0), address(0), 0, 0);
            } else {
                pending[i] = withdrawals[indices[i]];
            }
        }
    }

    /**
     * @notice Fetch the queue of pending withdrawals for an address for a token type.
     * @param receiver The account to fetch the queue for.
     * @param token The token to locate withdrawals for.
     * @param startIndex Offset into withdrawal array to start search.
     * @param stopIndex Offset into withdrawal array to stop search.
     * @param maxFind Maximum number of items to locate.
     * @return found Array of information about pending withdrawals for the token.
     */
    function findPendingWithdrawals(
        address receiver,
        address token,
        uint256 startIndex,
        uint256 stopIndex,
        uint256 maxFind
    ) external view returns (FindPendingWithdrawal[] memory found) {
        PendingWithdrawal[] storage withdrawals = pendingWithdrawals[receiver];
        found = new FindPendingWithdrawal[](maxFind);
        uint256 foundIndex = 0;
        uint256 stop = stopIndex > withdrawals.length ? withdrawals.length : stopIndex;
        for (uint256 i = startIndex; i < stop && foundIndex < maxFind; i++) {
            if (withdrawals[i].token == token) {
                found[foundIndex] = FindPendingWithdrawal(i, withdrawals[i].amount, withdrawals[i].timestamp);
                foundIndex++;
            }
        }

        if (foundIndex != maxFind) {
            FindPendingWithdrawal[] memory temp = new FindPendingWithdrawal[](foundIndex);
            for (uint256 i = 0; i < foundIndex; i++) {
                temp[i] = found[i];
            }
            found = temp;
        }
    }

    // slither-disable-next-line unused-state,naming-convention
    uint256[50] private __gapFlowRateWithdrawalQueue;
}

File 4 of 28 : RootERC20Bridge.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {
    IRootERC20Bridge,
    IERC20Metadata,
    IRootERC20BridgeEvents,
    IRootERC20BridgeErrors
} from "../interfaces/root/IRootERC20Bridge.sol";
import {IRootBridgeAdaptor} from "../interfaces/root/IRootBridgeAdaptor.sol";
import {IWETH} from "../interfaces/root/IWETH.sol";
import {BridgeRoles} from "../common/BridgeRoles.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

/**
 * @title Root ERC20 Bridge
 * @notice An ERC20 bridge contract for the root chain, which enables bridging of standard ERC20 tokens, ETH, wETH, IMX and wIMX from the root chain to the child chain and back.
 * @dev Features:
 *      - Map ERC20 tokens from the root chain to the child chain, so as to enable subsequent bridging of the token.
 *      - Deposit ERC20 tokens, native ETH, wrapped ETH and IMX from the root chain to the child chain.
 *      - Withdraw ERC20 tokens, ETH, and IMX from the child chain to the root chain.
 *      - Set and manage a limit to the amount of IMX that can be deposited into the bridge.
 *      - Manage Role Based Access Control
 *
 * @dev Design:
 *      This contract follows a pattern of using a bridge adaptor to communicate with the child chain. This is because the underlying communication protocol may change,
 *      and also allows us to decouple vendor-specific messaging logic from the bridge logic.
 *      Because of this pattern, any checks or logic that is agnostic to the messaging protocol should be done in this contract.
 *      Any checks or logic that is specific to the underlying messaging protocol should be done in the bridge adaptor.
 *
 * @dev Roles:
 *      - An account with a PAUSER_ROLE can pause the contract.
 *      - An account with an UNPAUSER_ROLE can unpause the contract.
 *      - An account with a VARIABLE_MANAGER_ROLE can update the cumulative IMX deposit limit.
 *      - An account with an ADAPTOR_MANAGER_ROLE can update the root bridge adaptor address.
 *      - An account with a DEFAULT_ADMIN_ROLE can grant and revoke roles.
 *
 * @dev Caution:
 *      - When depositing IMX (L1 -> L2) it's crucial to make sure that the receiving address on the child chain,
 *        if it's a contract, has a receive or fallback function that allows it to accept native IMX on the child chain.
 *        If this isn't the case, the transaction on the child chain could revert, potentially locking the user's funds indefinitely.
 *      - There is undefined behaviour for bridging non-standard ERC20 tokens (e.g. rebasing tokens). Please approach such cases with great care.
 *      - The initialize function is susceptible to front running, so precautions should be taken to account for this scenario.
 *
 * @dev Note:
 *      - This is an upgradeable contract that should be operated behind OpenZeppelin's TransparentUpgradeableProxy.
 */
contract RootERC20Bridge is
    BridgeRoles,
    ReentrancyGuardUpgradeable,
    IRootERC20Bridge,
    IRootERC20BridgeEvents,
    IRootERC20BridgeErrors
{
    using SafeERC20 for IERC20Metadata;

    /// @dev leave this as the first param for the integration tests.
    mapping(address => address) public rootTokenToChildToken;

    /// @notice Role identifier those who can update the cumulative IMX deposit limit.
    bytes32 public constant VARIABLE_MANAGER_ROLE = keccak256("VARIABLE_MANAGER");

    uint256 public constant UNLIMITED_DEPOSIT = 0;
    bytes32 public constant MAP_TOKEN_SIG = keccak256("MAP_TOKEN");
    bytes32 public constant DEPOSIT_SIG = keccak256("DEPOSIT");
    bytes32 public constant WITHDRAW_SIG = keccak256("WITHDRAW");
    address public constant NATIVE_ETH = address(0xeee);
    address public constant NATIVE_IMX = address(0xfff);

    /// @dev The address of the bridge adapter used to send and receive messages to and from the child chain.
    IRootBridgeAdaptor public rootBridgeAdaptor;

    /// @dev The address that will be minting tokens on the child chain.
    address public childERC20Bridge;
    /// @dev The address of the token template that will be cloned to create tokens on the child chain.
    address public childTokenTemplate;
    /// @dev The address of the IMX ERC20 token on L1.
    address public rootIMXToken;
    /// @dev The address of the ETH ERC20 token on L2.
    address public childETHToken;
    /// @dev The address of the wETH ERC20 token on L1.
    address public rootWETHToken;
    /// @dev The maximum cumulative amount of IMX that can be deposited into the bridge.
    /// @dev A limit of zero indicates unlimited.
    uint256 public imxCumulativeDepositLimit;
    /// @dev Address of the authorized initializer.
    address public immutable initializerAddress;

    /**
     * @notice Modifier to ensure that the caller is the registered root bridge adaptor.
     */
    modifier onlyBridgeAdaptor() {
        if (msg.sender != address(rootBridgeAdaptor)) {
            revert NotBridgeAdaptor();
        }
        _;
    }

    /**
     * @notice Constructs the RootERC20Bridge contract.
     * @param _initializerAddress The address of the authorized initializer.
     */
    constructor(address _initializerAddress) {
        if (_initializerAddress == address(0)) {
            revert ZeroAddress();
        }
        initializerAddress = _initializerAddress;
    }

    /**
     * @notice Initialization function for RootERC20Bridge.
     * @param newRoles Struct containing addresses of roles.
     * @param newRootBridgeAdaptor Address of adaptor to send bridge messages to, and receive messages from.
     * @param newChildERC20Bridge Address of child ERC20 bridge to communicate with.
     * @param newChildTokenTemplate Address of child token template to clone.
     * @param newRootIMXToken Address of ERC20 IMX on the root chain.
     * @param newRootWETHToken Address of ERC20 WETH on the root chain.
     * @param newImxCumulativeDepositLimit The cumulative IMX deposit limit.
     * @dev Can only be called once.
     */
    function initialize(
        InitializationRoles memory newRoles,
        address newRootBridgeAdaptor,
        address newChildERC20Bridge,
        address newChildTokenTemplate,
        address newRootIMXToken,
        address newRootWETHToken,
        uint256 newImxCumulativeDepositLimit
    ) external virtual initializer {
        __RootERC20Bridge_init(
            newRoles,
            newRootBridgeAdaptor,
            newChildERC20Bridge,
            newChildTokenTemplate,
            newRootIMXToken,
            newRootWETHToken,
            newImxCumulativeDepositLimit
        );
    }

    /**
     * @notice Initialization function for RootERC20Bridge.
     * @param newRoles Struct containing addresses of roles.
     * @param newRootBridgeAdaptor Address of StateSender to send bridge messages to, and receive messages from.
     * @param newChildERC20Bridge Address of child ERC20 bridge to communicate with.
     * @param newChildTokenTemplate Address of child token template to clone.
     * @param newRootIMXToken Address of ERC20 IMX on the root chain.
     * @param newRootWETHToken Address of ERC20 WETH on the root chain.
     * @param newImxCumulativeDepositLimit The cumulative IMX deposit limit.
     */
    function __RootERC20Bridge_init(
        InitializationRoles memory newRoles,
        address newRootBridgeAdaptor,
        address newChildERC20Bridge,
        address newChildTokenTemplate,
        address newRootIMXToken,
        address newRootWETHToken,
        uint256 newImxCumulativeDepositLimit
    ) internal {
        if (msg.sender != initializerAddress) {
            revert UnauthorizedInitializer();
        }
        if (
            newRootBridgeAdaptor == address(0) || newChildERC20Bridge == address(0)
                || newChildTokenTemplate == address(0) || newRootIMXToken == address(0) || newRootWETHToken == address(0)
                || newRoles.defaultAdmin == address(0) || newRoles.pauser == address(0) || newRoles.unpauser == address(0)
                || newRoles.variableManager == address(0) || newRoles.adaptorManager == address(0)
        ) {
            revert ZeroAddress();
        }

        __AccessControl_init();
        __Pausable_init();
        __ReentrancyGuard_init();

        _grantRole(DEFAULT_ADMIN_ROLE, newRoles.defaultAdmin);
        _grantRole(PAUSER_ROLE, newRoles.pauser);
        _grantRole(UNPAUSER_ROLE, newRoles.unpauser);
        _grantRole(VARIABLE_MANAGER_ROLE, newRoles.variableManager);
        _grantRole(ADAPTOR_MANAGER_ROLE, newRoles.adaptorManager);

        childERC20Bridge = newChildERC20Bridge;
        childTokenTemplate = newChildTokenTemplate;
        rootIMXToken = newRootIMXToken;
        rootWETHToken = newRootWETHToken;
        childETHToken = Clones.predictDeterministicAddress(
            childTokenTemplate, keccak256(abi.encodePacked(NATIVE_ETH)), childERC20Bridge
        );
        rootBridgeAdaptor = IRootBridgeAdaptor(newRootBridgeAdaptor);
        imxCumulativeDepositLimit = newImxCumulativeDepositLimit;

        // Map the supported tokens by default
        rootTokenToChildToken[rootIMXToken] = rootIMXToken;
        rootTokenToChildToken[NATIVE_ETH] = NATIVE_ETH;
        rootTokenToChildToken[rootWETHToken] = NATIVE_ETH;
    }

    /**
     * @inheritdoc IRootERC20Bridge
     */
    function revokeVariableManagerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        revokeRole(VARIABLE_MANAGER_ROLE, account);
    }

    /**
     * @inheritdoc IRootERC20Bridge
     */
    function grantVariableManagerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        grantRole(VARIABLE_MANAGER_ROLE, account);
    }

    /**
     * @inheritdoc IRootERC20Bridge
     */
    function updateRootBridgeAdaptor(address newRootBridgeAdaptor) external onlyRole(ADAPTOR_MANAGER_ROLE) {
        if (newRootBridgeAdaptor == address(0)) {
            revert ZeroAddress();
        }
        emit RootBridgeAdaptorUpdated(address(rootBridgeAdaptor), newRootBridgeAdaptor);
        rootBridgeAdaptor = IRootBridgeAdaptor(newRootBridgeAdaptor);
    }

    /**
     * @notice Updates the IMX deposit limit.
     * @param newImxCumulativeDepositLimit The new cumulative IMX deposit limit.
     * @dev Can only be called by VARIABLE_MANAGER_ROLE.
     * @dev The limit can decrease, but it can never decrease to below the contract's IMX balance.
     */
    function updateImxCumulativeDepositLimit(uint256 newImxCumulativeDepositLimit)
        external
        onlyRole(VARIABLE_MANAGER_ROLE)
    {
        if (
            newImxCumulativeDepositLimit != UNLIMITED_DEPOSIT
                && newImxCumulativeDepositLimit < IERC20Metadata(rootIMXToken).balanceOf(address(this))
        ) {
            revert ImxDepositLimitTooLow();
        }
        emit NewImxDepositLimit(imxCumulativeDepositLimit, newImxCumulativeDepositLimit);
        imxCumulativeDepositLimit = newImxCumulativeDepositLimit;
    }

    /**
     * @notice Method to receive ETH back from the WETH contract when it is unwrapped
     * @dev When a user deposits wETH, it must first be unwrapped.
     *      This allows the bridge to store the underlying native ETH, rather than the wrapped version.
     *      The unwrapping is done through the WETH contract's `withdraw()` function, which sends the native ETH to this bridge contract.
     *      The only reason this `receive()` function is needed is for this process, hence the validation ensures that the sender is the WETH contract.
     */
    receive() external payable {
        // Revert if sender is not the WETH token address
        if (msg.sender != rootWETHToken) {
            revert NonWrappedNativeTransfer();
        }
    }

    /**
     * @inheritdoc IRootERC20Bridge
     * @dev This is only callable by the root chain bridge adaptor.
     *      This method assumes that the adaptor will have performed all
     *     validations relating to the source of the message, prior to calling this method.
     */
    function onMessageReceive(bytes calldata data) external override whenNotPaused onlyBridgeAdaptor {
        if (data.length <= 32) {
            // Data must always be greater than 32.
            // 32 bytes for the signature, and at least some information for the payload
            revert InvalidData("Data too short");
        }

        if (bytes32(data[:32]) == WITHDRAW_SIG) {
            _withdraw(data[32:]);
        } else {
            revert InvalidData("Unsupported action signature");
        }
    }

    /**
     * @inheritdoc IRootERC20Bridge
     * @dev Note that there is undefined behaviour for bridging non-standard ERC20 tokens (e.g. rebasing tokens). Please approach such cases with great care.
     */
    function mapToken(IERC20Metadata rootToken) external payable override whenNotPaused returns (address) {
        return _mapToken(rootToken);
    }

    /**
     * @inheritdoc IRootERC20Bridge
     */
    function depositETH(uint256 amount) external payable {
        _depositETH(msg.sender, amount);
    }

    /**
     * @inheritdoc IRootERC20Bridge
     */
    function depositToETH(address receiver, uint256 amount) external payable {
        _depositETH(receiver, amount);
    }

    /**
     * @inheritdoc IRootERC20Bridge
     * @dev Caution:
     *      - When depositing IMX, it's crucial to make sure that the receiving address (`msg.sender`) on the child chain,
     *        if it's a contract, has a receive or fallback function that allows it to accept native IMX.
     *        If this isn't the case, the transaction on the child chain could revert, potentially locking the user's funds indefinitely.
     *      - Note that there is undefined behaviour for bridging non-standard ERC20 tokens (e.g. rebasing tokens). Please approach such cases with great care.
     */
    function deposit(IERC20Metadata rootToken, uint256 amount) external payable override {
        _depositToken(rootToken, msg.sender, amount);
    }

    /**
     * @inheritdoc IRootERC20Bridge
     * @dev Caution:
     *      - When depositing IMX, it's crucial to make sure that the receiving address (`receiver`) on the child chain,
     *        if it's a contract, has a receive or fallback function that allows it to accept native IMX.
     *        If this isn't the case, the transaction on the child chain could revert, potentially locking the user's funds indefinitely.
     *      - Note that there is undefined behaviour for bridging non-standard ERC20 tokens (e.g. rebasing tokens). Please approach such cases with great care.
     */
    function depositTo(IERC20Metadata rootToken, address receiver, uint256 amount) external payable override {
        _depositToken(rootToken, receiver, amount);
    }

    function _depositETH(address receiver, uint256 amount) private {
        if (msg.value < amount) {
            revert InsufficientValue();
        }

        uint256 expectedBalance = address(this).balance - (msg.value - amount);

        _deposit(IERC20Metadata(NATIVE_ETH), receiver, amount);

        // invariant check to ensure that the root native balance has increased by the amount deposited
        if (address(this).balance != expectedBalance) {
            revert BalanceInvariantCheckFailed(address(this).balance, expectedBalance);
        }
    }

    function _depositToken(IERC20Metadata rootToken, address receiver, uint256 amount) private {
        if (address(rootToken) == rootWETHToken) {
            _depositWrappedETH(receiver, amount);
        } else {
            _depositERC20(rootToken, receiver, amount);
        }
    }

    function _depositWrappedETH(address receiver, uint256 amount) private {
        uint256 expectedBalance = address(this).balance + amount;

        IERC20Metadata erc20WETH = IERC20Metadata(rootWETHToken);

        erc20WETH.safeTransferFrom(msg.sender, address(this), amount);
        IWETH(rootWETHToken).withdraw(amount);

        // invariant check to ensure that the root native balance has increased by the amount deposited
        if (address(this).balance != expectedBalance) {
            revert BalanceInvariantCheckFailed(address(this).balance, expectedBalance);
        }
        _deposit(IERC20Metadata(rootWETHToken), receiver, amount);
    }

    function _depositERC20(IERC20Metadata rootToken, address receiver, uint256 amount) private {
        uint256 expectedBalance = rootToken.balanceOf(address(this)) + amount;
        _deposit(rootToken, receiver, amount);
        // invariant check to ensure that the root token balance has increased by the amount deposited
        // slither-disable-next-line incorrect-equality
        if (rootToken.balanceOf(address(this)) != expectedBalance) {
            revert BalanceInvariantCheckFailed(rootToken.balanceOf(address(this)), expectedBalance);
        }
    }

    function _mapToken(IERC20Metadata rootToken) private returns (address) {
        if (msg.value == 0) {
            revert NoGas();
        }
        if (address(rootToken) == address(0)) {
            revert ZeroAddress();
        }
        if (address(rootToken) == rootIMXToken) {
            revert CantMapIMX();
        }

        if (address(rootToken) == NATIVE_ETH) {
            revert CantMapETH();
        }

        if (address(rootToken) == rootWETHToken) {
            revert CantMapWETH();
        }

        if (rootTokenToChildToken[address(rootToken)] != address(0)) {
            revert AlreadyMapped();
        }

        address childBridge = childERC20Bridge;

        address childToken =
            Clones.predictDeterministicAddress(childTokenTemplate, keccak256(abi.encodePacked(rootToken)), childBridge);

        rootTokenToChildToken[address(rootToken)] = childToken;

        (string memory tokenName, string memory tokenSymbol, uint8 tokenDecimals) = _getTokenDetails(rootToken);

        bytes memory payload = abi.encode(MAP_TOKEN_SIG, rootToken, tokenName, tokenSymbol, tokenDecimals);
        rootBridgeAdaptor.sendMessage{value: msg.value}(payload, msg.sender);

        emit L1TokenMapped(address(rootToken), childToken);
        return childToken;
    }

    function _deposit(IERC20Metadata rootToken, address receiver, uint256 amount)
        private
        nonReentrant
        whenNotPaused
        wontIMXOverflow(address(rootToken), amount)
    {
        if (receiver == address(0) || address(rootToken) == address(0)) {
            revert ZeroAddress();
        }
        if (amount == 0) {
            revert ZeroAmount();
        }
        if (msg.value == 0) {
            revert NoGas();
        }
        // ETH, WETH and IMX do not need to be mapped since it should have been mapped on initialization
        if (rootTokenToChildToken[address(rootToken)] == address(0)) {
            revert NotMapped();
        }

        // We can call _mapToken here, but ordering in the GMP is not guaranteed.
        // Therefore, we need to decide how to handle this and it may be a UI decision to wait until map token message is executed on child chain.
        // Discuss this, and add this decision to the design doc.

        address payloadToken = (address(rootToken) == rootWETHToken) ? NATIVE_ETH : address(rootToken);

        // Deposit sig, root token address, depositor, receiver, amount
        bytes memory payload = abi.encode(DEPOSIT_SIG, payloadToken, msg.sender, receiver, amount);

        // Adjust for fee amount on native transfers
        uint256 feeAmount = (address(rootToken) == NATIVE_ETH) ? msg.value - amount : msg.value;

        // Send message to child chain
        rootBridgeAdaptor.sendMessage{value: feeAmount}(payload, msg.sender);

        // Emit the appropriate deposit event
        _transferTokensAndEmitEvent(address(rootToken), receiver, amount);
    }

    /**
     * @notice Private helper function to emit the appropriate deposit event and execute transfer if rootIMX or rootERC20
     */
    function _transferTokensAndEmitEvent(address rootToken, address receiver, uint256 amount) private {
        // ETH also cannot be transferred since it was received in the payable function call
        if (rootToken == NATIVE_ETH) {
            emit NativeEthDeposit(rootToken, childETHToken, msg.sender, receiver, amount);
            // WETH is also not transferred here since it was earlier unwrapped to ETH
        } else if (rootToken == rootWETHToken) {
            emit WETHDeposit(rootToken, childETHToken, msg.sender, receiver, amount);
        } else if (rootToken == rootIMXToken) {
            emit IMXDeposit(rootToken, msg.sender, receiver, amount);
            IERC20Metadata(rootToken).safeTransferFrom(msg.sender, address(this), amount);
        } else {
            emit ChildChainERC20Deposit(rootToken, rootTokenToChildToken[rootToken], msg.sender, receiver, amount);
            IERC20Metadata(rootToken).safeTransferFrom(msg.sender, address(this), amount);
        }
    }

    function _withdraw(bytes memory data) internal virtual {
        (address rootToken, address childToken, address withdrawer, address receiver, uint256 amount) =
            _decodeAndValidateWithdrawal(data);
        _executeTransfer(rootToken, childToken, withdrawer, receiver, amount);
    }

    function _decodeAndValidateWithdrawal(bytes memory data)
        internal
        view
        returns (address rootToken, address childToken, address withdrawer, address receiver, uint256 amount)
    {
        (rootToken, withdrawer, receiver, amount) = abi.decode(data, (address, address, address, uint256));

        if (address(rootToken) == address(0)) {
            revert ZeroAddress();
        }

        if (rootToken == rootIMXToken) {
            childToken = NATIVE_IMX;
        } else if (rootToken == NATIVE_ETH) {
            childToken = childETHToken;
        } else {
            childToken = rootTokenToChildToken[rootToken];
            if (childToken == address(0)) {
                revert NotMapped();
            }
        }
    }

    function _executeTransfer(
        address rootToken,
        address childToken,
        address withdrawer,
        address receiver,
        uint256 amount
    ) internal whenNotPaused {
        if (rootToken == NATIVE_ETH) {
            Address.sendValue(payable(receiver), amount);
            emit RootChainETHWithdraw(NATIVE_ETH, childToken, withdrawer, receiver, amount);
        } else {
            IERC20Metadata(rootToken).safeTransfer(receiver, amount);
            emit RootChainERC20Withdraw(rootToken, childToken, withdrawer, receiver, amount);
        }
    }

    function _getTokenDetails(IERC20Metadata token) private view returns (string memory, string memory, uint8) {
        string memory tokenName;
        try token.name() returns (string memory name) {
            tokenName = name;
        } catch {
            revert TokenNotSupported();
        }

        string memory tokenSymbol;
        try token.symbol() returns (string memory symbol) {
            tokenSymbol = symbol;
        } catch {
            revert TokenNotSupported();
        }

        uint8 tokenDecimals;
        try token.decimals() returns (uint8 decimals) {
            tokenDecimals = decimals;
        } catch {
            revert TokenNotSupported();
        }

        return (tokenName, tokenSymbol, tokenDecimals);
    }

    modifier wontIMXOverflow(address rootToken, uint256 amount) {
        // Assert whether the deposit is root IMX
        address imxToken = rootIMXToken;
        uint256 depositLimit = imxCumulativeDepositLimit;
        if (rootToken == imxToken && depositLimit != UNLIMITED_DEPOSIT) {
            // Based on the balance of this contract, check if the deposit will exceed the cumulative limit
            if (IERC20Metadata(imxToken).balanceOf(address(this)) + amount > depositLimit) {
                revert ImxDepositLimitExceeded();
            }
        }
        _;
    }

    // slither-disable-next-line unused-state,naming-convention
    uint256[50] private __gapRootERC20Bridge;
}

File 5 of 28 : IRootERC20BridgeFlowRate.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

/**
 * @title Root ERC20 Bridge Flow Rate Events
 * @notice Defines event types emitted by a Root ERC20 Bridge implementation with flow rate control capabilities.
 */
interface IRootERC20BridgeFlowRateEvents {
    /**
     * @notice Indicates rate control thresholds have been set for a certain token.
     * @param token The token thresholds applied to.
     * @param capacity The size of the bucket in tokens.
     * @param refillRate How quickly the bucket refills in tokens per second.
     * @param largeTransferThreshold Threshold over which a withdrawal is deemed to be large,
     *         and will be put in the withdrawal queue.
     */
    event RateControlThresholdSet(
        address indexed token,
        uint256 capacity,
        uint256 refillRate,
        uint256 largeTransferThreshold,
        uint256 previousCapacity,
        uint256 previousRefillRate,
        uint256 previousLargeTransferThreshold
    );

    /**
     * @notice Indicates a withdrawal was queued.
     * @param token Address of token that is being withdrawn.
     * @param withdrawer child chain sender of tokens.
     * @param receiver Recipient of tokens.
     * @param amount The number of tokens.
     * @param delayWithdrawalLargeAmount is true if the reason for queuing was a large transfer.
     * @param delayWithdrawalUnknownToken is true if the reason for queuing was that the
     *         token had not been configured using the setRateControlThreshold function.
     * @param withdrawalQueueActivated is true if the withdrawal queue has been activated.
     */
    event QueuedWithdrawal(
        address indexed token,
        address indexed withdrawer,
        address indexed receiver,
        uint256 amount,
        bool delayWithdrawalLargeAmount,
        bool delayWithdrawalUnknownToken,
        bool withdrawalQueueActivated
    );
}

/**
 * @title Root ERC20 Bridge Flow Rate Errors
 * @notice Defines error types emitted by a Root ERC20 Bridge implementation with flow rate control capabilities.
 */
interface IRootERC20BridgeFlowRateErrors {
    // Error if the RootERC20Bridge initializer is called, and not the one for this contract.
    error WrongInitializer();
    // finaliseQueuedWithdrawalsAggregated was called with a zero length indices array.
    error ProvideAtLeastOneIndex();
    // The expected and actual token did not match for an aggregated withdrawal.
    error MixedTokens(address token, address actualToken);
}

File 6 of 28 : IFlowRateWithdrawalQueue.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

/**
 * @title Withdrawal Queue Events
 * @notice Defines event types emitted by the an implementation of the flow rate withdrawal queue.
 */
interface IFlowRateWithdrawalQueueEvents {
    // Indicates a withdrawal has been queued.
    event EnQueuedWithdrawal(
        address indexed token,
        address indexed withdrawer,
        address indexed receiver,
        uint256 amount,
        uint256 timestamp,
        uint256 index
    );

    // Indicates a withdrawal has been processed.
    event ProcessedWithdrawal(
        address indexed token,
        address indexed withdrawer,
        address indexed receiver,
        uint256 amount,
        uint256 timestamp,
        uint256 index
    );

    // Indicates the new withdrawal delay.
    event WithdrawalDelayUpdated(uint256 delay, uint256 previousDelay);
}
/**
 * @title Withdrawal Queue Errors
 * @notice Defines the error types that can be thrown by an implementation of the flow rate withdrawal queue.
 */

interface IFlowRateWithdrawalQueueErrors {
    // A withdrawal was being processed, but the index is outside of the array.
    error IndexOutsideWithdrawalQueue(uint256 lengthOfQueue, uint256 requestedIndex);

    // A withdrawal was being processed, but the withdrawal is not yet available.
    error WithdrawalRequestTooEarly(uint256 timeNow, uint256 currentWithdrawalTime);

    // A withdrawal was being processed, but the token is zero. This indicates that the
    // withdrawal has already been processed.
    error WithdrawalAlreadyProcessed(address receiver, uint256 index);

    // Attempting to enqueue a token with token address = 0.
    error TokenIsZero(address receiver);
}

File 7 of 28 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

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

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

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

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

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

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

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

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

File 8 of 28 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(0, 0x09, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(0, 0x09, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := keccak256(add(ptr, 0x43), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt
    ) internal view returns (address predicted) {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

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

File 10 of 28 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _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 11 of 28 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, 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);
        _;
    }

    /**
     * @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 `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @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(account),
                        " 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.
     *
     * May emit a {RoleGranted} event.
     */
    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.
     *
     * May emit a {RoleRevoked} event.
     */
    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`.
     *
     * May emit a {RoleRevoked} event.
     */
    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.
     *
     * May emit a {RoleGranted} event.
     *
     * [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.
     *
     * May emit a {RoleGranted} event.
     */
    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.
     *
     * May emit a {RoleRevoked} event.
     */
    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 12 of 28 : IRootERC20Bridge.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

/**
 * @title Root ERC20 Bridge Interface
 * @notice Defines the key functions of an ERC20 bridge on the root chain, which enables bridging of standard ERC20 tokens, ETH, wETH, IMX and wIMX from the root chain to the child chain and back.
 * @dev Features:
 *     - Maps tokens from the root chain to the child chain.
 *     - Deposits tokens from the root chain to the child chain.
 *     - Deposits native ETH from the root chain to the child chain.
 */
interface IRootERC20Bridge {
    /**
     * @notice Holds the addresses of accounts that should be assigned different roles in the bridge, during initialization.
     */
    struct InitializationRoles {
        address defaultAdmin; // The address which will inherit `DEFAULT_ADMIN_ROLE`.
        address pauser; // The address which will inherit `PAUSER_ROLE`.
        address unpauser; // The address which will inherit `UNPAUSER_ROLE`.
        address variableManager; // The address which will inherit `VARIABLE_MANAGER_ROLE`.
        address adaptorManager; // The address which will inherit `ADAPTOR_MANAGER_ROLE`.
    }

    /**
     * @notice Function to revoke `VARIABLE_MANAGER_ROLE` role from an address
     */
    function revokeVariableManagerRole(address account) external;

    /**
     * @notice Function to grant `VARIABLE_MANAGER_ROLE` role to an address
     */
    function grantVariableManagerRole(address account) external;

    /**
     * @notice Updates the root bridge adaptor.
     * @param newRootBridgeAdaptor Address of new root bridge adaptor.
     * @dev Can only be called by ADAPTOR_MANAGER_ROLE.
     */
    function updateRootBridgeAdaptor(address newRootBridgeAdaptor) external;

    /**
     * @notice Receives a bridge message from the child chain.
     * @param data The data payload of the message.
     * @dev This function is called by the underlying bridge adaptor on the root chain, when it receives a validated message from the GMP.
     *         It assumes that the underlying adaptor has already validated the sender chain and sender address.
     */
    function onMessageReceive(bytes calldata data) external;

    /**
     * @notice Initiates sending a mapToken message to the child chain, if the token hasn't been mapped before.
     *         This operation requires the `rootToken` to have the following public getter functions: `name()`, `symbol()`, and `decimals()`.
     *         These functions are optional in the ERC20 standard. If the token does not provide these functions,
     *         the mapping operation will fail and return a `TokenNotSupported` error.
     *
     * @dev The function:
     *      - fails with a `AlreadyMapped` error if the token has already been mapped.
     *      - populates a root token => child token mapping on the root chain before
     *        sending a message telling the child chain to do the same.
     *      - is `payable` because the message passing protocol requires a fee to be paid.
     *
     * @dev The address of the child chain token is deterministic using CREATE2.
     *
     * @param rootToken The address of the token on the root chain.
     * @return childToken The address of the token to be deployed on the child chain.
     */
    function mapToken(IERC20Metadata rootToken) external payable returns (address);

    /**
     * @notice Deposit tokens to the bridge and issue corresponding tokens to `msg.sender` on the child chain.
     * @custom:requires `rootToken` should already have been mapped with `mapToken()`.
     * @param rootToken The address of the token on the root chain.
     * @param amount The amount of tokens to deposit.
     * @dev The function is `payable` because the message passing protocol requires a fee to be paid.
     */
    function deposit(IERC20Metadata rootToken, uint256 amount) external payable;

    /**
     * @notice Deposit tokens to the bridge and issue corresponding tokens to `receiver` address on the child chain.
     * @custom:requires `rootToken` should already have been mapped with `mapToken()`.
     * @param rootToken The address of the token on the root chain.
     * @param receiver The address of the receiver on the child chain, to credit tokens to.
     * @param amount The amount of tokens to deposit.
     * @dev The function is `payable` because the message passing protocol requires a fee to be paid.
     */
    function depositTo(IERC20Metadata rootToken, address receiver, uint256 amount) external payable;

    /**
     * @notice Deposit ETH to the bridge and issue corresponding wrapped ETH to `msg.sender` on the child chain.
     * @param amount The amount of tokens to deposit.
     * @dev The function is `payable` because the message passing protocol requires a fee to be paid.
     * @dev the `msg.value` provided should cover the amount to send as well as the bridge fee.
     */
    function depositETH(uint256 amount) external payable;
    /**
     * @notice Deposit ETH to the bridge and issue corresponding wrapped ETH to `receiver` address on the child chain.
     * @param receiver The address of the receiver on the child chain.
     * @param amount The amount of tokens to deposit.
     * @dev The function is `payable` because the message passing protocol requires a fee to be paid.
     * @dev the `msg.value` provided should cover the amount to send as well as the bridge fee.
     */
    function depositToETH(address receiver, uint256 amount) external payable;
}

/**
 * @title Root ERC20 Bridge Events
 * @notice Defines event types emitted by a Root ERC20 Bridge implementation.
 */
interface IRootERC20BridgeEvents {
    /// @notice Emitted when the root chain bridge adaptor is updated.
    event RootBridgeAdaptorUpdated(address oldRootBridgeAdaptor, address newRootBridgeAdaptor);
    /// @notice Emitted when the IMX deposit limit is updated.
    event NewImxDepositLimit(uint256 oldImxDepositLimit, uint256 newImxDepositLimit);
    /// @notice Emitted when a map token message is sent to the child chain.
    event L1TokenMapped(address indexed rootToken, address indexed childToken);
    /// @notice Emitted when an ERC20 deposit message is sent to the child chain.
    event ChildChainERC20Deposit(
        address indexed rootToken,
        address indexed childToken,
        address depositor,
        address indexed receiver,
        uint256 amount
    );
    /// @notice Emitted when an IMX deposit is initated on the root chain.
    event IMXDeposit(address indexed rootToken, address depositor, address indexed receiver, uint256 amount);
    /// @notice Emitted when a WETH deposit is initiated on the root chain.
    event WETHDeposit(
        address indexed rootToken,
        address indexed childToken,
        address depositor,
        address indexed receiver,
        uint256 amount
    );
    /// @notice Emitted when an ETH deposit initiated on the root chain.
    event NativeEthDeposit(
        address indexed rootToken,
        address indexed childToken,
        address depositor,
        address indexed receiver,
        uint256 amount
    );
    /// @notice Emitted when an ERC20 withdrawal is executed on the root chain.
    event RootChainERC20Withdraw(
        address indexed rootToken,
        address indexed childToken,
        address withdrawer,
        address indexed receiver,
        uint256 amount
    );
    /// @notice Emitted when an ETH withdrawal is executed on the root chain.
    event RootChainETHWithdraw(
        address indexed rootToken,
        address indexed childToken,
        address withdrawer,
        address indexed receiver,
        uint256 amount
    );
}

/**
 * @notice Root ERC20 Bridge Errors
 * @notice Defines error types emitted by a Root ERC20 Bridge implementation.
 */
interface IRootERC20BridgeErrors {
    /// @notice Error when the amount requested is less than the value sent.
    error InsufficientValue();
    /// @notice Error when there is no gas payment received.
    error ZeroAmount();
    /// @notice Error when a zero address is given when not valid.
    error ZeroAddress();
    /// @notice Error when a message is sent with no gas payment.
    error NoGas();
    /// @notice Error when the child chain name is invalid.
    error InvalidChildChain();
    /// @notice Error when a token is already mapped.
    error AlreadyMapped();
    /// @notice Error when a token is not mapped when it should be.
    error NotMapped();
    /// @notice Error when attempting to map IMX.
    error CantMapIMX();
    /// @notice Error when attempting to map ETH.
    error CantMapETH();
    /// @notice Error when attempting to map wETH.
    error CantMapWETH();
    /// @notice Error when token balance invariant check fails.
    error BalanceInvariantCheckFailed(uint256 actualBalance, uint256 expectedBalance);
    /// @notice Error when a message received has invalid data.
    error InvalidData(string reason);
    /// @notice Error when caller is not the root bridge adaptor but should be.
    error NotBridgeAdaptor();
    /// @notice Error when the total IMX deposit limit is exceeded
    error ImxDepositLimitExceeded();
    /// @notice Error when the IMX deposit limit is set below the amount of IMX already deposited
    error ImxDepositLimitTooLow();
    /// @notice Error when native transfer is sent to contract from non wrapped-token address.
    error NonWrappedNativeTransfer();
    /// @notice Error when the an unauthorized initializer tries to initialize the contract.
    error UnauthorizedInitializer();
    /// @notice Error when attempt to map a ERC20 token that doesn't support name(), symbol() or decimals().
    error TokenNotSupported();
}

File 13 of 28 : IRootBridgeAdaptor.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

/**
 * @title Root ERC20 Bridge Adaptor Interface
 * @notice Defines the functions that can be used be used by a Root ERC20 Bridge to send messages through an underlying GMP
 * @dev This interface abstracts the details of the underlying General Purpose Message Passing protocol.
 *      This minimizes changes to the interface consumer if the underlying GMP is changed in the future.
 *      In addition, this interface is not specific to an ERC20 bridge, and will likely eventually be renamed to be more generic.
 */
interface IRootBridgeAdaptor {
    /**
     * @notice Send an arbitrary message to the child chain via the message passing protocol.
     * @param payload The message to send, encoded in a `bytes` array.
     * @param refundRecipient Used if the message passing protocol requires fees & pays back excess to a refund recipient.
     * @dev The function is `payable` because the message passing protocol may require a fee to be paid.
     */
    function sendMessage(bytes calldata payload, address refundRecipient) external payable;
}

File 14 of 28 : IWETH.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @notice Interface for the Wrapped ETH (wETH) contract.
 * @dev Interface for the standard wrapped ETH contract deployed on Ethereum: https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
 */
interface IWETH is IERC20 {
    /**
     * @notice Emitted when native ETH is deposited to the contract, and a corresponding amount of wETH are minted
     * @param account The address of the account that deposited the tokens.
     * @param value The amount of tokens that were deposited.
     */
    event Deposit(address indexed account, uint256 value);

    /**
     * @notice Emitted when wETH is withdrawn from the contract, and a corresponding amount of wETH are burnt.
     * @param account The address of the account that withdrew the tokens.
     * @param value The amount of tokens that were withdrawn.
     */
    event Withdrawal(address indexed account, uint256 value);

    /**
     * @notice Deposit native ETH to the contract and mint an equal amount of wrapped ETH to msg.sender.
     */
    function deposit() external payable;

    /**
     * @notice Withdraw given amount of native ETH to msg.sender after burning an equal amount of wrapped ETH.
     * @param value The amount to withdraw.
     */
    function withdraw(uint256 value) external;
}

File 15 of 28 : BridgeRoles.sol
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

/**
 * @title BridgeRoles.sol
 * @notice BridgeRoles.sol is an abstract contract that defines the roles and permissions and pausable functionality across the root and child chain bridge contracts.
 * @dev This contract uses OpenZeppelin's AccessControl and Pausable contracts. This contract is abstract and is intended to be inherited by the root and child chain bridge contracts.
 */
abstract contract BridgeRoles is AccessControlUpgradeable, PausableUpgradeable {
    // Roles
    /// @notice Role identifier for those who can pause functionanlity.
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER");

    /// @notice Role identifier for those who can unpause functionality.
    bytes32 public constant UNPAUSER_ROLE = keccak256("UNPAUSER");

    /// @notice Role identifier for those who can update the bridge adaptor.
    bytes32 public constant ADAPTOR_MANAGER_ROLE = keccak256("ADAPTOR_MANAGER");

    // Role granting functions
    /**
     * @notice Function to grant pauser role to an address
     */
    function grantPauserRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        grantRole(PAUSER_ROLE, account);
    }

    /**
     * @notice Function to grant unpauser role to an address
     */
    function grantUnpauserRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        grantRole(UNPAUSER_ROLE, account);
    }

    /**
     * @notice Function to grant adaptor manager role to an address
     */
    function grantAdaptorManagerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        grantRole(ADAPTOR_MANAGER_ROLE, account);
    }

    // Role revoking functions
    /**
     * @notice Function to revoke pauser role from an address
     */
    function revokePauserRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        revokeRole(PAUSER_ROLE, account);
    }

    /**
     * @notice Function to revoke unpauser role from an address
     */
    function revokeUnpauserRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        revokeRole(UNPAUSER_ROLE, account);
    }

    /**
     * @notice Function to revoke adaptor manager role from an address
     */
    function revokeAdaptorManagerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
        revokeRole(ADAPTOR_MANAGER_ROLE, account);
    }

    // Pausable functions
    /**
     * @notice Function to pause the contract
     * @dev Only PAUSER_ROLE can call this function
     */
    function pause() external onlyRole(PAUSER_ROLE) {
        _pause();
    }

    /**
     * @notice Function to pause the contract
     * @dev Only UNPAUSER_ROLE can call this function
     */
    function unpause() external onlyRole(UNPAUSER_ROLE) {
        _unpause();
    }

    // slither-disable-next-line unused-state,naming-convention
    uint256[50] private __gapBridgeRoles;
}

File 16 of 28 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 17 of 28 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 18 of 28 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.2;

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

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

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

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

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

File 20 of 28 : 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 21 of 28 : 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 22 of 28 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = MathUpgradeable.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.log256(value) + 1);
        }
    }

    /**
     * @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] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 23 of 28 : 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 24 of 28 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        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 25 of 28 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

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

File 26 of 28 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

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

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

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 27 of 28 : SignedMathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMathUpgradeable {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 28 of 28 : 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);
}

Settings
{
  "remappings": [
    "@axelar-cgp-solidity/=lib/axelar-cgp-solidity/",
    "@axelar-gmp-sdk-solidity/=lib/axelar-gmp-sdk-solidity/",
    "@axelar-network/axelar-gmp-sdk-solidity/=lib/axelar-gmp-sdk-solidity/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "axelar-cgp-solidity/=lib/axelar-cgp-solidity/contracts/",
    "axelar-gmp-sdk-solidity/=lib/axelar-gmp-sdk-solidity/contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_initializerAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyMapped","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualBalance","type":"uint256"},{"internalType":"uint256","name":"expectedBalance","type":"uint256"}],"name":"BalanceInvariantCheckFailed","type":"error"},{"inputs":[],"name":"CantMapETH","type":"error"},{"inputs":[],"name":"CantMapIMX","type":"error"},{"inputs":[],"name":"CantMapWETH","type":"error"},{"inputs":[],"name":"ImxDepositLimitExceeded","type":"error"},{"inputs":[],"name":"ImxDepositLimitTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"lengthOfQueue","type":"uint256"},{"internalType":"uint256","name":"requestedIndex","type":"uint256"}],"name":"IndexOutsideWithdrawalQueue","type":"error"},{"inputs":[],"name":"InsufficientValue","type":"error"},{"inputs":[],"name":"InvalidCapacity","type":"error"},{"inputs":[],"name":"InvalidChildChain","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"InvalidData","type":"error"},{"inputs":[],"name":"InvalidRefillRate","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"actualToken","type":"address"}],"name":"MixedTokens","type":"error"},{"inputs":[],"name":"NoGas","type":"error"},{"inputs":[],"name":"NonWrappedNativeTransfer","type":"error"},{"inputs":[],"name":"NotBridgeAdaptor","type":"error"},{"inputs":[],"name":"NotMapped","type":"error"},{"inputs":[],"name":"ProvideAtLeastOneIndex","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"TokenIsZero","type":"error"},{"inputs":[],"name":"TokenNotSupported","type":"error"},{"inputs":[],"name":"UnauthorizedInitializer","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"WithdrawalAlreadyProcessed","type":"error"},{"inputs":[{"internalType":"uint256","name":"timeNow","type":"uint256"},{"internalType":"uint256","name":"currentWithdrawalTime","type":"uint256"}],"name":"WithdrawalRequestTooEarly","type":"error"},{"inputs":[],"name":"WrongInitializer","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"who","type":"address"}],"name":"ActivatedWithdrawalQueue","type":"event"},{"anonymous":false,"inputs":[],"name":"AutoActivatedWithdrawalQueue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootToken","type":"address"},{"indexed":true,"internalType":"address","name":"childToken","type":"address"},{"indexed":false,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ChildChainERC20Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"who","type":"address"}],"name":"DeactivatedWithdrawalQueue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"EnQueuedWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootToken","type":"address"},{"indexed":false,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IMXDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootToken","type":"address"},{"indexed":true,"internalType":"address","name":"childToken","type":"address"}],"name":"L1TokenMapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootToken","type":"address"},{"indexed":true,"internalType":"address","name":"childToken","type":"address"},{"indexed":false,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NativeEthDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldImxDepositLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newImxDepositLimit","type":"uint256"}],"name":"NewImxDepositLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"ProcessedWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"delayWithdrawalLargeAmount","type":"bool"},{"indexed":false,"internalType":"bool","name":"delayWithdrawalUnknownToken","type":"bool"},{"indexed":false,"internalType":"bool","name":"withdrawalQueueActivated","type":"bool"}],"name":"QueuedWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"capacity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"refillRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"largeTransferThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousCapacity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousRefillRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousLargeTransferThreshold","type":"uint256"}],"name":"RateControlThresholdSet","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":"address","name":"oldRootBridgeAdaptor","type":"address"},{"indexed":false,"internalType":"address","name":"newRootBridgeAdaptor","type":"address"}],"name":"RootBridgeAdaptorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootToken","type":"address"},{"indexed":true,"internalType":"address","name":"childToken","type":"address"},{"indexed":false,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RootChainERC20Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootToken","type":"address"},{"indexed":true,"internalType":"address","name":"childToken","type":"address"},{"indexed":false,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RootChainETHWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootToken","type":"address"},{"indexed":true,"internalType":"address","name":"childToken","type":"address"},{"indexed":false,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WETHDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"delay","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousDelay","type":"uint256"}],"name":"WithdrawalDelayUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawalForNonFlowRatedToken","type":"event"},{"inputs":[],"name":"ADAPTOR_MANAGER_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":"DEPOSIT_SIG","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAP_TOKEN_SIG","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_IMX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNLIMITED_DEPOSIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNPAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VARIABLE_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAW_SIG","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activateWithdrawalQueue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"childERC20Bridge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"childETHToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"childTokenTemplate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deactivateWithdrawalQueue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20Metadata","name":"rootToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20Metadata","name":"rootToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositToETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"finaliseQueuedWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256[]","name":"indices","type":"uint256[]"}],"name":"finaliseQueuedWithdrawalsAggregated","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"startIndex","type":"uint256"},{"internalType":"uint256","name":"stopIndex","type":"uint256"},{"internalType":"uint256","name":"maxFind","type":"uint256"}],"name":"findPendingWithdrawals","outputs":[{"components":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct FlowRateWithdrawalQueue.FindPendingWithdrawal[]","name":"found","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"flowRateBuckets","outputs":[{"internalType":"uint256","name":"capacity","type":"uint256"},{"internalType":"uint256","name":"depth","type":"uint256"},{"internalType":"uint256","name":"refillTime","type":"uint256"},{"internalType":"uint256","name":"refillRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256[]","name":"indices","type":"uint256[]"}],"name":"getPendingWithdrawals","outputs":[{"components":[{"internalType":"address","name":"withdrawer","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct FlowRateWithdrawalQueue.PendingWithdrawal[]","name":"pending","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"getPendingWithdrawalsLength","outputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"grantAdaptorManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"grantPauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"grantUnpauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"grantVariableManagerRole","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":[],"name":"imxCumulativeDepositLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"defaultAdmin","type":"address"},{"internalType":"address","name":"pauser","type":"address"},{"internalType":"address","name":"unpauser","type":"address"},{"internalType":"address","name":"variableManager","type":"address"},{"internalType":"address","name":"adaptorManager","type":"address"}],"internalType":"struct IRootERC20Bridge.InitializationRoles","name":"newRoles","type":"tuple"},{"internalType":"address","name":"newRootBridgeAdaptor","type":"address"},{"internalType":"address","name":"newChildERC20Bridge","type":"address"},{"internalType":"address","name":"newChildTokenTemplate","type":"address"},{"internalType":"address","name":"newRootIMXToken","type":"address"},{"internalType":"address","name":"newRootWETHToken","type":"address"},{"internalType":"uint256","name":"newImxCumulativeDepositLimit","type":"uint256"},{"internalType":"address","name":"rateAdmin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"defaultAdmin","type":"address"},{"internalType":"address","name":"pauser","type":"address"},{"internalType":"address","name":"unpauser","type":"address"},{"internalType":"address","name":"variableManager","type":"address"},{"internalType":"address","name":"adaptorManager","type":"address"}],"internalType":"struct IRootERC20Bridge.InitializationRoles","name":"","type":"tuple"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"initializerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"largeTransferThresholds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20Metadata","name":"rootToken","type":"address"}],"name":"mapToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onMessageReceive","outputs":[],"stateMutability":"nonpayable","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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"revokeAdaptorManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"revokePauserRole","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":"address","name":"account","type":"address"}],"name":"revokeUnpauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"revokeVariableManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rootBridgeAdaptor","outputs":[{"internalType":"contract IRootBridgeAdaptor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rootIMXToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rootTokenToChildToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rootWETHToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"capacity","type":"uint256"},{"internalType":"uint256","name":"refillRate","type":"uint256"},{"internalType":"uint256","name":"largeTransferThreshold","type":"uint256"}],"name":"setRateControlThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"delay","type":"uint256"}],"name":"setWithdrawalDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newImxCumulativeDepositLimit","type":"uint256"}],"name":"updateImxCumulativeDepositLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRootBridgeAdaptor","type":"address"}],"name":"updateRootBridgeAdaptor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalQueueActivated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523480156200001157600080fd5b506040516200453038038062004530833981016040819052620000349162000070565b806001600160a01b0381166200005d5760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b031660805250620000a2565b6000602082840312156200008357600080fd5b81516001600160a01b03811681146200009b57600080fd5b9392505050565b60805161446b620000c560003960008181610a7301526119d1015261446b6000f3fe60806040526004361061039b5760003560e01c80638456cb59116101dc578063d2c13da511610102578063dee1ef0d116100a0578063f4a120f71161006f578063f4a120f714610b41578063f645125514610b54578063f865af0814610b88578063fb1bb9de14610ba857600080fd5b8063dee1ef0d14610ad8578063e041043214610af9578063e63ab1e914610b0c578063f213159c14610b2e57600080fd5b8063d68d5fd6116100dc578063d68d5fd614610a41578063d6dc0b0d14610a61578063d837671614610a95578063da51c71e14610ab657600080fd5b8063d2c13da5146109cd578063d41f1771146109ed578063d547741f14610a2157600080fd5b8063a217fddf1161017a578063af8bbb5e11610149578063af8bbb5e14610943578063b176806514610958578063b68ad1e41461098c578063c880d915146109ad57600080fd5b8063a217fddf14610734578063a6f72cb8146108f1578063a7ab69611461090c578063a8deae561461092357600080fd5b80638c956990116101b65780638c956990146108705780638f3a4e4f146108915780638f70121f146108b157806391d14854146108d157600080fd5b80638456cb591461080d57806384a3291a1461082257806389c65d411461085057600080fd5b80633a7a228e116102c15780636066ae871161025f5780637248c77c1161022e5780637248c77c146107695780637ab5e3ae146107895780637b1929b71461079f5780637efab4f5146107d657600080fd5b80636066ae87146106fd57806367e4e1891461071d57806368673a03146107345780636c11c21c1461074957600080fd5b8063499fa04b1161029b578063499fa04b146106915780635358fbda146106b25780635c975abb146106c55780635d3a22ab146106dd57600080fd5b80633a7a228e146106495780633f4ba83a1461066957806347e7ef241461067e57600080fd5b80632540e2da116103395780632f2ff15d116103085780632f2ff15d1461058657806332968782146105a657806336568abe146105c6578063366963ea146105e657600080fd5b80632540e2da146104ea57806326fe4fc31461050a57806328a6ff1e1461052c5780632bf839111461055957600080fd5b80630800dd27116103755780630800dd2714610456578063106d5726146104765780631657a6e514610497578063248a9ca3146104ac57600080fd5b8063011e1167146103d357806301ffc9a71461040657806307b2b7ad1461043657600080fd5b366103ce57610133546001600160a01b031633146103cc57604051630402506f60e01b815260040160405180910390fd5b005b600080fd5b3480156103df57600080fd5b506103e9610eee81565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561041257600080fd5b506104266104213660046139ef565b610bca565b60405190151581526020016103fd565b34801561044257600080fd5b506103cc610451366004613a2e565b610c01565b34801561046257600080fd5b506103cc610471366004613afd565b610c28565b34801561048257600080fd5b5061012f546103e9906001600160a01b031681565b3480156104a357600080fd5b506103cc610d94565b3480156104b857600080fd5b506104dc6104c7366004613ba0565b60009081526065602052604090206001015490565b6040519081526020016103fd565b3480156104f657600080fd5b506103cc610505366004613a2e565b610db7565b34801561051657600080fd5b506104dc60008051602061441683398151915281565b34801561053857600080fd5b5061054c610547366004613c05565b610dda565b6040516103fd9190613c5a565b34801561056557600080fd5b50610579610574366004613cca565b610f9e565b6040516103fd9190613d1b565b34801561059257600080fd5b506103cc6105a1366004613d67565b611216565b3480156105b257600080fd5b506103cc6105c1366004613a2e565b611240565b3480156105d257600080fd5b506103cc6105e1366004613d67565b611263565b3480156105f257600080fd5b50610629610601366004613a2e565b6101676020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016103fd565b34801561065557600080fd5b506103cc610664366004613d97565b6112dd565b34801561067557600080fd5b506103cc611333565b6103cc61068c366004613d97565b611353565b34801561069d57600080fd5b5061012e546103e9906001600160a01b031681565b6103cc6106c0366004613ba0565b61135e565b3480156106d157600080fd5b5060975460ff16610426565b3480156106e957600080fd5b506103cc6106f8366004613dc3565b611368565b34801561070957600080fd5b506103cc610718366004613a2e565b611469565b34801561072957600080fd5b506104dc6101345481565b34801561074057600080fd5b506104dc600081565b34801561075557600080fd5b506103cc610764366004613a2e565b61148c565b34801561077557600080fd5b506103cc610784366004613e28565b6114af565b34801561079557600080fd5b506103e9610fff81565b3480156107ab57600080fd5b506104dc6107ba366004613a2e565b6001600160a01b0316600090815261019b602052604090205490565b3480156107e257600080fd5b506103e96107f1366004613a2e565b61012d602052600090815260409020546001600160a01b031681565b34801561081957600080fd5b506103cc6115f5565b34801561082e57600080fd5b506104dc61083d366004613a2e565b6101cf6020526000908152604090205481565b34801561085c57600080fd5b506103cc61086b366004613a2e565b611615565b34801561087c57600080fd5b50610131546103e9906001600160a01b031681565b34801561089d57600080fd5b506103cc6108ac366004613e9a565b611638565b3480156108bd57600080fd5b506103cc6108cc366004613a2e565b611705565b3480156108dd57600080fd5b506104266108ec366004613d67565b611728565b3480156108fd57600080fd5b50610168546104269060ff1681565b34801561091857600080fd5b506104dc61019c5481565b34801561092f57600080fd5b506103cc61093e366004613a2e565b611753565b34801561094f57600080fd5b506103cc6117fe565b34801561096457600080fd5b506104dc7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e98286981565b34801561099857600080fd5b50610130546103e9906001600160a01b031681565b3480156109b957600080fd5b506103cc6109c8366004613ed5565b61181e565b3480156109d957600080fd5b506103cc6109e8366004613ba0565b611837565b3480156109f957600080fd5b506104dc7f87a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f82181565b348015610a2d57600080fd5b506103cc610a3c366004613d67565b611858565b348015610a4d57600080fd5b506103cc610a5c366004613ba0565b61187d565b348015610a6d57600080fd5b506103e97f000000000000000000000000000000000000000000000000000000000000000081565b348015610aa157600080fd5b50610133546103e9906001600160a01b031681565b348015610ac257600080fd5b506104dc60008051602061439683398151915281565b348015610ae457600080fd5b50610132546103e9906001600160a01b031681565b6103cc610b07366004613d97565b611971565b348015610b1857600080fd5b506104dc6000805160206143d683398151915281565b6103cc610b3c366004613f65565b61197b565b6103e9610b4f366004613a2e565b611986565b348015610b6057600080fd5b506104dc7f2cef46a936bdc5b7e6e8c71aa04560c41cf7d88bb26901a7e7f4936ff02accad81565b348015610b9457600080fd5b506103cc610ba3366004613a2e565b611999565b348015610bb457600080fd5b506104dc6000805160206143b683398151915281565b60006001600160e01b03198216637965db0b60e01b1480610bfb57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610c0c816119bc565b610c2460008051602061441683398151915283611216565b5050565b600054610100900460ff1615808015610c485750600054600160ff909116105b80610c625750303b158015610c62575060005460ff166001145b610cca5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610ced576000805461ff0019166101001790555b6001600160a01b038216610d145760405163d92e233d60e01b815260040160405180910390fd5b610d23898989898989896119c6565b610d2b611cb1565b610d436000805160206143f683398151915283611cbf565b8015610d89576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000805160206143f6833981519152610dac816119bc565b610db4611d45565b50565b6000610dc2816119bc565b610c246000805160206143b683398151915283611858565b6001600160a01b038316600090815261019b602052604090208054606091908367ffffffffffffffff811115610e1257610e12613a4b565b604051908082528060200260200182016040528015610e6457816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181610e305790505b50925060005b8351811015610f945781868683818110610e8657610e86613fa6565b9050602002013510610eeb57604051806080016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815250848281518110610edb57610edb613fa6565b6020026020010181905250610f82565b82868683818110610efe57610efe613fa6565b9050602002013581548110610f1557610f15613fa6565b600091825260209182902060408051608081018252600490930290910180546001600160a01b0390811684526001820154169383019390935260028301549082015260039091015460608201528451859083908110610f7657610f76613fa6565b60200260200101819052505b80610f8c81613fd2565b915050610e6a565b5050509392505050565b6001600160a01b038516600090815261019b602052604090206060908267ffffffffffffffff811115610fd357610fd3613a4b565b60405190808252806020026020018201604052801561102857816020015b61101560405180606001604052806000815260200160008152602001600081525090565b815260200190600190039081610ff15790505b5091506000808280549050861161103f5785611042565b82545b9050865b818110801561105457508583105b1561113657886001600160a01b031684828154811061107557611075613fa6565b60009182526020909120600160049092020101546001600160a01b0316036111245760405180606001604052808281526020018583815481106110ba576110ba613fa6565b90600052602060002090600402016002015481526020018583815481106110e3576110e3613fa6565b90600052602060002090600402016003015481525085848151811061110a5761110a613fa6565b6020026020010181905250828061112090613fd2565b9350505b8061112e81613fd2565b915050611046565b5084821461120a5760008267ffffffffffffffff81111561115957611159613a4b565b6040519080825280602002602001820160405280156111ae57816020015b61119b60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816111775790505b50905060005b83811015611206578581815181106111ce576111ce613fa6565b60200260200101518282815181106111e8576111e8613fa6565b602002602001018190525080806111fe90613fd2565b9150506111b4565b5093505b50505095945050505050565b600082815260656020526040902060010154611231816119bc565b61123b8383611cbf565b505050565b600061124b816119bc565b610c246000805160206143b683398151915283611216565b6001600160a01b03811633146112d35760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610cc1565b610c248282611d86565b6112e5611ded565b60008060006112f48585611e46565b6001600160a01b03808316600090815261012d60205260409020549396509194509250166113258382868986611ff7565b50505050610c24600160fb55565b6000805160206143b683398151915261134b816119bc565b610db46120e2565b610c2482338361212f565b610db4338261215b565b611370611ded565b6000819003611392576040516318301aa760e01b815260040160405180910390fd5b60008060005b8381101561142c576000806113c5898888868181106113b9576113b9613fa6565b90506020020135611e46565b919550925090506001600160a01b038083169089161461140b57604051632469ee5360e01b81526001600160a01b03808a16600483015283166024820152604401610cc1565b6114158186613feb565b94505050808061142490613fd2565b915050611398565b506001600160a01b03808616600090815261012d6020526040902054166114568682848a87611ff7565b505050611463600160fb55565b50505050565b6000611474816119bc565b610c2460008051602061441683398151915283611858565b6000611497816119bc565b610c246000805160206143d683398151915283611216565b6114b76121ca565b61012e546001600160a01b031633146114e35760405163122d54c760e11b815260040160405180910390fd5b602081116115255760405163180a097760e01b815260206004820152600e60248201526d11185d18481d1bdbc81cda1bdc9d60921b6044820152606401610cc1565b7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e982869611554602060008486613ffe565b61155d91614028565b036115ac57610c246115728260208186613ffe565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061221092505050565b60405163180a097760e01b815260206004820152601c60248201527f556e737570706f7274656420616374696f6e207369676e6174757265000000006044820152606401610cc1565b6000805160206143d683398151915261160d816119bc565b610db461230f565b6000611620816119bc565b610c2460008051602061439683398151915283611858565b6000805160206143f6833981519152611650816119bc565b6001600160a01b03851660009081526101676020908152604080832080546003909101546101cf90935292205461168888888861234c565b6001600160a01b03881660008181526101cf602090815260409182902088905581518a8152908101899052908101879052606081018590526080810184905260a081018390527f300bef0f21f43f60e0c1798e3095fc7583e6832358453bef5e5af765a7b53e3d9060c00160405180910390a25050505050505050565b6000611710816119bc565b610c2460008051602061439683398151915283611216565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60008051602061439683398151915261176b816119bc565b6001600160a01b0382166117925760405163d92e233d60e01b815260040160405180910390fd5b61012e54604080516001600160a01b03928316815291841660208301527f9f505d2f223df1f36d2bbc40c8817da20509a9722f3fc09d005bb9d5df154210910160405180910390a15061012e80546001600160a01b0319166001600160a01b0392909216919091179055565b6000805160206143f6833981519152611816816119bc565b610db46123eb565b60405163f0e2219760e01b815260040160405180910390fd5b6000805160206143f683398151915261184f816119bc565b610c2482612429565b600082815260656020526040902060010154611873816119bc565b61123b8383611d86565b600080516020614416833981519152611895816119bc565b811580159061190f5750610131546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156118e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190c9190614046565b82105b1561192d576040516308c4bd0b60e11b815260040160405180910390fd5b6101345460408051918252602082018490527f20f79e1e156e9d4acad9184b2d8283c178ddb9638463180bf2176285b77ab76b910160405180910390a15061013455565b610c24828261215b565b61123b83838361212f565b60006119906121ca565b610bfb8261246f565b60006119a4816119bc565b610c246000805160206143d683398151915283611858565b610db48133612711565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611a0f57604051630d622feb60e01b815260040160405180910390fd5b6001600160a01b0386161580611a2c57506001600160a01b038516155b80611a3e57506001600160a01b038416155b80611a5057506001600160a01b038316155b80611a6257506001600160a01b038216155b80611a75575086516001600160a01b0316155b80611a8b575060208701516001600160a01b0316155b80611aa1575060408701516001600160a01b0316155b80611ab7575060608701516001600160a01b0316155b80611acd575060808701516001600160a01b0316155b15611aeb5760405163d92e233d60e01b815260040160405180910390fd5b611af361276a565b611afb612791565b611b036127c0565b8651611b1190600090611cbf565b611b2d6000805160206143d68339815191528860200151611cbf565b611b496000805160206143b68339815191528860400151611cbf565b611b656000805160206144168339815191528860600151611cbf565b611b816000805160206143968339815191528860800151611cbf565b61012f80546001600160a01b038781166001600160a01b03199283161790925561013080548784169083168117909155610131805487851690841617905561013380549386169390921692909217905560405161077760611b6020820152611c11919060340160408051601f19818403018152919052805160209091012061012f546001600160a01b03166127ef565b61013280546001600160a01b03199081166001600160a01b039384161790915561012e805482169883169890981790975561013491909155610131548116600081815261012d602052604080822080548a169093179092557fad76b4044bfa734d1658e7587c3fd33991772c4284f450d12a829695b2e0bd048054610eee908a168117909155610133549093168152208054909616179094555050505050565b611cbd62015180612429565b565b611cc98282611728565b610c245760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611d013390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610168805460ff191690556040513381527fca830263c7c51a7fd39e6424d29d9e7a11ce1250e908ee0763c2c921d7a3022b906020015b60405180910390a1565b611d908282611728565b15610c245760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600260fb5403611e3f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610cc1565b600260fb55565b6001600160a01b038216600090815261019b60205260408120805482918291808610611e8f5760405163c0876ed360e01b81526004810182905260248101879052604401610cc1565b6000828781548110611ea357611ea3613fa6565b600091825260209091206004909102018054600182015460028301546001600160a01b039283169950911696509450905084611f045760405163373a67e760e21b81526001600160a01b038916600482015260248101889052604401610cc1565b600061019c548260030154611f199190613feb565b905080421015611f45576040516337c6546160e01b815242600482015260248101829052604401610cc1565b838881548110611f5757611f57613fa6565b60009182526020822060049091020180546001600160a01b03199081168255600182018054909116905560028101829055600301556040516001600160a01b038a811691898216918916907f3d7c245d695cceb19fe0fa394d673c860b810a04592fe5415e980c651bb81b9290611fe4908a9042908f909283526020830191909152604082015260600190565b60405180910390a4505050509250925092565b611fff6121ca565b610eed196001600160a01b038616016120705761201c828261284b565b604080516001600160a01b038581168252602082018490528085169290871691610eee917f4327909ba044fbe8b04a4d999929cd91a03b30ebfae467b54c16353a44660f43910160405180910390a46120d4565b6120846001600160a01b0386168383612964565b604080516001600160a01b038581168252602082018490528085169287821692918916917f6e90696e59c60d3ffd22a244d98b9d73dae6642f03b99cd4d3e5aa852121443b910160405180910390a45b5050505050565b600160fb55565b6120ea6129c7565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001611d7c565b610133546001600160a01b03908116908416036121505761123b8282612a10565b61123b838383612ad8565b8034101561217c5760405163044044a560e21b815260040160405180910390fd5b6000612188823461405f565b612192904761405f565b90506121a1610eee8484612c57565b80471461123b57604051637244981560e11b815247600482015260248101829052604401610cc1565b60975460ff1615611cbd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610cc1565b600080600080600061222186612f06565b9450945094509450945060006122378683612fe0565b905060008161225f57506001600160a01b03861660009081526101cf60205260409020548210155b6101685460ff16818061226f5750825b806122775750805b156123025761228885878a876130fb565b846001600160a01b0316866001600160a01b0316896001600160a01b03167fbdca490c3df14c1d2a133e5b1e2300a5086f2ddc3f90d5dc9ad1d50287df574b878688876040516122f594939291909384529115156020840152151560408301521515606082015260800190565b60405180910390a4610d89565b610d898888888888611ff7565b6123176121ca565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586121173390565b6001600160a01b0383166123735760405163c1ab6dc160e01b815260040160405180910390fd5b81600003612394576040516331278a8760e01b815260040160405180910390fd5b806000036123b557604051636cbcfbe360e11b815260040160405180910390fd5b6001600160a01b03831660009081526101676020526040812080549091036123df57600181018390555b91825560039091015550565b610168805460ff191660011790556040513381527fe6f871681d402a779a934141b5608fb6f3226c91b5fc9d24d93b7dc83e4aceb690602001611d7c565b61019c80549082905560408051838152602081018390527f9c3f1b54b1487e018f1d0593ff5cf7fb625b2df6332c974a6cc56bb358879841910160405180910390a15050565b60003460000361249257604051631d3e008d60e21b815260040160405180910390fd5b6001600160a01b0382166124b95760405163d92e233d60e01b815260040160405180910390fd5b610131546001600160a01b03908116908316036124e95760405163a9a43cf960e01b815260040160405180910390fd5b610eed196001600160a01b038316016125155760405163e9edc9b360e01b815260040160405180910390fd5b610133546001600160a01b0390811690831603612545576040516311eba7e360e01b815260040160405180910390fd5b6001600160a01b03828116600090815261012d6020526040902054161561257f57604051632a431ae760e11b815260040160405180910390fd5b61012f54610130546040516bffffffffffffffffffffffff19606086901b1660208201526001600160a01b03928316926000926125d89291169060340160405160208183030381529060405280519060200120846127ef565b6001600160a01b03858116600090815261012d6020526040812080546001600160a01b03191692841692909217909155909150808061261687613204565b92509250925060007f2cef46a936bdc5b7e6e8c71aa04560c41cf7d88bb26901a7e7f4936ff02accad888585856040516020016126579594939291906140c2565b60408051601f198184030181529082905261012e54637903aadd60e11b83529092506001600160a01b03169063f20755ba90349061269b9085903390600401614114565b6000604051808303818588803b1580156126b457600080fd5b505af11580156126c8573d6000803e3d6000fd5b50506040516001600160a01b03808a1694508c1692507fadbf4fee5f2ebdb59bcf27cd835d152ca7931a51cb921c5f8fdc43cf7c1f33049150600090a350929695505050505050565b61271b8282611728565b610c245761272881613390565b6127338360206133a2565b60405160200161274492919061413e565b60408051601f198184030181529082905262461bcd60e51b8252610cc1916004016141b3565b600054610100900460ff16611cbd5760405162461bcd60e51b8152600401610cc1906141c6565b600054610100900460ff166127b85760405162461bcd60e51b8152600401610cc1906141c6565b611cbd613545565b600054610100900460ff166127e75760405162461bcd60e51b8152600401610cc1906141c6565b611cbd613578565b60405160388101919091526f5af43d82803e903d91602b57fd5bf3ff60248201526014810192909252733d602d80600a3d3981f3363d3d373d3d3d363d73825260588201526037600c8201206078820152605560439091012090565b8047101561289b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610cc1565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146128e8576040519150601f19603f3d011682016040523d82523d6000602084013e6128ed565b606091505b505090508061123b5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610cc1565b6040516001600160a01b03831660248201526044810182905261123b90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261359f565b60975460ff16611cbd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610cc1565b6000612a1c8247613feb565b610133549091506001600160a01b0316612a3881333086613674565b61013354604051632e1a7d4d60e01b8152600481018590526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015612a7f57600080fd5b505af1158015612a93573d6000803e3d6000fd5b50505050814714612ac057604051637244981560e11b815247600482015260248101839052604401610cc1565b61013354611463906001600160a01b03168585612c57565b6040516370a0823160e01b815230600482015260009082906001600160a01b038616906370a0823190602401602060405180830381865afa158015612b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b459190614046565b612b4f9190613feb565b9050612b5c848484612c57565b6040516370a0823160e01b815230600482015281906001600160a01b038616906370a0823190602401602060405180830381865afa158015612ba2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc69190614046565b14611463576040516370a0823160e01b81523060048201526001600160a01b038516906370a0823190602401602060405180830381865afa158015612c0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c339190614046565b604051637244981560e11b8152600481019190915260248101829052604401610cc1565b612c5f611ded565b612c676121ca565b6101315461013454849183916001600160a01b0391821691841682148015612c8e57508015155b15612d28576040516370a0823160e01b8152306004820152819084906001600160a01b038516906370a0823190602401602060405180830381865afa158015612cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cff9190614046565b612d099190613feb565b1115612d285760405163cf79cc9b60e01b815260040160405180910390fd5b6001600160a01b0386161580612d4557506001600160a01b038716155b15612d635760405163d92e233d60e01b815260040160405180910390fd5b84600003612d8457604051631f2a200560e01b815260040160405180910390fd5b34600003612da557604051631d3e008d60e21b815260040160405180910390fd5b6001600160a01b03878116600090815261012d602052604090205416612dde57604051633a3c22ef60e11b815260040160405180910390fd5b610133546000906001600160a01b03898116911614612dfd5787612e01565b610eee5b604080517f87a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f82160208201526001600160a01b03838116828401523360608301528a8116608083015260a08083018b90528351808403909101815260c09092019092529192506000908a16610eee14612e785734612e82565b612e82883461405f565b61012e54604051637903aadd60e11b81529192506001600160a01b03169063f20755ba908390612eb89086903390600401614114565b6000604051808303818588803b158015612ed157600080fd5b505af1158015612ee5573d6000803e3d6000fd5b5050505050612ef58a8a8a6136ac565b5050505050505061123b600160fb55565b600080600080600085806020019051810190612f229190614211565b929750909450925090506001600160a01b038516612f535760405163d92e233d60e01b815260040160405180910390fd5b610131546001600160a01b0390811690861603612f7457610fff9350612fd7565b610eed196001600160a01b03861601612f9b57610132546001600160a01b03169350612fd7565b6001600160a01b03808616600090815261012d602052604090205416935083612fd757604051633a3c22ef60e11b815260040160405180910390fd5b91939590929450565b6001600160a01b038216600090815261016760205260408120805480830361305057846001600160a01b03167f63455daddfcbe1b76f2cf1d25b17dc8d8b54805d19a0a33035f2a9fb6178bf7d8560405161303d91815260200190565b60405180910390a2600192505050610bfb565b60008260030154836002015442613067919061405f565b6130719190614264565b83600101546130809190613feb565b4260028501559050818111156130935750805b8085106130df576040517f93634b349f9e42d781ffd65b7052280b7d3dd517717c267d448441b4716884cd90600090a1610168805460ff191660019081179091556000908401556130ef565b6130e9858261405f565b60018401555b50600095945050505050565b6001600160a01b03821661312d576040516329f8b6ed60e01b81526001600160a01b0385166004820152602401610cc1565b604080516080810182526001600160a01b0385811680835285821660208085018281528587018881524260608089018281528e8916600081815261019b88528c8120805460018082018355918352918990208d51600484029091018054918e166001600160a01b03199283161781559851918901805492909d16911617909a55935160028601555160039094019390935588518a815293840152968201859052949593947fdc3ff1d1a171333fabe1d0df7590fc79fe74e95fbbfe8aefff8b8c8961f4e02a910160405180910390a4505050505050565b60608060006060846001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561326a57506040513d6000823e601f3d908101601f19168201604052613267919081019061427b565b60015b61328757604051633dd1b30560e01b815260040160405180910390fd5b90506060856001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa9250505080156132ea57506040513d6000823e601f3d908101601f191682016040526132e7919081019061427b565b60015b61330757604051633dd1b30560e01b815260040160405180910390fd5b90506000866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613365575060408051601f3d908101601f191682019092526133629181019061431d565b60015b61338257604051633dd1b30560e01b815260040160405180910390fd5b929791965091945092505050565b6060610bfb6001600160a01b03831660145b606060006133b1836002614264565b6133bc906002613feb565b67ffffffffffffffff8111156133d4576133d4613a4b565b6040519080825280601f01601f1916602001820160405280156133fe576020820181803683370190505b509050600360fc1b8160008151811061341957613419613fa6565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061344857613448613fa6565b60200101906001600160f81b031916908160001a905350600061346c846002614264565b613477906001613feb565b90505b60018111156134ef576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106134ab576134ab613fa6565b1a60f81b8282815181106134c1576134c1613fa6565b60200101906001600160f81b031916908160001a90535060049490941c936134e881614340565b905061347a565b50831561353e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610cc1565b9392505050565b600054610100900460ff1661356c5760405162461bcd60e51b8152600401610cc1906141c6565b6097805460ff19169055565b600054610100900460ff166120db5760405162461bcd60e51b8152600401610cc1906141c6565b60006135f4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661385f9092919063ffffffff16565b90508051600014806136155750808060200190518101906136159190614357565b61123b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610cc1565b6040516001600160a01b03808516602483015283166044820152606481018290526114639085906323b872dd60e01b90608401612990565b610eed196001600160a01b03841601613715576101325460408051338152602081018490526001600160a01b0385811693811692908716917fd1b4e24e81f1c901551420568a9447fd105593af143ae8b096c6385e4fb7ec8691015b60405180910390a4505050565b610133546001600160a01b0390811690841603613779576101325460408051338152602081018490526001600160a01b0385811693811692908716917fa88fe860ecdd7b9e7311676f780fe08f0ed96990b74319e26ad505932d36890f9101613708565b610131546001600160a01b03908116908416036137ee5760408051338152602081018390526001600160a01b0380851692908616917f8294ebca1c2aada95b98b62a8d705ba5d7be4bdb75901d3f0eeb35062b706c79910160405180910390a361123b6001600160a01b038416333084613674565b6001600160a01b03838116600081815261012d6020908152604091829020548251338152918201869052868516941692917f3207f1f801a6ba9b6005cb9dc97d8498df3407dc7b1c7a644c7b57997f4f03c5910160405180910390a461123b6001600160a01b038416333084613674565b606061386e8484600085613876565b949350505050565b6060824710156138d75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610cc1565b600080866001600160a01b031685876040516138f39190614379565b60006040518083038185875af1925050503d8060008114613930576040519150601f19603f3d011682016040523d82523d6000602084013e613935565b606091505b509150915061394687838387613951565b979650505050505050565b606083156139c05782516000036139b9576001600160a01b0385163b6139b95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610cc1565b508161386e565b61386e83838151156139d55781518083602001fd5b8060405162461bcd60e51b8152600401610cc191906141b3565b600060208284031215613a0157600080fd5b81356001600160e01b03198116811461353e57600080fd5b6001600160a01b0381168114610db457600080fd5b600060208284031215613a4057600080fd5b813561353e81613a19565b634e487b7160e01b600052604160045260246000fd5b600060a08284031215613a7357600080fd5b60405160a0810181811067ffffffffffffffff82111715613a9657613a96613a4b565b6040529050808235613aa781613a19565b81526020830135613ab781613a19565b60208201526040830135613aca81613a19565b60408201526060830135613add81613a19565b60608201526080830135613af081613a19565b6080919091015292915050565b600080600080600080600080610180898b031215613b1a57600080fd5b613b248a8a613a61565b975060a0890135613b3481613a19565b965060c0890135613b4481613a19565b955060e0890135613b5481613a19565b9450610100890135613b6581613a19565b9350610120890135613b7681613a19565b92506101408901359150610160890135613b8f81613a19565b809150509295985092959890939650565b600060208284031215613bb257600080fd5b5035919050565b60008083601f840112613bcb57600080fd5b50813567ffffffffffffffff811115613be357600080fd5b6020830191508360208260051b8501011115613bfe57600080fd5b9250929050565b600080600060408486031215613c1a57600080fd5b8335613c2581613a19565b9250602084013567ffffffffffffffff811115613c4157600080fd5b613c4d86828701613bb9565b9497909650939450505050565b602080825282518282018190526000919060409081850190868401855b82811015613cbd57815180516001600160a01b03908116865287820151168786015285810151868601526060908101519085015260809093019290850190600101613c77565b5091979650505050505050565b600080600080600060a08688031215613ce257600080fd5b8535613ced81613a19565b94506020860135613cfd81613a19565b94979496505050506040830135926060810135926080909101359150565b602080825282518282018190526000919060409081850190868401855b82811015613cbd5781518051855286810151878601528501518585015260609093019290850190600101613d38565b60008060408385031215613d7a57600080fd5b823591506020830135613d8c81613a19565b809150509250929050565b60008060408385031215613daa57600080fd5b8235613db581613a19565b946020939093013593505050565b60008060008060608587031215613dd957600080fd5b8435613de481613a19565b93506020850135613df481613a19565b9250604085013567ffffffffffffffff811115613e1057600080fd5b613e1c87828801613bb9565b95989497509550505050565b60008060208385031215613e3b57600080fd5b823567ffffffffffffffff80821115613e5357600080fd5b818501915085601f830112613e6757600080fd5b813581811115613e7657600080fd5b866020828501011115613e8857600080fd5b60209290920196919550909350505050565b60008060008060808587031215613eb057600080fd5b8435613ebb81613a19565b966020860135965060408601359560600135945092505050565b6000806000806000806000610160888a031215613ef157600080fd5b613efb8989613a61565b965060a0880135613f0b81613a19565b955060c0880135613f1b81613a19565b945060e0880135613f2b81613a19565b9350610100880135613f3c81613a19565b9250610120880135613f4d81613a19565b80925050610140880135905092959891949750929550565b600080600060608486031215613f7a57600080fd5b8335613f8581613a19565b92506020840135613f9581613a19565b929592945050506040919091013590565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613fe457613fe4613fbc565b5060010190565b80820180821115610bfb57610bfb613fbc565b6000808585111561400e57600080fd5b8386111561401b57600080fd5b5050820193919092039150565b80356020831015610bfb57600019602084900360031b1b1692915050565b60006020828403121561405857600080fd5b5051919050565b81810381811115610bfb57610bfb613fbc565b60005b8381101561408d578181015183820152602001614075565b50506000910152565b600081518084526140ae816020860160208601614072565b601f01601f19169290920160200192915050565b8581526001600160a01b038516602082015260a0604082018190526000906140ec90830186614096565b82810360608401526140fe8186614096565b91505060ff831660808301529695505050505050565b6040815260006141276040830185614096565b905060018060a01b03831660208301529392505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614176816017850160208801614072565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516141a7816028840160208801614072565b01602801949350505050565b60208152600061353e6020830184614096565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000806000806080858703121561422757600080fd5b845161423281613a19565b602086015190945061424381613a19565b604086015190935061425481613a19565b6060959095015193969295505050565b8082028115828204841417610bfb57610bfb613fbc565b60006020828403121561428d57600080fd5b815167ffffffffffffffff808211156142a557600080fd5b818401915084601f8301126142b957600080fd5b8151818111156142cb576142cb613a4b565b604051601f8201601f19908116603f011681019083821181831017156142f3576142f3613a4b565b8160405282815287602084870101111561430c57600080fd5b613946836020830160208801614072565b60006020828403121561432f57600080fd5b815160ff8116811461353e57600080fd5b60008161434f5761434f613fbc565b506000190190565b60006020828403121561436957600080fd5b8151801515811461353e57600080fd5b6000825161438b818460208701614072565b919091019291505056fea6d0b532cacea090bc411482cd491720e2eac14d48ce5d0402b8851e0bb2aec182b32d9ab5100db08aeb9a0e08b422d14851ec118736590462bf9c085a6e9448539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14cdcd3beafca8a1012a37a08a8968959a8e9278fafc576974c99735b24d5d8ae0f5b94a8cd68affa84315f488cc2e6e456f761d334859cae8a073ef8fe13fb0ee6a264697066735822122062a5cae4376c09d167f3baee47aab68af10c1a210783a29e0f7afe9a4200f8eb64736f6c63430008130033000000000000000000000000dda0d9448ebe3ea43afece5fa6401f5795c19333

Deployed Bytecode

0x60806040526004361061039b5760003560e01c80638456cb59116101dc578063d2c13da511610102578063dee1ef0d116100a0578063f4a120f71161006f578063f4a120f714610b41578063f645125514610b54578063f865af0814610b88578063fb1bb9de14610ba857600080fd5b8063dee1ef0d14610ad8578063e041043214610af9578063e63ab1e914610b0c578063f213159c14610b2e57600080fd5b8063d68d5fd6116100dc578063d68d5fd614610a41578063d6dc0b0d14610a61578063d837671614610a95578063da51c71e14610ab657600080fd5b8063d2c13da5146109cd578063d41f1771146109ed578063d547741f14610a2157600080fd5b8063a217fddf1161017a578063af8bbb5e11610149578063af8bbb5e14610943578063b176806514610958578063b68ad1e41461098c578063c880d915146109ad57600080fd5b8063a217fddf14610734578063a6f72cb8146108f1578063a7ab69611461090c578063a8deae561461092357600080fd5b80638c956990116101b65780638c956990146108705780638f3a4e4f146108915780638f70121f146108b157806391d14854146108d157600080fd5b80638456cb591461080d57806384a3291a1461082257806389c65d411461085057600080fd5b80633a7a228e116102c15780636066ae871161025f5780637248c77c1161022e5780637248c77c146107695780637ab5e3ae146107895780637b1929b71461079f5780637efab4f5146107d657600080fd5b80636066ae87146106fd57806367e4e1891461071d57806368673a03146107345780636c11c21c1461074957600080fd5b8063499fa04b1161029b578063499fa04b146106915780635358fbda146106b25780635c975abb146106c55780635d3a22ab146106dd57600080fd5b80633a7a228e146106495780633f4ba83a1461066957806347e7ef241461067e57600080fd5b80632540e2da116103395780632f2ff15d116103085780632f2ff15d1461058657806332968782146105a657806336568abe146105c6578063366963ea146105e657600080fd5b80632540e2da146104ea57806326fe4fc31461050a57806328a6ff1e1461052c5780632bf839111461055957600080fd5b80630800dd27116103755780630800dd2714610456578063106d5726146104765780631657a6e514610497578063248a9ca3146104ac57600080fd5b8063011e1167146103d357806301ffc9a71461040657806307b2b7ad1461043657600080fd5b366103ce57610133546001600160a01b031633146103cc57604051630402506f60e01b815260040160405180910390fd5b005b600080fd5b3480156103df57600080fd5b506103e9610eee81565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561041257600080fd5b506104266104213660046139ef565b610bca565b60405190151581526020016103fd565b34801561044257600080fd5b506103cc610451366004613a2e565b610c01565b34801561046257600080fd5b506103cc610471366004613afd565b610c28565b34801561048257600080fd5b5061012f546103e9906001600160a01b031681565b3480156104a357600080fd5b506103cc610d94565b3480156104b857600080fd5b506104dc6104c7366004613ba0565b60009081526065602052604090206001015490565b6040519081526020016103fd565b3480156104f657600080fd5b506103cc610505366004613a2e565b610db7565b34801561051657600080fd5b506104dc60008051602061441683398151915281565b34801561053857600080fd5b5061054c610547366004613c05565b610dda565b6040516103fd9190613c5a565b34801561056557600080fd5b50610579610574366004613cca565b610f9e565b6040516103fd9190613d1b565b34801561059257600080fd5b506103cc6105a1366004613d67565b611216565b3480156105b257600080fd5b506103cc6105c1366004613a2e565b611240565b3480156105d257600080fd5b506103cc6105e1366004613d67565b611263565b3480156105f257600080fd5b50610629610601366004613a2e565b6101676020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016103fd565b34801561065557600080fd5b506103cc610664366004613d97565b6112dd565b34801561067557600080fd5b506103cc611333565b6103cc61068c366004613d97565b611353565b34801561069d57600080fd5b5061012e546103e9906001600160a01b031681565b6103cc6106c0366004613ba0565b61135e565b3480156106d157600080fd5b5060975460ff16610426565b3480156106e957600080fd5b506103cc6106f8366004613dc3565b611368565b34801561070957600080fd5b506103cc610718366004613a2e565b611469565b34801561072957600080fd5b506104dc6101345481565b34801561074057600080fd5b506104dc600081565b34801561075557600080fd5b506103cc610764366004613a2e565b61148c565b34801561077557600080fd5b506103cc610784366004613e28565b6114af565b34801561079557600080fd5b506103e9610fff81565b3480156107ab57600080fd5b506104dc6107ba366004613a2e565b6001600160a01b0316600090815261019b602052604090205490565b3480156107e257600080fd5b506103e96107f1366004613a2e565b61012d602052600090815260409020546001600160a01b031681565b34801561081957600080fd5b506103cc6115f5565b34801561082e57600080fd5b506104dc61083d366004613a2e565b6101cf6020526000908152604090205481565b34801561085c57600080fd5b506103cc61086b366004613a2e565b611615565b34801561087c57600080fd5b50610131546103e9906001600160a01b031681565b34801561089d57600080fd5b506103cc6108ac366004613e9a565b611638565b3480156108bd57600080fd5b506103cc6108cc366004613a2e565b611705565b3480156108dd57600080fd5b506104266108ec366004613d67565b611728565b3480156108fd57600080fd5b50610168546104269060ff1681565b34801561091857600080fd5b506104dc61019c5481565b34801561092f57600080fd5b506103cc61093e366004613a2e565b611753565b34801561094f57600080fd5b506103cc6117fe565b34801561096457600080fd5b506104dc7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e98286981565b34801561099857600080fd5b50610130546103e9906001600160a01b031681565b3480156109b957600080fd5b506103cc6109c8366004613ed5565b61181e565b3480156109d957600080fd5b506103cc6109e8366004613ba0565b611837565b3480156109f957600080fd5b506104dc7f87a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f82181565b348015610a2d57600080fd5b506103cc610a3c366004613d67565b611858565b348015610a4d57600080fd5b506103cc610a5c366004613ba0565b61187d565b348015610a6d57600080fd5b506103e97f000000000000000000000000dda0d9448ebe3ea43afece5fa6401f5795c1933381565b348015610aa157600080fd5b50610133546103e9906001600160a01b031681565b348015610ac257600080fd5b506104dc60008051602061439683398151915281565b348015610ae457600080fd5b50610132546103e9906001600160a01b031681565b6103cc610b07366004613d97565b611971565b348015610b1857600080fd5b506104dc6000805160206143d683398151915281565b6103cc610b3c366004613f65565b61197b565b6103e9610b4f366004613a2e565b611986565b348015610b6057600080fd5b506104dc7f2cef46a936bdc5b7e6e8c71aa04560c41cf7d88bb26901a7e7f4936ff02accad81565b348015610b9457600080fd5b506103cc610ba3366004613a2e565b611999565b348015610bb457600080fd5b506104dc6000805160206143b683398151915281565b60006001600160e01b03198216637965db0b60e01b1480610bfb57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610c0c816119bc565b610c2460008051602061441683398151915283611216565b5050565b600054610100900460ff1615808015610c485750600054600160ff909116105b80610c625750303b158015610c62575060005460ff166001145b610cca5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610ced576000805461ff0019166101001790555b6001600160a01b038216610d145760405163d92e233d60e01b815260040160405180910390fd5b610d23898989898989896119c6565b610d2b611cb1565b610d436000805160206143f683398151915283611cbf565b8015610d89576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000805160206143f6833981519152610dac816119bc565b610db4611d45565b50565b6000610dc2816119bc565b610c246000805160206143b683398151915283611858565b6001600160a01b038316600090815261019b602052604090208054606091908367ffffffffffffffff811115610e1257610e12613a4b565b604051908082528060200260200182016040528015610e6457816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181610e305790505b50925060005b8351811015610f945781868683818110610e8657610e86613fa6565b9050602002013510610eeb57604051806080016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815250848281518110610edb57610edb613fa6565b6020026020010181905250610f82565b82868683818110610efe57610efe613fa6565b9050602002013581548110610f1557610f15613fa6565b600091825260209182902060408051608081018252600490930290910180546001600160a01b0390811684526001820154169383019390935260028301549082015260039091015460608201528451859083908110610f7657610f76613fa6565b60200260200101819052505b80610f8c81613fd2565b915050610e6a565b5050509392505050565b6001600160a01b038516600090815261019b602052604090206060908267ffffffffffffffff811115610fd357610fd3613a4b565b60405190808252806020026020018201604052801561102857816020015b61101560405180606001604052806000815260200160008152602001600081525090565b815260200190600190039081610ff15790505b5091506000808280549050861161103f5785611042565b82545b9050865b818110801561105457508583105b1561113657886001600160a01b031684828154811061107557611075613fa6565b60009182526020909120600160049092020101546001600160a01b0316036111245760405180606001604052808281526020018583815481106110ba576110ba613fa6565b90600052602060002090600402016002015481526020018583815481106110e3576110e3613fa6565b90600052602060002090600402016003015481525085848151811061110a5761110a613fa6565b6020026020010181905250828061112090613fd2565b9350505b8061112e81613fd2565b915050611046565b5084821461120a5760008267ffffffffffffffff81111561115957611159613a4b565b6040519080825280602002602001820160405280156111ae57816020015b61119b60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816111775790505b50905060005b83811015611206578581815181106111ce576111ce613fa6565b60200260200101518282815181106111e8576111e8613fa6565b602002602001018190525080806111fe90613fd2565b9150506111b4565b5093505b50505095945050505050565b600082815260656020526040902060010154611231816119bc565b61123b8383611cbf565b505050565b600061124b816119bc565b610c246000805160206143b683398151915283611216565b6001600160a01b03811633146112d35760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610cc1565b610c248282611d86565b6112e5611ded565b60008060006112f48585611e46565b6001600160a01b03808316600090815261012d60205260409020549396509194509250166113258382868986611ff7565b50505050610c24600160fb55565b6000805160206143b683398151915261134b816119bc565b610db46120e2565b610c2482338361212f565b610db4338261215b565b611370611ded565b6000819003611392576040516318301aa760e01b815260040160405180910390fd5b60008060005b8381101561142c576000806113c5898888868181106113b9576113b9613fa6565b90506020020135611e46565b919550925090506001600160a01b038083169089161461140b57604051632469ee5360e01b81526001600160a01b03808a16600483015283166024820152604401610cc1565b6114158186613feb565b94505050808061142490613fd2565b915050611398565b506001600160a01b03808616600090815261012d6020526040902054166114568682848a87611ff7565b505050611463600160fb55565b50505050565b6000611474816119bc565b610c2460008051602061441683398151915283611858565b6000611497816119bc565b610c246000805160206143d683398151915283611216565b6114b76121ca565b61012e546001600160a01b031633146114e35760405163122d54c760e11b815260040160405180910390fd5b602081116115255760405163180a097760e01b815260206004820152600e60248201526d11185d18481d1bdbc81cda1bdc9d60921b6044820152606401610cc1565b7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e982869611554602060008486613ffe565b61155d91614028565b036115ac57610c246115728260208186613ffe565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061221092505050565b60405163180a097760e01b815260206004820152601c60248201527f556e737570706f7274656420616374696f6e207369676e6174757265000000006044820152606401610cc1565b6000805160206143d683398151915261160d816119bc565b610db461230f565b6000611620816119bc565b610c2460008051602061439683398151915283611858565b6000805160206143f6833981519152611650816119bc565b6001600160a01b03851660009081526101676020908152604080832080546003909101546101cf90935292205461168888888861234c565b6001600160a01b03881660008181526101cf602090815260409182902088905581518a8152908101899052908101879052606081018590526080810184905260a081018390527f300bef0f21f43f60e0c1798e3095fc7583e6832358453bef5e5af765a7b53e3d9060c00160405180910390a25050505050505050565b6000611710816119bc565b610c2460008051602061439683398151915283611216565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60008051602061439683398151915261176b816119bc565b6001600160a01b0382166117925760405163d92e233d60e01b815260040160405180910390fd5b61012e54604080516001600160a01b03928316815291841660208301527f9f505d2f223df1f36d2bbc40c8817da20509a9722f3fc09d005bb9d5df154210910160405180910390a15061012e80546001600160a01b0319166001600160a01b0392909216919091179055565b6000805160206143f6833981519152611816816119bc565b610db46123eb565b60405163f0e2219760e01b815260040160405180910390fd5b6000805160206143f683398151915261184f816119bc565b610c2482612429565b600082815260656020526040902060010154611873816119bc565b61123b8383611d86565b600080516020614416833981519152611895816119bc565b811580159061190f5750610131546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156118e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190c9190614046565b82105b1561192d576040516308c4bd0b60e11b815260040160405180910390fd5b6101345460408051918252602082018490527f20f79e1e156e9d4acad9184b2d8283c178ddb9638463180bf2176285b77ab76b910160405180910390a15061013455565b610c24828261215b565b61123b83838361212f565b60006119906121ca565b610bfb8261246f565b60006119a4816119bc565b610c246000805160206143d683398151915283611858565b610db48133612711565b336001600160a01b037f000000000000000000000000dda0d9448ebe3ea43afece5fa6401f5795c193331614611a0f57604051630d622feb60e01b815260040160405180910390fd5b6001600160a01b0386161580611a2c57506001600160a01b038516155b80611a3e57506001600160a01b038416155b80611a5057506001600160a01b038316155b80611a6257506001600160a01b038216155b80611a75575086516001600160a01b0316155b80611a8b575060208701516001600160a01b0316155b80611aa1575060408701516001600160a01b0316155b80611ab7575060608701516001600160a01b0316155b80611acd575060808701516001600160a01b0316155b15611aeb5760405163d92e233d60e01b815260040160405180910390fd5b611af361276a565b611afb612791565b611b036127c0565b8651611b1190600090611cbf565b611b2d6000805160206143d68339815191528860200151611cbf565b611b496000805160206143b68339815191528860400151611cbf565b611b656000805160206144168339815191528860600151611cbf565b611b816000805160206143968339815191528860800151611cbf565b61012f80546001600160a01b038781166001600160a01b03199283161790925561013080548784169083168117909155610131805487851690841617905561013380549386169390921692909217905560405161077760611b6020820152611c11919060340160408051601f19818403018152919052805160209091012061012f546001600160a01b03166127ef565b61013280546001600160a01b03199081166001600160a01b039384161790915561012e805482169883169890981790975561013491909155610131548116600081815261012d602052604080822080548a169093179092557fad76b4044bfa734d1658e7587c3fd33991772c4284f450d12a829695b2e0bd048054610eee908a168117909155610133549093168152208054909616179094555050505050565b611cbd62015180612429565b565b611cc98282611728565b610c245760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611d013390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610168805460ff191690556040513381527fca830263c7c51a7fd39e6424d29d9e7a11ce1250e908ee0763c2c921d7a3022b906020015b60405180910390a1565b611d908282611728565b15610c245760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600260fb5403611e3f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610cc1565b600260fb55565b6001600160a01b038216600090815261019b60205260408120805482918291808610611e8f5760405163c0876ed360e01b81526004810182905260248101879052604401610cc1565b6000828781548110611ea357611ea3613fa6565b600091825260209091206004909102018054600182015460028301546001600160a01b039283169950911696509450905084611f045760405163373a67e760e21b81526001600160a01b038916600482015260248101889052604401610cc1565b600061019c548260030154611f199190613feb565b905080421015611f45576040516337c6546160e01b815242600482015260248101829052604401610cc1565b838881548110611f5757611f57613fa6565b60009182526020822060049091020180546001600160a01b03199081168255600182018054909116905560028101829055600301556040516001600160a01b038a811691898216918916907f3d7c245d695cceb19fe0fa394d673c860b810a04592fe5415e980c651bb81b9290611fe4908a9042908f909283526020830191909152604082015260600190565b60405180910390a4505050509250925092565b611fff6121ca565b610eed196001600160a01b038616016120705761201c828261284b565b604080516001600160a01b038581168252602082018490528085169290871691610eee917f4327909ba044fbe8b04a4d999929cd91a03b30ebfae467b54c16353a44660f43910160405180910390a46120d4565b6120846001600160a01b0386168383612964565b604080516001600160a01b038581168252602082018490528085169287821692918916917f6e90696e59c60d3ffd22a244d98b9d73dae6642f03b99cd4d3e5aa852121443b910160405180910390a45b5050505050565b600160fb55565b6120ea6129c7565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001611d7c565b610133546001600160a01b03908116908416036121505761123b8282612a10565b61123b838383612ad8565b8034101561217c5760405163044044a560e21b815260040160405180910390fd5b6000612188823461405f565b612192904761405f565b90506121a1610eee8484612c57565b80471461123b57604051637244981560e11b815247600482015260248101829052604401610cc1565b60975460ff1615611cbd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610cc1565b600080600080600061222186612f06565b9450945094509450945060006122378683612fe0565b905060008161225f57506001600160a01b03861660009081526101cf60205260409020548210155b6101685460ff16818061226f5750825b806122775750805b156123025761228885878a876130fb565b846001600160a01b0316866001600160a01b0316896001600160a01b03167fbdca490c3df14c1d2a133e5b1e2300a5086f2ddc3f90d5dc9ad1d50287df574b878688876040516122f594939291909384529115156020840152151560408301521515606082015260800190565b60405180910390a4610d89565b610d898888888888611ff7565b6123176121ca565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586121173390565b6001600160a01b0383166123735760405163c1ab6dc160e01b815260040160405180910390fd5b81600003612394576040516331278a8760e01b815260040160405180910390fd5b806000036123b557604051636cbcfbe360e11b815260040160405180910390fd5b6001600160a01b03831660009081526101676020526040812080549091036123df57600181018390555b91825560039091015550565b610168805460ff191660011790556040513381527fe6f871681d402a779a934141b5608fb6f3226c91b5fc9d24d93b7dc83e4aceb690602001611d7c565b61019c80549082905560408051838152602081018390527f9c3f1b54b1487e018f1d0593ff5cf7fb625b2df6332c974a6cc56bb358879841910160405180910390a15050565b60003460000361249257604051631d3e008d60e21b815260040160405180910390fd5b6001600160a01b0382166124b95760405163d92e233d60e01b815260040160405180910390fd5b610131546001600160a01b03908116908316036124e95760405163a9a43cf960e01b815260040160405180910390fd5b610eed196001600160a01b038316016125155760405163e9edc9b360e01b815260040160405180910390fd5b610133546001600160a01b0390811690831603612545576040516311eba7e360e01b815260040160405180910390fd5b6001600160a01b03828116600090815261012d6020526040902054161561257f57604051632a431ae760e11b815260040160405180910390fd5b61012f54610130546040516bffffffffffffffffffffffff19606086901b1660208201526001600160a01b03928316926000926125d89291169060340160405160208183030381529060405280519060200120846127ef565b6001600160a01b03858116600090815261012d6020526040812080546001600160a01b03191692841692909217909155909150808061261687613204565b92509250925060007f2cef46a936bdc5b7e6e8c71aa04560c41cf7d88bb26901a7e7f4936ff02accad888585856040516020016126579594939291906140c2565b60408051601f198184030181529082905261012e54637903aadd60e11b83529092506001600160a01b03169063f20755ba90349061269b9085903390600401614114565b6000604051808303818588803b1580156126b457600080fd5b505af11580156126c8573d6000803e3d6000fd5b50506040516001600160a01b03808a1694508c1692507fadbf4fee5f2ebdb59bcf27cd835d152ca7931a51cb921c5f8fdc43cf7c1f33049150600090a350929695505050505050565b61271b8282611728565b610c245761272881613390565b6127338360206133a2565b60405160200161274492919061413e565b60408051601f198184030181529082905262461bcd60e51b8252610cc1916004016141b3565b600054610100900460ff16611cbd5760405162461bcd60e51b8152600401610cc1906141c6565b600054610100900460ff166127b85760405162461bcd60e51b8152600401610cc1906141c6565b611cbd613545565b600054610100900460ff166127e75760405162461bcd60e51b8152600401610cc1906141c6565b611cbd613578565b60405160388101919091526f5af43d82803e903d91602b57fd5bf3ff60248201526014810192909252733d602d80600a3d3981f3363d3d373d3d3d363d73825260588201526037600c8201206078820152605560439091012090565b8047101561289b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610cc1565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146128e8576040519150601f19603f3d011682016040523d82523d6000602084013e6128ed565b606091505b505090508061123b5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610cc1565b6040516001600160a01b03831660248201526044810182905261123b90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261359f565b60975460ff16611cbd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610cc1565b6000612a1c8247613feb565b610133549091506001600160a01b0316612a3881333086613674565b61013354604051632e1a7d4d60e01b8152600481018590526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015612a7f57600080fd5b505af1158015612a93573d6000803e3d6000fd5b50505050814714612ac057604051637244981560e11b815247600482015260248101839052604401610cc1565b61013354611463906001600160a01b03168585612c57565b6040516370a0823160e01b815230600482015260009082906001600160a01b038616906370a0823190602401602060405180830381865afa158015612b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b459190614046565b612b4f9190613feb565b9050612b5c848484612c57565b6040516370a0823160e01b815230600482015281906001600160a01b038616906370a0823190602401602060405180830381865afa158015612ba2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc69190614046565b14611463576040516370a0823160e01b81523060048201526001600160a01b038516906370a0823190602401602060405180830381865afa158015612c0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c339190614046565b604051637244981560e11b8152600481019190915260248101829052604401610cc1565b612c5f611ded565b612c676121ca565b6101315461013454849183916001600160a01b0391821691841682148015612c8e57508015155b15612d28576040516370a0823160e01b8152306004820152819084906001600160a01b038516906370a0823190602401602060405180830381865afa158015612cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cff9190614046565b612d099190613feb565b1115612d285760405163cf79cc9b60e01b815260040160405180910390fd5b6001600160a01b0386161580612d4557506001600160a01b038716155b15612d635760405163d92e233d60e01b815260040160405180910390fd5b84600003612d8457604051631f2a200560e01b815260040160405180910390fd5b34600003612da557604051631d3e008d60e21b815260040160405180910390fd5b6001600160a01b03878116600090815261012d602052604090205416612dde57604051633a3c22ef60e11b815260040160405180910390fd5b610133546000906001600160a01b03898116911614612dfd5787612e01565b610eee5b604080517f87a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f82160208201526001600160a01b03838116828401523360608301528a8116608083015260a08083018b90528351808403909101815260c09092019092529192506000908a16610eee14612e785734612e82565b612e82883461405f565b61012e54604051637903aadd60e11b81529192506001600160a01b03169063f20755ba908390612eb89086903390600401614114565b6000604051808303818588803b158015612ed157600080fd5b505af1158015612ee5573d6000803e3d6000fd5b5050505050612ef58a8a8a6136ac565b5050505050505061123b600160fb55565b600080600080600085806020019051810190612f229190614211565b929750909450925090506001600160a01b038516612f535760405163d92e233d60e01b815260040160405180910390fd5b610131546001600160a01b0390811690861603612f7457610fff9350612fd7565b610eed196001600160a01b03861601612f9b57610132546001600160a01b03169350612fd7565b6001600160a01b03808616600090815261012d602052604090205416935083612fd757604051633a3c22ef60e11b815260040160405180910390fd5b91939590929450565b6001600160a01b038216600090815261016760205260408120805480830361305057846001600160a01b03167f63455daddfcbe1b76f2cf1d25b17dc8d8b54805d19a0a33035f2a9fb6178bf7d8560405161303d91815260200190565b60405180910390a2600192505050610bfb565b60008260030154836002015442613067919061405f565b6130719190614264565b83600101546130809190613feb565b4260028501559050818111156130935750805b8085106130df576040517f93634b349f9e42d781ffd65b7052280b7d3dd517717c267d448441b4716884cd90600090a1610168805460ff191660019081179091556000908401556130ef565b6130e9858261405f565b60018401555b50600095945050505050565b6001600160a01b03821661312d576040516329f8b6ed60e01b81526001600160a01b0385166004820152602401610cc1565b604080516080810182526001600160a01b0385811680835285821660208085018281528587018881524260608089018281528e8916600081815261019b88528c8120805460018082018355918352918990208d51600484029091018054918e166001600160a01b03199283161781559851918901805492909d16911617909a55935160028601555160039094019390935588518a815293840152968201859052949593947fdc3ff1d1a171333fabe1d0df7590fc79fe74e95fbbfe8aefff8b8c8961f4e02a910160405180910390a4505050505050565b60608060006060846001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561326a57506040513d6000823e601f3d908101601f19168201604052613267919081019061427b565b60015b61328757604051633dd1b30560e01b815260040160405180910390fd5b90506060856001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa9250505080156132ea57506040513d6000823e601f3d908101601f191682016040526132e7919081019061427b565b60015b61330757604051633dd1b30560e01b815260040160405180910390fd5b90506000866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613365575060408051601f3d908101601f191682019092526133629181019061431d565b60015b61338257604051633dd1b30560e01b815260040160405180910390fd5b929791965091945092505050565b6060610bfb6001600160a01b03831660145b606060006133b1836002614264565b6133bc906002613feb565b67ffffffffffffffff8111156133d4576133d4613a4b565b6040519080825280601f01601f1916602001820160405280156133fe576020820181803683370190505b509050600360fc1b8160008151811061341957613419613fa6565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061344857613448613fa6565b60200101906001600160f81b031916908160001a905350600061346c846002614264565b613477906001613feb565b90505b60018111156134ef576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106134ab576134ab613fa6565b1a60f81b8282815181106134c1576134c1613fa6565b60200101906001600160f81b031916908160001a90535060049490941c936134e881614340565b905061347a565b50831561353e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610cc1565b9392505050565b600054610100900460ff1661356c5760405162461bcd60e51b8152600401610cc1906141c6565b6097805460ff19169055565b600054610100900460ff166120db5760405162461bcd60e51b8152600401610cc1906141c6565b60006135f4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661385f9092919063ffffffff16565b90508051600014806136155750808060200190518101906136159190614357565b61123b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610cc1565b6040516001600160a01b03808516602483015283166044820152606481018290526114639085906323b872dd60e01b90608401612990565b610eed196001600160a01b03841601613715576101325460408051338152602081018490526001600160a01b0385811693811692908716917fd1b4e24e81f1c901551420568a9447fd105593af143ae8b096c6385e4fb7ec8691015b60405180910390a4505050565b610133546001600160a01b0390811690841603613779576101325460408051338152602081018490526001600160a01b0385811693811692908716917fa88fe860ecdd7b9e7311676f780fe08f0ed96990b74319e26ad505932d36890f9101613708565b610131546001600160a01b03908116908416036137ee5760408051338152602081018390526001600160a01b0380851692908616917f8294ebca1c2aada95b98b62a8d705ba5d7be4bdb75901d3f0eeb35062b706c79910160405180910390a361123b6001600160a01b038416333084613674565b6001600160a01b03838116600081815261012d6020908152604091829020548251338152918201869052868516941692917f3207f1f801a6ba9b6005cb9dc97d8498df3407dc7b1c7a644c7b57997f4f03c5910160405180910390a461123b6001600160a01b038416333084613674565b606061386e8484600085613876565b949350505050565b6060824710156138d75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610cc1565b600080866001600160a01b031685876040516138f39190614379565b60006040518083038185875af1925050503d8060008114613930576040519150601f19603f3d011682016040523d82523d6000602084013e613935565b606091505b509150915061394687838387613951565b979650505050505050565b606083156139c05782516000036139b9576001600160a01b0385163b6139b95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610cc1565b508161386e565b61386e83838151156139d55781518083602001fd5b8060405162461bcd60e51b8152600401610cc191906141b3565b600060208284031215613a0157600080fd5b81356001600160e01b03198116811461353e57600080fd5b6001600160a01b0381168114610db457600080fd5b600060208284031215613a4057600080fd5b813561353e81613a19565b634e487b7160e01b600052604160045260246000fd5b600060a08284031215613a7357600080fd5b60405160a0810181811067ffffffffffffffff82111715613a9657613a96613a4b565b6040529050808235613aa781613a19565b81526020830135613ab781613a19565b60208201526040830135613aca81613a19565b60408201526060830135613add81613a19565b60608201526080830135613af081613a19565b6080919091015292915050565b600080600080600080600080610180898b031215613b1a57600080fd5b613b248a8a613a61565b975060a0890135613b3481613a19565b965060c0890135613b4481613a19565b955060e0890135613b5481613a19565b9450610100890135613b6581613a19565b9350610120890135613b7681613a19565b92506101408901359150610160890135613b8f81613a19565b809150509295985092959890939650565b600060208284031215613bb257600080fd5b5035919050565b60008083601f840112613bcb57600080fd5b50813567ffffffffffffffff811115613be357600080fd5b6020830191508360208260051b8501011115613bfe57600080fd5b9250929050565b600080600060408486031215613c1a57600080fd5b8335613c2581613a19565b9250602084013567ffffffffffffffff811115613c4157600080fd5b613c4d86828701613bb9565b9497909650939450505050565b602080825282518282018190526000919060409081850190868401855b82811015613cbd57815180516001600160a01b03908116865287820151168786015285810151868601526060908101519085015260809093019290850190600101613c77565b5091979650505050505050565b600080600080600060a08688031215613ce257600080fd5b8535613ced81613a19565b94506020860135613cfd81613a19565b94979496505050506040830135926060810135926080909101359150565b602080825282518282018190526000919060409081850190868401855b82811015613cbd5781518051855286810151878601528501518585015260609093019290850190600101613d38565b60008060408385031215613d7a57600080fd5b823591506020830135613d8c81613a19565b809150509250929050565b60008060408385031215613daa57600080fd5b8235613db581613a19565b946020939093013593505050565b60008060008060608587031215613dd957600080fd5b8435613de481613a19565b93506020850135613df481613a19565b9250604085013567ffffffffffffffff811115613e1057600080fd5b613e1c87828801613bb9565b95989497509550505050565b60008060208385031215613e3b57600080fd5b823567ffffffffffffffff80821115613e5357600080fd5b818501915085601f830112613e6757600080fd5b813581811115613e7657600080fd5b866020828501011115613e8857600080fd5b60209290920196919550909350505050565b60008060008060808587031215613eb057600080fd5b8435613ebb81613a19565b966020860135965060408601359560600135945092505050565b6000806000806000806000610160888a031215613ef157600080fd5b613efb8989613a61565b965060a0880135613f0b81613a19565b955060c0880135613f1b81613a19565b945060e0880135613f2b81613a19565b9350610100880135613f3c81613a19565b9250610120880135613f4d81613a19565b80925050610140880135905092959891949750929550565b600080600060608486031215613f7a57600080fd5b8335613f8581613a19565b92506020840135613f9581613a19565b929592945050506040919091013590565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613fe457613fe4613fbc565b5060010190565b80820180821115610bfb57610bfb613fbc565b6000808585111561400e57600080fd5b8386111561401b57600080fd5b5050820193919092039150565b80356020831015610bfb57600019602084900360031b1b1692915050565b60006020828403121561405857600080fd5b5051919050565b81810381811115610bfb57610bfb613fbc565b60005b8381101561408d578181015183820152602001614075565b50506000910152565b600081518084526140ae816020860160208601614072565b601f01601f19169290920160200192915050565b8581526001600160a01b038516602082015260a0604082018190526000906140ec90830186614096565b82810360608401526140fe8186614096565b91505060ff831660808301529695505050505050565b6040815260006141276040830185614096565b905060018060a01b03831660208301529392505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614176816017850160208801614072565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516141a7816028840160208801614072565b01602801949350505050565b60208152600061353e6020830184614096565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000806000806080858703121561422757600080fd5b845161423281613a19565b602086015190945061424381613a19565b604086015190935061425481613a19565b6060959095015193969295505050565b8082028115828204841417610bfb57610bfb613fbc565b60006020828403121561428d57600080fd5b815167ffffffffffffffff808211156142a557600080fd5b818401915084601f8301126142b957600080fd5b8151818111156142cb576142cb613a4b565b604051601f8201601f19908116603f011681019083821181831017156142f3576142f3613a4b565b8160405282815287602084870101111561430c57600080fd5b613946836020830160208801614072565b60006020828403121561432f57600080fd5b815160ff8116811461353e57600080fd5b60008161434f5761434f613fbc565b506000190190565b60006020828403121561436957600080fd5b8151801515811461353e57600080fd5b6000825161438b818460208701614072565b919091019291505056fea6d0b532cacea090bc411482cd491720e2eac14d48ce5d0402b8851e0bb2aec182b32d9ab5100db08aeb9a0e08b422d14851ec118736590462bf9c085a6e9448539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14cdcd3beafca8a1012a37a08a8968959a8e9278fafc576974c99735b24d5d8ae0f5b94a8cd68affa84315f488cc2e6e456f761d334859cae8a073ef8fe13fb0ee6a264697066735822122062a5cae4376c09d167f3baee47aab68af10c1a210783a29e0f7afe9a4200f8eb64736f6c63430008130033

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

000000000000000000000000dda0d9448ebe3ea43afece5fa6401f5795c19333

-----Decoded View---------------
Arg [0] : _initializerAddress (address): 0xdDA0d9448Ebe3eA43aFecE5Fa6401F5795c19333

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000dda0d9448ebe3ea43afece5fa6401f5795c19333


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.