ETH Price: $2,361.37 (+1.43%)
Gas: 3.7 Gwei

Token

UNCODE Avatars Male (UNCODE▽)
 

Overview

Max Total Supply

76 UNCODE▽

Holders

45

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Balance
1 UNCODE▽
0x156e624f55c040ab1c65b8ced533f8c14d26b3a8
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
UncodeAvatars

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 34 : UncodeGenesis.sol
// SPDX-License-Identifier: MIT
/**
╔╗ ╔╗╔═╗ ╔╗╔═══╗╔═══╗╔═══╗╔═══╗
║║ ║║║║╚╗║║║╔═╗║║╔═╗║╚╗╔╗║║╔══╝
║║ ║║║╔╗╚╝║║║ ╚╝║║ ║║ ║║║║║╚══╗
║║ ║║║║╚╗║║║║ ╔╗║║ ║║ ║║║║║╔══╝
║╚═╝║║║ ║║║║╚═╝║║╚═╝║╔╝╚╝║║╚══╗
╚═══╝╚╝ ╚═╝╚═══╝╚═══╝╚═══╝╚═══╝
 */
pragma solidity ^0.8.4;

import "erc721psi/contracts/ERC721Psi.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "@divergencetech/ethier/contracts/sales/FixedPriceSeller.sol";
import "@divergencetech/ethier/contracts/crypto/SignerManager.sol";
import "@divergencetech/ethier/contracts/crypto/SignatureChecker.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "fpe-map/contracts/FPEMap.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/**
 @title Uncode Avatars
 @author Uncode GmbH
 @dev Inherits from ERC721Psi and uses FPE-Map and VRF randomized tokenId/metadataId mapping using.
 */
contract UncodeAvatars is
  ERC721Psi,
  ERC2981,
  FixedPriceSeller,
  SignerManager,
  VRFConsumerBaseV2
{
  using SignatureChecker for EnumerableSet.AddressSet;
  using Strings for uint256;

  uint32 public mintAllowlistStartTime;
  uint32 public mintPublicStartTime;

  /// @dev The final inventory (total supply) can only be set once, at the reveal.
  /// @dev It is used to calculate the randomized metadata mapping,
  uint256 private finalInventory = 0;

  string private _baseTokenURI;
  string private _baseTokenURIStaticMetadata;

  mapping(bytes32 => bool) private usedMessages;

  /// @dev Emitted when a Uncode Avatar begins staking.
  event Staked(uint256 indexed tokenId);

  /// @dev Emitted when a Uncode Avatar stops staking; either through standard means or by expulsion.
  event Unstaked(uint256 indexed tokenId);

  /// @dev Emitted when a Uncode Avatar is expelled from the staking.
  event Expelled(uint256 indexed tokenId);

  /// @notice Whether staking is currently allowed.
  /// @dev If false then staking is blocked, but unstaking is always allowed.
  bool public stakingIsOpen = false;

  /// @dev Per-token start time, 0 means not staked at all yet.
  mapping(uint256 => uint256) private stakingStarted;

  /// @dev Cumulative per-token staking time, excluding the current period.
  mapping(uint256 => uint256) private stakingTotal;

  VRFCoordinatorV2Interface private COORDINATOR;

  /// @dev The gas lane to use, which specifies the maximum gas price to bump to.
  bytes32 private immutable vrfKeyHash;
  
  /// @dev The chainlink VRF subscriptionId to use.
  uint64 private immutable vrfSubscriptionId;

  /// @dev Depends on the number of requested values. Storing each word costs about 20,000 gas.
  uint32 private vrfCallbackGasLimit;

  /// @dev Number of confirmations before callback request.
  uint16 private immutable vrfRequestConfirmations;

  /// @dev Prevents requesting a new random seed, can not be unlocked again.
  bool private metadataMapIsLocked = false;

  uint256 public randomSeed = 0;
  uint256 public randomRequestId;

  constructor(
    address payable _beneficiary,
    address payable _royaltyReceiver,
    uint256 _initialInventory,
    address _vrfCoordinator, // see https://docs.chain.link/docs/vrf-contracts/#configurations
    bytes32 _vrfKeyHash, // see https://docs.chain.link/docs/vrf-contracts/#configurations
    uint64 _vrfSubscriptionId,
    uint32 _vrfCallbackGasLimit,
    uint16 _vrfRequestConfirmations
  )
    ERC721Psi(unicode"UNCODE Avatars Male", unicode"UNCODE▽")
    VRFConsumerBaseV2(_vrfCoordinator)
    FixedPriceSeller(
      0.3 ether,
      Seller.SellerConfig({
        totalInventory: _initialInventory,
        //we need to increase the total inventory once, to give an additional avatar for all holders who locked their avatar 14 days
        lockTotalInventory: false,
        maxPerAddress: 1,
        maxPerTx: 1,
        freeQuota: 300,
        lockFreeQuota: false,
        reserveFreeQuota: true
      }),
      _beneficiary
    )
  {
    _setDefaultRoyalty(_royaltyReceiver, 500);
    COORDINATOR = VRFCoordinatorV2Interface(_vrfCoordinator);
    vrfKeyHash = _vrfKeyHash;
    vrfSubscriptionId = _vrfSubscriptionId;
    vrfCallbackGasLimit = _vrfCallbackGasLimit;
    vrfRequestConfirmations = _vrfRequestConfirmations;
  }

  /// @notice Requires that msg.sender owns or is approved for the token.
  modifier onlyApprovedOrOwner(uint256 tokenId) {
    require(
      ownerOf(tokenId) == _msgSender() || getApproved(tokenId) == _msgSender(),
      "not approved nor owner"
    );
    _;
  }

  /// @notice Requires that a token with this id exists.
  modifier tokenIdExists(uint256 tokenId) {
    require(_exists(tokenId), "id does not exist");
    _;
  }

  /// @notice Requires that the mint is already open.
  modifier mintIsOpen(uint32 startTime) {
    uint256 _startTime = uint256(startTime);
    require(
      _startTime != 0 && block.timestamp >= _startTime,
      "mint has not started yet"
    );
    _;
  }

  /// @dev Request the random seed for a randomized tokenId/metadataId mapping.
  /// @dev Can only be called once.
  /// @dev Assumes the subscription is funded sufficiently.
  function requestRandomSeed() external onlyOwner {
    require(!metadataMapIsLocked, "already requested");
    // Will revert if subscription is not set and funded.
    randomRequestId = COORDINATOR.requestRandomWords(
      vrfKeyHash,
      vrfSubscriptionId,
      vrfRequestConfirmations,
      vrfCallbackGasLimit,
      1
    );
  }

  function fulfillRandomWords(uint256, uint256[] memory randomWords)
    internal
    override
  {
    randomSeed = randomWords[0];
  }

  function lockMetadataMap() external onlyOwner {
    metadataMapIsLocked = true;
  }

  function setVrfCallbackGasLimit(uint32 _vrfCallbackGasLimit)
    external 
    onlyOwner
  {
    vrfCallbackGasLimit = _vrfCallbackGasLimit;
  }

  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC721Psi, ERC2981)
    returns (bool)
  {
    // Supports the following `interfaceId`s:
    // - IERC165: 0x01ffc9a7
    // - IERC721: 0x80ac58cd
    // - IERC721Metadata: 0x5b5e139f
    // - IERC2981: 0x2a55205a
    return
      ERC721Psi.supportsInterface(interfaceId) ||
      ERC2981.supportsInterface(interfaceId);
  }

  /// @notice Entry point for minting on the public mint.
  function mintPublic(uint16 requested)
    external
    payable
    mintIsOpen(mintPublicStartTime)
  {
    Seller._purchase(msg.sender, requested);
  }

  /// @notice Allowlist Mint.
  function mintAllowlist(
    address to,
    uint16 requested,
    uint32 nonce,
    bytes calldata sig
  ) 
    external
    payable
    mintIsOpen(mintAllowlistStartTime)
  {
    signers.requireValidSignature(
      _signaturePayload(to, nonce),
      sig,
      usedMessages
    );
    Seller._purchase(to, requested);
  }

  function setMintConfig(uint32 allowlistStartTime, uint32 publicStartTime)
    external
    onlyOwner
  {
    mintAllowlistStartTime = allowlistStartTime;
    mintPublicStartTime = publicStartTime;
  }

  function setFinalInventory(uint256 _finalInventory) external onlyOwner {
    require(finalInventory == 0, "already set");
    finalInventory = _finalInventory;
  }

  function allTokensOwnedBy(address ownerAdr)
    external
    view
    returns (uint256[] memory)
  {
    uint256 balance = balanceOf(ownerAdr);
    uint256[] memory tokenIds = new uint256[](balance);

    uint256 idx;
    for (uint256 i = 0; i < ERC721Psi.totalSupply(); i++) {
      if (ownerOf(i) != ownerAdr) {
        continue;
      }
      tokenIds[idx] = i;
      idx++;
    }
    return tokenIds;
  }

  function setBaseURI(string calldata baseURI) external onlyOwner {
    _baseTokenURI = baseURI;
  }

  function setBaseURIStaticMetadata(string calldata baseURIStaticMetadata)
    external
    onlyOwner
  {
    _baseTokenURIStaticMetadata = baseURIStaticMetadata;
  }

  function _baseURI() internal view override returns (string memory) {
    return _baseTokenURI;
  }

  function _baseURIStaticMetadata() internal view returns (string memory) {
    return _baseTokenURIStaticMetadata;
  }

  function tokenURI(uint256 tokenId)
    public
    view
    virtual
    override
    tokenIdExists(tokenId)
    returns (string memory)
  {
    return _tokenURI(tokenId, _baseURI());
  }

  function tokenURIStaticMetadata(uint256 tokenId)
    public
    view
    virtual
    tokenIdExists(tokenId)
    returns (string memory)
  {
    return _tokenURI(tokenId, _baseURIStaticMetadata());
  }

  function _tokenURI(uint256 tokenId, string memory baseURI)
    internal
    view
    returns (string memory)
  {
    require(bytes(baseURI).length > 0, "baseURI not set");
    if (randomSeed == 0 || finalInventory == 0) {
      // collection is still unrevealed, return a special tokenURI
      return string(abi.encodePacked(baseURI, "unrevealed/", tokenId.toString()));
    } else {
      // calculate randomized mapping of tokenId -> metadataId
      uint256 metadataId = FPEMap.fpeMappingFeistelAuto(
        tokenId,
        randomSeed,
        finalInventory
      );
      return string(abi.encodePacked(baseURI, metadataId.toString()));
    }
  }

  /// @notice Internal override of Seller function for handling purchase (i.e. minting).
  function _handlePurchase(
    address to,
    uint256 n,
    bool
  ) internal override {
    _safeMint(to, n);
  }

  /// @dev Prevent transfers while Avatar is staked.
  function _beforeTokenTransfers(
    address,
    address,
    uint256 startTokenId,
    uint256 quantity
  ) internal view override {
    uint256 tokenId = startTokenId;
    for (uint256 end = tokenId + quantity; tokenId < end; ++tokenId) {
      require(stakingStarted[tokenId] == 0, "is staked");
    }
  }

  /**
    @dev Constructs the buffer that is hashed for validation with a minting
    signature.
     */
  function _signaturePayload(address to, uint32 nonce)
    internal
    pure
    returns (bytes memory)
  {
    return abi.encodePacked(to, nonce);
  }

  /**
    @notice Returns the length of time, in seconds, that the Uncode Avatar has
    been staked.
    @dev Staking is tied to a specific Uncode Avatar, not to the owner, so it doesn't
    reset upon sale.
    @return staking Whether the Uncode Avatar is currently staking. MAY be true with
    zero current staking if in the same block as staking began.
    @return current Zero if not currently staking, otherwise the length of time
    since the most recent staking began.
    @return total Total period of time for which the Uncode Avatar has been staked across
    its life, including the current period.
     */
  function stakingPeriod(uint256 tokenId)
    external
    view
    returns (
      bool staking,
      uint256 current,
      uint256 total
    )
  {
    uint256 start = stakingStarted[tokenId];
    if (start != 0) {
      staking = true;
      current = block.timestamp - start;
    }
    total = current + stakingTotal[tokenId];
  }

  /**
    @notice Enable or disable the staking functionality.
    */
  function setStakingOpen(bool open) external onlyOwner {
    stakingIsOpen = open;
  }

  /**
    @notice Changes a single Avatar's staking status
    */
  function toggleStaking(uint256 tokenId) public onlyApprovedOrOwner(tokenId) {
    uint256 start = stakingStarted[tokenId];
    if (start == 0) {
      require(stakingIsOpen, "staking closed");
      stakingStarted[tokenId] = block.timestamp;
      emit Staked(tokenId);
    } else {
      stakingTotal[tokenId] += block.timestamp - start;
      stakingStarted[tokenId] = 0;
      emit Unstaked(tokenId);
    }
  }

  /**
    @notice Changes multiple Avatars' staking status at once
    */
  function toggleStaking(uint256[] calldata tokenIds) external {
    uint256 n = tokenIds.length;
    for (uint256 i = 0; i < n; ++i) {
      toggleStaking(tokenIds[i]);
    }
  }

  /**
    @notice Admin-only ability to unstake an Uncode Avatar.
    @dev As most sales listings use off-chain signatures it's impossible to
    detect someone who has staked and then deliberately undercuts the floor
    price in the knowledge that the sale can't proceed. This function allows for
    monitoring of such practices and expulsion if abuse is detected, allowing
    the undercutting Avatar to be sold on the open market. Since OpenSea uses
    isApprovedForAll() in its pre-listing checks, we can't block by that means
    because staking would then be all-or-nothing for all of a particular owner's
    Uncode Avatars.
    */
  function unstake(uint256 tokenId) external onlyOwner {
    require(stakingStarted[tokenId] != 0, "is not staked");
    stakingTotal[tokenId] += block.timestamp - stakingStarted[tokenId];
    stakingStarted[tokenId] = 0;
    emit Unstaked(tokenId);
    emit Expelled(tokenId);
  }
}

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

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    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);
    }
}

File 3 of 34 : FPEMap.sol
//SPDX-License-Identifier: MIT
/**

███████╗██████╗ ███████╗    ███╗   ███╗ █████╗ ██████╗ 
██╔════╝██╔══██╗██╔════╝    ████╗ ████║██╔══██╗██╔══██╗
█████╗  ██████╔╝█████╗█████╗██╔████╔██║███████║██████╔╝
██╔══╝  ██╔═══╝ ██╔══╝╚════╝██║╚██╔╝██║██╔══██║██╔═══╝ 
██║     ██║     ███████╗    ██║ ╚═╝ ██║██║  ██║██║     
╚═╝     ╚═╝     ╚══════╝    ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     
                                                       
github: https://github.com/estarriolvetch/fpe-mapping

 */

pragma solidity ^0.8.0;

import "solidity-bits/contracts/BitScan.sol";
import "./Feistel.sol";

library FPEMap {
    using Feistel for uint256;

    string constant DOMAIN_ERROR_MSG = "The FPE domain should be within the domain of the Fiestel network (domain <= 2 ** size)";
    string constant INPUT_OUTSIDE_DOMAIN_ERROR_MSG = "input is not within the domain";

    uint256 constant DEFAULT_ROUND = 3;

    function fpeMappingFeistel(uint256 input, uint256 key, uint256 round, uint256 size, uint256 domain) internal pure returns (uint256 output) {
        require(input < domain, INPUT_OUTSIDE_DOMAIN_ERROR_MSG);
        require(2 ** size >= domain, DOMAIN_ERROR_MSG);
        while(true) {
            output = input.feistel(key, round, size);
            if(output < domain) {
                break;
            } else {
                input = output;
            }
        }
    }

    function fpeMappingFeistelUnbalanced(uint256 input, uint256 key, uint256 round, uint256 size, uint256 domain) internal pure returns (uint256 output) {
        require(input < domain, INPUT_OUTSIDE_DOMAIN_ERROR_MSG);
        require(2 ** size >= domain, DOMAIN_ERROR_MSG);
        while(true) {
            output = input.feistelUnbalanced(key, round, size);
            if(output < domain) {
                break;
            } else {
                input = output;
            }
        }
    }

    function fpeMappingFeistelAuto(uint256 input, uint256 key, uint256 domain) internal pure returns (uint256 output) {
        require(input < domain, INPUT_OUTSIDE_DOMAIN_ERROR_MSG);
        uint256 size;

        // Calculate the smallest required block size of the unbalanced Feistel network
        unchecked {
            size = BitScan.log2(domain) + 1;    
        }
        
        while(true) {
            output = input.feistelUnbalanced(key, DEFAULT_ROUND, size);
            if(output < domain) {
                break;
            } else {
                input = output;
            }
        }
    }
}

