Contract 0x24455aa55ded7728783c9474be8ea2f5c935f8eb 2

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xd131969e8ed677758ebf0f7b37503122fa3f27acaee40f3ad15bdca0bd1554cbInitialize135766502022-06-03 3:21:16190 days 2 hrs ago0xb779daead6031ef189cad4ac438c991efe7635a7 IN 0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH0.000485136121 ETH
0x3d2cc01c5847d335a9a7a1a7835241c8a7e935922d096fb1f801be4a146785db0x6080604078890272022-03-14 13:37:12270 days 15 hrs ago0xd6f0dabbbccd143f7d526a82ca176b5395ccc844 IN  Create: DeBridgeGate0 ETH0.020177921556 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x5129e49b9807697c0318ba9c641ead47765789e62278eccd9ac9d543ef7661ac449914042022-12-10 4:19:281 hr 10 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x5d910b161d67a4a361bc4950e41ee4f578efc1a9f14b4d3468faa4675ac14942449887052022-12-10 3:56:421 hr 32 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x1b14ed8b716e9ce7279b327e8dc93c143988f32ed0d7f0c54355d2fd6ad802d2449875382022-12-10 3:48:121 hr 41 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x1893b54be95da50a4d497ce04b3618cb0f0de8a636cd5324ed017af60b819d58449675562022-12-10 1:08:074 hrs 21 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xd86c089aeb407d34776c0f8e94cea02a89618639d5a159692d0c0be6711d3392449669892022-12-10 1:03:034 hrs 26 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x83502ea35abbc58df31be36192b5284496c08aa93d5e0e291745d9749b2d674a449667342022-12-10 1:00:474 hrs 28 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x86cc84c2c0856d8b6ec62c65e53e17c5622d4ce3185f9337697fbe7aa5772efc449646882022-12-10 0:41:544 hrs 47 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xc56a3e6e7d44f40bee140189dfe6870ca1df9bc9e4cc1c4400349291f3904349449640902022-12-10 0:36:424 hrs 52 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x0a2285308d6d99cd43f03f488ed716f3b2ed2aa4fbad65da5e0b9842a372fa6d449613942022-12-10 0:14:395 hrs 14 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x3ad91ac72c3eb5349068399aa0a2c71d5c3eca0952b4d4acaee57988d6f154e7449542182022-12-09 23:14:176 hrs 15 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xe6afaebe69192f2d11178bc883ef4c86a2fc40aa6934ba491ee8bd603b6d2133449517602022-12-09 22:53:526 hrs 35 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x38f812d6b13ed436d20a77c3d108eaa96adb12c4ea61705ae2c9b2607f00dd80449427562022-12-09 21:45:237 hrs 44 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x4e4decaaa89d23c7f37d3bf09bde8c1ef5f5587206596d7da7f81345818a797d449423802022-12-09 21:42:437 hrs 46 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x5d5bc244afb1cd7caaa1cf5c08973a33498159c86b2340c9ea75d657d30c266f449414142022-12-09 21:36:037 hrs 53 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xf8580aa2904c328ea7f226fd168a279cd406270932634a118fb8c031d7dda32e449404412022-12-09 21:29:168 hrs ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xf707a2070c7f8f4486c7f6a4c20f308cb6f45176da3c0d4ac6b7e3c8ccd0de2a449123692022-12-09 18:25:5311 hrs 3 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xf697ec12c7c012b887269c782f32941c63d5c9b125f43171c78ab38ae7966e52449106962022-12-09 18:15:3211 hrs 14 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x5a316a2865562c7c1cae954a2bc2107bcb612bb73b1619de159ccfd29adbf961449068112022-12-09 17:52:1211 hrs 37 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xa4cc2da6dc670f0982a0e8f80e89e3a8754106d06b9c0c98ed7904fea3ffcde6449049262022-12-09 17:39:3811 hrs 49 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x03f8c91a461c142d77c1e0ee338e75bb40b7f95a984ba1f4c2b69a5a1cdf0b58448994222022-12-09 17:08:0412 hrs 21 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x2e212b64f6d618468e6c80833274bea2248c85c8eda6bb7f2f8c6d5634b8b3b5448894162022-12-09 16:19:4713 hrs 9 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xc3e8d9eeeae9579e7fee5e6bd954914b1eb4aca4749396cbcea9b7810e443652448840722022-12-09 15:56:5213 hrs 32 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x4306996b987a3e4f965e7a1f6a6f038dbc5b9b830e1f1842ca5d2ecded97b559448797312022-12-09 15:36:4813 hrs 52 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0xc9d9e250efd677a85ff778009b80c8c598175066e8c834a790b09b724b589e68448784062022-12-09 15:29:4313 hrs 59 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
0x590e68967713bd2a631617bdf796ffdfc6b0686803c9186c96752022d21d9ea7448749542022-12-09 15:11:2414 hrs 18 mins ago deBridgeGate0x24455aa55ded7728783c9474be8ea2f5c935f8eb0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DeBridgeGate

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 29 : DeBridgeGate.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.7;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "../interfaces/IERC20Permit.sol";
import "../interfaces/IDeBridgeToken.sol";
import "../interfaces/IDeBridgeTokenDeployer.sol";
import "../interfaces/ISignatureVerifier.sol";
import "../interfaces/IWETH.sol";
import "../interfaces/IDeBridgeGate.sol";
import "../interfaces/ICallProxy.sol";
import "../interfaces/IFlashCallback.sol";
import "../libraries/SignatureUtil.sol";
import "../libraries/Flags.sol";
import "../interfaces/IWethGate.sol";

