false
false

Contract Address Details

0x5d774245F4C1e7318F90ab8362184c39f2728981

Contract Name
ExchangeV4
Creator
0xded443–e738b9 at 0x88bd5c–512ce6
Balance
0
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
4179
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
ExchangeV4




Optimization enabled
true
Compiler version
v0.8.19+commit.7dd6d404




Optimization runs
200
EVM Version
default




Verified at
2024-08-19T12:24:10.207301Z

Constructor Arguments

0x000000000000000000000000307e7a9713dbf6f19a2d2a2b670544f4791c4ec2

Arg [0] (address) : 0x307e7a9713dbf6f19a2d2a2b670544f4791c4ec2

              

contracts/sbinft/market/v4/exchange/ExchangeV4.sol

Sol2uml
new
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "@sbinft/contracts/upgradeable/access/AdminUpgradeable.sol";
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 "@openzeppelin/contracts-upgradeable/metatx/ERC2771ContextUpgradeable.sol";
import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "contracts/sbinft/market/v1/interface/IPlatformRegistry.sol";
import "contracts/sbinft/market/v1/interface/ITransferProxy.sol";
import "contracts/sbinft/market/v1/interface/IRoyaltyRegistry.sol";
import "contracts/sbinft/market/v4/interface/IExchangeV4.sol";

/**
 * @dev SBINFT Exchange 4.0
 * @author SBINFT Co., Ltd.
 */