File 4 of 34 : VRFCoordinatorV2Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface VRFCoordinatorV2Interface {
  /**
   * @notice Get configuration relevant for making requests
   * @return minimumRequestConfirmations global min for request confirmations
   * @return maxGasLimit global max for request gas limit
   * @return s_provingKeyHashes list of registered key hashes
   */
  function getRequestConfig()
    external
    view
    returns (
      uint16,
      uint32,
      bytes32[] memory
    );

  /**
   * @notice Request a set of random words.
   * @param keyHash - Corresponds to a particular oracle job which uses
   * that key for generating the VRF proof. Different keyHash's have different gas price
   * ceilings, so you can select a specific one to bound your maximum per request cost.
   * @param subId  - The ID of the VRF subscription. Must be funded
   * with the minimum subscription balance required for the selected keyHash.
   * @param minimumRequestConfirmations - How many blocks you'd like the
   * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS
   * for why you may want to request more. The acceptable range is
   * [minimumRequestBlockConfirmations, 200].
   * @param callbackGasLimit - How much gas you'd like to receive in your
   * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords
   * may be slightly less than this amount because of gas used calling the function
   * (argument decoding etc.), so you may need to request slightly more than you expect
   * to have inside fulfillRandomWords. The acceptable range is
   * [0, maxGasLimit]
   * @param numWords - The number of uint256 random values you'd like to receive
   * in your fulfillRandomWords callback. Note these numbers are expanded in a
   * secure way by the VRFCoordinator from a single random value supplied by the oracle.
   * @return requestId - A unique identifier of the request. Can be used to match
   * a request to a response in fulfillRandomWords.
   */
  function requestRandomWords(
    bytes32 keyHash,
    uint64 subId,
    uint16 minimumRequestConfirmations,
    uint32 callbackGasLimit,
    uint32 numWords
  ) external returns (uint256 requestId);

  /**
   * @notice Create a VRF subscription.
   * @return subId - A unique subscription id.
   * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer.
   * @dev Note to fund the subscription, use transferAndCall. For example
   * @dev  LINKTOKEN.transferAndCall(
   * @dev    address(COORDINATOR),
   * @dev    amount,
   * @dev    abi.encode(subId));
   */
  function createSubscription() external returns (uint64 subId);

  /**
   * @notice Get a VRF subscription.
   * @param subId - ID of the subscription
   * @return balance - LINK balance of the subscription in juels.
   * @return reqCount - number of requests for this subscription, determines fee tier.
   * @return owner - owner of the subscription.
   * @return consumers - list of consumer address which are able to use this subscription.
   */
  function getSubscription(uint64 subId)
    external
    view
    returns (
      uint96 balance,
      uint64 reqCount,
      address owner,
      address[] memory consumers
    );

  /**
   * @notice Request subscription owner transfer.
   * @param subId - ID of the subscription
   * @param newOwner - proposed new owner of the subscription
   */
  function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;

  /**
   * @notice Request subscription owner transfer.
   * @param subId - ID of the subscription
   * @dev will revert if original owner of subId has
   * not requested that msg.sender become the new owner.
   */
  function acceptSubscriptionOwnerTransfer(uint64 subId) external;

  /**
   * @notice Add a consumer to a VRF subscription.
   * @param subId - ID of the subscription
   * @param consumer - New consumer which can use the subscription
   */
  function addConsumer(uint64 subId, address consumer) external;

  /**
   * @notice Remove a consumer from a VRF subscription.
   * @param subId - ID of the subscription
   * @param consumer - Consumer to remove from the subscription
   */
  function removeConsumer(uint64 subId, address consumer) external;

  /**
   * @notice Cancel a subscription
   * @param subId - ID of the subscription
   * @param to - Where to send the remaining LINK to
   */
  function cancelSubscription(uint64 subId, address to) external;
}

File 5 of 34 : VRFConsumerBaseV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/** ****************************************************************************
 * @notice Interface for contracts using VRF randomness
 * *****************************************************************************
 * @dev PURPOSE
 *
 * @dev Reggie the Random Oracle (not his real job) wants to provide randomness
 * @dev to Vera the verifier in such a way that Vera can be sure he's not
 * @dev making his output up to suit himself. Reggie provides Vera a public key
 * @dev to which he knows the secret key. Each time Vera provides a seed to
 * @dev Reggie, he gives back a value which is computed completely
 * @dev deterministically from the seed and the secret key.
 *
 * @dev Reggie provides a proof by which Vera can verify that the output was
 * @dev correctly computed once Reggie tells it to her, but without that proof,
 * @dev the output is indistinguishable to her from a uniform random sample
 * @dev from the output space.
 *
 * @dev The purpose of this contract is to make it easy for unrelated contracts
 * @dev to talk to Vera the verifier about the work Reggie is doing, to provide
 * @dev simple access to a verifiable source of randomness. It ensures 2 things:
 * @dev 1. The fulfillment came from the VRFCoordinator
 * @dev 2. The consumer contract implements fulfillRandomWords.
 * *****************************************************************************
 * @dev USAGE
 *
 * @dev Calling contracts must inherit from VRFConsumerBase, and can
 * @dev initialize VRFConsumerBase's attributes in their constructor as
 * @dev shown:
 *
 * @dev   contract VRFConsumer {
 * @dev     constructor(<other arguments>, address _vrfCoordinator, address _link)
 * @dev       VRFConsumerBase(_vrfCoordinator) public {
 * @dev         <initialization with other arguments goes here>
 * @dev       }
 * @dev   }
 *
 * @dev The oracle will have given you an ID for the VRF keypair they have
 * @dev committed to (let's call it keyHash). Create subscription, fund it
 * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface
 * @dev subscription management functions).
 * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations,
 * @dev callbackGasLimit, numWords),
 * @dev see (VRFCoordinatorInterface for a description of the arguments).
 *
 * @dev Once the VRFCoordinator has received and validated the oracle's response
 * @dev to your request, it will call your contract's fulfillRandomWords method.
 *
 * @dev The randomness argument to fulfillRandomWords is a set of random words
 * @dev generated from your requestId and the blockHash of the request.
 *
 * @dev If your contract could have concurrent requests open, you can use the
 * @dev requestId returned from requestRandomWords to track which response is associated
 * @dev with which randomness request.
 * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind,
 * @dev if your contract could have multiple requests in flight simultaneously.
 *
 * @dev Colliding `requestId`s are cryptographically impossible as long as seeds
 * @dev differ.
 *
 * *****************************************************************************
 * @dev SECURITY CONSIDERATIONS
 *
 * @dev A method with the ability to call your fulfillRandomness method directly
 * @dev could spoof a VRF response with any random value, so it's critical that
 * @dev it cannot be directly called by anything other than this base contract
 * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method).
 *
 * @dev For your users to trust that your contract's random behavior is free
 * @dev from malicious interference, it's best if you can write it so that all
 * @dev behaviors implied by a VRF response are executed *during* your
 * @dev fulfillRandomness method. If your contract must store the response (or
 * @dev anything derived from it) and use it later, you must ensure that any
 * @dev user-significant behavior which depends on that stored value cannot be
 * @dev manipulated by a subsequent VRF request.
 *
 * @dev Similarly, both miners and the VRF oracle itself have some influence
 * @dev over the order in which VRF responses appear on the blockchain, so if
 * @dev your contract could have multiple VRF requests in flight simultaneously,
 * @dev you must ensure that the order in which the VRF responses arrive cannot
 * @dev be used to manipulate your contract's user-significant behavior.
 *
 * @dev Since the block hash of the block which contains the requestRandomness
 * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful
 * @dev miner could, in principle, fork the blockchain to evict the block
 * @dev containing the request, forcing the request to be included in a
 * @dev different block with a different hash, and therefore a different input
 * @dev to the VRF. However, such an attack would incur a substantial economic
 * @dev cost. This cost scales with the number of blocks the VRF oracle waits
 * @dev until it calls responds to a request. It is for this reason that
 * @dev that you can signal to an oracle you'd like them to wait longer before
 * @dev responding to the request (however this is not enforced in the contract
 * @dev and so remains effective only in the case of unmodified oracle software).
 */
abstract contract VRFConsumerBaseV2 {
  error OnlyCoordinatorCanFulfill(address have, address want);
  address private immutable vrfCoordinator;

  /**
   * @param _vrfCoordinator address of VRFCoordinator contract
   */
  constructor(address _vrfCoordinator) {
    vrfCoordinator = _vrfCoordinator;
  }

  /**
   * @notice fulfillRandomness handles the VRF response. Your contract must
   * @notice implement it. See "SECURITY CONSIDERATIONS" above for important
   * @notice principles to keep in mind when implementing your fulfillRandomness
   * @notice method.
   *
   * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this
   * @dev signature, and will call it once it has verified the proof
   * @dev associated with the randomness. (It is triggered via a call to
   * @dev rawFulfillRandomness, below.)
   *
   * @param requestId The Id initially returned by requestRandomness
   * @param randomWords the VRF output expanded to the requested number of words
   */
  function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual;

  // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
  // proof. rawFulfillRandomness then calls fulfillRandomness, after validating
  // the origin of the call
  function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external {
    if (msg.sender != vrfCoordinator) {
      revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator);
    }
    fulfillRandomWords(requestId, randomWords);
  }
}

File 6 of 34 : SignatureChecker.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

/**
@title SignatureChecker
@notice Additional functions for EnumerableSet.Addresset that require a valid
ECDSA signature of a standardized message, signed by any member of the set.
 */
library SignatureChecker {
    using EnumerableSet for EnumerableSet.AddressSet;

    /**
    @notice Requires that the message has not been used previously and that the
    recovered signer is contained in the signers AddressSet.
    @dev Convenience wrapper for message generation + signature verification
    + marking message as used
    @param signers Set of addresses from which signatures are accepted.
    @param usedMessages Set of already-used messages.
    @param signature ECDSA signature of message.
     */
    function requireValidSignature(
        EnumerableSet.AddressSet storage signers,
        bytes memory data,
        bytes calldata signature,
        mapping(bytes32 => bool) storage usedMessages
    ) internal {
        bytes32 message = generateMessage(data);
        require(
            !usedMessages[message],
            "SignatureChecker: Message already used"
        );
        usedMessages[message] = true;
        requireValidSignature(signers, message, signature);
    }

    /**
    @notice Requires that the message has not been used previously and that the
    recovered signer is contained in the signers AddressSet.
    @dev Convenience wrapper for message generation + signature verification.
     */
    function requireValidSignature(
        EnumerableSet.AddressSet storage signers,
        bytes memory data,
        bytes calldata signature
    ) internal view {
        bytes32 message = generateMessage(data);
        requireValidSignature(signers, message, signature);
    }

    /**
    @notice Requires that the message has not been used previously and that the
    recovered signer is contained in the signers AddressSet.
    @dev Convenience wrapper for message generation from address +
    signature verification.
     */
    function requireValidSignature(
        EnumerableSet.AddressSet storage signers,
        address a,
        bytes calldata signature
    ) internal view {
        bytes32 message = generateMessage(abi.encodePacked(a));
        requireValidSignature(signers, message, signature);
    }

    /**
    @notice Common validator logic, checking if the recovered signer is
    contained in the signers AddressSet.
    */
    function validSignature(
        EnumerableSet.AddressSet storage signers,
        bytes32 message,
        bytes calldata signature
    ) internal view returns (bool) {
        return signers.contains(ECDSA.recover(message, signature));
    }

    /**
    @notice Requires that the recovered signer is contained in the signers
    AddressSet.
    @dev Convenience wrapper that reverts if the signature validation fails.
    */
    function requireValidSignature(
        EnumerableSet.AddressSet storage signers,
        bytes32 message,
        bytes calldata signature
    ) internal view {
        require(
            validSignature(signers, message, signature),
            "SignatureChecker: Invalid signature"
        );
    }

    /**
    @notice Generates a message for a given data input that will be signed
    off-chain using ECDSA.
    @dev For multiple data fields, a standard concatenation using 
    `abi.encodePacked` is commonly used to build data.
     */
    function generateMessage(bytes memory data)
        internal
        pure
        returns (bytes32)
    {
        return ECDSA.toEthSignedMessageHash(data);
    }
}

File 7 of 34 : SignerManager.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

/**
@title SignerManager
@notice Manges addition and removal of a core set of addresses from which
valid ECDSA signatures can be accepted; see SignatureChecker.
 */
contract SignerManager is Ownable {
    using EnumerableSet for EnumerableSet.AddressSet;

    /**
    @dev Addresses from which signatures can be accepted.
     */
    EnumerableSet.AddressSet internal signers;

    /**
    @notice Add an address to the set of accepted signers.
     */
    function addSigner(address signer) external onlyOwner {
        signers.add(signer);
    }

    /**
    @notice Remove an address previously added with addSigner().
     */
    function removeSigner(address signer) external onlyOwner {
        signers.remove(signer);
    }
}

File 8 of 34 : FixedPriceSeller.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import "./Seller.sol";

/// @notice A Seller with fixed per-item price.
abstract contract FixedPriceSeller is Seller {
    constructor(
        uint256 _price,
        Seller.SellerConfig memory sellerConfig,
        address payable _beneficiary
    ) Seller(sellerConfig, _beneficiary) {
        setPrice(_price);
    }

    /**
    @notice The fixed per-item price.
    @dev Fixed as in not changing with time nor number of items, but not a
    constant.
     */
    uint256 public price;

    /// @notice Sets the per-item price.
    function setPrice(uint256 _price) public onlyOwner {
        price = _price;
    }

    /**
    @notice Override of Seller.cost() with fixed price.
    @dev The second parameter, metadata propagated from the call to _purchase(),
    is ignored.
     */
    function cost(uint256 n, uint256) public view override returns (uint256) {
        return n * price;
    }
}

File 9 of 34 : ERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)

pragma solidity ^0.8.0;

import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
 *
 * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
 * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
 *
 * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
 * fee is specified in basis points by default.
 *
 * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
 * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
 * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
 *
 * _Available since v4.5._
 */
abstract contract ERC2981 is IERC2981, ERC165 {
    struct RoyaltyInfo {
        address receiver;
        uint96 royaltyFraction;
    }

    RoyaltyInfo private _defaultRoyaltyInfo;
    mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;

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

    /**
     * @inheritdoc IERC2981
     */
    function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
        RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];

        if (royalty.receiver == address(0)) {
            royalty = _defaultRoyaltyInfo;
        }

        uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();

        return (royalty.receiver, royaltyAmount);
    }

    /**
     * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
     * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
     * override.
     */
    function _feeDenominator() internal pure virtual returns (uint96) {
        return 10000;
    }

    /**
     * @dev Sets the royalty information that all ids in this contract will default to.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
        require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
        require(receiver != address(0), "ERC2981: invalid receiver");

        _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
    }

    /**
     * @dev Removes default royalty information.
     */
    function _deleteDefaultRoyalty() internal virtual {
        delete _defaultRoyaltyInfo;
    }

    /**
     * @dev Sets the royalty information for a specific token id, overriding the global default.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setTokenRoyalty(
        uint256 tokenId,
        address receiver,
        uint96 feeNumerator
    ) internal virtual {
        require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
        require(receiver != address(0), "ERC2981: Invalid parameters");

        _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
    }

    /**
     * @dev Resets royalty information for the token id back to the global default.
     */
    function _resetTokenRoyalty(uint256 tokenId) internal virtual {
        delete _tokenRoyaltyInfo[tokenId];
    }
}

File 10 of 34 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

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

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 11 of 34 : ERC721Psi.sol
// SPDX-License-Identifier: MIT
/**
  ______ _____   _____ ______ ___  __ _  _  _ 
 |  ____|  __ \ / ____|____  |__ \/_ | || || |
 | |__  | |__) | |        / /   ) || | \| |/ |
 |  __| |  _  /| |       / /   / / | |\_   _/ 
 | |____| | \ \| |____  / /   / /_ | |  | |   
 |______|_|  \_\\_____|/_/   |____||_|  |_|   
                                              
                                            
 */

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "solidity-bits/contracts/BitMaps.sol";


