MATIC Price: $0.35641 (-20.98%)
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Token Holdings

Transaction Hash
Method
Block
From
To
0x712b373663fb8a29e32d95af16e66afc569de95de7f6445175963e6fe82469f7 -(pending)2024-08-05 11:50:064 secs ago1722858606IN
0xd658843c...e13f935B5
0 MATIC(Pending)(Pending)
Associate One Ti...602214052024-08-05 11:49:5218 secs ago1722858592IN
0xd658843c...e13f935B5
0 MATIC0.00710636148.78078944
Reveal Mystery B...602214042024-08-05 11:49:5020 secs ago1722858590IN
0xd658843c...e13f935B5
3 MATIC0.05846517293.97950143
Reveal Mystery B...602214012024-08-05 11:49:4426 secs ago1722858584IN
0xd658843c...e13f935B5
3 MATIC0.023865120.00000008
Reveal Mystery B...602214012024-08-05 11:49:4426 secs ago1722858584IN
0xd658843c...e13f935B5
3 MATIC0.023865120.0000002
Associate One Ti...602213982024-08-05 11:49:3832 secs ago1722858578IN
0xd658843c...e13f935B5
0 MATIC0.00862328180.53944013
Reveal Mystery B...602213982024-08-05 11:49:3832 secs ago1722858578IN
0xd658843c...e13f935B5
3 MATIC0.05846517293.97950143
Reveal Mystery B...602213972024-08-05 11:49:3634 secs ago1722858576IN
0xd658843c...e13f935B5
3 MATIC0.05597457281.45606158
Reveal Mystery B...602213972024-08-05 11:49:3634 secs ago1722858576IN
0xd658843c...e13f935B5
3 MATIC0.05717111287.47260505
Associate One Ti...602213962024-08-05 11:49:3436 secs ago1722858574IN
0xd658843c...e13f935B5
0 MATIC0.00747697156.53988921
Associate One Ti...602213962024-08-05 11:49:3436 secs ago1722858574IN
0xd658843c...e13f935B5
0 MATIC0.00747697156.53988921
Associate One Ti...602213932024-08-05 11:49:2842 secs ago1722858568IN
0xd658843c...e13f935B5
0 MATIC0.00843363176.5687983
Reveal Mystery B...602213932024-08-05 11:49:2842 secs ago1722858568IN
0xd658843c...e13f935B5
3 MATIC0.04232659212.83015237
Reveal Mystery B...602213932024-08-05 11:49:2842 secs ago1722858568IN
0xd658843c...e13f935B5
3 MATIC0.04535449228.05528949
Reveal Mystery B...602213902024-08-05 11:49:2050 secs ago1722858560IN
0xd658843c...e13f935B5
3 MATIC0.02494766125.44396864
Reveal Mystery B...602213902024-08-05 11:49:2050 secs ago1722858560IN
0xd658843c...e13f935B5
3 MATIC0.03079426154.84233246
Associate One Ti...602213882024-08-05 11:49:1654 secs ago1722858556IN
0xd658843c...e13f935B5
0 MATIC0.0077091161.39986887
Reveal Mystery B...602213862024-08-05 11:49:1258 secs ago1722858552IN
0xd658843c...e13f935B5
3 MATIC0.04005622201.41407269
Reveal Mystery B...602213842024-08-05 11:49:081 min ago1722858548IN
0xd658843c...e13f935B5
3 MATIC0.05260264264.5010661
Associate One Ti...602213832024-08-05 11:49:061 min ago1722858546IN
0xd658843c...e13f935B5
0 MATIC0.00836895175.21480446
Associate One Ti...602213832024-08-05 11:49:061 min ago1722858546IN
0xd658843c...e13f935B5
0 MATIC0.00836895175.21480446
Associate One Ti...602213822024-08-05 11:49:041 min ago1722858544IN
0xd658843c...e13f935B5
0 MATIC0.00815476170.73027448
Associate One Ti...602213812024-08-05 11:49:021 min ago1722858542IN
0xd658843c...e13f935B5
0 MATIC0.00827017173.14662629
Associate One Ti...602213772024-08-05 11:48:541 min ago1722858534IN
0xd658843c...e13f935B5
0 MATIC0.00931554195.03279813
Associate One Ti...602213732024-08-05 11:48:441 min ago1722858524IN
0xd658843c...e13f935B5
0 MATIC0.00859873180.02539158
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
602214042024-08-05 11:49:5020 secs ago1722858590
0xd658843c...e13f935B5
3 MATIC
602214012024-08-05 11:49:4426 secs ago1722858584
0xd658843c...e13f935B5
3 MATIC
602214012024-08-05 11:49:4426 secs ago1722858584
0xd658843c...e13f935B5
3 MATIC
602213982024-08-05 11:49:3832 secs ago1722858578
0xd658843c...e13f935B5
3 MATIC
602213972024-08-05 11:49:3634 secs ago1722858576
0xd658843c...e13f935B5
3 MATIC
602213972024-08-05 11:49:3634 secs ago1722858576
0xd658843c...e13f935B5
3 MATIC
602213932024-08-05 11:49:2842 secs ago1722858568
0xd658843c...e13f935B5
3 MATIC
602213932024-08-05 11:49:2842 secs ago1722858568
0xd658843c...e13f935B5
3 MATIC
602213902024-08-05 11:49:2050 secs ago1722858560
0xd658843c...e13f935B5
3 MATIC
602213902024-08-05 11:49:2050 secs ago1722858560
0xd658843c...e13f935B5
3 MATIC
602213862024-08-05 11:49:1258 secs ago1722858552
0xd658843c...e13f935B5
3 MATIC
602213842024-08-05 11:49:081 min ago1722858548
0xd658843c...e13f935B5
3 MATIC
602213702024-08-05 11:48:381 min ago1722858518
0xd658843c...e13f935B5
3 MATIC
602213652024-08-05 11:48:281 min ago1722858508
0xd658843c...e13f935B5
3 MATIC
602213612024-08-05 11:48:201 min ago1722858500
0xd658843c...e13f935B5
3 MATIC
602213602024-08-05 11:48:181 min ago1722858498
0xd658843c...e13f935B5
3 MATIC
602213602024-08-05 11:48:181 min ago1722858498
0xd658843c...e13f935B5
3 MATIC
602213562024-08-05 11:48:082 mins ago1722858488
0xd658843c...e13f935B5
3 MATIC
602213552024-08-05 11:48:062 mins ago1722858486
0xd658843c...e13f935B5
3 MATIC
602213542024-08-05 11:48:042 mins ago1722858484
0xd658843c...e13f935B5
3 MATIC
602213532024-08-05 11:48:022 mins ago1722858482
0xd658843c...e13f935B5
3 MATIC
602213512024-08-05 11:47:582 mins ago1722858478
0xd658843c...e13f935B5
3 MATIC
602213502024-08-05 11:47:562 mins ago1722858476
0xd658843c...e13f935B5
3 MATIC
602213452024-08-05 11:47:462 mins ago1722858466
0xd658843c...e13f935B5
3 MATIC
602213412024-08-05 11:47:362 mins ago1722858456
0xd658843c...e13f935B5
3 MATIC
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MysteryBox

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 32 : MysteryBox.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;

import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
import "@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

