ETH Price: $2,951.44 (+0.12%)

Token

NFT Taller LLCs (NFT Taller LLCs)

Overview

Max Total Supply

78 NFT Taller LLCs

Holders

78

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Balance
1 NFT Taller LLCs
0x9321d0db7088d109da5736af1a41dd2bf071cd97
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x0909d640...b87a043D7
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
MuchoNFT

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion, MIT license
// SPDX-License-Identifier: MIT
// MuchoNFT contract

/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

import "./AccessControl.sol";
import "../interfaces/IMuchoUriGenerator.sol";
import "../interfaces/IMuchoNFT.sol";

contract MuchoNFT is IMuchoNFT, ERC721Burnable, ERC721Enumerable, AccessControl {
    using SafeERC20 for IERC20;

    /*--------ToDo-----------*/
    //Evaluate overriding _ownerOf including expiration logic

    /*--------Events-----------*/
    event Subscribed(uint256 tokenId, address subscriber);
    event SubscriptionCancelled(uint256 tokenId, address subscriber);
    event SubscriptionExpirationChanged(uint256 tokenId, address subscriber, uint256 expirationTime);

    /*--------Attributes-----------*/
    PlanAttributes private _planAttributes;
    IMuchoUriGenerator public uriGenerator;

    /*--------Setters-----------*/
    function setPlanName(string calldata _planName) external onlyOwnerOrAuthorized {
        _planAttributes.planName = _planName;
    }

    function setDuration(uint256 _duration) external onlyOwnerOrAuthorized {
        _planAttributes.duration = _duration;
    }

    function setEnabled(bool _enabled) external onlyOwnerOrAuthorized {
        _planAttributes.enabled = _enabled;
    }

    function setUriGenerator(address _uriGen) external onlyOwnerOrAuthorized {
        uriGenerator = IMuchoUriGenerator(_uriGen);
    }

    /*--------Data-----------*/
    uint256 public lastTokenId = 0;
    mapping(uint256 => TokenAttributes) private _tokenIdAttributes;

    /*--------Constructor-----------*/
    constructor(string memory name, string memory symbol) ERC721(name, symbol) {
        _planAttributes.nftAddress = address(this);
    }

    /*--------Modifiers-----------*/
    modifier onlyEnabled() {
        require(_planAttributes.enabled, "MuchoNFT - not enabled");
        _;
    }

    modifier onlyExistingToken(uint256 _tokenId) {
        require(_tokenId <= lastTokenId, "MuchoNFT - not existing tokenID");
        _;
    }

    modifier onlyZeroBalance(address _user) {
        require(balanceOf(_user) == 0, "MuchoNFT - not zero balance for user");
        _;
    }

    /*-------------------EXTERNAL - OWNER-------------------------*/
    function subscribeTo(address _subscriber, string calldata _metadata) external onlyEnabled onlyOwnerOrAuthorized onlyZeroBalance(_subscriber) {
        _mintAndStart(_subscriber, _metadata);
    }

    function bulkSubscribeTo(address[] calldata _subscribers, string[] calldata _metadata) external onlyEnabled onlyOwnerOrAuthorized {
        require(_subscribers.length == _metadata.length, "MuchoNFT: different length");
        for (uint16 i = 0; i < _subscribers.length; i++) {
            if (balanceOf(_subscribers[i]) == 0) {
                _mintAndStart(_subscribers[i], _metadata[i]);
            }
        }
    }

    function cancelSubscriptionTo(uint256 _tokenId) external onlyOwnerOrAuthorized onlyExistingToken(_tokenId) {
        _burnNFTPlan(_tokenId);
    }

    function bulkCancelSubscriptionTo(uint256[] memory _tokenIds) external onlyOwnerOrAuthorized {
        for (uint16 i = 0; i < _tokenIds.length; i++) {
            _burnNFTPlan(_tokenIds[i]);
        }
    }

    function renewTo(uint256 _tokenId) external onlyOwnerOrAuthorized onlyExistingToken(_tokenId) onlyEnabled {
        _renewNFTPlan(_tokenId, block.timestamp + _planAttributes.duration);
    }

    function bulkRenewTo(uint256[] memory _tokenIds) external onlyOwnerOrAuthorized onlyEnabled {
        for (uint16 i = 0; i < _tokenIds.length; i++) {
            _renewNFTPlan(_tokenIds[i], block.timestamp + _planAttributes.duration);
        }
    }

    function changeExpiration(uint256 _tokenId, uint256 _date) external onlyOwnerOrAuthorized onlyExistingToken(_tokenId) onlyEnabled {
        _renewNFTPlan(_tokenId, _date);
    }

    function bulkChangeExpiration(uint256[] memory _tokenIds, uint256[] memory _dates) external onlyOwnerOrAuthorized onlyEnabled {
        require(_tokenIds.length == _dates.length, "Required same amount of IDs and dates");
        for (uint16 i = 0; i < _tokenIds.length; i++) {
            _renewNFTPlan(_tokenIds[i], _dates[i]);
        }
    }

    function changeMetaData(uint256 _tokenId, string calldata _metadata) external onlyOwnerOrAuthorized onlyExistingToken(_tokenId) {
        _tokenIdAttributes[_tokenId].metaData = _metadata;
    }

    function withdraw(address _token, uint256 _amount) external onlyOwnerOrAuthorized {
        IERC20 token = IERC20(_token);
        token.safeTransfer(msg.sender, _amount);
    }

    /*-------------------VIEWS-------------------------*/

    function tokenIdAttributes(uint256 tokenId) external view returns (TokenAttributes memory attr) {
        attr = _tokenIdAttributes[tokenId];
    }

    function planAttributes() external view returns (PlanAttributes memory) {
        return _planAttributes;
    }

    function tokenURI(uint256 tokenId) public view override(IMuchoNFT, ERC721) returns (string memory) {
        _requireOwned(tokenId);

        string[] memory params = new string[](3);
        uint256 daysToExpire = 0;
        if (_tokenIdAttributes[tokenId].expirationTime > block.timestamp) {
            daysToExpire = (_tokenIdAttributes[tokenId].expirationTime - block.timestamp) / (1 days);
        }

        params[0] = Strings.toString(tokenId);
        params[1] = Strings.toString(daysToExpire);
        if (activeToken(tokenId)) {
            params[2] = "Active";
        } else {
            params[2] = "Disabled";
        }

        return uriGenerator.getUri(name(), params);
    }

    //Token is active
    function activeToken(uint256 tokenId) public view returns (bool isActive) {
        isActive = (tokenId <= lastTokenId && _planAttributes.enabled && _tokenIdAttributes[tokenId].expirationTime > block.timestamp && _tokenIdAttributes[tokenId].startTime <= block.timestamp);
    }

    //Balance of active and not expired tokens
    function activeBalanceOf(address user) external view returns (uint256 bal) {
        bal = balanceOf(user);
        if (bal > 0) {
            for (uint256 i = 0; i < bal; i++) {
                uint256 tokenId = tokenOfOwnerByIndex(user, i);
                if (!activeToken(tokenId)) {
                    bal--;
                }
            }
        }
    }

    /*---------------------INTERNAL------------------------*/

    function _mintAndStart(address _subscriber, string calldata _metadata) internal {
        lastTokenId++;

        //Mint NFT
        _mint(_subscriber, lastTokenId);

        //Save subscription attributes
        _tokenIdAttributes[lastTokenId] = TokenAttributes({tokenId: lastTokenId, startTime: block.timestamp, expirationTime: block.timestamp + _planAttributes.duration, metaData: _metadata});

        emit Subscribed(lastTokenId, _subscriber);
    }

    function _burnNFTPlan(uint256 _tokenId) internal {
        address subscriber = _ownerOf(_tokenId);

        //Burn NFT
        _burn(_tokenId);

        emit SubscriptionCancelled(_tokenId, subscriber);
    }

    function _renewNFTPlan(uint256 _tokenId, uint256 _expiration) internal {
        address subscriber = _ownerOf(_tokenId);

        //Save subscription plan and date - no need to burn nor mint NFT
        _tokenIdAttributes[_tokenId].expirationTime = _expiration;

        emit SubscriptionExpirationChanged(_tokenId, subscriber, _expiration);
    }

    /*-----------Overrides--------------------*/
    function _increaseBalance(address account, uint128 amount) internal override(ERC721, ERC721Enumerable) {
        ERC721Enumerable._increaseBalance(account, amount);
    }

    function _update(address to, uint256 tokenId, address auth) internal override(ERC721, ERC721Enumerable) returns (address) {
        return ERC721Enumerable._update(to, tokenId, auth);
    }

    function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, IERC165) returns (bool) {
        return ERC721Enumerable.supportsInterface(interfaceId);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

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

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.20;

import {IERC1155} from "./IERC1155.sol";
import {IERC1155Receiver} from "./IERC1155Receiver.sol";
import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol";
import {Context} from "../../utils/Context.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {Arrays} from "../../utils/Arrays.sol";
import {IERC1155Errors} from "../../interfaces/draft-IERC6093.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
 */
abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors {
    using Arrays for uint256[];
    using Arrays for address[];

    mapping(uint256 id => mapping(address account => uint256)) private _balances;

    mapping(address account => mapping(address operator => 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 /* id */) public view virtual returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     */
    function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
        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 returns (uint256[] memory) {
        if (accounts.length != ids.length) {
            revert ERC1155InvalidArrayLength(ids.length, accounts.length);
        }

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

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

        return batchBalances;
    }

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

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

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
        address sender = _msgSender();
        if (from != sender && !isApprovedForAll(from, sender)) {
            revert ERC1155MissingApprovalForAll(sender, from);
        }
        _safeTransferFrom(from, to, id, value, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) public virtual {
        address sender = _msgSender();
        if (from != sender && !isApprovedForAll(from, sender)) {
            revert ERC1155MissingApprovalForAll(sender, from);
        }
        _safeBatchTransferFrom(from, to, ids, values, data);
    }

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from`
     * (or `to`) is the zero address.
     *
     * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
     *   or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
     * - `ids` and `values` must have the same length.
     *
     * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
     */
    function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
        if (ids.length != values.length) {
            revert ERC1155InvalidArrayLength(ids.length, values.length);
        }

        address operator = _msgSender();

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids.unsafeMemoryAccess(i);
            uint256 value = values.unsafeMemoryAccess(i);

            if (from != address(0)) {
                uint256 fromBalance = _balances[id][from];
                if (fromBalance < value) {
                    revert ERC1155InsufficientBalance(from, fromBalance, value, id);
                }
                unchecked {
                    // Overflow not possible: value <= fromBalance
                    _balances[id][from] = fromBalance - value;
                }
            }

            if (to != address(0)) {
                _balances[id][to] += value;
            }
        }

        if (ids.length == 1) {
            uint256 id = ids.unsafeMemoryAccess(0);
            uint256 value = values.unsafeMemoryAccess(0);
            emit TransferSingle(operator, from, to, id, value);
        } else {
            emit TransferBatch(operator, from, to, ids, values);
        }
    }

    /**
     * @dev Version of {_update} that performs the token acceptance check by calling
     * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it
     * contains code (eg. is a smart contract at the moment of execution).
     *
     * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any
     * update to the contract state after this function would break the check-effect-interaction pattern. Consider
     * overriding {_update} instead.
     */
    function _updateWithAcceptanceCheck(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) internal virtual {
        _update(from, to, ids, values);
        if (to != address(0)) {
            address operator = _msgSender();
            if (ids.length == 1) {
                uint256 id = ids.unsafeMemoryAccess(0);
                uint256 value = values.unsafeMemoryAccess(0);
                _doSafeTransferAcceptanceCheck(operator, from, to, id, value, data);
            } else {
                _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data);
            }
        }
    }

    /**
     * @dev Transfers a `value` 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 `value` 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 value, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(from, to, ids, values, 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.
     * - `ids` and `values` must have the same length.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        _updateWithAcceptanceCheck(from, to, ids, values, 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 values 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 a `value` amount of tokens of 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 value, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(address(0), to, ids, values, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - `to` cannot be the zero address.
     * - 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 values, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        _updateWithAcceptanceCheck(address(0), to, ids, values, data);
    }

    /**
     * @dev Destroys a `value` amount of tokens of type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `value` amount of tokens of type `id`.
     */
    function _burn(address from, uint256 id, uint256 value) internal {
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(from, address(0), ids, values, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `value` amount of tokens of type `id`.
     * - `ids` and `values` must have the same length.
     */
    function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        _updateWithAcceptanceCheck(from, address(0), ids, values, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the zero address.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        if (operator == address(0)) {
            revert ERC1155InvalidOperator(address(0));
        }
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address
     * if it contains code at the moment of execution.
     */
    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 value,
        bytes memory data
    ) private {
        if (to.code.length > 0) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    // Tokens rejected
                    revert ERC1155InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-ERC1155Receiver implementer
                    revert ERC1155InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }

    /**
     * @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address
     * if it contains code at the moment of execution.
     */
    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) private {
        if (to.code.length > 0) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    // Tokens rejected
                    revert ERC1155InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-ERC1155Receiver implementer
                    revert ERC1155InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }

    /**
     * @dev Creates an array in memory with only one value for each of the elements provided.
     */
    function _asSingletonArrays(
        uint256 element1,
        uint256 element2
    ) private pure returns (uint256[] memory array1, uint256[] memory array2) {
        /// @solidity memory-safe-assembly
        assembly {
            // Load the free memory pointer
            array1 := mload(0x40)
            // Set array length to 1
            mstore(array1, 1)
            // Store the single element at the next word after the length (where content starts)
            mstore(add(array1, 0x20), element1)

            // Repeat for next array locating it right after the first array
            array2 := add(array1, 0x40)
            mstore(array2, 1)
            mstore(add(array2, 0x20), element2)

            // Update the free memory pointer by pointing after the second array
            mstore(0x40, add(array2, 0x40))
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 */
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);
}

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

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of 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 value 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 a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * 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 `value` 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 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` 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 values,
        bytes calldata data
    ) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

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

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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 An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, 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);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @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.encodeCall(token.approve, (spender, value));

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

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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(token).code.length > 0;
    }
}

File 13 of 49 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.20;

import {IERC721} from "./IERC721.sol";
import {IERC721Receiver} from "./IERC721Receiver.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    mapping(uint256 tokenId => address) private _owners;

    mapping(address owner => uint256) private _balances;

    mapping(uint256 tokenId => address) private _tokenApprovals;

    mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;

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

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual returns (uint256) {
        if (owner == address(0)) {
            revert ERC721InvalidOwner(address(0));
        }
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual returns (address) {
        return _requireOwned(tokenId);
    }

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

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

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

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

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

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual {
        _approve(to, tokenId, _msgSender());
    }

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

        return _getApproved(tokenId);
    }

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

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
        address previousOwner = _update(to, tokenId, _msgSender());
        if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

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

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
        transferFrom(from, to, tokenId);
        _checkOnERC721Received(from, to, tokenId, data);
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     *
     * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
     * core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances
     * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
     * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
     */
    function _getApproved(uint256 tokenId) internal view virtual returns (address) {
        return _tokenApprovals[tokenId];
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
     * particular (ignoring whether it is owned by `owner`).
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
        return
            spender != address(0) &&
            (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
    }

    /**
     * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
     * Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets
     * the `spender` for the specific `tokenId`.
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
        if (!_isAuthorized(owner, spender, tokenId)) {
            if (owner == address(0)) {
                revert ERC721NonexistentToken(tokenId);
            } else {
                revert ERC721InsufficientApproval(spender, tokenId);
            }
        }
    }

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
     * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
     *
     * WARNING: Increasing an account's balance using this function tends to be paired with an override of the
     * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
     * remain consistent with one another.
     */
    function _increaseBalance(address account, uint128 value) internal virtual {
        unchecked {
            _balances[account] += value;
        }
    }

    /**
     * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
     * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that
     * `auth` is either the owner of the token, or approved to operate on the token (by the owner).
     *
     * Emits a {Transfer} event.
     *
     * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
        address from = _ownerOf(tokenId);

        // Perform (optional) operator check
        if (auth != address(0)) {
            _checkAuthorized(from, auth, tokenId);
        }

        // Execute the update
        if (from != address(0)) {
            // Clear approval. No need to re-authorize or emit the Approval event
            _approve(address(0), tokenId, address(0), false);

            unchecked {
                _balances[from] -= 1;
            }
        }

        if (to != address(0)) {
            unchecked {
                _balances[to] += 1;
            }
        }

        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        return from;
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner != address(0)) {
            revert ERC721InvalidSender(address(0));
        }
    }

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

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

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal {
        address previousOwner = _update(address(0), tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        } else if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
     * are aware of the ERC721 standard to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is like {safeTransferFrom} in the sense that it invokes
     * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `tokenId` token must exist and be owned by `from`.
     * - `to` cannot be the zero address.
     * - `from` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId) internal {
        _safeTransfer(from, to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
        _transfer(from, to, tokenId);
        _checkOnERC721Received(from, to, tokenId, data);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
     * either the owner of the token, or approved to operate on all tokens held by this owner.
     *
     * Emits an {Approval} event.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address to, uint256 tokenId, address auth) internal {
        _approve(to, tokenId, auth, true);
    }

    /**
     * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
     * emitted in the context of transfers.
     */
    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
        // Avoid reading the owner unless necessary
        if (emitEvent || auth != address(0)) {
            address owner = _requireOwned(tokenId);

            // We do not use _isAuthorized because single-token approvals should not be able to call approve
            if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
                revert ERC721InvalidApprover(auth);
            }

            if (emitEvent) {
                emit Approval(owner, to, tokenId);
            }
        }

        _tokenApprovals[tokenId] = to;
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Requirements:
     * - operator can't be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        if (operator == address(0)) {
            revert ERC721InvalidOperator(operator);
        }
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
     * Returns the owner.
     *
     * Overrides to ownership logic should be done to {_ownerOf}.
     */
    function _requireOwned(uint256 tokenId) internal view returns (address) {
        address owner = _ownerOf(tokenId);
        if (owner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
        return owner;
    }

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the
     * recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     */
    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private {
        if (to.code.length > 0) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                if (retval != IERC721Receiver.onERC721Received.selector) {
                    revert ERC721InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert ERC721InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }
}

File 14 of 49 : ERC721Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Burnable.sol)

pragma solidity ^0.8.20;

import {ERC721} from "../ERC721.sol";
import {Context} from "../../../utils/Context.sol";

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be burned (destroyed).
 */
