ETH Price: $3,164.17 (-7.45%)
Gas: 3 Gwei

Contract

0x333E885469d29F623681d8157A2Faad5bF4E3333
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

1 address found via
Transaction Hash
Method
Block
From
To
Sweep Tokens162965362022-12-30 8:56:47573 days ago1672390607IN
0x333E8854...5bF4E3333
0 ETH0.0004792315.3424782
Pause Execution162683812022-12-26 10:38:11577 days ago1672051091IN
0x333E8854...5bF4E3333
0 ETH0.000488810.37992885
Collect Gas Fee162614032022-12-25 11:16:59578 days ago1671967019IN
0x333E8854...5bF4E3333
0 ETH0.000362610.67372123
Transfer With Sw...162611792022-12-25 10:31:35578 days ago1671964295IN
0x333E8854...5bF4E3333
0.50463425 ETH0.0034847612.62541132
Transfer With Sw...162520262022-12-24 3:51:35579 days ago1671853895IN
0x333E8854...5bF4E3333
1.05647301 ETH0.0031788811.3239637
Transfer With Sw...162432272022-12-22 22:27:11580 days ago1671748031IN
0x333E8854...5bF4E3333
0.05437748 ETH0.0058079416.97796341
Set Integrator I...162378702022-12-22 4:31:59581 days ago1671683519IN
0x333E8854...5bF4E3333
0 ETH0.0006754114.0049315
Bridge With Swap162344962022-12-21 17:13:35582 days ago1671642815IN
0x333E8854...5bF4E3333
0.00235513 ETH0.0045537822.72043451
Transfer With Sw...162328532022-12-21 11:43:11582 days ago1671622991IN
0x333E8854...5bF4E3333
0.10237088 ETH0.0041078714.88333528
Transfer With Sw...162283732022-12-20 20:44:11582 days ago1671569051IN
0x333E8854...5bF4E3333
0.65210148 ETH0.0051825315
Set Integrator I...162247922022-12-20 8:44:23583 days ago1671525863IN
0x333E8854...5bF4E3333
0 ETH0.0004865315.63053505
Set Integrator I...162236982022-12-20 5:04:59583 days ago1671512699IN
0x333E8854...5bF4E3333
0 ETH0.0007038814.59518073
Set Fixed Crypto...162172002022-12-19 7:18:35584 days ago1671434315IN
0x333E8854...5bF4E3333
0 ETH0.0003947913.62718466
Transfer With Sw...162114762022-12-18 12:08:11585 days ago1671365291IN
0x333E8854...5bF4E3333
0.05118321 ETH0.0041531714.90404891
Bridge With Swap162072852022-12-17 22:05:35585 days ago1671314735IN
0x333E8854...5bF4E3333
0.00198518 ETH0.0040303820.39668084
Transfer With Sw...162066262022-12-17 19:51:59585 days ago1671306719IN
0x333E8854...5bF4E3333
0.05227363 ETH0.0057074516.49987586
Set Integrator I...161975792022-12-16 13:32:47587 days ago1671197567IN
0x333E8854...5bF4E3333
0 ETH0.0014484830.07212654
Bridge With Swap161947312022-12-16 4:00:11587 days ago1671163211IN
0x333E8854...5bF4E3333
0.00198533 ETH0.0025869713.09200284
Transfer With Sw...161946542022-12-16 3:44:47587 days ago1671162287IN
0x333E8854...5bF4E3333
1.00225863 ETH0.0042073714.41855258
Collect Gas Fee161912862022-12-15 16:28:11588 days ago1671121691IN
0x333E8854...5bF4E3333
0 ETH0.0012933538.07111589
Bridge With Swap161900702022-12-15 12:23:35588 days ago1671107015IN
0x333E8854...5bF4E3333
0.00196808 ETH0.0027155914.22979502
Transfer With Sw...161873202022-12-15 3:09:47588 days ago1671073787IN
0x333E8854...5bF4E3333
0.00227333 ETH0.0055177215.01863706
Transfer With Sw...161846202022-12-14 18:07:11588 days ago1671041231IN
0x333E8854...5bF4E3333
0.30199658 ETH0.0073258320.65944246
Transfer With Sw...161816342022-12-14 8:06:23589 days ago1671005183IN
0x333E8854...5bF4E3333
0.20198968 ETH0.0042005414.16672846
Transfer With Sw...161816312022-12-14 8:05:47589 days ago1671005147IN
0x333E8854...5bF4E3333
0.20198968 ETH0.0043940514.81788173
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
162965362022-12-30 8:56:47573 days ago1672390607
0x333E8854...5bF4E3333
0.12059075 ETH
162614032022-12-25 11:16:59578 days ago1671967019
0x333E8854...5bF4E3333
0.00733596 ETH
162611792022-12-25 10:31:35578 days ago1671964295
0x333E8854...5bF4E3333
0.0001218 ETH
162611792022-12-25 10:31:35578 days ago1671964295
0x333E8854...5bF4E3333
0.5 ETH
162520262022-12-24 3:51:35579 days ago1671853895
0x333E8854...5bF4E3333
0.0001218 ETH
162520262022-12-24 3:51:35579 days ago1671853895
0x333E8854...5bF4E3333
1.055 ETH
162432272022-12-22 22:27:11580 days ago1671748031
0x333E8854...5bF4E3333
0.00012225 ETH
162432272022-12-22 22:27:11580 days ago1671748031
0x333E8854...5bF4E3333
0.052 ETH
162344962022-12-21 17:13:35582 days ago1671642815
0x333E8854...5bF4E3333
0.0000999 ETH
162328532022-12-21 11:43:11582 days ago1671622991
0x333E8854...5bF4E3333
0.00011564 ETH
162328532022-12-21 11:43:11582 days ago1671622991
0x333E8854...5bF4E3333
0.1 ETH
162283732022-12-20 20:44:11582 days ago1671569051
0x333E8854...5bF4E3333
0.00012839 ETH
162283732022-12-20 20:44:11582 days ago1671569051
0x333E8854...5bF4E3333
0.65 ETH
162114762022-12-18 12:08:11585 days ago1671365291
0x333E8854...5bF4E3333
0.00011415 ETH
162114762022-12-18 12:08:11585 days ago1671365291
0x333E8854...5bF4E3333
0.05 ETH
162072852022-12-17 22:05:35585 days ago1671314735
0x333E8854...5bF4E3333
0.000117 ETH
162066262022-12-17 19:51:59585 days ago1671306719
0x333E8854...5bF4E3333
0.00012329 ETH
162066262022-12-17 19:51:59585 days ago1671306719
0x333E8854...5bF4E3333
0.05 ETH
161947312022-12-16 4:00:11587 days ago1671163211
0x333E8854...5bF4E3333
0.00011715 ETH
161946542022-12-16 3:44:47587 days ago1671162287
0x333E8854...5bF4E3333
0.0001083 ETH
161946542022-12-16 3:44:47587 days ago1671162287
0x333E8854...5bF4E3333
1 ETH
161912862022-12-15 16:28:11588 days ago1671121691
0x333E8854...5bF4E3333
0.01043963 ETH
161900702022-12-15 12:23:35588 days ago1671107015
0x333E8854...5bF4E3333
0.0000999 ETH
161873202022-12-15 3:09:47588 days ago1671073787
0x333E8854...5bF4E3333
0.000123 ETH
161846202022-12-14 18:07:11588 days ago1671041231
0x333E8854...5bF4E3333
0.0001284 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RubicRouterV2

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 36 : RubicRouterV2.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import './TransferSwapV2.sol';
import './TransferSwapV3.sol';
import './TransferSwapInch.sol';
import './BridgeSwap.sol';

contract RubicRouterV2 is TransferSwapV2, TransferSwapV3, TransferSwapInch, BridgeSwap {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    constructor(
        uint256 _fixedCryptoFee,
        uint256 _RubicPlatformFee,
        address[] memory _routers,
        address[] memory _tokens,
        uint256[] memory _minTokenAmounts,
        uint256[] memory _maxTokenAmounts,
        uint256[] memory _blockchainIDs,
        uint256[] memory _blockchainToGasFee,
        address _relayer,
        address _messageBus,
        address _nativeWrap
    ) {
        initialize(
            _fixedCryptoFee,
            _RubicPlatformFee,
            _routers,
            _tokens,
            _minTokenAmounts,
            _maxTokenAmounts,
            _blockchainIDs,
            _blockchainToGasFee
        );

        nativeWrap = _nativeWrap;
        messageBus = _messageBus;
        _setupRole(RELAYER_ROLE, _relayer);
    }

    function initialize(
        uint256 _fixedCryptoFee,
        uint256 _RubicPlatformFee,
        address[] memory _routers,
        address[] memory _tokens,
        uint256[] memory _minTokenAmounts,
        uint256[] memory _maxTokenAmounts,
        uint256[] memory _blockchainIDs,
        uint256[] memory _blockchainToGasFee
    ) private initializer {
        __WithDestinationFunctionalityInit(
            _fixedCryptoFee,
            _RubicPlatformFee,
            _routers,
            _tokens,
            _minTokenAmounts,
            _maxTokenAmounts,
            _blockchainIDs,
            _blockchainToGasFee
        );
    }

    /**
     * @notice called by MessageBus when the tokens are checked to be arrived at this contract's address.
               sends the amount received to the receiver. swaps beforehand if swap behavior is defined in message
     * NOTE: if the swap fails, it sends the tokens received directly to the receiver as fallback behavior
     * @param _token the address of the token sent through the bridge
     * @param _amount the amount of tokens received at this contract through the cross-chain bridge
     * @param _srcChainId source chain ID
     * @param _message SwapRequestDst message that defines the swap behavior on this destination chain
     */
    function executeMessageWithTransfer(
        address,
        address _token,
        uint256 _amount,
        uint64 _srcChainId,
        bytes calldata _message,
        address _relayer
    )
        external
        payable
        override
        onlyMessageBus
        nonReentrant
        whenNotPaused
        onlyRelayer(_relayer)
        returns (ExecutionStatus)
    {
        SwapRequestDest memory m = abi.decode((_message), (SwapRequestDest));
        bytes32 id = _computeSwapRequestId(m.swap.receiverEOA, _srcChainId, uint64(block.chainid), _message);

        _amount = accrueTokenFees(m.swap.integrator, integratorToFeeInfo[m.swap.integrator], _amount, 0, _token);

        address _outputToken = _retrieveDstTokenAddress(m.swap);

        if (m.swap.version == SwapVersion.v3) {
            _executeDstSwapV3(_token, _outputToken, _amount, id, m);
        } else if (m.swap.version == SwapVersion.bridge) {
            _executeDstBridge(_token, _amount, id, m);
        } else {
            _executeDstSwapV2(_token, _outputToken, _amount, id, m);
        }

        // always return true since swap failure is already handled in-place
        return ExecutionStatus.Success;
    }

    /**
     * @notice called by MessageBus when the executeMessageWithTransfer call fails. does nothing but emitting a "fail" event
     * @param _srcChainId source chain ID
     * @param _message SwapRequestDst message that defines the swap behavior on this destination chain
     * execution on dst chain
     */
    function executeMessageWithTransferFallback(
        address, // _sender
        address  _token,
        uint256 _amount,
        uint64 _srcChainId,
        bytes calldata _message,
        address _relayer
    ) external payable override onlyMessageBus nonReentrant onlyRelayer(_relayer) returns (ExecutionStatus) {
        SwapRequestDest memory m = abi.decode((_message), (SwapRequestDest));

        bytes32 id = _computeSwapRequestId(m.swap.receiverEOA, _srcChainId, uint64(block.chainid), _message);

        // collect data about failed cross-chain for manual refund
        refundDetails[id] = RefundData(m.swap.integrator, _token, _amount, m.swap.receiverEOA, m.swap.nativeOut);

        // Failed status means user hasn't received funds
        _afterTargetProcessing(id, _token, _amount, SwapStatus.Failed);
        // always return Fail to mark this transfer as failed since if this function is called then there nothing more
        // we can do in this app as the swap failures are already handled in executeMessageWithTransfer
        return ExecutionStatus.Fail;
    }

    // called on source chain for handling of bridge failures (bad liquidity, bad slippage, etc...)
    function executeMessageWithTransferRefund(
        address _token,
        uint256 _amount,
        bytes calldata _message,
        address _relayer
    )
        external
        payable
        override
        onlyMessageBus
        nonReentrant
        whenNotPaused
        onlyRelayer(_relayer)
        returns (ExecutionStatus)
    {
        SwapRequestDest memory m = abi.decode((_message), (SwapRequestDest));

        bytes32 id = _computeSwapRequestId(m.swap.receiverEOA, uint64(block.chainid), m.dstChainId, _message);

        _sendToken(_token, _amount, m.swap.receiverEOA, m.swap.nativeOut);

        _afterTargetProcessing(id, _token, _amount, SwapStatus.Fallback);

        return ExecutionStatus.Success;
    }

    // no need to swap, directly send the bridged token to user
    function _executeDstBridge(
        address _inputToken,
        uint256 _amount,
        bytes32 _id,
        SwapRequestDest memory _msgDst
    ) private {
        _sendToken(_inputToken, _amount, _msgDst.swap.receiverEOA, _msgDst.swap.nativeOut);

        _afterTargetProcessing(_id, _inputToken, _amount, SwapStatus.Succeeded);
    }

    function _executeDstSwapV2(
        address _inputToken,
        address _outputToken,
        uint256 _amount,
        bytes32 _id,
        SwapRequestDest memory _msgDst
    ) private isTransit(_inputToken, _msgDst.swap.path[0]) {
        SwapInfoV2 memory _dstSwap = SwapInfoV2({
            dex: _msgDst.swap.dex,
            path: _msgDst.swap.path,
            deadline: _msgDst.swap.deadline,
            amountOutMinimum: _msgDst.swap.amountOutMinimum
        });

        (bool success, uint256 dstAmount) = _trySwapV2(_dstSwap, _amount);
        if (success) {
            _sendToken(_outputToken, dstAmount, _msgDst.swap.receiverEOA, _msgDst.swap.nativeOut);
            _afterTargetProcessing(_id, _outputToken, dstAmount, SwapStatus.Succeeded);
        } else {
            // handle swap failure, send the received token directly to receiver
            _sendToken(_inputToken, _amount, _msgDst.swap.receiverEOA, _msgDst.swap.nativeOut);
            _afterTargetProcessing(_id, _inputToken, _amount, SwapStatus.Fallback);
        }
    }

    function _executeDstSwapV3(
        address _inputToken,
        address _outputToken,
        uint256 _amount,
        bytes32 _id,
        SwapRequestDest memory _msgDst
    ) private isTransit(_inputToken, address(_getFirstBytes20(_msgDst.swap.pathV3))) {
       SwapInfoV3 memory _dstSwap = SwapInfoV3({
            dex: _msgDst.swap.dex,
            path: _msgDst.swap.pathV3,
            deadline: _msgDst.swap.deadline,
            amountOutMinimum: _msgDst.swap.amountOutMinimum
        });

        (bool success, uint256 dstAmount) = _trySwapV3(_dstSwap, _amount);
        if (success) {
            _sendToken(_outputToken, dstAmount, _msgDst.swap.receiverEOA, _msgDst.swap.nativeOut);
            _afterTargetProcessing(_id, _outputToken, dstAmount, SwapStatus.Succeeded);
        } else {
            // handle swap failure, send the received token directly to receiver
            _sendToken(_inputToken, _amount, _msgDst.swap.receiverEOA, _msgDst.swap.nativeOut);
            _afterTargetProcessing(_id, _inputToken, _amount, SwapStatus.Fallback);
        }
    }

    function _sendToken(
        address _token,
        uint256 _amount,
        address _receiver,
        bool _nativeOut
    ) private {
        if (_token == nativeWrap && _nativeOut == true) {
            IWETH(nativeWrap).withdraw(_amount);
            sendToken(address(0), _amount, _receiver);
        } else {
            sendToken(_token, _amount, _receiver);
        }
    }

    function _afterTargetProcessing(
        bytes32 _id,
        address _token,
        uint256 _amount,
        SwapStatus _status
    ) private {
        processedTransactions[_id] = _status;
        emit CrossChainProcessed(_id, _token, _amount, _status);
    }

    function sweepTokens(address _token, uint256 _amount) external onlyAdmin {
        sendToken(_token, _amount, msg.sender);
    }

    function manualRefund(bytes32 _id) external nonReentrant onlyManagerOrAdmin {
        SwapStatus _status = processedTransactions[_id];
        require(_status != SwapStatus.Succeeded && _status != SwapStatus.Fallback);

        RefundData memory refundParams = refundDetails[_id];

        uint256 _amount = accrueTokenFees(
            refundParams.integrator,
            integratorToFeeInfo[refundParams.integrator],
            refundParams.amount,
            0,
            refundParams.token
        );

        _sendToken(refundParams.token, _amount, refundParams.to, refundParams.nativeOut);
        processedTransactions[_id] = SwapStatus.Fallback;
    }

    function setNativeWrap(address _nativeWrap) external onlyManagerOrAdmin {
        nativeWrap = _nativeWrap;
    }

    function setMessageBus(address _messageBus) external onlyManagerOrAdmin {
        messageBus = _messageBus;
        emit MessageBusUpdated(messageBus);
    }
}

File 2 of 36 : TransferSwapV2.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import './SwapBase.sol';
import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';

contract TransferSwapV2 is SwapBase {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    function transferWithSwapV2Native(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoV2 calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecksNative(_amountIn, _dstChainId, _dstSwap.integrator, _srcSwap.path[0]);

        _swapAndSendMessageV2(
            _receiver,
            _amountIn,
            _dstChainId,
            _srcSwap,
            _dstSwap,
            _maxBridgeSlippage,
            _fee,
            _srcSwap.path[_srcSwap.path.length - 1]
        );
    }

    function transferWithSwapV2(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoV2 calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecks(_amountIn, _dstChainId, _dstSwap.integrator, _srcSwap.path[0]);

        _swapAndSendMessageV2(
            _receiver,
            _amountIn,
            _dstChainId,
            _srcSwap,
            _dstSwap,
            _maxBridgeSlippage,
            _fee,
            _srcSwap.path[_srcSwap.path.length - 1]
        );
    }

    /**
     * @notice Sends a cross-chain transfer via the liquidity pool-based bridge and sends a message specifying a wanted swap action on the
               destination chain via the message bus
     * @param _receiver the app contract that implements the MessageReceiver abstract contract
     *        NOTE not to be confused with the receiver field in SwapInfoV2 which is an EOA address of a user
     * @param _amountIn the input amount that the user wants to swap and/or bridge
     * @param _dstChainId destination chain ID
     * @param _srcSwap a struct containing swap related requirements
     * @param _dstSwap a struct containing swap related requirements
     * @param _maxBridgeSlippage the max acceptable slippage at bridge, given as percentage in point (pip). Eg. 5000 means 0.5%.
     *        Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the
     *        transfer can be refunded.
     * @param _fee the fee to pay to MessageBus.
     */
    function _swapAndSendMessageV2(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoV2 calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage,
        uint256 _fee,
        address _outputToken
    ) private {
        BaseCrossChainParams memory _baseParams = BaseCrossChainParams(
            _srcSwap.path[0],
            _amountIn,
            _dstChainId,
            _retrieveDstTokenAddress(_dstSwap),
            _dstSwap.amountOutMinimum,
            msg.sender,
            _dstSwap.integrator,
            _srcSwap.dex
        );

        require(_srcSwap.path.length > 1, 'empty swap path');

        (bool success, uint256 srcAmtOut) = _trySwapV2(_srcSwap, _amountIn);

        bytes32 id = _sendMessage(
            _receiver,
            uint64(_baseParams.dstChainID),
            _dstSwap,
            _maxBridgeSlippage,
            _beforeSwapAndSendMessage(),
            _fee,
            _outputToken,
            srcAmtOut,
            success
        );

        emit CrossChainRequestSent(id, _baseParams);
    }

    function _trySwapV2(SwapInfoV2 memory _swap, uint256 _amount) internal returns (bool ok, uint256 amountOut) {
        if (!availableRouters.contains(_swap.dex)) {
            return (false, 0);
        }

        SmartApprove.smartApprove(_swap.path[0], _amount, _swap.dex);

        try
            IUniswapV2Router02(_swap.dex).swapExactTokensForTokens(
                _amount,
                _swap.amountOutMinimum,
                _swap.path,
                address(this),
                _swap.deadline
            )
        returns (uint256[] memory amounts) {
            return (true, amounts[amounts.length - 1]);
        } catch {
            return (false, 0);
        }
    }
}

File 3 of 36 : TransferSwapV3.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import './SwapBase.sol';
import '../../interfaces/IUniswapRouterV3.sol';