/// @author EARN'M Loyalty Ecosystem - EARN'M Copyright ©
/// @title MysteryBox
/// @notice This contract is used to redeem Mystery Boxes ERC1155 tokens and claim the rewards of the Mystery Boxes ERC1155 tokens.
/// @notice This contract uses Chainlink VRF to generate random numbers and Chainlink external adapters to make API calls.
contract MysteryBox is ChainlinkClient, VRFConsumerBaseV2, ConfirmedOwner, ReentrancyGuard, ERC1155 {
    using SafeERC20 for IERC20;
    using Chainlink for Chainlink.Request;

    /// @notice Private immutable variables
    VRFCoordinatorV2Interface private immutable COORDINATOR;
    IERC20 private immutable EARNM;
    IERC20 private immutable LINK;
    uint64 private immutable SUBSCRIPTION_ID;
    bytes32 private immutable KEY_HASH;

    /// @notice Constants - Chainlink
    uint32 private constant CALLBACK_GAS_LIMIT = 1_000_000;
    uint8 private constant REQUEST_CONFIRMATIONS = 30;
    uint8 private constant NUM_WORDS = 1;
    
    /// @notice Constants - MysteryBox
    uint256 private constant EARNM_DECIMALS = 18;
    uint256 internal constant MAX_BOX_AMOUNT = 100;
    uint256 private constant MAX_BATCHES_AMOUNT = 1000;
    uint256 private constant MAX_MINT_FEE = 10 ether;

    /// @notice Constants - Tiers
    uint256 internal constant TIER_IDS_LENGTH = 6;

    /// @notice Constants - Tier EARNM claim tokens per box
    uint256 private constant TIER_6_TOKENS = 500_000;
    uint256 private constant TIER_5_TOKENS = 500_00;
    uint256 private constant TIER_4_TOKENS = 5000;
    uint256 private constant TIER_3_TOKENS = 500;
    uint256 private constant TIER_2_TOKENS = 5;
    // tier 1 (common) gives 2.5 tokens, taken care of in relevant function

    /// @notice Constants - Tier max boxes
    uint256 private constant TIER_6_MAX_BOXES = 1;
    uint256 private constant TIER_5_MAX_BOXES = 5;
    uint256 private constant TIER_4_MAX_BOXES = 50;
    uint256 private constant TIER_3_MAX_BOXES = 2000;
    uint256 private constant TIER_2_MAX_BOXES = 200_000;
    // tier 1 (common) has unlimited supply

    /// @notice Constants - Tier names boxes
    string private constant TIER_6_NAME = "Mythical Box";
    string private constant TIER_5_NAME = "Legendary Box";
    string private constant TIER_4_NAME = "Epic Box";
    string private constant TIER_3_NAME = "Rare Box";
    string private constant TIER_2_NAME = "Uncommon Box";
    string private constant TIER_1_NAME = "Common Box";

    /// @notice Internal variables
    uint256 internal boxIdCounter;

    /// @notice Public variables
    address public apiAddress;
    address public operatorAddress;
    uint256 public mintFee = 0.1 ether;
    uint256 public batchesAmount = 1;
    string public _contractURI; // OpenSea Contract-level metadata

    /// @notice this array stores index: tierId, value: total amount minted
    /// element [0] never used since tierId : [1,6]
    uint256 internal constant TIER_IDS_ARRAY_LEN = TIER_IDS_LENGTH+1;
    uint256[TIER_IDS_ARRAY_LEN] internal mintedTierAmount;
    uint256[TIER_IDS_ARRAY_LEN] private unclaimedTierAmount;

    bytes32 public jobId;
    bool public isEarnmClaimAllowed;
    
    /// @notice Structs
    struct VRFRequest {
        address sender;
        bytes code;
    }
    struct Box {
        uint256 blockTs;
        uint256 tier;
        address owner;
    }

    /// @notice Mappings
    mapping(uint256 => Box) internal boxIdToBox; // boxId -> Box
    mapping(address => mapping(uint256 => uint256[])) internal addressToTiersToBoxIds; // address -> tier -> boxId[]
    mapping(address => mapping(uint256 => mapping(uint256 => uint256))) internal addressToTierToBoxIdToIndex; // address -> tier -> boxId -> index in the boxId[]
    mapping(bytes32 => address) private oneTimeCodeToAddress; // oneTimeCodeHash -> address
    mapping(address => uint256) private addressToRandomNumber; // address -> randomSeed

    /// [Chainlink External Adapter]
    mapping(bytes32 => address) private activeEaRequests; // external adapter requests -> address (sender)
    mapping(bytes32 => bool) private fulfilledEaRequests; // external adapter requests -> fulfilled
    /// [Chainlink VRF]
    mapping(uint256 => VRFRequest) private activeVrfRequests; // vrf request -> VRFRequest
    mapping(uint256 => bool) private fulfilledVrfRequests; // vrf request -> fulfilled

    /// @notice Events
    event MysteryBoxRevealRequested(address indexed claimerAddress);
    event MysteryBoxesMinted(address indexed claimerAddress, uint256[] boxIds);
    event MysteryBoxesClaimed(address indexed claimerAddress, uint256[] boxIds, uint256 amount);

    /// @notice Only Owner triggered events
    event BatchesAmountUpdated(uint256 batchesAmount);
    event MintFeeUpdated(uint256 mintFee);
    event EarnmWithdrawnByOwner(uint256 amount);
    event EarnmDepositedByOwner(uint256 amount);
    event IsEarnmClaimAllowedUpdated(bool isEarnmClaimAllowed);
    event OperatorAddressUpdated(address operatorAddress);
    event ApiAddressUpdated(address apiAddress);
    event BaseMetadataURIUpdated(string baseMetadataURI);
    event ContractMetadataURIUpdated(string contractMetadataURI);
    event JobIdUpdated(bytes32 jobId);
    event ChainlinkOracleUpdated(address oracle);
    
    /// @notice Chainlink events
    event FulfillRandomWordsSucceeded(address indexed claimerAddress, uint256 requestId);
    event FulfillBoxAmountSucceeded(address indexed claimerAddress, bytes32 requestId, uint8 boxAmount);

    /// @notice Errors
    error Unauthorized();
    error BadRequest();
    error InsufficientEarnmBalance();
    error InsufficientBoxesBalance();
    error InvalidTierId();
    error InvalidAddress();
    error InvalidMintFee();
    error InvalidVrfState();
    error InvalidEaRequestState();
    error InvalidBoxAmount();
    error InvalidBlockTimestamp();
    error AmountOfEarnmToClaimIsZero();

    /// @param subscriptionId - the subscription ID that this contract uses for funding requests
    /// @param vrfCoordinator - coordinator, check https://docs.chain.link/docs/vrf-contracts/#configurations
    /// @param _oracle - address of the specific Chainlink node that a contract makes an API call from
    /// @param _operatorAddress - address of the wallet that will receive the mint fee of the "revealMysteryBoxes" function
    /// @param _jobId - specific job for :_oracle: to run; each job is unique and returns different types of data
    /// @param _link - LINK token address on the corresponding network
    /// @param _uri - the token metadata URI
    /// @param __contractURI - the contract metadata URI
    /// @param _keyHash - the key hash for the VRF
    /// @param _apiAddress - The address of the api wallet
    constructor(
        // VRF
        uint64 subscriptionId,
        address vrfCoordinator,
        // External adapter
        address _oracle,
        address _operatorAddress,
        string memory _jobId,
        address _link,
        // ERC1155
        string memory _uri,
        string memory __contractURI,
        // Rewards ERC20 token address
        address _token,
        // Key Hash
        bytes32 _keyHash,
        address _apiAddress
    ) VRFConsumerBaseV2(vrfCoordinator) ConfirmedOwner(msg.sender) ERC1155(_uri) {
        if (_operatorAddress == address(0x0)) revert InvalidAddress();
        if (_apiAddress == address(0x0)) revert InvalidAddress();

        setChainlinkToken(_link);

        // External adapter
        setChainlinkOracle(_oracle);
        jobId = _stringToBytes32(_jobId);

        // VRF
        COORDINATOR = VRFCoordinatorV2Interface(vrfCoordinator);
        SUBSCRIPTION_ID = subscriptionId;
        KEY_HASH = _keyHash;

        // ERC 1155
        setURI(_uri);
        _contractURI = __contractURI;

        apiAddress = _apiAddress;
        operatorAddress = _operatorAddress;

        EARNM = IERC20(_token);
        LINK = IERC20(_link);

        isEarnmClaimAllowed = false;
    }

    /// Only api backend can call this function. This function is called from the api backend to associate a code code to an address.
    /// @notice Function to associate a code code to an address. Uniqueness of the one-time code is validated off-chain by the api backend that 
    /// issues the one-time codes.
    /// @dev This function is used to prevent users from claiming boxes that are not theirs by front-running the "revealMysteryBoxes" function.
    /// @param code The one-time code to use to claim the boxes.
    function associateOneTimeCodeToAddress(string memory code, address allowedAddress) external only(apiAddress) {
        // [Safety check] Validate that the code is not empty
        if (bytes(code).length == 0) revert BadRequest();
        if (allowedAddress == address(0x0)) revert BadRequest();

        // Generate the hash of the code and the sender address
        bytes32 otpHash = _getOneTimeCodeHash(code, allowedAddress);

        // Save the code hash to the oneTimeCodeToAddress mapping
        oneTimeCodeToAddress[otpHash] = allowedAddress;
    }

    /// @notice Function to claim ERC1155 boxes, requests a VRF random number to be used as seed for the boxes that will be minted. Uniqueness of the 
    /// one-time code is validated by the api backend.
    /// @dev Front-running attacks are prevented by allow-listing the one-time codes to an adress by the api backend.
    /// @param code The one-time code to use to claim the boxes.
    function revealMysteryBoxes(string memory code) external payable nonReentrant {
        // [Safety check] Validate that the code is not empty
        if (bytes(code).length == 0) revert BadRequest();

        // Generate the hash of the code and the sender address
        bytes32 otpHash = _getOneTimeCodeHash(code, msg.sender);

        // [Safety check] Validate that the code's owner is the sender
        if (oneTimeCodeToAddress[otpHash] != msg.sender) revert Unauthorized();

        // Delete the one-time code from the mapping
        delete oneTimeCodeToAddress[otpHash];

        // Require that the user sends a fee of "mintFee" amount to the node operator wallet
        // This will be used to pay for the fulfillBoxAmount callback fees in the Chainlink Node
        // Execution not allowed if the mint fee is not equal to the "mintFee" variable
        if (msg.value != mintFee) revert InvalidMintFee();

        // Use low level call to send the mint fee to the operator address
        bool sent;
        address receiver = operatorAddress;
        uint256 amount = msg.value;
        assembly {
            sent := call(gas(), receiver, amount, 0, 0, 0, 0)
        }
        if (!sent) revert Unauthorized();

        // [Chainlink] Request a random number to use as seed for the boxes that will be minted
        uint256 vrfRequestId = COORDINATOR.requestRandomWords(
            KEY_HASH, SUBSCRIPTION_ID, REQUEST_CONFIRMATIONS, CALLBACK_GAS_LIMIT, NUM_WORDS
        );

        // Save the vrf request to the mapping
        activeVrfRequests[vrfRequestId] = VRFRequest({sender: msg.sender, code: abi.encode(code)});

        // Emit an event indicating the reveal process has started
        emit MysteryBoxRevealRequested(msg.sender);
    }

    /// [Chainlink] Callback function for the Chainlink VRF request.
    /// @notice Stores the random seed for the sender and requests the amount of boxes to mint associated to the one-time code and the sender address.
    /// @dev A Chainlink request is executed to the external adapter to get the amount of boxes to mint. The external adapter requests the amount of
    /// boxes to mint to the backend. The backend uses the one-time code and the sender address to validate that the request is valid and returns the
    /// amount of boxes to mint. The backend validates that the one-time code is valid and that the sender address is the owner of the one-time code
    /// to prevent front-running attacks.
    /// @param _requestId The request id of the Chainlink request.
    /// @param _randomWords The random words generated by Chainlink VRF.
    function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override {
        // [Safety check] Validate that the vrf request has not been fulfilled
        if (fulfilledVrfRequests[_requestId]) revert InvalidVrfState();

        // Mark the vrf request as fulfilled
        fulfilledVrfRequests[_requestId] = true;

        // Get the active vrf request from the mapping
        VRFRequest memory vrfRequest = activeVrfRequests[_requestId];

        // [Safety check] Validate that the sender is not the zero address
        if (vrfRequest.sender == address(0x0)) revert InvalidAddress();

        // Get the sender address of the reveal boxes request
        address sender = vrfRequest.sender;

        // Get the code from the vrf requests mapping
        bytes memory code = vrfRequest.code;

        // Save the random number
        addressToRandomNumber[sender] = _randomWords[0];

        // [Chainlink] Request the amount of boxes to mint
        Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfillBoxAmount.selector);
        request.addBytes("code", code);
        request.addBytes("address", abi.encode(sender));

        // [Chainlink] Send the external adapter request
        bytes32 eaRequestId = sendChainlinkRequest(request, 0);

        // Save the external adapter request to the mapping
        activeEaRequests[eaRequestId] = sender;

        // Delete the vrf request from the mapping
        delete activeVrfRequests[_requestId];

        // Emit an event indicating the random number has been generated
        emit FulfillRandomWordsSucceeded(sender, _requestId);
    }

    /// [Chainlink] Callback function for the Chainlink external adapter request.
    /// @notice Assigns a tier to the boxes and mints them.
    /// @param _requestId The request id of the Chainlink request.
    /// @param _boxAmount The amount of boxes to mint.
    function fulfillBoxAmount(bytes32 _requestId, uint8 _boxAmount) external recordChainlinkFulfillment(_requestId) {
        // [Safety check] Validate that the external adapter request has not been fulfilled
        if (fulfilledEaRequests[_requestId]) revert InvalidEaRequestState();
      
        // Mark the external adapter request as fulfilled
        fulfilledEaRequests[_requestId] = true;
      
        // Get the sender address of the reveal boxes request
        address sender = activeEaRequests[_requestId];

        // [Safety check] Validate that the sender is not the zero address
        if (sender == address(0x0)) revert InvalidAddress();

        // [Safety check] Validate that the box amount is valid
        if (!(_boxAmount > 0 && _boxAmount <= MAX_BOX_AMOUNT)) revert InvalidBoxAmount();

        // Get the random number from the addresses that requested the random number
        uint256 seed = addressToRandomNumber[sender];

        // Assign tier to boxes and mint
        _assignTierAndMint(_boxAmount, seed, sender);

        // Delete the random number from the addresses that requested the random number
        delete addressToRandomNumber[sender];

        // Delete the external adapter request from the mapping
        delete activeEaRequests[_requestId];

        // [Chainlink] Emit an event indicating the external adapter request has been fulfilled
        emit FulfillBoxAmountSucceeded(sender, _requestId, _boxAmount);
    }

    /// @notice Function to claim the rewards of the Mystery Boxes ERC1155 tokens.
    /// @param _boxIds The box ids to use to claim the rewards. Reverts if the sender does not have enough boxes,
    /// or if the _boxIds array is empty or have duplicated values.
    function claimMysteryBoxes(uint256[] memory _boxIds) external nonReentrant {
        // [Safety check] Only allowed to claim if the isEarnmClaimAllowed variable is true
        // Can be modified by the owner as a safety measure
        if (!(isEarnmClaimAllowed)) revert Unauthorized();
        // [Safety check] Validate that the boxIds array is not empty
        if (!(_boxIds.length > 0)) revert Unauthorized();

        // Amount of Earnm tokens to claim
        uint256 amountToClaim = 0;
        // Array to store the amount of boxes to claim per tier. Ordered from highest tier to lowest tier.
        // Will be used as parameter for the _burnBatch function of the ERC1155 contract.
        uint256[] memory boxesToClaimPerTier = new uint256[](TIER_IDS_LENGTH);

        // Iterate over box IDs to calculate rewards and validate ownership and uniqueness.
        // - Validate that the sender is the owner of the boxes
        // - Validate that the sender has enough boxes to claim
        // - Validate that the box ids are valid 
        // - Validate that the box ids are not duplicated
        // - Calculate the amount of Earnm tokens to claim given the box ids
        for (uint256 i = 0; i < _boxIds.length; i++) {
            // Get the box from the boxes mappings
            Box memory box = boxIdToBox[_boxIds[i]];

            // [Safety check] Validate that the box owner is the sender
            if (!(box.owner == msg.sender)) revert Unauthorized();
            // [Safety check] Validate that the box tier is valid
            if (!(box.tier > 0 && box.tier <= TIER_IDS_LENGTH)) revert InvalidTierId();

            // Increment the amount of boxes per tier to claim
            boxesToClaimPerTier[TIER_IDS_LENGTH - box.tier]++;
            // Increment the amount of Earnm tokens to send to the sender
            amountToClaim += _calculateVestingPeriodPerBox(box.tier, box.blockTs);

            // [Safety check] Duplicate values are not allowed
            for (uint256 j = i + 1; j < _boxIds.length; j++) {
                if (_boxIds[i] == _boxIds[j]) revert BadRequest();
            }
        }

        // Get sender's boxes balances per each tier, length 6. Ordered from highest tier to lowest tier.
        uint256[] memory boxesBalancesPerTier = _tierBalances(msg.sender);
        // [Safety check] Validate sender's ownership of enough boxes per tier.
        for (uint256 i = 0; i < boxesBalancesPerTier.length; i++) {
            if (!(boxesBalancesPerTier[i] >= boxesToClaimPerTier[i])) revert Unauthorized();
        }

        // [Safety check] In case the amount to claim is 0, revert
        if (amountToClaim == 0) revert AmountOfEarnmToClaimIsZero();

        // Get the balance of Earnm ERC20 tokens of the contract
        uint256 balance = EARNM.balanceOf(address(this));

        // [Safety check] Validate there is more than 0 balance of Earnm ERC20 tokens
        // [Safety check] Validate there is enough balance of Earnm ERC20 tokens to claim
        if (!(amountToClaim > 0 && balance > 0 && balance >= amountToClaim)) revert InsufficientEarnmBalance();

        // Burn the ERC1155 tokens that were used to claim the rewards
        _burnBatch(msg.sender, getTierIds(), boxesToClaimPerTier);
        for (uint256 i = 0; i < _boxIds.length; i++) {
            // Delete the box from the boxes mappings
            _deleteBox(_boxIds[i], msg.sender);
        }

        // Transfer the tokens to the sender
        EARNM.safeTransfer(msg.sender, amountToClaim);

        // Emit an event indicating the boxes have been claimed
        emit MysteryBoxesClaimed(msg.sender, _boxIds, amountToClaim);
    }

    /*//////////////////////////////////////////////////////////////
                BOX STORAGE FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    function _saveBox(uint256 boxId, address _address, uint256 tierId) internal {
        // Create a new Box struct and save it in boxIdToBox
        // boxId -> Box
        boxIdToBox[boxId] = Box({ blockTs: block.timestamp, tier: tierId, owner: _address });

        // address -> tier -> boxId -> index in the boxId[]
        addressToTierToBoxIdToIndex[_address][tierId][boxId] = addressToTiersToBoxIds[_address][tierId].length;

        // address -> tier -> boxId[]
        addressToTiersToBoxIds[_address][tierId].push(boxId);

        // Increase the unclaimed amount of boxes minted per tier
        unclaimedTierAmount[tierId]++;
    }

    function _deleteBox(uint256 boxId, address _address) internal {
        // Get the tier of the box
        uint256 boxTierId = boxIdToBox[boxId].tier;

        // Get the index of the box id in the boxId[] array
        uint256 boxIndex = addressToTierToBoxIdToIndex[_address][boxTierId][boxId];

        // Swap the last box with the box to delete
        uint256[] storage arr = addressToTiersToBoxIds[_address][boxTierId];

        // Get the last box
        uint256 lastBoxId = arr[arr.length - 1];

        // Move the last box into the place where the box to delete was
        arr[boxIndex] = lastBoxId;

        // Remove the last box from the array, so the box to delete
        arr.pop();

        // Update the swap from address -> tier -> boxId -> index in the boxId[] mapping
        addressToTierToBoxIdToIndex[_address][boxTierId][lastBoxId] = boxIndex;

        // Delete from address -> tier -> boxId -> index in the boxId[] mapping
        delete addressToTierToBoxIdToIndex[_address][boxTierId][boxId];

        // Delete from address -> boxId mapping
        delete boxIdToBox[boxId];

        // Decrease the unclaimed amount of boxes minted per tier
        unclaimedTierAmount[boxTierId]--;
    }

    /*//////////////////////////////////////////////////////////////
                INTERNAL MINT - VESTING HELPERS
    //////////////////////////////////////////////////////////////*/

    /// @notice Private function to determine the tier of the box based on the random number.
    /// @param randomNumber The random number to use to determine the tier. 0 to 999_999
    /// @param batchesAmountCache cached batchesAmount from storage
    /// @param mintedTierAmountCache cached amount minted for each tier 
    /// @return tierId The tier id of the box.
    function _determineTier(
        uint256 randomNumber, uint256 batchesAmountCache, uint256[TIER_IDS_ARRAY_LEN] memory mintedTierAmountCache) 
    internal pure returns (uint256) {
        // Iterate backwards from the highest tier to the lowest.
        for (uint256 tierId = TIER_IDS_LENGTH; tierId > 0; tierId--) {
            // As soon as the tierId is 1 (Common Box) break the loop
            if(tierId == 1) break;

            // Tier range upper bound for tiers [2, 6]
            uint256 maxBoxesPerTier;

            // Define the upper bound of the range for tiers [2, 6]
            if(tierId == 6) maxBoxesPerTier = TIER_6_MAX_BOXES;
            if(tierId == 5) maxBoxesPerTier = TIER_5_MAX_BOXES;
            if(tierId == 4) maxBoxesPerTier = TIER_4_MAX_BOXES;
            if(tierId == 3) maxBoxesPerTier = TIER_3_MAX_BOXES;
            if(tierId == 2) maxBoxesPerTier = TIER_2_MAX_BOXES;

            // Total number of boxes minted for this tier.
            uint256 totalMintedForTier = mintedTierAmountCache[tierId];

            // Check if there is capacity for more boxes to be minted for this tier.
            bool hasCapacity = totalMintedForTier < maxBoxesPerTier * batchesAmountCache;

            // Check if the randomNumber falls within the current tier's range and hasn't exceeded the mint limit.
            if ((randomNumber < maxBoxesPerTier) && hasCapacity) {
                return tierId;
            }
        }

        // Default to Tier 1 (Common Box) as it has an unlimited cap
        return 1;
    }

    /// @notice Private function to calculate the amount of Earnm tokens to claim given the tier and the divisor.
    /// @param tier The tier of the box.
    /// @param divisor The divisor to use to calculate the amount of Earnm tokens to claim.
    /// @return amountToClaim The amount of Earnm tokens to claim.
    function _calculateAmountToClaim(uint256 tier, uint256 divisor) internal pure returns (uint256) {
        // If the tierId is 1 (Common Box) the amount of tokens to claim is 2.5
        // So to handle the decimal the divisor must be multiplied by 10 for handling the decimal
        if (tier == 1) return (25 * (10 ** EARNM_DECIMALS)) / (10 * divisor);

        // if one of the tiers
        uint256 tokens;
        if(tier == 6) tokens = TIER_6_TOKENS;
        if(tier == 5) tokens = TIER_5_TOKENS;
        if(tier == 4) tokens = TIER_4_TOKENS;
        if(tier == 3) tokens = TIER_3_TOKENS;
        if(tier == 2) tokens = TIER_2_TOKENS;
        
        // Return the amount of tokens to claim
        return (tokens * (10 ** EARNM_DECIMALS)) / divisor;
    }

    /// @notice Function to return the amount of Earnm ERC20 tokens to claim for a box given the box id.
    /// @dev Uses block timestamps for comparisons. Aware of block timestamp manipulation, no security risk for this use case.
    /// Calculates the vesting period for the box id and returns the amount of Earnm tokens to claim.
    /// - If the time since the blockTs of the filled request is between 0 to 6 months you have access to 10% of the tokens
    /// - If the time since the blockTs of the filled request is between 6 to 12 months you have access to 50% of the tokens
    /// - If the time since the blockTs of the filled request is more than 12 months you have access to 100% of the tokens
    /// @param boxTierId tier of the box
    /// @param boxMintedTimestamp minted timestamp of the box
    /// @return amountToClaimByBox The amount of Earnm tokens to claim.
    function _calculateVestingPeriodPerBox(uint256 boxTierId, uint256 boxMintedTimestamp) internal view returns (uint256) {
        // [Safety check] Validate that the box tier is valid
        if (!(boxTierId > 0 && boxTierId <= TIER_IDS_LENGTH)) revert InvalidTierId();

        // [Safety check] Validate that the box block timestamp is valid
        if (!(boxMintedTimestamp <= block.timestamp && boxMintedTimestamp > 0)) revert InvalidBlockTimestamp();

        // Calculate the days passed since the blockTs of the request
        uint256 daysPassed = (block.timestamp - boxMintedTimestamp) / 1 days;

        uint256 amountToClaimByBox = 0;
        if (daysPassed >= 0 && daysPassed < 180) {
            // 0 to 6 months (0 to 180 days)
            amountToClaimByBox += _calculateAmountToClaim(boxTierId, 10);
        } else if (daysPassed >= 180 && daysPassed < 365) {
            // 6 to 12 months (180 to 365 days)
            amountToClaimByBox += _calculateAmountToClaim(boxTierId, 2);
        } else if (daysPassed >= 365) {
            // more than 12 months (365 days)
            amountToClaimByBox += _calculateAmountToClaim(boxTierId, 1);
        }

        return amountToClaimByBox;
    }

    /// @notice Private function to assign a tier to the boxes and mint them.
    /// @param boxAmount The amount of boxes to mint.
    /// @param seed The random seed to use to determine the tier.
    /// @param _address The address of the sender.
    function _assignTierAndMint(uint8 boxAmount, uint256 seed, address _address) internal {
        uint256[] memory mintBatchBoxAmounts = new uint256[](TIER_IDS_LENGTH);
        uint256[] memory boxIdsToEmit = new uint256[](boxAmount);

        // [Safety check] Validate that the box amount is valid
        if (!(boxAmount > 0 && boxAmount <= MAX_BOX_AMOUNT)) revert InvalidBoxAmount();

        // [Gas] Cache batchesAmount to prevent _determineTier() re-reading it from storage multiple times
        uint256 batchesAmountCache = batchesAmount;

        // [Gas] Cache mintedTierAmount and update cache during the loop to prevent
        // _determineTier() from re-reading it from storage multiple times
        uint256[TIER_IDS_ARRAY_LEN] memory mintedTierAmountCache = mintedTierAmount;

        // For each box to mint
        for (uint8 i = 0; i < boxAmount; i++) {
            // Generate a new box id
            uint256 newBoxId = ++boxIdCounter;

            // Box seed
            uint256 boxSeed = uint256(keccak256(abi.encode(seed, newBoxId)));

            // Generate a random number between 0 and 999_999
            uint256 randomNumber = boxSeed % 1_000_000;

            // Determine the tier of the box based on the random number
            uint256 tierId = _determineTier(randomNumber, batchesAmountCache, mintedTierAmountCache);

            // Save the box to the boxes mappings
            _saveBox(newBoxId, _address, tierId);

            // Increment the global total amount of boxes minted per tier
            mintedTierAmountCache[tierId] = ++mintedTierAmount[tierId];

            // [Memory] Add the box id to the boxes ids array
            boxIdsToEmit[i] = newBoxId;

            // [Memory] Increment the amount of boxes to mint per tier in the mintBatchBoxAmounts array
            ++mintBatchBoxAmounts[TIER_IDS_LENGTH - tierId];
        }

        // Mint the ERC1155 tokens for the user
        _mintBatch(_address, getTierIds(), mintBatchBoxAmounts, "");

        // Emit an event indicating the boxes have been minted
        emit MysteryBoxesMinted(_address, boxIdsToEmit);
    }

    /// @notice Private function to get the balance of the sender for each tier.
    /// @param sender The address of the sender.
    function _tierBalances(address sender) internal view returns (uint256[] memory) {
        // Get the balance of the sender for each tier
        address[] memory senderBoxesPerTier = new address[](TIER_IDS_LENGTH);
        for (uint256 tierId = TIER_IDS_LENGTH; tierId > 0; tierId--) {
            senderBoxesPerTier[TIER_IDS_LENGTH - tierId] = sender;
        }
        uint256[] memory balances = balanceOfBatch(senderBoxesPerTier, getTierIds());

        // [Safety check] Require the sender has at least 1 Mystery Box ERC1155 token of any of the tier ids
        if (
            !(balances[0] > 0 ||
                balances[1] > 0 ||
                balances[2] > 0 ||
                balances[3] > 0 ||
                balances[4] > 0 ||
                balances[5] > 0)
        ) revert InsufficientBoxesBalance();

        return balances;
    }

    /*//////////////////////////////////////////////////////////////
                UTILS
    //////////////////////////////////////////////////////////////*/

    /// @notice Requires caller address to match user address.
    /// @param _address The user address to compare with the caller address.
    modifier only(address _address) {
        if (msg.sender != _address) revert Unauthorized();
        _;
    }

    /// @notice Private. Converts a 32 bytes string to bytes32.
    /// @param source The string to convert.
    function _stringToBytes32(string memory source) private pure returns (bytes32 result) {
        bytes memory sourceBytes = bytes(source);
        if (sourceBytes.length == 0) return 0x0;
        if (sourceBytes.length > 32) revert BadRequest();
        assembly {
            // solhint-disable-line no-inline-assembly
            result := mload(add(source, 32))
        }
    }

    /// @notice Private. Returns the one-time code hash associated to an address.
    /// @param code The one-time code to use to claim the boxes.
    /// @param allowedAddress The address allowed to claim the boxes.
    function _getOneTimeCodeHash(string memory code, address allowedAddress) private pure returns (bytes32) {
        return keccak256(abi.encode(code, allowedAddress));
    }

    /// @notice Calculates the total Earnm token liability for all unclaimed boxes.
    /// @return totalLiability The total tokens needed to cover all potential claims.
    function _calculateTotalLiability() internal view returns (uint256) {
        uint256 totalLiability = 0;

        // Iterate over the tiers from highest to lowest
        for (uint256 tierId = TIER_IDS_LENGTH; tierId > 0; tierId--) {
            // Total number of unclaimed boxes minted for this tier
            uint256 totalUnclaimedBoxesInTier = unclaimedTierAmount[tierId];

            // Total Earnm token liability for this tier. We use the 12 month vesting period as the 
            // user has the right to wait until the end of the vesting period to claim the tokens.
            uint256 earnmPerBox = _calculateAmountToClaim(tierId, 1);

            // Calculate the total liability for this tier
            uint256 tierLiability = totalUnclaimedBoxesInTier * earnmPerBox;

            // Add the tier liability to the total liability
            totalLiability += tierLiability;
        }

        // Return the total amount of Earnm tokens that must be held by the contract to cover all potential claims
        return totalLiability;
    }

    /*//////////////////////////////////////////////////////////////
                GETTERS
    //////////////////////////////////////////////////////////////*/

    /// @notice Function to get the URI of the ERC1155 token.
    function uri(uint256 _tokenid) public view override returns (string memory) {
        return string(abi.encodePacked(bytes(super.uri(_tokenid)), Strings.toString(_tokenid), ".json"));
    }

    /// @notice OpenSea URL for the storefront-level metadata for the contract.
    function contractURI() public view returns (string memory) {
        return string(abi.encodePacked(bytes(_contractURI)));
    }

    /// @notice Function to retrieve the Earnm token balance of the contract.
    /// @return balance The Earnm token balance of the contract.
    function getEarnmBalance() external view returns (uint256 balance) {
        return EARNM.balanceOf(address(this));
    }

    /// @notice Function to get the list of tier ids
    /// @return tierIds the list of tier ids
    function getTierIds() internal pure returns (uint256[] memory) {
        uint256[] memory tierIds = new uint256[](6);
        tierIds[0] = 6;
        tierIds[1] = 5;
        tierIds[2] = 4;
        tierIds[3] = 3;
        tierIds[4] = 2;
        tierIds[5] = 1;

        return tierIds;
    }

    /// @notice Function to get the names of the tiers.
    /// @return tierNames The names of the tiers.
    function getNames() external pure returns (string[] memory) {
        string[] memory tierNames = new string[](6);
        tierNames[0] = TIER_6_NAME;
        tierNames[1] = TIER_5_NAME;
        tierNames[2] = TIER_4_NAME;
        tierNames[3] = TIER_3_NAME;
        tierNames[4] = TIER_2_NAME;
        tierNames[5] = TIER_1_NAME;

        return tierNames;
    }

    /*//////////////////////////////////////////////////////////////
                [EXTERNAL VIEW] BOXES - GETTERS
    //////////////////////////////////////////////////////////////*/

    /// @notice [External View] Get the tier and timestamp of a box from the id
    /// @param boxIds Array of box ids to get the tier and timestamp from
    function getBoxTierAndBlockTsOfIds(uint256[] memory boxIds) external view returns (uint256[3][] memory) {
        uint256[3][] memory boxIdsData = new uint256[3][](boxIds.length);

        for (uint256 i = 0; i < boxIds.length; i++) {
            uint256 currentBoxId = boxIds[i];
            Box memory box = boxIdToBox[currentBoxId];
            uint256 tierId = box.tier;
            uint256 blockTs = box.blockTs;
            boxIdsData[i] = [currentBoxId, tierId, blockTs];
        }

        return boxIdsData;
    }

    /// @notice [External View] Get the box id and timestamp of the boxes of a tier for an address
    /// @param sender The address of the sender.
    /// @param tierId Tier of the box
    function getSenderBoxIdsAndBlockTssOfTier(address sender, uint256 tierId) external view returns (uint256[2][] memory) {
        uint256[] memory boxIds = addressToTiersToBoxIds[sender][tierId];

        uint256[2][] memory boxIdsAndBlockTss = new uint256[2][](boxIds.length);

        for (uint256 i = 0; i < boxIds.length; i++) {
            uint256 currentBoxId = boxIds[i];
            Box memory box = boxIdToBox[currentBoxId];
            uint256 blockTs = box.blockTs;
            boxIdsAndBlockTss[i] = [currentBoxId, blockTs];
        }

        return boxIdsAndBlockTss;
    }

    /// @notice [External View] Get the box ids array of a tier for an address
    /// @param sender The address of the sender.
    /// @param tierId Tier of the box
    function getSenderTierBoxIds(address sender, uint256 tierId) external view returns (uint256[] memory) {
        return addressToTiersToBoxIds[sender][tierId];
    }

    /// @notice [External View] Get the amount of boxes of a tier for an address
    /// @param sender The address of the sender.
    /// @param tierId Tier of the box
    /// @param page Page of the boxes
    /// @param resultsPerPage Amount of boxes per page
    function getSenderTierBoxIdsPaginated(
        address sender,
        uint256 tierId,
        uint256 page,
        uint256 resultsPerPage
    ) external view returns (uint256[] memory, uint256) {
        uint256[] memory boxes = addressToTiersToBoxIds[sender][tierId];
        if (boxes.length == 0) {
            return (new uint256[](0), 0);
        }

        uint256 startIndex = (page - 1) * resultsPerPage;
        if (startIndex >= boxes.length) {
            // If the start index is out of bounds, return an empty array
            return (new uint256[](0), boxes.length);
        }

        uint256 endIndex = startIndex + resultsPerPage;
        if (endIndex > boxes.length) {
            endIndex = boxes.length;
        }

        uint256[] memory pageBoxes = new uint256[](endIndex - startIndex);
        for (uint256 i = 0; i < pageBoxes.length; i++) {
            pageBoxes[i] = boxes[startIndex + i];
        }

        return (pageBoxes, boxes.length);
    }

    /// @notice [External View] Get the amount of boxes by tiers for an address
    /// @param sender The address of the sender.
    function getSenderBoxIdsByTiers(address sender) external view returns (uint256[][] memory) {
        uint256[][] memory boxIds = new uint256[][](TIER_IDS_LENGTH);

        for (uint256 tierId = TIER_IDS_LENGTH; tierId > 0; tierId--) {
            uint256[] memory boxesIds = addressToTiersToBoxIds[sender][tierId];
            boxIds[TIER_IDS_LENGTH - tierId] = boxesIds;
        }
        return boxIds;
    }

    /// @notice [External View] Get the address associated to a one-time code hash
    /// @param sender The address of the sender.
    /// @param code The one-time code to use to claim the boxes.
    function getOneTimeCodeToAddress(address sender, string memory code) external view returns (address) {
        return oneTimeCodeToAddress[_getOneTimeCodeHash(code, sender)];
    }

    /// @notice [External View] Get the Earnm amount of tokens locked by the vesting process
    /// and not available to be widrawn by the owner
    function getEarnmInVestingProcess() external view returns (uint256) {
        // Get the total Earnm token liability for all unclaimed boxes
        uint256 totalLiability = _calculateTotalLiability();

        return totalLiability;
    }
    /*//////////////////////////////////////////////////////////////
                ERC 1155 OVERRIDE
    //////////////////////////////////////////////////////////////*/

    /// @notice Override the _beforeTokenTransfer function of the ERC1155 contract.
    /// @dev This function is called when a user transfers tokens, and it is used to prevent transfers.
    ///      only from/to parameters are used
    /// @param from The address of the sender.
    /// @param to The address of the receiver.
    function _beforeTokenTransfer(
        address /*operator*/,
        address from,
        address to,
        uint256[] memory /*ids*/,
        uint256[] memory /*amounts*/,
        bytes memory /*data*/
    ) internal pure override {
       if (from != address(0) && to != address(0)) revert Unauthorized();
    }

    /*//////////////////////////////////////////////////////////////
                ONLY OWNER
    //////////////////////////////////////////////////////////////*/

    /// @notice Function to set the isEarnmClaimAllowed variable, only owner access
    /// @param _isEarnmClaimAllowed The new isEarnmClaimAllowed variable value.
    function ownerModifyIsEarnmClaimAllowed(bool _isEarnmClaimAllowed) external onlyOwner {
        isEarnmClaimAllowed = _isEarnmClaimAllowed;

        // Emit an event indicating the isEarnmClaimAllowed variable has been updated
        emit IsEarnmClaimAllowedUpdated(_isEarnmClaimAllowed);
    }

    /// @notice Function to deposit Earnm ERC20 tokens to the contract, only owner access
    /// @param amount The amount of Earnm ERC20 tokens to deposit.
    function ownerDepositEarnm(uint256 amount) external onlyOwner {
        EARNM.safeTransferFrom(msg.sender, address(this), amount);

        // Emit an event indicating the tokens have been deposited
        emit EarnmDepositedByOwner(amount);
    }

    /// @notice Function to withdraw Earnm ERC20 tokens from the contract, only owner access.
    /// This function will only withdraw the amount of Earnm tokens that are not needed to cover all potential claims.
    function ownerWithdrawEarnm() external onlyOwner {
        // Get the balance of Earnm ERC20 tokens of the contract
        uint256 balance = EARNM.balanceOf(address(this));

        // [Safety check] Validate there is more than 0 balance of Earnm ERC20 tokens
        if (balance == 0) revert InsufficientEarnmBalance();

        // Get the total Earnm token liability for all unclaimed boxes
        uint256 totalLiability = _calculateTotalLiability();

        // Calculate the surplus of Earnm ERC20 tokens
        uint256 surplus = balance > totalLiability ? balance - totalLiability : 0;

        // [Safety check] Validate there is more than 0 surplus of Earnm ERC20 tokens
        if (surplus == 0) revert InsufficientEarnmBalance();

        // Transfer the tokens to the owner
        EARNM.safeTransfer(msg.sender, surplus);

        // Emit an event indicating the tokens have been withdrawn
        emit EarnmWithdrawnByOwner(surplus);
    }

    /// @notice Function to set the batches amount, only owner access
    /// @param _batchesAmount The new batches amount.
    function setBatchesAmount(uint256 _batchesAmount) external onlyOwner {
        if (!(_batchesAmount > 0 && _batchesAmount > batchesAmount && _batchesAmount <= MAX_BATCHES_AMOUNT)) {
            revert BadRequest();
        }

        batchesAmount = _batchesAmount;

        // Emit an event indicating the batches amount has been updated
        emit BatchesAmountUpdated(_batchesAmount);
    }

    /// @notice Function to set the base URI, only owner access
    function setURI(string memory newuri) public onlyOwner {
        if (bytes(newuri).length == 0) revert BadRequest();

        _setURI(newuri);

        // Emit an event indicating the base URI has been updated
        emit BaseMetadataURIUpdated(newuri);
    }

    /// @notice Function to set the api address, only owner access
    /// @param _apiAddress The new api address.
    function setApiAddress(address _apiAddress) external onlyOwner {
        if (_apiAddress == address(0x0)) revert InvalidAddress();

        apiAddress = _apiAddress;

        // Emit an event indicating the api address has been updated
        emit ApiAddressUpdated(_apiAddress);
    }

    /// @notice Function to set the operator address, only owner access
    /// @param _operatorAddress The new operator address.
    function setOperatorAddress(address _operatorAddress) external onlyOwner {
        if (_operatorAddress == address(0x0)) revert InvalidAddress();

        operatorAddress = _operatorAddress;

        // Emit an event indicating the operator address has been updated
        emit OperatorAddressUpdated(_operatorAddress);
    }

    /// @notice Function to update the Chainlink external adapter job id, only owner access
    /// @param _jobId The new job id.
    function setJobId(string memory _jobId) external onlyOwner {
        if (bytes(_jobId).length != 32) revert BadRequest();
        jobId = _stringToBytes32(_jobId);

        // Emit an event indicating the job id has been updated
        emit JobIdUpdated(jobId);
    }

    /// @notice Function to update the mint fee, only owner access
    /// @param _mintFee The new mint fee.
    function setMintFee(uint256 _mintFee) external onlyOwner {
        // Setting max mint fee to 10 matic
        if (_mintFee > MAX_MINT_FEE) revert InvalidMintFee();

        mintFee = _mintFee;

        // Emit an event indicating the mint fee has been updated
        emit MintFeeUpdated(_mintFee);
    }

    /// @notice Function to update the Chainlink Node address, only owner access
    /// @param _chainlinkNodeAddress The new Chainlink Node address.
    function setChainlinkNodeAddress(address _chainlinkNodeAddress) external onlyOwner {
        if (_chainlinkNodeAddress == address(0x0)) revert InvalidAddress();

        setChainlinkOracle(_chainlinkNodeAddress);

        // Emit an event indicating the Chainlink Node address has been updated
        emit ChainlinkOracleUpdated(_chainlinkNodeAddress);
    }

    /// @notice Function to update the contract URI, only owner access
    /// @param __contractURI The new contract URI.
    function setContractURI(string memory __contractURI) external onlyOwner {
        if (bytes(_contractURI).length == 0) revert BadRequest();

        _contractURI = __contractURI;

        // Emit an event indicating the contract URI has been updated
        emit ContractMetadataURIUpdated(_contractURI);
    }
}

