Sepolia Testnet

Contract

0xe1f5dd6bA03Cc5500081775827dfbf8DC29250E5
Source Code Source Code

Overview

ETH Balance

0 ETH

More Info

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Amount

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
UzuExchange

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";

import "../interfaces/IUzuExchange.sol";
import "../interfaces/IFundTransferProxy.sol";
import "../interfaces/INftTransferProxy.sol";
import "../access/AdminPool.sol";

contract UzuExchange is
  Initializable,
  ERC165Upgradeable,
  IUzuExchange,
  EIP712Upgradeable,
  ERC2771ContextUpgradeable,
  AdminPool,
  UUPSUpgradeable
{
  using ECDSAUpgradeable for bytes32;
  /**
   * @dev Store the processed orders. True if the order was processed.
   */
  mapping(uint256 => bool) internal _processedOrders;

  IFundTransferProxy public fundTransferProxy;
  INftTransferProxy public nftTransferProxy;

  /**
   * @dev constructor
   *
   * @param _trustedForwarder address
   */
  constructor(
    address _trustedForwarder
  ) ERC2771ContextUpgradeable(_trustedForwarder) {}

  /**
   * @dev initialize
   *
   * @param fundTransferProxy_ IFundTransferProxy
   * @param nftTransferProxy_ INftTransferProxy
   */
  function __UzuExchange_init(
    IFundTransferProxy fundTransferProxy_,
    INftTransferProxy nftTransferProxy_
  ) external initializer {
    __ERC165_init();
    __AdminPool_init();
    __EIP712_init("UzuExchange", "1.0");
    __UUPSUpgradeable_init();

    updateFundTransferProxy(fundTransferProxy_);
    updateNftTransferProxy(nftTransferProxy_);
  }

  /**
   * @dev See {UUPSUpgradeable._authorizeUpgrade()}
   *
   * @param _newImplementation address
   *
   * Requirements:
   * - onlyAdmin can call
   */
  function _authorizeUpgrade(
    address _newImplementation
  ) internal virtual override onlyAdmin {}

  /**
   * @dev See {IERC165Upgradeable-supportsInterface}.
   *
   * @param _interfaceId bytes4
   */
  function supportsInterface(
    bytes4 _interfaceId
  ) public view virtual override(ERC165Upgradeable) returns (bool) {
    return
      _interfaceId == type(IUzuExchange).interfaceId ||
      super.supportsInterface(_interfaceId);
  }

  /**
   * @dev Updates FundTransferProxy
   *
   * @param fundTransferProxy_ IFundTransferProxy
   */
  function updateFundTransferProxy(
    IFundTransferProxy fundTransferProxy_
  ) public onlyAdmin {
    require(
      IFundTransferProxy(fundTransferProxy_).supportsInterface(
        type(IFundTransferProxy).interfaceId
      ),
      "UzuExchange: invalid IFundTransferProxy"
    );

    require(
      fundTransferProxy != fundTransferProxy_,
      "UzuExchange: existing same FundTransferProxy"
    );

    emit FundTransferProxyUpdated(fundTransferProxy, fundTransferProxy_);

    fundTransferProxy = fundTransferProxy_;
  }

  /**
   * @dev Updates NftTransferProxy
   *
   * @param nftTransferProxy_ INftTransferProxy
   */
  function updateNftTransferProxy(
    INftTransferProxy nftTransferProxy_
  ) public onlyAdmin {
    require(
      INftTransferProxy(nftTransferProxy_).supportsInterface(
        type(INftTransferProxy).interfaceId
      ),
      "UzuExchange: invalid INftTransferProxy"
    );

    require(
      nftTransferProxy != nftTransferProxy_,
      "UzuExchange: existing same NftTransferProxy"
    );

    emit NftTransferProxyUpdated(nftTransferProxy, nftTransferProxy_);

    nftTransferProxy = nftTransferProxy_;
  }

  /**
   * @dev Check parameter for ProcessOrder
   *
   * @param order Domain.Order
   */
  function _checkParameterForProcessOrder(
    Domain.Order calldata order
  ) internal view {
    // Check OrderManagement
    uint256 orderId = order.orderId;
    require(orderId != 0, "UzuExchange: invalid order.orderId");

    require(!isOrderProcessed(orderId), "UzuExchange: order already process");

    uint256 orderCreatedAt = order.orderCreatedAt;
    require(
      orderCreatedAt > 0 && orderCreatedAt <= block.timestamp,
      "UzuExchange: invalid order.orderCreatedAt"
    );

    uint256 orderExpiresAt = order.orderExpiresAt;
    require(
      orderExpiresAt == 0 || orderExpiresAt > block.timestamp,
      "UzuExchange: invalid order.orderExpiresAt"
    );

    // make sure its a contract address
    require(
      order.collectionAddress.code.length > 0,
      "UzuExchange: invalid order.collectionAddress"
    );

    require(order.nftId != 0, "UzuExchange: invalid order.nftId");

    require(order.amount != 0, "UzuExchange: invalid order.amount");

    require(order.salePrice != 0, "UzuExchange: invalid order.salePrice");

    require(order.seller != address(0), "UzuExchange: invalid order.seller");
    require(
      order.paymentReceiver != address(0),
      "UzuExchange: invalid order.paymentReceiver"
    );
    require(order.buyer != address(0), "UzuExchange: invalid order.buyer");

    uint256 idx = 0;
    for (; idx < order.royalties.length; idx++) {
      Domain.Royalty memory royalty = order.royalties[idx];
      require(
        bytes(royalty.recipientType).length > 0,
        "UzuExchange: invalid royalty.recipientType"
      );
      require(
        royalty.recipientAddress != address(0),
        "UzuExchange: invalid royalty.recipientAddress"
      );
    }

    idx = 0;
    for (; idx < order.cruators.length; idx++) {
      Domain.Curator memory cruator = order.cruators[idx];
      require(
        cruator.curatorAddress != address(0),
        "UzuExchange: invalid cruator.curatorAddress"
      );
      require(
        bytes(cruator.curatorType).length > 0,
        "UzuExchange: invalid cruator.curatorType"
      );
    }
  }

  /**
   * @dev See {IUzuExchange-processOrder}
   */
  function processOrder(
    Domain.Order calldata order,
    bytes calldata adminSign,
    Domain.MintData calldata lazyMintData,
    bytes calldata lazyMintSign
  ) external payable virtual override {
    /*
     * CHECKS
     */
    // Ensure that the Order information is correct and valid.
    // Ensure that the same order is not processed yet.
    // Ensure that the order is not expired.
    _checkParameterForProcessOrder(order);

    // Ensure that the adminSig is valid.
    // Prepares ERC712 message hash of Order signature
    address recoverdAddress = _hashTypedDataV4(Domain._hashOrder(order))
      .recover(adminSign);
    require(isAdmin(recoverdAddress), "UzuExchange: invalid order signer");

    /*
     * EFFECTS
     */
    // Mark that the order is processed
    uint256 orderId = order.orderId;
    _processedOrders[orderId] = true;

    Domain.Payment memory buyerPayment = order.buyerPayment;

    // Deposit sales to UZU Vault
    // If pay in ETH: Ask FundTransferProxy to deposit ETH to UZU Vault
    // This must be = salePrice + totalRoyaltyPrice + comissionFeeToUzuVault
    if (msg.value > 0) {
      if (msg.value == buyerPayment.amount) {
        // Case 1 : When exact amount is sent as needed to buy
        fundTransferProxy.depositNativeTokenToVault{value: buyerPayment.amount}(
          _msgSender()
        );
      } else if (msg.value > buyerPayment.amount) {
        // Case 2 : When amount is sent greater than needed to buy
        fundTransferProxy.depositNativeTokenToVault{value: buyerPayment.amount}(
          _msgSender()
        );
        // Refund back the exceeding amount
        payable(_msgSender()).transfer(msg.value - buyerPayment.amount);
      } else {
        // Case 3 : Not enought native tokens are sent
        revert("UzuExchange: not enought native tokens are sent");
      }
    }
    // If pay in ERC20: Ask FundTransferProxy to transfer ERC20 token from Buyer to UZU Vault. (Only if the buyer pays the sales fee in Crypto)
    // This must be = salePrice + totalRoyaltyPrice + comissionFeeToUzuVault
    if (
      Domain.isCryptoCurrencyType(buyerPayment.currencyType) &&
      buyerPayment.tokenAddress != address(0)
    ) {
      fundTransferProxy.depositERC20ToVault(
        IERC20(buyerPayment.tokenAddress),
        buyerPayment.amount,
        order.buyer
      );
    }

    /*
     * INTERACTIONS
     */
    // Execute the sale price transfer to the Seller
    // (Only if the seller wants to receive the sales in Crypto)
    Domain.Payment memory sellerPayment = order.sellerPayment;
    if (Domain.isCryptoCurrencyType(sellerPayment.currencyType)) {
      if (sellerPayment.tokenAddress == address(0)) {
        // This is the case of NativeToken payment
        fundTransferProxy.transferNativeTokenFromVault(
          order.paymentReceiver,
          sellerPayment.amount
        );
      } else {
        // This is the case of ERC20 payment
        fundTransferProxy.transferERC20FromVault(
          IERC20(sellerPayment.tokenAddress),
          order.paymentReceiver,
          sellerPayment.amount
        );
      }
    }

    // Execute the Royalty distribution to the given recipients (Only if the recipient wants to receive Royalty in Crypto)
    // For EVERY Rolatly record, including Fiat payment, RoyaltyDistributed MUST be emitted. (to record an evidence on blockchain that the royalty has been paid.)
    processRoyalty(order);

    // Transfer NFT from the seller to the buyer.
    // If lazyMint, transferFromOrMint() on UZU-Shared-Collection.
    bool isLazyMint = (lazyMintData.nftId != 0);
    if (isLazyMint) {
      // Lazy mint
      nftTransferProxy.proxyNftTransfer(
        order.seller,
        order.buyer,
        order.amount,
        order.nftId,
        order.collectionAddress,
        order.nftKind,
        "",
        isLazyMint,
        lazyMintData,
        lazyMintSign
      );
    } else {
      // Normal transfer
      nftTransferProxy.proxyNftTransfer(
        order.seller,
        order.buyer,
        order.amount,
        order.nftId,
        order.collectionAddress,
        order.nftKind,
        "",
        isLazyMint,
        lazyMintData,
        lazyMintSign
      );
    }

    // Emit OrderProcessed event.
    emit OrderProcessed(
      orderId,
      order.collectionAddress,
      order.nftKind,
      order.nftId,
      order.amount,
      order.salePrice,
      order.seller,
      order.paymentReceiver,
      order.buyer,
      order.cruators,
      order.referenceMarketCommissionFee
    );

    emit OrderPaymentInfo(
      buyerPayment.currencyType,
      buyerPayment.currencySymbol,
      buyerPayment.tokenAddress,
      buyerPayment.amount,
      buyerPayment.decimals,
      buyerPayment.rate,
      sellerPayment.currencyType,
      sellerPayment.currencySymbol,
      sellerPayment.tokenAddress,
      sellerPayment.amount,
      sellerPayment.decimals,
      sellerPayment.rate
    );
  }

  /**
   * @dev [Internal] Process royalties
   *
   * @param order Domain.Order
   */
  function processRoyalty(Domain.Order calldata order) internal {
    address buyer = order.buyer;
    for (uint256 idx = 0; idx < order.royalties.length; idx++) {
      Domain.Royalty memory royalty = order.royalties[idx];
      Domain.Payment memory royaltyPayment = order.royalties[idx].payment;

      if (Domain.isCryptoCurrencyType(royaltyPayment.currencyType)) {
        if (royaltyPayment.tokenAddress == address(0)) {
          // This is the case of NativeToken payment
          fundTransferProxy.transferNativeTokenFromVault(
            royalty.recipientAddress,
            royaltyPayment.amount
          );
        } else {
          // This is the case of ERC20 payment
          fundTransferProxy.transferERC20FromVault(
            IERC20(royaltyPayment.tokenAddress),
            royalty.recipientAddress,
            royaltyPayment.amount
          );
        }
      }

      emit RoyaltyDistributed(
        royalty.recipientType,
        royalty.recipientAddress,
        buyer,
        royaltyPayment.currencyType,
        royaltyPayment.currencySymbol,
        royaltyPayment.tokenAddress,
        royaltyPayment.amount,
        royaltyPayment.decimals,
        royaltyPayment.rate,
        royalty.referenceRoyaltyFee
      );
    }
  }

  /**
   * @dev See {IUzuExchange-isOrderProcessed}
   */
  function isOrderProcessed(
    uint256 orderId
  ) public view virtual override returns (bool) {
    return _processedOrders[orderId];
  }
}