contract ExchangeV4 is
  Initializable,
  IExchangeV4,
  EIP712Upgradeable,
  ERC2771ContextUpgradeable,
  AdminUpgradeable,
  ERC165Upgradeable,
  ReentrancyGuardUpgradeable,
  PausableUpgradeable,
  UUPSUpgradeable
{
  using ECDSAUpgradeable for bytes32;

  // Fired when PlatformRegistry is changed
  event PlatformRegistryUpdated(IPlatformRegistry indexed platformRegistry);
  // PlatformRegistry holds platform related info
  IPlatformRegistry public platformRegistry;

  // Fired when TransferProxy is changed
  event TransferProxyUpdated(ITransferProxy indexed transferProxy);
  // Holds access rights for on-chain asset transfer.
  // Must be pre approved for the respective asset
  ITransferProxy public transferProxy;

  // Fired when RoyaltyRegistry is changed
  event RoyaltyRegistryUpdated(IRoyaltyRegistry indexed royaltyRegistry);
  // RoyaltyRegistry holds Royalty info
  IRoyaltyRegistry public royaltyRegistry;

  // Map of SaleOrderHash => soldCount
  // Instead of soldCount being uint256 it can be bool but using uint256 inorder to support ERC1155 later
  mapping(bytes32 => uint256) internal _saleProgress;

  // Tip related
  struct ERC20Tip {
    address tipper;
    uint256 amount;
  }
  mapping(address => ERC20Tip[]) internal _erc20TipDeposite;

  // Just a temp variable to be used as local function variable
  // as mapping declaration is not supported inside function
  mapping(address => uint256) internal _tempPayoutAmount;
  address[] internal _tempPayoutAddress;

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

  /**
   * @dev See {UUPSUpgradeable._authorizeUpgrade()}
   *
   * 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, IERC165Upgradeable)
    returns (bool)
  {
    return
      _interfaceId == type(IExchangeV4).interfaceId ||
      super.supportsInterface(_interfaceId);
  }

  /**
   * See {ERC2771ContextUpgradeable._msgSender()}
   */
  function _msgSender()
    internal
    view
    virtual
    override(ContextUpgradeable, ERC2771ContextUpgradeable)
    returns (address sender)
  {
    return ERC2771ContextUpgradeable._msgSender();
  }

  /**
   * See {ERC2771ContextUpgradeable._msgData()}
   */
  function _msgData()
    internal
    view
    virtual
    override(ContextUpgradeable, ERC2771ContextUpgradeable)
    returns (bytes calldata)
  {
    return ERC2771ContextUpgradeable._msgData();
  }

  /**
   * @dev See {PausableUpgradeable._pause()}
   *
   * Requirements:
   * - onlyAdmin can call
   */
  function pause() external virtual onlyAdmin {
    PausableUpgradeable._pause();
  }

  /**
   * @dev See {PausableUpgradeable._unpause()}
   *
   * Requirements:
   * - onlyAdmin can call
   */
  function unpause() external virtual onlyAdmin {
    PausableUpgradeable._unpause();
  }

  /**
   * @dev Update to new PlatformRegistry
   *
   * @param _newPlatformRegistry new PlatformRegistry
   *
   * Requirements:
   * - _newPlatformRegistry must be a contract and must support IPlatformRegistry
   *
   * Emits a {PlatformRegistryUpdated} event
   */
  function updatePlatformRegistry(
    IPlatformRegistry _newPlatformRegistry
  ) public virtual onlyAdmin {
    // EM: IPlatformRegistry interface not supported
    require(
      IPlatformRegistry(_newPlatformRegistry).supportsInterface(
        type(IPlatformRegistry).interfaceId
      ),
      "E_INS"
    );

    platformRegistry = _newPlatformRegistry;

    emit PlatformRegistryUpdated(_newPlatformRegistry);
  }

  /**
   * @dev Update to new TransferProxy
   *
   * @param _newTransferProxy new TransferProxy
   *
   * Requirements:
   * - _newTransferProxy must be a contract and must support ITransferProxy
   *
   * Emits a {TransferProxyUpdated} event
   */
  function updateTransferProxy(
    ITransferProxy _newTransferProxy
  ) public virtual onlyAdmin {
    // EM: ITransferProxy interface not supported
    require(
      ITransferProxy(_newTransferProxy).supportsInterface(
        type(ITransferProxy).interfaceId
      ),
      "E_INS"
    );

    transferProxy = _newTransferProxy;

    emit TransferProxyUpdated(_newTransferProxy);
  }

  /**
   * @dev Update to new RoyaltyRegistry
   *
   * @param _newRoyaltyRegistry new RoyaltyRegistry
   *
   * Requirements:
   * - _newRoyaltyRegistry must be a contract and must support IRoyaltyRegistry
   *
   * Emits a {RoyaltyManagerUpdated} event
   */
  function updateRoyaltyRegistry(
    IRoyaltyRegistry _newRoyaltyRegistry
  ) public virtual onlyAdmin {
    // EM: IRoyaltyRegistry interface not supported
    require(
      IRoyaltyRegistry(_newRoyaltyRegistry).supportsInterface(
        type(IRoyaltyRegistry).interfaceId
      ),
      "E_INS"
    );

    royaltyRegistry = _newRoyaltyRegistry;

    emit RoyaltyRegistryUpdated(_newRoyaltyRegistry);
  }

  /**
   * @dev Gets sold count of an order
   *
   * @param _saleKey Sale key
   * @return sold count of an order
   */
  function getSoldCountByKey(
    bytes32 _saleKey
  ) public view virtual returns (uint256) {
    return _saleProgress[_saleKey];
  }

  /**
   * @dev Gets sold count of an order
   *
   * @param _nonce Sale nonce
   * @param _token token address
   * @param _tokenId token ID
   * @return sold count of an order
   */
  function getSoldCountByNonce(
    uint256 _nonce,
    address _token,
    uint256 _tokenId
  ) public view virtual returns (uint256) {
    return _saleProgress[keccak256(abi.encode(_nonce, _token, _tokenId))];
  }

  /**
   * @dev Updates order state as sold
   *
   * @param _saleKey Sale Key
   * @param _soldValueCount sold value count
   */
  function _setSoldByKey(
    bytes32 _saleKey,
    uint256 _soldValueCount
  ) internal virtual {
    unchecked {
      _saleProgress[_saleKey] += _soldValueCount;
    }
  }

  /**
   * @dev Updates order state as sold
   *
   * @param _nonce Sale nonce
   * @param _token token address
   * @param _tokenId token ID
   * @param _soldValueCount sold value count
   */
  function _setSoldByNonce(
    uint256 _nonce,
    address _token,
    uint256 _tokenId,
    uint256 _soldValueCount
  ) internal virtual {
    unchecked {
      _saleProgress[
        keccak256(abi.encode(_nonce, _token, _tokenId))
      ] += _soldValueCount;
    }
  }

  /**
   * @dev Simulate the PartnerFeeTransfer(Not actual transfer)
   *
   * @param _asset OrderDomainV4.Asset
   * @param _pricePerAsset uint256 price of the asset
   * @param _version uint8 version of the Asset
   */
  function _simulateRoyaltyTransfer(
    OrderDomainV4.Asset calldata _asset,
    uint256 _pricePerAsset,
    uint8 _version
  ) internal virtual returns (uint256) {
    (
      address[] memory royaltyReceivers,
      uint256[] memory royaltyReceiversCut,

    ) = royaltyRegistry.royaltyInfo(
        _asset.token,
        _asset.tokenId,
        _pricePerAsset,
        _asset.isSecondarySale
      );

    uint256 royaltyReceiversCount = royaltyReceivers.length;
    uint256 idx = 0;
    if (
      _version >= 2 &&
      royaltyReceiversCount == 0 &&
      _asset.royaltyReceivers.length > 0
    ) {
      // No RoyaltyRegistry info is set, use Royalty from parameter
      royaltyReceivers = _asset.royaltyReceivers;
      royaltyReceiversCount = royaltyReceivers.length;

      // EM: Invalid royalty data
      // EM: secondaryOnwardsRoyaltyPercentage greater than 100%
      require(
        (royaltyReceiversCount == _asset.royaltyDistributionRate.length) &&
          (_asset.secondaryOnwardsRoyaltyPercentage <=
            OrderDomainV4.FEE_DENOMINATOR),
        "E_IRD_SOPG100"
      );

      // Find the amount that needs to be split for royalty
      uint256 splitTotalPrice = _pricePerAsset;
      if (_asset.isSecondarySale == 1) {
        // Secondary Sale onwards royalty is distributed based on royaltyPercentage
        unchecked {
          splitTotalPrice =
            (_pricePerAsset * _asset.secondaryOnwardsRoyaltyPercentage) /
            OrderDomainV4.FEE_DENOMINATOR;
        }
      }

      // Find/Calculate royaltyReceiversCut
      royaltyReceiversCut = new uint256[](royaltyReceiversCount);
      uint16 totalPercentage = 0;
      for (idx = 0; idx < royaltyReceiversCount; ) {
        unchecked {
          // EM: zero address must not be included in receivers
          require(royaltyReceivers[idx] != address(0), "E_IRA");

          uint16 distRate = _asset.royaltyDistributionRate[idx];
          royaltyReceiversCut[idx] =
            (splitTotalPrice * distRate) /
            OrderDomainV4.FEE_DENOMINATOR;

          totalPercentage += distRate;
          idx++;
        }
      }

      // EM: receiversPercentage total in not 100%
      require(totalPercentage == OrderDomainV4.FEE_DENOMINATOR, "E_RPN100");
    }

    uint256 totalRoyaltyToSend = 0;
    for (idx = 0; idx < royaltyReceiversCount; ) {
      uint256 royaltyReceiverCut = royaltyReceiversCut[idx];

      _registerPayout(royaltyReceivers[idx], royaltyReceiverCut);

      unchecked {
        totalRoyaltyToSend += royaltyReceiverCut;

        idx++;
      }
    }

    return totalRoyaltyToSend;
  }

  /**
   * @dev Payout to all receivers using _tempPayoutAddress and _tempPayoutAmount
   * when execting exchange
   *
   * @param _paymentMode bytes4 Payment.paymentMode
   * @param _paymentToken address
   * @param _payer address
   */
  function _payout(
    bytes4 _paymentMode,
    address _paymentToken,
    address _payer
  ) internal virtual {
    for (uint256 idx = 0; idx < _tempPayoutAddress.length; ) {
      address payable reciever = payable(_tempPayoutAddress[idx]);
      uint256 amount = _tempPayoutAmount[reciever];

      if (_paymentMode == OrderDomainV4.NATIVE_PAYMENT_MODE) {
        // Sending ETH
        reciever.transfer(amount);
      } else if (_paymentMode == OrderDomainV4.ERC20_PAYMENT_MODE) {
        // Sending ERC20
        transferProxy.erc20safeTransferFrom(
          IERC20(_paymentToken),
          _payer,
          reciever,
          amount
        );
      }

      unchecked {
        idx++;
      }
    }
  }

  /**
   * @dev Register payment locally, to be used in _payout
   *
   * @param _reciever address
   * @param _amount uint256
   */
  function _registerPayout(
    address _reciever,
    uint256 _amount
  ) internal virtual {
    if (_amount > 0) {
      if (_tempPayoutAmount[_reciever] == 0) {
        _tempPayoutAddress.push(_reciever);
      }
      unchecked {
        _tempPayoutAmount[_reciever] += _amount;
      }
    }
  }

  /**
   * @dev Clears previous payout data
   *
   * It is used for collective payment to pay one address only once
   */
  function _resetPayoutTemp() internal virtual {
    for (uint256 idx = 0; idx < _tempPayoutAddress.length; ) {
      delete _tempPayoutAmount[_tempPayoutAddress[idx]];

      unchecked {
        idx++;
      }
    }
    delete _tempPayoutAddress;
  }

  /**
   * @dev Transfer one asset and update the onchain sale state
   *
   * @param _token address of token to transfer
   * @param _tokenId uint256 tokenId of the asset
   * @param _from address of sender
   * @param _to address of reciever
   * @param _value uint256 in case of ERC1155, count to asset
   * @param _hashMsgSaleOrder bytes32 SaleOrder hash message
   * @param _nonce uint256 sale unique identifier
   */
  function _transferNFTAndUpdateSale(
    address _token,
    uint256 _tokenId,
    address _from,
    address _to,
    uint256 _value,
    bytes32 _hashMsgSaleOrder,
    uint256 _nonce
  ) internal virtual {
    if (_value != 0) {
      // [ERC1155]
      transferProxy.erc1155safeTransferFrom(
        IERC1155(_token),
        _from,
        _to,
        _tokenId,
        _value,
        bytes("0x")
      );

      // Update sale order state
      _setSoldByNonce(_nonce, _token, _tokenId, _value);
    } else {
      // [ERC721]
      transferProxy.erc721safeTransferFrom(
        IERC721(_token),
        _from,
        _to,
        _tokenId
      );

      // Mark whole order as sold
      _setSoldByKey(_hashMsgSaleOrder, 1);
    }

    // Emit Event
    emit SaleSingle(_nonce, _token, _tokenId, _value);
  }

  /**
   * @dev Find the total sale price by matching payment mode of SaleOrder and BuyOrder
   *
   * @param _saleAcceptedPaymentModes Payment[] calldata
   * @param _buyPayment Payment calldata
   */
  function _findAssetSalePrice(
    OrderDomainV4.Payment[] calldata _saleAcceptedPaymentModes,
    OrderDomainV4.Payment calldata _buyPayment
  ) internal pure returns (uint256) {
    uint256 salePrice = 0;

    for (uint256 idxP = 0; idxP < _saleAcceptedPaymentModes.length; ) {
      OrderDomainV4.Payment calldata salePayment = _saleAcceptedPaymentModes[
        idxP
      ];

      // EM: SaleOrder acceptedPaymentMode invalid price
      // EM: SaleOrder acceptedPaymentMode invalid paymentMode
      require(
        OrderDomainV4._isValidPaymentMode(salePayment.paymentMode) &&
          salePayment.price != 0,
        "E_SPMIP"
      );

      if (salePayment.paymentMode == _buyPayment.paymentMode) {
        salePrice = salePayment.price;
        break;
      }

      unchecked {
        ++idxP;
      }
    }

    // EM: payment mode did't match
    require(salePrice != 0, "E_PMNM");

    return salePrice;
  }

  /**
   * @dev Check validity of arguments and Verify signatures for calling exchange
   *
   * @param _saleOrder OrderDomainV4.SaleOrder
   * @param _asset OrderDomainV4.Asset calldata
   * @param _salerSign saler signature
   * @param _hashMsgSaleOrder Hash of Sale Order
   * @param _firstAssetBuyValue uint256
   */
  function _checkParameterForExchange(
    OrderDomainV4.SaleOrder calldata _saleOrder,
    OrderDomainV4.Asset calldata _asset,
    bytes calldata _salerSign,
    bytes32 _hashMsgSaleOrder,
    uint256 _firstAssetBuyValue
  ) internal virtual {
    // EM: SaleOrder asset invalid originKind
    // EM: SaleOrder asset invalid token
    require(
      OrderDomainV4._isValidOriginKind(_asset.originKind) &&
        (_asset.token.code.length != 0),
      "E_SIOIT"
    );

    // Make sure asset is not already sold out
    if (IERC721(_asset.token).supportsInterface(type(IERC721).interfaceId)) {
      // [ERC721]
      // EM: not enough asset remaining for sale
      require(getSoldCountByKey(_hashMsgSaleOrder) != 1, "E_SOLD");
    } else if (
      IERC1155(_asset.token).supportsInterface(type(IERC1155).interfaceId)
    ) {
      // [ERC1155]
      // EM: invalid first asset buy value
      require(_firstAssetBuyValue != 0, "E_IFABV");

      // EM: not enough asset remaining for sale
      require(
        _firstAssetBuyValue <=
          (_asset.value -
            getSoldCountByNonce(
              _saleOrder.nonce,
              _asset.token,
              _asset.tokenId
            )),
        "E_SOLD"
      );
    } else {
      // EM: Unsupported asset type
      revert("E_UAT");
    }

    // Platform fee rate should be greater than PlatformFeeRateLowerLimit
    // EM: SaleOrder pfSaleFeeRate Lower than low limit
    uint16 pfFeeRateLowerLimit = platformRegistry
      .getPlatformFeeRateLowerLimit();
    require(_saleOrder.pfSaleFeeRate >= pfFeeRateLowerLimit, "E_SPFLTLL");
    if (_saleOrder.version >= 1) {
      require(
        _saleOrder.pfSaleFeeRateSecondary >= pfFeeRateLowerLimit,
        "E_SPFLTLL"
      );
    }

    // Make sure using newer signature for new version
    // EM: Version not correct
    if (_asset.value > 0) {
      require(_saleOrder.version >= 1, "E_VNC");
    }

    // EM: SaleOrder invalid paymentReceiver
    // EM: SaleOrder invalid currentOwner
    require(
      _saleOrder.currentOwner != address(0) &&
        _saleOrder.paymentReceiver != address(0),
      "E_SIPC"
    );

    // EM: SaleOrder invalid end
    // EM: SaleOrder invalid start
    require(
      _saleOrder.start > 0 &&
        _saleOrder.start <= block.timestamp &&
        (_saleOrder.end == 0 || _saleOrder.end > block.timestamp),
      "E_SIES"
    );

    // Prepares ERC712 message hash of Saler signature
    // EM: invalid saler signer
    require(
      _domainSeparatorV4().toTypedDataHash(_hashMsgSaleOrder).recover(
        _salerSign
      ) == _saleOrder.currentOwner,
      "E_ISS"
    );
  }

  /**
   * @dev See {IExchange.exchange()}
   *
   * @param _saleOrder OrderDomainV4.SaleOrder
   * @param _salerSign saler signature
   * @param _buyOrder OrderDomainV4.BuyOrder
   * @param _platformSign platform signature
   *
   * Requirements:
   * - whenNotPaused
   * - nonReentrant
   *
   * Emits a {Sale} event
   */
  function exchange(
    OrderDomainV4.SaleOrder calldata _saleOrder,
    bytes calldata _salerSign,
    OrderDomainV4.BuyOrder calldata _buyOrder,
    bytes calldata _platformSign
  ) external payable virtual override whenNotPaused nonReentrant {
    // EM: Expired Order
    // EM: BuyOrder invalid payer
    // EM: BuyOrder invalid buyer
    // EM: BuyOrder invalid price
    require(
      (_buyOrder.validUntil >= block.timestamp) &&
        (_buyOrder.buyer != address(0)) &&
        (_buyOrder.payer != address(0)) &&
        (_buyOrder.paymentDetails.price != 0),
      "E_EO_IB_IP_IBP"
    );

    // EM: BuyOrder invalid price
    // EM: SaleOrder invalid nonce
    // EM: Version mismatch
    // EM: currentOwner and buyer can't be same
    require(
      (_saleOrder.assetList.length == 1) &&
        (_saleOrder.nonce != 0) &&
        (_saleOrder.nonce == _buyOrder.saleNonce) &&
        (_saleOrder.version == _buyOrder.version) &&
        (_saleOrder.currentOwner != _buyOrder.buyer),
      "E_AL_N_VM_IB"
    );

    // Prepares ERC712 message hash of platform signature
    // EM: invalid platform signer
    require(
      platformRegistry.isPlatformSigner(
        _domainSeparatorV4()
          .toTypedDataHash(OrderDomainV4._hashBuyOrder(_buyOrder))
          .recover(_platformSign)
      ),
      "E_IPS"
    );

    // Step1 : Parameters and signatures checks
    bytes32 hashMsgSaleOrder = OrderDomainV4._hashSaleOrder(_saleOrder);

    OrderDomainV4.Asset calldata asset = _saleOrder.assetList[0];
    _checkParameterForExchange(
      _saleOrder,
      asset,
      _salerSign,
      hashMsgSaleOrder,
      _buyOrder.firstAssetBuyValue
    );

    // Sale Price = Platform Fee + Partner Fee(If partner) + Royalty + Saler(Secondary onwards)
    // Find the total sale price by matching payment mode of SaleOrder and BuyOrder
    uint256 assetSalePrice = _findAssetSalePrice(
      _saleOrder.acceptedPaymentMode,
      _buyOrder.paymentDetails
    );

    // Step2 : Payout (if OnchainPaymentMode) : Platform Fee + Partner Fee(If partner) + Royalty + Saler(Secondary onwards)
    // OnchainPaymentMode == NATIVE_PAYMENT_MODE || ERC20_PAYMENT_MODE
    if (
      OrderDomainV4._isOnchainPaymentMode(_buyOrder.paymentDetails.paymentMode)
    ) {
      // Payout map is used for collective payment by sending only once for an address
      // So reset it before using it
      _resetPayoutTemp();

      // Single Sale for ERC1155
      if (_buyOrder.firstAssetBuyValue > 0) {
        assetSalePrice =
          (assetSalePrice * _buyOrder.firstAssetBuyValue) /
          asset.value;
      }

      // Make sure Native Token/ERC20 recieved is enough for sale
      // NOTE: if got more Native Token/ERC20 then needed, it will be stored in this contract(considered as TIP)
      if (
        _buyOrder.paymentDetails.paymentMode ==
        OrderDomainV4.NATIVE_PAYMENT_MODE
      ) {
        // Native Token case
        // EM: not enough Native Token received for sale
        require(msg.value >= assetSalePrice, "E_NENT");
        // NOTE: TIP will be added to the balance of this contract
      } else if (
        _buyOrder.paymentDetails.paymentMode == OrderDomainV4.ERC20_PAYMENT_MODE
      ) {
        // Whitelist check for ERC20
        // EM: BuyOrder paymentToken not whitelisted
        require(
          platformRegistry.isWhitelistedERC20(
            _buyOrder.paymentDetails.paymentToken
          ),
          "E_BPTNW"
        );

        // ERC20 case
        // NOTE: Make sure appropriate amount of ERC20 is approved to TransferProxy
        address paymentToken = _buyOrder.paymentDetails.paymentToken;
        // EM: not enough ERC20 approved for sale
        uint256 allowanceCount = IERC20(paymentToken).allowance(
          _buyOrder.payer,
          address(transferProxy)
        );
        require(allowanceCount >= assetSalePrice, "E_NEERC20");

        // Register TIP
        uint256 tip = allowanceCount - assetSalePrice;
        if (tip > 0) {
          _erc20TipDeposite[paymentToken].push(ERC20Tip(_buyOrder.payer, tip));
        }
      }

      // [Platform Fee for Asset]
      // NOTE: from version 1 onward, need to set Secondary Sale fee rate at [SaleOrder.pfSaleFeeRateSecondary]
      uint256 pfFeeForAsset = (assetSalePrice *
        (
          (_saleOrder.version >= 1 && asset.isSecondarySale == 1)
            ? _saleOrder.pfSaleFeeRateSecondary
            : _saleOrder.pfSaleFeeRate
        )) / OrderDomainV4.FEE_DENOMINATOR;
      // Simulate sending platform fee
      _registerPayout(platformRegistry.getPlatformFeeReceiver(), pfFeeForAsset);

      // [Partner Fee for Asset]
      uint256 partnerFeeForAsset = 0;
      if (
        OrderDomainV4._isPartnerOrigin(asset.originKind) &&
        asset.partnerFeeRate > 0
      ) {
        address payable partnerFeeReceiver = asset.partnerFeeReceiver;
        if (partnerFeeReceiver == address(0)) {
          // If _asset.partnerFeeReceiver is not set, try to get from platformRegistry
          partnerFeeReceiver = platformRegistry.getPartnerFeeReceiver(
            asset.token
          );
        }

        // Make sure partner fee recever is set
        // EM: partner fee recever is not set
        require(partnerFeeReceiver != address(0), "E_PFRNS");

        unchecked {
          partnerFeeForAsset =
            (assetSalePrice * asset.partnerFeeRate) /
            OrderDomainV4.FEE_DENOMINATOR;
        }
        _registerPayout(partnerFeeReceiver, partnerFeeForAsset);
      }

      // [Royalties for Asset] + [Saler Cut for Asset]
      unchecked {
        _registerPayout(
          _saleOrder.paymentReceiver,
          assetSalePrice -
            pfFeeForAsset -
            partnerFeeForAsset -
            _simulateRoyaltyTransfer(
              asset,
              (asset.isSecondarySale == 1)
                ? assetSalePrice
                : (assetSalePrice - pfFeeForAsset - partnerFeeForAsset),
              _saleOrder.version
            )
        );
      }

      // Payout
      _payout(
        _buyOrder.paymentDetails.paymentMode,
        _buyOrder.paymentDetails.paymentToken,
        _buyOrder.payer
      );
      _resetPayoutTemp();
    }

    // Step3 : Transfer NFT and Update Sale
    _transferNFTAndUpdateSale(
      asset.token,
      asset.tokenId,
      _saleOrder.currentOwner,
      _buyOrder.buyer,
      _buyOrder.firstAssetBuyValue,
      hashMsgSaleOrder,
      _saleOrder.nonce
    );
  }

  /**
   * @dev Try to exchange multiple asset in process of Sale
   *
   * @param _saleOrderList List of OrderDomainV4.SaleOrder
   * @param _salerSignList List of saler signature
   * @param _buyOrderBatch OrderDomainV4.BuyOrderBatch
   * @param _platformSign platform signature
   */
  function exchangeAll(
    OrderDomainV4.SaleOrder[] calldata _saleOrderList,
    bytes[] calldata _salerSignList,
    OrderDomainV4.BuyOrderBatch calldata _buyOrderBatch,
    bytes calldata _platformSign
  ) external payable virtual override whenNotPaused nonReentrant {
    uint256 saleOrderCount = _saleOrderList.length;
    // EM: Sale Order length mismatch
    require(
      saleOrderCount != 0 &&
        saleOrderCount == _salerSignList.length &&
        saleOrderCount == _buyOrderBatch.saleNonceList.length &&
        saleOrderCount == _buyOrderBatch.firstAssetBuyValueList.length &&
        saleOrderCount == _buyOrderBatch.versionList.length,
      "E_SOLM"
    );

    // EM: Expired Order
    // EM: BuyOrder invalid payer
    // EM: BuyOrder invalid buyer
    // EM: BuyOrder invalid price
    require(
      (_buyOrderBatch.validUntil >= block.timestamp) &&
        (_buyOrderBatch.buyer != address(0)) &&
        (_buyOrderBatch.payer != address(0)) &&
        (_buyOrderBatch.paymentDetails.price != 0),
      "E_EO_IB_IP_IBP"
    );

    // Verify platform signatures
    // EM: invalid platform signer
    require(
      platformRegistry.isPlatformSigner(
        _domainSeparatorV4()
          .toTypedDataHash(OrderDomainV4._hashBuyOrderBatch(_buyOrderBatch))
          .recover(_platformSign)
      ),
      "E_IPS"
    );

    // Payout map is used for collective payment by sending only once for an address
    // So reset it before using it
    _resetPayoutTemp();

    uint256 totalSalePrice = 0;
    for (uint256 idx = 0; idx < saleOrderCount; ) {
      OrderDomainV4.SaleOrder calldata saleOrder = _saleOrderList[idx];
      uint8 saleOrderVersion = saleOrder.version;

      // EM: Sale Order Asset length is not valid
      // EM: SaleOrder and BuyOrder nonce does't match
      // EM: SaleOrder invalid nonce
      // EM: Version mismatch
      require(
        (saleOrder.assetList.length == 1) &&
          (saleOrder.nonce != 0) &&
          (saleOrder.nonce == _buyOrderBatch.saleNonceList[idx]) &&
          (saleOrderVersion == _buyOrderBatch.versionList[idx]),
        "E_AL_N_VM_IB"
      );

      OrderDomainV4.Asset calldata asset = saleOrder.assetList[0];
      uint256 firstAssetBuyValue = _buyOrderBatch.firstAssetBuyValueList[idx];
      bytes32 hashMsgSaleOrder = OrderDomainV4._hashSaleOrder(saleOrder);

      _checkParameterForExchange(
        saleOrder,
        asset,
        _salerSignList[idx],
        hashMsgSaleOrder,
        firstAssetBuyValue
      );

      // EM: currentOwner and buyer can't be same
      require(saleOrder.currentOwner != _buyOrderBatch.buyer, "E_CAABS");

      // Sale Price = Platform Fee + Partner Fee(If partner) + Royalty + Saler(Secondary onwards)
      // Check for matching payment mode for Sale and Buy
      uint256 assetSalePrice = _findAssetSalePrice(
        saleOrder.acceptedPaymentMode,
        _buyOrderBatch.paymentDetails
      );

      // Payout (if OnchainPaymentMode) : Platform Fee + Partner Fee(If partner) + Royalty + Saler(Secondary onwards)
      // OnchainPaymentMode == NATIVE_PAYMENT_MODE || ERC20_PAYMENT_MODE
      if (
        OrderDomainV4._isOnchainPaymentMode(
          _buyOrderBatch.paymentDetails.paymentMode
        )
      ) {
        unchecked {
          // Single Sale for ERC1155
          if (firstAssetBuyValue > 0) {
            assetSalePrice =
              (assetSalePrice * firstAssetBuyValue) /
              asset.value;
          }

          totalSalePrice += assetSalePrice;
        }

        // [Platform Fee for Asset]
        // NOTE: from version 1 onward, need to set Secondary Sale fee rate at [SaleOrder.pfSaleFeeRateSecondary]
        uint256 pfFeeForAsset = (assetSalePrice *
          (
            (saleOrderVersion >= 1 && asset.isSecondarySale == 1)
              ? saleOrder.pfSaleFeeRateSecondary
              : saleOrder.pfSaleFeeRate
          )) / OrderDomainV4.FEE_DENOMINATOR;
        // Simulate sending platform fee
        _registerPayout(
          platformRegistry.getPlatformFeeReceiver(),
          pfFeeForAsset
        );

        // [Partner Fee for Asset]
        uint256 partnerFeeForAsset = 0;
        if (
          OrderDomainV4._isPartnerOrigin(asset.originKind) &&
          asset.partnerFeeRate > 0
        ) {
          address payable partnerFeeReceiver = asset.partnerFeeReceiver;
          if (partnerFeeReceiver == address(0)) {
            // If _asset.partnerFeeReceiver is not set, try to get from platformRegistry
            partnerFeeReceiver = platformRegistry.getPartnerFeeReceiver(
              asset.token
            );
          }
          // Make sure partner fee recever is set
          // EM: partner fee recever is not set
          require(partnerFeeReceiver != address(0), "E_PFRNS");
          unchecked {
            partnerFeeForAsset =
              (assetSalePrice * asset.partnerFeeRate) /
              OrderDomainV4.FEE_DENOMINATOR;
          }
          _registerPayout(partnerFeeReceiver, partnerFeeForAsset);
        }

        // [Royalties for Asset] + [Saler Cut for Asset]
        unchecked {
          _registerPayout(
            saleOrder.paymentReceiver,
            assetSalePrice -
              pfFeeForAsset -
              partnerFeeForAsset -
              _simulateRoyaltyTransfer(
                asset,
                (asset.isSecondarySale == 1)
                  ? assetSalePrice
                  : (assetSalePrice - pfFeeForAsset - partnerFeeForAsset),
                saleOrderVersion
              )
          );
        }
      }

      // Transfer NFT and Update Sale
      _transferNFTAndUpdateSale(
        asset.token,
        asset.tokenId,
        saleOrder.currentOwner,
        _buyOrderBatch.buyer,
        firstAssetBuyValue,
        hashMsgSaleOrder,
        saleOrder.nonce
      );

      unchecked {
        ++idx;
      }
    }

    // Make sure Native Token/ERC20 recieved is enough for sale
    // NOTE: if got more Native Token/ERC20 then needed, it will be stored in this contract(considered as TIP)
    if (
      _buyOrderBatch.paymentDetails.paymentMode ==
      OrderDomainV4.NATIVE_PAYMENT_MODE
    ) {
      // Native Token case
      // EM: not enough Native Token received for sale
      require(msg.value >= totalSalePrice, "E_NENT");
      // NOTE: TIP will be added to the balance of this contract
    } else if (
      _buyOrderBatch.paymentDetails.paymentMode ==
      OrderDomainV4.ERC20_PAYMENT_MODE
    ) {
      // Whitelist check for ERC20
      // EM: BuyOrder paymentToken not whitelisted
      require(
        platformRegistry.isWhitelistedERC20(
          _buyOrderBatch.paymentDetails.paymentToken
        ),
        "E_BPTNW"
      );

      // ERC20 case
      // NOTE: Make sure appropriate amount of ERC20 is approved to TransferProxy
      address paymentToken = _buyOrderBatch.paymentDetails.paymentToken;
      // EM: not enough ERC20 approved for sale
      uint256 allowanceCount = IERC20(paymentToken).allowance(
        _buyOrderBatch.payer,
        address(transferProxy)
      );
      require(allowanceCount >= totalSalePrice, "E_NEERC20");

      // Register TIP
      unchecked {
        uint256 tip = allowanceCount - totalSalePrice;
        if (tip > 0) {
          _erc20TipDeposite[paymentToken].push(
            ERC20Tip(_buyOrderBatch.payer, tip)
          );
        }
      }
    }

    // Payout
    _payout(
      _buyOrderBatch.paymentDetails.paymentMode,
      _buyOrderBatch.paymentDetails.paymentToken,
      _buyOrderBatch.payer
    );
    _resetPayoutTemp();
  }

  /**
   * @dev Withdraw Tip
   *
   * @param _receiver address payable
   * @param _erc20Token address. When Native, address is zero.
   */
  function withdrawTip(
    address payable _receiver,
    address _erc20Token
  ) public virtual onlyAdmin {
    // EM: Invalid withdraw address
    require(_receiver != address(0), "E_IWA");

    if (_erc20Token == address(0)) {
      // Native tip withdraw
      _receiver.transfer(address(this).balance);
    } else {
      // ERC20 tip withdrawal
      ERC20Tip[] storage erc20TipList = _erc20TipDeposite[_erc20Token];
      uint256 tipperCount = erc20TipList.length;

      for (uint256 idx = 0; idx < tipperCount; ) {
        ERC20Tip storage erc20Tip = erc20TipList[idx];
        // Sending ERC20
        transferProxy.erc20safeTransferFrom(
          IERC20(_erc20Token),
          erc20Tip.tipper,
          _receiver,
          erc20Tip.amount
        );

        unchecked {
          idx++;
        }
      }

      // Clear tip info after transfer
      delete _erc20TipDeposite[_erc20Token];
    }
  }

  /**
   * @dev Returns the version of this contract
   * 0 = version 1
   * 1 = version 2
   * 2 = version 3
   * 3 = version 4
   */
  function version() public pure virtual override returns (uint8) {
    return 3;
  }
}
        

@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol

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

pragma solidity ^0.8.0;

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

@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * _Available since v4.5._
 */