contract TransferSwapV3 is SwapBase {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    function transferWithSwapV3Native(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoV3 calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecksNative(_amountIn, _dstChainId, _dstSwap.integrator, address(_getFirstBytes20(_srcSwap.path)));

        _swapAndSendMessageV3(
            _receiver,
            _amountIn,
            _dstChainId,
            _srcSwap,
            _dstSwap,
            _maxBridgeSlippage,
            _fee,
            address(_getLastBytes20(_srcSwap.path))
        );
    }

    function transferWithSwapV3(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoV3 calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecks(_amountIn, _dstChainId, _dstSwap.integrator, address(_getFirstBytes20(_srcSwap.path)));

        _swapAndSendMessageV3(
            _receiver,
            _amountIn,
            _dstChainId,
            _srcSwap,
            _dstSwap,
            _maxBridgeSlippage,
            _fee,
            address(_getLastBytes20(_srcSwap.path))
        );
    }

    /**
     * @notice Sends a cross-chain transfer via the liquidity pool-based bridge and sends a message specifying a wanted swap action on the
               destination chain via the message bus
     * @param _receiver the app contract that implements the MessageReceiver abstract contract
     *        NOTE not to be confused with the receiver field in SwapInfoV3 which is an EOA address of a user
     * @param _amountIn the input amount that the user wants to swap and/or bridge
     * @param _dstChainId destination chain ID
     * @param _srcSwap a struct containing swap related requirements
     * @param _dstSwap a struct containing swap related requirements
     * @param _maxBridgeSlippage the max acceptable slippage at bridge, given as percentage in point (pip). Eg. 5000 means 0.5%.
     *        Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the
     *        transfer can be refunded.
     * @param _fee the fee to pay to MessageBus.
     */
    function _swapAndSendMessageV3(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoV3 calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage,
        uint256 _fee,
        address srcOutputToken
    ) private {
        BaseCrossChainParams memory _baseParams = BaseCrossChainParams(
            address(_getFirstBytes20(_srcSwap.path)),
            _amountIn,
            _dstChainId,
            _retrieveDstTokenAddress(_dstSwap),
            _dstSwap.amountOutMinimum,
            msg.sender,
            _dstSwap.integrator,
            _srcSwap.dex
        );

        require(_srcSwap.path.length > 20, 'empty swap path');

        (bool success, uint256 srcAmtOut) = _trySwapV3(_srcSwap, _amountIn);

        bytes32 id = _sendMessage(
            _receiver,
            uint64(_baseParams.dstChainID),
            _dstSwap,
            _maxBridgeSlippage,
            _beforeSwapAndSendMessage(), // TODO rename
            _fee,
            srcOutputToken,
            srcAmtOut,
            success
        );

        emit CrossChainRequestSent(id, _baseParams);
    }

    function _trySwapV3(SwapInfoV3 memory _swap, uint256 _amount) internal returns (bool ok, uint256 amountOut) {
        if (!availableRouters.contains(_swap.dex)) {
            return (false, 0);
        }

        SmartApprove.smartApprove(address(_getFirstBytes20(_swap.path)), _amount, _swap.dex);

        IUniswapRouterV3.ExactInputParams memory paramsV3 = IUniswapRouterV3.ExactInputParams(
            _swap.path,
            address(this),
            _swap.deadline,
            _amount,
            _swap.amountOutMinimum
        );

        try IUniswapRouterV3(_swap.dex).exactInput(paramsV3) returns (uint256 _amountOut) {
            return (true, _amountOut);
        } catch {
            return (false, 0);
        }
    }
}

File 4 of 36 : TransferSwapInch.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import './SwapBase.sol';

contract TransferSwapInch is SwapBase {

    using AddressUpgradeable for address payable;
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    function transferWithSwapInchNative(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoInch calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecksNative(_amountIn, _dstChainId, _dstSwap.integrator, _srcSwap.path[0]);

        _swapAndSendMessageInch(
            _receiver,
            _amountIn,
            _dstChainId,
            _srcSwap,
            _dstSwap,
            _maxBridgeSlippage,
            _fee,
            _srcSwap.path[_srcSwap.path.length - 1]
        );
    }

    function transferWithSwapInch(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoInch calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecks(_amountIn, _dstChainId, _dstSwap.integrator, _srcSwap.path[0]);

        _swapAndSendMessageInch(
            _receiver,
            _amountIn,
            _dstChainId,
            _srcSwap,
            _dstSwap,
            _maxBridgeSlippage,
            _fee,
            _srcSwap.path[_srcSwap.path.length - 1]
        );
    }

    /**
     * @notice Sends a cross-chain transfer via the liquidity pool-based bridge and sends a message specifying a wanted swap action on the
               destination chain via the message bus
     * @param _receiver the app contract that implements the MessageReceiver abstract contract
     *        NOTE not to be confused with the receiver field in SwapInfoInch which is an EOA address of a user
     * @param _amountIn the input amount that the user wants to swap and/or bridge
     * @param _dstChainId destination chain ID
     * @param _srcSwap a struct containing swap related requirements
     * @param _dstSwap a struct containing swap related requirements
     * @param _maxBridgeSlippage the max acceptable slippage at bridge, given as percentage in point (pip). Eg. 5000 means 0.5%.
     *        Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the
     *        transfer can be refunded.
     * @param _fee the fee to pay to MessageBus.
     */
    function _swapAndSendMessageInch(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        SwapInfoInch calldata _srcSwap,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage,
        uint256 _fee,
        address srcOutputToken
    ) private {
        BaseCrossChainParams memory _baseParams = BaseCrossChainParams(
            _srcSwap.path[0],
            _amountIn,
            _dstChainId,
            _retrieveDstTokenAddress(_dstSwap),
            _dstSwap.amountOutMinimum,
            msg.sender,
            _dstSwap.integrator,
            _srcSwap.dex
        );

        require(_srcSwap.path.length > 1, 'empty swap path');

        (bool success, uint256 srcAmtOut) = _trySwapInch(_srcSwap, _amountIn);

        bytes32 id = _sendMessage(
            _receiver,
            uint64(_baseParams.dstChainID),
            _dstSwap,
            _maxBridgeSlippage,
            _beforeSwapAndSendMessage(),
            _fee,
            srcOutputToken,
            srcAmtOut,
            success
        );

        emit CrossChainRequestSent(id, _baseParams);
    }

    function _trySwapInch(SwapInfoInch memory _swap, uint256 _amount) internal returns (bool ok, uint256 amountOut) {
        if (!availableRouters.contains(_swap.dex)) {
            return (false, 0);
        }

        SmartApprove.smartApprove(_swap.path[0], _amount, _swap.dex);

        IERC20Upgradeable Transit = IERC20Upgradeable(_swap.path[_swap.path.length - 1]);
        uint256 transitBalanceBefore = Transit.balanceOf(address(this));

        AddressUpgradeable.functionCall(_swap.dex, _swap.data);

        uint256 balanceDif = Transit.balanceOf(address(this)) - transitBalanceBefore;

        if (balanceDif >= _swap.amountOutMinimum) {
            return (true, balanceDif);
        }

        return (false, 0);
    }
}

File 5 of 36 : BridgeSwap.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import './SwapBase.sol';

contract BridgeSwap is SwapBase {

    function bridgeWithSwapNative(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        address _srcBridgeToken,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecksNative(_amountIn, _dstChainId, _dstSwap.integrator, _srcBridgeToken);

        _sendBridgeMessage(_receiver, _dstChainId, _srcBridgeToken, _dstSwap, _maxBridgeSlippage, _fee, _amountIn);
    }

    function bridgeWithSwap(
        address _receiver,
        uint256 _amountIn,
        uint64 _dstChainId,
        address _srcBridgeToken,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage
    ) external payable {
        uint256 _fee = _deriveFeeAndPerformChecks(_amountIn, _dstChainId, _dstSwap.integrator, _srcBridgeToken);

        _sendBridgeMessage(_receiver, _dstChainId, _srcBridgeToken, _dstSwap, _maxBridgeSlippage, _fee, _amountIn);
    }

    function _sendBridgeMessage(
        address _receiver,
        uint64 _dstChainId,
        address _srcBridgeToken,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage,
        uint256 _fee,
        uint256 _amountIn
    ) private {
        BaseCrossChainParams memory _baseParams = BaseCrossChainParams(
            _srcBridgeToken,
            _amountIn,
            _dstChainId,
            _retrieveDstTokenAddress(_dstSwap),
            _dstSwap.amountOutMinimum,
            _dstSwap.receiverEOA,
            _dstSwap.integrator,
            address(0)
        );

        require(_baseParams.dstChainID != uint64(block.chainid), 'same chain id');

        bytes32 id = _sendMessage(
            _receiver,
            uint64(_baseParams.dstChainID),
            _dstSwap,
            _maxBridgeSlippage,
            _beforeSwapAndSendMessage(),
            _fee,
            _baseParams.srcInputToken,
            _baseParams.srcInputAmount,
            true
        );

        emit CrossChainRequestSent(id, _baseParams);
    }
}

File 6 of 36 : SwapBase.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import 'rubic-bridge-base/contracts/architecture/WithDestinationFunctionality.sol';

import 'rubic-bridge-base/contracts/libraries/SmartApprove.sol';

import '../framework/MessageSenderApp.sol';
import '../../interfaces/IWETH.sol';

contract SwapBase is MessageSenderApp, WithDestinationFunctionality {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    address public nativeWrap;
    uint64 public nonce;

    mapping(bytes32 => RefundData) public refundDetails;

    modifier isTransit(address _transitToken, address _tokenInPath) {
        checkIsTransit(_transitToken, _tokenInPath);
        _;
    }

    // ============== struct for refunds ==============

    struct RefundData {
        address integrator; // integrator address in order to take commission
        address token; // transit token
        uint256 amount; // amount of transit token
        address to; // recipient
        bool nativeOut; // receive wrapped/native
    }

    // ============== struct for V2 like dexes ==============

    struct SwapInfoV2 {
        address dex; // the DEX to use for the swap
        // if this array has only one element, it means no need to swap
        address[] path;
        // the following fields are only needed if path.length > 1
        uint256 deadline; // deadline for the swap
        uint256 amountOutMinimum; // minimum receive amount for the swap
    }

    // ============== struct for V3 like dexes ==============

    struct SwapInfoV3 {
        address dex; // the DEX to use for the swap
        bytes path;
        uint256 deadline;
        uint256 amountOutMinimum;
    }

    // ============== struct for inch swap ==============

    struct SwapInfoInch {
        address dex;
        // path is tokenIn, tokenOut
        address[] path;
        bytes data;
        uint256 amountOutMinimum;
    }

    // ============== struct dstSwap ==============
    // This is needed to make v2 -> SGN -> v3 swaps and etc.

    struct SwapInfoDest {
        address dex; // dex address
        bool nativeOut;
        address receiverEOA; // EOA recipient in dst chain
        address integrator;
        SwapVersion version; // identifies swap type
        address[] path; // path address for v2 and inch
        bytes pathV3; // path address for v3
        uint256 deadline; // for v2 and v3
        uint256 amountOutMinimum;
    }

    struct SwapRequestDest {
        SwapInfoDest swap;
        uint64 nonce;
        uint64 dstChainId;
    }

    enum SwapVersion {
        v2,
        v3,
        bridge
    }

    // ============== common checks for src swaps ==============

    function _deriveFeeAndPerformChecksNative(
        uint256 _amountIn,
        uint64 _dstChainId,
        address _integrator,
        address srcInputToken
    ) internal onlyEOA whenNotPaused returns (uint256 _fee) {
        require(srcInputToken == nativeWrap, 'token mismatch');
        require(msg.value >= _amountIn, 'amount insufficient');
        IWETH(nativeWrap).deposit{value: _amountIn}();

        _fee = accrueFixedAndGasFees(_integrator, integratorToFeeInfo[_integrator], _dstChainId) - _amountIn;
    }

    function _deriveFeeAndPerformChecks(
        uint256 _amountIn,
        uint64 _dstChainId,
        address _integrator,
        address srcInputToken
    ) internal onlyEOA whenNotPaused returns (uint256 _fee) {
        IERC20Upgradeable(srcInputToken).safeTransferFrom(msg.sender, address(this), _amountIn);

        _fee = accrueFixedAndGasFees(_integrator, integratorToFeeInfo[_integrator], _dstChainId);
    }

    // ============== Celer call ==============

    function _sendMessage(
        address _receiver,
        uint64 _dstChainId,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage,
        uint64 _nonce,
        uint256 _fee,
        address _srcOutputToken,
        uint256 _srcAmtOut,
        bool _success
    ) internal returns (bytes32 id) {
        if (!_success) revert('src swap failed');

        require(_srcAmtOut >= minTokenAmount[_srcOutputToken], 'less than min');
        if (maxTokenAmount[_srcOutputToken] > 0) {
            require(_srcAmtOut <= maxTokenAmount[_srcOutputToken], 'greater than max');
        }

        id = _crossChainTransferWithSwap(
            _receiver,
            _dstChainId,
            _dstSwap,
            _maxBridgeSlippage,
            _nonce,
            _fee,
            _srcOutputToken,
            _srcAmtOut
        );
    }

    function _crossChainTransferWithSwap(
        address _receiver,
        uint64 _dstChainId,
        SwapInfoDest calldata _dstSwap,
        uint32 _maxBridgeSlippage,
        uint64 _nonce,
        uint256 _fee,
        address srcOutputToken,
        uint256 srcAmtOut
    ) private returns (bytes32 id) {
        // todo increment nonce in compute ...
        require(_dstSwap.path.length > 0, 'empty dst swap path');
        bytes memory message = abi.encode(
            SwapRequestDest({swap: _dstSwap, nonce: nonce, dstChainId: _dstChainId})
        );
        id = _computeSwapRequestId(_dstSwap.receiverEOA, uint64(block.chainid), _dstChainId, message);

        sendMessageWithTransfer(
            _receiver,
            srcOutputToken,
            srcAmtOut,
            _dstChainId,
            _nonce,
            _maxBridgeSlippage,
            message,
            _fee
        );
    }

    // ============== Utilities ==============

    function _beforeSwapAndSendMessage() internal returns (uint64) {
        return ++nonce;
    }

    function _retrieveDstTokenAddress(SwapInfoDest memory _swapInfo) internal pure returns (address) {
        if (_swapInfo.version == SwapVersion.v3) {
            require(_swapInfo.pathV3.length > 20, 'dst swap expected');

            return address(_getLastBytes20(_swapInfo.pathV3));
        } else if (_swapInfo.version == SwapVersion.v2) {
            require(_swapInfo.path.length > 1, 'dst swap expected');

            return _swapInfo.path[_swapInfo.path.length - 1];
        } else {
            require(_swapInfo.path.length == 1, 'dst bridge expected');
            return _swapInfo.path[0];
        }
    }

    // returns address of first token for V3
    function _getFirstBytes20(bytes memory input) internal pure returns (bytes20 result) {
        assembly {
            result := mload(add(input, 32))
        }
    }

    // returns address of tokenOut for V3
    function _getLastBytes20(bytes memory input) internal pure returns (bytes20 result) {
        uint256 offset = input.length + 12;
        assembly {
            result := mload(add(input, offset))
        }
    }

    function _computeSwapRequestId(
        address _receiverEOA,
        uint64 _srcChainId,
        uint64 _dstChainId,
        bytes memory _message
    ) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(_receiverEOA, _srcChainId, _dstChainId, _message));
    }

    /**
     * @dev Function to check if the address in path is transit token received from Celer
     */
    function checkIsTransit(address _transitToken, address _tokenInPath) internal pure {
        require(_transitToken == _tokenInPath, 'first token must be transit');
    }
}

File 7 of 36 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 8 of 36 : WithDestinationFunctionality.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import '../BridgeBase.sol';

contract WithDestinationFunctionality is BridgeBase {
    enum SwapStatus {
        Null,
        Succeeded,
        Failed,
        Fallback
    }

    event CrossChainRequestSent(bytes32 indexed id, BaseCrossChainParams parameters);
    event CrossChainProcessed(bytes32 indexed id, address outputTokenAddress, uint256 amount, SwapStatus status);

    mapping(bytes32 => SwapStatus) public processedTransactions;

    mapping(uint256 => uint256) public blockchainToGasFee;

    uint256 public availableRubicGasFee;

    bytes32 public constant RELAYER_ROLE = keccak256('RELAYER_ROLE');

    modifier onlyRelayer(address _relayer) {
        checkIsRelayer(_relayer);
        _;
    }

    function __WithDestinationFunctionalityInit(
        uint256 _fixedCryptoFee,
        uint256 _RubicPlatformFee,
        address[] memory _routers,
        address[] memory _tokens,
        uint256[] memory _minTokenAmounts,
        uint256[] memory _maxTokenAmounts,
        uint256[] memory _blockchainIDs,
        uint256[] memory _blockchainToGasFee
    ) internal onlyInitializing {
        __BridgeBaseInit(_fixedCryptoFee, _RubicPlatformFee, _routers, _tokens, _minTokenAmounts, _maxTokenAmounts);

        uint256 length = _blockchainIDs.length;
        if (_blockchainToGasFee.length != length) {
            revert LengthMismatch();
        }

        for (uint256 i; i < length; ) {
            blockchainToGasFee[_blockchainIDs[i]] = _blockchainToGasFee[i];

            unchecked {
                ++i;
            }
        }
    }

    /**
     * @dev Calculates and accrues gas fee and fixed crypto fee
     * @param _integrator Integrator's address if there is one
     * @param _info A struct with integrator fee info
     * @param _blockchainID ID of the target blockchain
     * @return _amountWithoutCryptoFee The msg.value without gasFee and fixed crypto fee
     */
    function accrueFixedAndGasFees(
        address _integrator,
        IntegratorFeeInfo memory _info,
        uint256 _blockchainID
    ) internal returns (uint256 _amountWithoutCryptoFee) {
        uint256 _gasFee = blockchainToGasFee[_blockchainID];
        availableRubicGasFee += _gasFee;

        _amountWithoutCryptoFee = accrueFixedCryptoFee(_integrator, _info) - _gasFee;
    }

    /// FEE MANAGEMENT ///

    /**
     * @dev Changes crypto tokens values for blockchains in blockchainCryptoFee variables
     * @param _blockchainID ID of the blockchain
     * @param _gasFee Fee amount of native token that must be sent in init call
     */
    function setGasFeeOfBlockchain(uint256 _blockchainID, uint256 _gasFee) external onlyManagerOrAdmin {
        blockchainToGasFee[_blockchainID] = _gasFee;
    }

    function collectGasFee(address _to) external onlyManagerOrAdmin {
        uint256 _gasFee = availableRubicGasFee;
        availableRubicGasFee = 0;
        sendToken(address(0), _gasFee, _to);
    }

    /// TX STATUSES MANAGEMENT ///

    /**
     * @dev Function changes values associated with certain originalTxHash
     * @param _id ID of the transaction to change
     * @param _statusCode Associated status
     */
    function changeTxStatus(bytes32 _id, SwapStatus _statusCode) external onlyManagerOrAdmin {
        if (_statusCode == SwapStatus.Null) {
            revert CantSetToNull();
        }

        SwapStatus _status = processedTransactions[_id];

        if (_status == SwapStatus.Succeeded || _status == SwapStatus.Fallback) {
            revert Unchangeable();
        }

        processedTransactions[_id] = _statusCode;
    }

    /**
     * @dev Function to check if address is belongs to relayer role
     */
    function checkIsRelayer(address _relayer) internal view {
        if (!hasRole(RELAYER_ROLE, _relayer)) {
            revert NotARelayer();
        }
    }

}

File 9 of 36 : SmartApprove.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import '@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';

import '../errors/Errors.sol';

library SmartApprove {
    using SafeERC20Upgradeable for IERC20Upgradeable;

    function smartApprove(
        address _tokenIn,
        uint256 _amount,
        address _to
    ) internal {
        IERC20Upgradeable tokenIn = IERC20Upgradeable(_tokenIn);
        uint256 _allowance = tokenIn.allowance(address(this), _to);
        if (_allowance < _amount) {
            if (_allowance == 0) {
                tokenIn.safeApprove(_to, type(uint256).max);
            } else {
                try tokenIn.approve(_to, type(uint256).max) returns (bool res) {
                    if (!res) {
                        revert ApproveFailed();
                    }
                } catch {
                    tokenIn.safeApprove(_to, 0);
                    tokenIn.safeApprove(_to, type(uint256).max);
                }
            }
        }
    }
}

File 10 of 36 : MessageSenderApp.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import '../libraries/MsgDataTypes.sol';
import '../libraries/MessageSenderLib.sol';

import './MessageReceiverApp.sol';

