MNT Price: $0.90 (+2.63%)

Contract

0x960105e099cd32c0cF3168DAfd13742d689F3Af5
 

Overview

MNT Balance

Mantle Mainnet Network LogoMantle Mainnet Network LogoMantle Mainnet Network Logo0 MNT

MNT Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Amount:Between 1-1k
Reset Filter

Transaction Hash
Block
From
To

There are no matching entries

> 10 Internal Transactions and > 10 Token Transfers found.

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
873658002025-11-11 11:51:5274 days ago1762861912
0x960105e0...d689F3Af5
0.4047222 MNT
843104022025-09-01 18:25:16144 days ago1756751116
0x960105e0...d689F3Af5
0.51030296 MNT
842093742025-08-30 10:17:40147 days ago1756549060
0x960105e0...d689F3Af5
0.52163541 MNT
842086522025-08-30 9:53:36147 days ago1756547616
0x960105e0...d689F3Af5
0.52163541 MNT
842082892025-08-30 9:41:30147 days ago1756546890
0x960105e0...d689F3Af5
0.52163541 MNT
835621702025-08-15 10:44:12162 days ago1755254652
0x960105e0...d689F3Af5
0.49116339 MNT
830662602025-08-03 23:13:52173 days ago1754262832
0x960105e0...d689F3Af5
0.18760089 MNT
828178052025-07-29 5:12:02179 days ago1753765922
0x960105e0...d689F3Af5
0.66343238 MNT
820760722025-07-12 1:07:36196 days ago1752282456
0x960105e0...d689F3Af5
0.88872112 MNT
817514182025-07-04 12:45:48204 days ago1751633148
0x960105e0...d689F3Af5
0.22150664 MNT
816129522025-07-01 7:50:16207 days ago1751356216
0x960105e0...d689F3Af5
0.7926863 MNT
814461942025-06-27 11:11:40211 days ago1751022700
0x960105e0...d689F3Af5
0.7926863 MNT
814027862025-06-26 11:04:44212 days ago1750935884
0x960105e0...d689F3Af5
0.21967884 MNT
807319152025-06-10 22:22:22227 days ago1749594142
0x960105e0...d689F3Af5
0.71929641 MNT
807309122025-06-10 21:48:56227 days ago1749592136
0x960105e0...d689F3Af5
0.71929641 MNT
807299462025-06-10 21:16:44227 days ago1749590204
0x960105e0...d689F3Af5
0.19843738 MNT
807203822025-06-10 15:57:56228 days ago1749571076
0x960105e0...d689F3Af5
0.71929641 MNT
806885472025-06-09 22:16:46228 days ago1749507406
0x960105e0...d689F3Af5
0.19763223 MNT
806745132025-06-09 14:28:58229 days ago1749479338
0x960105e0...d689F3Af5
0.71929641 MNT
806696192025-06-09 11:45:50229 days ago1749469550
0x960105e0...d689F3Af5
0.71929641 MNT
806665242025-06-09 10:02:40229 days ago1749463360
0x960105e0...d689F3Af5
0.71929641 MNT
806659302025-06-09 9:42:52229 days ago1749462172
0x960105e0...d689F3Af5
0.71929641 MNT
806653722025-06-09 9:24:16229 days ago1749461056
0x960105e0...d689F3Af5
0.71929641 MNT
806330202025-06-08 15:25:52230 days ago1749396352
0x960105e0...d689F3Af5
0.19905087 MNT
805867462025-06-07 13:43:24231 days ago1749303804
0x960105e0...d689F3Af5
0.19787565 MNT
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SwapsicleBridge

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 500000 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./util/IERC721WithUtilityHelpers.sol";
import "./layerzero/oftv2/IOFTV2.sol";
import "./layerzero/libraries/LzLib.sol";

/**
 * @title SwapsicleBridge
 * @notice This contract bridges OFT tokens to other chains using LayerZero
 */