File 2 of 32 : Chainlink.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {CBORChainlink} from "./vendor/CBORChainlink.sol";
import {BufferChainlink} from "./vendor/BufferChainlink.sol";

/**
 * @title Library for common Chainlink functions
 * @dev Uses imported CBOR library for encoding to buffer
 */
library Chainlink {
  uint256 internal constant defaultBufferSize = 256; // solhint-disable-line const-name-snakecase

  using CBORChainlink for BufferChainlink.buffer;

  struct Request {
    bytes32 id;
    address callbackAddress;
    bytes4 callbackFunctionId;
    uint256 nonce;
    BufferChainlink.buffer buf;
  }

  /**
   * @notice Initializes a Chainlink request
   * @dev Sets the ID, callback address, and callback function signature on the request
   * @param self The uninitialized request
   * @param jobId The Job Specification ID
   * @param callbackAddr The callback address
   * @param callbackFunc The callback function signature
   * @return The initialized request
   */
  function initialize(
    Request memory self,
    bytes32 jobId,
    address callbackAddr,
    bytes4 callbackFunc
  ) internal pure returns (Chainlink.Request memory) {
    BufferChainlink.init(self.buf, defaultBufferSize);
    self.id = jobId;
    self.callbackAddress = callbackAddr;
    self.callbackFunctionId = callbackFunc;
    return self;
  }

  /**
   * @notice Sets the data for the buffer without encoding CBOR on-chain
   * @dev CBOR can be closed with curly-brackets {} or they can be left off
   * @param self The initialized request
   * @param data The CBOR data
   */
  function setBuffer(Request memory self, bytes memory data) internal pure {
    BufferChainlink.init(self.buf, data.length);
    BufferChainlink.append(self.buf, data);
  }

  /**
   * @notice Adds a string value to the request with a given key name
   * @param self The initialized request
   * @param key The name of the key
   * @param value The string value to add
   */
  function add(Request memory self, string memory key, string memory value) internal pure {
    self.buf.encodeString(key);
    self.buf.encodeString(value);
  }

  /**
   * @notice Adds a bytes value to the request with a given key name
   * @param self The initialized request
   * @param key The name of the key
   * @param value The bytes value to add
   */
  function addBytes(Request memory self, string memory key, bytes memory value) internal pure {
    self.buf.encodeString(key);
    self.buf.encodeBytes(value);
  }

  /**
   * @notice Adds a int256 value to the request with a given key name
   * @param self The initialized request
   * @param key The name of the key
   * @param value The int256 value to add
   */
  function addInt(Request memory self, string memory key, int256 value) internal pure {
    self.buf.encodeString(key);
    self.buf.encodeInt(value);
  }

  /**
   * @notice Adds a uint256 value to the request with a given key name
   * @param self The initialized request
   * @param key The name of the key
   * @param value The uint256 value to add
   */
  function addUint(Request memory self, string memory key, uint256 value) internal pure {
    self.buf.encodeString(key);
    self.buf.encodeUInt(value);
  }

  /**
   * @notice Adds an array of strings to the request with a given key name
   * @param self The initialized request
   * @param key The name of the key
   * @param values The array of string values to add
   */
  function addStringArray(Request memory self, string memory key, string[] memory values) internal pure {
    self.buf.encodeString(key);
    self.buf.startArray();
    for (uint256 i = 0; i < values.length; i++) {
      self.buf.encodeString(values[i]);
    }
    self.buf.endSequence();
  }
}

File 3 of 32 : ChainlinkClient.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./Chainlink.sol";
import "./interfaces/ENSInterface.sol";
import "./shared/interfaces/LinkTokenInterface.sol";
import "./interfaces/ChainlinkRequestInterface.sol";
import "./interfaces/OperatorInterface.sol";
import "./interfaces/PointerInterface.sol";
import {ENSResolver as ENSResolver_Chainlink} from "./vendor/ENSResolver.sol";

/**
 * @title The ChainlinkClient contract
 * @notice Contract writers can inherit this contract in order to create requests for the
 * Chainlink network
 */
abstract contract ChainlinkClient {
  using Chainlink for Chainlink.Request;

  uint256 internal constant LINK_DIVISIBILITY = 10 ** 18;
  uint256 private constant AMOUNT_OVERRIDE = 0;
  address private constant SENDER_OVERRIDE = address(0);
  uint256 private constant ORACLE_ARGS_VERSION = 1;
  uint256 private constant OPERATOR_ARGS_VERSION = 2;
  bytes32 private constant ENS_TOKEN_SUBNAME = keccak256("link");
  bytes32 private constant ENS_ORACLE_SUBNAME = keccak256("oracle");
  address private constant LINK_TOKEN_POINTER = 0xC89bD4E1632D3A43CB03AAAd5262cbe4038Bc571;

  ENSInterface private s_ens;
  bytes32 private s_ensNode;
  LinkTokenInterface private s_link;
  OperatorInterface private s_oracle;
  uint256 private s_requestCount = 1;
  mapping(bytes32 => address) private s_pendingRequests;

  event ChainlinkRequested(bytes32 indexed id);
  event ChainlinkFulfilled(bytes32 indexed id);
  event ChainlinkCancelled(bytes32 indexed id);

  /**
   * @notice Creates a request that can hold additional parameters
   * @param specId The Job Specification ID that the request will be created for
   * @param callbackAddr address to operate the callback on
   * @param callbackFunctionSignature function signature to use for the callback
   * @return A Chainlink Request struct in memory
   */
  function buildChainlinkRequest(
    bytes32 specId,
    address callbackAddr,
    bytes4 callbackFunctionSignature
  ) internal pure returns (Chainlink.Request memory) {
    Chainlink.Request memory req;
    return req.initialize(specId, callbackAddr, callbackFunctionSignature);
  }

  /**
   * @notice Creates a request that can hold additional parameters
   * @param specId The Job Specification ID that the request will be created for
   * @param callbackFunctionSignature function signature to use for the callback
   * @return A Chainlink Request struct in memory
   */
  function buildOperatorRequest(
    bytes32 specId,
    bytes4 callbackFunctionSignature
  ) internal view returns (Chainlink.Request memory) {
    Chainlink.Request memory req;
    return req.initialize(specId, address(this), callbackFunctionSignature);
  }

  /**
   * @notice Creates a Chainlink request to the stored oracle address
   * @dev Calls `chainlinkRequestTo` with the stored oracle address
   * @param req The initialized Chainlink Request
   * @param payment The amount of LINK to send for the request
   * @return requestId The request ID
   */
  function sendChainlinkRequest(Chainlink.Request memory req, uint256 payment) internal returns (bytes32) {
    return sendChainlinkRequestTo(address(s_oracle), req, payment);
  }

  /**
   * @notice Creates a Chainlink request to the specified oracle address
   * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to
   * send LINK which creates a request on the target oracle contract.
   * Emits ChainlinkRequested event.
   * @param oracleAddress The address of the oracle for the request
   * @param req The initialized Chainlink Request
   * @param payment The amount of LINK to send for the request
   * @return requestId The request ID
   */
  function sendChainlinkRequestTo(
    address oracleAddress,
    Chainlink.Request memory req,
    uint256 payment
  ) internal returns (bytes32 requestId) {
    uint256 nonce = s_requestCount;
    s_requestCount = nonce + 1;
    bytes memory encodedRequest = abi.encodeWithSelector(
      ChainlinkRequestInterface.oracleRequest.selector,
      SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address
      AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent
      req.id,
      address(this),
      req.callbackFunctionId,
      nonce,
      ORACLE_ARGS_VERSION,
      req.buf.buf
    );
    return _rawRequest(oracleAddress, nonce, payment, encodedRequest);
  }

  /**
   * @notice Creates a Chainlink request to the stored oracle address
   * @dev This function supports multi-word response
   * @dev Calls `sendOperatorRequestTo` with the stored oracle address
   * @param req The initialized Chainlink Request
   * @param payment The amount of LINK to send for the request
   * @return requestId The request ID
   */
  function sendOperatorRequest(Chainlink.Request memory req, uint256 payment) internal returns (bytes32) {
    return sendOperatorRequestTo(address(s_oracle), req, payment);
  }

  /**
   * @notice Creates a Chainlink request to the specified oracle address
   * @dev This function supports multi-word response
   * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to
   * send LINK which creates a request on the target oracle contract.
   * Emits ChainlinkRequested event.
   * @param oracleAddress The address of the oracle for the request
   * @param req The initialized Chainlink Request
   * @param payment The amount of LINK to send for the request
   * @return requestId The request ID
   */
  function sendOperatorRequestTo(
    address oracleAddress,
    Chainlink.Request memory req,
    uint256 payment
  ) internal returns (bytes32 requestId) {
    uint256 nonce = s_requestCount;
    s_requestCount = nonce + 1;
    bytes memory encodedRequest = abi.encodeWithSelector(
      OperatorInterface.operatorRequest.selector,
      SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address
      AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent
      req.id,
      req.callbackFunctionId,
      nonce,
      OPERATOR_ARGS_VERSION,
      req.buf.buf
    );
    return _rawRequest(oracleAddress, nonce, payment, encodedRequest);
  }

  /**
   * @notice Make a request to an oracle
   * @param oracleAddress The address of the oracle for the request
   * @param nonce used to generate the request ID
   * @param payment The amount of LINK to send for the request
   * @param encodedRequest data encoded for request type specific format
   * @return requestId The request ID
   */
  function _rawRequest(
    address oracleAddress,
    uint256 nonce,
    uint256 payment,
    bytes memory encodedRequest
  ) private returns (bytes32 requestId) {
    requestId = keccak256(abi.encodePacked(this, nonce));
    s_pendingRequests[requestId] = oracleAddress;
    emit ChainlinkRequested(requestId);
    require(s_link.transferAndCall(oracleAddress, payment, encodedRequest), "unable to transferAndCall to oracle");
  }

  /**
   * @notice Allows a request to be cancelled if it has not been fulfilled
   * @dev Requires keeping track of the expiration value emitted from the oracle contract.
   * Deletes the request from the `pendingRequests` mapping.
   * Emits ChainlinkCancelled event.
   * @param requestId The request ID
   * @param payment The amount of LINK sent for the request
   * @param callbackFunc The callback function specified for the request
   * @param expiration The time of the expiration for the request
   */
  function cancelChainlinkRequest(
    bytes32 requestId,
    uint256 payment,
    bytes4 callbackFunc,
    uint256 expiration
  ) internal {
    OperatorInterface requested = OperatorInterface(s_pendingRequests[requestId]);
    delete s_pendingRequests[requestId];
    emit ChainlinkCancelled(requestId);
    requested.cancelOracleRequest(requestId, payment, callbackFunc, expiration);
  }

  /**
   * @notice the next request count to be used in generating a nonce
   * @dev starts at 1 in order to ensure consistent gas cost
   * @return returns the next request count to be used in a nonce
   */
  function getNextRequestCount() internal view returns (uint256) {
    return s_requestCount;
  }

  /**
   * @notice Sets the stored oracle address
   * @param oracleAddress The address of the oracle contract
   */
  function setChainlinkOracle(address oracleAddress) internal {
    s_oracle = OperatorInterface(oracleAddress);
  }

  /**
   * @notice Sets the LINK token address
   * @param linkAddress The address of the LINK token contract
   */
  function setChainlinkToken(address linkAddress) internal {
    s_link = LinkTokenInterface(linkAddress);
  }

  /**
   * @notice Sets the Chainlink token address for the public
   * network as given by the Pointer contract
   */
  function setPublicChainlinkToken() internal {
    setChainlinkToken(PointerInterface(LINK_TOKEN_POINTER).getAddress());
  }

  /**
   * @notice Retrieves the stored address of the LINK token
   * @return The address of the LINK token
   */
  function chainlinkTokenAddress() internal view returns (address) {
    return address(s_link);
  }

  /**
   * @notice Retrieves the stored address of the oracle contract
   * @return The address of the oracle contract
   */
  function chainlinkOracleAddress() internal view returns (address) {
    return address(s_oracle);
  }

  /**
   * @notice Allows for a request which was created on another contract to be fulfilled
   * on this contract
   * @param oracleAddress The address of the oracle contract that will fulfill the request
   * @param requestId The request ID used for the response
   */
  function addChainlinkExternalRequest(address oracleAddress, bytes32 requestId) internal notPendingRequest(requestId) {
    s_pendingRequests[requestId] = oracleAddress;
  }

  /**
   * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS
   * @dev Accounts for subnodes having different resolvers
   * @param ensAddress The address of the ENS contract
   * @param node The ENS node hash
   */
  function useChainlinkWithENS(address ensAddress, bytes32 node) internal {
    s_ens = ENSInterface(ensAddress);
    s_ensNode = node;
    bytes32 linkSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_TOKEN_SUBNAME));
    ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(linkSubnode));
    setChainlinkToken(resolver.addr(linkSubnode));
    updateChainlinkOracleWithENS();
  }

  /**
   * @notice Sets the stored oracle contract with the address resolved by ENS
   * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously
   */
  function updateChainlinkOracleWithENS() internal {
    bytes32 oracleSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME));
    ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(oracleSubnode));
    setChainlinkOracle(resolver.addr(oracleSubnode));
  }

  /**
   * @notice Ensures that the fulfillment is valid for this contract
   * @dev Use if the contract developer prefers methods instead of modifiers for validation
   * @param requestId The request ID for fulfillment
   */
  function validateChainlinkCallback(
    bytes32 requestId
  )
    internal
    recordChainlinkFulfillment(requestId) // solhint-disable-next-line no-empty-blocks
  {}

  /**
   * @dev Reverts if the sender is not the oracle of the request.
   * Emits ChainlinkFulfilled event.
   * @param requestId The request ID for fulfillment
   */
  modifier recordChainlinkFulfillment(bytes32 requestId) {
    require(msg.sender == s_pendingRequests[requestId], "Source must be the oracle of the request");
    delete s_pendingRequests[requestId];
    emit ChainlinkFulfilled(requestId);
    _;
  }

  /**
   * @dev Reverts if the request is already pending
   * @param requestId The request ID for fulfillment
   */
  modifier notPendingRequest(bytes32 requestId) {
    require(s_pendingRequests[requestId] == address(0), "Request is already pending");
    _;
  }
}

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

interface ChainlinkRequestInterface {
  function oracleRequest(
    address sender,
    uint256 requestPrice,
    bytes32 serviceAgreementID,
    address callbackAddress,
    bytes4 callbackFunctionId,
    uint256 nonce,
    uint256 dataVersion,
    bytes calldata data
  ) external;

  function cancelOracleRequest(
    bytes32 requestId,
    uint256 payment,
    bytes4 callbackFunctionId,
    uint256 expiration
  ) external;
}

File 5 of 32 : ENSInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ENSInterface {
  // Logged when the owner of a node assigns a new owner to a subnode.
  event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);

  // Logged when the owner of a node transfers ownership to a new account.
  event Transfer(bytes32 indexed node, address owner);

  // Logged when the resolver for a node changes.
  event NewResolver(bytes32 indexed node, address resolver);

  // Logged when the TTL of a node changes
  event NewTTL(bytes32 indexed node, uint64 ttl);

  function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external;

  function setResolver(bytes32 node, address resolver) external;

  function setOwner(bytes32 node, address owner) external;

  function setTTL(bytes32 node, uint64 ttl) external;

  function owner(bytes32 node) external view returns (address);

  function resolver(bytes32 node) external view returns (address);

  function ttl(bytes32 node) external view returns (uint64);
}

File 6 of 32 : OperatorInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./OracleInterface.sol";
import "./ChainlinkRequestInterface.sol";

interface OperatorInterface is OracleInterface, ChainlinkRequestInterface {
  function operatorRequest(
    address sender,
    uint256 payment,
    bytes32 specId,
    bytes4 callbackFunctionId,
    uint256 nonce,
    uint256 dataVersion,
    bytes calldata data
  ) external;

  function fulfillOracleRequest2(
    bytes32 requestId,
    uint256 payment,
    address callbackAddress,
    bytes4 callbackFunctionId,
    uint256 expiration,
    bytes calldata data
  ) external returns (bool);

  function ownerTransferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);

  function distributeFunds(address payable[] calldata receivers, uint256[] calldata amounts) external payable;

  function getAuthorizedSenders() external returns (address[] memory);

  function setAuthorizedSenders(address[] calldata senders) external;

  function getForwarder() external returns (address);
}

File 7 of 32 : OracleInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface OracleInterface {
  function fulfillOracleRequest(
    bytes32 requestId,
    uint256 payment,
    address callbackAddress,
    bytes4 callbackFunctionId,
    uint256 expiration,
    bytes32 data
  ) external returns (bool);

  function isAuthorizedSender(address node) external view returns (bool);

  function withdraw(address recipient, uint256 amount) external;

  function withdrawable() external view returns (uint256);
}

File 8 of 32 : PointerInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface PointerInterface {
  function getAddress() external view returns (address);
}