abstract contract MessageSenderApp is MessageReceiverApp {

    // ============== Utility functions called by apps ==============

    /**
     * @notice Sends a message associated with a transfer to a contract on another chain.
     * @param _receiver The address of the destination app contract.
     * @param _token The address of the token to be sent.
     * @param _amount The amount of tokens to be sent.
     * @param _dstChainId The destination chain ID.
     * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.
     * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.
     *        Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least
     *        (100% - max slippage percentage) * amount or the transfer can be refunded.
     *        Only applicable to the {MsgDataTypes.BridgeSendType.Liquidity}.
     * @param _message Arbitrary message bytes to be decoded by the destination app contract.
     *        If message is empty, only the token transfer will be sent
     * param _bridgeSendType One of the {BridgeSendType} enum.
     * @param _fee The fee amount to pay to MessageBus.
     * @return The transfer ID.
     */
    function sendMessageWithTransfer(
        address _receiver,
        address _token,
        uint256 _amount,
        uint64 _dstChainId,
        uint64 _nonce,
        uint32 _maxSlippage,
        bytes memory _message,
        uint256 _fee
    ) internal returns (bytes32) {
        return
            MessageSenderLib.sendMessageWithTransfer(
                _receiver,
                _token,
                _amount,
                _dstChainId,
                _nonce,
                _maxSlippage,
                _message,
                messageBus,
                _fee
            );
    }
}

File 11 of 36 : IWETH.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

interface IWETH {
    function deposit() external payable;

    function withdraw(uint256) external;
}

File 12 of 36 : BridgeBase.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';

import './libraries/FullMath.sol';

import './errors/Errors.sol';

contract BridgeBase is AccessControlUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable {
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    // Denominator for setting fees
    uint256 internal constant DENOMINATOR = 1e6;

    bytes32 public constant MANAGER_ROLE = keccak256('MANAGER_ROLE');

    // Struct with all info about integrator fees
    mapping(address => IntegratorFeeInfo) public integratorToFeeInfo;
    // Amount of collected fees in native token integrator -> native fees
    mapping(address => uint256) public availableIntegratorCryptoFee;

    // token -> minAmount for swap
    mapping(address => uint256) public minTokenAmount;
    // token -> maxAmount for swap
    mapping(address => uint256) public maxTokenAmount;

    // token -> rubic collected fees
    mapping(address => uint256) public availableRubicTokenFee;
    // token -> integrator collected fees
    mapping(address => mapping(address => uint256)) public availableIntegratorTokenFee;

    // Rubic token fee
    uint256 public RubicPlatformFee;
    // Rubic fixed fee for swap
    uint256 public fixedCryptoFee;
    // Collected rubic fees in native token
    uint256 public availableRubicCryptoFee;

    // AddressSet of whitelisted addresses
    EnumerableSetUpgradeable.AddressSet internal availableRouters;

    event FixedCryptoFee(uint256 RubicPart, uint256 integratorPart, address indexed integrator);
    event FixedCryptoFeeCollected(uint256 amount, address collector);
    event TokenFee(uint256 RubicPart, uint256 integratorPart, address indexed integrator, address token);
    event IntegratorTokenFeeCollected(uint256 amount, address indexed integrator, address token);
    event RubicTokenFeeCollected(uint256 amount, address token);

    struct IntegratorFeeInfo {
        bool isIntegrator; // flag for setting 0 fees for integrator      - 1 byte
        uint32 tokenFee; // total fee percent gathered from user          - 4 bytes
        uint32 RubicTokenShare; // token share of platform commission     - 4 bytes
        uint32 RubicFixedCryptoShare; // native share of fixed commission - 4 bytes
        uint128 fixedFeeAmount; // custom fixed fee amount                - 16 bytes
    } //                                                            total - 29 bytes <= 32 bytes

    struct BaseCrossChainParams {
        address srcInputToken;
        uint256 srcInputAmount;
        uint256 dstChainID;
        address dstOutputToken;
        uint256 dstMinOutputAmount;
        address recipient;
        address integrator;
        address router;
    }

    // reference to https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3347/
    modifier onlyAdmin() {
        checkIsAdmin();
        _;
    }

    modifier onlyManagerOrAdmin() {
        checkIsManagerOrAdmin();
        _;
    }

    modifier onlyEOA() {
        if (msg.sender != tx.origin) {
            revert OnlyEOA();
        }
        _;
    }

    function __BridgeBaseInit(
        uint256 _fixedCryptoFee,
        uint256 _RubicPlatformFee,
        address[] memory _routers,
        address[] memory _tokens,
        uint256[] memory _minTokenAmounts,
        uint256[] memory _maxTokenAmounts
    ) internal onlyInitializing {
        __Pausable_init_unchained();

        fixedCryptoFee = _fixedCryptoFee;

        if (_RubicPlatformFee > DENOMINATOR) {
            revert FeeTooHigh();
        }

        RubicPlatformFee = _RubicPlatformFee;

        uint256 routerLength = _routers.length;
        for (uint256 i; i < routerLength; ) {
            availableRouters.add(_routers[i]);
            unchecked {
                ++i;
            }
        }

        uint256 tokensLength = _tokens.length;
        for (uint256 i; i < tokensLength; ) {
            if (_minTokenAmounts[i] > _maxTokenAmounts[i]) {
                revert MinMustBeLowerThanMax();
            }
            minTokenAmount[_tokens[i]] = _minTokenAmounts[i];
            maxTokenAmount[_tokens[i]] = _maxTokenAmounts[i];
            unchecked {
                ++i;
            }
        }

        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /**
     * @dev Calculates and accrues fixed crypto fee
     * @param _integrator Integrator's address if there is one
     * @param _info A struct with integrator fee info
     * @return The msg.value without fixedCryptoFee
     */
    function accrueFixedCryptoFee(address _integrator, IntegratorFeeInfo memory _info) internal returns (uint256) {
        uint256 _fixedCryptoFee;
        uint256 _RubicPart;
        if (_info.isIntegrator) {
            _fixedCryptoFee = uint256(_info.fixedFeeAmount);

            if (_fixedCryptoFee > 0) {
               _RubicPart = (_fixedCryptoFee * _info.RubicFixedCryptoShare) / DENOMINATOR;

                availableIntegratorCryptoFee[_integrator] += _fixedCryptoFee - _RubicPart;
            }
        } else {
            _fixedCryptoFee = fixedCryptoFee;
            _RubicPart = _fixedCryptoFee;
        }

        availableRubicCryptoFee += _RubicPart;

        emit FixedCryptoFee(_RubicPart, _fixedCryptoFee - _RubicPart, _integrator);

        // Underflow is prevented by sol 0.8
        return (msg.value - _fixedCryptoFee);
    }

    /**
     * @dev Calculates token fees and accrues them
     * @param _integrator Integrator's address if there is one
     * @param _info A struct with fee info about integrator
     * @param _amountWithFee Total amount passed by the user
     * @param _token The token in which the fees are collected
     * @param _initBlockchainNum Used if the _calculateFee is overriden by
     * WithDestinationFunctionality, otherwise is ignored
     * @return Amount of tokens without fee
     */
    function accrueTokenFees(
        address _integrator,
        IntegratorFeeInfo memory _info,
        uint256 _amountWithFee,
        uint256 _initBlockchainNum,
        address _token
    ) internal returns (uint256) {
        (uint256 _totalFees, uint256 _RubicFee) = _calculateFee(_info, _amountWithFee, _initBlockchainNum);

        if (_integrator != address(0)) {
            availableIntegratorTokenFee[_token][_integrator] += _totalFees - _RubicFee;
        }
        availableRubicTokenFee[_token] += _RubicFee;

        emit TokenFee(_RubicFee, _totalFees - _RubicFee, _integrator, _token);

        return _amountWithFee - _totalFees;
    }

    /**
     * @dev Calculates fee amount for integrator and rubic, used in architecture
     * @param _amountWithFee the users initial amount
     * @param _info the struct with data about integrator
     * @return _totalFee the amount of Rubic + integrator fee
     * @return _RubicFee the amount of Rubic fee only
     */
    function _calculateFeeWithIntegrator(uint256 _amountWithFee, IntegratorFeeInfo memory _info)
        internal
        pure
        returns (uint256 _totalFee, uint256 _RubicFee)
    {
        if (_info.tokenFee > 0) {
            _totalFee = FullMath.mulDiv(_amountWithFee, _info.tokenFee, DENOMINATOR);

            _RubicFee = FullMath.mulDiv(_totalFee, _info.RubicTokenShare, DENOMINATOR);
        }
    }

    function _calculateFee(
        IntegratorFeeInfo memory _info,
        uint256 _amountWithFee,
        uint256
    ) internal view returns (uint256 _totalFee, uint256 _RubicFee) {
        if (_info.isIntegrator) {
            (_totalFee, _RubicFee) = _calculateFeeWithIntegrator(_amountWithFee, _info);
        } else {
            _totalFee = FullMath.mulDiv(_amountWithFee, RubicPlatformFee, DENOMINATOR);

            _RubicFee = _totalFee;
        }
    }

    /// COLLECT FUNCTIONS ///

    function _collectIntegrator(address _integrator, address _token) private {
        uint256 _amount;

        if (_token == address(0)) {
            _amount = availableIntegratorCryptoFee[_integrator];
            availableIntegratorCryptoFee[_integrator] = 0;
            emit FixedCryptoFeeCollected(_amount, _integrator);
        }

        _amount += availableIntegratorTokenFee[_token][_integrator];

        if (_amount == 0) {
            revert ZeroAmount();
        }

        availableIntegratorTokenFee[_token][_integrator] = 0;

        sendToken(_token, _amount, _integrator);

        emit IntegratorTokenFeeCollected(_amount, _integrator, _token);
    }

    /**
     * @dev Integrator can collect fees calling this function
     * @param _token The token to collect fees in
     */
    function collectIntegratorFee(address _token) external nonReentrant {
        _collectIntegrator(msg.sender, _token);
    }

    /**
     * @dev Managers can collect integrator's fees calling this function
     * Fees go to the integrator
     * @param _integrator Address of the integrator
     * @param _token The token to collect fees in
     */
    function collectIntegratorFee(address _integrator, address _token) external onlyManagerOrAdmin {
        _collectIntegrator(_integrator, _token);
    }

    /**
     * @dev Calling this function managers can collect Rubic's token fee
     * @param _token The token to collect fees in
     */
    function collectRubicFee(address _token) external onlyManagerOrAdmin {
        uint256 _amount = availableRubicTokenFee[_token];
        if (_amount == 0) {
            revert ZeroAmount();
        }

        availableRubicTokenFee[_token] = 0;
        sendToken(_token, _amount, msg.sender);

        emit RubicTokenFeeCollected(_amount, _token);
    }

    /**
     * @dev Calling this function managers can collect Rubic's fixed crypto fee
     */
    function collectRubicCryptoFee() external onlyManagerOrAdmin {
        uint256 _cryptoFee = availableRubicCryptoFee;
        availableRubicCryptoFee = 0;

        sendToken(address(0), _cryptoFee, msg.sender);

        emit FixedCryptoFeeCollected(_cryptoFee, msg.sender);
    }

    /// CONTROL FUNCTIONS ///

    function pauseExecution() external onlyManagerOrAdmin {
        _pause();
    }

    function unpauseExecution() external onlyManagerOrAdmin {
        _unpause();
    }

    /**
     * @dev Sets fee info associated with an integrator
     * @param _integrator Address of the integrator
     * @param _info Struct with fee info
     */
    function setIntegratorInfo(address _integrator, IntegratorFeeInfo memory _info) external onlyManagerOrAdmin {
        if (_info.tokenFee > DENOMINATOR) {
            revert FeeTooHigh();
        }
        if (_info.RubicTokenShare > DENOMINATOR || _info.RubicFixedCryptoShare > DENOMINATOR) {
            revert ShareTooHigh();
        }

        integratorToFeeInfo[_integrator] = _info;
    }

    /**
     * @dev Sets fixed crypto fee
     * @param _fixedCryptoFee Fixed crypto fee
     */
    function setFixedCryptoFee(uint256 _fixedCryptoFee) external onlyManagerOrAdmin {
        fixedCryptoFee = _fixedCryptoFee;
    }

    function setRubicPlatformFee(uint256 _platformFee) external onlyManagerOrAdmin {
        if (_platformFee > DENOMINATOR) {
            revert FeeTooHigh();
        }

        RubicPlatformFee = _platformFee;
    }

    /**
     * @dev Changes requirement for minimal token amount on transfers
     * @param _token The token address to setup
     * @param _minTokenAmount Amount of tokens
     */
    function setMinTokenAmount(address _token, uint256 _minTokenAmount) external onlyManagerOrAdmin {
        if (_minTokenAmount > maxTokenAmount[_token]) {
            // can be equal in case we want them to be zero
            revert MinMustBeLowerThanMax();
        }
        minTokenAmount[_token] = _minTokenAmount;
    }

    /**
     * @dev Changes requirement for maximum token amount on transfers
     * @param _token The token address to setup
     * @param _maxTokenAmount Amount of tokens
     */
    function setMaxTokenAmount(address _token, uint256 _maxTokenAmount) external onlyManagerOrAdmin {
        if (_maxTokenAmount < minTokenAmount[_token]) {
            // can be equal in case we want them to be zero
            revert MaxMustBeBiggerThanMin();
        }
        maxTokenAmount[_token] = _maxTokenAmount;
    }

    /**
     * @dev Appends new available router
     * @param _router Router's address to add
     */
    function addAvailableRouter(address _router) external onlyManagerOrAdmin {
        if (_router == address(0)) {
            revert ZeroAddress();
        }
        // Check that router exists is performed inside the library
        availableRouters.add(_router);
    }

    /**
     * @dev Removes existing available router
     * @param _router Router's address to remove
     */
    function removeAvailableRouter(address _router) external onlyManagerOrAdmin {
        // Check that router exists is performed inside the library
        availableRouters.remove(_router);
    }

    /**
     * @dev Transfers admin role
     * @param _newAdmin New admin's address
     */
    function transferAdmin(address _newAdmin) external onlyAdmin {
        _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(DEFAULT_ADMIN_ROLE, _newAdmin);
    }

    /// VIEW FUNCTIONS ///

    /**
     * @return Available routers
     */
    function getAvailableRouters() external view returns (address[] memory) {
        return availableRouters.values();
    }

    /**
     * @notice Used in modifiers
     * @dev Function to check if address is belongs to manager or admin role
     */
    function checkIsManagerOrAdmin() internal view {
        if (!(hasRole(MANAGER_ROLE, msg.sender) || hasRole(DEFAULT_ADMIN_ROLE, msg.sender))) {
            revert NotAManager();
        }
    }

    /**
     * @notice Used in modifiers
     * @dev Function to check if address is belongs to default admin role
     */
    function checkIsAdmin() internal view {
        if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
            revert NotAnAdmin();
        }
    }

    function sendToken(
        address _token,
        uint256 _amount,
        address _receiver
    ) internal virtual {
        if (_token == address(0)) {
            AddressUpgradeable.sendValue(payable(_receiver), _amount);
        } else {
            IERC20Upgradeable(_token).safeTransfer(_receiver, _amount);
        }
    }

    /**
     * @dev Plain fallback function to receive native
     */
    receive() external payable {}

    /**
     * @dev Plain fallback function
     */
    fallback() external {}
}

File 13 of 36 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

    /**
     * @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(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

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

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * 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 14 of 36 : 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 15 of 36 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable 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));
    }

    function safeIncreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20PermitUpgradeable 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(IERC20Upgradeable 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");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 16 of 36 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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 17 of 36 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

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

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }
}

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

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

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

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

    uint256 private _status;

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

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

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

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

        _;

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

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

File 19 of 36 : FullMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = a * b
            // Compute the product mod 2**256 and mod 2**256 - 1
            // then 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(a, b, not(0))
                prod0 := mul(a, b)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division
            if (prod1 == 0) {
                require(denominator > 0);
                assembly {
                    result := div(prod0, denominator)
                }
                return result;
            }

            // Make sure the result is less than 2**256.
            // Also prevents denominator == 0
            require(denominator > prod1);

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

            // Make division exact by subtracting the remainder from [prod1 prod0]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly {
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator
            // Compute largest power of two divisor of denominator.
            // Always >= 1.
            uint256 twos = (0 - denominator) & denominator;
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly {
                prod0 := div(prod0, twos)
            }
            // Shift in bits from prod1 into prod0. For this we need
            // to flip `twos` such that it is 2**256 / twos.
            // If twos is zero, then it becomes one
            assembly {
                twos := add(div(sub(0, twos), twos), 1)
            }
            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
            // correct for four bits. That is, denominator * inv = 1 mod 2**4
            uint256 inv = (3 * denominator) ^ 2;
            // Now use 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.
            inv *= 2 - denominator * inv; // inverse mod 2**8
            inv *= 2 - denominator * inv; // inverse mod 2**16
            inv *= 2 - denominator * inv; // inverse mod 2**32
            inv *= 2 - denominator * inv; // inverse mod 2**64
            inv *= 2 - denominator * inv; // inverse mod 2**128
            inv *= 2 - denominator * inv; // 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 precoditions 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 * inv;
            return result;
        }
    }
}

File 20 of 36 : Errors.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

error NotAnAdmin();
error NotAManager();
error NotARelayer();
error OnlyEOA();
error FeeTooHigh();
error ShareTooHigh();
error ZeroAddress();
error ZeroAmount();
error InefficientFixedFee();
error ApproveFailed();
error MinMustBeLowerThanMax();
error MaxMustBeBiggerThanMin();
error CantSetToNull();
error Unchangeable();
error LengthMismatch();

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

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_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) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

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

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

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

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

File 24 of 36 : 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 25 of 36 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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]
 * ```
 * 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. Equivalent to `reinitializer(1)`.
     */
    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.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so 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.
     *
     * 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.
     */
    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.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

File 26 of 36 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 28 of 36 : draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 IERC20PermitUpgradeable {
    /**
     * @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 29 of 36 : MsgDataTypes.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

library MsgDataTypes {
    // bridge operation type at the sender side (src chain)
    enum BridgeSendType {
        Null,
        Liquidity,
        PegDeposit,
        PegBurn,
        PegV2Deposit,
        PegV2Burn,
        PegV2BurnFrom
    }

    // bridge operation type at the receiver side (dst chain)
    enum TransferType {
        Null,
        LqRelay, // relay through liquidity bridge
        LqWithdraw, // withdraw from liquidity bridge
        PegMint, // mint through pegged token bridge
        PegWithdraw, // withdraw from original token vault
        PegV2Mint, // mint through pegged token bridge v2
        PegV2Withdraw // withdraw from original token vault v2
    }

    enum MsgType {
        MessageWithTransfer,
        MessageOnly
    }

    enum TxStatus {
        Null,
        Success,
        Fail,
        Fallback,
        Pending // transient state within a transaction
    }

    struct TransferInfo {
        TransferType t;
        address sender;
        address receiver;
        address token;
        uint256 amount;
        uint64 wdseq; // only needed for LqWithdraw (refund)
        uint64 srcChainId;
        bytes32 refId;
        bytes32 srcTxHash; // src chain msg tx hash
    }

    struct RouteInfo {
        address sender;
        address receiver;
        uint64 srcChainId;
        bytes32 srcTxHash; // src chain msg tx hash
    }

    struct MsgWithTransferExecutionParams {
        bytes message;
        TransferInfo transfer;
        bytes[] sigs;
        address[] signers;
        uint256[] powers;
    }

    struct BridgeTransferParams {
        bytes request;
        bytes[] sigs;
        address[] signers;
        uint256[] powers;
    }
}

File 30 of 36 : MessageSenderLib.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import 'rubic-bridge-base/contracts/libraries/SmartApprove.sol';

import '../../interfaces/IBridge.sol';
import '../../interfaces/IMessageBus.sol';

import './MsgDataTypes.sol';

library MessageSenderLib {

    // ============== Internal library functions called by apps ==============

    /**
     * @notice Sends a message associated with a transfer to a contract on another chain.
     * @param _receiver The address of the destination app contract.
     * @param _token The address of the token to be sent.
     * @param _amount The amount of tokens to be sent.
     * @param _dstChainId The destination chain ID.
     * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.
     * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.
     *        Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least
     *        (100% - max slippage percentage) * amount or the transfer can be refunded.
     *        Only applicable to the {MsgDataTypes.BridgeSendType.Liquidity}.
     * @param _message Arbitrary message bytes to be decoded by the destination app contract.
     *        If message is empty, only the token transfer will be sent
     * param _bridgeSendType One of the {MsgDataTypes.BridgeSendType} enum.
     * @param _messageBus The address of the MessageBus on this chain.
     * @param _fee The fee amount to pay to MessageBus.
     * @return The transfer ID.
     */
    function sendMessageWithTransfer(
        address _receiver,
        address _token,
        uint256 _amount,
        uint64 _dstChainId,
        uint64 _nonce,
        uint32 _maxSlippage,
        bytes memory _message,
        address _messageBus,
        uint256 _fee
    ) internal returns (bytes32) {
        return
            sendMessageWithLiquidityBridgeTransfer(
                _receiver,
                _token,
                _amount,
                _dstChainId,
                _nonce,
                _maxSlippage,
                _message,
                _messageBus,
                _fee
            );
    }

    /**
     * @notice Sends a message to an app on another chain via MessageBus with an associated liquidity bridge transfer.
     * @param _receiver The address of the destination app contract.
     * @param _token The address of the token to be sent.
     * @param _amount The amount of tokens to be sent.
     * @param _dstChainId The destination chain ID.
     * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.
     * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.
     *        Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least
     *        (100% - max slippage percentage) * amount or the transfer can be refunded.
     * @param _message Arbitrary message bytes to be decoded by the destination app contract.
     *        If message is empty, only the token transfer will be sent
     * @param _messageBus The address of the MessageBus on this chain.
     * @param _fee The fee amount to pay to MessageBus.
     * @return The transfer ID.
     */
    function sendMessageWithLiquidityBridgeTransfer(
        address _receiver,
        address _token,
        uint256 _amount,
        uint64 _dstChainId,
        uint64 _nonce,
        uint32 _maxSlippage,
        bytes memory _message,
        address _messageBus,
        uint256 _fee
    ) internal returns (bytes32) {
        address bridge = IMessageBus(_messageBus).liquidityBridge();
        SmartApprove.smartApprove(_token, _amount, bridge);
        IBridge(bridge).send(_receiver, _token, _amount, _dstChainId, _nonce, _maxSlippage);
        bytes32 transferId = keccak256(
            abi.encodePacked(address(this), _receiver, _token, _amount, _dstChainId, _nonce, uint64(block.chainid))
        );
        if (_message.length > 0) {
            IMessageBus(_messageBus).sendMessageWithTransfer{value: _fee}(
                _receiver,
                _dstChainId,
                bridge,
                transferId,
                _message
            );
        }
        return transferId;
    }
}