/// @dev Contract for assets transfers. The user can transfer the asset to any of the approved chains.
/// The admin manages the assets, fees and other important protocol parameters.
contract DeBridgeGate is
    Initializable,
    AccessControlUpgradeable,
    PausableUpgradeable,
    ReentrancyGuardUpgradeable,
    IDeBridgeGate
{
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using SignatureUtil for bytes;
    using Flags for uint256;

    /* ========== STATE VARIABLES ========== */

    /// @dev Basis points or bps, set to 10 000 (equal to 1/10000). Used to express relative values (fees)
    uint256 public constant BPS_DENOMINATOR = 10000;
    /// @dev Role allowed to stop transfers
    bytes32 public constant GOVMONITORING_ROLE = keccak256("GOVMONITORING_ROLE");

    /// @dev prefix to calculation submissionId
    uint256 public constant SUBMISSION_PREFIX = 1;
    /// @dev prefix to calculation deployId
    uint256 public constant DEPLOY_PREFIX = 2;

    /// @dev Address of IDeBridgeTokenDeployer contract
    address public deBridgeTokenDeployer;
    /// @dev Current signature verifier address to verify signatures.
    address public signatureVerifier;
    /// @dev Minimal required confirmations in case sent amount is big, have no effect if less than SignatureVerifier.minConfirmations
    uint8 public excessConfirmations;
    /// @dev Flash loan fee in basis points (1/10000)
    uint256 public flashFeeBps;
    /// @dev outgoing submissions count
    uint256 public nonce;

    /// @dev Maps debridgeId (see getDebridgeId) => bridge-specific information.
    mapping(bytes32 => DebridgeInfo) public getDebridge;
    /// @dev Maps debridgeId (see getDebridgeId) => fee information
    mapping(bytes32 => DebridgeFeeInfo) public getDebridgeFeeInfo;
    /// @dev Returns whether the transfer with the submissionId was claimed.
    /// submissionId is generated in getSubmissionIdFrom
    mapping(bytes32 => bool) public override isSubmissionUsed;
    /// @dev Returns whether the transfer with the submissionId is blocked.
    mapping(bytes32 => bool) public isBlockedSubmission;
    /// @dev Maps debridgeId (see getDebridgeId) to threshold amount after which
    /// Math.max(excessConfirmations,SignatureVerifier.minConfirmations) is used instead of
    /// SignatureVerifier.minConfirmations
    mapping(bytes32 => uint256) public getAmountThreshold;
    /// @dev Whether the chain for the asset is supported to send
    mapping(uint256 => ChainSupportInfo) public getChainToConfig;
    /// @dev Whether the chain for the asset is supported to claim
    mapping(uint256 => ChainSupportInfo) public getChainFromConfig;
    /// @dev Fee discount for address
    mapping(address => DiscountInfo) public feeDiscount;
    /// @dev Returns native token info by wrapped token address
    mapping(address => TokenInfo) public override getNativeInfo;

    /// @dev Return DefiController that can supply liquidity to staking strategies (AAVE, Compound, etc.)
    address public defiController;
    /// @dev Returns proxy to convert the collected fees and transfer to Ethereum network to treasury
    address public feeProxy;
    /// @dev Returns address of the proxy to execute user's calls.
    address public callProxy;
    /// @dev Returns contract for wrapped native token.
    IWETH public weth;

    /// @dev Contract address that can override globalFixedNativeFee
    address public feeContractUpdater;

    /// @dev Fallback fixed fee in native asset, used if a chain fixed fee is set to 0
    uint256 public globalFixedNativeFee;
    /// @dev Fallback transfer fee in BPS, used if a chain transfer fee is set to 0
    uint16 public globalTransferFeeBps;

    /// @dev WethGate contract, that is used for weth withdraws affected by EIP1884
    IWethGate public wethGate;
    /// @dev Locker for claim method
    uint256 public lockedClaim;

    /* ========== ERRORS ========== */

    error FeeProxyBadRole();
    error DefiControllerBadRole();
    error FeeContractUpdaterBadRole();
    error AdminBadRole();
    error GovMonitoringBadRole();
    error DebridgeNotFound();

    error WrongChainTo();
    error WrongChainFrom();
    error WrongArgument();
    error WrongAutoArgument();

    error TransferAmountTooHigh();

    error NotSupportedFixedFee();
    error TransferAmountNotCoverFees();
    error InvalidTokenToSend();

    error SubmissionUsed();
    error SubmissionBlocked();

    error AssetAlreadyExist();
    error ZeroAddress();

    error ProposedFeeTooHigh();
    error FlashFeeNotPaid();

    error NotEnoughReserves();
    error EthTransferFailed();

    /* ========== MODIFIERS ========== */

    modifier onlyFeeProxy() {
        if (feeProxy != msg.sender) revert FeeProxyBadRole();
        _;
    }

    modifier onlyDefiController() {
        if (defiController != msg.sender) revert DefiControllerBadRole();
        _;
    }

    modifier onlyFeeContractUpdater() {
        if (feeContractUpdater != msg.sender) revert FeeContractUpdaterBadRole();
        _;
    }

    modifier onlyAdmin() {
        if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert AdminBadRole();
        _;
    }

    modifier onlyGovMonitoring() {
        if (!hasRole(GOVMONITORING_ROLE, msg.sender)) revert GovMonitoringBadRole();
        _;
    }

    /* ========== CONSTRUCTOR  ========== */

    /// @dev Constructor that initializes the most important configurations.
    /// @param _excessConfirmations minimal required confirmations in case of too many confirmations
    /// @param _weth wrapped native token contract
    function initialize(
        uint8 _excessConfirmations,
        IWETH _weth
    ) public initializer {
        excessConfirmations = _excessConfirmations;
        weth = _weth;

        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        __ReentrancyGuard_init();
    }

    /* ========== send, claim ========== */

    /// @inheritdoc IDeBridgeGate
    function send(
        address _tokenAddress,
        uint256 _amount,
        uint256 _chainIdTo,
        bytes memory _receiver,
        bytes memory _permit,
        bool _useAssetFee,
        uint32 _referralCode,
        bytes calldata _autoParams
    ) external payable override nonReentrant whenNotPaused {
        bytes32 debridgeId;
        FeeParams memory feeParams;
        uint256 amountAfterFee;
        // the amount will be reduced by the protocol fee
        (amountAfterFee, debridgeId, feeParams) = _send(
            _permit,
            _tokenAddress,
            _amount,
            _chainIdTo,
            _useAssetFee
        );

        SubmissionAutoParamsTo memory autoParams;

        // Validate Auto Params
        if (_autoParams.length > 0) {
            autoParams = abi.decode(_autoParams, (SubmissionAutoParamsTo));
            autoParams.executionFee = _normalizeTokenAmount(_tokenAddress, autoParams.executionFee);
            if (autoParams.executionFee > _amount) revert ProposedFeeTooHigh();
            if (autoParams.data.length > 0 && autoParams.fallbackAddress.length == 0 ) revert WrongAutoArgument();
        }

        amountAfterFee -= autoParams.executionFee;

        // round down amount in order not to bridge dust
        amountAfterFee = _normalizeTokenAmount(_tokenAddress, amountAfterFee);

        _publishSubmission(
            debridgeId,
            _chainIdTo,
            amountAfterFee,
            _receiver,
            feeParams,
            _referralCode,
            autoParams,
            _autoParams.length > 0
        );
    }

    /// @inheritdoc IDeBridgeGate
    function claim(
        bytes32 _debridgeId,
        uint256 _amount,
        uint256 _chainIdFrom,
        address _receiver,
        uint256 _nonce,
        bytes calldata _signatures,
        bytes calldata _autoParams
    ) external override whenNotPaused {
        if (!getChainFromConfig[_chainIdFrom].isSupported) revert WrongChainFrom();

        SubmissionAutoParamsFrom memory autoParams;
        if (_autoParams.length > 0) {
            autoParams = abi.decode(_autoParams, (SubmissionAutoParamsFrom));
        }

        bytes32 submissionId = getSubmissionIdFrom(
            _debridgeId,
            _chainIdFrom,
            _amount,
            _receiver,
            _nonce,
            autoParams,
            _autoParams.length > 0,
            msg.sender
        );

        // check if submission already claimed
        if (isSubmissionUsed[submissionId]) revert SubmissionUsed();
        isSubmissionUsed[submissionId] = true;

        _checkConfirmations(submissionId, _debridgeId, _amount, _signatures);

        bool isNativeToken =_claim(
            submissionId,
            _debridgeId,
            _receiver,
            _amount,
            _chainIdFrom,
            autoParams
        );

        emit Claimed(
            submissionId,
            _debridgeId,
            _amount,
            _receiver,
            _nonce,
            _chainIdFrom,
            _autoParams,
            isNativeToken
        );
    }

    /// @inheritdoc IDeBridgeGate
    function flash(
        address _tokenAddress,
        address _receiver,
        uint256 _amount,
        bytes memory _data
    ) external override nonReentrant whenNotPaused
    {
        bytes32 debridgeId = getDebridgeId(getChainId(), _tokenAddress);
        if (!getDebridge[debridgeId].exist) revert DebridgeNotFound();
        uint256 currentFlashFee = (_amount * flashFeeBps) / BPS_DENOMINATOR;
        uint256 balanceBefore = IERC20Upgradeable(_tokenAddress).balanceOf(address(this));

        IERC20Upgradeable(_tokenAddress).safeTransfer(_receiver, _amount);
        IFlashCallback(msg.sender).flashCallback(currentFlashFee, _data);

        uint256 balanceAfter = IERC20Upgradeable(_tokenAddress).balanceOf(address(this));
        if (balanceBefore + currentFlashFee > balanceAfter) revert FlashFeeNotPaid();

        uint256 paid = balanceAfter - balanceBefore;
        getDebridgeFeeInfo[debridgeId].collectedFees += paid;
        emit Flash(msg.sender, _tokenAddress, _receiver, _amount, paid);
    }

    /// @dev Deploy a deToken(DeBridgeTokenProxy) for an asset
    /// @param _nativeTokenAddress A token address on a native chain
    /// @param _nativeChainId The token native chain's id
    /// @param _name The token's name
    /// @param _symbol The token's symbol
    /// @param _decimals The token's decimals
    /// @param _signatures Validators' signatures
    function deployNewAsset(
        bytes memory _nativeTokenAddress,
        uint256 _nativeChainId,
        string memory _name,
        string memory _symbol,
        uint8 _decimals,
        bytes memory _signatures
    ) external nonReentrant whenNotPaused{
        bytes32 debridgeId = getbDebridgeId(_nativeChainId, _nativeTokenAddress);

        if (getDebridge[debridgeId].exist) revert AssetAlreadyExist();

        bytes32 deployId = getDeployId(debridgeId, _name, _symbol, _decimals);

        // verify signatures
        ISignatureVerifier(signatureVerifier).submit(deployId, _signatures, excessConfirmations);

        address deBridgeTokenAddress = IDeBridgeTokenDeployer(deBridgeTokenDeployer)
            .deployAsset(debridgeId, _name, _symbol, _decimals);

        _addAsset(debridgeId, deBridgeTokenAddress, _nativeTokenAddress, _nativeChainId);
    }

    /// @dev Update native fix fee. Called by our fee update contract
    /// @param _globalFixedNativeFee  new value
    function autoUpdateFixedNativeFee(
        uint256 _globalFixedNativeFee
    ) external onlyFeeContractUpdater {
        globalFixedNativeFee = _globalFixedNativeFee;
        emit FixedNativeFeeAutoUpdated(_globalFixedNativeFee);
    }

    /* ========== ADMIN ========== */

    /// @dev Update asset's fees.
    /// @param _chainIds Chain identifiers.
    /// @param _chainSupportInfo Chain support info.
    /// @param _isChainFrom is true for editing getChainFromConfig.
    function updateChainSupport(
        uint256[] memory _chainIds,
        ChainSupportInfo[] memory _chainSupportInfo,
        bool _isChainFrom
    ) external onlyAdmin {
        if (_chainIds.length != _chainSupportInfo.length) revert WrongArgument();
        for (uint256 i = 0; i < _chainIds.length; i++) {
            if(_isChainFrom){
                getChainFromConfig[_chainIds[i]] = _chainSupportInfo[i];
            }
            else {
                getChainToConfig[_chainIds[i]] = _chainSupportInfo[i];
            }
            emit ChainsSupportUpdated(_chainIds[i], _chainSupportInfo[i], _isChainFrom);
        }
    }

    /// @dev Update fallbacks for fixed fee in native asset and transfer fee
    /// @param _globalFixedNativeFee Fallback fixed fee in native asset, used if a chain fixed fee is set to 0
    /// @param _globalTransferFeeBps Fallback transfer fee in BPS, used if a chain transfer fee is set to 0
    function updateGlobalFee(
        uint256 _globalFixedNativeFee,
        uint16 _globalTransferFeeBps
    ) external onlyAdmin {
        globalFixedNativeFee = _globalFixedNativeFee;
        globalTransferFeeBps = _globalTransferFeeBps;
        emit FixedNativeFeeUpdated(_globalFixedNativeFee, _globalTransferFeeBps);
    }

    /// @dev Update asset's fees.
    /// @param _debridgeId Asset identifier.
    /// @param _supportedChainIds Chain identifiers.
    /// @param _assetFeesInfo Chain support info.
    function updateAssetFixedFees(
        bytes32 _debridgeId,
        uint256[] memory _supportedChainIds,
        uint256[] memory _assetFeesInfo
    ) external onlyAdmin {
        if (_supportedChainIds.length != _assetFeesInfo.length) revert WrongArgument();
        DebridgeFeeInfo storage debridgeFee = getDebridgeFeeInfo[_debridgeId];
        for (uint256 i = 0; i < _supportedChainIds.length; i++) {
            debridgeFee.getChainFee[_supportedChainIds[i]] = _assetFeesInfo[i];
        }
    }

    /// @dev Update minimal amount of required signatures, must be > SignatureVerifier.minConfirmations to have an effect
    /// @param _excessConfirmations Minimal amount of required signatures
    function updateExcessConfirmations(uint8 _excessConfirmations) external onlyAdmin {
        if (_excessConfirmations == 0) revert WrongArgument();
        excessConfirmations = _excessConfirmations;
    }

    /// @dev Set support for the chains where the token can be transferred.
    /// @param _chainId Chain id where tokens are sent.
    /// @param _isSupported Whether the token is transferable to the other chain.
    /// @param _isChainFrom is true for editing getChainFromConfig.
    function setChainSupport(uint256 _chainId, bool _isSupported, bool _isChainFrom) external onlyAdmin {
        if (_isChainFrom) {
            getChainFromConfig[_chainId].isSupported = _isSupported;
        }
        else {
            getChainToConfig[_chainId].isSupported = _isSupported;
        }
        emit ChainSupportUpdated(_chainId, _isSupported, _isChainFrom);
    }

    /// @dev Set address of the call proxy.
    /// @param _callProxy Address of the proxy that executes external calls.
    function setCallProxy(address _callProxy) external onlyAdmin {
        callProxy = _callProxy;
        emit CallProxyUpdated(_callProxy);
    }

    /// @dev Update specific asset's bridge parameters.
    /// @param _debridgeId Asset identifier.
    /// @param _maxAmount Maximum amount of current chain token to be wrapped.
    /// @param _minReservesBps Minimal reserve ration in BPS.
    /// @param _amountThreshold Threshold amount after which Math.max(excessConfirmations,SignatureVerifier.minConfirmations) is used instead of SignatureVerifier.minConfirmations
    function updateAsset(
        bytes32 _debridgeId,
        uint256 _maxAmount,
        uint16 _minReservesBps,
        uint256 _amountThreshold
    ) external onlyAdmin {
        if (_minReservesBps > BPS_DENOMINATOR) revert WrongArgument();
        DebridgeInfo storage debridge = getDebridge[_debridgeId];
        // don't check existence of debridge - it allows to setup asset before first transfer
        debridge.maxAmount = _maxAmount;
        debridge.minReservesBps = _minReservesBps;
        getAmountThreshold[_debridgeId] = _amountThreshold;
    }


    /// @dev Set signature verifier address.
    /// @param _verifier Signature verifier address.
    function setSignatureVerifier(address _verifier) external onlyAdmin {
        signatureVerifier = _verifier;
    }

    /// @dev Set asset deployer address.
    /// @param _deBridgeTokenDeployer Asset deployer address.
    function setDeBridgeTokenDeployer(address _deBridgeTokenDeployer) external onlyAdmin {
        deBridgeTokenDeployer = _deBridgeTokenDeployer;
    }

    /// @dev Set defi controller.
    /// @param _defiController Defi controller address.
    function setDefiController(address _defiController) external onlyAdmin {
        defiController = _defiController;
    }

    /// @dev Set fee contract updater, that can update fix native fee
    /// @param _value new contract address.
    function setFeeContractUpdater(address _value) external onlyAdmin {
        feeContractUpdater = _value;
    }

    /// @dev Set wethGate contract, that uses for weth withdraws affected by EIP1884
    /// @param _wethGate address of new wethGate contract.
    function setWethGate(IWethGate _wethGate) external onlyAdmin {
        wethGate = _wethGate;
    }

    /// @dev Stop all transfers.
    function pause() external onlyGovMonitoring {
        _pause();
    }

    /// @dev Allow transfers.
    function unpause() external onlyAdmin {
        _unpause();
    }

    /// @inheritdoc IDeBridgeGate
    function withdrawFee(bytes32 _debridgeId) external override nonReentrant onlyFeeProxy {
        DebridgeFeeInfo storage debridgeFee = getDebridgeFeeInfo[_debridgeId];
        // Amount for transfer to treasury
        uint256 amount = debridgeFee.collectedFees - debridgeFee.withdrawnFees;

        if (amount == 0) revert NotEnoughReserves();

        debridgeFee.withdrawnFees += amount;

        if (_debridgeId == getDebridgeId(getChainId(), address(0))) {
            _safeTransferETH(feeProxy, amount);
        } else {
            // don't need this check as we check that amount is not zero
            // if (!getDebridge[_debridgeId].exist) revert DebridgeNotFound();
            IERC20Upgradeable(getDebridge[_debridgeId].tokenAddress).safeTransfer(feeProxy, amount);
        }
        emit WithdrawnFee(_debridgeId, amount);
    }

    /// @inheritdoc IDeBridgeGate
    function requestReserves(address _tokenAddress, uint256 _amount)
        external
        override
        onlyDefiController
        nonReentrant
    {
        bytes32 debridgeId = getDebridgeId(getChainId(), _tokenAddress);
        DebridgeInfo storage debridge = getDebridge[debridgeId];
        if (!debridge.exist) revert DebridgeNotFound();
        uint256 minReserves = (debridge.balance * debridge.minReservesBps) / BPS_DENOMINATOR;

        if (minReserves + _amount > IERC20Upgradeable(_tokenAddress).balanceOf(address(this)))
            revert NotEnoughReserves();

        debridge.lockedInStrategies += _amount;
        IERC20Upgradeable(_tokenAddress).safeTransfer(defiController, _amount);
    }

    /// @inheritdoc IDeBridgeGate
    function returnReserves(address _tokenAddress, uint256 _amount)
        external
        override
        onlyDefiController
        nonReentrant
    {
        bytes32 debridgeId = getDebridgeId(getChainId(), _tokenAddress);
        DebridgeInfo storage debridge = getDebridge[debridgeId];
        if (!debridge.exist) revert DebridgeNotFound();
        debridge.lockedInStrategies -= _amount;
        IERC20Upgradeable(debridge.tokenAddress).safeTransferFrom(
            defiController,
            address(this),
            _amount
        );
    }

    /// @dev Set fee converter proxy.
    /// @param _feeProxy Fee proxy address.
    function setFeeProxy(address _feeProxy) external onlyAdmin {
        feeProxy = _feeProxy;
    }

    /// @dev Block or unblock a list of submissions
    /// @param _submissionIds Ids of submissions to block/unblock
    /// @param isBlocked True to block, false to unblock
    function blockSubmission(bytes32[] memory _submissionIds, bool isBlocked) external onlyAdmin {
        for (uint256 i = 0; i < _submissionIds.length; i++) {
            isBlockedSubmission[_submissionIds[i]] = isBlocked;
            if (isBlocked) {
                emit Blocked(_submissionIds[i]);
            } else {
                emit Unblocked(_submissionIds[i]);
            }
        }
    }

    /// @dev Update flash fees.
    /// @param _flashFeeBps new fee in BPS
    function updateFlashFee(uint256 _flashFeeBps) external onlyAdmin {
        if (_flashFeeBps > BPS_DENOMINATOR) revert WrongArgument();
        flashFeeBps = _flashFeeBps;
    }

    /// @dev Update discount.
    /// @param _address customer address
    /// @param _discountFixBps  fix discount in BPS
    /// @param _discountTransferBps transfer % discount in BPS
    function updateFeeDiscount(
        address _address,
        uint16 _discountFixBps,
        uint16 _discountTransferBps
    ) external onlyAdmin {
        if (_address == address(0) ||
            _discountFixBps > BPS_DENOMINATOR ||
            _discountTransferBps > BPS_DENOMINATOR
        ) revert WrongArgument();
        DiscountInfo storage discountInfo = feeDiscount[_address];
        discountInfo.discountFixBps = _discountFixBps;
        discountInfo.discountTransferBps = _discountTransferBps;
    }

    // we need to accept ETH sends to unwrap WETH
    receive() external payable {
        // assert(msg.sender == address(weth)); // only accept ETH via fallback from the WETH contract
    }

    /* ========== INTERNAL ========== */

    function _checkConfirmations(
        bytes32 _submissionId,
        bytes32 _debridgeId,
        uint256 _amount,
        bytes calldata _signatures
    ) internal {
        if (isBlockedSubmission[_submissionId]) revert SubmissionBlocked();
        // inside check is confirmed
        ISignatureVerifier(signatureVerifier).submit(
            _submissionId,
            _signatures,
            _amount >= getAmountThreshold[_debridgeId] ? excessConfirmations : 0
        );
    }

    /// @dev Add support for the asset.
    /// @param _debridgeId Asset identifier.
    /// @param _tokenAddress Address of the asset on the current chain.
    /// @param _nativeAddress Address of the asset on the native chain.
    /// @param _nativeChainId Native chain id.
    function _addAsset(
        bytes32 _debridgeId,
        address _tokenAddress,
        bytes memory _nativeAddress,
        uint256 _nativeChainId
    ) internal {
        DebridgeInfo storage debridge = getDebridge[_debridgeId];

        if (debridge.exist) revert AssetAlreadyExist();
        if (_tokenAddress == address(0)) revert ZeroAddress();

        debridge.exist = true;
        debridge.tokenAddress = _tokenAddress;
        debridge.chainId = _nativeChainId;
        // Don't override if the admin already set maxAmount in updateAsset method before
        if (debridge.maxAmount == 0) {
            debridge.maxAmount = type(uint256).max;
        }
        // set minReservesBps to 100% to prevent using new asset by DeFiController by default
        debridge.minReservesBps = uint16(BPS_DENOMINATOR);
        if (getAmountThreshold[_debridgeId] == 0) {
            getAmountThreshold[_debridgeId] = type(uint256).max;
        }

        TokenInfo storage tokenInfo = getNativeInfo[_tokenAddress];
        tokenInfo.nativeChainId = _nativeChainId;
        tokenInfo.nativeAddress = _nativeAddress;

        emit PairAdded(
            _debridgeId,
            _tokenAddress,
            _nativeAddress,
            _nativeChainId,
            debridge.maxAmount,
            debridge.minReservesBps
        );
    }

    /// @dev Locks asset on the chain and enables minting on the other chain.
    /// @param _amount Amount to be transferred (note: the fee can be applied).
    /// @param _chainIdTo Chain id of the target chain.
    /// @param _permit deadline + signature for approving the spender by signature.
    function _send(
        bytes memory _permit,
        address _tokenAddress,
        uint256 _amount,
        uint256 _chainIdTo,
        bool _useAssetFee
    ) internal returns (
        uint256 amountAfterFee,
        bytes32 debridgeId,
        FeeParams memory feeParams
    ) {
        _validateToken(_tokenAddress);

        // Run _permit first. Avoid Stack too deep
        if (_permit.length > 0) {
            // call permit before transferring token
            uint256 deadline = _permit.toUint256(0);
            (bytes32 r, bytes32 s, uint8 v) = _permit.parseSignature(32);
            IERC20Permit(_tokenAddress).permit(
                msg.sender,
                address(this),
                _amount,
                deadline,
                v,
                r,
                s);
        }

        TokenInfo memory nativeTokenInfo = getNativeInfo[_tokenAddress];
        bool isNativeToken = nativeTokenInfo.nativeChainId  == 0
            ? true // token not in mapping
            : nativeTokenInfo.nativeChainId == getChainId(); // token native chain id the same

        if (isNativeToken) {
            //We use WETH debridgeId for transfer ETH
            debridgeId = getDebridgeId(
                getChainId(),
                _tokenAddress == address(0) ? address(weth) : _tokenAddress
            );
        }
        else {
            debridgeId = getbDebridgeId(
                nativeTokenInfo.nativeChainId,
                nativeTokenInfo.nativeAddress
            );
        }

        DebridgeInfo storage debridge = getDebridge[debridgeId];
        if (!debridge.exist) {
            if (isNativeToken) {
                // Use WETH as a token address for native tokens
                address assetAddress = _tokenAddress == address(0) ? address(weth) : _tokenAddress;
                _addAsset(
                    debridgeId,
                    assetAddress,
                    abi.encodePacked(assetAddress),
                    getChainId()
                );
            } else revert DebridgeNotFound();
        }

        ChainSupportInfo memory chainFees = getChainToConfig[_chainIdTo];
        if (!chainFees.isSupported) revert WrongChainTo();

        if (_tokenAddress == address(0)) {
            // use msg.value as amount for native tokens
            _amount = msg.value;
            weth.deposit{value: _amount}();
            _useAssetFee = true;
        } else {
            IERC20Upgradeable token = IERC20Upgradeable(_tokenAddress);
            uint256 balanceBefore = token.balanceOf(address(this));
            token.safeTransferFrom(msg.sender, address(this), _amount);
            // Received real amount
            _amount = token.balanceOf(address(this)) - balanceBefore;
        }

        if (_amount > debridge.maxAmount) revert TransferAmountTooHigh();

        //_processFeeForTransfer
        {
            DiscountInfo memory discountInfo = feeDiscount[msg.sender];
            DebridgeFeeInfo storage debridgeFee = getDebridgeFeeInfo[debridgeId];

            // calculate fixed fee
            uint256 assetsFixedFee;
            if (_useAssetFee) {
                if (_tokenAddress == address(0)) {
                    // collect asset fixed fee (in weth) for native token transfers
                    assetsFixedFee = chainFees.fixedNativeFee == 0 ? globalFixedNativeFee : chainFees.fixedNativeFee;
                } else {
                    // collect asset fixed fee for non native token transfers
                    assetsFixedFee = debridgeFee.getChainFee[_chainIdTo];
                    if (assetsFixedFee == 0) revert NotSupportedFixedFee();
                }
                // Apply discount for a asset fixed fee
                assetsFixedFee = _applyDiscount(assetsFixedFee, discountInfo.discountFixBps);
                if (_amount < assetsFixedFee) revert TransferAmountNotCoverFees();
                feeParams.fixFee = assetsFixedFee;
            } else {
                // collect fixed native fee for non native token transfers

                // use globalFixedNativeFee if value for chain is not set
                uint256 nativeFee = chainFees.fixedNativeFee == 0 ? globalFixedNativeFee : chainFees.fixedNativeFee;
                // Apply discount for a native fixed fee
                nativeFee = _applyDiscount(nativeFee, discountInfo.discountFixBps);

                if (msg.value < nativeFee) revert TransferAmountNotCoverFees();
                else if (msg.value > nativeFee) {
                    // refund extra fee eth
                     _safeTransferETH(msg.sender, msg.value - nativeFee);
                }
                bytes32 nativeDebridgeId = getDebridgeId(getChainId(), address(0));
                getDebridgeFeeInfo[nativeDebridgeId].collectedFees += nativeFee;
                feeParams.fixFee = nativeFee;
            }

            // Calculate transfer fee
            // use globalTransferFeeBps if value for chain is not set
            uint256 transferFee = (chainFees.transferFeeBps == 0
                ? globalTransferFeeBps : chainFees.transferFeeBps)
                * (_amount - assetsFixedFee) / BPS_DENOMINATOR;
            // apply discount for a transfer fee
            transferFee = _applyDiscount(transferFee, discountInfo.discountTransferBps);

            uint256 totalFee = transferFee + assetsFixedFee;
            if (_amount < totalFee) revert TransferAmountNotCoverFees();
            debridgeFee.collectedFees += totalFee;
            amountAfterFee = _amount - totalFee;

            // initialize feeParams
            feeParams.transferFee = transferFee;
            feeParams.useAssetFee = _useAssetFee;
            feeParams.receivedAmount = _amount;
            feeParams.isNativeToken = isNativeToken;
        }

        if (isNativeToken) {
            debridge.balance += amountAfterFee;
        }
        else {
            debridge.balance -= amountAfterFee;
            IDeBridgeToken(debridge.tokenAddress).burn(amountAfterFee);
        }
        return (amountAfterFee, debridgeId, feeParams);
    }

    function _publishSubmission(
        bytes32 _debridgeId,
        uint256 _chainIdTo,
        uint256 _amount,
        bytes memory _receiver,
        FeeParams memory feeParams,
        uint32 _referralCode,
        SubmissionAutoParamsTo memory autoParams,
        bool hasAutoParams
    ) internal {
        bytes32 submissionId;
        bytes memory packedSubmission = abi.encodePacked(
            SUBMISSION_PREFIX,
            _debridgeId,
            getChainId(),
            _chainIdTo,
            _amount,
            _receiver,
            nonce
        );
        if (hasAutoParams) {
            bool isHashedData = autoParams.flags.getFlag(Flags.SEND_HASHED_DATA);
            if (isHashedData && autoParams.data.length != 32) revert WrongAutoArgument();
            // auto submission
            submissionId = keccak256(
                abi.encodePacked(
                    packedSubmission,
                    autoParams.executionFee,
                    autoParams.flags,
                    keccak256(autoParams.fallbackAddress),
                    isHashedData ? autoParams.data : abi.encodePacked(keccak256(autoParams.data)),
                    keccak256(abi.encodePacked(msg.sender))
                )
            );
        }
        // regular submission
        else {
            submissionId = keccak256(packedSubmission);
        }

        emit Sent(
            submissionId,
            _debridgeId,
            _amount,
            _receiver,
            nonce,
            _chainIdTo,
            _referralCode,
            feeParams,
            hasAutoParams ? abi.encode(autoParams): bytes(""),
            msg.sender
        );

        {
            emit MonitoringSendEvent(
                submissionId,
                nonce,
                getDebridge[_debridgeId].balance,
                IERC20Upgradeable(getDebridge[_debridgeId].tokenAddress).totalSupply()
            );
        }

        nonce++;
    }

    function _applyDiscount(
        uint256 amount,
        uint16 discountBps
    ) internal pure returns (uint256) {
        return amount - amount * discountBps / BPS_DENOMINATOR;
    }

    function _validateToken(address _token) internal {
        if (_token == address(0)) {
            // no validation for native tokens
            return;
        }

        // check existence of decimals method
        (bool success, ) = _token.call(abi.encodeWithSignature("decimals()"));
        if (!success) revert InvalidTokenToSend();

        // check existence of symbol method
        (success, ) = _token.call(abi.encodeWithSignature("symbol()"));
        if (!success) revert InvalidTokenToSend();
    }


    /// @dev Unlock the asset on the current chain and transfer to receiver.
    /// @param _debridgeId Asset identifier.
    /// @param _receiver Receiver address.
    /// @param _amount Amount of the transfered asset (note: the fee can be applyed).
    function _claim(
        bytes32 _submissionId,
        bytes32 _debridgeId,
        address _receiver,
        uint256 _amount,
        uint256 _chainIdFrom,
        SubmissionAutoParamsFrom memory _autoParams
    ) internal returns (bool isNativeToken) {
        DebridgeInfo storage debridge = getDebridge[_debridgeId];
        if (!debridge.exist) revert DebridgeNotFound();
        isNativeToken = debridge.chainId == getChainId();

        if (isNativeToken) {
            debridge.balance -= _amount + _autoParams.executionFee;
        } else {
            debridge.balance += _amount + _autoParams.executionFee;
        }

        address _token = debridge.tokenAddress;
        bool unwrapETH = isNativeToken
            && _autoParams.flags.getFlag(Flags.UNWRAP_ETH)
            && _token == address(weth);

        if (_autoParams.executionFee > 0) {
            _mintOrTransfer(_token, msg.sender, _autoParams.executionFee, isNativeToken);
        }
        if (_autoParams.data.length > 0) {
            // use local variable to reduce gas usage
            address _callProxy = callProxy;
            bool status;
            if (unwrapETH) {
                // withdraw weth to callProxy directly
                _withdrawWeth(_callProxy, _amount);
                status = ICallProxy(_callProxy).call(
                    _autoParams.fallbackAddress,
                    _receiver,
                    _autoParams.data,
                    _autoParams.flags,
                    _autoParams.nativeSender,
                    _chainIdFrom
                );
            }
            else {
                _mintOrTransfer(_token, _callProxy, _amount, isNativeToken);

                status = ICallProxy(_callProxy).callERC20(
                    _token,
                    _autoParams.fallbackAddress,
                    _receiver,
                    _autoParams.data,
                    _autoParams.flags,
                    _autoParams.nativeSender,
                    _chainIdFrom
                );
            }
            emit AutoRequestExecuted(_submissionId, status, _callProxy);
        } else if (unwrapETH) {
            // transferring WETH with unwrap flag
            _withdrawWeth(_receiver, _amount);
        } else {
            _mintOrTransfer(_token, _receiver, _amount, isNativeToken);
        }

        emit MonitoringClaimEvent(
            _submissionId,
            debridge.balance,
            IERC20Upgradeable(debridge.tokenAddress).totalSupply()
        );
    }

    function _mintOrTransfer(
        address _token,
        address _receiver,
        uint256 _amount,
        bool isNativeToken
    ) internal {
        if (_amount > 0) {
            if (isNativeToken) {
                IERC20Upgradeable(_token).safeTransfer(_receiver, _amount);
            } else {
                IDeBridgeToken(_token).mint(_receiver, _amount);
            }
        }
    }

    /*
    * @dev transfer ETH to an address, revert if it fails.
    * @param to recipient of the transfer
    * @param value the amount to send
    */
    function _safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        if (!success) revert EthTransferFailed();
    }


    function _withdrawWeth(address _receiver, uint _amount) internal {
        if (address(wethGate) == address(0)) {
            // dealing with weth withdraw affected by EIP1884
            weth.withdraw(_amount);
            _safeTransferETH(_receiver, _amount);
        }
        else {
            IERC20Upgradeable(address(weth)).safeTransfer(address(wethGate), _amount);
            wethGate.withdraw(_receiver, _amount);
        }
    }

    /*
    * @dev round down token amount
    * @param _token address of token, zero for native tokens
    * @param __amount amount for rounding
    */
    function _normalizeTokenAmount(
        address _token,
        uint256 _amount
    ) internal view returns (uint256) {
        uint256 decimals = _token == address(0)
            ? 18
            : IERC20Metadata(_token).decimals();
        uint256 maxDecimals = 8;
        if (decimals > maxDecimals) {
            uint256 multiplier = 10 ** (decimals - maxDecimals);
            _amount = _amount / multiplier * multiplier;
        }
        return _amount;
    }

    /* VIEW */

    /// @inheritdoc IDeBridgeGate
    function getDefiAvaliableReserves(address _tokenAddress)
        external
        view
        override
        returns (uint256)
    {
        DebridgeInfo storage debridge = getDebridge[getDebridgeId(getChainId(), _tokenAddress)];
        return (debridge.balance * (BPS_DENOMINATOR - debridge.minReservesBps)) / BPS_DENOMINATOR;
    }

    /// @dev Calculates asset identifier.
    /// @param _chainId Current chain id.
    /// @param _tokenAddress Address of the asset on the other chain.
    function getDebridgeId(uint256 _chainId, address _tokenAddress) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(_chainId, _tokenAddress));
    }

    /// @dev Calculates asset identifier.
    /// @param _chainId Current chain id.
    /// @param _tokenAddress Address of the asset on the other chain.
    function getbDebridgeId(uint256 _chainId, bytes memory _tokenAddress) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(_chainId, _tokenAddress));
    }

    /// @inheritdoc IDeBridgeGate
    function getDebridgeChainAssetFixedFee(
        bytes32 _debridgeId,
        uint256 _chainId
    ) external view override returns (uint256) {
        // if (!getDebridge[_debridgeId].exist) revert DebridgeNotFound();
        return getDebridgeFeeInfo[_debridgeId].getChainFee[_chainId];
    }

    /// @dev Calculate submission id for auto claimable transfer.
    /// @param _debridgeId Asset identifier.
    /// @param _chainIdFrom Chain identifier of the chain where tokens are sent from.
    /// @param _amount Amount of the transferred asset (note: the fee can be applied).
    /// @param _receiver Receiver address.
    /// @param _nonce Submission id.
    /// @param _autoParams Auto params for external call
    /// @param _hasAutoParams True if auto params are provided
    /// @param _sender Address that will call claim
    function getSubmissionIdFrom(
        bytes32 _debridgeId,
        uint256 _chainIdFrom,
        uint256 _amount,
        address _receiver,
        uint256 _nonce,
        SubmissionAutoParamsFrom memory _autoParams,
        bool _hasAutoParams,
        address _sender
    ) public view returns (bytes32) {
        bytes memory packedSubmission = abi.encodePacked(
            SUBMISSION_PREFIX,
            _debridgeId,
            _chainIdFrom,
            getChainId(),
            _amount,
            _receiver,
            _nonce
        );
        if (_hasAutoParams) {
            // Needed to let fallback address claim tokens in case user lost call data and can't restore its' hash
            bool isHashedData = _autoParams.flags.getFlag(Flags.SEND_HASHED_DATA)
                             && _sender == _autoParams.fallbackAddress
                             && _autoParams.data.length == 32;

            // auto submission
            return keccak256(
                abi.encodePacked(
                    packedSubmission,
                    _autoParams.executionFee,
                    _autoParams.flags,
                    keccak256(abi.encodePacked(_autoParams.fallbackAddress)),
                    isHashedData ? _autoParams.data : abi.encodePacked(keccak256(_autoParams.data)),
                    keccak256(_autoParams.nativeSender)
                )
            );
        }
        // regular submission
        return keccak256(packedSubmission);
    }



    /// @dev Calculates asset identifier for deployment.
    /// @param _debridgeId Id of an asset, see getDebridgeId.
    /// @param _name Asset's name.
    /// @param _symbol Asset's symbol.
    /// @param _decimals Asset's decimals.
    function getDeployId(
        bytes32 _debridgeId,
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(
            DEPLOY_PREFIX,
            _debridgeId,
            keccak256(abi.encodePacked(_name)),
            keccak256(abi.encodePacked(_symbol)),
            _decimals));
    }

    /// @dev Get current chain id
    function getChainId() public view virtual returns (uint256 cid) {
        assembly {
            cid := chainid()
        }
    }

    // ============ Version Control ============
    /// @dev Get this contract's version
    function version() external pure returns (uint256) {
        return 410; // 4.1.0
    }
}