contract SwapsicleBridge is Ownable, AccessControl, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using EnumerableMap for EnumerableMap.AddressToUintMap;
    using EnumerableSet for EnumerableSet.AddressSet;
    using EnumerableSet for EnumerableSet.UintSet;

    /// @notice The maximum percent value (100%), divide by this value to get the percentage
    uint256 public constant MAX_PERCENT = 10000;

    /**
     * @notice Bridging fee, value in percent, to be divided by 10000 (e.g. 10 = 0.1%)
     * bridgingFee and bridgingFeeDiscounted are the global fees, they can be overridden by tokenFee and tokenFeeDiscounted;
     * tokenFee and tokenFeeDiscounted are the fees for a given token, they can be overridden by tokenChainFee and
     * tokenChainFeeDiscounted. This allows customization per token and per chain.
     */
    uint256 public bridgingFee;

    /// @notice Bridging discounted fee (for users holding an NFT)
    uint256 public bridgingFeeDiscounted;

    /// @notice The address to send the bridging fees to
    address public feeAddress;

    /**
    * @dev Mapping to TokenOwnerFee struct (address & percent) for a given token (does not override feeAddress, 
    * it's intended to allow a token to get part of the fees, the value is a percent, to be divided by 10000:
    * a value of 3000 means that 30% of the fees go the token feeAddress and 70% go to the bridge feeAddress)
    */
    mapping(address => TokenOwnerFee) public tokenOwnerFee;

    /// @dev Mapping to set a custom fee for a given token (overrides bridgingFee)
    EnumerableMap.AddressToUintMap private tokenFee;

    /// @dev Mapping to set a custom fee for a given token (overrides bridgingFeeDiscounted)
    EnumerableMap.AddressToUintMap private tokenFeeDiscounted;

    /// @dev Mapping to set a custom discounted fee for a given token and chain (overrides tokenFee)
    mapping(address => EnumerableMap.UintToUintMap) private tokenChainFee;

    /// @dev Mapping to set a custom discounted fee for a given token and chain (overrides tokenFeeDiscounted)
    mapping(address => EnumerableMap.UintToUintMap) private tokenChainFeeDiscounted;

    /// @notice Set of tokens that can be bridged
    EnumerableSet.AddressSet private tokens;

    /// @notice Set of tokens that cannot be transferred to a different address than msg.sender (e.g. ICE)
    EnumerableSet.AddressSet private nonTransferableTokens;

    /**
     * @notice Mapping of NFT collection => implements IERC721WithUtility (1) or not (0)
     * for standard IERC721 collections, owning them has already utility, without checking their status
     */
    EnumerableMap.AddressToUintMap private nftCollections;

    /// @notice Mapping of token => total amount bridged
    mapping(address => uint256) public totalBridged;

    /// @notice Mapping of token => chainId => total amount bridged
    mapping(address => mapping(uint16 => uint256)) public totalBridgedToChain;

    /// @notice Mapping of chain IDs to LayerZero IDs
    mapping(uint16 => uint16) public chainIdToLzChainId;

    /// @notice Mapping of token => chain ID => whether bridging is allowed
    mapping(address => mapping(uint16 => bool)) public bridgingAllowed;

    /// @notice The list of chain IDs used by this bridge; note: not all tokens can be bridged to all chains
    uint16[] public supportedChains;

    /// @notice The operator role
    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

    struct TokenOwnerFee {
        address feeAddress; /// @notice The token owner/founder address to send the fees to
        uint256 percent; /// @notice The percent of the fees that goes to the token owner
    }

    struct BridgingAllowed {
        address token; /// @notice The token address
        uint16 chainId; /// @notice The chainId of the target chain
        bool bridgingAllowed; /// @notice Whether bridging is allowed
    }

    struct TotalBridged {
        address token; /// @notice The token address
        uint16 chainId; /// @notice The chainId of the target chain
        uint256 totalBridged; /// @notice The total amount bridged
    }

    /// @notice Emitted when a token is bridged
    event Bridge (
        address indexed from,
        address to,
        address indexed token,
        uint256 amount,
        uint16 indexed chainId
    );

    error BridgingNotAllowed();
    error InsufficientAllowance();
    error InsufficientBalance();
    error InvalidArrayLength();
    error InvalidChainId();
    error InvalidLzChainId();
    error InvalidPercent();
    error NonTransferableToken();
    error OperatorRoleRequired();
    error ZeroAddress();
    error ZeroAmount();

    modifier onlyOperator() {
        if (!hasRole(OPERATOR_ROLE, msg.sender)) revert OperatorRoleRequired();
        _;
    }

    /**
     * @notice Initializes the contract
     * @param supportedChains_ The list of the supported chains
     */
    constructor(uint16[] memory supportedChains_, address[] memory tokens_) {
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(OPERATOR_ROLE, msg.sender);

        supportedChains = supportedChains_;

        for (uint i = 0; i < tokens_.length; i++) {
            if (tokens_[i] == address(0)) revert ZeroAddress();
            tokens.add(tokens_[i]);
        }

        // For each token: set bridging allowed to true for each supported chain
        for (uint t = 0; t < tokens_.length; t++) {
            address token = tokens.at(t);
            for (uint c = 0; c < supportedChains_.length; c++) {
                if (supportedChains_[c] == 0) revert InvalidChainId();
                bridgingAllowed[token][supportedChains[c]] = true;
            }
        }
    }

    /**
     * @notice Returns the list of configured tokens
     */
    function getTokens() public view returns (address[] memory) {
        return tokens.values();
    }

    /**
     * @notice Returns the list of non transferable tokens
     */
    function getNonTransferableTokens() public view returns (address[] memory) {
        return nonTransferableTokens.values();
    }

    /**
     * @notice Returns the list of supported chains
     */
    function getSupportedChains() public view returns (uint16[] memory) {
        return supportedChains;
    }

    /**
     * @notice Returns the list of all configurations (token, chainId, bridgingAllowed true/false)
     */
    function getBridgingAllowed() public view returns (BridgingAllowed[] memory) {
        BridgingAllowed[] memory result = new BridgingAllowed[](supportedChains.length * tokens.length());
        uint index = 0;
        for (uint t = 0; t < tokens.length(); t++) {
            address token = tokens.at(t);
            for (uint c = 0; c < supportedChains.length; c++) {
                result[index] = BridgingAllowed(token, supportedChains[c], bridgingAllowed[token][supportedChains[c]]);
                index++;
            }
        }
        return result;
    }

    /**
     * @notice Returns `true` if the given chainId is supported
     */
    function supportsChain(uint16 chainId) public view returns (bool) {
        for (uint i = 0; i < supportedChains.length; i++) {
            if (supportedChains[i] == chainId) {
                return true;
            }
        }
        return false;
    }

    /**
     * @notice Returns the bridging fee for the user (divide by 10000 to get the percentage)
     * @param token The token address
     * @param chainId The chain ID
     * @param user The user address
     */
    function getBridgingFee(address token, uint16 chainId, address user) public view returns (uint256 fee) {
        if (feeAddress == address(0)) return 0;
        bool hasDiscount;
        for (uint i = 0; i < nftCollections.length(); i++) {
            (address nftCollection, uint256 isIERC721WithUtility) = nftCollections.at(i);
            bool ownsNftWithUtility = IERC721WithUtilityHelpers.ownsNftWithUtility(user, nftCollection, isIERC721WithUtility > 0);
            if (ownsNftWithUtility) {
                hasDiscount = true;
                break;
            }
        }
        uint256 _bridgingFee = tokenFee.contains(token) ? tokenFee.get(token) : bridgingFee;
        uint256 _bridgingFeeDiscounted = tokenFeeDiscounted.contains(token) ? tokenFeeDiscounted.get(token) : bridgingFeeDiscounted;
        if (EnumerableMap.contains(tokenChainFee[token], chainId)) {
          _bridgingFee = EnumerableMap.get(tokenChainFee[token], chainId);
        }
        if (EnumerableMap.contains(tokenChainFeeDiscounted[token], chainId)) {
          _bridgingFeeDiscounted = EnumerableMap.get(tokenChainFeeDiscounted[token], chainId);
        }
        fee = hasDiscount ? _bridgingFeeDiscounted : _bridgingFee;
    }

    /**
     * @notice Returns the list of NFT collections
     */
    function getNftCollections() public view returns (address[] memory) {
        return nftCollections.keys();
    }

    /**
    * @notice Returns a list of all tokens and the total bridged to each supported chain
    */
    function getTotalBridgedToChain() public view returns (TotalBridged[] memory) {
        uint tokensLength = tokens.length();
        uint chainsLength = supportedChains.length;
        TotalBridged[] memory result = new TotalBridged[](tokensLength * chainsLength);
        uint index = 0;
        for (uint t = 0; t < tokens.length(); t++) {
            address token = tokens.at(t);
            for (uint c = 0; c < chainsLength; c++) {
                result[index] = TotalBridged(token, supportedChains[c], totalBridgedToChain[token][supportedChains[c]]);
                index++;
            }
        }
        return result;
    }

    /**
     * @notice Returns the LayerZero native fee value to pay when calling `bridge`.
     * Note: `chainId` is the official chain ID; toAddress is human friendly, not in bytes.
     */
    function getLzNativeFee(
        address token,
        address recipient,
        uint16 chainId,
        uint amount,
        bool useZro,
        bytes calldata adapterParams
    ) external view returns (uint256) {
        uint16 lzChainId = _validateBridging(token, chainId);
        bytes32 toAddressBytes = LzLib.addressToBytes32(recipient);
        (uint nativeFee, ) = IOFTV2(token).estimateSendFee(
            lzChainId, toAddressBytes, amount, useZro, adapterParams
        );
        return nativeFee;
    }

    /**
     * @notice Bridges a token amount to a different chain.
     * Note: call `getLzNativeFee` and pay the nativeFee returned when calling this function.
     * @param amount The amount of token to bridge
     * @param token The token address
     * @param recipient The recipient address to bridge the amount to
     * @param chainId The chain ID where the token needs to be bridged to
     * @param adapterParams The adapter params (same as the ones used to call `getLzNativeFee`)
     */
    function bridge(uint256 amount, address token, address recipient, uint16 chainId, bytes calldata adapterParams
    ) external payable nonReentrant {
        if (!bridgingAllowed[token][chainId]) revert BridgingNotAllowed();
        uint16 lzChainId = _validateBridging(token, chainId);
        if (amount == 0) revert ZeroAmount();
        if (IERC20(token).balanceOf(msg.sender) < amount) revert InsufficientBalance();
        if (IERC20(token).allowance(msg.sender, address(this)) < amount) revert InsufficientAllowance();
        if (nonTransferableTokens.contains(token) && recipient != msg.sender) revert NonTransferableToken();

        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);

        uint256 fee = getBridgingFee(token, chainId, msg.sender);
        uint256 targetAmount = amount;
        if (fee > 0) {
            uint256 feeAmount = amount * fee / MAX_PERCENT;
            targetAmount -= feeAmount;

            TokenOwnerFee memory _tokenOwnerFee = tokenOwnerFee[token];
            if (_tokenOwnerFee.feeAddress != address(0)) {
                // Percent of fees for to the token owner/founder
                uint256 tokenOwnerFeeAmount = feeAmount * _tokenOwnerFee.percent / MAX_PERCENT;
                feeAmount -= tokenOwnerFeeAmount;
                IERC20(token).safeTransfer(_tokenOwnerFee.feeAddress, tokenOwnerFeeAmount);
            }

            IERC20(token).safeTransfer(feeAddress, feeAmount);
        }

        IOFTV2(token).sendFrom{value: msg.value}(
          address(this), lzChainId, LzLib.addressToBytes32(recipient), targetAmount,
          ICommonOFT.LzCallParams(payable(msg.sender), address(0), adapterParams)
        );

        // Update these totals for statistical purposes
        totalBridged[token] += targetAmount;
        totalBridgedToChain[token][chainId] += targetAmount;

        emit Bridge(msg.sender, recipient, token, targetAmount, chainId);
    }

    /********************************************************/
    /****************** OPERATOR FUNCTIONS ******************/
    /********************************************************/

    /**
     * @notice Sets whether bridging to a destination chainId is allowed
     * @param token The token address
     * @param chainId The official (remote) chain ID
     * @param allowed Whether bridging is allowed
     */
    function updateBridgingAllowed(address token, uint16 chainId, bool allowed) external onlyOperator {
        if (token == address(0)) revert ZeroAddress();
        if (!supportsChain(chainId)) revert InvalidChainId();
        if (token == address(0)) revert ZeroAddress();
        bridgingAllowed[token][chainId] = allowed;
    }

    /**
     * @notice Sets the mappings of the original chain IDs to the LayerZero chain IDs
     * @param chainIds The official chain IDs
     * @param lzChainIds The LayerZero chain IDs
     */
    function updateChainMappings(uint16[] calldata chainIds, uint16[] calldata lzChainIds) external onlyOperator {
        if (chainIds.length != lzChainIds.length) revert InvalidArrayLength();
        for (uint i = 0; i < chainIds.length; i++) {
            if (chainIds[i] == 0) revert InvalidChainId();
            chainIdToLzChainId[chainIds[i]] = lzChainIds[i];
        }
    }

    /**
     * @notice Update the supported chains
     * @param supportedChains_ The list of supported chains
     */
    function updateSupportedChains(uint16[] calldata supportedChains_) external onlyOperator {
        supportedChains = supportedChains_;
    }

    /**
     * Edit or remove a token
     * @param token The token address
     * @param add Whether to add or remove the token
     */
    function updateToken(address token, bool add) external onlyOperator {
        if (token == address(0)) revert ZeroAddress();
        if (add) {
            tokens.add(token);
        } else {
            tokens.remove(token);
            for (uint i = 0; i < supportedChains.length; i++) {
                bridgingAllowed[token][supportedChains[i]] = false;
            }
        }
    }

    /**
     * @notice Sets the bridging fee for a given token (overrides bridgingFee)
     * @param token_ The token address
     * @param fee_ The bridging fee percentage
     * @param add Whether to add/update or remove the fee
     */
    function updateTokenFee(address token_, uint256 fee_, bool add) external onlyOperator {
        if (fee_ > MAX_PERCENT) revert InvalidPercent();
        if (add) {
          tokenFee.set(token_, fee_);
        } else {
          tokenFee.remove(token_);
        }
    }

    /**
     * @notice Sets the discounted bridging fee for a given token (overrides bridgingFeeDiscounted)
     * @param token_ The token address
     * @param feeDiscounted_ The discounted bridging fee percentage
     * @param add Whether to add/update or remove the fee
     */
    function updateTokenFeeDiscounted(address token_, uint256 feeDiscounted_, bool add) external onlyOperator {
        if (feeDiscounted_ > MAX_PERCENT) revert InvalidPercent();
        if (add) {
          tokenFeeDiscounted.set(token_, feeDiscounted_);
        } else {
          tokenFeeDiscounted.remove(token_);
        }
    }

    /**
     * @notice Sets the bridging fee for a given token and chain (overrides tokenFee)
     * @param token_ The token address
     * @param chainId_ The chain ID
     * @param fee_ The bridging fee
     * @param add Whether to add/update or remove the fee
     */
    function updateTokenChainFee(address token_, uint16 chainId_, uint256 fee_, bool add) external onlyOperator {
        if (fee_ > MAX_PERCENT) revert InvalidPercent();
        if (add) {
          EnumerableMap.set(tokenChainFee[token_], chainId_, fee_);
        } else {
          EnumerableMap.remove(tokenChainFee[token_], chainId_);
        }
    }

    /**
     * @notice Sets the discounted bridging fee for a given token and chain (overrides tokenFeeDiscounted)
     * @param token_ The token address
     * @param chainId_ The chain ID
     * @param feeDiscounted_ The discounted bridging fee
     */
    function updateTokenChainFeeDiscounted(address token_, uint16 chainId_, uint256 feeDiscounted_, bool add) external onlyOperator {
        if (feeDiscounted_ > MAX_PERCENT) revert InvalidPercent();
        if (add) {
          EnumerableMap.set(tokenChainFeeDiscounted[token_], chainId_, feeDiscounted_);
        } else {
          EnumerableMap.remove(tokenChainFeeDiscounted[token_], chainId_);
        }
    }

    /**
     * @notice Sets the fee address and percentage for a token owner/founder
     * @param token_ The token address
     * @param tokenFeeAddress_ The token owner/founder address to send the fees to
     * @param percent_ The fee percentage for tokenFeeAddress
     */
    function updateTokenOwnerFee(address token_, address tokenFeeAddress_, uint256 percent_) external onlyOperator {
        if (token_ == address(0)) revert ZeroAddress();
        if (tokenFeeAddress_ == address(0)) revert ZeroAddress();
        if (percent_ > MAX_PERCENT) revert InvalidPercent();
        if (percent_ > 0) {
            tokenOwnerFee[token_] = TokenOwnerFee(tokenFeeAddress_, percent_);
        } else {
            delete tokenOwnerFee[token_];
        }
    }

    /*****************************************************/
    /****************** ADMIN FUNCTIONS ******************/
    /*****************************************************/

    /**
     * @notice Updates the fee address, setting it to address(0) disables fees
     * @param feeAddress_ The fee address
     */
    function updateFeeAddress(address feeAddress_) external onlyOwner {
        feeAddress = feeAddress_;
    }

    /**
     * @notice Updates the briding fees, both normal and discounted: 1 = 0.01%, 10 = 0.1%, 100 = 1%, 1000 = 10%, 10000 = 100%
     * @param bridgingFee_ The bridging fee
     * @param bridgingFeeDiscounted_ The bridging fee discounted
     */
    function updateBridgingFee(uint256 bridgingFee_, uint256 bridgingFeeDiscounted_) external onlyOwner {
        bridgingFee = bridgingFee_;
        bridgingFeeDiscounted = bridgingFeeDiscounted_;
    }

    /**
     * Edit or remove a non-transferable token
     * @param token The token address
     * @param add Whether to add or remove the token
     */
    function updateNonTransferableToken(address token, bool add) external onlyOwner {
        if (token == address(0)) revert ZeroAddress();
        if (add) {
            nonTransferableTokens.add(token);
        } else {
            nonTransferableTokens.remove(token);
        }
    }

    /**
     * @notice Edit or remove an NFT collection. To remove a collection, set its multiplier to 0.
     * @param nftAddress Address of the NFT contract
     * @param isIERC721WithUtility Whether the NFT collection implements IERC721WithUtility
     * @param add Whether to add or remove the NFT collection
     */
    function updateNftCollection(address nftAddress, bool isIERC721WithUtility, bool add) external onlyOwner {
        if (nftAddress == address(0)) revert ZeroAddress();
        if (add) {
            // Add/Edit the NFT collection
            nftCollections.set(nftAddress, isIERC721WithUtility ? 1 : 0);
        } else {
            // Remove the NFT collection & multiplier
            nftCollections.remove(nftAddress);
        }
    }

    /**
     * @notice Transfers to owner a given amount of ERC20 token
     * @param token The ERC20 token to withdraw
     * @param amount The amount to withdraw (set to 0 to withdraw the entire balance)
     */
    function withdrawToken(IERC20 token, uint256 amount) external onlyOwner {
        uint256 balance = token.balanceOf(address(this));
        if (balance == 0 || amount > balance) revert InsufficientBalance();
        amount = amount == 0 ? balance : amount;
        token.safeTransfer(owner(), amount);
    }

    /**
     * @dev Checks if tokenId and chainId are supported
     */
    function _validateBridging(address token, uint16 chainId) private view returns (uint16 lzChainId) {
        if (chainId == 0 || !supportsChain(chainId)) revert InvalidChainId();
        if (!bridgingAllowed[token][chainId]) revert BridgingNotAllowed();
        lzChainId = chainIdToLzChainId[chainId];
        if (lzChainId == 0) revert InvalidLzChainId();
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

interface IERC721WithUtility {
    function hasUtility(uint256 tokenId) external view returns (bool);
    function balanceWithUtilityOf(address owner) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

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

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.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 `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, 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);
    }

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library 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) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

File 18 of 23 : EnumerableMap.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableMap.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.

pragma solidity ^0.8.0;

import "./EnumerableSet.sol";

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * The following map types are supported:
 *
 * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0
 * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0
 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0
 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableMap.
 * ====
 */
library EnumerableMap {
    using EnumerableSet for EnumerableSet.Bytes32Set;

    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct Bytes32ToBytes32Map {
        // Storage of keys
        EnumerableSet.Bytes32Set _keys;
        mapping(bytes32 => bytes32) _values;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {
        map._values[key] = value;
        return map._keys.add(key);
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
        delete map._values[key];
        return map._keys.remove(key);
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
        return map._keys.contains(key);
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
        return map._keys.length();
    }

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

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
        bytes32 value = map._values[key];
        if (value == bytes32(0)) {
            return (contains(map, key), bytes32(0));
        } else {
            return (true, value);
        }
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
        return value;
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), errorMessage);
        return value;
    }

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

    // UintToUintMap

    struct UintToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

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

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(key)));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(key), errorMessage));
    }

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

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

        return result;
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

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

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));
    }

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

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

        return result;
    }

    // AddressToUintMap

    struct AddressToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {
        return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(AddressToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

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

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        AddressToUintMap storage map,
        address key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));
    }

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

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

        return result;
    }

    // Bytes32ToUintMap

    struct Bytes32ToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {
        return set(map._inner, key, bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(Bytes32ToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

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

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, key);
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {
        return uint256(get(map._inner, key));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        Bytes32ToUintMap storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, key, errorMessage));
    }

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

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

        return result;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }
}

// SPDX-License-Identifier: BUSL-1.1

pragma solidity >=0.6.0;
pragma experimental ABIEncoderV2;

library LzLib {
    // LayerZero communication
    struct CallParams {
        address payable refundAddress;
        address zroPaymentAddress;
    }

    //---------------------------------------------------------------------------
    // Address type handling

    struct AirdropParams {
        uint airdropAmount;
        bytes32 airdropAddress;
    }

    function buildAdapterParams(LzLib.AirdropParams memory _airdropParams, uint _uaGasLimit) internal pure returns (bytes memory adapterParams) {
        if (_airdropParams.airdropAmount == 0 && _airdropParams.airdropAddress == bytes32(0x0)) {
            adapterParams = buildDefaultAdapterParams(_uaGasLimit);
        } else {
            adapterParams = buildAirdropAdapterParams(_uaGasLimit, _airdropParams);
        }
    }

    // Build Adapter Params
    function buildDefaultAdapterParams(uint _uaGas) internal pure returns (bytes memory) {
        // txType 1
        // bytes  [2       32      ]
        // fields [txType  extraGas]
        return abi.encodePacked(uint16(1), _uaGas);
    }

    function buildAirdropAdapterParams(uint _uaGas, AirdropParams memory _params) internal pure returns (bytes memory) {
        require(_params.airdropAmount > 0, "Airdrop amount must be greater than 0");
        require(_params.airdropAddress != bytes32(0x0), "Airdrop address must be set");

        // txType 2
        // bytes  [2       32        32            bytes[]         ]
        // fields [txType  extraGas  dstNativeAmt  dstNativeAddress]
        return abi.encodePacked(uint16(2), _uaGas, _params.airdropAmount, _params.airdropAddress);
    }

    function getGasLimit(bytes memory _adapterParams) internal pure returns (uint gasLimit) {
        require(_adapterParams.length == 34 || _adapterParams.length > 66, "Invalid adapterParams");
        assembly {
            gasLimit := mload(add(_adapterParams, 34))
        }
    }

    // Decode Adapter Params
    function decodeAdapterParams(bytes memory _adapterParams) internal pure returns (uint16 txType, uint uaGas, uint airdropAmount, address payable airdropAddress) {
        require(_adapterParams.length == 34 || _adapterParams.length > 66, "Invalid adapterParams");
        assembly {
            txType := mload(add(_adapterParams, 2))
            uaGas := mload(add(_adapterParams, 34))
        }
        require(txType == 1 || txType == 2, "Unsupported txType");
        require(uaGas > 0, "Gas too low");

        if (txType == 2) {
            assembly {
                airdropAmount := mload(add(_adapterParams, 66))
                airdropAddress := mload(add(_adapterParams, 86))
            }
        }
    }

    //---------------------------------------------------------------------------
    // Address type handling
    function bytes32ToAddress(bytes32 _bytes32Address) internal pure returns (address _address) {
        return address(uint160(uint(_bytes32Address)));
    }

    function addressToBytes32(address _address) internal pure returns (bytes32 _bytes32Address) {
        return bytes32(uint(uint160(_address)));
    }

    function bytesToAddress(bytes memory addressBytes) internal pure returns (address) {
        address addr;
        assembly {
            addr := mload(add(addressBytes, 20))
        }
        return addr;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @dev Interface of the IOFT core standard
 */
interface ICommonOFT is IERC165 {

    struct LzCallParams {
        address payable refundAddress;
        address zroPaymentAddress;
        bytes adapterParams;
    }

    /**
     * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`)
     * _dstChainId - L0 defined chain id to send tokens too
     * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
     * _amount - amount of the tokens to transfer
     * _useZro - indicates to use zro to pay L0 fees
     * _adapterParam - flexible bytes array to indicate messaging adapter services in L0
     */
    function estimateSendFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);

    function estimateSendAndCallFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);

    /**
     * @dev returns the circulating amount of tokens on current chain
     */
    function circulatingSupply() external view returns (uint);

    /**
     * @dev returns the address of the ERC20 token
     */
    function token() external view returns (address);
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