abstract contract ERC721Burnable is Context, ERC721 {
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
        _update(address(0), tokenId, _msgSender());
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.20;

import {ERC721} from "../ERC721.sol";
import {IERC721Enumerable} from "./IERC721Enumerable.sol";
import {IERC165} from "../../../utils/introspection/ERC165.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds enumerability
 * of all the token ids in the contract as well as all token ids owned by each account.
 *
 * CAUTION: `ERC721` extensions that implement custom `balanceOf` logic, such as `ERC721Consecutive`,
 * interfere with enumerability and should not be used together with `ERC721Enumerable`.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;
    mapping(uint256 tokenId => uint256) private _ownedTokensIndex;

    uint256[] private _allTokens;
    mapping(uint256 tokenId => uint256) private _allTokensIndex;

    /**
     * @dev An `owner`'s token query was out of bounds for `index`.
     *
     * NOTE: The owner being `address(0)` indicates a global out of bounds index.
     */
    error ERC721OutOfBoundsIndex(address owner, uint256 index);

    /**
     * @dev Batch mint is not allowed.
     */
    error ERC721EnumerableForbiddenBatchMint();

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {
        if (index >= balanceOf(owner)) {
            revert ERC721OutOfBoundsIndex(owner, index);
        }
        return _ownedTokens[owner][index];
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual returns (uint256) {
        if (index >= totalSupply()) {
            revert ERC721OutOfBoundsIndex(address(0), index);
        }
        return _allTokens[index];
    }

    /**
     * @dev See {ERC721-_update}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
        address previousOwner = super._update(to, tokenId, auth);

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

        return previousOwner;
    }

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

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

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

        uint256 lastTokenIndex = balanceOf(from);
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

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

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

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

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

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

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

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

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

    /**
     * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
     */
    function _increaseBalance(address account, uint128 amount) internal virtual override {
        if (amount > 0) {
            revert ERC721EnumerableForbiddenBatchMint();
        }
        super._increaseBalance(account, amount);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.20;

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

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

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

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

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

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

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

File 19 of 49 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) 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 FailedInnerCall();
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol)

pragma solidity ^0.8.20;

import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";

/**
 * @dev Collection of functions related to array types.
 */
library Arrays {
    using StorageSlot for bytes32;

    /**
     * @dev Searches a sorted `array` and returns the first index that contains
     * a value greater or equal to `element`. If no such index exists (i.e. all
     * values in the array are strictly less than `element`), the array length is
     * returned. Time complexity O(log n).
     *
     * `array` is expected to be sorted in ascending order, and to contain no
     * repeated elements.
     */
    function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
        uint256 low = 0;
        uint256 high = array.length;

        if (high == 0) {
            return 0;
        }

        while (low < high) {
            uint256 mid = Math.average(low, high);

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because Math.average rounds towards zero (it does integer division with truncation).
            if (unsafeAccess(array, mid).value > element) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
        if (low > 0 && unsafeAccess(array, low - 1).value == element) {
            return low - 1;
        } else {
            return low;
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getAddressSlot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getBytes32Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getUint256Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.2) (utils/Base64.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides a set of functions to operate with Base64 strings.
 */
library Base64 {
    /**
     * @dev Base64 Encoding/Decoding Table
     */
    string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    /**
     * @dev Converts a `bytes` to its Bytes64 `string` representation.
     */
    function encode(bytes memory data) internal pure returns (string memory) {
        /**
         * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
         * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
         */
        if (data.length == 0) return "";

        // Loads the table into memory
        string memory table = _TABLE;

        // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
        // and split into 4 numbers of 6 bits.
        // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
        // - `data.length + 2`  -> Round up
        // - `/ 3`              -> Number of 3-bytes chunks
        // - `4 *`              -> 4 characters for each chunk
        string memory result = new string(4 * ((data.length + 2) / 3));

        /// @solidity memory-safe-assembly
        assembly {
            // Prepare the lookup table (skip the first "length" byte)
            let tablePtr := add(table, 1)

            // Prepare result pointer, jump over length
            let resultPtr := add(result, 0x20)
            let dataPtr := data
            let endPtr := add(data, mload(data))

            // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and
            // set it to zero to make sure no dirty bytes are read in that section.
            let afterPtr := add(endPtr, 0x20)
            let afterCache := mload(afterPtr)
            mstore(afterPtr, 0x00)

            // Run over the input, 3 bytes at a time
            for {

            } lt(dataPtr, endPtr) {

            } {
                // Advance 3 bytes
                dataPtr := add(dataPtr, 3)
                let input := mload(dataPtr)

                // To write each character, shift the 3 byte (24 bits) chunk
                // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
                // and apply logical AND with 0x3F to bitmask the least significant 6 bits.
                // Use this as an index into the lookup table, mload an entire word
                // so the desired character is in the least significant byte, and
                // mstore8 this least significant byte into the result and continue.

                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance
            }

            // Reset the value that was cached
            mstore(afterPtr, afterCache)

            // When data `bytes` is not exactly 3 bytes long
            // it is padded with `=` characters at the end
            switch mod(mload(data), 3)
            case 1 {
                mstore8(sub(resultPtr, 1), 0x3d)
                mstore8(sub(resultPtr, 2), 0x3d)
            }
            case 2 {
                mstore8(sub(resultPtr, 1), 0x3d)
            }
        }

        return result;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @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 towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (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 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                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.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

            uint256 twos = denominator & (0 - denominator);
            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 (unsignedRoundsUp(rounding) && 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
     * towards zero.
     *
     * 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * 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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * 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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * 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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

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

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

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

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

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

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

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

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

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

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

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

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

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

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @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), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(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) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        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 bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

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

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }
}

// SPDX-License-Identifier: MIT
// AccessControl contract

pragma solidity ^0.8.7;

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

abstract contract AccessControl is Ownable {
    event Authorized(address _authorized);
    event UnAuthorized(address _authorized);

    mapping(address => bool) private authorized;

    modifier onlyOwnerOrAuthorized() {
        _checkOwnerOrAuthorized();
        _;
    }

    constructor() Ownable(msg.sender) {}

    function _checkOwnerOrAuthorized() internal view virtual {
        require((owner() == _msgSender()) || (authorized[_msgSender()] == true), "Access Control: caller is not the owner or authorized");
    }

    function addAuthorized(address _authorized) public onlyOwner {
        authorized[_authorized] = true;
        emit Authorized(_authorized);
    }

    function removeAuthorized(address _authorized) public onlyOwner {
        authorized[_authorized] = false;
        emit UnAuthorized(_authorized);
    }

    function isAuthorized(address _user) public view returns (bool) {
        return authorized[_user];
    }
}

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

pragma solidity ^0.8.0;

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

contract FakeERC20 is ERC20 {
    constructor() ERC20("FakeERC20", "FakeERC20") {
        _mint(msg.sender, 100000 * 10 ** 6);
    }

    function decimals() public pure override returns (uint8) {
        return 6;
    }

    function mint(address _to, uint256 _amount) external {
        _mint(_to, _amount);
    }

    function burn(address _from, uint256 _amount) external {
        _burn(_from, _amount);
    }
}

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

library LibString {
    function replace(string memory subject, string memory search, string memory replacement) internal pure returns (string memory result) {
        assembly {
            let subjectLength := mload(subject)
            let searchLength := mload(search)
            let replacementLength := mload(replacement)

            // Store the mask for sub-word comparisons in the scratch space.
            mstore(0x00, not(0))
            mstore(0x20, 0)

            subject := add(subject, 0x20)
            search := add(search, 0x20)
            replacement := add(replacement, 0x20)
            result := add(mload(0x40), 0x20)

            let k := 0

            let subjectEnd := add(subject, subjectLength)
            if iszero(gt(searchLength, subjectLength)) {
                let subjectSearchEnd := add(sub(subjectEnd, searchLength), 1)
                for {

                } lt(subject, subjectSearchEnd) {

                } {
                    let o := and(searchLength, 31)
                    // Whether the first `searchLength % 32` bytes of
                    // `subject` and `search` matches.
                    let l := iszero(and(xor(mload(subject), mload(search)), mload(sub(0x20, o))))
                    // Iterate through the rest of `search` and check if any word mismatch.
                    // If any mismatch is detected, `l` is set to 0.
                    for {

                    } and(lt(o, searchLength), l) {

                    } {
                        l := eq(mload(add(subject, o)), mload(add(search, o)))
                        o := add(o, 0x20)
                    }
                    // If `l` is one, there is a match, and we have to copy the `replacement`.
                    if l {
                        // Copy the `replacement` one word at a time.
                        for {
                            o := 0
                        } lt(o, replacementLength) {
                            o := add(o, 0x20)
                        } {
                            mstore(add(result, add(k, o)), mload(add(replacement, o)))
                        }
                        k := add(k, replacementLength)
                        subject := add(subject, searchLength)
                    }
                    // If `l` or `searchLength` is zero.
                    if iszero(mul(l, searchLength)) {
                        mstore(add(result, k), mload(subject))
                        k := add(k, 1)
                        subject := add(subject, 1)
                    }
                }
            }

            let resultRemainder := add(result, k)
            k := add(k, sub(subjectEnd, subject))
            // Copy the rest of the string one word at a time.
            for {

            } lt(subject, subjectEnd) {

            } {
                mstore(resultRemainder, mload(subject))
                resultRemainder := add(resultRemainder, 0x20)
                subject := add(subject, 0x20)
            }
            // Allocate memory for the length and the bytes, rounded up to a multiple of 32.
            mstore(0x40, add(result, and(add(k, 64), not(31))))
            result := sub(result, 0x20)
            mstore(result, k)
        }
    }
}

File 34 of 49 : MuchoBadgeManager.sol
// SPDX-License-Identifier: MIT
// MuchoBadgeManager contract

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./AccessControl.sol";

contract MuchoBadgeManager is ERC1155, AccessControl {
    event PlanAdded(uint256 id, string name, string uri, uint time, Price subscriptionPrice, Price renewalPrice, bool enabled);
    event PlanUpdated(uint256 id, string name, string uri, uint time, Price subscriptionPrice, Price renewalPrice, bool enabled);
    event PlanDisabled(uint256 id);
    event PlanEnabled(uint256 id);
    event Subscribed(uint256 planId, address subscriber);
    event SubscriptionCancelled(uint256 planId, address subscriber);
    event SubscriptionRenewed(uint256 planId, address subscriber);

    using SafeERC20 for IERC20;

    struct Price {
        address token;
        uint256 amount;
    }

    struct Plan {
        uint256 id;
        string name;
        string uri;
        uint256 subscribers;
        Price subscriptionPrice;
        Price renewalPrice;
        uint time;
        bool exists;
        bool enabled;
        uint256 activeSubscribers;
    }

    mapping(uint256 => Plan) internal plans;
    mapping(address => mapping(uint256 => uint256)) internal subscriberToPlanDate;
    address[] internal subscriberList;
    uint256 public totalPlans;

    constructor(string memory name, string memory symbol, string memory uri) ERC1155(uri) {}

    modifier correctId(uint _planId) {
        require(_planId <= totalPlans && _planId > 0, "MuchoBadgeManager correctId: provide a correct planID");
        _;
    }

    modifier enabledPlan(uint _planId) {
        require(plans[_planId].enabled, "MuchoBadgeManager activePlan: plan is not enabled");
        _;
    }

    function existsAndExpired(address _user, uint _planId) internal view correctId(_planId) returns (bool) {
        if (subscriberToPlanDate[_user][_planId] > 0) {
            return ((block.timestamp) - (subscriberToPlanDate[_user][_planId]) >= plans[_planId].time);
        } else {
            return false;
        }
    }

    function existsAndActive(address _user, uint _planId) internal view correctId(_planId) returns (bool) {
        if (subscriberToPlanDate[_user][_planId] > 0) {
            return ((block.timestamp) - (subscriberToPlanDate[_user][_planId]) < plans[_planId].time);
        } else {
            return false;
        }
    }

    function notSubscribed(address _user, uint _planId) internal view correctId(_planId) returns (bool) {
        return (subscriberToPlanDate[_user][_planId] <= 0);
    }

    /*-------------------EXTERNAL - OWNER-------------------------*/

    function subscribe(uint256 _planId, address _subscriber) external correctId(_planId) enabledPlan(_planId) onlyOwnerOrAuthorized {
        _addToPlan(_planId, _subscriber);
    }

    function cancelSubscription(uint256 _planId, address _subscriber) external correctId(_planId) enabledPlan(_planId) onlyOwnerOrAuthorized {
        _removeFromPlan(_planId, _subscriber);
    }

    function renew(uint256 _planId, address _subscriber) external correctId(_planId) enabledPlan(_planId) onlyOwnerOrAuthorized {
        _renewPlan(_planId, _subscriber);
    }

    function updateAllActiveSubscribers() external onlyOwnerOrAuthorized {
        _updateAllActiveSubscribers();
    }

    // force the expiration of a subscription (for testing purposes mainly)
    function forceExpiration(uint256 _planId, address _subscriber) external correctId(_planId) enabledPlan(_planId) onlyOwnerOrAuthorized {
        //Manipulate sign in date
        subscriberToPlanDate[_subscriber][_planId] = block.timestamp - (plans[_planId].time) - (1 days);
    }

    function setURI(string memory _uri) external onlyOwnerOrAuthorized {
        _setURI(_uri);
    }

    function addPlan(
        string memory _name,
        string memory _uri,
        uint256 _time,
        Price memory _subscriptionPrice,
        Price memory _renewalPrice,
        bool _enabled
    ) external onlyOwnerOrAuthorized returns (uint256) {
        totalPlans += 1;
        uint256 id = totalPlans;

        plans[id] = Plan(id, _name, _uri, 0, _subscriptionPrice, _renewalPrice, _time, true, _enabled, 0);

        emit PlanAdded(id, _name, _uri, _time, _subscriptionPrice, _renewalPrice, _enabled);

        return id;
    }

    function updatePlan(
        uint256 _planId,
        string memory _name,
        string memory _uri,
        uint _time,
        Price memory _subscriptionPrice,
        Price memory _renewalPrice,
        bool _enabled
    ) external onlyOwnerOrAuthorized correctId(_planId) {
        plans[_planId].name = _name;
        plans[_planId].uri = _uri;
        plans[_planId].subscriptionPrice = _subscriptionPrice;
        plans[_planId].renewalPrice = _renewalPrice;
        plans[_planId].time = _time;
        plans[_planId].enabled = _enabled;

        emit PlanUpdated(_planId, _name, _uri, _time, _subscriptionPrice, _renewalPrice, _enabled);

        _updateActiveSubscribers(_planId);
    }

    function updatePlanDuration(uint256 _planId, uint _time) external onlyOwnerOrAuthorized correctId(_planId) {
        plans[_planId].time = _time;

        emit PlanUpdated(_planId, plans[_planId].name, plans[_planId].uri, plans[_planId].time, plans[_planId].subscriptionPrice, plans[_planId].renewalPrice, plans[_planId].enabled);

        _updateActiveSubscribers(_planId);
    }

    function disablePlan(uint256 _planId) external onlyOwnerOrAuthorized correctId(_planId) enabledPlan(_planId) {
        plans[_planId].enabled = false;
        emit PlanDisabled(_planId);
        _updateActiveSubscribers(_planId);
    }

    function enablePlan(uint256 _planId) external onlyOwnerOrAuthorized correctId(_planId) {
        require(!plans[_planId].enabled, "MuchoBadgeManager enablePlan: plan is already enabled");
        plans[_planId].enabled = true;
        emit PlanEnabled(_planId);
        _updateActiveSubscribers(_planId);
    }

    function balance() public view onlyOwnerOrAuthorized returns (uint) {
        return address(this).balance;
    }

    function withdraw(address _token, uint256 _amount) external onlyOwnerOrAuthorized {
        IERC20 token = IERC20(_token);
        //token.safeApprove(this.address, _amount); //this.address?
        token.safeTransfer(owner(), _amount);
    }

    /*-------------------EXTERNAL-------------------------*/
    function subscribe(uint256 _planId) external correctId(_planId) enabledPlan(_planId) {
        require(notSubscribed(msg.sender, _planId), "MuchoBadgeManager subscribe: already subscribed");

        //Charge subscription fee
        _chargeFee(msg.sender, plans[_planId].subscriptionPrice);

        //Subscribe and mint NFT
        _addToPlan(_planId, msg.sender);
    }

    function renew(uint256 _planId) external correctId(_planId) enabledPlan(_planId) {
        require(existsAndExpired(msg.sender, _planId), "MuchoBadgeManager renew: Your current plan has not expired yet");

        //Charge renewal fee
        _chargeFee(msg.sender, plans[_planId].renewalPrice);

        //Subscribe and mint NFT
        _renewPlan(_planId, msg.sender);
    }

    function activePlansForUser(address _user) public view returns (Plan[] memory) {
        uint256 planCount = 0;
        Plan[] memory currentPlans = new Plan[](totalPlans);
        for (uint256 i = 1; i <= totalPlans; i++) {
            if (existsAndActive(_user, i)) {
                currentPlans[planCount] = plans[i];
                planCount++;
            }
        }

        Plan[] memory _returnPlans = new Plan[](planCount);
        for (uint256 i = 0; i < planCount; i++) {
            _returnPlans[i] = currentPlans[i];
        }

        return _returnPlans;
    }

    function expiredPlansForUser(address _user) public view returns (Plan[] memory) {
        uint256 planCount = 0;
        Plan[] memory currentPlans = new Plan[](totalPlans);
        for (uint256 i = 1; i <= totalPlans; i++) {
            if (existsAndExpired(_user, i)) {
                currentPlans[planCount] = plans[i];
                planCount++;
            }
        }

        Plan[] memory _returnPlans = new Plan[](planCount);
        for (uint256 i = 0; i < planCount; i++) {
            _returnPlans[i] = currentPlans[i];
        }

        return _returnPlans;
    }

    function enabledPlans() public view returns (Plan[] memory) {
        uint256 enabledPlanCount = 0;
        Plan[] memory currentPlans = new Plan[](totalPlans);
        for (uint256 i = 1; i <= totalPlans; i++) {
            if (plans[i].enabled) {
                currentPlans[enabledPlanCount] = plans[i];
                enabledPlanCount++;
            }
        }

        Plan[] memory _enabledPlans = new Plan[](enabledPlanCount);
        for (uint256 i = 0; i < enabledPlanCount; i++) {
            _enabledPlans[i] = currentPlans[i];
        }

        return _enabledPlans;
    }

    function allPlans() public view returns (Plan[] memory) {
        Plan[] memory currentPlans = new Plan[](totalPlans);
        for (uint256 i = 1; i <= totalPlans; i++) {
            currentPlans[i - 1] = plans[i];
        }

        return currentPlans;
    }

    function plan(uint256 _planId) public view correctId(_planId) returns (Plan memory) {
        return plans[_planId];
    }

    function isSubscribedAndActive(address _user, uint256 _planId) public view correctId(_planId) returns (bool) {
        return existsAndActive(_user, _planId);
    }

    function subscriptionExpiration(address _user, uint256 _planId) public view correctId(_planId) returns (uint256) {
        require(existsAndActive(_user, _planId), "subscriptionExpiration: not subscribed");
        return subscriberToPlanDate[_user][_planId] + (plans[_planId].time);
    }

    function isSubscribedAndExpired(address _user, uint256 _planId) public view correctId(_planId) returns (bool) {
        return existsAndExpired(_user, _planId);
    }

    function tokenURI(uint _planId) public view correctId(_planId) returns (string memory) {
        return plans[_planId].uri;
    }

    function tokenSupply(uint _planId) public view correctId(_planId) returns (uint) {
        return plans[_planId].subscribers;
    }

    function subscriptionPrice(uint _planId) public view correctId(_planId) returns (Price memory) {
        return plans[_planId].subscriptionPrice;
    }

    function renewalPrice(uint _planId) public view correctId(_planId) returns (Price memory) {
        return plans[_planId].renewalPrice;
    }

    function totalSupply() public view returns (uint) {
        return totalPlans;
    }

    /*---------------------INTERNAL------------------------*/

    function _addToPlan(uint256 _planId, address _subscriber) internal correctId(_planId) {
        require(notSubscribed(_subscriber, _planId), "MuchoBadgeManager addToPlan: Already subscribed");

        //Add a subscriber to the count
        plans[_planId].subscribers++;
        plans[_planId].activeSubscribers++;
        _addSubscriberToList(_subscriber);

        //Save subscription plan and date
        subscriberToPlanDate[_subscriber][_planId] = block.timestamp;

        //Mint 1 NFT of the planId
        _mint(_subscriber, _planId, 1, "");

        emit Subscribed(_planId, _subscriber);

        _updateActiveSubscribers(_planId);
    }

    function _removeFromPlan(uint256 _planId, address _subscriber) internal correctId(_planId) {
        require(!notSubscribed(_subscriber, _planId), "MuchoBadgeManager removeFromPlan: Not subscribed");

        //Subtract a subscriber to the count
        plans[_planId].subscribers--;
        plans[_planId].activeSubscribers--;

        //Remove subscription date
        subscriberToPlanDate[_subscriber][_planId] = 0;

        //Burn NFT
        _burn(_subscriber, _planId, 1);

        emit SubscriptionCancelled(_planId, _subscriber);

        _updateActiveSubscribers(_planId);
    }

    function _renewPlan(uint256 _planId, address _subscriber) internal correctId(_planId) {
        require(existsAndExpired(_subscriber, _planId), "MuchoBadgeManager renewPlan: Not subscribed or not expired");

        //Add a subscriber to the count - As we do not subtract when expired, we do not add when renewed
        _updateActiveSubscribers(_planId);

        //Save subscription plan and date - no need to burn nor mint NFT
        subscriberToPlanDate[_subscriber][_planId] = block.timestamp;

        emit SubscriptionRenewed(_planId, _subscriber);

        _updateActiveSubscribers(_planId);
    }

    function _chargeFee(address _subscriber, Price memory _price) internal {
        IERC20 token = IERC20(_price.token);
        require(token.balanceOf(_subscriber) >= _price.amount, "Not enough balance to pay fee");
        require(token.allowance(_subscriber, address(this)) >= _price.amount, "Not enough allowance to pay fee");
        token.safeTransferFrom(_subscriber, address(this), _price.amount);
    }

    function _updateAllActiveSubscribers() internal {
        for (uint i = 1; i <= totalPlans; i++) {
            _updateActiveSubscribers(plans[i].id);
        }
    }

    function _updateActiveSubscribers(uint256 _planId) internal correctId(_planId) {
        uint activeSubs = 0;
        for (uint i = 0; i < subscriberList.length; i++) {
            address subscriber = subscriberList[i];
            if (existsAndActive(subscriber, _planId)) activeSubs++;
        }

        plans[_planId].activeSubscribers = activeSubs;
    }

    function _addSubscriberToList(address _subscriber) internal {
        for (uint i = 0; i < subscriberList.length; i++) {
            if (subscriberList[i] == _subscriber) return;
        }
        subscriberList.push(_subscriber);
    }
}

// SPDX-License-Identifier: MIT
// MuchoBadgeManager contract

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./AccessControl.sol";
import "../interfaces/IMuchoBadgeNFTBridge.sol";
import "../interfaces/IMuchoNFTFetcher.sol";

contract MuchoBadgeNFTBridge is AccessControl, IMuchoBadgeNFTBridge {
    using SafeERC20 for IERC20;

    IMuchoNFTFetcher fetcher = IMuchoNFTFetcher(0xBA3EacD2afADD1C38b940A461c48540c77a121d3);

    /*-------------------EXTERNAL - OWNER-------------------------*/
    function setFetcher(IMuchoNFTFetcher _fetcher) external onlyOwnerOrAuthorized {
        fetcher = _fetcher;
    }

    /*-------------------EXTERNAL-------------------------*/
    function activePlansForUser(address _user) public view returns (Plan[] memory) {
        IMuchoNFTFetcher.PlanAttributesExtended[] memory plans = fetcher.activePlansForUser(_user);

        Plan[] memory _returnPlans = new Plan[](plans.length);
        for (uint256 i = 0; i < plans.length; i++) {
            _returnPlans[i] = Plan({
                id: plans[i].id,
                name: plans[i].planName,
                uri: "",
                subscribers: 0,
                subscriptionPrice: Price({token: address(0), amount: 0}),
                renewalPrice: Price({token: address(0), amount: 0}),
                time: plans[i].duration,
                exists: true,
                enabled: plans[i].enabled,
                activeSubscribers: 0
            });
        }

        return _returnPlans;
    }
}

// SPDX-License-Identifier: MIT
// MuchoBadgeManager contract

pragma solidity ^0.8.20;
import "./AccessControl.sol";
import "../interfaces/IMuchoBadgeManager.sol";
import "../interfaces/IMuchoRewardRouter.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract MuchoBadgeWrapper is AccessControl {
    using SafeERC20 for IERC20;

    IMuchoBadgeManager public badgeManager = IMuchoBadgeManager(0xC439d29ee3C7fa237da928AD3A3D6aEcA9aA0717);
    IMuchoRewardRouter public rewardRouter = IMuchoRewardRouter(0x96D395d088C8e053f759F97695Efac4D4b45407A);

    function setBadgeManager(address badge) external onlyOwner {
        badgeManager = IMuchoBadgeManager(badge);
    }

    function setRewardRouter(address router) external onlyOwner {
        rewardRouter = IMuchoRewardRouter(router);
    }

    function subscribe(uint256 planId, address subscriber) public onlyOwnerOrAuthorized {
        if (!badgeManager.isSubscribedAndActive(subscriber, planId)) badgeManager.subscribe(planId, subscriber);

        rewardRouter.addUserIfNotExists(subscriber);
    }

    function bulkSubscribe(uint256 planId, address[] calldata subscribers) external onlyOwnerOrAuthorized {
        for (uint256 i = 0; i < subscribers.length; i++) {
            subscribe(planId, subscribers[i]);
        }
    }

    function subscribe(uint256 _planId) external {
        IMuchoBadgeManager.Plan memory plan = badgeManager.plan(_planId);

        //Pay subscription fee
        IERC20 token = IERC20(plan.subscriptionPrice.token);
        token.safeTransferFrom(msg.sender, address(badgeManager), plan.subscriptionPrice.amount);

        //Subscribe and mint NFT
        subscribe(_planId, msg.sender);
    }

    function renew(uint256 _planId) external {
        IMuchoBadgeManager.Plan memory plan = badgeManager.plan(_planId);

        //Pay renewal fee
        IERC20 token = IERC20(plan.renewalPrice.token);
        token.safeTransferFrom(msg.sender, address(badgeManager), plan.renewalPrice.amount);

        //Subscribe and mint NFT
        badgeManager.renew(_planId, msg.sender);
        rewardRouter.addUserIfNotExists(msg.sender);
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./AccessControl.sol";
import "../interfaces/IMuchoNFT.sol";
import "../interfaces/IMuchoNFTFetcher.sol";
import "./MuchoNFT.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

contract MuchoNFTFetcher is AccessControl, IMuchoNFTFetcher {
    using SafeERC20 for IERC20;
    using EnumerableSet for EnumerableSet.AddressSet;

    /*-------------------ATTRIBUTES-------------------------*/
    uint256 public nextNFT = 1;
    mapping(uint256 => IMuchoNFT) public nftList;
    mapping(uint256 => IMuchoPricing) public nftPricing;
    mapping(uint256 => IMuchoPricing) public nftRenewalPricing;

    /*-------------------SETTERS-------------------------*/
    function setSubscriptionPricing(uint256 _idToken, IMuchoPricing _pricing) external onlyOwnerOrAuthorized {
        nftPricing[_idToken] = _pricing;
    }

    function setRenewalPricing(uint256 _idToken, IMuchoPricing _pricing) external onlyOwnerOrAuthorized {
        nftRenewalPricing[_idToken] = _pricing;
    }

    /*-------------------VIEWS-------------------------*/
    function nftById(uint256 _id) external view returns (IMuchoNFT nft) {
        nft = nftList[_id];
    }

    function activePlansForUser(address _user) external view returns (PlanAttributesExtended[] memory plans) {
        uint256 totalPlans = 0;
        PlanAttributesExtended[] memory totPlans = new PlanAttributesExtended[](nextNFT - 1);

        for (uint256 i = 1; i < nextNFT; i++) {
            if (address(nftList[i]) != address(0)) {
                IMuchoNFT mNFT = nftList[i];
                if (mNFT.activeBalanceOf(_user) > 0) {
                    IMuchoNFT.PlanAttributes memory attr = mNFT.planAttributes();
                    totPlans[totalPlans++] = PlanAttributesExtended({id: i, nftAddress: attr.nftAddress, planName: attr.planName, duration: attr.duration, enabled: attr.enabled});
                }
            }
        }

        //Reduce array
        if (totalPlans > 0) {
            plans = new PlanAttributesExtended[](totalPlans);
            for (uint256 i = 0; i < totalPlans; i++) {
                plans[i] = totPlans[i];
            }
        }
    }

    function enabledPlans() external view returns (PlanAttributesExtended[] memory plans) {
        uint256 totalPlans = 0;
        PlanAttributesExtended[] memory totPlans = new PlanAttributesExtended[](nextNFT - 1);

        for (uint256 i = 1; i < nextNFT; i++) {
            if (address(nftList[i]) != address(0)) {
                IMuchoNFT mNFT = nftList[i];
                IMuchoNFT.PlanAttributes memory attr = mNFT.planAttributes();
                if (attr.enabled) {
                    totPlans[totalPlans++] = PlanAttributesExtended({id: i, nftAddress: attr.nftAddress, planName: attr.planName, duration: attr.duration, enabled: attr.enabled});
                }
            }
        }

        //Reduce array
        if (totalPlans > 0) {
            plans = new PlanAttributesExtended[](totalPlans);
            for (uint256 i = 0; i < totalPlans; i++) {
                plans[i] = totPlans[i];
            }
        }
    }

    function allPlans() external view returns (PlanAttributesExtended[] memory plans) {
        uint256 totalPlans = 0;
        PlanAttributesExtended[] memory totPlans = new PlanAttributesExtended[](nextNFT - 1);

        for (uint256 i = 1; i < nextNFT; i++) {
            if (address(nftList[i]) != address(0)) {
                IMuchoNFT mNFT = nftList[i];
                IMuchoNFT.PlanAttributes memory attr = mNFT.planAttributes();
                totPlans[totalPlans++] = PlanAttributesExtended({id: i, nftAddress: attr.nftAddress, planName: attr.planName, duration: attr.duration, enabled: attr.enabled});
            }
        }

        //Reduce array
        if (totalPlans > 0) {
            plans = new PlanAttributesExtended[](totalPlans);
            for (uint256 i = 0; i < totalPlans; i++) {
                plans[i] = totPlans[i];
            }
        }
    }

    function subscriptionPrice(uint256 _idNFT, address _user) external view returns (IMuchoPricing.Price memory price) {
        IMuchoNFT mNFT = nftList[_idNFT];
        require(address(mNFT) != address(0), "MuchoNFTFetcher - Id does not exist");

        IMuchoPricing pricing = nftPricing[_idNFT];
        require(address(pricing) != address(0), "MuchoNFTFetcher - Pricing not set");

        price = pricing.getPrice(_user);
    }

    function renewalPrice(uint256 _idNFT, address _user) external view returns (IMuchoPricing.Price memory price) {
        IMuchoNFT mNFT = nftList[_idNFT];
        require(address(mNFT) != address(0), "MuchoNFTFetcher - Id does not exist");

        IMuchoPricing pricing = nftRenewalPricing[_idNFT];
        require(address(pricing) != address(0), "MuchoNFTFetcher - Pricing not set");

        price = pricing.getPrice(_user);
    }

    /*-------------------OWNER EXTERNAL-------------------------*/

    function addNFT(IMuchoNFT _nft) external onlyOwnerOrAuthorized {
        nftList[nextNFT++] = _nft;
    }

    function removeNFT(uint256 _idNft) external onlyOwnerOrAuthorized {
        nftList[_idNft] = IMuchoNFT(address(0));
    }

    function deployNFT(string calldata _nftName, string calldata _nftSymbol, string calldata _planName, uint256 _planDuration) external onlyOwnerOrAuthorized {
        MuchoNFT mNFT = new MuchoNFT(_nftName, _nftSymbol);
        mNFT.addAuthorized(msg.sender);
        mNFT.setPlanName(_planName);
        mNFT.setDuration(_planDuration);
        nftList[nextNFT++] = mNFT;
    }

    function withdraw(address _token, uint256 _amount) external onlyOwnerOrAuthorized {
        IERC20 token = IERC20(_token);
        token.safeTransfer(msg.sender, _amount);
    }

    /*-------------------EXTERNAL-------------------------*/

    function subscribe(uint256 _idNFT, string calldata _metadata, uint256 _customAmount) external {
        IMuchoNFT mNFT = nftList[_idNFT];
        require(address(mNFT) != address(0), "MuchoNFTFetcher - Id does not exist");
        require(mNFT.balanceOf(msg.sender) == 0, "MuchoNFTFetcher - User already has NFT");
        IMuchoPricing pricing = nftPricing[_idNFT];
        require(address(pricing) != address(0), "MuchoNFTFetcher - Pricing not set");

        //Charge subscription fee
        IMuchoPricing.Price memory price = pricing.getPrice(msg.sender);
        if (_customAmount > 0) {
            require(pricing.isCustomPrice(), "MuchoNFTFetcher - Not a custom price NFT");
            price.amount = _customAmount;
        }
        require(price.amount > 0, "MuchoNFTFetcher - Price not set");
        _chargeFee(msg.sender, price);

        //Subscribe and mint NFT
        mNFT.subscribeTo(msg.sender, _metadata);
    }

    function renew(uint256 _idNFT) external {
        IMuchoNFT mNFT = nftList[_idNFT];
        require(address(mNFT) != address(0), "MuchoNFTFetcher - Id does not exist");
        require(mNFT.balanceOf(msg.sender) == 1, "MuchoNFTFetcher - address with 0 or more than 1 NFT");

        IMuchoPricing pricing = nftRenewalPricing[_idNFT];
        require(address(pricing) != address(0), "MuchoNFTFetcher - Renewal pricing not set");
        IMuchoPricing.Price memory price = pricing.getPrice(msg.sender);
        require(price.amount > 0, "MuchoNFTFetcher - Renewal price not set");

        //Retrieve current tokenID
        uint256 tokenId = mNFT.tokenOfOwnerByIndex(msg.sender, 0);

        //Charge renewal fee
        _chargeFee(msg.sender, price);

        //Subscribe and mint NFT
        mNFT.renewTo(tokenId);
    }

    function subscribeWithPermit(address _subscriber, uint256 _idNFT, string calldata _metadata, uint256 _customAmount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external {
        IMuchoNFT mNFT = nftList[_idNFT];
        require(address(mNFT) != address(0), "MuchoNFTFetcher - Id does not exist");
        require(mNFT.balanceOf(_subscriber) == 0, "MuchoNFTFetcher - User already has NFT");
        IMuchoPricing pricing = nftPricing[_idNFT];
        require(address(pricing) != address(0), "MuchoNFTFetcher - Pricing not set");

        //Charge subscription fee
        IMuchoPricing.Price memory price = pricing.getPrice(_subscriber);
        if (_customAmount > 0) {
            require(pricing.isCustomPrice(), "MuchoNFTFetcher - Not a custom price NFT");
            price.amount = _customAmount;
        }
        require(price.amount > 0, "MuchoNFTFetcher - Price not set");

        // Use EIP-2612 permit to approve the contract to spend tokens
        IERC20Permit(address(price.token)).permit(_subscriber, address(this), price.amount, deadline, v, r, s);

        _chargeFee(_subscriber, price);

        //Subscribe and mint NFT
        mNFT.subscribeTo(_subscriber, _metadata);
    }

    function renewWithPermit(address _subscriber, uint256 _idNFT, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external {
        IMuchoNFT mNFT = nftList[_idNFT];
        require(address(mNFT) != address(0), "MuchoNFTFetcher - Id does not exist");
        require(mNFT.balanceOf(_subscriber) == 1, "MuchoNFTFetcher - address with 0 or more than 1 NFT");

        IMuchoPricing pricing = nftRenewalPricing[_idNFT];
        require(address(pricing) != address(0), "MuchoNFTFetcher - Renewal pricing not set");
        IMuchoPricing.Price memory price = pricing.getPrice(_subscriber);
        require(price.amount > 0, "MuchoNFTFetcher - Renewal price not set");

        //Retrieve current tokenID
        uint256 tokenId = mNFT.tokenOfOwnerByIndex(_subscriber, 0);

        // Use EIP-2612 permit to approve the contract to spend tokens
        IERC20Permit(address(price.token)).permit(_subscriber, address(this), price.amount, deadline, v, r, s);

        //Charge renewal fee
        _chargeFee(_subscriber, price);

        //Subscribe and mint NFT
        mNFT.renewTo(tokenId);
    }

    /*-------------------INTERNAL-------------------------*/

    function _chargeFee(address _subscriber, IMuchoPricing.Price memory _price) internal {
        IERC20 token = IERC20(_price.token);
        require(token.balanceOf(_subscriber) >= _price.amount, "Not enough balance to pay fee");
        require(token.allowance(_subscriber, address(this)) >= _price.amount, "Not enough allowance to pay fee");
        token.safeTransferFrom(_subscriber, address(this), _price.amount);
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./AccessControl.sol";
import "../interfaces/IMuchoNFT.sol";
import "../interfaces/IMuchoNFTFetcher.sol";
import "../interfaces/IMuchoPricing.sol";
import "./MuchoNFT.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

contract MuchoNFTReader is AccessControl {
    using SafeERC20 for IERC20;
    using EnumerableSet for EnumerableSet.AddressSet;

    /*-------------------TYPES-----------------------*/
    struct MuchoNFTDetailed {
        uint256 fetcherNftId;
        IMuchoNFT nft;
        IMuchoPricing subPricing;
        IMuchoPricing renPricing;
        IMuchoNFT.PlanAttributes planAttributes;
        uint256 totalSupply;
        uint256 userBalance;
        uint256 tokenId;
        IMuchoNFT.TokenAttributes tokenIdAttributes;
        DetailedNFTPricingAttributes subscriptionPricingAttributes;
        DetailedNFTPricingAttributes renewalPricingAttributes;
        IMuchoPricing.Price subscriptionPrice;
        IMuchoPricing.Price subscriptionPublicPrice;
        IMuchoPricing.Price renewalPrice;
        IMuchoPricing.Price renewalPublicPrice;
    }

    struct DetailedNFTPricingAttributes {
        uint256 dateIni;
        uint256 dateEnd;
        address token;
    }

    /*-------------------ATTRIBUTES-------------------------*/
    IMuchoNFTFetcher fetcher = IMuchoNFTFetcher(0xBA3EacD2afADD1C38b940A461c48540c77a121d3);

    /*-------------------SETTERS-------------------------*/
    function setFetcher(IMuchoNFTFetcher _newFetcher) external onlyOwnerOrAuthorized {
        fetcher = _newFetcher;
    }

    /*-------------------VIEWS-------------------------*/
    function detailedNftsById(uint256[] calldata _ids, address _user) external view returns (MuchoNFTDetailed[] memory detailedNfts) {
        detailedNfts = new MuchoNFTDetailed[](_ids.length);
        for (uint256 i = 0; i < _ids.length; i++) {
            detailedNfts[i] = detailedNftById(_ids[i], _user);
        }
    }

    function detailedNftById(uint256 _id, address _user) public view returns (MuchoNFTDetailed memory detailedNft) {
        detailedNft.fetcherNftId = _id;
        detailedNft.nft = IMuchoNFT(fetcher.nftById(_id));
        detailedNft.subPricing = fetcher.nftPricing(_id);
        detailedNft.renPricing = fetcher.nftRenewalPricing(_id);
        detailedNft.planAttributes = detailedNft.nft.planAttributes();
        detailedNft.totalSupply = detailedNft.nft.totalSupply();
        if (_user != address(0)) {
            detailedNft.userBalance = detailedNft.nft.activeBalanceOf(_user);
            if (detailedNft.userBalance > 0 || detailedNft.nft.balanceOf(_user) > 0) {
                detailedNft.tokenId = detailedNft.nft.tokenOfOwnerByIndex(_user, 0);
            }
        }

        if (detailedNft.tokenId > 0) {
            detailedNft.tokenIdAttributes = detailedNft.nft.tokenIdAttributes(detailedNft.tokenId);
        }

        //Pricing attributes
        if (address(detailedNft.subPricing) != address(0)) {
            detailedNft.subscriptionPricingAttributes = detailedNftPricingAttributes(detailedNft.subPricing);
            if (detailedNft.subscriptionPricingAttributes.dateIni < block.timestamp && detailedNft.subscriptionPricingAttributes.dateEnd > block.timestamp) {
                detailedNft.subscriptionPrice = fetcher.subscriptionPrice(_id, _user);
                if (_user == address(0)) {
                    detailedNft.subscriptionPublicPrice = detailedNft.subscriptionPrice;
                } else {
                    detailedNft.subscriptionPublicPrice = fetcher.subscriptionPrice(_id, address(0));
                }
            }
        }

        if (address(detailedNft.renPricing) != address(0)) {
            detailedNft.renewalPricingAttributes = detailedNftPricingAttributes(detailedNft.renPricing);
            if (detailedNft.renewalPricingAttributes.dateIni < block.timestamp && detailedNft.renewalPricingAttributes.dateEnd > block.timestamp) {
                detailedNft.renewalPrice = fetcher.renewalPrice(_id, _user);
                if (_user == address(0)) {
                    detailedNft.renewalPublicPrice = detailedNft.renewalPrice;
                } else {
                    detailedNft.renewalPublicPrice = fetcher.renewalPrice(_id, address(0));
                }
            }
        }
    }

    function detailedNftPricingAttributes(IMuchoPricing _pricing) public view returns (DetailedNFTPricingAttributes memory res) {
        res.dateIni = _pricing.dateIni();
        res.dateEnd = _pricing.dateEnd();
        res.token = _pricing.token();
    }

    function subscribersByPlanId(uint256 _id) public view returns (IMuchoNFT.TokenAttributes[] memory attributes, address[] memory addresses) {
        IMuchoNFT nftPlan = fetcher.nftById(_id);
        return subscribersByNFT(address(nftPlan));
    }

    function subscribersByNFT(address nftAddress) public view returns (IMuchoNFT.TokenAttributes[] memory attributes, address[] memory addresses) {
        IMuchoNFT nftPlan = IMuchoNFT(nftAddress);
        uint256 supply = nftPlan.totalSupply();
        attributes = new IMuchoNFT.TokenAttributes[](supply);
        addresses = new address[](supply);
        for (uint256 i = 0; i < supply; i++) {
            uint256 tokenId = nftPlan.tokenByIndex(i);
            attributes[i] = nftPlan.tokenIdAttributes(tokenId);
            addresses[i] = nftPlan.ownerOf(tokenId);
        }
    }
}

// SPDX-License-Identifier: MIT
// MuchoNFT contract

/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/utils/Base64.sol";
import "./AccessControl.sol";
import "./lib/LibString.sol";

contract MuchoNFTUriGenerator is AccessControl {
    using LibString for string;

    //Variables
    string[] public chunks;
    uint256[] public gaps;

    //Setters
    function setChunks(string[] memory _uriChunks) external onlyOwner {
        chunks = _uriChunks;
    }

    function addChunk(string memory _uriChunk) external onlyOwner {
        chunks.push(_uriChunk);
    }

    function setGaps(uint256[] memory _gaps) external onlyOwner {
        gaps = _gaps;
    }

    function getChunks() external view returns (string[] memory) {
        return chunks;
    }

    //Views
    function getUri(string memory _name, string[] memory _replacements) external view returns (string memory uri) {
        require(_replacements.length <= chunks.length, "More replacements than chunks");
        require(_replacements.length == gaps.length, "Replacements should be same lenght than gaps");
        bytes memory output;

        uint16 iGap = 0;
        for (uint16 i = 0; i < chunks.length; i++) {
            output = abi.encodePacked(output, chunks[i]);
            if (iGap < gaps.length && i == gaps[iGap]) {
                output = abi.encodePacked(output, _replacements[iGap]);
                iGap++;
            }
        }

        bytes memory json = abi.encodePacked('{"name": "', _name, '", "image": "data:image/svg+xml;base64,', Base64.encode(output), '"}');

        uri = string(abi.encodePacked("data:application/json;base64,", Base64.encode(json)));
    }
}

/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "./AccessControl.sol";
import "../interfaces/IMuchoPricing.sol";
import "../interfaces/IMuchoNFT.sol";

contract MuchoPricing is AccessControl, IMuchoPricing {
    //Types
    enum DiscountType {
        FIXED,
        PERCENTAGE
    }

    struct Discount {
        DiscountType discountType;
        uint256 discountAmount;
    }

    //Attributes
    uint256 public dateIni;
    uint256 public dateEnd;
    uint256 public dateRampIni;
    uint256 public dateRampEnd;
    uint256 public priceRampIni;
    uint256 public priceRampEnd;
    address public token;
    bool public isCustomPrice;

    uint256 public dateDiscountPriceEnd;
    mapping(uint256 => mapping(address => Discount)) public userDiscount;
    uint256 public userDiscountPointer = 0;

    //Discount ramp, by having nft
    IMuchoNFT public muchoNFTDiscount = IMuchoNFT(0x04cC55EE08f749bEBc68E8FccAB0f697E36D559b);
    uint256 public dateNFTDiscountIni = 1726178461; //13-09 00:01:01
    uint256 public dateNFTDiscountEnd = 1726869599; //20-09 23:59:59
    uint256 public dateNFTDiscountRampIni = 1726444860; //16-09 00:01:00
    uint256 public dateNFTDiscountRampEnd = 1726869599; //20-09 23:59:59
    uint256 public nftDiscountRampIni = 500000000;
    uint256 public nftDiscountRampEnd = 0;
    mapping(uint256 => bool) public nftTokenIdDiscountUsed;

    //Setters
    function setDateIni(uint256 date) external onlyOwnerOrAuthorized {
        dateIni = date;
    }

    function setDateEnd(uint256 date) external onlyOwnerOrAuthorized {
        dateEnd = date;
    }

    function setDateRampIni(uint256 date) external onlyOwnerOrAuthorized {
        dateRampIni = date;
    }

    function setDateRampEnd(uint256 date) external onlyOwnerOrAuthorized {
        dateRampEnd = date;
    }

    function setPriceRampIni(uint256 price) external onlyOwnerOrAuthorized {
        priceRampIni = price;
    }

    function setPriceRampEnd(uint256 price) external onlyOwnerOrAuthorized {
        priceRampEnd = price;
    }

    function setToken(address newToken) external onlyOwnerOrAuthorized {
        require(newToken != address(0), "MuchoPricing invalid token");
        token = newToken;
    }

    function setDateDiscountPriceEnd(uint256 date) external onlyOwnerOrAuthorized {
        dateDiscountPriceEnd = date;
    }

    function setUserDiscount(address user, Discount calldata discount) external onlyOwnerOrAuthorized {
        require(discount.discountType != DiscountType.PERCENTAGE || discount.discountAmount <= 10000, "Discount out of range");
        userDiscount[userDiscountPointer][user] = discount;
    }

    function setUserDiscountPointer(uint256 newPointer) external onlyOwnerOrAuthorized {
        userDiscountPointer = newPointer;
    }

    function increaseUserDiscountPointer() external onlyOwnerOrAuthorized {
        userDiscountPointer++;
    }

    function setMuchoNFTDiscount(IMuchoNFT newNFT) external onlyOwnerOrAuthorized {
        muchoNFTDiscount = newNFT;
    }

    function setDateNFTDiscountIni(uint256 newDate) external onlyOwnerOrAuthorized {
        dateNFTDiscountIni = newDate;
    }

    function setDateNFTDiscountEnd(uint256 newDate) external onlyOwnerOrAuthorized {
        dateNFTDiscountEnd = newDate;
    }

    function setDateNFTDiscountRampIni(uint256 newDate) external onlyOwnerOrAuthorized {
        dateNFTDiscountRampIni = newDate;
    }

    function setDateNFTDiscountRampEnd(uint256 newDate) external onlyOwnerOrAuthorized {
        dateNFTDiscountRampEnd = newDate;
    }

    function setNftDiscountRampIni(uint256 newDiscount) external onlyOwnerOrAuthorized {
        nftDiscountRampIni = newDiscount;
    }

    function setNftDiscountRampEnd(uint256 newDiscount) external onlyOwnerOrAuthorized {
        nftDiscountRampEnd = newDiscount;
    }

    function setNftTokenIdDiscountUsed(uint256 tokenId, bool isUsed) external onlyOwnerOrAuthorized {
        nftTokenIdDiscountUsed[tokenId] = isUsed;
    }

    function setIsCustomPrice(bool customPrice) external onlyOwnerOrAuthorized {
        isCustomPrice = customPrice;
    }

    //Views
    function getUserDiscount(address user) public view returns (Discount memory userFinalDiscount) {
        userFinalDiscount = userDiscount[userDiscountPointer][user];
    }

    function getPrice(address user) external view returns (Price memory price) {
        require(block.timestamp >= dateIni, "MuchoPrice not started");
        require(block.timestamp <= dateEnd, "MuchoPrice ended");
        price.amount = _getCurrentPrice(user);
        price.token = token;
    }

    //Internal
    function _getCurrentPrice(address user) internal view returns (uint256 price) {
        price = _getRampedPrice();
        uint256 nftDiscount = _getRampedNFTDiscount(user);
        require(nftDiscount < price, "NFT discount is higher than price");
        price -= nftDiscount;

        Discount memory disc = getUserDiscount(user);
        if (disc.discountType == DiscountType.PERCENTAGE) {
            price = (price * (10000 - disc.discountAmount)) / 10000;
        } else if (disc.discountType == DiscountType.FIXED) {
            if (disc.discountAmount < price) {
                price -= disc.discountAmount;
            } else {
                price = 0;
            }
        } else {
            revert("MuchoPricing: Unknown discount type");
        }
    }

    function _getRampedPrice() internal view returns (uint256 price) {
        price = priceRampIni;
        if (block.timestamp > dateRampEnd) {
            price = priceRampEnd;
        } else if (block.timestamp > dateRampIni && block.timestamp <= dateRampEnd) {
            uint256 timeElapsed = block.timestamp - dateRampIni;
            uint256 timeRamp = dateRampEnd - dateRampIni;

            if (priceRampEnd > price) {
                price += ((priceRampEnd - price) * timeElapsed) / timeRamp;
            } else if (priceRampEnd < price) {
                price -= ((price - priceRampEnd) * timeElapsed) / timeRamp;
            }
        }
    }

    function _getRampedNFTDiscount(address user) internal view returns (uint256 discount) {
        //NFT discount is set and we are in valid dates for the discount:
        if (user != address(0) && address(muchoNFTDiscount) != address(0) && block.timestamp > dateNFTDiscountIni && block.timestamp <= dateNFTDiscountEnd) {
            //User has that active NFT:
            if (muchoNFTDiscount.activeBalanceOf(user) > 0) {
                //That tokenId has not been used:
                uint256 tokenId = muchoNFTDiscount.tokenOfOwnerByIndex(user, 0);
                if (!nftTokenIdDiscountUsed[tokenId]) {
                    //Price is before ramping:
                    if (block.timestamp < dateNFTDiscountRampIni) {
                        discount = nftDiscountRampIni;
                    }
                    //Price ramp is over:
                    else if (block.timestamp > dateNFTDiscountRampEnd) {
                        discount = nftDiscountRampEnd;
                    }
                    //In the middle of the ramp:
                    else {
                        uint256 timeElapsed = block.timestamp - dateNFTDiscountRampIni;
                        uint256 timeRamp = dateNFTDiscountRampEnd - dateNFTDiscountRampIni;

                        if (nftDiscountRampEnd < nftDiscountRampIni) {
                            discount = nftDiscountRampIni - ((nftDiscountRampIni - nftDiscountRampEnd) * timeElapsed) / timeRamp;
                        } else {
                            discount = nftDiscountRampIni + ((nftDiscountRampEnd - nftDiscountRampIni) * timeElapsed) / timeRamp;
                        }
                    }
                }
            }
        }
    }
}

/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "./AccessControl.sol";
import "../interfaces/IMuchoPricing.sol";
import "../interfaces/IMuchoNFT.sol";
import "../interfaces/IMuchoNFTFetcher.sol";

contract MuchoPricingRate is AccessControl, IMuchoPricing {
    //Types
    enum DiscountType {
        FIXED,
        PERCENTAGE
    }

    struct Discount {
        DiscountType discountType;
        uint256 discountAmount;
    }

    //Attributes
    uint256 public dateIni;
    uint256 public dateEnd;
    uint256 public dateRampIni;
    uint256 public dateRampEnd;
    uint256 public priceIni;
    uint256 public ratePerHour;
    address public token;
    bool public isCustomPrice = false;

    mapping(uint256 => mapping(address => Discount)) public userDiscount;
    uint256 public userDiscountPointer = 0;

    //Discount ramp, by having nft
    IMuchoNFTFetcher public muchoNFTFetcher = IMuchoNFTFetcher(0xBA3EacD2afADD1C38b940A461c48540c77a121d3);
    mapping(uint256 => uint256) public nftDiscounts;
    mapping(uint256 => bool) public nftTokenIdDiscountUsed;

    //Setters
    function setIsCustomPrice(bool customPrice) external onlyOwnerOrAuthorized {
        isCustomPrice = customPrice;
    }

    function setDateIni(uint256 date) external onlyOwnerOrAuthorized {
        dateIni = date;
    }

    function setDateEnd(uint256 date) external onlyOwnerOrAuthorized {
        dateEnd = date;
    }

    function setDateRampIni(uint256 date) external onlyOwnerOrAuthorized {
        dateRampIni = date;
    }

    function setDateRampEnd(uint256 date) external onlyOwnerOrAuthorized {
        dateRampEnd = date;
    }

    function setPriceIni(uint256 price) external onlyOwnerOrAuthorized {
        priceIni = price;
    }

    function setRatePerHour(uint256 rate) external onlyOwnerOrAuthorized {
        ratePerHour = rate;
    }

    function setToken(address newToken) external onlyOwnerOrAuthorized {
        require(newToken != address(0), "MuchoPricing invalid token");
        token = newToken;
    }

    function setUserDiscount(address user, Discount calldata discount) external onlyOwnerOrAuthorized {
        require(discount.discountType != DiscountType.PERCENTAGE || discount.discountAmount <= 10000, "Discount out of range");
        userDiscount[userDiscountPointer][user] = discount;
    }

    function setUserDiscountPointer(uint256 newPointer) external onlyOwnerOrAuthorized {
        userDiscountPointer = newPointer;
    }

    function increaseUserDiscountPointer() external onlyOwnerOrAuthorized {
        userDiscountPointer++;
    }

    function setMuchoNFTDiscount(uint256 nftId, uint256 discount) external onlyOwnerOrAuthorized {
        nftDiscounts[nftId] = discount;
    }

    function setNftTokenIdDiscountUsed(uint256 tokenId, bool isUsed) external onlyOwnerOrAuthorized {
        nftTokenIdDiscountUsed[tokenId] = isUsed;
    }

    //Views
    function priceRampIni() external view returns (uint256) {
        return priceIni;
    }

    function priceRampEnd() external view returns (uint256) {
        return priceIni;
    }

    function getUserDiscount(address user) public view returns (Discount memory userFinalDiscount) {
        userFinalDiscount = userDiscount[userDiscountPointer][user];
    }

    function getPrice(address user) external view returns (Price memory price) {
        require(block.timestamp >= dateIni, "MuchoPrice not started");
        require(block.timestamp <= dateEnd, "MuchoPrice ended");
        price.amount = _getCurrentPrice(user);
        price.token = token;
    }

    //Internal
    function _getCurrentPrice(address user) internal view returns (uint256 price) {
        price = _getRatePrice();
        uint256 nftDiscount = _getRampedNFTDiscount(user);
        require(nftDiscount < price, "NFT discount is higher than price");
        price -= nftDiscount;

        if (nftDiscount == 0) {
            Discount memory disc = getUserDiscount(user);
            if (disc.discountType == DiscountType.PERCENTAGE) {
                price = (price * (10000 - disc.discountAmount)) / 10000;
            } else if (disc.discountType == DiscountType.FIXED) {
                if (disc.discountAmount < price) {
                    price -= disc.discountAmount;
                } else {
                    price = 0;
                }
            } else {
                revert("MuchoPricing: Unknown discount type");
            }
        }
    }

    function _getRatePrice() internal view returns (uint256 price) {
        price = priceIni;
        if (block.timestamp > dateRampIni) {
            uint256 finalDate = (block.timestamp > dateRampEnd) ? dateRampEnd : block.timestamp;
            uint256 hoursElapsed = (finalDate - dateRampIni) / 3600;
            price += hoursElapsed * ratePerHour;
        }
    }

    function _getRampedNFTDiscount(address user) internal view returns (uint256 discount) {
        discount = 0;
        if (user != address(0)) {
            IMuchoNFTFetcher.PlanAttributesExtended[] memory plans = muchoNFTFetcher.activePlansForUser(user);
            for (uint256 i = 0; i < plans.length; i++) {
                uint256 disc = nftDiscounts[plans[i].id];
                if (disc > discount) {
                    discount = disc;
                }
            }
        }
    }
}

/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "./AccessControl.sol";
import "../interfaces/IMuchoPricing.sol";
import "../interfaces/IMuchoNFT.sol";

contract MuchoRenewalPricing is AccessControl, IMuchoPricing {
    //Attributes
    uint256 public ratePerDelayedDay = 10 * 1E6;
    address public token = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831;
    uint256 public basePrice = 1650 * 1E6;
    mapping(uint256 => mapping(uint256 => uint256)) public userSpecialPrice;
    uint256 public userSpecialPricePointer = 0;
    IMuchoNFT public nft = IMuchoNFT(0xF4820467171695F4d2760614C77503147A9CB1E8);

    //Setters
    function setRatePerDelayedDay(uint256 newRate) external onlyOwnerOrAuthorized {
        ratePerDelayedDay = newRate;
    }

    function setToken(address newToken) external onlyOwnerOrAuthorized {
        require(newToken != address(0), "MuchoPricing invalid token");
        token = newToken;
    }

    function setBasePrice(uint256 newPrice) external onlyOwnerOrAuthorized {
        basePrice = newPrice;
    }

    function setUserSpecialPrice(uint256 user, uint256 newPrice) external onlyOwnerOrAuthorized {
        userSpecialPrice[userSpecialPricePointer][user] = newPrice;
    }

    function setUserSpecialPrices(uint256[] memory users, uint256 newPrice) external onlyOwnerOrAuthorized {
        for (uint256 i = 0; i < users.length; i++) {
            userSpecialPrice[userSpecialPricePointer][users[i]] = newPrice;
        }
    }

    function setUserSpecialPricePointer(uint256 newPointer) external onlyOwnerOrAuthorized {
        userSpecialPricePointer = newPointer;
    }

    function increaseUserSpecialPricePointer() external onlyOwnerOrAuthorized {
        userSpecialPricePointer++;
    }

    function setNFT(address newNFT) external onlyOwnerOrAuthorized {
        require(newNFT != address(0), "MuchoPricing invalid NFT");
        nft = IMuchoNFT(newNFT);
    }

    //Views
    function isCustomPrice() external pure returns (bool) {
        return false;
    }

    function getUserBasePrice(address user) public view returns (uint256 userPrice) {
        uint256 userBalance = nft.balanceOf(user);
        require(userBalance == 1, "MuchoPricing user has different than 1 NFT");
        uint256 tokenId = nft.tokenOfOwnerByIndex(user, 0);
        userPrice = userSpecialPrice[userSpecialPricePointer][tokenId] > 0 ? userSpecialPrice[userSpecialPricePointer][tokenId] : basePrice;
    }

    function getPrice(address user) external view returns (Price memory price) {
        price.amount = _getCurrentPrice(user);
        price.token = token;
    }

    function dateIni() external pure returns (uint256) {
        return 0;
    }

    function dateEnd() external view returns (uint256) {
        return block.timestamp + 86400 * 365;
    }

    function dateRampIni() external pure returns (uint256) {
        return 0;
    }

    function dateRampEnd() external pure returns (uint256) {
        return 0;
    }

    function priceRampIni() external pure returns (uint256) {
        return 0;
    }

    function priceRampEnd() external pure returns (uint256) {
        return 0;
    }

    //Internal
    function _getCurrentPrice(address user) internal view returns (uint256 price) {
        //Renewal price for address 0x0 is the base price
        if (user == address(0)) {
            return basePrice;
        }
        price = getUserBasePrice(user);
        uint256 tokenId = nft.tokenOfOwnerByIndex(user, 0);
        uint256 expirationTime = nft.tokenIdAttributes(tokenId).expirationTime;
        if (block.timestamp > expirationTime) {
            uint256 daysDelayed = (block.timestamp - expirationTime) / 86400;
            price += daysDelayed * ratePerDelayedDay;
        }
    }
}

File 43 of 49 : IMuchoBadgeManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

interface IMuchoBadgeManager {
    struct Price {
        address token;
        uint256 amount;
    }

    struct Plan {
        uint256 id;
        string name;
        string uri;
        uint256 subscribers;
        Price subscriptionPrice;
        Price renewalPrice;
        uint time;
        bool exists;
        bool enabled;
        uint256 activeSubscribers;
    }

    function activePlansForUser(address _user) external view returns (Plan[] memory);

    function addAuthorized(address _authorized) external;

    function addPlan(string memory _name, string memory _uri, uint256 _time, Price memory _subscriptionPrice, Price memory _renewalPrice, bool _enabled) external returns (uint256);

    function allPlans() external view returns (Plan[] memory);

    function balance() external view returns (uint256);

    function balanceOf(address account, uint256 id) external view returns (uint256);

    function balanceOfBatch(address[] memory accounts, uint256[] memory ids) external view returns (uint256[] memory);

    function cancelSubscription(uint256 _planId, address _subscriber) external;

    function disablePlan(uint256 _planId) external;

    function enablePlan(uint256 _planId) external;

    function enabledPlans() external view returns (Plan[] memory);

    function expiredPlansForUser(address _user) external view returns (Plan[] memory);

    function forceExpiration(uint256 _planId, address _subscriber) external;

    function isApprovedForAll(address account, address operator) external view returns (bool);

    function isAuthorized(address _user) external view returns (bool);

    function isSubscribedAndActive(address _user, uint256 _planId) external view returns (bool);

    function isSubscribedAndExpired(address _user, uint256 _planId) external view returns (bool);

    function owner() external view returns (address);

    function plan(uint256 _planId) external view returns (Plan memory);

    function removeAuthorized(address _authorized) external;

    function renew(uint256 _planId) external;

    function renew(uint256 _planId, address _subscriber) external;

    function renewalPrice(uint256 _planId) external view returns (Price memory);

    function renounceOwnership() external;

    function safeBatchTransferFrom(address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) external;

    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) external;

    function setApprovalForAll(address operator, bool approved) external;

    function setURI(string memory _uri) external;

    function subscribe(uint256 _planId) external;

    function subscribe(uint256 _planId, address _subscriber) external;

    function subscriptionExpiration(address _user, uint256 _planId) external view returns (uint256);

    function subscriptionPrice(uint256 _planId) external view returns (Price memory);

    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    function tokenSupply(uint256 _planId) external view returns (uint256);

    function tokenURI(uint256 _planId) external view returns (string memory);

    function totalPlans() external view returns (uint256);

    function totalSupply() external view returns (uint256);

    function transferOwnership(address newOwner) external;

    function updateAllActiveSubscribers() external;

    function updatePlan(uint256 _planId, string memory _name, string memory _uri, uint256 _time, Price memory _subscriptionPrice, Price memory _renewalPrice, bool _enabled) external;

    function updatePlanDuration(uint256 _planId, uint256 _time) external;

    function uri(uint256) external view returns (string memory);

    function withdraw(address _token, uint256 _amount) external;
}

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

interface IMuchoBadgeNFTBridge {
    struct Price {
        address token;
        uint256 amount;
    }

    struct Plan {
        uint256 id;
        string name;
        string uri;
        uint256 subscribers;
        Price subscriptionPrice;
        Price renewalPrice;
        uint time;
        bool exists;
        bool enabled;
        uint256 activeSubscribers;
    }

    function activePlansForUser(address _user) external view returns (Plan[] memory);
}

// SPDX-License-Identifier: MIT
/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */

pragma solidity ^0.8.7;

import "./IMuchoUriGenerator.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "../interfaces/IMuchoPricing.sol";

interface IMuchoNFT is IERC721Enumerable {
    /*--------Types-----------*/
    struct TokenAttributes {
        uint256 tokenId;
        uint256 startTime;
        uint256 expirationTime;
        string metaData;
    }
    struct PlanAttributes {
        address nftAddress;
        string planName;
        uint duration;
        bool enabled;
    }

    /*--------Attributes-----------*/
    function planAttributes() external view returns (PlanAttributes memory);

    function uriGenerator() external view returns (IMuchoUriGenerator);

    /*--------Data-----------*/
    function lastTokenId() external view returns (uint256);

    function tokenIdAttributes(uint256 i) external view returns (TokenAttributes memory);

    /*-------------------EXTERNAL - OWNER-------------------------*/
    function subscribeTo(address _subscriber, string calldata _metadata) external;

    function cancelSubscriptionTo(uint256 _tokenId) external;

    function renewTo(uint256 _tokenId) external;

    function changeExpiration(uint256 _tokenId, uint256 _date) external;

    function withdraw(address _token, uint256 _amount) external;

    /*-------------------VIEWS-------------------------*/

    function tokenURI(uint256 tokenId) external view returns (string memory);

    function activeToken(uint256 tokenId) external view returns (bool);

    function activeBalanceOf(address user) external view returns (uint256);
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

import "../interfaces/IMuchoNFT.sol";

interface IMuchoNFTFetcher {
    struct PlanAttributesExtended {
        uint256 id;
        address nftAddress;
        string planName;
        uint duration;
        bool enabled;
    }

    function activePlansForUser(address _user) external view returns (PlanAttributesExtended[] memory plans);

    function nftById(uint256 _id) external view returns (IMuchoNFT);

    function nftPricing(uint256 _id) external view returns (IMuchoPricing);

    function nftRenewalPricing(uint256 _id) external view returns (IMuchoPricing);

    function subscriptionPrice(uint256 _idNFT, address _user) external view returns (IMuchoPricing.Price memory);

    function renewalPrice(uint256 _idNFT, address _user) external view returns (IMuchoPricing.Price memory);
}

// SPDX-License-Identifier: MIT
/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */

pragma solidity ^0.8.7;

interface IMuchoPricing {
    struct Price {
        address token;
        uint256 amount;
    }

    function getPrice(address user) external view returns (Price memory price);

    function dateIni() external view returns (uint256);

    function dateEnd() external view returns (uint256);

    function dateRampIni() external view returns (uint256);

    function dateRampEnd() external view returns (uint256);

    function priceRampIni() external view returns (uint256);

    function priceRampEnd() external view returns (uint256);

    function token() external view returns (address);

    function isCustomPrice() external view returns (bool);
}

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

interface IMuchoRewardRouter {
    function CONTRACT_OWNER() external view returns (bytes32);

    function DEFAULT_ADMIN_ROLE() external view returns (bytes32);

    function TRADER() external view returns (bytes32);

    function addPlanId(uint256 _planId, uint256 _multiplier) external;

    function addUserIfNotExists(address _user) external;

    function badgeManager() external view returns (address);

    function depositRewards(address _token, uint256 _amount) external;

    function earningsAddress() external view returns (address);

    function getPlanPonderation(uint256 _planId) external view returns (uint256);

    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    function getTotalPonderatedInvestment() external view returns (uint256);

    function getUserMultiplierAndPlan(address _user) external view returns (uint256, uint256);

    function grantRole(bytes32 role, address account) external;

    function hasRole(bytes32 role, address account) external view returns (bool);

    function muchoVault() external view returns (address);

    function planMultiplier(uint256) external view returns (uint256);

    function removePlanId(uint256 _planId) external;

    function removeUserIfExists(address _user) external;

    function renounceRole(bytes32 role, address account) external;

    function revokeRole(bytes32 role, address account) external;

    function rewards(address, address) external view returns (uint256);

    function setBadgeManager(address _bm) external;

    function setEarningsAddress(address _ea) external;

    function setMuchoVault(address _mv) external;

    function setMultiplier(uint256 _planId, uint256 _multiplier) external;

    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    function withdraw() external;

    function withdrawToken(address _token) external returns (uint256);
}

// SPDX-License-Identifier: MIT
// MuchoNFT contract

/*                               %@@@@@@@@@@@@@@@@@(                              
                        ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        
                    /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.                   
                 &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                
              ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
            *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
         &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&       
       @@@@@@@@@@@@@   #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@      
      &@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.   @@@@@@@@@@,     
      @@@@@@@@@@&   .@@@@@@@@@@@@@@@@@&@@@@@@@@@&&@@@@@@@@@@@#   /@@@@@@@@@     
     &@@@@@@@@@@    @@@@@&                 %          @@@@@@@@,   #@@@@@@@@,    
     @@@@@@@@@@    @@@@@@@@%       &&        *@,       @@@@@@@@    @@@@@@@@%    
     @@@@@@@@@@    @@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@&    
     @@@@@@@@@@    &@@@@@@@%      @@@@      /@@@.      @@@@@@@@    @@@@@@@@/    
     .@@@@@@@@@@    @@@@@@@%      @@@@      /@@@.      @@@@@@@    &@@@@@@@@     
      @@@@@@@@@@@    @@@@&         @@        .@          @@@@.   @@@@@@@@@&     
       @@@@@@@@@@@.   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@      
        @@@@@@@@@@@@.  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@       
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#         
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@             
                &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/               
                   &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(                  
                       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#                      
                            /@@@@@@@@@@@@@@@@@@@@@@@*  */

pragma solidity ^0.8.7;

interface IMuchoUriGenerator {
    function getUri(string memory _name, string[] memory _replacements) external view returns (string memory);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"ERC721EnumerableForbiddenBatchMint","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"ERC721OutOfBoundsIndex","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_authorized","type":"address"}],"name":"Authorized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"subscriber","type":"address"}],"name":"Subscribed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"subscriber","type":"address"}],"name":"SubscriptionCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"subscriber","type":"address"},{"indexed":false,"internalType":"uint256","name":"expirationTime","type":"uint256"}],"name":"SubscriptionExpirationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_authorized","type":"address"}],"name":"UnAuthorized","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"activeBalanceOf","outputs":[{"internalType":"uint256","name":"bal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"activeToken","outputs":[{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_authorized","type":"address"}],"name":"addAuthorized","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"bulkCancelSubscriptionTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_dates","type":"uint256[]"}],"name":"bulkChangeExpiration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"bulkRenewTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_subscribers","type":"address[]"},{"internalType":"string[]","name":"_metadata","type":"string[]"}],"name":"bulkSubscribeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelSubscriptionTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_date","type":"uint256"}],"name":"changeExpiration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"string","name":"_metadata","type":"string"}],"name":"changeMetaData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"isAuthorized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"planAttributes","outputs":[{"components":[{"internalType":"address","name":"nftAddress","type":"address"},{"internalType":"string","name":"planName","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"}],"internalType":"struct IMuchoNFT.PlanAttributes","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_authorized","type":"address"}],"name":"removeAuthorized","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"renewTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"setDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_planName","type":"string"}],"name":"setPlanName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_uriGen","type":"address"}],"name":"setUriGenerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subscriber","type":"address"},{"internalType":"string","name":"_metadata","type":"string"}],"name":"subscribeTo","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":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenIdAttributes","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"string","name":"metaData","type":"string"}],"internalType":"struct IMuchoNFT.TokenAttributes","name":"attr","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uriGenerator","outputs":[{"internalType":"contract IMuchoUriGenerator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

0x60806040525f60115534801562000014575f80fd5b506040516200308a3803806200308a8339810160408190526200003791620001bf565b3382825f620000478382620002af565b506001620000568282620002af565b5050506001600160a01b0381166200008757604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6200009281620000ad565b5050600c80546001600160a01b03191630179055506200037b565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f83011262000122575f80fd5b81516001600160401b03808211156200013f576200013f620000fe565b604051601f8301601f19908116603f011681019082821181831017156200016a576200016a620000fe565b816040528381526020925086602085880101111562000187575f80fd5b5f91505b83821015620001aa57858201830151818301840152908201906200018b565b5f602085830101528094505050505092915050565b5f8060408385031215620001d1575f80fd5b82516001600160401b0380821115620001e8575f80fd5b620001f68683870162000112565b935060208501519150808211156200020c575f80fd5b506200021b8582860162000112565b9150509250929050565b600181811c908216806200023a57607f821691505b6020821081036200025957634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620002aa57805f5260205f20601f840160051c81016020851015620002865750805b601f840160051c820191505b81811015620002a7575f815560010162000292565b50505b505050565b81516001600160401b03811115620002cb57620002cb620000fe565b620002e381620002dc845462000225565b846200025f565b602080601f83116001811462000319575f8415620003015750858301515b5f19600386901b1c1916600185901b17855562000373565b5f85815260208120601f198616915b82811015620003495788860151825594840194600190910190840162000328565b50858210156200036757878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b612d0180620003895f395ff3fe608060405234801561000f575f80fd5b5060043610610260575f3560e01c806370a082311161014b578063e985e9c5116100bf578063f5b3e4a411610084578063f5b3e4a41461054a578063f6be71d11461055d578063f76c563b14610570578063f84ddf0b14610583578063fe9fbb801461058c578063feebd5bb146105b7575f80fd5b8063e985e9c5146104de578063e9ff82a7146104f1578063edf5a6a014610511578063f2fde38b14610524578063f3fef3a314610537575f80fd5b8063b88d4fde11610110578063b88d4fde1461046a578063c87b56dd1461047d578063cf1c316a14610490578063d164bef6146104a3578063dc26cf12146104b6578063e51dd5c3146104c9575f80fd5b806370a0823114610423578063715018a6146104365780638da5cb5b1461043e57806395d89b411461044f578063a22cb46514610457575f80fd5b8063328d8f72116101e2578063485d7d94116101a7578063485d7d94146103b15780634f6ccce7146103c45780634f6f96dc146103d757806359f769a9146103ea5780636352211e146103fd57806368af2c7114610410575f80fd5b8063328d8f72146103525780633d218a521461036557806342842e0e1461037857806342966c681461038b57806347cf4b231461039e575f80fd5b806318160ddd1161022857806318160ddd146102f45780631c722dbd1461030657806323b872dd14610319578063277e69de1461032c5780632f745c591461033f575f80fd5b806301ffc9a71461026457806306a93d241461028c57806306fdde031461029f578063081812fc146102b4578063095ea7b3146102df575b5f80fd5b6102776102723660046121ef565b6105ca565b60405190151581526020015b60405180910390f35b61027761029a36600461220a565b6105da565b6102a7610629565b604051610283919061226e565b6102c76102c236600461220a565b6106b8565b6040516001600160a01b039091168152602001610283565b6102f26102ed366004612296565b6106df565b005b6008545b604051908152602001610283565b6102f261031436600461237e565b6106ee565b6102f26103273660046123af565b61073d565b6102f261033a36600461237e565b6107cb565b6102f861034d366004612296565b61084d565b6102f26103603660046123f5565b6108b0565b6102f2610373366004612454565b6108cb565b6102f26103863660046123af565b610918565b6102f261039936600461220a565b610937565b6010546102c7906001600160a01b031681565b6102f26103bf36600461249b565b610942565b6102f86103d236600461220a565b6109a1565b6102f26103e53660046124b4565b6109f6565b6102f86103f836600461249b565b610a0b565b6102c761040b36600461220a565b610a5f565b6102f261041e3660046124f2565b610a69565b6102f861043136600461249b565b610b57565b6102f2610b9c565b600a546001600160a01b03166102c7565b6102a7610baf565b6102f2610465366004612551565b610bbe565b6102f26104783660046125ac565b610bc9565b6102a761048b36600461220a565b610be0565b6102f261049e36600461249b565b610dbe565b6102f26104b136600461249b565b610e19565b6102f26104c436600461220a565b610e43565b6104d1610ea3565b604051610283919061264f565b6102776104ec36600461269e565b610fa2565b6105046104ff36600461220a565b610fcf565b60405161028391906126cf565b6102f261051f366004612747565b6110c7565b6102f261053236600461249b565b6111ef565b6102f2610545366004612296565b61122c565b6102f261055836600461220a565b611249565b6102f261056b36600461220a565b61127d565b6102f261057e3660046127ad565b61128a565b6102f860115481565b61027761059a36600461249b565b6001600160a01b03165f908152600b602052604090205460ff1690565b6102f26105c53660046127cd565b6112e1565b5f6105d482611379565b92915050565b5f60115482111580156105ef5750600f5460ff165b801561060a57505f8281526012602052604090206002015442105b80156105d45750505f9081526012602052604090206001015442101590565b60605f805461063790612802565b80601f016020809104026020016040519081016040528092919081815260200182805461066390612802565b80156106ae5780601f10610685576101008083540402835291602001916106ae565b820191905f5260205f20905b81548152906001019060200180831161069157829003601f168201915b5050505050905090565b5f6106c28261139d565b505f828152600460205260409020546001600160a01b03166105d4565b6106ea8282336113d5565b5050565b6106f66113e2565b5f5b81518161ffff1610156106ea5761072b828261ffff168151811061071e5761071e612834565b6020026020010151611478565b806107358161285c565b9150506106f8565b6001600160a01b03821661076b57604051633250574960e11b81525f60048201526024015b60405180910390fd5b5f6107778383336114dd565b9050836001600160a01b0316816001600160a01b0316146107c5576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610762565b50505050565b6107d36113e2565b600f5460ff166107f55760405162461bcd60e51b81526004016107629061287c565b5f5b81518161ffff1610156106ea5761083b828261ffff168151811061081d5761081d612834565b6020026020010151600c600201544261083691906128ac565b6114f3565b806108458161285c565b9150506107f7565b5f61085783610b57565b82106108885760405163295f44f760e21b81526001600160a01b038416600482015260248101839052604401610762565b506001600160a01b03919091165f908152600660209081526040808320938352929052205490565b6108b86113e2565b600f805460ff1916911515919091179055565b6108d36113e2565b826011548111156108f65760405162461bcd60e51b8152600401610762906128bf565b5f84815260126020526040902060030161091183858361293a565b5050505050565b61093283838360405180602001604052805f815250610bc9565b505050565b6106ea5f82336114dd565b61094a611562565b6001600160a01b0381165f818152600b6020908152604091829020805460ff1916905590519182527fb392249530409099dedf8a34dfe3498cfc2f81a2f80804432221e95cda37175491015b60405180910390a150565b5f6109ab60085490565b82106109d35760405163295f44f760e21b81525f600482015260248101839052604401610762565b600882815481106109e6576109e6612834565b905f5260205f2001549050919050565b6109fe6113e2565b600d61093282848361293a565b5f610a1582610b57565b90508015610a5a575f5b81811015610a58575f610a32848361084d565b9050610a3d816105da565b610a4f5782610a4b816129f3565b9350505b50600101610a1f565b505b919050565b5f6105d48261139d565b610a716113e2565b600f5460ff16610a935760405162461bcd60e51b81526004016107629061287c565b8051825114610af25760405162461bcd60e51b815260206004820152602560248201527f52657175697265642073616d6520616d6f756e74206f662049447320616e6420604482015264646174657360d81b6064820152608401610762565b5f5b82518161ffff16101561093257610b45838261ffff1681518110610b1a57610b1a612834565b6020026020010151838361ffff1681518110610b3857610b38612834565b60200260200101516114f3565b80610b4f8161285c565b915050610af4565b5f6001600160a01b038216610b81576040516322718ad960e21b81525f6004820152602401610762565b506001600160a01b03165f9081526003602052604090205490565b610ba4611562565b610bad5f61158f565b565b60606001805461063790612802565b6106ea3383836115e0565b610bd484848461073d565b6107c58484848461167e565b6060610beb8261139d565b50604080516003808252608082019092525f91816020015b6060815260200190600190039081610c035750505f8481526012602052604081206002015491925090421015610c61575f848152601260205260409020600201546201518090610c54904290612a08565b610c5e9190612a1b565b90505b610c6a8461179d565b825f81518110610c7c57610c7c612834565b6020026020010181905250610c908161179d565b82600181518110610ca357610ca3612834565b6020026020010181905250610cb7846105da565b15610cfe576040518060400160405280600681526020016541637469766560d01b81525082600281518110610cee57610cee612834565b6020026020010181905250610d3e565b60405180604001604052806008815260200167111a5cd8589b195960c21b81525082600281518110610d3257610d32612834565b60200260200101819052505b6010546001600160a01b03166383b104f9610d57610629565b846040518363ffffffff1660e01b8152600401610d75929190612a3a565b5f60405180830381865afa158015610d8f573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610db69190810190612aaa565b949350505050565b610dc6611562565b6001600160a01b0381165f818152600b6020908152604091829020805460ff1916600117905590519182527fdc84e3a4c83602050e3865df792a4e6800211a79ac60db94e703a820ce8929249101610996565b610e216113e2565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b610e4b6113e2565b80601154811115610e6e5760405162461bcd60e51b8152600401610762906128bf565b600f5460ff16610e905760405162461bcd60e51b81526004016107629061287c565b600e546106ea90839061083690426128ac565b610ed660405180608001604052805f6001600160a01b03168152602001606081526020015f81526020015f151581525090565b6040805160808101909152600c80546001600160a01b03168252600d8054602084019190610f0390612802565b80601f0160208091040260200160405190810160405280929190818152602001828054610f2f90612802565b8015610f7a5780601f10610f5157610100808354040283529160200191610f7a565b820191905f5260205f20905b815481529060010190602001808311610f5d57829003601f168201915b50505091835250506002820154602082015260039091015460ff161515604090910152919050565b6001600160a01b039182165f90815260056020908152604080832093909416825291909152205460ff1690565b610ff760405180608001604052805f81526020015f81526020015f8152602001606081525090565b60125f8381526020019081526020015f206040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201805461104090612802565b80601f016020809104026020016040519081016040528092919081815260200182805461106c90612802565b80156110b75780601f1061108e576101008083540402835291602001916110b7565b820191905f5260205f20905b81548152906001019060200180831161109a57829003601f168201915b5050505050815250509050919050565b600f5460ff166110e95760405162461bcd60e51b81526004016107629061287c565b6110f16113e2565b8281146111405760405162461bcd60e51b815260206004820152601a60248201527f4d7563686f4e46543a20646966666572656e74206c656e6774680000000000006044820152606401610762565b5f5b61ffff81168411156109115761117c85858361ffff1681811061116757611167612834565b9050602002016020810190610431919061249b565b5f036111dd576111dd85858361ffff1681811061119b5761119b612834565b90506020020160208101906111b0919061249b565b84848461ffff168181106111c6576111c6612834565b90506020028101906111d89190612b1b565b61182c565b806111e78161285c565b915050611142565b6111f7611562565b6001600160a01b03811661122057604051631e4fbdf760e01b81525f6004820152602401610762565b6112298161158f565b50565b6112346113e2565b816109326001600160a01b0382163384611935565b6112516113e2565b806011548111156112745760405162461bcd60e51b8152600401610762906128bf565b6106ea82611478565b6112856113e2565b600e55565b6112926113e2565b816011548111156112b55760405162461bcd60e51b8152600401610762906128bf565b600f5460ff166112d75760405162461bcd60e51b81526004016107629061287c565b61093283836114f3565b600f5460ff166113035760405162461bcd60e51b81526004016107629061287c565b61130b6113e2565b8261131581610b57565b1561136e5760405162461bcd60e51b8152602060048201526024808201527f4d7563686f4e4654202d206e6f74207a65726f2062616c616e636520666f72206044820152633ab9b2b960e11b6064820152608401610762565b6107c584848461182c565b5f6001600160e01b0319821663780e9d6360e01b14806105d457506105d482611987565b5f818152600260205260408120546001600160a01b0316806105d457604051637e27328960e01b815260048101849052602401610762565b61093283838360016119d6565b600a546001600160a01b031633148061140e5750335f908152600b602052604090205460ff1615156001145b610bad5760405162461bcd60e51b815260206004820152603560248201527f41636365737320436f6e74726f6c3a2063616c6c6572206973206e6f7420746860448201527419481bdddb995c881bdc88185d5d1a1bdc9a5e9959605a1b6064820152608401610762565b5f818152600260205260409020546001600160a01b031661149882611ada565b604080518381526001600160a01b03831660208201527f533734a768f070673b823079652464b7e002bb51cdf15e3108209f397425225f910160405180910390a15050565b5f6114e9848484611b12565b90505b9392505050565b5f82815260026020818152604080842054601283529381902090920184905581518581526001600160a01b03909316908301819052908201839052907f9f9cd93677008124701daf99eaa2255e5e2223458bee993592b59162933f8064906060015b60405180910390a1505050565b600a546001600160a01b03163314610bad5760405163118cdaa760e01b8152336004820152602401610762565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b03821661161257604051630b61174360e31b81526001600160a01b0383166004820152602401610762565b6001600160a01b038381165f81815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b156107c557604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906116c0903390889087908790600401612b5d565b6020604051808303815f875af19250505080156116fa575060408051601f3d908101601f191682019092526116f791810190612b8f565b60015b611761573d808015611727576040519150601f19603f3d011682016040523d82523d5f602084013e61172c565b606091505b5080515f0361175957604051633250574960e11b81526001600160a01b0385166004820152602401610762565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b1461091157604051633250574960e11b81526001600160a01b0385166004820152602401610762565b60605f6117a983611bdd565b60010190505f816001600160401b038111156117c7576117c76122be565b6040519080825280601f01601f1916602001820160405280156117f1576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846117fb57509392505050565b60118054905f61183b83612baa565b919050555061184c83601154611cb4565b60405180608001604052806011548152602001428152602001600c600201544261187691906128ac565b815260200183838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92018290525093909452505060115481526012602090815260409182902084518155908401516001820155908301516002820155606083015190915060038201906118f19082612bc2565b5050601154604080519182526001600160a01b03861660208301527f5db0e562b58e88ae25b795493b5a9c538bb02bd38430aa3194dbf8c68f619f54925001611555565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610932908490611d15565b5f6001600160e01b031982166380ac58cd60e01b14806119b757506001600160e01b03198216635b5e139f60e01b145b806105d457506301ffc9a760e01b6001600160e01b03198316146105d4565b80806119ea57506001600160a01b03821615155b15611aab575f6119f98461139d565b90506001600160a01b03831615801590611a255750826001600160a01b0316816001600160a01b031614155b8015611a385750611a368184610fa2565b155b15611a615760405163a9fbf51f60e01b81526001600160a01b0384166004820152602401610762565b8115611aa95783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50505f90815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b5f611ae65f835f6114dd565b90506001600160a01b0381166106ea57604051637e27328960e01b815260048101839052602401610762565b5f80611b1f858585611d76565b90506001600160a01b038116611b7b57611b7684600880545f838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611b9e565b846001600160a01b0316816001600160a01b031614611b9e57611b9e8185611e68565b6001600160a01b038516611bba57611bb584611ef5565b6114e9565b846001600160a01b0316816001600160a01b0316146114e9576114e98585611f9c565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310611c1b5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611c47576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611c6557662386f26fc10000830492506010015b6305f5e1008310611c7d576305f5e100830492506008015b6127108310611c9157612710830492506004015b60648310611ca3576064830492506002015b600a83106105d45760010192915050565b6001600160a01b038216611cdd57604051633250574960e11b81525f6004820152602401610762565b5f611ce983835f6114dd565b90506001600160a01b03811615610932576040516339e3563760e11b81525f6004820152602401610762565b5f611d296001600160a01b03841683611fea565b905080515f14158015611d4d575080806020019051810190611d4b9190612c81565b155b1561093257604051635274afe760e01b81526001600160a01b0384166004820152602401610762565b5f828152600260205260408120546001600160a01b0390811690831615611da257611da2818486611ff7565b6001600160a01b03811615611ddc57611dbd5f855f806119d6565b6001600160a01b0381165f90815260036020526040902080545f190190555b6001600160a01b03851615611e0a576001600160a01b0385165f908152600360205260409020805460010190555b5f8481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b5f611e7283610b57565b5f83815260076020526040902054909150808214611ec3576001600160a01b0384165f9081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b505f9182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008545f90611f0690600190612a08565b5f8381526009602052604081205460088054939450909284908110611f2d57611f2d612834565b905f5260205f20015490508060088381548110611f4c57611f4c612834565b5f918252602080832090910192909255828152600990915260408082208490558582528120556008805480611f8357611f83612c9c565b600190038181905f5260205f20015f9055905550505050565b5f6001611fa884610b57565b611fb29190612a08565b6001600160a01b039093165f908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b60606114ec83835f61205b565b6120028383836120f4565b610932576001600160a01b03831661203057604051637e27328960e01b815260048101829052602401610762565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610762565b6060814710156120805760405163cd78605960e01b8152306004820152602401610762565b5f80856001600160a01b0316848660405161209b9190612cb0565b5f6040518083038185875af1925050503d805f81146120d5576040519150601f19603f3d011682016040523d82523d5f602084013e6120da565b606091505b50915091506120ea868383612155565b9695505050505050565b5f6001600160a01b038316158015906114e95750826001600160a01b0316846001600160a01b0316148061212d575061212d8484610fa2565b806114e95750505f908152600460205260409020546001600160a01b03908116911614919050565b60608261216a57612165826121b1565b6114ec565b815115801561218157506001600160a01b0384163b155b156121aa57604051639996b31560e01b81526001600160a01b0385166004820152602401610762565b50806114ec565b8051156121c15780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160e01b031981168114611229575f80fd5b5f602082840312156121ff575f80fd5b81356114ec816121da565b5f6020828403121561221a575f80fd5b5035919050565b5f5b8381101561223b578181015183820152602001612223565b50505f910152565b5f815180845261225a816020860160208601612221565b601f01601f19169290920160200192915050565b602081525f6114ec6020830184612243565b80356001600160a01b0381168114610a5a575f80fd5b5f80604083850312156122a7575f80fd5b6122b083612280565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b03811182821017156122fa576122fa6122be565b604052919050565b5f82601f830112612311575f80fd5b813560206001600160401b0382111561232c5761232c6122be565b8160051b61233b8282016122d2565b9283528481018201928281019087851115612354575f80fd5b83870192505b848310156123735782358252918301919083019061235a565b979650505050505050565b5f6020828403121561238e575f80fd5b81356001600160401b038111156123a3575f80fd5b610db684828501612302565b5f805f606084860312156123c1575f80fd5b6123ca84612280565b92506123d860208501612280565b9150604084013590509250925092565b8015158114611229575f80fd5b5f60208284031215612405575f80fd5b81356114ec816123e8565b5f8083601f840112612420575f80fd5b5081356001600160401b03811115612436575f80fd5b60208301915083602082850101111561244d575f80fd5b9250929050565b5f805f60408486031215612466575f80fd5b8335925060208401356001600160401b03811115612482575f80fd5b61248e86828701612410565b9497909650939450505050565b5f602082840312156124ab575f80fd5b6114ec82612280565b5f80602083850312156124c5575f80fd5b82356001600160401b038111156124da575f80fd5b6124e685828601612410565b90969095509350505050565b5f8060408385031215612503575f80fd5b82356001600160401b0380821115612519575f80fd5b61252586838701612302565b9350602085013591508082111561253a575f80fd5b5061254785828601612302565b9150509250929050565b5f8060408385031215612562575f80fd5b61256b83612280565b9150602083013561257b816123e8565b809150509250929050565b5f6001600160401b0382111561259e5761259e6122be565b50601f01601f191660200190565b5f805f80608085870312156125bf575f80fd5b6125c885612280565b93506125d660208601612280565b92506040850135915060608501356001600160401b038111156125f7575f80fd5b8501601f81018713612607575f80fd5b803561261a61261582612586565b6122d2565b81815288602083850101111561262e575f80fd5b816020840160208301375f6020838301015280935050505092959194509250565b602080825282516001600160a01b031682820152820151608060408301525f9061267c60a0840182612243565b9050604084015160608401526060840151151560808401528091505092915050565b5f80604083850312156126af575f80fd5b6126b883612280565b91506126c660208401612280565b90509250929050565b602081528151602082015260208201516040820152604082015160608201525f6060830151608080840152610db660a0840182612243565b5f8083601f840112612717575f80fd5b5081356001600160401b0381111561272d575f80fd5b6020830191508360208260051b850101111561244d575f80fd5b5f805f806040858703121561275a575f80fd5b84356001600160401b0380821115612770575f80fd5b61277c88838901612707565b90965094506020870135915080821115612794575f80fd5b506127a187828801612707565b95989497509550505050565b5f80604083850312156127be575f80fd5b50508035926020909101359150565b5f805f604084860312156127df575f80fd5b6127e884612280565b925060208401356001600160401b03811115612482575f80fd5b600181811c9082168061281657607f821691505b602082108103610a5857634e487b7160e01b5f52602260045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f61ffff80831681810361287257612872612848565b6001019392505050565b602080825260169082015275135d58da1bd39195080b481b9bdd08195b98589b195960521b604082015260600190565b808201808211156105d4576105d4612848565b6020808252601f908201527f4d7563686f4e4654202d206e6f74206578697374696e6720746f6b656e494400604082015260600190565b601f82111561093257805f5260205f20601f840160051c8101602085101561291b5750805b601f840160051c820191505b81811015610911575f8155600101612927565b6001600160401b03831115612951576129516122be565b6129658361295f8354612802565b836128f6565b5f601f841160018114612996575f851561297f5750838201355b5f19600387901b1c1916600186901b178355610911565b5f83815260208120601f198716915b828110156129c557868501358255602094850194600190920191016129a5565b50868210156129e1575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b5f81612a0157612a01612848565b505f190190565b818103818111156105d4576105d4612848565b5f82612a3557634e487b7160e01b5f52601260045260245ffd5b500490565b604081525f612a4c6040830185612243565b6020838203818501528185518084528284019150828160051b8501018388015f5b83811015612a9b57601f19878403018552612a89838351612243565b94860194925090850190600101612a6d565b50909998505050505050505050565b5f60208284031215612aba575f80fd5b81516001600160401b03811115612acf575f80fd5b8201601f81018413612adf575f80fd5b8051612aed61261582612586565b818152856020838501011115612b01575f80fd5b612b12826020830160208601612221565b95945050505050565b5f808335601e19843603018112612b30575f80fd5b8301803591506001600160401b03821115612b49575f80fd5b60200191503681900382131561244d575f80fd5b6001600160a01b03858116825284166020820152604081018390526080606082018190525f906120ea90830184612243565b5f60208284031215612b9f575f80fd5b81516114ec816121da565b5f60018201612bbb57612bbb612848565b5060010190565b81516001600160401b03811115612bdb57612bdb6122be565b612bef81612be98454612802565b846128f6565b602080601f831160018114612c22575f8415612c0b5750858301515b5f19600386901b1c1916600185901b178555612c79565b5f85815260208120601f198616915b82811015612c5057888601518255948401946001909101908401612c31565b5085821015612c6d57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b5f60208284031215612c91575f80fd5b81516114ec816123e8565b634e487b7160e01b5f52603160045260245ffd5b5f8251612cc1818460208701612221565b919091019291505056fea2646970667358221220a69b4b3d2b52b8913410a0d59aaac8a917ccaa4f83b207ca9d18be0f3119834a64736f6c6343000818003300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000f4e46542054616c6c6572204c4c43730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f4e46542054616c6c6572204c4c43730000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561000f575f80fd5b5060043610610260575f3560e01c806370a082311161014b578063e985e9c5116100bf578063f5b3e4a411610084578063f5b3e4a41461054a578063f6be71d11461055d578063f76c563b14610570578063f84ddf0b14610583578063fe9fbb801461058c578063feebd5bb146105b7575f80fd5b8063e985e9c5146104de578063e9ff82a7146104f1578063edf5a6a014610511578063f2fde38b14610524578063f3fef3a314610537575f80fd5b8063b88d4fde11610110578063b88d4fde1461046a578063c87b56dd1461047d578063cf1c316a14610490578063d164bef6146104a3578063dc26cf12146104b6578063e51dd5c3146104c9575f80fd5b806370a0823114610423578063715018a6146104365780638da5cb5b1461043e57806395d89b411461044f578063a22cb46514610457575f80fd5b8063328d8f72116101e2578063485d7d94116101a7578063485d7d94146103b15780634f6ccce7146103c45780634f6f96dc146103d757806359f769a9146103ea5780636352211e146103fd57806368af2c7114610410575f80fd5b8063328d8f72146103525780633d218a521461036557806342842e0e1461037857806342966c681461038b57806347cf4b231461039e575f80fd5b806318160ddd1161022857806318160ddd146102f45780631c722dbd1461030657806323b872dd14610319578063277e69de1461032c5780632f745c591461033f575f80fd5b806301ffc9a71461026457806306a93d241461028c57806306fdde031461029f578063081812fc146102b4578063095ea7b3146102df575b5f80fd5b6102776102723660046121ef565b6105ca565b60405190151581526020015b60405180910390f35b61027761029a36600461220a565b6105da565b6102a7610629565b604051610283919061226e565b6102c76102c236600461220a565b6106b8565b6040516001600160a01b039091168152602001610283565b6102f26102ed366004612296565b6106df565b005b6008545b604051908152602001610283565b6102f261031436600461237e565b6106ee565b6102f26103273660046123af565b61073d565b6102f261033a36600461237e565b6107cb565b6102f861034d366004612296565b61084d565b6102f26103603660046123f5565b6108b0565b6102f2610373366004612454565b6108cb565b6102f26103863660046123af565b610918565b6102f261039936600461220a565b610937565b6010546102c7906001600160a01b031681565b6102f26103bf36600461249b565b610942565b6102f86103d236600461220a565b6109a1565b6102f26103e53660046124b4565b6109f6565b6102f86103f836600461249b565b610a0b565b6102c761040b36600461220a565b610a5f565b6102f261041e3660046124f2565b610a69565b6102f861043136600461249b565b610b57565b6102f2610b9c565b600a546001600160a01b03166102c7565b6102a7610baf565b6102f2610465366004612551565b610bbe565b6102f26104783660046125ac565b610bc9565b6102a761048b36600461220a565b610be0565b6102f261049e36600461249b565b610dbe565b6102f26104b136600461249b565b610e19565b6102f26104c436600461220a565b610e43565b6104d1610ea3565b604051610283919061264f565b6102776104ec36600461269e565b610fa2565b6105046104ff36600461220a565b610fcf565b60405161028391906126cf565b6102f261051f366004612747565b6110c7565b6102f261053236600461249b565b6111ef565b6102f2610545366004612296565b61122c565b6102f261055836600461220a565b611249565b6102f261056b36600461220a565b61127d565b6102f261057e3660046127ad565b61128a565b6102f860115481565b61027761059a36600461249b565b6001600160a01b03165f908152600b602052604090205460ff1690565b6102f26105c53660046127cd565b6112e1565b5f6105d482611379565b92915050565b5f60115482111580156105ef5750600f5460ff165b801561060a57505f8281526012602052604090206002015442105b80156105d45750505f9081526012602052604090206001015442101590565b60605f805461063790612802565b80601f016020809104026020016040519081016040528092919081815260200182805461066390612802565b80156106ae5780601f10610685576101008083540402835291602001916106ae565b820191905f5260205f20905b81548152906001019060200180831161069157829003601f168201915b5050505050905090565b5f6106c28261139d565b505f828152600460205260409020546001600160a01b03166105d4565b6106ea8282336113d5565b5050565b6106f66113e2565b5f5b81518161ffff1610156106ea5761072b828261ffff168151811061071e5761071e612834565b6020026020010151611478565b806107358161285c565b9150506106f8565b6001600160a01b03821661076b57604051633250574960e11b81525f60048201526024015b60405180910390fd5b5f6107778383336114dd565b9050836001600160a01b0316816001600160a01b0316146107c5576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610762565b50505050565b6107d36113e2565b600f5460ff166107f55760405162461bcd60e51b81526004016107629061287c565b5f5b81518161ffff1610156106ea5761083b828261ffff168151811061081d5761081d612834565b6020026020010151600c600201544261083691906128ac565b6114f3565b806108458161285c565b9150506107f7565b5f61085783610b57565b82106108885760405163295f44f760e21b81526001600160a01b038416600482015260248101839052604401610762565b506001600160a01b03919091165f908152600660209081526040808320938352929052205490565b6108b86113e2565b600f805460ff1916911515919091179055565b6108d36113e2565b826011548111156108f65760405162461bcd60e51b8152600401610762906128bf565b5f84815260126020526040902060030161091183858361293a565b5050505050565b61093283838360405180602001604052805f815250610bc9565b505050565b6106ea5f82336114dd565b61094a611562565b6001600160a01b0381165f818152600b6020908152604091829020805460ff1916905590519182527fb392249530409099dedf8a34dfe3498cfc2f81a2f80804432221e95cda37175491015b60405180910390a150565b5f6109ab60085490565b82106109d35760405163295f44f760e21b81525f600482015260248101839052604401610762565b600882815481106109e6576109e6612834565b905f5260205f2001549050919050565b6109fe6113e2565b600d61093282848361293a565b5f610a1582610b57565b90508015610a5a575f5b81811015610a58575f610a32848361084d565b9050610a3d816105da565b610a4f5782610a4b816129f3565b9350505b50600101610a1f565b505b919050565b5f6105d48261139d565b610a716113e2565b600f5460ff16610a935760405162461bcd60e51b81526004016107629061287c565b8051825114610af25760405162461bcd60e51b815260206004820152602560248201527f52657175697265642073616d6520616d6f756e74206f662049447320616e6420604482015264646174657360d81b6064820152608401610762565b5f5b82518161ffff16101561093257610b45838261ffff1681518110610b1a57610b1a612834565b6020026020010151838361ffff1681518110610b3857610b38612834565b60200260200101516114f3565b80610b4f8161285c565b915050610af4565b5f6001600160a01b038216610b81576040516322718ad960e21b81525f6004820152602401610762565b506001600160a01b03165f9081526003602052604090205490565b610ba4611562565b610bad5f61158f565b565b60606001805461063790612802565b6106ea3383836115e0565b610bd484848461073d565b6107c58484848461167e565b6060610beb8261139d565b50604080516003808252608082019092525f91816020015b6060815260200190600190039081610c035750505f8481526012602052604081206002015491925090421015610c61575f848152601260205260409020600201546201518090610c54904290612a08565b610c5e9190612a1b565b90505b610c6a8461179d565b825f81518110610c7c57610c7c612834565b6020026020010181905250610c908161179d565b82600181518110610ca357610ca3612834565b6020026020010181905250610cb7846105da565b15610cfe576040518060400160405280600681526020016541637469766560d01b81525082600281518110610cee57610cee612834565b6020026020010181905250610d3e565b60405180604001604052806008815260200167111a5cd8589b195960c21b81525082600281518110610d3257610d32612834565b60200260200101819052505b6010546001600160a01b03166383b104f9610d57610629565b846040518363ffffffff1660e01b8152600401610d75929190612a3a565b5f60405180830381865afa158015610d8f573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610db69190810190612aaa565b949350505050565b610dc6611562565b6001600160a01b0381165f818152600b6020908152604091829020805460ff1916600117905590519182527fdc84e3a4c83602050e3865df792a4e6800211a79ac60db94e703a820ce8929249101610996565b610e216113e2565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b610e4b6113e2565b80601154811115610e6e5760405162461bcd60e51b8152600401610762906128bf565b600f5460ff16610e905760405162461bcd60e51b81526004016107629061287c565b600e546106ea90839061083690426128ac565b610ed660405180608001604052805f6001600160a01b03168152602001606081526020015f81526020015f151581525090565b6040805160808101909152600c80546001600160a01b03168252600d8054602084019190610f0390612802565b80601f0160208091040260200160405190810160405280929190818152602001828054610f2f90612802565b8015610f7a5780601f10610f5157610100808354040283529160200191610f7a565b820191905f5260205f20905b815481529060010190602001808311610f5d57829003601f168201915b50505091835250506002820154602082015260039091015460ff161515604090910152919050565b6001600160a01b039182165f90815260056020908152604080832093909416825291909152205460ff1690565b610ff760405180608001604052805f81526020015f81526020015f8152602001606081525090565b60125f8381526020019081526020015f206040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201805461104090612802565b80601f016020809104026020016040519081016040528092919081815260200182805461106c90612802565b80156110b75780601f1061108e576101008083540402835291602001916110b7565b820191905f5260205f20905b81548152906001019060200180831161109a57829003601f168201915b5050505050815250509050919050565b600f5460ff166110e95760405162461bcd60e51b81526004016107629061287c565b6110f16113e2565b8281146111405760405162461bcd60e51b815260206004820152601a60248201527f4d7563686f4e46543a20646966666572656e74206c656e6774680000000000006044820152606401610762565b5f5b61ffff81168411156109115761117c85858361ffff1681811061116757611167612834565b9050602002016020810190610431919061249b565b5f036111dd576111dd85858361ffff1681811061119b5761119b612834565b90506020020160208101906111b0919061249b565b84848461ffff168181106111c6576111c6612834565b90506020028101906111d89190612b1b565b61182c565b806111e78161285c565b915050611142565b6111f7611562565b6001600160a01b03811661122057604051631e4fbdf760e01b81525f6004820152602401610762565b6112298161158f565b50565b6112346113e2565b816109326001600160a01b0382163384611935565b6112516113e2565b806011548111156112745760405162461bcd60e51b8152600401610762906128bf565b6106ea82611478565b6112856113e2565b600e55565b6112926113e2565b816011548111156112b55760405162461bcd60e51b8152600401610762906128bf565b600f5460ff166112d75760405162461bcd60e51b81526004016107629061287c565b61093283836114f3565b600f5460ff166113035760405162461bcd60e51b81526004016107629061287c565b61130b6113e2565b8261131581610b57565b1561136e5760405162461bcd60e51b8152602060048201526024808201527f4d7563686f4e4654202d206e6f74207a65726f2062616c616e636520666f72206044820152633ab9b2b960e11b6064820152608401610762565b6107c584848461182c565b5f6001600160e01b0319821663780e9d6360e01b14806105d457506105d482611987565b5f818152600260205260408120546001600160a01b0316806105d457604051637e27328960e01b815260048101849052602401610762565b61093283838360016119d6565b600a546001600160a01b031633148061140e5750335f908152600b602052604090205460ff1615156001145b610bad5760405162461bcd60e51b815260206004820152603560248201527f41636365737320436f6e74726f6c3a2063616c6c6572206973206e6f7420746860448201527419481bdddb995c881bdc88185d5d1a1bdc9a5e9959605a1b6064820152608401610762565b5f818152600260205260409020546001600160a01b031661149882611ada565b604080518381526001600160a01b03831660208201527f533734a768f070673b823079652464b7e002bb51cdf15e3108209f397425225f910160405180910390a15050565b5f6114e9848484611b12565b90505b9392505050565b5f82815260026020818152604080842054601283529381902090920184905581518581526001600160a01b03909316908301819052908201839052907f9f9cd93677008124701daf99eaa2255e5e2223458bee993592b59162933f8064906060015b60405180910390a1505050565b600a546001600160a01b03163314610bad5760405163118cdaa760e01b8152336004820152602401610762565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b03821661161257604051630b61174360e31b81526001600160a01b0383166004820152602401610762565b6001600160a01b038381165f81815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b156107c557604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906116c0903390889087908790600401612b5d565b6020604051808303815f875af19250505080156116fa575060408051601f3d908101601f191682019092526116f791810190612b8f565b60015b611761573d808015611727576040519150601f19603f3d011682016040523d82523d5f602084013e61172c565b606091505b5080515f0361175957604051633250574960e11b81526001600160a01b0385166004820152602401610762565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b1461091157604051633250574960e11b81526001600160a01b0385166004820152602401610762565b60605f6117a983611bdd565b60010190505f816001600160401b038111156117c7576117c76122be565b6040519080825280601f01601f1916602001820160405280156117f1576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846117fb57509392505050565b60118054905f61183b83612baa565b919050555061184c83601154611cb4565b60405180608001604052806011548152602001428152602001600c600201544261187691906128ac565b815260200183838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92018290525093909452505060115481526012602090815260409182902084518155908401516001820155908301516002820155606083015190915060038201906118f19082612bc2565b5050601154604080519182526001600160a01b03861660208301527f5db0e562b58e88ae25b795493b5a9c538bb02bd38430aa3194dbf8c68f619f54925001611555565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610932908490611d15565b5f6001600160e01b031982166380ac58cd60e01b14806119b757506001600160e01b03198216635b5e139f60e01b145b806105d457506301ffc9a760e01b6001600160e01b03198316146105d4565b80806119ea57506001600160a01b03821615155b15611aab575f6119f98461139d565b90506001600160a01b03831615801590611a255750826001600160a01b0316816001600160a01b031614155b8015611a385750611a368184610fa2565b155b15611a615760405163a9fbf51f60e01b81526001600160a01b0384166004820152602401610762565b8115611aa95783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50505f90815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b5f611ae65f835f6114dd565b90506001600160a01b0381166106ea57604051637e27328960e01b815260048101839052602401610762565b5f80611b1f858585611d76565b90506001600160a01b038116611b7b57611b7684600880545f838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611b9e565b846001600160a01b0316816001600160a01b031614611b9e57611b9e8185611e68565b6001600160a01b038516611bba57611bb584611ef5565b6114e9565b846001600160a01b0316816001600160a01b0316146114e9576114e98585611f9c565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310611c1b5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611c47576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611c6557662386f26fc10000830492506010015b6305f5e1008310611c7d576305f5e100830492506008015b6127108310611c9157612710830492506004015b60648310611ca3576064830492506002015b600a83106105d45760010192915050565b6001600160a01b038216611cdd57604051633250574960e11b81525f6004820152602401610762565b5f611ce983835f6114dd565b90506001600160a01b03811615610932576040516339e3563760e11b81525f6004820152602401610762565b5f611d296001600160a01b03841683611fea565b905080515f14158015611d4d575080806020019051810190611d4b9190612c81565b155b1561093257604051635274afe760e01b81526001600160a01b0384166004820152602401610762565b5f828152600260205260408120546001600160a01b0390811690831615611da257611da2818486611ff7565b6001600160a01b03811615611ddc57611dbd5f855f806119d6565b6001600160a01b0381165f90815260036020526040902080545f190190555b6001600160a01b03851615611e0a576001600160a01b0385165f908152600360205260409020805460010190555b5f8481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b5f611e7283610b57565b5f83815260076020526040902054909150808214611ec3576001600160a01b0384165f9081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b505f9182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008545f90611f0690600190612a08565b5f8381526009602052604081205460088054939450909284908110611f2d57611f2d612834565b905f5260205f20015490508060088381548110611f4c57611f4c612834565b5f918252602080832090910192909255828152600990915260408082208490558582528120556008805480611f8357611f83612c9c565b600190038181905f5260205f20015f9055905550505050565b5f6001611fa884610b57565b611fb29190612a08565b6001600160a01b039093165f908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b60606114ec83835f61205b565b6120028383836120f4565b610932576001600160a01b03831661203057604051637e27328960e01b815260048101829052602401610762565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610762565b6060814710156120805760405163cd78605960e01b8152306004820152602401610762565b5f80856001600160a01b0316848660405161209b9190612cb0565b5f6040518083038185875af1925050503d805f81146120d5576040519150601f19603f3d011682016040523d82523d5f602084013e6120da565b606091505b50915091506120ea868383612155565b9695505050505050565b5f6001600160a01b038316158015906114e95750826001600160a01b0316846001600160a01b0316148061212d575061212d8484610fa2565b806114e95750505f908152600460205260409020546001600160a01b03908116911614919050565b60608261216a57612165826121b1565b6114ec565b815115801561218157506001600160a01b0384163b155b156121aa57604051639996b31560e01b81526001600160a01b0385166004820152602401610762565b50806114ec565b8051156121c15780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160e01b031981168114611229575f80fd5b5f602082840312156121ff575f80fd5b81356114ec816121da565b5f6020828403121561221a575f80fd5b5035919050565b5f5b8381101561223b578181015183820152602001612223565b50505f910152565b5f815180845261225a816020860160208601612221565b601f01601f19169290920160200192915050565b602081525f6114ec6020830184612243565b80356001600160a01b0381168114610a5a575f80fd5b5f80604083850312156122a7575f80fd5b6122b083612280565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b03811182821017156122fa576122fa6122be565b604052919050565b5f82601f830112612311575f80fd5b813560206001600160401b0382111561232c5761232c6122be565b8160051b61233b8282016122d2565b9283528481018201928281019087851115612354575f80fd5b83870192505b848310156123735782358252918301919083019061235a565b979650505050505050565b5f6020828403121561238e575f80fd5b81356001600160401b038111156123a3575f80fd5b610db684828501612302565b5f805f606084860312156123c1575f80fd5b6123ca84612280565b92506123d860208501612280565b9150604084013590509250925092565b8015158114611229575f80fd5b5f60208284031215612405575f80fd5b81356114ec816123e8565b5f8083601f840112612420575f80fd5b5081356001600160401b03811115612436575f80fd5b60208301915083602082850101111561244d575f80fd5b9250929050565b5f805f60408486031215612466575f80fd5b8335925060208401356001600160401b03811115612482575f80fd5b61248e86828701612410565b9497909650939450505050565b5f602082840312156124ab575f80fd5b6114ec82612280565b5f80602083850312156124c5575f80fd5b82356001600160401b038111156124da575f80fd5b6124e685828601612410565b90969095509350505050565b5f8060408385031215612503575f80fd5b82356001600160401b0380821115612519575f80fd5b61252586838701612302565b9350602085013591508082111561253a575f80fd5b5061254785828601612302565b9150509250929050565b5f8060408385031215612562575f80fd5b61256b83612280565b9150602083013561257b816123e8565b809150509250929050565b5f6001600160401b0382111561259e5761259e6122be565b50601f01601f191660200190565b5f805f80608085870312156125bf575f80fd5b6125c885612280565b93506125d660208601612280565b92506040850135915060608501356001600160401b038111156125f7575f80fd5b8501601f81018713612607575f80fd5b803561261a61261582612586565b6122d2565b81815288602083850101111561262e575f80fd5b816020840160208301375f6020838301015280935050505092959194509250565b602080825282516001600160a01b031682820152820151608060408301525f9061267c60a0840182612243565b9050604084015160608401526060840151151560808401528091505092915050565b5f80604083850312156126af575f80fd5b6126b883612280565b91506126c660208401612280565b90509250929050565b602081528151602082015260208201516040820152604082015160608201525f6060830151608080840152610db660a0840182612243565b5f8083601f840112612717575f80fd5b5081356001600160401b0381111561272d575f80fd5b6020830191508360208260051b850101111561244d575f80fd5b5f805f806040858703121561275a575f80fd5b84356001600160401b0380821115612770575f80fd5b61277c88838901612707565b90965094506020870135915080821115612794575f80fd5b506127a187828801612707565b95989497509550505050565b5f80604083850312156127be575f80fd5b50508035926020909101359150565b5f805f604084860312156127df575f80fd5b6127e884612280565b925060208401356001600160401b03811115612482575f80fd5b600181811c9082168061281657607f821691505b602082108103610a5857634e487b7160e01b5f52602260045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f61ffff80831681810361287257612872612848565b6001019392505050565b602080825260169082015275135d58da1bd39195080b481b9bdd08195b98589b195960521b604082015260600190565b808201808211156105d4576105d4612848565b6020808252601f908201527f4d7563686f4e4654202d206e6f74206578697374696e6720746f6b656e494400604082015260600190565b601f82111561093257805f5260205f20601f840160051c8101602085101561291b5750805b601f840160051c820191505b81811015610911575f8155600101612927565b6001600160401b03831115612951576129516122be565b6129658361295f8354612802565b836128f6565b5f601f841160018114612996575f851561297f5750838201355b5f19600387901b1c1916600186901b178355610911565b5f83815260208120601f198716915b828110156129c557868501358255602094850194600190920191016129a5565b50868210156129e1575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b5f81612a0157612a01612848565b505f190190565b818103818111156105d4576105d4612848565b5f82612a3557634e487b7160e01b5f52601260045260245ffd5b500490565b604081525f612a4c6040830185612243565b6020838203818501528185518084528284019150828160051b8501018388015f5b83811015612a9b57601f19878403018552612a89838351612243565b94860194925090850190600101612a6d565b50909998505050505050505050565b5f60208284031215612aba575f80fd5b81516001600160401b03811115612acf575f80fd5b8201601f81018413612adf575f80fd5b8051612aed61261582612586565b818152856020838501011115612b01575f80fd5b612b12826020830160208601612221565b95945050505050565b5f808335601e19843603018112612b30575f80fd5b8301803591506001600160401b03821115612b49575f80fd5b60200191503681900382131561244d575f80fd5b6001600160a01b03858116825284166020820152604081018390526080606082018190525f906120ea90830184612243565b5f60208284031215612b9f575f80fd5b81516114ec816121da565b5f60018201612bbb57612bbb612848565b5060010190565b81516001600160401b03811115612bdb57612bdb6122be565b612bef81612be98454612802565b846128f6565b602080601f831160018114612c22575f8415612c0b5750858301515b5f19600386901b1c1916600185901b178555612c79565b5f85815260208120601f198616915b82811015612c5057888601518255948401946001909101908401612c31565b5085821015612c6d57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b5f60208284031215612c91575f80fd5b81516114ec816123e8565b634e487b7160e01b5f52603160045260245ffd5b5f8251612cc1818460208701612221565b919091019291505056fea2646970667358221220a69b4b3d2b52b8913410a0d59aaac8a917ccaa4f83b207ca9d18be0f3119834a64736f6c63430008180033

Deployed Bytecode Sourcemap

2834:7814:34:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10457:189;;;;;;:::i;:::-;;:::i;:::-;;;565:14:49;;558:22;540:41;;528:2;513:18;10457:189:34;;;;;;;;8246:277;;;;;;:::i;:::-;;:::i;2365:89:11:-;;;:::i;:::-;;;;;;;:::i;3497:154::-;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;1697:32:49;;;1679:51;;1667:2;1652:18;3497:154:11;1533:203:49;3323:113:11;;;;;;:::i;:::-;;:::i;:::-;;2062:102:15;2140:10;:17;2062:102;;;2324:25:49;;;2312:2;2297:18;2062:102:15;2178:177:49;5612:206:34;;;;;;:::i;:::-;;:::i;4143:578:11:-;;;;;;:::i;:::-;;:::i;6020:250:34:-;;;;;;:::i;:::-;;:::i;1736:255:15:-;;;;;;:::i;:::-;;:::i;3744:117:34:-;;;;;;:::i;:::-;;:::i;6809:194::-;;;;;;:::i;:::-;;:::i;4787:132:11:-;;;;;;:::i;:::-;;:::i;561:314:14:-;;;;;;:::i;:::-;;:::i;3396:38:34:-;;;;;-1:-1:-1;;;;;3396:38:34;;;821:152:29;;;;;;:::i;:::-;;:::i;2236:226:15:-;;;;;;:::i;:::-;;:::i;3476:132:34:-;;;;;;:::i;:::-;;:::i;8576:362::-;;;;;;:::i;:::-;;:::i;2185:118:11:-;;;;;;:::i;:::-;;:::i;6459:344:34:-;;;;;;:::i;:::-;;:::i;1920:208:11:-;;;;;;:::i;:::-;;:::i;2293:101:0:-;;;:::i;1638:85::-;1710:6;;-1:-1:-1;;;;;1710:6:0;1638:85;;2518:93:11;;;:::i;3718:144::-;;;;;;:::i;:::-;;:::i;4985:208::-;;;;;;:::i;:::-;;:::i;7521:697:34:-;;;;;;:::i;:::-;;:::i;669:146:29:-;;;;;;:::i;:::-;;:::i;3867:132:34:-;;;;;;:::i;:::-;;:::i;5824:190::-;;;;;;:::i;:::-;;:::i;7404:111::-;;;:::i;:::-;;;;;;;:::i;3928:153:11:-;;;;;;:::i;:::-;;:::i;7251:147:34:-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;5033:421::-;;;;;;:::i;:::-;;:::i;2543:215:0:-;;;;;;:::i;:::-;;:::i;7009:177:34:-;;;;;;:::i;:::-;;:::i;5460:146::-;;;;;;:::i;:::-;;:::i;3614:124::-;;;;;;:::i;:::-;;:::i;6276:177::-;;;;;;:::i;:::-;;:::i;4037:30::-;;;;;;979:105:29;;;;;;:::i;:::-;-1:-1:-1;;;;;1060:17:29;1037:4;1060:17;;;:10;:17;;;;;;;;;979:105;4832:195:34;;;;;;:::i;:::-;;:::i;10457:189::-;10569:4;10592:47;10627:11;10592:34;:47::i;:::-;10585:54;10457:189;-1:-1:-1;;10457:189:34:o;8246:277::-;8305:13;8353:11;;8342:7;:22;;:49;;;;-1:-1:-1;8368:23:34;;;;8342:49;:113;;;;-1:-1:-1;8395:27:34;;;;:18;:27;;;;;:42;;;8440:15;-1:-1:-1;8342:113:34;:173;;;;-1:-1:-1;;8459:27:34;;;;:18;:27;;;;;:37;;;8500:15;-1:-1:-1;8459:56:34;;8246:277::o;2365:89:11:-;2410:13;2442:5;2435:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2365:89;:::o;3497:154::-;3564:7;3583:22;3597:7;3583:13;:22::i;:::-;-1:-1:-1;6008:7:11;6034:24;;;:15;:24;;;;;;-1:-1:-1;;;;;6034:24:11;3623:21;5938:127;3323:113;3394:35;3403:2;3407:7;735:10:21;3394:8:11;:35::i;:::-;3323:113;;:::o;5612:206:34:-;369:25:29;:23;:25::i;:::-;5720:8:34::1;5715:97;5738:9;:16;5734:1;:20;;;5715:97;;;5775:26;5788:9;5798:1;5788:12;;;;;;;;;;:::i;:::-;;;;;;;5775;:26::i;:::-;5756:3:::0;::::1;::::0;::::1;:::i;:::-;;;;5715:97;;4143:578:11::0;-1:-1:-1;;;;;4237:16:11;;4233:87;;4276:33;;-1:-1:-1;;;4276:33:11;;4306:1;4276:33;;;1679:51:49;1652:18;;4276:33:11;;;;;;;;4233:87;4538:21;4562:34;4570:2;4574:7;735:10:21;4562:7:11;:34::i;:::-;4538:58;;4627:4;-1:-1:-1;;;;;4610:21:11;:13;-1:-1:-1;;;;;4610:21:11;;4606:109;;4654:50;;-1:-1:-1;;;4654:50:11;;-1:-1:-1;;;;;12660:15:49;;;4654:50:11;;;12642:34:49;12692:18;;;12685:34;;;12755:15;;12735:18;;;12728:43;12577:18;;4654:50:11;12402:375:49;4606:109:11;4223:498;4143:578;;;:::o;6020:250:34:-;369:25:29;:23;:25::i;:::-;4399:23:34;;::::1;;4391:58;;;;-1:-1:-1::0;;;4391:58:34::1;;;;;;;:::i;:::-;6127:8:::2;6122:142;6145:9;:16;6141:1;:20;;;6122:142;;;6182:71;6196:9;6206:1;6196:12;;;;;;;;;;:::i;:::-;;;;;;;6228:15;:24;;;6210:15;:42;;;;:::i;:::-;6182:13;:71::i;:::-;6163:3:::0;::::2;::::0;::::2;:::i;:::-;;;;6122:142;;1736:255:15::0;1824:7;1856:16;1866:5;1856:9;:16::i;:::-;1847:5;:25;1843:99;;1895:36;;-1:-1:-1;;;1895:36:15;;-1:-1:-1;;;;;13455:32:49;;1895:36:15;;;13437:51:49;13504:18;;;13497:34;;;13410:18;;1895:36:15;13263:274:49;1843:99:15;-1:-1:-1;;;;;;1958:19:15;;;;;;;;:12;:19;;;;;;;;:26;;;;;;;;;1736:255::o;3744:117:34:-;369:25:29;:23;:25::i;:::-;3820:23:34;:34;;-1:-1:-1;;3820:34:34::1;::::0;::::1;;::::0;;;::::1;::::0;;3744:117::o;6809:194::-;369:25:29;:23;:25::i;:::-;6927:8:34::1;4548:11;;4536:8;:23;;4528:67;;;;-1:-1:-1::0;;;4528:67:34::1;;;;;;;:::i;:::-;6947:28:::2;::::0;;;:18:::2;:28;::::0;;;;:37:::2;;:49;6987:9:::0;;6947:37;:49:::2;:::i;:::-;;404:1:29::1;6809:194:34::0;;;:::o;4787:132:11:-;4873:39;4890:4;4896:2;4900:7;4873:39;;;;;;;;;;;;:16;:39::i;:::-;4787:132;;;:::o;561:314:14:-;826:42;842:1;846:7;735:10:21;4562:7:11;:34::i;821:152:29:-;1531:13:0;:11;:13::i;:::-;-1:-1:-1;;;;;895:23:29;::::1;921:5;895:23:::0;;;:10:::1;:23;::::0;;;;;;;;:31;;-1:-1:-1;;895:31:29::1;::::0;;941:25;;1679:51:49;;;941:25:29::1;::::0;1652:18:49;941:25:29::1;;;;;;;;821:152:::0;:::o;2236:226:15:-;2302:7;2334:13;2140:10;:17;;2062:102;2334:13;2325:5;:22;2321:101;;2370:41;;-1:-1:-1;;;2370:41:15;;2401:1;2370:41;;;13437:51:49;13504:18;;;13497:34;;;13410:18;;2370:41:15;13263:274:49;2321:101:15;2438:10;2449:5;2438:17;;;;;;;;:::i;:::-;;;;;;;;;2431:24;;2236:226;;;:::o;3476:132:34:-;369:25:29;:23;:25::i;:::-;3565:24:34;:36:::1;3592:9:::0;;3565:24;:36:::1;:::i;8576:362::-:0;8638:11;8667:15;8677:4;8667:9;:15::i;:::-;8661:21;-1:-1:-1;8696:7:34;;8692:240;;8724:9;8719:203;8743:3;8739:1;:7;8719:203;;;8771:15;8789:28;8809:4;8815:1;8789:19;:28::i;:::-;8771:46;;8840:20;8852:7;8840:11;:20::i;:::-;8835:73;;8884:5;;;;:::i;:::-;;;;8835:73;-1:-1:-1;8748:3:34;;8719:203;;;;8692:240;8576:362;;;:::o;2185:118:11:-;2248:7;2274:22;2288:7;2274:13;:22::i;6459:344:34:-;369:25:29;:23;:25::i;:::-;4399:23:34;;::::1;;4391:58;;;;-1:-1:-1::0;;;4391:58:34::1;;;;;;;:::i;:::-;6623:6:::2;:13;6603:9;:16;:33;6595:83;;;::::0;-1:-1:-1;;;6595:83:34;;16268:2:49;6595:83:34::2;::::0;::::2;16250:21:49::0;16307:2;16287:18;;;16280:30;16346:34;16326:18;;;16319:62;-1:-1:-1;;;16397:18:49;;;16390:35;16442:19;;6595:83:34::2;16066:401:49::0;6595:83:34::2;6693:8;6688:109;6711:9;:16;6707:1;:20;;;6688:109;;;6748:38;6762:9;6772:1;6762:12;;;;;;;;;;:::i;:::-;;;;;;;6776:6;6783:1;6776:9;;;;;;;;;;:::i;:::-;;;;;;;6748:13;:38::i;:::-;6729:3:::0;::::2;::::0;::::2;:::i;:::-;;;;6688:109;;1920:208:11::0;1983:7;-1:-1:-1;;;;;2006:19:11;;2002:87;;2048:30;;-1:-1:-1;;;2048:30:11;;2075:1;2048:30;;;1679:51:49;1652:18;;2048:30:11;1533:203:49;2002:87:11;-1:-1:-1;;;;;;2105:16:11;;;;;:9;:16;;;;;;;1920:208::o;2293:101:0:-;1531:13;:11;:13::i;:::-;2357:30:::1;2384:1;2357:18;:30::i;:::-;2293:101::o:0;2518:93:11:-;2565:13;2597:7;2590:14;;;;;:::i;3718:144::-;3803:52;735:10:21;3836:8:11;3846;3803:18;:52::i;4985:208::-;5098:31;5111:4;5117:2;5121:7;5098:12;:31::i;:::-;5139:47;5162:4;5168:2;5172:7;5181:4;5139:22;:47::i;7521:697:34:-;7605:13;7630:22;7644:7;7630:13;:22::i;:::-;-1:-1:-1;7688:15:34;;;7701:1;7688:15;;;;;;;;;7663:22;;7688:15;;;;;;;;;;;;;;;;;-1:-1:-1;;7713:20:34;7751:27;;;:18;:27;;;;;:42;;;7663:40;;-1:-1:-1;7713:20:34;7796:15;-1:-1:-1;7747:179:34;;;7843:27;;;;:18;:27;;;;;:42;;;7908:6;;7843:60;;7888:15;;7843:60;:::i;:::-;7842:73;;;;:::i;:::-;7827:88;;7747:179;7948:25;7965:7;7948:16;:25::i;:::-;7936:6;7943:1;7936:9;;;;;;;;:::i;:::-;;;;;;:37;;;;7995:30;8012:12;7995:16;:30::i;:::-;7983:6;7990:1;7983:9;;;;;;;;:::i;:::-;;;;;;:42;;;;8039:20;8051:7;8039:11;:20::i;:::-;8035:124;;;8075:20;;;;;;;;;;;;;-1:-1:-1;;;8075:20:34;;;:6;8082:1;8075:9;;;;;;;;:::i;:::-;;;;;;:20;;;;8035:124;;;8126:22;;;;;;;;;;;;;-1:-1:-1;;;8126:22:34;;;:6;8133:1;8126:9;;;;;;;;:::i;:::-;;;;;;:22;;;;8035:124;8176:12;;-1:-1:-1;;;;;8176:12:34;:19;8196:6;:4;:6::i;:::-;8204;8176:35;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8176:35:34;;;;;;;;;;;;:::i;:::-;8169:42;7521:697;-1:-1:-1;;;;7521:697:34:o;669:146:29:-;1531:13:0;:11;:13::i;:::-;-1:-1:-1;;;;;740:23:29;::::1;;::::0;;;:10:::1;:23;::::0;;;;;;;;:30;;-1:-1:-1;;740:30:29::1;766:4;740:30;::::0;;785:23;;1679:51:49;;;785:23:29::1;::::0;1652:18:49;785:23:29::1;1533:203:49::0;3867:132:34;369:25:29;:23;:25::i;:::-;3950:12:34::1;:42:::0;;-1:-1:-1;;;;;;3950:42:34::1;-1:-1:-1::0;;;;;3950:42:34;;;::::1;::::0;;;::::1;::::0;;3867:132::o;5824:190::-;369:25:29;:23;:25::i;:::-;5908:8:34::1;4548:11;;4536:8;:23;;4528:67;;;;-1:-1:-1::0;;;4528:67:34::1;;;;;;;:::i;:::-;4399:23:::0;;::::2;;4391:58;;;;-1:-1:-1::0;;;4391:58:34::2;;;;;;;:::i;:::-;5982:24:::0;;5940:67:::3;::::0;5954:8;;5964:42:::3;::::0;:15:::3;:42;:::i;7404:111::-:0;7453:21;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7453:21:34;7486:22;;;;;;;;;7493:15;7486:22;;-1:-1:-1;;;;;7486:22:34;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;7486:22:34;;;-1:-1:-1;;7486:22:34;;;;;;;;;;;;;;;;;;;;;;;7404:111;-1:-1:-1;7404:111:34:o;3928:153:11:-;-1:-1:-1;;;;;4039:25:11;;;4016:4;4039:25;;;:18;:25;;;;;;;;:35;;;;;;;;;;;;;;;3928:153::o;7251:147:34:-;7318:27;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7318:27:34;7364:18;:27;7383:7;7364:27;;;;;;;;;;;7357:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7251:147;;;:::o;5033:421::-;4399:23;;;;4391:58;;;;-1:-1:-1;;;4391:58:34;;;;;;;:::i;:::-;369:25:29::1;:23;:25::i;:::-;5181:39:34::0;;::::2;5173:78;;;::::0;-1:-1:-1;;;5173:78:34;;18747:2:49;5173:78:34::2;::::0;::::2;18729:21:49::0;18786:2;18766:18;;;18759:30;18825:28;18805:18;;;18798:56;18871:18;;5173:78:34::2;18545:350:49::0;5173:78:34::2;5266:8;5261:187;5280:23;::::0;::::2;::::0;-1:-1:-1;5261:187:34::2;;;5328:26;5338:12;;5351:1;5338:15;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;:::i;5328:26::-;5358:1;5328:31:::0;5324:114:::2;;5379:44;5393:12;;5406:1;5393:15;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;:::i;:::-;5410:9;;5420:1;5410:12;;;;;;;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;5379:13;:44::i;:::-;5305:3:::0;::::2;::::0;::::2;:::i;:::-;;;;5261:187;;2543:215:0::0;1531:13;:11;:13::i;:::-;-1:-1:-1;;;;;2627:22:0;::::1;2623:91;;2672:31;::::0;-1:-1:-1;;;2672:31:0;;2700:1:::1;2672:31;::::0;::::1;1679:51:49::0;1652:18;;2672:31:0::1;1533:203:49::0;2623:91:0::1;2723:28;2742:8;2723:18;:28::i;:::-;2543:215:::0;:::o;7009:177:34:-;369:25:29;:23;:25::i;:::-;7123:6:34;7140:39:::1;-1:-1:-1::0;;;;;7140:18:34;::::1;7159:10;7171:7:::0;7140:18:::1;:39::i;5460:146::-:0;369:25:29;:23;:25::i;:::-;5557:8:34::1;4548:11;;4536:8;:23;;4528:67;;;;-1:-1:-1::0;;;4528:67:34::1;;;;;;;:::i;:::-;5577:22:::2;5590:8;5577:12;:22::i;3614:124::-:0;369:25:29;:23;:25::i;:::-;3695:24:34;:36;3614:124::o;6276:177::-;369:25:29;:23;:25::i;:::-;6384:8:34::1;4548:11;;4536:8;:23;;4528:67;;;;-1:-1:-1::0;;;4528:67:34::1;;;;;;;:::i;:::-;4399:23:::0;;::::2;;4391:58;;;;-1:-1:-1::0;;;4391:58:34::2;;;;;;;:::i;:::-;6416:30:::3;6430:8;6440:5;6416:13;:30::i;4832:195::-:0;4399:23;;;;4391:58;;;;-1:-1:-1;;;4391:58:34;;;;;;;:::i;:::-;369:25:29::1;:23;:25::i;:::-;4960:11:34::2;4677:16;4687:5;4677:9;:16::i;:::-;:21:::0;4669:70:::2;;;::::0;-1:-1:-1;;;4669:70:34;;19629:2:49;4669:70:34::2;::::0;::::2;19611:21:49::0;19668:2;19648:18;;;19641:30;19707:34;19687:18;;;19680:62;-1:-1:-1;;;19758:18:49;;;19751:34;19802:19;;4669:70:34::2;19427:400:49::0;4669:70:34::2;4983:37:::3;4997:11;5010:9;;4983:13;:37::i;1435:222:15:-:0;1537:4;-1:-1:-1;;;;;;1560:50:15;;-1:-1:-1;;;1560:50:15;;:90;;;1614:36;1638:11;1614:23;:36::i;16138:241:11:-;16201:7;5799:16;;;:7;:16;;;;;;-1:-1:-1;;;;;5799:16:11;;16263:88;;16309:31;;-1:-1:-1;;;16309:31:11;;;;;2324:25:49;;;2297:18;;16309:31:11;2178:177:49;14418:120:11;14498:33;14507:2;14511:7;14520:4;14526;14498:8;:33::i;460:203:29:-;1710:6:0;;-1:-1:-1;;;;;1710:6:0;735:10:21;536:23:29;;535:63;;-1:-1:-1;735:10:21;565:24:29;;;;:10;:24;;;;;;;;:32;;:24;:32;535:63;527:129;;;;-1:-1:-1;;;527:129:29;;20034:2:49;527:129:29;;;20016:21:49;20073:2;20053:18;;;20046:30;20112:34;20092:18;;;20085:62;-1:-1:-1;;;20163:18:49;;;20156:51;20224:19;;527:129:29;19832:417:49;9468:209:34;9527:18;5799:16:11;;;:7;:16;;;;;;-1:-1:-1;;;;;5799:16:11;9596:15:34;5799:16:11;9596:5:34;:15::i;:::-;9627:43;;;20428:25:49;;;-1:-1:-1;;;;;20489:32:49;;20484:2;20469:18;;20462:60;9627:43:34;;20401:18:49;9627:43:34;;;;;;;9517:160;9468:209;:::o;10262:189::-;10375:7;10401:43;10426:2;10430:7;10439:4;10401:24;:43::i;:::-;10394:50;;10262:189;;;;;;:::o;9683:348::-;9764:18;5799:16:11;;;:7;:16;;;;;;;;;9887:18:34;:28;;;;;;:43;;;:57;;;9960:64;;20735:25:49;;;-1:-1:-1;;;;;5799:16:11;;;20776:18:49;;;20769:60;;;20845:18;;;20838:34;;;5799:16:11;9960:64:34;;20723:2:49;20708:18;9960:64:34;;;;;;;;9754:277;9683:348;;:::o;1796:162:0:-;1710:6;;-1:-1:-1;;;;;1710:6:0;735:10:21;1855:23:0;1851:101;;1901:40;;-1:-1:-1;;;1901:40:0;;735:10:21;1901:40:0;;;1679:51:49;1652:18;;1901:40:0;1533:203:49;2912:187:0;3004:6;;;-1:-1:-1;;;;;3020:17:0;;;-1:-1:-1;;;;;;3020:17:0;;;;;;;3052:40;;3004:6;;;3020:17;3004:6;;3052:40;;2985:16;;3052:40;2975:124;2912:187;:::o;15591:312:11:-;-1:-1:-1;;;;;15698:22:11;;15694:91;;15743:31;;-1:-1:-1;;;15743:31:11;;-1:-1:-1;;;;;1697:32:49;;15743:31:11;;;1679:51:49;1652:18;;15743:31:11;1533:203:49;15694:91:11;-1:-1:-1;;;;;15794:25:11;;;;;;;:18;:25;;;;;;;;:35;;;;;;;;;;;;;:46;;-1:-1:-1;;15794:46:11;;;;;;;;;;15855:41;;540::49;;;15855::11;;513:18:49;15855:41:11;;;;;;;15591:312;;;:::o;16918:782::-;-1:-1:-1;;;;;17034:14:11;;;:18;17030:664;;17072:71;;-1:-1:-1;;;17072:71:11;;-1:-1:-1;;;;;17072:36:11;;;;;:71;;735:10:21;;17123:4:11;;17129:7;;17138:4;;17072:71;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17072:71:11;;;;;;;;-1:-1:-1;;17072:71:11;;;;;;;;;;;;:::i;:::-;;;17068:616;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;17381:6;:13;17398:1;17381:18;17377:293;;17430:25;;-1:-1:-1;;;17430:25:11;;-1:-1:-1;;;;;1697:32:49;;17430:25:11;;;1679:51:49;1652:18;;17430:25:11;1533:203:49;17377:293:11;17622:6;17616:13;17607:6;17603:2;17599:15;17592:38;17068:616;-1:-1:-1;;;;;;17190:51:11;;-1:-1:-1;;;17190:51:11;17186:130;;17272:25;;-1:-1:-1;;;17272:25:11;;-1:-1:-1;;;;;1697:32:49;;17272:25:11;;;1679:51:49;1652:18;;17272:25:11;1533:203:49;637:698:23;693:13;742:14;759:17;770:5;759:10;:17::i;:::-;779:1;759:21;742:38;;794:20;828:6;-1:-1:-1;;;;;817:18:23;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;817:18:23;-1:-1:-1;794:41:23;-1:-1:-1;955:28:23;;;971:2;955:28;1010:282;-1:-1:-1;;1041:5:23;-1:-1:-1;;;1175:2:23;1164:14;;1159:32;1041:5;1146:46;1236:2;1227:11;;;-1:-1:-1;1256:21:23;1010:282;1256:21;-1:-1:-1;1312:6:23;637:698;-1:-1:-1;;;637:698:23:o;9007:455:34:-;9097:11;:13;;;:11;:13;;;:::i;:::-;;;;;;9140:31;9146:11;9159;;9140:5;:31::i;:::-;9255:148;;;;;;;;9281:11;;9255:148;;;;9305:15;9255:148;;;;9356:15;:24;;;9338:15;:42;;;;:::i;:::-;9255:148;;;;9392:9;;9255:148;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;9255:148:34;;;;-1:-1:-1;;9240:11:34;;9221:31;;:18;:31;;;;;;;;;:182;;;;;;;;;;;;;;;;;;;;;;;;:31;;-1:-1:-1;9221:182:34;;;;;;;;:::i;:::-;-1:-1:-1;;9430:11:34;;9419:36;;;20428:25:49;;;-1:-1:-1;;;;;20489:32:49;;20484:2;20469:18;;20462:60;9419:36:34;;-1:-1:-1;20401:18:49;9419:36:34;20254:274:49;1303:160:10;1412:43;;;-1:-1:-1;;;;;13455:32:49;;1412:43:10;;;13437:51:49;13504:18;;;;13497:34;;;1412:43:10;;;;;;;;;;13410:18:49;;;;1412:43:10;;;;;;;;-1:-1:-1;;;;;1412:43:10;-1:-1:-1;;;1412:43:10;;;1385:71;;1405:5;;1385:19;:71::i;1561:300:11:-;1663:4;-1:-1:-1;;;;;;1698:40:11;;-1:-1:-1;;;1698:40:11;;:104;;-1:-1:-1;;;;;;;1754:48:11;;-1:-1:-1;;;1754:48:11;1698:104;:156;;;-1:-1:-1;;;;;;;;;;861:40:24;;;1818:36:11;762:146:24;14720:662:11;14880:9;:31;;;-1:-1:-1;;;;;;14893:18:11;;;;14880:31;14876:460;;;14927:13;14943:22;14957:7;14943:13;:22::i;:::-;14927:38;-1:-1:-1;;;;;;15093:18:11;;;;;;:35;;;15124:4;-1:-1:-1;;;;;15115:13:11;:5;-1:-1:-1;;;;;15115:13:11;;;15093:35;:69;;;;;15133:29;15150:5;15157:4;15133:16;:29::i;:::-;15132:30;15093:69;15089:142;;;15189:27;;-1:-1:-1;;;15189:27:11;;-1:-1:-1;;;;;1697:32:49;;15189:27:11;;;1679:51:49;1652:18;;15189:27:11;1533:203:49;15089:142:11;15249:9;15245:81;;;15303:7;15299:2;-1:-1:-1;;;;;15283:28:11;15292:5;-1:-1:-1;;;;;15283:28:11;;;;;;;;;;;15245:81;14913:423;14876:460;-1:-1:-1;;15346:24:11;;;;:15;:24;;;;;:29;;-1:-1:-1;;;;;;15346:29:11;-1:-1:-1;;;;;15346:29:11;;;;;;;;;;14720:662::o;11462:227::-;11513:21;11537:40;11553:1;11557:7;11574:1;11537:7;:40::i;:::-;11513:64;-1:-1:-1;;;;;;11591:27:11;;11587:96;;11641:31;;-1:-1:-1;;;11641:31:11;;;;;2324:25:49;;;2297:18;;11641:31:11;2178:177:49;2518:625:15;2613:7;2632:21;2656:32;2670:2;2674:7;2683:4;2656:13;:32::i;:::-;2632:56;-1:-1:-1;;;;;;2703:27:15;;2699:210;;2746:40;2778:7;3949:10;:17;;3922:24;;;;:15;:24;;;;;:44;;;3976:24;;;;;;;;;;;;3846:161;2746:40;2699:210;;;2824:2;-1:-1:-1;;;;;2807:19:15;:13;-1:-1:-1;;;;;2807:19:15;;2803:106;;2842:56;2875:13;2890:7;2842:32;:56::i;:::-;-1:-1:-1;;;;;2922:16:15;;2918:188;;2954:45;2991:7;2954:36;:45::i;:::-;2918:188;;;3037:2;-1:-1:-1;;;;;3020:19:15;:13;-1:-1:-1;;;;;3020:19:15;;3016:90;;3055:40;3083:2;3087:7;3055:27;:40::i;12214:916:26:-;12267:7;;-1:-1:-1;;;12342:17:26;;12338:103;;-1:-1:-1;;;12379:17:26;;;-1:-1:-1;12424:2:26;12414:12;12338:103;12467:8;12458:5;:17;12454:103;;12504:8;12495:17;;;-1:-1:-1;12540:2:26;12530:12;12454:103;12583:8;12574:5;:17;12570:103;;12620:8;12611:17;;;-1:-1:-1;12656:2:26;12646:12;12570:103;12699:7;12690:5;:16;12686:100;;12735:7;12726:16;;;-1:-1:-1;12770:1:26;12760:11;12686:100;12812:7;12803:5;:16;12799:100;;12848:7;12839:16;;;-1:-1:-1;12883:1:26;12873:11;12799:100;12925:7;12916:5;:16;12912:100;;12961:7;12952:16;;;-1:-1:-1;12996:1:26;12986:11;12912:100;13038:7;13029:5;:16;13025:66;;13075:1;13065:11;13117:6;12214:916;-1:-1:-1;;12214:916:26:o;9955:327:11:-;-1:-1:-1;;;;;10022:16:11;;10018:87;;10061:33;;-1:-1:-1;;;10061:33:11;;10091:1;10061:33;;;1679:51:49;1652:18;;10061:33:11;1533:203:49;10018:87:11;10114:21;10138:32;10146:2;10150:7;10167:1;10138:7;:32::i;:::-;10114:56;-1:-1:-1;;;;;;10184:27:11;;;10180:96;;10234:31;;-1:-1:-1;;;10234:31:11;;10262:1;10234:31;;;1679:51:49;1652:18;;10234:31:11;1533:203:49;4059:629:10;4478:23;4504:33;-1:-1:-1;;;;;4504:27:10;;4532:4;4504:27;:33::i;:::-;4478:59;;4551:10;:17;4572:1;4551:22;;:57;;;;;4589:10;4578:30;;;;;;;;;;;;:::i;:::-;4577:31;4551:57;4547:135;;;4631:40;;-1:-1:-1;;;4631:40:10;;-1:-1:-1;;;;;1697:32:49;;4631:40:10;;;1679:51:49;1652:18;;4631:40:10;1533:203:49;8838:795:11;8924:7;5799:16;;;:7;:16;;;;;;-1:-1:-1;;;;;5799:16:11;;;;9035:18;;;9031:86;;9069:37;9086:4;9092;9098:7;9069:16;:37::i;:::-;-1:-1:-1;;;;;9161:18:11;;;9157:256;;9277:48;9294:1;9298:7;9315:1;9319:5;9277:8;:48::i;:::-;-1:-1:-1;;;;;9368:15:11;;;;;;:9;:15;;;;;:20;;-1:-1:-1;;9368:20:11;;;9157:256;-1:-1:-1;;;;;9427:16:11;;;9423:107;;-1:-1:-1;;;;;9487:13:11;;;;;;:9;:13;;;;;:18;;9504:1;9487:18;;;9423:107;9540:16;;;;:7;:16;;;;;;:21;;-1:-1:-1;;;;;;9540:21:11;-1:-1:-1;;;;;9540:21:11;;;;;;;;;9577:27;;9540:16;;9577:27;;;;;;;9622:4;8838:795;-1:-1:-1;;;;8838:795:11:o;4624:959:15:-;4886:22;4911:15;4921:4;4911:9;:15::i;:::-;4936:18;4957:26;;;:17;:26;;;;;;4886:40;;-1:-1:-1;5087:28:15;;;5083:323;;-1:-1:-1;;;;;5153:18:15;;5131:19;5153:18;;;:12;:18;;;;;;;;:34;;;;;;;;;5202:30;;;;;;:44;;;5318:30;;:17;:30;;;;;:43;;;5083:323;-1:-1:-1;5499:26:15;;;;:17;:26;;;;;;;;5492:33;;;-1:-1:-1;;;;;5542:18:15;;;;;:12;:18;;;;;:34;;;;;;;5535:41;4624:959::o;5871:1061::-;6145:10;:17;6120:22;;6145:21;;6165:1;;6145:21;:::i;:::-;6176:18;6197:24;;;:15;:24;;;;;;6565:10;:26;;6120:46;;-1:-1:-1;6197:24:15;;6120:46;;6565:26;;;;;;:::i;:::-;;;;;;;;;6543:48;;6627:11;6602:10;6613;6602:22;;;;;;;;:::i;:::-;;;;;;;;;;;;:36;;;;6706:28;;;:15;:28;;;;;;;:41;;;6875:24;;;;;6868:31;6909:10;:16;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;5942:990;;;5871:1061;:::o;3437:214::-;3521:14;3554:1;3538:13;3548:2;3538:9;:13::i;:::-;:17;;;;:::i;:::-;-1:-1:-1;;;;;3565:16:15;;;;;;;:12;:16;;;;;;;;:24;;;;;;;;:34;;;3609:26;;;:17;:26;;;;;;:35;;;;-1:-1:-1;3437:214:15:o;2705:151:18:-;2780:12;2811:38;2833:6;2841:4;2847:1;2811:21;:38::i;7082:368:11:-;7194:38;7208:5;7215:7;7224;7194:13;:38::i;:::-;7189:255;;-1:-1:-1;;;;;7252:19:11;;7248:186;;7298:31;;-1:-1:-1;;;7298:31:11;;;;;2324:25:49;;;2297:18;;7298:31:11;2178:177:49;7248:186:11;7375:44;;-1:-1:-1;;;7375:44:11;;-1:-1:-1;;;;;13455:32:49;;7375:44:11;;;13437:51:49;13504:18;;;13497:34;;;13410:18;;7375:44:11;13263:274:49;3180:392:18;3279:12;3331:5;3307:21;:29;3303:108;;;3359:41;;-1:-1:-1;;;3359:41:18;;3394:4;3359:41;;;1679:51:49;1652:18;;3359:41:18;1533:203:49;3303:108:18;3421:12;3435:23;3462:6;-1:-1:-1;;;;;3462:11:18;3481:5;3488:4;3462:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3420:73;;;;3510:55;3537:6;3545:7;3554:10;3510:26;:55::i;:::-;3503:62;3180:392;-1:-1:-1;;;;;;3180:392:18:o;6376:272:11:-;6479:4;-1:-1:-1;;;;;6514:21:11;;;;;;:127;;;6561:7;-1:-1:-1;;;;;6552:16:11;:5;-1:-1:-1;;;;;6552:16:11;;:52;;;;6572:32;6589:5;6596:7;6572:16;:32::i;:::-;6552:88;;;-1:-1:-1;;6008:7:11;6034:24;;;:15;:24;;;;;;-1:-1:-1;;;;;6034:24:11;;;6608:32;;;;;-1:-1:-1;6376:272:11:o;4625:582:18:-;4769:12;4798:7;4793:408;;4821:19;4829:10;4821:7;:19::i;:::-;4793:408;;;5045:17;;:22;:49;;;;-1:-1:-1;;;;;;5071:18:18;;;:23;5045:49;5041:119;;;5121:24;;-1:-1:-1;;;5121:24:18;;-1:-1:-1;;;;;1697:32:49;;5121:24:18;;;1679:51:49;1652:18;;5121:24:18;1533:203:49;5041:119:18;-1:-1:-1;5180:10:18;5173:17;;5743:516;5874:17;;:21;5870:383;;6102:10;6096:17;6158:15;6145:10;6141:2;6137:19;6130:44;5870:383;6225:17;;-1:-1:-1;;;6225:17:18;;;;;;;;;;;14:131:49;-1:-1:-1;;;;;;88:32:49;;78:43;;68:71;;135:1;132;125:12;150:245;208:6;261:2;249:9;240:7;236:23;232:32;229:52;;;277:1;274;267:12;229:52;316:9;303:23;335:30;359:5;335:30;:::i;592:180::-;651:6;704:2;692:9;683:7;679:23;675:32;672:52;;;720:1;717;710:12;672:52;-1:-1:-1;743:23:49;;592:180;-1:-1:-1;592:180:49:o;777:250::-;862:1;872:113;886:6;883:1;880:13;872:113;;;962:11;;;956:18;943:11;;;936:39;908:2;901:10;872:113;;;-1:-1:-1;;1019:1:49;1001:16;;994:27;777:250::o;1032:271::-;1074:3;1112:5;1106:12;1139:6;1134:3;1127:19;1155:76;1224:6;1217:4;1212:3;1208:14;1201:4;1194:5;1190:16;1155:76;:::i;:::-;1285:2;1264:15;-1:-1:-1;;1260:29:49;1251:39;;;;1292:4;1247:50;;1032:271;-1:-1:-1;;1032:271:49:o;1308:220::-;1457:2;1446:9;1439:21;1420:4;1477:45;1518:2;1507:9;1503:18;1495:6;1477:45;:::i;1741:173::-;1809:20;;-1:-1:-1;;;;;1858:31:49;;1848:42;;1838:70;;1904:1;1901;1894:12;1919:254;1987:6;1995;2048:2;2036:9;2027:7;2023:23;2019:32;2016:52;;;2064:1;2061;2054:12;2016:52;2087:29;2106:9;2087:29;:::i;:::-;2077:39;2163:2;2148:18;;;;2135:32;;-1:-1:-1;;;1919:254:49:o;2360:127::-;2421:10;2416:3;2412:20;2409:1;2402:31;2452:4;2449:1;2442:15;2476:4;2473:1;2466:15;2492:275;2563:2;2557:9;2628:2;2609:13;;-1:-1:-1;;2605:27:49;2593:40;;-1:-1:-1;;;;;2648:34:49;;2684:22;;;2645:62;2642:88;;;2710:18;;:::i;:::-;2746:2;2739:22;2492:275;;-1:-1:-1;2492:275:49:o;2772:712::-;2826:5;2879:3;2872:4;2864:6;2860:17;2856:27;2846:55;;2897:1;2894;2887:12;2846:55;2933:6;2920:20;2959:4;-1:-1:-1;;;;;2978:2:49;2975:26;2972:52;;;3004:18;;:::i;:::-;3050:2;3047:1;3043:10;3073:28;3097:2;3093;3089:11;3073:28;:::i;:::-;3135:15;;;3205;;;3201:24;;;3166:12;;;;3237:15;;;3234:35;;;3265:1;3262;3255:12;3234:35;3301:2;3293:6;3289:15;3278:26;;3313:142;3329:6;3324:3;3321:15;3313:142;;;3395:17;;3383:30;;3346:12;;;;3433;;;;3313:142;;;3473:5;2772:712;-1:-1:-1;;;;;;;2772:712:49:o;3489:348::-;3573:6;3626:2;3614:9;3605:7;3601:23;3597:32;3594:52;;;3642:1;3639;3632:12;3594:52;3682:9;3669:23;-1:-1:-1;;;;;3707:6:49;3704:30;3701:50;;;3747:1;3744;3737:12;3701:50;3770:61;3823:7;3814:6;3803:9;3799:22;3770:61;:::i;3842:328::-;3919:6;3927;3935;3988:2;3976:9;3967:7;3963:23;3959:32;3956:52;;;4004:1;4001;3994:12;3956:52;4027:29;4046:9;4027:29;:::i;:::-;4017:39;;4075:38;4109:2;4098:9;4094:18;4075:38;:::i;:::-;4065:48;;4160:2;4149:9;4145:18;4132:32;4122:42;;3842:328;;;;;:::o;4175:118::-;4261:5;4254:13;4247:21;4240:5;4237:32;4227:60;;4283:1;4280;4273:12;4298:241;4354:6;4407:2;4395:9;4386:7;4382:23;4378:32;4375:52;;;4423:1;4420;4413:12;4375:52;4462:9;4449:23;4481:28;4503:5;4481:28;:::i;4544:348::-;4596:8;4606:6;4660:3;4653:4;4645:6;4641:17;4637:27;4627:55;;4678:1;4675;4668:12;4627:55;-1:-1:-1;4701:20:49;;-1:-1:-1;;;;;4733:30:49;;4730:50;;;4776:1;4773;4766:12;4730:50;4813:4;4805:6;4801:17;4789:29;;4865:3;4858:4;4849:6;4841;4837:19;4833:30;4830:39;4827:59;;;4882:1;4879;4872:12;4827:59;4544:348;;;;;:::o;4897:479::-;4977:6;4985;4993;5046:2;5034:9;5025:7;5021:23;5017:32;5014:52;;;5062:1;5059;5052:12;5014:52;5098:9;5085:23;5075:33;;5159:2;5148:9;5144:18;5131:32;-1:-1:-1;;;;;5178:6:49;5175:30;5172:50;;;5218:1;5215;5208:12;5172:50;5257:59;5308:7;5299:6;5288:9;5284:22;5257:59;:::i;:::-;4897:479;;5335:8;;-1:-1:-1;5231:85:49;;-1:-1:-1;;;;4897:479:49:o;5617:186::-;5676:6;5729:2;5717:9;5708:7;5704:23;5700:32;5697:52;;;5745:1;5742;5735:12;5697:52;5768:29;5787:9;5768:29;:::i;5808:411::-;5879:6;5887;5940:2;5928:9;5919:7;5915:23;5911:32;5908:52;;;5956:1;5953;5946:12;5908:52;5996:9;5983:23;-1:-1:-1;;;;;6021:6:49;6018:30;6015:50;;;6061:1;6058;6051:12;6015:50;6100:59;6151:7;6142:6;6131:9;6127:22;6100:59;:::i;:::-;6178:8;;6074:85;;-1:-1:-1;5808:411:49;-1:-1:-1;;;;5808:411:49:o;6224:595::-;6342:6;6350;6403:2;6391:9;6382:7;6378:23;6374:32;6371:52;;;6419:1;6416;6409:12;6371:52;6459:9;6446:23;-1:-1:-1;;;;;6529:2:49;6521:6;6518:14;6515:34;;;6545:1;6542;6535:12;6515:34;6568:61;6621:7;6612:6;6601:9;6597:22;6568:61;:::i;:::-;6558:71;;6682:2;6671:9;6667:18;6654:32;6638:48;;6711:2;6701:8;6698:16;6695:36;;;6727:1;6724;6717:12;6695:36;;6750:63;6805:7;6794:8;6783:9;6779:24;6750:63;:::i;:::-;6740:73;;;6224:595;;;;;:::o;6824:315::-;6889:6;6897;6950:2;6938:9;6929:7;6925:23;6921:32;6918:52;;;6966:1;6963;6956:12;6918:52;6989:29;7008:9;6989:29;:::i;:::-;6979:39;;7068:2;7057:9;7053:18;7040:32;7081:28;7103:5;7081:28;:::i;:::-;7128:5;7118:15;;;6824:315;;;;;:::o;7144:186::-;7192:4;-1:-1:-1;;;;;7217:6:49;7214:30;7211:56;;;7247:18;;:::i;:::-;-1:-1:-1;7313:2:49;7292:15;-1:-1:-1;;7288:29:49;7319:4;7284:40;;7144:186::o;7335:888::-;7430:6;7438;7446;7454;7507:3;7495:9;7486:7;7482:23;7478:33;7475:53;;;7524:1;7521;7514:12;7475:53;7547:29;7566:9;7547:29;:::i;:::-;7537:39;;7595:38;7629:2;7618:9;7614:18;7595:38;:::i;:::-;7585:48;;7680:2;7669:9;7665:18;7652:32;7642:42;;7735:2;7724:9;7720:18;7707:32;-1:-1:-1;;;;;7754:6:49;7751:30;7748:50;;;7794:1;7791;7784:12;7748:50;7817:22;;7870:4;7862:13;;7858:27;-1:-1:-1;7848:55:49;;7899:1;7896;7889:12;7848:55;7935:2;7922:16;7960:48;7976:31;8004:2;7976:31;:::i;:::-;7960:48;:::i;:::-;8031:2;8024:5;8017:17;8071:7;8066:2;8061;8057;8053:11;8049:20;8046:33;8043:53;;;8092:1;8089;8082:12;8043:53;8147:2;8142;8138;8134:11;8129:2;8122:5;8118:14;8105:45;8191:1;8186:2;8181;8174:5;8170:14;8166:23;8159:34;8212:5;8202:15;;;;;7335:888;;;;;;;:::o;8228:606::-;8423:2;8405:21;;;8466:13;;-1:-1:-1;;;;;8462:39:49;8442:18;;;8435:67;8537:15;;8531:22;8589:4;8584:2;8569:18;;8562:32;-1:-1:-1;;8617:52:49;8489:3;8649:19;;8531:22;8617:52;:::i;:::-;8603:66;;8723:2;8715:6;8711:15;8705:22;8700:2;8689:9;8685:18;8678:50;8798:2;8790:6;8786:15;8780:22;8773:30;8766:38;8759:4;8748:9;8744:20;8737:68;8822:6;8814:14;;;8228:606;;;;:::o;8839:260::-;8907:6;8915;8968:2;8956:9;8947:7;8943:23;8939:32;8936:52;;;8984:1;8981;8974:12;8936:52;9007:29;9026:9;9007:29;:::i;:::-;8997:39;;9055:38;9089:2;9078:9;9074:18;9055:38;:::i;:::-;9045:48;;8839:260;;;;;:::o;9104:537::-;9301:2;9290:9;9283:21;9346:6;9340:13;9335:2;9324:9;9320:18;9313:41;9408:2;9400:6;9396:15;9390:22;9385:2;9374:9;9370:18;9363:50;9467:2;9459:6;9455:15;9449:22;9444:2;9433:9;9429:18;9422:50;9264:4;9519:2;9511:6;9507:15;9501:22;9561:4;9554;9543:9;9539:20;9532:34;9583:52;9630:3;9619:9;9615:19;9601:12;9583:52;:::i;9646:367::-;9709:8;9719:6;9773:3;9766:4;9758:6;9754:17;9750:27;9740:55;;9791:1;9788;9781:12;9740:55;-1:-1:-1;9814:20:49;;-1:-1:-1;;;;;9846:30:49;;9843:50;;;9889:1;9886;9879:12;9843:50;9926:4;9918:6;9914:17;9902:29;;9986:3;9979:4;9969:6;9966:1;9962:14;9954:6;9950:27;9946:38;9943:47;9940:67;;;10003:1;10000;9993:12;10018:785;10152:6;10160;10168;10176;10229:2;10217:9;10208:7;10204:23;10200:32;10197:52;;;10245:1;10242;10235:12;10197:52;10285:9;10272:23;-1:-1:-1;;;;;10355:2:49;10347:6;10344:14;10341:34;;;10371:1;10368;10361:12;10341:34;10410:70;10472:7;10463:6;10452:9;10448:22;10410:70;:::i;:::-;10499:8;;-1:-1:-1;10384:96:49;-1:-1:-1;10587:2:49;10572:18;;10559:32;;-1:-1:-1;10603:16:49;;;10600:36;;;10632:1;10629;10622:12;10600:36;;10671:72;10735:7;10724:8;10713:9;10709:24;10671:72;:::i;:::-;10018:785;;;;-1:-1:-1;10762:8:49;-1:-1:-1;;;;10018:785:49:o;10808:248::-;10876:6;10884;10937:2;10925:9;10916:7;10912:23;10908:32;10905:52;;;10953:1;10950;10943:12;10905:52;-1:-1:-1;;10976:23:49;;;11046:2;11031:18;;;11018:32;;-1:-1:-1;10808:248:49:o;11061:485::-;11141:6;11149;11157;11210:2;11198:9;11189:7;11185:23;11181:32;11178:52;;;11226:1;11223;11216:12;11178:52;11249:29;11268:9;11249:29;:::i;:::-;11239:39;;11329:2;11318:9;11314:18;11301:32;-1:-1:-1;;;;;11348:6:49;11345:30;11342:50;;;11388:1;11385;11378:12;11551:380;11630:1;11626:12;;;;11673;;;11694:61;;11748:4;11740:6;11736:17;11726:27;;11694:61;11801:2;11793:6;11790:14;11770:18;11767:38;11764:161;;11847:10;11842:3;11838:20;11835:1;11828:31;11882:4;11879:1;11872:15;11910:4;11907:1;11900:15;11936:127;11997:10;11992:3;11988:20;11985:1;11978:31;12028:4;12025:1;12018:15;12052:4;12049:1;12042:15;12068:127;12129:10;12124:3;12120:20;12117:1;12110:31;12160:4;12157:1;12150:15;12184:4;12181:1;12174:15;12200:197;12238:3;12266:6;12307:2;12300:5;12296:14;12334:2;12325:7;12322:15;12319:41;;12340:18;;:::i;:::-;12389:1;12376:15;;12200:197;-1:-1:-1;;;12200:197:49:o;12782:346::-;12984:2;12966:21;;;13023:2;13003:18;;;12996:30;-1:-1:-1;;;13057:2:49;13042:18;;13035:52;13119:2;13104:18;;12782:346::o;13133:125::-;13198:9;;;13219:10;;;13216:36;;;13232:18;;:::i;13542:355::-;13744:2;13726:21;;;13783:2;13763:18;;;13756:30;13822:33;13817:2;13802:18;;13795:61;13888:2;13873:18;;13542:355::o;14028:518::-;14130:2;14125:3;14122:11;14119:421;;;14166:5;14163:1;14156:16;14210:4;14207:1;14197:18;14280:2;14268:10;14264:19;14261:1;14257:27;14251:4;14247:38;14316:4;14304:10;14301:20;14298:47;;;-1:-1:-1;14339:4:49;14298:47;14394:2;14389:3;14385:12;14382:1;14378:20;14372:4;14368:31;14358:41;;14449:81;14467:2;14460:5;14457:13;14449:81;;;14526:1;14512:16;;14493:1;14482:13;14449:81;;14722:1198;-1:-1:-1;;;;;14841:3:49;14838:27;14835:53;;;14868:18;;:::i;:::-;14897:94;14987:3;14947:38;14979:4;14973:11;14947:38;:::i;:::-;14941:4;14897:94;:::i;:::-;15017:1;15042:2;15037:3;15034:11;15059:1;15054:608;;;;15706:1;15723:3;15720:93;;;-1:-1:-1;15779:19:49;;;15766:33;15720:93;-1:-1:-1;;14679:1:49;14675:11;;;14671:24;14667:29;14657:40;14703:1;14699:11;;;14654:57;15826:78;;15027:887;;15054:608;13975:1;13968:14;;;14012:4;13999:18;;-1:-1:-1;;15090:17:49;;;15205:229;15219:7;15216:1;15213:14;15205:229;;;15308:19;;;15295:33;15280:49;;15415:4;15400:20;;;;15368:1;15356:14;;;;15235:12;15205:229;;;15209:3;15462;15453:7;15450:16;15447:159;;;15586:1;15582:6;15576:3;15570;15567:1;15563:11;15559:21;15555:34;15551:39;15538:9;15533:3;15529:19;15516:33;15512:79;15504:6;15497:95;15447:159;;;15649:1;15643:3;15640:1;15636:11;15632:19;15626:4;15619:33;15027:887;;14722:1198;;;:::o;15925:136::-;15964:3;15992:5;15982:39;;16001:18;;:::i;:::-;-1:-1:-1;;;16037:18:49;;15925:136::o;16472:128::-;16539:9;;;16560:11;;;16557:37;;;16574:18;;:::i;16737:217::-;16777:1;16803;16793:132;;16847:10;16842:3;16838:20;16835:1;16828:31;16882:4;16879:1;16872:15;16910:4;16907:1;16900:15;16793:132;-1:-1:-1;16939:9:49;;16737:217::o;16959:928::-;17206:2;17195:9;17188:21;17169:4;17232:45;17273:2;17262:9;17258:18;17250:6;17232:45;:::i;:::-;17296:2;17346:9;17338:6;17334:22;17329:2;17318:9;17314:18;17307:50;17377:6;17412;17406:13;17443:6;17435;17428:22;17478:2;17470:6;17466:15;17459:22;;17537:2;17527:6;17524:1;17520:14;17512:6;17508:27;17504:36;17575:2;17567:6;17563:15;17596:1;17606:252;17620:6;17617:1;17614:13;17606:252;;;17710:2;17706:7;17697:6;17689;17685:19;17681:33;17676:3;17669:46;17738:40;17771:6;17762;17756:13;17738:40;:::i;:::-;17836:12;;;;17728:50;-1:-1:-1;17801:15:49;;;;17642:1;17635:9;17606:252;;;-1:-1:-1;17875:6:49;;16959:928;-1:-1:-1;;;;;;;;;16959:928:49:o;17892:648::-;17972:6;18025:2;18013:9;18004:7;18000:23;17996:32;17993:52;;;18041:1;18038;18031:12;17993:52;18074:9;18068:16;-1:-1:-1;;;;;18099:6:49;18096:30;18093:50;;;18139:1;18136;18129:12;18093:50;18162:22;;18215:4;18207:13;;18203:27;-1:-1:-1;18193:55:49;;18244:1;18241;18234:12;18193:55;18273:2;18267:9;18298:48;18314:31;18342:2;18314:31;:::i;18298:48::-;18369:2;18362:5;18355:17;18409:7;18404:2;18399;18395;18391:11;18387:20;18384:33;18381:53;;;18430:1;18427;18420:12;18381:53;18443:67;18507:2;18502;18495:5;18491:14;18486:2;18482;18478:11;18443:67;:::i;:::-;18529:5;17892:648;-1:-1:-1;;;;;17892:648:49:o;18900:522::-;18978:4;18984:6;19044:11;19031:25;19138:2;19134:7;19123:8;19107:14;19103:29;19099:43;19079:18;19075:68;19065:96;;19157:1;19154;19147:12;19065:96;19184:33;;19236:20;;;-1:-1:-1;;;;;;19268:30:49;;19265:50;;;19311:1;19308;19301:12;19265:50;19344:4;19332:17;;-1:-1:-1;19375:14:49;19371:27;;;19361:38;;19358:58;;;19412:1;19409;19402:12;20883:489;-1:-1:-1;;;;;21152:15:49;;;21134:34;;21204:15;;21199:2;21184:18;;21177:43;21251:2;21236:18;;21229:34;;;21299:3;21294:2;21279:18;;21272:31;;;21077:4;;21320:46;;21346:19;;21338:6;21320:46;:::i;21377:249::-;21446:6;21499:2;21487:9;21478:7;21474:23;21470:32;21467:52;;;21515:1;21512;21505:12;21467:52;21547:9;21541:16;21566:30;21590:5;21566:30;:::i;21631:135::-;21670:3;21691:17;;;21688:43;;21711:18;;:::i;:::-;-1:-1:-1;21758:1:49;21747:13;;21631:135::o;21771:1345::-;21897:3;21891:10;-1:-1:-1;;;;;21916:6:49;21913:30;21910:56;;;21946:18;;:::i;:::-;21975:97;22065:6;22025:38;22057:4;22051:11;22025:38;:::i;:::-;22019:4;21975:97;:::i;:::-;22127:4;;22184:2;22173:14;;22201:1;22196:663;;;;22903:1;22920:6;22917:89;;;-1:-1:-1;22972:19:49;;;22966:26;22917:89;-1:-1:-1;;14679:1:49;14675:11;;;14671:24;14667:29;14657:40;14703:1;14699:11;;;14654:57;23019:81;;22166:944;;22196:663;13975:1;13968:14;;;14012:4;13999:18;;-1:-1:-1;;22232:20:49;;;22350:236;22364:7;22361:1;22358:14;22350:236;;;22453:19;;;22447:26;22432:42;;22545:27;;;;22513:1;22501:14;;;;22380:19;;22350:236;;;22354:3;22614:6;22605:7;22602:19;22599:201;;;22675:19;;;22669:26;-1:-1:-1;;22758:1:49;22754:14;;;22770:3;22750:24;22746:37;22742:42;22727:58;22712:74;;22599:201;;;22846:1;22837:6;22834:1;22830:14;22826:22;22820:4;22813:36;22166:944;;;;;21771:1345;;:::o;23121:245::-;23188:6;23241:2;23229:9;23220:7;23216:23;23212:32;23209:52;;;23257:1;23254;23247:12;23209:52;23289:9;23283:16;23308:28;23330:5;23308:28;:::i;23371:127::-;23432:10;23427:3;23423:20;23420:1;23413:31;23463:4;23460:1;23453:15;23487:4;23484:1;23477:15;23503:287;23632:3;23670:6;23664:13;23686:66;23745:6;23740:3;23733:4;23725:6;23721:17;23686:66;:::i;:::-;23768:16;;;;;23503:287;-1:-1:-1;;23503:287:49:o

Swarm Source

ipfs://a69b4b3d2b52b8913410a0d59aaac8a917ccaa4f83b207ca9d18be0f3119834a
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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