File 2 of 29 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 3 of 29 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

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

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

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

File 4 of 29 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 5 of 29 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.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));
        }
    }

    /**
     * @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 6 of 29 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

/**
 * @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 a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 7 of 29 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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 initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        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 override returns (bytes32) {
        return _roles[role].adminRole;
    }

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

File 8 of 29 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (security/ReentrancyGuard.sol)

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

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal initializer {
        _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;
    }
    uint256[49] private __gap;
}

File 9 of 29 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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 initializer {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

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

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

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

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

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

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

File 10 of 29 : IERC20Permit.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.7;

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

File 11 of 29 : IDeBridgeToken.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

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

interface IDeBridgeToken is IERC20Upgradeable, IERC20Permit {
    /// @dev Issues new tokens.
    /// @param _receiver Token's receiver.
    /// @param _amount Amount to be minted.
    function mint(address _receiver, uint256 _amount) external;

    /// @dev Destroys existing tokens.
    /// @param _amount Amount to be burnt.
    function burn(uint256 _amount) external;
}

File 12 of 29 : IDeBridgeTokenDeployer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

interface IDeBridgeTokenDeployer {

    /// @dev Deploy a deToken(DeBridgeTokenProxy) for an asset
    /// @param _debridgeId Asset id, see DeBridgeGate.getDebridgeId
    /// @param _name The asset's name
    /// @param _symbol The asset's symbol
    /// @param _decimals The asset's decimals
    function deployAsset(
        bytes32 _debridgeId,
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) external returns (address deTokenAddress);

    /// @dev Emitted when a deToken(DeBridgeTokenProxy) is deployed using this contract
    event DeBridgeTokenDeployed(
        address asset,
        string name,
        string symbol,
        uint8 decimals
    );
}

File 13 of 29 : ISignatureVerifier.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

interface ISignatureVerifier {

    /* ========== EVENTS ========== */

    /// @dev Emitted once the submission is confirmed by one oracle.
    event Confirmed(bytes32 submissionId, address operator);
    /// @dev Emitted once the submission is confirmed by min required amount of oracles.
    event DeployConfirmed(bytes32 deployId, address operator);

    /* ========== FUNCTIONS ========== */

    /// @dev Check confirmation (validate signatures) for the transfer request.
    /// @param _submissionId Submission identifier.
    /// @param _signatures Array of signatures by oracles.
    /// @param _excessConfirmations override min confirmations count
    function submit(
        bytes32 _submissionId,
        bytes memory _signatures,
        uint8 _excessConfirmations
    ) external;

}