File 9 of 32 : 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;

  /*
   * @notice Check to see if there exists a request commitment consumers
   * for all consumers and keyhashes for a given sub.
   * @param subId - ID of the subscription
   * @return true if there exists at least one unfulfilled request for the subscription, false
   * otherwise.
   */
  function pendingRequestExists(uint64 subId) external view returns (bool);
}

File 10 of 32 : ConfirmedOwner.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ConfirmedOwnerWithProposal.sol";

/**
 * @title The ConfirmedOwner contract
 * @notice A contract with helpers for basic contract ownership.
 */
contract ConfirmedOwner is ConfirmedOwnerWithProposal {
  constructor(address newOwner) ConfirmedOwnerWithProposal(newOwner, address(0)) {}
}

File 11 of 32 : ConfirmedOwnerWithProposal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../interfaces/IOwnable.sol";

/**
 * @title The ConfirmedOwner contract
 * @notice A contract with helpers for basic contract ownership.
 */
contract ConfirmedOwnerWithProposal is IOwnable {
  address private s_owner;
  address private s_pendingOwner;

  event OwnershipTransferRequested(address indexed from, address indexed to);
  event OwnershipTransferred(address indexed from, address indexed to);

  constructor(address newOwner, address pendingOwner) {
    require(newOwner != address(0), "Cannot set owner to zero");

    s_owner = newOwner;
    if (pendingOwner != address(0)) {
      _transferOwnership(pendingOwner);
    }
  }

  /**
   * @notice Allows an owner to begin transferring ownership to a new address,
   * pending.
   */
  function transferOwnership(address to) public override onlyOwner {
    _transferOwnership(to);
  }

  /**
   * @notice Allows an ownership transfer to be completed by the recipient.
   */
  function acceptOwnership() external override {
    require(msg.sender == s_pendingOwner, "Must be proposed owner");

    address oldOwner = s_owner;
    s_owner = msg.sender;
    s_pendingOwner = address(0);

    emit OwnershipTransferred(oldOwner, msg.sender);
  }

  /**
   * @notice Get the current owner
   */
  function owner() public view override returns (address) {
    return s_owner;
  }

  /**
   * @notice validate, transfer ownership, and emit relevant events
   */
  function _transferOwnership(address to) private {
    require(to != msg.sender, "Cannot transfer to self");

    s_pendingOwner = to;

    emit OwnershipTransferRequested(s_owner, to);
  }

  /**
   * @notice validate access
   */
  function _validateOwnership() internal view {
    require(msg.sender == s_owner, "Only callable by owner");
  }

  /**
   * @notice Reverts if called by anyone other than the contract owner.
   */
  modifier onlyOwner() {
    _validateOwnership();
    _;
  }
}

File 12 of 32 : IOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOwnable {
  function owner() external returns (address);

  function transferOwnership(address recipient) external;

  function acceptOwnership() external;
}

File 13 of 32 : LinkTokenInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface LinkTokenInterface {
  function allowance(address owner, address spender) external view returns (uint256 remaining);

  function approve(address spender, uint256 value) external returns (bool success);

  function balanceOf(address owner) external view returns (uint256 balance);

  function decimals() external view returns (uint8 decimalPlaces);

  function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);

  function increaseApproval(address spender, uint256 subtractedValue) external;

  function name() external view returns (string memory tokenName);

  function symbol() external view returns (string memory tokenSymbol);

  function totalSupply() external view returns (uint256 totalTokensIssued);

  function transfer(address to, uint256 value) external returns (bool success);

  function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);

  function transferFrom(address from, address to, uint256 value) external returns (bool success);
}

File 14 of 32 : BufferChainlink.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @dev A library for working with mutable byte buffers in Solidity.
 *
 * Byte buffers are mutable and expandable, and provide a variety of primitives
 * for writing to them. At any time you can fetch a bytes object containing the
 * current contents of the buffer. The bytes object should not be stored between
 * operations, as it may change due to resizing of the buffer.
 */
library BufferChainlink {
  /**
   * @dev Represents a mutable buffer. Buffers have a current value (buf) and
   *      a capacity. The capacity may be longer than the current value, in
   *      which case it can be extended without the need to allocate more memory.
   */
  struct buffer {
    bytes buf;
    uint256 capacity;
  }

  /**
   * @dev Initializes a buffer with an initial capacity.
   * @param buf The buffer to initialize.
   * @param capacity The number of bytes of space to allocate the buffer.
   * @return The buffer, for chaining.
   */
  function init(buffer memory buf, uint256 capacity) internal pure returns (buffer memory) {
    if (capacity % 32 != 0) {
      capacity += 32 - (capacity % 32);
    }
    // Allocate space for the buffer data
    buf.capacity = capacity;
    assembly {
      let ptr := mload(0x40)
      mstore(buf, ptr)
      mstore(ptr, 0)
      mstore(0x40, add(32, add(ptr, capacity)))
    }
    return buf;
  }

  /**
   * @dev Initializes a new buffer from an existing bytes object.
   *      Changes to the buffer may mutate the original value.
   * @param b The bytes object to initialize the buffer with.
   * @return A new buffer.
   */
  function fromBytes(bytes memory b) internal pure returns (buffer memory) {
    buffer memory buf;
    buf.buf = b;
    buf.capacity = b.length;
    return buf;
  }

  function resize(buffer memory buf, uint256 capacity) private pure {
    bytes memory oldbuf = buf.buf;
    init(buf, capacity);
    append(buf, oldbuf);
  }

  function max(uint256 a, uint256 b) private pure returns (uint256) {
    if (a > b) {
      return a;
    }
    return b;
  }

  /**
   * @dev Sets buffer length to 0.
   * @param buf The buffer to truncate.
   * @return The original buffer, for chaining..
   */
  function truncate(buffer memory buf) internal pure returns (buffer memory) {
    assembly {
      let bufptr := mload(buf)
      mstore(bufptr, 0)
    }
    return buf;
  }

  /**
   * @dev Writes a byte string to a buffer. Resizes if doing so would exceed
   *      the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param off The start offset to write to.
   * @param data The data to append.
   * @param len The number of bytes to copy.
   * @return The original buffer, for chaining.
   */
  function write(
    buffer memory buf,
    uint256 off,
    bytes memory data,
    uint256 len
  ) internal pure returns (buffer memory) {
    require(len <= data.length);

    if (off + len > buf.capacity) {
      resize(buf, max(buf.capacity, len + off) * 2);
    }

    uint256 dest;
    uint256 src;
    assembly {
      // Memory address of the buffer data
      let bufptr := mload(buf)
      // Length of existing buffer data
      let buflen := mload(bufptr)
      // Start address = buffer address + offset + sizeof(buffer length)
      dest := add(add(bufptr, 32), off)
      // Update buffer length if we're extending it
      if gt(add(len, off), buflen) {
        mstore(bufptr, add(len, off))
      }
      src := add(data, 32)
    }

    // Copy word-length chunks while possible
    for (; len >= 32; len -= 32) {
      assembly {
        mstore(dest, mload(src))
      }
      dest += 32;
      src += 32;
    }

    // Copy remaining bytes
    unchecked {
      uint256 mask = (256**(32 - len)) - 1;
      assembly {
        let srcpart := and(mload(src), not(mask))
        let destpart := and(mload(dest), mask)
        mstore(dest, or(destpart, srcpart))
      }
    }

    return buf;
  }

  /**
   * @dev Appends a byte string to a buffer. Resizes if doing so would exceed
   *      the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param data The data to append.
   * @param len The number of bytes to copy.
   * @return The original buffer, for chaining.
   */
  function append(
    buffer memory buf,
    bytes memory data,
    uint256 len
  ) internal pure returns (buffer memory) {
    return write(buf, buf.buf.length, data, len);
  }

  /**
   * @dev Appends a byte string to a buffer. Resizes if doing so would exceed
   *      the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param data The data to append.
   * @return The original buffer, for chaining.
   */
  function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {
    return write(buf, buf.buf.length, data, data.length);
  }

  /**
   * @dev Writes a byte to the buffer. Resizes if doing so would exceed the
   *      capacity of the buffer.
   * @param buf The buffer to append to.
   * @param off The offset to write the byte at.
   * @param data The data to append.
   * @return The original buffer, for chaining.
   */
  function writeUint8(
    buffer memory buf,
    uint256 off,
    uint8 data
  ) internal pure returns (buffer memory) {
    if (off >= buf.capacity) {
      resize(buf, buf.capacity * 2);
    }

    assembly {
      // Memory address of the buffer data
      let bufptr := mload(buf)
      // Length of existing buffer data
      let buflen := mload(bufptr)
      // Address = buffer address + sizeof(buffer length) + off
      let dest := add(add(bufptr, off), 32)
      mstore8(dest, data)
      // Update buffer length if we extended it
      if eq(off, buflen) {
        mstore(bufptr, add(buflen, 1))
      }
    }
    return buf;
  }

  /**
   * @dev Appends a byte to the buffer. Resizes if doing so would exceed the
   *      capacity of the buffer.
   * @param buf The buffer to append to.
   * @param data The data to append.
   * @return The original buffer, for chaining.
   */
  function appendUint8(buffer memory buf, uint8 data) internal pure returns (buffer memory) {
    return writeUint8(buf, buf.buf.length, data);
  }

  /**
   * @dev Writes up to 32 bytes to the buffer. Resizes if doing so would
   *      exceed the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param off The offset to write at.
   * @param data The data to append.
   * @param len The number of bytes to write (left-aligned).
   * @return The original buffer, for chaining.
   */
  function write(
    buffer memory buf,
    uint256 off,
    bytes32 data,
    uint256 len
  ) private pure returns (buffer memory) {
    if (len + off > buf.capacity) {
      resize(buf, (len + off) * 2);
    }

    unchecked {
      uint256 mask = (256**len) - 1;
      // Right-align data
      data = data >> (8 * (32 - len));
      assembly {
        // Memory address of the buffer data
        let bufptr := mload(buf)
        // Address = buffer address + sizeof(buffer length) + off + len
        let dest := add(add(bufptr, off), len)
        mstore(dest, or(and(mload(dest), not(mask)), data))
        // Update buffer length if we extended it
        if gt(add(off, len), mload(bufptr)) {
          mstore(bufptr, add(off, len))
        }
      }
    }
    return buf;
  }

  /**
   * @dev Writes a bytes20 to the buffer. Resizes if doing so would exceed the
   *      capacity of the buffer.
   * @param buf The buffer to append to.
   * @param off The offset to write at.
   * @param data The data to append.
   * @return The original buffer, for chaining.
   */
  function writeBytes20(
    buffer memory buf,
    uint256 off,
    bytes20 data
  ) internal pure returns (buffer memory) {
    return write(buf, off, bytes32(data), 20);
  }

  /**
   * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed
   *      the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param data The data to append.
   * @return The original buffer, for chhaining.
   */
  function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {
    return write(buf, buf.buf.length, bytes32(data), 20);
  }

  /**
   * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed
   *      the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param data The data to append.
   * @return The original buffer, for chaining.
   */
  function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {
    return write(buf, buf.buf.length, data, 32);
  }

  /**
   * @dev Writes an integer to the buffer. Resizes if doing so would exceed
   *      the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param off The offset to write at.
   * @param data The data to append.
   * @param len The number of bytes to write (right-aligned).
   * @return The original buffer, for chaining.
   */
  function writeInt(
    buffer memory buf,
    uint256 off,
    uint256 data,
    uint256 len
  ) private pure returns (buffer memory) {
    if (len + off > buf.capacity) {
      resize(buf, (len + off) * 2);
    }

    uint256 mask = (256**len) - 1;
    assembly {
      // Memory address of the buffer data
      let bufptr := mload(buf)
      // Address = buffer address + off + sizeof(buffer length) + len
      let dest := add(add(bufptr, off), len)
      mstore(dest, or(and(mload(dest), not(mask)), data))
      // Update buffer length if we extended it
      if gt(add(off, len), mload(bufptr)) {
        mstore(bufptr, add(off, len))
      }
    }
    return buf;
  }

  /**
   * @dev Appends a byte to the end of the buffer. Resizes if doing so would
   * exceed the capacity of the buffer.
   * @param buf The buffer to append to.
   * @param data The data to append.
   * @return The original buffer.
   */
  function appendInt(
    buffer memory buf,
    uint256 data,
    uint256 len
  ) internal pure returns (buffer memory) {
    return writeInt(buf, buf.buf.length, data, len);
  }
}

File 15 of 32 : CBORChainlink.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.19;

import {BufferChainlink} from "./BufferChainlink.sol";

library CBORChainlink {
  using BufferChainlink for BufferChainlink.buffer;

  uint8 private constant MAJOR_TYPE_INT = 0;
  uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1;
  uint8 private constant MAJOR_TYPE_BYTES = 2;
  uint8 private constant MAJOR_TYPE_STRING = 3;
  uint8 private constant MAJOR_TYPE_ARRAY = 4;
  uint8 private constant MAJOR_TYPE_MAP = 5;
  uint8 private constant MAJOR_TYPE_TAG = 6;
  uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7;

  uint8 private constant TAG_TYPE_BIGNUM = 2;
  uint8 private constant TAG_TYPE_NEGATIVE_BIGNUM = 3;

  function encodeFixedNumeric(BufferChainlink.buffer memory buf, uint8 major, uint64 value) private pure {
    if(value <= 23) {
      buf.appendUint8(uint8((major << 5) | value));
    } else if (value <= 0xFF) {
      buf.appendUint8(uint8((major << 5) | 24));
      buf.appendInt(value, 1);
    } else if (value <= 0xFFFF) {
      buf.appendUint8(uint8((major << 5) | 25));
      buf.appendInt(value, 2);
    } else if (value <= 0xFFFFFFFF) {
      buf.appendUint8(uint8((major << 5) | 26));
      buf.appendInt(value, 4);
    } else {
      buf.appendUint8(uint8((major << 5) | 27));
      buf.appendInt(value, 8);
    }
  }

  function encodeIndefiniteLengthType(BufferChainlink.buffer memory buf, uint8 major) private pure {
    buf.appendUint8(uint8((major << 5) | 31));
  }

  function encodeUInt(BufferChainlink.buffer memory buf, uint value) internal pure {
    if(value > 0xFFFFFFFFFFFFFFFF) {
      encodeBigNum(buf, value);
    } else {
      encodeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(value));
    }
  }

  function encodeInt(BufferChainlink.buffer memory buf, int value) internal pure {
    if(value < -0x10000000000000000) {
      encodeSignedBigNum(buf, value);
    } else if(value > 0xFFFFFFFFFFFFFFFF) {
      encodeBigNum(buf, uint(value));
    } else if(value >= 0) {
      encodeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(uint256(value)));
    } else {
      encodeFixedNumeric(buf, MAJOR_TYPE_NEGATIVE_INT, uint64(uint256(-1 - value)));
    }
  }

  function encodeBytes(BufferChainlink.buffer memory buf, bytes memory value) internal pure {
    encodeFixedNumeric(buf, MAJOR_TYPE_BYTES, uint64(value.length));
    buf.append(value);
  }

  function encodeBigNum(BufferChainlink.buffer memory buf, uint value) internal pure {
    buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_BIGNUM));
    encodeBytes(buf, abi.encode(value));
  }

  function encodeSignedBigNum(BufferChainlink.buffer memory buf, int input) internal pure {
    buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_NEGATIVE_BIGNUM));
    encodeBytes(buf, abi.encode(uint256(-1 - input)));
  }

  function encodeString(BufferChainlink.buffer memory buf, string memory value) internal pure {
    encodeFixedNumeric(buf, MAJOR_TYPE_STRING, uint64(bytes(value).length));
    buf.append(bytes(value));
  }

  function startArray(BufferChainlink.buffer memory buf) internal pure {
    encodeIndefiniteLengthType(buf, MAJOR_TYPE_ARRAY);
  }

  function startMap(BufferChainlink.buffer memory buf) internal pure {
    encodeIndefiniteLengthType(buf, MAJOR_TYPE_MAP);
  }

  function endSequence(BufferChainlink.buffer memory buf) internal pure {
    encodeIndefiniteLengthType(buf, MAJOR_TYPE_CONTENT_FREE);
  }
}

File 16 of 32 : ENSResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

abstract contract ENSResolver {
  function addr(bytes32 node) public view virtual returns (address);
}

File 17 of 32 : 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 18 of 32 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

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

File 19 of 32 : ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

        return batchBalances;
    }

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

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

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

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

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

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

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

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

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

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

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

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

        address operator = _msgSender();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        address operator = _msgSender();

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

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

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

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

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

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

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

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

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

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

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

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

        address operator = _msgSender();

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

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

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

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

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

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

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

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

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

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

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

        return array;
    }
}

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

pragma solidity ^0.8.0;

import "../IERC1155.sol";

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

File 21 of 32 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 27 of 32 : 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 28 of 32 : 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 29 of 32 : 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 32 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

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

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

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint64","name":"subscriptionId","type":"uint64"},{"internalType":"address","name":"vrfCoordinator","type":"address"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"address","name":"_operatorAddress","type":"address"},{"internalType":"string","name":"_jobId","type":"string"},{"internalType":"address","name":"_link","type":"address"},{"internalType":"string","name":"_uri","type":"string"},{"internalType":"string","name":"__contractURI","type":"string"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"},{"internalType":"address","name":"_apiAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AmountOfEarnmToClaimIsZero","type":"error"},{"inputs":[],"name":"BadRequest","type":"error"},{"inputs":[],"name":"InsufficientBoxesBalance","type":"error"},{"inputs":[],"name":"InsufficientEarnmBalance","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidBlockTimestamp","type":"error"},{"inputs":[],"name":"InvalidBoxAmount","type":"error"},{"inputs":[],"name":"InvalidEaRequestState","type":"error"},{"inputs":[],"name":"InvalidMintFee","type":"error"},{"inputs":[],"name":"InvalidTierId","type":"error"},{"inputs":[],"name":"InvalidVrfState","type":"error"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"apiAddress","type":"address"}],"name":"ApiAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"baseMetadataURI","type":"string"}],"name":"BaseMetadataURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"batchesAmount","type":"uint256"}],"name":"BatchesAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"ChainlinkCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"ChainlinkFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oracle","type":"address"}],"name":"ChainlinkOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"ChainlinkRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"contractMetadataURI","type":"string"}],"name":"ContractMetadataURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EarnmDepositedByOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EarnmWithdrawnByOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimerAddress","type":"address"},{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"},{"indexed":false,"internalType":"uint8","name":"boxAmount","type":"uint8"}],"name":"FulfillBoxAmountSucceeded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimerAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"FulfillRandomWordsSucceeded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isEarnmClaimAllowed","type":"bool"}],"name":"IsEarnmClaimAllowedUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"jobId","type":"bytes32"}],"name":"JobIdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"mintFee","type":"uint256"}],"name":"MintFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimerAddress","type":"address"}],"name":"MysteryBoxRevealRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimerAddress","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"boxIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MysteryBoxesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimerAddress","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"boxIds","type":"uint256[]"}],"name":"MysteryBoxesMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operatorAddress","type":"address"}],"name":"OperatorAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[],"name":"_contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"apiAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"code","type":"string"},{"internalType":"address","name":"allowedAddress","type":"address"}],"name":"associateOneTimeCodeToAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"batchesAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_boxIds","type":"uint256[]"}],"name":"claimMysteryBoxes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_requestId","type":"bytes32"},{"internalType":"uint8","name":"_boxAmount","type":"uint8"}],"name":"fulfillBoxAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"boxIds","type":"uint256[]"}],"name":"getBoxTierAndBlockTsOfIds","outputs":[{"internalType":"uint256[3][]","name":"","type":"uint256[3][]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEarnmBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEarnmInVestingProcess","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNames","outputs":[{"internalType":"string[]","name":"","type":"string[]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"string","name":"code","type":"string"}],"name":"getOneTimeCodeToAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tierId","type":"uint256"}],"name":"getSenderBoxIdsAndBlockTssOfTier","outputs":[{"internalType":"uint256[2][]","name":"","type":"uint256[2][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"getSenderBoxIdsByTiers","outputs":[{"internalType":"uint256[][]","name":"","type":"uint256[][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tierId","type":"uint256"}],"name":"getSenderTierBoxIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tierId","type":"uint256"},{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"resultsPerPage","type":"uint256"}],"name":"getSenderTierBoxIdsPaginated","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isEarnmClaimAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"jobId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operatorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ownerDepositEarnm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isEarnmClaimAllowed","type":"bool"}],"name":"ownerModifyIsEarnmClaimAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ownerWithdrawEarnm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"code","type":"string"}],"name":"revealMysteryBoxes","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_apiAddress","type":"address"}],"name":"setApiAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchesAmount","type":"uint256"}],"name":"setBatchesAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_chainlinkNodeAddress","type":"address"}],"name":"setChainlinkNodeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"__contractURI","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_jobId","type":"string"}],"name":"setJobId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintFee","type":"uint256"}],"name":"setMintFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operatorAddress","type":"address"}],"name":"setOperatorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newuri","type":"string"}],"name":"setURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenid","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]

