ETH Price: $2,678.51 (-0.63%)

Contract

0xfF3aFb7d847AeD8f2540f7b5042F693242e01ebD
 

Overview

ETH Balance

0.05028730367112335 ETH

Eth Value

$134.70 (@ $2,678.51/ETH)
Transaction Hash
Method
Block
From
To
Set Approval For...198664832024-05-14 6:32:11137 days ago1715668331IN
0xfF3aFb7d...242e01ebD
0 ETH0.000169826.98585108
Set Approval For...187756312023-12-13 7:01:35290 days ago1702450895IN
0xfF3aFb7d...242e01ebD
0 ETH0.0019858542.96340591
Set Approval For...187719012023-12-12 18:30:47291 days ago1702405847IN
0xfF3aFb7d...242e01ebD
0 ETH0.0022233148.10080353
Set Approval For...187468162023-12-09 6:14:23294 days ago1702102463IN
0xfF3aFb7d...242e01ebD
0 ETH0.0012978528.07882844
Set Approval For...185934092023-11-17 18:32:47316 days ago1700245967IN
0xfF3aFb7d...242e01ebD
0 ETH0.001878940.64951852
Set Approval For...183154262023-10-09 20:54:47355 days ago1696884887IN
0xfF3aFb7d...242e01ebD
0 ETH0.00015246.26926604
Set Approval For...182920542023-10-06 14:27:47358 days ago1696602467IN
0xfF3aFb7d...242e01ebD
0 ETH0.0006266313.55699839
Set Approval For...182654252023-10-02 21:05:59362 days ago1696280759IN
0xfF3aFb7d...242e01ebD
0 ETH0.0007672716.59971973
Set Approval For...182621782023-10-02 10:13:59362 days ago1696241639IN
0xfF3aFb7d...242e01ebD
0 ETH0.000413098.93716532
Set Approval For...181146492023-09-11 17:38:35383 days ago1694453915IN
0xfF3aFb7d...242e01ebD
0 ETH0.0011488824.85570424
Set Approval For...176760222023-07-12 7:32:47444 days ago1689147167IN
0xfF3aFb7d...242e01ebD
0 ETH0.0006787314.68422555
Set Approval For...176736082023-07-11 23:23:35445 days ago1689117815IN
0xfF3aFb7d...242e01ebD
0 ETH0.0006364113.76872879
Set Approval For...176690882023-07-11 8:08:11445 days ago1689062891IN
0xfF3aFb7d...242e01ebD
0 ETH0.0007342415.88523604
Set Approval For...175553172023-06-25 8:29:59461 days ago1687681799IN
0xfF3aFb7d...242e01ebD
0 ETH0.000291912.00747347
Set Approval For...175553032023-06-25 8:27:11461 days ago1687681631IN
0xfF3aFb7d...242e01ebD
0 ETH0.0005632312.1853368
Set Approval For...173365702023-05-25 13:51:47492 days ago1685022707IN
0xfF3aFb7d...242e01ebD
0 ETH0.0019711942.6462788
Set Approval For...170129822023-04-09 20:06:35538 days ago1681070795IN
0xfF3aFb7d...242e01ebD
0 ETH0.0008319918
Set Approval For...169832472023-04-05 14:43:47542 days ago1680705827IN
0xfF3aFb7d...242e01ebD
0 ETH0.0018055539.06262798
Set Approval For...169067962023-03-25 20:17:23553 days ago1679775443IN
0xfF3aFb7d...242e01ebD
0 ETH0.0003870615.92224603
Set Approval For...169067882023-03-25 20:15:47553 days ago1679775347IN
0xfF3aFb7d...242e01ebD
0 ETH0.0007519716.26878994
Set Approval For...168201542023-03-13 16:07:59565 days ago1678723679IN
0xfF3aFb7d...242e01ebD
0 ETH0.0035425776.64269698
Set Approval For...168158682023-03-13 1:41:59565 days ago1678671719IN
0xfF3aFb7d...242e01ebD
0 ETH0.0009536120.63127635
Set Approval For...167964642023-03-10 8:09:11568 days ago1678435751IN
0xfF3aFb7d...242e01ebD
0 ETH0.0010373822.44344803
Set Approval For...167480012023-03-03 12:32:23575 days ago1677846743IN
0xfF3aFb7d...242e01ebD
0 ETH0.0009755721.10624732
Set Approval For...167298662023-02-28 23:18:11578 days ago1677626291IN
0xfF3aFb7d...242e01ebD
0 ETH0.0009326820.17837331
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
163753002023-01-10 8:45:59627 days ago1673340359
0xfF3aFb7d...242e01ebD
0.001 ETH
163750112023-01-10 7:47:59627 days ago1673336879
0xfF3aFb7d...242e01ebD
0.00168461 ETH
163750112023-01-10 7:47:59627 days ago1673336879
0xfF3aFb7d...242e01ebD
0.01853115 ETH
163686932023-01-09 10:37:47628 days ago1673260667
0xfF3aFb7d...242e01ebD
0.00000461 ETH
163686932023-01-09 10:37:47628 days ago1673260667
0xfF3aFb7d...242e01ebD
0.00005079 ETH
163641822023-01-08 19:33:11629 days ago1673206391
0xfF3aFb7d...242e01ebD
0.01799999 ETH
163638462023-01-08 18:25:35629 days ago1673202335
0xfF3aFb7d...242e01ebD
0.019 ETH
163636622023-01-08 17:48:47629 days ago1673200127
0xfF3aFb7d...242e01ebD
0.03 ETH
163634512023-01-08 17:06:23629 days ago1673197583
0xfF3aFb7d...242e01ebD
0.00176022 ETH
163634512023-01-08 17:06:23629 days ago1673197583
0xfF3aFb7d...242e01ebD
0.01936281 ETH
163634512023-01-08 17:06:23629 days ago1673197583
0xfF3aFb7d...242e01ebD
0.00078074 ETH
163627172023-01-08 14:38:35629 days ago1673188715
0xfF3aFb7d...242e01ebD
0.05 ETH
163626072023-01-08 14:16:23629 days ago1673187383
0xfF3aFb7d...242e01ebD
0.0017146 ETH
163626072023-01-08 14:16:23629 days ago1673187383
0xfF3aFb7d...242e01ebD
0.01886083 ETH
163626072023-01-08 14:16:23629 days ago1673187383
0xfF3aFb7d...242e01ebD
0.00002947 ETH
163614682023-01-08 10:27:11629 days ago1673173631
0xfF3aFb7d...242e01ebD
0.0015 ETH
163607502023-01-08 8:02:35629 days ago1673164955
0xfF3aFb7d...242e01ebD
0.00187534 ETH
163607502023-01-08 8:02:35629 days ago1673164955
0xfF3aFb7d...242e01ebD
0.0206296 ETH
163605852023-01-08 7:29:23629 days ago1673162963
0xfF3aFb7d...242e01ebD
0.00168136 ETH
163605852023-01-08 7:29:23629 days ago1673162963
0xfF3aFb7d...242e01ebD
0.01849506 ETH
163605852023-01-08 7:29:23629 days ago1673162963
0xfF3aFb7d...242e01ebD
0.01799999 ETH
163565892023-01-07 18:06:35630 days ago1673114795
0xfF3aFb7d...242e01ebD
0.01799999 ETH
163565832023-01-07 18:05:23630 days ago1673114723
0xfF3aFb7d...242e01ebD
0.01799999 ETH
163535542023-01-07 7:56:23630 days ago1673078183
0xfF3aFb7d...242e01ebD
0.01799999 ETH
163531702023-01-07 6:38:59630 days ago1673073539
0xfF3aFb7d...242e01ebD
0.01799999 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SuperRouter

Compiler Version
v0.8.14+commit.80d49f37

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion
File 1 of 20 : SuperRouter.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.14;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import {LiqRequest} from "./types/socketTypes.sol";
import {StateReq, StateData, TransactionType, ReturnData, CallbackType, InitData} from "./types/lzTypes.sol";

import {IStateHandler} from "./interface/layerzero/IStateHandler.sol";
import {IDestination} from "./interface/IDestination.sol";

import "./socket/liquidityHandler.sol";

/**
 * @title Super Router
 * @author Zeropoint Labs.
 *
 * Routes users funds and deposit information to a remote execution chain.
 * extends ERC1155 and Socket's Liquidity Handler.
 * @notice access controlled was removed due to contract sizing issues.
 */