contract ERC721Psi is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
    using Address for address;
    using Strings for uint256;
    using BitMaps for BitMaps.BitMap;

    BitMaps.BitMap private _batchHead;

    string private _name;
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) internal _owners;
    uint256 internal _minted;

    mapping(uint256 => address) private _tokenApprovals;
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) 
        public 
        view 
        virtual 
        override 
        returns (uint) 
    {
        require(owner != address(0), "ERC721Psi: balance query for the zero address");

        uint count;
        for( uint i; i < _minted; ++i ){
            if(_exists(i)){
                if( owner == ownerOf(i)){
                    ++count;
                }
            }
        }
        return count;
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId)
        public
        view
        virtual
        override
        returns (address)
    {
        (address owner, ) = _ownerAndBatchHeadOf(tokenId);
        return owner;
    }

    function _ownerAndBatchHeadOf(uint256 tokenId) internal view returns (address owner, uint256 tokenIdBatchHead){
        require(_exists(tokenId), "ERC721Psi: owner query for nonexistent token");
        tokenIdBatchHead = _getBatchHead(tokenId);
        owner = _owners[tokenIdBatchHead];
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Psi: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }


    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ownerOf(tokenId);
        require(to != owner, "ERC721Psi: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721Psi: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId)
        public
        view
        virtual
        override
        returns (address)
    {
        require(
            _exists(tokenId),
            "ERC721Psi: approved query for nonexistent token"
        );

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved)
        public
        virtual
        override
    {
        require(operator != _msgSender(), "ERC721Psi: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            "ERC721Psi: transfer caller is not owner nor approved"
        );

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            "ERC721Psi: transfer caller is not owner nor approved"
        );
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @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.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(
            _checkOnERC721Received(from, to, tokenId, 1,_data),
            "ERC721Psi: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return tokenId < _minted;
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId)
        internal
        view
        virtual
        returns (bool)
    {
        require(
            _exists(tokenId),
            "ERC721Psi: operator query for nonexistent token"
        );
        address owner = ownerOf(tokenId);
        return (spender == owner ||
            getApproved(tokenId) == spender ||
            isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 quantity) internal virtual {
        _safeMint(to, quantity, "");
    }

    
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal virtual {
        uint256 startTokenId = _minted;
        _mint(to, quantity);
        require(
            _checkOnERC721Received(address(0), to, startTokenId, quantity, _data),
            "ERC721Psi: transfer to non ERC721Receiver implementer"
        );
    }


    function _mint(
        address to,
        uint256 quantity
    ) internal virtual {
        uint256 tokenIdBatchHead = _minted;
        
        require(quantity > 0, "ERC721Psi: quantity must be greater 0");
        require(to != address(0), "ERC721Psi: mint to the zero address");
        
        _beforeTokenTransfers(address(0), to, tokenIdBatchHead, quantity);
        _minted += quantity;
        _owners[tokenIdBatchHead] = to;
        _batchHead.set(tokenIdBatchHead);
        _afterTokenTransfers(address(0), to, tokenIdBatchHead, quantity);
        
        // Emit events
        for(uint256 tokenId=tokenIdBatchHead;tokenId < tokenIdBatchHead + quantity; tokenId++){
            emit Transfer(address(0), to, tokenId);
        } 
    }


    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        (address owner, uint256 tokenIdBatchHead) = _ownerAndBatchHeadOf(tokenId);

        require(
            owner == from,
            "ERC721Psi: transfer of token that is not own"
        );
        require(to != address(0), "ERC721Psi: transfer to the zero address");

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);   

        uint256 nextTokenId = tokenId + 1;

        if(!_batchHead.get(nextTokenId) &&  
            nextTokenId < _minted
        ) {
            _owners[nextTokenId] = from;
            _batchHead.set(nextTokenId);
        }

        _owners[tokenId] = to;
        if(tokenId != tokenIdBatchHead) {
            _batchHead.set(tokenId);
        }

        emit Transfer(from, to, tokenId);

        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param startTokenId uint256 the first ID of the tokens to be transferred
     * @param quantity uint256 amount of the tokens to be transfered.
     * @param _data bytes optional data to send along with the call
     * @return r bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity,
        bytes memory _data
    ) private returns (bool r) {
        if (to.isContract()) {
            r = true;
            for(uint256 tokenId = startTokenId; tokenId < startTokenId + quantity; tokenId++){
                try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                    r = r && retval == IERC721Receiver.onERC721Received.selector;
                } catch (bytes memory reason) {
                    if (reason.length == 0) {
                        revert("ERC721Psi: transfer to non ERC721Receiver implementer");
                    } else {
                        assembly {
                            revert(add(32, reason), mload(reason))
                        }
                    }
                }
            }
            return r;
        } else {
            return true;
        }
    }

    function _getBatchHead(uint256 tokenId) internal view returns (uint256 tokenIdBatchHead) {
        tokenIdBatchHead = _batchHead.scanForward(tokenId); 
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256 tokenId) {
        require(index < totalSupply(), "ERC721Psi: global index out of bounds");
        
        uint count;
        for(uint i; i < _minted; i++){
            if(_exists(i)){
                if(count == index) return i;
                else count++;
            }
        }
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
        uint count;
        for(uint i; i < _minted; i++){
            if(_exists(i) && owner == ownerOf(i)){
                if(count == index) return i;
                else count++;
            }
        }

        revert("ERC721Psi: owner index out of bounds");
    }


    /**
     * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
     *
     * startTokenId - the first token id to be transferred
     * quantity - the amount to be transferred
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
     * minting.
     *
     * startTokenId - the first token id to be transferred
     * quantity - the amount to be transferred
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}
}

File 12 of 34 : Feistel.sol
//SPDX-License-Identifier: MIT
/**

███████╗██████╗ ███████╗    ███╗   ███╗ █████╗ ██████╗ 
██╔════╝██╔══██╗██╔════╝    ████╗ ████║██╔══██╗██╔══██╗
█████╗  ██████╔╝█████╗█████╗██╔████╔██║███████║██████╔╝
██╔══╝  ██╔═══╝ ██╔══╝╚════╝██║╚██╔╝██║██╔══██║██╔═══╝ 
██║     ██║     ███████╗    ██║ ╚═╝ ██║██║  ██║██║     
╚═╝     ╚═╝     ╚══════╝    ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     
                                                       
github: https://github.com/estarriolvetch/fpe-mapping

 */
pragma solidity ^0.8.0;

library Feistel {
    /// Balanced Feistel network
    function feistel(uint256 input, uint256 key, uint256 round, uint256 size) internal pure returns (uint256) {
        unchecked {
            uint256 halfSize = size / 2;
            uint256 halfMap = (2 ** halfSize) - 1;
                
            uint256 left = (input >> halfSize) & halfMap;
            uint256 right = (input & halfMap);
            
            for(uint256 i=0; i < round; i++) {
                uint256 roundKey = uint256(keccak256(abi.encode(key, i)));
                uint256 left_new = right;
                uint256 right_new = left ^ (halfMap & uint256(keccak256(abi.encode(right, roundKey))));

                left = left_new;
                right = right_new;
            }
            return (left << halfSize) | right;
        }
    }

    /// Unbalanced Feistel network
    function feistelUnbalanced(uint256 input, uint256 key, uint256 round, uint256 size) internal pure returns (uint256) {
        unchecked {
            uint256 shortSize = size / 2;
            uint256 longSize = size - shortSize;
            
            uint256 longMap = (1 << longSize) - 1;
            uint256 shortMap = (1 << shortSize) - 1;
            
            uint256 left = (input >> shortSize) & longMap;
            uint256 right = (input & shortMap);
            
            for(uint256 i=0; i < round; i++) {
                uint256 roundKey = uint256(keccak256(abi.encode(key, i)));
                uint256 left_new = right;
                uint256 right_new;
                if(i % 2 == 0){
                    right_new = left ^ (longMap & uint256(keccak256(abi.encode(right, roundKey))));
                } else {
                    right_new = left ^ (shortMap & uint256(keccak256(abi.encode(right, roundKey))));
                }
                
                left = left_new;
                right = right_new;
            }

            if (round % 2 == 0) {
                return (left << shortSize) | right;
            } else {
                return (left << longSize) | right;
            }
        }
    }
}

File 13 of 34 : BitScan.sol
// SPDX-License-Identifier: MIT
/**
   _____       ___     ___ __           ____  _ __      
  / ___/____  / (_)___/ (_) /___  __   / __ )(_) /______
  \__ \/ __ \/ / / __  / / __/ / / /  / __  / / __/ ___/
 ___/ / /_/ / / / /_/ / / /_/ /_/ /  / /_/ / / /_(__  ) 
/____/\____/_/_/\__,_/_/\__/\__, /  /_____/_/\__/____/  
                           /____/                        

- npm: https://www.npmjs.com/package/solidity-bits
- github: https://github.com/estarriolvetch/solidity-bits

 */

pragma solidity ^0.8.0;


library BitScan {
    uint256 constant private DEBRUIJN_256 = 0x818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff;
    bytes constant private LOOKUP_TABLE_256 = hex"0001020903110a19042112290b311a3905412245134d2a550c5d32651b6d3a7506264262237d468514804e8d2b95569d0d495ea533a966b11c886eb93bc176c9071727374353637324837e9b47af86c7155181ad4fd18ed32c9096db57d59ee30e2e4a6a5f92a6be3498aae067ddb2eb1d5989b56fd7baf33ca0c2ee77e5caf7ff0810182028303840444c545c646c7425617c847f8c949c48a4a8b087b8c0c816365272829aaec650acd0d28fdad4e22d6991bd97dfdcea58b4d6f29fede4f6fe0f1f2f3f4b5b6b607b8b93a3a7b7bf357199c5abcfd9e168bcdee9b3f1ecf5fd1e3e5a7a8aa2b670c4ced8bbe8f0f4fc3d79a1c3cde7effb78cce6facbf9f8";

    /**
        @dev Isolate the least significant set bit.
     */ 
    function isolateLS1B256(uint256 bb) pure internal returns (uint256) {
        require(bb > 0);
        unchecked {
            return bb & (0 - bb);
        }
    } 

    /**
        @dev Isolate the most significant set bit.
     */ 
    function isolateMS1B256(uint256 bb) pure internal returns (uint256) {
        require(bb > 0);
        unchecked {
            bb |= bb >> 128;
            bb |= bb >> 64;
            bb |= bb >> 32;
            bb |= bb >> 16;
            bb |= bb >> 8;
            bb |= bb >> 4;
            bb |= bb >> 2;
            bb |= bb >> 1;
            
            return (bb >> 1) + 1;
        }
    } 

    /**
        @dev Find the index of the lest significant set bit. (trailing zero count)
     */ 
    function bitScanForward256(uint256 bb) pure internal returns (uint8) {
        unchecked {
            return uint8(LOOKUP_TABLE_256[(isolateLS1B256(bb) * DEBRUIJN_256) >> 248]);
        }   
    }

    /**
        @dev Find the index of the most significant set bit.
     */ 
    function bitScanReverse256(uint256 bb) pure internal returns (uint8) {
        unchecked {
            return 255 - uint8(LOOKUP_TABLE_256[((isolateMS1B256(bb) * DEBRUIJN_256) >> 248)]);
        }   
    }

    function log2(uint256 bb) pure internal returns (uint8) {
        unchecked {
            return uint8(LOOKUP_TABLE_256[(isolateMS1B256(bb) * DEBRUIJN_256) >> 248]);
        } 
    }
}

File 14 of 34 : BitMaps.sol
// SPDX-License-Identifier: MIT
/**
   _____       ___     ___ __           ____  _ __      
  / ___/____  / (_)___/ (_) /___  __   / __ )(_) /______
  \__ \/ __ \/ / / __  / / __/ / / /  / __  / / __/ ___/
 ___/ / /_/ / / / /_/ / / /_/ /_/ /  / /_/ / / /_(__  ) 
/____/\____/_/_/\__,_/_/\__/\__, /  /_____/_/\__/____/  
                           /____/                        

- npm: https://www.npmjs.com/package/solidity-bits
- github: https://github.com/estarriolvetch/solidity-bits

 */
pragma solidity ^0.8.0;

import "./BitScan.sol";

/**
 * @dev This Library is a modified version of Openzeppelin's BitMaps library.
 * Functions of finding the index of the closest set bit from a given index are added.
 * The indexing of each bucket is modifed to count from the MSB to the LSB instead of from the LSB to the MSB.
 * The modification of indexing makes finding the closest previous set bit more efficient in gas usage.
*/

/**
 * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential.
 * Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor].
 */

library BitMaps {
    using BitScan for uint256;
    uint256 private constant MASK_INDEX_ZERO = (1 << 255);
    uint256 private constant MASK_FULL = type(uint256).max;

    struct BitMap {
        mapping(uint256 => uint256) _data;
    }

    /**
     * @dev Returns whether the bit at `index` is set.
     */
    function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
        uint256 bucket = index >> 8;
        uint256 mask = MASK_INDEX_ZERO >> (index & 0xff);
        return bitmap._data[bucket] & mask != 0;
    }

    /**
     * @dev Sets the bit at `index` to the boolean `value`.
     */
    function setTo(
        BitMap storage bitmap,
        uint256 index,
        bool value
    ) internal {
        if (value) {
            set(bitmap, index);
        } else {
            unset(bitmap, index);
        }
    }

    /**
     * @dev Sets the bit at `index`.
     */
    function set(BitMap storage bitmap, uint256 index) internal {
        uint256 bucket = index >> 8;
        uint256 mask = MASK_INDEX_ZERO >> (index & 0xff);
        bitmap._data[bucket] |= mask;
    }

    /**
     * @dev Unsets the bit at `index`.
     */
    function unset(BitMap storage bitmap, uint256 index) internal {
        uint256 bucket = index >> 8;
        uint256 mask = MASK_INDEX_ZERO >> (index & 0xff);
        bitmap._data[bucket] &= ~mask;
    }


    /**
     * @dev Consecutively sets `amount` of bits starting from the bit at `startIndex`.
     */    
    function setBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal {
        uint256 bucket = startIndex >> 8;

        uint256 bucketStartIndex = (startIndex & 0xff);

        unchecked {
            if(bucketStartIndex + amount < 256) {
                bitmap._data[bucket] |= MASK_FULL << (256 - amount) >> bucketStartIndex;
            } else {
                bitmap._data[bucket] |= MASK_FULL >> bucketStartIndex;
                amount -= (256 - bucketStartIndex);
                bucket++;

                while(amount > 256) {
                    bitmap._data[bucket] = MASK_FULL;
                    amount -= 256;
                    bucket++;
                }

                bitmap._data[bucket] |= MASK_FULL << (256 - amount);
            }
        }
    }


    /**
     * @dev Consecutively unsets `amount` of bits starting from the bit at `startIndex`.
     */    
    function unsetBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal {
        uint256 bucket = startIndex >> 8;

        uint256 bucketStartIndex = (startIndex & 0xff);

        unchecked {
            if(bucketStartIndex + amount < 256) {
                bitmap._data[bucket] &= ~(MASK_FULL << (256 - amount) >> bucketStartIndex);
            } else {
                bitmap._data[bucket] &= ~(MASK_FULL >> bucketStartIndex);
                amount -= (256 - bucketStartIndex);
                bucket++;

                while(amount > 256) {
                    bitmap._data[bucket] = 0;
                    amount -= 256;
                    bucket++;
                }

                bitmap._data[bucket] &= ~(MASK_FULL << (256 - amount));
            }
        }
    }


    /**
     * @dev Find the closest index of the set bit before `index`.
     */
    function scanForward(BitMap storage bitmap, uint256 index) internal view returns (uint256 setBitIndex) {
        uint256 bucket = index >> 8;

        // index within the bucket
        uint256 bucketIndex = (index & 0xff);

        // load a bitboard from the bitmap.
        uint256 bb = bitmap._data[bucket];

        // offset the bitboard to scan from `bucketIndex`.
        bb = bb >> (0xff ^ bucketIndex); // bb >> (255 - bucketIndex)
        
        if(bb > 0) {
            unchecked {
                setBitIndex = (bucket << 8) | (bucketIndex -  bb.bitScanForward256());    
            }
        } else {
            while(true) {
                require(bucket > 0, "BitMaps: The set bit before the index doesn't exist.");
                unchecked {
                    bucket--;
                }
                // No offset. Always scan from the least significiant bit now.
                bb = bitmap._data[bucket];
                
                if(bb > 0) {
                    unchecked {
                        setBitIndex = (bucket << 8) | (255 -  bb.bitScanForward256());
                        break;
                    }
                } 
            }
        }
    }

    function getBucket(BitMap storage bitmap, uint256 bucket) internal view returns (uint256) {
        return bitmap._data[bucket];
    }
}

File 15 of 34 : StorageSlot.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 StorageSlot {
    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
        }
    }
}

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

        return account.code.length > 0;
    }

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

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

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

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

        (bool success, bytes memory returndata) = target.delegatecall(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);
            }
        }
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

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

File 19 of 34 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 20 of 34 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 21 of 34 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 22 of 34 : 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);
}

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

pragma solidity ^0.8.0;

import "../utils/introspection/IERC165.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 IERC2981 is IERC165 {
    /**
     * @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);
}

File 24 of 34 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

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

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

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

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
        _safeTransfer(from, to, tokenId, data);
    }

    /**
     * @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.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

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

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

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

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

File 25 of 34 : Seller.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import "../utils/Monotonic.sol";
import "../utils/OwnerPausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/**
@notice An abstract contract providing the _purchase() function to:
 - Enforce per-wallet / per-transaction limits
 - Calculate required cost, forwarding to a beneficiary, and refunding extra
 */