File 14 of 29 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

interface IWETH {
    function deposit() external payable;

    function withdraw(uint256 wad) external;

    function totalSupply() external view returns (uint256);

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

    function transfer(address recipient, uint256 amount) external returns (bool);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

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

File 15 of 29 : IDeBridgeGate.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

interface IDeBridgeGate {
    /* ========== STRUCTS ========== */

    struct TokenInfo {
        uint256 nativeChainId;
        bytes nativeAddress;
    }

    struct DebridgeInfo {
        uint256 chainId; // native chain id
        uint256 maxAmount; // maximum amount to transfer
        uint256 balance; // total locked assets
        uint256 lockedInStrategies; // total locked assets in strategy (AAVE, Compound, etc)
        address tokenAddress; // asset address on the current chain
        uint16 minReservesBps; // minimal hot reserves in basis points (1/10000)
        bool exist;
    }

    struct DebridgeFeeInfo {
        uint256 collectedFees; // total collected fees
        uint256 withdrawnFees; // fees that already withdrawn
        mapping(uint256 => uint256) getChainFee; // whether the chain for the asset is supported
    }

    struct ChainSupportInfo {
        uint256 fixedNativeFee; // transfer fixed fee
        bool isSupported; // whether the chain for the asset is supported
        uint16 transferFeeBps; // transfer fee rate nominated in basis points (1/10000) of transferred amount
    }

    struct DiscountInfo {
        uint16 discountFixBps; // fix discount in BPS
        uint16 discountTransferBps; // transfer % discount in BPS
    }

    /// @param executionFee Fee paid to the transaction executor.
    /// @param fallbackAddress Receiver of the tokens if the call fails.
    struct SubmissionAutoParamsTo {
        uint256 executionFee;
        uint256 flags;
        bytes fallbackAddress;
        bytes data;
    }

    /// @param executionFee Fee paid to the transaction executor.
    /// @param fallbackAddress Receiver of the tokens if the call fails.
    struct SubmissionAutoParamsFrom {
        uint256 executionFee;
        uint256 flags;
        address fallbackAddress;
        bytes data;
        bytes nativeSender;
    }

    struct FeeParams {
        uint256 receivedAmount;
        uint256 fixFee;
        uint256 transferFee;
        bool useAssetFee;
        bool isNativeToken;
    }

    /* ========== PUBLIC VARS GETTERS ========== */

    /// @dev Returns whether the transfer with the submissionId was claimed.
    /// submissionId is generated in getSubmissionIdFrom
    function isSubmissionUsed(bytes32 submissionId) external returns (bool);

    /// @dev Returns native token info by wrapped token address
    function getNativeInfo(address token) external returns (
        uint256 nativeChainId,
        bytes memory nativeAddress);

    /* ========== FUNCTIONS ========== */

    /// @dev This method is used for the transfer of assets [from the native chain](https://docs.debridge.finance/the-core-protocol/transfers#transfer-from-native-chain).
    /// It locks an asset in the smart contract in the native chain and enables minting of deAsset on the secondary chain.
    /// @param _tokenAddress Asset identifier.
    /// @param _amount Amount to be transferred (note: the fee can be applied).
    /// @param _chainIdTo Chain id of the target chain.
    /// @param _receiver Receiver address.
    /// @param _permit deadline + signature for approving the spender by signature.
    /// @param _useAssetFee use assets fee for pay protocol fix (work only for specials token)
    /// @param _referralCode Referral code
    /// @param _autoParams Auto params for external call in target network
    function send(
        address _tokenAddress,
        uint256 _amount,
        uint256 _chainIdTo,
        bytes memory _receiver,
        bytes memory _permit,
        bool _useAssetFee,
        uint32 _referralCode,
        bytes calldata _autoParams
    ) external payable;

    /// @dev Is used for transfers [into the native chain](https://docs.debridge.finance/the-core-protocol/transfers#transfer-from-secondary-chain-to-native-chain)
    /// to unlock the designated amount of asset from collateral and transfer it to the receiver.
    /// @param _debridgeId Asset identifier.
    /// @param _amount Amount of the transferred asset (note: the fee can be applied).
    /// @param _chainIdFrom Chain where submission was sent
    /// @param _receiver Receiver address.
    /// @param _nonce Submission id.
    /// @param _signatures Validators signatures to confirm
    /// @param _autoParams Auto params for external call
    function claim(
        bytes32 _debridgeId,
        uint256 _amount,
        uint256 _chainIdFrom,
        address _receiver,
        uint256 _nonce,
        bytes calldata _signatures,
        bytes calldata _autoParams
    ) external;

    /// @dev Get a flash loan, msg.sender must implement IFlashCallback
    /// @param _tokenAddress An asset to loan
    /// @param _receiver Where funds should be sent
    /// @param _amount Amount to loan
    /// @param _data Data to pass to sender's flashCallback function
    function flash(
        address _tokenAddress,
        address _receiver,
        uint256 _amount,
        bytes memory _data
    ) external;

    /// @dev Get reserves of a token available to use in defi
    /// @param _tokenAddress Token address
    function getDefiAvaliableReserves(address _tokenAddress) external view returns (uint256);

    /// @dev Request the assets to be used in DeFi protocol.
    /// @param _tokenAddress Asset address.
    /// @param _amount Amount of tokens to request.
    function requestReserves(address _tokenAddress, uint256 _amount) external;

    /// @dev Return the assets that were used in DeFi  protocol.
    /// @param _tokenAddress Asset address.
    /// @param _amount Amount of tokens to claim.
    function returnReserves(address _tokenAddress, uint256 _amount) external;

    /// @dev Withdraw collected fees to feeProxy
    /// @param _debridgeId Asset identifier.
    function withdrawFee(bytes32 _debridgeId) external;

    /// @dev Returns asset fixed fee value for specified debridge and chainId.
    /// @param _debridgeId Asset identifier.
    /// @param _chainId Chain id.
    function getDebridgeChainAssetFixedFee(
        bytes32 _debridgeId,
        uint256 _chainId
    ) external view returns (uint256);

    /* ========== EVENTS ========== */

    /// @dev Emitted once the tokens are sent from the original(native) chain to the other chain; the transfer tokens
    /// are expected to be claimed by the users.
    event Sent(
        bytes32 submissionId,
        bytes32 indexed debridgeId,
        uint256 amount,
        bytes receiver,
        uint256 nonce,
        uint256 indexed chainIdTo,
        uint32 referralCode,
        FeeParams feeParams,
        bytes autoParams,
        address nativeSender
        // bool isNativeToken //added to feeParams
    );

    /// @dev Emitted once the tokens are transferred and withdrawn on a target chain
    event Claimed(
        bytes32 submissionId,
        bytes32 indexed debridgeId,
        uint256 amount,
        address indexed receiver,
        uint256 nonce,
        uint256 indexed chainIdFrom,
        bytes autoParams,
        bool isNativeToken
    );

    /// @dev Emitted when new asset support is added.
    event PairAdded(
        bytes32 debridgeId,
        address tokenAddress,
        bytes nativeAddress,
        uint256 indexed nativeChainId,
        uint256 maxAmount,
        uint16 minReservesBps
    );

    event MonitoringSendEvent(
        bytes32 submissionId,
        uint256 nonce,
        uint256 lockedOrMintedAmount,
        uint256 totalSupply
    );

    event MonitoringClaimEvent(
        bytes32 submissionId,
        uint256 lockedOrMintedAmount,
        uint256 totalSupply
    );

    /// @dev Emitted when the asset is allowed/disallowed to be transferred to the chain.
    event ChainSupportUpdated(uint256 chainId, bool isSupported, bool isChainFrom);
    /// @dev Emitted when the supported chains are updated.
    event ChainsSupportUpdated(
        uint256 chainIds,
        ChainSupportInfo chainSupportInfo,
        bool isChainFrom);

    /// @dev Emitted when the new call proxy is set.
    event CallProxyUpdated(address callProxy);
    /// @dev Emitted when the transfer request is executed.
    event AutoRequestExecuted(
        bytes32 submissionId,
        bool indexed success,
        address callProxy
    );

    /// @dev Emitted when a submission is blocked.
    event Blocked(bytes32 submissionId);
    /// @dev Emitted when a submission is unblocked.
    event Unblocked(bytes32 submissionId);

    /// @dev Emitted when a flash loan is successfully returned.
    event Flash(
        address sender,
        address indexed tokenAddress,
        address indexed receiver,
        uint256 amount,
        uint256 paid
    );

    /// @dev Emitted when fee is withdrawn.
    event WithdrawnFee(bytes32 debridgeId, uint256 fee);

    /// @dev Emitted when globalFixedNativeFee and globalTransferFeeBps are updated.
    event FixedNativeFeeUpdated(
        uint256 globalFixedNativeFee,
        uint256 globalTransferFeeBps);

    /// @dev Emitted when globalFixedNativeFee is updated by feeContractUpdater
    event FixedNativeFeeAutoUpdated(uint256 globalFixedNativeFee);
}

File 16 of 29 : ICallProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

interface ICallProxy {

    /// @dev Chain from which the current submission is received
    function submissionChainIdFrom() external returns (uint256);
    /// @dev Native sender of the current submission
    function submissionNativeSender() external returns (bytes memory);

    /// @dev Used for calls where native asset transfer is involved.
    /// @param _reserveAddress Receiver of the tokens if the call to _receiver fails
    /// @param _receiver Contract to be called
    /// @param _data Call data
    /// @param _flags Flags to change certain behavior of this function, see Flags library for more details
    /// @param _nativeSender Native sender
    /// @param _chainIdFrom Id of a chain that originated the request
    function call(
        address _reserveAddress,
        address _receiver,
        bytes memory _data,
        uint256 _flags,
        bytes memory _nativeSender,
        uint256 _chainIdFrom
    ) external payable returns (bool);

    /// @dev Used for calls where ERC20 transfer is involved.
    /// @param _token Asset address
    /// @param _reserveAddress Receiver of the tokens if the call to _receiver fails
    /// @param _receiver Contract to be called
    /// @param _data Call data
    /// @param _flags Flags to change certain behavior of this function, see Flags library for more details
    /// @param _nativeSender Native sender
    /// @param _chainIdFrom Id of a chain that originated the request
    function callERC20(
        address _token,
        address _reserveAddress,
        address _receiver,
        bytes memory _data,
        uint256 _flags,
        bytes memory _nativeSender,
        uint256 _chainIdFrom
    ) external returns (bool);
}

File 17 of 29 : IFlashCallback.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

/// @title Callback for IDeBridgeGate#flash
/// @notice Any contract that calls IDeBridgeGate#flash must implement this interface
interface IFlashCallback {
    /// @param fee The fee amount in token due to the pool by the end of the flash
    /// @param data Any data passed through by the caller via the IDeBridgeGate#flash call
    function flashCallback(uint256 fee, bytes calldata data) external;
}

File 18 of 29 : SignatureUtil.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.7;

library SignatureUtil {
    /* ========== ERRORS ========== */

    error WrongArgumentLength();
    error SignatureInvalidLength();
    error SignatureInvalidV();

    /// @dev Prepares raw msg that was signed by the oracle.
    /// @param _submissionId Submission identifier.
    function getUnsignedMsg(bytes32 _submissionId) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _submissionId));
    }

    /// @dev Splits signature bytes to r,s,v components.
    /// @param _signature Signature bytes in format r+s+v.
    function splitSignature(bytes memory _signature)
        internal
        pure
        returns (
            bytes32 r,
            bytes32 s,
            uint8 v
        )
    {
        if (_signature.length != 65) revert SignatureInvalidLength();
        return parseSignature(_signature, 0);
    }

    function parseSignature(bytes memory _signatures, uint256 offset)
        internal
        pure
        returns (
            bytes32 r,
            bytes32 s,
            uint8 v
        )
    {
        assembly {
            r := mload(add(_signatures, add(32, offset)))
            s := mload(add(_signatures, add(64, offset)))
            v := and(mload(add(_signatures, add(65, offset))), 0xff)
        }

        if (v < 27) v += 27;
        if (v != 27 && v != 28) revert SignatureInvalidV();
    }

    function toUint256(bytes memory _bytes, uint256 _offset)
        internal
        pure
        returns (uint256 result)
    {
        if (_bytes.length < _offset + 32) revert WrongArgumentLength();

        assembly {
            result := mload(add(add(_bytes, 0x20), _offset))
        }
    }
}