File 31 of 36 : MessageReceiverApp.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import '../../interfaces/IMessageReceiverApp.sol';

abstract contract MessageReceiverApp is IMessageReceiverApp {

    address public messageBus;
    event MessageBusUpdated(address messageBus);

    modifier onlyMessageBus() {
        checkIsMessageBus();
        _;
    }

    function checkIsMessageBus() internal view {
        require(msg.sender == messageBus, 'caller is not message bus');
    }

    /**
     * @notice Called by MessageBus (MessageBusReceiver) if the process is originated from MessageBus (MessageBusSender)'s
     *         sendMessageWithTransfer it is only called when the tokens are checked to be arrived at this contract's address.
     * @param _sender The address of the source app contract
     * @param _token The address of the token that comes out of the bridge
     * @param _amount The amount of tokens received at this contract through the cross-chain bridge.
     *        the contract that implements this contract can safely assume that the tokens will arrive before this
     *        function is called.
     * @param _srcChainId The source chain ID where the transfer is originated from
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessageWithTransfer(
        address _sender,
        address _token,
        uint256 _amount,
        uint64 _srcChainId,
        bytes calldata _message,
        address _executor
    ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}

    /**
     * @notice Only called by MessageBus (MessageBusReceiver) if
     *         1. executeMessageWithTransfer reverts, or
     *         2. executeMessageWithTransfer returns ExecutionStatus.Fail
     * @param _sender The address of the source app contract
     * @param _token The address of the token that comes out of the bridge
     * @param _amount The amount of tokens received at this contract through the cross-chain bridge.
     *        the contract that implements this contract can safely assume that the tokens will arrive before this
     *        function is called.
     * @param _srcChainId The source chain ID where the transfer is originated from
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessageWithTransferFallback(
        address _sender,
        address _token,
        uint256 _amount,
        uint64 _srcChainId,
        bytes calldata _message,
        address _executor
    ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}

    /**
     * @notice Called by MessageBus (MessageBusReceiver) to process refund of the original transfer from this contract
     * @param _token The token address of the original transfer
     * @param _amount The amount of the original transfer
     * @param _message The same message associated with the original transfer
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessageWithTransferRefund(
        address _token,
        uint256 _amount,
        bytes calldata _message,
        address _executor
    ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}

    /**
     * @notice Called by MessageBus (MessageBusReceiver)
     * @param _sender The address of the source app contract
     * @param _srcChainId The source chain ID where the transfer is originated from
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessage(
        address _sender,
        uint64 _srcChainId,
        bytes calldata _message,
        address _executor
    ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}
}

File 32 of 36 : IBridge.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

interface IBridge {
    function send(
        address _receiver,
        address _token,
        uint256 _amount,
        uint64 _dstChainId,
        uint64 _nonce,
        uint32 _maxSlippage
    ) external;

    function relay(
        bytes calldata _relayRequest,
        bytes[] calldata _sigs,
        address[] calldata _signers,
        uint256[] calldata _powers
    ) external;

    function transfers(bytes32 transferId) external view returns (bool);

    function withdraws(bytes32 withdrawId) external view returns (bool);

    function withdraw(
        bytes calldata _wdmsg,
        bytes[] calldata _sigs,
        address[] calldata _signers,
        uint256[] calldata _powers
    ) external;

    /**
     * @notice Verifies that a message is signed by a quorum among the signers.
     * @param _msg signed message
     * @param _sigs list of signatures sorted by signer addresses in ascending order
     * @param _signers sorted list of current signers
     * @param _powers powers of current signers
     */
    function verifySigs(
        bytes memory _msg,
        bytes[] calldata _sigs,
        address[] calldata _signers,
        uint256[] calldata _powers
    ) external view;
}

File 33 of 36 : IMessageBus.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

import '../message/libraries/MsgDataTypes.sol';

interface IMessageBus {
    function liquidityBridge() external view returns (address);

    function pegBridge() external view returns (address);

    function pegBridgeV2() external view returns (address);

    function pegVault() external view returns (address);

    function pegVaultV2() external view returns (address);

    /**
     * @notice Calculates the required fee for the message.
     * @param _message Arbitrary message bytes to be decoded by the destination app contract.
     @ @return The required fee.
     */
    function calcFee(bytes calldata _message) external view returns (uint256);

    /**
     * @notice Sends a message to a contract on another chain.
     * Sender needs to make sure the uniqueness of the message Id, which is computed as
     * hash(type.MessageOnly, sender, receiver, srcChainId, srcTxHash, dstChainId, message).
     * If messages with the same Id are sent, only one of them will succeed at dst chain..
     * A fee is charged in the native gas token.
     * @param _receiver The address of the destination app contract.
     * @param _dstChainId The destination chain ID.
     * @param _message Arbitrary message bytes to be decoded by the destination app contract.
     */
    function sendMessage(
        address _receiver,
        uint256 _dstChainId,
        bytes calldata _message
    ) external payable;

    /**
     * @notice Sends a message associated with a transfer to a contract on another chain.
     * If messages with the same srcTransferId are sent, only one of them will succeed at dst chain..
     * A fee is charged in the native token.
     * @param _receiver The address of the destination app contract.
     * @param _dstChainId The destination chain ID.
     * @param _srcBridge The bridge contract to send the transfer with.
     * @param _srcTransferId The transfer ID.
     * @param _dstChainId The destination chain ID.
     * @param _message Arbitrary message bytes to be decoded by the destination app contract.
     */
    function sendMessageWithTransfer(
        address _receiver,
        uint256 _dstChainId,
        address _srcBridge,
        bytes32 _srcTransferId,
        bytes calldata _message
    ) external payable;

    /**
     * @notice Withdraws message fee in the form of native gas token.
     * @param _account The address receiving the fee.
     * @param _cumulativeFee The cumulative fee credited to the account. Tracked by SGN.
     * @param _sigs The list of signatures sorted by signing addresses in ascending order. A withdrawal must be
     * signed-off by +2/3 of the sigsVerifier's current signing power to be delivered.
     * @param _signers The sorted list of signers.
     * @param _powers The signing powers of the signers.
     */
    function withdrawFee(
        address _account,
        uint256 _cumulativeFee,
        bytes[] calldata _sigs,
        address[] calldata _signers,
        uint256[] calldata _powers
    ) external;

    /**
     * @notice Execute a message with a successful transfer.
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _transfer The transfer info.
     * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by
     * +2/3 of the sigsVerifier's current signing power to be delivered.
     * @param _signers The sorted list of signers.
     * @param _powers The signing powers of the signers.
     */
    function executeMessageWithTransfer(
        bytes calldata _message,
        MsgDataTypes.TransferInfo calldata _transfer,
        bytes[] calldata _sigs,
        address[] calldata _signers,
        uint256[] calldata _powers
    ) external payable;

    /**
     * @notice Execute a message with a refunded transfer.
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _transfer The transfer info.
     * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by
     * +2/3 of the sigsVerifier's current signing power to be delivered.
     * @param _signers The sorted list of signers.
     * @param _powers The signing powers of the signers.
     */
    function executeMessageWithTransferRefund(
        bytes calldata _message, // the same message associated with the original transfer
        MsgDataTypes.TransferInfo calldata _transfer,
        bytes[] calldata _sigs,
        address[] calldata _signers,
        uint256[] calldata _powers
    ) external payable;

    /**
     * @notice Execute a message not associated with a transfer.
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by
     * +2/3 of the sigsVerifier's current signing power to be delivered.
     * @param _signers The sorted list of signers.
     * @param _powers The signing powers of the signers.
     */
    function executeMessage(
        bytes calldata _message,
        MsgDataTypes.RouteInfo calldata _route,
        bytes[] calldata _sigs,
        address[] calldata _signers,
        uint256[] calldata _powers
    ) external payable;
}

File 34 of 36 : IMessageReceiverApp.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.9;

interface IMessageReceiverApp {
    enum ExecutionStatus {
        Fail, // execution failed, finalized
        Success, // execution succeeded, finalized
        Retry // execution rejected, can retry later
    }

    /**
     * @notice Called by MessageBus (MessageBusReceiver) if the process is originated from MessageBus (MessageBusSender)'s
     *         sendMessageWithTransfer it is only called when the tokens are checked to be arrived at this contract's address.
     * @param _sender The address of the source app contract
     * @param _token The address of the token that comes out of the bridge
     * @param _amount The amount of tokens received at this contract through the cross-chain bridge.
     *        the contract that implements this contract can safely assume that the tokens will arrive before this
     *        function is called.
     * @param _srcChainId The source chain ID where the transfer is originated from
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessageWithTransfer(
        address _sender,
        address _token,
        uint256 _amount,
        uint64 _srcChainId,
        bytes calldata _message,
        address _executor
    ) external payable returns (ExecutionStatus);

    /**
     * @notice Only called by MessageBus (MessageBusReceiver) if
     *         1. executeMessageWithTransfer reverts, or
     *         2. executeMessageWithTransfer returns ExecutionStatus.Fail
     * @param _sender The address of the source app contract
     * @param _token The address of the token that comes out of the bridge
     * @param _amount The amount of tokens received at this contract through the cross-chain bridge.
     *        the contract that implements this contract can safely assume that the tokens will arrive before this
     *        function is called.
     * @param _srcChainId The source chain ID where the transfer is originated from
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessageWithTransferFallback(
        address _sender,
        address _token,
        uint256 _amount,
        uint64 _srcChainId,
        bytes calldata _message,
        address _executor
    ) external payable returns (ExecutionStatus);

    /**
     * @notice Called by MessageBus (MessageBusReceiver) to process refund of the original transfer from this contract
     * @param _token The token address of the original transfer
     * @param _amount The amount of the original transfer
     * @param _message The same message associated with the original transfer
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessageWithTransferRefund(
        address _token,
        uint256 _amount,
        bytes calldata _message,
        address _executor
    ) external payable returns (ExecutionStatus);

    /**
     * @notice Called by MessageBus (MessageBusReceiver)
     * @param _sender The address of the source app contract
     * @param _srcChainId The source chain ID where the transfer is originated from
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     * @param _executor Address who called the MessageBus execution function
     */
    function executeMessage(
        address _sender,
        uint64 _srcChainId,
        bytes calldata _message,
        address _executor
    ) external payable returns (ExecutionStatus);
}