abstract contract Seller is OwnerPausable, ReentrancyGuard {
    using Address for address payable;
    using Monotonic for Monotonic.Increaser;
    using Strings for uint256;

    /**
    @dev Note that the address limits are vulnerable to wallet farming.
    @param maxPerAddress Unlimited if zero.
    @param maxPerTex Unlimited if zero.
    @param freeQuota Maximum number that can be purchased free of charge by
    the contract owner.
    @param reserveFreeQuota Whether to excplitly reserve the freeQuota amount
    and not let it be eroded by regular purchases.
    @param lockFreeQuota If true, calls to setSellerConfig() will ignore changes
    to freeQuota. Can be locked after initial setting, but not unlocked. This
    allows a contract owner to commit to a maximum number of reserved items.
    @param lockTotalInventory Similar to lockFreeQuota but applied to
    totalInventory.
    */
    struct SellerConfig {
        uint256 totalInventory;
        uint256 maxPerAddress;
        uint256 maxPerTx;
        uint248 freeQuota;
        bool reserveFreeQuota;
        bool lockFreeQuota;
        bool lockTotalInventory;
    }

    constructor(SellerConfig memory config, address payable _beneficiary) {
        setSellerConfig(config);
        setBeneficiary(_beneficiary);
    }

    /// @notice Configuration of purchase limits.
    SellerConfig public sellerConfig;

    /// @notice Sets the seller config.
    function setSellerConfig(SellerConfig memory config) public onlyOwner {
        require(
            config.totalInventory >= config.freeQuota,
            "Seller: excessive free quota"
        );
        require(
            config.totalInventory >= _totalSold.current(),
            "Seller: inventory < already sold"
        );
        require(
            config.freeQuota >= purchasedFreeOfCharge.current(),
            "Seller: free quota < already used"
        );

        // Overriding the in-memory fields before copying the whole struct, as
        // against writing individual fields, gives a greater guarantee of
        // correctness as the code is simpler to read.
        if (sellerConfig.lockTotalInventory) {
            config.lockTotalInventory = true;
            config.totalInventory = sellerConfig.totalInventory;
        }
        if (sellerConfig.lockFreeQuota) {
            config.lockFreeQuota = true;
            config.freeQuota = sellerConfig.freeQuota;
        }
        sellerConfig = config;
    }

    /// @notice Recipient of revenues.
    address payable public beneficiary;

    /// @notice Sets the recipient of revenues.
    function setBeneficiary(address payable _beneficiary) public onlyOwner {
        beneficiary = _beneficiary;
    }

    /**
    @dev Must return the current cost of a batch of items. This may be constant
    or, for example, decreasing for a Dutch auction or increasing for a bonding
    curve.
    @param n The number of items being purchased.
    @param metadata Arbitrary data, propagated by the call to _purchase() that
    can be used to charge different prices. This value is a uint256 instead of
    bytes as this allows simple passing of a set cost (see
    ArbitraryPriceSeller).
     */
    function cost(uint256 n, uint256 metadata)
        public
        view
        virtual
        returns (uint256);

    /**
    @dev Called by both _purchase() and purchaseFreeOfCharge() after all limits
    have been put in place; must perform all contract-specific sale logic, e.g.
    ERC721 minting. When _handlePurchase() is called, the value returned by
    Seller.totalSold() will be the POST-purchase amount to allow for the
    checks-effects-interactions (ECI) pattern as _handlePurchase() may include
    an interaction. _handlePurchase() MUST itself implement the CEI pattern.
    @param to The recipient of the item(s).
    @param n The number of items allowed to be purchased, which MAY be less than
    to the number passed to _purchase() but SHALL be greater than zero.
    @param freeOfCharge Indicates that the call originated from
    purchaseFreeOfCharge() and not _purchase().
    */
    function _handlePurchase(
        address to,
        uint256 n,
        bool freeOfCharge
    ) internal virtual;

    /**
    @notice Tracks total number of items sold by this contract, including those
    purchased free of charge by the contract owner.
     */
    Monotonic.Increaser private _totalSold;

    /// @notice Returns the total number of items sold by this contract.
    function totalSold() public view returns (uint256) {
        return _totalSold.current();
    }

    /**
    @notice Tracks the number of items already bought by an address, regardless
    of transferring out (in the case of ERC721).
    @dev This isn't public as it may be skewed due to differences in msg.sender
    and tx.origin, which it treats in the same way such that
    sum(_bought)>=totalSold().
     */
    mapping(address => uint256) private _bought;

    /**
    @notice Returns min(n, max(extra items addr can purchase)) and reverts if 0.
    @param zeroMsg The message with which to revert on 0 extra.
     */
    function _capExtra(
        uint256 n,
        address addr,
        string memory zeroMsg
    ) internal view returns (uint256) {
        uint256 extra = sellerConfig.maxPerAddress - _bought[addr];
        if (extra == 0) {
            revert(string(abi.encodePacked("Seller: ", zeroMsg)));
        }
        return Math.min(n, extra);
    }

    /// @notice Emitted when a buyer is refunded.
    event Refund(address indexed buyer, uint256 amount);

    /// @notice Emitted on all purchases of non-zero amount.
    event Revenue(
        address indexed beneficiary,
        uint256 numPurchased,
        uint256 amount
    );

    /// @notice Tracks number of items purchased free of charge.
    Monotonic.Increaser private purchasedFreeOfCharge;

    /**
    @notice Allows the contract owner to purchase without payment, within the
    quota enforced by the SellerConfig.
     */
    function purchaseFreeOfCharge(address to, uint256 n)
        public
        onlyOwner
        whenNotPaused
    {
        /**
         * ##### CHECKS
         */

        uint256 freeQuota = sellerConfig.freeQuota;
        n = Math.min(n, freeQuota - purchasedFreeOfCharge.current());
        require(n > 0, "Seller: Free quota exceeded");

        uint256 totalInventory = sellerConfig.totalInventory;
        n = Math.min(n, totalInventory - _totalSold.current());
        require(n > 0, "Seller: Sold out");

        /**
         * ##### EFFECTS
         */
        _totalSold.add(n);
        purchasedFreeOfCharge.add(n);

        /**
         * ##### INTERACTIONS
         */
        _handlePurchase(to, n, true);
        assert(_totalSold.current() <= totalInventory);
        assert(purchasedFreeOfCharge.current() <= freeQuota);
    }

    /**
    @notice Convenience function for calling _purchase() with empty costMetadata
    when unneeded.
     */
    function _purchase(address to, uint256 requested) internal virtual {
        _purchase(to, requested, 0);
    }

    /**
    @notice Enforces all purchase limits (counts and costs) before calling
    _handlePurchase(), after which the received funds are disbursed to the
    beneficiary, less any required refunds.
    @param to The final recipient of the item(s).
    @param requested The number of items requested for purchase, which MAY be
    reduced when passed to _handlePurchase().
    @param costMetadata Arbitrary data, propagated in the call to cost(), to be
    optionally used in determining the price.
     */
    function _purchase(
        address to,
        uint256 requested,
        uint256 costMetadata
    ) internal nonReentrant whenNotPaused {
        /**
         * ##### CHECKS
         */
        SellerConfig memory config = sellerConfig;

        uint256 n = config.maxPerTx == 0
            ? requested
            : Math.min(requested, config.maxPerTx);

        uint256 maxAvailable;
        uint256 sold;

        if (config.reserveFreeQuota) {
            maxAvailable = config.totalInventory - config.freeQuota;
            sold = _totalSold.current() - purchasedFreeOfCharge.current();
        } else {
            maxAvailable = config.totalInventory;
            sold = _totalSold.current();
        }

        n = Math.min(n, maxAvailable - sold);
        require(n > 0, "Seller: Sold out");

        if (config.maxPerAddress > 0) {
            bool alsoLimitSender = _msgSender() != to;
            // solhint-disable-next-line avoid-tx-origin
            bool alsoLimitOrigin = tx.origin != _msgSender() && tx.origin != to;

            n = _capExtra(n, to, "Buyer limit");
            if (alsoLimitSender) {
                n = _capExtra(n, _msgSender(), "Sender limit");
            }
            if (alsoLimitOrigin) {
                // solhint-disable-next-line avoid-tx-origin
                n = _capExtra(n, tx.origin, "Origin limit");
            }

            _bought[to] += n;
            if (alsoLimitSender) {
                _bought[_msgSender()] += n;
            }
            if (alsoLimitOrigin) {
                // solhint-disable-next-line avoid-tx-origin
                _bought[tx.origin] += n;
            }
        }

        uint256 _cost = cost(n, costMetadata);
        if (msg.value < _cost) {
            revert(
                string(
                    abi.encodePacked(
                        "Seller: Costs ",
                        (_cost / 1e9).toString(),
                        " GWei"
                    )
                )
            );
        }

        /**
         * ##### EFFECTS
         */
        _totalSold.add(n);
        assert(_totalSold.current() <= config.totalInventory);

        /**
         * ##### INTERACTIONS
         */

        // As _handlePurchase() is often an ERC721 safeMint(), it constitutes an
        // interaction.
        _handlePurchase(to, n, false);

        // Ideally we'd be using a PullPayment here, but the user experience is
        // poor when there's a variable cost or the number of items purchased
        // has been capped. We've addressed reentrancy with both a nonReentrant
        // modifier and the checks, effects, interactions pattern.

        if (_cost > 0) {
            beneficiary.sendValue(_cost);
            emit Revenue(beneficiary, n, _cost);
        }

        if (msg.value > _cost) {
            address payable reimburse = payable(_msgSender());
            uint256 refund = msg.value - _cost;

            // Using Address.sendValue() here would mask the revertMsg upon
            // reentrancy, but we want to expose it to allow for more precise
            // testing. This otherwise uses the exact same pattern as
            // Address.sendValue().
            // solhint-disable-next-line avoid-low-level-calls
            (bool success, bytes memory returnData) = reimburse.call{
                value: refund
            }("");
            // Although `returnData` will have a spurious prefix, all we really
            // care about is that it contains the ReentrancyGuard reversion
            // message so we can check in the tests.
            require(success, string(returnData));

            emit Refund(reimburse, refund);
        }
    }
}

File 26 of 34 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 28 of 34 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.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 ECDSA {
    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", Strings.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));
    }
}

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

pragma solidity ^0.8.0;

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

File 30 of 34 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
        // good first aproximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 1;
        }

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

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

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

File 32 of 34 : OwnerPausable.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

/// @notice A Pausable contract that can only be toggled by the Owner.
contract OwnerPausable is Ownable, Pausable {
    /// @notice Pauses the contract.
    function pause() public onlyOwner {
        Pausable._pause();
    }

    /// @notice Unpauses the contract.
    function unpause() public onlyOwner {
        Pausable._unpause();
    }
}

File 33 of 34 : Monotonic.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

/**
@notice Provides monotonic increasing and decreasing values, similar to
OpenZeppelin's Counter but (a) limited in direction, and (b) allowing for steps
> 1.
 */
library Monotonic {
    /**
    @notice Holds a value that can only increase.
    @dev The internal value MUST NOT be accessed directly. Instead use current()
    and add().
     */
    struct Increaser {
        uint256 value;
    }

    /// @notice Returns the current value of the Increaser.
    function current(Increaser storage incr) internal view returns (uint256) {
        return incr.value;
    }

    /// @notice Adds x to the Increaser's value.
    function add(Increaser storage incr, uint256 x) internal {
        incr.value += x;
    }

    /**
    @notice Holds a value that can only decrease.
    @dev The internal value MUST NOT be accessed directly. Instead use current()
    and subtract().
     */
    struct Decreaser {
        uint256 value;
    }

    /// @notice Returns the current value of the Decreaser.
    function current(Decreaser storage decr) internal view returns (uint256) {
        return decr.value;
    }

    /// @notice Subtracts x from the Decreaser's value.
    function subtract(Decreaser storage decr, uint256 x) internal {
        decr.value -= x;
    }
}

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

pragma solidity ^0.8.0;

import "../utils/Context.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 Pausable is Context {
    /**
     * @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.
     */
    constructor() {
        _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());
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address payable","name":"_beneficiary","type":"address"},{"internalType":"address payable","name":"_royaltyReceiver","type":"address"},{"internalType":"uint256","name":"_initialInventory","type":"uint256"},{"internalType":"address","name":"_vrfCoordinator","type":"address"},{"internalType":"bytes32","name":"_vrfKeyHash","type":"bytes32"},{"internalType":"uint64","name":"_vrfSubscriptionId","type":"uint64"},{"internalType":"uint32","name":"_vrfCallbackGasLimit","type":"uint32"},{"internalType":"uint16","name":"_vrfRequestConfirmations","type":"uint16"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Expelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"numPurchased","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Revenue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Unstaked","type":"event"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"addSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"ownerAdr","type":"address"}],"name":"allTokensOwnedBy","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beneficiary","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"cost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockMetadataMap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint16","name":"requested","type":"uint16"},{"internalType":"uint32","name":"nonce","type":"uint32"},{"internalType":"bytes","name":"sig","type":"bytes"}],"name":"mintAllowlist","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintAllowlistStartTime","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"requested","type":"uint16"}],"name":"mintPublic","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintPublicStartTime","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"n","type":"uint256"}],"name":"purchaseFreeOfCharge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"randomRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randomSeed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"removeSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRandomSeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellerConfig","outputs":[{"internalType":"uint256","name":"totalInventory","type":"uint256"},{"internalType":"uint256","name":"maxPerAddress","type":"uint256"},{"internalType":"uint256","name":"maxPerTx","type":"uint256"},{"internalType":"uint248","name":"freeQuota","type":"uint248"},{"internalType":"bool","name":"reserveFreeQuota","type":"bool"},{"internalType":"bool","name":"lockFreeQuota","type":"bool"},{"internalType":"bool","name":"lockTotalInventory","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURIStaticMetadata","type":"string"}],"name":"setBaseURIStaticMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_beneficiary","type":"address"}],"name":"setBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_finalInventory","type":"uint256"}],"name":"setFinalInventory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"allowlistStartTime","type":"uint32"},{"internalType":"uint32","name":"publicStartTime","type":"uint32"}],"name":"setMintConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"totalInventory","type":"uint256"},{"internalType":"uint256","name":"maxPerAddress","type":"uint256"},{"internalType":"uint256","name":"maxPerTx","type":"uint256"},{"internalType":"uint248","name":"freeQuota","type":"uint248"},{"internalType":"bool","name":"reserveFreeQuota","type":"bool"},{"internalType":"bool","name":"lockFreeQuota","type":"bool"},{"internalType":"bool","name":"lockTotalInventory","type":"bool"}],"internalType":"struct Seller.SellerConfig","name":"config","type":"tuple"}],"name":"setSellerConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"open","type":"bool"}],"name":"setStakingOpen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_vrfCallbackGasLimit","type":"uint32"}],"name":"setVrfCallbackGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingIsOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"stakingPeriod","outputs":[{"internalType":"bool","name":"staking","type":"bool"},{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"toggleStaking","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"toggleStaking","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURIStaticMetadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"}]