import "./ICommonOFT.sol";

/**
 * @dev Interface of the IOFT core standard
 */
interface IOFTV2 is ICommonOFT {

    /**
     * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from`
     * `_from` the owner of token
     * `_dstChainId` the destination chain identifier
     * `_toAddress` can be any size depending on the `dstChainId`.
     * `_amount` the quantity of tokens in wei
     * `_refundAddress` the address LayerZero refunds if too much message fee is sent
     * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token)
     * `_adapterParams` is a flexible bytes array to indicate messaging adapter services
     */
    function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) external payable;

    function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) external payable;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../interfaces/IERC721WithUtility.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

library IERC721WithUtilityHelpers {
    /**
     * @notice Returns the balance of NFTs with utility (of `nftCollection`) of a given owner
     * @param owner Address of the owner to query the balance of
     * @param nftCollection Address of the NFT collection
     * @param isIERC721WithUtility Whether the NFT collection implements IERC721WithUtility
     */
    function balanceWithUtilityOf(address owner, address nftCollection, bool isIERC721WithUtility) public view returns (uint256 balance) {
        if (isIERC721WithUtility) {
            balance = IERC721WithUtility(nftCollection).balanceWithUtilityOf(owner);
        } else {
            balance = IERC721(nftCollection).balanceOf(owner);
        }
    }

    /**
     * @notice Returns whether the given owner owns at least one NFT with utility (of `nftCollection`)
     * @param owner Address of the owner to query the balance of
     * @param nftCollection Address of the NFT collection
     * @param isIERC721WithUtility Whether the NFT collection implements IERC721WithUtility
     */
    function ownsNftWithUtility(address owner, address nftCollection, bool isIERC721WithUtility) public view returns (bool) {
        return balanceWithUtilityOf(owner, nftCollection, isIERC721WithUtility) > 0;
    }
}