contract SuperRouter is ERC1155, LiquidityHandler, Ownable {
    using SafeERC20 for IERC20;
    using Strings for string;

    /* ================ State Variables =================== */
    string public name = "SuperPositions";
    string public symbol = "SP";
    string public dynamicURI = "https://api.superform.xyz/superposition/";

    /**
     * @notice state = information about destination chain & vault id.
     * @notice  stateHandler accepts requests from whitelisted addresses.
     * @dev stateHandler integrates with interblockchain messaging protocols.
     */
    IStateHandler public stateHandler;

    /**
     * @notice chainId represents layerzero's unique chain id for each chains.
     * @notice admin handles critical state updates.
     * @dev totalTransactions keeps track of overall routed transactions.
     */
    uint16 public chainId;
    uint256 public totalTransactions;

    /**
     * @notice same chain deposits are processed in one atomic transaction flow.
     * @dev allows to store same chain destination contract addresses.
     */
    IDestination public immutable srcSuperDestination;

    /**
     * @notice history of state sent across chains are used for debugging.
     * @dev maps all transaction data routed through the smart contract.
     */
    mapping(uint256 => StateData) public txHistory;

    /**
     * @notice bridge id is mapped to its execution address.
     * @dev maps all the bridges to their address.
     */
    mapping(uint8 => address) public bridgeAddress;

    /* ================ Events =================== */

    event Initiated(uint256 txId, address fromToken, uint256 fromAmount);
    event Completed(uint256 txId);

    event SetBridgeAddress(uint256 bridgeId, address bridgeAddress);

    /* ================ Constructor =================== */

    /**
     * @notice deploy stateHandler and SuperDestination before SuperRouter
     *
     * @param chainId_              Layerzero chain id
     * @param baseUri_              URL for external metadata of ERC1155 SuperPositions
     * @param stateHandler_         State handler address deployed
     * @param srcSuperDestination_  Destination address deployed on same chain
     */
    constructor(
        uint16 chainId_,
        string memory baseUri_,
        IStateHandler stateHandler_,
        IDestination srcSuperDestination_
    ) ERC1155(baseUri_) {
        srcSuperDestination = srcSuperDestination_;
        stateHandler = stateHandler_;
        chainId = chainId_;
    }

    /* ================ External Functions =================== */
    /**
     * @notice receive enables processing native token transfers into the smart contract.
     * @dev socket.tech fails without a native receive function.
     */
    receive() external payable {}

    /* ================ Write Functions =================== */

    /**
     * @dev allows users to mint vault tokens and receive vault positions in return.
     *
     * @param _liqData      represents the data required to move tokens from user wallet to destination contract.
     * @param _stateData    represents the state information including destination vault ids and amounts to be deposited to such vaults.
     *
     * ENG NOTE: Just use single type not arr and delegate to SuperFormRouter?
     */
    function deposit(
        LiqRequest[] calldata _liqData,
        StateReq[] calldata _stateData
    ) external payable {
        address srcSender = _msgSender();
        uint256 l1 = _liqData.length;
        uint256 l2 = _stateData.length;
        require(l1 == l2, "Router: Input Data Length Mismatch"); ///@dev ENG NOTE: but we may want to split single token deposit to multiple vaults on dst! this block it
        if (l1 > 1) {
            for (uint256 i = 0; i < l1; ++i) {
                singleDeposit(_liqData[i], _stateData[i], srcSender);
            }
        } else {
            singleDeposit(_liqData[0], _stateData[0], srcSender);
        }
    }

    /**
     * @dev burns users superpositions and dispatch a withdrawal request to the destination chain.
      
     * @param _stateReq       represents the state data required for withdrawal of funds from the vaults.
     * @param _liqReq         represents the bridge data for underlying to be moved from destination chain.

     * @dev API NOTE: This function can be called by anybody
     * @dev ENG NOTE: Amounts is abstracted. 1:1 of positions on DESTINATION, but user can't query ie. previewWithdraw() cross-chain
     */
    function withdraw(
        StateReq[] calldata _stateReq,
        LiqRequest[] calldata _liqReq /// @dev Allow [] because user can request multiple tokens (as long as bridge has them - Needs check!)
    ) external payable {
        address sender = _msgSender();
        uint256 l1 = _stateReq.length;
        uint256 l2 = _liqReq.length;

        require(l1 == l2, "Router: Invalid Input Length");
        if (l1 > 1) {
            for (uint256 i = 0; i < l1; ++i) {
                singleWithdrawal(_liqReq[i], _stateReq[i], sender);
            }
        } else {
            singleWithdrawal(_liqReq[0], _stateReq[0], sender);
        }
    }

    /**
     * PREVILAGED admin ONLY FUNCTION.
     * @dev allows admin to set the bridge address for an bridge id.
     * @param _bridgeId         represents the bridge unqiue identifier.
     * @param _bridgeAddress    represents the bridge address.
     */
    function setBridgeAddress(
        uint8[] memory _bridgeId,
        address[] memory _bridgeAddress
    ) external onlyOwner {
        for (uint256 i = 0; i < _bridgeId.length; i++) {
            address x = _bridgeAddress[i];
            uint8 y = _bridgeId[i];
            require(x != address(0), "Router: Zero Bridge Address");

            bridgeAddress[y] = x;
            emit SetBridgeAddress(y, x);
        }
    }

    /* ================ Development Only Functions =================== */

    /**
     * PREVILAGED admin ONLY FUNCTION.
     * @notice should be removed after end-to-end testing.
     * @dev allows admin to withdraw lost tokens in the smart contract.
     */
    function withdrawToken(address _tokenContract, uint256 _amount)
        external
        onlyOwner
    {
        IERC20 tokenContract = IERC20(_tokenContract);

        // transfer the token from address of this contract
        // to address of the user (executing the withdrawToken() function)
        tokenContract.safeTransfer(owner(), _amount);
    }

    /**
     * PREVILAGED admin ONLY FUNCTION.
     * @dev allows admin to withdraw lost native tokens in the smart contract.
     */
    function withdrawNativeToken(uint256 _amount) external onlyOwner {
        payable(owner()).transfer(_amount);
    }

    /**
     * ANYONE CAN CALL THE FUNCTION.
     *
     * @dev processes state channel messages from destination chain post successful deposit to a vault.
     * @param _payload  represents internal transactionId associated with every deposit/withdrawal transaction.
     */
    function stateSync(bytes memory _payload) external payable {
        require(msg.sender == address(stateHandler), "Router: Request Denied");

        StateData memory data = abi.decode(_payload, (StateData));
        require(data.flag == CallbackType.RETURN, "Router: Invalid Payload");

        ReturnData memory returnData = abi.decode(data.params, (ReturnData));

        StateData memory stored = txHistory[returnData.txId];
        InitData memory initData = abi.decode(stored.params, (InitData));

        require(returnData.srcChainId == initData.srcChainId, "Router: Source Chain Ids Mismatch");
        require(returnData.dstChainId == initData.dstChainId, "Router: Dst Chain Ids Mismatch");

        if (data.txType == TransactionType.DEPOSIT) {
            require(returnData.status, "Router: Invalid Payload Status");
            _mintBatch(
                initData.user,
                initData.vaultIds,
                returnData.amounts,
                ""
            );
        } else {
            require(!returnData.status, "Router: Invalid Payload Status");
            _mintBatch(
                initData.user,
                initData.vaultIds,
                returnData.amounts,
                ""
            );
        }

        emit Completed(returnData.txId);
    }

    /**
     * Function to support Metadata hosting in Opensea.
     */
    function tokenURI(uint256 id) public view returns (string memory) {
        return string(abi.encodePacked(dynamicURI, Strings.toString(id), ".json"));
    }

    /* ================ Internal Functions =================== */

    /**
     * @notice validates input and call state handler & liquidity handler to move
     * tokens and state messages to the destination chain.
     */
    function singleDeposit(
        LiqRequest calldata _liqData,
        StateReq calldata _stateData,
        address srcSender
    ) internal {
        totalTransactions++;
        uint16 dstChainId = _stateData.dstChainId;

        require(
            validateSlippage(_stateData.maxSlippage),
            "Super Router: Invalid Slippage"
        );

        InitData memory initData = InitData(
            chainId,
            dstChainId,
            srcSender,
            _stateData.vaultIds,
            _stateData.amounts,
            _stateData.maxSlippage,
            totalTransactions,
            bytes("")
        );

        StateData memory info = StateData(
            TransactionType.DEPOSIT,
            CallbackType.INIT,
            abi.encode(initData)
        );

        txHistory[totalTransactions] = info;

        if (chainId == dstChainId) {
            dstDeposit(_liqData, _stateData, srcSender, totalTransactions);
        } else {
            dispatchTokens(
                bridgeAddress[_liqData.bridgeId],
                _liqData.txData,
                _liqData.token,
                _liqData.allowanceTarget,
                _liqData.amount,
                srcSender,
                _liqData.nativeAmount
            );

            /// @dev LayerZero endpoint
            stateHandler.dispatchState{value: _stateData.msgValue}(
                dstChainId,
                abi.encode(info),
                _stateData.adapterParam
            );
        }

        emit Initiated(totalTransactions, _liqData.token, _liqData.amount);
    }

    /**
     * @notice validates input and initiates withdrawal process
     */
    function singleWithdrawal(
        LiqRequest calldata _liqData,
        StateReq calldata _stateData,
        address sender
    ) internal {
        uint16 dstChainId = _stateData.dstChainId;

        require(dstChainId != 0, "Router: Invalid Destination Chain");
        _burnBatch(sender, _stateData.vaultIds, _stateData.amounts);

        totalTransactions++;

        InitData memory initData = InitData(
            chainId,
            _stateData.dstChainId,
            sender,
            _stateData.vaultIds,
            _stateData.amounts,
            _stateData.maxSlippage,
            totalTransactions,
            abi.encode(_liqData)
        );

        StateData memory info = StateData(
            TransactionType.WITHDRAW,
            CallbackType.INIT,
            abi.encode(initData)
        );

        txHistory[totalTransactions] = info;

        LiqRequest memory data = _liqData;

        if (chainId == dstChainId) {
            /// @dev srcSuperDestination can only transfer tokens back to this SuperRouter
            /// @dev to allow bridging somewhere else requires arch change
            srcSuperDestination.directWithdraw{value: msg.value}(
                sender,
                _stateData.vaultIds,
                _stateData.amounts,
                data
            );

            emit Completed(totalTransactions);
        } else {
            /// @dev _liqReq should have path encoded for withdraw to SuperRouter on chain different than chainId
            /// @dev construct txData in this fashion: from FTM SOURCE send message to BSC DESTINATION
            /// @dev so that BSC DISPATCHTOKENS sends tokens to AVAX receiver (EOA/contract/user-specified)
            /// @dev sync could be a problem, how long Socket path stays vaild vs. how fast we bridge/receive on Dst
            stateHandler.dispatchState{value: _stateData.msgValue}(
                dstChainId,
                abi.encode(info),
                _stateData.adapterParam
            );
        }

        emit Initiated(totalTransactions, _liqData.token, _liqData.amount);
    }

    /**
     * @notice deposit() to vaults existing on the same chain as SuperRouter
     * @dev Optimistic transfer & call
     */
    function dstDeposit(
        LiqRequest calldata _liqData,
        StateReq calldata _stateData,
        address srcSender,
        uint256 txId
    ) internal {
        /// @dev deposits collateral to a given vault and mint vault positions.
        uint256[] memory dstAmounts = srcSuperDestination.directDeposit{
            value: msg.value
        }(srcSender, _liqData, _stateData.vaultIds, _stateData.amounts);

        /// @dev TEST-CASE: _msgSender() to whom we mint. use passed `admin` arg?
        _mintBatch(srcSender, _stateData.vaultIds, dstAmounts, "");
        emit Completed(txId);
    }

    /**
     * @dev validates slippage parameter;
     * slippages should always be within 0 - 100
     * decimal is handles in the form of 10s
     * for eg. 0.05 = 5
     *         100 = 10000
     */
    function validateSlippage(uint256[] calldata slippages)
        internal
        pure
        returns (bool)
    {
        for (uint256 i = 0; i < slippages.length; i++) {
            if (slippages[i] < 0 || slippages[i] > 10000) {
                return false;
            }
        }
        return true;
    }

    function addValues(uint256[] calldata amounts)
        internal
        pure
        returns (uint256)
    {
        uint256 total;
        for (uint256 i = 0; i < amounts.length; i++) {
            total += amounts[i];
        }
        return total;
    }
}

File 2 of 20 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 20 : ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

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

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: address zero is not a valid owner");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `ids` and `amounts` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}