61010060405260006018819055601c805460ff19169055601f805460ff60c01b191690556020553480156200003357600080fd5b5060405162004ff038038062004ff08339810160408190526200005691620005e5565b6040805160e0810182528781526001602080830182905282840182905261012c606084015260808301829052600060a0840181905260c084015283518085018552601381527f554e434f44452041766174617273204d616c65000000000000000000000000008183015284518086019095526009855268554e434f4445e296bd60b81b918501919091528893670429d069189e000093928d9284928492620000ff83826200074c565b5060026200010e82826200074c565b5050506200012b62000125620001d660201b60201c565b620001da565b6009805460ff60a01b191690556001600a5562000148826200022c565b62000153816200042e565b50620001619050836200045a565b5050506001600160a01b03166080526200017e876101f462000469565b601f805460a0959095526001600160401b0390931660c05263ffffffff909116600160a01b026001600160c01b03199093166001600160a01b039094169390931791909117905561ffff1660e0525062000818915050565b3390565b600980546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b620002366200056a565b80606001516001600160f81b0316816000015110156200029d5760405162461bcd60e51b815260206004820152601c60248201527f53656c6c65723a2065786365737369766520667265652071756f74610000000060448201526064015b60405180910390fd5b620002b46011620005c860201b62001eb81760201c565b81511015620003065760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c64604482015260640162000294565b6200031d6013620005c860201b62001eb81760201c565b81606001516001600160f81b03161015620003855760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b606482015260840162000294565b600f54610100900460ff1615620003a357600160c0820152600b5481525b600f5460ff1615620003c857600160a0820152600e546001600160f81b031660608201525b8051600b556020810151600c556040810151600d55606081015160808201511515600160f81b026001600160f81b0390911617600e5560a0810151600f805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b620004386200056a565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b620004646200056a565b601455565b6127106001600160601b0382161115620004d95760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b606482015260840162000294565b6001600160a01b038216620005315760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c696420726563656976657200000000000000604482015260640162000294565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600755565b6009546001600160a01b03163314620005c65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000294565b565b5490565b6001600160a01b0381168114620005e257600080fd5b50565b600080600080600080600080610100898b0312156200060357600080fd5b88516200061081620005cc565b60208a01519098506200062381620005cc565b60408a015160608b015191985096506200063d81620005cc565b60808a015160a08b015191965094506001600160401b03811681146200066257600080fd5b60c08a015190935063ffffffff811681146200067d57600080fd5b60e08a015190925061ffff811681146200069657600080fd5b809150509295985092959890939650565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620006d257607f821691505b602082108103620006f357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200074757600081815260208120601f850160051c81016020861015620007225750805b601f850160051c820191505b8181101562000743578281556001016200072e565b5050505b505050565b81516001600160401b03811115620007685762000768620006a7565b6200078081620007798454620006bd565b84620006f9565b602080601f831160018114620007b857600084156200079f5750858301515b600019600386901b1c1916600185901b17855562000743565b600085815260208120601f198616915b82811015620007e957888601518255948401946001909101908401620007c8565b5085821015620008085787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e051614797620008596000396000611cec01526000611cc201526000611c93015260008181610f990152610fdb01526147976000f3fe60806040526004361061036b5760003560e01c80636ef4f9b5116101c6578063b88d4fde116100f7578063e5d8d0a111610095578063f2fde38b1161006f578063f2fde38b14610a8b578063f615907814610aab578063f856f42b14610acb578063fb54a06b14610ae557600080fd5b8063e5d8d0a114610a02578063e985e9c514610a22578063eb12d61e14610a6b57600080fd5b8063c1027c98116100d1578063c1027c981461097d578063c87b56dd146109ba578063d13dfa63146109da578063e1da26c6146109ed57600080fd5b8063b88d4fde146108b2578063bb69b7ef146108d2578063bf62e21d1461095d57600080fd5b80638d323a8b1161016457806391b7f5ed1161013e57806391b7f5ed1461084757806395d89b4114610867578063a035b1fe1461087c578063a22cb4651461089257600080fd5b80638d323a8b146107fe5780638da5cb5b146108145780639106d7ba1461083257600080fd5b8063792ede4d116101a0578063792ede4d146107825780638158ecee146107b45780638296b01d146107c95780638456cb59146107e957600080fd5b80636ef4f9b51461072d57806370a082311461074d578063715018a61461076d57600080fd5b80632f274bd4116102a05780634f6ccce71161023e578063564892dc11610218578063564892dc146106ae5780635a405c87146106ce5780635c975abb146106ee5780636352211e1461070d57600080fd5b80634f6ccce71461064157806353321c721461066157806355f804b31461068e57600080fd5b80633ec02e141161027a5780633ec02e14146105cc5780633f06b8ab146105ec5780633f4ba83a1461060c57806342842e0e1461062157600080fd5b80632f274bd41461056c5780632f745c591461058c57806338af3eed146105ac57600080fd5b806316755b571161030d5780631fe543e3116102e75780631fe543e3146104cd57806323b872dd146104ed5780632a55205a1461050d5780632e17de781461054c57600080fd5b806316755b571461048557806318160ddd146104985780631c31f710146104ad57600080fd5b8063081812fc11610349578063081812fc146103e9578063095ea7b3146104215780630b747d91146104415780630e316ab71461046557600080fd5b806301ffc9a71461037057806302c1afd9146103a557806306fdde03146103c7575b600080fd5b34801561037c57600080fd5b5061039061038b366004613b1f565b610b0a565b60405190151581526020015b60405180910390f35b3480156103b157600080fd5b506103c56103c0366004613b3c565b610b2a565b005b3480156103d357600080fd5b506103dc610ca6565b60405161039c9190613ba5565b3480156103f557600080fd5b50610409610404366004613b3c565b610d38565b6040516001600160a01b03909116815260200161039c565b34801561042d57600080fd5b506103c561043c366004613bcd565b610dc5565b34801561044d57600080fd5b5061045760205481565b60405190815260200161039c565b34801561047157600080fd5b506103c5610480366004613bf9565b610ed7565b6103c5610493366004613c2d565b610eee565b3480156104a457600080fd5b50600454610457565b3480156104b957600080fd5b506103c56104c8366004613bf9565b610f64565b3480156104d957600080fd5b506103c56104e8366004613cb8565b610f8e565b3480156104f957600080fd5b506103c5610508366004613d6a565b611012565b34801561051957600080fd5b5061052d610528366004613dab565b611043565b604080516001600160a01b03909316835260208301919091520161039c565b34801561055857600080fd5b506103c5610567366004613b3c565b6110f1565b34801561057857600080fd5b506103c5610587366004613ddd565b6111e8565b34801561059857600080fd5b506104576105a7366004613bcd565b6113b4565b3480156105b857600080fd5b50601054610409906001600160a01b031681565b3480156105d857600080fd5b506104576105e7366004613dab565b61147e565b3480156105f857600080fd5b506103c5610607366004613e7c565b611495565b34801561061857600080fd5b506103c56114cd565b34801561062d57600080fd5b506103c561063c366004613d6a565b6114df565b34801561064d57600080fd5b5061045761065c366004613b3c565b6114fa565b34801561066d57600080fd5b5061068161067c366004613bf9565b6115b4565b60405161039c9190613eaf565b34801561069a57600080fd5b506103c56106a9366004613f35565b611681565b3480156106ba57600080fd5b506103c56106c9366004613f77565b611696565b3480156106da57600080fd5b506103c56106e9366004613f92565b6116b1565b3480156106fa57600080fd5b50600954600160a01b900460ff16610390565b34801561071957600080fd5b50610409610728366004613b3c565b6116df565b34801561073957600080fd5b506103c5610748366004613fad565b6116f3565b34801561075957600080fd5b50610457610768366004613bf9565b611736565b34801561077957600080fd5b506103c5611806565b34801561078e57600080fd5b5060175461079f9063ffffffff1681565b60405163ffffffff909116815260200161039c565b3480156107c057600080fd5b506103c5611818565b3480156107d557600080fd5b506103c56107e4366004613f35565b611835565b3480156107f557600080fd5b506103c561184a565b34801561080a57600080fd5b5061045760215481565b34801561082057600080fd5b506009546001600160a01b0316610409565b34801561083e57600080fd5b5061045761185a565b34801561085357600080fd5b506103c5610862366004613b3c565b61186a565b34801561087357600080fd5b506103dc611877565b34801561088857600080fd5b5061045760145481565b34801561089e57600080fd5b506103c56108ad366004614022565b611886565b3480156108be57600080fd5b506103c56108cd36600461404e565b61194a565b3480156108de57600080fd5b50600b54600c54600d54600e54600f5461091a949392916001600160f81b0381169160ff600160f81b9092048216918181169161010090041687565b604080519788526020880196909652948601939093526001600160f81b03909116606085015215156080840152151560a0830152151560c082015260e00161039c565b34801561096957600080fd5b506103c5610978366004613bcd565b61197c565b34801561098957600080fd5b5061099d610998366004613b3c565b611aad565b60408051931515845260208401929092529082015260600161039c565b3480156109c657600080fd5b506103dc6109d5366004613b3c565b611af9565b6103c56109e8366004614112565b611b61565b3480156109f957600080fd5b506103c5611c2b565b348015610a0e57600080fd5b506103dc610a1d366004613b3c565b611d87565b348015610a2e57600080fd5b50610390610a3d36600461418a565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b348015610a7757600080fd5b506103c5610a86366004613bf9565b611de1565b348015610a9757600080fd5b506103c5610aa6366004613bf9565b611df4565b348015610ab757600080fd5b506103c5610ac6366004613b3c565b611e6d565b348015610ad757600080fd5b50601c546103909060ff1681565b348015610af157600080fd5b5060175461079f90640100000000900463ffffffff1681565b6000610b1582611ebc565b80610b245750610b2482611f27565b92915050565b8033610b35826116df565b6001600160a01b03161480610b5a575033610b4f82610d38565b6001600160a01b0316145b610ba45760405162461bcd60e51b81526020600482015260166024820152753737ba1030b8383937bb32b2103737b91037bbb732b960511b60448201526064015b60405180910390fd5b6000828152601d602052604081205490819003610c3b57601c5460ff16610bfe5760405162461bcd60e51b815260206004820152600e60248201526d1cdd185ada5b99c818db1bdcd95960921b6044820152606401610b9b565b6000838152601d60205260408082204290555184917feebbaa86c348cb664e392b180fd0ff2e1998af9fa833ef69a778cb0b42d3ca2791a2505050565b610c4581426141d9565b6000848152601e602052604081208054909190610c639084906141ec565b90915550506000838152601d60205260408082208290555184917f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b291a25b505050565b606060018054610cb5906141ff565b80601f0160208091040260200160405190810160405280929190818152602001828054610ce1906141ff565b8015610d2e5780601f10610d0357610100808354040283529160200191610d2e565b820191906000526020600020905b815481529060010190602001808311610d1157829003601f168201915b5050505050905090565b6000610d45826004541190565b610da95760405162461bcd60e51b815260206004820152602f60248201527f4552433732315073693a20617070726f76656420717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610b9b565b506000908152600560205260409020546001600160a01b031690565b6000610dd0826116df565b9050806001600160a01b0316836001600160a01b031603610e3f5760405162461bcd60e51b8152602060048201526024808201527f4552433732315073693a20617070726f76616c20746f2063757272656e74206f6044820152633bb732b960e11b6064820152608401610b9b565b336001600160a01b0382161480610e5b5750610e5b8133610a3d565b610ecd5760405162461bcd60e51b815260206004820152603b60248201527f4552433732315073693a20617070726f76652063616c6c6572206973206e6f7460448201527f206f776e6572206e6f7220617070726f76656420666f7220616c6c00000000006064820152608401610b9b565b610ca18383611f4c565b610edf611fba565b610eea601582612014565b5050565b601754640100000000900463ffffffff16808015801590610f0f5750804210155b610f565760405162461bcd60e51b81526020600482015260186024820152771b5a5b9d081a185cc81b9bdd081cdd185c9d1959081e595d60421b6044820152606401610b9b565b610ca1338461ffff16612029565b610f6c611fba565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146110085760405163073e64fd60e21b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604401610b9b565b610eea8282612035565b61101c338261205a565b6110385760405162461bcd60e51b8152600401610b9b90614233565b610ca1838383612149565b60008281526008602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b03169282019290925282916110b85750604080518082019091526007546001600160a01b0381168252600160a01b90046001600160601b031660208201525b6020810151600090612710906110d7906001600160601b031687614287565b6110e191906142b4565b91519350909150505b9250929050565b6110f9611fba565b6000818152601d602052604081205490036111465760405162461bcd60e51b815260206004820152600d60248201526c1a5cc81b9bdd081cdd185ad959609a1b6044820152606401610b9b565b6000818152601d602052604090205461115f90426141d9565b6000828152601e60205260408120805490919061117d9084906141ec565b90915550506000818152601d60205260408082208290555182917f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b291a260405181907f3ebee94e74ea24f711b5876dca724062e18b7b37b6883e686a92f093248a4fcf90600090a250565b6111f0611fba565b80606001516001600160f81b0316816000015110156112515760405162461bcd60e51b815260206004820152601c60248201527f53656c6c65723a2065786365737369766520667265652071756f7461000000006044820152606401610b9b565b601154815110156112a45760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c646044820152606401610b9b565b60135481606001516001600160f81b0316101561130d5760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b6064820152608401610b9b565b600f54610100900460ff161561132a57600160c0820152600b5481525b600f5460ff161561134e57600160a0820152600e546001600160f81b031660608201525b8051600b556020810151600c556040810151600d55606081015160808201511515600160f81b026001600160f81b0390911617600e5560a0810151600f805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b60008060005b600454811015611429576113cf816004541190565b80156113f457506113df816116df565b6001600160a01b0316856001600160a01b0316145b1561141757838203611409579150610b249050565b81611413816142c8565b9250505b80611421816142c8565b9150506113ba565b5060405162461bcd60e51b8152602060048201526024808201527f4552433732315073693a206f776e657220696e646578206f7574206f6620626f604482015263756e647360e01b6064820152608401610b9b565b60006014548361148e9190614287565b9392505050565b61149d611fba565b6017805463ffffffff9283166401000000000267ffffffffffffffff199091169290931691909117919091179055565b6114d5611fba565b6114dd612343565b565b610ca18383836040518060200160405280600081525061194a565b600061150560045490565b82106115615760405162461bcd60e51b815260206004820152602560248201527f4552433732315073693a20676c6f62616c20696e646578206f7574206f6620626044820152646f756e647360d81b6064820152608401610b9b565b6000805b6004548110156115ad5761157a816004541190565b1561159b5783820361158d579392505050565b81611597816142c8565b9250505b806115a5816142c8565b915050611565565b5050919050565b606060006115c183611736565b905060008167ffffffffffffffff8111156115de576115de613c48565b604051908082528060200260200182016040528015611607578160200160208202803683370190505b5090506000805b60045481101561167757856001600160a01b031661162b826116df565b6001600160a01b031603611665578083838151811061164c5761164c6142e1565b602090810291909101015281611661816142c8565b9250505b8061166f816142c8565b91505061160e565b5090949350505050565b611689611fba565b6019610ca182848361433d565b61169e611fba565b601c805460ff1916911515919091179055565b6116b9611fba565b601f805463ffffffff909216600160a01b0263ffffffff60a01b19909216919091179055565b6000806116eb83612398565b509392505050565b8060005b8181101561173057611720848483818110611714576117146142e1565b90506020020135610b2a565b611729816142c8565b90506116f7565b50505050565b60006001600160a01b0382166117a45760405162461bcd60e51b815260206004820152602d60248201527f4552433732315073693a2062616c616e636520717565727920666f722074686560448201526c207a65726f206164647265737360981b6064820152608401610b9b565b6000805b6004548110156117ff576117bd816004541190565b156117ef576117cb816116df565b6001600160a01b0316846001600160a01b0316036117ef576117ec826142c8565b91505b6117f8816142c8565b90506117a8565b5092915050565b61180e611fba565b6114dd6000612431565b611820611fba565b601f805460ff60c01b1916600160c01b179055565b61183d611fba565b601a610ca182848361433d565b611852611fba565b6114dd612483565b600061186560115490565b905090565b611872611fba565b601455565b606060028054610cb5906141ff565b336001600160a01b038316036118de5760405162461bcd60e51b815260206004820152601c60248201527f4552433732315073693a20617070726f766520746f2063616c6c6572000000006044820152606401610b9b565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611954338361205a565b6119705760405162461bcd60e51b8152600401610b9b90614233565b611730848484846124c6565b611984611fba565b61198c6124fb565b600e546001600160f81b03166119b4826119a560135490565b6119af90846141d9565b612548565b915060008211611a065760405162461bcd60e51b815260206004820152601b60248201527f53656c6c65723a20467265652071756f746120657863656564656400000000006044820152606401610b9b565b600b54611a16836119a560115490565b925060008311611a5b5760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b6044820152606401610b9b565b611a6660118461255e565b611a7160138461255e565b611a7d8484600161257b565b80611a8760115490565b1115611a9557611a956143fe565b81611a9f60135490565b1115611730576117306143fe565b6000818152601d6020526040812054819081908015611ad75760019350611ad481426141d9565b92505b6000858152601e6020526040902054611af090846141ec565b93959294505050565b606081611b07816004541190565b611b475760405162461bcd60e51b81526020600482015260116024820152701a5908191bd95cc81b9bdd08195e1a5cdd607a1b6044820152606401610b9b565b611b5883611b53612585565b612594565b91505b50919050565b60175463ffffffff16808015801590611b7a5750804210155b611bc15760405162461bcd60e51b81526020600482015260186024820152771b5a5b9d081a185cc81b9bdd081cdd185c9d1959081e595d60421b6044820152606401610b9b565b604080516bffffffffffffffffffffffff1960608a901b1660208201526001600160e01b031960e088901b166034820152815160188183030181526038909101909152611c14906015908686601b612663565b611c22878761ffff16612029565b50505050505050565b611c33611fba565b601f54600160c01b900460ff1615611c815760405162461bcd60e51b8152602060048201526011602482015270185b1c9958591e481c995c5d595cdd1959607a1b6044820152606401610b9b565b601f546040516305d3b1d360e41b81527f0000000000000000000000000000000000000000000000000000000000000000600482015267ffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016602482015261ffff7f0000000000000000000000000000000000000000000000000000000000000000166044820152600160a01b820463ffffffff166064820152600160848201526001600160a01b0390911690635d3b1d309060a4016020604051808303816000875af1158015611d5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d829190614414565b602155565b606081611d95816004541190565b611dd55760405162461bcd60e51b81526020600482015260116024820152701a5908191bd95cc81b9bdd08195e1a5cdd607a1b6044820152606401610b9b565b611b5883611b53612704565b611de9611fba565b610eea601582612713565b611dfc611fba565b6001600160a01b038116611e615760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b9b565b611e6a81612431565b50565b611e75611fba565b60185415611eb35760405162461bcd60e51b815260206004820152600b60248201526a185b1c9958591e481cd95d60aa1b6044820152606401610b9b565b601855565b5490565b60006001600160e01b031982166380ac58cd60e01b1480611eed57506001600160e01b03198216635b5e139f60e01b145b80611f0857506001600160e01b0319821663780e9d6360e01b145b80610b2457506301ffc9a760e01b6001600160e01b0319831614610b24565b60006001600160e01b0319821663152a902d60e11b1480610b245750610b2482611ebc565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611f81826116df565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6009546001600160a01b031633146114dd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b9b565b600061148e836001600160a01b038416612728565b610eea8282600061281b565b80600081518110612048576120486142e1565b60200260200101516020819055505050565b6000612067826004541190565b6120cb5760405162461bcd60e51b815260206004820152602f60248201527f4552433732315073693a206f70657261746f7220717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610b9b565b60006120d6836116df565b9050806001600160a01b0316846001600160a01b031614806121115750836001600160a01b031661210684610d38565b6001600160a01b0316145b8061214157506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b60008061215583612398565b91509150846001600160a01b0316826001600160a01b0316146121cf5760405162461bcd60e51b815260206004820152602c60248201527f4552433732315073693a207472616e73666572206f6620746f6b656e2074686160448201526b3a1034b9903737ba1037bbb760a11b6064820152608401610b9b565b6001600160a01b0384166122355760405162461bcd60e51b815260206004820152602760248201527f4552433732315073693a207472616e7366657220746f20746865207a65726f206044820152666164647265737360c81b6064820152608401610b9b565b6122428585856001612cd6565b61224d600084611f4c565b600061225a8460016141ec565b600881901c600090815260208190526040902054909150600160ff1b60ff83161c1615801561228a575060045481105b156122c057600081815260036020526040812080546001600160a01b0319166001600160a01b0389161790556122c09082612d46565b600084815260036020526040902080546001600160a01b0319166001600160a01b0387161790558184146122f9576122f9600085612d46565b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b61234b612d72565b6009805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000806123a6836004541190565b6124075760405162461bcd60e51b815260206004820152602c60248201527f4552433732315073693a206f776e657220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610b9b565b61241083612dc2565b6000818152600360205260409020546001600160a01b031694909350915050565b600980546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61248b6124fb565b6009805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861237b3390565b6124d1848484612149565b6124df848484600185612dce565b6117305760405162461bcd60e51b8152600401610b9b9061442d565b600954600160a01b900460ff16156114dd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b9b565b6000818310612557578161148e565b5090919050565b8082600001600082825461257291906141ec565b90915550505050565b610ca18383612f05565b606060198054610cb5906141ff565b606060008251116125d95760405162461bcd60e51b815260206004820152600f60248201526e18985cd9555492481b9bdd081cd95d608a1b6044820152606401610b9b565b60205415806125e85750601854155b1561261e57816125f784612f1f565b604051602001612608929190614482565b6040516020818303038152906040529050610b24565b600061262f84602054601854613020565b90508261263b82612f1f565b60405160200161264c9291906144c8565b604051602081830303815290604052915050610b24565b600061266e856130ac565b60008181526020849052604090205490915060ff16156126df5760405162461bcd60e51b815260206004820152602660248201527f5369676e6174757265436865636b65723a204d65737361676520616c726561646044820152651e481d5cd95960d21b6064820152608401610b9b565b6000818152602083905260409020805460ff1916600117905561233b868286866130b7565b6060601a8054610cb5906141ff565b600061148e836001600160a01b03841661311b565b6000818152600183016020526040812054801561281157600061274c6001836141d9565b8554909150600090612760906001906141d9565b90508181146127c5576000866000018281548110612780576127806142e1565b90600052602060002001549050808760000184815481106127a3576127a36142e1565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806127d6576127d66144f7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b24565b6000915050610b24565b6002600a540361286d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b9b565b6002600a5561287a6124fb565b6040805160e081018252600b548152600c546020820152600d54918101829052600e546001600160f81b038116606083015260ff600160f81b909104811615156080830152600f54808216151560a0840152610100900416151560c082015290600090156128f5576128f0848360400151612548565b6128f7565b835b905060008083608001511561293f5760608401518451612920916001600160f81b0316906141d9565b915061292b60135490565b60115461293891906141d9565b905061294f565b8351915061294c60115490565b90505b61295d836119af83856141d9565b9250600083116129a25760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b6044820152606401610b9b565b602084015115612afe57336001600160a01b0388168114159060009032148015906129d65750326001600160a01b038a1614155b9050612a06858a6040518060400160405280600b81526020016a109d5e595c881b1a5b5a5d60aa1b81525061316a565b94508115612a4057612a3d85336040518060400160405280600c81526020016b14d95b99195c881b1a5b5a5d60a21b81525061316a565b94505b8015612a7857612a7585326040518060400160405280600c81526020016b13dc9a59da5b881b1a5b5a5d60a21b81525061316a565b94505b6001600160a01b03891660009081526012602052604081208054879290612aa09084906141ec565b90915550508115612ad0573360009081526012602052604081208054879290612aca9084906141ec565b90915550505b8015612afb573260009081526012602052604081208054879290612af59084906141ec565b90915550505b50505b6000612b0a848761147e565b905080341015612b6057612b2a612b25633b9aca00836142b4565b612f1f565b604051602001612b3a919061450d565b60408051601f198184030181529082905262461bcd60e51b8252610b9b91600401613ba5565b612b6b60118561255e565b84516011541115612b7e57612b7e6143fe565b612b8a8885600061257b565b8015612bef57601054612ba6906001600160a01b0316826131b6565b60105460408051868152602081018490526001600160a01b03909216917f01f51b99bd1c3cca301836178e5dee13aadfe44eff06dc3ddcbf3c9d058454f8910160405180910390a25b80341115612cc757336000612c0483346141d9565b9050600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114612c54576040519150601f19603f3d011682016040523d82523d6000602084013e612c59565b606091505b5091509150818190612c7e5760405162461bcd60e51b8152600401610b9b9190613ba5565b50836001600160a01b03167fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d84604051612cba91815260200190565b60405180910390a2505050505b50506001600a55505050505050565b816000612ce383836141ec565b90505b8082101561233b576000828152601d602052604090205415612d365760405162461bcd60e51b81526020600482015260096024820152681a5cc81cdd185ad95960ba1b6044820152606401610b9b565b612d3f826142c8565b9150612ce6565b600881901c600090815260209290925260409091208054600160ff1b60ff9093169290921c9091179055565b600954600160a01b900460ff166114dd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b9b565b6000610b2481836132cf565b60006001600160a01b0385163b15612ef857506001835b612def84866141ec565b811015612ef257604051630a85bd0160e11b81526001600160a01b0387169063150b7a0290612e289033908b9086908990600401614552565b6020604051808303816000875af1925050508015612e63575060408051601f3d908101601f19168201909252612e609181019061458f565b60015b612ec0573d808015612e91576040519150601f19603f3d011682016040523d82523d6000602084013e612e96565b606091505b508051600003612eb85760405162461bcd60e51b8152600401610b9b9061442d565b805181602001fd5b828015612edd57506001600160e01b03198116630a85bd0160e11b145b92505080612eea816142c8565b915050612de5565b50612efc565b5060015b95945050505050565b610eea8282604051806020016040528060008152506133c7565b606081600003612f465750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612f705780612f5a816142c8565b9150612f699050600a836142b4565b9150612f4a565b60008167ffffffffffffffff811115612f8b57612f8b613c48565b6040519080825280601f01601f191660200182016040528015612fb5576020820181803683370190505b5090505b841561214157612fca6001836141d9565b9150612fd7600a866145ac565b612fe29060306141ec565b60f81b818381518110612ff757612ff76142e1565b60200101906001600160f81b031916908160001a905350613019600a866142b4565b9450612fb9565b60008184106040518060400160405280601e81526020017f696e707574206973206e6f742077697468696e2074686520646f6d61696e0000815250906130795760405162461bcd60e51b8152600401610b9b9190613ba5565b506000613085836133e2565b60010160ff1690505b61309b858560038461344c565b91508282106116eb5781945061308e565b6000610b2482613545565b6130c384848484613580565b6117305760405162461bcd60e51b815260206004820152602360248201527f5369676e6174757265436865636b65723a20496e76616c6964207369676e617460448201526275726560e81b6064820152608401610b9b565b600081815260018301602052604081205461316257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b24565b506000610b24565b6001600160a01b038216600090815260126020526040812054600c548291613191916141d9565b9050806000036131ac5782604051602001612b3a91906145c0565b612efc8582612548565b804710156132065760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610b9b565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613253576040519150601f19603f3d011682016040523d82523d6000602084013e613258565b606091505b5050905080610ca15760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610b9b565b600881901c60008181526020849052604081205490919060ff808516919082181c8015613311576132ff816135cc565b60ff168203600884901b1793506133be565b6000831161337e5760405162461bcd60e51b815260206004820152603460248201527f4269744d6170733a205468652073657420626974206265666f7265207468652060448201527334b73232bc103237b2b9b713ba1032bc34b9ba1760611b6064820152608401610b9b565b5060001990910160008181526020869052604090205490919080156133b9576133a6816135cc565b60ff0360ff16600884901b1793506133be565b613311565b50505092915050565b6004546133d48484613615565b6124df600085838686612dce565b60006040518061012001604052806101008152602001614662610100913960f87e818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff61342b85613787565b02901c8151811061343e5761343e6142e1565b016020015160f81c92915050565b600060028204808303600180821b60001990810191841b0188841c8216898216865b89811015613519576040805160208082018e9052818301849052825180830384018152606090920190925280519101208260006001841681036134dd5750604080516020808201879052818301859052825180830384018152606090920190925280519101208716851861350b565b5060408051602080820187905281830185905282518083038401815260609092019092528051910120861685185b90945092505060010161346e565b506002890660000361353557941b909317935061214192505050565b931b909217935061214192505050565b60006135518251612f1f565b826040516020016135639291906145f0565b604051602081830303815290604052805190602001209050919050565b6000612efc6135c58585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506137ce92505050565b86906137ea565b60006040518061012001604052806101008152602001614662610100913960f87e818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff61342b8561380c565b600454816136735760405162461bcd60e51b815260206004820152602560248201527f4552433732315073693a207175616e74697479206d7573742062652067726561604482015264074657220360dc1b6064820152608401610b9b565b6001600160a01b0383166136d55760405162461bcd60e51b815260206004820152602360248201527f4552433732315073693a206d696e7420746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610b9b565b6136e26000848385612cd6565b81600460008282546136f491906141ec565b9091555050600081815260036020526040812080546001600160a01b0319166001600160a01b03861617905561372a9082612d46565b805b61373683836141ec565b8110156117305760405181906001600160a01b038616906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48061377f816142c8565b91505061372c565b600080821161379557600080fd5b50608081901c17604081901c17602081901c17601081901c17600881901c17600481901c17600281901c17600181811c909117811c0190565b60008060006137dd8585613824565b915091506116eb81613866565b6001600160a01b0381166000908152600183016020526040812054151561148e565b600080821161381a57600080fd5b5060008190031690565b600080825160410361385a5760208301516040840151606085015160001a61384e87828585613a1c565b945094505050506110ea565b506000905060026110ea565b600081600481111561387a5761387a61464b565b036138825750565b60018160048111156138965761389661464b565b036138e35760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610b9b565b60028160048111156138f7576138f761464b565b036139445760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610b9b565b60038160048111156139585761395861464b565b036139b05760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610b9b565b60048160048111156139c4576139c461464b565b03611e6a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610b9b565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613a535750600090506003613b00565b8460ff16601b14158015613a6b57508460ff16601c14155b15613a7c5750600090506004613b00565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613ad0573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613af957600060019250925050613b00565b9150600090505b94509492505050565b6001600160e01b031981168114611e6a57600080fd5b600060208284031215613b3157600080fd5b813561148e81613b09565b600060208284031215613b4e57600080fd5b5035919050565b60005b83811015613b70578181015183820152602001613b58565b50506000910152565b60008151808452613b91816020860160208601613b55565b601f01601f19169290920160200192915050565b60208152600061148e6020830184613b79565b6001600160a01b0381168114611e6a57600080fd5b60008060408385031215613be057600080fd5b8235613beb81613bb8565b946020939093013593505050565b600060208284031215613c0b57600080fd5b813561148e81613bb8565b803561ffff81168114613c2857600080fd5b919050565b600060208284031215613c3f57600080fd5b61148e82613c16565b634e487b7160e01b600052604160045260246000fd5b60405160e0810167ffffffffffffffff81118282101715613c8157613c81613c48565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613cb057613cb0613c48565b604052919050565b60008060408385031215613ccb57600080fd5b8235915060208084013567ffffffffffffffff80821115613ceb57600080fd5b818601915086601f830112613cff57600080fd5b813581811115613d1157613d11613c48565b8060051b9150613d22848301613c87565b8181529183018401918481019089841115613d3c57600080fd5b938501935b83851015613d5a57843582529385019390850190613d41565b8096505050505050509250929050565b600080600060608486031215613d7f57600080fd5b8335613d8a81613bb8565b92506020840135613d9a81613bb8565b929592945050506040919091013590565b60008060408385031215613dbe57600080fd5b50508035926020909101359150565b80358015158114613c2857600080fd5b600060e08284031215613def57600080fd5b613df7613c5e565b82358152602080840135908201526040808401359082015260608301356001600160f81b0381168114613e2957600080fd5b6060820152613e3a60808401613dcd565b6080820152613e4b60a08401613dcd565b60a0820152613e5c60c08401613dcd565b60c08201529392505050565b803563ffffffff81168114613c2857600080fd5b60008060408385031215613e8f57600080fd5b613e9883613e68565b9150613ea660208401613e68565b90509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613ee757835183529284019291840191600101613ecb565b50909695505050505050565b60008083601f840112613f0557600080fd5b50813567ffffffffffffffff811115613f1d57600080fd5b6020830191508360208285010111156110ea57600080fd5b60008060208385031215613f4857600080fd5b823567ffffffffffffffff811115613f5f57600080fd5b613f6b85828601613ef3565b90969095509350505050565b600060208284031215613f8957600080fd5b61148e82613dcd565b600060208284031215613fa457600080fd5b61148e82613e68565b60008060208385031215613fc057600080fd5b823567ffffffffffffffff80821115613fd857600080fd5b818501915085601f830112613fec57600080fd5b813581811115613ffb57600080fd5b8660208260051b850101111561401057600080fd5b60209290920196919550909350505050565b6000806040838503121561403557600080fd5b823561404081613bb8565b9150613ea660208401613dcd565b6000806000806080858703121561406457600080fd5b843561406f81613bb8565b935060208581013561408081613bb8565b935060408601359250606086013567ffffffffffffffff808211156140a457600080fd5b818801915088601f8301126140b857600080fd5b8135818111156140ca576140ca613c48565b6140dc601f8201601f19168501613c87565b915080825289848285010111156140f257600080fd5b808484018584013760008482840101525080935050505092959194509250565b60008060008060006080868803121561412a57600080fd5b853561413581613bb8565b945061414360208701613c16565b935061415160408701613e68565b9250606086013567ffffffffffffffff81111561416d57600080fd5b61417988828901613ef3565b969995985093965092949392505050565b6000806040838503121561419d57600080fd5b82356141a881613bb8565b915060208301356141b881613bb8565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610b2457610b246141c3565b80820180821115610b2457610b246141c3565b600181811c9082168061421357607f821691505b602082108103611b5b57634e487b7160e01b600052602260045260246000fd5b60208082526034908201527f4552433732315073693a207472616e736665722063616c6c6572206973206e6f6040820152731d081bdddb995c881b9bdc88185c1c1c9bdd995960621b606082015260800190565b8082028115828204841417610b2457610b246141c3565b634e487b7160e01b600052601260045260246000fd5b6000826142c3576142c361429e565b500490565b6000600182016142da576142da6141c3565b5060010190565b634e487b7160e01b600052603260045260246000fd5b601f821115610ca157600081815260208120601f850160051c8101602086101561431e5750805b601f850160051c820191505b8181101561233b5782815560010161432a565b67ffffffffffffffff83111561435557614355613c48565b6143698361436383546141ff565b836142f7565b6000601f84116001811461439d57600085156143855750838201355b600019600387901b1c1916600186901b1783556143f7565b600083815260209020601f19861690835b828110156143ce57868501358255602094850194600190920191016143ae565b50868210156143eb5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b634e487b7160e01b600052600160045260246000fd5b60006020828403121561442657600080fd5b5051919050565b60208082526035908201527f4552433732315073693a207472616e7366657220746f206e6f6e20455243373260408201527418a932b1b2b4bb32b91034b6b83632b6b2b73a32b960591b606082015260800190565b60008351614494818460208801613b55565b6a756e72657665616c65642f60a81b90830190815283516144bc81600b840160208801613b55565b01600b01949350505050565b600083516144da818460208801613b55565b8351908301906144ee818360208801613b55565b01949350505050565b634e487b7160e01b600052603160045260246000fd5b6d029b2b63632b91d1021b7b9ba39960951b81526000825161453681600e850160208701613b55565b64204757656960d81b600e939091019283015250601301919050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061458590830184613b79565b9695505050505050565b6000602082840312156145a157600080fd5b815161148e81613b09565b6000826145bb576145bb61429e565b500690565b67029b2b63632b91d160c51b8152600082516145e3816008850160208701613b55565b9190910160080192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a00000000000081526000835161462881601a850160208801613b55565b83519083019061463f81601a840160208801613b55565b01601a01949350505050565b634e487b7160e01b600052602160045260246000fdfe0001020903110a19042112290b311a3905412245134d2a550c5d32651b6d3a7506264262237d468514804e8d2b95569d0d495ea533a966b11c886eb93bc176c9071727374353637324837e9b47af86c7155181ad4fd18ed32c9096db57d59ee30e2e4a6a5f92a6be3498aae067ddb2eb1d5989b56fd7baf33ca0c2ee77e5caf7ff0810182028303840444c545c646c7425617c847f8c949c48a4a8b087b8c0c816365272829aaec650acd0d28fdad4e22d6991bd97dfdcea58b4d6f29fede4f6fe0f1f2f3f4b5b6b607b8b93a3a7b7bf357199c5abcfd9e168bcdee9b3f1ecf5fd1e3e5a7a8aa2b670c4ced8bbe8f0f4fc3d79a1c3cde7effb78cce6facbf9f8a2646970667358221220de5356b10ee18eefe57cb20d0279f19993e5348f22bb298956821b739f3a68fa64736f6c634300081100330000000000000000000000007f69dc8812cc2e642c19af97f712b2da2033b5610000000000000000000000000a8c4aa7818288fa2c79e47e3d34c0b0ea93312b0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909ff8dedfbfa60af186cf3c830acbc32c05aae823045ae5ea7da1e45fbfaba4f9200000000000000000000000000000000000000000000000000000000000001870000000000000000000000000000000000000000000000000000000000030d40000000000000000000000000000000000000000000000000000000000000000a