File 2 of 36 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

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

pragma solidity ^0.8.0;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)

pragma solidity ^0.8.9;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Context variant with ERC2771 support.
 */
abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable _trustedForwarder;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor(address trustedForwarder) {
        _trustedForwarder = trustedForwarder;
    }

    function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
        return forwarder == _trustedForwarder;
    }

    function _msgSender() internal view virtual override returns (address sender) {
        if (isTrustedForwarder(msg.sender)) {
            // The assembly code is more direct than the Solidity version using `abi.decode`.
            /// @solidity memory-safe-assembly
            assembly {
                sender := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            return super._msgSender();
        }
    }

    function _msgData() internal view virtual override returns (bytes calldata) {
        if (isTrustedForwarder(msg.sender)) {
            return msg.data[:msg.data.length - 20];
        } else {
            return super._msgData();
        }
    }

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

File 5 of 36 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @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) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

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

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

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

File 12 of 36 : draft-EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

// EIP-712 is Final as of 2022-08-11. This file is deprecated.

import "./EIP712Upgradeable.sol";

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

pragma solidity ^0.8.0;

import "../StringsUpgradeable.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSAUpgradeable {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

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

pragma solidity ^0.8.0;

import "./ECDSAUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 *
 * @custom:storage-size 52
 */
abstract contract EIP712Upgradeable is Initializable {
    /* solhint-disable var-name-mixedcase */
    bytes32 private _HASHED_NAME;
    bytes32 private _HASHED_VERSION;
    bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
        __EIP712_init_unchained(name, version);
    }

    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev The hash of the name parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712NameHash() internal virtual view returns (bytes32) {
        return _HASHED_NAME;
    }

    /**
     * @dev The hash of the version parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712VersionHash() internal virtual view returns (bytes32) {
        return _HASHED_VERSION;
    }

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

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

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

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

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract 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
// 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.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

// 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 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.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./math/Math.sol";

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

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

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

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

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

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

import "@openzeppelin/contracts-upgradeable/metatx/ERC2771ContextUpgradeable.sol";

abstract contract AdminPool is ERC2771ContextUpgradeable {
  event AdminAdded(address indexed adminAddress);
  event AdminRemoved(address indexed adminAddress);

  // Map of admin and their active state
  mapping(address => bool) internal _admin;

  function __AdminPool_init() internal onlyInitializing {
    // At the time of init use deployer as an Admin
    _addAdmin(_msgSender());
  }

  /**
   * @dev Add new admin[s]
   *
   * @param _newAdminList address[]
   */
  function addAdminBatch(
    address[] calldata _newAdminList
  ) public virtual onlyAdmin {
    for (uint256 idx = 0; idx < _newAdminList.length; idx++) {
      _addAdmin(_newAdminList[idx]);
    }
  }

  /**
   * @dev Add new admin
   *
   * @param _newAdmin address
   */
  function addAdmin(address _newAdmin) public virtual onlyAdmin {
    _addAdmin(_newAdmin);
  }

  /**
   * @dev [internal] Add new admin
   *
   * @param _newAdmin address
   */
  function _addAdmin(address _newAdmin) internal virtual {
    require(
      _newAdmin != address(0),
      "Admin:addAdmin newAdmin is the zero address"
    );

    _admin[_newAdmin] = true;
    emit AdminAdded(_newAdmin);
  }

  /**
   * @dev Removes an admin
   *
   * @param _adminToRemove address
   */
  function removeAdmin(address _adminToRemove) public virtual onlyAdmin {
    _removeAdmin(_adminToRemove);
  }

  /**
   * @dev [internal] Removes an admin
   *
   * @param _adminToRemove address
   */
  function _removeAdmin(address _adminToRemove) internal virtual {
    require(
      _admin[_adminToRemove],
      "Admin:removeAdmin trying to remove non existing Admin"
    );

    delete _admin[_adminToRemove];
    emit AdminRemoved(_adminToRemove);
  }

  /**
   * @dev Check is an address is admin
   *
   * @param _addressToCheck address
   */
  function isAdmin(address _addressToCheck) public view virtual returns (bool) {
    return _admin[_addressToCheck];
  }

  /**
   * @dev Throws if called by any account other than Admin.
   */
  modifier onlyAdmin() {
    require(_admin[_msgSender()], "Admin:onlyAdmin caller is not an Admin");
    _;
  }
}

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol";
import "./IUzuVault.sol";

interface IFundTransferProxy is IERC165Upgradeable {
  /**
   * @dev Change the UZU Shared Collection Address
   * This contract must be added to UZU Vault as Trusted Proxy.
   * That allows this contract to use the assets in UZU Vault.
   *
   * @param newAddress address
   */
  function setUzuVaultAddress(IUzuVault newAddress) external;

  /**
   * @dev Deposit NativeToken to UZU Vault
   *
   * @param sender address
   */
  function depositNativeTokenToVault(address sender) external payable;

  /**
   * @dev Deposit ETH20 to UZU Vault
   *
   * @param amount uint256
   */
  function depositERC20ToVault(
    IERC20 tokenAddress,
    uint256 amount,
    address sender
  ) external;

  /**
   * @dev Proxy the NativeToken transfer transaction
   *
   * @param to address
   * @param amount uint256
   */
  function transferNativeTokenFromVault(address to, uint256 amount) external;

  /**
   * @dev Proxy the ERC20 token transfer
   * This contract must approved by the target ERC20 contract.
   * If not approved, the transaction will be reverted.
   *
   * @param tokenAddress IERC20
   * @param to address
   * @param amount uint256
   */
  function transferERC20FromVault(
    IERC20 tokenAddress,
    address to,
    uint256 amount
  ) external;
}

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol";

import "./IUzuSharedCollection.sol";
import "../library/Domain.sol";

interface INftTransferProxy is IERC165Upgradeable {
  /**
   * @dev Change the UZU Shared Collection Address
   * This contract must be added to UZUSharedCollection as Trusted Proxy.
   * That allows this contract to do LazyMint and NFT Transfer.
   *
   * @param newAddress IUzuSharedCollection
   */
  function setUzuSharedCollectionAddress(
    IUzuSharedCollection newAddress
  ) external;

  /**
   * @dev Proxy the NFT Transfer transaction
   *
   * @param from address
   * @param to address
   * @param amount uint256
   * @param nftId uint256
   * @param collectionAddress address
   * @param collectionType uint256
   * @param data bytes
   * @param isLazyMint bool
   * @param lazyMintData bytes
   * @param lazyMintSign bytes calldata
   */
  function proxyNftTransfer(
    address from,
    address to,
    uint256 amount,
    uint256 nftId,
    address collectionAddress,
    Domain.NFTKind collectionType,
    bytes calldata data,
    bool isLazyMint,
    Domain.MintData calldata lazyMintData,
    bytes calldata lazyMintSign
  ) external;
}

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

import "../library/Domain.sol";
import "./IFundTransferProxy.sol";
import "./INftTransferProxy.sol";

interface IUzuExchange {
  /**
   * @dev [Event1] Emitted when the Order Processing has succeeded.
   */
  event OrderProcessed(
    uint256 indexed orderId,
    address indexed collectionAddress,
    Domain.NFTKind nftKind,
    uint256 indexed nftId,
    uint256 amount,
    uint256 salePrice,
    address seller,
    address paymentReceiver,
    address buyer,
    Domain.Curator[] cruators,
    uint16 referenceMarketCommissionFee
  );

  /**
   * @dev [Event2] Emitted when the Order Processing has succeeded.
   */
  event OrderPaymentInfo(
    string buyerCurrencyType,
    string buyerCurrencySymbol,
    address buyerTokenAddress,
    uint256 buyerAmount,
    uint256 buyerDecimals,
    uint256 buyerRate,
    string sellerCurrencyType,
    string sellerCurrencySymbol,
    address sellerTokenAddress,
    uint256 sellerAmount,
    uint256 sellerDecimals,
    uint256 sellerRate
  );

  /**
   * @dev Emitted when the Royalty Distribution has succeeded.
   */
  event RoyaltyDistributed(
    string indexed recipientType,
    address indexed to,
    address indexed from,
    string currencyType,
    string currencySymbol,
    address tokenAddress,
    uint256 amount,
    uint256 decimals,
    uint256 rate,
    uint256 referenceRoyaltyFee
  );

  event FundTransferProxyUpdated(
    IFundTransferProxy indexed previousFundTransferProxy,
    IFundTransferProxy indexed newFundTransferProxy
  );

  event NftTransferProxyUpdated(
    INftTransferProxy indexed previousNftTransferProxy,
    INftTransferProxy indexed newNftTransferProxy
  );

  /**
   * @dev Main function to process the order
   *
   * @param order Domain.Order
   * @param adminSign bytes
   * @param lazyMintData Domain.MintData
   * @param lazyMintSign bytes calldata
   */
  function processOrder(
    Domain.Order calldata order,
    bytes calldata adminSign,
    Domain.MintData calldata lazyMintData,
    bytes calldata lazyMintSign
  ) external payable;

  /**
   * @dev Check whether the order ID has already been processed or not.
   *
   * @param orderId uint256 Order identifier
   */
  function isOrderProcessed(uint256 orderId) external view returns (bool);
}

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";

import "../interfaces/INftTransferProxy.sol";
import "../library/Domain.sol";

interface IUzuSharedCollection is IERC1155Upgradeable {
  /**
   * @dev Emitted when NFT transfer for anyone is approved by the NFT Creator.
   */
  event NftTransferApprovedForAll(
    uint256 indexed nftId,
    address indexed caller // TODO: Not sure this event data is needed
  );

  /**
   * @dev Emitted when new NftTransferProxy added
   */
  event TrustedNftTransferProxyAdded(INftTransferProxy indexed operator);
  /**
   * @dev Emitted when a NftTransferProxy deleted
   */
  event TrustedNftTransferProxyDeleted(INftTransferProxy indexed operator);

  /**
   * @dev If balance is enough, then transfer. If not, mint new NFT based on the data.
   * @notice https://github.com/rarible/protocol-contracts/blob/master/tokens/contracts/erc-1155/ERC1155Lazy.sol#L37
   *
   * @param to address
   * @param transferAmount uint256
   * @param lazyMintData bytes
   * @param lazyMintSign bytes calldata
   */
  function lazyMintAndTransferFrom(
    address to,
    uint256 transferAmount,
    Domain.MintData calldata lazyMintData,
    bytes calldata lazyMintSign
  ) external;

  /**
   * @dev mint NFT. Register the NFT Creator.
   *
   * @param mintData Domain.MintData calldata
   * @param sign bytes calldata
   */
  function mint(
    Domain.MintData calldata mintData,
    bytes calldata sign
  ) external;

  /**
   * @dev NftCreator give permission to anyone to transfer the NFT
   *
   * @param nftId uint256
   */
  function approveTransferForEveryoneByNftCreator(uint256 nftId) external;

  /**
   * @dev Transfer NFT for the first time by the approval of Creator
   * The person who transfers the NFT must pay the gas fee for NFT transfer approval from NFT creators
   *
   * @param ot Domain.OwnershipTransfer calldata
   * @param signature bytes calldata
   */
  function approveByNftCreatorAndTransfer(
    Domain.OwnershipTransfer calldata ot,
    bytes calldata signature
  ) external;

  /**
   * @dev Check a nft is transferable for non creator
   *
   * By default creator could transfer nft but when a creator transfer nft to
   * recever1 then recever1 else could not re-transfer to someone else.
   *
   * creator  -> recever1 => OK
   * recever1 -> recever2 => NG
   *
   * In order to make a nft transferable creator must allow first.
   * See :
   * {IUzuSharedCollection.approveTransferForEveryoneByNftCreator}
   * {IUzuSharedCollection.approveByNftCreatorAndTransfer}
   *
   * @param nftId uint256
   */
  function isNftTransferableForNonCreator(
    uint256 nftId
  ) external returns (bool);

  /**
   * @dev Add Trusted Proxy
   *
   * @param operator INftTransferProxy
   */
  function addTrustedNftTransferProxy(INftTransferProxy operator) external;

  /**
   * @dev Delete Trusted Proxy
   *
   * @param operator INftTransferProxy
   */
  function deleteTrustedNftTransferProxy(INftTransferProxy operator) external;
}

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol";