Settings
{
  "libraries": {
    "contracts/util/IERC721WithUtilityHelpers.sol": {
      "IERC721WithUtilityHelpers": "0x2626658bb9186b22c798ea85a4623c2c1eba2901"
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 500000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"uint16[]","name":"supportedChains_","type":"uint16[]"},{"internalType":"address[]","name":"tokens_","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BridgingNotAllowed","type":"error"},{"inputs":[],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidArrayLength","type":"error"},{"inputs":[],"name":"InvalidChainId","type":"error"},{"inputs":[],"name":"InvalidLzChainId","type":"error"},{"inputs":[],"name":"InvalidPercent","type":"error"},{"inputs":[],"name":"NonTransferableToken","type":"error"},{"inputs":[],"name":"OperatorRoleRequired","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"chainId","type":"uint16"}],"name":"Bridge","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":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"bytes","name":"adapterParams","type":"bytes"}],"name":"bridge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"bridgingAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgingFeeDiscounted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"chainIdToLzChainId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBridgingAllowed","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"bool","name":"bridgingAllowed","type":"bool"}],"internalType":"struct SwapsicleBridge.BridgingAllowed[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"user","type":"address"}],"name":"getBridgingFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"useZro","type":"bool"},{"internalType":"bytes","name":"adapterParams","type":"bytes"}],"name":"getLzNativeFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNftCollections","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNonTransferableTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedChains","outputs":[{"internalType":"uint16[]","name":"","type":"uint16[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalBridgedToChain","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint256","name":"totalBridged","type":"uint256"}],"internalType":"struct SwapsicleBridge.TotalBridged[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"supportedChains","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"chainId","type":"uint16"}],"name":"supportsChain","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenOwnerFee","outputs":[{"internalType":"address","name":"feeAddress","type":"address"},{"internalType":"uint256","name":"percent","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalBridged","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"totalBridgedToChain","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":"address","name":"token","type":"address"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"bool","name":"allowed","type":"bool"}],"name":"updateBridgingAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"bridgingFee_","type":"uint256"},{"internalType":"uint256","name":"bridgingFeeDiscounted_","type":"uint256"}],"name":"updateBridgingFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16[]","name":"chainIds","type":"uint16[]"},{"internalType":"uint16[]","name":"lzChainIds","type":"uint16[]"}],"name":"updateChainMappings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"feeAddress_","type":"address"}],"name":"updateFeeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftAddress","type":"address"},{"internalType":"bool","name":"isIERC721WithUtility","type":"bool"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateNftCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateNonTransferableToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16[]","name":"supportedChains_","type":"uint16[]"}],"name":"updateSupportedChains","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint16","name":"chainId_","type":"uint16"},{"internalType":"uint256","name":"fee_","type":"uint256"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateTokenChainFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint16","name":"chainId_","type":"uint16"},{"internalType":"uint256","name":"feeDiscounted_","type":"uint256"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateTokenChainFeeDiscounted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint256","name":"fee_","type":"uint256"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateTokenFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint256","name":"feeDiscounted_","type":"uint256"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateTokenFeeDiscounted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"address","name":"tokenFeeAddress_","type":"address"},{"internalType":"uint256","name":"percent_","type":"uint256"}],"name":"updateTokenOwnerFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162004b1b38038062004b1b8339810160408190526200003491620005a4565b6200003f336200024f565b6001600255620000516000336200029f565b6200007d7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929336200029f565b81516200009290601a906020850190620003e4565b5060005b8151811015620001385760006001600160a01b0316828281518110620000c057620000c06200067d565b60200260200101516001600160a01b031603620000f05760405163d92e233d60e01b815260040160405180910390fd5b620001228282815181106200010957620001096200067d565b6020026020010151600f620002af60201b90919060201c565b50806200012f8162000693565b91505062000096565b5060005b81518110156200024657600062000155600f83620002cf565b905060005b84518110156200022e578481815181106200017957620001796200067d565b602002602001015161ffff16600003620001a657604051633d23e4d160e11b815260040160405180910390fd5b6001600160a01b0382166000908152601960205260408120601a8054600193919085908110620001da57620001da6200067d565b60009182526020808320601083040154600f9092166002026101000a90910461ffff1683528201929092526040019020805460ff191691151591909117905580620002258162000693565b9150506200015a565b505080806200023d9062000693565b9150506200013c565b505050620006bb565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b620002ab8282620002dd565b5050565b6000620002c6836001600160a01b03841662000365565b90505b92915050565b6000620002c68383620003b7565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16620002ab5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000818152600183016020526040812054620003ae57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620002c9565b506000620002c9565b6000826000018281548110620003d157620003d16200067d565b9060005260206000200154905092915050565b82805482825590600052602060002090600f01601090048101928215620004825791602002820160005b838211156200045057835183826101000a81548161ffff021916908361ffff16021790555092602001926002016020816001010492830192600103026200040e565b8015620004805782816101000a81549061ffff021916905560020160208160010104928301926001030262000450565b505b506200049092915062000494565b5090565b5b8082111562000490576000815560010162000495565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620004ec57620004ec620004ab565b604052919050565b60006001600160401b03821115620005105762000510620004ab565b5060051b60200190565b600082601f8301126200052c57600080fd5b81516020620005456200053f83620004f4565b620004c1565b82815260059290921b840181019181810190868411156200056557600080fd5b8286015b84811015620005995780516001600160a01b03811681146200058b5760008081fd5b835291830191830162000569565b509695505050505050565b60008060408385031215620005b857600080fd5b82516001600160401b0380821115620005d057600080fd5b818501915085601f830112620005e557600080fd5b81516020620005f86200053f83620004f4565b82815260059290921b840181019181810190898411156200061857600080fd5b948201945b838610156200064a57855161ffff811681146200063a5760008081fd5b825294820194908201906200061d565b918801519196509093505050808211156200066457600080fd5b5062000673858286016200051a565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b600060018201620006b457634e487b7160e01b600052601160045260246000fd5b5060010190565b61445080620006cb6000396000f3fe6080604052600436106102f25760003560e01c80637e67d5661161018f578063b3cbf396116100e1578063d547741f1161008a578063f2fde38b11610064578063f2fde38b14610949578063f5b541a614610969578063f7d283a11461099d57600080fd5b8063d547741f146108e9578063d7d9e64314610909578063ed177f231461092957600080fd5b8063bc19a268116100bb578063bc19a26814610876578063c1873c11146108a7578063c4bffe2b146108c757600080fd5b8063b3cbf396146107fe578063baa0ad731461081e578063bbcaac381461085657600080fd5b806391d1485411610143578063a64ba5ee1161011d578063a64ba5ee1461075b578063aa6ca808146107d4578063b1686ab6146107e957600080fd5b806391d14854146106d35780639e281a9814610726578063a217fddf1461074657600080fd5b80638a5d75c0116101745780638a5d75c0146106725780638da5cb5b14610688578063916dda2f146106b357600080fd5b80637e67d5661461063c57806389067c5e1461065c57600080fd5b80633d9fa93211610248578063548d496f116101fc5780636338bc11116101d65780636338bc11146105f4578063715018a61461061457806379110acf1461062957600080fd5b8063548d496f1461057f57806359c8aa46146105b257806360d7b506146105d257600080fd5b80634693ffbc1161022d5780634693ffbc146105045780634779f2541461052457806348bc17c61461055f57600080fd5b80633d9fa9321461049257806341275358146104b257600080fd5b8063174318c1116102aa5780632756cf93116102845780632756cf93146104325780632f2ff15d1461045257806336568abe1461047257600080fd5b8063174318c1146103bf5780631bc3c0b2146103df578063248a9ca31461040157600080fd5b8063082568d0116102db578063082568d01461034e5780630b93192b146103895780631036bbe2146103a957600080fd5b806301ffc9a7146102f75780630672e79b1461032c575b600080fd5b34801561030357600080fd5b50610317610312366004613923565b6109bf565b60405190151581526020015b60405180910390f35b34801561033857600080fd5b5061034c610347366004613995565b610a58565b005b34801561035a57600080fd5b5061037b6103693660046139d7565b60166020526000908152604090205481565b604051908152602001610323565b34801561039557600080fd5b5061034c6103a4366004613a0b565b610b24565b3480156103b557600080fd5b5061037b61271081565b3480156103cb57600080fd5b5061034c6103da366004613aa1565b610c42565b3480156103eb57600080fd5b506103f4610dfa565b6040516103239190613b0d565b34801561040d57600080fd5b5061037b61041c366004613b67565b6000908152600160208190526040909120015490565b34801561043e57600080fd5b5061031761044d366004613b80565b610e0b565b34801561045e57600080fd5b5061034c61046d366004613b9b565b610e7c565b34801561047e57600080fd5b5061034c61048d366004613b9b565b610ea2565b34801561049e57600080fd5b5061034c6104ad366004613995565b610f5a565b3480156104be57600080fd5b506005546104df9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610323565b34801561051057600080fd5b5061034c61051f366004613bcb565b61101b565b34801561053057600080fd5b5061031761053f366004613c0d565b601960209081526000928352604080842090915290825290205460ff1681565b34801561056b57600080fd5b5061034c61057a366004613a0b565b61108f565b34801561058b57600080fd5b5061059f61059a366004613b67565b6111a0565b60405161ffff9091168152602001610323565b3480156105be57600080fd5b5061037b6105cd366004613c84565b6111d8565b3480156105de57600080fd5b506105e761129b565b6040516103239190613d1a565b34801561060057600080fd5b5061034c61060f366004613d8d565b6114c4565b34801561062057600080fd5b5061034c61166b565b61034c610637366004613dcb565b61167f565b34801561064857600080fd5b5061034c610657366004613e4e565b611c4b565b34801561066857600080fd5b5061037b60035481565b34801561067e57600080fd5b5061037b60045481565b34801561069457600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166104df565b3480156106bf57600080fd5b5061034c6106ce366004613e7e565b611cd0565b3480156106df57600080fd5b506103176106ee366004613b9b565b600091825260016020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561073257600080fd5b5061034c610741366004613eac565b611d41565b34801561075257600080fd5b5061037b600081565b34801561076757600080fd5b506107a86107763660046139d7565b6006602052600090815260409020805460019091015473ffffffffffffffffffffffffffffffffffffffff9091169082565b6040805173ffffffffffffffffffffffffffffffffffffffff9093168352602083019190915201610323565b3480156107e057600080fd5b506103f4611e6f565b3480156107f557600080fd5b506103f4611e7b565b34801561080a57600080fd5b5061034c610819366004613e7e565b611e87565b34801561082a57600080fd5b5061037b610839366004613c0d565b601760209081526000928352604080842090915290825290205481565b34801561086257600080fd5b5061034c6108713660046139d7565b612011565b34801561088257600080fd5b5061059f610891366004613b80565b60186020526000908152604090205461ffff1681565b3480156108b357600080fd5b5061037b6108c2366004613ed8565b612060565b3480156108d357600080fd5b506108dc6122d3565b6040516103239190613f16565b3480156108f557600080fd5b5061034c610904366004613b9b565b612353565b34801561091557600080fd5b5061034c610924366004613f52565b612379565b34801561093557600080fd5b5061034c610944366004613f93565b612580565b34801561095557600080fd5b5061034c6109643660046139d7565b612593565b34801561097557600080fd5b5061037b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b3480156109a957600080fd5b506109b261264a565b6040516103239190613fb5565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610a5257507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610ac0576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115610afc576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015610b1457610b0e6007848461286a565b50505050565b610b0e600784612895565b505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610b8c576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115610bc8576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015610c085773ffffffffffffffffffffffffffffffffffffffff84166000908152600e60205260409020610c029061ffff8516846128b7565b50610b0e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600e60205260409020610c3b9061ffff85166128c4565b5050505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610caa576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828114610ce3576040517f9d89020a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b83811015610c3b57848482818110610d0057610d0061401d565b9050602002016020810190610d159190613b80565b61ffff16600003610d52576040517f7a47c9a200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828282818110610d6457610d6461401d565b9050602002016020810190610d799190613b80565b60186000878785818110610d8f57610d8f61401d565b9050602002016020810190610da49190613b80565b61ffff9081168252602082019290925260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000169290911691909117905580610df28161407b565b915050610ce6565b6060610e0660116128d0565b905090565b6000805b601a54811015610e73578261ffff16601a8281548110610e3157610e3161401d565b60009182526020909120601082040154600f9091166002026101000a900461ffff1603610e615750600192915050565b80610e6b8161407b565b915050610e0f565b50600092915050565b60008281526001602081905260409091200154610e98816128dd565b610b1f83836128e7565b73ffffffffffffffffffffffffffffffffffffffff81163314610f4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610f5682826129a6565b5050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610fc2576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115610ffe576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561101057610b0e600a848461286a565b610b0e600a84612895565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611083576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b1f601a8383613861565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff166110f7576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115611133576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561116d5773ffffffffffffffffffffffffffffffffffffffff84166000908152600d60205260409020610c029061ffff8516846128b7565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600d60205260409020610c3b9061ffff85166128c4565b601a81815481106111b057600080fd5b9060005260206000209060109182820401919006600202915054906101000a900461ffff1681565b6000806111e58988612a61565b6040517f365260b400000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff898116916000918c169063365260b49061124b90869086908d908d908d908d906004016140b3565b6040805180830381865afa158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b9190614122565b509b9a5050505050505050505050565b606060006112a9600f612b72565b601a5490915060006112bb8284614146565b67ffffffffffffffff8111156112d3576112d361415d565b60405190808252806020026020018201604052801561133c57816020015b60408051606081018252600080825260208083018290529282015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092019101816112f15790505b5090506000805b61134d600f612b72565b8110156114ba576000611361600f83612b7c565b905060005b858110156114a55760405180606001604052808373ffffffffffffffffffffffffffffffffffffffff168152602001601a83815481106113a8576113a861401d565b90600052602060002090601091828204019190066002029054906101000a900461ffff1661ffff168152602001601760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000601a85815481106114295761142961401d565b90600052602060002090601091828204019190066002029054906101000a900461ffff1661ffff1661ffff168152602001908152602001600020548152508585815181106114795761147961401d565b6020026020010181905250838061148f9061407b565b945050808061149d9061407b565b915050611366565b505080806114b29061407b565b915050611343565b5090949350505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff1661152c576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316611579576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61158282610e0b565b6115b8576040517f7a47c9a200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316611605576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff909216600090815260196020908152604080832061ffff90941683529290522080549115157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909216919091179055565b611673612b88565b61167d6000612c09565b565b611687612c7e565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260196020908152604080832061ffff8716845290915290205460ff166116f5576040517f3392a5ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006117018685612a61565b90508660000361173d576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a08231000000000000000000000000000000000000000000000000000000008152336004820152879073ffffffffffffffffffffffffffffffffffffffff8816906370a0823190602401602060405180830381865afa1580156117a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117cd919061418c565b1015611805576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152336004820152306024820152879073ffffffffffffffffffffffffffffffffffffffff88169063dd62ed3e90604401602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b919061418c565b10156118d3576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6118de601187612cef565b8015611900575073ffffffffffffffffffffffffffffffffffffffff85163314155b15611937576040517f30d4e75d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61195973ffffffffffffffffffffffffffffffffffffffff871633308a612d1e565b6000611966878633612060565b9050878115611a5e57600061271061197e848c614146565b61198891906141a5565b905061199481836141e0565b73ffffffffffffffffffffffffffffffffffffffff808b16600090815260066020908152604091829020825180840190935280549093168083526001909301549082015291935015611a345760006127108260200151846119f59190614146565b6119ff91906141a5565b9050611a0b81846141e0565b8251909350611a329073ffffffffffffffffffffffffffffffffffffffff8d169083612dfa565b505b600554611a5b9073ffffffffffffffffffffffffffffffffffffffff8c8116911684612dfa565b50505b8773ffffffffffffffffffffffffffffffffffffffff1663695ef6bf343086611a9a8c73ffffffffffffffffffffffffffffffffffffffff1690565b6040805160608101825233815260006020808301919091528251601f8e0182900482028101820184528d81528a938301918f908f908190840183828082843760009201919091525050509152506040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b168152611b24959493929190600401614261565b6000604051808303818588803b158015611b3d57600080fd5b505af1158015611b51573d6000803e3d6000fd5b50505073ffffffffffffffffffffffffffffffffffffffff8a1660009081526016602052604081208054859450909250611b8c9084906142d6565b909155505073ffffffffffffffffffffffffffffffffffffffff8816600090815260176020908152604080832061ffff8a16845290915281208054839290611bd59084906142d6565b90915550506040805173ffffffffffffffffffffffffffffffffffffffff89811682526020820184905261ffff891692908b169133917ff2581378aa3050d401b78b3e531c7c4011c0ad46b8901efd9f068e35f741e668910160405180910390a4505050611c436001600255565b505050505050565b611c53612b88565b73ffffffffffffffffffffffffffffffffffffffff8316611ca0576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015611cc557610b0e8383611cb6576000611cb9565b60015b6013919060ff1661286a565b610b0e601384612895565b611cd8612b88565b73ffffffffffffffffffffffffffffffffffffffff8216611d25576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015611d3657610b1f601183612e50565b610b1f601183612e72565b611d49612b88565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015611db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dda919061418c565b9050801580611de857508082115b15611e1f576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8115611e2b5781611e2d565b805b9150610b1f611e5160005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff85169084612dfa565b6060610e06600f6128d0565b6060610e066013612e94565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611eef576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216611f3c576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015611f4d57610b1f600f83612e50565b611f58600f83612e72565b5060005b601a54811015610b1f5773ffffffffffffffffffffffffffffffffffffffff83166000908152601960205260408120601a805483919085908110611fa257611fa261401d565b60009182526020808320601083040154600f9092166002026101000a90910461ffff168352820192909252604001902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055806120098161407b565b915050611f5c565b612019612b88565b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60055460009073ffffffffffffffffffffffffffffffffffffffff16612088575060006122cc565b6000805b6120966013612ea1565b81101561218f576000806120ab601384612eac565b6040517fd171401800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808a1660048301528316602482015281151560448201529193509150600090732626658bb9186b22c798ea85a4623c2c1eba29019063d171401890606401602060405180830381865af4158015612141573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216591906142e9565b90508015612179576001945050505061218f565b50505080806121879061407b565b91505061208c565b50600061219d600787612eca565b6121a9576003546121b4565b6121b4600787612eec565b905060006121c3600a88612eca565b6121cf576004546121da565b6121da600a88612eec565b73ffffffffffffffffffffffffffffffffffffffff88166000908152600d602052604090209091506122109061ffff8816612f0e565b1561224b5773ffffffffffffffffffffffffffffffffffffffff87166000908152600d602052604090206122489061ffff8816612f1a565b91505b73ffffffffffffffffffffffffffffffffffffffff87166000908152600e6020526040902061227e9061ffff8816612f0e565b156122b95773ffffffffffffffffffffffffffffffffffffffff87166000908152600e602052604090206122b69061ffff8816612f1a565b90505b826122c457816122c6565b805b93505050505b9392505050565b6060601a80548060200260200160405190810160405280929190818152602001828054801561234957602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116123105790505b5050505050905090565b6000828152600160208190526040909120015461236f816128dd565b610b1f83836129a6565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff166123e1576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831661242e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821661247b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127108111156124b7576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561252e5760408051808201825273ffffffffffffffffffffffffffffffffffffffff93841681526020808201938452948416600090815260069095529320925183547fffffffffffffffffffffffff000000000000000000000000000000000000000016921691909117825551600190910155565b505073ffffffffffffffffffffffffffffffffffffffff16600090815260066020526040812080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010155565b612588612b88565b600391909155600455565b61259b612b88565b73ffffffffffffffffffffffffffffffffffffffff811661263e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610f43565b61264781612c09565b50565b60606000612658600f612b72565b601a546126659190614146565b67ffffffffffffffff81111561267d5761267d61415d565b6040519080825280602002602001820160405280156126e657816020015b60408051606081018252600080825260208083018290529282015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191018161269b5790505b5090506000805b6126f7600f612b72565b81101561286257600061270b600f83612b7c565b905060005b601a5481101561284d5760405180606001604052808373ffffffffffffffffffffffffffffffffffffffff168152602001601a83815481106127545761275461401d565b90600052602060002090601091828204019190066002029054906101000a900461ffff1661ffff168152602001601960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000601a85815481106127d5576127d561401d565b60009182526020808320601083040154600f9092166002026101000a90910461ffff16835282019290925260400190205460ff161515905285518690869081106128215761282161401d565b602002602001018190525083806128379061407b565b94505080806128459061407b565b915050612710565b5050808061285a9061407b565b9150506126ed565b509092915050565b600061288d8473ffffffffffffffffffffffffffffffffffffffff851684612f26565b949350505050565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff8416612f43565b600061288d848484612f26565b60006122cc8383612f43565b606060006122cc83612f60565b6126478133612fbc565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610f5657600082815260016020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616808652925280842080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610f5657600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061ffff82161580612a7a5750612a7882610e0b565b155b15612ab1576040517f7a47c9a200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260196020908152604080832061ffff8616845290915290205460ff16612b1f576040517f3392a5ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5061ffff80821660009081526018602052604081205490911690819003610a52576040517fad37f3b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a52825490565b60006122cc8383613076565b60005473ffffffffffffffffffffffffffffffffffffffff16331461167d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f43565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6002805403612ce9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f43565b60028055565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260018301602052604081205415156122cc565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052610b0e9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526130a0565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610b1f9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401612d78565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff84166131af565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff84166131fe565b606060006122cc836132f1565b6000610a52826132fc565b6000808080612ebb8686613307565b909450925050505b9250929050565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff8416613332565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff841661333e565b60006122cc8383613332565b60006122cc838361333e565b6000828152600284016020526040812082905561288d84846133c8565b600081815260028301602052604081208190556122cc83836133d4565b606081600001805480602002602001604051908101604052809291908181526020018280548015612fb057602002820191906000526020600020905b815481526020019060010190808311612f9c575b50505050509050919050565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610f5657612ffc816133e0565b6130078360206133ff565b604051602001613018929190614306565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610f4391600401614387565b600082600001828154811061308d5761308d61401d565b9060005260206000200154905092915050565b6000613102826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166136429092919063ffffffff16565b905080516000148061312357508080602001905181019061312391906142e9565b610b1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610f43565b60008181526001830160205260408120546131f657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a52565b506000610a52565b600081815260018301602052604081205480156132e75760006132226001836141e0565b8554909150600090613236906001906141e0565b905081811461329b5760008660000182815481106132565761325661401d565b90600052602060002001549050808760000184815481106132795761327961401d565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806132ac576132ac61439a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a52565b6000915050610a52565b6060610a52826128d0565b6000610a5282612b72565b600080806133158585612b7c565b600081815260029690960160205260409095205494959350505050565b60006122cc8383613651565b60008181526002830160205260408120548015158061336257506133628484613332565b6122cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b657900006044820152606401610f43565b60006122cc83836131af565b60006122cc83836131fe565b6060610a5273ffffffffffffffffffffffffffffffffffffffff831660145b6060600061340e836002614146565b6134199060026142d6565b67ffffffffffffffff8111156134315761343161415d565b6040519080825280601f01601f19166020018201604052801561345b576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106134925761349261401d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106134f5576134f561401d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613531846002614146565b61353c9060016142d6565b90505b60018111156135d9577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061357d5761357d61401d565b1a60f81b8282815181106135935761359361401d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936135d2816143c9565b905061353f565b5083156122cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610f43565b606061288d8484600085613669565b600081815260018301602052604081205415156122cc565b6060824710156136fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610f43565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161372491906143fe565b60006040518083038185875af1925050503d8060008114613761576040519150601f19603f3d011682016040523d82523d6000602084013e613766565b606091505b509150915061377787838387613782565b979650505050505050565b606083156138185782516000036138115773ffffffffffffffffffffffffffffffffffffffff85163b613811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f43565b508161288d565b61288d838381511561382d5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f439190614387565b82805482825590600052602060002090600f016010900481019282156138fe5791602002820160005b838211156138ce57833561ffff1683826101000a81548161ffff021916908361ffff160217905550926020019260020160208160010104928301926001030261388a565b80156138fc5782816101000a81549061ffff02191690556002016020816001010492830192600103026138ce565b505b5061390a92915061390e565b5090565b5b8082111561390a576000815560010161390f565b60006020828403121561393557600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146122cc57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461264757600080fd5b801515811461264757600080fd5b6000806000606084860312156139aa57600080fd5b83356139b581613965565b92506020840135915060408401356139cc81613987565b809150509250925092565b6000602082840312156139e957600080fd5b81356122cc81613965565b803561ffff81168114613a0657600080fd5b919050565b60008060008060808587031215613a2157600080fd5b8435613a2c81613965565b9350613a3a602086016139f4565b9250604085013591506060850135613a5181613987565b939692955090935050565b60008083601f840112613a6e57600080fd5b50813567ffffffffffffffff811115613a8657600080fd5b6020830191508360208260051b8501011115612ec357600080fd5b60008060008060408587031215613ab757600080fd5b843567ffffffffffffffff80821115613acf57600080fd5b613adb88838901613a5c565b90965094506020870135915080821115613af457600080fd5b50613b0187828801613a5c565b95989497509550505050565b6020808252825182820181905260009190848201906040850190845b81811015613b5b57835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101613b29565b50909695505050505050565b600060208284031215613b7957600080fd5b5035919050565b600060208284031215613b9257600080fd5b6122cc826139f4565b60008060408385031215613bae57600080fd5b823591506020830135613bc081613965565b809150509250929050565b60008060208385031215613bde57600080fd5b823567ffffffffffffffff811115613bf557600080fd5b613c0185828601613a5c565b90969095509350505050565b60008060408385031215613c2057600080fd5b8235613c2b81613965565b9150613c39602084016139f4565b90509250929050565b60008083601f840112613c5457600080fd5b50813567ffffffffffffffff811115613c6c57600080fd5b602083019150836020828501011115612ec357600080fd5b600080600080600080600060c0888a031215613c9f57600080fd5b8735613caa81613965565b96506020880135613cba81613965565b9550613cc8604089016139f4565b9450606088013593506080880135613cdf81613987565b925060a088013567ffffffffffffffff811115613cfb57600080fd5b613d078a828b01613c42565b989b979a50959850939692959293505050565b602080825282518282018190526000919060409081850190868401855b82811015613d80578151805173ffffffffffffffffffffffffffffffffffffffff1685528681015161ffff16878601528501518585015260609093019290850190600101613d37565b5091979650505050505050565b600080600060608486031215613da257600080fd5b8335613dad81613965565b9250613dbb602085016139f4565b915060408401356139cc81613987565b60008060008060008060a08789031215613de457600080fd5b863595506020870135613df681613965565b94506040870135613e0681613965565b9350613e14606088016139f4565b9250608087013567ffffffffffffffff811115613e3057600080fd5b613e3c89828a01613c42565b979a9699509497509295939492505050565b600080600060608486031215613e6357600080fd5b8335613e6e81613965565b92506020840135613dbb81613987565b60008060408385031215613e9157600080fd5b8235613e9c81613965565b91506020830135613bc081613987565b60008060408385031215613ebf57600080fd5b8235613eca81613965565b946020939093013593505050565b600080600060608486031215613eed57600080fd5b8335613ef881613965565b9250613f06602085016139f4565b915060408401356139cc81613965565b6020808252825182820181905260009190848201906040850190845b81811015613b5b57835161ffff1683529284019291840191600101613f32565b600080600060608486031215613f6757600080fd5b8335613f7281613965565b92506020840135613f8281613965565b929592945050506040919091013590565b60008060408385031215613fa657600080fd5b50508035926020909101359150565b602080825282518282018190526000919060409081850190868401855b82811015613d80578151805173ffffffffffffffffffffffffffffffffffffffff1685528681015161ffff168786015285015115158585015260609093019290850190600101613fd2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036140ac576140ac61404c565b5060010190565b61ffff87168152856020820152846040820152831515606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b6000806040838503121561413557600080fd5b505080516020909101519092909150565b8082028115828204841417610a5257610a5261404c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561419e57600080fd5b5051919050565b6000826141db577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115610a5257610a5261404c565b60005b8381101561420e5781810151838201526020016141f6565b50506000910152565b6000815180845261422f8160208601602086016141f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600073ffffffffffffffffffffffffffffffffffffffff808816835261ffff8716602084015285604084015284606084015260a060808401528084511660a08401528060208501511660c0840152506040830151606060e08401526142ca610100840182614217565b98975050505050505050565b80820180821115610a5257610a5261404c565b6000602082840312156142fb57600080fd5b81516122cc81613987565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161433e8160178501602088016141f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161437b8160288401602088016141f3565b01602801949350505050565b6020815260006122cc6020830184614217565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000816143d8576143d861404c565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b600082516144108184602087016141f3565b919091019291505056fea264697066735822122011724d934fa858b5104c21b02f0d76b0c5970ebec5a72efeda31db09a0ef983c64736f6c63430008130033000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000008309bc8bb43fb54db02da7d8bf87192355532829000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e3