Deployed Bytecode

0x60806040526004361061036b5760003560e01c80636ef4f9b5116101c6578063b88d4fde116100f7578063e5d8d0a111610095578063f2fde38b1161006f578063f2fde38b14610a8b578063f615907814610aab578063f856f42b14610acb578063fb54a06b14610ae557600080fd5b8063e5d8d0a114610a02578063e985e9c514610a22578063eb12d61e14610a6b57600080fd5b8063c1027c98116100d1578063c1027c981461097d578063c87b56dd146109ba578063d13dfa63146109da578063e1da26c6146109ed57600080fd5b8063b88d4fde146108b2578063bb69b7ef146108d2578063bf62e21d1461095d57600080fd5b80638d323a8b1161016457806391b7f5ed1161013e57806391b7f5ed1461084757806395d89b4114610867578063a035b1fe1461087c578063a22cb4651461089257600080fd5b80638d323a8b146107fe5780638da5cb5b146108145780639106d7ba1461083257600080fd5b8063792ede4d116101a0578063792ede4d146107825780638158ecee146107b45780638296b01d146107c95780638456cb59146107e957600080fd5b80636ef4f9b51461072d57806370a082311461074d578063715018a61461076d57600080fd5b80632f274bd4116102a05780634f6ccce71161023e578063564892dc11610218578063564892dc146106ae5780635a405c87146106ce5780635c975abb146106ee5780636352211e1461070d57600080fd5b80634f6ccce71461064157806353321c721461066157806355f804b31461068e57600080fd5b80633ec02e141161027a5780633ec02e14146105cc5780633f06b8ab146105ec5780633f4ba83a1461060c57806342842e0e1461062157600080fd5b80632f274bd41461056c5780632f745c591461058c57806338af3eed146105ac57600080fd5b806316755b571161030d5780631fe543e3116102e75780631fe543e3146104cd57806323b872dd146104ed5780632a55205a1461050d5780632e17de781461054c57600080fd5b806316755b571461048557806318160ddd146104985780631c31f710146104ad57600080fd5b8063081812fc11610349578063081812fc146103e9578063095ea7b3146104215780630b747d91146104415780630e316ab71461046557600080fd5b806301ffc9a71461037057806302c1afd9146103a557806306fdde03146103c7575b600080fd5b34801561037c57600080fd5b5061039061038b366004613b1f565b610b0a565b60405190151581526020015b60405180910390f35b3480156103b157600080fd5b506103c56103c0366004613b3c565b610b2a565b005b3480156103d357600080fd5b506103dc610ca6565b60405161039c9190613ba5565b3480156103f557600080fd5b50610409610404366004613b3c565b610d38565b6040516001600160a01b03909116815260200161039c565b34801561042d57600080fd5b506103c561043c366004613bcd565b610dc5565b34801561044d57600080fd5b5061045760205481565b60405190815260200161039c565b34801561047157600080fd5b506103c5610480366004613bf9565b610ed7565b6103c5610493366004613c2d565b610eee565b3480156104a457600080fd5b50600454610457565b3480156104b957600080fd5b506103c56104c8366004613bf9565b610f64565b3480156104d957600080fd5b506103c56104e8366004613cb8565b610f8e565b3480156104f957600080fd5b506103c5610508366004613d6a565b611012565b34801561051957600080fd5b5061052d610528366004613dab565b611043565b604080516001600160a01b03909316835260208301919091520161039c565b34801561055857600080fd5b506103c5610567366004613b3c565b6110f1565b34801561057857600080fd5b506103c5610587366004613ddd565b6111e8565b34801561059857600080fd5b506104576105a7366004613bcd565b6113b4565b3480156105b857600080fd5b50601054610409906001600160a01b031681565b3480156105d857600080fd5b506104576105e7366004613dab565b61147e565b3480156105f857600080fd5b506103c5610607366004613e7c565b611495565b34801561061857600080fd5b506103c56114cd565b34801561062d57600080fd5b506103c561063c366004613d6a565b6114df565b34801561064d57600080fd5b5061045761065c366004613b3c565b6114fa565b34801561066d57600080fd5b5061068161067c366004613bf9565b6115b4565b60405161039c9190613eaf565b34801561069a57600080fd5b506103c56106a9366004613f35565b611681565b3480156106ba57600080fd5b506103c56106c9366004613f77565b611696565b3480156106da57600080fd5b506103c56106e9366004613f92565b6116b1565b3480156106fa57600080fd5b50600954600160a01b900460ff16610390565b34801561071957600080fd5b50610409610728366004613b3c565b6116df565b34801561073957600080fd5b506103c5610748366004613fad565b6116f3565b34801561075957600080fd5b50610457610768366004613bf9565b611736565b34801561077957600080fd5b506103c5611806565b34801561078e57600080fd5b5060175461079f9063ffffffff1681565b60405163ffffffff909116815260200161039c565b3480156107c057600080fd5b506103c5611818565b3480156107d557600080fd5b506103c56107e4366004613f35565b611835565b3480156107f557600080fd5b506103c561184a565b34801561080a57600080fd5b5061045760215481565b34801561082057600080fd5b506009546001600160a01b0316610409565b34801561083e57600080fd5b5061045761185a565b34801561085357600080fd5b506103c5610862366004613b3c565b61186a565b34801561087357600080fd5b506103dc611877565b34801561088857600080fd5b5061045760145481565b34801561089e57600080fd5b506103c56108ad366004614022565b611886565b3480156108be57600080fd5b506103c56108cd36600461404e565b61194a565b3480156108de57600080fd5b50600b54600c54600d54600e54600f5461091a949392916001600160f81b0381169160ff600160f81b9092048216918181169161010090041687565b604080519788526020880196909652948601939093526001600160f81b03909116606085015215156080840152151560a0830152151560c082015260e00161039c565b34801561096957600080fd5b506103c5610978366004613bcd565b61197c565b34801561098957600080fd5b5061099d610998366004613b3c565b611aad565b60408051931515845260208401929092529082015260600161039c565b3480156109c657600080fd5b506103dc6109d5366004613b3c565b611af9565b6103c56109e8366004614112565b611b61565b3480156109f957600080fd5b506103c5611c2b565b348015610a0e57600080fd5b506103dc610a1d366004613b3c565b611d87565b348015610a2e57600080fd5b50610390610a3d36600461418a565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b348015610a7757600080fd5b506103c5610a86366004613bf9565b611de1565b348015610a9757600080fd5b506103c5610aa6366004613bf9565b611df4565b348015610ab757600080fd5b506103c5610ac6366004613b3c565b611e6d565b348015610ad757600080fd5b50601c546103909060ff1681565b348015610af157600080fd5b5060175461079f90640100000000900463ffffffff1681565b6000610b1582611ebc565b80610b245750610b2482611f27565b92915050565b8033610b35826116df565b6001600160a01b03161480610b5a575033610b4f82610d38565b6001600160a01b0316145b610ba45760405162461bcd60e51b81526020600482015260166024820152753737ba1030b8383937bb32b2103737b91037bbb732b960511b60448201526064015b60405180910390fd5b6000828152601d602052604081205490819003610c3b57601c5460ff16610bfe5760405162461bcd60e51b815260206004820152600e60248201526d1cdd185ada5b99c818db1bdcd95960921b6044820152606401610b9b565b6000838152601d60205260408082204290555184917feebbaa86c348cb664e392b180fd0ff2e1998af9fa833ef69a778cb0b42d3ca2791a2505050565b610c4581426141d9565b6000848152601e602052604081208054909190610c639084906141ec565b90915550506000838152601d60205260408082208290555184917f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b291a25b505050565b606060018054610cb5906141ff565b80601f0160208091040260200160405190810160405280929190818152602001828054610ce1906141ff565b8015610d2e5780601f10610d0357610100808354040283529160200191610d2e565b820191906000526020600020905b815481529060010190602001808311610d1157829003601f168201915b5050505050905090565b6000610d45826004541190565b610da95760405162461bcd60e51b815260206004820152602f60248201527f4552433732315073693a20617070726f76656420717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610b9b565b506000908152600560205260409020546001600160a01b031690565b6000610dd0826116df565b9050806001600160a01b0316836001600160a01b031603610e3f5760405162461bcd60e51b8152602060048201526024808201527f4552433732315073693a20617070726f76616c20746f2063757272656e74206f6044820152633bb732b960e11b6064820152608401610b9b565b336001600160a01b0382161480610e5b5750610e5b8133610a3d565b610ecd5760405162461bcd60e51b815260206004820152603b60248201527f4552433732315073693a20617070726f76652063616c6c6572206973206e6f7460448201527f206f776e6572206e6f7220617070726f76656420666f7220616c6c00000000006064820152608401610b9b565b610ca18383611f4c565b610edf611fba565b610eea601582612014565b5050565b601754640100000000900463ffffffff16808015801590610f0f5750804210155b610f565760405162461bcd60e51b81526020600482015260186024820152771b5a5b9d081a185cc81b9bdd081cdd185c9d1959081e595d60421b6044820152606401610b9b565b610ca1338461ffff16612029565b610f6c611fba565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b037f000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e6990916146110085760405163073e64fd60e21b81523360048201526001600160a01b037f000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909166024820152604401610b9b565b610eea8282612035565b61101c338261205a565b6110385760405162461bcd60e51b8152600401610b9b90614233565b610ca1838383612149565b60008281526008602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b03169282019290925282916110b85750604080518082019091526007546001600160a01b0381168252600160a01b90046001600160601b031660208201525b6020810151600090612710906110d7906001600160601b031687614287565b6110e191906142b4565b91519350909150505b9250929050565b6110f9611fba565b6000818152601d602052604081205490036111465760405162461bcd60e51b815260206004820152600d60248201526c1a5cc81b9bdd081cdd185ad959609a1b6044820152606401610b9b565b6000818152601d602052604090205461115f90426141d9565b6000828152601e60205260408120805490919061117d9084906141ec565b90915550506000818152601d60205260408082208290555182917f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b291a260405181907f3ebee94e74ea24f711b5876dca724062e18b7b37b6883e686a92f093248a4fcf90600090a250565b6111f0611fba565b80606001516001600160f81b0316816000015110156112515760405162461bcd60e51b815260206004820152601c60248201527f53656c6c65723a2065786365737369766520667265652071756f7461000000006044820152606401610b9b565b601154815110156112a45760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c646044820152606401610b9b565b60135481606001516001600160f81b0316101561130d5760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b6064820152608401610b9b565b600f54610100900460ff161561132a57600160c0820152600b5481525b600f5460ff161561134e57600160a0820152600e546001600160f81b031660608201525b8051600b556020810151600c556040810151600d55606081015160808201511515600160f81b026001600160f81b0390911617600e5560a0810151600f805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b60008060005b600454811015611429576113cf816004541190565b80156113f457506113df816116df565b6001600160a01b0316856001600160a01b0316145b1561141757838203611409579150610b249050565b81611413816142c8565b9250505b80611421816142c8565b9150506113ba565b5060405162461bcd60e51b8152602060048201526024808201527f4552433732315073693a206f776e657220696e646578206f7574206f6620626f604482015263756e647360e01b6064820152608401610b9b565b60006014548361148e9190614287565b9392505050565b61149d611fba565b6017805463ffffffff9283166401000000000267ffffffffffffffff199091169290931691909117919091179055565b6114d5611fba565b6114dd612343565b565b610ca18383836040518060200160405280600081525061194a565b600061150560045490565b82106115615760405162461bcd60e51b815260206004820152602560248201527f4552433732315073693a20676c6f62616c20696e646578206f7574206f6620626044820152646f756e647360d81b6064820152608401610b9b565b6000805b6004548110156115ad5761157a816004541190565b1561159b5783820361158d579392505050565b81611597816142c8565b9250505b806115a5816142c8565b915050611565565b5050919050565b606060006115c183611736565b905060008167ffffffffffffffff8111156115de576115de613c48565b604051908082528060200260200182016040528015611607578160200160208202803683370190505b5090506000805b60045481101561167757856001600160a01b031661162b826116df565b6001600160a01b031603611665578083838151811061164c5761164c6142e1565b602090810291909101015281611661816142c8565b9250505b8061166f816142c8565b91505061160e565b5090949350505050565b611689611fba565b6019610ca182848361433d565b61169e611fba565b601c805460ff1916911515919091179055565b6116b9611fba565b601f805463ffffffff909216600160a01b0263ffffffff60a01b19909216919091179055565b6000806116eb83612398565b509392505050565b8060005b8181101561173057611720848483818110611714576117146142e1565b90506020020135610b2a565b611729816142c8565b90506116f7565b50505050565b60006001600160a01b0382166117a45760405162461bcd60e51b815260206004820152602d60248201527f4552433732315073693a2062616c616e636520717565727920666f722074686560448201526c207a65726f206164647265737360981b6064820152608401610b9b565b6000805b6004548110156117ff576117bd816004541190565b156117ef576117cb816116df565b6001600160a01b0316846001600160a01b0316036117ef576117ec826142c8565b91505b6117f8816142c8565b90506117a8565b5092915050565b61180e611fba565b6114dd6000612431565b611820611fba565b601f805460ff60c01b1916600160c01b179055565b61183d611fba565b601a610ca182848361433d565b611852611fba565b6114dd612483565b600061186560115490565b905090565b611872611fba565b601455565b606060028054610cb5906141ff565b336001600160a01b038316036118de5760405162461bcd60e51b815260206004820152601c60248201527f4552433732315073693a20617070726f766520746f2063616c6c6572000000006044820152606401610b9b565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611954338361205a565b6119705760405162461bcd60e51b8152600401610b9b90614233565b611730848484846124c6565b611984611fba565b61198c6124fb565b600e546001600160f81b03166119b4826119a560135490565b6119af90846141d9565b612548565b915060008211611a065760405162461bcd60e51b815260206004820152601b60248201527f53656c6c65723a20467265652071756f746120657863656564656400000000006044820152606401610b9b565b600b54611a16836119a560115490565b925060008311611a5b5760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b6044820152606401610b9b565b611a6660118461255e565b611a7160138461255e565b611a7d8484600161257b565b80611a8760115490565b1115611a9557611a956143fe565b81611a9f60135490565b1115611730576117306143fe565b6000818152601d6020526040812054819081908015611ad75760019350611ad481426141d9565b92505b6000858152601e6020526040902054611af090846141ec565b93959294505050565b606081611b07816004541190565b611b475760405162461bcd60e51b81526020600482015260116024820152701a5908191bd95cc81b9bdd08195e1a5cdd607a1b6044820152606401610b9b565b611b5883611b53612585565b612594565b91505b50919050565b60175463ffffffff16808015801590611b7a5750804210155b611bc15760405162461bcd60e51b81526020600482015260186024820152771b5a5b9d081a185cc81b9bdd081cdd185c9d1959081e595d60421b6044820152606401610b9b565b604080516bffffffffffffffffffffffff1960608a901b1660208201526001600160e01b031960e088901b166034820152815160188183030181526038909101909152611c14906015908686601b612663565b611c22878761ffff16612029565b50505050505050565b611c33611fba565b601f54600160c01b900460ff1615611c815760405162461bcd60e51b8152602060048201526011602482015270185b1c9958591e481c995c5d595cdd1959607a1b6044820152606401610b9b565b601f546040516305d3b1d360e41b81527fff8dedfbfa60af186cf3c830acbc32c05aae823045ae5ea7da1e45fbfaba4f92600482015267ffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000018716602482015261ffff7f000000000000000000000000000000000000000000000000000000000000000a166044820152600160a01b820463ffffffff166064820152600160848201526001600160a01b0390911690635d3b1d309060a4016020604051808303816000875af1158015611d5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d829190614414565b602155565b606081611d95816004541190565b611dd55760405162461bcd60e51b81526020600482015260116024820152701a5908191bd95cc81b9bdd08195e1a5cdd607a1b6044820152606401610b9b565b611b5883611b53612704565b611de9611fba565b610eea601582612713565b611dfc611fba565b6001600160a01b038116611e615760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b9b565b611e6a81612431565b50565b611e75611fba565b60185415611eb35760405162461bcd60e51b815260206004820152600b60248201526a185b1c9958591e481cd95d60aa1b6044820152606401610b9b565b601855565b5490565b60006001600160e01b031982166380ac58cd60e01b1480611eed57506001600160e01b03198216635b5e139f60e01b145b80611f0857506001600160e01b0319821663780e9d6360e01b145b80610b2457506301ffc9a760e01b6001600160e01b0319831614610b24565b60006001600160e01b0319821663152a902d60e11b1480610b245750610b2482611ebc565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611f81826116df565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6009546001600160a01b031633146114dd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b9b565b600061148e836001600160a01b038416612728565b610eea8282600061281b565b80600081518110612048576120486142e1565b60200260200101516020819055505050565b6000612067826004541190565b6120cb5760405162461bcd60e51b815260206004820152602f60248201527f4552433732315073693a206f70657261746f7220717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610b9b565b60006120d6836116df565b9050806001600160a01b0316846001600160a01b031614806121115750836001600160a01b031661210684610d38565b6001600160a01b0316145b8061214157506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b60008061215583612398565b91509150846001600160a01b0316826001600160a01b0316146121cf5760405162461bcd60e51b815260206004820152602c60248201527f4552433732315073693a207472616e73666572206f6620746f6b656e2074686160448201526b3a1034b9903737ba1037bbb760a11b6064820152608401610b9b565b6001600160a01b0384166122355760405162461bcd60e51b815260206004820152602760248201527f4552433732315073693a207472616e7366657220746f20746865207a65726f206044820152666164647265737360c81b6064820152608401610b9b565b6122428585856001612cd6565b61224d600084611f4c565b600061225a8460016141ec565b600881901c600090815260208190526040902054909150600160ff1b60ff83161c1615801561228a575060045481105b156122c057600081815260036020526040812080546001600160a01b0319166001600160a01b0389161790556122c09082612d46565b600084815260036020526040902080546001600160a01b0319166001600160a01b0387161790558184146122f9576122f9600085612d46565b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b61234b612d72565b6009805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000806123a6836004541190565b6124075760405162461bcd60e51b815260206004820152602c60248201527f4552433732315073693a206f776e657220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610b9b565b61241083612dc2565b6000818152600360205260409020546001600160a01b031694909350915050565b600980546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61248b6124fb565b6009805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861237b3390565b6124d1848484612149565b6124df848484600185612dce565b6117305760405162461bcd60e51b8152600401610b9b9061442d565b600954600160a01b900460ff16156114dd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b9b565b6000818310612557578161148e565b5090919050565b8082600001600082825461257291906141ec565b90915550505050565b610ca18383612f05565b606060198054610cb5906141ff565b606060008251116125d95760405162461bcd60e51b815260206004820152600f60248201526e18985cd9555492481b9bdd081cd95d608a1b6044820152606401610b9b565b60205415806125e85750601854155b1561261e57816125f784612f1f565b604051602001612608929190614482565b6040516020818303038152906040529050610b24565b600061262f84602054601854613020565b90508261263b82612f1f565b60405160200161264c9291906144c8565b604051602081830303815290604052915050610b24565b600061266e856130ac565b60008181526020849052604090205490915060ff16156126df5760405162461bcd60e51b815260206004820152602660248201527f5369676e6174757265436865636b65723a204d65737361676520616c726561646044820152651e481d5cd95960d21b6064820152608401610b9b565b6000818152602083905260409020805460ff1916600117905561233b868286866130b7565b6060601a8054610cb5906141ff565b600061148e836001600160a01b03841661311b565b6000818152600183016020526040812054801561281157600061274c6001836141d9565b8554909150600090612760906001906141d9565b90508181146127c5576000866000018281548110612780576127806142e1565b90600052602060002001549050808760000184815481106127a3576127a36142e1565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806127d6576127d66144f7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b24565b6000915050610b24565b6002600a540361286d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b9b565b6002600a5561287a6124fb565b6040805160e081018252600b548152600c546020820152600d54918101829052600e546001600160f81b038116606083015260ff600160f81b909104811615156080830152600f54808216151560a0840152610100900416151560c082015290600090156128f5576128f0848360400151612548565b6128f7565b835b905060008083608001511561293f5760608401518451612920916001600160f81b0316906141d9565b915061292b60135490565b60115461293891906141d9565b905061294f565b8351915061294c60115490565b90505b61295d836119af83856141d9565b9250600083116129a25760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b6044820152606401610b9b565b602084015115612afe57336001600160a01b0388168114159060009032148015906129d65750326001600160a01b038a1614155b9050612a06858a6040518060400160405280600b81526020016a109d5e595c881b1a5b5a5d60aa1b81525061316a565b94508115612a4057612a3d85336040518060400160405280600c81526020016b14d95b99195c881b1a5b5a5d60a21b81525061316a565b94505b8015612a7857612a7585326040518060400160405280600c81526020016b13dc9a59da5b881b1a5b5a5d60a21b81525061316a565b94505b6001600160a01b03891660009081526012602052604081208054879290612aa09084906141ec565b90915550508115612ad0573360009081526012602052604081208054879290612aca9084906141ec565b90915550505b8015612afb573260009081526012602052604081208054879290612af59084906141ec565b90915550505b50505b6000612b0a848761147e565b905080341015612b6057612b2a612b25633b9aca00836142b4565b612f1f565b604051602001612b3a919061450d565b60408051601f198184030181529082905262461bcd60e51b8252610b9b91600401613ba5565b612b6b60118561255e565b84516011541115612b7e57612b7e6143fe565b612b8a8885600061257b565b8015612bef57601054612ba6906001600160a01b0316826131b6565b60105460408051868152602081018490526001600160a01b03909216917f01f51b99bd1c3cca301836178e5dee13aadfe44eff06dc3ddcbf3c9d058454f8910160405180910390a25b80341115612cc757336000612c0483346141d9565b9050600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114612c54576040519150601f19603f3d011682016040523d82523d6000602084013e612c59565b606091505b5091509150818190612c7e5760405162461bcd60e51b8152600401610b9b9190613ba5565b50836001600160a01b03167fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d84604051612cba91815260200190565b60405180910390a2505050505b50506001600a55505050505050565b816000612ce383836141ec565b90505b8082101561233b576000828152601d602052604090205415612d365760405162461bcd60e51b81526020600482015260096024820152681a5cc81cdd185ad95960ba1b6044820152606401610b9b565b612d3f826142c8565b9150612ce6565b600881901c600090815260209290925260409091208054600160ff1b60ff9093169290921c9091179055565b600954600160a01b900460ff166114dd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b9b565b6000610b2481836132cf565b60006001600160a01b0385163b15612ef857506001835b612def84866141ec565b811015612ef257604051630a85bd0160e11b81526001600160a01b0387169063150b7a0290612e289033908b9086908990600401614552565b6020604051808303816000875af1925050508015612e63575060408051601f3d908101601f19168201909252612e609181019061458f565b60015b612ec0573d808015612e91576040519150601f19603f3d011682016040523d82523d6000602084013e612e96565b606091505b508051600003612eb85760405162461bcd60e51b8152600401610b9b9061442d565b805181602001fd5b828015612edd57506001600160e01b03198116630a85bd0160e11b145b92505080612eea816142c8565b915050612de5565b50612efc565b5060015b95945050505050565b610eea8282604051806020016040528060008152506133c7565b606081600003612f465750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612f705780612f5a816142c8565b9150612f699050600a836142b4565b9150612f4a565b60008167ffffffffffffffff811115612f8b57612f8b613c48565b6040519080825280601f01601f191660200182016040528015612fb5576020820181803683370190505b5090505b841561214157612fca6001836141d9565b9150612fd7600a866145ac565b612fe29060306141ec565b60f81b818381518110612ff757612ff76142e1565b60200101906001600160f81b031916908160001a905350613019600a866142b4565b9450612fb9565b60008184106040518060400160405280601e81526020017f696e707574206973206e6f742077697468696e2074686520646f6d61696e0000815250906130795760405162461bcd60e51b8152600401610b9b9190613ba5565b506000613085836133e2565b60010160ff1690505b61309b858560038461344c565b91508282106116eb5781945061308e565b6000610b2482613545565b6130c384848484613580565b6117305760405162461bcd60e51b815260206004820152602360248201527f5369676e6174757265436865636b65723a20496e76616c6964207369676e617460448201526275726560e81b6064820152608401610b9b565b600081815260018301602052604081205461316257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b24565b506000610b24565b6001600160a01b038216600090815260126020526040812054600c548291613191916141d9565b9050806000036131ac5782604051602001612b3a91906145c0565b612efc8582612548565b804710156132065760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610b9b565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613253576040519150601f19603f3d011682016040523d82523d6000602084013e613258565b606091505b5050905080610ca15760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610b9b565b600881901c60008181526020849052604081205490919060ff808516919082181c8015613311576132ff816135cc565b60ff168203600884901b1793506133be565b6000831161337e5760405162461bcd60e51b815260206004820152603460248201527f4269744d6170733a205468652073657420626974206265666f7265207468652060448201527334b73232bc103237b2b9b713ba1032bc34b9ba1760611b6064820152608401610b9b565b5060001990910160008181526020869052604090205490919080156133b9576133a6816135cc565b60ff0360ff16600884901b1793506133be565b613311565b50505092915050565b6004546133d48484613615565b6124df600085838686612dce565b60006040518061012001604052806101008152602001614662610100913960f87e818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff61342b85613787565b02901c8151811061343e5761343e6142e1565b016020015160f81c92915050565b600060028204808303600180821b60001990810191841b0188841c8216898216865b89811015613519576040805160208082018e9052818301849052825180830384018152606090920190925280519101208260006001841681036134dd5750604080516020808201879052818301859052825180830384018152606090920190925280519101208716851861350b565b5060408051602080820187905281830185905282518083038401815260609092019092528051910120861685185b90945092505060010161346e565b506002890660000361353557941b909317935061214192505050565b931b909217935061214192505050565b60006135518251612f1f565b826040516020016135639291906145f0565b604051602081830303815290604052805190602001209050919050565b6000612efc6135c58585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506137ce92505050565b86906137ea565b60006040518061012001604052806101008152602001614662610100913960f87e818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff61342b8561380c565b600454816136735760405162461bcd60e51b815260206004820152602560248201527f4552433732315073693a207175616e74697479206d7573742062652067726561604482015264074657220360dc1b6064820152608401610b9b565b6001600160a01b0383166136d55760405162461bcd60e51b815260206004820152602360248201527f4552433732315073693a206d696e7420746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610b9b565b6136e26000848385612cd6565b81600460008282546136f491906141ec565b9091555050600081815260036020526040812080546001600160a01b0319166001600160a01b03861617905561372a9082612d46565b805b61373683836141ec565b8110156117305760405181906001600160a01b038616906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48061377f816142c8565b91505061372c565b600080821161379557600080fd5b50608081901c17604081901c17602081901c17601081901c17600881901c17600481901c17600281901c17600181811c909117811c0190565b60008060006137dd8585613824565b915091506116eb81613866565b6001600160a01b0381166000908152600183016020526040812054151561148e565b600080821161381a57600080fd5b5060008190031690565b600080825160410361385a5760208301516040840151606085015160001a61384e87828585613a1c565b945094505050506110ea565b506000905060026110ea565b600081600481111561387a5761387a61464b565b036138825750565b60018160048111156138965761389661464b565b036138e35760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610b9b565b60028160048111156138f7576138f761464b565b036139445760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610b9b565b60038160048111156139585761395861464b565b036139b05760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610b9b565b60048160048111156139c4576139c461464b565b03611e6a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610b9b565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613a535750600090506003613b00565b8460ff16601b14158015613a6b57508460ff16601c14155b15613a7c5750600090506004613b00565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613ad0573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613af957600060019250925050613b00565b9150600090505b94509492505050565b6001600160e01b031981168114611e6a57600080fd5b600060208284031215613b3157600080fd5b813561148e81613b09565b600060208284031215613b4e57600080fd5b5035919050565b60005b83811015613b70578181015183820152602001613b58565b50506000910152565b60008151808452613b91816020860160208601613b55565b601f01601f19169290920160200192915050565b60208152600061148e6020830184613b79565b6001600160a01b0381168114611e6a57600080fd5b60008060408385031215613be057600080fd5b8235613beb81613bb8565b946020939093013593505050565b600060208284031215613c0b57600080fd5b813561148e81613bb8565b803561ffff81168114613c2857600080fd5b919050565b600060208284031215613c3f57600080fd5b61148e82613c16565b634e487b7160e01b600052604160045260246000fd5b60405160e0810167ffffffffffffffff81118282101715613c8157613c81613c48565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613cb057613cb0613c48565b604052919050565b60008060408385031215613ccb57600080fd5b8235915060208084013567ffffffffffffffff80821115613ceb57600080fd5b818601915086601f830112613cff57600080fd5b813581811115613d1157613d11613c48565b8060051b9150613d22848301613c87565b8181529183018401918481019089841115613d3c57600080fd5b938501935b83851015613d5a57843582529385019390850190613d41565b8096505050505050509250929050565b600080600060608486031215613d7f57600080fd5b8335613d8a81613bb8565b92506020840135613d9a81613bb8565b929592945050506040919091013590565b60008060408385031215613dbe57600080fd5b50508035926020909101359150565b80358015158114613c2857600080fd5b600060e08284031215613def57600080fd5b613df7613c5e565b82358152602080840135908201526040808401359082015260608301356001600160f81b0381168114613e2957600080fd5b6060820152613e3a60808401613dcd565b6080820152613e4b60a08401613dcd565b60a0820152613e5c60c08401613dcd565b60c08201529392505050565b803563ffffffff81168114613c2857600080fd5b60008060408385031215613e8f57600080fd5b613e9883613e68565b9150613ea660208401613e68565b90509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613ee757835183529284019291840191600101613ecb565b50909695505050505050565b60008083601f840112613f0557600080fd5b50813567ffffffffffffffff811115613f1d57600080fd5b6020830191508360208285010111156110ea57600080fd5b60008060208385031215613f4857600080fd5b823567ffffffffffffffff811115613f5f57600080fd5b613f6b85828601613ef3565b90969095509350505050565b600060208284031215613f8957600080fd5b61148e82613dcd565b600060208284031215613fa457600080fd5b61148e82613e68565b60008060208385031215613fc057600080fd5b823567ffffffffffffffff80821115613fd857600080fd5b818501915085601f830112613fec57600080fd5b813581811115613ffb57600080fd5b8660208260051b850101111561401057600080fd5b60209290920196919550909350505050565b6000806040838503121561403557600080fd5b823561404081613bb8565b9150613ea660208401613dcd565b6000806000806080858703121561406457600080fd5b843561406f81613bb8565b935060208581013561408081613bb8565b935060408601359250606086013567ffffffffffffffff808211156140a457600080fd5b818801915088601f8301126140b857600080fd5b8135818111156140ca576140ca613c48565b6140dc601f8201601f19168501613c87565b915080825289848285010111156140f257600080fd5b808484018584013760008482840101525080935050505092959194509250565b60008060008060006080868803121561412a57600080fd5b853561413581613bb8565b945061414360208701613c16565b935061415160408701613e68565b9250606086013567ffffffffffffffff81111561416d57600080fd5b61417988828901613ef3565b969995985093965092949392505050565b6000806040838503121561419d57600080fd5b82356141a881613bb8565b915060208301356141b881613bb8565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610b2457610b246141c3565b80820180821115610b2457610b246141c3565b600181811c9082168061421357607f821691505b602082108103611b5b57634e487b7160e01b600052602260045260246000fd5b60208082526034908201527f4552433732315073693a207472616e736665722063616c6c6572206973206e6f6040820152731d081bdddb995c881b9bdc88185c1c1c9bdd995960621b606082015260800190565b8082028115828204841417610b2457610b246141c3565b634e487b7160e01b600052601260045260246000fd5b6000826142c3576142c361429e565b500490565b6000600182016142da576142da6141c3565b5060010190565b634e487b7160e01b600052603260045260246000fd5b601f821115610ca157600081815260208120601f850160051c8101602086101561431e5750805b601f850160051c820191505b8181101561233b5782815560010161432a565b67ffffffffffffffff83111561435557614355613c48565b6143698361436383546141ff565b836142f7565b6000601f84116001811461439d57600085156143855750838201355b600019600387901b1c1916600186901b1783556143f7565b600083815260209020601f19861690835b828110156143ce57868501358255602094850194600190920191016143ae565b50868210156143eb5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b634e487b7160e01b600052600160045260246000fd5b60006020828403121561442657600080fd5b5051919050565b60208082526035908201527f4552433732315073693a207472616e7366657220746f206e6f6e20455243373260408201527418a932b1b2b4bb32b91034b6b83632b6b2b73a32b960591b606082015260800190565b60008351614494818460208801613b55565b6a756e72657665616c65642f60a81b90830190815283516144bc81600b840160208801613b55565b01600b01949350505050565b600083516144da818460208801613b55565b8351908301906144ee818360208801613b55565b01949350505050565b634e487b7160e01b600052603160045260246000fd5b6d029b2b63632b91d1021b7b9ba39960951b81526000825161453681600e850160208701613b55565b64204757656960d81b600e939091019283015250601301919050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061458590830184613b79565b9695505050505050565b6000602082840312156145a157600080fd5b815161148e81613b09565b6000826145bb576145bb61429e565b500690565b67029b2b63632b91d160c51b8152600082516145e3816008850160208701613b55565b9190910160080192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a00000000000081526000835161462881601a850160208801613b55565b83519083019061463f81601a840160208801613b55565b01601a01949350505050565b634e487b7160e01b600052602160045260246000fdfe0001020903110a19042112290b311a3905412245134d2a550c5d32651b6d3a7506264262237d468514804e8d2b95569d0d495ea533a966b11c886eb93bc176c9071727374353637324837e9b47af86c7155181ad4fd18ed32c9096db57d59ee30e2e4a6a5f92a6be3498aae067ddb2eb1d5989b56fd7baf33ca0c2ee77e5caf7ff0810182028303840444c545c646c7425617c847f8c949c48a4a8b087b8c0c816365272829aaec650acd0d28fdad4e22d6991bd97dfdcea58b4d6f29fede4f6fe0f1f2f3f4b5b6b607b8b93a3a7b7bf357199c5abcfd9e168bcdee9b3f1ecf5fd1e3e5a7a8aa2b670c4ced8bbe8f0f4fc3d79a1c3cde7effb78cce6facbf9f8a2646970667358221220de5356b10ee18eefe57cb20d0279f19993e5348f22bb298956821b739f3a68fa64736f6c63430008110033

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