interface IUzuVault is IERC165Upgradeable {
  event NativeTokenDeposited(uint256 amount, address indexed depositer);
  event ERC20Deposited(
    IERC20 indexed erc20token,
    uint256 amount,
    address indexed from
  );

  event NativeTokenWithdrawn(uint256 amount, address indexed recipient);
  event ERC20Withdrawn(
    IERC20 indexed erc20token,
    uint256 amount,
    address indexed recipient
  );

  event NativeTokenTransferred(
    address indexed recipient,
    uint256 amount,
    uint256 remainingBalance
  );
  event ERC20TokenTransferred(
    IERC20 indexed erc20Token,
    address indexed recipient,
    uint256 amount,
    uint256 remainingBalance
  );

  /**
   * @dev Deposit NativeToken to this contract
   * @notice Anyone can deposit ETH. So please use this function carefully!
   */
  function depositNativeToken(address depositor) external payable;

  /**
   * @dev Transfer NativeToken to the recipient. Assume that FundTransferProxy has SPENDER_ROLE.
   *
   * @param recipient address
   * @param amount uint256
   */
  function transferNativeToken(address recipient, uint256 amount) external;

  /**
   * @dev To withdraw the NativeToken that this contract has.
   *
   * @param amount uint256
   */
  function withdrawNativeToken(uint256 amount) external;

  /**
   * @dev To withdraw all NativeToken that this contract has.
   */
  function withdrawAllNativeToken() external;

  /**
   * @dev Deposit ERC20 to this contract
   * @notice Anyone can deposit ERC20. So please use this function carefully!
   */
  function depositERC20(
    IERC20 erc20token,
    uint256 amount,
    address from
  ) external;

  /**
   * @dev Transfer ERC20 to the recipient. Assume that FundTransferProxy has SPENDER_ROLE.
   *
   * @param erc20Token address
   * @param recipient address
   * @param amount uint256
   */
  function transferERC20(
    IERC20 erc20Token,
    address recipient,
    uint256 amount
  ) external;

  /**
   * @dev Withdraw ERC20 token
   *
   * @param erc20Token address
   * @param amount uint256
   */
  function withdrawERC20(IERC20 erc20Token, uint256 amount) external;

  /**
   * @dev Withdraw All ERC20 token to Sender
   *
   * @param erc20Token address
   */
  function withdrawAllERC20(IERC20 erc20Token) external;
}

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

/**
 * @dev Holds all struct and static functions
 */