610140604052600160045567016345785d8a0000600f5560016010553480156200002857600080fd5b506040516200622d3803806200622d8339810160408190526200004b91620004ef565b6001600160a01b038a16608052843380600081620000b05760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600680546001600160a01b0319166001600160a01b0384811691909117909155811615620000e357620000e38162000219565b5050600160085550620000f681620002c5565b506001600160a01b0388166200011f5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038116620001475760405163e6c4247b60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b038816179055600380546001600160a01b0319166001600160a01b038b161790556200018887620002d7565b6020556001600160a01b038a1660a0526001600160401b038b1661010052610120829052620001b7856200031b565b6011620001c58582620006ad565b50600d80546001600160a01b03199081166001600160a01b0393841617909155600e80549091169882169890981790975550851660c052505090911660e05250506021805460ff1916905550620007ae9050565b336001600160a01b03821603620002735760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401620000a7565b600780546001600160a01b0319166001600160a01b03838116918217909255600654604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b600b620002d38282620006ad565b5050565b805160009082908203620002ee5750600092915050565b60208151111562000312576040516341cc6b2160e01b815260040160405180910390fd5b50506020015190565b620003256200038f565b805160000362000348576040516341cc6b2160e01b815260040160405180910390fd5b6200035381620002c5565b7fd926fde11e1623e83f8becaf0d50ebe506b5bb4b70570742a0bb36901f65a5d98160405162000384919062000779565b60405180910390a150565b6006546001600160a01b03163314620003eb5760405162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e6572000000000000000000006044820152606401620000a7565b565b80516001600160401b03811681146200040557600080fd5b919050565b80516001600160a01b03811681146200040557600080fd5b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004555781810151838201526020016200043b565b50506000910152565b600082601f8301126200047057600080fd5b81516001600160401b03808211156200048d576200048d62000422565b604051601f8301601f19908116603f01168101908282118183101715620004b857620004b862000422565b81604052838152866020858801011115620004d257600080fd5b620004e584602083016020890162000438565b9695505050505050565b60008060008060008060008060008060006101608c8e0312156200051257600080fd5b6200051d8c620003ed565b9a506200052d60208d016200040a565b99506200053d60408d016200040a565b98506200054d60608d016200040a565b60808d01519098506001600160401b038111156200056a57600080fd5b620005788e828f016200045e565b9750506200058960a08d016200040a565b60c08d01519096506001600160401b03811115620005a657600080fd5b620005b48e828f016200045e565b60e08e015190965090506001600160401b03811115620005d357600080fd5b620005e18e828f016200045e565b945050620005f36101008d016200040a565b92506101208c015191506200060c6101408d016200040a565b90509295989b509295989b9093969950565b600181811c908216806200063357607f821691505b6020821081036200065457634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620006a857600081815260208120601f850160051c81016020861015620006835750805b601f850160051c820191505b81811015620006a4578281556001016200068f565b5050505b505050565b81516001600160401b03811115620006c957620006c962000422565b620006e181620006da84546200061e565b846200065a565b602080601f831160018114620007195760008415620007005750858301515b600019600386901b1c1916600185901b178555620006a4565b600085815260208120601f198616915b828110156200074a5788860151825594840194600190910190840162000729565b5085821015620007695787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208152600082518060208401526200079a81604085016020870162000438565b601f01601f19169190910160400192915050565b60805160a05160c05160e0516101005161012051615a08620008256000396000611d4b01526000611d7901526000505060008181610fc4015281816112f101528181611400015281816115bc015281816121d501526122c101526000611dba015260008181610aa60152610ae80152615a086000f3fe6080604052600436106102665760003560e01c80636fb1d08111610144578063c20652fe116100b6578063e62a6e151161007a578063e62a6e151461074f578063e8a3d4851461076f578063e985e9c514610784578063eddd0d9c146107cd578063f242432a146107ed578063f2fde38b1461080d57600080fd5b8063c20652fe146106c2578063c2939d97146106e2578063cd838f0f146106f8578063d55441b51461071a578063e546bb0c1461072f57600080fd5b8063938e3d7b11610108578063938e3d7b1461061a578063a22cb4651461063a578063ac12f64e1461065a578063bae716141461067a578063bf693cdb1461069a578063c0e72740146106ad57600080fd5b80636fb1d0811461056d57806379ba50971461059a5780638158e6ae146105af57806388ef544c146105cf5780638da5cb5b146105fc57600080fd5b80632f1d5a60116101dd5780634a008141116101a15780634a008141146104bb5780634e1273f4146104d5578063626c2091146104f5578063698504c81461050a5780636c151876146105205780636ebd386e1461054d57600080fd5b80632f1d5a601461040d57806331a99a091461042d578063344701581461044d5780633b1ef5421461047b57806345e9724a1461049b57600080fd5b8063127effb21161022f578063127effb21461034a578063129fc1c01461038257806313966db5146103a25780631fe543e3146103b85780632a15218e146103d85780632eb2c2d6146103ed57600080fd5b8062fdd58e1461026b57806301ffc9a71461029e57806302fe5305146102ce5780630e89341c146102f057806312364cb91461031d575b600080fd5b34801561027757600080fd5b5061028b610286366004614935565b61082d565b6040519081526020015b60405180910390f35b3480156102aa57600080fd5b506102be6102b9366004614975565b6108c8565b6040519015158152602001610295565b3480156102da57600080fd5b506102ee6102e9366004614a47565b610918565b005b3480156102fc57600080fd5b5061031061030b366004614a7b565b610985565b6040516102959190614ae4565b34801561032957600080fd5b5061033d610338366004614935565b6109c0565b6040516102959190614b27565b34801561035657600080fd5b50600e5461036a906001600160a01b031681565b6040516001600160a01b039091168152602001610295565b34801561038e57600080fd5b506102ee61039d366004614a47565b610a35565b3480156103ae57600080fd5b5061028b600f5481565b3480156103c457600080fd5b506102ee6103d3366004614bce565b610a9b565b3480156103e457600080fd5b5061028b610b23565b3480156103f957600080fd5b506102ee610408366004614c14565b610b2e565b34801561041957600080fd5b506102ee610428366004614cbd565b610b7a565b34801561043957600080fd5b506102ee610448366004614cd8565b610bf7565b34801561045957600080fd5b5061046d610468366004614d0e565b610dff565b604051610295929190614d47565b34801561048757600080fd5b506102ee610496366004614a7b565b610faf565b3480156104a757600080fd5b506102ee6104b6366004614d69565b61101c565b3480156104c757600080fd5b506021546102be9060ff1681565b3480156104e157600080fd5b5061033d6104f0366004614d9d565b61147b565b34801561050157600080fd5b5061028b6115a4565b34801561051657600080fd5b5061028b60105481565b34801561052c57600080fd5b5061054061053b366004614d69565b611634565b6040516102959190614e5d565b34801561055957600080fd5b506102ee610568366004614ed5565b611750565b34801561057957600080fd5b5061058d610588366004614cbd565b611799565b6040516102959190614ef2565b3480156105a657600080fd5b506102ee611882565b3480156105bb57600080fd5b506102ee6105ca366004614a7b565b611930565b3480156105db57600080fd5b506105ef6105ea366004614935565b6119a9565b6040516102959190614f7c565b34801561060857600080fd5b506006546001600160a01b031661036a565b34801561062657600080fd5b506102ee610635366004614a47565b611b25565b34801561064657600080fd5b506102ee610655366004614fe5565b611b99565b34801561066657600080fd5b5061036a610675366004615011565b611ba4565b34801561068657600080fd5b506102ee610695366004614cbd565b611bd5565b6102ee6106a8366004614a47565b611c58565b3480156106b957600080fd5b50610310611ee9565b3480156106ce57600080fd5b506102ee6106dd366004614cbd565b611f77565b3480156106ee57600080fd5b5061028b60205481565b34801561070457600080fd5b5061070d611ff4565b6040516102959190615054565b34801561072657600080fd5b506102ee6121b5565b34801561073b57600080fd5b50600d5461036a906001600160a01b031681565b34801561075b57600080fd5b506102ee61076a3660046150b6565b612320565b34801561077b57600080fd5b506103106123d2565b34801561079057600080fd5b506102be61079f366004615103565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205460ff1690565b3480156107d957600080fd5b506102ee6107e8366004614a7b565b6123fa565b3480156107f957600080fd5b506102ee61080836600461512d565b612460565b34801561081957600080fd5b506102ee610828366004614cbd565b6124a5565b60006001600160a01b03831661089d5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b5060008181526009602090815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b14806108f957506001600160e01b031982166303a24d0760e21b145b806108c257506301ffc9a760e01b6001600160e01b03198316146108c2565b6109206124b6565b8051600003610942576040516341cc6b2160e01b815260040160405180910390fd5b61094b8161250b565b7fd926fde11e1623e83f8becaf0d50ebe506b5bb4b70570742a0bb36901f65a5d98160405161097a9190614ae4565b60405180910390a150565b606061099082612517565b610999836125ab565b6040516020016109aa929190615191565b6040516020818303038152906040529050919050565b6001600160a01b0382166000908152602360209081526040808320848452825291829020805483518184028101840190945280845260609392830182828015610a2857602002820191906000526020600020905b815481526020019060010190808311610a14575b5050505050905092915050565b610a3d6124b6565b8051602014610a5f576040516341cc6b2160e01b815260040160405180910390fd5b610a688161263d565b60208181556040519182527ff1a050b089446eb1e4e418e9f558b0bab8205507c47dabeadf24a9f3b9c15253910161097a565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610b155760405163073e64fd60e21b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604401610894565b610b1f828261267f565b5050565b6000806108c2612931565b6001600160a01b038516331480610b4a5750610b4a853361079f565b610b665760405162461bcd60e51b8152600401610894906151d0565b610b73858585858561299b565b5050505050565b610b826124b6565b6001600160a01b038116610ba95760405163e6c4247b60e01b815260040160405180910390fd5b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f7b77641e3e43914132d91ce9450aac1cbf5aa9c28ab80d416d241a5c456d837d9060200161097a565b60008281526005602052604090205482906001600160a01b03163314610c705760405162461bcd60e51b815260206004820152602860248201527f536f75726365206d75737420626520746865206f7261636c65206f6620746865604482015267081c995c5d595cdd60c21b6064820152608401610894565b60008181526005602052604080822080546001600160a01b03191690555182917f7cc135e0cebb02c3480ae5d74d377283180a2601f8f644edf7987b009316c63a91a260008381526028602052604090205460ff1615610ce357604051636db38e6d60e11b815260040160405180910390fd5b6000838152602860209081526040808320805460ff1916600117905560279091529020546001600160a01b031680610d2e5760405163e6c4247b60e01b815260040160405180910390fd5b60008360ff16118015610d45575060648360ff1611155b610d62576040516302a34b0f60e31b815260040160405180910390fd5b6001600160a01b038116600090815260266020526040902054610d86848284612b48565b6001600160a01b0382166000818152602660209081526040808320839055888352602782529182902080546001600160a01b0319169055815188815260ff8816918101919091527f50f9cbb82b664c70bc2b8443d65cbabfbad3eaef92cba0b1357ec86fcd94df36910160405180910390a25050505050565b6001600160a01b038416600090815260236020908152604080832086845282528083208054825181850281018501909352808352606094938493929190830182828015610e6b57602002820191906000526020600020905b815481526020019060010190808311610e57575b505050505090508051600003610e94575050604080516000808252602082019092529150610fa6565b600084610ea2600188615234565b610eac9190615247565b905081518110610ed2575060408051600081526020810190915290519092509050610fa6565b6000610ede868361525e565b90508251811115610eed575081515b6000610ef98383615234565b6001600160401b03811115610f1057610f10614992565b604051908082528060200260200182016040528015610f39578160200160208202803683370190505b50905060005b8151811015610f9a5784610f53828661525e565b81518110610f6357610f63615271565b6020026020010151828281518110610f7d57610f7d615271565b602090810291909101015280610f9281615287565b915050610f3f565b50925192945091925050505b94509492505050565b610fb76124b6565b610fec6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333084612da0565b6040518181527f65b09eea04b6df90dff75de9ed57261250e71c1b7941a4e41e431e1437fc92c09060200161097a565b611024612e11565b60215460ff16611046576040516282b42960e81b815260040160405180910390fd5b6000815111611067576040516282b42960e81b815260040160405180910390fd5b60408051600680825260e082019092526000918291906020820160c08036833701905050905060005b8351811015611239576000602260008684815181106110b1576110b1615271565b6020908102919091018101518252818101929092526040908101600020815160608101835281548152600182015493810193909352600201546001600160a01b0316908201819052909150331461111a576040516282b42960e81b815260040160405180910390fd5b6000816020015111801561113357506006816020015111155b6111505760405163907e751560e01b815260040160405180910390fd5b82816020015160066111629190615234565b8151811061117257611172615271565b60200260200101805180919061118790615287565b9052506020810151815161119b9190612e6a565b6111a5908561525e565b935060006111b483600161525e565b90505b8551811015611224578581815181106111d2576111d2615271565b60200260200101518684815181106111ec576111ec615271565b602002602001015103611212576040516341cc6b2160e01b815260040160405180910390fd5b8061121c81615287565b9150506111b7565b5050808061123190615287565b915050611090565b50600061124533612f54565b905060005b81518110156112b75782818151811061126557611265615271565b602002602001015182828151811061127f5761127f615271565b602002602001015110156112a5576040516282b42960e81b815260040160405180910390fd5b806112af81615287565b91505061124a565b50826000036112d95760405163500802a160e11b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136491906152a0565b90506000841180156113765750600081115b80156113825750838110155b61139f57604051632d4dd87f60e01b815260040160405180910390fd5b6113b1336113ab6130d7565b856131b8565b60005b85518110156113f2576113e08682815181106113d2576113d2615271565b6020026020010151336133cf565b806113ea81615287565b9150506113b4565b506114276001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338661351e565b336001600160a01b03167f0385f3b80e145b046d4b1ff30d63ef9b9dd72269394cfdd97d317d997f436ac38686604051611462929190614d47565b60405180910390a2505050506114786001600855565b50565b606081518351146114e05760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610894565b600083516001600160401b038111156114fb576114fb614992565b604051908082528060200260200182016040528015611524578160200160208202803683370190505b50905060005b845181101561159c5761156f85828151811061154857611548615271565b602002602001015185838151811061156257611562615271565b602002602001015161082d565b82828151811061158157611581615271565b602090810291909101015261159581615287565b905061152a565b509392505050565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa15801561160b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162f91906152a0565b905090565b6060600082516001600160401b0381111561165157611651614992565b60405190808252806020026020018201604052801561168a57816020015b61167761484f565b81526020019060019003908161166f5790505b50905060005b83518110156117495760008482815181106116ad576116ad615271565b602090810291909101810151600081815260228352604090819020815160608082018452825480835260018401548388018190526002909401546001600160a01b03168386015284519182018552858252958101839052928301859052875193955093909290919087908790811061172757611727615271565b602002602001018190525050505050808061174190615287565b915050611690565b5092915050565b6117586124b6565b6021805460ff19168215159081179091556040519081527f5e3f6ff8ea2235d60e824a2ad40aaa526bbf7720612d8f19b7ef8a6b67b897389060200161097a565b60408051600680825260e0820190925260609160009190816020015b60608152602001906001900390816117b557905050905060065b8015611749576001600160a01b038416600090815260236020908152604080832084845282528083208054825181850281018501909352808352919290919083018282801561183d57602002820191906000526020600020905b815481526020019060010190808311611829575b5050505050905080838360066118539190615234565b8151811061186357611863615271565b602002602001018190525050808061187a906152b9565b9150506117cf565b6007546001600160a01b031633146118d55760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b6044820152606401610894565b600680546001600160a01b0319808216339081179093556007805490911690556040516001600160a01b03909116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b6119386124b6565b600081118015611949575060105481115b801561195757506103e88111155b611974576040516341cc6b2160e01b815260040160405180910390fd5b60108190556040518181527f24b98f806e4d141480cbd184b85f98af8e8af90649c2340579e556fb29327c2a9060200161097a565b6001600160a01b03821660009081526023602090815260408083208484528252808320805482518185028101850190935280835260609493830182828015611a1057602002820191906000526020600020905b8154815260200190600101908083116119fc575b50505050509050600081516001600160401b03811115611a3257611a32614992565b604051908082528060200260200182016040528015611a6b57816020015b611a5861486d565b815260200190600190039081611a505790505b50905060005b8251811015611b1c576000838281518110611a8e57611a8e615271565b602090810291909101810151600081815260228352604090819020815160608101835281548082526001830154828701526002909201546001600160a01b0316818401528251808401909352838352938201819052865192945091869086908110611afb57611afb615271565b60200260200101819052505050508080611b1490615287565b915050611a71565b50949350505050565b611b2d6124b6565b60118054611b3a906152d0565b9050600003611b5c576040516341cc6b2160e01b815260040160405180910390fd5b6011611b68828261534a565b507ffe1e68475db2c7a4962ab936f3084ce9cc5edaed551a4893b08b98cac24bef6b601160405161097a9190615409565b610b1f338383613553565b600060256000611bb48486613633565b81526020810191909152604001600020546001600160a01b03169392505050565b611bdd6124b6565b6001600160a01b038116611c045760405163e6c4247b60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0383161790556040516001600160a01b03821681527ffb815385f643693ee2547a3ea422030c533509d0370d8f919ef1f1aba68bcf1d9060200161097a565b611c60612e11565b8051600003611c82576040516341cc6b2160e01b815260040160405180910390fd5b6000611c8e8233613633565b6000818152602560205260409020549091506001600160a01b03163314611cc7576040516282b42960e81b815260040160405180910390fd5b600081815260256020526040902080546001600160a01b0319169055600f543414611d055760405163c288bf8f60e01b815260040160405180910390fd5b600e546000906001600160a01b0316348280808084865af1925082611d3c576040516282b42960e81b815260040160405180910390fd5b6040516305d3b1d360e41b81527f000000000000000000000000000000000000000000000000000000000000000060048201526001600160401b037f0000000000000000000000000000000000000000000000000000000000000000166024820152601e6044820152620f42406064820152600160848201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690635d3b1d309060a4016020604051808303816000875af1158015611e0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2f91906152a0565b90506040518060400160405280336001600160a01b0316815260200187604051602001611e5c9190614ae4565b60408051808303601f190181529181529152600083815260296020908152919020825181546001600160a01b0319166001600160a01b03909116178155908201516001820190611eac908261534a565b50506040513391507f2c0c0ba8c38db82429c4ccac00b5532ba435982913b8c2c88fee59f2ef3cf96b90600090a250505050506114786001600855565b60118054611ef6906152d0565b80601f0160208091040260200160405190810160405280929190818152602001828054611f22906152d0565b8015611f6f5780601f10611f4457610100808354040283529160200191611f6f565b820191906000526020600020905b815481529060010190602001808311611f5257829003601f168201915b505050505081565b611f7f6124b6565b6001600160a01b038116611fa65760405163e6c4247b60e01b815260040160405180910390fd5b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527ffd3e8d123f8f642884c0d014771c2581ed12ce65ae55069285e86dd6a355dff49060200161097a565b60408051600680825260e0820190925260609160009190816020015b60608152602001906001900390816120105790505090506040518060400160405280600c81526020016b09af2e8d0d2c6c2d84084def60a31b8152508160008151811061205f5761205f615271565b60200260200101819052506040518060400160405280600d81526020016c098cacecadcc8c2e4f24084def609b1b815250816001815181106120a3576120a3615271565b60200260200101819052506040518060400160405280600881526020016708ae0d2c64084def60c31b815250816002815181106120e2576120e2615271565b6020026020010181905250604051806040016040528060088152602001670a4c2e4ca4084def60c31b8152508160038151811061212157612121615271565b60200260200101819052506040518060400160405280600c81526020016b0aadcc6dedadadedc4084def60a31b8152508160048151811061216457612164615271565b60200260200101819052506040518060400160405280600a815260200169086dedadadedc4084def60b31b815250816005815181106121a5576121a5615271565b6020908102919091010152919050565b6121bd6124b6565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015612224573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224891906152a0565b90508060000361226b57604051632d4dd87f60e01b815260040160405180910390fd5b6000612275612931565b90506000818311612287576000612291565b6122918284615234565b9050806000036122b457604051632d4dd87f60e01b815260040160405180910390fd5b6122e86001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338361351e565b6040518181527fb6deef47dcb3d0a897412bc9f5d1d147d7cd6d742c46045f40db924bfa67e8b39060200160405180910390a1505050565b600d546001600160a01b031633811461234b576040516282b42960e81b815260040160405180910390fd5b825160000361236d576040516341cc6b2160e01b815260040160405180910390fd5b6001600160a01b038216612394576040516341cc6b2160e01b815260040160405180910390fd5b60006123a08484613633565b600090815260256020526040902080546001600160a01b0319166001600160a01b039490941693909317909255505050565b606060116040516020016123e69190615492565b604051602081830303815290604052905090565b6124026124b6565b678ac7230489e8000081111561242b5760405163c288bf8f60e01b815260040160405180910390fd5b600f8190556040518181527f38fbb1c8b109c430f0c030e7ed076cf5611a307773a4e8e365601e8f8bceaec69060200161097a565b6001600160a01b03851633148061247c575061247c853361079f565b6124985760405162461bcd60e51b8152600401610894906151d0565b610b738585858585613666565b6124ad6124b6565b611478816137a2565b6006546001600160a01b031633146125095760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b6044820152606401610894565b565b600b610b1f828261534a565b6060600b8054612526906152d0565b80601f0160208091040260200160405190810160405280929190818152602001828054612552906152d0565b801561259f5780601f106125745761010080835404028352916020019161259f565b820191906000526020600020905b81548152906001019060200180831161258257829003601f168201915b50505050509050919050565b606060006125b88361384c565b60010190506000816001600160401b038111156125d7576125d7614992565b6040519080825280601f01601f191660200182016040528015612601576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461260b57509392505050565b8051600090829082036126535750600092915050565b602081511115612676576040516341cc6b2160e01b815260040160405180910390fd5b50506020015190565b6000828152602a602052604090205460ff16156126af5760405163ac53670960e01b815260040160405180910390fd5b6000828152602a60209081526040808320805460ff1916600190811790915560298352818420825180840190935280546001600160a01b0316835290810180549293919291840191612700906152d0565b80601f016020809104026020016040519081016040528092919081815260200182805461272c906152d0565b80156127795780601f1061274e57610100808354040283529160200191612779565b820191906000526020600020905b81548152906001019060200180831161275c57829003601f168201915b5050509190925250508151919250506001600160a01b03166127ae5760405163e6c4247b60e01b815260040160405180910390fd5b80516020820151835184906000906127c8576127c8615271565b6020908102919091018101516001600160a01b0384166000908152602683526040812091909155905461280390306331a99a0960e01b613924565b604080518082019091526004815263636f646560e01b602082015290915061282d90829084613949565b612888604051806040016040528060078152602001666164647265737360c81b8152508460405160200161287091906001600160a01b0391909116815260200190565b60408051601f19818403018152919052839190613949565b6000612895826000613967565b600081815260276020908152604080832080546001600160a01b038a166001600160a01b0319918216179091558b845260299092528220805490911681559192506128e3600183018261488b565b5050836001600160a01b03167f268d41957d793c5db1ea517d7df76da1e28f8b844bd87e26a4c42b242b4b459c8860405161292091815260200190565b60405180910390a250505050505050565b60008060065b80156129955760006019826007811061295257612952615271565b015490506000612963836001613981565b905060006129718284615247565b905061297d818661525e565b9450505050808061298d906152b9565b915050612937565b50919050565b81518351146129bc5760405162461bcd60e51b81526004016108949061551e565b6001600160a01b0384166129e25760405162461bcd60e51b815260040161089490615566565b336129f1818787878787613a22565b60005b8451811015612ada576000858281518110612a1157612a11615271565b602002602001015190506000858381518110612a2f57612a2f615271565b60209081029190910181015160008481526009835260408082206001600160a01b038e168352909352919091205490915081811015612a805760405162461bcd60e51b8152600401610894906155ab565b60008381526009602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612abf90849061525e565b9250508190555050505080612ad390615287565b90506129f4565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051612b2a9291906155f5565b60405180910390a4612b40818787878787613a5f565b505050505050565b60408051600680825260e082019092526000916020820160c08036833701905050905060008460ff166001600160401b03811115612b8857612b88614992565b604051908082528060200260200182016040528015612bb1578160200160208202803683370190505b50905060008560ff16118015612bcb575060648560ff1611155b612be8576040516302a34b0f60e31b815260040160405180910390fd5b6010546040805160e081019182905260009160129060079082845b815481526020019060010190808311612c03575050505050905060005b8760ff168160ff161015612d44576000600c60008154612c3f90615287565b91829055506040805160208082018c9052818301849052825180830384018152606090920190925280519101209091506000612c7e620f42408361561a565b90506000612c8d828888613bc3565b9050612c9a848b83613c80565b60128160078110612cad57612cad615271565b0160008154612cbb90615287565b9182905550868260078110612cd257612cd2615271565b602002015287518490899060ff8816908110612cf057612cf0615271565b602090810291909101015288612d07826006615234565b81518110612d1757612d17615271565b602002602001018051612d2990615287565b905250839250612d3c915082905061562e565b915050612c20565b50612d6785612d516130d7565b8660405180602001604052806000815250613d4e565b846001600160a01b03167f58f188356312b86d65ea217eeb39386250d8ee5fa6df17fae35d8fabda7518ed846040516129209190614b27565b6040516001600160a01b0380851660248301528316604482015260648101829052612e0b9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613ee3565b50505050565b600260085403612e635760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610894565b6002600855565b60008083118015612e7c575060068311155b612e995760405163907e751560e01b815260040160405180910390fd5b428211158015612ea95750600082115b612ec657604051634d0b0a4160e01b815260040160405180910390fd5b600062015180612ed68442615234565b612ee0919061564d565b9050600060b4821015612f0957612ef885600a613981565b612f02908261525e565b9050612f4c565b60b48210158015612f1b575061016d82105b15612f2b57612ef8856002613981565b61016d8210612f4c57612f3f856001613981565b612f49908261525e565b90505b949350505050565b60408051600680825260e08201909252606091600091906020820160c08036833701905050905060065b8015612fcb578382612f91836006615234565b81518110612fa157612fa1615271565b6001600160a01b039092166020928302919091019091015280612fc3816152b9565b915050612f7e565b506000612fda826104f06130d7565b9050600081600081518110612ff157612ff1615271565b6020026020010151118061301f575060008160018151811061301557613015615271565b6020026020010151115b80613044575060008160028151811061303a5761303a615271565b6020026020010151115b80613069575060008160038151811061305f5761305f615271565b6020026020010151115b8061308e575060008160048151811061308457613084615271565b6020026020010151115b806130b357506000816005815181106130a9576130a9615271565b6020026020010151115b6130d057604051635d97b6a360e01b815260040160405180910390fd5b9392505050565b60408051600680825260e08201909252606091600091906020820160c08036833701905050905060068160008151811061311357613113615271565b60200260200101818152505060058160018151811061313457613134615271565b60200260200101818152505060048160028151811061315557613155615271565b60200260200101818152505060038160038151811061317657613176615271565b60200260200101818152505060028160048151811061319757613197615271565b6020026020010181815250506001816005815181106121a5576121a5615271565b6001600160a01b03831661321a5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610894565b805182511461323b5760405162461bcd60e51b81526004016108949061551e565b600033905061325e81856000868660405180602001604052806000815250613a22565b60005b835181101561336257600084828151811061327e5761327e615271565b60200260200101519050600084838151811061329c5761329c615271565b60209081029190910181015160008481526009835260408082206001600160a01b038c1683529093529190912054909150818110156133295760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610894565b60009283526009602090815260408085206001600160a01b038b168652909152909220910390558061335a81615287565b915050613261565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb86866040516133b39291906155f5565b60405180910390a4604080516020810190915260009052612e0b565b60008281526022602090815260408083206001908101546001600160a01b03861680865260248552838620828752855283862088875285528386205490865260238552838620828752909452918420805492949092909183916134329190615234565b8154811061344257613442615271565b906000526020600020015490508082848154811061346257613462615271565b90600052602060002001819055508180548061348057613480615661565b6000828152602080822060001990840181018390559092019092556001600160a01b03871682526024815260408083208784528252808320848452825280832086905588835280832083905560229091528120818155600181019190915560020180546001600160a01b03191690556019846007811061350257613502615271565b018054906000613511836152b9565b9190505550505050505050565b6040516001600160a01b03831660248201526044810182905261354e90849063a9059cbb60e01b90606401612dd4565b505050565b816001600160a01b0316836001600160a01b0316036135c65760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610894565b6001600160a01b038381166000818152600a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60008282604051602001613648929190615677565b60405160208183030381529060405280519060200120905092915050565b6001600160a01b03841661368c5760405162461bcd60e51b815260040161089490615566565b33600061369885613fb8565b905060006136a585613fb8565b90506136b5838989858589613a22565b60008681526009602090815260408083206001600160a01b038c168452909152902054858110156136f85760405162461bcd60e51b8152600401610894906155ab565b60008781526009602090815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061373790849061525e565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4613797848a8a8a8a8a614003565b505050505050505050565b336001600160a01b038216036137fa5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610894565b600780546001600160a01b0319166001600160a01b03838116918217909255600654604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b831061388b5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106138b7576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106138d557662386f26fc10000830492506010015b6305f5e10083106138ed576305f5e100830492506008015b612710831061390157612710830492506004015b60648310613913576064830492506002015b600a83106108c25760010192915050565b61392c6148c5565b6139346148c5565b613940818686866140be565b95945050505050565b608083015161395890836140fb565b608083015161354e9082614112565b6003546000906130d0906001600160a01b0316848461411f565b6000826001036139be5761399682600a615247565b6139a26012600a615785565b6139ad906019615247565b6139b7919061564d565b90506108c2565b6000836006036139ce57506207a1205b836005036139db575061c3505b836004036139e857506113885b836003036139f557506101f45b83600203613a01575060055b82613a0e6012600a615785565b613a189083615247565b612f4c919061564d565b6001600160a01b03851615801590613a4257506001600160a01b03841615155b15612b40576040516282b42960e81b815260040160405180910390fd5b6001600160a01b0384163b15612b405760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190613aa39089908990889088908890600401615791565b6020604051808303816000875af1925050508015613ade575060408051601f3d908101601f19168201909252613adb918101906157ef565b60015b613b8a57613aea61580c565b806308c379a003613b235750613afe615828565b80613b095750613b25565b8060405162461bcd60e51b81526004016108949190614ae4565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610894565b6001600160e01b0319811663bc197c8160e01b14613bba5760405162461bcd60e51b8152600401610894906158b1565b50505050505050565b600060065b8015613c755760018114613c7557600081600603613be4575060015b81600503613bf0575060055b81600403613bfc575060325b81600303613c0957506107d05b81600203613c17575062030d405b6000848360078110613c2b57613c2b615271565b602002015190506000613c3e8784615247565b821090508288108015613c4e5750805b15613c5f57839450505050506130d0565b5050508080613c6d906152b9565b915050613bc8565b506001949350505050565b6040805160608101825242815260208082018481526001600160a01b0386811684860181815260008a8152602286528781209651875593516001808801919091559051600290960180546001600160a01b03191696909316959095179091558082526023835284822086835280845285832080549284526024855286842088855285528684208a85528552958320829055835292830184559283529091200183905560198160078110613d3557613d35615271565b018054906000613d4483615287565b9190505550505050565b6001600160a01b038416613dae5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610894565b8151835114613dcf5760405162461bcd60e51b81526004016108949061551e565b33613ddf81600087878787613a22565b60005b8451811015613e7b57838181518110613dfd57613dfd615271565b602002602001015160096000878481518110613e1b57613e1b615271565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254613e63919061525e565b90915550819050613e7381615287565b915050613de2565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051613ecc9291906155f5565b60405180910390a4610b7381600087878787613a5f565b6000613f38826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166141b29092919063ffffffff16565b9050805160001480613f59575080806020019051810190613f5991906158f9565b61354e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610894565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110613ff257613ff2615271565b602090810291909101015292915050565b6001600160a01b0384163b15612b405760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906140479089908990889088908890600401615916565b6020604051808303816000875af1925050508015614082575060408051601f3d908101601f1916820190925261407f918101906157ef565b60015b61408e57613aea61580c565b6001600160e01b0319811663f23a6e6160e01b14613bba5760405162461bcd60e51b8152600401610894906158b1565b6140c66148c5565b6140d685608001516101006141c1565b50509183526001600160a01b031660208301526001600160e01b031916604082015290565b6141088260038351614226565b61354e828261432d565b6141088260028351614226565b60045460009061413081600161525e565b600455835160408086015160808701515191516000936320214ca360e11b936141689386938493923092918a91600191602401615950565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915290506141a886838684614354565b9695505050505050565b6060612f4c84846000856144b2565b6040805180820190915260608152600060208201526141e160208361561a565b15614209576141f160208361561a565b6141fc906020615234565b614206908361525e565b91505b506020828101829052604080518085526000815290920101905290565b6017816001600160401b03161161424a57612e0b8360e0600585901b16831761458d565b60ff816001600160401b03161161428657614270836018611fe0600586901b161761458d565b50612e0b836001600160401b03831660016145b2565b61ffff816001600160401b0316116142c3576142ad836019611fe0600586901b161761458d565b50612e0b836001600160401b03831660026145b2565b63ffffffff816001600160401b031611614302576142ec83601a611fe0600586901b161761458d565b50612e0b836001600160401b03831660046145b2565b61431783601b611fe0600586901b161761458d565b50612e0b836001600160401b03831660086145b2565b6040805180820190915260608152600060208201526130d0838460000151518485516145d8565b6040516bffffffffffffffffffffffff193060601b1660208201526034810184905260009060540160408051808303601f1901815282825280516020918201206000818152600590925291812080546001600160a01b0319166001600160a01b038a1617905590925082917fb5e6e01e79f91267dc17b4e6314d5d4d03593d2ceee0fbb452b750bd70ea5af99190a2600254604051630200057560e51b81526001600160a01b0390911690634000aea090614417908890879087906004016159b8565b6020604051808303816000875af1158015614436573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061445a91906158f9565b612f4c5760405162461bcd60e51b815260206004820152602360248201527f756e61626c6520746f207472616e73666572416e6443616c6c20746f206f7261604482015262636c6560e81b6064820152608401610894565b6060824710156145135760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610894565b600080866001600160a01b0316858760405161452f91906159df565b60006040518083038185875af1925050503d806000811461456c576040519150601f19603f3d011682016040523d82523d6000602084013e614571565b606091505b5091509150614582878383876146c2565b979650505050505050565b6040805180820190915260608152600060208201526130d0838460000151518461473b565b604080518082019091526060815260006020820152612f4c848560000151518585614796565b60408051808201909152606081526000602082015282518211156145fb57600080fd5b602085015161460a838661525e565b111561463d5761463d8561462d87602001518786614628919061525e565b614817565b614638906002615247565b614828565b60008086518051876020830101935080888701111561465c5787860182525b505050602084015b6020841061469c578051825261467b60208361525e565b915061468860208261525e565b9050614695602085615234565b9350614664565b51815160001960208690036101000a019081169019919091161790525083949350505050565b6060831561473157825160000361472a576001600160a01b0385163b61472a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610894565b5081612f4c565b612f4c838361483f565b604080518082019091526060815260006020820152836020015183106147705761477084856020015160026146389190615247565b835180516020858301018481535080850361478c576001810182525b5093949350505050565b60408051808201909152606081526000602082015260208501516147ba858461525e565b11156147ce576147ce8561462d868561525e565b600060016147de84610100615785565b6147e89190615234565b905085518386820101858319825116178152508051848701111561480c5783860181525b509495945050505050565b6000818311156129955750816108c2565b815161483483836141c1565b50612e0b838261432d565b815115613b095781518083602001fd5b60405180606001604052806003906020820280368337509192915050565b60405180604001604052806002906020820280368337509192915050565b508054614897906152d0565b6000825580601f106148a7575050565b601f0160209004906000526020600020908101906114789190614900565b6040805160a0810182526000808252602080830182905282840182905260608084018390528451808601909552845283015290608082015290565b5b808211156149155760008155600101614901565b5090565b80356001600160a01b038116811461493057600080fd5b919050565b6000806040838503121561494857600080fd5b61495183614919565b946020939093013593505050565b6001600160e01b03198116811461147857600080fd5b60006020828403121561498757600080fd5b81356130d08161495f565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b03811182821017156149cd576149cd614992565b6040525050565b600082601f8301126149e557600080fd5b81356001600160401b038111156149fe576149fe614992565b604051614a15601f8301601f1916602001826149a8565b818152846020838601011115614a2a57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215614a5957600080fd5b81356001600160401b03811115614a6f57600080fd5b612f4c848285016149d4565b600060208284031215614a8d57600080fd5b5035919050565b60005b83811015614aaf578181015183820152602001614a97565b50506000910152565b60008151808452614ad0816020860160208601614a94565b601f01601f19169290920160200192915050565b6020815260006130d06020830184614ab8565b600081518084526020808501945080840160005b8381101561480c57815187529582019590820190600101614b0b565b6020815260006130d06020830184614af7565b60006001600160401b03821115614b5357614b53614992565b5060051b60200190565b600082601f830112614b6e57600080fd5b81356020614b7b82614b3a565b604051614b8882826149a8565b83815260059390931b8501820192828101915086841115614ba857600080fd5b8286015b84811015614bc35780358352918301918301614bac565b509695505050505050565b60008060408385031215614be157600080fd5b8235915060208301356001600160401b03811115614bfe57600080fd5b614c0a85828601614b5d565b9150509250929050565b600080600080600060a08688031215614c2c57600080fd5b614c3586614919565b9450614c4360208701614919565b935060408601356001600160401b0380821115614c5f57600080fd5b614c6b89838a01614b5d565b94506060880135915080821115614c8157600080fd5b614c8d89838a01614b5d565b93506080880135915080821115614ca357600080fd5b50614cb0888289016149d4565b9150509295509295909350565b600060208284031215614ccf57600080fd5b6130d082614919565b60008060408385031215614ceb57600080fd5b82359150602083013560ff81168114614d0357600080fd5b809150509250929050565b60008060008060808587031215614d2457600080fd5b614d2d85614919565b966020860135965060408601359560600135945092505050565b604081526000614d5a6040830185614af7565b90508260208301529392505050565b600060208284031215614d7b57600080fd5b81356001600160401b03811115614d9157600080fd5b612f4c84828501614b5d565b60008060408385031215614db057600080fd5b82356001600160401b0380821115614dc757600080fd5b818501915085601f830112614ddb57600080fd5b81356020614de882614b3a565b604051614df582826149a8565b83815260059390931b8501820192828101915089841115614e1557600080fd5b948201945b83861015614e3a57614e2b86614919565b82529482019490820190614e1a565b96505086013592505080821115614e5057600080fd5b50614c0a85828601614b5d565b602080825282518282018190526000919084820190604085019084805b82811015614eba57845184835b6003811015614ea457825182529188019190880190600101614e87565b5050509385019360609390930192600101614e7a565b5091979650505050505050565b801515811461147857600080fd5b600060208284031215614ee757600080fd5b81356130d081614ec7565b6000602080830181845280855180835260408601915060408160051b87010192508387016000805b83811015614f6e57888603603f19018552825180518088529088019088880190845b81811015614f585783518352928a0192918a0191600101614f3c565b5090975050509386019391860191600101614f1a565b509398975050505050505050565b60208082528251828201819052600091906040908185019086840185805b83811015614fd757825185835b6002811015614fc457825182529189019190890190600101614fa7565b5050509385019391860191600101614f9a565b509298975050505050505050565b60008060408385031215614ff857600080fd5b61500183614919565b91506020830135614d0381614ec7565b6000806040838503121561502457600080fd5b61502d83614919565b915060208301356001600160401b0381111561504857600080fd5b614c0a858286016149d4565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156150a957603f19888603018452615097858351614ab8565b9450928501929085019060010161507b565b5092979650505050505050565b600080604083850312156150c957600080fd5b82356001600160401b038111156150df57600080fd5b6150eb858286016149d4565b9250506150fa60208401614919565b90509250929050565b6000806040838503121561511657600080fd5b61511f83614919565b91506150fa60208401614919565b600080600080600060a0868803121561514557600080fd5b61514e86614919565b945061515c60208701614919565b9350604086013592506060860135915060808601356001600160401b0381111561518557600080fd5b614cb0888289016149d4565b600083516151a3818460208801614a94565b8351908301906151b7818360208801614a94565b64173539b7b760d91b9101908152600501949350505050565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b818103818111156108c2576108c261521e565b80820281158282048414176108c2576108c261521e565b808201808211156108c2576108c261521e565b634e487b7160e01b600052603260045260246000fd5b6000600182016152995761529961521e565b5060010190565b6000602082840312156152b257600080fd5b5051919050565b6000816152c8576152c861521e565b506000190190565b600181811c908216806152e457607f821691505b60208210810361299557634e487b7160e01b600052602260045260246000fd5b601f82111561354e57600081815260208120601f850160051c8101602086101561532b5750805b601f850160051c820191505b81811015612b4057828155600101615337565b81516001600160401b0381111561536357615363614992565b6153778161537184546152d0565b84615304565b602080601f8311600181146153ac57600084156153945750858301515b600019600386901b1c1916600185901b178555612b40565b600085815260208120601f198616915b828110156153db578886015182559484019460019091019084016153bc565b50858210156153f95787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083526000845461541d816152d0565b8084870152604060018084166000811461543e576001811461545857614f6e565b60ff1985168984015283151560051b890183019550614f6e565b896000528660002060005b8581101561547e5781548b8201860152908301908801615463565b909901929092019998505050505050505050565b60008083546154a0816152d0565b600182811680156154b857600181146154cd576154fc565b60ff19841687528215158302870194506154fc565b8760005260208060002060005b858110156154f35781548a8201529084019082016154da565b50505082870194505b50929695505050505050565b634e487b7160e01b600052601260045260246000fd5b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6040815260006156086040830185614af7565b82810360208401526139408185614af7565b60008261562957615629615508565b500690565b600060ff821660ff81036156445761564461521e565b60010192915050565b60008261565c5761565c615508565b500490565b634e487b7160e01b600052603160045260246000fd5b60408152600061568a6040830185614ab8565b905060018060a01b03831660208301529392505050565b600181815b808511156156dc5781600019048211156156c2576156c261521e565b808516156156cf57918102915b93841c93908002906156a6565b509250929050565b6000826156f3575060016108c2565b81615700575060006108c2565b816001811461571657600281146157205761573c565b60019150506108c2565b60ff8411156157315761573161521e565b50506001821b6108c2565b5060208310610133831016604e8410600b841016171561575f575081810a6108c2565b61576983836156a1565b806000190482111561577d5761577d61521e565b029392505050565b60006130d083836156e4565b6001600160a01b0386811682528516602082015260a0604082018190526000906157bd90830186614af7565b82810360608401526157cf8186614af7565b905082810360808401526157e38185614ab8565b98975050505050505050565b60006020828403121561580157600080fd5b81516130d08161495f565b600060033d11156158255760046000803e5060005160e01c5b90565b600060443d10156158365790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561586557505050505090565b828501915081518181111561587d5750505050505090565b843d87010160208285010111156158975750505050505090565b6158a6602082860101876149a8565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60006020828403121561590b57600080fd5b81516130d081614ec7565b6001600160a01b03868116825285166020820152604081018490526060810183905260a06080820181905260009061458290830184614ab8565b6001600160a01b0389811682526020820189905260408201889052861660608201526001600160e01b03198516608082015260a0810184905260c0810183905261010060e082018190526000906159a983820185614ab8565b9b9a5050505050505050505050565b60018060a01b03841681528260208201526060604082015260006139406060830184614ab8565b600082516159f1818460208701614a94565b919091019291505056fea164736f6c6343000812000a0000000000000000000000000000000000000000000000000000000000000410000000000000000000000000ae975071be8f8ee67addbc1a82488f1c24858067000000000000000000000000a561862aa4efd0b57fcf9ac9384c353871e8225f000000000000000000000000114214150af93998a80d39ed3f92b0035bc5ecd20000000000000000000000000000000000000000000000000000000000000160000000000000000000000000b0897686c545045afc77cf20ec7a532e3120e0f100000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000220000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093ecc294a196eeeb44da2888d17c0625cc88d70d9760a69d58d853ba6581a9ab0cd0000000000000000000000008755811a623c81da777b18c0b9f478311786d17700000000000000000000000000000000000000000000000000000000000000206535376362313034323538323461383438383665626464313433313135336432000000000000000000000000000000000000000000000000000000000000005368747470733a2f2f6261667962656966753279353766766533716135626976726578646d3676617034726f7264696c686e6573377974736f6d357732616568656a66612e697066732e647765622e6c696e6b2f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005368747470733a2f2f6261667962656964776a7337376e726a65766e356f37726b667576786c3765646f67323664733661636776677662647a68326f6a646f6d657664752e697066732e647765622e6c696e6b2f00000000000000000000000000