File 19 of 29 : Flags.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.7;

library Flags {

    /* ========== FLAGS ========== */

    /// @dev Flag to unwrap ETH
    uint256 public constant UNWRAP_ETH = 0;
    /// @dev Flag to revert if external call fails
    uint256 public constant REVERT_IF_EXTERNAL_FAIL = 1;
    /// @dev Flag to call proxy with a sender contract
    uint256 public constant PROXY_WITH_SENDER = 2;
    /// @dev Data is hash in DeBridgeGate send method
    uint256 public constant SEND_HASHED_DATA = 3;
    /// @dev First 24 bytes from data is gas limit for external call
    uint256 public constant SEND_EXTERNAL_CALL_GAS_LIMIT = 4;

    /// @dev Get flag
    /// @param _packedFlags Flags packed to uint256
    /// @param _flag Flag to check
    function getFlag(
        uint256 _packedFlags,
        uint256 _flag
    ) internal pure returns (bool) {
        uint256 flag = (_packedFlags >> _flag) & uint256(1);
        return flag == 1;
    }
    
    /// @dev Set flag
    /// @param _packedFlags Flags packed to uint256
    /// @param _flag Flag to set
    /// @param _value Is set or not set
     function setFlag(
         uint256 _packedFlags,
         uint256 _flag,
         bool _value
     ) internal pure returns (uint256) {
         if (_value)
             return _packedFlags | uint256(1) << _flag;
         else
             return _packedFlags & ~(uint256(1) << _flag);
     }
}

File 20 of 29 : IWethGate.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.7;

interface IWethGate {
    /// @dev Transfer assets to a receiver.
    /// @param receiver This address will receive a transfer.
    /// @param wad Amount in wei
    function withdraw(address receiver, uint wad) external;
}

File 21 of 29 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 22 of 29 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

File 23 of 29 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

File 24 of 29 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

File 25 of 29 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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 26 of 29 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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 initializer {
        __Context_init_unchained();
    }

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 27 of 29 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