library Domain {
  enum NFTKind {
    // ERC721-compatible Collection
    ERC721,
    // ERC1155-compatible Collections
    ERC1155
  }

  // Curator Info
  struct Curator {
    address curatorAddress;
    string curatorType;
  }

  // Because Solidity cannot deal with float value, we need to introduce decimals.
  // ex) If the price is 123.45USD, the value of each variables should be as follows:
  //   - currencyType   = CRYPTO
  //   - currencySymbol = USD
  //   - tokenAddress   = 0x0
  //   - amount         = 123450000000000000000
  //   - decimals       = 18
  struct Payment {
    // Currency Type. If Fiat, tokenAddress field MUST be ignored.
    string currencyType;
    // Currency Symbol. To specify the currency.
    string currencySymbol;
    // If not 0, means ERC20 token address. If 0, means ETH.
    address tokenAddress;
    // Amount of payment
    uint256 amount;
    // Decimals of the amount.
    uint256 decimals;
    // USD price per Fiat/Token/ETH
    uint256 rate;
  }

  struct Royalty {
    // The type of recipient of the Royalty, like:
    // - CREATOR
    // - SPECIAL_CURATOR
    // - RECOMMENDER
    string recipientType;
    // The recipient of the Royalty.
    address recipientAddress;
    // Rolayty percentage as a reference (using 2 decimals. That is, 10000 = 100%, 231 = 2.31%, 0 = 0%)
    // *Important Note* This value is not used for calculation.
    //                  All of payment details, including amount of rolayty, MUST be specified in Payment.
    uint256 referenceRoyaltyFee;
    // Royalty Payment Information
    Payment payment;
  }

  // Order Body
  struct Order {
    /* Order-related Information */
    // Order ID (Generated Off-chain), used as nonce
    uint256 orderId;
    // The time when the order is created (signed by UZU Admin) in Unix timestamp.
    uint256 orderCreatedAt;
    // The time when the order will expires in Unix timestamp.
    uint256 orderExpiresAt;
    /* NFT-related Information */
    // The target collection address
    address collectionAddress;
    // The NFT Kind
    NFTKind nftKind;
    // The target NFT ID
    uint256 nftId;
    // The number of NFT amount. Must be 1 if the NFTKind = ERC721.
    uint256 amount;
    /* Basic Order Information */
    // The price of this order (in USD multiplied by 10**decimals)
    uint256 salePrice;
    // The decimal of salePrice
    uint256 salePriceDecimals;
    // Address of Seller
    address seller;
    // Address where payment will be received, can be same as seller
    address paymentReceiver;
    // Address of Buyer
    address buyer;
    // Market Commission Percentage (using 2 decimals. That is, 10000 = 100%, 231 = 2.31%, 0 = 0%)
    // *Important Note* This value is not used for calculation. Just for the information.
    uint16 referenceMarketCommissionFee;
    /* Buyer and Seller Fee */
    Payment buyerPayment;
    Payment sellerPayment;
    // /* Management information of the order */
    // OrderManagement orderManagement;
    /* Royalty Information */
    Royalty[] royalties;
    // List of cruators
    Curator[] cruators;
  }

  // Represents an un-minted NFT, which has not yet been recorded into the blockchain. A signed voucher can be redeemed for a real NFT using the redeem function.
  struct MintData {
    // Mint ID (Generated Off-chain), used as nonce
    uint256 mintId;
    // Address of the creator
    address creator;
    // The id of the token to be redeemed. Must be unique - if another token with this ID already exists, the redeem function will revert.
    uint256 nftId;
    // Amount of NFT needs to be minted
    uint256 amount;
    // The metadata URI to associate with this token.
    string uri;
    // Data to be passed for minting
    bytes data;
    // ERC2981 receiver
    address royaltyReceiver;
    // ERC2981 feeNumerator
    uint96 royaltyFeeNumerator;
  }

  struct OwnershipTransfer {
    uint256 nftId;
    address to;
    uint256 amount;
  }

  /**
   * @dev Checks if the Currency Type is Crypto
   *
   * @param currencyType string
   */
  function isCryptoCurrencyType(
    string memory currencyType
  ) public pure returns (bool) {
    return compareStrings(currencyType, "CRYPTO");
  }

  /**
   * @dev Compares two strings
   *
   * @param a string first
   * @param b string second
   */
  function compareStrings(
    string memory a,
    string memory b
  ) public pure returns (bool) {
    return (keccak256(abi.encodePacked((a))) ==
      keccak256(abi.encodePacked((b))));
  }

  // ---- EIP712 ----
  bytes32 internal constant PAYMENT_TYPEHASH =
    keccak256(
      "Payment(string currencyType,string currencySymbol,address tokenAddress,uint256 amount,uint256 decimals,uint256 rate)"
    );

  bytes32 internal constant ROYALTY_TYPEHASH =
    keccak256(
      "Royalty(string recipientType,address recipientAddress,uint256 referenceRoyaltyFee,Payment payment)Payment(string currencyType,string currencySymbol,address tokenAddress,uint256 amount,uint256 decimals,uint256 rate)"
    );

  bytes32 internal constant CURATOR_TYPEHASH =
    keccak256("Curator(address curatorAddress,string curatorType)");

  bytes32 internal constant ORDER_TYPEHASH =
    keccak256(
      "Order(uint256 orderId,uint256 orderCreatedAt,uint256 orderExpiresAt,address collectionAddress,uint8 nftKind,uint256 nftId,uint256 amount,uint256 salePrice,uint256 salePriceDecimals,address seller,address paymentReceiver,address buyer,uint16 referenceMarketCommissionFee,Payment buyerPayment,Payment sellerPayment,Royalty[] royalties,Curator[] cruators)Curator(address curatorAddress,string curatorType)Payment(string currencyType,string currencySymbol,address tokenAddress,uint256 amount,uint256 decimals,uint256 rate)Royalty(string recipientType,address recipientAddress,uint256 referenceRoyaltyFee,Payment payment)"
    );

  bytes32 internal constant MINT_DATA_TYPEHASH =
    keccak256(
      "MintData(uint256 mintId,address creator,uint256 nftId,uint256 amount,string uri,bytes data,address royaltyReceiver,uint96 royaltyFeeNumerator)"
    );

  bytes32 internal constant OWNERSHIP_TRASNFER_TYPEHASH =
    keccak256("OwnershipTransfer(uint256 nftId,address to,uint256 amount)");

  /**
   * @dev Prepares keccak256 hash for Curator list
   *
   * @param curatorList Curator[] calldata
   */
  function _hashCurator(
    Curator[] calldata curatorList
  ) internal pure returns (bytes32) {
    bytes32[] memory keccakData = new bytes32[](curatorList.length);

    for (uint256 idx = 0; idx < curatorList.length; idx++) {
      keccakData[idx] = _hashCurator(curatorList[idx]);
    }

    return keccak256(abi.encodePacked(keccakData));
  }

  /**
   * @dev Prepares keccak256 hash for Curator
   *
   * @param curator Curator
   */
  function _hashCurator(
    Curator calldata curator
  ) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(
          CURATOR_TYPEHASH,
          curator.curatorAddress,
          keccak256(bytes(curator.curatorType))
        )
      );
  }

  /**
   * @dev Prepares keccak256 hash for Payment
   *
   * @param payment Payment
   */
  function _hashPayment(
    Payment calldata payment
  ) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(
          PAYMENT_TYPEHASH,
          keccak256(bytes(payment.currencyType)),
          keccak256(bytes(payment.currencySymbol)),
          payment.tokenAddress,
          payment.amount,
          payment.decimals,
          payment.rate
        )
      );
  }

  /**
   * @dev Prepares keccak256 hash for Royalty list
   *
   * @param royaltyList Royalty[]
   */
  function _hashRoyalty(
    Royalty[] calldata royaltyList
  ) internal pure returns (bytes32) {
    bytes32[] memory keccakData = new bytes32[](royaltyList.length);

    for (uint256 idx = 0; idx < royaltyList.length; idx++) {
      keccakData[idx] = _hashRoyalty(royaltyList[idx]);
    }

    return keccak256(abi.encodePacked(keccakData));
  }

  /**
   * @dev Prepares keccak256 hash for Royalty
   *
   * @param royalty Royalty
   */
  function _hashRoyalty(
    Royalty calldata royalty
  ) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(
          ROYALTY_TYPEHASH,
          keccak256(bytes(royalty.recipientType)),
          royalty.recipientAddress,
          royalty.referenceRoyaltyFee,
          _hashPayment(royalty.payment)
        )
      );
  }

  /**
   * @dev Prepares keccak256 hash for Order
   *
   * @param order Order
   */
  function _hashOrder(Order calldata order) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(
          ORDER_TYPEHASH,
          order.orderId,
          order.orderCreatedAt,
          order.orderExpiresAt,
          order.collectionAddress,
          order.nftKind,
          order.nftId,
          order.amount,
          order.salePrice,
          order.salePriceDecimals,
          order.seller,
          order.paymentReceiver,
          order.buyer,
          order.referenceMarketCommissionFee,
          _hashPayment(order.buyerPayment),
          _hashPayment(order.sellerPayment),
          _hashRoyalty(order.royalties),
          _hashCurator(order.cruators)
        )
      );
  }

  /**
   * @dev Prepares keccak256 hash for MintData
   *
   * @param mintData Domain.MintData
   */
  function _hashMintData(
    MintData calldata mintData
  ) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(
          MINT_DATA_TYPEHASH,
          mintData.mintId,
          mintData.creator,
          mintData.nftId,
          mintData.amount,
          keccak256(bytes(mintData.uri)),
          keccak256(mintData.data),
          mintData.royaltyReceiver,
          mintData.royaltyFeeNumerator
        )
      );
  }

  /**
   * @dev Prepares keccak256 hash for OwnershipTransfer
   *
   * @param ot OwnershipTransfer calldata
   */
  function _hashOwnershipTranfer(
    OwnershipTransfer calldata ot
  ) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(OWNERSHIP_TRASNFER_TYPEHASH, ot.nftId, ot.to, ot.amount)
      );
  }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {
    "contracts/library/Domain.sol": {
      "Domain": "0xd143026e990b58149a4b347e94333973dd72b227"
    }
  }
}

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_trustedForwarder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"adminAddress","type":"address"}],"name":"AdminAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"adminAddress","type":"address"}],"name":"AdminRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IFundTransferProxy","name":"previousFundTransferProxy","type":"address"},{"indexed":true,"internalType":"contract IFundTransferProxy","name":"newFundTransferProxy","type":"address"}],"name":"FundTransferProxyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract INftTransferProxy","name":"previousNftTransferProxy","type":"address"},{"indexed":true,"internalType":"contract INftTransferProxy","name":"newNftTransferProxy","type":"address"}],"name":"NftTransferProxyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"buyerCurrencyType","type":"string"},{"indexed":false,"internalType":"string","name":"buyerCurrencySymbol","type":"string"},{"indexed":false,"internalType":"address","name":"buyerTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"buyerAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"buyerDecimals","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"buyerRate","type":"uint256"},{"indexed":false,"internalType":"string","name":"sellerCurrencyType","type":"string"},{"indexed":false,"internalType":"string","name":"sellerCurrencySymbol","type":"string"},{"indexed":false,"internalType":"address","name":"sellerTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"sellerAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sellerDecimals","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sellerRate","type":"uint256"}],"name":"OrderPaymentInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":true,"internalType":"address","name":"collectionAddress","type":"address"},{"indexed":false,"internalType":"enum Domain.NFTKind","name":"nftKind","type":"uint8"},{"indexed":true,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"address","name":"paymentReceiver","type":"address"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"components":[{"internalType":"address","name":"curatorAddress","type":"address"},{"internalType":"string","name":"curatorType","type":"string"}],"indexed":false,"internalType":"struct Domain.Curator[]","name":"cruators","type":"tuple[]"},{"indexed":false,"internalType":"uint16","name":"referenceMarketCommissionFee","type":"uint16"}],"name":"OrderProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"recipientType","type":"string"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"string","name":"currencyType","type":"string"},{"indexed":false,"internalType":"string","name":"currencySymbol","type":"string"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"decimals","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"referenceRoyaltyFee","type":"uint256"}],"name":"RoyaltyDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"contract IFundTransferProxy","name":"fundTransferProxy_","type":"address"},{"internalType":"contract INftTransferProxy","name":"nftTransferProxy_","type":"address"}],"name":"__UzuExchange_init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newAdmin","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_newAdminList","type":"address[]"}],"name":"addAdminBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fundTransferProxy","outputs":[{"internalType":"contract IFundTransferProxy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_addressToCheck","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"}],"name":"isOrderProcessed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftTransferProxy","outputs":[{"internalType":"contract INftTransferProxy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"orderId","type":"uint256"},{"internalType":"uint256","name":"orderCreatedAt","type":"uint256"},{"internalType":"uint256","name":"orderExpiresAt","type":"uint256"},{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"enum Domain.NFTKind","name":"nftKind","type":"uint8"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"},{"internalType":"uint256","name":"salePriceDecimals","type":"uint256"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"address","name":"paymentReceiver","type":"address"},{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint16","name":"referenceMarketCommissionFee","type":"uint16"},{"components":[{"internalType":"string","name":"currencyType","type":"string"},{"internalType":"string","name":"currencySymbol","type":"string"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"rate","type":"uint256"}],"internalType":"struct Domain.Payment","name":"buyerPayment","type":"tuple"},{"components":[{"internalType":"string","name":"currencyType","type":"string"},{"internalType":"string","name":"currencySymbol","type":"string"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"rate","type":"uint256"}],"internalType":"struct Domain.Payment","name":"sellerPayment","type":"tuple"},{"components":[{"internalType":"string","name":"recipientType","type":"string"},{"internalType":"address","name":"recipientAddress","type":"address"},{"internalType":"uint256","name":"referenceRoyaltyFee","type":"uint256"},{"components":[{"internalType":"string","name":"currencyType","type":"string"},{"internalType":"string","name":"currencySymbol","type":"string"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"rate","type":"uint256"}],"internalType":"struct Domain.Payment","name":"payment","type":"tuple"}],"internalType":"struct Domain.Royalty[]","name":"royalties","type":"tuple[]"},{"components":[{"internalType":"address","name":"curatorAddress","type":"address"},{"internalType":"string","name":"curatorType","type":"string"}],"internalType":"struct Domain.Curator[]","name":"cruators","type":"tuple[]"}],"internalType":"struct Domain.Order","name":"order","type":"tuple"},{"internalType":"bytes","name":"adminSign","type":"bytes"},{"components":[{"internalType":"uint256","name":"mintId","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"uri","type":"string"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"address","name":"royaltyReceiver","type":"address"},{"internalType":"uint96","name":"royaltyFeeNumerator","type":"uint96"}],"internalType":"struct Domain.MintData","name":"lazyMintData","type":"tuple"},{"internalType":"bytes","name":"lazyMintSign","type":"bytes"}],"name":"processOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_adminToRemove","type":"address"}],"name":"removeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IFundTransferProxy","name":"fundTransferProxy_","type":"address"}],"name":"updateFundTransferProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract INftTransferProxy","name":"nftTransferProxy_","type":"address"}],"name":"updateNftTransferProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

60c0346200009257601f62003c5a38819003918201601f19168301916001600160401b0383118484101762000097578084926020946040528339810103126200009257516001600160a01b038116810362000092576080523060a052604051613bac9081620000ae8239608051818181610af30152613441015260a051818181610b3501528181610c420152612b4a0152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe608080604052600436101561001357600080fd5b600090813560e01c90816301ffc9a714612f7e575080631785f53c14612e7f57806324d7806c14612e565780633659cfe614612b23578063456dcd6314610f6e5780634f1ef28614610bef57806352d1902d14610b1a578063572b6c0514610ac85780635e3b2c991461092d578063643debfe1461040757806370480275146103bf5780638ff4df371461038f578063970c486f1461036757806397c679bc146101ab578063aba47579146100fb5763cfb70e2e146100d157600080fd5b346100f857806003193601126100f85760206001600160a01b036101315416604051908152f35b80fd5b50346100f85760203660031901126100f85767ffffffffffffffff6004358181116101a757366023820112156101a75780600401359182116101a7576024906005368385831b840101116101a3576001600160a01b0361015961343e565b16855260cb60205261017160ff604087205416613394565b845b84811061017e578580f35b806101996101948661019e94861b87010161342a565b61347e565b613405565b610173565b8480fd5b8280fd5b50346100f857602080600319360112610363576101c6613005565b6001600160a01b038091816101d961343e565b16855260cb84526101f060ff604087205416613394565b16906040516301ffc9a760e01b8152631b19349f60e01b60048201528381602481865afa90811561035857859161032b575b50156102d7576101319283549182169083821461027e5750908273ffffffffffffffffffffffffffffffffffffffff19927fd03109d94c8ca45e3dcb73d8703c3c5dc248f3d8ab2ef8e63f59b73a4d8c3b2e8780a31617905580f35b6084906040519062461bcd60e51b82526004820152602c60248201527f557a7545786368616e67653a206578697374696e672073616d652046756e645460448201526b72616e7366657250726f787960a01b6064820152fd5b6084836040519062461bcd60e51b82526004820152602760248201527f557a7545786368616e67653a20696e76616c6964204946756e645472616e7366604482015266657250726f787960c81b6064820152fd5b61034b9150843d8611610351575b61034381836130f7565b8101906135a8565b38610222565b503d610339565b6040513d87823e3d90fd5b5080fd5b50346100f857806003193601126100f85760206001600160a01b036101325416604051908152f35b50346100f85760203660031901126100f85760ff6040602092600435815261013084522054166040519015158152f35b50346100f85760203660031901126100f8576104046103dc613005565b6001600160a01b036103ec61343e565b16835260cb60205261019460ff604085205416613394565b80f35b50346100f85760403660031901126100f857610421613005565b602435906001600160a01b038216820361092857825460ff8160081c16159081809261091b575b8015610904575b1561089a5760ff198116600117855581610889575b5061047e60ff855460081c1661047981613537565b613537565b61048661343e565b916104908361347e565b6001600160a01b0380604051946104a6866130db565b600b86527f557a7545786368616e67650000000000000000000000000000000000000000006020870152610542604051966104e0886130db565b600388527f312e300000000000000000000000000000000000000000000000000000000000602089015289549760ff8960081c169161051e83613537565b61052783613537565b60208151910120906020815191012090603355603455613537565b169182875260cb60205261055c60ff604089205416613394565b1690604051906301ffc9a760e01b91828152631b19349f60e01b6004820152602081602481875afa90811561087e57889161085f575b501561080b576101318054936001600160a01b0385168181146107b25781907fd03109d94c8ca45e3dcb73d8703c3c5dc248f3d8ab2ef8e63f59b73a4d8c3b2e8b80a373ffffffffffffffffffffffffffffffffffffffff19809516179055865260cb60205261060860ff604088205416613394565b604051908152633a03be4360e01b60048201526020816024816001600160a01b0389165afa9081156107a7578691610788575b501561073557610132908154906001600160a01b038216956001600160a01b03811687146106dd576001600160a01b039060405197828216907f557463bb380f634e0ff0c656a09566f9e7bcacbc6cb16eba1d108a86719f5f168b80a31691161790556106a6578280f35b61ff0019168255600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a138808280f35b608460405162461bcd60e51b815260206004820152602b60248201527f557a7545786368616e67653a206578697374696e672073616d65204e6674547260448201526a616e7366657250726f787960a81b6064820152fd5b608460405162461bcd60e51b815260206004820152602660248201527f557a7545786368616e67653a20696e76616c696420494e66745472616e7366656044820152657250726f787960d01b6064820152fd5b6107a1915060203d6020116103515761034381836130f7565b3861063b565b6040513d88823e3d90fd5b608460405162461bcd60e51b815260206004820152602c60248201527f557a7545786368616e67653a206578697374696e672073616d652046756e645460448201526b72616e7366657250726f787960a01b6064820152fd5b608460405162461bcd60e51b815260206004820152602760248201527f557a7545786368616e67653a20696e76616c6964204946756e645472616e7366604482015266657250726f787960c81b6064820152fd5b610878915060203d6020116103515761034381836130f7565b38610592565b6040513d8a823e3d90fd5b61ffff191661010117845538610464565b608460405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152fd5b50303b15801561044f5750600160ff82161461044f565b50600160ff821610610448565b600080fd5b50346100f85760208060031936011261036357610948613005565b6001600160a01b0380918161095b61343e565b16855260cb845261097260ff604087205416613394565b16906040516301ffc9a760e01b8152633a03be4360e01b60048201528381602481865afa908115610358578591610aab575b5015610a585761013292835491821690838214610a005750908273ffffffffffffffffffffffffffffffffffffffff19927f557463bb380f634e0ff0c656a09566f9e7bcacbc6cb16eba1d108a86719f5f168780a31617905580f35b6084906040519062461bcd60e51b82526004820152602b60248201527f557a7545786368616e67653a206578697374696e672073616d65204e6674547260448201526a616e7366657250726f787960a81b6064820152fd5b6084836040519062461bcd60e51b82526004820152602660248201527f557a7545786368616e67653a20696e76616c696420494e66745472616e7366656044820152657250726f787960d01b6064820152fd5b610ac29150843d86116103515761034381836130f7565b386109a4565b50346100f85760203660031901126100f8576020610ae4613005565b604051906001600160a01b03807f0000000000000000000000000000000000000000000000000000000000000000169116148152f35b50346100f857806003193601126100f8576001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610b855760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b608460405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152fd5b5060403660031901126100f857610c04613005565b9060243567ffffffffffffffff8111610363573660238201121561036357610c36903690602481600401359101613135565b916001600160a01b03807f000000000000000000000000000000000000000000000000000000000000000016610c6e8130141561316c565b610c9d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9183835416146131dd565b81610ca661343e565b16845260209160cb8352610cc060ff604087205416613394565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610cf85750505061040491925061324e565b8392949316906040516352d1902d60e01b81528581600481865afa60009181610f3f575b50610d8b576084866040519062461bcd60e51b82526004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152fd5b94939403610ee957610d9c8261324e565b604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2845115801590610ee1575b610ddd575b505050905080f35b813b15610e915750600084819284610e7f9697519201905af43d15610e89573d90610e0782613119565b91610e1560405193846130f7565b82523d60008484013e5b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60405193610e4d85613087565b602785528401527f206661696c6564000000000000000000000000000000000000000000000000006040840152613308565b5080388080610dd5565b606090610e1f565b808362461bcd60e51b608493526004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152fd5b506001610dd0565b6084836040519062461bcd60e51b82526004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152fd5b90918782813d8311610f67575b610f5681836130f7565b810103126100f85750519038610d1c565b503d610f4c565b5060803660031901126100f85767ffffffffffffffff600435116100f857610220600435360360031901126100f85760243567ffffffffffffffff811161036357610fbd90369060040161302f565b909167ffffffffffffffff604435116100f857610100604435360360031901126100f85760643567ffffffffffffffff81116103635761100190369060040161302f565b6004356004013515612ab95760043560040135835261013060205260ff604084205416612a4f5760246004350135151580612a3f575b156129d557604460043501351580156129c6575b1561295c5761105e60646004350161342a565b3b156128f25760a46004350135156128ae5760c46004350135156128445760e46004350135156127db576001600160a01b0361109f6101246004350161342a565b161561278d576001600160a01b036110bc6101446004350161342a565b1615612723576001600160a01b036110d96101646004350161342a565b16156126df57825b6110f66101e4600435016004356004016136fb565b9050811015611222576111266111218261111b6101e4600435016004356004016136fb565b90613923565b61395b565b805151156111b857602001516001600160a01b03161561114e5761114990613405565b6110e1565b608460405162461bcd60e51b815260206004820152602d60248201527f557a7545786368616e67653a20696e76616c696420726f79616c74792e72656360448201527f697069656e7441646472657373000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602a60248201527f557a7545786368616e67653a20696e76616c696420726f79616c74792e72656360448201527f697069656e7454797065000000000000000000000000000000000000000000006064820152fd5b5084835b61123b610204600435016004356004016136fb565b90508110156113dc576112638161125d610204600435016004356004016136fb565b906139d8565b6040813603126113d8576040519081604081011067ffffffffffffffff6040840111176113c4576040820160405261129a8161301b565b825267ffffffffffffffff6020820135116113c0576112c86001600160a01b039136906020810135016135d5565b9160208101928352511615611356575151156112ec576112e790613405565b611226565b608460405162461bcd60e51b815260206004820152602860248201527f557a7545786368616e67653a20696e76616c69642063727561746f722e63757260448201527f61746f72547970650000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602b60248201527f557a7545786368616e67653a20696e76616c69642063727561746f722e63757260448201527f61746f72416464726573730000000000000000000000000000000000000000006064820152fd5b8680fd5b602487634e487b7160e01b81526041600452fd5b8580fd5b50846113ec60646004350161342a565b91600260846004350135101592836113c05761140d6101246004350161342a565b61141c6101446004350161342a565b61142b6101646004350161342a565b61143a61018460043501613731565b6114576114526101a4600435016004356004016135c0565b613ab8565b906114706114526101c4600435016004356004016135c0565b928c6114876101e4600435016004356004016136fb565b61149081613a12565b925b81811061263f575050506040516114bf816114b1602082018095613a58565b03601f1981018352826130f7565b519020948d6114d9610204600435016004356004016136fb565b6114e281613a12565b925b8181106125a4575050506040518060208101928361150191613a58565b03601f198101825261151390826130f7565b519020966040519860208a017f9a30949473f7060ed7d984f94495e2d6db584d8074b32e7861e46b524e55557c90526004356004013560408b01526004356024013560608b01526004356044013560808b01526001600160a01b031660a08a015260c08901600435608401359061158991613685565b60043560a4013560e08a015260043560c401356101008a015260043560e401356101208a015260043561010401356101408a01526001600160a01b03166101608901526001600160a01b03166101808801526001600160a01b03166101a087015261ffff166101c08601526101e08501526102008401526102208301526102409081830152815280610260810110610260820167ffffffffffffffff10176113c457611726926116fb611709938361026061170195016040528051602082012090610260603354916034546102808201937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f85526102a08301526102c0820152466102e08201523061030082015260a0828201526116a88282016130a3565b01519020906040519060208201927f1901000000000000000000000000000000000000000000000000000000000000845260228301526042820152604281526116f0816130bf565b519020923691613135565b9061385c565b919091613740565b6001600160a01b031660005260cb60205260ff6040600020541690565b156125565760043560040135845261013060205260408420600160ff19825416179055611767366117626101a4600435016004356004016135c0565b6135f3565b90346123aa575b611796602083516040518093819263d44d255760e01b8352846004840152602483019061336f565b038173d143026e990b58149a4b347e94333973dd72b2275af49081156107a757869161238b575b5080612375575b6122cc575b6117e2366117626101c4600435016004356004016135c0565b9061180b602083516040518093819263d44d255760e01b8352846004840152602483019061336f565b038173d143026e990b58149a4b347e94333973dd72b2275af49081156122c15787916122a2575b506121a2575b6118476101646004350161342a565b93865b61185f6101e4600435016004356004016136fb565b9050811015611b46576118846111218261111b6101e4600435016004356004016136fb565b906118b06118a18261111b6101e4600435016004356004016136fb565b611762369160608101906135c0565b6118d8602082516040518093819263d44d255760e01b8352846004840152602483019061336f565b038173d143026e990b58149a4b347e94333973dd72b2275af4908115611b3b578b91611b1c575b506119df575b826119da9351907ff2542b261fd65b2cfbd5d50bae4d85a8e55df6eb5a13bb6dba9d400c066923e26001600160a01b03602083015116928451906020860151936001600160a01b036040880151169660608101516119ac611983604060a060808601519501519501519560206040519282848094519384920161334c565b81010390209761199e6040519760e0895260e089019061336f565b90878203602089015261336f565b9860408601526060850152608084015260a083015260c0820152806001600160a01b038d16950390a4613405565b61184a565b896001600160a01b036040830151168015600014611a9057506001600160a01b0361013154166001600160a01b036020860151166060840151823b15611a8c576040516307638ad760e51b81526001600160a01b0392909216600483015260248201529082908290604490829084905af18015611a8157611a69575b50506119da925b9250611905565b611a729061305d565b611a7d57898b611a5b565b8980fd5b6040513d84823e3d90fd5b8380fd5b6001600160a01b036101315416906001600160a01b0360208701511691606085015190803b156101a35760405163b04dc6ef60e01b81526001600160a01b039384166004820152939092166024840152604483015282908290606490829084905af18015611a8157611b08575b50506119da92611a62565b611b119061305d565b611a7d57898b611afd565b611b35915060203d6020116103515761034381836130f7565b8b6118ff565b6040513d8d823e3d90fd5b508694508560448035013515611fc6576001600160a01b03610132541690611b736101246004350161342a565b91611b836101646004350161342a565b85611b9260646004350161342a565b90611a7d57823b15611a7d576001600160a01b03809281604051976305e6548d60e51b895216600488015216602486015260c46004350135604486015260a460043501356064860152166084840152611bf460a4840160846004350135613685565b61014060c48401526000610144840152604480350135151560e4840152610160610104840152611cab60443560040180356101648601526001600160a01b03611c4160246044350161301b565b166101848601526044803501356101a4860152606460443501356101c4860152611c97611c8a611c76608460443501846136a8565b6101006101e48a01526102648901916136da565b9160a460443501906136a8565b8683036101631901610204880152906136da565b906001600160a01b03611cc260c46044350161301b565b1661022485015260e46044350135916bffffffffffffffffffffffff83168303610928578985611d1a819593839984986bffffffffffffffffffffffff859716610244860152600319858403016101248601526136da565b03925af18015611a8157611fb2575b50505b611d3a60646004350161342a565b90611a8c57611d4e6101246004350161342a565b6001600160a01b03611d656101446004350161342a565b611d746101646004350161342a565b611d89610204600435016004356004016136fb565b93909181611d9c61018460043501613731565b948160405198611db28a60846004350135613685565b60c4600435013560208b015260e4600435013560408b01521660608901521660808701521660a085015261010060c08501528261010085015261012084016101208460051b86010193828a905b828210611f4557505050505061ffff1660e083015260043560a40135926001600160a01b031691806004356004013592037f6757cfa181840e9e3e9964c8c34a790a30cb2bcc75b88286149a6ebee460fcaf91a481519060208301519260408101516001600160a01b03169160608201519160808101519060a0015193825160208401519160408501516001600160a01b03169660608601519460808701519660a00151976040519b8c9b6101808d526101808d01611ebd9161336f565b8c810360208e0152611ece9161336f565b9360408c015260608b015260808a015260a089015287810360c0890152611ef49161336f565b86810360e0880152611f059161336f565b93610100860152610120850152610140840152610160830152037fa8fed2eeed33c77e6a1eaca87e011d01f27d87401350a8f51530ea36ced1d06b91a180f35b909192939561011f198882030185528635603e1983360301811215611fae576020611fa16001936040611f92878596016001600160a01b03611f868261301b565b168452858101906136a8565b919092818682015201916136da565b9801950193920190611dff565b8c80fd5b611fbb9061305d565b611a8c578385611d29565b9091506001600160a01b036101325416611fe56101246004350161342a565b91611ff56101646004350161342a565b9361200460646004350161342a565b94600095843b15611a7d576001600160a01b03809281604051986305e6548d60e51b8a5216600489015216602487015260c46004350135604487015260a46004350135606487015216608485015261206560a4850160846004350135613685565b61014060c4850152846101448501528460e485015261016061010485015261210760443560040180356101648701526001600160a01b036120aa60246044350161301b565b166101848701526044803501356101a4870152606460443501356101c48701526120f3611c8a6120df608460443501846136a8565b6101006101e48b01526102648a01916136da565b8783036101631901610204890152906136da565b916001600160a01b0361211e60c46044350161301b565b1661022486015260e460443501356bffffffffffffffffffffffff811681036113c0579489816121788298968298959683976bffffffffffffffffffffffff869a16610244860152600319858403016101248601526136da565b03925af18015611a815761218e575b5050611d2c565b6121979061305d565b611a8c578385612187565b856001600160a01b03604084015116801560001461223c57506001600160a01b0361013154166121d76101446004350161342a565b6060850151823b15611a8c576040516307638ad760e51b81526001600160a01b03909216600483015260248201529082908290818381604481015b03925af18015611a8157612228575b5050611838565b6122319061305d565b6113d8578587612221565b6001600160a01b036101315416906122596101446004350161342a565b91606086015190803b156101a35760405163b04dc6ef60e01b81526001600160a01b03938416600482015293909216602484015260448301528290829081838160648101612212565b6122bb915060203d6020116103515761034381836130f7565b87611832565b6040513d89823e3d90fd5b846001600160a01b0361013154166001600160a01b0360408501511660608501516122fc6101646004350161342a565b92803b156101a3578492836064926001600160a01b0360405197889687957fbe9bc258000000000000000000000000000000000000000000000000000000008752600487015260248601521660448401525af18015611a8157612361575b50506117c9565b61236a9061305d565b6101a357848661235a565b506001600160a01b0360408301511615156117c4565b6123a4915060203d6020116103515761034381836130f7565b866117bd565b60608201513481036124265750846001600160a01b03610131541660608401516123d261343e565b823b15611a8c5760246001600160a01b0391859360405195869485936357b145a560e11b85521660048401525af18015611a8157612412575b505061176e565b61241b9061305d565b6101a357848661240b565b3411156124ec576001600160a01b03610131541660608301518661244861343e565b92803b15610363576024604051809481936357b145a560e11b83526001600160a01b03881660048401525af180156122c1576124d9575b50606083015134813403116124c55786808093819382908034146124bb575b3403916001600160a01b031690f161176e576040513d86823e3d90fd5b6108fc915061249e565b602487634e487b7160e01b81526011600452fd5b6124e59096919661305d565b948661247f565b608460405162461bcd60e51b815260206004820152602f60248201527f557a7545786368616e67653a206e6f7420656e6f75676874206e61746976652060448201527f746f6b656e73206172652073656e7400000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f557a7545786368616e67653a20696e76616c6964206f72646572207369676e656044820152603960f91b6064820152fd5b806125b361263a9284866139d8565b6125d46125cd6125c28361342a565b926020810190613a85565b3691613135565b60208151910120604051906001600160a01b0360208301937f3368eda4c006f63bc3e286003bf874dcf861e5565a691d913bb9c32bfb7447528552166040830152606090818301528152612627816130bf565b5190206126348287613a44565b52613405565b6114e4565b8061264e6126da928486613923565b61265b6125cd8280613a85565b602081519101209061266f6020820161342a565b906040606091612684611452848301836135c0565b926001600160a01b0383519560208701977f3e996bae226469b8a4faff6b2ee8b4b33aac0d6f398c0021adc7797d52e55da289528588015216908501520135608083015260a090818301528152612627816130a3565b611492565b606460405162461bcd60e51b815260206004820152602060248201527f557a7545786368616e67653a20696e76616c6964206f726465722e62757965726044820152fd5b608460405162461bcd60e51b815260206004820152602a60248201527f557a7545786368616e67653a20696e76616c6964206f726465722e7061796d6560448201527f6e745265636569766572000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f557a7545786368616e67653a20696e76616c6964206f726465722e73656c6c656044820152603960f91b6064820152fd5b608460405162461bcd60e51b8152602060048201526024808201527f557a7545786368616e67653a20696e76616c6964206f726465722e73616c655060448201527f72696365000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f557a7545786368616e67653a20696e76616c6964206f726465722e616d6f756e60448201527f74000000000000000000000000000000000000000000000000000000000000006064820152fd5b606460405162461bcd60e51b815260206004820152602060248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6e667449646044820152fd5b608460405162461bcd60e51b815260206004820152602c60248201527f557a7545786368616e67653a20696e76616c6964206f726465722e636f6c6c6560448201527f6374696f6e4164647265737300000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602960248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6f7264657260448201527f45787069726573417400000000000000000000000000000000000000000000006064820152fd5b5042604460043501351161104b565b608460405162461bcd60e51b815260206004820152602960248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6f7264657260448201527f43726561746564417400000000000000000000000000000000000000000000006064820152fd5b5042602460043501351115611037565b608460405162461bcd60e51b815260206004820152602260248201527f557a7545786368616e67653a206f7264657220616c72656164792070726f636560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602260248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6f7264657260448201527f49640000000000000000000000000000000000000000000000000000000000006064820152fd5b50346100f85760208060031936011261036357612b3e613005565b906001600160a01b03807f000000000000000000000000000000000000000000000000000000000000000016612b768130141561316c565b612ba57f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9183835416146131dd565b81612bae61343e565b16855260cb8352612bc560ff604087205416613394565b604051908382019282841067ffffffffffffffff8511176113c4578360405286835260ff7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435416600014612c215750505050506104049061324e565b8596949516906040516352d1902d60e01b81528681600481865afa869181612e27575b50612cb3576084876040519062461bcd60e51b82526004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152fd5b95949503612dd157612cc48661324e565b604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8680a2815115801590612dca575b612d05575b50505050905080f35b853b15612d7a57509280948192612d6f9551915af43d15610e89573d90612d2b82613119565b91612d3960405193846130f7565b82523d858484013e7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60405193610e4d85613087565b508038808080612cfc565b808462461bcd60e51b608493526004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152fd5b5084612cf7565b6084846040519062461bcd60e51b82526004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152fd5b9091508781813d8311612e4f575b612e3f81836130f7565b810103126113c057519038612c44565b503d612e35565b50346100f85760203660031901126100f8576020612e75611709613005565b6040519015158152f35b50346100f85760203660031901126100f857612e99613005565b6001600160a01b039081612eab61343e565b16835260cb602052612ec360ff604085205416613394565b1680825260cb60205260ff60408320541615612f145780825260cb60205260408220805460ff191690557fa3b62bc36326052d97ea62d63c3d60308ed4c3ea8ac079dd8499f1e9c4f80c0f8280a280f35b608460405162461bcd60e51b815260206004820152603560248201527f41646d696e3a72656d6f766541646d696e20747279696e6720746f2072656d6f60448201527f7665206e6f6e206578697374696e672041646d696e00000000000000000000006064820152fd5b905034610363576020366003190112610363576004357fffffffff0000000000000000000000000000000000000000000000000000000081168091036101a757602092507fca991254000000000000000000000000000000000000000000000000000000008114908115612ff4575b5015158152f35b6301ffc9a760e01b91501438612fed565b600435906001600160a01b038216820361092857565b35906001600160a01b038216820361092857565b9181601f840112156109285782359167ffffffffffffffff8311610928576020838186019501011161092857565b67ffffffffffffffff811161307157604052565b634e487b7160e01b600052604160045260246000fd5b6060810190811067ffffffffffffffff82111761307157604052565b60c0810190811067ffffffffffffffff82111761307157604052565b6080810190811067ffffffffffffffff82111761307157604052565b6040810190811067ffffffffffffffff82111761307157604052565b90601f8019910116810190811067ffffffffffffffff82111761307157604052565b67ffffffffffffffff811161307157601f01601f191660200190565b92919261314182613119565b9161314f60405193846130f7565b829481845281830111610928578281602093846000960137010152565b1561317357565b608460405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152fd5b156131e457565b608460405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152fd5b803b1561329e576001600160a01b037f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc911673ffffffffffffffffffffffffffffffffffffffff19825416179055565b608460405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152fd5b90919015613314575090565b8151156133245750805190602001fd5b6133489060405191829162461bcd60e51b835260206004840152602483019061336f565b0390fd5b60005b83811061335f5750506000910152565b818101518382015260200161334f565b906020916133888151809281855285808601910161334c565b601f01601f1916010190565b1561339b57565b608460405162461bcd60e51b815260206004820152602660248201527f41646d696e3a6f6e6c7941646d696e2063616c6c6572206973206e6f7420616e60448201527f2041646d696e00000000000000000000000000000000000000000000000000006064820152fd5b60001981146134145760010190565b634e487b7160e01b600052601160045260246000fd5b356001600160a01b03811681036109285790565b337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03160361347a5736601319013560601c90565b3390565b6001600160a01b031680156134cd578060005260cb6020526040600020600160ff198254161790557f44d6d25963f097ad14f29f06854a01f575648a1ef82f30e562ccd3889717e339600080a2565b608460405162461bcd60e51b815260206004820152602b60248201527f41646d696e3a61646441646d696e206e657741646d696e20697320746865207a60448201527f65726f20616464726573730000000000000000000000000000000000000000006064820152fd5b1561353e57565b608460405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152fd5b90816020910312610928575180151581036109285790565b90359060be1981360301821215610928570190565b9080601f83011215610928578160206135f093359101613135565b90565b919060c083820312610928576040519067ffffffffffffffff9060c0830182811184821017613071576040528294803583811161092857826136369183016135d5565b845260208101359283116109285761365460a09392849383016135d5565b60208501526136656040820161301b565b604085015260608101356060850152608081013560808501520135910152565b9060028210156136925752565b634e487b7160e01b600052602160045260246000fd5b9035601e198236030181121561092857016020813591019167ffffffffffffffff821161092857813603831361092857565b908060209392818452848401376000828201840152601f01601f1916010190565b903590601e1981360301821215610928570180359067ffffffffffffffff821161092857602001918160051b3603831361092857565b3561ffff811681036109285790565b600581101561369257806137515750565b6001810361379d57606460405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152fd5b600281036137e957606460405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152fd5b6003146137f257565b608460405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152fd5b90604181511460001461388a57613886916020820151906060604084015193015160001a90613894565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116139175791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa1561390a5781516001600160a01b03811615613904579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b91908110156139455760051b81013590607e1981360301821215610928570190565b634e487b7160e01b600052603260045260246000fd5b608081360312610928576040519067ffffffffffffffff9060808301828111848210176130715760405280358281116109285761399b90369083016135d5565b83526139a96020820161301b565b6020840152604081013560408401526060810135918211610928576139d0913691016135f3565b606082015290565b91908110156139455760051b81013590603e1981360301821215610928570190565b67ffffffffffffffff81116130715760051b60200190565b90613a1c826139fa565b613a2960405191826130f7565b8281528092613a3a601f19916139fa565b0190602036910137565b80518210156139455760209160051b010190565b805160208092019160005b828110613a71575050505090565b835185529381019392810192600101613a63565b903590601e1981360301821215610928570180359067ffffffffffffffff82116109285760200191813603831361092857565b613ac56125cd8280613a85565b602081519101209060a0613adf6125cd6020840184613a85565b60208151910120916001600160a01b03613afb6040830161342a565b6040519460208601967fe624642faf7c3fc1af077178fc4b3efd420220d3170a57bc507fa1d6f8832815885260408701526060860152166080840152606081013582840152608081013560c0840152013560e082015260e08152610100810181811067ffffffffffffffff821117613071576040525190209056fea264697066735822122060bd63135f67d12493f131ec3868551f8db1bc009d9583c40e869dd9ef3b644864736f6c634300081100330000000000000000000000005a6f0240cc0b7386541736049c917e568bd160f6

Deployed Bytecode

0x608080604052600436101561001357600080fd5b600090813560e01c90816301ffc9a714612f7e575080631785f53c14612e7f57806324d7806c14612e565780633659cfe614612b23578063456dcd6314610f6e5780634f1ef28614610bef57806352d1902d14610b1a578063572b6c0514610ac85780635e3b2c991461092d578063643debfe1461040757806370480275146103bf5780638ff4df371461038f578063970c486f1461036757806397c679bc146101ab578063aba47579146100fb5763cfb70e2e146100d157600080fd5b346100f857806003193601126100f85760206001600160a01b036101315416604051908152f35b80fd5b50346100f85760203660031901126100f85767ffffffffffffffff6004358181116101a757366023820112156101a75780600401359182116101a7576024906005368385831b840101116101a3576001600160a01b0361015961343e565b16855260cb60205261017160ff604087205416613394565b845b84811061017e578580f35b806101996101948661019e94861b87010161342a565b61347e565b613405565b610173565b8480fd5b8280fd5b50346100f857602080600319360112610363576101c6613005565b6001600160a01b038091816101d961343e565b16855260cb84526101f060ff604087205416613394565b16906040516301ffc9a760e01b8152631b19349f60e01b60048201528381602481865afa90811561035857859161032b575b50156102d7576101319283549182169083821461027e5750908273ffffffffffffffffffffffffffffffffffffffff19927fd03109d94c8ca45e3dcb73d8703c3c5dc248f3d8ab2ef8e63f59b73a4d8c3b2e8780a31617905580f35b6084906040519062461bcd60e51b82526004820152602c60248201527f557a7545786368616e67653a206578697374696e672073616d652046756e645460448201526b72616e7366657250726f787960a01b6064820152fd5b6084836040519062461bcd60e51b82526004820152602760248201527f557a7545786368616e67653a20696e76616c6964204946756e645472616e7366604482015266657250726f787960c81b6064820152fd5b61034b9150843d8611610351575b61034381836130f7565b8101906135a8565b38610222565b503d610339565b6040513d87823e3d90fd5b5080fd5b50346100f857806003193601126100f85760206001600160a01b036101325416604051908152f35b50346100f85760203660031901126100f85760ff6040602092600435815261013084522054166040519015158152f35b50346100f85760203660031901126100f8576104046103dc613005565b6001600160a01b036103ec61343e565b16835260cb60205261019460ff604085205416613394565b80f35b50346100f85760403660031901126100f857610421613005565b602435906001600160a01b038216820361092857825460ff8160081c16159081809261091b575b8015610904575b1561089a5760ff198116600117855581610889575b5061047e60ff855460081c1661047981613537565b613537565b61048661343e565b916104908361347e565b6001600160a01b0380604051946104a6866130db565b600b86527f557a7545786368616e67650000000000000000000000000000000000000000006020870152610542604051966104e0886130db565b600388527f312e300000000000000000000000000000000000000000000000000000000000602089015289549760ff8960081c169161051e83613537565b61052783613537565b60208151910120906020815191012090603355603455613537565b169182875260cb60205261055c60ff604089205416613394565b1690604051906301ffc9a760e01b91828152631b19349f60e01b6004820152602081602481875afa90811561087e57889161085f575b501561080b576101318054936001600160a01b0385168181146107b25781907fd03109d94c8ca45e3dcb73d8703c3c5dc248f3d8ab2ef8e63f59b73a4d8c3b2e8b80a373ffffffffffffffffffffffffffffffffffffffff19809516179055865260cb60205261060860ff604088205416613394565b604051908152633a03be4360e01b60048201526020816024816001600160a01b0389165afa9081156107a7578691610788575b501561073557610132908154906001600160a01b038216956001600160a01b03811687146106dd576001600160a01b039060405197828216907f557463bb380f634e0ff0c656a09566f9e7bcacbc6cb16eba1d108a86719f5f168b80a31691161790556106a6578280f35b61ff0019168255600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a138808280f35b608460405162461bcd60e51b815260206004820152602b60248201527f557a7545786368616e67653a206578697374696e672073616d65204e6674547260448201526a616e7366657250726f787960a81b6064820152fd5b608460405162461bcd60e51b815260206004820152602660248201527f557a7545786368616e67653a20696e76616c696420494e66745472616e7366656044820152657250726f787960d01b6064820152fd5b6107a1915060203d6020116103515761034381836130f7565b3861063b565b6040513d88823e3d90fd5b608460405162461bcd60e51b815260206004820152602c60248201527f557a7545786368616e67653a206578697374696e672073616d652046756e645460448201526b72616e7366657250726f787960a01b6064820152fd5b608460405162461bcd60e51b815260206004820152602760248201527f557a7545786368616e67653a20696e76616c6964204946756e645472616e7366604482015266657250726f787960c81b6064820152fd5b610878915060203d6020116103515761034381836130f7565b38610592565b6040513d8a823e3d90fd5b61ffff191661010117845538610464565b608460405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152fd5b50303b15801561044f5750600160ff82161461044f565b50600160ff821610610448565b600080fd5b50346100f85760208060031936011261036357610948613005565b6001600160a01b0380918161095b61343e565b16855260cb845261097260ff604087205416613394565b16906040516301ffc9a760e01b8152633a03be4360e01b60048201528381602481865afa908115610358578591610aab575b5015610a585761013292835491821690838214610a005750908273ffffffffffffffffffffffffffffffffffffffff19927f557463bb380f634e0ff0c656a09566f9e7bcacbc6cb16eba1d108a86719f5f168780a31617905580f35b6084906040519062461bcd60e51b82526004820152602b60248201527f557a7545786368616e67653a206578697374696e672073616d65204e6674547260448201526a616e7366657250726f787960a81b6064820152fd5b6084836040519062461bcd60e51b82526004820152602660248201527f557a7545786368616e67653a20696e76616c696420494e66745472616e7366656044820152657250726f787960d01b6064820152fd5b610ac29150843d86116103515761034381836130f7565b386109a4565b50346100f85760203660031901126100f8576020610ae4613005565b604051906001600160a01b03807f0000000000000000000000005a6f0240cc0b7386541736049c917e568bd160f6169116148152f35b50346100f857806003193601126100f8576001600160a01b037f000000000000000000000000e1f5dd6ba03cc5500081775827dfbf8dc29250e5163003610b855760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b608460405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152fd5b5060403660031901126100f857610c04613005565b9060243567ffffffffffffffff8111610363573660238201121561036357610c36903690602481600401359101613135565b916001600160a01b03807f000000000000000000000000e1f5dd6ba03cc5500081775827dfbf8dc29250e516610c6e8130141561316c565b610c9d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9183835416146131dd565b81610ca661343e565b16845260209160cb8352610cc060ff604087205416613394565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610cf85750505061040491925061324e565b8392949316906040516352d1902d60e01b81528581600481865afa60009181610f3f575b50610d8b576084866040519062461bcd60e51b82526004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152fd5b94939403610ee957610d9c8261324e565b604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2845115801590610ee1575b610ddd575b505050905080f35b813b15610e915750600084819284610e7f9697519201905af43d15610e89573d90610e0782613119565b91610e1560405193846130f7565b82523d60008484013e5b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60405193610e4d85613087565b602785528401527f206661696c6564000000000000000000000000000000000000000000000000006040840152613308565b5080388080610dd5565b606090610e1f565b808362461bcd60e51b608493526004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152fd5b506001610dd0565b6084836040519062461bcd60e51b82526004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152fd5b90918782813d8311610f67575b610f5681836130f7565b810103126100f85750519038610d1c565b503d610f4c565b5060803660031901126100f85767ffffffffffffffff600435116100f857610220600435360360031901126100f85760243567ffffffffffffffff811161036357610fbd90369060040161302f565b909167ffffffffffffffff604435116100f857610100604435360360031901126100f85760643567ffffffffffffffff81116103635761100190369060040161302f565b6004356004013515612ab95760043560040135835261013060205260ff604084205416612a4f5760246004350135151580612a3f575b156129d557604460043501351580156129c6575b1561295c5761105e60646004350161342a565b3b156128f25760a46004350135156128ae5760c46004350135156128445760e46004350135156127db576001600160a01b0361109f6101246004350161342a565b161561278d576001600160a01b036110bc6101446004350161342a565b1615612723576001600160a01b036110d96101646004350161342a565b16156126df57825b6110f66101e4600435016004356004016136fb565b9050811015611222576111266111218261111b6101e4600435016004356004016136fb565b90613923565b61395b565b805151156111b857602001516001600160a01b03161561114e5761114990613405565b6110e1565b608460405162461bcd60e51b815260206004820152602d60248201527f557a7545786368616e67653a20696e76616c696420726f79616c74792e72656360448201527f697069656e7441646472657373000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602a60248201527f557a7545786368616e67653a20696e76616c696420726f79616c74792e72656360448201527f697069656e7454797065000000000000000000000000000000000000000000006064820152fd5b5084835b61123b610204600435016004356004016136fb565b90508110156113dc576112638161125d610204600435016004356004016136fb565b906139d8565b6040813603126113d8576040519081604081011067ffffffffffffffff6040840111176113c4576040820160405261129a8161301b565b825267ffffffffffffffff6020820135116113c0576112c86001600160a01b039136906020810135016135d5565b9160208101928352511615611356575151156112ec576112e790613405565b611226565b608460405162461bcd60e51b815260206004820152602860248201527f557a7545786368616e67653a20696e76616c69642063727561746f722e63757260448201527f61746f72547970650000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602b60248201527f557a7545786368616e67653a20696e76616c69642063727561746f722e63757260448201527f61746f72416464726573730000000000000000000000000000000000000000006064820152fd5b8680fd5b602487634e487b7160e01b81526041600452fd5b8580fd5b50846113ec60646004350161342a565b91600260846004350135101592836113c05761140d6101246004350161342a565b61141c6101446004350161342a565b61142b6101646004350161342a565b61143a61018460043501613731565b6114576114526101a4600435016004356004016135c0565b613ab8565b906114706114526101c4600435016004356004016135c0565b928c6114876101e4600435016004356004016136fb565b61149081613a12565b925b81811061263f575050506040516114bf816114b1602082018095613a58565b03601f1981018352826130f7565b519020948d6114d9610204600435016004356004016136fb565b6114e281613a12565b925b8181106125a4575050506040518060208101928361150191613a58565b03601f198101825261151390826130f7565b519020966040519860208a017f9a30949473f7060ed7d984f94495e2d6db584d8074b32e7861e46b524e55557c90526004356004013560408b01526004356024013560608b01526004356044013560808b01526001600160a01b031660a08a015260c08901600435608401359061158991613685565b60043560a4013560e08a015260043560c401356101008a015260043560e401356101208a015260043561010401356101408a01526001600160a01b03166101608901526001600160a01b03166101808801526001600160a01b03166101a087015261ffff166101c08601526101e08501526102008401526102208301526102409081830152815280610260810110610260820167ffffffffffffffff10176113c457611726926116fb611709938361026061170195016040528051602082012090610260603354916034546102808201937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f85526102a08301526102c0820152466102e08201523061030082015260a0828201526116a88282016130a3565b01519020906040519060208201927f1901000000000000000000000000000000000000000000000000000000000000845260228301526042820152604281526116f0816130bf565b519020923691613135565b9061385c565b919091613740565b6001600160a01b031660005260cb60205260ff6040600020541690565b156125565760043560040135845261013060205260408420600160ff19825416179055611767366117626101a4600435016004356004016135c0565b6135f3565b90346123aa575b611796602083516040518093819263d44d255760e01b8352846004840152602483019061336f565b038173d143026e990b58149a4b347e94333973dd72b2275af49081156107a757869161238b575b5080612375575b6122cc575b6117e2366117626101c4600435016004356004016135c0565b9061180b602083516040518093819263d44d255760e01b8352846004840152602483019061336f565b038173d143026e990b58149a4b347e94333973dd72b2275af49081156122c15787916122a2575b506121a2575b6118476101646004350161342a565b93865b61185f6101e4600435016004356004016136fb565b9050811015611b46576118846111218261111b6101e4600435016004356004016136fb565b906118b06118a18261111b6101e4600435016004356004016136fb565b611762369160608101906135c0565b6118d8602082516040518093819263d44d255760e01b8352846004840152602483019061336f565b038173d143026e990b58149a4b347e94333973dd72b2275af4908115611b3b578b91611b1c575b506119df575b826119da9351907ff2542b261fd65b2cfbd5d50bae4d85a8e55df6eb5a13bb6dba9d400c066923e26001600160a01b03602083015116928451906020860151936001600160a01b036040880151169660608101516119ac611983604060a060808601519501519501519560206040519282848094519384920161334c565b81010390209761199e6040519760e0895260e089019061336f565b90878203602089015261336f565b9860408601526060850152608084015260a083015260c0820152806001600160a01b038d16950390a4613405565b61184a565b896001600160a01b036040830151168015600014611a9057506001600160a01b0361013154166001600160a01b036020860151166060840151823b15611a8c576040516307638ad760e51b81526001600160a01b0392909216600483015260248201529082908290604490829084905af18015611a8157611a69575b50506119da925b9250611905565b611a729061305d565b611a7d57898b611a5b565b8980fd5b6040513d84823e3d90fd5b8380fd5b6001600160a01b036101315416906001600160a01b0360208701511691606085015190803b156101a35760405163b04dc6ef60e01b81526001600160a01b039384166004820152939092166024840152604483015282908290606490829084905af18015611a8157611b08575b50506119da92611a62565b611b119061305d565b611a7d57898b611afd565b611b35915060203d6020116103515761034381836130f7565b8b6118ff565b6040513d8d823e3d90fd5b508694508560448035013515611fc6576001600160a01b03610132541690611b736101246004350161342a565b91611b836101646004350161342a565b85611b9260646004350161342a565b90611a7d57823b15611a7d576001600160a01b03809281604051976305e6548d60e51b895216600488015216602486015260c46004350135604486015260a460043501356064860152166084840152611bf460a4840160846004350135613685565b61014060c48401526000610144840152604480350135151560e4840152610160610104840152611cab60443560040180356101648601526001600160a01b03611c4160246044350161301b565b166101848601526044803501356101a4860152606460443501356101c4860152611c97611c8a611c76608460443501846136a8565b6101006101e48a01526102648901916136da565b9160a460443501906136a8565b8683036101631901610204880152906136da565b906001600160a01b03611cc260c46044350161301b565b1661022485015260e46044350135916bffffffffffffffffffffffff83168303610928578985611d1a819593839984986bffffffffffffffffffffffff859716610244860152600319858403016101248601526136da565b03925af18015611a8157611fb2575b50505b611d3a60646004350161342a565b90611a8c57611d4e6101246004350161342a565b6001600160a01b03611d656101446004350161342a565b611d746101646004350161342a565b611d89610204600435016004356004016136fb565b93909181611d9c61018460043501613731565b948160405198611db28a60846004350135613685565b60c4600435013560208b015260e4600435013560408b01521660608901521660808701521660a085015261010060c08501528261010085015261012084016101208460051b86010193828a905b828210611f4557505050505061ffff1660e083015260043560a40135926001600160a01b031691806004356004013592037f6757cfa181840e9e3e9964c8c34a790a30cb2bcc75b88286149a6ebee460fcaf91a481519060208301519260408101516001600160a01b03169160608201519160808101519060a0015193825160208401519160408501516001600160a01b03169660608601519460808701519660a00151976040519b8c9b6101808d526101808d01611ebd9161336f565b8c810360208e0152611ece9161336f565b9360408c015260608b015260808a015260a089015287810360c0890152611ef49161336f565b86810360e0880152611f059161336f565b93610100860152610120850152610140840152610160830152037fa8fed2eeed33c77e6a1eaca87e011d01f27d87401350a8f51530ea36ced1d06b91a180f35b909192939561011f198882030185528635603e1983360301811215611fae576020611fa16001936040611f92878596016001600160a01b03611f868261301b565b168452858101906136a8565b919092818682015201916136da565b9801950193920190611dff565b8c80fd5b611fbb9061305d565b611a8c578385611d29565b9091506001600160a01b036101325416611fe56101246004350161342a565b91611ff56101646004350161342a565b9361200460646004350161342a565b94600095843b15611a7d576001600160a01b03809281604051986305e6548d60e51b8a5216600489015216602487015260c46004350135604487015260a46004350135606487015216608485015261206560a4850160846004350135613685565b61014060c4850152846101448501528460e485015261016061010485015261210760443560040180356101648701526001600160a01b036120aa60246044350161301b565b166101848701526044803501356101a4870152606460443501356101c48701526120f3611c8a6120df608460443501846136a8565b6101006101e48b01526102648a01916136da565b8783036101631901610204890152906136da565b916001600160a01b0361211e60c46044350161301b565b1661022486015260e460443501356bffffffffffffffffffffffff811681036113c0579489816121788298968298959683976bffffffffffffffffffffffff869a16610244860152600319858403016101248601526136da565b03925af18015611a815761218e575b5050611d2c565b6121979061305d565b611a8c578385612187565b856001600160a01b03604084015116801560001461223c57506001600160a01b0361013154166121d76101446004350161342a565b6060850151823b15611a8c576040516307638ad760e51b81526001600160a01b03909216600483015260248201529082908290818381604481015b03925af18015611a8157612228575b5050611838565b6122319061305d565b6113d8578587612221565b6001600160a01b036101315416906122596101446004350161342a565b91606086015190803b156101a35760405163b04dc6ef60e01b81526001600160a01b03938416600482015293909216602484015260448301528290829081838160648101612212565b6122bb915060203d6020116103515761034381836130f7565b87611832565b6040513d89823e3d90fd5b846001600160a01b0361013154166001600160a01b0360408501511660608501516122fc6101646004350161342a565b92803b156101a3578492836064926001600160a01b0360405197889687957fbe9bc258000000000000000000000000000000000000000000000000000000008752600487015260248601521660448401525af18015611a8157612361575b50506117c9565b61236a9061305d565b6101a357848661235a565b506001600160a01b0360408301511615156117c4565b6123a4915060203d6020116103515761034381836130f7565b866117bd565b60608201513481036124265750846001600160a01b03610131541660608401516123d261343e565b823b15611a8c5760246001600160a01b0391859360405195869485936357b145a560e11b85521660048401525af18015611a8157612412575b505061176e565b61241b9061305d565b6101a357848661240b565b3411156124ec576001600160a01b03610131541660608301518661244861343e565b92803b15610363576024604051809481936357b145a560e11b83526001600160a01b03881660048401525af180156122c1576124d9575b50606083015134813403116124c55786808093819382908034146124bb575b3403916001600160a01b031690f161176e576040513d86823e3d90fd5b6108fc915061249e565b602487634e487b7160e01b81526011600452fd5b6124e59096919661305d565b948661247f565b608460405162461bcd60e51b815260206004820152602f60248201527f557a7545786368616e67653a206e6f7420656e6f75676874206e61746976652060448201527f746f6b656e73206172652073656e7400000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f557a7545786368616e67653a20696e76616c6964206f72646572207369676e656044820152603960f91b6064820152fd5b806125b361263a9284866139d8565b6125d46125cd6125c28361342a565b926020810190613a85565b3691613135565b60208151910120604051906001600160a01b0360208301937f3368eda4c006f63bc3e286003bf874dcf861e5565a691d913bb9c32bfb7447528552166040830152606090818301528152612627816130bf565b5190206126348287613a44565b52613405565b6114e4565b8061264e6126da928486613923565b61265b6125cd8280613a85565b602081519101209061266f6020820161342a565b906040606091612684611452848301836135c0565b926001600160a01b0383519560208701977f3e996bae226469b8a4faff6b2ee8b4b33aac0d6f398c0021adc7797d52e55da289528588015216908501520135608083015260a090818301528152612627816130a3565b611492565b606460405162461bcd60e51b815260206004820152602060248201527f557a7545786368616e67653a20696e76616c6964206f726465722e62757965726044820152fd5b608460405162461bcd60e51b815260206004820152602a60248201527f557a7545786368616e67653a20696e76616c6964206f726465722e7061796d6560448201527f6e745265636569766572000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f557a7545786368616e67653a20696e76616c6964206f726465722e73656c6c656044820152603960f91b6064820152fd5b608460405162461bcd60e51b8152602060048201526024808201527f557a7545786368616e67653a20696e76616c6964206f726465722e73616c655060448201527f72696365000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602160248201527f557a7545786368616e67653a20696e76616c6964206f726465722e616d6f756e60448201527f74000000000000000000000000000000000000000000000000000000000000006064820152fd5b606460405162461bcd60e51b815260206004820152602060248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6e667449646044820152fd5b608460405162461bcd60e51b815260206004820152602c60248201527f557a7545786368616e67653a20696e76616c6964206f726465722e636f6c6c6560448201527f6374696f6e4164647265737300000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602960248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6f7264657260448201527f45787069726573417400000000000000000000000000000000000000000000006064820152fd5b5042604460043501351161104b565b608460405162461bcd60e51b815260206004820152602960248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6f7264657260448201527f43726561746564417400000000000000000000000000000000000000000000006064820152fd5b5042602460043501351115611037565b608460405162461bcd60e51b815260206004820152602260248201527f557a7545786368616e67653a206f7264657220616c72656164792070726f636560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b608460405162461bcd60e51b815260206004820152602260248201527f557a7545786368616e67653a20696e76616c6964206f726465722e6f7264657260448201527f49640000000000000000000000000000000000000000000000000000000000006064820152fd5b50346100f85760208060031936011261036357612b3e613005565b906001600160a01b03807f000000000000000000000000e1f5dd6ba03cc5500081775827dfbf8dc29250e516612b768130141561316c565b612ba57f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9183835416146131dd565b81612bae61343e565b16855260cb8352612bc560ff604087205416613394565b604051908382019282841067ffffffffffffffff8511176113c4578360405286835260ff7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435416600014612c215750505050506104049061324e565b8596949516906040516352d1902d60e01b81528681600481865afa869181612e27575b50612cb3576084876040519062461bcd60e51b82526004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152fd5b95949503612dd157612cc48661324e565b604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8680a2815115801590612dca575b612d05575b50505050905080f35b853b15612d7a57509280948192612d6f9551915af43d15610e89573d90612d2b82613119565b91612d3960405193846130f7565b82523d858484013e7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60405193610e4d85613087565b508038808080612cfc565b808462461bcd60e51b608493526004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152fd5b5084612cf7565b6084846040519062461bcd60e51b82526004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152fd5b9091508781813d8311612e4f575b612e3f81836130f7565b810103126113c057519038612c44565b503d612e35565b50346100f85760203660031901126100f8576020612e75611709613005565b6040519015158152f35b50346100f85760203660031901126100f857612e99613005565b6001600160a01b039081612eab61343e565b16835260cb602052612ec360ff604085205416613394565b1680825260cb60205260ff60408320541615612f145780825260cb60205260408220805460ff191690557fa3b62bc36326052d97ea62d63c3d60308ed4c3ea8ac079dd8499f1e9c4f80c0f8280a280f35b608460405162461bcd60e51b815260206004820152603560248201527f41646d696e3a72656d6f766541646d696e20747279696e6720746f2072656d6f60448201527f7665206e6f6e206578697374696e672041646d696e00000000000000000000006064820152fd5b905034610363576020366003190112610363576004357fffffffff0000000000000000000000000000000000000000000000000000000081168091036101a757602092507fca991254000000000000000000000000000000000000000000000000000000008114908115612ff4575b5015158152f35b6301ffc9a760e01b91501438612fed565b600435906001600160a01b038216820361092857565b35906001600160a01b038216820361092857565b9181601f840112156109285782359167ffffffffffffffff8311610928576020838186019501011161092857565b67ffffffffffffffff811161307157604052565b634e487b7160e01b600052604160045260246000fd5b6060810190811067ffffffffffffffff82111761307157604052565b60c0810190811067ffffffffffffffff82111761307157604052565b6080810190811067ffffffffffffffff82111761307157604052565b6040810190811067ffffffffffffffff82111761307157604052565b90601f8019910116810190811067ffffffffffffffff82111761307157604052565b67ffffffffffffffff811161307157601f01601f191660200190565b92919261314182613119565b9161314f60405193846130f7565b829481845281830111610928578281602093846000960137010152565b1561317357565b608460405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152fd5b156131e457565b608460405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152fd5b803b1561329e576001600160a01b037f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc911673ffffffffffffffffffffffffffffffffffffffff19825416179055565b608460405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152fd5b90919015613314575090565b8151156133245750805190602001fd5b6133489060405191829162461bcd60e51b835260206004840152602483019061336f565b0390fd5b60005b83811061335f5750506000910152565b818101518382015260200161334f565b906020916133888151809281855285808601910161334c565b601f01601f1916010190565b1561339b57565b608460405162461bcd60e51b815260206004820152602660248201527f41646d696e3a6f6e6c7941646d696e2063616c6c6572206973206e6f7420616e60448201527f2041646d696e00000000000000000000000000000000000000000000000000006064820152fd5b60001981146134145760010190565b634e487b7160e01b600052601160045260246000fd5b356001600160a01b03811681036109285790565b337f0000000000000000000000005a6f0240cc0b7386541736049c917e568bd160f66001600160a01b03160361347a5736601319013560601c90565b3390565b6001600160a01b031680156134cd578060005260cb6020526040600020600160ff198254161790557f44d6d25963f097ad14f29f06854a01f575648a1ef82f30e562ccd3889717e339600080a2565b608460405162461bcd60e51b815260206004820152602b60248201527f41646d696e3a61646441646d696e206e657741646d696e20697320746865207a60448201527f65726f20616464726573730000000000000000000000000000000000000000006064820152fd5b1561353e57565b608460405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152fd5b90816020910312610928575180151581036109285790565b90359060be1981360301821215610928570190565b9080601f83011215610928578160206135f093359101613135565b90565b919060c083820312610928576040519067ffffffffffffffff9060c0830182811184821017613071576040528294803583811161092857826136369183016135d5565b845260208101359283116109285761365460a09392849383016135d5565b60208501526136656040820161301b565b604085015260608101356060850152608081013560808501520135910152565b9060028210156136925752565b634e487b7160e01b600052602160045260246000fd5b9035601e198236030181121561092857016020813591019167ffffffffffffffff821161092857813603831361092857565b908060209392818452848401376000828201840152601f01601f1916010190565b903590601e1981360301821215610928570180359067ffffffffffffffff821161092857602001918160051b3603831361092857565b3561ffff811681036109285790565b600581101561369257806137515750565b6001810361379d57606460405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152fd5b600281036137e957606460405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152fd5b6003146137f257565b608460405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152fd5b90604181511460001461388a57613886916020820151906060604084015193015160001a90613894565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116139175791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa1561390a5781516001600160a01b03811615613904579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b91908110156139455760051b81013590607e1981360301821215610928570190565b634e487b7160e01b600052603260045260246000fd5b608081360312610928576040519067ffffffffffffffff9060808301828111848210176130715760405280358281116109285761399b90369083016135d5565b83526139a96020820161301b565b6020840152604081013560408401526060810135918211610928576139d0913691016135f3565b606082015290565b91908110156139455760051b81013590603e1981360301821215610928570190565b67ffffffffffffffff81116130715760051b60200190565b90613a1c826139fa565b613a2960405191826130f7565b8281528092613a3a601f19916139fa565b0190602036910137565b80518210156139455760209160051b010190565b805160208092019160005b828110613a71575050505090565b835185529381019392810192600101613a63565b903590601e1981360301821215610928570180359067ffffffffffffffff82116109285760200191813603831361092857565b613ac56125cd8280613a85565b602081519101209060a0613adf6125cd6020840184613a85565b60208151910120916001600160a01b03613afb6040830161342a565b6040519460208601967fe624642faf7c3fc1af077178fc4b3efd420220d3170a57bc507fa1d6f8832815885260408701526060860152166080840152606081013582840152608081013560c0840152013560e082015260e08152610100810181811067ffffffffffffffff821117613071576040525190209056fea264697066735822122060bd63135f67d12493f131ec3868551f8db1bc009d9583c40e869dd9ef3b644864736f6c63430008110033

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

0000000000000000000000005a6f0240cc0b7386541736049c917e568bd160f6

-----Decoded View---------------
Arg [0] : _trustedForwarder (address): 0x5A6F0240cc0B7386541736049C917e568bd160f6

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000005a6f0240cc0b7386541736049c917e568bd160f6


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

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.