interface IERC2981Upgradeable is IERC165Upgradeable {
    /**
     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}
          

@openzeppelin/contracts-upgradeable/interfaces/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);
}
          

@openzeppelin/contracts-upgradeable/metatx/ERC2771ContextUpgradeable.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;
}
          

@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol

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

@openzeppelin/contracts-upgradeable/proxy/beacon/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);
}
          

@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

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

pragma solidity ^0.8.2;

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

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

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

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

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

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

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

@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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 that the this implementation remains valid after 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;
}
          

@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol

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

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

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

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

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

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

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

@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol

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

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

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

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

    uint256 private _status;

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

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

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

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

        _;

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

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

@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol

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

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

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

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

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

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

@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol

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

@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (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
    }

    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");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' 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 (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

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

@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-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;
}
          

@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol

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

pragma solidity ^0.8.0;

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

@openzeppelin/contracts/token/ERC1155/IERC1155.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/token/ERC20/IERC20.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

@openzeppelin/contracts/token/ERC721/IERC721.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

@openzeppelin/contracts/utils/introspection/IERC165.sol

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

pragma solidity ^0.8.0;

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

@sbinft/contracts/upgradeable/access/AdminUpgradeable.sol

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

import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";

/**
 * @notice deprecated use AdminUpgradeableV2
 * @title AdminUpgradeable Contract to manage access
 *
 * @author SBINFT Co., Ltd.
 */
abstract contract AdminUpgradeable is ContextUpgradeable {
  event AdminAdded(address);
  event AdminRemoved(address);

  /**
   * @dev 管理者のマッピング。管理者でないならばfalseを返す。
   */
  mapping(address => bool) private _admin;

  function __Admin_init() internal onlyInitializing {
    __Context_init();
    // 初期化時にデプロイ者を管理者に追加する。
    _addAdmin(_msgSender());
  }

  /**
   * @dev 管理者を複数追加
   */
  function addAdmin(address[] calldata newAdmin) public virtual onlyAdmin {
    for (uint256 idx = 0; idx < newAdmin.length; idx++) {
      _addAdmin(newAdmin[idx]);
    }
  }

  /**
   * @dev 管理者を一人追加
   */
  function addAdmin(address newAdmin) public virtual onlyAdmin {
    _addAdmin(newAdmin);
  }

  /**
   * @dev 管理者を一人追加
   * 無制限 Internal function
   */
  function _addAdmin(address newAdmin) internal virtual {
    require(
      newAdmin != address(0),
      "Admin:addAdmin newAdmin is the zero address"
    );

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

  /**
   * @dev 管理者を一人削除
   */
  function removeAdmin(address admin) public virtual onlyAdmin {
    require(
      _admin[admin],
      "Admin:removeAdmin trying to remove non existing Admin"
    );

    _removeAdmin(admin);
  }

  /**
   * @dev 管理者を一人削除
   * 無制限 Internal function
   */
  function _removeAdmin(address admin) internal virtual {
    delete _admin[admin];
    emit AdminRemoved(admin);
  }

  /**
   * @dev
   * Adminかどうかのチェック
   */
  function isAdmin(address checkAdmin) public view virtual returns (bool) {
    return _admin[checkAdmin];
  }

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

contracts/sbinft/market/v1/interface/IPlatformRegistry.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol";

/**
 * @title SBINFT Platform Registry
 */
interface IPlatformRegistry is IERC165Upgradeable {
  /**
   * @dev Update to new PlatformFeeRateLowerLimit
   *
   * @param _new new PlatformFeeRateLowerLimit
   */
  function updatePlatformFeeLowerLimit(uint16 _new) external;

  /**
   * @dev Update to new PlatformFeeReceiver
   *
   * @param _new new PlatformFeeReceiver
   */
  function updatePlatformFeeReceiver(address payable _new) external;

  /**
   * @dev Update to new PartnerFeeReceiver for partner's collection
   *
   * @param collection partner's collection
   * @param partnerFeeReceiver new partner's FeeReceiver
   * @param sign bytes calldata signature of platform signer
   */
  function updatePartnerFeeReceiver(
    address collection,
    address payable partnerFeeReceiver,
    bytes calldata sign
  ) external;

  /**
   * @dev Checks if partner fee receiver
   *
   * @param _collection address of token
   * @param _partnerFeeReceiver address of partner FeeReceiver
   *
   * Requirements:
   * - _collection must be a non zero address
   * - _partnerFeeReceiver must be a non zero address
   */
  function isPartnerFeeReceiver(
    address _collection,
    address _partnerFeeReceiver
  ) external view returns (bool);

  /**
   * @dev Checks state of a Whitelisted token
   *
   * @param _token address of token
   */
  function isWhitelistedERC20(address _token) external view returns (bool);

  /**
   * @dev Adds list of token to Whitelisted, if zero address then will be ignored
   *
   * @param _addTokenList array of address of token to add
   */
  function addToERC20Whitelist(address[] calldata _addTokenList) external;

  /**
   * @dev Removes list of token from Whitelisted
   *
   * @param _tokenList array of address of token to remove
   */
  function removeFromERC20Whitelist(address[] calldata _tokenList) external;

  /**
   * @dev Checks state of a Whitelisted token
   *
   * @param _signer address of token
   */
  function isPlatformSigner(address _signer) external view returns (bool);

  /**
   * @dev Adds list of token to Whitelisted, if zero address then will be ignored
   *
   * @param _platformSignerList array of platfomr signer address  to add
   */
  function addPlatformSigner(address[] calldata _platformSignerList) external;

  /**
   * @dev Removes list of platform signers address
   *
   * @param _list array of platfomr signer address to remove
   */
  function removePlatformSigner(address[] calldata _list) external;

  /**
   * @dev Returns PlatformFeeReceiver
   */
  function getPlatformFeeReceiver() external returns (address payable);

  /**
   * @dev Returns PartnerFeeReceiver
   *
   * @param _token address of partner token
   */
  function getPartnerFeeReceiver(
    address _token
  ) external returns (address payable);

  /**
   * @dev Returns PlatformFeeReceiver
   *
   */
  function getPlatformFeeRateLowerLimit() external returns (uint16);

  /**
   * @dev Update to new PartnerPfFeeReceiver for partner's platformSigner
   *
   * @param _externalPlatformToken address of external Platform Token
   * @param _partnerPfFeeReceiver address new partner's platformer FeeReceiver
   *
   * Requirements:
   * - _platformSigner must be a non zero address
   * - _partnerPfFeeReceiver must be a non zero address
   *
   * Emits a {ExternalPfFeeReceiverUpdated} event
   */
  function updateExternalPlatformFeeReceiver(
    address _externalPlatformToken,
    address payable _partnerPfFeeReceiver
  ) external;

  /**
   * @dev Returns ExternalPlatformFeeReceiver
   *
   * @param _token address of external platform token
   */
  function getExternalPlatformFeeReceiver(
    address _token
  ) external returns (address payable);
}
          

contracts/sbinft/market/v1/interface/IRoyaltyRegistry.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.17;

import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * _Available since v4.5._
 */
interface IRoyaltyRegistry is IERC2981Upgradeable {
  /**
   * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
   * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
   */
  function royaltyInfo(
    address _token,
    uint256 _tokenId,
    uint256 _salePrice,
    uint8 _isSecondarySale
  )
    external
    returns (
      address[] memory receivers,
      uint256[] memory royaltyFees,
      uint8 royaltyType
    );

  /**
   * @dev Returns the division factor for calculating precentage
   */
  function feeDenominator() external returns (uint16);
}
          

contracts/sbinft/market/v1/interface/ITransferProxy.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol";

/**
 * @title  SBINFT market non-native asset transfer protocol
 */
interface ITransferProxy is IERC165Upgradeable {
  /**
   * @notice Safe transfer ERC20 token
   * @dev only registered operators could call this function(i.e. Exchange)
   *
   * @param _token IERC20 token address
   * @param _from address from
   * @param _to address to
   * @param _value uint256 value
   */
  function erc20safeTransferFrom(
    IERC20 _token,
    address _from,
    address _to,
    uint256 _value
  ) external;

  /**
   * @notice Safe transfer ERC721 token
   * @dev only registered operators could call this function(i.e. Exchange)
   *
   * @param _token IERC721 token address
   * @param _from address current owner address
   * @param _to address new to be owner address
   * @param _tokenId uint256 token id to transfer
   */
  function erc721safeTransferFrom(
    IERC721 _token,
    address _from,
    address _to,
    uint256 _tokenId
  ) external;

  /**
   * @notice Safe transfer ERC1155 token
   * @dev only registered operators could call this function(i.e. Exchange)
   *
   * @param _token IERC1155 token address
   * @param _from address current owner address
   * @param _to address new to be owner address
   * @param _tokenId uint256 token id to transfer
   * @param _value uint256 count of token to transfer
   * @param _data bytes extra data if needed
   */
  function erc1155safeTransferFrom(
    IERC1155 _token,
    address _from,
    address _to,
    uint256 _tokenId,
    uint256 _value,
    bytes calldata _data
  ) external;
}
          

contracts/sbinft/market/v4/interface/IExchangeV4.sol

// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.19;

import "@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol";

import "contracts/sbinft/market/v4/library/OrderDomainV4.sol";

/**
 * @title SBINFT Exchange protocol interface
 * @author SBINFT Co., Ltd.
 */
interface IExchangeV4 is IERC165Upgradeable {
  // Emits whenever there is a exchange/sale
  event SaleSingle(
    uint256 indexed nonce,
    address indexed token,
    uint256 indexed tokenId,
    uint256 value
  );

  /**
   * @dev Try to exchange single asset in process of Sale
   *
   * @param _saleOrder OrderDomainV3.SaleOrder
   * @param _salerSign saler signature
   * @param _buyOrder OrderDomainV3.BuyOrder
   * @param _platformSign platform signature
   */
  function exchange(
    OrderDomainV4.SaleOrder calldata _saleOrder,
    bytes calldata _salerSign,
    OrderDomainV4.BuyOrder calldata _buyOrder,
    bytes calldata _platformSign
  ) external payable;

  /**
   * @dev Try to exchange multiple asset in process of Sale
   *
   * @param _saleOrderList List of OrderDomainV3.SaleOrder
   * @param _salerSignList List of saler signature
   * @param _buyOrderBatch OrderDomainV4.BuyOrderBatch
   * @param _platformSign platform signature
   */
  function exchangeAll(
    OrderDomainV4.SaleOrder[] calldata _saleOrderList,
    bytes[] calldata _salerSignList,
    OrderDomainV4.BuyOrderBatch calldata _buyOrderBatch,
    bytes calldata _platformSign
  ) external payable;

  /**
   * @dev Returns the version of this contract
   */
  function version() external pure returns (uint8);
}
          

contracts/sbinft/market/v4/library/OrderDomainV4.sol

// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.19;

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

/**
 * @dev Model data related with Order
 * @author SBINFT Co., Ltd.
 */
library OrderDomainV4 {
  // ORIGIN_KIND
  bytes4 private constant NANAKUSA_ORIGIN_KIND = bytes4(keccak256("NANAKUSA"));
  bytes4 private constant PARTNER_ORIGIN_KIND = bytes4(keccak256("PARTNER"));

  // PAYMENT_MODE
  bytes4 public constant NATIVE_PAYMENT_MODE = bytes4(keccak256("NATIVE"));
  bytes4 public constant ERC20_PAYMENT_MODE = bytes4(keccak256("ERC20"));
  bytes4 private constant CREDIT_CARD_PAYMENT_MODE =
    bytes4(keccak256("CREDIT_CARD"));
  bytes4 private constant OTHER_BLOCKCHAIN_PAYMENT_MODE =
    bytes4(keccak256("OTHER_BLOCKCHAIN"));

  /**
   * @dev Sale Asset Info
   */
  struct Asset {
    bytes4 originKind;
    address token;
    uint256 tokenId;
    uint256 value; // [v2] Only For ERC1155, For ERC721 always 0
    uint16 partnerFeeRate; // only set when originKind = PARTNER_ORIGIN_KIND
    address payable partnerFeeReceiver; //[v2] only set when originKind = PARTNER_ORIGIN_KIND or can be set into PlatformRegistry
    uint8 isSecondarySale; // 1 = true, 0 = false
    address[] royaltyReceivers; // [v3]
    uint16[] royaltyDistributionRate; // [v3]
    uint16 secondaryOnwardsRoyaltyPercentage; // [v3]
  }

  struct Payment {
    bytes4 paymentMode; // Like NATIVE_PAYMENT_MODE || ERC20_PAYMENT_MODE || ...
    address paymentToken; // Token contract address
    uint256 price;
  }

  struct SaleOrder {
    Asset[] assetList; // Array but only zero [0] index will be used(as bundle listing is depreciated)
    address currentOwner;
    address paymentReceiver; // Onchain payment receiver, can be same as currentOwner
    Payment[] acceptedPaymentMode;
    uint16 pfSaleFeeRate;
    uint16 pfSaleFeeRateSecondary; // [v2]
    uint256 start; // Always non zero
    uint256 end; // Can be zero when there is no end time
    uint256 nonce;
    uint8 version; // [v2] 0 = version1, 1 = version2, 2 = version3 ...
  }

  struct BuyOrder {
    uint256 saleNonce;
    address payable buyer;
    address payable payer; // If no payer means buyer is the payer
    uint256 firstAssetBuyValue; // [v2] For bundle sale and ERC721 always 0, Only for single ERC1155 sale need some value
    Payment paymentDetails;
    uint256 validUntil; // UNIX timestamp to determine the of validity of buyOrder
    uint8 version; // [v2] 0 = version1, 1 = version2 ...
  }

  // [v4]
  struct BuyOrderBatch {
    uint256 validUntil; // UNIX timestamp to determine the of validity of buyOrder
    address payable buyer;
    address payable payer;
    Payment paymentDetails;
    uint256[] saleNonceList;
    uint256[] firstAssetBuyValueList; // For ERC721 always 0, Only for single ERC1155 sale need some value
    uint8[] versionList; // 0 = version1, 1 = version2 ...
  }

  // ---- EIP712 ----
  // [v1]
  bytes32 private constant ASSET_TYPEHASH =
    keccak256(
      "Asset(bytes4 originKind,address token,uint256 tokenId,uint16 partnerFeeRate,uint8 isSecondarySale)"
    );

  bytes32 private constant PAYMENT_TYPEHASH =
    keccak256("Payment(bytes4 paymentMode,address paymentToken,uint256 price)");

  bytes32 private constant SALE_ORDER_TYPEHASH =
    keccak256(
      "SaleOrder(Asset[] assetList,address currentOwner,address paymentReceiver,Payment[] acceptedPaymentMode,uint16 pfSaleFeeRate,uint256 start,uint256 end,uint256 nonce)Asset(bytes4 originKind,address token,uint256 tokenId,uint16 partnerFeeRate,uint8 isSecondarySale)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
    );

  bytes32 private constant BUY_ORDER_TYPEHASH =
    keccak256(
      "BuyOrder(uint256 saleNonce,address buyer,address payer,Payment paymentDetails,uint256 validUntil)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
    );

  // [v2]
  bytes32 private constant ASSET_TYPEHASH_V2 =
    keccak256(
      "Asset(bytes4 originKind,address token,uint256 tokenId,uint256 value,uint16 partnerFeeRate,address partnerFeeReceiver,uint8 isSecondarySale)"
    );

  bytes32 private constant SALE_ORDER_TYPEHASH_V2 =
    keccak256(
      "SaleOrder(Asset[] assetList,address currentOwner,address paymentReceiver,Payment[] acceptedPaymentMode,uint16 pfSaleFeeRate,uint16 pfSaleFeeRateSecondary,uint256 start,uint256 end,uint256 nonce,uint8 version)Asset(bytes4 originKind,address token,uint256 tokenId,uint256 value,uint16 partnerFeeRate,address partnerFeeReceiver,uint8 isSecondarySale)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
    );

  bytes32 private constant BUY_ORDER_TYPEHASH_V2 =
    keccak256(
      "BuyOrder(uint256 saleNonce,address buyer,address payer,uint256 firstAssetBuyValue,Payment paymentDetails,uint256 validUntil,uint8 version)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
    );

  // [v3]
  /**
   * @dev Defaults to 10000 so fees are expressed in basis points, but may be customized by an override.
   * 10000 = 100%
   */
  uint16 internal constant FEE_DENOMINATOR = 10000;

  bytes32 private constant ASSET_TYPEHASH_V3 =
    keccak256(
      "Asset(bytes4 originKind,address token,uint256 tokenId,uint256 value,uint16 partnerFeeRate,address partnerFeeReceiver,uint8 isSecondarySale,address[] royaltyReceivers,uint16[] royaltyDistributionRate,uint16 secondaryOnwardsRoyaltyPercentage)"
    );

  bytes32 private constant SALE_ORDER_TYPEHASH_V3 =
    keccak256(
      "SaleOrder(Asset[] assetList,address currentOwner,address paymentReceiver,Payment[] acceptedPaymentMode,uint16 pfSaleFeeRate,uint16 pfSaleFeeRateSecondary,uint256 start,uint256 end,uint256 nonce,uint8 version)Asset(bytes4 originKind,address token,uint256 tokenId,uint256 value,uint16 partnerFeeRate,address partnerFeeReceiver,uint8 isSecondarySale,address[] royaltyReceivers,uint16[] royaltyDistributionRate,uint16 secondaryOnwardsRoyaltyPercentage)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
    );

  // [v4]
  bytes32 private constant BUY_ORDER_BATCH_TYPEHASH =
    keccak256(
      "BuyOrderBatch(uint256 validUntil,address buyer,address payer,Payment paymentDetails,uint256[] saleNonceList,uint256[] firstAssetBuyValueList,uint8[] versionList)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
    );

  /**
   * @dev Prepares keccak256 hash for Asset
   *
   * @param _asset OrderDomain.Asset
   * @param _version uint8
   */
  function _hashAsset(
    Asset calldata _asset,
    uint8 _version
  ) internal pure returns (bytes32) {
    if (_version == 0) {
      // [v1]
      return
        keccak256(
          abi.encode(
            ASSET_TYPEHASH,
            _asset.originKind,
            _asset.token,
            _asset.tokenId,
            _asset.partnerFeeRate,
            _asset.isSecondarySale
          )
        );
    } else if (_version == 1) {
      // [v2]
      return
        keccak256(
          abi.encode(
            ASSET_TYPEHASH_V2,
            _asset.originKind,
            _asset.token,
            _asset.tokenId,
            _asset.value,
            _asset.partnerFeeRate,
            _asset.partnerFeeReceiver,
            _asset.isSecondarySale
          )
        );
    } else if (_version == 2) {
      // [v3]
      return
        keccak256(
          abi.encode(
            ASSET_TYPEHASH_V3,
            _asset.originKind,
            _asset.token,
            _asset.tokenId,
            _asset.value,
            _asset.partnerFeeRate,
            _asset.partnerFeeReceiver,
            _asset.isSecondarySale,
            keccak256(abi.encodePacked(_asset.royaltyReceivers)),
            keccak256(abi.encodePacked(_asset.royaltyDistributionRate)),
            _asset.secondaryOnwardsRoyaltyPercentage
          )
        );
    } else {
      revert("E_IV");
    }
  }

  /**
   * @dev Prepares keccak256 hash for Asset list
   *
   * @param _assetList OrderDomain.Asset[]
   * @param _version uint8
   */
  function _hashAsset(
    Asset[] calldata _assetList,
    uint8 _version
  ) internal pure returns (bytes32) {
    bytes memory keccakData;

    for (uint256 idx = 0; idx < _assetList.length; ) {
      keccakData = abi.encodePacked(
        keccakData,
        _hashAsset(_assetList[idx], _version)
      );

      unchecked {
        idx++;
      }
    }

    return keccak256(keccakData);
  }

  /**
   * @dev Prepares keccak256 hash for Payment
   *
   * @param _payment OrderDomain.Payment
   */
  function _hashPayment(
    Payment calldata _payment
  ) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(
          PAYMENT_TYPEHASH,
          _payment.paymentMode,
          _payment.paymentToken,
          _payment.price
        )
      );
  }

  /**
   * @dev Prepares keccak256 hash for Payment list
   *
   * @param _paymentList OrderDomain.Payment[]
   */
  function _hashPayment(
    Payment[] calldata _paymentList
  ) internal pure returns (bytes32) {
    bytes memory keccakData;

    for (uint256 idx = 0; idx < _paymentList.length; ) {
      keccakData = abi.encodePacked(
        keccakData,
        _hashPayment(_paymentList[idx])
      );

      unchecked {
        idx++;
      }
    }

    return keccak256(keccakData);
  }

  /**
   * @dev Prepares keccak256 hash for SaleOrder
   *
   * @param _saleOrder OrderDomain.SaleOrder
   */
  function _hashSaleOrder(
    SaleOrder calldata _saleOrder
  ) internal pure returns (bytes32) {
    if (_saleOrder.version == 0) {
      // [v1]
      return
        keccak256(
          abi.encode(
            SALE_ORDER_TYPEHASH,
            _hashAsset(_saleOrder.assetList, _saleOrder.version),
            _saleOrder.currentOwner,
            _saleOrder.paymentReceiver,
            _hashPayment(_saleOrder.acceptedPaymentMode),
            _saleOrder.pfSaleFeeRate,
            _saleOrder.start,
            _saleOrder.end,
            _saleOrder.nonce
          )
        );
    } else if (_saleOrder.version == 1) {
      // [v2]
      return
        keccak256(
          abi.encode(
            SALE_ORDER_TYPEHASH_V2,
            _hashAsset(_saleOrder.assetList, _saleOrder.version),
            _saleOrder.currentOwner,
            _saleOrder.paymentReceiver,
            _hashPayment(_saleOrder.acceptedPaymentMode),
            _saleOrder.pfSaleFeeRate,
            _saleOrder.pfSaleFeeRateSecondary,
            _saleOrder.start,
            _saleOrder.end,
            _saleOrder.nonce,
            _saleOrder.version
          )
        );
    } else if (_saleOrder.version == 2) {
      // [v3]
      return
        keccak256(
          abi.encode(
            SALE_ORDER_TYPEHASH_V3,
            _hashAsset(_saleOrder.assetList, _saleOrder.version),
            _saleOrder.currentOwner,
            _saleOrder.paymentReceiver,
            _hashPayment(_saleOrder.acceptedPaymentMode),
            _saleOrder.pfSaleFeeRate,
            _saleOrder.pfSaleFeeRateSecondary,
            _saleOrder.start,
            _saleOrder.end,
            _saleOrder.nonce,
            _saleOrder.version
          )
        );
    } else {
      revert("E_IV");
    }
  }

  /**
   * @dev Prepares keccak256 hash for BuyOrder
   *
   * @param _buyOrder OrderDomain.BuyOrder
   */
  function _hashBuyOrder(
    BuyOrder calldata _buyOrder
  ) internal pure returns (bytes32) {
    if (_buyOrder.version == 0) {
      // [v1]
      return
        keccak256(
          abi.encode(
            BUY_ORDER_TYPEHASH,
            _buyOrder.saleNonce,
            _buyOrder.buyer,
            _buyOrder.payer,
            _hashPayment(_buyOrder.paymentDetails),
            _buyOrder.validUntil
          )
        );
    } else if (_buyOrder.version == 1 || _buyOrder.version == 2) {
      // [v2] or [v3]
      return
        keccak256(
          abi.encode(
            BUY_ORDER_TYPEHASH_V2,
            _buyOrder.saleNonce,
            _buyOrder.buyer,
            _buyOrder.payer,
            _buyOrder.firstAssetBuyValue,
            _hashPayment(_buyOrder.paymentDetails),
            _buyOrder.validUntil,
            _buyOrder.version
          )
        );
    } else {
      revert("E_OD3_IV");
    }
  }

  /**
   * @dev Prepares keccak256 hash for BuyOrderBatch
   *
   * @param _buyOrderBatch OrderDomain._buyOrderBatch
   */
  function _hashBuyOrderBatch(
    BuyOrderBatch calldata _buyOrderBatch
  ) internal pure returns (bytes32) {
    return
      keccak256(
        abi.encode(
          BUY_ORDER_BATCH_TYPEHASH,
          _buyOrderBatch.validUntil,
          _buyOrderBatch.buyer,
          _buyOrderBatch.payer,
          _hashPayment(_buyOrderBatch.paymentDetails),
          keccak256(abi.encodePacked(_buyOrderBatch.saleNonceList)),
          keccak256(abi.encodePacked(_buyOrderBatch.firstAssetBuyValueList)),
          keccak256(abi.encodePacked(_buyOrderBatch.versionList))
        )
      );
  }

  // ---- EIP712 ----

  /**
   * @dev Checks if it's a valid origin kind
   *
   * @param _originKind bytes4
   */
  function _isValidOriginKind(bytes4 _originKind) internal pure returns (bool) {
    return (_originKind == NANAKUSA_ORIGIN_KIND ||
      _originKind == PARTNER_ORIGIN_KIND);
  }

  /**
   * @dev Checks if it's a valid payment mode
   *
   * @param _paymentMode bytes4
   */
  function _isValidPaymentMode(
    bytes4 _paymentMode
  ) internal pure returns (bool) {
    return (_paymentMode == NATIVE_PAYMENT_MODE ||
      _paymentMode == ERC20_PAYMENT_MODE ||
      _paymentMode == CREDIT_CARD_PAYMENT_MODE ||
      _paymentMode == OTHER_BLOCKCHAIN_PAYMENT_MODE);
  }

  /**
   * @dev Checks if payment mode is onchain
   *
   * @param _paymentMode bytes4
   */
  function _isOnchainPaymentMode(
    bytes4 _paymentMode
  ) internal pure returns (bool) {
    return (_paymentMode == NATIVE_PAYMENT_MODE ||
      _paymentMode == ERC20_PAYMENT_MODE);
  }

  /**
   * @dev Checks if origin kind is partner
   *
   * @param _originKind bytes4
   */
  function _isPartnerOrigin(bytes4 _originKind) internal pure returns (bool) {
    return (_originKind == PARTNER_ORIGIN_KIND);
  }
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata","storageLayout"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"trustedForwarder","internalType":"address"}]},{"type":"event","name":"AdminAdded","inputs":[{"type":"address","name":"","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"AdminRemoved","inputs":[{"type":"address","name":"","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"PlatformRegistryUpdated","inputs":[{"type":"address","name":"platformRegistry","internalType":"contract IPlatformRegistry","indexed":true}],"anonymous":false},{"type":"event","name":"RoyaltyRegistryUpdated","inputs":[{"type":"address","name":"royaltyRegistry","internalType":"contract IRoyaltyRegistry","indexed":true}],"anonymous":false},{"type":"event","name":"SaleSingle","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TransferProxyUpdated","inputs":[{"type":"address","name":"transferProxy","internalType":"contract ITransferProxy","indexed":true}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addAdmin","inputs":[{"type":"address[]","name":"newAdmin","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addAdmin","inputs":[{"type":"address","name":"newAdmin","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"exchange","inputs":[{"type":"tuple","name":"_saleOrder","internalType":"struct OrderDomainV4.SaleOrder","components":[{"type":"tuple[]","name":"assetList","internalType":"struct OrderDomainV4.Asset[]","components":[{"type":"bytes4","name":"originKind","internalType":"bytes4"},{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint16","name":"partnerFeeRate","internalType":"uint16"},{"type":"address","name":"partnerFeeReceiver","internalType":"address payable"},{"type":"uint8","name":"isSecondarySale","internalType":"uint8"},{"type":"address[]","name":"royaltyReceivers","internalType":"address[]"},{"type":"uint16[]","name":"royaltyDistributionRate","internalType":"uint16[]"},{"type":"uint16","name":"secondaryOnwardsRoyaltyPercentage","internalType":"uint16"}]},{"type":"address","name":"currentOwner","internalType":"address"},{"type":"address","name":"paymentReceiver","internalType":"address"},{"type":"tuple[]","name":"acceptedPaymentMode","internalType":"struct OrderDomainV4.Payment[]","components":[{"type":"bytes4","name":"paymentMode","internalType":"bytes4"},{"type":"address","name":"paymentToken","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"}]},{"type":"uint16","name":"pfSaleFeeRate","internalType":"uint16"},{"type":"uint16","name":"pfSaleFeeRateSecondary","internalType":"uint16"},{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"end","internalType":"uint256"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint8","name":"version","internalType":"uint8"}]},{"type":"bytes","name":"_salerSign","internalType":"bytes"},{"type":"tuple","name":"_buyOrder","internalType":"struct OrderDomainV4.BuyOrder","components":[{"type":"uint256","name":"saleNonce","internalType":"uint256"},{"type":"address","name":"buyer","internalType":"address payable"},{"type":"address","name":"payer","internalType":"address payable"},{"type":"uint256","name":"firstAssetBuyValue","internalType":"uint256"},{"type":"tuple","name":"paymentDetails","internalType":"struct OrderDomainV4.Payment","components":[{"type":"bytes4","name":"paymentMode","internalType":"bytes4"},{"type":"address","name":"paymentToken","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"}]},{"type":"uint256","name":"validUntil","internalType":"uint256"},{"type":"uint8","name":"version","internalType":"uint8"}]},{"type":"bytes","name":"_platformSign","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"exchangeAll","inputs":[{"type":"tuple[]","name":"_saleOrderList","internalType":"struct OrderDomainV4.SaleOrder[]","components":[{"type":"tuple[]","name":"assetList","internalType":"struct OrderDomainV4.Asset[]","components":[{"type":"bytes4","name":"originKind","internalType":"bytes4"},{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint16","name":"partnerFeeRate","internalType":"uint16"},{"type":"address","name":"partnerFeeReceiver","internalType":"address payable"},{"type":"uint8","name":"isSecondarySale","internalType":"uint8"},{"type":"address[]","name":"royaltyReceivers","internalType":"address[]"},{"type":"uint16[]","name":"royaltyDistributionRate","internalType":"uint16[]"},{"type":"uint16","name":"secondaryOnwardsRoyaltyPercentage","internalType":"uint16"}]},{"type":"address","name":"currentOwner","internalType":"address"},{"type":"address","name":"paymentReceiver","internalType":"address"},{"type":"tuple[]","name":"acceptedPaymentMode","internalType":"struct OrderDomainV4.Payment[]","components":[{"type":"bytes4","name":"paymentMode","internalType":"bytes4"},{"type":"address","name":"paymentToken","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"}]},{"type":"uint16","name":"pfSaleFeeRate","internalType":"uint16"},{"type":"uint16","name":"pfSaleFeeRateSecondary","internalType":"uint16"},{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"end","internalType":"uint256"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint8","name":"version","internalType":"uint8"}]},{"type":"bytes[]","name":"_salerSignList","internalType":"bytes[]"},{"type":"tuple","name":"_buyOrderBatch","internalType":"struct OrderDomainV4.BuyOrderBatch","components":[{"type":"uint256","name":"validUntil","internalType":"uint256"},{"type":"address","name":"buyer","internalType":"address payable"},{"type":"address","name":"payer","internalType":"address payable"},{"type":"tuple","name":"paymentDetails","internalType":"struct OrderDomainV4.Payment","components":[{"type":"bytes4","name":"paymentMode","internalType":"bytes4"},{"type":"address","name":"paymentToken","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"}]},{"type":"uint256[]","name":"saleNonceList","internalType":"uint256[]"},{"type":"uint256[]","name":"firstAssetBuyValueList","internalType":"uint256[]"},{"type":"uint8[]","name":"versionList","internalType":"uint8[]"}]},{"type":"bytes","name":"_platformSign","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getSoldCountByKey","inputs":[{"type":"bytes32","name":"_saleKey","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getSoldCountByNonce","inputs":[{"type":"uint256","name":"_nonce","internalType":"uint256"},{"type":"address","name":"_token","internalType":"address"},{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isAdmin","inputs":[{"type":"address","name":"checkAdmin","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTrustedForwarder","inputs":[{"type":"address","name":"forwarder","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IPlatformRegistry"}],"name":"platformRegistry","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeAdmin","inputs":[{"type":"address","name":"admin","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IRoyaltyRegistry"}],"name":"royaltyRegistry","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"_interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ITransferProxy"}],"name":"transferProxy","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updatePlatformRegistry","inputs":[{"type":"address","name":"_newPlatformRegistry","internalType":"contract IPlatformRegistry"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateRoyaltyRegistry","inputs":[{"type":"address","name":"_newRoyaltyRegistry","internalType":"contract IRoyaltyRegistry"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTransferProxy","inputs":[{"type":"address","name":"_newTransferProxy","internalType":"contract ITransferProxy"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"version","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawTip","inputs":[{"type":"address","name":"_receiver","internalType":"address payable"},{"type":"address","name":"_erc20Token","internalType":"address"}]}]
              

Contract Creation Code

0x60c06040523060a0523480156200001557600080fd5b50604051620054f8380380620054f8833981016040819052620000389162000118565b6001600160a01b0381166080526200004f62000056565b506200014a565b600054610100900460ff1615620000c35760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116101562000116576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6000602082840312156200012b57600080fd5b81516001600160a01b03811681146200014357600080fd5b9392505050565b60805160a05161536562000193600039600081816112d501528181611315015281816115b1015281816115f101526116800152600081816103250152613c3b01526153656000f3fe60806040526004361061014b5760003560e01c806354fd4d50116100b6578063704802751161006f57806370480275146103d95780638456cb59146103f9578063a11b07121461040e578063c255f8781461042f578063cc25319314610450578063cf1d53cf1461047057600080fd5b806354fd4d50146102ec578063572b6c05146103085780635c975abb14610355578063653551501461036d578063658c09a81461038d5780636e667db3146103a057600080fd5b80633659cfe6116101085780633659cfe61461024f5780633d0950a81461026f5780633f4ba83a1461028f5780634c275cac146102a45780634f1ef286146102c457806352d1902d146102d757600080fd5b806301ffc9a71461015057806313263340146101855780631785f53c146101c157806318cdeccc146101e357806324d7806c14610203578063345c669e1461023c575b600080fd5b34801561015c57600080fd5b5061017061016b3660046147f2565b610490565b60405190151581526020015b60405180910390f35b34801561019157600080fd5b506101b36101a036600461481c565b6000908152610197602052604090205490565b60405190815260200161017c565b3480156101cd57600080fd5b506101e16101dc36600461484a565b6104c7565b005b3480156101ef57600080fd5b506101e16101fe366004614867565b6105a7565b34801561020f57600080fd5b5061017061021e36600461484a565b6001600160a01b031660009081526099602052604090205460ff1690565b6101e161024a36600461493e565b610765565b34801561025b57600080fd5b506101e161026a36600461484a565b6112cb565b34801561027b57600080fd5b506101e161028a3660046149fc565b6113a7565b34801561029b57600080fd5b506101e1611438565b3480156102b057600080fd5b506101e16102bf36600461484a565b611487565b6101e16102d2366004614a83565b6115a7565b3480156102e357600080fd5b506101b3611673565b3480156102f857600080fd5b506040516003815260200161017c565b34801561031457600080fd5b5061017061032336600461484a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b34801561036157600080fd5b5060fe5460ff16610170565b34801561037957600080fd5b506101e161038836600461484a565b611726565b6101e161039b366004614b2a565b611846565b3480156103ac57600080fd5b50610195546103c1906001600160a01b031681565b6040516001600160a01b03909116815260200161017c565b3480156103e557600080fd5b506101e16103f436600461484a565b6121a9565b34801561040557600080fd5b506101e16121f7565b34801561041a57600080fd5b50610196546103c1906001600160a01b031681565b34801561043b57600080fd5b50610194546103c1906001600160a01b031681565b34801561045c57600080fd5b506101e161046b36600461484a565b612244565b34801561047c57600080fd5b506101b361048b366004614bdd565b612364565b60006001600160e01b03198216630296913360e11b14806104c157506301ffc9a760e01b6001600160e01b03198316145b92915050565b609960006104d36123c9565b6001600160a01b0316815260208101919091526040016000205460ff166105155760405162461bcd60e51b815260040161050c90614c15565b60405180910390fd5b6001600160a01b03811660009081526099602052604090205460ff1661059b5760405162461bcd60e51b815260206004820152603560248201527f41646d696e3a72656d6f766541646d696e20747279696e6720746f2072656d6f6044820152743b32903737b71032bc34b9ba34b7339020b236b4b760591b606482015260840161050c565b6105a4816123d8565b50565b609960006105b36123c9565b6001600160a01b0316815260208101919091526040016000205460ff166105ec5760405162461bcd60e51b815260040161050c90614c15565b6001600160a01b03821661062a5760405162461bcd60e51b8152602060048201526005602482015264455f49574160d81b604482015260640161050c565b6001600160a01b038116610672576040516001600160a01b038316904780156108fc02916000818181858888f1935050505015801561066d573d6000803e3d6000fd5b505050565b6001600160a01b038116600090815261019860205260408120805490915b8181101561073b5760008382815481106106ac576106ac614c5b565b60009182526020909120610195546002909202018054600182015460405163776062c360e01b81529294506001600160a01b039384169363776062c3936106fc938b939216918c91600401614c71565b600060405180830381600087803b15801561071657600080fd5b505af115801561072a573d6000803e3d6000fd5b505060019093019250610690915050565b506001600160a01b03831660009081526101986020526040812061075e91614774565b50505b5050565b61076d612430565b600260cc54036107bf5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161050c565b600260cc558580158015906107d357508085145b80156107ec57506107e760c0850185614c9b565b905081145b8015610805575061080060e0850185614c9b565b905081145b801561081f575061081a610100850185614c9b565b905081145b6108545760405162461bcd60e51b8152602060048201526006602482015265455f534f4c4d60d01b604482015260640161050c565b4284351080159061087e57506000610872604086016020870161484a565b6001600160a01b031614155b80156108a357506000610897606086016040870161484a565b6001600160a01b031614155b80156108b2575060a084013515155b6108ef5760405162461bcd60e51b815260206004820152600e60248201526d0455f454f5f49425f49505f4942560941b604482015260640161050c565b61019454604080516020601f86018190048102820181019092528481526001600160a01b0390921691634d4ed32c916109959190879087908190840183828082843760009201919091525061098f925061094c91508a9050612476565b6109546125ca565b6040805161190160f01b6020808301919091526022820193909352604280820194909452815180820390940184526062019052815191012090565b90612645565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156109d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fd9190614ce4565b610a315760405162461bcd60e51b8152602060048201526005602482015264455f49505360d81b604482015260640161050c565b610a39612669565b6000805b82811015610fbb57368a8a83818110610a5857610a58614c5b565b9050602002810190610a6a9190614d06565b90506000610a8061014083016101208401614d36565b9050610a8c8280614c9b565b90506001148015610aa1575061010082013515155b8015610ad45750610ab560c0890189614c9b565b84818110610ac557610ac5614c5b565b90506020020135826101000135145b8015610b175750610ae9610100890189614c9b565b84818110610af957610af9614c5b565b9050602002016020810190610b0e9190614d36565b60ff168160ff16145b610b525760405162461bcd60e51b815260206004820152600c60248201526b22afa0a62fa72fab26afa4a160a11b604482015260640161050c565b36610b5d8380614c9b565b6000818110610b6e57610b6e614c5b565b9050602002810190610b809190614d06565b90506000610b9160e08b018b614c9b565b86818110610ba157610ba1614c5b565b9050602002013590506000610bb5856126cb565b9050610be785848f8f8a818110610bce57610bce614c5b565b9050602002810190610be09190614d53565b858761297d565b610bf760408c0160208d0161484a565b6001600160a01b0316610c10604087016020880161484a565b6001600160a01b031603610c505760405162461bcd60e51b8152602060048201526007602482015266455f434141425360c81b604482015260640161050c565b6000610c6b610c626060880188614d99565b8e606001612f2e565b9050610c85610c8060808e0160608f016147f2565b61303c565b15610f61578215610ca957836060013583820281610ca557610ca5614de1565b0490505b968701966000612710600160ff881610801590610cd85750610cd160e0870160c08801614d36565b60ff166001145b610cf157610cec60a0890160808a01614e07565b610d01565b610d0160c0890160a08a01614e07565b610d0f9061ffff1684614e3a565b610d199190614e51565b9050610d9e61019460009054906101000a90046001600160a01b03166001600160a01b031663707d18486040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d989190614e73565b82613072565b6000610dc6610db060208801886147f2565b6001600160e01b03191663163b6d3b60e21b1490565b8015610de557506000610ddf60a0880160808901614e07565b61ffff16115b15610f10576000610dfc60c0880160a0890161484a565b90506001600160a01b038116610e9b57610194546001600160a01b0316636859c996610e2e60408a0160208b0161484a565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016020604051808303816000875af1158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e989190614e73565b90505b6001600160a01b038116610edb5760405162461bcd60e51b8152602060048201526007602482015266455f5046524e5360c81b604482015260640161050c565b612710610eee60a0890160808a01614e07565b61ffff16850281610f0157610f01614de1565b049150610f0e8183613072565b505b610f5e610f2360608a0160408b0161484a565b610f5388610f3760e0820160c08301614d36565b60ff16600114610f4b578486880303610f4d565b865b8b613108565b838587030303613072565b50505b610faa610f74604086016020870161484a565b60408087013590610f8a908a0160208b0161484a565b8f6020016020810190610f9d919061484a565b87878c61010001356134cd565b866001019650505050505050610a3d565b5063fdae1ba760e01b610fd460808701606088016147f2565b6001600160e01b03191603611021578034101561101c5760405162461bcd60e51b81526020600482015260066024820152651157d391539560d21b604482015260640161050c565b61127b565b6322ba176160e21b61103960808701606088016147f2565b6001600160e01b0319160361127b57610194546001600160a01b0316635247385c61106a60a088016080890161484a565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156110ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d29190614ce4565b6111085760405162461bcd60e51b8152602060048201526007602482015266455f4250544e5760c81b604482015260640161050c565b600061111a60a087016080880161484a565b905060006001600160a01b03821663dd62ed3e61113d60608a0160408b0161484a565b6101955460405160e084901b6001600160e01b03191681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561118c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b09190614e90565b9050828110156111ee5760405162461bcd60e51b81526020600482015260096024820152680455f4e4545524332360bc1b604482015260640161050c565b828103818414611277576001600160a01b0383166000908152610198602052604090819020815180830183529091819061122e9060608d01908d0161484a565b6001600160a01b0390811682526020918201859052835460018082018655600095865294839020845160029092020180546001600160a01b031916919092161781559101519101555b5050505b6112b361128e60808701606088016147f2565b61129e60a088016080890161484a565b6112ae6060890160408a0161484a565b613635565b6112bb612669565b5050600160cc5550505050505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036113135760405162461bcd60e51b815260040161050c90614ea9565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661135c6000805160206152e9833981519152546001600160a01b031690565b6001600160a01b0316146113825760405162461bcd60e51b815260040161050c90614ef5565b61138b81613762565b604080516000808252602082019092526105a4918391906137a7565b609960006113b36123c9565b6001600160a01b0316815260208101919091526040016000205460ff166113ec5760405162461bcd60e51b815260040161050c90614c15565b60005b8181101561066d5761142683838381811061140c5761140c614c5b565b9050602002016020810190611421919061484a565b613912565b8061143081614f41565b9150506113ef565b609960006114446123c9565b6001600160a01b0316815260208101919091526040016000205460ff1661147d5760405162461bcd60e51b815260040161050c90614c15565b6114856139d0565b565b609960006114936123c9565b6001600160a01b0316815260208101919091526040016000205460ff166114cc5760405162461bcd60e51b815260040161050c90614c15565b6040516301ffc9a760e01b81526001600160a01b038216906301ffc9a7906114ff9063071d7d4b60e21b90600401614f5a565b602060405180830381865afa15801561151c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115409190614ce4565b61155c5760405162461bcd60e51b815260040161050c90614f6f565b61019580546001600160a01b0319166001600160a01b0383169081179091556040517fdf3b866248a7a3e982f0a93fde9cf30633ed3bb09365c16b08260ad033db920790600090a250565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036115ef5760405162461bcd60e51b815260040161050c90614ea9565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166116386000805160206152e9833981519152546001600160a01b031690565b6001600160a01b03161461165e5760405162461bcd60e51b815260040161050c90614ef5565b61166782613762565b610761828260016137a7565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146117135760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161050c565b506000805160206152e983398151915290565b609960006117326123c9565b6001600160a01b0316815260208101919091526040016000205460ff1661176b5760405162461bcd60e51b815260040161050c90614c15565b6040516301ffc9a760e01b81526001600160a01b038216906301ffc9a79061179e9063042eca1d60e51b90600401614f5a565b602060405180830381865afa1580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df9190614ce4565b6117fb5760405162461bcd60e51b815260040161050c90614f6f565b61019480546001600160a01b0319166001600160a01b0383169081179091556040517fa48d197b43b1826afcf98445392676fa169817dd3216002b6fd70e8601ef2b0190600090a250565b61184e612430565b600260cc54036118a05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161050c565b600260cc554260e0840135108015906118d2575060006118c6604085016020860161484a565b6001600160a01b031614155b80156118f7575060006118eb606085016040860161484a565b6001600160a01b031614155b8015611906575060c083013515155b6119435760405162461bcd60e51b815260206004820152600e60248201526d0455f454f5f49425f49505f4942560941b604482015260640161050c565b61194d8680614c9b565b90506001148015611962575061010086013515155b801561197357506101008601358335145b80156119a6575061198c61012084016101008501614d36565b60ff166119a161014088016101208901614d36565b60ff16145b80156119e257506119bd604084016020850161484a565b6001600160a01b03166119d6604088016020890161484a565b6001600160a01b031614155b611a1d5760405162461bcd60e51b815260206004820152600c60248201526b22afa0a62fa72fab26afa4a160a11b604482015260640161050c565b61019454604080516020601f85018190048102820181019092528381526001600160a01b0390921691634d4ed32c91611a7a9190869086908190840183828082843760009201919091525061098f925061094c9150899050613a28565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae29190614ce4565b611b165760405162461bcd60e51b8152602060048201526005602482015264455f49505360d81b604482015260640161050c565b6000611b21876126cb565b905036611b2e8880614c9b565b6000818110611b3f57611b3f614c5b565b9050602002810190611b519190614d06565b9050611b6588828989868a6060013561297d565b6000611b80611b7760608b018b614d99565b88608001612f2e565b9050611b95610c8060a08801608089016147f2565b1561215f57611ba2612669565b606086013515611bce578160600135866060013582611bc19190614e3a565b611bcb9190614e51565b90505b63fdae1ba760e01b611be660a08801608089016147f2565b6001600160e01b03191603611c335780341015611c2e5760405162461bcd60e51b81526020600482015260066024820152651157d391539560d21b604482015260640161050c565b611e97565b6322ba176160e21b611c4b60a08801608089016147f2565b6001600160e01b03191603611e9757610194546001600160a01b0316635247385c611c7c60c0890160a08a0161484a565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce49190614ce4565b611d1a5760405162461bcd60e51b8152602060048201526007602482015266455f4250544e5760c81b604482015260640161050c565b6000611d2c60c0880160a0890161484a565b905060006001600160a01b03821663dd62ed3e611d4f60608b0160408c0161484a565b6101955460405160e084901b6001600160e01b03191681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015611d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc29190614e90565b905082811015611e005760405162461bcd60e51b81526020600482015260096024820152680455f4e4545524332360bc1b604482015260640161050c565b6000611e0c8483614f8e565b90508015611e93576001600160a01b03831660009081526101986020526040908190208151808301835290918190611e4a9060608e01908e0161484a565b6001600160a01b0390811682526020918201859052835460018082018655600095865294839020845160029092020180546001600160a01b031916919092161781559101519101555b5050505b60006127106001611eb06101408d016101208e01614d36565b60ff1610158015611ed35750611ecc60e0850160c08601614d36565b60ff166001145b611eec57611ee760a08c0160808d01614e07565b611efc565b611efc60c08c0160a08d01614e07565b611f0a9061ffff1684614e3a565b611f149190614e51565b9050611f6f61019460009054906101000a90046001600160a01b03166001600160a01b031663707d18486040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610d74573d6000803e3d6000fd5b6000611f81610db060208601866147f2565b8015611fa057506000611f9a60a0860160808701614e07565b61ffff16115b156120cb576000611fb760c0860160a0870161484a565b90506001600160a01b03811661205657610194546001600160a01b0316636859c996611fe9604088016020890161484a565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016020604051808303816000875af115801561202f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120539190614e73565b90505b6001600160a01b0381166120965760405162461bcd60e51b8152602060048201526007602482015266455f5046524e5360c81b604482015260640161050c565b6127106120a960a0870160808801614e07565b61ffff168502816120bc576120bc614de1565b0491506120c98183613072565b505b6121216120de60608d0160408e0161484a565b610f53866120f260e0820160c08301614d36565b60ff16600114612106578486880303612108565b865b8f61012001602081019061211c9190614d36565b613108565b61215461213460a08a0160808b016147f2565b61214460c08b0160a08c0161484a565b6112ae60608c0160408d0161484a565b61215c612669565b50505b6112bb612172604084016020850161484a565b60408085013590612188908d0160208e0161484a565b61219860408b0160208c0161484a565b8a60600135888f61010001356134cd565b609960006121b56123c9565b6001600160a01b0316815260208101919091526040016000205460ff166121ee5760405162461bcd60e51b815260040161050c90614c15565b6105a481613912565b609960006122036123c9565b6001600160a01b0316815260208101919091526040016000205460ff1661223c5760405162461bcd60e51b815260040161050c90614c15565b611485613bf9565b609960006122506123c9565b6001600160a01b0316815260208101919091526040016000205460ff166122895760405162461bcd60e51b815260040161050c90614c15565b6040516301ffc9a760e01b81526001600160a01b038216906301ffc9a7906122bc90635a8c1c2960e01b90600401614f5a565b602060405180830381865afa1580156122d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122fd9190614ce4565b6123195760405162461bcd60e51b815260040161050c90614f6f565b61019680546001600160a01b0319166001600160a01b0383169081179091556040517f39753a6336ef533f6e1785dcab15abdacaf0467b09c6127c32053ad75bcefc6790600090a250565b6000610197600085858560405160200161239a939291909283526001600160a01b03919091166020830152604082015260600190565b6040516020818303038152906040528051906020012081526020019081526020016000205490505b9392505050565b60006123d3613c37565b905090565b6001600160a01b038116600081815260996020908152604091829020805460ff1916905590519182527fa3b62bc36326052d97ea62d63c3d60308ed4c3ea8ac079dd8499f1e9c4f80c0f91015b60405180910390a150565b60fe5460ff16156114855760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161050c565b60007fa92c8cc9fc7227e4b1ec1338cf160ee706956404bf66ef20d50ac4a1aab7af7b82356124ab604085016020860161484a565b6124bb606086016040870161484a565b6124c786606001613c7b565b6124d460c0880188614c9b565b6040516020016124e5929190614fa1565b60408051601f19818403018152919052805160209091012061250a60e0890189614c9b565b60405160200161251b929190614fa1565b60408051601f1981840301815291905280516020909101206125416101008a018a614c9b565b604051602001612552929190614fca565b60408051601f198184030181528282528051602091820120908301999099528101969096526001600160a01b03948516606087015293909216608085015260a084015260c083015260e0820152610100810191909152610120015b604051602081830303815290604052805190602001209050919050565b60006123d37f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6125f960015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b60008060006126548585613cf5565b9150915061266181613d3a565b509392505050565b60005b61019a548110156126bd57610199600061019a838154811061269057612690614c5b565b60009182526020808320909101546001600160a01b0316835282019290925260400181205560010161266c565b5061148561019a6000614795565b60006126df61014083016101208401614d36565b60ff166000036127d9577f39b77601008263a7668e3e906fb7170db776f21b4b101c313e63194c888f361d61272e6127178480614c9b565b61272961014087016101208801614d36565b613ef0565b61273e604085016020860161484a565b61274e606086016040870161484a565b61276361275e6060880188614d99565b613f69565b61277360a0880160808901614e07565b6040805160208101979097528601949094526001600160a01b0392831660608601529116608084015260a083015261ffff1660c08281019190915283013560e08281019190915283013561010082810191909152830135610120820152610140016125ad565b6127eb61014083016101208401614d36565b60ff166001036128fd577fd7db0db2ef492c99933d7c642ebe5da2a1b81a50be6ba5b0752806cad27c3cc16128236127178480614c9b565b612833604085016020860161484a565b612843606086016040870161484a565b61285361275e6060880188614d99565b61286360a0880160808901614e07565b61287360c0890160a08a01614e07565b60c089013560e08a01356101008b01356128956101408d016101208e01614d36565b60408051602081019c909c528b01999099526001600160a01b0397881660608b015296909516608089015260a088019390935261ffff91821660c08801521660e086015261010085015261012084015261014083015260ff16610160820152610180016125ad565b61290f61014083016101208401614d36565b60ff16600203612947577f9f4eecad4a60dff4b37449aceb09bdac950063fc93d795c35ece8212883dffe26128236127178480614c9b565b60405162461bcd60e51b815260040161050c9060208082526004908201526322afa4ab60e11b604082015260600190565b919050565b61299261298d60208701876147f2565b613fd4565b80156129b657506129a9604086016020870161484a565b6001600160a01b03163b15155b6129ec5760405162461bcd60e51b81526020600482015260076024820152661157d4d253d25560ca1b604482015260640161050c565b6129fc604086016020870161484a565b6001600160a01b03166301ffc9a76380ac58cd60e01b6040518263ffffffff1660e01b8152600401612a2e9190614f5a565b602060405180830381865afa158015612a4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6f9190614ce4565b15612ac15760008281526101976020526040902054600103612abc5760405162461bcd60e51b81526020600482015260066024820152651157d4d3d31160d21b604482015260640161050c565b612c1c565b612ad1604086016020870161484a565b6001600160a01b03166301ffc9a7636cdb3d1360e11b6040518263ffffffff1660e01b8152600401612b039190614f5a565b602060405180830381865afa158015612b20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b449190614ce4565b15612bec5780600003612b835760405162461bcd60e51b815260206004820152600760248201526622afa4a320a12b60c91b604482015260640161050c565b612ba6610100870135612b9c604088016020890161484a565b8760400135612364565b612bb4906060870135614f8e565b811115612abc5760405162461bcd60e51b81526020600482015260066024820152651157d4d3d31160d21b604482015260640161050c565b60405162461bcd60e51b81526020600482015260056024820152641157d5505560da1b604482015260640161050c565b610194546040805163f815d6cf60e01b815290516000926001600160a01b03169163f815d6cf916004808301926020929190829003018187875af1158015612c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8c9190615006565b905061ffff8116612ca360a0890160808a01614e07565b61ffff161015612ce15760405162461bcd60e51b81526020600482015260096024820152681157d4d4119315131360ba1b604482015260640161050c565b6001612cf561014089016101208a01614d36565b60ff1610612d505761ffff8116612d1260c0890160a08a01614e07565b61ffff161015612d505760405162461bcd60e51b81526020600482015260096024820152681157d4d4119315131360ba1b604482015260640161050c565b606086013515612da7576001612d6e61014089016101208a01614d36565b60ff161015612da75760405162461bcd60e51b8152602060048201526005602482015264455f564e4360d81b604482015260640161050c565b6000612db96040890160208a0161484a565b6001600160a01b031614158015612de957506000612ddd6060890160408a0161484a565b6001600160a01b031614155b612e1e5760405162461bcd60e51b8152602060048201526006602482015265455f5349504360d01b604482015260640161050c565b60008760c00135118015612e365750428760c0013511155b8015612e51575060e08701351580612e515750428760e00135115b612e865760405162461bcd60e51b8152602060048201526006602482015265455f5349455360d01b604482015260640161050c565b612e96604088016020890161484a565b6001600160a01b0316612ee786868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061098f925088915061095490506125ca565b6001600160a01b031614612f255760405162461bcd60e51b8152602060048201526005602482015264455f49535360d81b604482015260640161050c565b50505050505050565b600080805b84811015612ffa5736868683818110612f4e57612f4e614c5b565b606002919091019150612f6e9050612f6960208301836147f2565b61400a565b8015612f7d5750604081013515155b612fb35760405162461bcd60e51b81526020600482015260076024820152660455f53504d49560cc1b604482015260640161050c565b612fc060208601866147f2565b6001600160e01b031916612fd760208301836147f2565b6001600160e01b03191603612ff157604001359150612ffa565b50600101612f33565b50806000036130345760405162461bcd60e51b8152602060048201526006602482015265455f504d4e4d60d01b604482015260640161050c565b949350505050565b60006001600160e01b0319821663fdae1ba760e01b14806104c157506001600160e01b031982166322ba176160e21b1492915050565b8015610761576001600160a01b0382166000908152610199602052604081205490036130e55761019a80546001810182556000919091527fd994f4dad00f9ff89caab117647e768aa59b274f965a222ec6a1586aa6e26bcb0180546001600160a01b0319166001600160a01b0384161790555b6001600160a01b0382166000908152610199602052604090208054820190555050565b61019654600090819081906001600160a01b031663428711576131316040890160208a0161484a565b60408901358861314760e08c0160c08d01614d36565b6040516001600160e01b031960e087901b1681526001600160a01b0390941660048501526024840192909252604483015260ff1660648201526084016000604051808303816000875af11580156131a2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526131ca91908101906150bc565b50815191935091506000600260ff8716108015906131e6575081155b8015613200575060006131fc60e08a018a614c9b565b9050115b156134675761321260e0890189614c9b565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050825192965091935061325a915050610100890189614c9b565b905082148015613281575061271061327a6101408a016101208b01614e07565b61ffff1611155b6132bd5760405162461bcd60e51b815260206004820152600d60248201526c0455f4952445f534f504731303609c1b604482015260640161050c565b866132ce60e08a0160c08b01614d36565b60ff16600103613304576127106132ed6101408b016101208c01614e07565b61ffff1689028161330057613300614de1565b0490505b826001600160401b0381111561331c5761331c614a3d565b604051908082528060200260200182016040528015613345578160200160208202803683370190505b50935060008092505b838310156134245760006001600160a01b031686848151811061337357613373614c5b565b60200260200101516001600160a01b0316036133b95760405162461bcd60e51b8152602060048201526005602482015264455f49524160d81b604482015260640161050c565b60006133c96101008c018c614c9b565b858181106133d9576133d9614c5b565b90506020020160208101906133ee9190614e07565b905061271061ffff821684020486858151811061340d5761340d614c5b565b60209081029190910101526001909301920161334e565b61ffff8116612710146134645760405162461bcd60e51b81526020600482015260086024820152670455f52504e3130360c41b604482015260640161050c565b50505b506000805b828210156134c157600084838151811061348857613488614c5b565b602002602001015190506134b58684815181106134a7576134a7614c5b565b602002602001015182613072565b6001909201910161346c565b98975050505050505050565b821561356757610195546040805180820182526002815261060f60f31b60208201529051639c1c2ee960e01b81526001600160a01b0390921691639c1c2ee991613524918b918a918a918d918b91906004016151e0565b600060405180830381600087803b15801561353e57600080fd5b505af1158015613552573d6000803e3d6000fd5b5050505061356281888886614076565b6135e7565b61019554604051637b84dc8360e11b81526001600160a01b039091169063f709b9069061359e908a90899089908c90600401614c71565b600060405180830381600087803b1580156135b857600080fd5b505af11580156135cc573d6000803e3d6000fd5b50505060008381526101976020526040902080546001019055505b85876001600160a01b0316827f052aa775128ed1cbbd47b4948be31a03a0e96f23361fbabd94fde8e24aedfb038660405161362491815260200190565b60405180910390a450505050505050565b60005b61019a5481101561075e57600061019a828154811061365957613659614c5b565b60009182526020808320909101546001600160a01b0316808352610199909152604090912054909150630251e45960e01b6001600160e01b03198716016136d6576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156136d0573d6000803e3d6000fd5b50613758565b631d45e89f60e21b6001600160e01b0319871601613758576101955460405163776062c360e01b81526001600160a01b039091169063776062c390613725908890889087908790600401614c71565b600060405180830381600087803b15801561373f57600080fd5b505af1158015613753573d6000803e3d6000fd5b505050505b5050600101613638565b6099600061376e6123c9565b6001600160a01b0316815260208101919091526040016000205460ff166105a45760405162461bcd60e51b815260040161050c90614c15565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156137da5761066d836140dd565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613834575060408051601f3d908101601f1916820190925261383191810190614e90565b60015b6138975760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161050c565b6000805160206152e983398151915281146139065760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161050c565b5061066d838383614179565b6001600160a01b03811661397c5760405162461bcd60e51b815260206004820152602b60248201527f41646d696e3a61646441646d696e206e657741646d696e20697320746865207a60448201526a65726f206164647265737360a81b606482015260840161050c565b6001600160a01b038116600081815260996020908152604091829020805460ff1916600117905590519182527f44d6d25963f097ad14f29f06854a01f575648a1ef82f30e562ccd3889717e3399101612425565b6139d861419e565b60fe805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa613a0b6123c9565b6040516001600160a01b03909116815260200160405180910390a1565b6000613a3c61012083016101008401614d36565b60ff16600003613ad3577f16533b1a2b574048998c15c61696aff2836a5106c01e21954538cf393cf8124a8235613a79604085016020860161484a565b613a89606086016040870161484a565b613a9586608001613c7b565b6040805160208101969096528501939093526001600160a01b03918216606085015216608083015260a082015260e08084013560c0830152016125ad565b613ae561012083016101008401614d36565b60ff1660011480613b0a5750613b0361012083016101008401614d36565b60ff166002145b15613bc6577f02e75952f6dbd570765759927f425880efe915c78b4351b9f010366a3a15f8e08235613b42604085016020860161484a565b613b52606086016040870161484a565b8560600135613b6387608001613c7b565b60e0880135613b7a6101208a016101008b01614d36565b6040805160208101999099528801969096526001600160a01b03948516606088015293909216608086015260a085015260c084015260e083015260ff16610100820152610120016125ad565b60405162461bcd60e51b815260206004820152600860248201526722afa7a219afa4ab60c11b604482015260640161050c565b613c01612430565b60fe805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613a0b6123c9565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303613c76575060131936013560601c90565b503390565b60007f5b442961536b72a0442e9a53df012289ed70f5c860457d810d2c17836bd8bdce613cab60208401846147f2565b613cbb604085016020860161484a565b6040805160208101949094526001600160e01b0319909216838301526001600160a01b03166060830152830135608082015260a0016125ad565b6000808251604103613d2b5760208301516040840151606085015160001a613d1f878285856141e7565b94509450505050613d33565b506000905060025b9250929050565b6000816004811115613d4e57613d4e615222565b03613d565750565b6001816004811115613d6a57613d6a615222565b03613db75760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161050c565b6002816004811115613dcb57613dcb615222565b03613e185760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161050c565b6003816004811115613e2c57613e2c615222565b03613e845760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161050c565b6004816004811115613e9857613e98615222565b036105a45760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161050c565b6000606060005b84811015613f585781613f2d878784818110613f1557613f15614c5b565b9050602002810190613f279190614d06565b866142d4565b604051602001613f3e929190615238565b60408051601f198184030181529190529150600101613ef7565b508051602090910120949350505050565b6000606060005b83811015613fc45781613f99868684818110613f8e57613f8e614c5b565b905060600201613c7b565b604051602001613faa929190615238565b60408051601f198184030181529190529150600101613f70565b5080516020909101209392505050565b60006001600160e01b03198216639e80de3760e01b14806104c157506001600160e01b0319821663163b6d3b60e21b1492915050565b60006001600160e01b0319821663fdae1ba760e01b148061403b57506001600160e01b031982166322ba176160e21b145b8061405657506001600160e01b03198216633ecaa07960e21b145b806104c157506001600160e01b0319821663d5a81f1960e01b1492915050565b8061019760008686866040516020016140ab939291909283526001600160a01b03919091166020830152604082015260600190565b60408051601f198184030181529181528151602092830120835290820192909252016000208054909101905550505050565b6001600160a01b0381163b61414a5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161050c565b6000805160206152e983398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61418283614607565b60008251118061418f5750805b1561066d5761075e8383614647565b60fe5460ff166114855760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161050c565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561421e57506000905060036142cb565b8460ff16601b1415801561423657508460ff16601c14155b1561424757506000905060046142cb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561429b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166142c4576000600192509250506142cb565b9150600090505b94509492505050565b60008160ff166000036143aa577fda89efe36e8d4174abec2b392e28fde5f06a39ea80761619c7690bf86606452461430f60208501856147f2565b61431f604086016020870161484a565b604086013561433460a0880160808901614e07565b61434460e0890160c08a01614d36565b6040805160208101979097526001600160e01b0319909516948601949094526001600160a01b039092166060850152608084015261ffff1660a083015260ff1660c082015260e0015b6040516020818303038152906040528051906020012090506104c1565b8160ff1660010361448d577f711444f222b4586ccfaca2037481d3fab181017c88fc21fb2f78909a6953ba066143e360208501856147f2565b6143f3604086016020870161484a565b6040860135606087013561440d60a0890160808a01614e07565b61441d60c08a0160a08b0161484a565b61442d60e08b0160c08c01614d36565b6040805160208101999099526001600160e01b0319909716968801969096526001600160a01b039485166060880152608087019390935260a086019190915261ffff1660c08501521660e083015260ff166101008201526101200161438d565b8160ff16600203612947577fbd60107b487bdfeb3ec8fcbfe07542913ceca85dc095c07f5cb6b97d028573cd6144c660208501856147f2565b6144d6604086016020870161484a565b604086013560608701356144f060a0890160808a01614e07565b61450060c08a0160a08b0161484a565b61451060e08b0160c08c01614d36565b61451d60e08c018c614c9b565b60405160200161452e92919061525a565b60408051601f1981840301815291905280516020909101206145546101008d018d614c9b565b604051602001614565929190615291565b60408051601f19818403018152919052805160209091012061458f6101408e016101208f01614e07565b60408051602081019c909c526001600160e01b0319909a16998b01999099526001600160a01b0397881660608b015260808a019690965260a089019490945261ffff92831660c0890152941660e087015260ff909316610100860152610120850152610140840152166101608201526101800161438d565b614610816140dd565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6146af5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161050c565b600080846001600160a01b0316846040516146ca91906152c3565b600060405180830381855af49150503d8060008114614705576040519150601f19603f3d011682016040523d82523d6000602084013e61470a565b606091505b509150915061473282826040518060600160405280602781526020016153096027913961473b565b95945050505050565b6060831561474a5750816123c2565b82511561475a5782518084602001fd5b8160405162461bcd60e51b815260040161050c91906152d5565b50805460008255600202906000526020600020908101906105a491906147b3565b50805460008255906000526020600020908101906105a491906147dd565b5b808211156147d95780546001600160a01b0319168155600060018201556002016147b4565b5090565b5b808211156147d957600081556001016147de565b60006020828403121561480457600080fd5b81356001600160e01b0319811681146123c257600080fd5b60006020828403121561482e57600080fd5b5035919050565b6001600160a01b03811681146105a457600080fd5b60006020828403121561485c57600080fd5b81356123c281614835565b6000806040838503121561487a57600080fd5b823561488581614835565b9150602083013561489581614835565b809150509250929050565b60008083601f8401126148b257600080fd5b5081356001600160401b038111156148c957600080fd5b6020830191508360208260051b8501011115613d3357600080fd5b600061012082840312156148f757600080fd5b50919050565b60008083601f84011261490f57600080fd5b5081356001600160401b0381111561492657600080fd5b602083019150836020828501011115613d3357600080fd5b60008060008060008060006080888a03121561495957600080fd5b87356001600160401b038082111561497057600080fd5b61497c8b838c016148a0565b909950975060208a013591508082111561499557600080fd5b6149a18b838c016148a0565b909750955060408a01359150808211156149ba57600080fd5b6149c68b838c016148e4565b945060608a01359150808211156149dc57600080fd5b506149e98a828b016148fd565b989b979a50959850939692959293505050565b60008060208385031215614a0f57600080fd5b82356001600160401b03811115614a2557600080fd5b614a31858286016148a0565b90969095509350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715614a7b57614a7b614a3d565b604052919050565b60008060408385031215614a9657600080fd5b8235614aa181614835565b91506020838101356001600160401b0380821115614abe57600080fd5b818601915086601f830112614ad257600080fd5b813581811115614ae457614ae4614a3d565b614af6601f8201601f19168501614a53565b91508082528784828501011115614b0c57600080fd5b80848401858401376000848284010152508093505050509250929050565b6000806000806000806101808789031215614b4457600080fd5b86356001600160401b0380821115614b5b57600080fd5b90880190610140828b031215614b7057600080fd5b90965060208801359080821115614b8657600080fd5b614b928a838b016148fd565b9097509550859150614ba78a60408b016148e4565b9450610160890135915080821115614bbe57600080fd5b50614bcb89828a016148fd565b979a9699509497509295939492505050565b600080600060608486031215614bf257600080fd5b833592506020840135614c0481614835565b929592945050506040919091013590565b60208082526026908201527f41646d696e3a6f6e6c7941646d696e2063616c6c6572206973206e6f7420616e6040820152651020b236b4b760d11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6000808335601e19843603018112614cb257600080fd5b8301803591506001600160401b03821115614ccc57600080fd5b6020019150600581901b3603821315613d3357600080fd5b600060208284031215614cf657600080fd5b815180151581146123c257600080fd5b6000823561013e19833603018112614d1d57600080fd5b9190910192915050565b60ff811681146105a457600080fd5b600060208284031215614d4857600080fd5b81356123c281614d27565b6000808335601e19843603018112614d6a57600080fd5b8301803591506001600160401b03821115614d8457600080fd5b602001915036819003821315613d3357600080fd5b6000808335601e19843603018112614db057600080fd5b8301803591506001600160401b03821115614dca57600080fd5b6020019150606081023603821315613d3357600080fd5b634e487b7160e01b600052601260045260246000fd5b61ffff811681146105a457600080fd5b600060208284031215614e1957600080fd5b81356123c281614df7565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176104c1576104c1614e24565b600082614e6e57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215614e8557600080fd5b81516123c281614835565b600060208284031215614ea257600080fd5b5051919050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b600060018201614f5357614f53614e24565b5060010190565b6001600160e01b031991909116815260200190565b602080825260059082015264455f494e5360d81b604082015260600190565b818103818111156104c1576104c1614e24565b60006001600160fb1b03831115614fb757600080fd5b8260051b80858437919091019392505050565b60008184825b85811015614ffb578135614fe381614d27565b60ff1683526020928301929190910190600101614fd0565b509095945050505050565b60006020828403121561501857600080fd5b81516123c281614df7565b60006001600160401b0382111561503c5761503c614a3d565b5060051b60200190565b600082601f83011261505757600080fd5b8151602061506c61506783615023565b614a53565b82815260059290921b8401810191818101908684111561508b57600080fd5b8286015b848110156150a6578051835291830191830161508f565b509695505050505050565b805161297881614d27565b6000806000606084860312156150d157600080fd5b83516001600160401b03808211156150e857600080fd5b818601915086601f8301126150fc57600080fd5b8151602061510c61506783615023565b82815260059290921b8401810191818101908a84111561512b57600080fd5b948201945b8386101561515257855161514381614835565b82529482019490820190615130565b9189015191975090935050508082111561516b57600080fd5b5061517886828701615046565b925050615187604085016150b1565b90509250925092565b60005b838110156151ab578181015183820152602001615193565b50506000910152565b600081518084526151cc816020860160208601615190565b601f01601f19169290920160200192915050565b6001600160a01b038781168252868116602083015285166040820152606081018490526080810183905260c060a082018190526000906134c1908301846151b4565b634e487b7160e01b600052602160045260246000fd5b6000835161524a818460208801615190565b9190910191825250602001919050565b60008184825b85811015614ffb57813561527381614835565b6001600160a01b031683526020928301929190910190600101615260565b60008184825b85811015614ffb5781356152aa81614df7565b61ffff1683526020928301929190910190600101615297565b60008251614d1d818460208701615190565b6020815260006123c260208301846151b456fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d50cd222d1cbe4c250af7cf59b942522222d81815cfb694b555e44bbee11414564736f6c63430008130033000000000000000000000000307e7a9713dbf6f19a2d2a2b670544f4791c4ec2

Deployed ByteCode

0x60806040526004361061014b5760003560e01c806354fd4d50116100b6578063704802751161006f57806370480275146103d95780638456cb59146103f9578063a11b07121461040e578063c255f8781461042f578063cc25319314610450578063cf1d53cf1461047057600080fd5b806354fd4d50146102ec578063572b6c05146103085780635c975abb14610355578063653551501461036d578063658c09a81461038d5780636e667db3146103a057600080fd5b80633659cfe6116101085780633659cfe61461024f5780633d0950a81461026f5780633f4ba83a1461028f5780634c275cac146102a45780634f1ef286146102c457806352d1902d146102d757600080fd5b806301ffc9a71461015057806313263340146101855780631785f53c146101c157806318cdeccc146101e357806324d7806c14610203578063345c669e1461023c575b600080fd5b34801561015c57600080fd5b5061017061016b3660046147f2565b610490565b60405190151581526020015b60405180910390f35b34801561019157600080fd5b506101b36101a036600461481c565b6000908152610197602052604090205490565b60405190815260200161017c565b3480156101cd57600080fd5b506101e16101dc36600461484a565b6104c7565b005b3480156101ef57600080fd5b506101e16101fe366004614867565b6105a7565b34801561020f57600080fd5b5061017061021e36600461484a565b6001600160a01b031660009081526099602052604090205460ff1690565b6101e161024a36600461493e565b610765565b34801561025b57600080fd5b506101e161026a36600461484a565b6112cb565b34801561027b57600080fd5b506101e161028a3660046149fc565b6113a7565b34801561029b57600080fd5b506101e1611438565b3480156102b057600080fd5b506101e16102bf36600461484a565b611487565b6101e16102d2366004614a83565b6115a7565b3480156102e357600080fd5b506101b3611673565b3480156102f857600080fd5b506040516003815260200161017c565b34801561031457600080fd5b5061017061032336600461484a565b7f000000000000000000000000307e7a9713dbf6f19a2d2a2b670544f4791c4ec26001600160a01b0390811691161490565b34801561036157600080fd5b5060fe5460ff16610170565b34801561037957600080fd5b506101e161038836600461484a565b611726565b6101e161039b366004614b2a565b611846565b3480156103ac57600080fd5b50610195546103c1906001600160a01b031681565b6040516001600160a01b03909116815260200161017c565b3480156103e557600080fd5b506101e16103f436600461484a565b6121a9565b34801561040557600080fd5b506101e16121f7565b34801561041a57600080fd5b50610196546103c1906001600160a01b031681565b34801561043b57600080fd5b50610194546103c1906001600160a01b031681565b34801561045c57600080fd5b506101e161046b36600461484a565b612244565b34801561047c57600080fd5b506101b361048b366004614bdd565b612364565b60006001600160e01b03198216630296913360e11b14806104c157506301ffc9a760e01b6001600160e01b03198316145b92915050565b609960006104d36123c9565b6001600160a01b0316815260208101919091526040016000205460ff166105155760405162461bcd60e51b815260040161050c90614c15565b60405180910390fd5b6001600160a01b03811660009081526099602052604090205460ff1661059b5760405162461bcd60e51b815260206004820152603560248201527f41646d696e3a72656d6f766541646d696e20747279696e6720746f2072656d6f6044820152743b32903737b71032bc34b9ba34b7339020b236b4b760591b606482015260840161050c565b6105a4816123d8565b50565b609960006105b36123c9565b6001600160a01b0316815260208101919091526040016000205460ff166105ec5760405162461bcd60e51b815260040161050c90614c15565b6001600160a01b03821661062a5760405162461bcd60e51b8152602060048201526005602482015264455f49574160d81b604482015260640161050c565b6001600160a01b038116610672576040516001600160a01b038316904780156108fc02916000818181858888f1935050505015801561066d573d6000803e3d6000fd5b505050565b6001600160a01b038116600090815261019860205260408120805490915b8181101561073b5760008382815481106106ac576106ac614c5b565b60009182526020909120610195546002909202018054600182015460405163776062c360e01b81529294506001600160a01b039384169363776062c3936106fc938b939216918c91600401614c71565b600060405180830381600087803b15801561071657600080fd5b505af115801561072a573d6000803e3d6000fd5b505060019093019250610690915050565b506001600160a01b03831660009081526101986020526040812061075e91614774565b50505b5050565b61076d612430565b600260cc54036107bf5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161050c565b600260cc558580158015906107d357508085145b80156107ec57506107e760c0850185614c9b565b905081145b8015610805575061080060e0850185614c9b565b905081145b801561081f575061081a610100850185614c9b565b905081145b6108545760405162461bcd60e51b8152602060048201526006602482015265455f534f4c4d60d01b604482015260640161050c565b4284351080159061087e57506000610872604086016020870161484a565b6001600160a01b031614155b80156108a357506000610897606086016040870161484a565b6001600160a01b031614155b80156108b2575060a084013515155b6108ef5760405162461bcd60e51b815260206004820152600e60248201526d0455f454f5f49425f49505f4942560941b604482015260640161050c565b61019454604080516020601f86018190048102820181019092528481526001600160a01b0390921691634d4ed32c916109959190879087908190840183828082843760009201919091525061098f925061094c91508a9050612476565b6109546125ca565b6040805161190160f01b6020808301919091526022820193909352604280820194909452815180820390940184526062019052815191012090565b90612645565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156109d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fd9190614ce4565b610a315760405162461bcd60e51b8152602060048201526005602482015264455f49505360d81b604482015260640161050c565b610a39612669565b6000805b82811015610fbb57368a8a83818110610a5857610a58614c5b565b9050602002810190610a6a9190614d06565b90506000610a8061014083016101208401614d36565b9050610a8c8280614c9b565b90506001148015610aa1575061010082013515155b8015610ad45750610ab560c0890189614c9b565b84818110610ac557610ac5614c5b565b90506020020135826101000135145b8015610b175750610ae9610100890189614c9b565b84818110610af957610af9614c5b565b9050602002016020810190610b0e9190614d36565b60ff168160ff16145b610b525760405162461bcd60e51b815260206004820152600c60248201526b22afa0a62fa72fab26afa4a160a11b604482015260640161050c565b36610b5d8380614c9b565b6000818110610b6e57610b6e614c5b565b9050602002810190610b809190614d06565b90506000610b9160e08b018b614c9b565b86818110610ba157610ba1614c5b565b9050602002013590506000610bb5856126cb565b9050610be785848f8f8a818110610bce57610bce614c5b565b9050602002810190610be09190614d53565b858761297d565b610bf760408c0160208d0161484a565b6001600160a01b0316610c10604087016020880161484a565b6001600160a01b031603610c505760405162461bcd60e51b8152602060048201526007602482015266455f434141425360c81b604482015260640161050c565b6000610c6b610c626060880188614d99565b8e606001612f2e565b9050610c85610c8060808e0160608f016147f2565b61303c565b15610f61578215610ca957836060013583820281610ca557610ca5614de1565b0490505b968701966000612710600160ff881610801590610cd85750610cd160e0870160c08801614d36565b60ff166001145b610cf157610cec60a0890160808a01614e07565b610d01565b610d0160c0890160a08a01614e07565b610d0f9061ffff1684614e3a565b610d199190614e51565b9050610d9e61019460009054906101000a90046001600160a01b03166001600160a01b031663707d18486040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d989190614e73565b82613072565b6000610dc6610db060208801886147f2565b6001600160e01b03191663163b6d3b60e21b1490565b8015610de557506000610ddf60a0880160808901614e07565b61ffff16115b15610f10576000610dfc60c0880160a0890161484a565b90506001600160a01b038116610e9b57610194546001600160a01b0316636859c996610e2e60408a0160208b0161484a565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016020604051808303816000875af1158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e989190614e73565b90505b6001600160a01b038116610edb5760405162461bcd60e51b8152602060048201526007602482015266455f5046524e5360c81b604482015260640161050c565b612710610eee60a0890160808a01614e07565b61ffff16850281610f0157610f01614de1565b049150610f0e8183613072565b505b610f5e610f2360608a0160408b0161484a565b610f5388610f3760e0820160c08301614d36565b60ff16600114610f4b578486880303610f4d565b865b8b613108565b838587030303613072565b50505b610faa610f74604086016020870161484a565b60408087013590610f8a908a0160208b0161484a565b8f6020016020810190610f9d919061484a565b87878c61010001356134cd565b866001019650505050505050610a3d565b5063fdae1ba760e01b610fd460808701606088016147f2565b6001600160e01b03191603611021578034101561101c5760405162461bcd60e51b81526020600482015260066024820152651157d391539560d21b604482015260640161050c565b61127b565b6322ba176160e21b61103960808701606088016147f2565b6001600160e01b0319160361127b57610194546001600160a01b0316635247385c61106a60a088016080890161484a565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156110ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d29190614ce4565b6111085760405162461bcd60e51b8152602060048201526007602482015266455f4250544e5760c81b604482015260640161050c565b600061111a60a087016080880161484a565b905060006001600160a01b03821663dd62ed3e61113d60608a0160408b0161484a565b6101955460405160e084901b6001600160e01b03191681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561118c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b09190614e90565b9050828110156111ee5760405162461bcd60e51b81526020600482015260096024820152680455f4e4545524332360bc1b604482015260640161050c565b828103818414611277576001600160a01b0383166000908152610198602052604090819020815180830183529091819061122e9060608d01908d0161484a565b6001600160a01b0390811682526020918201859052835460018082018655600095865294839020845160029092020180546001600160a01b031916919092161781559101519101555b5050505b6112b361128e60808701606088016147f2565b61129e60a088016080890161484a565b6112ae6060890160408a0161484a565b613635565b6112bb612669565b5050600160cc5550505050505050565b6001600160a01b037f0000000000000000000000005d774245f4c1e7318f90ab8362184c39f27289811630036113135760405162461bcd60e51b815260040161050c90614ea9565b7f0000000000000000000000005d774245f4c1e7318f90ab8362184c39f27289816001600160a01b031661135c6000805160206152e9833981519152546001600160a01b031690565b6001600160a01b0316146113825760405162461bcd60e51b815260040161050c90614ef5565b61138b81613762565b604080516000808252602082019092526105a4918391906137a7565b609960006113b36123c9565b6001600160a01b0316815260208101919091526040016000205460ff166113ec5760405162461bcd60e51b815260040161050c90614c15565b60005b8181101561066d5761142683838381811061140c5761140c614c5b565b9050602002016020810190611421919061484a565b613912565b8061143081614f41565b9150506113ef565b609960006114446123c9565b6001600160a01b0316815260208101919091526040016000205460ff1661147d5760405162461bcd60e51b815260040161050c90614c15565b6114856139d0565b565b609960006114936123c9565b6001600160a01b0316815260208101919091526040016000205460ff166114cc5760405162461bcd60e51b815260040161050c90614c15565b6040516301ffc9a760e01b81526001600160a01b038216906301ffc9a7906114ff9063071d7d4b60e21b90600401614f5a565b602060405180830381865afa15801561151c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115409190614ce4565b61155c5760405162461bcd60e51b815260040161050c90614f6f565b61019580546001600160a01b0319166001600160a01b0383169081179091556040517fdf3b866248a7a3e982f0a93fde9cf30633ed3bb09365c16b08260ad033db920790600090a250565b6001600160a01b037f0000000000000000000000005d774245f4c1e7318f90ab8362184c39f27289811630036115ef5760405162461bcd60e51b815260040161050c90614ea9565b7f0000000000000000000000005d774245f4c1e7318f90ab8362184c39f27289816001600160a01b03166116386000805160206152e9833981519152546001600160a01b031690565b6001600160a01b03161461165e5760405162461bcd60e51b815260040161050c90614ef5565b61166782613762565b610761828260016137a7565b6000306001600160a01b037f0000000000000000000000005d774245f4c1e7318f90ab8362184c39f272898116146117135760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161050c565b506000805160206152e983398151915290565b609960006117326123c9565b6001600160a01b0316815260208101919091526040016000205460ff1661176b5760405162461bcd60e51b815260040161050c90614c15565b6040516301ffc9a760e01b81526001600160a01b038216906301ffc9a79061179e9063042eca1d60e51b90600401614f5a565b602060405180830381865afa1580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df9190614ce4565b6117fb5760405162461bcd60e51b815260040161050c90614f6f565b61019480546001600160a01b0319166001600160a01b0383169081179091556040517fa48d197b43b1826afcf98445392676fa169817dd3216002b6fd70e8601ef2b0190600090a250565b61184e612430565b600260cc54036118a05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161050c565b600260cc554260e0840135108015906118d2575060006118c6604085016020860161484a565b6001600160a01b031614155b80156118f7575060006118eb606085016040860161484a565b6001600160a01b031614155b8015611906575060c083013515155b6119435760405162461bcd60e51b815260206004820152600e60248201526d0455f454f5f49425f49505f4942560941b604482015260640161050c565b61194d8680614c9b565b90506001148015611962575061010086013515155b801561197357506101008601358335145b80156119a6575061198c61012084016101008501614d36565b60ff166119a161014088016101208901614d36565b60ff16145b80156119e257506119bd604084016020850161484a565b6001600160a01b03166119d6604088016020890161484a565b6001600160a01b031614155b611a1d5760405162461bcd60e51b815260206004820152600c60248201526b22afa0a62fa72fab26afa4a160a11b604482015260640161050c565b61019454604080516020601f85018190048102820181019092528381526001600160a01b0390921691634d4ed32c91611a7a9190869086908190840183828082843760009201919091525061098f925061094c9150899050613a28565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae29190614ce4565b611b165760405162461bcd60e51b8152602060048201526005602482015264455f49505360d81b604482015260640161050c565b6000611b21876126cb565b905036611b2e8880614c9b565b6000818110611b3f57611b3f614c5b565b9050602002810190611b519190614d06565b9050611b6588828989868a6060013561297d565b6000611b80611b7760608b018b614d99565b88608001612f2e565b9050611b95610c8060a08801608089016147f2565b1561215f57611ba2612669565b606086013515611bce578160600135866060013582611bc19190614e3a565b611bcb9190614e51565b90505b63fdae1ba760e01b611be660a08801608089016147f2565b6001600160e01b03191603611c335780341015611c2e5760405162461bcd60e51b81526020600482015260066024820152651157d391539560d21b604482015260640161050c565b611e97565b6322ba176160e21b611c4b60a08801608089016147f2565b6001600160e01b03191603611e9757610194546001600160a01b0316635247385c611c7c60c0890160a08a0161484a565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce49190614ce4565b611d1a5760405162461bcd60e51b8152602060048201526007602482015266455f4250544e5760c81b604482015260640161050c565b6000611d2c60c0880160a0890161484a565b905060006001600160a01b03821663dd62ed3e611d4f60608b0160408c0161484a565b6101955460405160e084901b6001600160e01b03191681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015611d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc29190614e90565b905082811015611e005760405162461bcd60e51b81526020600482015260096024820152680455f4e4545524332360bc1b604482015260640161050c565b6000611e0c8483614f8e565b90508015611e93576001600160a01b03831660009081526101986020526040908190208151808301835290918190611e4a9060608e01908e0161484a565b6001600160a01b0390811682526020918201859052835460018082018655600095865294839020845160029092020180546001600160a01b031916919092161781559101519101555b5050505b60006127106001611eb06101408d016101208e01614d36565b60ff1610158015611ed35750611ecc60e0850160c08601614d36565b60ff166001145b611eec57611ee760a08c0160808d01614e07565b611efc565b611efc60c08c0160a08d01614e07565b611f0a9061ffff1684614e3a565b611f149190614e51565b9050611f6f61019460009054906101000a90046001600160a01b03166001600160a01b031663707d18486040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610d74573d6000803e3d6000fd5b6000611f81610db060208601866147f2565b8015611fa057506000611f9a60a0860160808701614e07565b61ffff16115b156120cb576000611fb760c0860160a0870161484a565b90506001600160a01b03811661205657610194546001600160a01b0316636859c996611fe9604088016020890161484a565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016020604051808303816000875af115801561202f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120539190614e73565b90505b6001600160a01b0381166120965760405162461bcd60e51b8152602060048201526007602482015266455f5046524e5360c81b604482015260640161050c565b6127106120a960a0870160808801614e07565b61ffff168502816120bc576120bc614de1565b0491506120c98183613072565b505b6121216120de60608d0160408e0161484a565b610f53866120f260e0820160c08301614d36565b60ff16600114612106578486880303612108565b865b8f61012001602081019061211c9190614d36565b613108565b61215461213460a08a0160808b016147f2565b61214460c08b0160a08c0161484a565b6112ae60608c0160408d0161484a565b61215c612669565b50505b6112bb612172604084016020850161484a565b60408085013590612188908d0160208e0161484a565b61219860408b0160208c0161484a565b8a60600135888f61010001356134cd565b609960006121b56123c9565b6001600160a01b0316815260208101919091526040016000205460ff166121ee5760405162461bcd60e51b815260040161050c90614c15565b6105a481613912565b609960006122036123c9565b6001600160a01b0316815260208101919091526040016000205460ff1661223c5760405162461bcd60e51b815260040161050c90614c15565b611485613bf9565b609960006122506123c9565b6001600160a01b0316815260208101919091526040016000205460ff166122895760405162461bcd60e51b815260040161050c90614c15565b6040516301ffc9a760e01b81526001600160a01b038216906301ffc9a7906122bc90635a8c1c2960e01b90600401614f5a565b602060405180830381865afa1580156122d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122fd9190614ce4565b6123195760405162461bcd60e51b815260040161050c90614f6f565b61019680546001600160a01b0319166001600160a01b0383169081179091556040517f39753a6336ef533f6e1785dcab15abdacaf0467b09c6127c32053ad75bcefc6790600090a250565b6000610197600085858560405160200161239a939291909283526001600160a01b03919091166020830152604082015260600190565b6040516020818303038152906040528051906020012081526020019081526020016000205490505b9392505050565b60006123d3613c37565b905090565b6001600160a01b038116600081815260996020908152604091829020805460ff1916905590519182527fa3b62bc36326052d97ea62d63c3d60308ed4c3ea8ac079dd8499f1e9c4f80c0f91015b60405180910390a150565b60fe5460ff16156114855760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161050c565b60007fa92c8cc9fc7227e4b1ec1338cf160ee706956404bf66ef20d50ac4a1aab7af7b82356124ab604085016020860161484a565b6124bb606086016040870161484a565b6124c786606001613c7b565b6124d460c0880188614c9b565b6040516020016124e5929190614fa1565b60408051601f19818403018152919052805160209091012061250a60e0890189614c9b565b60405160200161251b929190614fa1565b60408051601f1981840301815291905280516020909101206125416101008a018a614c9b565b604051602001612552929190614fca565b60408051601f198184030181528282528051602091820120908301999099528101969096526001600160a01b03948516606087015293909216608085015260a084015260c083015260e0820152610100810191909152610120015b604051602081830303815290604052805190602001209050919050565b60006123d37f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6125f960015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b60008060006126548585613cf5565b9150915061266181613d3a565b509392505050565b60005b61019a548110156126bd57610199600061019a838154811061269057612690614c5b565b60009182526020808320909101546001600160a01b0316835282019290925260400181205560010161266c565b5061148561019a6000614795565b60006126df61014083016101208401614d36565b60ff166000036127d9577f39b77601008263a7668e3e906fb7170db776f21b4b101c313e63194c888f361d61272e6127178480614c9b565b61272961014087016101208801614d36565b613ef0565b61273e604085016020860161484a565b61274e606086016040870161484a565b61276361275e6060880188614d99565b613f69565b61277360a0880160808901614e07565b6040805160208101979097528601949094526001600160a01b0392831660608601529116608084015260a083015261ffff1660c08281019190915283013560e08281019190915283013561010082810191909152830135610120820152610140016125ad565b6127eb61014083016101208401614d36565b60ff166001036128fd577fd7db0db2ef492c99933d7c642ebe5da2a1b81a50be6ba5b0752806cad27c3cc16128236127178480614c9b565b612833604085016020860161484a565b612843606086016040870161484a565b61285361275e6060880188614d99565b61286360a0880160808901614e07565b61287360c0890160a08a01614e07565b60c089013560e08a01356101008b01356128956101408d016101208e01614d36565b60408051602081019c909c528b01999099526001600160a01b0397881660608b015296909516608089015260a088019390935261ffff91821660c08801521660e086015261010085015261012084015261014083015260ff16610160820152610180016125ad565b61290f61014083016101208401614d36565b60ff16600203612947577f9f4eecad4a60dff4b37449aceb09bdac950063fc93d795c35ece8212883dffe26128236127178480614c9b565b60405162461bcd60e51b815260040161050c9060208082526004908201526322afa4ab60e11b604082015260600190565b919050565b61299261298d60208701876147f2565b613fd4565b80156129b657506129a9604086016020870161484a565b6001600160a01b03163b15155b6129ec5760405162461bcd60e51b81526020600482015260076024820152661157d4d253d25560ca1b604482015260640161050c565b6129fc604086016020870161484a565b6001600160a01b03166301ffc9a76380ac58cd60e01b6040518263ffffffff1660e01b8152600401612a2e9190614f5a565b602060405180830381865afa158015612a4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6f9190614ce4565b15612ac15760008281526101976020526040902054600103612abc5760405162461bcd60e51b81526020600482015260066024820152651157d4d3d31160d21b604482015260640161050c565b612c1c565b612ad1604086016020870161484a565b6001600160a01b03166301ffc9a7636cdb3d1360e11b6040518263ffffffff1660e01b8152600401612b039190614f5a565b602060405180830381865afa158015612b20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b449190614ce4565b15612bec5780600003612b835760405162461bcd60e51b815260206004820152600760248201526622afa4a320a12b60c91b604482015260640161050c565b612ba6610100870135612b9c604088016020890161484a565b8760400135612364565b612bb4906060870135614f8e565b811115612abc5760405162461bcd60e51b81526020600482015260066024820152651157d4d3d31160d21b604482015260640161050c565b60405162461bcd60e51b81526020600482015260056024820152641157d5505560da1b604482015260640161050c565b610194546040805163f815d6cf60e01b815290516000926001600160a01b03169163f815d6cf916004808301926020929190829003018187875af1158015612c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8c9190615006565b905061ffff8116612ca360a0890160808a01614e07565b61ffff161015612ce15760405162461bcd60e51b81526020600482015260096024820152681157d4d4119315131360ba1b604482015260640161050c565b6001612cf561014089016101208a01614d36565b60ff1610612d505761ffff8116612d1260c0890160a08a01614e07565b61ffff161015612d505760405162461bcd60e51b81526020600482015260096024820152681157d4d4119315131360ba1b604482015260640161050c565b606086013515612da7576001612d6e61014089016101208a01614d36565b60ff161015612da75760405162461bcd60e51b8152602060048201526005602482015264455f564e4360d81b604482015260640161050c565b6000612db96040890160208a0161484a565b6001600160a01b031614158015612de957506000612ddd6060890160408a0161484a565b6001600160a01b031614155b612e1e5760405162461bcd60e51b8152602060048201526006602482015265455f5349504360d01b604482015260640161050c565b60008760c00135118015612e365750428760c0013511155b8015612e51575060e08701351580612e515750428760e00135115b612e865760405162461bcd60e51b8152602060048201526006602482015265455f5349455360d01b604482015260640161050c565b612e96604088016020890161484a565b6001600160a01b0316612ee786868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061098f925088915061095490506125ca565b6001600160a01b031614612f255760405162461bcd60e51b8152602060048201526005602482015264455f49535360d81b604482015260640161050c565b50505050505050565b600080805b84811015612ffa5736868683818110612f4e57612f4e614c5b565b606002919091019150612f6e9050612f6960208301836147f2565b61400a565b8015612f7d5750604081013515155b612fb35760405162461bcd60e51b81526020600482015260076024820152660455f53504d49560cc1b604482015260640161050c565b612fc060208601866147f2565b6001600160e01b031916612fd760208301836147f2565b6001600160e01b03191603612ff157604001359150612ffa565b50600101612f33565b50806000036130345760405162461bcd60e51b8152602060048201526006602482015265455f504d4e4d60d01b604482015260640161050c565b949350505050565b60006001600160e01b0319821663fdae1ba760e01b14806104c157506001600160e01b031982166322ba176160e21b1492915050565b8015610761576001600160a01b0382166000908152610199602052604081205490036130e55761019a80546001810182556000919091527fd994f4dad00f9ff89caab117647e768aa59b274f965a222ec6a1586aa6e26bcb0180546001600160a01b0319166001600160a01b0384161790555b6001600160a01b0382166000908152610199602052604090208054820190555050565b61019654600090819081906001600160a01b031663428711576131316040890160208a0161484a565b60408901358861314760e08c0160c08d01614d36565b6040516001600160e01b031960e087901b1681526001600160a01b0390941660048501526024840192909252604483015260ff1660648201526084016000604051808303816000875af11580156131a2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526131ca91908101906150bc565b50815191935091506000600260ff8716108015906131e6575081155b8015613200575060006131fc60e08a018a614c9b565b9050115b156134675761321260e0890189614c9b565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050825192965091935061325a915050610100890189614c9b565b905082148015613281575061271061327a6101408a016101208b01614e07565b61ffff1611155b6132bd5760405162461bcd60e51b815260206004820152600d60248201526c0455f4952445f534f504731303609c1b604482015260640161050c565b866132ce60e08a0160c08b01614d36565b60ff16600103613304576127106132ed6101408b016101208c01614e07565b61ffff1689028161330057613300614de1565b0490505b826001600160401b0381111561331c5761331c614a3d565b604051908082528060200260200182016040528015613345578160200160208202803683370190505b50935060008092505b838310156134245760006001600160a01b031686848151811061337357613373614c5b565b60200260200101516001600160a01b0316036133b95760405162461bcd60e51b8152602060048201526005602482015264455f49524160d81b604482015260640161050c565b60006133c96101008c018c614c9b565b858181106133d9576133d9614c5b565b90506020020160208101906133ee9190614e07565b905061271061ffff821684020486858151811061340d5761340d614c5b565b60209081029190910101526001909301920161334e565b61ffff8116612710146134645760405162461bcd60e51b81526020600482015260086024820152670455f52504e3130360c41b604482015260640161050c565b50505b506000805b828210156134c157600084838151811061348857613488614c5b565b602002602001015190506134b58684815181106134a7576134a7614c5b565b602002602001015182613072565b6001909201910161346c565b98975050505050505050565b821561356757610195546040805180820182526002815261060f60f31b60208201529051639c1c2ee960e01b81526001600160a01b0390921691639c1c2ee991613524918b918a918a918d918b91906004016151e0565b600060405180830381600087803b15801561353e57600080fd5b505af1158015613552573d6000803e3d6000fd5b5050505061356281888886614076565b6135e7565b61019554604051637b84dc8360e11b81526001600160a01b039091169063f709b9069061359e908a90899089908c90600401614c71565b600060405180830381600087803b1580156135b857600080fd5b505af11580156135cc573d6000803e3d6000fd5b50505060008381526101976020526040902080546001019055505b85876001600160a01b0316827f052aa775128ed1cbbd47b4948be31a03a0e96f23361fbabd94fde8e24aedfb038660405161362491815260200190565b60405180910390a450505050505050565b60005b61019a5481101561075e57600061019a828154811061365957613659614c5b565b60009182526020808320909101546001600160a01b0316808352610199909152604090912054909150630251e45960e01b6001600160e01b03198716016136d6576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156136d0573d6000803e3d6000fd5b50613758565b631d45e89f60e21b6001600160e01b0319871601613758576101955460405163776062c360e01b81526001600160a01b039091169063776062c390613725908890889087908790600401614c71565b600060405180830381600087803b15801561373f57600080fd5b505af1158015613753573d6000803e3d6000fd5b505050505b5050600101613638565b6099600061376e6123c9565b6001600160a01b0316815260208101919091526040016000205460ff166105a45760405162461bcd60e51b815260040161050c90614c15565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156137da5761066d836140dd565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613834575060408051601f3d908101601f1916820190925261383191810190614e90565b60015b6138975760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161050c565b6000805160206152e983398151915281146139065760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161050c565b5061066d838383614179565b6001600160a01b03811661397c5760405162461bcd60e51b815260206004820152602b60248201527f41646d696e3a61646441646d696e206e657741646d696e20697320746865207a60448201526a65726f206164647265737360a81b606482015260840161050c565b6001600160a01b038116600081815260996020908152604091829020805460ff1916600117905590519182527f44d6d25963f097ad14f29f06854a01f575648a1ef82f30e562ccd3889717e3399101612425565b6139d861419e565b60fe805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa613a0b6123c9565b6040516001600160a01b03909116815260200160405180910390a1565b6000613a3c61012083016101008401614d36565b60ff16600003613ad3577f16533b1a2b574048998c15c61696aff2836a5106c01e21954538cf393cf8124a8235613a79604085016020860161484a565b613a89606086016040870161484a565b613a9586608001613c7b565b6040805160208101969096528501939093526001600160a01b03918216606085015216608083015260a082015260e08084013560c0830152016125ad565b613ae561012083016101008401614d36565b60ff1660011480613b0a5750613b0361012083016101008401614d36565b60ff166002145b15613bc6577f02e75952f6dbd570765759927f425880efe915c78b4351b9f010366a3a15f8e08235613b42604085016020860161484a565b613b52606086016040870161484a565b8560600135613b6387608001613c7b565b60e0880135613b7a6101208a016101008b01614d36565b6040805160208101999099528801969096526001600160a01b03948516606088015293909216608086015260a085015260c084015260e083015260ff16610100820152610120016125ad565b60405162461bcd60e51b815260206004820152600860248201526722afa7a219afa4ab60c11b604482015260640161050c565b613c01612430565b60fe805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613a0b6123c9565b60007f000000000000000000000000307e7a9713dbf6f19a2d2a2b670544f4791c4ec26001600160a01b03163303613c76575060131936013560601c90565b503390565b60007f5b442961536b72a0442e9a53df012289ed70f5c860457d810d2c17836bd8bdce613cab60208401846147f2565b613cbb604085016020860161484a565b6040805160208101949094526001600160e01b0319909216838301526001600160a01b03166060830152830135608082015260a0016125ad565b6000808251604103613d2b5760208301516040840151606085015160001a613d1f878285856141e7565b94509450505050613d33565b506000905060025b9250929050565b6000816004811115613d4e57613d4e615222565b03613d565750565b6001816004811115613d6a57613d6a615222565b03613db75760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161050c565b6002816004811115613dcb57613dcb615222565b03613e185760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161050c565b6003816004811115613e2c57613e2c615222565b03613e845760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161050c565b6004816004811115613e9857613e98615222565b036105a45760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161050c565b6000606060005b84811015613f585781613f2d878784818110613f1557613f15614c5b565b9050602002810190613f279190614d06565b866142d4565b604051602001613f3e929190615238565b60408051601f198184030181529190529150600101613ef7565b508051602090910120949350505050565b6000606060005b83811015613fc45781613f99868684818110613f8e57613f8e614c5b565b905060600201613c7b565b604051602001613faa929190615238565b60408051601f198184030181529190529150600101613f70565b5080516020909101209392505050565b60006001600160e01b03198216639e80de3760e01b14806104c157506001600160e01b0319821663163b6d3b60e21b1492915050565b60006001600160e01b0319821663fdae1ba760e01b148061403b57506001600160e01b031982166322ba176160e21b145b8061405657506001600160e01b03198216633ecaa07960e21b145b806104c157506001600160e01b0319821663d5a81f1960e01b1492915050565b8061019760008686866040516020016140ab939291909283526001600160a01b03919091166020830152604082015260600190565b60408051601f198184030181529181528151602092830120835290820192909252016000208054909101905550505050565b6001600160a01b0381163b61414a5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161050c565b6000805160206152e983398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61418283614607565b60008251118061418f5750805b1561066d5761075e8383614647565b60fe5460ff166114855760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161050c565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561421e57506000905060036142cb565b8460ff16601b1415801561423657508460ff16601c14155b1561424757506000905060046142cb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561429b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166142c4576000600192509250506142cb565b9150600090505b94509492505050565b60008160ff166000036143aa577fda89efe36e8d4174abec2b392e28fde5f06a39ea80761619c7690bf86606452461430f60208501856147f2565b61431f604086016020870161484a565b604086013561433460a0880160808901614e07565b61434460e0890160c08a01614d36565b6040805160208101979097526001600160e01b0319909516948601949094526001600160a01b039092166060850152608084015261ffff1660a083015260ff1660c082015260e0015b6040516020818303038152906040528051906020012090506104c1565b8160ff1660010361448d577f711444f222b4586ccfaca2037481d3fab181017c88fc21fb2f78909a6953ba066143e360208501856147f2565b6143f3604086016020870161484a565b6040860135606087013561440d60a0890160808a01614e07565b61441d60c08a0160a08b0161484a565b61442d60e08b0160c08c01614d36565b6040805160208101999099526001600160e01b0319909716968801969096526001600160a01b039485166060880152608087019390935260a086019190915261ffff1660c08501521660e083015260ff166101008201526101200161438d565b8160ff16600203612947577fbd60107b487bdfeb3ec8fcbfe07542913ceca85dc095c07f5cb6b97d028573cd6144c660208501856147f2565b6144d6604086016020870161484a565b604086013560608701356144f060a0890160808a01614e07565b61450060c08a0160a08b0161484a565b61451060e08b0160c08c01614d36565b61451d60e08c018c614c9b565b60405160200161452e92919061525a565b60408051601f1981840301815291905280516020909101206145546101008d018d614c9b565b604051602001614565929190615291565b60408051601f19818403018152919052805160209091012061458f6101408e016101208f01614e07565b60408051602081019c909c526001600160e01b0319909a16998b01999099526001600160a01b0397881660608b015260808a019690965260a089019490945261ffff92831660c0890152941660e087015260ff909316610100860152610120850152610140840152166101608201526101800161438d565b614610816140dd565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6146af5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161050c565b600080846001600160a01b0316846040516146ca91906152c3565b600060405180830381855af49150503d8060008114614705576040519150601f19603f3d011682016040523d82523d6000602084013e61470a565b606091505b509150915061473282826040518060600160405280602781526020016153096027913961473b565b95945050505050565b6060831561474a5750816123c2565b82511561475a5782518084602001fd5b8160405162461bcd60e51b815260040161050c91906152d5565b50805460008255600202906000526020600020908101906105a491906147b3565b50805460008255906000526020600020908101906105a491906147dd565b5b808211156147d95780546001600160a01b0319168155600060018201556002016147b4565b5090565b5b808211156147d957600081556001016147de565b60006020828403121561480457600080fd5b81356001600160e01b0319811681146123c257600080fd5b60006020828403121561482e57600080fd5b5035919050565b6001600160a01b03811681146105a457600080fd5b60006020828403121561485c57600080fd5b81356123c281614835565b6000806040838503121561487a57600080fd5b823561488581614835565b9150602083013561489581614835565b809150509250929050565b60008083601f8401126148b257600080fd5b5081356001600160401b038111156148c957600080fd5b6020830191508360208260051b8501011115613d3357600080fd5b600061012082840312156148f757600080fd5b50919050565b60008083601f84011261490f57600080fd5b5081356001600160401b0381111561492657600080fd5b602083019150836020828501011115613d3357600080fd5b60008060008060008060006080888a03121561495957600080fd5b87356001600160401b038082111561497057600080fd5b61497c8b838c016148a0565b909950975060208a013591508082111561499557600080fd5b6149a18b838c016148a0565b909750955060408a01359150808211156149ba57600080fd5b6149c68b838c016148e4565b945060608a01359150808211156149dc57600080fd5b506149e98a828b016148fd565b989b979a50959850939692959293505050565b60008060208385031215614a0f57600080fd5b82356001600160401b03811115614a2557600080fd5b614a31858286016148a0565b90969095509350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715614a7b57614a7b614a3d565b604052919050565b60008060408385031215614a9657600080fd5b8235614aa181614835565b91506020838101356001600160401b0380821115614abe57600080fd5b818601915086601f830112614ad257600080fd5b813581811115614ae457614ae4614a3d565b614af6601f8201601f19168501614a53565b91508082528784828501011115614b0c57600080fd5b80848401858401376000848284010152508093505050509250929050565b6000806000806000806101808789031215614b4457600080fd5b86356001600160401b0380821115614b5b57600080fd5b90880190610140828b031215614b7057600080fd5b90965060208801359080821115614b8657600080fd5b614b928a838b016148fd565b9097509550859150614ba78a60408b016148e4565b9450610160890135915080821115614bbe57600080fd5b50614bcb89828a016148fd565b979a9699509497509295939492505050565b600080600060608486031215614bf257600080fd5b833592506020840135614c0481614835565b929592945050506040919091013590565b60208082526026908201527f41646d696e3a6f6e6c7941646d696e2063616c6c6572206973206e6f7420616e6040820152651020b236b4b760d11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6000808335601e19843603018112614cb257600080fd5b8301803591506001600160401b03821115614ccc57600080fd5b6020019150600581901b3603821315613d3357600080fd5b600060208284031215614cf657600080fd5b815180151581146123c257600080fd5b6000823561013e19833603018112614d1d57600080fd5b9190910192915050565b60ff811681146105a457600080fd5b600060208284031215614d4857600080fd5b81356123c281614d27565b6000808335601e19843603018112614d6a57600080fd5b8301803591506001600160401b03821115614d8457600080fd5b602001915036819003821315613d3357600080fd5b6000808335601e19843603018112614db057600080fd5b8301803591506001600160401b03821115614dca57600080fd5b6020019150606081023603821315613d3357600080fd5b634e487b7160e01b600052601260045260246000fd5b61ffff811681146105a457600080fd5b600060208284031215614e1957600080fd5b81356123c281614df7565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176104c1576104c1614e24565b600082614e6e57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215614e8557600080fd5b81516123c281614835565b600060208284031215614ea257600080fd5b5051919050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b600060018201614f5357614f53614e24565b5060010190565b6001600160e01b031991909116815260200190565b602080825260059082015264455f494e5360d81b604082015260600190565b818103818111156104c1576104c1614e24565b60006001600160fb1b03831115614fb757600080fd5b8260051b80858437919091019392505050565b60008184825b85811015614ffb578135614fe381614d27565b60ff1683526020928301929190910190600101614fd0565b509095945050505050565b60006020828403121561501857600080fd5b81516123c281614df7565b60006001600160401b0382111561503c5761503c614a3d565b5060051b60200190565b600082601f83011261505757600080fd5b8151602061506c61506783615023565b614a53565b82815260059290921b8401810191818101908684111561508b57600080fd5b8286015b848110156150a6578051835291830191830161508f565b509695505050505050565b805161297881614d27565b6000806000606084860312156150d157600080fd5b83516001600160401b03808211156150e857600080fd5b818601915086601f8301126150fc57600080fd5b8151602061510c61506783615023565b82815260059290921b8401810191818101908a84111561512b57600080fd5b948201945b8386101561515257855161514381614835565b82529482019490820190615130565b9189015191975090935050508082111561516b57600080fd5b5061517886828701615046565b925050615187604085016150b1565b90509250925092565b60005b838110156151ab578181015183820152602001615193565b50506000910152565b600081518084526151cc816020860160208601615190565b601f01601f19169290920160200192915050565b6001600160a01b038781168252868116602083015285166040820152606081018490526080810183905260c060a082018190526000906134c1908301846151b4565b634e487b7160e01b600052602160045260246000fd5b6000835161524a818460208801615190565b9190910191825250602001919050565b60008184825b85811015614ffb57813561527381614835565b6001600160a01b031683526020928301929190910190600101615260565b60008184825b85811015614ffb5781356152aa81614df7565b61ffff1683526020928301929190910190600101615297565b60008251614d1d818460208701615190565b6020815260006123c260208301846151b456fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d50cd222d1cbe4c250af7cf59b942522222d81815cfb694b555e44bbee11414564736f6c63430008130033