Deployed Bytecode

0x6080604052600436106102665760003560e01c80636fb1d08111610144578063c20652fe116100b6578063e62a6e151161007a578063e62a6e151461074f578063e8a3d4851461076f578063e985e9c514610784578063eddd0d9c146107cd578063f242432a146107ed578063f2fde38b1461080d57600080fd5b8063c20652fe146106c2578063c2939d97146106e2578063cd838f0f146106f8578063d55441b51461071a578063e546bb0c1461072f57600080fd5b8063938e3d7b11610108578063938e3d7b1461061a578063a22cb4651461063a578063ac12f64e1461065a578063bae716141461067a578063bf693cdb1461069a578063c0e72740146106ad57600080fd5b80636fb1d0811461056d57806379ba50971461059a5780638158e6ae146105af57806388ef544c146105cf5780638da5cb5b146105fc57600080fd5b80632f1d5a60116101dd5780634a008141116101a15780634a008141146104bb5780634e1273f4146104d5578063626c2091146104f5578063698504c81461050a5780636c151876146105205780636ebd386e1461054d57600080fd5b80632f1d5a601461040d57806331a99a091461042d578063344701581461044d5780633b1ef5421461047b57806345e9724a1461049b57600080fd5b8063127effb21161022f578063127effb21461034a578063129fc1c01461038257806313966db5146103a25780631fe543e3146103b85780632a15218e146103d85780632eb2c2d6146103ed57600080fd5b8062fdd58e1461026b57806301ffc9a71461029e57806302fe5305146102ce5780630e89341c146102f057806312364cb91461031d575b600080fd5b34801561027757600080fd5b5061028b610286366004614935565b61082d565b6040519081526020015b60405180910390f35b3480156102aa57600080fd5b506102be6102b9366004614975565b6108c8565b6040519015158152602001610295565b3480156102da57600080fd5b506102ee6102e9366004614a47565b610918565b005b3480156102fc57600080fd5b5061031061030b366004614a7b565b610985565b6040516102959190614ae4565b34801561032957600080fd5b5061033d610338366004614935565b6109c0565b6040516102959190614b27565b34801561035657600080fd5b50600e5461036a906001600160a01b031681565b6040516001600160a01b039091168152602001610295565b34801561038e57600080fd5b506102ee61039d366004614a47565b610a35565b3480156103ae57600080fd5b5061028b600f5481565b3480156103c457600080fd5b506102ee6103d3366004614bce565b610a9b565b3480156103e457600080fd5b5061028b610b23565b3480156103f957600080fd5b506102ee610408366004614c14565b610b2e565b34801561041957600080fd5b506102ee610428366004614cbd565b610b7a565b34801561043957600080fd5b506102ee610448366004614cd8565b610bf7565b34801561045957600080fd5b5061046d610468366004614d0e565b610dff565b604051610295929190614d47565b34801561048757600080fd5b506102ee610496366004614a7b565b610faf565b3480156104a757600080fd5b506102ee6104b6366004614d69565b61101c565b3480156104c757600080fd5b506021546102be9060ff1681565b3480156104e157600080fd5b5061033d6104f0366004614d9d565b61147b565b34801561050157600080fd5b5061028b6115a4565b34801561051657600080fd5b5061028b60105481565b34801561052c57600080fd5b5061054061053b366004614d69565b611634565b6040516102959190614e5d565b34801561055957600080fd5b506102ee610568366004614ed5565b611750565b34801561057957600080fd5b5061058d610588366004614cbd565b611799565b6040516102959190614ef2565b3480156105a657600080fd5b506102ee611882565b3480156105bb57600080fd5b506102ee6105ca366004614a7b565b611930565b3480156105db57600080fd5b506105ef6105ea366004614935565b6119a9565b6040516102959190614f7c565b34801561060857600080fd5b506006546001600160a01b031661036a565b34801561062657600080fd5b506102ee610635366004614a47565b611b25565b34801561064657600080fd5b506102ee610655366004614fe5565b611b99565b34801561066657600080fd5b5061036a610675366004615011565b611ba4565b34801561068657600080fd5b506102ee610695366004614cbd565b611bd5565b6102ee6106a8366004614a47565b611c58565b3480156106b957600080fd5b50610310611ee9565b3480156106ce57600080fd5b506102ee6106dd366004614cbd565b611f77565b3480156106ee57600080fd5b5061028b60205481565b34801561070457600080fd5b5061070d611ff4565b6040516102959190615054565b34801561072657600080fd5b506102ee6121b5565b34801561073b57600080fd5b50600d5461036a906001600160a01b031681565b34801561075b57600080fd5b506102ee61076a3660046150b6565b612320565b34801561077b57600080fd5b506103106123d2565b34801561079057600080fd5b506102be61079f366004615103565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205460ff1690565b3480156107d957600080fd5b506102ee6107e8366004614a7b565b6123fa565b3480156107f957600080fd5b506102ee61080836600461512d565b612460565b34801561081957600080fd5b506102ee610828366004614cbd565b6124a5565b60006001600160a01b03831661089d5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b5060008181526009602090815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b14806108f957506001600160e01b031982166303a24d0760e21b145b806108c257506301ffc9a760e01b6001600160e01b03198316146108c2565b6109206124b6565b8051600003610942576040516341cc6b2160e01b815260040160405180910390fd5b61094b8161250b565b7fd926fde11e1623e83f8becaf0d50ebe506b5bb4b70570742a0bb36901f65a5d98160405161097a9190614ae4565b60405180910390a150565b606061099082612517565b610999836125ab565b6040516020016109aa929190615191565b6040516020818303038152906040529050919050565b6001600160a01b0382166000908152602360209081526040808320848452825291829020805483518184028101840190945280845260609392830182828015610a2857602002820191906000526020600020905b815481526020019060010190808311610a14575b5050505050905092915050565b610a3d6124b6565b8051602014610a5f576040516341cc6b2160e01b815260040160405180910390fd5b610a688161263d565b60208181556040519182527ff1a050b089446eb1e4e418e9f558b0bab8205507c47dabeadf24a9f3b9c15253910161097a565b336001600160a01b037f000000000000000000000000ae975071be8f8ee67addbc1a82488f1c248580671614610b155760405163073e64fd60e21b81523360048201526001600160a01b037f000000000000000000000000ae975071be8f8ee67addbc1a82488f1c24858067166024820152604401610894565b610b1f828261267f565b5050565b6000806108c2612931565b6001600160a01b038516331480610b4a5750610b4a853361079f565b610b665760405162461bcd60e51b8152600401610894906151d0565b610b73858585858561299b565b5050505050565b610b826124b6565b6001600160a01b038116610ba95760405163e6c4247b60e01b815260040160405180910390fd5b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f7b77641e3e43914132d91ce9450aac1cbf5aa9c28ab80d416d241a5c456d837d9060200161097a565b60008281526005602052604090205482906001600160a01b03163314610c705760405162461bcd60e51b815260206004820152602860248201527f536f75726365206d75737420626520746865206f7261636c65206f6620746865604482015267081c995c5d595cdd60c21b6064820152608401610894565b60008181526005602052604080822080546001600160a01b03191690555182917f7cc135e0cebb02c3480ae5d74d377283180a2601f8f644edf7987b009316c63a91a260008381526028602052604090205460ff1615610ce357604051636db38e6d60e11b815260040160405180910390fd5b6000838152602860209081526040808320805460ff1916600117905560279091529020546001600160a01b031680610d2e5760405163e6c4247b60e01b815260040160405180910390fd5b60008360ff16118015610d45575060648360ff1611155b610d62576040516302a34b0f60e31b815260040160405180910390fd5b6001600160a01b038116600090815260266020526040902054610d86848284612b48565b6001600160a01b0382166000818152602660209081526040808320839055888352602782529182902080546001600160a01b0319169055815188815260ff8816918101919091527f50f9cbb82b664c70bc2b8443d65cbabfbad3eaef92cba0b1357ec86fcd94df36910160405180910390a25050505050565b6001600160a01b038416600090815260236020908152604080832086845282528083208054825181850281018501909352808352606094938493929190830182828015610e6b57602002820191906000526020600020905b815481526020019060010190808311610e57575b505050505090508051600003610e94575050604080516000808252602082019092529150610fa6565b600084610ea2600188615234565b610eac9190615247565b905081518110610ed2575060408051600081526020810190915290519092509050610fa6565b6000610ede868361525e565b90508251811115610eed575081515b6000610ef98383615234565b6001600160401b03811115610f1057610f10614992565b604051908082528060200260200182016040528015610f39578160200160208202803683370190505b50905060005b8151811015610f9a5784610f53828661525e565b81518110610f6357610f63615271565b6020026020010151828281518110610f7d57610f7d615271565b602090810291909101015280610f9281615287565b915050610f3f565b50925192945091925050505b94509492505050565b610fb76124b6565b610fec6001600160a01b037f000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093e16333084612da0565b6040518181527f65b09eea04b6df90dff75de9ed57261250e71c1b7941a4e41e431e1437fc92c09060200161097a565b611024612e11565b60215460ff16611046576040516282b42960e81b815260040160405180910390fd5b6000815111611067576040516282b42960e81b815260040160405180910390fd5b60408051600680825260e082019092526000918291906020820160c08036833701905050905060005b8351811015611239576000602260008684815181106110b1576110b1615271565b6020908102919091018101518252818101929092526040908101600020815160608101835281548152600182015493810193909352600201546001600160a01b0316908201819052909150331461111a576040516282b42960e81b815260040160405180910390fd5b6000816020015111801561113357506006816020015111155b6111505760405163907e751560e01b815260040160405180910390fd5b82816020015160066111629190615234565b8151811061117257611172615271565b60200260200101805180919061118790615287565b9052506020810151815161119b9190612e6a565b6111a5908561525e565b935060006111b483600161525e565b90505b8551811015611224578581815181106111d2576111d2615271565b60200260200101518684815181106111ec576111ec615271565b602002602001015103611212576040516341cc6b2160e01b815260040160405180910390fd5b8061121c81615287565b9150506111b7565b5050808061123190615287565b915050611090565b50600061124533612f54565b905060005b81518110156112b75782818151811061126557611265615271565b602002602001015182828151811061127f5761127f615271565b602002602001015110156112a5576040516282b42960e81b815260040160405180910390fd5b806112af81615287565b91505061124a565b50826000036112d95760405163500802a160e11b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526000907f000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093e6001600160a01b0316906370a0823190602401602060405180830381865afa158015611340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136491906152a0565b90506000841180156113765750600081115b80156113825750838110155b61139f57604051632d4dd87f60e01b815260040160405180910390fd5b6113b1336113ab6130d7565b856131b8565b60005b85518110156113f2576113e08682815181106113d2576113d2615271565b6020026020010151336133cf565b806113ea81615287565b9150506113b4565b506114276001600160a01b037f000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093e16338661351e565b336001600160a01b03167f0385f3b80e145b046d4b1ff30d63ef9b9dd72269394cfdd97d317d997f436ac38686604051611462929190614d47565b60405180910390a2505050506114786001600855565b50565b606081518351146114e05760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610894565b600083516001600160401b038111156114fb576114fb614992565b604051908082528060200260200182016040528015611524578160200160208202803683370190505b50905060005b845181101561159c5761156f85828151811061154857611548615271565b602002602001015185838151811061156257611562615271565b602002602001015161082d565b82828151811061158157611581615271565b602090810291909101015261159581615287565b905061152a565b509392505050565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093e6001600160a01b0316906370a0823190602401602060405180830381865afa15801561160b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162f91906152a0565b905090565b6060600082516001600160401b0381111561165157611651614992565b60405190808252806020026020018201604052801561168a57816020015b61167761484f565b81526020019060019003908161166f5790505b50905060005b83518110156117495760008482815181106116ad576116ad615271565b602090810291909101810151600081815260228352604090819020815160608082018452825480835260018401548388018190526002909401546001600160a01b03168386015284519182018552858252958101839052928301859052875193955093909290919087908790811061172757611727615271565b602002602001018190525050505050808061174190615287565b915050611690565b5092915050565b6117586124b6565b6021805460ff19168215159081179091556040519081527f5e3f6ff8ea2235d60e824a2ad40aaa526bbf7720612d8f19b7ef8a6b67b897389060200161097a565b60408051600680825260e0820190925260609160009190816020015b60608152602001906001900390816117b557905050905060065b8015611749576001600160a01b038416600090815260236020908152604080832084845282528083208054825181850281018501909352808352919290919083018282801561183d57602002820191906000526020600020905b815481526020019060010190808311611829575b5050505050905080838360066118539190615234565b8151811061186357611863615271565b602002602001018190525050808061187a906152b9565b9150506117cf565b6007546001600160a01b031633146118d55760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b6044820152606401610894565b600680546001600160a01b0319808216339081179093556007805490911690556040516001600160a01b03909116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b6119386124b6565b600081118015611949575060105481115b801561195757506103e88111155b611974576040516341cc6b2160e01b815260040160405180910390fd5b60108190556040518181527f24b98f806e4d141480cbd184b85f98af8e8af90649c2340579e556fb29327c2a9060200161097a565b6001600160a01b03821660009081526023602090815260408083208484528252808320805482518185028101850190935280835260609493830182828015611a1057602002820191906000526020600020905b8154815260200190600101908083116119fc575b50505050509050600081516001600160401b03811115611a3257611a32614992565b604051908082528060200260200182016040528015611a6b57816020015b611a5861486d565b815260200190600190039081611a505790505b50905060005b8251811015611b1c576000838281518110611a8e57611a8e615271565b602090810291909101810151600081815260228352604090819020815160608101835281548082526001830154828701526002909201546001600160a01b0316818401528251808401909352838352938201819052865192945091869086908110611afb57611afb615271565b60200260200101819052505050508080611b1490615287565b915050611a71565b50949350505050565b611b2d6124b6565b60118054611b3a906152d0565b9050600003611b5c576040516341cc6b2160e01b815260040160405180910390fd5b6011611b68828261534a565b507ffe1e68475db2c7a4962ab936f3084ce9cc5edaed551a4893b08b98cac24bef6b601160405161097a9190615409565b610b1f338383613553565b600060256000611bb48486613633565b81526020810191909152604001600020546001600160a01b03169392505050565b611bdd6124b6565b6001600160a01b038116611c045760405163e6c4247b60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0383161790556040516001600160a01b03821681527ffb815385f643693ee2547a3ea422030c533509d0370d8f919ef1f1aba68bcf1d9060200161097a565b611c60612e11565b8051600003611c82576040516341cc6b2160e01b815260040160405180910390fd5b6000611c8e8233613633565b6000818152602560205260409020549091506001600160a01b03163314611cc7576040516282b42960e81b815260040160405180910390fd5b600081815260256020526040902080546001600160a01b0319169055600f543414611d055760405163c288bf8f60e01b815260040160405180910390fd5b600e546000906001600160a01b0316348280808084865af1925082611d3c576040516282b42960e81b815260040160405180910390fd5b6040516305d3b1d360e41b81527fcc294a196eeeb44da2888d17c0625cc88d70d9760a69d58d853ba6581a9ab0cd60048201526001600160401b037f0000000000000000000000000000000000000000000000000000000000000410166024820152601e6044820152620f42406064820152600160848201526000907f000000000000000000000000ae975071be8f8ee67addbc1a82488f1c248580676001600160a01b031690635d3b1d309060a4016020604051808303816000875af1158015611e0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2f91906152a0565b90506040518060400160405280336001600160a01b0316815260200187604051602001611e5c9190614ae4565b60408051808303601f190181529181529152600083815260296020908152919020825181546001600160a01b0319166001600160a01b03909116178155908201516001820190611eac908261534a565b50506040513391507f2c0c0ba8c38db82429c4ccac00b5532ba435982913b8c2c88fee59f2ef3cf96b90600090a250505050506114786001600855565b60118054611ef6906152d0565b80601f0160208091040260200160405190810160405280929190818152602001828054611f22906152d0565b8015611f6f5780601f10611f4457610100808354040283529160200191611f6f565b820191906000526020600020905b815481529060010190602001808311611f5257829003601f168201915b505050505081565b611f7f6124b6565b6001600160a01b038116611fa65760405163e6c4247b60e01b815260040160405180910390fd5b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527ffd3e8d123f8f642884c0d014771c2581ed12ce65ae55069285e86dd6a355dff49060200161097a565b60408051600680825260e0820190925260609160009190816020015b60608152602001906001900390816120105790505090506040518060400160405280600c81526020016b09af2e8d0d2c6c2d84084def60a31b8152508160008151811061205f5761205f615271565b60200260200101819052506040518060400160405280600d81526020016c098cacecadcc8c2e4f24084def609b1b815250816001815181106120a3576120a3615271565b60200260200101819052506040518060400160405280600881526020016708ae0d2c64084def60c31b815250816002815181106120e2576120e2615271565b6020026020010181905250604051806040016040528060088152602001670a4c2e4ca4084def60c31b8152508160038151811061212157612121615271565b60200260200101819052506040518060400160405280600c81526020016b0aadcc6dedadadedc4084def60a31b8152508160048151811061216457612164615271565b60200260200101819052506040518060400160405280600a815260200169086dedadadedc4084def60b31b815250816005815181106121a5576121a5615271565b6020908102919091010152919050565b6121bd6124b6565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093e6001600160a01b0316906370a0823190602401602060405180830381865afa158015612224573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224891906152a0565b90508060000361226b57604051632d4dd87f60e01b815260040160405180910390fd5b6000612275612931565b90506000818311612287576000612291565b6122918284615234565b9050806000036122b457604051632d4dd87f60e01b815260040160405180910390fd5b6122e86001600160a01b037f000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093e16338361351e565b6040518181527fb6deef47dcb3d0a897412bc9f5d1d147d7cd6d742c46045f40db924bfa67e8b39060200160405180910390a1505050565b600d546001600160a01b031633811461234b576040516282b42960e81b815260040160405180910390fd5b825160000361236d576040516341cc6b2160e01b815260040160405180910390fd5b6001600160a01b038216612394576040516341cc6b2160e01b815260040160405180910390fd5b60006123a08484613633565b600090815260256020526040902080546001600160a01b0319166001600160a01b039490941693909317909255505050565b606060116040516020016123e69190615492565b604051602081830303815290604052905090565b6124026124b6565b678ac7230489e8000081111561242b5760405163c288bf8f60e01b815260040160405180910390fd5b600f8190556040518181527f38fbb1c8b109c430f0c030e7ed076cf5611a307773a4e8e365601e8f8bceaec69060200161097a565b6001600160a01b03851633148061247c575061247c853361079f565b6124985760405162461bcd60e51b8152600401610894906151d0565b610b738585858585613666565b6124ad6124b6565b611478816137a2565b6006546001600160a01b031633146125095760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b6044820152606401610894565b565b600b610b1f828261534a565b6060600b8054612526906152d0565b80601f0160208091040260200160405190810160405280929190818152602001828054612552906152d0565b801561259f5780601f106125745761010080835404028352916020019161259f565b820191906000526020600020905b81548152906001019060200180831161258257829003601f168201915b50505050509050919050565b606060006125b88361384c565b60010190506000816001600160401b038111156125d7576125d7614992565b6040519080825280601f01601f191660200182016040528015612601576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461260b57509392505050565b8051600090829082036126535750600092915050565b602081511115612676576040516341cc6b2160e01b815260040160405180910390fd5b50506020015190565b6000828152602a602052604090205460ff16156126af5760405163ac53670960e01b815260040160405180910390fd5b6000828152602a60209081526040808320805460ff1916600190811790915560298352818420825180840190935280546001600160a01b0316835290810180549293919291840191612700906152d0565b80601f016020809104026020016040519081016040528092919081815260200182805461272c906152d0565b80156127795780601f1061274e57610100808354040283529160200191612779565b820191906000526020600020905b81548152906001019060200180831161275c57829003601f168201915b5050509190925250508151919250506001600160a01b03166127ae5760405163e6c4247b60e01b815260040160405180910390fd5b80516020820151835184906000906127c8576127c8615271565b6020908102919091018101516001600160a01b0384166000908152602683526040812091909155905461280390306331a99a0960e01b613924565b604080518082019091526004815263636f646560e01b602082015290915061282d90829084613949565b612888604051806040016040528060078152602001666164647265737360c81b8152508460405160200161287091906001600160a01b0391909116815260200190565b60408051601f19818403018152919052839190613949565b6000612895826000613967565b600081815260276020908152604080832080546001600160a01b038a166001600160a01b0319918216179091558b845260299092528220805490911681559192506128e3600183018261488b565b5050836001600160a01b03167f268d41957d793c5db1ea517d7df76da1e28f8b844bd87e26a4c42b242b4b459c8860405161292091815260200190565b60405180910390a250505050505050565b60008060065b80156129955760006019826007811061295257612952615271565b015490506000612963836001613981565b905060006129718284615247565b905061297d818661525e565b9450505050808061298d906152b9565b915050612937565b50919050565b81518351146129bc5760405162461bcd60e51b81526004016108949061551e565b6001600160a01b0384166129e25760405162461bcd60e51b815260040161089490615566565b336129f1818787878787613a22565b60005b8451811015612ada576000858281518110612a1157612a11615271565b602002602001015190506000858381518110612a2f57612a2f615271565b60209081029190910181015160008481526009835260408082206001600160a01b038e168352909352919091205490915081811015612a805760405162461bcd60e51b8152600401610894906155ab565b60008381526009602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612abf90849061525e565b9250508190555050505080612ad390615287565b90506129f4565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051612b2a9291906155f5565b60405180910390a4612b40818787878787613a5f565b505050505050565b60408051600680825260e082019092526000916020820160c08036833701905050905060008460ff166001600160401b03811115612b8857612b88614992565b604051908082528060200260200182016040528015612bb1578160200160208202803683370190505b50905060008560ff16118015612bcb575060648560ff1611155b612be8576040516302a34b0f60e31b815260040160405180910390fd5b6010546040805160e081019182905260009160129060079082845b815481526020019060010190808311612c03575050505050905060005b8760ff168160ff161015612d44576000600c60008154612c3f90615287565b91829055506040805160208082018c9052818301849052825180830384018152606090920190925280519101209091506000612c7e620f42408361561a565b90506000612c8d828888613bc3565b9050612c9a848b83613c80565b60128160078110612cad57612cad615271565b0160008154612cbb90615287565b9182905550868260078110612cd257612cd2615271565b602002015287518490899060ff8816908110612cf057612cf0615271565b602090810291909101015288612d07826006615234565b81518110612d1757612d17615271565b602002602001018051612d2990615287565b905250839250612d3c915082905061562e565b915050612c20565b50612d6785612d516130d7565b8660405180602001604052806000815250613d4e565b846001600160a01b03167f58f188356312b86d65ea217eeb39386250d8ee5fa6df17fae35d8fabda7518ed846040516129209190614b27565b6040516001600160a01b0380851660248301528316604482015260648101829052612e0b9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613ee3565b50505050565b600260085403612e635760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610894565b6002600855565b60008083118015612e7c575060068311155b612e995760405163907e751560e01b815260040160405180910390fd5b428211158015612ea95750600082115b612ec657604051634d0b0a4160e01b815260040160405180910390fd5b600062015180612ed68442615234565b612ee0919061564d565b9050600060b4821015612f0957612ef885600a613981565b612f02908261525e565b9050612f4c565b60b48210158015612f1b575061016d82105b15612f2b57612ef8856002613981565b61016d8210612f4c57612f3f856001613981565b612f49908261525e565b90505b949350505050565b60408051600680825260e08201909252606091600091906020820160c08036833701905050905060065b8015612fcb578382612f91836006615234565b81518110612fa157612fa1615271565b6001600160a01b039092166020928302919091019091015280612fc3816152b9565b915050612f7e565b506000612fda826104f06130d7565b9050600081600081518110612ff157612ff1615271565b6020026020010151118061301f575060008160018151811061301557613015615271565b6020026020010151115b80613044575060008160028151811061303a5761303a615271565b6020026020010151115b80613069575060008160038151811061305f5761305f615271565b6020026020010151115b8061308e575060008160048151811061308457613084615271565b6020026020010151115b806130b357506000816005815181106130a9576130a9615271565b6020026020010151115b6130d057604051635d97b6a360e01b815260040160405180910390fd5b9392505050565b60408051600680825260e08201909252606091600091906020820160c08036833701905050905060068160008151811061311357613113615271565b60200260200101818152505060058160018151811061313457613134615271565b60200260200101818152505060048160028151811061315557613155615271565b60200260200101818152505060038160038151811061317657613176615271565b60200260200101818152505060028160048151811061319757613197615271565b6020026020010181815250506001816005815181106121a5576121a5615271565b6001600160a01b03831661321a5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610894565b805182511461323b5760405162461bcd60e51b81526004016108949061551e565b600033905061325e81856000868660405180602001604052806000815250613a22565b60005b835181101561336257600084828151811061327e5761327e615271565b60200260200101519050600084838151811061329c5761329c615271565b60209081029190910181015160008481526009835260408082206001600160a01b038c1683529093529190912054909150818110156133295760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610894565b60009283526009602090815260408085206001600160a01b038b168652909152909220910390558061335a81615287565b915050613261565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb86866040516133b39291906155f5565b60405180910390a4604080516020810190915260009052612e0b565b60008281526022602090815260408083206001908101546001600160a01b03861680865260248552838620828752855283862088875285528386205490865260238552838620828752909452918420805492949092909183916134329190615234565b8154811061344257613442615271565b906000526020600020015490508082848154811061346257613462615271565b90600052602060002001819055508180548061348057613480615661565b6000828152602080822060001990840181018390559092019092556001600160a01b03871682526024815260408083208784528252808320848452825280832086905588835280832083905560229091528120818155600181019190915560020180546001600160a01b03191690556019846007811061350257613502615271565b018054906000613511836152b9565b9190505550505050505050565b6040516001600160a01b03831660248201526044810182905261354e90849063a9059cbb60e01b90606401612dd4565b505050565b816001600160a01b0316836001600160a01b0316036135c65760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610894565b6001600160a01b038381166000818152600a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60008282604051602001613648929190615677565b60405160208183030381529060405280519060200120905092915050565b6001600160a01b03841661368c5760405162461bcd60e51b815260040161089490615566565b33600061369885613fb8565b905060006136a585613fb8565b90506136b5838989858589613a22565b60008681526009602090815260408083206001600160a01b038c168452909152902054858110156136f85760405162461bcd60e51b8152600401610894906155ab565b60008781526009602090815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061373790849061525e565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4613797848a8a8a8a8a614003565b505050505050505050565b336001600160a01b038216036137fa5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610894565b600780546001600160a01b0319166001600160a01b03838116918217909255600654604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b831061388b5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106138b7576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106138d557662386f26fc10000830492506010015b6305f5e10083106138ed576305f5e100830492506008015b612710831061390157612710830492506004015b60648310613913576064830492506002015b600a83106108c25760010192915050565b61392c6148c5565b6139346148c5565b613940818686866140be565b95945050505050565b608083015161395890836140fb565b608083015161354e9082614112565b6003546000906130d0906001600160a01b0316848461411f565b6000826001036139be5761399682600a615247565b6139a26012600a615785565b6139ad906019615247565b6139b7919061564d565b90506108c2565b6000836006036139ce57506207a1205b836005036139db575061c3505b836004036139e857506113885b836003036139f557506101f45b83600203613a01575060055b82613a0e6012600a615785565b613a189083615247565b612f4c919061564d565b6001600160a01b03851615801590613a4257506001600160a01b03841615155b15612b40576040516282b42960e81b815260040160405180910390fd5b6001600160a01b0384163b15612b405760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190613aa39089908990889088908890600401615791565b6020604051808303816000875af1925050508015613ade575060408051601f3d908101601f19168201909252613adb918101906157ef565b60015b613b8a57613aea61580c565b806308c379a003613b235750613afe615828565b80613b095750613b25565b8060405162461bcd60e51b81526004016108949190614ae4565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610894565b6001600160e01b0319811663bc197c8160e01b14613bba5760405162461bcd60e51b8152600401610894906158b1565b50505050505050565b600060065b8015613c755760018114613c7557600081600603613be4575060015b81600503613bf0575060055b81600403613bfc575060325b81600303613c0957506107d05b81600203613c17575062030d405b6000848360078110613c2b57613c2b615271565b602002015190506000613c3e8784615247565b821090508288108015613c4e5750805b15613c5f57839450505050506130d0565b5050508080613c6d906152b9565b915050613bc8565b506001949350505050565b6040805160608101825242815260208082018481526001600160a01b0386811684860181815260008a8152602286528781209651875593516001808801919091559051600290960180546001600160a01b03191696909316959095179091558082526023835284822086835280845285832080549284526024855286842088855285528684208a85528552958320829055835292830184559283529091200183905560198160078110613d3557613d35615271565b018054906000613d4483615287565b9190505550505050565b6001600160a01b038416613dae5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610894565b8151835114613dcf5760405162461bcd60e51b81526004016108949061551e565b33613ddf81600087878787613a22565b60005b8451811015613e7b57838181518110613dfd57613dfd615271565b602002602001015160096000878481518110613e1b57613e1b615271565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254613e63919061525e565b90915550819050613e7381615287565b915050613de2565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051613ecc9291906155f5565b60405180910390a4610b7381600087878787613a5f565b6000613f38826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166141b29092919063ffffffff16565b9050805160001480613f59575080806020019051810190613f5991906158f9565b61354e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610894565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110613ff257613ff2615271565b602090810291909101015292915050565b6001600160a01b0384163b15612b405760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906140479089908990889088908890600401615916565b6020604051808303816000875af1925050508015614082575060408051601f3d908101601f1916820190925261407f918101906157ef565b60015b61408e57613aea61580c565b6001600160e01b0319811663f23a6e6160e01b14613bba5760405162461bcd60e51b8152600401610894906158b1565b6140c66148c5565b6140d685608001516101006141c1565b50509183526001600160a01b031660208301526001600160e01b031916604082015290565b6141088260038351614226565b61354e828261432d565b6141088260028351614226565b60045460009061413081600161525e565b600455835160408086015160808701515191516000936320214ca360e11b936141689386938493923092918a91600191602401615950565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915290506141a886838684614354565b9695505050505050565b6060612f4c84846000856144b2565b6040805180820190915260608152600060208201526141e160208361561a565b15614209576141f160208361561a565b6141fc906020615234565b614206908361525e565b91505b506020828101829052604080518085526000815290920101905290565b6017816001600160401b03161161424a57612e0b8360e0600585901b16831761458d565b60ff816001600160401b03161161428657614270836018611fe0600586901b161761458d565b50612e0b836001600160401b03831660016145b2565b61ffff816001600160401b0316116142c3576142ad836019611fe0600586901b161761458d565b50612e0b836001600160401b03831660026145b2565b63ffffffff816001600160401b031611614302576142ec83601a611fe0600586901b161761458d565b50612e0b836001600160401b03831660046145b2565b61431783601b611fe0600586901b161761458d565b50612e0b836001600160401b03831660086145b2565b6040805180820190915260608152600060208201526130d0838460000151518485516145d8565b6040516bffffffffffffffffffffffff193060601b1660208201526034810184905260009060540160408051808303601f1901815282825280516020918201206000818152600590925291812080546001600160a01b0319166001600160a01b038a1617905590925082917fb5e6e01e79f91267dc17b4e6314d5d4d03593d2ceee0fbb452b750bd70ea5af99190a2600254604051630200057560e51b81526001600160a01b0390911690634000aea090614417908890879087906004016159b8565b6020604051808303816000875af1158015614436573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061445a91906158f9565b612f4c5760405162461bcd60e51b815260206004820152602360248201527f756e61626c6520746f207472616e73666572416e6443616c6c20746f206f7261604482015262636c6560e81b6064820152608401610894565b6060824710156145135760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610894565b600080866001600160a01b0316858760405161452f91906159df565b60006040518083038185875af1925050503d806000811461456c576040519150601f19603f3d011682016040523d82523d6000602084013e614571565b606091505b5091509150614582878383876146c2565b979650505050505050565b6040805180820190915260608152600060208201526130d0838460000151518461473b565b604080518082019091526060815260006020820152612f4c848560000151518585614796565b60408051808201909152606081526000602082015282518211156145fb57600080fd5b602085015161460a838661525e565b111561463d5761463d8561462d87602001518786614628919061525e565b614817565b614638906002615247565b614828565b60008086518051876020830101935080888701111561465c5787860182525b505050602084015b6020841061469c578051825261467b60208361525e565b915061468860208261525e565b9050614695602085615234565b9350614664565b51815160001960208690036101000a019081169019919091161790525083949350505050565b6060831561473157825160000361472a576001600160a01b0385163b61472a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610894565b5081612f4c565b612f4c838361483f565b604080518082019091526060815260006020820152836020015183106147705761477084856020015160026146389190615247565b835180516020858301018481535080850361478c576001810182525b5093949350505050565b60408051808201909152606081526000602082015260208501516147ba858461525e565b11156147ce576147ce8561462d868561525e565b600060016147de84610100615785565b6147e89190615234565b905085518386820101858319825116178152508051848701111561480c5783860181525b509495945050505050565b6000818311156129955750816108c2565b815161483483836141c1565b50612e0b838261432d565b815115613b095781518083602001fd5b60405180606001604052806003906020820280368337509192915050565b60405180604001604052806002906020820280368337509192915050565b508054614897906152d0565b6000825580601f106148a7575050565b601f0160209004906000526020600020908101906114789190614900565b6040805160a0810182526000808252602080830182905282840182905260608084018390528451808601909552845283015290608082015290565b5b808211156149155760008155600101614901565b5090565b80356001600160a01b038116811461493057600080fd5b919050565b6000806040838503121561494857600080fd5b61495183614919565b946020939093013593505050565b6001600160e01b03198116811461147857600080fd5b60006020828403121561498757600080fd5b81356130d08161495f565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b03811182821017156149cd576149cd614992565b6040525050565b600082601f8301126149e557600080fd5b81356001600160401b038111156149fe576149fe614992565b604051614a15601f8301601f1916602001826149a8565b818152846020838601011115614a2a57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215614a5957600080fd5b81356001600160401b03811115614a6f57600080fd5b612f4c848285016149d4565b600060208284031215614a8d57600080fd5b5035919050565b60005b83811015614aaf578181015183820152602001614a97565b50506000910152565b60008151808452614ad0816020860160208601614a94565b601f01601f19169290920160200192915050565b6020815260006130d06020830184614ab8565b600081518084526020808501945080840160005b8381101561480c57815187529582019590820190600101614b0b565b6020815260006130d06020830184614af7565b60006001600160401b03821115614b5357614b53614992565b5060051b60200190565b600082601f830112614b6e57600080fd5b81356020614b7b82614b3a565b604051614b8882826149a8565b83815260059390931b8501820192828101915086841115614ba857600080fd5b8286015b84811015614bc35780358352918301918301614bac565b509695505050505050565b60008060408385031215614be157600080fd5b8235915060208301356001600160401b03811115614bfe57600080fd5b614c0a85828601614b5d565b9150509250929050565b600080600080600060a08688031215614c2c57600080fd5b614c3586614919565b9450614c4360208701614919565b935060408601356001600160401b0380821115614c5f57600080fd5b614c6b89838a01614b5d565b94506060880135915080821115614c8157600080fd5b614c8d89838a01614b5d565b93506080880135915080821115614ca357600080fd5b50614cb0888289016149d4565b9150509295509295909350565b600060208284031215614ccf57600080fd5b6130d082614919565b60008060408385031215614ceb57600080fd5b82359150602083013560ff81168114614d0357600080fd5b809150509250929050565b60008060008060808587031215614d2457600080fd5b614d2d85614919565b966020860135965060408601359560600135945092505050565b604081526000614d5a6040830185614af7565b90508260208301529392505050565b600060208284031215614d7b57600080fd5b81356001600160401b03811115614d9157600080fd5b612f4c84828501614b5d565b60008060408385031215614db057600080fd5b82356001600160401b0380821115614dc757600080fd5b818501915085601f830112614ddb57600080fd5b81356020614de882614b3a565b604051614df582826149a8565b83815260059390931b8501820192828101915089841115614e1557600080fd5b948201945b83861015614e3a57614e2b86614919565b82529482019490820190614e1a565b96505086013592505080821115614e5057600080fd5b50614c0a85828601614b5d565b602080825282518282018190526000919084820190604085019084805b82811015614eba57845184835b6003811015614ea457825182529188019190880190600101614e87565b5050509385019360609390930192600101614e7a565b5091979650505050505050565b801515811461147857600080fd5b600060208284031215614ee757600080fd5b81356130d081614ec7565b6000602080830181845280855180835260408601915060408160051b87010192508387016000805b83811015614f6e57888603603f19018552825180518088529088019088880190845b81811015614f585783518352928a0192918a0191600101614f3c565b5090975050509386019391860191600101614f1a565b509398975050505050505050565b60208082528251828201819052600091906040908185019086840185805b83811015614fd757825185835b6002811015614fc457825182529189019190890190600101614fa7565b5050509385019391860191600101614f9a565b509298975050505050505050565b60008060408385031215614ff857600080fd5b61500183614919565b91506020830135614d0381614ec7565b6000806040838503121561502457600080fd5b61502d83614919565b915060208301356001600160401b0381111561504857600080fd5b614c0a858286016149d4565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156150a957603f19888603018452615097858351614ab8565b9450928501929085019060010161507b565b5092979650505050505050565b600080604083850312156150c957600080fd5b82356001600160401b038111156150df57600080fd5b6150eb858286016149d4565b9250506150fa60208401614919565b90509250929050565b6000806040838503121561511657600080fd5b61511f83614919565b91506150fa60208401614919565b600080600080600060a0868803121561514557600080fd5b61514e86614919565b945061515c60208701614919565b9350604086013592506060860135915060808601356001600160401b0381111561518557600080fd5b614cb0888289016149d4565b600083516151a3818460208801614a94565b8351908301906151b7818360208801614a94565b64173539b7b760d91b9101908152600501949350505050565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b818103818111156108c2576108c261521e565b80820281158282048414176108c2576108c261521e565b808201808211156108c2576108c261521e565b634e487b7160e01b600052603260045260246000fd5b6000600182016152995761529961521e565b5060010190565b6000602082840312156152b257600080fd5b5051919050565b6000816152c8576152c861521e565b506000190190565b600181811c908216806152e457607f821691505b60208210810361299557634e487b7160e01b600052602260045260246000fd5b601f82111561354e57600081815260208120601f850160051c8101602086101561532b5750805b601f850160051c820191505b81811015612b4057828155600101615337565b81516001600160401b0381111561536357615363614992565b6153778161537184546152d0565b84615304565b602080601f8311600181146153ac57600084156153945750858301515b600019600386901b1c1916600185901b178555612b40565b600085815260208120601f198616915b828110156153db578886015182559484019460019091019084016153bc565b50858210156153f95787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083526000845461541d816152d0565b8084870152604060018084166000811461543e576001811461545857614f6e565b60ff1985168984015283151560051b890183019550614f6e565b896000528660002060005b8581101561547e5781548b8201860152908301908801615463565b909901929092019998505050505050505050565b60008083546154a0816152d0565b600182811680156154b857600181146154cd576154fc565b60ff19841687528215158302870194506154fc565b8760005260208060002060005b858110156154f35781548a8201529084019082016154da565b50505082870194505b50929695505050505050565b634e487b7160e01b600052601260045260246000fd5b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6040815260006156086040830185614af7565b82810360208401526139408185614af7565b60008261562957615629615508565b500690565b600060ff821660ff81036156445761564461521e565b60010192915050565b60008261565c5761565c615508565b500490565b634e487b7160e01b600052603160045260246000fd5b60408152600061568a6040830185614ab8565b905060018060a01b03831660208301529392505050565b600181815b808511156156dc5781600019048211156156c2576156c261521e565b808516156156cf57918102915b93841c93908002906156a6565b509250929050565b6000826156f3575060016108c2565b81615700575060006108c2565b816001811461571657600281146157205761573c565b60019150506108c2565b60ff8411156157315761573161521e565b50506001821b6108c2565b5060208310610133831016604e8410600b841016171561575f575081810a6108c2565b61576983836156a1565b806000190482111561577d5761577d61521e565b029392505050565b60006130d083836156e4565b6001600160a01b0386811682528516602082015260a0604082018190526000906157bd90830186614af7565b82810360608401526157cf8186614af7565b905082810360808401526157e38185614ab8565b98975050505050505050565b60006020828403121561580157600080fd5b81516130d08161495f565b600060033d11156158255760046000803e5060005160e01c5b90565b600060443d10156158365790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561586557505050505090565b828501915081518181111561587d5750505050505090565b843d87010160208285010111156158975750505050505090565b6158a6602082860101876149a8565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60006020828403121561590b57600080fd5b81516130d081614ec7565b6001600160a01b03868116825285166020820152604081018490526060810183905260a06080820181905260009061458290830184614ab8565b6001600160a01b0389811682526020820189905260408201889052861660608201526001600160e01b03198516608082015260a0810184905260c0810183905261010060e082018190526000906159a983820185614ab8565b9b9a5050505050505050505050565b60018060a01b03841681528260208201526060604082015260006139406060830184614ab8565b600082516159f1818460208701614a94565b919091019291505056fea164736f6c6343000812000a

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