0000000000000000000000007f69dc8812cc2e642c19af97f712b2da2033b5610000000000000000000000000a8c4aa7818288fa2c79e47e3d34c0b0ea93312b0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909ff8dedfbfa60af186cf3c830acbc32c05aae823045ae5ea7da1e45fbfaba4f9200000000000000000000000000000000000000000000000000000000000001870000000000000000000000000000000000000000000000000000000000030d40000000000000000000000000000000000000000000000000000000000000000a

-----Decoded View---------------
Arg [0] : _beneficiary (address): 0x7F69dC8812Cc2E642c19af97f712b2Da2033B561
Arg [1] : _royaltyReceiver (address): 0x0a8c4aa7818288FA2C79e47e3D34C0B0eA93312B
Arg [2] : _initialInventory (uint256): 3000
Arg [3] : _vrfCoordinator (address): 0x271682DEB8C4E0901D1a1550aD2e64D568E69909
Arg [4] : _vrfKeyHash (bytes32): 0xff8dedfbfa60af186cf3c830acbc32c05aae823045ae5ea7da1e45fbfaba4f92
Arg [5] : _vrfSubscriptionId (uint64): 391
Arg [6] : _vrfCallbackGasLimit (uint32): 200000
Arg [7] : _vrfRequestConfirmations (uint16): 10

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000007f69dc8812cc2e642c19af97f712b2da2033b561
Arg [1] : 0000000000000000000000000a8c4aa7818288fa2c79e47e3d34c0b0ea93312b
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000bb8
Arg [3] : 000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909
Arg [4] : ff8dedfbfa60af186cf3c830acbc32c05aae823045ae5ea7da1e45fbfaba4f92
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000187
Arg [6] : 0000000000000000000000000000000000000000000000000000000000030d40
Arg [7] : 000000000000000000000000000000000000000000000000000000000000000a


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.