Deployed Bytecode

0x6080604052600436106102f25760003560e01c80637e67d5661161018f578063b3cbf396116100e1578063d547741f1161008a578063f2fde38b11610064578063f2fde38b14610949578063f5b541a614610969578063f7d283a11461099d57600080fd5b8063d547741f146108e9578063d7d9e64314610909578063ed177f231461092957600080fd5b8063bc19a268116100bb578063bc19a26814610876578063c1873c11146108a7578063c4bffe2b146108c757600080fd5b8063b3cbf396146107fe578063baa0ad731461081e578063bbcaac381461085657600080fd5b806391d1485411610143578063a64ba5ee1161011d578063a64ba5ee1461075b578063aa6ca808146107d4578063b1686ab6146107e957600080fd5b806391d14854146106d35780639e281a9814610726578063a217fddf1461074657600080fd5b80638a5d75c0116101745780638a5d75c0146106725780638da5cb5b14610688578063916dda2f146106b357600080fd5b80637e67d5661461063c57806389067c5e1461065c57600080fd5b80633d9fa93211610248578063548d496f116101fc5780636338bc11116101d65780636338bc11146105f4578063715018a61461061457806379110acf1461062957600080fd5b8063548d496f1461057f57806359c8aa46146105b257806360d7b506146105d257600080fd5b80634693ffbc1161022d5780634693ffbc146105045780634779f2541461052457806348bc17c61461055f57600080fd5b80633d9fa9321461049257806341275358146104b257600080fd5b8063174318c1116102aa5780632756cf93116102845780632756cf93146104325780632f2ff15d1461045257806336568abe1461047257600080fd5b8063174318c1146103bf5780631bc3c0b2146103df578063248a9ca31461040157600080fd5b8063082568d0116102db578063082568d01461034e5780630b93192b146103895780631036bbe2146103a957600080fd5b806301ffc9a7146102f75780630672e79b1461032c575b600080fd5b34801561030357600080fd5b50610317610312366004613923565b6109bf565b60405190151581526020015b60405180910390f35b34801561033857600080fd5b5061034c610347366004613995565b610a58565b005b34801561035a57600080fd5b5061037b6103693660046139d7565b60166020526000908152604090205481565b604051908152602001610323565b34801561039557600080fd5b5061034c6103a4366004613a0b565b610b24565b3480156103b557600080fd5b5061037b61271081565b3480156103cb57600080fd5b5061034c6103da366004613aa1565b610c42565b3480156103eb57600080fd5b506103f4610dfa565b6040516103239190613b0d565b34801561040d57600080fd5b5061037b61041c366004613b67565b6000908152600160208190526040909120015490565b34801561043e57600080fd5b5061031761044d366004613b80565b610e0b565b34801561045e57600080fd5b5061034c61046d366004613b9b565b610e7c565b34801561047e57600080fd5b5061034c61048d366004613b9b565b610ea2565b34801561049e57600080fd5b5061034c6104ad366004613995565b610f5a565b3480156104be57600080fd5b506005546104df9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610323565b34801561051057600080fd5b5061034c61051f366004613bcb565b61101b565b34801561053057600080fd5b5061031761053f366004613c0d565b601960209081526000928352604080842090915290825290205460ff1681565b34801561056b57600080fd5b5061034c61057a366004613a0b565b61108f565b34801561058b57600080fd5b5061059f61059a366004613b67565b6111a0565b60405161ffff9091168152602001610323565b3480156105be57600080fd5b5061037b6105cd366004613c84565b6111d8565b3480156105de57600080fd5b506105e761129b565b6040516103239190613d1a565b34801561060057600080fd5b5061034c61060f366004613d8d565b6114c4565b34801561062057600080fd5b5061034c61166b565b61034c610637366004613dcb565b61167f565b34801561064857600080fd5b5061034c610657366004613e4e565b611c4b565b34801561066857600080fd5b5061037b60035481565b34801561067e57600080fd5b5061037b60045481565b34801561069457600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166104df565b3480156106bf57600080fd5b5061034c6106ce366004613e7e565b611cd0565b3480156106df57600080fd5b506103176106ee366004613b9b565b600091825260016020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561073257600080fd5b5061034c610741366004613eac565b611d41565b34801561075257600080fd5b5061037b600081565b34801561076757600080fd5b506107a86107763660046139d7565b6006602052600090815260409020805460019091015473ffffffffffffffffffffffffffffffffffffffff9091169082565b6040805173ffffffffffffffffffffffffffffffffffffffff9093168352602083019190915201610323565b3480156107e057600080fd5b506103f4611e6f565b3480156107f557600080fd5b506103f4611e7b565b34801561080a57600080fd5b5061034c610819366004613e7e565b611e87565b34801561082a57600080fd5b5061037b610839366004613c0d565b601760209081526000928352604080842090915290825290205481565b34801561086257600080fd5b5061034c6108713660046139d7565b612011565b34801561088257600080fd5b5061059f610891366004613b80565b60186020526000908152604090205461ffff1681565b3480156108b357600080fd5b5061037b6108c2366004613ed8565b612060565b3480156108d357600080fd5b506108dc6122d3565b6040516103239190613f16565b3480156108f557600080fd5b5061034c610904366004613b9b565b612353565b34801561091557600080fd5b5061034c610924366004613f52565b612379565b34801561093557600080fd5b5061034c610944366004613f93565b612580565b34801561095557600080fd5b5061034c6109643660046139d7565b612593565b34801561097557600080fd5b5061037b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b3480156109a957600080fd5b506109b261264a565b6040516103239190613fb5565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610a5257507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610ac0576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115610afc576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015610b1457610b0e6007848461286a565b50505050565b610b0e600784612895565b505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610b8c576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115610bc8576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015610c085773ffffffffffffffffffffffffffffffffffffffff84166000908152600e60205260409020610c029061ffff8516846128b7565b50610b0e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600e60205260409020610c3b9061ffff85166128c4565b5050505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610caa576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828114610ce3576040517f9d89020a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b83811015610c3b57848482818110610d0057610d0061401d565b9050602002016020810190610d159190613b80565b61ffff16600003610d52576040517f7a47c9a200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828282818110610d6457610d6461401d565b9050602002016020810190610d799190613b80565b60186000878785818110610d8f57610d8f61401d565b9050602002016020810190610da49190613b80565b61ffff9081168252602082019290925260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000169290911691909117905580610df28161407b565b915050610ce6565b6060610e0660116128d0565b905090565b6000805b601a54811015610e73578261ffff16601a8281548110610e3157610e3161401d565b60009182526020909120601082040154600f9091166002026101000a900461ffff1603610e615750600192915050565b80610e6b8161407b565b915050610e0f565b50600092915050565b60008281526001602081905260409091200154610e98816128dd565b610b1f83836128e7565b73ffffffffffffffffffffffffffffffffffffffff81163314610f4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610f5682826129a6565b5050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16610fc2576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115610ffe576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561101057610b0e600a848461286a565b610b0e600a84612895565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611083576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b1f601a8383613861565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff166110f7576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710821115611133576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561116d5773ffffffffffffffffffffffffffffffffffffffff84166000908152600d60205260409020610c029061ffff8516846128b7565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600d60205260409020610c3b9061ffff85166128c4565b601a81815481106111b057600080fd5b9060005260206000209060109182820401919006600202915054906101000a900461ffff1681565b6000806111e58988612a61565b6040517f365260b400000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff898116916000918c169063365260b49061124b90869086908d908d908d908d906004016140b3565b6040805180830381865afa158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b9190614122565b509b9a5050505050505050505050565b606060006112a9600f612b72565b601a5490915060006112bb8284614146565b67ffffffffffffffff8111156112d3576112d361415d565b60405190808252806020026020018201604052801561133c57816020015b60408051606081018252600080825260208083018290529282015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092019101816112f15790505b5090506000805b61134d600f612b72565b8110156114ba576000611361600f83612b7c565b905060005b858110156114a55760405180606001604052808373ffffffffffffffffffffffffffffffffffffffff168152602001601a83815481106113a8576113a861401d565b90600052602060002090601091828204019190066002029054906101000a900461ffff1661ffff168152602001601760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000601a85815481106114295761142961401d565b90600052602060002090601091828204019190066002029054906101000a900461ffff1661ffff1661ffff168152602001908152602001600020548152508585815181106114795761147961401d565b6020026020010181905250838061148f9061407b565b945050808061149d9061407b565b915050611366565b505080806114b29061407b565b915050611343565b5090949350505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff1661152c576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316611579576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61158282610e0b565b6115b8576040517f7a47c9a200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316611605576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff909216600090815260196020908152604080832061ffff90941683529290522080549115157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909216919091179055565b611673612b88565b61167d6000612c09565b565b611687612c7e565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260196020908152604080832061ffff8716845290915290205460ff166116f5576040517f3392a5ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006117018685612a61565b90508660000361173d576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a08231000000000000000000000000000000000000000000000000000000008152336004820152879073ffffffffffffffffffffffffffffffffffffffff8816906370a0823190602401602060405180830381865afa1580156117a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117cd919061418c565b1015611805576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152336004820152306024820152879073ffffffffffffffffffffffffffffffffffffffff88169063dd62ed3e90604401602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b919061418c565b10156118d3576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6118de601187612cef565b8015611900575073ffffffffffffffffffffffffffffffffffffffff85163314155b15611937576040517f30d4e75d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61195973ffffffffffffffffffffffffffffffffffffffff871633308a612d1e565b6000611966878633612060565b9050878115611a5e57600061271061197e848c614146565b61198891906141a5565b905061199481836141e0565b73ffffffffffffffffffffffffffffffffffffffff808b16600090815260066020908152604091829020825180840190935280549093168083526001909301549082015291935015611a345760006127108260200151846119f59190614146565b6119ff91906141a5565b9050611a0b81846141e0565b8251909350611a329073ffffffffffffffffffffffffffffffffffffffff8d169083612dfa565b505b600554611a5b9073ffffffffffffffffffffffffffffffffffffffff8c8116911684612dfa565b50505b8773ffffffffffffffffffffffffffffffffffffffff1663695ef6bf343086611a9a8c73ffffffffffffffffffffffffffffffffffffffff1690565b6040805160608101825233815260006020808301919091528251601f8e0182900482028101820184528d81528a938301918f908f908190840183828082843760009201919091525050509152506040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b168152611b24959493929190600401614261565b6000604051808303818588803b158015611b3d57600080fd5b505af1158015611b51573d6000803e3d6000fd5b50505073ffffffffffffffffffffffffffffffffffffffff8a1660009081526016602052604081208054859450909250611b8c9084906142d6565b909155505073ffffffffffffffffffffffffffffffffffffffff8816600090815260176020908152604080832061ffff8a16845290915281208054839290611bd59084906142d6565b90915550506040805173ffffffffffffffffffffffffffffffffffffffff89811682526020820184905261ffff891692908b169133917ff2581378aa3050d401b78b3e531c7c4011c0ad46b8901efd9f068e35f741e668910160405180910390a4505050611c436001600255565b505050505050565b611c53612b88565b73ffffffffffffffffffffffffffffffffffffffff8316611ca0576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015611cc557610b0e8383611cb6576000611cb9565b60015b6013919060ff1661286a565b610b0e601384612895565b611cd8612b88565b73ffffffffffffffffffffffffffffffffffffffff8216611d25576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015611d3657610b1f601183612e50565b610b1f601183612e72565b611d49612b88565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015611db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dda919061418c565b9050801580611de857508082115b15611e1f576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8115611e2b5781611e2d565b805b9150610b1f611e5160005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff85169084612dfa565b6060610e06600f6128d0565b6060610e066013612e94565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611eef576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216611f3c576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015611f4d57610b1f600f83612e50565b611f58600f83612e72565b5060005b601a54811015610b1f5773ffffffffffffffffffffffffffffffffffffffff83166000908152601960205260408120601a805483919085908110611fa257611fa261401d565b60009182526020808320601083040154600f9092166002026101000a90910461ffff168352820192909252604001902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055806120098161407b565b915050611f5c565b612019612b88565b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60055460009073ffffffffffffffffffffffffffffffffffffffff16612088575060006122cc565b6000805b6120966013612ea1565b81101561218f576000806120ab601384612eac565b6040517fd171401800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808a1660048301528316602482015281151560448201529193509150600090732626658bb9186b22c798ea85a4623c2c1eba29019063d171401890606401602060405180830381865af4158015612141573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216591906142e9565b90508015612179576001945050505061218f565b50505080806121879061407b565b91505061208c565b50600061219d600787612eca565b6121a9576003546121b4565b6121b4600787612eec565b905060006121c3600a88612eca565b6121cf576004546121da565b6121da600a88612eec565b73ffffffffffffffffffffffffffffffffffffffff88166000908152600d602052604090209091506122109061ffff8816612f0e565b1561224b5773ffffffffffffffffffffffffffffffffffffffff87166000908152600d602052604090206122489061ffff8816612f1a565b91505b73ffffffffffffffffffffffffffffffffffffffff87166000908152600e6020526040902061227e9061ffff8816612f0e565b156122b95773ffffffffffffffffffffffffffffffffffffffff87166000908152600e602052604090206122b69061ffff8816612f1a565b90505b826122c457816122c6565b805b93505050505b9392505050565b6060601a80548060200260200160405190810160405280929190818152602001828054801561234957602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116123105790505b5050505050905090565b6000828152600160208190526040909120015461236f816128dd565b610b1f83836129a6565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff166123e1576040517f64d6181d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831661242e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821661247b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127108111156124b7576040517fb92e9c7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561252e5760408051808201825273ffffffffffffffffffffffffffffffffffffffff93841681526020808201938452948416600090815260069095529320925183547fffffffffffffffffffffffff000000000000000000000000000000000000000016921691909117825551600190910155565b505073ffffffffffffffffffffffffffffffffffffffff16600090815260066020526040812080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010155565b612588612b88565b600391909155600455565b61259b612b88565b73ffffffffffffffffffffffffffffffffffffffff811661263e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610f43565b61264781612c09565b50565b60606000612658600f612b72565b601a546126659190614146565b67ffffffffffffffff81111561267d5761267d61415d565b6040519080825280602002602001820160405280156126e657816020015b60408051606081018252600080825260208083018290529282015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191018161269b5790505b5090506000805b6126f7600f612b72565b81101561286257600061270b600f83612b7c565b905060005b601a5481101561284d5760405180606001604052808373ffffffffffffffffffffffffffffffffffffffff168152602001601a83815481106127545761275461401d565b90600052602060002090601091828204019190066002029054906101000a900461ffff1661ffff168152602001601960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000601a85815481106127d5576127d561401d565b60009182526020808320601083040154600f9092166002026101000a90910461ffff16835282019290925260400190205460ff161515905285518690869081106128215761282161401d565b602002602001018190525083806128379061407b565b94505080806128459061407b565b915050612710565b5050808061285a9061407b565b9150506126ed565b509092915050565b600061288d8473ffffffffffffffffffffffffffffffffffffffff851684612f26565b949350505050565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff8416612f43565b600061288d848484612f26565b60006122cc8383612f43565b606060006122cc83612f60565b6126478133612fbc565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610f5657600082815260016020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616808652925280842080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610f5657600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061ffff82161580612a7a5750612a7882610e0b565b155b15612ab1576040517f7a47c9a200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260196020908152604080832061ffff8616845290915290205460ff16612b1f576040517f3392a5ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5061ffff80821660009081526018602052604081205490911690819003610a52576040517fad37f3b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a52825490565b60006122cc8383613076565b60005473ffffffffffffffffffffffffffffffffffffffff16331461167d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f43565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6002805403612ce9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f43565b60028055565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260018301602052604081205415156122cc565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052610b0e9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526130a0565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610b1f9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401612d78565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff84166131af565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff84166131fe565b606060006122cc836132f1565b6000610a52826132fc565b6000808080612ebb8686613307565b909450925050505b9250929050565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff8416613332565b60006122cc8373ffffffffffffffffffffffffffffffffffffffff841661333e565b60006122cc8383613332565b60006122cc838361333e565b6000828152600284016020526040812082905561288d84846133c8565b600081815260028301602052604081208190556122cc83836133d4565b606081600001805480602002602001604051908101604052809291908181526020018280548015612fb057602002820191906000526020600020905b815481526020019060010190808311612f9c575b50505050509050919050565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610f5657612ffc816133e0565b6130078360206133ff565b604051602001613018929190614306565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610f4391600401614387565b600082600001828154811061308d5761308d61401d565b9060005260206000200154905092915050565b6000613102826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166136429092919063ffffffff16565b905080516000148061312357508080602001905181019061312391906142e9565b610b1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610f43565b60008181526001830160205260408120546131f657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a52565b506000610a52565b600081815260018301602052604081205480156132e75760006132226001836141e0565b8554909150600090613236906001906141e0565b905081811461329b5760008660000182815481106132565761325661401d565b90600052602060002001549050808760000184815481106132795761327961401d565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806132ac576132ac61439a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a52565b6000915050610a52565b6060610a52826128d0565b6000610a5282612b72565b600080806133158585612b7c565b600081815260029690960160205260409095205494959350505050565b60006122cc8383613651565b60008181526002830160205260408120548015158061336257506133628484613332565b6122cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b657900006044820152606401610f43565b60006122cc83836131af565b60006122cc83836131fe565b6060610a5273ffffffffffffffffffffffffffffffffffffffff831660145b6060600061340e836002614146565b6134199060026142d6565b67ffffffffffffffff8111156134315761343161415d565b6040519080825280601f01601f19166020018201604052801561345b576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106134925761349261401d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106134f5576134f561401d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613531846002614146565b61353c9060016142d6565b90505b60018111156135d9577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061357d5761357d61401d565b1a60f81b8282815181106135935761359361401d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936135d2816143c9565b905061353f565b5083156122cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610f43565b606061288d8484600085613669565b600081815260018301602052604081205415156122cc565b6060824710156136fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610f43565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161372491906143fe565b60006040518083038185875af1925050503d8060008114613761576040519150601f19603f3d011682016040523d82523d6000602084013e613766565b606091505b509150915061377787838387613782565b979650505050505050565b606083156138185782516000036138115773ffffffffffffffffffffffffffffffffffffffff85163b613811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f43565b508161288d565b61288d838381511561382d5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f439190614387565b82805482825590600052602060002090600f016010900481019282156138fe5791602002820160005b838211156138ce57833561ffff1683826101000a81548161ffff021916908361ffff160217905550926020019260020160208160010104928301926001030261388a565b80156138fc5782816101000a81549061ffff02191690556002016020816001010492830192600103026138ce565b505b5061390a92915061390e565b5090565b5b8082111561390a576000815560010161390f565b60006020828403121561393557600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146122cc57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461264757600080fd5b801515811461264757600080fd5b6000806000606084860312156139aa57600080fd5b83356139b581613965565b92506020840135915060408401356139cc81613987565b809150509250925092565b6000602082840312156139e957600080fd5b81356122cc81613965565b803561ffff81168114613a0657600080fd5b919050565b60008060008060808587031215613a2157600080fd5b8435613a2c81613965565b9350613a3a602086016139f4565b9250604085013591506060850135613a5181613987565b939692955090935050565b60008083601f840112613a6e57600080fd5b50813567ffffffffffffffff811115613a8657600080fd5b6020830191508360208260051b8501011115612ec357600080fd5b60008060008060408587031215613ab757600080fd5b843567ffffffffffffffff80821115613acf57600080fd5b613adb88838901613a5c565b90965094506020870135915080821115613af457600080fd5b50613b0187828801613a5c565b95989497509550505050565b6020808252825182820181905260009190848201906040850190845b81811015613b5b57835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101613b29565b50909695505050505050565b600060208284031215613b7957600080fd5b5035919050565b600060208284031215613b9257600080fd5b6122cc826139f4565b60008060408385031215613bae57600080fd5b823591506020830135613bc081613965565b809150509250929050565b60008060208385031215613bde57600080fd5b823567ffffffffffffffff811115613bf557600080fd5b613c0185828601613a5c565b90969095509350505050565b60008060408385031215613c2057600080fd5b8235613c2b81613965565b9150613c39602084016139f4565b90509250929050565b60008083601f840112613c5457600080fd5b50813567ffffffffffffffff811115613c6c57600080fd5b602083019150836020828501011115612ec357600080fd5b600080600080600080600060c0888a031215613c9f57600080fd5b8735613caa81613965565b96506020880135613cba81613965565b9550613cc8604089016139f4565b9450606088013593506080880135613cdf81613987565b925060a088013567ffffffffffffffff811115613cfb57600080fd5b613d078a828b01613c42565b989b979a50959850939692959293505050565b602080825282518282018190526000919060409081850190868401855b82811015613d80578151805173ffffffffffffffffffffffffffffffffffffffff1685528681015161ffff16878601528501518585015260609093019290850190600101613d37565b5091979650505050505050565b600080600060608486031215613da257600080fd5b8335613dad81613965565b9250613dbb602085016139f4565b915060408401356139cc81613987565b60008060008060008060a08789031215613de457600080fd5b863595506020870135613df681613965565b94506040870135613e0681613965565b9350613e14606088016139f4565b9250608087013567ffffffffffffffff811115613e3057600080fd5b613e3c89828a01613c42565b979a9699509497509295939492505050565b600080600060608486031215613e6357600080fd5b8335613e6e81613965565b92506020840135613dbb81613987565b60008060408385031215613e9157600080fd5b8235613e9c81613965565b91506020830135613bc081613987565b60008060408385031215613ebf57600080fd5b8235613eca81613965565b946020939093013593505050565b600080600060608486031215613eed57600080fd5b8335613ef881613965565b9250613f06602085016139f4565b915060408401356139cc81613965565b6020808252825182820181905260009190848201906040850190845b81811015613b5b57835161ffff1683529284019291840191600101613f32565b600080600060608486031215613f6757600080fd5b8335613f7281613965565b92506020840135613f8281613965565b929592945050506040919091013590565b60008060408385031215613fa657600080fd5b50508035926020909101359150565b602080825282518282018190526000919060409081850190868401855b82811015613d80578151805173ffffffffffffffffffffffffffffffffffffffff1685528681015161ffff168786015285015115158585015260609093019290850190600101613fd2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036140ac576140ac61404c565b5060010190565b61ffff87168152856020820152846040820152831515606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b6000806040838503121561413557600080fd5b505080516020909101519092909150565b8082028115828204841417610a5257610a5261404c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561419e57600080fd5b5051919050565b6000826141db577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115610a5257610a5261404c565b60005b8381101561420e5781810151838201526020016141f6565b50506000910152565b6000815180845261422f8160208601602086016141f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600073ffffffffffffffffffffffffffffffffffffffff808816835261ffff8716602084015285604084015284606084015260a060808401528084511660a08401528060208501511660c0840152506040830151606060e08401526142ca610100840182614217565b98975050505050505050565b80820180821115610a5257610a5261404c565b6000602082840312156142fb57600080fd5b81516122cc81613987565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161433e8160178501602088016141f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161437b8160288401602088016141f3565b01602801949350505050565b6020815260006122cc6020830184614217565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000816143d8576143d861404c565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b600082516144108184602087016141f3565b919091019291505056fea264697066735822122011724d934fa858b5104c21b02f0d76b0c5970ebec5a72efeda31db09a0ef983c64736f6c63430008130033

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

000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000008309bc8bb43fb54db02da7d8bf87192355532829000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e3

-----Decoded View---------------
Arg [0] : supportedChains_ (uint16[]): 40
Arg [1] : tokens_ (address[]): 0x8309Bc8BB43fB54dB02DA7d8bf87192355532829,0x005E16eccDFd3EA76E7B777A1bEb7b826E3AA7E3

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000028
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [5] : 0000000000000000000000008309bc8bb43fb54db02da7d8bf87192355532829
Arg [6] : 000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e3


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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