0000000000000000000000000000000000000000000000000000000000000410000000000000000000000000ae975071be8f8ee67addbc1a82488f1c24858067000000000000000000000000a561862aa4efd0b57fcf9ac9384c353871e8225f000000000000000000000000114214150af93998a80d39ed3f92b0035bc5ecd20000000000000000000000000000000000000000000000000000000000000160000000000000000000000000b0897686c545045afc77cf20ec7a532e3120e0f100000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000220000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093ecc294a196eeeb44da2888d17c0625cc88d70d9760a69d58d853ba6581a9ab0cd0000000000000000000000008755811a623c81da777b18c0b9f478311786d17700000000000000000000000000000000000000000000000000000000000000206535376362313034323538323461383438383665626464313433313135336432000000000000000000000000000000000000000000000000000000000000005368747470733a2f2f6261667962656966753279353766766533716135626976726578646d3676617034726f7264696c686e6573377974736f6d357732616568656a66612e697066732e647765622e6c696e6b2f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005368747470733a2f2f6261667962656964776a7337376e726a65766e356f37726b667576786c3765646f67323664733661636776677662647a68326f6a646f6d657664752e697066732e647765622e6c696e6b2f00000000000000000000000000

-----Decoded View---------------
Arg [0] : subscriptionId (uint64): 1040
Arg [1] : vrfCoordinator (address): 0xAE975071Be8F8eE67addBC1A82488F1C24858067
Arg [2] : _oracle (address): 0xA561862Aa4efd0B57Fcf9aC9384c353871E8225F
Arg [3] : _operatorAddress (address): 0x114214150af93998A80d39ED3f92B0035bc5eCD2
Arg [4] : _jobId (string): e57cb10425824a84886ebdd1431153d2
Arg [5] : _link (address): 0xb0897686c545045aFc77CF20eC7A532E3120E0F1
Arg [6] : _uri (string): https://bafybeifu2y57fve3qa5bivrexdm6vap4rordilhnes7ytsom5w2aehejfa.ipfs.dweb.link/
Arg [7] : __contractURI (string): https://bafybeidwjs77nrjevn5o7rkfuvxl7edog26ds6acgvgvbdzh2ojdomevdu.ipfs.dweb.link/
Arg [8] : _token (address): 0xaeb3DD897Ade187B9F9e4c491Bc7A81F69F7093E
Arg [9] : _keyHash (bytes32): 0xcc294a196eeeb44da2888d17c0625cc88d70d9760a69d58d853ba6581a9ab0cd
Arg [10] : _apiAddress (address): 0x8755811a623c81Da777B18C0B9f478311786D177