File 28 of 29 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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 initializer {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal initializer {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.0;

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

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

Contract ABI

[{"inputs":[],"name":"AdminBadRole","type":"error"},{"inputs":[],"name":"AssetAlreadyExist","type":"error"},{"inputs":[],"name":"DebridgeNotFound","type":"error"},{"inputs":[],"name":"DefiControllerBadRole","type":"error"},{"inputs":[],"name":"EthTransferFailed","type":"error"},{"inputs":[],"name":"FeeContractUpdaterBadRole","type":"error"},{"inputs":[],"name":"FeeProxyBadRole","type":"error"},{"inputs":[],"name":"FlashFeeNotPaid","type":"error"},{"inputs":[],"name":"GovMonitoringBadRole","type":"error"},{"inputs":[],"name":"InvalidTokenToSend","type":"error"},{"inputs":[],"name":"NotEnoughReserves","type":"error"},{"inputs":[],"name":"NotSupportedFixedFee","type":"error"},{"inputs":[],"name":"ProposedFeeTooHigh","type":"error"},{"inputs":[],"name":"SignatureInvalidV","type":"error"},{"inputs":[],"name":"SubmissionBlocked","type":"error"},{"inputs":[],"name":"SubmissionUsed","type":"error"},{"inputs":[],"name":"TransferAmountNotCoverFees","type":"error"},{"inputs":[],"name":"TransferAmountTooHigh","type":"error"},{"inputs":[],"name":"WrongArgument","type":"error"},{"inputs":[],"name":"WrongArgumentLength","type":"error"},{"inputs":[],"name":"WrongAutoArgument","type":"error"},{"inputs":[],"name":"WrongChainFrom","type":"error"},{"inputs":[],"name":"WrongChainTo","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"},{"indexed":true,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"address","name":"callProxy","type":"address"}],"name":"AutoRequestExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"}],"name":"Blocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"callProxy","type":"address"}],"name":"CallProxyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isSupported","type":"bool"},{"indexed":false,"internalType":"bool","name":"isChainFrom","type":"bool"}],"name":"ChainSupportUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainIds","type":"uint256"},{"components":[{"internalType":"uint256","name":"fixedNativeFee","type":"uint256"},{"internalType":"bool","name":"isSupported","type":"bool"},{"internalType":"uint16","name":"transferFeeBps","type":"uint16"}],"indexed":false,"internalType":"struct IDeBridgeGate.ChainSupportInfo","name":"chainSupportInfo","type":"tuple"},{"indexed":false,"internalType":"bool","name":"isChainFrom","type":"bool"}],"name":"ChainsSupportUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"debridgeId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"chainIdFrom","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"autoParams","type":"bytes"},{"indexed":false,"internalType":"bool","name":"isNativeToken","type":"bool"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalFixedNativeFee","type":"uint256"}],"name":"FixedNativeFeeAutoUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalFixedNativeFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"globalTransferFeeBps","type":"uint256"}],"name":"FixedNativeFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paid","type":"uint256"}],"name":"Flash","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"lockedOrMintedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalSupply","type":"uint256"}],"name":"MonitoringClaimEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lockedOrMintedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalSupply","type":"uint256"}],"name":"MonitoringSendEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"debridgeId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"bytes","name":"nativeAddress","type":"bytes"},{"indexed":true,"internalType":"uint256","name":"nativeChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxAmount","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"minReservesBps","type":"uint16"}],"name":"PairAdded","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":"bytes32","name":"submissionId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"debridgeId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"receiver","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"chainIdTo","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"referralCode","type":"uint32"},{"components":[{"internalType":"uint256","name":"receivedAmount","type":"uint256"},{"internalType":"uint256","name":"fixFee","type":"uint256"},{"internalType":"uint256","name":"transferFee","type":"uint256"},{"internalType":"bool","name":"useAssetFee","type":"bool"},{"internalType":"bool","name":"isNativeToken","type":"bool"}],"indexed":false,"internalType":"struct IDeBridgeGate.FeeParams","name":"feeParams","type":"tuple"},{"indexed":false,"internalType":"bytes","name":"autoParams","type":"bytes"},{"indexed":false,"internalType":"address","name":"nativeSender","type":"address"}],"name":"Sent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"}],"name":"Unblocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"debridgeId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"WithdrawnFee","type":"event"},{"inputs":[],"name":"BPS_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPLOY_PREFIX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOVMONITORING_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SUBMISSION_PREFIX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_globalFixedNativeFee","type":"uint256"}],"name":"autoUpdateFixedNativeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_submissionIds","type":"bytes32[]"},{"internalType":"bool","name":"isBlocked","type":"bool"}],"name":"blockSubmission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"callProxy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_debridgeId","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_chainIdFrom","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes","name":"_signatures","type":"bytes"},{"internalType":"bytes","name":"_autoParams","type":"bytes"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deBridgeTokenDeployer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defiController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_nativeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"_nativeChainId","type":"uint256"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"bytes","name":"_signatures","type":"bytes"}],"name":"deployNewAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"excessConfirmations","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeContractUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeDiscount","outputs":[{"internalType":"uint16","name":"discountFixBps","type":"uint16"},{"internalType":"uint16","name":"discountTransferBps","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeProxy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"flash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flashFeeBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"getAmountThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getChainFromConfig","outputs":[{"internalType":"uint256","name":"fixedNativeFee","type":"uint256"},{"internalType":"bool","name":"isSupported","type":"bool"},{"internalType":"uint16","name":"transferFeeBps","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"cid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getChainToConfig","outputs":[{"internalType":"uint256","name":"fixedNativeFee","type":"uint256"},{"internalType":"bool","name":"isSupported","type":"bool"},{"internalType":"uint16","name":"transferFeeBps","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"getDebridge","outputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockedInStrategies","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint16","name":"minReservesBps","type":"uint16"},{"internalType":"bool","name":"exist","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_debridgeId","type":"bytes32"},{"internalType":"uint256","name":"_chainId","type":"uint256"}],"name":"getDebridgeChainAssetFixedFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"getDebridgeFeeInfo","outputs":[{"internalType":"uint256","name":"collectedFees","type":"uint256"},{"internalType":"uint256","name":"withdrawnFees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_chainId","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"getDebridgeId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"getDefiAvaliableReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_debridgeId","type":"bytes32"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"}],"name":"getDeployId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"getNativeInfo","outputs":[{"internalType":"uint256","name":"nativeChainId","type":"uint256"},{"internalType":"bytes","name":"nativeAddress","type":"bytes"}],"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":"_debridgeId","type":"bytes32"},{"internalType":"uint256","name":"_chainIdFrom","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"},{"components":[{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"address","name":"fallbackAddress","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"nativeSender","type":"bytes"}],"internalType":"struct IDeBridgeGate.SubmissionAutoParamsFrom","name":"_autoParams","type":"tuple"},{"internalType":"bool","name":"_hasAutoParams","type":"bool"},{"internalType":"address","name":"_sender","type":"address"}],"name":"getSubmissionIdFrom","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_chainId","type":"uint256"},{"internalType":"bytes","name":"_tokenAddress","type":"bytes"}],"name":"getbDebridgeId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"globalFixedNativeFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalTransferFeeBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"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":"uint8","name":"_excessConfirmations","type":"uint8"},{"internalType":"contract IWETH","name":"_weth","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"isBlockedSubmission","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"isSubmissionUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockedClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"requestReserves","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"returnReserves","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_chainIdTo","type":"uint256"},{"internalType":"bytes","name":"_receiver","type":"bytes"},{"internalType":"bytes","name":"_permit","type":"bytes"},{"internalType":"bool","name":"_useAssetFee","type":"bool"},{"internalType":"uint32","name":"_referralCode","type":"uint32"},{"internalType":"bytes","name":"_autoParams","type":"bytes"}],"name":"send","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_callProxy","type":"address"}],"name":"setCallProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_chainId","type":"uint256"},{"internalType":"bool","name":"_isSupported","type":"bool"},{"internalType":"bool","name":"_isChainFrom","type":"bool"}],"name":"setChainSupport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_deBridgeTokenDeployer","type":"address"}],"name":"setDeBridgeTokenDeployer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_defiController","type":"address"}],"name":"setDefiController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_value","type":"address"}],"name":"setFeeContractUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeProxy","type":"address"}],"name":"setFeeProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_verifier","type":"address"}],"name":"setSignatureVerifier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IWethGate","name":"_wethGate","type":"address"}],"name":"setWethGate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signatureVerifier","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_debridgeId","type":"bytes32"},{"internalType":"uint256","name":"_maxAmount","type":"uint256"},{"internalType":"uint16","name":"_minReservesBps","type":"uint16"},{"internalType":"uint256","name":"_amountThreshold","type":"uint256"}],"name":"updateAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_debridgeId","type":"bytes32"},{"internalType":"uint256[]","name":"_supportedChainIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_assetFeesInfo","type":"uint256[]"}],"name":"updateAssetFixedFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_chainIds","type":"uint256[]"},{"components":[{"internalType":"uint256","name":"fixedNativeFee","type":"uint256"},{"internalType":"bool","name":"isSupported","type":"bool"},{"internalType":"uint16","name":"transferFeeBps","type":"uint16"}],"internalType":"struct IDeBridgeGate.ChainSupportInfo[]","name":"_chainSupportInfo","type":"tuple[]"},{"internalType":"bool","name":"_isChainFrom","type":"bool"}],"name":"updateChainSupport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_excessConfirmations","type":"uint8"}],"name":"updateExcessConfirmations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint16","name":"_discountFixBps","type":"uint16"},{"internalType":"uint16","name":"_discountTransferBps","type":"uint16"}],"name":"updateFeeDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_flashFeeBps","type":"uint256"}],"name":"updateFlashFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_globalFixedNativeFee","type":"uint256"},{"internalType":"uint16","name":"_globalTransferFeeBps","type":"uint16"}],"name":"updateGlobalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wethGate","outputs":[{"internalType":"contract IWethGate","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_debridgeId","type":"bytes32"}],"name":"withdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b50615c0980620000216000396000f3fe6080604052600436106104095760003560e01c806391d1485411610213578063c1efe77d11610123578063da615052116100ab578063e1a452181161007a578063e1a4521814610de8578063e836a7a914610dfe578063ee81fb9714610e2c578063f449063314610e43578063fde919f614610e6357600080fd5b8063da61505214610d46578063dc1995e914610d7a578063e08a660514610da8578063e0d3f02914610dc857600080fd5b8063cb33764a116100f2578063cb33764a14610c89578063d19c3dd814610cc6578063d547741f14610ce6578063d6b531aa14610d06578063d7457c0314610d2657600080fd5b8063c1efe77d14610be6578063c280c90514610c29578063c41449eb14610c49578063c432e3ff14610c6957600080fd5b8063affed0e0116101a6578063ba9f777611610175578063ba9f777614610b52578063bd2608fa14610b73578063bdbc91ab14610b93578063be29747614610bb3578063be7f218414610bc657600080fd5b8063affed0e014610a92578063b242e7cf14610aa8578063b3b25f9514610aff578063b9b5565214610b1f57600080fd5b80639682b909116101e25780639682b909146109f2578063970a117c14610a125780639a8c3a0f14610a33578063a217fddf14610a7d57600080fd5b806391d148541461096c578063932fb34b1461098c578063960396ae146109bd57806396341ea7146109d257600080fd5b80634665a2f41161031957806366dfd489116102a15780637f4de21c116102705780637f4de21c146108d05780638456cb59146108f7578063889d71a21461090c578063895f0c6a1461092c5780638ffcc54f1461094c57600080fd5b806366dfd489146108185780636b063d651461082e578063760112ff1461084e5780637796656c1461086e57600080fd5b8063551156d6116102e8578063551156d6146106ce57806357cf07ca146106ee5780635c837198146107a05780635c975abb146107cf57806365ac9f78146107e757600080fd5b80634665a2f4146106645780634a77d3b6146106845780635187599d1461069957806354fd4d50146106b957600080fd5b80632da688ac1161039c57806335087f0a1161036b57806335087f0a146105d657806336568abe146105ed5780633f4ba83a1461060d5780633fc8cef31461062257806346144c8f1461064357600080fd5b80632da688ac1461054a5780632f2ff15d1461058357806331bf10c1146105a35780633408e470146105c357600080fd5b8063248a9ca3116103d8578063248a9ca3146104ac57806325be0be1146104ea57806326c09e941461050a5780632b0d0a8b1461052a57600080fd5b806301ffc9a714610415578063106f432f1461044a57806311b6e6b41461046c57806315a4587a1461048c57600080fd5b3661041057005b600080fd5b34801561042157600080fd5b50610435610430366004615061565b610e83565b60405190151581526020015b60405180910390f35b34801561045657600080fd5b5061046a6104653660046149f8565b610eba565b005b34801561047857600080fd5b5061046a610487366004614dab565b610f05565b34801561049857600080fd5b5061046a6104a7366004614c8d565b610f55565b3480156104b857600080fd5b506104dc6104c7366004614dab565b60009081526065602052604090206001015490565b604051908152602001610441565b3480156104f657600080fd5b5061046a6105053660046149f8565b611167565b34801561051657600080fd5b5061046a610525366004614dab565b6111b2565b34801561053657600080fd5b5061046a6105453660046149f8565b61130b565b34801561055657600080fd5b5061010a5461056b906001600160a01b031681565b6040516001600160a01b039091168152602001610441565b34801561058f57600080fd5b5061046a61059e366004614dc4565b611389565b3480156105af57600080fd5b5061046a6105be366004615241565b6113b4565b3480156105cf57600080fd5b50466104dc565b3480156105e257600080fd5b506104dc61010d5481565b3480156105f957600080fd5b5061046a610608366004614dc4565b61146b565b34801561061957600080fd5b5061046a6114e9565b34801561062e57600080fd5b5061010b5461056b906001600160a01b031681565b34801561064f57600080fd5b506101085461056b906001600160a01b031681565b34801561067057600080fd5b5061046a61067f3660046152f5565b61151b565b34801561069057600080fd5b506104dc600281565b3480156106a557600080fd5b5061046a6106b436600461532f565b611584565b3480156106c557600080fd5b5061019a6104dc565b3480156106da57600080fd5b5061046a6106e9366004614f01565b611638565b3480156106fa57600080fd5b5061075c610709366004614dab565b60ff602081905260009182526040909120805460018201546002830154600384015460049094015492949193909290916001600160a01b0382169161ffff600160a01b82041691600160b01b9091041687565b6040805197885260208801969096529486019390935260608501919091526001600160a01b0316608084015261ffff1660a0830152151560c082015260e001610441565b3480156107ac57600080fd5b5061010e546107bc9061ffff1681565b60405161ffff9091168152602001610441565b3480156107db57600080fd5b5060975460ff16610435565b3480156107f357600080fd5b50610435610802366004614dab565b6101016020526000908152604090205460ff1681565b34801561082457600080fd5b506104dc60fd5481565b34801561083a57600080fd5b5061046a610849366004614ae2565b6116cf565b34801561085a57600080fd5b506104dc610869366004614fc4565b6117b4565b34801561087a57600080fd5b506108b1610889366004614dab565b610104602052600090815260409020805460019091015460ff811690610100900461ffff1683565b60408051938452911515602084015261ffff1690820152606001610441565b3480156108dc57600080fd5b5061010e5461056b906201000090046001600160a01b031681565b34801561090357600080fd5b5061046a61192f565b34801561091857600080fd5b5061046a6109273660046149f8565b61197e565b34801561093857600080fd5b5061046a610947366004614df4565b6119c8565b34801561095857600080fd5b506104dc6109673660046149f8565b611a92565b34801561097857600080fd5b50610435610987366004614dc4565b611af4565b34801561099857600080fd5b506104356109a7366004614dab565b6101026020526000908152604090205460ff1681565b3480156109c957600080fd5b506104dc600181565b3480156109de57600080fd5b5061046a6109ed366004614be4565b611b1f565b3480156109fe57600080fd5b506104dc610a0d366004614dc4565b611c5a565b348015610a1e57600080fd5b5061010c5461056b906001600160a01b031681565b348015610a3f57600080fd5b50610a68610a4e366004614dab565b610100602052600090815260409020805460019091015482565b60408051928352602083019190915201610441565b348015610a8957600080fd5b506104dc600081565b348015610a9e57600080fd5b506104dc60fe5481565b348015610ab457600080fd5b50610ae4610ac33660046149f8565b6101066020526000908152604090205461ffff808216916201000090041682565b6040805161ffff938416815292909116602083015201610441565b348015610b0b57600080fd5b5061046a610b1a366004614a9d565b611ca3565b348015610b2b57600080fd5b5060fc54610b4090600160a01b900460ff1681565b60405160ff9091168152602001610441565b348015610b5e57600080fd5b506101095461056b906001600160a01b031681565b348015610b7f57600080fd5b5061046a610b8e36600461508b565b611d51565b348015610b9f57600080fd5b5061046a610bae366004614a32565b611f10565b61046a610bc1366004614b0e565b6121e7565b348015610bd257600080fd5b5061046a610be1366004614ae2565b612351565b348015610bf257600080fd5b506108b1610c01366004614dab565b610105602052600090815260409020805460019091015460ff811690610100900461ffff1683565b348015610c3557600080fd5b5061046a610c44366004614f3e565b612502565b348015610c5557600080fd5b5061046a610c643660046152c9565b612684565b348015610c7557600080fd5b5061046a610c843660046149f8565b612705565b348015610c9557600080fd5b506104dc610ca4366004614edf565b6000918252610100602090815260408084209284526002909201905290205490565b348015610cd257600080fd5b506104dc610ce1366004614e60565b612758565b348015610cf257600080fd5b5061046a610d01366004614dc4565b6127fe565b348015610d1257600080fd5b5061046a610d21366004614dab565b612824565b348015610d3257600080fd5b5060fb5461056b906001600160a01b031681565b348015610d5257600080fd5b506104dc7f2b36fa99e118fa8485d488becf749a974743fbeb6a7aa57e663893bf5d69a3c181565b348015610d8657600080fd5b50610d9a610d953660046149f8565b612886565b604051610441929190615890565b348015610db457600080fd5b5061046a610dc33660046149f8565b61292c565b348015610dd457600080fd5b5061046a610de33660046149f8565b612976565b348015610df457600080fd5b506104dc61271081565b348015610e0a57600080fd5b506104dc610e19366004614dab565b6101036020526000908152604090205481565b348015610e3857600080fd5b506104dc61010f5481565b348015610e4f57600080fd5b506104dc610e5e366004615283565b6129c1565b348015610e6f57600080fd5b5060fc5461056b906001600160a01b031681565b60006001600160e01b03198216637965db0b60e01b1480610eb457506301ffc9a760e01b6001600160e01b03198316145b92915050565b610ec5600033611af4565b610ee257604051636f4720fd60e11b815260040160405180910390fd5b61010880546001600160a01b0319166001600160a01b0392909216919091179055565b610f10600033611af4565b610f2d57604051636f4720fd60e11b815260040160405180910390fd5b612710811115610f5057604051634668624160e01b815260040160405180910390fd5b60fd55565b610f60600033611af4565b610f7d57604051636f4720fd60e11b815260040160405180910390fd5b8151835114610f9f57604051634668624160e01b815260040160405180910390fd5b60005b835181101561116157811561103b57828181518110610fc357610fc3615b75565b60200260200101516101056000868481518110610fe257610fe2615b75565b6020908102919091018101518252818101929092526040908101600020835181559183015160019092018054939091015161ffff166101000262ffff00199215159290921662ffffff19909316929092171790556110c1565b82818151811061104d5761104d615b75565b6020026020010151610104600086848151811061106c5761106c615b75565b6020908102919091018101518252818101929092526040908101600020835181559183015160019092018054939091015161ffff166101000262ffff00199215159290921662ffffff19909316929092171790555b7f753df979edb610900dbec05f67411d26a90a78013a0e3a028f2fd9d3c6fd214f8482815181106110f4576110f4615b75565b602002602001015184838151811061110e5761110e615b75565b6020908102919091018101516040805193845281518484015291810151151583830152015161ffff166060820152831515608082015260a00160405180910390a18061115981615b44565b915050610fa2565b50505050565b611172600033611af4565b61118f57604051636f4720fd60e11b815260040160405180910390fd5b61010980546001600160a01b0319166001600160a01b0392909216919091179055565b600260c95414156111de5760405162461bcd60e51b81526004016111d590615803565b60405180910390fd5b600260c955610109546001600160a01b0316331461120f5760405163dd518cdb60e01b815260040160405180910390fd5b600081815261010060205260408120600181015481549192916112329190615aaf565b9050806112525760405163c6c13aa760e01b815260040160405180910390fd5b808260010160008282546112669190615946565b909155506112789050465b6000611c5a565b83141561129b5761010954611296906001600160a01b0316826129d6565b6112c8565b61010954600084815260ff60205260409020600401546112c8916001600160a01b03918216911683612a64565b60408051848152602081018390527fb4006a5a0c03fd761a319df109910cdb56253d60a54ffc647c070b8bad0a8ae3910160405180910390a15050600160c95550565b611316600033611af4565b61133357604051636f4720fd60e11b815260040160405180910390fd5b61010a80546001600160a01b0319166001600160a01b0383169081179091556040519081527fa9543b36462a5e2c2259a14d72a8bd4e2342eaf9d7c828e9fb86921b3aa3eb5f906020015b60405180910390a150565b6000828152606560205260409020600101546113a58133612ac7565b6113af8383612b2b565b505050565b6113bf600033611af4565b6113dc57604051636f4720fd60e11b815260040160405180910390fd5b801561140557600083815261010560205260409020600101805460ff1916831515179055611424565b600083815261010460205260409020600101805460ff19168315151790555b6040805184815283151560208201528215158183015290517f522cc1aea4e8d667320894993cf2dc17feb624e400eb812c41a8efbcefc3d3409181900360600190a1505050565b6001600160a01b03811633146114db5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016111d5565b6114e58282612bb1565b5050565b6114f4600033611af4565b61151157604051636f4720fd60e11b815260040160405180910390fd5b611519612c18565b565b611526600033611af4565b61154357604051636f4720fd60e11b815260040160405180910390fd5b60ff811661156457604051634668624160e01b815260040160405180910390fd5b60fc805460ff909216600160a01b0260ff60a01b19909216919091179055565b600054610100900460ff168061159d575060005460ff16155b6115b95760405162461bcd60e51b81526004016111d5906157b5565b600054610100900460ff161580156115db576000805461ffff19166101011790555b60fc805460ff60a01b1916600160a01b60ff86160217905561010b80546001600160a01b0319166001600160a01b03841617905561161a600033612cab565b611622612cb5565b80156113af576000805461ff0019169055505050565b611643600033611af4565b61166057604051636f4720fd60e11b815260040160405180910390fd5b6127108261ffff16111561168757604051634668624160e01b815260040160405180910390fd5b600093845260ff6020908152604080862060018101959095556004909401805461ffff909416600160a01b0261ffff60a01b1990941693909317909255610103909152912055565b610108546001600160a01b031633146116fb57604051631d1dfb6d60e01b815260040160405180910390fd5b600260c954141561171e5760405162461bcd60e51b81526004016111d590615803565b600260c9556000611730465b84611c5a565b600081815260ff60208190526040909120600481015492935091600160b01b90041661176f57604051631433b3cd60e01b815260040160405180910390fd5b828160030160008282546117839190615aaf565b90915550506101085460048201546117a9916001600160a01b0391821691163086612d29565b5050600160c9555050565b60408051600160208201528082018a905260608082018a905246608083015260a0820189905287901b6001600160601b03191660c082015260d48082018790528251808303909101815260f4909101909152600090831561191857602085015160009060031c6001908116148015611841575085604001516001600160a01b0316846001600160a01b0316145b801561185257508560600151516020145b905081866000015187602001518860400151604051602001611887919060609190911b6001600160601b031916815260140190565b60405160208183030381529060405280519060200120846118d45760608a015180516020918201206040516118c0920190815260200190565b6040516020818303038152906040526118da565b89606001515b60808b015180516020918201206040516118f9979695949392016153ce565b6040516020818303038152906040528051906020012092505050611923565b805160209091012090505b98975050505050505050565b6119597f2b36fa99e118fa8485d488becf749a974743fbeb6a7aa57e663893bf5d69a3c133611af4565b61197657604051636053780560e01b815260040160405180910390fd5b611519612d61565b611989600033611af4565b6119a657604051636f4720fd60e11b815260040160405180910390fd5b60fb80546001600160a01b0319166001600160a01b0392909216919091179055565b6119d3600033611af4565b6119f057604051636f4720fd60e11b815260040160405180910390fd5b8051825114611a1257604051634668624160e01b815260040160405180910390fd5b600083815261010060205260408120905b8351811015611a8b57828181518110611a3e57611a3e615b75565b6020026020010151826002016000868481518110611a5e57611a5e615b75565b60200260200101518152602001908152602001600020819055508080611a8390615b44565b915050611a23565b5050505050565b60008060ff81611aa3465b86611c5a565b81526020810191909152604001600020600481015490915061271090611ad490600160a01b900461ffff1682615aaf565b8260020154611ae39190615a90565b611aed9190615983565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611b2a600033611af4565b611b4757604051636f4720fd60e11b815260040160405180910390fd5b60005b82518110156113af57816101026000858481518110611b6b57611b6b615b75565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055508115611bf5577f7f2b4c099f4c970e6d3b8677f8c32755ce38018a03dad58ed015c68a7e9bc791838281518110611bd157611bd1615b75565b6020026020010151604051611be891815260200190565b60405180910390a1611c48565b7f598eac83c515ef525efc37796beda3b069e752328e8325fb446f84e6cc7d2242838281518110611c2857611c28615b75565b6020026020010151604051611c3f91815260200190565b60405180910390a15b80611c5281615b44565b915050611b4a565b60008282604051602001611c8592919091825260601b6001600160601b031916602082015260340190565b60405160208183030381529060405280519060200120905092915050565b611cae600033611af4565b611ccb57604051636f4720fd60e11b815260040160405180910390fd5b6001600160a01b0383161580611ce657506127108261ffff16115b80611cf657506127108161ffff16115b15611d1457604051634668624160e01b815260040160405180910390fd5b6001600160a01b03909216600090815261010660205260409020805461ffff938416620100000263ffffffff199091169390921692909217179055565b600260c9541415611d745760405162461bcd60e51b81526004016111d590615803565b600260c95560975460ff1615611d9c5760405162461bcd60e51b81526004016111d59061578b565b6000611da886886129c1565b600081815260ff6020819052604090912060040154919250600160b01b9091041615611de75760405163f0faeff560e01b815260040160405180910390fd5b6000611df582878787612758565b60fc54604051632597429960e21b81529192506001600160a01b0381169163965d0a6491611e359185918891600160a01b90910460ff169060040161562f565b600060405180830381600087803b158015611e4f57600080fd5b505af1158015611e63573d6000803e3d6000fd5b505060fb54604051630743550560e01b8152600093506001600160a01b039091169150630743550590611ea09086908b908b908b9060040161565b565b602060405180830381600087803b158015611eba57600080fd5b505af1158015611ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ef29190614a15565b9050611f0083828b8b612db9565b5050600160c95550505050505050565b600260c9541415611f335760405162461bcd60e51b81526004016111d590615803565b600260c95560975460ff1615611f5b5760405162461bcd60e51b81526004016111d59061578b565b6000611f6646611a9d565b600081815260ff6020819052604090912060040154919250600160b01b90910416611fa457604051631433b3cd60e01b815260040160405180910390fd5b600061271060fd5485611fb79190615a90565b611fc19190615983565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a082319060240160206040518083038186803b15801561200657600080fd5b505afa15801561201a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203e9190615228565b90506120546001600160a01b0388168787612a64565b604051635b6e007960e11b8152339063b6dc00f2906120799085908890600401615890565b600060405180830381600087803b15801561209357600080fd5b505af11580156120a7573d6000803e3d6000fd5b50506040516370a0823160e01b8152306004820152600092506001600160a01b038a1691506370a082319060240160206040518083038186803b1580156120ed57600080fd5b505afa158015612101573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121259190615228565b9050806121328484615946565b11156121515760405163b1b335fb60e01b815260040160405180910390fd5b600061215d8383615aaf565b60008681526101006020526040812080549293508392909190612181908490615946565b909155505060408051338152602081018990529081018290526001600160a01b03808a1691908b16907f3a1e073dab8e368be1648fd9c55ea62610b7eb53f9154791282692a76b153ca19060600160405180910390a35050600160c95550505050505050565b600260c954141561220a5760405162461bcd60e51b81526004016111d590615803565b600260c95560975460ff16156122325760405162461bcd60e51b81526004016111d59061578b565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101829052600061226b888d8d8d8b612f2e565b604080516080810182526000808252602082015260609181018290528181019190915291955093509091508415612311576122a885870187615184565b90506122b88d826000015161371b565b8082528c10156122db5760405163fe768a2360e01b815260040160405180910390fd5b60008160600151511180156122f35750604081015151155b15612311576040516315c1f47560e31b815260040160405180910390fd5b805161231d9083615aaf565b91506123298d8361371b565b915061233d848c848d878c878c15156137f0565b5050600160c9555050505050505050505050565b610108546001600160a01b0316331461237d57604051631d1dfb6d60e01b815260040160405180910390fd5b600260c95414156123a05760405162461bcd60e51b81526004016111d590615803565b600260c95560006123b04661172a565b600081815260ff60208190526040909120600481015492935091600160b01b9004166123ef57604051631433b3cd60e01b815260040160405180910390fd5b600481015460028201546000916127109161241591600160a01b900461ffff1690615a90565b61241f9190615983565b6040516370a0823160e01b81523060048201529091506001600160a01b038616906370a082319060240160206040518083038186803b15801561246157600080fd5b505afa158015612475573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124999190615228565b6124a38583615946565b11156124c25760405163c6c13aa760e01b815260040160405180910390fd5b838260030160008282546124d69190615946565b9091555050610108546124f6906001600160a01b03878116911686612a64565b5050600160c955505050565b60975460ff16156125255760405162461bcd60e51b81526004016111d59061578b565b6000878152610105602052604090206001015460ff1661255857604051633b5bbdf960e11b815260040160405180910390fd5b6125936040518060a00160405280600081526020016000815260200160006001600160a01b0316815260200160608152602001606081525090565b81156125a8576125a582840184615150565b90505b60006125bc8b8a8c8b8b87891515336117b4565b6000818152610101602052604090205490915060ff16156125f05760405163e4e5e97560e01b815260040160405180910390fd5b600081815261010160205260409020805460ff19166001179055612617818c8c8989613aa9565b6000612627828d8b8e8e88613b79565b905089896001600160a01b03168d7ffee5cae6d86f128037e90fc8d24296e73ad402bd6f6f09098589d528c2e14ad2858f8d8b8b8960405161266e9695949392919061573d565b60405180910390a4505050505050505050505050565b61268f600033611af4565b6126ac57604051636f4720fd60e11b815260040160405180910390fd5b61010d82905561010e805461ffff191661ffff83169081179091556040805184815260208101929092527f850cd955704b99a3588cb377341a321bc53b01073abba0af4616b0c70eb77943910160405180910390a15050565b612710600033611af4565b61272d57604051636f4720fd60e11b815260040160405180910390fd5b61010e80546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b60006002858560405160200161276e91906153b2565b604051602081830303815290604052805190602001208560405160200161279591906153b2565b60408051601f19818403018152828252805160209182012090830195909552810192909252606082015260808101919091526001600160f81b031960f884901b1660a082015260a101604051602081830303815290604052805190602001209050949350505050565b60008281526065602052604090206001015461281a8133612ac7565b6113af8383612bb1565b61010c546001600160a01b03163314612850576040516341c83f5f60e11b815260040160405180910390fd5b61010d8190556040518181527f6af65247cf743b7cb486dac49457e290bf672f3d89f71ed05d3f56d7b69c014b9060200161137e565b61010760205260009081526040902080546001820180549192916128a990615b09565b80601f01602080910402602001604051908101604052809291908181526020018280546128d590615b09565b80156129225780601f106128f757610100808354040283529160200191612922565b820191906000526020600020905b81548152906001019060200180831161290557829003601f168201915b5050505050905082565b612937600033611af4565b61295457604051636f4720fd60e11b815260040160405180910390fd5b60fc80546001600160a01b0319166001600160a01b0392909216919091179055565b612981600033611af4565b61299e57604051636f4720fd60e11b815260040160405180910390fd5b61010c80546001600160a01b0319166001600160a01b0392909216919091179055565b60008282604051602001611c859291906154dc565b604080516000808252602082019092526001600160a01b038416908390604051612a0091906153b2565b60006040518083038185875af1925050503d8060008114612a3d576040519150601f19603f3d011682016040523d82523d6000602084013e612a42565b606091505b50509050806113af57604051630db2c7f160e31b815260040160405180910390fd5b6040516001600160a01b0383166024820152604481018290526113af90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613f17565b612ad18282611af4565b6114e557612ae9816001600160a01b03166014613fe9565b612af4836020613fe9565b604051602001612b0592919061541e565b60408051601f198184030181529082905262461bcd60e51b82526111d591600401615778565b612b358282611af4565b6114e55760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612b6d3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b612bbb8282611af4565b156114e55760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60975460ff16612c615760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016111d5565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6114e58282612b2b565b600054610100900460ff1680612cce575060005460ff16155b612cea5760405162461bcd60e51b81526004016111d5906157b5565b600054610100900460ff16158015612d0c576000805461ffff19166101011790555b612d14614184565b8015612d26576000805461ff00191690555b50565b6040516001600160a01b03808516602483015283166044820152606481018290526111619085906323b872dd60e01b90608401612a90565b60975460ff1615612d845760405162461bcd60e51b81526004016111d59061578b565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612c8e3390565b600084815260ff6020819052604090912060048101549091600160b01b9091041615612df85760405163f0faeff560e01b815260040160405180910390fd5b6001600160a01b038416612e1f5760405163d92e233d60e01b815260040160405180910390fd5b6004810180546001600160a01b038616600162ff000160a01b031990911617600160b01b1790558181556001810154612e5b5760001960018201555b60048101805461ffff60a01b191661027160a41b17905560008581526101036020526040902054612e9b5760008581526101036020526040902060001990555b6001600160a01b03841660009081526101076020908152604090912083815584519091612ecf916001840191870190614737565b50827f2fe256b895c7737f17df53e47f93d864727942c40cbfeb0098fb10b2b57da51487878786600101548760040160149054906101000a900461ffff16604051612f1e9594939291906155bb565b60405180910390a2505050505050565b6040805160a08101825260008082526020820181905291810182905260608101829052608081018290528190612f63876141f4565b875115613018576000612f76898261434f565b905060008080612f878c6020614386565b60405163d505accf60e01b8152336004820152306024820152604481018e90526064810188905260ff8216608482015260a4810184905260c4810183905292955090935091506001600160a01b038c169063d505accf9060e401600060405180830381600087803b158015612ffb57600080fd5b505af115801561300f573d6000803e3d6000fd5b50505050505050505b60006101076000896001600160a01b03166001600160a01b031681526020019081526020016000206040518060400160405290816000820154815260200160018201805461306590615b09565b80601f016020809104026020016040519081016040528092919081815260200182805461309190615b09565b80156130de5780601f106130b3576101008083540402835291602001916130de565b820191906000526020600020905b8154815290600101906020018083116130c157829003601f168201915b5050505050815250509050600081600001516000146131005746825114613103565b60015b9050801561313d57613136466001600160a01b038b1615613124578a611c5a565b61010b546001600160a01b0316611c5a565b9350613152565b61314f826000015183602001516129c1565b93505b600084815260ff6020819052604090912060048101549091600160b01b909104166132015781156131e85760006001600160a01b038b1615613194578a6131a2565b61010b546001600160a01b03165b6040516001600160601b0319606083901b1660208201529091506131e290879083906034016040516020818303038152906040526131dd4690565b612db9565b50613201565b604051631433b3cd60e01b815260040160405180910390fd5b6000888152610104602090815260409182902082516060810184528154815260019091015460ff81161515928201839052610100900461ffff169281019290925261325f576040516357fca4cf60e11b815260040160405180910390fd5b6001600160a01b038b166132e35734995061010b60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db08b6040518263ffffffff1660e01b81526004016000604051808303818588803b1580156132c157600080fd5b505af11580156132d5573d6000803e3d6000fd5b5050505050600197506133fe565b6040516370a0823160e01b81523060048201528b906000906001600160a01b038316906370a082319060240160206040518083038186803b15801561332757600080fd5b505afa15801561333b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061335f9190615228565b90506133766001600160a01b03831633308f612d29565b6040516370a0823160e01b815230600482015281906001600160a01b038416906370a082319060240160206040518083038186803b1580156133b757600080fd5b505afa1580156133cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ef9190615228565b6133f99190615aaf565b9b5050505b81600101548a111561342357604051635a20217760e11b815260040160405180910390fd5b3360009081526101066020908152604080832081518083018352905461ffff8082168352620100009091041681840152898452610100909252822090918a156134fb576001600160a01b038e1661348e57835115613482578351613487565b61010d545b90506134be565b5060008b8152600282016020526040902054806134be5760405163156321fb60e11b815260040160405180910390fd5b6134cc8184600001516143f3565b9050808d10156134ef57604051630a44071360e01b815260040160405180910390fd5b6020880181905261359a565b83516000901561350c578451613511565b61010d545b90506135218185600001516143f3565b90508034101561354457604051630a44071360e01b815260040160405180910390fd5b8034111561355f5761355f3361355a8334615aaf565b6129d6565b600061356a46611271565b6000818152610100602052604081208054929350849290919061358e908490615946565b90915550505060208901525b6000612710828f6135ab9190615aaf565b604087015161ffff16156135c35786604001516135cc565b61010e5461ffff165b61ffff166135da9190615a90565b6135e49190615983565b90506135f48185602001516143f3565b905060006136028383615946565b9050808f101561362557604051630a44071360e01b815260040160405180910390fd5b808460000160008282546136399190615946565b92505081905550808f61364c9190615aaf565b60408b0192909252508b151560608a01528d89528615801560808b0152909a50925061369491505057868260020160008282546136899190615946565b9091555061370c9050565b868260020160008282546136a89190615aaf565b9091555050600482810154604051630852cd8d60e31b81529182018990526001600160a01b0316906342966c6890602401600060405180830381600087803b1580156136f357600080fd5b505af1158015613707573d6000803e3d6000fd5b505050505b50505050955095509592505050565b6000806001600160a01b038416156137a357836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561376657600080fd5b505afa15801561377a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379e9190615312565b6137a6565b60125b60ff1690506008808211156137e75760006137c18284615aaf565b6137cc90600a6159e8565b9050806137d98187615983565b6137e39190615a90565b9450505b50919392505050565b60008060018a4660fe54604051613812949392918e918e918e91602001615493565b6040516020818303038152906040529050821561391e57602084015160031c60019081161480801561384a5750846060015151602014155b15613868576040516315c1f47560e31b815260040160405180910390fd5b8185600001518660200151876040015180519060200120846138b657606089015180516020918201206040516138a2920190815260200190565b6040516020818303038152906040526138bc565b88606001515b6040516001600160601b03193360601b16602082015260340160405160208183030381529060405280519060200120604051602001613900969594939291906153ce565b60405160208183030381529060405280519060200120925050613928565b8051602082012091505b888a7fe315721819a1f353fe56de404206bdd896ab5edc7822f1804a8c4c2c4788174c848b8b60fe548b8d8b61396d576040518060200160405280600081525061398e565b8c60405160200161397e919061583a565b6040516020818303038152906040525b336040516139a398979695949392919061569b565b60405180910390a360fe5460008b815260ff6020908152604091829020600281015460049182015484516318160ddd60e01b815294517f6bc83b8dd1a15f3a247f8f99d37e3bb8ae7074ea13ee1f509e045723fafe0b55968996909593946001600160a01b03909316936318160ddd93828101939192829003018186803b158015613a2d57600080fd5b505afa158015613a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a659190615228565b60408051948552602085019390935291830152606082015260800160405180910390a160fe8054906000613a9883615b44565b919050555050505050505050505050565b6000858152610102602052604090205460ff1615613ada5760405163d49624bf60e01b815260040160405180910390fd5b60fc54600085815261010360205260409020546001600160a01b039091169063965d0a6490879085908590881015613b13576000613b21565b60fc54600160a01b900460ff165b6040518563ffffffff1660e01b8152600401613b409493929190615601565b600060405180830381600087803b158015613b5a57600080fd5b505af1158015613b6e573d6000803e3d6000fd5b505050505050505050565b600085815260ff60208190526040822060048101549091600160b01b90910416613bb657604051631433b3cd60e01b815260040160405180910390fd5b4681541491508115613bec578251613bce9086615946565b816002016000828254613be19190615aaf565b90915550613c119050565b8251613bf89086615946565b816002016000828254613c0b9190615946565b90915550505b60048101546001600160a01b03166000838015613c35575060208501516001908116145b8015613c4f575061010b546001600160a01b038381169116145b855190915015613c6957613c69823387600001518761441a565b60608501515115613e275761010a546001600160a01b031660008215613d3257613c93828a6144a7565b816001600160a01b03166329e164db88604001518c8a606001518b602001518c608001518e6040518763ffffffff1660e01b8152600401613cd996959493929190615563565b602060405180830381600087803b158015613cf357600080fd5b505af1158015613d07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d2b9190614d8e565b9050613ddb565b613d3e84838b8961441a565b816001600160a01b031663b88c998b8589604001518d8b606001518c602001518d608001518f6040518863ffffffff1660e01b8152600401613d869796959493929190615502565b602060405180830381600087803b158015613da057600080fd5b505af1158015613db4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dd89190614d8e565b90505b604080518d81526001600160a01b0384166020820152821515917fb5fadd70c6860131059f49f37dff63a2b25d1df54e62d75c8327d896c0f7a0ad910160405180910390a25050613e48565b8015613e3c57613e3788886144a7565b613e48565b613e488289898761441a565b6002830154600480850154604080516318160ddd60e01b815290517fe16b3d616e66789124fb71bf745a9a969a79906489c299e52e09686696152ef1948f9490936001600160a01b0316926318160ddd9281830192602092829003018186803b158015613eb457600080fd5b505afa158015613ec8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eec9190615228565b6040805193845260208401929092529082015260600160405180910390a15050509695505050505050565b6000613f6c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166145bf9092919063ffffffff16565b8051909150156113af5780806020019051810190613f8a9190614d8e565b6113af5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016111d5565b60606000613ff8836002615a90565b614003906002615946565b6001600160401b0381111561401a5761401a615b8b565b6040519080825280601f01601f191660200182016040528015614044576020820181803683370190505b509050600360fc1b8160008151811061405f5761405f615b75565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061408e5761408e615b75565b60200101906001600160f81b031916908160001a90535060006140b2846002615a90565b6140bd906001615946565b90505b6001811115614135576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106140f1576140f1615b75565b1a60f81b82828151811061410757614107615b75565b60200101906001600160f81b031916908160001a90535060049490941c9361412e81615af2565b90506140c0565b508315611aed5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016111d5565b600054610100900460ff168061419d575060005460ff16155b6141b95760405162461bcd60e51b81526004016111d5906157b5565b600054610100900460ff161580156141db576000805461ffff19166101011790555b600160c9558015612d26576000805461ff001916905550565b6001600160a01b0381166142055750565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290516000916001600160a01b0384169161424791906153b2565b6000604051808303816000865af19150503d8060008114614284576040519150601f19603f3d011682016040523d82523d6000602084013e614289565b606091505b50509050806142ab57604051636d737eeb60e01b815260040160405180910390fd5b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b17905290516001600160a01b038416916142e9916153b2565b6000604051808303816000865af19150503d8060008114614326576040519150601f19603f3d011682016040523d82523d6000602084013e61432b565b606091505b505080915050806114e557604051636d737eeb60e01b815260040160405180910390fd5b600061435c826020615946565b8351101561437d576040516340f0f32960e01b815260040160405180910390fd5b50016020015190565b8181016020810151604082015160419092015190919060ff16601b8110156143b6576143b3601b8261595e565b90505b8060ff16601b141580156143ce57508060ff16601c14155b156143ec57604051630633a0a560e21b815260040160405180910390fd5b9250925092565b600061271061440661ffff841685615a90565b6144109190615983565b611aed9084615aaf565b811561116157801561443f5761443a6001600160a01b0385168484612a64565b611161565b6040516340c10f1960e01b81526001600160a01b038481166004830152602482018490528516906340c10f1990604401600060405180830381600087803b15801561448957600080fd5b505af115801561449d573d6000803e3d6000fd5b5050505050505050565b61010e546201000090046001600160a01b03166145275761010b54604051632e1a7d4d60e01b8152600481018390526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b15801561450557600080fd5b505af1158015614519573d6000803e3d6000fd5b505050506114e582826129d6565b61010e5461010b5461454d916001600160a01b0391821691620100009091041683612a64565b61010e5460405163f3fef3a360e01b81526001600160a01b03848116600483015260248201849052620100009092049091169063f3fef3a390604401600060405180830381600087803b1580156145a357600080fd5b505af11580156145b7573d6000803e3d6000fd5b505050505050565b60606145ce84846000856145d6565b949350505050565b6060824710156146375760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016111d5565b843b6146855760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016111d5565b600080866001600160a01b031685876040516146a191906153b2565b60006040518083038185875af1925050503d80600081146146de576040519150601f19603f3d011682016040523d82523d6000602084013e6146e3565b606091505b50915091506146f38282866146fe565b979650505050505050565b6060831561470d575081611aed565b82511561471d5782518084602001fd5b8160405162461bcd60e51b81526004016111d59190615778565b82805461474390615b09565b90600052602060002090601f01602090048101928261476557600085556147ab565b82601f1061477e57805160ff19168380011785556147ab565b828001600101855582156147ab579182015b828111156147ab578251825591602001919060010190614790565b506147b79291506147bb565b5090565b5b808211156147b757600081556001016147bc565b80356147db81615ba1565b919050565b600082601f8301126147f157600080fd5b8135602061480661480183615923565b6158f3565b80838252828201915082860187848660051b890101111561482657600080fd5b60005b8581101561484557813584529284019290840190600101614829565b5090979650505050505050565b80356147db81615bb6565b60008083601f84011261486f57600080fd5b5081356001600160401b0381111561488657600080fd5b60208301915083602082850101111561489e57600080fd5b9250929050565b600082601f8301126148b657600080fd5b81356001600160401b038111156148cf576148cf615b8b565b6148e2601f8201601f19166020016158f3565b8181528460208386010111156148f757600080fd5b816020850160208301376000918101602001919091529392505050565b600060a0828403121561492657600080fd5b60405160a081016001600160401b03828210818311171561494957614949615b8b565b8160405282935084358352602085013560208401526040850135915061496e82615ba1565b816040840152606085013591508082111561498857600080fd5b614994868387016148a5565b606084015260808501359150808211156149ad57600080fd5b506149ba858286016148a5565b6080830152505092915050565b803561ffff811681146147db57600080fd5b803563ffffffff811681146147db57600080fd5b80356147db81615bc4565b600060208284031215614a0a57600080fd5b8135611aed81615ba1565b600060208284031215614a2757600080fd5b8151611aed81615ba1565b60008060008060808587031215614a4857600080fd5b8435614a5381615ba1565b93506020850135614a6381615ba1565b92506040850135915060608501356001600160401b03811115614a8557600080fd5b614a91878288016148a5565b91505092959194509250565b600080600060608486031215614ab257600080fd5b8335614abd81615ba1565b9250614acb602085016149c7565b9150614ad9604085016149c7565b90509250925092565b60008060408385031215614af557600080fd5b8235614b0081615ba1565b946020939093013593505050565b60008060008060008060008060006101008a8c031215614b2d57600080fd5b614b368a6147d0565b985060208a0135975060408a0135965060608a01356001600160401b0380821115614b6057600080fd5b614b6c8d838e016148a5565b975060808c0135915080821115614b8257600080fd5b614b8e8d838e016148a5565b9650614b9c60a08d01614852565b9550614baa60c08d016149d9565b945060e08c0135915080821115614bc057600080fd5b50614bcd8c828d0161485d565b915080935050809150509295985092959850929598565b60008060408385031215614bf757600080fd5b82356001600160401b03811115614c0d57600080fd5b8301601f81018513614c1e57600080fd5b80356020614c2e61480183615923565b80838252828201915082850189848660051b8801011115614c4e57600080fd5b600095505b84861015614c71578035835260019590950194918301918301614c53565b509550614c819050868201614852565b93505050509250929050565b60008060006060808587031215614ca357600080fd5b84356001600160401b0380821115614cba57600080fd5b614cc6888389016147e0565b9550602091508187013581811115614cdd57600080fd5b87019050601f81018813614cf057600080fd5b8035614cfe61480182615923565b81815283810190838501868402850186018c1015614d1b57600080fd5b60009450845b84811015614d775787828e031215614d37578586fd5b614d3f6158a9565b8235815287830135614d5081615bb6565b818901526040614d618482016149c7565b9082015284529286019290870190600101614d21565b5050809750505050505050614ad960408501614852565b600060208284031215614da057600080fd5b8151611aed81615bb6565b600060208284031215614dbd57600080fd5b5035919050565b60008060408385031215614dd757600080fd5b823591506020830135614de981615ba1565b809150509250929050565b600080600060608486031215614e0957600080fd5b8335925060208401356001600160401b0380821115614e2757600080fd5b614e33878388016147e0565b93506040860135915080821115614e4957600080fd5b50614e56868287016147e0565b9150509250925092565b60008060008060808587031215614e7657600080fd5b8435935060208501356001600160401b0380821115614e9457600080fd5b614ea0888389016148a5565b94506040870135915080821115614eb657600080fd5b50614ec3878288016148a5565b9250506060850135614ed481615bc4565b939692955090935050565b60008060408385031215614ef257600080fd5b50508035926020909101359150565b60008060008060808587031215614f1757600080fd5b8435935060208501359250614f2e604086016149c7565b9396929550929360600135925050565b600080600080600080600080600060e08a8c031215614f5c57600080fd5b8935985060208a0135975060408a0135965060608a0135614f7c81615ba1565b955060808a0135945060a08a01356001600160401b0380821115614f9f57600080fd5b614fab8d838e0161485d565b909650945060c08c0135915080821115614bc057600080fd5b600080600080600080600080610100898b031215614fe157600080fd5b883597506020890135965060408901359550606089013561500181615ba1565b94506080890135935060a08901356001600160401b0381111561502357600080fd5b61502f8b828c01614914565b93505060c089013561504081615bb6565b915060e089013561505081615ba1565b809150509295985092959890939650565b60006020828403121561507357600080fd5b81356001600160e01b031981168114611aed57600080fd5b60008060008060008060c087890312156150a457600080fd5b86356001600160401b03808211156150bb57600080fd5b6150c78a838b016148a5565b97506020890135965060408901359150808211156150e457600080fd5b6150f08a838b016148a5565b9550606089013591508082111561510657600080fd5b6151128a838b016148a5565b945061512060808a016149ed565b935060a089013591508082111561513657600080fd5b5061514389828a016148a5565b9150509295509295509295565b60006020828403121561516257600080fd5b81356001600160401b0381111561517857600080fd5b6145ce84828501614914565b60006020828403121561519657600080fd5b81356001600160401b03808211156151ad57600080fd5b90830190608082860312156151c157600080fd5b6151c96158d1565b82358152602083013560208201526040830135828111156151e957600080fd5b6151f5878286016148a5565b60408301525060608301358281111561520d57600080fd5b615219878286016148a5565b60608301525095945050505050565b60006020828403121561523a57600080fd5b5051919050565b60008060006060848603121561525657600080fd5b83359250602084013561526881615bb6565b9150604084013561527881615bb6565b809150509250925092565b6000806040838503121561529657600080fd5b8235915060208301356001600160401b038111156152b357600080fd5b6152bf858286016148a5565b9150509250929050565b600080604083850312156152dc57600080fd5b823591506152ec602084016149c7565b90509250929050565b60006020828403121561530757600080fd5b8135611aed81615bc4565b60006020828403121561532457600080fd5b8151611aed81615bc4565b6000806040838503121561534257600080fd5b823561534d81615bc4565b91506020830135614de981615ba1565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6000815180845261539e816020860160208601615ac6565b601f01601f19169290920160200192915050565b600082516153c4818460208701615ac6565b9190910192915050565b600087516153e0818460208c01615ac6565b80830190508781528660208201528560408201528451615407816060840160208901615ac6565b016060810193909352505060800195945050505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615456816017850160208801615ac6565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615487816028840160208801615ac6565b01602801949350505050565b878152866020820152856040820152846060820152836080820152600083516154c38160a0850160208801615ac6565b60a092019182019290925260c001979650505050505050565b828152600082516154f4816020850160208701615ac6565b919091016020019392505050565b6001600160a01b03888116825287811660208301528616604082015260e06060820181905260009061553690830187615386565b85608084015282810360a084015261554e8186615386565b9150508260c083015298975050505050505050565b6001600160a01b0387811682528616602082015260c06040820181905260009061558f90830187615386565b85606084015282810360808401526155a78186615386565b9150508260a0830152979650505050505050565b8581526001600160a01b038516602082015260a0604082018190526000906155e590830186615386565b905083606083015261ffff831660808301529695505050505050565b84815260606020820152600061561b60608301858761535d565b905060ff8316604083015295945050505050565b8381526060602082015260006156486060830185615386565b905060ff83166040830152949350505050565b8481526080602082015260006156746080830186615386565b82810360408401526156868186615386565b91505060ff8316606083015295945050505050565b60006101808a83528960208401528060408401526156bb8184018a615386565b905087606084015263ffffffff87166080840152855160a0840152602086015160c0840152604086015160e084015260608601511515610100840152608086015115156101208401528281036101408401526157178186615386565b9150506157306101608301846001600160a01b03169052565b9998505050505050505050565b86815285602082015284604082015260a06060820152600061576360a08301858761535d565b90508215156080830152979650505050505050565b602081526000611aed6020830184615386565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602081528151602082015260208201516040820152600060408301516080606084015261586a60a0840182615386565b90506060840151601f198483030160808501526158878282615386565b95945050505050565b8281526040602082015260006145ce6040830184615386565b604051606081016001600160401b03811182821017156158cb576158cb615b8b565b60405290565b604051608081016001600160401b03811182821017156158cb576158cb615b8b565b604051601f8201601f191681016001600160401b038111828210171561591b5761591b615b8b565b604052919050565b60006001600160401b0382111561593c5761593c615b8b565b5060051b60200190565b6000821982111561595957615959615b5f565b500190565b600060ff821660ff84168060ff0382111561597b5761597b615b5f565b019392505050565b6000826159a057634e487b7160e01b600052601260045260246000fd5b500490565b600181815b808511156159e05781600019048211156159c6576159c6615b5f565b808516156159d357918102915b93841c93908002906159aa565b509250929050565b6000611aed83836000826159fe57506001610eb4565b81615a0b57506000610eb4565b8160018114615a215760028114615a2b57615a47565b6001915050610eb4565b60ff841115615a3c57615a3c615b5f565b50506001821b610eb4565b5060208310610133831016604e8410600b8410161715615a6a575081810a610eb4565b615a7483836159a5565b8060001904821115615a8857615a88615b5f565b029392505050565b6000816000190483118215151615615aaa57615aaa615b5f565b500290565b600082821015615ac157615ac1615b5f565b500390565b60005b83811015615ae1578181015183820152602001615ac9565b838111156111615750506000910152565b600081615b0157615b01615b5f565b506000190190565b600181811c90821680615b1d57607f821691505b60208210811415615b3e57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615b5857615b58615b5f565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612d2657600080fd5b8015158114612d2657600080fd5b60ff81168114612d2657600080fdfea2646970667358221220b5eaeefca1e921eadde87940bbc0fdb52cd34993d5951ed8414bd2958265817964736f6c63430008070033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.