File 4 of 20 : IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURI is IERC1155 {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

File 5 of 20 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 6 of 20 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 7 of 20 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 9 of 20 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    function safeIncreaseAllowance(
        IERC20 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(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

File 10 of 20 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

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

File 11 of 20 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 12 of 20 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.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 ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

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

pragma solidity ^0.8.0;

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

File 14 of 20 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 15 of 20 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

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

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

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

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

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

File 16 of 20 : IDestination.sol
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.14;

import {LiqRequest} from "../types/socketTypes.sol";

interface IDestination {
    function directDeposit(
        address srcSender,
        LiqRequest memory liqData,
        uint256[] memory vaultIds,
        uint256[] memory amounts
    ) external payable returns (uint256[] memory dstAmounts);

    function directWithdraw(
        address srcSender,
        uint256[] memory vaultIds,
        uint256[] memory amounts,
        LiqRequest memory _liqData
    ) external payable;

    function stateSync(bytes memory _payload) external payable;

    function safeGasParam() external view returns (bytes memory);
}

File 17 of 20 : IStateHandler.sol
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.14;

interface IStateHandler {
    function dispatchState(
        uint16 dstChainId,
        bytes memory data,
        bytes memory adapterParam
    ) external payable;
}

File 18 of 20 : liquidityHandler.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.14;

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

/**
 * @title Liquidity Handler.
 * @author Zeropoint Labs.
 * @dev bridges tokens from Chain A -> Chain B
 */
abstract contract LiquidityHandler {
    /* ================ Write Functions =================== */

    /**
     * @dev dispatches tokens via the socket bridge.
     *
     * @param _txData           represents the api response data from socket api.
     * @param _to               represents the socket registry implementation address.
     * @param _allowanceTarget  represents the allowance target (zero address for native tokens)
     * @param _token            represents the ERC20 token to be transferred (zero address for native tokens)
     * @param _amount           represents the amount of tokens to be bridged.
     *
     * Note: refer https://docs.socket.tech/socket-api/v2/guides/socket-smart-contract-integration
     * Note: All the inputs are in array for processing multiple transactions.
     */
    function dispatchTokens(
        address _to,
        bytes memory _txData,
        address _token,
        address _allowanceTarget,
        uint256 _amount,
        address _owner,
        uint256 _nativeAmount
    ) internal virtual {
        /// @dev if allowance target is zero address represents non-native tokens.
        if (_allowanceTarget != address(0)) {
            if (_owner != address(this)) {
                require(
                    IERC20(_token).allowance(_owner, address(this)) >= _amount,
                    "Bridge Error: Insufficient approvals"
                );
                IERC20(_token).transferFrom(_owner, address(this), _amount);
            }
            IERC20(_token).approve(_allowanceTarget, _amount);
            unchecked {
                (bool success, ) = payable(_to).call{value: _nativeAmount}(
                    _txData
                );
                require(success, "Bridge Error: Failed To Execute Tx Data (1)");
            }
        } else {
            require(msg.value >= _amount, "Liq Handler: Insufficient Amount");
            unchecked {
                (bool success, ) = payable(_to).call{
                    value: _amount + _nativeAmount
                }(_txData);
                require(success, "Bridge Error: Failed To Execute Tx Data (2)");
            }
        }
    }
}

File 19 of 20 : lzTypes.sol
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.14;

/// @notice We should optimize those types more
enum TransactionType {
    DEPOSIT,
    WITHDRAW
}

enum CallbackType {
    INIT,
    RETURN
}

enum PayloadState {
    STORED,
    UPDATED,
    PROCESSED
}

struct StateReq {
    uint16 dstChainId;
    uint256[] amounts;
    uint256[] vaultIds;
    uint256[] maxSlippage;
    bytes adapterParam;
    uint256 msgValue;
}

/// Created during deposit by contract from Liq+StateReqs
/// @dev using this for communication between src & dst transfers
struct StateData {
    TransactionType txType;
    CallbackType flag;
    bytes params;
}

struct InitData {
    uint16 srcChainId;
    uint16 dstChainId;
    address user;
    uint256[] vaultIds;
    uint256[] amounts;
    uint256[] maxSlippage;
    uint256 txId;
    bytes liqData;
}

struct ReturnData {
    bool status;
    uint16 srcChainId;
    uint16 dstChainId;
    uint256 txId;
    uint256[] amounts;
}

File 20 of 20 : socketTypes.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.14;

struct LiqRequest {
    uint8 bridgeId;
    bytes txData;
    address token;
    address allowanceTarget; /// @dev should check with socket.
    uint256 amount;
    uint256 nativeAmount;
}

struct BridgeRequest {
    uint256 id;
    uint256 optionalNativeAmount;
    address inputToken;
    bytes data;
}

struct MiddlewareRequest {
    uint256 id;
    uint256 optionalNativeAmount;
    address inputToken;
    bytes data;
}

struct UserRequest {
    address receiverAddress;
    uint256 toChainId;
    uint256 amount;
    MiddlewareRequest middlewareRequest;
    BridgeRequest bridgeRequest;
}

struct LiqStruct {
    address inputToken;
    address bridge;
    UserRequest socketInfo;
}

//["0x092A9faFA20bdfa4b2EE721FE66Af64d94BB9FAF","1","3000000",["0","0","0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174","0x"],["7","0","0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174","0x00000000000000000000000076b22b8c1079a44f1211d867d68b1eda76a635a7000000000000000000000000000000000000000000000000000000000003db5400000000000000000000000000000000000000000000000000000000002a3a8f0000000000000000000000000000000000000000000000000000017fc2482f6800000000000000000000000000000000000000000000000000000000002a3a8f0000000000000000000000000000000000000000000000000000017fc2482f680000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174"]]

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint16","name":"chainId_","type":"uint16"},{"internalType":"string","name":"baseUri_","type":"string"},{"internalType":"contract IStateHandler","name":"stateHandler_","type":"address"},{"internalType":"contract IDestination","name":"srcSuperDestination_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"txId","type":"uint256"}],"name":"Completed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"txId","type":"uint256"},{"indexed":false,"internalType":"address","name":"fromToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromAmount","type":"uint256"}],"name":"Initiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"bridgeId","type":"uint256"},{"indexed":false,"internalType":"address","name":"bridgeAddress","type":"address"}],"name":"SetBridgeAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"bridgeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"allowanceTarget","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest[]","name":"_liqData","type":"tuple[]"},{"components":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"vaultIds","type":"uint256[]"},{"internalType":"uint256[]","name":"maxSlippage","type":"uint256[]"},{"internalType":"bytes","name":"adapterParam","type":"bytes"},{"internalType":"uint256","name":"msgValue","type":"uint256"}],"internalType":"struct StateReq[]","name":"_stateData","type":"tuple[]"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"dynamicURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8[]","name":"_bridgeId","type":"uint8[]"},{"internalType":"address[]","name":"_bridgeAddress","type":"address[]"}],"name":"setBridgeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"srcSuperDestination","outputs":[{"internalType":"contract IDestination","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stateHandler","outputs":[{"internalType":"contract IStateHandler","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"stateSync","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTransactions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"txHistory","outputs":[{"internalType":"enum TransactionType","name":"txType","type":"uint8"},{"internalType":"enum CallbackType","name":"flag","type":"uint8"},{"internalType":"bytes","name":"params","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"vaultIds","type":"uint256[]"},{"internalType":"uint256[]","name":"maxSlippage","type":"uint256[]"},{"internalType":"bytes","name":"adapterParam","type":"bytes"},{"internalType":"uint256","name":"msgValue","type":"uint256"}],"internalType":"struct StateReq[]","name":"_stateReq","type":"tuple[]"},{"components":[{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"allowanceTarget","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest[]","name":"_liqReq","type":"tuple[]"}],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawNativeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenContract","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e0604052600e60a08190526d5375706572506f736974696f6e7360901b60c090815262000031916004919062000182565b5060408051808201909152600280825261053560f41b60209092019182526200005d9160059162000182565b50604051806060016040528060288152602001620048e66028913980516200008e9160069160209091019062000182565b503480156200009c57600080fd5b506040516200490e3803806200490e833981016040819052620000bf916200025b565b82620000cb8162000117565b50620000d73362000130565b6001600160a01b039081166080526007805461ffff909516600160a01b026001600160b01b031990951692909116919091179290921790915550620003b7565b80516200012c90600290602084019062000182565b5050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b82805462000190906200037b565b90600052602060002090601f016020900481019282620001b45760008555620001ff565b82601f10620001cf57805160ff1916838001178555620001ff565b82800160010185558215620001ff579182015b82811115620001ff578251825591602001919060010190620001e2565b506200020d92915062000211565b5090565b5b808211156200020d576000815560010162000212565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200025657600080fd5b919050565b600080600080608085870312156200027257600080fd5b845161ffff811681146200028557600080fd5b602086810151919550906001600160401b0380821115620002a557600080fd5b818801915088601f830112620002ba57600080fd5b815181811115620002cf57620002cf62000228565b604051601f8201601f19908116603f01168101908382118183101715620002fa57620002fa62000228565b816040528281528b868487010111156200031357600080fd5b600093505b8284101562000337578484018601518185018701529285019262000318565b82841115620003495760008684830101525b80985050505050505062000360604086016200023e565b915062000370606086016200023e565b905092959194509250565b600181811c908216806200039057607f821691505b602082108103620003b157634e487b7160e01b600052602260045260246000fd5b50919050565b608051614505620003e1600039600081816102c101528181611d6401526123ea01526145056000f3fe60806040526004361061016f5760003560e01c8063715018a6116100cc5780639e281a981161007a5780639e281a981461044b578063a22cb4651461046b578063b9a600381461048b578063c87b56dd146104a1578063e985e9c5146104c1578063f242432a1461050a578063f2fde38b1461052a57600080fd5b8063715018a61461035657806375fcbd861461036b5780638aa7f7b61461039a5780638da5cb5b146103ad57806395d89b41146103cb5780639a8a0592146103e05780639b336e631461041557600080fd5b8063137bc42711610129578063137bc4271461027a57806317e0f2521461028f578063270e5b47146102af5780632eb2c2d6146102e3578063428309c5146103035780634e1273f4146103165780636466cd231461034357600080fd5b8062fdd58e1461017b57806301ffc9a7146101ae57806306fdde03146101de578063072de64e146102005780630d2fdccf146102225780630e89341c1461025a57600080fd5b3661017657005b600080fd5b34801561018757600080fd5b5061019b610196366004612f9d565b61054a565b6040519081526020015b60405180910390f35b3480156101ba57600080fd5b506101ce6101c9366004612fdf565b6105e3565b60405190151581526020016101a5565b3480156101ea57600080fd5b506101f3610633565b6040516101a5919061305b565b34801561020c57600080fd5b5061022061021b3660046131ac565b6106c1565b005b34801561022e57600080fd5b50600754610242906001600160a01b031681565b6040516001600160a01b0390911681526020016101a5565b34801561026657600080fd5b506101f3610275366004613276565b6107f3565b34801561028657600080fd5b506101f3610887565b34801561029b57600080fd5b506102206102aa366004613276565b610894565b3480156102bb57600080fd5b506102427f000000000000000000000000000000000000000000000000000000000000000081565b3480156102ef57600080fd5b506102206102fe366004613378565b6108da565b610220610311366004613470565b610926565b34801561032257600080fd5b506103366103313660046134db565b610a5a565b6040516101a5919061356f565b610220610351366004613582565b610b83565b34801561036257600080fd5b50610220610f3e565b34801561037757600080fd5b5061038b610386366004613276565b610f52565b6040516101a5939291906135ea565b6102206103a8366004613470565b611004565b3480156103b957600080fd5b506003546001600160a01b0316610242565b3480156103d757600080fd5b506101f361111e565b3480156103ec57600080fd5b5060075461040290600160a01b900461ffff1681565b60405161ffff90911681526020016101a5565b34801561042157600080fd5b50610242610430366004613624565b600a602052600090815260409020546001600160a01b031681565b34801561045757600080fd5b50610220610466366004612f9d565b61112b565b34801561047757600080fd5b5061022061048636600461364d565b61115a565b34801561049757600080fd5b5061019b60085481565b3480156104ad57600080fd5b506101f36104bc366004613276565b611165565b3480156104cd57600080fd5b506101ce6104dc366004613686565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b34801561051657600080fd5b506102206105253660046136b4565b611199565b34801561053657600080fd5b5061022061054536600461371c565b6111de565b60006001600160a01b0383166105ba5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061061457506001600160e01b031982166303a24d0760e21b145b806105dd57506301ffc9a760e01b6001600160e01b03198316146105dd565b6004805461064090613739565b80601f016020809104026020016040519081016040528092919081815260200182805461066c90613739565b80156106b95780601f1061068e576101008083540402835291602001916106b9565b820191906000526020600020905b81548152906001019060200180831161069c57829003601f168201915b505050505081565b6106c9611257565b60005b82518110156107ee5760008282815181106106e9576106e9613773565b60200260200101519050600084838151811061070757610707613773565b6020026020010151905060006001600160a01b0316826001600160a01b0316036107735760405162461bcd60e51b815260206004820152601b60248201527f526f757465723a205a65726f204272696467652041646472657373000000000060448201526064016105b1565b60ff81166000818152600a602090815260409182902080546001600160a01b0319166001600160a01b0387169081179091558251938452908301527f8585498d7de284d1c7ffe8331fd6f87a683875b6a4a7ef48cba0a3582a055429910160405180910390a1505080806107e69061379f565b9150506106cc565b505050565b60606002805461080290613739565b80601f016020809104026020016040519081016040528092919081815260200182805461082e90613739565b801561087b5780601f106108505761010080835404028352916020019161087b565b820191906000526020600020905b81548152906001019060200180831161085e57829003601f168201915b50505050509050919050565b6006805461064090613739565b61089c611257565b6003546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156108d6573d6000803e3d6000fd5b5050565b6001600160a01b0385163314806108f657506108f685336104dc565b6109125760405162461bcd60e51b81526004016105b1906137b8565b61091f85858585856112b1565b5050505050565b3383828082146109835760405162461bcd60e51b815260206004820152602260248201527f526f757465723a20496e7075742044617461204c656e677468204d69736d61746044820152610c6d60f31b60648201526084016105b1565b60018211156109fe5760005b828110156109f8576109e88888838181106109ac576109ac613773565b90506020028101906109be9190613806565b8787848181106109d0576109d0613773565b90506020028101906109e29190613806565b8661143b565b6109f18161379f565b905061098f565b50610a51565b610a5187876000818110610a1457610a14613773565b9050602002810190610a269190613806565b86866000818110610a3957610a39613773565b9050602002810190610a4b9190613806565b8561143b565b50505050505050565b60608151835114610abf5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016105b1565b600083516001600160401b03811115610ada57610ada61306e565b604051908082528060200260200182016040528015610b03578160200160208202803683370190505b50905060005b8451811015610b7b57610b4e858281518110610b2757610b27613773565b6020026020010151858381518110610b4157610b41613773565b602002602001015161054a565b828281518110610b6057610b60613773565b6020908102919091010152610b748161379f565b9050610b09565b509392505050565b6007546001600160a01b03163314610bd65760405162461bcd60e51b8152602060048201526016602482015275149bdd5d195c8e8814995c5d595cdd0811195b9a595960521b60448201526064016105b1565b600081806020019051810190610bec9190613882565b9050600181602001516001811115610c0657610c066135b6565b14610c4d5760405162461bcd60e51b8152602060048201526017602482015276149bdd5d195c8e88125b9d985b1a590814185e5b1bd859604a1b60448201526064016105b1565b60008160400151806020019051810190610c6791906139ab565b606080820151600090815260096020526040808220815193840190915280549394509092829060ff166001811115610ca157610ca16135b6565b6001811115610cb257610cb26135b6565b81528154602090910190610100900460ff166001811115610cd557610cd56135b6565b6001811115610ce657610ce66135b6565b8152602001600182018054610cfa90613739565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2690613739565b8015610d735780601f10610d4857610100808354040283529160200191610d73565b820191906000526020600020905b815481529060010190602001808311610d5657829003601f168201915b505050505081525050905060008160400151806020019051810190610d989190613a69565b9050806000015161ffff16836020015161ffff1614610e035760405162461bcd60e51b815260206004820152602160248201527f526f757465723a20536f7572636520436861696e20496473204d69736d6174636044820152600d60fb1b60648201526084016105b1565b806020015161ffff16836040015161ffff1614610e625760405162461bcd60e51b815260206004820152601e60248201527f526f757465723a2044737420436861696e20496473204d69736d61746368000060448201526064016105b1565b600084516001811115610e7757610e776135b6565b03610ec6578251610e9a5760405162461bcd60e51b81526004016105b190613b7f565b610ec18160400151826060015185608001516040518060200160405280600081525061185f565b610f0c565b825115610ee55760405162461bcd60e51b81526004016105b190613b7f565b610f0c8160400151826060015185608001516040518060200160405280600081525061185f565b6000805160206144b08339815191528360600151604051610f2f91815260200190565b60405180910390a15050505050565b610f46611257565b610f5060006119d2565b565b6009602052600090815260409020805460018201805460ff8084169461010090940416929190610f8190613739565b80601f0160208091040260200160405190810160405280929190818152602001828054610fad90613739565b8015610ffa5780601f10610fcf57610100808354040283529160200191610ffa565b820191906000526020600020905b815481529060010190602001808311610fdd57829003601f168201915b5050505050905083565b3383828082146110565760405162461bcd60e51b815260206004820152601c60248201527f526f757465723a20496e76616c696420496e707574204c656e6774680000000060448201526064016105b1565b60018211156110cb5760005b828110156109f8576110bb86868381811061107f5761107f613773565b90506020028101906110919190613806565b8989848181106110a3576110a3613773565b90506020028101906110b59190613806565b86611a24565b6110c48161379f565b9050611062565b610a51858560008181106110e1576110e1613773565b90506020028101906110f39190613806565b8888600081811061110657611106613773565b90506020028101906111189190613806565b85611a24565b6005805461064090613739565b611133611257565b816107ee6111496003546001600160a01b031690565b6001600160a01b0383169084611f1e565b6108d6338383611f70565b6060600661117283612050565b604051602001611183929190613bd2565b6040516020818303038152906040529050919050565b6001600160a01b0385163314806111b557506111b585336104dc565b6111d15760405162461bcd60e51b81526004016105b1906137b8565b61091f85858585856120e2565b6111e6611257565b6001600160a01b03811661124b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105b1565b611254816119d2565b50565b6003546001600160a01b03163314610f505760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105b1565b81518351146112d25760405162461bcd60e51b81526004016105b190613c83565b6001600160a01b0384166112f85760405162461bcd60e51b81526004016105b190613ccb565b3360005b84518110156113df57600085828151811061131957611319613773565b60200260200101519050600085838151811061133757611337613773565b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156113875760405162461bcd60e51b81526004016105b190613d10565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906113c4908490613d5a565b92505081905550505050806113d89061379f565b90506112fc565b50846001600160a01b0316866001600160a01b0316826001600160a01b0316600080516020614490833981519152878760405161141d929190613d72565b60405180910390a461143381878787878761220c565b505050505050565b6008805490600061144b8361379f565b90915550600090506114606020840184613d97565b90506114776114726060850185613db4565b612367565b6114c35760405162461bcd60e51b815260206004820152601e60248201527f537570657220526f757465723a20496e76616c696420536c697070616765000060448201526064016105b1565b604080516101008101825260075461ffff600160a01b90910481168252831660208201526001600160a01b03841681830152600091606082019061150990870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060209081019061154f90870187613db4565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016115936060870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509385525050600854602080850191909152604080519182018152838252938401525081516060810190925291925080828152602001600081526020018360405160200161160d9190613dfd565b60408051601f1981840301815291815291526008546000908152600960205220815181549293508392829060ff19166001838181111561164f5761164f6135b6565b021790555060208201518154829061ff001916610100836001811115611677576116776135b6565b021790555060408201518051611697916001840191602090910190612edf565b505060075461ffff808616600160a01b909204160390506116c5576116c08686866008546123de565b611806565b611769600a60006116d960208a018a613624565b60ff168152602080820192909252604001600020546001600160a01b03169061170490890189613ec7565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506117499250505060608a0160408b0161371c565b61175960808b0160608c0161371c565b8a60800135898c60a0013561250c565b6007546040516001600160a01b03909116906337e6ca029060a0880135908690611797908690602001613f0d565b60408051601f198184030181529190526117b460808b018b613ec7565b6040518663ffffffff1660e01b81526004016117d39493929190613f7b565b6000604051808303818588803b1580156117ec57600080fd5b505af1158015611800573d6000803e3d6000fd5b50505050505b6008547f25846f405be949794fa0c74fa95c4ccb6fc8aa1fc6d058d24b9e1f6e3fe767679061183b6060890160408a0161371c565b886080013560405161184f93929190613fab565b60405180910390a1505050505050565b6001600160a01b0384166118bf5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016105b1565b81518351146118e05760405162461bcd60e51b81526004016105b190613c83565b3360005b845181101561197c578381815181106118ff576118ff613773565b602002602001015160008087848151811061191c5761191c613773565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546119649190613d5a565b909155508190506119748161379f565b9150506118e4565b50846001600160a01b031660006001600160a01b0316826001600160a01b031660008051602061449083398151915287876040516119bb929190613d72565b60405180910390a461091f8160008787878761220c565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000611a336020840184613d97565b90508061ffff16600003611a935760405162461bcd60e51b815260206004820152602160248201527f526f757465723a20496e76616c69642044657374696e6174696f6e20436861696044820152603760f91b60648201526084016105b1565b611b1a82611aa46040860186613db4565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611ae3925050506020870187613db4565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506128c792505050565b60088054906000611b2a8361379f565b9091555050604080516101008101909152600754600160a01b900461ffff168152600090602080820190611b6090870187613d97565b61ffff168152602001846001600160a01b03168152602001858060400190611b889190613db4565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602090810190611bce90870187613db4565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602001611c126060870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060085460208083019190915260408051920191611c6591899101614084565b60408051601f19818403018152918152915280516060810190915290915060009080600181526020016000815260200183604051602001611ca69190613dfd565b60408051601f1981840301815291815291526008546000908152600960205220815181549293508392829060ff191660018381811115611ce857611ce86135b6565b021790555060208201518154829061ff001916610100836001811115611d1057611d106135b6565b021790555060408201518051611d30916001840191602090910190612edf565b50905050600086611d4090614097565b60075490915061ffff808616600160a01b9092041603611e27576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663186de5fd3487611d9860408b018b613db4565b611da560208d018d613db4565b886040518863ffffffff1660e01b8152600401611dc796959493929190614179565b6000604051808303818588803b158015611de057600080fd5b505af1158015611df4573d6000803e3d6000fd5b50505050506000805160206144b0833981519152600854604051611e1a91815260200190565b60405180910390a1611ec4565b6007546040516001600160a01b03909116906337e6ca029060a0890135908790611e55908790602001613f0d565b60408051601f19818403018152919052611e7260808c018c613ec7565b6040518663ffffffff1660e01b8152600401611e919493929190613f7b565b6000604051808303818588803b158015611eaa57600080fd5b505af1158015611ebe573d6000803e3d6000fd5b50505050505b6008547f25846f405be949794fa0c74fa95c4ccb6fc8aa1fc6d058d24b9e1f6e3fe7676790611ef960608a0160408b0161371c565b8960800135604051611f0d93929190613fab565b60405180910390a150505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526107ee908490612ab9565b816001600160a01b0316836001600160a01b031603611fe35760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016105b1565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6060600061205d83612b8b565b60010190506000816001600160401b0381111561207c5761207c61306e565b6040519080825280601f01601f1916602001820160405280156120a6576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846120b057509392505050565b6001600160a01b0384166121085760405162461bcd60e51b81526004016105b190613ccb565b33600061211485612c63565b9050600061212185612c63565b90506000868152602081815260408083206001600160a01b038c168452909152902054858110156121645760405162461bcd60e51b81526004016105b190613d10565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a168252812080548892906121a1908490613d5a565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4612201848a8a8a8a8a612cae565b505050505050505050565b6001600160a01b0384163b156114335760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906122509089908990889088908890600401614218565b6020604051808303816000875af192505050801561228b575060408051601f3d908101601f1916820190925261228891810190614276565b60015b61233757612297614293565b806308c379a0036122d057506122ab6142af565b806122b657506122d2565b8060405162461bcd60e51b81526004016105b1919061305b565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016105b1565b6001600160e01b0319811663bc197c8160e01b14610a515760405162461bcd60e51b81526004016105b190614338565b6000805b828110156123d457600084848381811061238757612387613773565b9050602002013510806123b357506127108484838181106123aa576123aa613773565b90506020020135115b156123c25760009150506105dd565b806123cc8161379f565b91505061236b565b5060019392505050565b60006001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166322927b7834858861241f60408a018a613db4565b61242c60208c018c613db4565b6040518863ffffffff1660e01b815260040161244d96959493929190614380565b60006040518083038185885af115801561246b573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261249491908101906143d9565b90506124ee836124a76040870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052506040805160208101909152908152879350915061185f9050565b6040518281526000805160206144b083398151915290602001610f2f565b6001600160a01b038416156127a9576001600160a01b038216301461267357604051636eb1769f60e11b81526001600160a01b03838116600483015230602483015284919087169063dd62ed3e90604401602060405180830381865afa15801561257a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259e919061440d565b10156125f85760405162461bcd60e51b8152602060048201526024808201527f427269646765204572726f723a20496e73756666696369656e7420617070726f60448201526376616c7360e01b60648201526084016105b1565b6040516323b872dd60e01b81526001600160a01b038381166004830152306024830152604482018590528616906323b872dd906064016020604051808303816000875af115801561264d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126719190614426565b505b60405163095ea7b360e01b81526001600160a01b0385811660048301526024820185905286169063095ea7b3906044016020604051808303816000875af11580156126c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e69190614426565b506000876001600160a01b031682886040516127029190614443565b60006040518083038185875af1925050503d806000811461273f576040519150601f19603f3d011682016040523d82523d6000602084013e612744565b606091505b50509050806109f85760405162461bcd60e51b815260206004820152602b60248201527f427269646765204572726f723a204661696c656420546f20457865637574652060448201526a547820446174612028312960a81b60648201526084016105b1565b823410156127f95760405162461bcd60e51b815260206004820181905260248201527f4c69712048616e646c65723a20496e73756666696369656e7420416d6f756e7460448201526064016105b1565b6000876001600160a01b0316828501886040516128169190614443565b60006040518083038185875af1925050503d8060008114612853576040519150601f19603f3d011682016040523d82523d6000602084013e612858565b606091505b50509050806128bd5760405162461bcd60e51b815260206004820152602b60248201527f427269646765204572726f723a204661696c656420546f20457865637574652060448201526a547820446174612028322960a81b60648201526084016105b1565b5050505050505050565b6001600160a01b0383166129295760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b60648201526084016105b1565b805182511461294a5760405162461bcd60e51b81526004016105b190613c83565b604080516020810190915260009081905233905b8351811015612a5c57600084828151811061297b5761297b613773565b60200260200101519050600084838151811061299957612999613773565b602090810291909101810151600084815280835260408082206001600160a01b038c168352909352919091205490915081811015612a255760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b60648201526084016105b1565b6000928352602083815260408085206001600160a01b038b1686529091529092209103905580612a548161379f565b91505061295e565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03166000805160206144908339815191528686604051612a9b929190613d72565b60405180910390a46040805160208101909152600090525b50505050565b6000612b0e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d699092919063ffffffff16565b8051909150156107ee5780806020019051810190612b2c9190614426565b6107ee5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105b1565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310612bca5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310612bf6576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310612c1457662386f26fc10000830492506010015b6305f5e1008310612c2c576305f5e100830492506008015b6127108310612c4057612710830492506004015b60648310612c52576064830492506002015b600a83106105dd5760010192915050565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612c9d57612c9d613773565b602090810291909101015292915050565b6001600160a01b0384163b156114335760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190612cf29089908990889088908890600401614455565b6020604051808303816000875af1925050508015612d2d575060408051601f3d908101601f19168201909252612d2a91810190614276565b60015b612d3957612297614293565b6001600160e01b0319811663f23a6e6160e01b14610a515760405162461bcd60e51b81526004016105b190614338565b6060612d788484600085612d80565b949350505050565b606082471015612de15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105b1565b600080866001600160a01b03168587604051612dfd9190614443565b60006040518083038185875af1925050503d8060008114612e3a576040519150601f19603f3d011682016040523d82523d6000602084013e612e3f565b606091505b5091509150612e5087838387612e5b565b979650505050505050565b60608315612eca578251600003612ec3576001600160a01b0385163b612ec35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105b1565b5081612d78565b612d7883838151156122b65781518083602001fd5b828054612eeb90613739565b90600052602060002090601f016020900481019282612f0d5760008555612f53565b82601f10612f2657805160ff1916838001178555612f53565b82800160010185558215612f53579182015b82811115612f53578251825591602001919060010190612f38565b50612f5f929150612f63565b5090565b5b80821115612f5f5760008155600101612f64565b6001600160a01b038116811461125457600080fd5b8035612f9881612f78565b919050565b60008060408385031215612fb057600080fd5b8235612fbb81612f78565b946020939093013593505050565b6001600160e01b03198116811461125457600080fd5b600060208284031215612ff157600080fd5b8135612ffc81612fc9565b9392505050565b60005b8381101561301e578181015183820152602001613006565b83811115612ab35750506000910152565b60008151808452613047816020860160208601613003565b601f01601f19169290920160200192915050565b602081526000612ffc602083018461302f565b634e487b7160e01b600052604160045260246000fd5b60a081018181106001600160401b03821117156130a3576130a361306e565b60405250565b601f8201601f191681016001600160401b03811182821017156130ce576130ce61306e565b6040525050565b60405161010081016001600160401b03811182821017156130f8576130f861306e565b60405290565b60006001600160401b038211156131175761311761306e565b5060051b60200190565b803560ff81168114612f9857600080fd5b600082601f83011261314357600080fd5b81356020613150826130fe565b60405161315d82826130a9565b83815260059390931b850182019282810191508684111561317d57600080fd5b8286015b848110156131a157803561319481612f78565b8352918301918301613181565b509695505050505050565b600080604083850312156131bf57600080fd5b82356001600160401b03808211156131d657600080fd5b818501915085601f8301126131ea57600080fd5b813560206131f7826130fe565b60405161320482826130a9565b83815260059390931b850182019282810191508984111561322457600080fd5b948201945b838610156132495761323a86613121565b82529482019490820190613229565b9650508601359250508082111561325f57600080fd5b5061326c85828601613132565b9150509250929050565b60006020828403121561328857600080fd5b5035919050565b600082601f8301126132a057600080fd5b813560206132ad826130fe565b6040516132ba82826130a9565b83815260059390931b85018201928281019150868411156132da57600080fd5b8286015b848110156131a157803583529183019183016132de565b60006001600160401b0382111561330e5761330e61306e565b50601f01601f191660200190565b600082601f83011261332d57600080fd5b8135613338816132f5565b60405161334582826130a9565b82815285602084870101111561335a57600080fd5b82602086016020830137600092810160200192909252509392505050565b600080600080600060a0868803121561339057600080fd5b853561339b81612f78565b945060208601356133ab81612f78565b935060408601356001600160401b03808211156133c757600080fd5b6133d389838a0161328f565b945060608801359150808211156133e957600080fd5b6133f589838a0161328f565b9350608088013591508082111561340b57600080fd5b506134188882890161331c565b9150509295509295909350565b60008083601f84011261343757600080fd5b5081356001600160401b0381111561344e57600080fd5b6020830191508360208260051b850101111561346957600080fd5b9250929050565b6000806000806040858703121561348657600080fd5b84356001600160401b038082111561349d57600080fd5b6134a988838901613425565b909650945060208701359150808211156134c257600080fd5b506134cf87828801613425565b95989497509550505050565b600080604083850312156134ee57600080fd5b82356001600160401b038082111561350557600080fd5b61351186838701613132565b9350602085013591508082111561352757600080fd5b5061326c8582860161328f565b600081518084526020808501945080840160005b8381101561356457815187529582019590820190600101613548565b509495945050505050565b602081526000612ffc6020830184613534565b60006020828403121561359457600080fd5b81356001600160401b038111156135aa57600080fd5b612d788482850161331c565b634e487b7160e01b600052602160045260246000fd5b6002811061125457634e487b7160e01b600052602160045260246000fd5b6135f3846135cc565b8381526135ff836135cc565b82602082015260606040820152600061361b606083018461302f565b95945050505050565b60006020828403121561363657600080fd5b612ffc82613121565b801515811461125457600080fd5b6000806040838503121561366057600080fd5b823561366b81612f78565b9150602083013561367b8161363f565b809150509250929050565b6000806040838503121561369957600080fd5b82356136a481612f78565b9150602083013561367b81612f78565b600080600080600060a086880312156136cc57600080fd5b85356136d781612f78565b945060208601356136e781612f78565b9350604086013592506060860135915060808601356001600160401b0381111561371057600080fd5b6134188882890161331c565b60006020828403121561372e57600080fd5b8135612ffc81612f78565b600181811c9082168061374d57607f821691505b60208210810361376d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016137b1576137b1613789565b5060010190565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b6000823560be1983360301811261381c57600080fd5b9190910192915050565b6002811061125457600080fd5b600082601f83011261384457600080fd5b815161384f816132f5565b60405161385c82826130a9565b82815285602084870101111561387157600080fd5b61361b836020830160208801613003565b60006020828403121561389457600080fd5b81516001600160401b03808211156138ab57600080fd5b90830190606082860312156138bf57600080fd5b6040516060810181811083821117156138da576138da61306e565b60405282516138e881613826565b815260208301516138f881613826565b602082015260408301518281111561390f57600080fd5b61391b87828601613833565b60408301525095945050505050565b61ffff8116811461125457600080fd5b8051612f988161392a565b600082601f83011261395657600080fd5b81516020613963826130fe565b60405161397082826130a9565b83815260059390931b850182019282810191508684111561399057600080fd5b8286015b848110156131a15780518352918301918301613994565b6000602082840312156139bd57600080fd5b81516001600160401b03808211156139d457600080fd5b9083019060a082860312156139e857600080fd5b6040516139f481613084565b82516139ff8161363f565b81526020830151613a0f8161392a565b60208201526040830151613a228161392a565b604082015260608381015190820152608083015182811115613a4357600080fd5b613a4f87828601613945565b60808301525095945050505050565b8051612f9881612f78565b600060208284031215613a7b57600080fd5b81516001600160401b0380821115613a9257600080fd5b908301906101008286031215613aa757600080fd5b613aaf6130d5565b613ab88361393a565b8152613ac66020840161393a565b6020820152613ad760408401613a5e565b6040820152606083015182811115613aee57600080fd5b613afa87828601613945565b606083015250608083015182811115613b1257600080fd5b613b1e87828601613945565b60808301525060a083015182811115613b3657600080fd5b613b4287828601613945565b60a08301525060c083015160c082015260e083015182811115613b6457600080fd5b613b7087828601613833565b60e08301525095945050505050565b6020808252601e908201527f526f757465723a20496e76616c6964205061796c6f6164205374617475730000604082015260600190565b60008151613bc8818560208601613003565b9290920192915050565b600080845481600182811c915080831680613bee57607f831692505b60208084108203613c0d57634e487b7160e01b86526022600452602486fd5b818015613c215760018114613c3257613c5f565b60ff19861689528489019650613c5f565b60008b81526020902060005b86811015613c575781548b820152908501908301613c3e565b505084890196505b50505050505061361b613c728286613bb6565b64173539b7b760d91b815260050190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60008219821115613d6d57613d6d613789565b500190565b604081526000613d856040830185613534565b828103602084015261361b8185613534565b600060208284031215613da957600080fd5b8135612ffc8161392a565b6000808335601e19843603018112613dcb57600080fd5b8301803591506001600160401b03821115613de557600080fd5b6020019150600581901b360382131561346957600080fd5b60208152613e1260208201835161ffff169052565b60006020830151613e29604084018261ffff169052565b5060408301516001600160a01b0381166060840152506060830151610100806080850152613e5b610120850183613534565b91506080850151601f19808685030160a0870152613e798483613534565b935060a08701519150808685030160c0870152613e968483613534565b935060c087015160e087015260e0870151915080868503018387015250613ebd838261302f565b9695505050505050565b6000808335601e19843603018112613ede57600080fd5b8301803591506001600160401b03821115613ef857600080fd5b60200191503681900382131561346957600080fd5b6020815260008251613f1e816135cc565b806020840152506020830151613f33816135cc565b806040840152506040830151606080840152612d78608084018261302f565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b61ffff85168152606060208201526000613f98606083018661302f565b8281036040840152612e50818587613f52565b9283526001600160a01b03919091166020830152604082015260600190565b60ff613fd582613121565b16825260006020820135601e19833603018112613ff157600080fd5b82016020810190356001600160401b0381111561400d57600080fd5b80360382131561401c57600080fd5b60c0602086015261403160c086018284613f52565b91505061404060408401612f8d565b6001600160a01b0316604085015261405a60608401612f8d565b6001600160a01b031660608501526080838101359085015260a09283013592909301919091525090565b602081526000612ffc6020830184613fca565b600060c082360312156140a957600080fd5b60405160c081016001600160401b0382821081831117156140cc576140cc61306e565b816040526140d985613121565b835260208501359150808211156140ef57600080fd5b506140fc3682860161331c565b602083015250604083013561411081612f78565b604082015261412160608401612f8d565b60608201526080830135608082015260a083013560a082015280915050919050565b81835260006001600160fb1b0383111561415c57600080fd5b8260051b8083602087013760009401602001938452509192915050565b600060018060a01b0380891683526080602084015261419c60808401888a614143565b83810360408501526141af818789614143565b9050838103606085015260ff8551168152602085015160c060208301526141d960c083018261302f565b90508260408701511660408301528260608701511660608301526080860151608083015260a086015160a0830152809350505050979650505050505050565b6001600160a01b0386811682528516602082015260a06040820181905260009061424490830186613534565b82810360608401526142568186613534565b9050828103608084015261426a818561302f565b98975050505050505050565b60006020828403121561428857600080fd5b8151612ffc81612fc9565b600060033d11156142ac5760046000803e5060005160e01c5b90565b600060443d10156142bd5790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156142ec57505050505090565b82850191508151818111156143045750505050505090565b843d870101602082850101111561431e5750505050505090565b61432d602082860101876130a9565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03871681526080602082018190526000906143a490830188613fca565b82810360408401526143b7818789614143565b905082810360608401526143cc818587614143565b9998505050505050505050565b6000602082840312156143eb57600080fd5b81516001600160401b0381111561440157600080fd5b612d7884828501613945565b60006020828403121561441f57600080fd5b5051919050565b60006020828403121561443857600080fd5b8151612ffc8161363f565b6000825161381c818460208701613003565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612e509083018461302f56fe4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fbdfd517ed69f8a0a57d49fe494e4864fac3cfe3585c14c0bfddf39f72463ec3fda2646970667358221220fabc4c41580fae7b0dd6c07703fdfa19d9063eb2fafb07c6a7637f6e9c0c10b064736f6c634300080e003368747470733a2f2f6170692e7375706572666f726d2e78797a2f7375706572706f736974696f6e2f00000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000080000000000000000000000000908da814cc9725616d410b2978e88ff2fb9482ee000000000000000000000000c8884ede1ae44bdff60da4b9c542c34a69648a87000000000000000000000000000000000000000000000000000000000000003168747470733a2f2f6170692e7375706572666f726d2e78797a2f7375706572706f736974696f6e2f7b69647d2e6a736f6e000000000000000000000000000000

Deployed Bytecode

0x60806040526004361061016f5760003560e01c8063715018a6116100cc5780639e281a981161007a5780639e281a981461044b578063a22cb4651461046b578063b9a600381461048b578063c87b56dd146104a1578063e985e9c5146104c1578063f242432a1461050a578063f2fde38b1461052a57600080fd5b8063715018a61461035657806375fcbd861461036b5780638aa7f7b61461039a5780638da5cb5b146103ad57806395d89b41146103cb5780639a8a0592146103e05780639b336e631461041557600080fd5b8063137bc42711610129578063137bc4271461027a57806317e0f2521461028f578063270e5b47146102af5780632eb2c2d6146102e3578063428309c5146103035780634e1273f4146103165780636466cd231461034357600080fd5b8062fdd58e1461017b57806301ffc9a7146101ae57806306fdde03146101de578063072de64e146102005780630d2fdccf146102225780630e89341c1461025a57600080fd5b3661017657005b600080fd5b34801561018757600080fd5b5061019b610196366004612f9d565b61054a565b6040519081526020015b60405180910390f35b3480156101ba57600080fd5b506101ce6101c9366004612fdf565b6105e3565b60405190151581526020016101a5565b3480156101ea57600080fd5b506101f3610633565b6040516101a5919061305b565b34801561020c57600080fd5b5061022061021b3660046131ac565b6106c1565b005b34801561022e57600080fd5b50600754610242906001600160a01b031681565b6040516001600160a01b0390911681526020016101a5565b34801561026657600080fd5b506101f3610275366004613276565b6107f3565b34801561028657600080fd5b506101f3610887565b34801561029b57600080fd5b506102206102aa366004613276565b610894565b3480156102bb57600080fd5b506102427f000000000000000000000000c8884ede1ae44bdff60da4b9c542c34a69648a8781565b3480156102ef57600080fd5b506102206102fe366004613378565b6108da565b610220610311366004613470565b610926565b34801561032257600080fd5b506103366103313660046134db565b610a5a565b6040516101a5919061356f565b610220610351366004613582565b610b83565b34801561036257600080fd5b50610220610f3e565b34801561037757600080fd5b5061038b610386366004613276565b610f52565b6040516101a5939291906135ea565b6102206103a8366004613470565b611004565b3480156103b957600080fd5b506003546001600160a01b0316610242565b3480156103d757600080fd5b506101f361111e565b3480156103ec57600080fd5b5060075461040290600160a01b900461ffff1681565b60405161ffff90911681526020016101a5565b34801561042157600080fd5b50610242610430366004613624565b600a602052600090815260409020546001600160a01b031681565b34801561045757600080fd5b50610220610466366004612f9d565b61112b565b34801561047757600080fd5b5061022061048636600461364d565b61115a565b34801561049757600080fd5b5061019b60085481565b3480156104ad57600080fd5b506101f36104bc366004613276565b611165565b3480156104cd57600080fd5b506101ce6104dc366004613686565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b34801561051657600080fd5b506102206105253660046136b4565b611199565b34801561053657600080fd5b5061022061054536600461371c565b6111de565b60006001600160a01b0383166105ba5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061061457506001600160e01b031982166303a24d0760e21b145b806105dd57506301ffc9a760e01b6001600160e01b03198316146105dd565b6004805461064090613739565b80601f016020809104026020016040519081016040528092919081815260200182805461066c90613739565b80156106b95780601f1061068e576101008083540402835291602001916106b9565b820191906000526020600020905b81548152906001019060200180831161069c57829003601f168201915b505050505081565b6106c9611257565b60005b82518110156107ee5760008282815181106106e9576106e9613773565b60200260200101519050600084838151811061070757610707613773565b6020026020010151905060006001600160a01b0316826001600160a01b0316036107735760405162461bcd60e51b815260206004820152601b60248201527f526f757465723a205a65726f204272696467652041646472657373000000000060448201526064016105b1565b60ff81166000818152600a602090815260409182902080546001600160a01b0319166001600160a01b0387169081179091558251938452908301527f8585498d7de284d1c7ffe8331fd6f87a683875b6a4a7ef48cba0a3582a055429910160405180910390a1505080806107e69061379f565b9150506106cc565b505050565b60606002805461080290613739565b80601f016020809104026020016040519081016040528092919081815260200182805461082e90613739565b801561087b5780601f106108505761010080835404028352916020019161087b565b820191906000526020600020905b81548152906001019060200180831161085e57829003601f168201915b50505050509050919050565b6006805461064090613739565b61089c611257565b6003546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156108d6573d6000803e3d6000fd5b5050565b6001600160a01b0385163314806108f657506108f685336104dc565b6109125760405162461bcd60e51b81526004016105b1906137b8565b61091f85858585856112b1565b5050505050565b3383828082146109835760405162461bcd60e51b815260206004820152602260248201527f526f757465723a20496e7075742044617461204c656e677468204d69736d61746044820152610c6d60f31b60648201526084016105b1565b60018211156109fe5760005b828110156109f8576109e88888838181106109ac576109ac613773565b90506020028101906109be9190613806565b8787848181106109d0576109d0613773565b90506020028101906109e29190613806565b8661143b565b6109f18161379f565b905061098f565b50610a51565b610a5187876000818110610a1457610a14613773565b9050602002810190610a269190613806565b86866000818110610a3957610a39613773565b9050602002810190610a4b9190613806565b8561143b565b50505050505050565b60608151835114610abf5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016105b1565b600083516001600160401b03811115610ada57610ada61306e565b604051908082528060200260200182016040528015610b03578160200160208202803683370190505b50905060005b8451811015610b7b57610b4e858281518110610b2757610b27613773565b6020026020010151858381518110610b4157610b41613773565b602002602001015161054a565b828281518110610b6057610b60613773565b6020908102919091010152610b748161379f565b9050610b09565b509392505050565b6007546001600160a01b03163314610bd65760405162461bcd60e51b8152602060048201526016602482015275149bdd5d195c8e8814995c5d595cdd0811195b9a595960521b60448201526064016105b1565b600081806020019051810190610bec9190613882565b9050600181602001516001811115610c0657610c066135b6565b14610c4d5760405162461bcd60e51b8152602060048201526017602482015276149bdd5d195c8e88125b9d985b1a590814185e5b1bd859604a1b60448201526064016105b1565b60008160400151806020019051810190610c6791906139ab565b606080820151600090815260096020526040808220815193840190915280549394509092829060ff166001811115610ca157610ca16135b6565b6001811115610cb257610cb26135b6565b81528154602090910190610100900460ff166001811115610cd557610cd56135b6565b6001811115610ce657610ce66135b6565b8152602001600182018054610cfa90613739565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2690613739565b8015610d735780601f10610d4857610100808354040283529160200191610d73565b820191906000526020600020905b815481529060010190602001808311610d5657829003601f168201915b505050505081525050905060008160400151806020019051810190610d989190613a69565b9050806000015161ffff16836020015161ffff1614610e035760405162461bcd60e51b815260206004820152602160248201527f526f757465723a20536f7572636520436861696e20496473204d69736d6174636044820152600d60fb1b60648201526084016105b1565b806020015161ffff16836040015161ffff1614610e625760405162461bcd60e51b815260206004820152601e60248201527f526f757465723a2044737420436861696e20496473204d69736d61746368000060448201526064016105b1565b600084516001811115610e7757610e776135b6565b03610ec6578251610e9a5760405162461bcd60e51b81526004016105b190613b7f565b610ec18160400151826060015185608001516040518060200160405280600081525061185f565b610f0c565b825115610ee55760405162461bcd60e51b81526004016105b190613b7f565b610f0c8160400151826060015185608001516040518060200160405280600081525061185f565b6000805160206144b08339815191528360600151604051610f2f91815260200190565b60405180910390a15050505050565b610f46611257565b610f5060006119d2565b565b6009602052600090815260409020805460018201805460ff8084169461010090940416929190610f8190613739565b80601f0160208091040260200160405190810160405280929190818152602001828054610fad90613739565b8015610ffa5780601f10610fcf57610100808354040283529160200191610ffa565b820191906000526020600020905b815481529060010190602001808311610fdd57829003601f168201915b5050505050905083565b3383828082146110565760405162461bcd60e51b815260206004820152601c60248201527f526f757465723a20496e76616c696420496e707574204c656e6774680000000060448201526064016105b1565b60018211156110cb5760005b828110156109f8576110bb86868381811061107f5761107f613773565b90506020028101906110919190613806565b8989848181106110a3576110a3613773565b90506020028101906110b59190613806565b86611a24565b6110c48161379f565b9050611062565b610a51858560008181106110e1576110e1613773565b90506020028101906110f39190613806565b8888600081811061110657611106613773565b90506020028101906111189190613806565b85611a24565b6005805461064090613739565b611133611257565b816107ee6111496003546001600160a01b031690565b6001600160a01b0383169084611f1e565b6108d6338383611f70565b6060600661117283612050565b604051602001611183929190613bd2565b6040516020818303038152906040529050919050565b6001600160a01b0385163314806111b557506111b585336104dc565b6111d15760405162461bcd60e51b81526004016105b1906137b8565b61091f85858585856120e2565b6111e6611257565b6001600160a01b03811661124b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105b1565b611254816119d2565b50565b6003546001600160a01b03163314610f505760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105b1565b81518351146112d25760405162461bcd60e51b81526004016105b190613c83565b6001600160a01b0384166112f85760405162461bcd60e51b81526004016105b190613ccb565b3360005b84518110156113df57600085828151811061131957611319613773565b60200260200101519050600085838151811061133757611337613773565b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156113875760405162461bcd60e51b81526004016105b190613d10565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906113c4908490613d5a565b92505081905550505050806113d89061379f565b90506112fc565b50846001600160a01b0316866001600160a01b0316826001600160a01b0316600080516020614490833981519152878760405161141d929190613d72565b60405180910390a461143381878787878761220c565b505050505050565b6008805490600061144b8361379f565b90915550600090506114606020840184613d97565b90506114776114726060850185613db4565b612367565b6114c35760405162461bcd60e51b815260206004820152601e60248201527f537570657220526f757465723a20496e76616c696420536c697070616765000060448201526064016105b1565b604080516101008101825260075461ffff600160a01b90910481168252831660208201526001600160a01b03841681830152600091606082019061150990870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060209081019061154f90870187613db4565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016115936060870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509385525050600854602080850191909152604080519182018152838252938401525081516060810190925291925080828152602001600081526020018360405160200161160d9190613dfd565b60408051601f1981840301815291815291526008546000908152600960205220815181549293508392829060ff19166001838181111561164f5761164f6135b6565b021790555060208201518154829061ff001916610100836001811115611677576116776135b6565b021790555060408201518051611697916001840191602090910190612edf565b505060075461ffff808616600160a01b909204160390506116c5576116c08686866008546123de565b611806565b611769600a60006116d960208a018a613624565b60ff168152602080820192909252604001600020546001600160a01b03169061170490890189613ec7565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506117499250505060608a0160408b0161371c565b61175960808b0160608c0161371c565b8a60800135898c60a0013561250c565b6007546040516001600160a01b03909116906337e6ca029060a0880135908690611797908690602001613f0d565b60408051601f198184030181529190526117b460808b018b613ec7565b6040518663ffffffff1660e01b81526004016117d39493929190613f7b565b6000604051808303818588803b1580156117ec57600080fd5b505af1158015611800573d6000803e3d6000fd5b50505050505b6008547f25846f405be949794fa0c74fa95c4ccb6fc8aa1fc6d058d24b9e1f6e3fe767679061183b6060890160408a0161371c565b886080013560405161184f93929190613fab565b60405180910390a1505050505050565b6001600160a01b0384166118bf5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016105b1565b81518351146118e05760405162461bcd60e51b81526004016105b190613c83565b3360005b845181101561197c578381815181106118ff576118ff613773565b602002602001015160008087848151811061191c5761191c613773565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546119649190613d5a565b909155508190506119748161379f565b9150506118e4565b50846001600160a01b031660006001600160a01b0316826001600160a01b031660008051602061449083398151915287876040516119bb929190613d72565b60405180910390a461091f8160008787878761220c565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000611a336020840184613d97565b90508061ffff16600003611a935760405162461bcd60e51b815260206004820152602160248201527f526f757465723a20496e76616c69642044657374696e6174696f6e20436861696044820152603760f91b60648201526084016105b1565b611b1a82611aa46040860186613db4565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611ae3925050506020870187613db4565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506128c792505050565b60088054906000611b2a8361379f565b9091555050604080516101008101909152600754600160a01b900461ffff168152600090602080820190611b6090870187613d97565b61ffff168152602001846001600160a01b03168152602001858060400190611b889190613db4565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602090810190611bce90870187613db4565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602001611c126060870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060085460208083019190915260408051920191611c6591899101614084565b60408051601f19818403018152918152915280516060810190915290915060009080600181526020016000815260200183604051602001611ca69190613dfd565b60408051601f1981840301815291815291526008546000908152600960205220815181549293508392829060ff191660018381811115611ce857611ce86135b6565b021790555060208201518154829061ff001916610100836001811115611d1057611d106135b6565b021790555060408201518051611d30916001840191602090910190612edf565b50905050600086611d4090614097565b60075490915061ffff808616600160a01b9092041603611e27576001600160a01b037f000000000000000000000000c8884ede1ae44bdff60da4b9c542c34a69648a871663186de5fd3487611d9860408b018b613db4565b611da560208d018d613db4565b886040518863ffffffff1660e01b8152600401611dc796959493929190614179565b6000604051808303818588803b158015611de057600080fd5b505af1158015611df4573d6000803e3d6000fd5b50505050506000805160206144b0833981519152600854604051611e1a91815260200190565b60405180910390a1611ec4565b6007546040516001600160a01b03909116906337e6ca029060a0890135908790611e55908790602001613f0d565b60408051601f19818403018152919052611e7260808c018c613ec7565b6040518663ffffffff1660e01b8152600401611e919493929190613f7b565b6000604051808303818588803b158015611eaa57600080fd5b505af1158015611ebe573d6000803e3d6000fd5b50505050505b6008547f25846f405be949794fa0c74fa95c4ccb6fc8aa1fc6d058d24b9e1f6e3fe7676790611ef960608a0160408b0161371c565b8960800135604051611f0d93929190613fab565b60405180910390a150505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526107ee908490612ab9565b816001600160a01b0316836001600160a01b031603611fe35760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016105b1565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6060600061205d83612b8b565b60010190506000816001600160401b0381111561207c5761207c61306e565b6040519080825280601f01601f1916602001820160405280156120a6576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846120b057509392505050565b6001600160a01b0384166121085760405162461bcd60e51b81526004016105b190613ccb565b33600061211485612c63565b9050600061212185612c63565b90506000868152602081815260408083206001600160a01b038c168452909152902054858110156121645760405162461bcd60e51b81526004016105b190613d10565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a168252812080548892906121a1908490613d5a565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4612201848a8a8a8a8a612cae565b505050505050505050565b6001600160a01b0384163b156114335760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906122509089908990889088908890600401614218565b6020604051808303816000875af192505050801561228b575060408051601f3d908101601f1916820190925261228891810190614276565b60015b61233757612297614293565b806308c379a0036122d057506122ab6142af565b806122b657506122d2565b8060405162461bcd60e51b81526004016105b1919061305b565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016105b1565b6001600160e01b0319811663bc197c8160e01b14610a515760405162461bcd60e51b81526004016105b190614338565b6000805b828110156123d457600084848381811061238757612387613773565b9050602002013510806123b357506127108484838181106123aa576123aa613773565b90506020020135115b156123c25760009150506105dd565b806123cc8161379f565b91505061236b565b5060019392505050565b60006001600160a01b037f000000000000000000000000c8884ede1ae44bdff60da4b9c542c34a69648a87166322927b7834858861241f60408a018a613db4565b61242c60208c018c613db4565b6040518863ffffffff1660e01b815260040161244d96959493929190614380565b60006040518083038185885af115801561246b573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261249491908101906143d9565b90506124ee836124a76040870187613db4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052506040805160208101909152908152879350915061185f9050565b6040518281526000805160206144b083398151915290602001610f2f565b6001600160a01b038416156127a9576001600160a01b038216301461267357604051636eb1769f60e11b81526001600160a01b03838116600483015230602483015284919087169063dd62ed3e90604401602060405180830381865afa15801561257a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259e919061440d565b10156125f85760405162461bcd60e51b8152602060048201526024808201527f427269646765204572726f723a20496e73756666696369656e7420617070726f60448201526376616c7360e01b60648201526084016105b1565b6040516323b872dd60e01b81526001600160a01b038381166004830152306024830152604482018590528616906323b872dd906064016020604051808303816000875af115801561264d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126719190614426565b505b60405163095ea7b360e01b81526001600160a01b0385811660048301526024820185905286169063095ea7b3906044016020604051808303816000875af11580156126c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e69190614426565b506000876001600160a01b031682886040516127029190614443565b60006040518083038185875af1925050503d806000811461273f576040519150601f19603f3d011682016040523d82523d6000602084013e612744565b606091505b50509050806109f85760405162461bcd60e51b815260206004820152602b60248201527f427269646765204572726f723a204661696c656420546f20457865637574652060448201526a547820446174612028312960a81b60648201526084016105b1565b823410156127f95760405162461bcd60e51b815260206004820181905260248201527f4c69712048616e646c65723a20496e73756666696369656e7420416d6f756e7460448201526064016105b1565b6000876001600160a01b0316828501886040516128169190614443565b60006040518083038185875af1925050503d8060008114612853576040519150601f19603f3d011682016040523d82523d6000602084013e612858565b606091505b50509050806128bd5760405162461bcd60e51b815260206004820152602b60248201527f427269646765204572726f723a204661696c656420546f20457865637574652060448201526a547820446174612028322960a81b60648201526084016105b1565b5050505050505050565b6001600160a01b0383166129295760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b60648201526084016105b1565b805182511461294a5760405162461bcd60e51b81526004016105b190613c83565b604080516020810190915260009081905233905b8351811015612a5c57600084828151811061297b5761297b613773565b60200260200101519050600084838151811061299957612999613773565b602090810291909101810151600084815280835260408082206001600160a01b038c168352909352919091205490915081811015612a255760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b60648201526084016105b1565b6000928352602083815260408085206001600160a01b038b1686529091529092209103905580612a548161379f565b91505061295e565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03166000805160206144908339815191528686604051612a9b929190613d72565b60405180910390a46040805160208101909152600090525b50505050565b6000612b0e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d699092919063ffffffff16565b8051909150156107ee5780806020019051810190612b2c9190614426565b6107ee5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105b1565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310612bca5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310612bf6576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310612c1457662386f26fc10000830492506010015b6305f5e1008310612c2c576305f5e100830492506008015b6127108310612c4057612710830492506004015b60648310612c52576064830492506002015b600a83106105dd5760010192915050565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612c9d57612c9d613773565b602090810291909101015292915050565b6001600160a01b0384163b156114335760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190612cf29089908990889088908890600401614455565b6020604051808303816000875af1925050508015612d2d575060408051601f3d908101601f19168201909252612d2a91810190614276565b60015b612d3957612297614293565b6001600160e01b0319811663f23a6e6160e01b14610a515760405162461bcd60e51b81526004016105b190614338565b6060612d788484600085612d80565b949350505050565b606082471015612de15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105b1565b600080866001600160a01b03168587604051612dfd9190614443565b60006040518083038185875af1925050503d8060008114612e3a576040519150601f19603f3d011682016040523d82523d6000602084013e612e3f565b606091505b5091509150612e5087838387612e5b565b979650505050505050565b60608315612eca578251600003612ec3576001600160a01b0385163b612ec35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105b1565b5081612d78565b612d7883838151156122b65781518083602001fd5b828054612eeb90613739565b90600052602060002090601f016020900481019282612f0d5760008555612f53565b82601f10612f2657805160ff1916838001178555612f53565b82800160010185558215612f53579182015b82811115612f53578251825591602001919060010190612f38565b50612f5f929150612f63565b5090565b5b80821115612f5f5760008155600101612f64565b6001600160a01b038116811461125457600080fd5b8035612f9881612f78565b919050565b60008060408385031215612fb057600080fd5b8235612fbb81612f78565b946020939093013593505050565b6001600160e01b03198116811461125457600080fd5b600060208284031215612ff157600080fd5b8135612ffc81612fc9565b9392505050565b60005b8381101561301e578181015183820152602001613006565b83811115612ab35750506000910152565b60008151808452613047816020860160208601613003565b601f01601f19169290920160200192915050565b602081526000612ffc602083018461302f565b634e487b7160e01b600052604160045260246000fd5b60a081018181106001600160401b03821117156130a3576130a361306e565b60405250565b601f8201601f191681016001600160401b03811182821017156130ce576130ce61306e565b6040525050565b60405161010081016001600160401b03811182821017156130f8576130f861306e565b60405290565b60006001600160401b038211156131175761311761306e565b5060051b60200190565b803560ff81168114612f9857600080fd5b600082601f83011261314357600080fd5b81356020613150826130fe565b60405161315d82826130a9565b83815260059390931b850182019282810191508684111561317d57600080fd5b8286015b848110156131a157803561319481612f78565b8352918301918301613181565b509695505050505050565b600080604083850312156131bf57600080fd5b82356001600160401b03808211156131d657600080fd5b818501915085601f8301126131ea57600080fd5b813560206131f7826130fe565b60405161320482826130a9565b83815260059390931b850182019282810191508984111561322457600080fd5b948201945b838610156132495761323a86613121565b82529482019490820190613229565b9650508601359250508082111561325f57600080fd5b5061326c85828601613132565b9150509250929050565b60006020828403121561328857600080fd5b5035919050565b600082601f8301126132a057600080fd5b813560206132ad826130fe565b6040516132ba82826130a9565b83815260059390931b85018201928281019150868411156132da57600080fd5b8286015b848110156131a157803583529183019183016132de565b60006001600160401b0382111561330e5761330e61306e565b50601f01601f191660200190565b600082601f83011261332d57600080fd5b8135613338816132f5565b60405161334582826130a9565b82815285602084870101111561335a57600080fd5b82602086016020830137600092810160200192909252509392505050565b600080600080600060a0868803121561339057600080fd5b853561339b81612f78565b945060208601356133ab81612f78565b935060408601356001600160401b03808211156133c757600080fd5b6133d389838a0161328f565b945060608801359150808211156133e957600080fd5b6133f589838a0161328f565b9350608088013591508082111561340b57600080fd5b506134188882890161331c565b9150509295509295909350565b60008083601f84011261343757600080fd5b5081356001600160401b0381111561344e57600080fd5b6020830191508360208260051b850101111561346957600080fd5b9250929050565b6000806000806040858703121561348657600080fd5b84356001600160401b038082111561349d57600080fd5b6134a988838901613425565b909650945060208701359150808211156134c257600080fd5b506134cf87828801613425565b95989497509550505050565b600080604083850312156134ee57600080fd5b82356001600160401b038082111561350557600080fd5b61351186838701613132565b9350602085013591508082111561352757600080fd5b5061326c8582860161328f565b600081518084526020808501945080840160005b8381101561356457815187529582019590820190600101613548565b509495945050505050565b602081526000612ffc6020830184613534565b60006020828403121561359457600080fd5b81356001600160401b038111156135aa57600080fd5b612d788482850161331c565b634e487b7160e01b600052602160045260246000fd5b6002811061125457634e487b7160e01b600052602160045260246000fd5b6135f3846135cc565b8381526135ff836135cc565b82602082015260606040820152600061361b606083018461302f565b95945050505050565b60006020828403121561363657600080fd5b612ffc82613121565b801515811461125457600080fd5b6000806040838503121561366057600080fd5b823561366b81612f78565b9150602083013561367b8161363f565b809150509250929050565b6000806040838503121561369957600080fd5b82356136a481612f78565b9150602083013561367b81612f78565b600080600080600060a086880312156136cc57600080fd5b85356136d781612f78565b945060208601356136e781612f78565b9350604086013592506060860135915060808601356001600160401b0381111561371057600080fd5b6134188882890161331c565b60006020828403121561372e57600080fd5b8135612ffc81612f78565b600181811c9082168061374d57607f821691505b60208210810361376d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016137b1576137b1613789565b5060010190565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b6000823560be1983360301811261381c57600080fd5b9190910192915050565b6002811061125457600080fd5b600082601f83011261384457600080fd5b815161384f816132f5565b60405161385c82826130a9565b82815285602084870101111561387157600080fd5b61361b836020830160208801613003565b60006020828403121561389457600080fd5b81516001600160401b03808211156138ab57600080fd5b90830190606082860312156138bf57600080fd5b6040516060810181811083821117156138da576138da61306e565b60405282516138e881613826565b815260208301516138f881613826565b602082015260408301518281111561390f57600080fd5b61391b87828601613833565b60408301525095945050505050565b61ffff8116811461125457600080fd5b8051612f988161392a565b600082601f83011261395657600080fd5b81516020613963826130fe565b60405161397082826130a9565b83815260059390931b850182019282810191508684111561399057600080fd5b8286015b848110156131a15780518352918301918301613994565b6000602082840312156139bd57600080fd5b81516001600160401b03808211156139d457600080fd5b9083019060a082860312156139e857600080fd5b6040516139f481613084565b82516139ff8161363f565b81526020830151613a0f8161392a565b60208201526040830151613a228161392a565b604082015260608381015190820152608083015182811115613a4357600080fd5b613a4f87828601613945565b60808301525095945050505050565b8051612f9881612f78565b600060208284031215613a7b57600080fd5b81516001600160401b0380821115613a9257600080fd5b908301906101008286031215613aa757600080fd5b613aaf6130d5565b613ab88361393a565b8152613ac66020840161393a565b6020820152613ad760408401613a5e565b6040820152606083015182811115613aee57600080fd5b613afa87828601613945565b606083015250608083015182811115613b1257600080fd5b613b1e87828601613945565b60808301525060a083015182811115613b3657600080fd5b613b4287828601613945565b60a08301525060c083015160c082015260e083015182811115613b6457600080fd5b613b7087828601613833565b60e08301525095945050505050565b6020808252601e908201527f526f757465723a20496e76616c6964205061796c6f6164205374617475730000604082015260600190565b60008151613bc8818560208601613003565b9290920192915050565b600080845481600182811c915080831680613bee57607f831692505b60208084108203613c0d57634e487b7160e01b86526022600452602486fd5b818015613c215760018114613c3257613c5f565b60ff19861689528489019650613c5f565b60008b81526020902060005b86811015613c575781548b820152908501908301613c3e565b505084890196505b50505050505061361b613c728286613bb6565b64173539b7b760d91b815260050190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60008219821115613d6d57613d6d613789565b500190565b604081526000613d856040830185613534565b828103602084015261361b8185613534565b600060208284031215613da957600080fd5b8135612ffc8161392a565b6000808335601e19843603018112613dcb57600080fd5b8301803591506001600160401b03821115613de557600080fd5b6020019150600581901b360382131561346957600080fd5b60208152613e1260208201835161ffff169052565b60006020830151613e29604084018261ffff169052565b5060408301516001600160a01b0381166060840152506060830151610100806080850152613e5b610120850183613534565b91506080850151601f19808685030160a0870152613e798483613534565b935060a08701519150808685030160c0870152613e968483613534565b935060c087015160e087015260e0870151915080868503018387015250613ebd838261302f565b9695505050505050565b6000808335601e19843603018112613ede57600080fd5b8301803591506001600160401b03821115613ef857600080fd5b60200191503681900382131561346957600080fd5b6020815260008251613f1e816135cc565b806020840152506020830151613f33816135cc565b806040840152506040830151606080840152612d78608084018261302f565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b61ffff85168152606060208201526000613f98606083018661302f565b8281036040840152612e50818587613f52565b9283526001600160a01b03919091166020830152604082015260600190565b60ff613fd582613121565b16825260006020820135601e19833603018112613ff157600080fd5b82016020810190356001600160401b0381111561400d57600080fd5b80360382131561401c57600080fd5b60c0602086015261403160c086018284613f52565b91505061404060408401612f8d565b6001600160a01b0316604085015261405a60608401612f8d565b6001600160a01b031660608501526080838101359085015260a09283013592909301919091525090565b602081526000612ffc6020830184613fca565b600060c082360312156140a957600080fd5b60405160c081016001600160401b0382821081831117156140cc576140cc61306e565b816040526140d985613121565b835260208501359150808211156140ef57600080fd5b506140fc3682860161331c565b602083015250604083013561411081612f78565b604082015261412160608401612f8d565b60608201526080830135608082015260a083013560a082015280915050919050565b81835260006001600160fb1b0383111561415c57600080fd5b8260051b8083602087013760009401602001938452509192915050565b600060018060a01b0380891683526080602084015261419c60808401888a614143565b83810360408501526141af818789614143565b9050838103606085015260ff8551168152602085015160c060208301526141d960c083018261302f565b90508260408701511660408301528260608701511660608301526080860151608083015260a086015160a0830152809350505050979650505050505050565b6001600160a01b0386811682528516602082015260a06040820181905260009061424490830186613534565b82810360608401526142568186613534565b9050828103608084015261426a818561302f565b98975050505050505050565b60006020828403121561428857600080fd5b8151612ffc81612fc9565b600060033d11156142ac5760046000803e5060005160e01c5b90565b600060443d10156142bd5790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156142ec57505050505090565b82850191508151818111156143045750505050505090565b843d870101602082850101111561431e5750505050505090565b61432d602082860101876130a9565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03871681526080602082018190526000906143a490830188613fca565b82810360408401526143b7818789614143565b905082810360608401526143cc818587614143565b9998505050505050505050565b6000602082840312156143eb57600080fd5b81516001600160401b0381111561440157600080fd5b612d7884828501613945565b60006020828403121561441f57600080fd5b5051919050565b60006020828403121561443857600080fd5b8151612ffc8161363f565b6000825161381c818460208701613003565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612e509083018461302f56fe4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fbdfd517ed69f8a0a57d49fe494e4864fac3cfe3585c14c0bfddf39f72463ec3fda2646970667358221220fabc4c41580fae7b0dd6c07703fdfa19d9063eb2fafb07c6a7637f6e9c0c10b064736f6c634300080e0033

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

00000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000080000000000000000000000000908da814cc9725616d410b2978e88ff2fb9482ee000000000000000000000000c8884ede1ae44bdff60da4b9c542c34a69648a87000000000000000000000000000000000000000000000000000000000000003168747470733a2f2f6170692e7375706572666f726d2e78797a2f7375706572706f736974696f6e2f7b69647d2e6a736f6e000000000000000000000000000000

-----Decoded View---------------
Arg [0] : chainId_ (uint16): 101
Arg [1] : baseUri_ (string): https://api.superform.xyz/superposition/{id}.json
Arg [2] : stateHandler_ (address): 0x908da814cc9725616D410b2978E88fF2fb9482eE
Arg [3] : srcSuperDestination_ (address): 0xc8884edE1ae44bDfF60da4B9c542C34A69648A87

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000065
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [2] : 000000000000000000000000908da814cc9725616d410b2978e88ff2fb9482ee
Arg [3] : 000000000000000000000000c8884ede1ae44bdff60da4b9c542c34a69648a87
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000031
Arg [5] : 68747470733a2f2f6170692e7375706572666f726d2e78797a2f737570657270
Arg [6] : 6f736974696f6e2f7b69647d2e6a736f6e000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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