-----Encoded View---------------
21 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000410
Arg [1] : 000000000000000000000000ae975071be8f8ee67addbc1a82488f1c24858067
Arg [2] : 000000000000000000000000a561862aa4efd0b57fcf9ac9384c353871e8225f
Arg [3] : 000000000000000000000000114214150af93998a80d39ed3f92b0035bc5ecd2
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [5] : 000000000000000000000000b0897686c545045afc77cf20ec7a532e3120e0f1
Arg [6] : 00000000000000000000000000000000000000000000000000000000000001a0
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000220
Arg [8] : 000000000000000000000000aeb3dd897ade187b9f9e4c491bc7a81f69f7093e
Arg [9] : cc294a196eeeb44da2888d17c0625cc88d70d9760a69d58d853ba6581a9ab0cd
Arg [10] : 0000000000000000000000008755811a623c81da777b18c0b9f478311786d177
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [12] : 6535376362313034323538323461383438383665626464313433313135336432
Arg [13] : 0000000000000000000000000000000000000000000000000000000000000053
Arg [14] : 68747470733a2f2f626166796265696675327935376676653371613562697672
Arg [15] : 6578646d3676617034726f7264696c686e6573377974736f6d35773261656865
Arg [16] : 6a66612e697066732e647765622e6c696e6b2f00000000000000000000000000
Arg [17] : 0000000000000000000000000000000000000000000000000000000000000053
Arg [18] : 68747470733a2f2f6261667962656964776a7337376e726a65766e356f37726b
Arg [19] : 667576786c3765646f67323664733661636776677662647a68326f6a646f6d65
Arg [20] : 7664752e697066732e647765622e6c696e6b2f00000000000000000000000000


Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

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

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