File 35 of 36 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 36 of 36 : IUniswapRouterV3.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap Algebra
interface IUniswapRouterV3 {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;

    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);

    function WETH9() external view returns (address);

    function WNativeToken() external view returns (address);

    function refundETH() external payable;

    function refundNativeToken() external payable;

    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    function unwrapWNativeToken(uint256 amountMinimum, address recipient) external payable;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_fixedCryptoFee","type":"uint256"},{"internalType":"uint256","name":"_RubicPlatformFee","type":"uint256"},{"internalType":"address[]","name":"_routers","type":"address[]"},{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_minTokenAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxTokenAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"_blockchainIDs","type":"uint256[]"},{"internalType":"uint256[]","name":"_blockchainToGasFee","type":"uint256[]"},{"internalType":"address","name":"_relayer","type":"address"},{"internalType":"address","name":"_messageBus","type":"address"},{"internalType":"address","name":"_nativeWrap","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApproveFailed","type":"error"},{"inputs":[],"name":"CantSetToNull","type":"error"},{"inputs":[],"name":"FeeTooHigh","type":"error"},{"inputs":[],"name":"LengthMismatch","type":"error"},{"inputs":[],"name":"MaxMustBeBiggerThanMin","type":"error"},{"inputs":[],"name":"MinMustBeLowerThanMax","type":"error"},{"inputs":[],"name":"NotAManager","type":"error"},{"inputs":[],"name":"NotARelayer","type":"error"},{"inputs":[],"name":"NotAnAdmin","type":"error"},{"inputs":[],"name":"OnlyEOA","type":"error"},{"inputs":[],"name":"ShareTooHigh","type":"error"},{"inputs":[],"name":"Unchangeable","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"outputTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum WithDestinationFunctionality.SwapStatus","name":"status","type":"uint8"}],"name":"CrossChainProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"components":[{"internalType":"address","name":"srcInputToken","type":"address"},{"internalType":"uint256","name":"srcInputAmount","type":"uint256"},{"internalType":"uint256","name":"dstChainID","type":"uint256"},{"internalType":"address","name":"dstOutputToken","type":"address"},{"internalType":"uint256","name":"dstMinOutputAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"address","name":"router","type":"address"}],"indexed":false,"internalType":"struct BridgeBase.BaseCrossChainParams","name":"parameters","type":"tuple"}],"name":"CrossChainRequestSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"RubicPart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"integratorPart","type":"uint256"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"}],"name":"FixedCryptoFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"collector","type":"address"}],"name":"FixedCryptoFeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"IntegratorTokenFeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"messageBus","type":"address"}],"name":"MessageBusUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"RubicTokenFeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"RubicPart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"integratorPart","type":"uint256"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RELAYER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RubicPlatformFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"addAvailableRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"availableIntegratorCryptoFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"availableIntegratorTokenFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"availableRubicCryptoFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"availableRubicGasFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"availableRubicTokenFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"blockchainToGasFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"internalType":"address","name":"_srcBridgeToken","type":"address"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"bridgeWithSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"internalType":"address","name":"_srcBridgeToken","type":"address"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"bridgeWithSwapNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"enum WithDestinationFunctionality.SwapStatus","name":"_statusCode","type":"uint8"}],"name":"changeTxStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"collectGasFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"collectIntegratorFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_integrator","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"collectIntegratorFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectRubicCryptoFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"collectRubicFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"uint64","name":"_srcChainId","type":"uint64"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"}],"name":"executeMessage","outputs":[{"internalType":"enum IMessageReceiverApp.ExecutionStatus","name":"","type":"uint8"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint64","name":"_srcChainId","type":"uint64"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_relayer","type":"address"}],"name":"executeMessageWithTransfer","outputs":[{"internalType":"enum IMessageReceiverApp.ExecutionStatus","name":"","type":"uint8"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint64","name":"_srcChainId","type":"uint64"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_relayer","type":"address"}],"name":"executeMessageWithTransferFallback","outputs":[{"internalType":"enum IMessageReceiverApp.ExecutionStatus","name":"","type":"uint8"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_relayer","type":"address"}],"name":"executeMessageWithTransferRefund","outputs":[{"internalType":"enum IMessageReceiverApp.ExecutionStatus","name":"","type":"uint8"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"fixedCryptoFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableRouters","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"integratorToFeeInfo","outputs":[{"internalType":"bool","name":"isIntegrator","type":"bool"},{"internalType":"uint32","name":"tokenFee","type":"uint32"},{"internalType":"uint32","name":"RubicTokenShare","type":"uint32"},{"internalType":"uint32","name":"RubicFixedCryptoShare","type":"uint32"},{"internalType":"uint128","name":"fixedFeeAmount","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"manualRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"messageBus","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nativeWrap","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"processedTransactions","outputs":[{"internalType":"enum WithDestinationFunctionality.SwapStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"refundDetails","outputs":[{"internalType":"address","name":"integrator","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"removeAvailableRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fixedCryptoFee","type":"uint256"}],"name":"setFixedCryptoFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_blockchainID","type":"uint256"},{"internalType":"uint256","name":"_gasFee","type":"uint256"}],"name":"setGasFeeOfBlockchain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_integrator","type":"address"},{"components":[{"internalType":"bool","name":"isIntegrator","type":"bool"},{"internalType":"uint32","name":"tokenFee","type":"uint32"},{"internalType":"uint32","name":"RubicTokenShare","type":"uint32"},{"internalType":"uint32","name":"RubicFixedCryptoShare","type":"uint32"},{"internalType":"uint128","name":"fixedFeeAmount","type":"uint128"}],"internalType":"struct BridgeBase.IntegratorFeeInfo","name":"_info","type":"tuple"}],"name":"setIntegratorInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_maxTokenAmount","type":"uint256"}],"name":"setMaxTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_messageBus","type":"address"}],"name":"setMessageBus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_minTokenAmount","type":"uint256"}],"name":"setMinTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nativeWrap","type":"address"}],"name":"setNativeWrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_platformFee","type":"uint256"}],"name":"setRubicPlatformFee","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":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sweepTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoInch","name":"_srcSwap","type":"tuple"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"transferWithSwapInch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoInch","name":"_srcSwap","type":"tuple"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"transferWithSwapInchNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoV2","name":"_srcSwap","type":"tuple"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"transferWithSwapV2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoV2","name":"_srcSwap","type":"tuple"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"transferWithSwapV2Native","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoV3","name":"_srcSwap","type":"tuple"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"transferWithSwapV3","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoV3","name":"_srcSwap","type":"tuple"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"bool","name":"nativeOut","type":"bool"},{"internalType":"address","name":"receiverEOA","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"enum SwapBase.SwapVersion","name":"version","type":"uint8"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bytes","name":"pathV3","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct SwapBase.SwapInfoDest","name":"_dstSwap","type":"tuple"},{"internalType":"uint32","name":"_maxBridgeSlippage","type":"uint32"}],"name":"transferWithSwapV3Native","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"unpauseExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b5060405162005ed238038062005ed2833981016040819052620000349162000864565b620000468b8b8b8b8b8b8b8b620000b4565b61010980546001600160a01b038084166001600160a01b0319928316179092556000805492851692909116919091179055620000a37fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc48462000211565b5050505050505050505050620009f8565b600054600160a81b900460ff1615808015620000dd57506000546001600160a01b90910460ff16105b80620001145750620000fa306200022160201b62001c6b1760201c565b158015620001145750600054600160a01b900460ff166001145b6200017d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff60a01b1916600160a01b1790558015620001ab576000805460ff60a81b1916600160a81b1790555b620001bd898989898989898962000230565b801562000206576000805460ff60a81b19169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6200021d82826200033a565b5050565b6001600160a01b03163b151590565b600054600160a81b900460ff166200028e5760405162461bcd60e51b815260206004820152602b602482015260008051602062005eb283398151915260448201526a6e697469616c697a696e6760a81b606482015260840162000174565b6200029e888888888888620003c4565b815181518114620002c5576040516001621398b960e31b0319815260040160405180910390fd5b60005b818110156200032e57828181518110620002e657620002e6620009e2565b60200260200101516101076000868481518110620003085762000308620009e2565b6020026020010151815260200190815260200160002081905550806001019050620002c8565b50505050505050505050565b620003468282620005f3565b6200021d5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620003803390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600054600160a81b900460ff16620004225760405162461bcd60e51b815260206004820152602b602482015260008051602062005eb283398151915260448201526a6e697469616c697a696e6760a81b606482015260840162000174565b6200042c62000620565b610102869055620f4240851115620004575760405163cd4e616760e01b815260040160405180910390fd5b610101859055835160005b81811015620004ad57620004a3868281518110620004845762000484620009e2565b60200260200101516101046200068a60201b62001c7a1790919060201c565b5060010162000462565b50835160005b81811015620005db57838181518110620004d157620004d1620009e2565b6020026020010151858281518110620004ee57620004ee620009e2565b60200260200101511115620005165760405163129c63a160e31b815260040160405180910390fd5b8481815181106200052b576200052b620009e2565b602002602001015160fd60008884815181106200054c576200054c620009e2565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055508381815181106200058d576200058d620009e2565b602002602001015160fe6000888481518110620005ae57620005ae620009e2565b6020908102919091018101516001600160a01b0316825281019190915260400160002055600101620004b3565b50620005e960003362000211565b5050505050505050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b600054600160a81b900460ff166200067e5760405162461bcd60e51b815260206004820152602b602482015260008051602062005eb283398151915260448201526a6e697469616c697a696e6760a81b606482015260840162000174565b6097805460ff19169055565b6000620006a1836001600160a01b038416620006a8565b9392505050565b6000818152600183016020526040812054620006f1575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200061a565b5060006200061a565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156200073b576200073b620006fa565b604052919050565b60006001600160401b038211156200075f576200075f620006fa565b5060051b60200190565b80516001600160a01b03811681146200078157600080fd5b919050565b600082601f8301126200079857600080fd5b81516020620007b1620007ab8362000743565b62000710565b82815260059290921b84018101918181019086841115620007d157600080fd5b8286015b84811015620007f757620007e98162000769565b8352918301918301620007d5565b509695505050505050565b600082601f8301126200081457600080fd5b8151602062000827620007ab8362000743565b82815260059290921b840181019181810190868411156200084757600080fd5b8286015b84811015620007f757805183529183019183016200084b565b60008060008060008060008060008060006101608c8e0312156200088757600080fd5b8b5160208d015160408e0151919c509a506001600160401b03811115620008ad57600080fd5b620008bb8e828f0162000786565b60608e0151909a5090506001600160401b03811115620008da57600080fd5b620008e88e828f0162000786565b60808e015190995090506001600160401b038111156200090757600080fd5b620009158e828f0162000802565b60a08e015190985090506001600160401b038111156200093457600080fd5b620009428e828f0162000802565b60c08e015190975090506001600160401b038111156200096157600080fd5b6200096f8e828f0162000802565b60e08e015190965090506001600160401b038111156200098e57600080fd5b6200099c8e828f0162000802565b945050620009ae6101008d0162000769565b9250620009bf6101208d0162000769565b9150620009d06101408d0162000769565b90509295989b509295989b9093969950565b634e487b7160e01b600052603260045260246000fd5b6154aa8062000a086000396000f3fe60806040526004361061039b5760003560e01c80636ba35d59116101dc5780639c649fdf11610102578063bca4a84c116100a0578063d547741f1161006f578063d547741f14610b45578063dec6603614610b65578063ec87621c14610b85578063fc66cfbf14610bb9576103a2565b8063bca4a84c14610ace578063beea8df814610ae1578063c470768614610b01578063c75b3d4114610b2e576103a2565b8063a217fddf116100dc578063a217fddf14610a28578063ac2e493614610a3d578063affed0e014610a7b578063b70ad44c14610abb576103a2565b80639c649fdf146109de5780639e369235146109f1578063a1a227fa14610a08576103a2565b80637e903aa61161017a5780638cde5946116101495780638cde59461461094a57806391d148541461096a578063926d7d7f1461098a57806395c54f5a146109be576103a2565b80637e903aa6146108e0578063825dc415146108f5578063859806cc1461091557806386ca9f751461092a576103a2565b8063772f8c2d116101b6578063772f8c2d146107df57806379e650621461080c5780637cd2bffc1461082c5780637cd5083f1461083f576103a2565b80636ba35d591461078c578063706bc66b1461079f57806375829def146107bf576103a2565b80633a68ff83116102c1578063547cad121161025f5780635c975abb1161022e5780635c975abb146106fa5780635fa294751461071257806369fe30e8146107255780636ac554711461075e576103a2565b8063547cad121461069057806354b3290d146106b05780635ab7afc6146106c75780635b5a66a7146106da576103a2565b806348d8b9a41161029b57806348d8b9a4146106335780634cb1e3411461064a5780634eecc1da1461066a5780635377f4621461067d576103a2565b80633a68ff83146105b85780633f979a9a146105da578063457bfa2f146105fa576103a2565b806316fcb97811610339578063248a9ca311610308578063248a9ca3146105355780632f2ff15d1461056557806336568abe1461058557806336a608cf146105a5576103a2565b806316fcb978146104c05780631bceb8d4146104d35780631e2c0314146105005780631f041ec614610520576103a2565b80630bcb4982116103755780630bcb4982146104255780630f4fb3731461044557806313a1667c14610480578063162dfb0d146104a0576103a2565b806301ffc9a7146103b057806304c39d1e146103e557806307598f6214610405576103a2565b366103a257005b3480156103ae57600080fd5b005b3480156103bc57600080fd5b506103d06103cb3660046143e3565b610c4c565b60405190151581526020015b60405180910390f35b3480156103f157600080fd5b506103ae61040036600461440d565b610c83565b34801561041157600080fd5b506103ae610420366004614446565b610e31565b6104386104333660046144a4565b610e6a565b6040516103dc919061453d565b34801561045157600080fd5b50610472610460366004614446565b60fe6020526000908152604090205481565b6040519081526020016103dc565b34801561048c57600080fd5b506103ae61049b366004614446565b610f4d565b3480156104ac57600080fd5b506103ae6104bb366004614550565b610f65565b6103ae6104ce3660046145df565b610f77565b3480156104df57600080fd5b506104726104ee366004614446565b60fd6020526000908152604090205481565b34801561050c57600080fd5b506103ae61051b36600461440d565b611047565b34801561052c57600080fd5b506103ae611055565b34801561054157600080fd5b5061047261055036600461440d565b60009081526065602052604090206001015490565b34801561057157600080fd5b506103ae61058036600461467e565b611067565b34801561059157600080fd5b506103ae6105a036600461467e565b611091565b6103ae6105b33660046145df565b61110b565b3480156105c457600080fd5b506105cd6111b9565b6040516103dc91906146e7565b3480156105e657600080fd5b506103ae6105f53660046146fa565b6111cb565b34801561060657600080fd5b506101095461061b906001600160a01b031681565b6040516001600160a01b0390911681526020016103dc565b34801561063f57600080fd5b506104726101025481565b34801561065657600080fd5b506103ae610665366004614446565b611228565b6103ae6106783660046145df565b611247565b6103ae61068b3660046145df565b611296565b34801561069c57600080fd5b506103ae6106ab366004614446565b6112c5565b3480156106bc57600080fd5b506104726101085481565b6104386106d5366004614726565b611322565b3480156106e657600080fd5b506103ae6106f5366004614446565b611502565b34801561070657600080fd5b5060975460ff166103d0565b6103ae6107203660046145df565b61152d565b34801561073157600080fd5b50610472610740366004614550565b61010060209081526000928352604080842090915290825290205481565b34801561076a57600080fd5b5061047261077936600461440d565b6101076020526000908152604090205481565b6103ae61079a3660046147bc565b6115a3565b3480156107ab57600080fd5b506103ae6107ba366004614446565b6115d1565b3480156107cb57600080fd5b506103ae6107da366004614446565b61160c565b3480156107eb57600080fd5b506104726107fa366004614446565b60fc6020526000908152604090205481565b34801561081857600080fd5b506103ae6108273660046146fa565b61162d565b61043861083a366004614726565b61168a565b34801561084b57600080fd5b506108a261085a366004614446565b60fb6020526000908152604090205460ff81169063ffffffff6101008204811691600160281b8104821691600160481b820416906001600160801b03600160681b9091041685565b60408051951515865263ffffffff94851660208701529284169285019290925290911660608301526001600160801b0316608082015260a0016103dc565b3480156108ec57600080fd5b506103ae61184d565b34801561090157600080fd5b506103ae6109103660046148f8565b6118a1565b34801561092157600080fd5b506103ae6119e7565b34801561093657600080fd5b506103ae6109453660046149a1565b6119f7565b34801561095657600080fd5b506103ae6109653660046149ca565b611ac9565b34801561097657600080fd5b506103d061098536600461467e565b611ae4565b34801561099657600080fd5b506104727fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc481565b3480156109ca57600080fd5b506103ae6109d936600461440d565b611b0f565b6104386109ec3660046149ec565b611b41565b3480156109fd57600080fd5b506104726101035481565b348015610a1457600080fd5b5060005461061b906001600160a01b031681565b348015610a3457600080fd5b50610472600081565b348015610a4957600080fd5b50610a6e610a5836600461440d565b6101066020526000908152604090205460ff1681565b6040516103dc9190614a4c565b348015610a8757600080fd5b5061010954610aa390600160a01b90046001600160401b031681565b6040516001600160401b0390911681526020016103dc565b6103ae610ac93660046145df565b611b54565b6103ae610adc3660046147bc565b611b6b565b348015610aed57600080fd5b506103ae610afc366004614446565b611b88565b348015610b0d57600080fd5b50610472610b1c366004614446565b60ff6020526000908152604090205481565b348015610b3a57600080fd5b506104726101015481565b348015610b5157600080fd5b506103ae610b6036600461467e565b611c33565b348015610b7157600080fd5b506103ae610b803660046146fa565b611c58565b348015610b9157600080fd5b506104727f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b348015610bc557600080fd5b50610c15610bd436600461440d565b61010a6020526000908152604090208054600182015460028301546003909301546001600160a01b039283169391831692811690600160a01b900460ff1685565b604080516001600160a01b03968716815294861660208601528401929092529092166060820152901515608082015260a0016103dc565b60006001600160e01b03198216637965db0b60e01b1480610c7d57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600260c95403610cae5760405162461bcd60e51b8152600401610ca590614a5a565b60405180910390fd5b600260c955610cbb611c96565b6000818152610106602052604090205460ff166001816003811115610ce257610ce2614517565b14158015610d0257506003816003811115610cff57610cff614517565b14155b610d0b57600080fd5b600082815261010a60209081526040808320815160a0808201845282546001600160a01b0390811680845260018501548216848801908152600286015485880190815260039096015492831660608087019190915260ff600160a01b90940484161515608080880191909152838b5260fb8a52888b2089519687018a52549485161515865263ffffffff610100860481169a87019a909a52600160281b85048a1698860198909852600160481b8404909816978401979097526001600160801b03600160681b909204919091169482019490945291519351909493610df39392918590611cee565b9050610e0d82602001518284606001518560800151611dfb565b505050600090815261010660205260409020805460ff19166003179055600160c955565b600260c95403610e535760405162461bcd60e51b8152600401610ca590614a5a565b600260c955610e623382611ea1565b50600160c955565b6000610e74611fde565b600260c95403610e965760405162461bcd60e51b8152600401610ca590614a5a565b600260c955610ea3612038565b81610ead8161207e565b6000610ebb85870187614c80565b90506000610f0d8260000151604001514684604001518a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120c592505050565b9050610f2b8989846000015160400151856000015160200151611dfb565b610f38818a8a60036120ff565b60019350505050600160c95595945050505050565b610f55611c96565b610f6161010482612172565b5050565b610f6d611c96565b610f618282611ea1565b6000610fe08686610f8e6080870160608801614446565b610fd8610f9e60208a018a614d24565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061218792505050565b60601c61218e565b905061103e87878787878787611036610ffc6020860186614d24565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061234f92505050565b60601c61236b565b50505050505050565b61104f611c96565b61010255565b61105d611c96565b6110656124c4565b565b6000828152606560205260409020600101546110828161251e565b61108c8383612528565b505050565b6001600160a01b03811633146111015760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610ca5565b610f6182826125ae565b600061115a86866111226080870160608801614446565b61112f6020890189614d6a565b600081811061114057611140614db3565b90506020020160208101906111559190614446565b61218e565b905061103e878787878787876111736020850185614d6a565b60018e80602001906111859190614d6a565b611190929150614ddf565b81811061119f5761119f614db3565b90506020020160208101906111b49190614446565b612615565b60606111c6610104612728565b905090565b6111d3611c96565b6001600160a01b038216600090815260fd602052604090205481101561120c57604051635909a3b560e11b815260040160405180910390fd5b6001600160a01b03909116600090815260fe6020526040902055565b611230611c96565b610108805460009182905590610f61908284612735565b600061115a868661125e6080870160608801614446565b61126b6020890189614d6a565b600081811061127c5761127c614db3565b90506020020160208101906112919190614446565b612761565b6000610fe086866112ad6080870160608801614446565b6112bd610f9e60208a018a614d24565b60601c612761565b6112cd611c96565b600080546001600160a01b0319166001600160a01b0383169081179091556040519081527f3f8223bcd8b3b875473e9f9e14e1ad075451a2b5ffd31591655da9a01516bf5e906020015b60405180910390a150565b600061132c611fde565b600260c9540361134e5760405162461bcd60e51b8152600401610ca590614a5a565b600260c9558161135d8161207e565b600061136b85870187614c80565b905060006113b982600001516040015189468a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120c592505050565b90506040518060a001604052808360000151606001516001600160a01b031681526020018b6001600160a01b031681526020018a81526020018360000151604001516001600160a01b03168152602001836000015160200151151581525061010a600083815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160030160146101000a81548160ff0219169083151502179055509050506114ec818b8b60026120ff565b5050600160c95550600098975050505050505050565b61150a611c96565b61010980546001600160a01b0319166001600160a01b0392909216919091179055565b600061154486866111226080870160608801614446565b905061103e8787878787878761155d6020850185614d6a565b60018e806020019061156f9190614d6a565b61157a929150614ddf565b81811061158957611589614db3565b905060200201602081019061159e9190614446565b61282c565b60006115c086866115ba6080870160608801614446565b8761218e565b905061103e8786868686868c61293f565b6115d9611c96565b6001600160a01b0381166116005760405163d92e233d60e01b815260040160405180910390fd5b610f6161010482611c7a565b611614612a9e565b61161f6000336125ae565b61162a600082612528565b50565b611635611c96565b6001600160a01b038216600090815260fe602052604090205481111561166e5760405163129c63a160e31b815260040160405180910390fd5b6001600160a01b03909116600090815260fd6020526040902055565b6000611694611fde565b600260c954036116b65760405162461bcd60e51b8152600401610ca590614a5a565b600260c9556116c3612038565b816116cd8161207e565b60006116db85870187614c80565b9050600061172982600001516040015189468a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120c592505050565b82516060908101516001600160a01b038116600090815260fb60209081526040808320815160a081018352905460ff811615158252610100810463ffffffff90811694830194909452600160281b8104841692820192909252600160481b820490921694820194909452600160681b9093046001600160801b031660808401529293506117bb929091908c908e611cee565b985060006117cc8360000151612ac6565b9050600183516080015160028111156117e7576117e7614517565b036117fe576117f98b828c8587612c43565b611835565b6002835160800151600281111561181757611817614517565b03611828576117f98b8b8486612d12565b6118358b828c8587612d3b565b6001945050505050600160c955979650505050505050565b611855611c96565b61010380546000918290559061186c908233612735565b604080518281523360208201527f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d9101611317565b6118a9611c96565b620f4240816020015163ffffffff1611156118d75760405163cd4e616760e01b815260040160405180910390fd5b620f4240816040015163ffffffff1611806118fe5750620f4240816060015163ffffffff16115b1561191c57604051630a81ff1360e21b815260040160405180910390fd5b6001600160a01b03909116600090815260fb602090815260409182902083518154928501519385015160608601516080909601516001600160801b0316600160681b026fffffffffffffffffffffffffffffffff60681b1963ffffffff978816600160481b026cffffffff00000000000000000019938916600160281b02939093166cffffffffffffffff000000000019989097166101000264ffffffff00199415159490941664ffffffffff19909616959095179290921795909516939093179390931716179055565b6119ef611c96565b611065612db2565b6119ff611c96565b6000816003811115611a1357611a13614517565b03611a315760405163b30d036f60e01b815260040160405180910390fd5b6000828152610106602052604090205460ff166001816003811115611a5857611a58614517565b1480611a7557506003816003811115611a7357611a73614517565b145b15611a935760405163e48fe4bf60e01b815260040160405180910390fd5b600083815261010660205260409020805483919060ff19166001836003811115611abf57611abf614517565b0217905550505050565b611ad1611c96565b6000918252610107602052604090912055565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611b17611c96565b620f4240811115611b3b5760405163cd4e616760e01b815260040160405180910390fd5b61010155565b6000611b4b611fde565b95945050505050565b6000611544868661125e6080870160608801614446565b60006115c08686611b826080870160608801614446565b87612761565b611b90611c96565b6001600160a01b038116600090815260ff602052604081205490819003611bca57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b038216600090815260ff6020526040812055611bee828233612735565b604080518281526001600160a01b03841660208201527f9216fa2f918153a5852ce98e7929c12cd94e0adeda8117f80e761c216157b27c910160405180910390a15050565b600082815260656020526040902060010154611c4e8161251e565b61108c83836125ae565b611c60612a9e565b610f61828233612735565b6001600160a01b03163b151590565b6000611c8f836001600160a01b038416612deb565b9392505050565b611cc07f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0833611ae4565b80611cd15750611cd1600033611ae4565b61106557604051633a4af34560e21b815260040160405180910390fd5b6000806000611cfe878787612e3a565b90925090506001600160a01b03881615611d5a57611d1c8183614ddf565b6001600160a01b03808616600090815261010060209081526040808320938d1683529290529081208054909190611d54908490614df6565b90915550505b6001600160a01b038416600090815260ff602052604081208054839290611d82908490614df6565b90915550506001600160a01b0388167f25471ec9f39b4ceb20d58f63c37f9c738011f0babcc4b6af69bdd82984ca5f8e82611dbd8186614ddf565b6040805192835260208301919091526001600160a01b0388169082015260600160405180910390a2611def8287614ddf565b98975050505050505050565b610109546001600160a01b038581169116148015611e1b57506001811515145b15611e905761010954604051632e1a7d4d60e01b8152600481018590526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015611e6757600080fd5b505af1158015611e7b573d6000803e3d6000fd5b50505050611e8b60008484612735565b611e9b565b611e9b848484612735565b50505050565b60006001600160a01b038216611f0c57506001600160a01b038216600081815260fc60209081526040808320805493905580518381529182019390935290917f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d910160405180910390a15b6001600160a01b0380831660009081526101006020908152604080832093871683529290522054611f3d9082614df6565b905080600003611f6057604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b03808316600090815261010060209081526040808320938716835292905290812055611f94828285612735565b604080518281526001600160a01b0384811660208301528516917f6f83ca8ce48e63b2a223b9f9e7ef1ea7bf3a8385c7a9bd63baae22963b2b26e0910160405180910390a2505050565b6000546001600160a01b031633146110655760405162461bcd60e51b815260206004820152601960248201527f63616c6c6572206973206e6f74206d65737361676520627573000000000000006044820152606401610ca5565b60975460ff16156110655760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610ca5565b6120a87fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc482611ae4565b61162a57604051633f0b607d60e11b815260040160405180910390fd5b6000848484846040516020016120de9493929190614e3a565b6040516020818303038152906040528051906020012090505b949350505050565b600084815261010660205260409020805482919060ff1916600183600381111561212b5761212b614517565b0217905550837fd75ce962bdb41de6ea8526caa7c0d7a0180c4255b67427804c125d8fcd0480cd84848460405161216493929190614e96565b60405180910390a250505050565b6000611c8f836001600160a01b038416612e7a565b6020015190565b60003332146121b057604051639f8129d160e01b815260040160405180910390fd5b6121b8612038565b610109546001600160a01b038381169116146122075760405162461bcd60e51b815260206004820152600e60248201526d0e8ded6cadc40dad2e6dac2e8c6d60931b6044820152606401610ca5565b8434101561224d5760405162461bcd60e51b8152602060048201526013602482015272185b5bdd5b9d081a5b9cdd59999a58da595b9d606a1b6044820152606401610ca5565b61010960009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b15801561229e57600080fd5b505af11580156122b2573d6000803e3d6000fd5b505050506001600160a01b038416600090815260fb6020908152604091829020825160a081018452905460ff811615158252610100810463ffffffff90811693830193909352600160281b8104831693820193909352600160481b83049091166060820152600160681b9091046001600160801b031660808201528691506123459085906001600160401b038816612f6d565b611b4b9190614ddf565b6000808251600c6123609190614df6565b929092015192915050565b600060405180610100016040528061238c888060200190610f9e9190614d24565b606090811c8252602082018b90526001600160401b038a166040830152016123bb6123b688614eba565b612ac6565b6001600160a01b0316815261010087013560208201523360408201526060908101906123ed9060808901908901614446565b6001600160a01b0316815260209081019061240a90890189614446565b6001600160a01b03169052905060146124266020880188614d24565b9050116124455760405162461bcd60e51b8152600401610ca590614ec6565b60008061245a61245489614eef565b8b612fa3565b91509150600061247c8c85604001518a8a6124736130a3565b8b8b898b6130ef565b9050807f6fd6f0d249b4127a9fbf18c57212c8fb026d40b6d4501397929fd57f39608649856040516124ae9190614f5e565b60405180910390a2505050505050505050505050565b6124cc612038565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586125013390565b6040516001600160a01b03909116815260200160405180910390a1565b61162a813361321f565b6125328282611ae4565b610f615760008281526065602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561256a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6125b88282611ae4565b15610f615760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006040518061010001604052808780602001906126339190614d6a565b600081811061264457612644614db3565b90506020020160208101906126599190614446565b6001600160a01b03168152602001898152602001886001600160401b03168152602001612689876123b690614eba565b6001600160a01b0316815261010087013560208201523360408201526060908101906126bb9060808901908901614446565b6001600160a01b031681526020908101906126d890890189614446565b6001600160a01b03169052905060016126f46020880188614d6a565b9050116127135760405162461bcd60e51b8152600401610ca590614ec6565b60008061245a61272289614fc4565b8b613283565b60606000611c8f83613429565b6001600160a01b03831661274d5761108c8183613485565b61108c6001600160a01b038416828461359e565b600033321461278357604051639f8129d160e01b815260040160405180910390fd5b61278b612038565b6127a06001600160a01b038316333088613601565b6001600160a01b038316600090815260fb6020908152604091829020825160a081018452905460ff811615158252610100810463ffffffff90811693830193909352600160281b8104831693820193909352600160481b83049091166060820152600160681b9091046001600160801b03166080820152611b4b9084906001600160401b038716612f6d565b600060405180610100016040528087806020019061284a9190614d6a565b600081811061285b5761285b614db3565b90506020020160208101906128709190614446565b6001600160a01b03168152602001898152602001886001600160401b031681526020016128a0876123b690614eba565b6001600160a01b0316815261010087013560208201523360408201526060908101906128d29060808901908901614446565b6001600160a01b031681526020908101906128ef90890189614446565b6001600160a01b031690529050600161290b6020880188614d6a565b90501161292a5760405162461bcd60e51b8152600401610ca590614ec6565b60008061245a6129398961504e565b8b613639565b6000604051806101000160405280876001600160a01b03168152602001838152602001886001600160401b0316815260200161297e876123b690614eba565b6001600160a01b0316815260200186610100013581526020018660400160208101906129aa9190614446565b6001600160a01b031681526020016129c86080880160608901614446565b6001600160a01b0316815260200160006001600160a01b03168152509050466001600160401b0316816040015103612a325760405162461bcd60e51b815260206004820152600d60248201526c1cd85b594818da185a5b881a59609a1b6044820152606401610ca5565b6000612a598983604001518888612a476130a3565b898860000151896020015160016130ef565b9050807f6fd6f0d249b4127a9fbf18c57212c8fb026d40b6d4501397929fd57f3960864983604051612a8b9190614f5e565b60405180910390a2505050505050505050565b612aa9600033611ae4565b611065576040516355098f2760e01b815260040160405180910390fd5b6000600182608001516002811115612ae057612ae0614517565b03612b445760148260c001515111612b2e5760405162461bcd60e51b8152602060048201526011602482015270191cdd081cddd85c08195e1c1958dd1959607a1b6044820152606401610ca5565b612b3b8260c0015161234f565b60601c92915050565b600082608001516002811115612b5c57612b5c614517565b03612bdc5760018260a001515111612baa5760405162461bcd60e51b8152602060048201526011602482015270191cdd081cddd85c08195e1c1958dd1959607a1b6044820152606401610ca5565b60a08201518051612bbd90600190614ddf565b81518110612bcd57612bcd614db3565b60200260200101519050919050565b8160a0015151600114612c275760405162461bcd60e51b8152602060048201526013602482015272191cdd08189c9a5919d948195e1c1958dd1959606a1b6044820152606401610ca5565b8160a00151600081518110612bcd57612bcd614db3565b919050565b805160c0015160200151859060601c612c5c828261373c565b604080516080810182528451516001600160a01b03168152845160c001516020820152845160e0015191810191909152835161010001516060820152600080612ca58389612fa3565b915091508115612cdd57612ccb8982886000015160400151896000015160200151611dfb565b612cd8878a8360016120ff565b612d06565b612cf98a89886000015160400151896000015160200151611dfb565b612d06878b8a60036120ff565b50505050505050505050565b612d2e8484836000015160400151846000015160200151611dfb565b611e9b82858560016120ff565b84816000015160a00151600081518110612d5757612d57614db3565b6020026020010151612d69828261373c565b604080516080810182528451516001600160a01b03168152845160a001516020820152845160e0015191810191909152835161010001516060820152600080612ca58389613639565b612dba61379d565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33612501565b6000818152600183016020526040812054612e3257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c7d565b506000610c7d565b600080846000015115612e5b57612e5184866137e6565b9092509050612e72565b612e6c8461010154620f4240613837565b91508190505b935093915050565b60008181526001830160205260408120548015612f63576000612e9e600183614ddf565b8554909150600090612eb290600190614ddf565b9050818114612f17576000866000018281548110612ed257612ed2614db3565b9060005260206000200154905080876000018481548110612ef557612ef5614db3565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612f2857612f2861509a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c7d565b6000915050610c7d565b6000818152610107602052604081205461010880548291908490612f92908490614df6565b9091555081905061234586866138e9565b81516000908190612fb790610104906139e9565b612fc65750600090508061309c565b612fe6612fd885602001516020015190565b60601c848660000151613a0b565b6040805160a081018252602080870151825230908201528582015181830152606080820186905286015160808201528551915163c04b8d5960e01b815290916001600160a01b03169063c04b8d59906130439084906004016150dc565b6020604051808303816000875af192505050801561307e575060408051601f3d908101601f1916820190925261307b91810190615134565b60015b61308f57600080925092505061309c565b60019350915061309c9050565b9250929050565b6000610109601481819054906101000a90046001600160401b03166130c79061514d565b91906101000a8154816001600160401b0302191690836001600160401b031602179055905090565b6000816131305760405162461bcd60e51b815260206004820152600f60248201526e1cdc98c81cddd85c0819985a5b1959608a1b6044820152606401610ca5565b6001600160a01b038416600090815260fd60205260409020548310156131885760405162461bcd60e51b815260206004820152600d60248201526c3632b9b9903a3430b71036b4b760991b6044820152606401610ca5565b6001600160a01b038416600090815260fe602052604090205415613201576001600160a01b038416600090815260fe60205260409020548311156132015760405162461bcd60e51b815260206004820152601060248201526f0cee4cac2e8cae440e8d0c2dc40dac2f60831b6044820152606401610ca5565b6132118a8a8a8a8a8a8a8a613b6f565b9a9950505050505050505050565b6132298282611ae4565b610f6157613241816001600160a01b03166014613c61565b61324c836020613c61565b60405160200161325d929190615173565b60408051601f198184030181529082905262461bcd60e51b8252610ca5916004016151e8565b8151600090819061329790610104906139e9565b6132a65750600090508061309c565b6132d384602001516000815181106132c0576132c0614db3565b6020026020010151848660000151613a0b565b60208401518051600091906132ea90600190614ddf565b815181106132fa576132fa614db3565b60209081029190910101516040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561334f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133739190615134565b905061338786600001518760400151613dfc565b506040516370a0823160e01b815230600482015260009082906001600160a01b038516906370a0823190602401602060405180830381865afa1580156133d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133f59190615134565b6133ff9190614ddf565b90508660600151811061341a5760019450925061309c915050565b50600096879650945050505050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561347957602002820191906000526020600020905b815481526020019060010190808311613465575b50505050509050919050565b804710156134d55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610ca5565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613522576040519150601f19603f3d011682016040523d82523d6000602084013e613527565b606091505b505090508061108c5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610ca5565b6040516001600160a01b03831660248201526044810182905261108c90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613e3e565b6040516001600160a01b0380851660248301528316604482015260648101829052611e9b9085906323b872dd60e01b906084016135ca565b8151600090819061364d90610104906139e9565b61365c5750600090508061309c565b61367684602001516000815181106132c0576132c0614db3565b83600001516001600160a01b03166338ed173984866060015187602001513089604001516040518663ffffffff1660e01b81526004016136ba9594939291906151fb565b6000604051808303816000875af19250505080156136fa57506040513d6000823e601f3d908101601f191682016040526136f79190810190615237565b60015b6137095750600090508061309c565b6001816001835161371a9190614ddf565b8151811061372a5761372a614db3565b6020026020010151925092505061309c565b806001600160a01b0316826001600160a01b031614610f615760405162461bcd60e51b815260206004820152601b60248201527f666972737420746f6b656e206d757374206265207472616e73697400000000006044820152606401610ca5565b60975460ff166110655760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610ca5565b6000806000836020015163ffffffff16111561309c5761381484846020015163ffffffff16620f4240613837565b915061382e82846040015163ffffffff16620f4240613837565b90509250929050565b6000808060001985870985870292508281108382030391505080600003613870576000841161386557600080fd5b508290049050611c8f565b80841161387c57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008060008360000151156139715760808401516001600160801b03169150811561396c57620f4240846060015163ffffffff168361392891906152bc565b61393291906152db565b905061393e8183614ddf565b6001600160a01b038616600090815260fc602052604081208054909190613966908490614df6565b90915550505b613979565b505061010254805b80610103600082825461398c9190614df6565b90915550506001600160a01b0385167f3a84e53f89d2f7779a9c9a54779858ae0eb0b7760d607b445b6fd175c30a04d4826139c78186614ddf565b6040805192835260208301919091520160405180910390a2611b4b8234614ddf565b6001600160a01b03811660009081526001830160205260408120541515611c8f565b604051636eb1769f60e11b81523060048201526001600160a01b038281166024830152849160009183169063dd62ed3e90604401602060405180830381865afa158015613a5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a809190615134565b905083811015613b685780600003613aad57613aa86001600160a01b03831684600019613f10565b613b68565b60405163095ea7b360e01b81526001600160a01b038481166004830152600019602483015283169063095ea7b3906044016020604051808303816000875af1925050508015613b19575060408051601f3d908101601f19168201909252613b16918101906152fd565b60015b613b4857613b326001600160a01b038316846000613f10565b613aa86001600160a01b03831684600019613f10565b80613b6657604051633e3f8f7360e01b815260040160405180910390fd5b505b5050505050565b600080613b7f60a0890189614d6a565b905011613bc45760405162461bcd60e51b81526020600482015260136024820152720cadae0e8f240c8e6e840e6eec2e040e0c2e8d606b1b6044820152606401610ca5565b6000604051806060016040528089613bdb90614eba565b8152610109546001600160401b03600160a01b9091048116602080840191909152908c166040928301529051613c12929101615323565b6040516020818303038152906040529050613c41886040016020810190613c399190614446565b468b846120c5565b9150613c538a85858c8a8c878c614025565b505098975050505050505050565b60606000613c708360026152bc565b613c7b906002614df6565b6001600160401b03811115613c9257613c9261482c565b6040519080825280601f01601f191660200182016040528015613cbc576020820181803683370190505b509050600360fc1b81600081518110613cd757613cd7614db3565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613d0657613d06614db3565b60200101906001600160f81b031916908160001a9053506000613d2a8460026152bc565b613d35906001614df6565b90505b6001811115613dad576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613d6957613d69614db3565b1a60f81b828281518110613d7f57613d7f614db3565b60200101906001600160f81b031916908160001a90535060049490941c93613da68161540b565b9050613d38565b508315611c8f5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610ca5565b6060611c8f83836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250614058565b6000613e93826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166140589092919063ffffffff16565b80519091501561108c5780806020019051810190613eb191906152fd565b61108c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ca5565b801580613f8a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015613f64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f889190615134565b155b613ff55760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610ca5565b6040516001600160a01b03831660248201526044810182905261108c90849063095ea7b360e01b906064016135ca565b600061404b8989898989898960008054906101000a90046001600160a01b03168a614067565b9998505050505050505050565b60606120f7848460008561407a565b60006132118a8a8a8a8a8a8a8a8a6141ab565b6060824710156140db5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ca5565b6001600160a01b0385163b6141325760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ca5565b600080866001600160a01b0316858760405161414e9190615422565b60006040518083038185875af1925050503d806000811461418b576040519150601f19603f3d011682016040523d82523d6000602084013e614190565b606091505b50915091506141a08282866143aa565b979650505050505050565b600080836001600160a01b03166382980dc46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156141ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614210919061543e565b905061421d8a8a83613a0b565b60405163a5977fbb60e01b81526001600160a01b038c811660048301528b81166024830152604482018b90526001600160401b03808b1660648401528916608483015263ffffffff881660a483015282169063a5977fbb9060c401600060405180830381600087803b15801561429257600080fd5b505af11580156142a6573d6000803e3d6000fd5b50506040516bffffffffffffffffffffffff1930606090811b821660208401528f811b821660348401528e901b166048820152605c81018c90526001600160c01b031960c08c811b8216607c8401528b811b8216608484015246901b16608c82015260009250609401905060405160208183030381529060405280519060200120905060008651111561439b57846001600160a01b0316634289fbb3858e8c86868c6040518763ffffffff1660e01b815260040161436895949392919061545b565b6000604051808303818588803b15801561438157600080fd5b505af1158015614395573d6000803e3d6000fd5b50505050505b9b9a5050505050505050505050565b606083156143b9575081611c8f565b8251156143c95782518084602001fd5b8160405162461bcd60e51b8152600401610ca591906151e8565b6000602082840312156143f557600080fd5b81356001600160e01b031981168114611c8f57600080fd5b60006020828403121561441f57600080fd5b5035919050565b6001600160a01b038116811461162a57600080fd5b8035612c3e81614426565b60006020828403121561445857600080fd5b8135611c8f81614426565b60008083601f84011261447557600080fd5b5081356001600160401b0381111561448c57600080fd5b60208301915083602082850101111561309c57600080fd5b6000806000806000608086880312156144bc57600080fd5b85356144c781614426565b94506020860135935060408601356001600160401b038111156144e957600080fd5b6144f588828901614463565b909450925050606086013561450981614426565b809150509295509295909350565b634e487b7160e01b600052602160045260246000fd5b6003811061162a5761162a614517565b6020810161454a8361452d565b91905290565b6000806040838503121561456357600080fd5b823561456e81614426565b9150602083013561457e81614426565b809150509250929050565b80356001600160401b0381168114612c3e57600080fd5b6000608082840312156145b257600080fd5b50919050565b600061012082840312156145b257600080fd5b803563ffffffff81168114612c3e57600080fd5b60008060008060008060c087890312156145f857600080fd5b863561460381614426565b95506020870135945061461860408801614589565b935060608701356001600160401b038082111561463457600080fd5b6146408a838b016145a0565b9450608089013591508082111561465657600080fd5b5061466389828a016145b8565b92505061467260a088016145cb565b90509295509295509295565b6000806040838503121561469157600080fd5b82359150602083013561457e81614426565b600081518084526020808501945080840160005b838110156146dc5781516001600160a01b0316875295820195908201906001016146b7565b509495945050505050565b602081526000611c8f60208301846146a3565b6000806040838503121561470d57600080fd5b823561471881614426565b946020939093013593505050565b600080600080600080600060c0888a03121561474157600080fd5b873561474c81614426565b9650602088013561475c81614426565b95506040880135945061477160608901614589565b935060808801356001600160401b0381111561478c57600080fd5b6147988a828b01614463565b90945092505060a08801356147ac81614426565b8091505092959891949750929550565b60008060008060008060c087890312156147d557600080fd5b86356147e081614426565b9550602087013594506147f560408801614589565b9350606087013561480581614426565b925060808701356001600160401b0381111561482057600080fd5b61466389828a016145b8565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b03811182821017156148645761486461482c565b60405290565b60405161012081016001600160401b03811182821017156148645761486461482c565b604051608081016001600160401b03811182821017156148645761486461482c565b604051601f8201601f191681016001600160401b03811182821017156148d7576148d761482c565b604052919050565b801515811461162a57600080fd5b8035612c3e816148df565b60008082840360c081121561490c57600080fd5b833561491781614426565b925060a0601f198201121561492b57600080fd5b50614934614842565b6020840135614942816148df565b8152614950604085016145cb565b6020820152614961606085016145cb565b6040820152614972608085016145cb565b606082015260a08401356001600160801b038116811461499157600080fd5b6080820152919491935090915050565b600080604083850312156149b457600080fd5b8235915060208301356004811061457e57600080fd5b600080604083850312156149dd57600080fd5b50508035926020909101359150565b600080600080600060808688031215614a0457600080fd5b8535614a0f81614426565b9450614a1d60208701614589565b935060408601356001600160401b038111156144e957600080fd5b60048110614a4857614a48614517565b9052565b60208101610c7d8284614a38565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b803560038110612c3e57600080fd5b60006001600160401b03821115614ab957614ab961482c565b5060051b60200190565b600082601f830112614ad457600080fd5b81356020614ae9614ae483614aa0565b6148af565b82815260059290921b84018101918181019086841115614b0857600080fd5b8286015b84811015614b2c578035614b1f81614426565b8352918301918301614b0c565b509695505050505050565b600082601f830112614b4857600080fd5b81356001600160401b03811115614b6157614b6161482c565b614b74601f8201601f19166020016148af565b818152846020838601011115614b8957600080fd5b816020850160208301376000918101602001919091529392505050565b60006101208284031215614bb957600080fd5b614bc161486a565b9050614bcc8261443b565b8152614bda602083016148ed565b6020820152614beb6040830161443b565b6040820152614bfc6060830161443b565b6060820152614c0d60808301614a91565b608082015260a08201356001600160401b0380821115614c2c57600080fd5b614c3885838601614ac3565b60a084015260c0840135915080821115614c5157600080fd5b50614c5e84828501614b37565b60c08301525060e082013560e082015261010080830135818301525092915050565b600060208284031215614c9257600080fd5b81356001600160401b0380821115614ca957600080fd5b9083019060608286031215614cbd57600080fd5b604051606081018181108382111715614cd857614cd861482c565b604052823582811115614cea57600080fd5b614cf687828601614ba6565b825250614d0560208401614589565b6020820152614d1660408401614589565b604082015295945050505050565b6000808335601e19843603018112614d3b57600080fd5b8301803591506001600160401b03821115614d5557600080fd5b60200191503681900382131561309c57600080fd5b6000808335601e19843603018112614d8157600080fd5b8301803591506001600160401b03821115614d9b57600080fd5b6020019150600581901b360382131561309c57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082821015614df157614df1614dc9565b500390565b60008219821115614e0957614e09614dc9565b500190565b60005b83811015614e29578181015183820152602001614e11565b83811115611e9b5750506000910152565b6bffffffffffffffffffffffff198560601b16815260006001600160401b0360c01b808660c01b166014840152808560c01b16601c840152508251614e86816024850160208701614e0e565b9190910160240195945050505050565b6001600160a01b038416815260208101839052606081016120f76040830184614a38565b6000610c7d3683614ba6565b6020808252600f908201526e0cadae0e8f240e6eec2e040e0c2e8d608b1b604082015260600190565b600060808236031215614f0157600080fd5b614f0961488d565b8235614f1481614426565b815260208301356001600160401b03811115614f2f57600080fd5b614f3b36828601614b37565b602083015250604083013560408201526060830135606082015280915050919050565b81516001600160a01b03908116825260208084015190830152604080840151908301526060808401518216908301526080808401519083015260a08381015182169083015260c08084015182169083015260e09283015116918101919091526101000190565b600060808236031215614fd657600080fd5b614fde61488d565b8235614fe981614426565b815260208301356001600160401b038082111561500557600080fd5b61501136838701614ac3565b6020840152604085013591508082111561502a57600080fd5b5061503736828601614b37565b604083015250606092830135928101929092525090565b60006080823603121561506057600080fd5b61506861488d565b823561507381614426565b815260208301356001600160401b0381111561508e57600080fd5b614f3b36828601614ac3565b634e487b7160e01b600052603160045260246000fd5b600081518084526150c8816020860160208601614e0e565b601f01601f19169290920160200192915050565b602081526000825160a060208401526150f860c08401826150b0565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60006020828403121561514657600080fd5b5051919050565b60006001600160401b0380831681810361516957615169614dc9565b6001019392505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516151ab816017850160208801614e0e565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516151dc816028840160208801614e0e565b01602801949350505050565b602081526000611c8f60208301846150b0565b85815284602082015260a06040820152600061521a60a08301866146a3565b6001600160a01b0394909416606083015250608001529392505050565b6000602080838503121561524a57600080fd5b82516001600160401b0381111561526057600080fd5b8301601f8101851361527157600080fd5b805161527f614ae482614aa0565b81815260059190911b8201830190838101908783111561529e57600080fd5b928401925b828410156141a0578351825292840192908401906152a3565b60008160001904831182151516156152d6576152d6614dc9565b500290565b6000826152f857634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561530f57600080fd5b8151611c8f816148df565b614a488161452d565b6020815260008251606060208401526153486080840182516001600160a01b03169052565b6020810151151560a084015260408101516001600160a01b0390811660c085015260608201511660e084015260808101516101006153888186018361531a565b60a08301516101208681015291506153a46101a08601836146a3565b915060c0830151607f19868403016101408701526153c283826150b0565b60e0850151610160880152919093015161018086015260208601516001600160401b03811660408701529250905060408501516001600160401b038116606086015291506120f7565b60008161541a5761541a614dc9565b506000190190565b60008251615434818460208701614e0e565b9190910192915050565b60006020828403121561545057600080fd5b8151611c8f81614426565b6001600160a01b0386811682526001600160401b0386166020830152841660408201526060810183905260a0608082018190526000906141a0908301846150b056fea164736f6c634300080f000a496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206900000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000280000000000000000000000000503cef47ce5e37aa62544a363bef3c9b62d421160000000000000000000000004066d196a423b2b3b8b054f4f40efb47a74e200c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000040000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x60806040526004361061039b5760003560e01c80636ba35d59116101dc5780639c649fdf11610102578063bca4a84c116100a0578063d547741f1161006f578063d547741f14610b45578063dec6603614610b65578063ec87621c14610b85578063fc66cfbf14610bb9576103a2565b8063bca4a84c14610ace578063beea8df814610ae1578063c470768614610b01578063c75b3d4114610b2e576103a2565b8063a217fddf116100dc578063a217fddf14610a28578063ac2e493614610a3d578063affed0e014610a7b578063b70ad44c14610abb576103a2565b80639c649fdf146109de5780639e369235146109f1578063a1a227fa14610a08576103a2565b80637e903aa61161017a5780638cde5946116101495780638cde59461461094a57806391d148541461096a578063926d7d7f1461098a57806395c54f5a146109be576103a2565b80637e903aa6146108e0578063825dc415146108f5578063859806cc1461091557806386ca9f751461092a576103a2565b8063772f8c2d116101b6578063772f8c2d146107df57806379e650621461080c5780637cd2bffc1461082c5780637cd5083f1461083f576103a2565b80636ba35d591461078c578063706bc66b1461079f57806375829def146107bf576103a2565b80633a68ff83116102c1578063547cad121161025f5780635c975abb1161022e5780635c975abb146106fa5780635fa294751461071257806369fe30e8146107255780636ac554711461075e576103a2565b8063547cad121461069057806354b3290d146106b05780635ab7afc6146106c75780635b5a66a7146106da576103a2565b806348d8b9a41161029b57806348d8b9a4146106335780634cb1e3411461064a5780634eecc1da1461066a5780635377f4621461067d576103a2565b80633a68ff83146105b85780633f979a9a146105da578063457bfa2f146105fa576103a2565b806316fcb97811610339578063248a9ca311610308578063248a9ca3146105355780632f2ff15d1461056557806336568abe1461058557806336a608cf146105a5576103a2565b806316fcb978146104c05780631bceb8d4146104d35780631e2c0314146105005780631f041ec614610520576103a2565b80630bcb4982116103755780630bcb4982146104255780630f4fb3731461044557806313a1667c14610480578063162dfb0d146104a0576103a2565b806301ffc9a7146103b057806304c39d1e146103e557806307598f6214610405576103a2565b366103a257005b3480156103ae57600080fd5b005b3480156103bc57600080fd5b506103d06103cb3660046143e3565b610c4c565b60405190151581526020015b60405180910390f35b3480156103f157600080fd5b506103ae61040036600461440d565b610c83565b34801561041157600080fd5b506103ae610420366004614446565b610e31565b6104386104333660046144a4565b610e6a565b6040516103dc919061453d565b34801561045157600080fd5b50610472610460366004614446565b60fe6020526000908152604090205481565b6040519081526020016103dc565b34801561048c57600080fd5b506103ae61049b366004614446565b610f4d565b3480156104ac57600080fd5b506103ae6104bb366004614550565b610f65565b6103ae6104ce3660046145df565b610f77565b3480156104df57600080fd5b506104726104ee366004614446565b60fd6020526000908152604090205481565b34801561050c57600080fd5b506103ae61051b36600461440d565b611047565b34801561052c57600080fd5b506103ae611055565b34801561054157600080fd5b5061047261055036600461440d565b60009081526065602052604090206001015490565b34801561057157600080fd5b506103ae61058036600461467e565b611067565b34801561059157600080fd5b506103ae6105a036600461467e565b611091565b6103ae6105b33660046145df565b61110b565b3480156105c457600080fd5b506105cd6111b9565b6040516103dc91906146e7565b3480156105e657600080fd5b506103ae6105f53660046146fa565b6111cb565b34801561060657600080fd5b506101095461061b906001600160a01b031681565b6040516001600160a01b0390911681526020016103dc565b34801561063f57600080fd5b506104726101025481565b34801561065657600080fd5b506103ae610665366004614446565b611228565b6103ae6106783660046145df565b611247565b6103ae61068b3660046145df565b611296565b34801561069c57600080fd5b506103ae6106ab366004614446565b6112c5565b3480156106bc57600080fd5b506104726101085481565b6104386106d5366004614726565b611322565b3480156106e657600080fd5b506103ae6106f5366004614446565b611502565b34801561070657600080fd5b5060975460ff166103d0565b6103ae6107203660046145df565b61152d565b34801561073157600080fd5b50610472610740366004614550565b61010060209081526000928352604080842090915290825290205481565b34801561076a57600080fd5b5061047261077936600461440d565b6101076020526000908152604090205481565b6103ae61079a3660046147bc565b6115a3565b3480156107ab57600080fd5b506103ae6107ba366004614446565b6115d1565b3480156107cb57600080fd5b506103ae6107da366004614446565b61160c565b3480156107eb57600080fd5b506104726107fa366004614446565b60fc6020526000908152604090205481565b34801561081857600080fd5b506103ae6108273660046146fa565b61162d565b61043861083a366004614726565b61168a565b34801561084b57600080fd5b506108a261085a366004614446565b60fb6020526000908152604090205460ff81169063ffffffff6101008204811691600160281b8104821691600160481b820416906001600160801b03600160681b9091041685565b60408051951515865263ffffffff94851660208701529284169285019290925290911660608301526001600160801b0316608082015260a0016103dc565b3480156108ec57600080fd5b506103ae61184d565b34801561090157600080fd5b506103ae6109103660046148f8565b6118a1565b34801561092157600080fd5b506103ae6119e7565b34801561093657600080fd5b506103ae6109453660046149a1565b6119f7565b34801561095657600080fd5b506103ae6109653660046149ca565b611ac9565b34801561097657600080fd5b506103d061098536600461467e565b611ae4565b34801561099657600080fd5b506104727fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc481565b3480156109ca57600080fd5b506103ae6109d936600461440d565b611b0f565b6104386109ec3660046149ec565b611b41565b3480156109fd57600080fd5b506104726101035481565b348015610a1457600080fd5b5060005461061b906001600160a01b031681565b348015610a3457600080fd5b50610472600081565b348015610a4957600080fd5b50610a6e610a5836600461440d565b6101066020526000908152604090205460ff1681565b6040516103dc9190614a4c565b348015610a8757600080fd5b5061010954610aa390600160a01b90046001600160401b031681565b6040516001600160401b0390911681526020016103dc565b6103ae610ac93660046145df565b611b54565b6103ae610adc3660046147bc565b611b6b565b348015610aed57600080fd5b506103ae610afc366004614446565b611b88565b348015610b0d57600080fd5b50610472610b1c366004614446565b60ff6020526000908152604090205481565b348015610b3a57600080fd5b506104726101015481565b348015610b5157600080fd5b506103ae610b6036600461467e565b611c33565b348015610b7157600080fd5b506103ae610b803660046146fa565b611c58565b348015610b9157600080fd5b506104727f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b348015610bc557600080fd5b50610c15610bd436600461440d565b61010a6020526000908152604090208054600182015460028301546003909301546001600160a01b039283169391831692811690600160a01b900460ff1685565b604080516001600160a01b03968716815294861660208601528401929092529092166060820152901515608082015260a0016103dc565b60006001600160e01b03198216637965db0b60e01b1480610c7d57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600260c95403610cae5760405162461bcd60e51b8152600401610ca590614a5a565b60405180910390fd5b600260c955610cbb611c96565b6000818152610106602052604090205460ff166001816003811115610ce257610ce2614517565b14158015610d0257506003816003811115610cff57610cff614517565b14155b610d0b57600080fd5b600082815261010a60209081526040808320815160a0808201845282546001600160a01b0390811680845260018501548216848801908152600286015485880190815260039096015492831660608087019190915260ff600160a01b90940484161515608080880191909152838b5260fb8a52888b2089519687018a52549485161515865263ffffffff610100860481169a87019a909a52600160281b85048a1698860198909852600160481b8404909816978401979097526001600160801b03600160681b909204919091169482019490945291519351909493610df39392918590611cee565b9050610e0d82602001518284606001518560800151611dfb565b505050600090815261010660205260409020805460ff19166003179055600160c955565b600260c95403610e535760405162461bcd60e51b8152600401610ca590614a5a565b600260c955610e623382611ea1565b50600160c955565b6000610e74611fde565b600260c95403610e965760405162461bcd60e51b8152600401610ca590614a5a565b600260c955610ea3612038565b81610ead8161207e565b6000610ebb85870187614c80565b90506000610f0d8260000151604001514684604001518a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120c592505050565b9050610f2b8989846000015160400151856000015160200151611dfb565b610f38818a8a60036120ff565b60019350505050600160c95595945050505050565b610f55611c96565b610f6161010482612172565b5050565b610f6d611c96565b610f618282611ea1565b6000610fe08686610f8e6080870160608801614446565b610fd8610f9e60208a018a614d24565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061218792505050565b60601c61218e565b905061103e87878787878787611036610ffc6020860186614d24565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061234f92505050565b60601c61236b565b50505050505050565b61104f611c96565b61010255565b61105d611c96565b6110656124c4565b565b6000828152606560205260409020600101546110828161251e565b61108c8383612528565b505050565b6001600160a01b03811633146111015760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610ca5565b610f6182826125ae565b600061115a86866111226080870160608801614446565b61112f6020890189614d6a565b600081811061114057611140614db3565b90506020020160208101906111559190614446565b61218e565b905061103e878787878787876111736020850185614d6a565b60018e80602001906111859190614d6a565b611190929150614ddf565b81811061119f5761119f614db3565b90506020020160208101906111b49190614446565b612615565b60606111c6610104612728565b905090565b6111d3611c96565b6001600160a01b038216600090815260fd602052604090205481101561120c57604051635909a3b560e11b815260040160405180910390fd5b6001600160a01b03909116600090815260fe6020526040902055565b611230611c96565b610108805460009182905590610f61908284612735565b600061115a868661125e6080870160608801614446565b61126b6020890189614d6a565b600081811061127c5761127c614db3565b90506020020160208101906112919190614446565b612761565b6000610fe086866112ad6080870160608801614446565b6112bd610f9e60208a018a614d24565b60601c612761565b6112cd611c96565b600080546001600160a01b0319166001600160a01b0383169081179091556040519081527f3f8223bcd8b3b875473e9f9e14e1ad075451a2b5ffd31591655da9a01516bf5e906020015b60405180910390a150565b600061132c611fde565b600260c9540361134e5760405162461bcd60e51b8152600401610ca590614a5a565b600260c9558161135d8161207e565b600061136b85870187614c80565b905060006113b982600001516040015189468a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120c592505050565b90506040518060a001604052808360000151606001516001600160a01b031681526020018b6001600160a01b031681526020018a81526020018360000151604001516001600160a01b03168152602001836000015160200151151581525061010a600083815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160030160146101000a81548160ff0219169083151502179055509050506114ec818b8b60026120ff565b5050600160c95550600098975050505050505050565b61150a611c96565b61010980546001600160a01b0319166001600160a01b0392909216919091179055565b600061154486866111226080870160608801614446565b905061103e8787878787878761155d6020850185614d6a565b60018e806020019061156f9190614d6a565b61157a929150614ddf565b81811061158957611589614db3565b905060200201602081019061159e9190614446565b61282c565b60006115c086866115ba6080870160608801614446565b8761218e565b905061103e8786868686868c61293f565b6115d9611c96565b6001600160a01b0381166116005760405163d92e233d60e01b815260040160405180910390fd5b610f6161010482611c7a565b611614612a9e565b61161f6000336125ae565b61162a600082612528565b50565b611635611c96565b6001600160a01b038216600090815260fe602052604090205481111561166e5760405163129c63a160e31b815260040160405180910390fd5b6001600160a01b03909116600090815260fd6020526040902055565b6000611694611fde565b600260c954036116b65760405162461bcd60e51b8152600401610ca590614a5a565b600260c9556116c3612038565b816116cd8161207e565b60006116db85870187614c80565b9050600061172982600001516040015189468a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120c592505050565b82516060908101516001600160a01b038116600090815260fb60209081526040808320815160a081018352905460ff811615158252610100810463ffffffff90811694830194909452600160281b8104841692820192909252600160481b820490921694820194909452600160681b9093046001600160801b031660808401529293506117bb929091908c908e611cee565b985060006117cc8360000151612ac6565b9050600183516080015160028111156117e7576117e7614517565b036117fe576117f98b828c8587612c43565b611835565b6002835160800151600281111561181757611817614517565b03611828576117f98b8b8486612d12565b6118358b828c8587612d3b565b6001945050505050600160c955979650505050505050565b611855611c96565b61010380546000918290559061186c908233612735565b604080518281523360208201527f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d9101611317565b6118a9611c96565b620f4240816020015163ffffffff1611156118d75760405163cd4e616760e01b815260040160405180910390fd5b620f4240816040015163ffffffff1611806118fe5750620f4240816060015163ffffffff16115b1561191c57604051630a81ff1360e21b815260040160405180910390fd5b6001600160a01b03909116600090815260fb602090815260409182902083518154928501519385015160608601516080909601516001600160801b0316600160681b026fffffffffffffffffffffffffffffffff60681b1963ffffffff978816600160481b026cffffffff00000000000000000019938916600160281b02939093166cffffffffffffffff000000000019989097166101000264ffffffff00199415159490941664ffffffffff19909616959095179290921795909516939093179390931716179055565b6119ef611c96565b611065612db2565b6119ff611c96565b6000816003811115611a1357611a13614517565b03611a315760405163b30d036f60e01b815260040160405180910390fd5b6000828152610106602052604090205460ff166001816003811115611a5857611a58614517565b1480611a7557506003816003811115611a7357611a73614517565b145b15611a935760405163e48fe4bf60e01b815260040160405180910390fd5b600083815261010660205260409020805483919060ff19166001836003811115611abf57611abf614517565b0217905550505050565b611ad1611c96565b6000918252610107602052604090912055565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611b17611c96565b620f4240811115611b3b5760405163cd4e616760e01b815260040160405180910390fd5b61010155565b6000611b4b611fde565b95945050505050565b6000611544868661125e6080870160608801614446565b60006115c08686611b826080870160608801614446565b87612761565b611b90611c96565b6001600160a01b038116600090815260ff602052604081205490819003611bca57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b038216600090815260ff6020526040812055611bee828233612735565b604080518281526001600160a01b03841660208201527f9216fa2f918153a5852ce98e7929c12cd94e0adeda8117f80e761c216157b27c910160405180910390a15050565b600082815260656020526040902060010154611c4e8161251e565b61108c83836125ae565b611c60612a9e565b610f61828233612735565b6001600160a01b03163b151590565b6000611c8f836001600160a01b038416612deb565b9392505050565b611cc07f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0833611ae4565b80611cd15750611cd1600033611ae4565b61106557604051633a4af34560e21b815260040160405180910390fd5b6000806000611cfe878787612e3a565b90925090506001600160a01b03881615611d5a57611d1c8183614ddf565b6001600160a01b03808616600090815261010060209081526040808320938d1683529290529081208054909190611d54908490614df6565b90915550505b6001600160a01b038416600090815260ff602052604081208054839290611d82908490614df6565b90915550506001600160a01b0388167f25471ec9f39b4ceb20d58f63c37f9c738011f0babcc4b6af69bdd82984ca5f8e82611dbd8186614ddf565b6040805192835260208301919091526001600160a01b0388169082015260600160405180910390a2611def8287614ddf565b98975050505050505050565b610109546001600160a01b038581169116148015611e1b57506001811515145b15611e905761010954604051632e1a7d4d60e01b8152600481018590526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015611e6757600080fd5b505af1158015611e7b573d6000803e3d6000fd5b50505050611e8b60008484612735565b611e9b565b611e9b848484612735565b50505050565b60006001600160a01b038216611f0c57506001600160a01b038216600081815260fc60209081526040808320805493905580518381529182019390935290917f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d910160405180910390a15b6001600160a01b0380831660009081526101006020908152604080832093871683529290522054611f3d9082614df6565b905080600003611f6057604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b03808316600090815261010060209081526040808320938716835292905290812055611f94828285612735565b604080518281526001600160a01b0384811660208301528516917f6f83ca8ce48e63b2a223b9f9e7ef1ea7bf3a8385c7a9bd63baae22963b2b26e0910160405180910390a2505050565b6000546001600160a01b031633146110655760405162461bcd60e51b815260206004820152601960248201527f63616c6c6572206973206e6f74206d65737361676520627573000000000000006044820152606401610ca5565b60975460ff16156110655760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610ca5565b6120a87fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc482611ae4565b61162a57604051633f0b607d60e11b815260040160405180910390fd5b6000848484846040516020016120de9493929190614e3a565b6040516020818303038152906040528051906020012090505b949350505050565b600084815261010660205260409020805482919060ff1916600183600381111561212b5761212b614517565b0217905550837fd75ce962bdb41de6ea8526caa7c0d7a0180c4255b67427804c125d8fcd0480cd84848460405161216493929190614e96565b60405180910390a250505050565b6000611c8f836001600160a01b038416612e7a565b6020015190565b60003332146121b057604051639f8129d160e01b815260040160405180910390fd5b6121b8612038565b610109546001600160a01b038381169116146122075760405162461bcd60e51b815260206004820152600e60248201526d0e8ded6cadc40dad2e6dac2e8c6d60931b6044820152606401610ca5565b8434101561224d5760405162461bcd60e51b8152602060048201526013602482015272185b5bdd5b9d081a5b9cdd59999a58da595b9d606a1b6044820152606401610ca5565b61010960009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b15801561229e57600080fd5b505af11580156122b2573d6000803e3d6000fd5b505050506001600160a01b038416600090815260fb6020908152604091829020825160a081018452905460ff811615158252610100810463ffffffff90811693830193909352600160281b8104831693820193909352600160481b83049091166060820152600160681b9091046001600160801b031660808201528691506123459085906001600160401b038816612f6d565b611b4b9190614ddf565b6000808251600c6123609190614df6565b929092015192915050565b600060405180610100016040528061238c888060200190610f9e9190614d24565b606090811c8252602082018b90526001600160401b038a166040830152016123bb6123b688614eba565b612ac6565b6001600160a01b0316815261010087013560208201523360408201526060908101906123ed9060808901908901614446565b6001600160a01b0316815260209081019061240a90890189614446565b6001600160a01b03169052905060146124266020880188614d24565b9050116124455760405162461bcd60e51b8152600401610ca590614ec6565b60008061245a61245489614eef565b8b612fa3565b91509150600061247c8c85604001518a8a6124736130a3565b8b8b898b6130ef565b9050807f6fd6f0d249b4127a9fbf18c57212c8fb026d40b6d4501397929fd57f39608649856040516124ae9190614f5e565b60405180910390a2505050505050505050505050565b6124cc612038565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586125013390565b6040516001600160a01b03909116815260200160405180910390a1565b61162a813361321f565b6125328282611ae4565b610f615760008281526065602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561256a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6125b88282611ae4565b15610f615760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006040518061010001604052808780602001906126339190614d6a565b600081811061264457612644614db3565b90506020020160208101906126599190614446565b6001600160a01b03168152602001898152602001886001600160401b03168152602001612689876123b690614eba565b6001600160a01b0316815261010087013560208201523360408201526060908101906126bb9060808901908901614446565b6001600160a01b031681526020908101906126d890890189614446565b6001600160a01b03169052905060016126f46020880188614d6a565b9050116127135760405162461bcd60e51b8152600401610ca590614ec6565b60008061245a61272289614fc4565b8b613283565b60606000611c8f83613429565b6001600160a01b03831661274d5761108c8183613485565b61108c6001600160a01b038416828461359e565b600033321461278357604051639f8129d160e01b815260040160405180910390fd5b61278b612038565b6127a06001600160a01b038316333088613601565b6001600160a01b038316600090815260fb6020908152604091829020825160a081018452905460ff811615158252610100810463ffffffff90811693830193909352600160281b8104831693820193909352600160481b83049091166060820152600160681b9091046001600160801b03166080820152611b4b9084906001600160401b038716612f6d565b600060405180610100016040528087806020019061284a9190614d6a565b600081811061285b5761285b614db3565b90506020020160208101906128709190614446565b6001600160a01b03168152602001898152602001886001600160401b031681526020016128a0876123b690614eba565b6001600160a01b0316815261010087013560208201523360408201526060908101906128d29060808901908901614446565b6001600160a01b031681526020908101906128ef90890189614446565b6001600160a01b031690529050600161290b6020880188614d6a565b90501161292a5760405162461bcd60e51b8152600401610ca590614ec6565b60008061245a6129398961504e565b8b613639565b6000604051806101000160405280876001600160a01b03168152602001838152602001886001600160401b0316815260200161297e876123b690614eba565b6001600160a01b0316815260200186610100013581526020018660400160208101906129aa9190614446565b6001600160a01b031681526020016129c86080880160608901614446565b6001600160a01b0316815260200160006001600160a01b03168152509050466001600160401b0316816040015103612a325760405162461bcd60e51b815260206004820152600d60248201526c1cd85b594818da185a5b881a59609a1b6044820152606401610ca5565b6000612a598983604001518888612a476130a3565b898860000151896020015160016130ef565b9050807f6fd6f0d249b4127a9fbf18c57212c8fb026d40b6d4501397929fd57f3960864983604051612a8b9190614f5e565b60405180910390a2505050505050505050565b612aa9600033611ae4565b611065576040516355098f2760e01b815260040160405180910390fd5b6000600182608001516002811115612ae057612ae0614517565b03612b445760148260c001515111612b2e5760405162461bcd60e51b8152602060048201526011602482015270191cdd081cddd85c08195e1c1958dd1959607a1b6044820152606401610ca5565b612b3b8260c0015161234f565b60601c92915050565b600082608001516002811115612b5c57612b5c614517565b03612bdc5760018260a001515111612baa5760405162461bcd60e51b8152602060048201526011602482015270191cdd081cddd85c08195e1c1958dd1959607a1b6044820152606401610ca5565b60a08201518051612bbd90600190614ddf565b81518110612bcd57612bcd614db3565b60200260200101519050919050565b8160a0015151600114612c275760405162461bcd60e51b8152602060048201526013602482015272191cdd08189c9a5919d948195e1c1958dd1959606a1b6044820152606401610ca5565b8160a00151600081518110612bcd57612bcd614db3565b919050565b805160c0015160200151859060601c612c5c828261373c565b604080516080810182528451516001600160a01b03168152845160c001516020820152845160e0015191810191909152835161010001516060820152600080612ca58389612fa3565b915091508115612cdd57612ccb8982886000015160400151896000015160200151611dfb565b612cd8878a8360016120ff565b612d06565b612cf98a89886000015160400151896000015160200151611dfb565b612d06878b8a60036120ff565b50505050505050505050565b612d2e8484836000015160400151846000015160200151611dfb565b611e9b82858560016120ff565b84816000015160a00151600081518110612d5757612d57614db3565b6020026020010151612d69828261373c565b604080516080810182528451516001600160a01b03168152845160a001516020820152845160e0015191810191909152835161010001516060820152600080612ca58389613639565b612dba61379d565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33612501565b6000818152600183016020526040812054612e3257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c7d565b506000610c7d565b600080846000015115612e5b57612e5184866137e6565b9092509050612e72565b612e6c8461010154620f4240613837565b91508190505b935093915050565b60008181526001830160205260408120548015612f63576000612e9e600183614ddf565b8554909150600090612eb290600190614ddf565b9050818114612f17576000866000018281548110612ed257612ed2614db3565b9060005260206000200154905080876000018481548110612ef557612ef5614db3565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612f2857612f2861509a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c7d565b6000915050610c7d565b6000818152610107602052604081205461010880548291908490612f92908490614df6565b9091555081905061234586866138e9565b81516000908190612fb790610104906139e9565b612fc65750600090508061309c565b612fe6612fd885602001516020015190565b60601c848660000151613a0b565b6040805160a081018252602080870151825230908201528582015181830152606080820186905286015160808201528551915163c04b8d5960e01b815290916001600160a01b03169063c04b8d59906130439084906004016150dc565b6020604051808303816000875af192505050801561307e575060408051601f3d908101601f1916820190925261307b91810190615134565b60015b61308f57600080925092505061309c565b60019350915061309c9050565b9250929050565b6000610109601481819054906101000a90046001600160401b03166130c79061514d565b91906101000a8154816001600160401b0302191690836001600160401b031602179055905090565b6000816131305760405162461bcd60e51b815260206004820152600f60248201526e1cdc98c81cddd85c0819985a5b1959608a1b6044820152606401610ca5565b6001600160a01b038416600090815260fd60205260409020548310156131885760405162461bcd60e51b815260206004820152600d60248201526c3632b9b9903a3430b71036b4b760991b6044820152606401610ca5565b6001600160a01b038416600090815260fe602052604090205415613201576001600160a01b038416600090815260fe60205260409020548311156132015760405162461bcd60e51b815260206004820152601060248201526f0cee4cac2e8cae440e8d0c2dc40dac2f60831b6044820152606401610ca5565b6132118a8a8a8a8a8a8a8a613b6f565b9a9950505050505050505050565b6132298282611ae4565b610f6157613241816001600160a01b03166014613c61565b61324c836020613c61565b60405160200161325d929190615173565b60408051601f198184030181529082905262461bcd60e51b8252610ca5916004016151e8565b8151600090819061329790610104906139e9565b6132a65750600090508061309c565b6132d384602001516000815181106132c0576132c0614db3565b6020026020010151848660000151613a0b565b60208401518051600091906132ea90600190614ddf565b815181106132fa576132fa614db3565b60209081029190910101516040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561334f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133739190615134565b905061338786600001518760400151613dfc565b506040516370a0823160e01b815230600482015260009082906001600160a01b038516906370a0823190602401602060405180830381865afa1580156133d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133f59190615134565b6133ff9190614ddf565b90508660600151811061341a5760019450925061309c915050565b50600096879650945050505050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561347957602002820191906000526020600020905b815481526020019060010190808311613465575b50505050509050919050565b804710156134d55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610ca5565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613522576040519150601f19603f3d011682016040523d82523d6000602084013e613527565b606091505b505090508061108c5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610ca5565b6040516001600160a01b03831660248201526044810182905261108c90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613e3e565b6040516001600160a01b0380851660248301528316604482015260648101829052611e9b9085906323b872dd60e01b906084016135ca565b8151600090819061364d90610104906139e9565b61365c5750600090508061309c565b61367684602001516000815181106132c0576132c0614db3565b83600001516001600160a01b03166338ed173984866060015187602001513089604001516040518663ffffffff1660e01b81526004016136ba9594939291906151fb565b6000604051808303816000875af19250505080156136fa57506040513d6000823e601f3d908101601f191682016040526136f79190810190615237565b60015b6137095750600090508061309c565b6001816001835161371a9190614ddf565b8151811061372a5761372a614db3565b6020026020010151925092505061309c565b806001600160a01b0316826001600160a01b031614610f615760405162461bcd60e51b815260206004820152601b60248201527f666972737420746f6b656e206d757374206265207472616e73697400000000006044820152606401610ca5565b60975460ff166110655760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610ca5565b6000806000836020015163ffffffff16111561309c5761381484846020015163ffffffff16620f4240613837565b915061382e82846040015163ffffffff16620f4240613837565b90509250929050565b6000808060001985870985870292508281108382030391505080600003613870576000841161386557600080fd5b508290049050611c8f565b80841161387c57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008060008360000151156139715760808401516001600160801b03169150811561396c57620f4240846060015163ffffffff168361392891906152bc565b61393291906152db565b905061393e8183614ddf565b6001600160a01b038616600090815260fc602052604081208054909190613966908490614df6565b90915550505b613979565b505061010254805b80610103600082825461398c9190614df6565b90915550506001600160a01b0385167f3a84e53f89d2f7779a9c9a54779858ae0eb0b7760d607b445b6fd175c30a04d4826139c78186614ddf565b6040805192835260208301919091520160405180910390a2611b4b8234614ddf565b6001600160a01b03811660009081526001830160205260408120541515611c8f565b604051636eb1769f60e11b81523060048201526001600160a01b038281166024830152849160009183169063dd62ed3e90604401602060405180830381865afa158015613a5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a809190615134565b905083811015613b685780600003613aad57613aa86001600160a01b03831684600019613f10565b613b68565b60405163095ea7b360e01b81526001600160a01b038481166004830152600019602483015283169063095ea7b3906044016020604051808303816000875af1925050508015613b19575060408051601f3d908101601f19168201909252613b16918101906152fd565b60015b613b4857613b326001600160a01b038316846000613f10565b613aa86001600160a01b03831684600019613f10565b80613b6657604051633e3f8f7360e01b815260040160405180910390fd5b505b5050505050565b600080613b7f60a0890189614d6a565b905011613bc45760405162461bcd60e51b81526020600482015260136024820152720cadae0e8f240c8e6e840e6eec2e040e0c2e8d606b1b6044820152606401610ca5565b6000604051806060016040528089613bdb90614eba565b8152610109546001600160401b03600160a01b9091048116602080840191909152908c166040928301529051613c12929101615323565b6040516020818303038152906040529050613c41886040016020810190613c399190614446565b468b846120c5565b9150613c538a85858c8a8c878c614025565b505098975050505050505050565b60606000613c708360026152bc565b613c7b906002614df6565b6001600160401b03811115613c9257613c9261482c565b6040519080825280601f01601f191660200182016040528015613cbc576020820181803683370190505b509050600360fc1b81600081518110613cd757613cd7614db3565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613d0657613d06614db3565b60200101906001600160f81b031916908160001a9053506000613d2a8460026152bc565b613d35906001614df6565b90505b6001811115613dad576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613d6957613d69614db3565b1a60f81b828281518110613d7f57613d7f614db3565b60200101906001600160f81b031916908160001a90535060049490941c93613da68161540b565b9050613d38565b508315611c8f5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610ca5565b6060611c8f83836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250614058565b6000613e93826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166140589092919063ffffffff16565b80519091501561108c5780806020019051810190613eb191906152fd565b61108c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ca5565b801580613f8a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015613f64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f889190615134565b155b613ff55760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610ca5565b6040516001600160a01b03831660248201526044810182905261108c90849063095ea7b360e01b906064016135ca565b600061404b8989898989898960008054906101000a90046001600160a01b03168a614067565b9998505050505050505050565b60606120f7848460008561407a565b60006132118a8a8a8a8a8a8a8a8a6141ab565b6060824710156140db5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ca5565b6001600160a01b0385163b6141325760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ca5565b600080866001600160a01b0316858760405161414e9190615422565b60006040518083038185875af1925050503d806000811461418b576040519150601f19603f3d011682016040523d82523d6000602084013e614190565b606091505b50915091506141a08282866143aa565b979650505050505050565b600080836001600160a01b03166382980dc46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156141ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614210919061543e565b905061421d8a8a83613a0b565b60405163a5977fbb60e01b81526001600160a01b038c811660048301528b81166024830152604482018b90526001600160401b03808b1660648401528916608483015263ffffffff881660a483015282169063a5977fbb9060c401600060405180830381600087803b15801561429257600080fd5b505af11580156142a6573d6000803e3d6000fd5b50506040516bffffffffffffffffffffffff1930606090811b821660208401528f811b821660348401528e901b166048820152605c81018c90526001600160c01b031960c08c811b8216607c8401528b811b8216608484015246901b16608c82015260009250609401905060405160208183030381529060405280519060200120905060008651111561439b57846001600160a01b0316634289fbb3858e8c86868c6040518763ffffffff1660e01b815260040161436895949392919061545b565b6000604051808303818588803b15801561438157600080fd5b505af1158015614395573d6000803e3d6000fd5b50505050505b9b9a5050505050505050505050565b606083156143b9575081611c8f565b8251156143c95782518084602001fd5b8160405162461bcd60e51b8152600401610ca591906151e8565b6000602082840312156143f557600080fd5b81356001600160e01b031981168114611c8f57600080fd5b60006020828403121561441f57600080fd5b5035919050565b6001600160a01b038116811461162a57600080fd5b8035612c3e81614426565b60006020828403121561445857600080fd5b8135611c8f81614426565b60008083601f84011261447557600080fd5b5081356001600160401b0381111561448c57600080fd5b60208301915083602082850101111561309c57600080fd5b6000806000806000608086880312156144bc57600080fd5b85356144c781614426565b94506020860135935060408601356001600160401b038111156144e957600080fd5b6144f588828901614463565b909450925050606086013561450981614426565b809150509295509295909350565b634e487b7160e01b600052602160045260246000fd5b6003811061162a5761162a614517565b6020810161454a8361452d565b91905290565b6000806040838503121561456357600080fd5b823561456e81614426565b9150602083013561457e81614426565b809150509250929050565b80356001600160401b0381168114612c3e57600080fd5b6000608082840312156145b257600080fd5b50919050565b600061012082840312156145b257600080fd5b803563ffffffff81168114612c3e57600080fd5b60008060008060008060c087890312156145f857600080fd5b863561460381614426565b95506020870135945061461860408801614589565b935060608701356001600160401b038082111561463457600080fd5b6146408a838b016145a0565b9450608089013591508082111561465657600080fd5b5061466389828a016145b8565b92505061467260a088016145cb565b90509295509295509295565b6000806040838503121561469157600080fd5b82359150602083013561457e81614426565b600081518084526020808501945080840160005b838110156146dc5781516001600160a01b0316875295820195908201906001016146b7565b509495945050505050565b602081526000611c8f60208301846146a3565b6000806040838503121561470d57600080fd5b823561471881614426565b946020939093013593505050565b600080600080600080600060c0888a03121561474157600080fd5b873561474c81614426565b9650602088013561475c81614426565b95506040880135945061477160608901614589565b935060808801356001600160401b0381111561478c57600080fd5b6147988a828b01614463565b90945092505060a08801356147ac81614426565b8091505092959891949750929550565b60008060008060008060c087890312156147d557600080fd5b86356147e081614426565b9550602087013594506147f560408801614589565b9350606087013561480581614426565b925060808701356001600160401b0381111561482057600080fd5b61466389828a016145b8565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b03811182821017156148645761486461482c565b60405290565b60405161012081016001600160401b03811182821017156148645761486461482c565b604051608081016001600160401b03811182821017156148645761486461482c565b604051601f8201601f191681016001600160401b03811182821017156148d7576148d761482c565b604052919050565b801515811461162a57600080fd5b8035612c3e816148df565b60008082840360c081121561490c57600080fd5b833561491781614426565b925060a0601f198201121561492b57600080fd5b50614934614842565b6020840135614942816148df565b8152614950604085016145cb565b6020820152614961606085016145cb565b6040820152614972608085016145cb565b606082015260a08401356001600160801b038116811461499157600080fd5b6080820152919491935090915050565b600080604083850312156149b457600080fd5b8235915060208301356004811061457e57600080fd5b600080604083850312156149dd57600080fd5b50508035926020909101359150565b600080600080600060808688031215614a0457600080fd5b8535614a0f81614426565b9450614a1d60208701614589565b935060408601356001600160401b038111156144e957600080fd5b60048110614a4857614a48614517565b9052565b60208101610c7d8284614a38565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b803560038110612c3e57600080fd5b60006001600160401b03821115614ab957614ab961482c565b5060051b60200190565b600082601f830112614ad457600080fd5b81356020614ae9614ae483614aa0565b6148af565b82815260059290921b84018101918181019086841115614b0857600080fd5b8286015b84811015614b2c578035614b1f81614426565b8352918301918301614b0c565b509695505050505050565b600082601f830112614b4857600080fd5b81356001600160401b03811115614b6157614b6161482c565b614b74601f8201601f19166020016148af565b818152846020838601011115614b8957600080fd5b816020850160208301376000918101602001919091529392505050565b60006101208284031215614bb957600080fd5b614bc161486a565b9050614bcc8261443b565b8152614bda602083016148ed565b6020820152614beb6040830161443b565b6040820152614bfc6060830161443b565b6060820152614c0d60808301614a91565b608082015260a08201356001600160401b0380821115614c2c57600080fd5b614c3885838601614ac3565b60a084015260c0840135915080821115614c5157600080fd5b50614c5e84828501614b37565b60c08301525060e082013560e082015261010080830135818301525092915050565b600060208284031215614c9257600080fd5b81356001600160401b0380821115614ca957600080fd5b9083019060608286031215614cbd57600080fd5b604051606081018181108382111715614cd857614cd861482c565b604052823582811115614cea57600080fd5b614cf687828601614ba6565b825250614d0560208401614589565b6020820152614d1660408401614589565b604082015295945050505050565b6000808335601e19843603018112614d3b57600080fd5b8301803591506001600160401b03821115614d5557600080fd5b60200191503681900382131561309c57600080fd5b6000808335601e19843603018112614d8157600080fd5b8301803591506001600160401b03821115614d9b57600080fd5b6020019150600581901b360382131561309c57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082821015614df157614df1614dc9565b500390565b60008219821115614e0957614e09614dc9565b500190565b60005b83811015614e29578181015183820152602001614e11565b83811115611e9b5750506000910152565b6bffffffffffffffffffffffff198560601b16815260006001600160401b0360c01b808660c01b166014840152808560c01b16601c840152508251614e86816024850160208701614e0e565b9190910160240195945050505050565b6001600160a01b038416815260208101839052606081016120f76040830184614a38565b6000610c7d3683614ba6565b6020808252600f908201526e0cadae0e8f240e6eec2e040e0c2e8d608b1b604082015260600190565b600060808236031215614f0157600080fd5b614f0961488d565b8235614f1481614426565b815260208301356001600160401b03811115614f2f57600080fd5b614f3b36828601614b37565b602083015250604083013560408201526060830135606082015280915050919050565b81516001600160a01b03908116825260208084015190830152604080840151908301526060808401518216908301526080808401519083015260a08381015182169083015260c08084015182169083015260e09283015116918101919091526101000190565b600060808236031215614fd657600080fd5b614fde61488d565b8235614fe981614426565b815260208301356001600160401b038082111561500557600080fd5b61501136838701614ac3565b6020840152604085013591508082111561502a57600080fd5b5061503736828601614b37565b604083015250606092830135928101929092525090565b60006080823603121561506057600080fd5b61506861488d565b823561507381614426565b815260208301356001600160401b0381111561508e57600080fd5b614f3b36828601614ac3565b634e487b7160e01b600052603160045260246000fd5b600081518084526150c8816020860160208601614e0e565b601f01601f19169290920160200192915050565b602081526000825160a060208401526150f860c08401826150b0565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60006020828403121561514657600080fd5b5051919050565b60006001600160401b0380831681810361516957615169614dc9565b6001019392505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516151ab816017850160208801614e0e565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516151dc816028840160208801614e0e565b01602801949350505050565b602081526000611c8f60208301846150b0565b85815284602082015260a06040820152600061521a60a08301866146a3565b6001600160a01b0394909416606083015250608001529392505050565b6000602080838503121561524a57600080fd5b82516001600160401b0381111561526057600080fd5b8301601f8101851361527157600080fd5b805161527f614ae482614aa0565b81815260059190911b8201830190838101908783111561529e57600080fd5b928401925b828410156141a0578351825292840192908401906152a3565b60008160001904831182151516156152d6576152d6614dc9565b500290565b6000826152f857634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561530f57600080fd5b8151611c8f816148df565b614a488161452d565b6020815260008251606060208401526153486080840182516001600160a01b03169052565b6020810151151560a084015260408101516001600160a01b0390811660c085015260608201511660e084015260808101516101006153888186018361531a565b60a08301516101208681015291506153a46101a08601836146a3565b915060c0830151607f19868403016101408701526153c283826150b0565b60e0850151610160880152919093015161018086015260208601516001600160401b03811660408701529250905060408501516001600160401b038116606086015291506120f7565b60008161541a5761541a614dc9565b506000190190565b60008251615434818460208701614e0e565b9190910192915050565b60006020828403121561545057600080fd5b8151611c8f81614426565b6001600160a01b0386811682526001600160401b0386166020830152841660408201526060810183905260a0608082018190526000906141a0908301846150b056fea164736f6c634300080f000a

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

00000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000280000000000000000000000000503cef47ce5e37aa62544a363bef3c9b62d421160000000000000000000000004066d196a423b2b3b8b054f4f40efb47a74e200c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000040000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _fixedCryptoFee (uint256): 1000000000000000
Arg [1] : _RubicPlatformFee (uint256): 3000
Arg [2] : _routers (address[]): 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D,0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F,0xE592427A0AEce92De3Edee1F18E0157C05861564,0x1111111254fb6c44bAC0beD2854e76F90643097d

-----Encoded View---------------
21 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000038d7ea4c68000
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000bb8
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000200
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000220
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000240
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000260
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000280
Arg [8] : 000000000000000000000000503cef47ce5e37aa62544a363bef3c9b62d42116
Arg [9] : 0000000000000000000000004066d196a423b2b3b8b054f4f40efb47a74e200c
Arg [10] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [12] : 0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d
Arg [13] : 000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f
Arg [14] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [15] : 0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [17] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [18] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [19] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [20] : 0000000000000000000000000000000000000000000000000000000000000000


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  ]
[ 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.