Address Details
contract

0xFc5aF63F4B0247423A5aA4c0B755bC7991234190

Contract Name
Collectionswap
Creator
0x8626f6–9c1199 at 0x7e38f6–681af8
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
8 Transactions
Transfers
5 Transfers
Gas Used
1,416,911
Last Balance Update
14820342
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Collectionswap




Optimization enabled
true
Compiler version
v0.8.17+commit.8df45f5f




Optimization runs
200
EVM Version
london




Verified at
2023-01-31T02:18:27.160815Z

contracts/Collectionswap.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {ICollectionswap} from "./ICollectionswap.sol";
import {ILSSVMPair, ILSSVMPairETH} from "./ILSSVMPair.sol";
import {ILSSVMPairFactory} from "./ILSSVMPairFactory.sol";
import {ICurve} from "./ICurve.sol";
import {OwnableWithTransferCallback} from "./OwnableWithTransferCallback.sol";

import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {ERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import {ERC721URIStorage} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {FixedPointMathLib} from "./FixedPointMathLib.sol";
import {ReentrancyGuard} from './ReentrancyGuard.sol';
import {ERC1155Receiver, ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";

contract Collectionswap is OwnableWithTransferCallback, ERC1155Holder, ERC721, ERC721Enumerable, ERC721URIStorage, ICollectionswap, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using FixedPointMathLib for uint256;
    ILSSVMPairFactory public immutable _factory;
    ILSSVMPair.PoolType immutable _poolType;

    mapping(address =>bool) private _mapPoolsToIsLiveForAnyNFT;

    /// @dev mapping of token IDs to pools
    mapping(uint256 => LPTokenParams721ETH) private _mapNFTIDToPool;

    /// @dev The ID of the next token that will be minted. Skips 0
    uint256 private _nextTokenId;

    event NewPair(address poolAddress); // @dev: Used for tests
    event NewTokenId(uint256 tokenId);
    event ERC20Rescued();
    event ERC721Rescued();
    event ERC1155Rescued();

    constructor (
        address payable lssvmPairFactoryAddress
    ) ERC721('Collectionswap','CollectSudo LP') {
        __Ownable_init(msg.sender);
        __ReentrancyGuard_init();
        _factory = ILSSVMPairFactory(lssvmPairFactoryAddress);
        _poolType = ILSSVMPair.PoolType.TRADE;
    }

    function transferOwnershipNFTList(
        ILSSVMPairFactory factory,
        address oldOwner,
        address newOwner,
        IERC721 _nft,
        uint256[] memory nftList
    ) private {
        
        for (uint256 i; i<nftList.length; ) {
            _nft.safeTransferFrom(
                oldOwner,
                newOwner,
                nftList[i]
            );
            // only approve if NFT is transferred into contract for pair creation
            // approval will fail otherwise
            if (newOwner == address(this))
                _nft.approve(address(factory), nftList[i]);
            unchecked {
                ++i;
            }
        }
    }

    function getMeasurableContribution(
        uint256 tokenId
        ) external view 
        returns (uint256 contribution) {
            LPTokenParams721ETH memory lpTokenParams = _mapNFTIDToPool[tokenId];
            uint256 initialPoolBalance = lpTokenParams.initialPoolBalance;
            uint256 initialNFTIDsLength = lpTokenParams.initialNFTIDsLength;
            contribution = uint256(initialPoolBalance * initialNFTIDsLength).sqrt();
    }

    function refreshPoolParameters(
        uint256 tokenId
    ) external {
        LPTokenParams721ETH memory lpTokenParams = _mapNFTIDToPool[tokenId];
        address payable poolAddress = lpTokenParams.poolAddress;
        require(isApprovedToOperateOnPool(msg.sender, tokenId),"unapproved caller");
        ILSSVMPairETH mypair = ILSSVMPairETH(poolAddress);
        uint256[] memory currentIds = mypair.getAllHeldIds();
        LPTokenParams721ETH memory lpTokenParams2 = LPTokenParams721ETH(
            lpTokenParams.nftAddress,
            lpTokenParams.bondingCurveAddress,
            lpTokenParams.poolAddress,
            mypair.fee(),
            mypair.delta(),
            mypair.spotPrice(),
            address(mypair).balance,
            currentIds.length
        );
        _mapNFTIDToPool[tokenId] = lpTokenParams2;
    }

    function getAllHeldIds(
        uint256 tokenId
    ) external view returns (uint256[] memory currentIds) {
        address payable poolAddress = _mapNFTIDToPool[tokenId].poolAddress;
        ILSSVMPairETH mypair = ILSSVMPairETH(poolAddress);
        currentIds = mypair.getAllHeldIds();
    }

    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) external pure returns (bytes4) {
        return IERC721Receiver.onERC721Received.selector;
    }

    function issueLPToken(
        address receiver,
        LPTokenParams721ETH memory lpTokenParams
    ) private {
        // prefix increment returns value after increment
        uint256 tokenId = ++_nextTokenId;
        _mapNFTIDToPool[tokenId] = lpTokenParams;
        // string memory uri = string(abi.encodePacked('{"pool":"', Strings.toHexString(lpTokenParams.poolAddress), '"}'));
        _mapPoolsToIsLiveForAnyNFT[lpTokenParams.poolAddress] = true;
        emit NewTokenId(tokenId);
        safeMint(receiver, tokenId);
    }

    function useLPTokenToDestroyDirectPairETH(
        uint256 tokenId
    ) external nonReentrant {
        LPTokenParams721ETH memory lpTokenParams = _mapNFTIDToPool[tokenId];
        ERC721 _nft = ERC721(lpTokenParams.nftAddress);
        destroyDirectPairETH(
            tokenId,
            _nft
        );
        // breaks CEI pattern, but has to be done after destruction to return correct msg
        _mapPoolsToIsLiveForAnyNFT[lpTokenParams.poolAddress] = false;
        burn(tokenId);
    }

    function validatePoolParamsLte(
        uint256 tokenId,
        address nftAddress,
        address bondingCurveAddress,
        uint96 fee,
        uint128 delta
    ) public view returns (bool) {    
        LPTokenParams721ETH memory poolParams = viewPoolParams(tokenId);
        return (
            poolParams.nftAddress == nftAddress &&
            poolParams.bondingCurveAddress == bondingCurveAddress &&
            poolParams.fee <= fee &&
            poolParams.delta <= delta
        );
    }

    function validatePoolParamsEq(
        uint256 tokenId,
        address nftAddress,
        address bondingCurveAddress,
        uint96 fee,
        uint128 delta
    ) public view returns (bool) {    
        LPTokenParams721ETH memory poolParams = viewPoolParams(tokenId);
        return (
            poolParams.nftAddress == nftAddress &&
            poolParams.bondingCurveAddress == bondingCurveAddress &&
            poolParams.fee == fee &&
            poolParams.delta == delta
        );
    }

    function viewPoolParams(
        uint256 tokenId
    ) public view returns (LPTokenParams721ETH memory poolParams) {
        poolParams = _mapNFTIDToPool[tokenId];
        require(isPoolAlive(poolParams.poolAddress), 'pool must be alive');
        return poolParams;
    }

    function createDirectPairETH(
        IERC721 _nft,
        ICurve _bondingCurve,
        uint128 _delta,
        uint96 _fee,
        uint128 _spotPrice,
        uint256[] calldata _initialNFTIDs
    ) external payable nonReentrant returns (ILSSVMPairETH newPair) {
        ILSSVMPairFactory factory = _factory;
        transferOwnershipNFTList(
            factory,
            msg.sender,
            address(this),
            _nft,
            _initialNFTIDs
            );

        newPair = factory.createPairETH{value:msg.value}(
            _nft,
            _bondingCurve,
            payable(0), // assetRecipient
            _poolType,
            _delta,
            _fee,
            _spotPrice,
            _initialNFTIDs
        );

        LPTokenParams721ETH memory poolParamsStruct = LPTokenParams721ETH(
            address(_nft),
            address(_bondingCurve),
            payable(address(newPair)),
            _fee,
            _delta,
            _spotPrice,
            msg.value,
            _initialNFTIDs.length
        );

        issueLPToken(
            msg.sender,
            poolParamsStruct
        );
    }

    function isApprovedToOperateOnPool(address _owner, uint256 tokenId) public view virtual returns (bool) {
        if (_exists(tokenId)) {
            return ownerOf(tokenId) == _owner;
        } else {
            return false;
        }   
    }    


    function isPoolAlive(address _pool) public view returns (bool) {
        return _mapPoolsToIsLiveForAnyNFT[_pool];
    }

    function destroyDirectPairETH(
        uint256 tokenId,
        IERC721 _nft
    ) private {
        string memory errmsg = "only token owner can destroy pool";
        address payable _pool = _mapNFTIDToPool[tokenId].poolAddress;
        if (!_mapPoolsToIsLiveForAnyNFT[_pool]) {
            errmsg = "pool already destroyed";
        }

        require(isApprovedToOperateOnPool(msg.sender, tokenId), errmsg);

        uint256[] memory currentIds = this.getAllHeldIds(tokenId);

        ILSSVMPairETH mypair = ILSSVMPairETH(_pool);
        mypair.withdrawERC721(_nft,currentIds);
        
        uint256 prevBalance = address(this).balance;
        mypair.withdrawAllETH();
        uint256 currBalance = address(this).balance; // check there's no global state here for getting address balance
        uint256 diffBalance = currBalance - prevBalance;

        transferOwnershipNFTList(
            _factory,
            address(this),
            msg.sender,
            _nft,
            currentIds
            );
        (bool sent,) = payable(msg.sender).call{value: diffBalance}("");
        require(sent, "Failed to send Ether");
    }

    receive() external payable {}

    /////////////////////////////////////////////////
    // Rescue Functions
    /////////////////////////////////////////////////
    /**
        @notice Rescues ERC20 tokens. Only callable by the owner if rescuing from this contract, else can be called by tokenId owner.
        @notice Since pools created cannot be paired with ERC20 tokens, there is no validation on the ERC20 token 
        @param a The token to transfer
        @param amount The amount of tokens to send to the owner
        @param tokenId 0 = rescue from this contract, non-zero = rescue from specified pool
     */
    function rescueERC20(IERC20 a, uint256 amount, uint256 tokenId) external {
        if (tokenId == 0) {
            require(msg.sender == owner(), "not owner");
        } else {
            ILSSVMPairETH _pool = ILSSVMPairETH(_mapNFTIDToPool[tokenId].poolAddress);
            require(isApprovedToOperateOnPool(msg.sender, tokenId), "unapproved caller");
            _pool.withdrawERC20(a, amount); // withdrawn to this contract
        }
        a.safeTransfer(msg.sender, amount);
        emit ERC20Rescued();
    }

    /**
        @notice Rescues ERC721 tokens. Only callable by the owner if rescuing from this contract, else can be called by tokenId owner.
        @param a The NFT to rescue
        @param nftIds NFT IDs to rescue
        @param tokenId 0 = rescue from this contract, non-zero = rescue from specified pool (cannot touch users' NFTs)
     */
    function rescueERC721(
        IERC721 a,
        uint256[] calldata nftIds,
        uint256 tokenId
    ) external {
        // 0 tokenId = pull from this contract directly
        if (tokenId == 0) {
            require(msg.sender == owner(), "not owner");
        } else {
            LPTokenParams721ETH memory lpTokenParams = _mapNFTIDToPool[tokenId];
            ILSSVMPairETH _pool = ILSSVMPairETH(lpTokenParams.poolAddress);
            require(isApprovedToOperateOnPool(msg.sender, tokenId), "unapproved caller");
            require(address(a) != lpTokenParams.nftAddress, "call useLPTokenToDestroyDirectPairETH()");
            _pool.withdrawERC721(a, nftIds); // withdrawn to this contract
        }
        uint256 numNFTs = nftIds.length;
        for (uint256 i; i < numNFTs; ) {
            a.safeTransferFrom(address(this), msg.sender, nftIds[i]);
            unchecked {
                ++i;
            }
        }
        emit ERC721Rescued();
    }

    /**
        @notice Rescues ERC1155 tokens. Only callable by the owner if rescuing from this contract, else can be called by tokenId owner.
        @notice There are some cases where an NFT is both ERC721 and ERC1155, so we have to ensure that the users' NFTs arent touched
        @param a The NFT to transfer
        @param ids The NFT ids to transfer
        @param amounts The amounts of each id to transfer
        @param tokenId 0 = rescue from this contract, non-zero = rescue from specified pool (cannot touch users' NFTs)
     */
    function rescueERC1155(
        IERC1155 a,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        uint256 tokenId
    ) external {
        if (tokenId == 0) {
            require(msg.sender == owner(), "not owner");
        } else {
            LPTokenParams721ETH memory lpTokenParams = _mapNFTIDToPool[tokenId];
            ILSSVMPairETH _pool = ILSSVMPairETH(lpTokenParams.poolAddress);
            require(isApprovedToOperateOnPool(msg.sender, tokenId), "unapproved caller");
            require(address(a) != lpTokenParams.nftAddress, "call useLPTokenToDestroyDirectPairETH()");
            _pool.withdrawERC1155(a, ids, amounts); // withdrawn to this contract
        }
        a.safeBatchTransferFrom(address(this), msg.sender, ids, amounts, "");
        emit ERC1155Rescued();
    }

    /////////////////////////////////////////////////
    // ERC 721
    /////////////////////////////////////////////////

    function safeMint(address to, uint256 tokenId)
        private
    {
        _safeMint(to, tokenId);
        // _setTokenURI(tokenId, '');
    }

    function burn(uint256 tokenId)
        private
        // onlyOwner
    {
        _burn(tokenId);
    }

    // overrides required by Solidiity for ERC721 contract
    // The following functions are overrides required by Solidity.

    function _beforeTokenTransfer(address from, address to, uint256 tokenId)
        internal
        override(ERC721, ERC721Enumerable)
    {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
        super._burn(tokenId);
    }

    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }

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

/_openzeppelin/contracts/interfaces/IERC165.sol

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

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts/token/ERC1155/IERC1155.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol

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

pragma solidity ^0.8.0;

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

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

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

/_openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}
          

/_openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol

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

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}
          

/_openzeppelin/contracts/token/ERC20/IERC20.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

/_openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

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

pragma solidity ^0.8.0;

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

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

/_openzeppelin/contracts/token/ERC721/ERC721.sol

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

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _beforeTokenTransfer(from, to, tokenId);

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

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

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

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

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

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

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

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

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

/_openzeppelin/contracts/token/ERC721/IERC721.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/token/ERC721/IERC721Receiver.sol

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

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol

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

pragma solidity ^0.8.0;

import "../ERC721.sol";

/**
 * @dev ERC721 token with storage based token URI management.
 */
abstract contract ERC721URIStorage is ERC721 {
    using Strings for uint256;

    // Optional mapping for token URIs
    mapping(uint256 => string) private _tokenURIs;

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

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }

        return super.tokenURI(tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev See {ERC721-_burn}. This override additionally checks to see if a
     * token-specific URI was set for the token, and if so, it deletes the token URI from
     * the storage mapping.
     */
    function _burn(uint256 tokenId) internal virtual override {
        super._burn(tokenId);

        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }
    }
}
          

/_openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

/_openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

/_openzeppelin/contracts/utils/Address.sol

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/utils/Context.sol

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

pragma solidity ^0.8.0;

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

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

/_openzeppelin/contracts/utils/Strings.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

/_openzeppelin/contracts/utils/introspection/ERC165.sol

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

/_openzeppelin/contracts/utils/introspection/ERC165Checker.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.2) (utils/introspection/ERC165Checker.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Library used to query support of an interface declared via {IERC165}.
 *
 * Note that these functions return the actual result of the query: they do not
 * `revert` if an interface is not supported. It is up to the caller to decide
 * what to do in these cases.
 */
library ERC165Checker {
    // As per the EIP-165 spec, no interface should ever match 0xffffffff
    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;

    /**
     * @dev Returns true if `account` supports the {IERC165} interface,
     */
    function supportsERC165(address account) internal view returns (bool) {
        // Any contract that implements ERC165 must explicitly indicate support of
        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
        return
            _supportsERC165Interface(account, type(IERC165).interfaceId) &&
            !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
    }

    /**
     * @dev Returns true if `account` supports the interface defined by
     * `interfaceId`. Support for {IERC165} itself is queried automatically.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
        // query support of both ERC165 as per the spec and support of _interfaceId
        return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);
    }

    /**
     * @dev Returns a boolean array where each value corresponds to the
     * interfaces passed in and whether they're supported or not. This allows
     * you to batch check interfaces for a contract where your expectation
     * is that some interfaces may not be supported.
     *
     * See {IERC165-supportsInterface}.
     *
     * _Available since v3.4._
     */
    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
        internal
        view
        returns (bool[] memory)
    {
        // an array of booleans corresponding to interfaceIds and whether they're supported or not
        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);

        // query support of ERC165 itself
        if (supportsERC165(account)) {
            // query support of each interface in interfaceIds
            for (uint256 i = 0; i < interfaceIds.length; i++) {
                interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
            }
        }

        return interfaceIdsSupported;
    }

    /**
     * @dev Returns true if `account` supports all the interfaces defined in
     * `interfaceIds`. Support for {IERC165} itself is queried automatically.
     *
     * Batch-querying can lead to gas savings by skipping repeated checks for
     * {IERC165} support.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
        // query support of ERC165 itself
        if (!supportsERC165(account)) {
            return false;
        }

        // query support of each interface in _interfaceIds
        for (uint256 i = 0; i < interfaceIds.length; i++) {
            if (!_supportsERC165Interface(account, interfaceIds[i])) {
                return false;
            }
        }

        // all interfaces supported
        return true;
    }

    /**
     * @notice Query if a contract implements an interface, does not check ERC165 support
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return true if the contract at account indicates support of the interface with
     * identifier interfaceId, false otherwise
     * @dev Assumes that account contains a contract that supports ERC165, otherwise
     * the behavior of this method is undefined. This precondition can be checked
     * with {supportsERC165}.
     * Interface identification is specified in ERC-165.
     */
    function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
        // prepare call
        bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);

        // perform static call
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly {
            success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0x00)
        }

        return success && returnSize >= 0x20 && returnValue > 0;
    }
}
          

/_openzeppelin/contracts/utils/introspection/IERC165.sol

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

pragma solidity ^0.8.0;

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

/contracts/CurveErrorCodes.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

contract CurveErrorCodes {
    enum Error {
        OK, // No error
        INVALID_NUMITEMS, // The numItem value is 0
        SPOT_PRICE_OVERFLOW // The updated spot price doesn't fit into 128 bits
    }
}
          

/contracts/FixedPointMathLib.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.7;

/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
    /*//////////////////////////////////////////////////////////////
                    SIMPLIFIED FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.

    function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
    }

    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
    }

    function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
    }

    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
    }

    /*//////////////////////////////////////////////////////////////
                    LOW LEVEL FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function mulDivDown(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        assembly {
            // Store x * y in z for now.
            z := mul(x, y)

            // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
            if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
                revert(0, 0)
            }

            // Divide z by the denominator.
            z := div(z, denominator)
        }
    }

    function mulDivUp(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        assembly {
            // Store x * y in z for now.
            z := mul(x, y)

            // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
            if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
                revert(0, 0)
            }

            // First, divide z - 1 by the denominator and add 1.
            // We allow z - 1 to underflow if z is 0, because we multiply the
            // end result by 0 if z is zero, ensuring we return 0 if z is zero.
            z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))
        }
    }

    function rpow(
        uint256 x,
        uint256 n,
        uint256 scalar
    ) internal pure returns (uint256 z) {
        assembly {
            switch x
            case 0 {
                switch n
                case 0 {
                    // 0 ** 0 = 1
                    z := scalar
                }
                default {
                    // 0 ** n = 0
                    z := 0
                }
            }
            default {
                switch mod(n, 2)
                case 0 {
                    // If n is even, store scalar in z for now.
                    z := scalar
                }
                default {
                    // If n is odd, store x in z for now.
                    z := x
                }

                // Shifting right by 1 is like dividing by 2.
                let half := shr(1, scalar)

                for {
                    // Shift n right by 1 before looping to halve it.
                    n := shr(1, n)
                } n {
                    // Shift n right by 1 each iteration to halve it.
                    n := shr(1, n)
                } {
                    // Revert immediately if x ** 2 would overflow.
                    // Equivalent to iszero(eq(div(xx, x), x)) here.
                    if shr(128, x) {
                        revert(0, 0)
                    }

                    // Store x squared.
                    let xx := mul(x, x)

                    // Round to the nearest number.
                    let xxRound := add(xx, half)

                    // Revert if xx + half overflowed.
                    if lt(xxRound, xx) {
                        revert(0, 0)
                    }

                    // Set x to scaled xxRound.
                    x := div(xxRound, scalar)

                    // If n is even:
                    if mod(n, 2) {
                        // Compute z * x.
                        let zx := mul(z, x)

                        // If z * x overflowed:
                        if iszero(eq(div(zx, x), z)) {
                            // Revert if x is non-zero.
                            if iszero(iszero(x)) {
                                revert(0, 0)
                            }
                        }

                        // Round to the nearest number.
                        let zxRound := add(zx, half)

                        // Revert if zx + half overflowed.
                        if lt(zxRound, zx) {
                            revert(0, 0)
                        }

                        // Return properly scaled zxRound.
                        z := div(zxRound, scalar)
                    }
                }
            }
        }
    }

    /*///////////////////////////////////////////////////////////////
                         FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function fmul(
        uint256 x,
        uint256 y,
        uint256 baseUnit
    ) internal pure returns (uint256 z) {
        assembly {
            // Store x * y in z for now.
            z := mul(x, y)

            // Equivalent to require(x == 0 || (x * y) / x == y)
            if iszero(or(iszero(x), eq(div(z, x), y))) {
                revert(0, 0)
            }

            // If baseUnit is zero this will return zero instead of reverting.
            z := div(z, baseUnit)
        }
    }

    function fdiv(
        uint256 x,
        uint256 y,
        uint256 baseUnit
    ) internal pure returns (uint256 z) {
        assembly {
            // Store x * baseUnit in z for now.
            z := mul(x, baseUnit)

            if or(
                // Revert if y is zero to ensure we don't divide by zero below.
                iszero(y),
                // Equivalent to require(x == 0 || (x * baseUnit) / x == baseUnit)
                iszero(or(iszero(x), eq(div(z, x), baseUnit)))
            ) {
                revert(0, 0)
            }

            // We ensure y is not zero above, so there is never division by zero here.
            z := div(z, y)
        }
    }

    function fpow(
        uint256 x,
        uint256 n,
        uint256 baseUnit
    ) internal pure returns (uint256 z) {
        assembly {
            switch x
            case 0 {
                switch n
                case 0 {
                    z := baseUnit
                }
                default {
                    z := 0
                }
            }
            default {
                switch mod(n, 2)
                case 0 {
                    z := baseUnit
                }
                default {
                    z := x
                }
                let half := div(baseUnit, 2)
                for {
                    n := div(n, 2)
                } n {
                    n := div(n, 2)
                } {
                    let xx := mul(x, x)
                    if iszero(eq(div(xx, x), x)) {
                        revert(0, 0)
                    }
                    let xxRound := add(xx, half)
                    if lt(xxRound, xx) {
                        revert(0, 0)
                    }
                    x := div(xxRound, baseUnit)
                    if mod(n, 2) {
                        let zx := mul(z, x)
                        if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) {
                            revert(0, 0)
                        }
                        let zxRound := add(zx, half)
                        if lt(zxRound, zx) {
                            revert(0, 0)
                        }
                        z := div(zxRound, baseUnit)
                    }
                }
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                        GENERAL NUMBER UTILITIES
    //////////////////////////////////////////////////////////////*/

    function sqrt(uint256 x) internal pure returns (uint256 z) {
        assembly {
            // Start off with z at 1.
            z := 1

            // Used below to help find a nearby power of 2.
            let y := x

            // Find the lowest power of 2 that is at least sqrt(x).
            if iszero(lt(y, 0x100000000000000000000000000000000)) {
                y := shr(128, y) // Like dividing by 2 ** 128.
                z := shl(64, z) // Like multiplying by 2 ** 64.
            }
            if iszero(lt(y, 0x10000000000000000)) {
                y := shr(64, y) // Like dividing by 2 ** 64.
                z := shl(32, z) // Like multiplying by 2 ** 32.
            }
            if iszero(lt(y, 0x100000000)) {
                y := shr(32, y) // Like dividing by 2 ** 32.
                z := shl(16, z) // Like multiplying by 2 ** 16.
            }
            if iszero(lt(y, 0x10000)) {
                y := shr(16, y) // Like dividing by 2 ** 16.
                z := shl(8, z) // Like multiplying by 2 ** 8.
            }
            if iszero(lt(y, 0x100)) {
                y := shr(8, y) // Like dividing by 2 ** 8.
                z := shl(4, z) // Like multiplying by 2 ** 4.
            }
            if iszero(lt(y, 0x10)) {
                y := shr(4, y) // Like dividing by 2 ** 4.
                z := shl(2, z) // Like multiplying by 2 ** 2.
            }
            if iszero(lt(y, 0x8)) {
                // Equivalent to 2 ** z.
                z := shl(1, z)
            }

            // Shifting right by 1 is like dividing by 2.
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))

            // Compute a rounded down version of z.
            let zRoundDown := div(x, z)

            // If zRoundDown is smaller, use it.
            if lt(zRoundDown, z) {
                z := zRoundDown
            }
        }
    }
}
          

/contracts/ICollectionswap.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

interface ICollectionswap is IERC721, IERC721Enumerable {
    struct LPTokenParams721ETH {
        address nftAddress;
        address bondingCurveAddress;
        address payable poolAddress;
        uint96 fee;
        uint128 delta;
        uint128 initialSpotPrice;
        uint256 initialPoolBalance;
        uint256 initialNFTIDsLength;
    }

    function viewPoolParams(uint256 tokenId)
        external
        view
        returns (LPTokenParams721ETH memory poolParams);

    function validatePoolParamsLte(
        uint256 tokenId,
        address nftAddress,
        address bondingCurveAddress,
        uint96 fee,
        uint128 delta
    )
        external
        view
        returns (bool);

    function validatePoolParamsEq(
        uint256 tokenId,
        address nftAddress,
        address bondingCurveAddress,
        uint96 fee,
        uint128 delta
    )
        external
        view
        returns (bool);
}
          

/contracts/ICurve.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

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

interface ICurve {
    /**
        @notice Validates if a delta value is valid for the curve. The criteria for
        validity can be different for each type of curve, for instance ExponentialCurve
        requires delta to be greater than 1.
        @param delta The delta value to be validated
        @return valid True if delta is valid, false otherwise
     */
    function validateDelta(uint128 delta) external pure returns (bool valid);

    /**
        @notice Validates if a new spot price is valid for the curve. Spot price is generally assumed to be the immediate sell price of 1 NFT to the pool, in units of the pool's paired token.
        @param newSpotPrice The new spot price to be set
        @return valid True if the new spot price is valid, false otherwise
     */
    function validateSpotPrice(uint128 newSpotPrice)
        external
        view
        returns (bool valid);

    /**
        @notice Given the current state of the pair and the trade, computes how much the user
        should pay to purchase an NFT from the pair, the new spot price, and other values.
        @param spotPrice The current selling spot price of the pair, in tokens
        @param delta The delta parameter of the pair, what it means depends on the curve
        @param numItems The number of NFTs the user is buying from the pair
        @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals
        @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals
        @return error Any math calculation errors, only Error.OK means the returned values are valid
        @return newSpotPrice The updated selling spot price, in tokens
        @return newDelta The updated delta, used to parameterize the bonding curve
        @return inputValue The amount that the user should pay, in tokens
        @return protocolFee The amount of fee to send to the protocol, in tokens
     */
    function getBuyInfo(
        uint128 spotPrice,
        uint128 delta,
        uint256 numItems,
        uint256 feeMultiplier,
        uint256 protocolFeeMultiplier
    )
        external
        view
        returns (
            CurveErrorCodes.Error error,
            uint128 newSpotPrice,
            uint128 newDelta,
            uint256 inputValue,
            uint256 protocolFee
        );

    /**
        @notice Given the current state of the pair and the trade, computes how much the user
        should receive when selling NFTs to the pair, the new spot price, and other values.
        @param spotPrice The current selling spot price of the pair, in tokens
        @param delta The delta parameter of the pair, what it means depends on the curve
        @param numItems The number of NFTs the user is selling to the pair
        @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals
        @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals
        @return error Any math calculation errors, only Error.OK means the returned values are valid
        @return newSpotPrice The updated selling spot price, in tokens
        @return newDelta The updated delta, used to parameterize the bonding curve
        @return outputValue The amount that the user should receive, in tokens
        @return protocolFee The amount of fee to send to the protocol, in tokens
     */
    function getSellInfo(
        uint128 spotPrice,
        uint128 delta,
        uint256 numItems,
        uint256 feeMultiplier,
        uint256 protocolFeeMultiplier
    )
        external
        view
        returns (
            CurveErrorCodes.Error error,
            uint128 newSpotPrice,
            uint128 newDelta,
            uint256 outputValue,
            uint256 protocolFee
        );
}
          

/contracts/ILSSVMPair.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {ICurve} from "./ICurve.sol";
import {CurveErrorCodes} from "./CurveErrorCodes.sol";

interface ILSSVMPair {
    enum PoolType {
        TOKEN,
        NFT,
        TRADE
    }

    function bondingCurve() external view returns (ICurve);

    function getAllHeldIds() external view returns (uint256[] memory);

    function delta() external view returns (uint128);

    function fee() external view returns (uint96);

    function nft() external view returns (IERC721);

    function spotPrice() external view returns (uint128);

    function withdrawERC721(IERC721 a, uint256[] calldata nftIds) external;

    function withdrawERC20(IERC20 a, uint256 amount) external;

    function withdrawERC1155(IERC1155 a, uint256[] calldata ids, uint256[] calldata amounts) external;

    function getSellNFTQuote(uint256 numNFTs) external view
    returns (
        CurveErrorCodes.Error error,
        uint256 newSpotPrice,
        uint256 newDelta,
        uint256 outputAmount,
        uint256 protocolFee
    );
}

interface ILSSVMPairETH is ILSSVMPair {
    function withdrawAllETH() external;
}
          

/contracts/ILSSVMPairFactory.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {ICurve} from "./ICurve.sol";
import {ILSSVMPair, ILSSVMPairETH} from "./ILSSVMPair.sol";

interface ILSSVMPairFactory {
    function createPairETH(
        IERC721 _nft,
        ICurve _bondingCurve,
        address payable _assetRecipient,
        ILSSVMPair.PoolType _poolType,
        uint128 _delta,
        uint96 _fee,
        uint128 _spotPrice,
        uint256[] calldata _initialNFTIDs
    ) external payable returns (ILSSVMPairETH pair);
}
          

/contracts/IOwnershipTransferCallback.sol

// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.4;

interface IOwnershipTransferCallback {
  function onOwnershipTransfer(address oldOwner) external;
}
          

/contracts/OwnableWithTransferCallback.sol

// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.4;

import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import {IOwnershipTransferCallback} from "./IOwnershipTransferCallback.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

abstract contract OwnableWithTransferCallback {
    using ERC165Checker for address;
    using Address for address;

    bytes4 constant TRANSFER_CALLBACK =
        type(IOwnershipTransferCallback).interfaceId;

    error Ownable_NotOwner();
    error Ownable_NewOwnerZeroAddress();

    address private _owner;

    event OwnershipTransferred(address indexed newOwner);

    /// @dev Initializes the contract setting the deployer as the initial owner.
    function __Ownable_init(address initialOwner) internal {
        _owner = initialOwner;
    }

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

    /// @dev Throws if called by any account other than the owner.
    modifier onlyOwner() {
        if (owner() != msg.sender) revert Ownable_NotOwner();
        _;
    }

    /// @dev Transfers ownership of the contract to a new account (`newOwner`).
    /// Disallows setting to the zero address as a way to more gas-efficiently avoid reinitialization
    /// When ownership is transferred, if the new owner implements IOwnershipTransferCallback, we make a callback
    /// Can only be called by the current owner.
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) revert Ownable_NewOwnerZeroAddress();
        _transferOwnership(newOwner);

        // Call the on ownership transfer callback if it exists
        // @dev try/catch is around 5k gas cheaper than doing ERC165 checking
        if (newOwner.isContract()) {
            try
                IOwnershipTransferCallback(newOwner).onOwnershipTransfer(msg.sender)
            {} catch (bytes memory) {}
        }
    }

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

/contracts/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// Forked from OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol), 
// removed initializer check as we already do that in our modified Ownable

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    function __ReentrancyGuard_init() internal {
      _status = _NOT_ENTERED;
    } 

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

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

        _;

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

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"lssvmPairFactoryAddress","internalType":"address payable"}]},{"type":"error","name":"Ownable_NewOwnerZeroAddress","inputs":[]},{"type":"error","name":"Ownable_NotOwner","inputs":[]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"approved","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"ERC1155Rescued","inputs":[],"anonymous":false},{"type":"event","name":"ERC20Rescued","inputs":[],"anonymous":false},{"type":"event","name":"ERC721Rescued","inputs":[],"anonymous":false},{"type":"event","name":"NewPair","inputs":[{"type":"address","name":"poolAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"NewTokenId","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ILSSVMPairFactory"}],"name":"_factory","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"approve","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[{"type":"address","name":"newPair","internalType":"contract ILSSVMPairETH"}],"name":"createDirectPairETH","inputs":[{"type":"address","name":"_nft","internalType":"contract IERC721"},{"type":"address","name":"_bondingCurve","internalType":"contract ICurve"},{"type":"uint128","name":"_delta","internalType":"uint128"},{"type":"uint96","name":"_fee","internalType":"uint96"},{"type":"uint128","name":"_spotPrice","internalType":"uint128"},{"type":"uint256[]","name":"_initialNFTIDs","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"currentIds","internalType":"uint256[]"}],"name":"getAllHeldIds","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getApproved","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"contribution","internalType":"uint256"}],"name":"getMeasurableContribution","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedToOperateOnPool","inputs":[{"type":"address","name":"_owner","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPoolAlive","inputs":[{"type":"address","name":"_pool","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155BatchReceived","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"refreshPoolParameters","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rescueERC1155","inputs":[{"type":"address","name":"a","internalType":"contract IERC1155"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rescueERC20","inputs":[{"type":"address","name":"a","internalType":"contract IERC20"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rescueERC721","inputs":[{"type":"address","name":"a","internalType":"contract IERC721"},{"type":"uint256[]","name":"nftIds","internalType":"uint256[]"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenByIndex","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenOfOwnerByIndex","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"tokenURI","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"useLPTokenToDestroyDirectPairETH","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"validatePoolParamsEq","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"nftAddress","internalType":"address"},{"type":"address","name":"bondingCurveAddress","internalType":"address"},{"type":"uint96","name":"fee","internalType":"uint96"},{"type":"uint128","name":"delta","internalType":"uint128"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"validatePoolParamsLte","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"nftAddress","internalType":"address"},{"type":"address","name":"bondingCurveAddress","internalType":"address"},{"type":"uint96","name":"fee","internalType":"uint96"},{"type":"uint128","name":"delta","internalType":"uint128"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"poolParams","internalType":"struct ICollectionswap.LPTokenParams721ETH","components":[{"type":"address","name":"nftAddress","internalType":"address"},{"type":"address","name":"bondingCurveAddress","internalType":"address"},{"type":"address","name":"poolAddress","internalType":"address payable"},{"type":"uint96","name":"fee","internalType":"uint96"},{"type":"uint128","name":"delta","internalType":"uint128"},{"type":"uint128","name":"initialSpotPrice","internalType":"uint128"},{"type":"uint256","name":"initialPoolBalance","internalType":"uint256"},{"type":"uint256","name":"initialNFTIDsLength","internalType":"uint256"}]}],"name":"viewPoolParams","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

0x60c0346200038057601f196001600160401b03601f6200398338819003828101851686018481118782101762000299578692829160405283396020958691810103126200038057516001600160a01b038116929083900362000380576200006562000385565b91600e83526d0436f6c6c656374696f6e737761760941b868401526200008a62000385565b95600e87526d0436f6c6c6563745375646f204c560941b81880152835183811162000299576001948554908682811c9216801562000375575b84831014620002785781858493116200031f575b508390858311600114620002bb57600092620002af575b5050600019600383901b1c191690851b1784555b8651928311620002995760029586548581811c911680156200028e575b8382101462000278578381116200022d575b5081928411600114620001c75750508192939495600092620001bb575b5050600019600383901b1c191690821b1783555b600080546001600160a01b03191633179055600c5560805260a0526040516135dd9081620003a68239608051818181610bab015281816112b10152818161139e0152612091015260a05181818161130501526113340152f35b0151905038806200014e565b6000878152828120918516989193925b89821062000215575050838596979810620001fb575b505050811b01835562000162565b015160001960f88460031b161c19169055388080620001ed565b808785968294968601518155019501930190620001d7565b87600052826000208480870160051c8201928588106200026e575b0160051c019086905b8281106200026157505062000131565b6000815501869062000251565b9250819262000248565b634e487b7160e01b600052602260045260246000fd5b90607f16906200011f565b634e487b7160e01b600052604160045260246000fd5b015190503880620000ee565b90898894169184600052856000209260005b87828210620003085750508411620002ee575b505050811b01845562000102565b015160001960f88460031b161c19169055388080620002e0565b8385015186558b97909501949384019301620002cd565b90915086600052836000208580850160051c8201928686106200036b575b918991869594930160051c01915b8281106200035b575050620000d7565b600081558594508991016200034b565b925081926200033d565b91607f1691620000c3565b600080fd5b60408051919082016001600160401b03811183821017620002995760405256fe6080604052600436101561001b575b361561001957600080fd5b005b6000803560e01c80630110f188146125eb57806301ffc9a714612548578063029032e6146124ab57806306fd072d14611eac57806306fdde0314611e08578063081812fc14611de9578063095ea7b314611c6f578063150b7a0214611c4b57806318160ddd14611c2d5780632376583614611ba557806323b872dd14611b805780632f745c5914611ad35780633d7c1bfc14611a9657806342842e0e14611a6357806345b56380146118ba5780634f6ccce7146118285780636352211e146117f757806370a08231146117cb57806387141f021461120457806388934a06146111d25780638da5cb5b146111ab57806395d89b41146110c6578063a22cb46514610ff4578063b88d4fde14610fb2578063bc197c8114610f29578063c481d84114610bda578063c5cc6b6a14610b95578063c6d2562314610943578063c87b56dd14610835578063cdb71d0d146107a6578063e985e9c514610752578063ef8673691461053b578063f04e0634146102f5578063f23a6e611461029f5763f2fde38b146101a8575061000e565b3461029c57602036600319011261029c576101c161267e565b81546001600160a01b03338183160361028a5782168015610278578084926001600160601b0360a01b1617825560405192817f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc6861638480a23b610220575080f35b803b1561027457826024818480946314e8368d60e31b83523360048401525af19182610260575b505061025b57610255612f03565b50388180f35b388180f35b61026990612763565b610274578138610247565b5080fd5b604051633b7c6c7f60e21b8152600490fd5b604051635eee3ad160e01b8152600490fd5b80fd5b503461029c5760a036600319011261029c576102b961267e565b506102c2612694565b506084356001600160401b038111610274576102e29036906004016127e8565b5060405163f23a6e6160e01b8152602090f35b503461029c57606036600319011261029c576001600160a01b036004358181169081900361047157826024359260443580156000146104ba575061033c91541633146134d3565b60405163a9059cbb60e01b602080830191825233602484015260448084019590955293825290919061036f6064846127ac565b6040519261037c84612776565b8484527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656485850152823b15610475576103c79392869283809351925af16103c1612f03565b9061350b565b8051806103f7575b837f549639b4800706ffeb7175ba0c6b929284789667d40a584575117d43f5df269b8180a180f35b81839181010312610471578101518015908115036104715761041a5780806103cf565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b8280fd5b60405162461bcd60e51b815260048101869052601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b906104da6104df91838552600e6020526002604086200154169233613492565b6130ef565b803b15610274578180916044604051809481936350edcbc160e11b83528860048401528960248401525af180156105305761051c575b505061033c565b61052590612763565b610471578238610515565b6040513d84823e3d90fd5b503461029c57606036600319011261029c5761055561267e565b816024356001600160401b038111610274576105759036906004016128ed565b9060443580610645575061059360018060a01b0384541633146134d3565b9290925b6001600160a01b0390911690825b8481106105d457837ff0d8db23b8f0b8d1dea970ce598d5903cc446f99d2a1c3995ffdb1b770c1ba8e8180a180f35b823b1561063657604051632142170760e11b8152306004820152336024820152600582901b8301356044820152848160648183885af190811561063a578591610622575b50506001016105a5565b61062b90612763565b610636578338610618565b8380fd5b6040513d87823e3d90fd5b808452600e60205260408420906106dd6040519161066283612747565b6106cf6104da60018060a01b03928387541686528360018801541660208701526005600288015497858916988960408a015260a01c606089015260038101546001600160801b03811660808a015260801c60a0890152600481015460c0890152015460e087015233613492565b80881692511682141561354b565b813b1561074e5784906040519283916313edab8160e01b8352600483015260406024830152818381610713604482018a8a613327565b03925af190811561074357849161072f575b5050929092610597565b61073890612763565b610471578238610725565b6040513d86823e3d90fd5b8480fd5b503461029c57604036600319011261029c5761076c61267e565b6040610776612694565b9260018060a01b0380931681526006602052209116600052602052602060ff604060002054166040519015158152f35b503461029c57602036600319011261029c576101006107c6600435613213565b60e06040519160018060a01b0380825116845280602083015116602085015260408201511660408401526001600160601b0360608201511660608401526001600160801b0380608083015116608085015260a08201511660a084015260c081015160c0840152015160e0820152f35b503461029c576020908160031936011261029c5750600435600081815260036020526040902054610870906001600160a01b03161515612a14565b600052600b815260406000209060405191826000825461088f81612a83565b938484526001918683821691826000146109215750506001146108e2575b50506108bb925003836127ac565b60006040516108c981612791565b526108de604051928284938452830190612707565b0390f35b85925060005281600020906000915b8583106109095750506108bb935082010138806108ad565b805483890185015287945086939092019181016108f1565b92509350506108bb94915060ff191682840152151560051b82010138806108ad565b503461029c5780600319608036820112610b92576001600160a01b039060043582811690819003610b8d576001600160401b0390602435828111610b895761098f9036906004016128ed565b9092604435908111610a6d576109a99036906004016128ed565b956064359081610a71576109c2915088541633146134d3565b823b15610a6d576020879586610a168194610a069a6040519b8c9a8b99631759616b60e11b8b523060048c01523360248c015260a060448c015260a48b0191613327565b91858984030160648a0152613327565b85810392830160848701525201925af1801561053057610a59575b50807fcc85acda6e8701522b69958b6ba1a9043bf9befffda96482e4b8665d5746760591a180f35b610a6290612763565b61029c578038610a31565b8680fd5b610afe90828a52600e60205260408a2092610af46104da60405192610a9584612747565b84875416845284600188015416602085015260056002880154978689169889604088015260a01c606087015260038101546001600160801b038116608088015260801c60a0870152600481015460c0870152015460e085015233613492565b511685141561354b565b803b15610b855787610b3d8892878388610b4d8c6040519889978896879563a5ceac9960e01b87526004870152606060248701528d6064870191613327565b918483030160448501528a613327565b03925af1908115610b7a578891610b66575b50506109c2565b610b6f90612763565b610a6d578638610b5f565b6040513d8a823e3d90fd5b8780fd5b8580fd5b505050fd5b50fd5b503461029c578060031936011261029c576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b503461029c57602036600319011261029c576004358152600e6020526040812060405190610c0782612747565b60018060a01b03815416825260018060a01b0360018201541691602081019283526002820154906005604082019360018060a01b03841685528360a01c606084015260038101546001600160801b038116608085015260801c60a0840152600481015460c0840152015460e0820152610c856104da60043533613492565b604051632f4fefaf60e01b81529085826004816001600160a01b0387165afa918215610f1e578692610efa575b50519351925160405163ddca3f4360e01b81526001600160a01b0395861695948516949182169390916020908390600490829085165afa918215610eef578792610eab575b5060405163025692b560e31b8152916020836004816001600160a01b0386165afa928315610b7a578893610e8a575b50604051630730905b60e31b8152956020876004816001600160a01b0387165afa928315610e7f576005978a94610e4e575b5060018060a01b03163194519560405198610d728a612747565b895260208901918252604089019081526001600160601b0360608a01931683526001600160801b0360808a01951685526001600160801b0360a08a019416845260c0890195865260e089019687526004358a52600e60205260408a209860018060a01b03905116916001600160601b0360a01b92838b5416178a5560018a019060018060a01b039051168382541617905560018060a01b03905116915160a01b161760028701556001600160801b0360038701925116878354926001600160801b0319905160801b169216171790555160048401555191015580f35b610e7191945060203d602011610e78575b610e6981836127ac565b8101906131a8565b9238610d58565b503d610e5f565b6040513d8b823e3d90fd5b610ea491935060203d602011610e7857610e6981836127ac565b9138610d26565b9091506020813d602011610ee7575b81610ec7602093836127ac565b81010312610a6d57516001600160601b0381168103610a6d579038610cf7565b3d9150610eba565b6040513d89823e3d90fd5b610f179192503d8088833e610f0f81836127ac565b81019061312f565b9038610cb2565b6040513d88823e3d90fd5b503461029c5760a036600319011261029c57610f4361267e565b50610f4c612694565b506001600160401b0360443581811161047157610f6d903690600401612982565b5060643581811161047157610f86903690600401612982565b5060843590811161027457610f9f9036906004016127e8565b5060405163bc197c8160e01b8152602090f35b503461029c57610ff1610fec610fc73661282f565b92610fdc610fd783949333612bd1565b612afb565b610fe7838383612c3f565b613027565b612bb1565b80f35b503461029c57604036600319011261029c5761100e61267e565b60243590811515809203610471576001600160a01b0316903382146110815733835260066020526040832082600052602052604060002060ff1981541660ff83161790556040519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a380f35b60405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606490fd5b503461029c578060031936011261029c5760405190806002546110e881612a83565b808552916001918083169081156111815750600114611126575b6108de85611112818703826127ac565b604051918291602083526020830190612707565b9250600283527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace5b828410611169575050508101602001611112826108de611102565b8054602085870181019190915290930192810161114e565b8695506108de9693506020925061111294915060ff191682840152151560051b8201019293611102565b503461029c578060031936011261029c57546040516001600160a01b039091168152602090f35b503461029c57604036600319011261029c5760206111fa6111f161267e565b60243590613492565b6040519015158152f35b5060c036600319011261029c5761121961267e565b602435906001600160a01b0382168203610471576044356001600160801b03811681036117c657606435906001600160601b03821682036117c657608435906001600160801b03821682036117c65760a4356001600160401b038111610a6d576112879036906004016128ed565b9390956112996002600c5414156131c7565b6002600c556112d56112ac36878a612934565b8730337f000000000000000000000000000000000000000000000000000000000000000061335f565b60405163ce9c095d60e01b81526001600160a01b03878116600483015282166024820152604481018990529660037f000000000000000000000000000000000000000000000000000000000000000010156117b25787806113996020937f000000000000000000000000000000000000000000000000000000000000000060648401526001600160801b03881660848401526001600160601b03871660a48401526001600160801b03891660c484015261010060e484015289610104840191613327565b0381347f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af1968715610b7a57889761175f575b50916001600160601b036001600160801b039493928593604051986113fa8a612747565b6001600160a01b039081168a5290811660208a0152891660408901521660608701521660808501521660a08301523460c083015260e0820152600f5460001981146117495760018101600f55600181018452600e602052604084209160018060a01b03815116926001600160601b0360a01b93848254161781556001810160018060a01b0360208401511685825416179055600560e060018060a01b036040850151169386606082015160a01b1685176002850155600384016001600160801b036080830151168154908b6001600160801b031960a086015160801b1692161717905560c0810151600485015501519101558452600d60205260408420600160ff198254161790557f8a1767404395cfcd1267c6537e872277dde277a29ac6dea742a111469f324a586020604051600184018152a160405191602083018381106001600160401b038211176117335760405284835233156116ef57600182016000908152600360205260409020546001600160a01b03166116aa57600954600183018652600a602052806040872055600160401b811015611696576115a88160016115c593016009556130a2565b600185019082549060031b600019811b9283911b16911916179055565b6115ce3361299d565b3386526007602052604086208187526020526001830160408720556001830186526008602052604086205533855260046020526040852080549060018201809211611682579260209661166b9593600193610fec9655838301825260038952604082209033908254161790558282019033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a40133612f33565b6001600c556040516001600160a01b039091168152f35b634e487b7160e01b87526011600452602487fd5b634e487b7160e01b86526041600452602486fd5b60405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606490fd5b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b9096506020939293813d6020116117aa575b8161177e602093836127ac565b81010312610b855751926001600160a01b0384168403610b855792959192916001600160601b036113d6565b3d9150611771565b634e487b7160e01b89526021600452602489fd5b600080fd5b503461029c57602036600319011261029c5760206117ef6117ea61267e565b61299d565b604051908152f35b503461029c57602036600319011261029c576020611816600435612a60565b6040516001600160a01b039091168152f35b503461029c57602036600319011261029c57600435600954811015611860576118526020916130a2565b90546040519160031b1c8152f35b60405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608490fd5b503461029c576020908160031936011261029c5760e0906004358152600e83526040812090604051916118ec83612747565b60018060a01b0392838254168152600193808584015416878301526002830154908116604083015260a01c606082015260038201546001600160801b038116608083015260801c60a082015260056004830154928360c084015201549485910152838102938185041490151715611a4f57508082600160801b811015611a3d575b80600160401b6008921015611a31575b640100000000811015611a25575b62010000811015611a19575b610100811015611a0d575b6010811015611a00575b10156119f9575b80830401811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c8091048181106119f1575b50604051908152f35b9050386119e8565b811b6119b3565b60041c9160021b916119ac565b811c9160041b916119a2565b60101c91811b91611997565b851c9160101b9161198b565b60401c91851b9161197d565b50600160401b9050608083901c61196d565b634e487b7160e01b81526011600452602490fd5b503461029c57610ff1610fec611a78366128b8565b9060405192611a8684612791565b868452610fdc610fd78433612bd1565b503461029c57602036600319011261029c5760206111fa611ab561267e565b6001600160a01b03166000908152600d602052604090205460ff1690565b503461029c57604036600319011261029c57611aed61267e565b60243591611afa8261299d565b831015611b275760209260409260018060a01b031682526007845282822090825283522054604051908152f35b60405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608490fd5b503461029c57610ff1611b92366128b8565b91611ba0610fd78433612bd1565b612c3f565b503461029c57602036600319011261029c57600480358252600e6020526040808320600201549051632f4fefaf60e01b815291839183919082906001600160a01b03165afa90811561053057826108de9392611c12575b5050604051918291602083526020830190612884565b611c2692503d8091833e610f0f81836127ac565b3880611bfc565b503461029c578060031936011261029c576020600954604051908152f35b503461029c57611c5a3661282f565b505050506020604051630a85bd0160e11b8152f35b503461029c57604036600319011261029c57611c8961267e565b602435906001600160a01b038080611ca085612a60565b16921691808314611d9a57803314908115611d77575b5015611d0c57600083815260056020526040902080546001600160a01b03191683179055611ce383612a60565b167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600080a480f35b60405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608490fd5b905084526006602052604084203360005260205260ff6040600020541638611cb6565b60405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608490fd5b503461029c57602036600319011261029c576020611816600435612abd565b503461029c578060031936011261029c5760405190806001805491611e2c83612a83565b808652928281169081156111815750600114611e52576108de85611112818703826127ac565b92508083527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b828410611e94575050508101602001611112826108de611102565b80546020858701810191909152909301928101611e79565b503461029c576020806003193601126102745760043590611ed26002600c5414156131c7565b6002600c55818352600e8152604083209160405192611ef084612747565b60018060a01b039081815416908186526001958387830154168682015260e060056002840154936040840194878116865260a01c606085015260038101546001600160801b038116608086015260801c60a0850152600481015460c08501520154910152604051606081018181106001600160401b0382111761249757604052602181527f6f6e6c7920746f6b656e206f776e65722063616e2064657374726f7920706f6f86820152601b60fa1b6040820152848852600e865283600260408a2001541690818952600d875260ff60408a20541615612463575b611fd48633613492565b1561243d57506040516311bb2c1b60e11b81526004810186905260249389828681305afa918215612432578a92612416575b50823b156123f4576040516313edab8160e01b81528160048201526040868201528a81806120376044820187612884565b038183885af1801561240b576123f8575b50894793803b15610274578180916004604051809481936390386bbf60e01b83525af18015610530576123e0575b5050479283039283116123cb578980936120b58294839433307f000000000000000000000000000000000000000000000000000000000000000061335f565b335af16120c0612f03565b5015612390575182168652600d845260408620805460ff191690556120e483612a60565b91821691826122f15750600954838752600a8552806040882055600160401b8110156122de578361211d828861213894016009556130a2565b90919082549060031b600019811b9283911b16911916179055565b60095460001991908281019081116122cb57848852600a865261215f6040892054916130a2565b90549060031b1c6121738161211d846130a2565b8852600a865260408820558387526000604088205560095480156122b857820161219c816130a2565b8482549160031b1b191690556009556121b484612eaf565b82875260048552604087209081549283019283116122a6575055818552600383526040852080546001600160a01b0319169055819085907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4600b82526122206040852054612a83565b61222d575b5050600c5580f35b8352600b815260408320906122428254612a83565b8061224e575b50612225565b601f8111600114612268575050600090555b388080612248565b908291859384528480601f848720930160051c830192015b828110612297575050506000908320915555612260565b60008155879550869101612280565b634e487b7160e01b8852601160045287fd5b50634e487b7160e01b8752603160045286fd5b50634e487b7160e01b8752601160045286fd5b50634e487b7160e01b8652604160045285fd5b6122fa9061299d565b600019810190811161237d57838752600885526040872054818103612341575b50838752600060408820558287526007855260408720908752845260006040872055612138565b8388526007865260408820828952865260408820548489526007875260408920828a5287528060408a205588526008865260408820553861231a565b50634e487b7160e01b8652601160045285fd5b60405162461bcd60e51b815260048101869052601481840152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606490fd5b84634e487b7160e01b60005260116004526000fd5b6123e990612763565b6123f4578938612076565b8980fd5b612404909a919a612763565b9838612048565b6040513d8d823e3d90fd5b61242b9192503d808c833e610f0f81836127ac565b9038612006565b6040513d8c823e3d90fd5b8661245f60405192839262461bcd60e51b845260048401526024830190612707565b0390fd5b5060405161247081612776565b60168152751c1bdbdb08185b1c9958591e4819195cdd1c9bde595960521b87820152611fca565b634e487b7160e01b89526041600452602489fd5b503461029c5760206124ca6124bf366126aa565b939490919294613213565b80516001600160a01b03958616908616149490929085612536575b50508361251b575b5082612500575b50506040519015158152f35b608001516001600160801b03918216911614905082806124f4565b60608201516001600160601b039182169116149250846124ed565b868401518116911614935085806124e5565b503461029c57602036600319011261029c5760043563ffffffff60e01b81168091036102745760209063780e9d6360e01b811490811561258e575b506040519015158152f35b6380ac58cd60e01b8114915081156125da575b81156125af575b5082612583565b630271189760e51b8114915081156125c9575b50826125a8565b6301ffc9a760e01b149050826125c2565b635b5e139f60e01b811491506125a1565b503461029c5760206125ff6124bf366126aa565b80516001600160a01b0395861690861614949092908561266c575b505083612650575b50826126345750506040519015158152f35b608001516001600160801b0390811691161015905082806124f4565b60608201516001600160601b0390811691161015925084612622565b8684015181169116149350858061261a565b600435906001600160a01b03821682036117c657565b602435906001600160a01b03821682036117c657565b60a09060031901126117c657600435906001600160a01b039060243582811681036117c6579160443590811681036117c657906064356001600160601b03811681036117c657906084356001600160801b03811681036117c65790565b919082519283825260005b848110612733575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201612712565b61010081019081106001600160401b0382111761173357604052565b6001600160401b03811161173357604052565b604081019081106001600160401b0382111761173357604052565b602081019081106001600160401b0382111761173357604052565b90601f801991011681019081106001600160401b0382111761173357604052565b6001600160401b03811161173357601f01601f191660200190565b81601f820112156117c6578035906127ff826127cd565b9261280d60405194856127ac565b828452602083830101116117c657816000926020809301838601378301015290565b9060806003198301126117c6576001600160a01b039160043583811681036117c6579260243590811681036117c6579160443591606435906001600160401b0382116117c657612881916004016127e8565b90565b90815180825260208080930193019160005b8281106128a4575050505090565b835185529381019392810192600101612896565b60609060031901126117c6576001600160a01b039060043582811681036117c6579160243590811681036117c6579060443590565b9181601f840112156117c6578235916001600160401b0383116117c6576020808501948460051b0101116117c657565b6001600160401b0381116117335760051b60200190565b929161293f8261291d565b9161294d60405193846127ac565b829481845260208094019160051b81019283116117c657905b8282106129735750505050565b81358152908301908301612966565b9080601f830112156117c65781602061288193359101612934565b6001600160a01b031680156129bd57600052600460205260406000205490565b60405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608490fd5b15612a1b57565b60405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606490fd5b6000908152600360205260409020546001600160a01b0316612881811515612a14565b90600182811c92168015612ab3575b6020831014612a9d57565b634e487b7160e01b600052602260045260246000fd5b91607f1691612a92565b600081815260036020526040902054612ae0906001600160a01b03161515612a14565b6000908152600560205260409020546001600160a01b031690565b15612b0257565b60405162461bcd60e51b815260206004820152602e60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526d1c881b9bdc88185c1c1c9bdd995960921b6064820152608490fd5b60809060208152603260208201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60608201520190565b15612bb857565b60405162461bcd60e51b81528061245f60048201612b5e565b906001600160a01b038080612be584612a60565b16931691838314938415612c18575b508315612c02575b50505090565b612c0e91929350612abd565b1614388080612bfc565b909350600052600660205260406000208260005260205260ff604060002054169238612bf4565b90612c4983612a60565b6001600160a01b0383811692918116839003612e5c578116928315612e0b5782612d75575060095484600052600a60205280604060002055600160401b811015611733578461211d826001612ca194016009556130a2565b818303612d42575b50612cb383612eaf565b60008181526004602052604081208054600019810191908211612d2e575582815260046020526040812080549060018201809211612d2e575583815260036020526040812080546001600160a01b031916841790557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b634e487b7160e01b83526011600452602483fd5b612d4b9061299d565b60406000848152600760205281812083825260205285828220558581526008602052205538612ca9565b838303612d83575b50612ca1565b612d8c9061299d565b6000198101908111611749576000908582526020906008825260409182842054828103612dd4575b508784528383812055858452600781528284209184525281205538612d7d565b8685526007825283852083865282528385205487865260078352848620828752835280858720558552600882528385205538612db4565b60405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b60405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608490fd5b600081815260056020526040812080546001600160a01b03191690556001600160a01b03612edc83612a60565b167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258280a4565b3d15612f2e573d90612f14826127cd565b91612f2260405193846127ac565b82523d6000602084013e565b606090565b9091600091803b1561301e57612f7e6020918493604051948580948193630a85bd0160e11b9a8b84523360048501528460248501526044840152608060648401526084830190612707565b03926001600160a01b03165af190829082612fd6575b5050612fc857612fa2612f03565b80519081612fc35760405162461bcd60e51b81528061245f60048201612b5e565b602001fd5b6001600160e01b0319161490565b909192506020813d8211613016575b81612ff2602093836127ac565b810103126102745751906001600160e01b03198216820361029c5750903880612f94565b3d9150612fe5565b50505050600190565b91926000929190813b156130985760209161307d9185604051958680958194630a85bd0160e11b9b8c845233600485015260018060a01b0380951660248501526044840152608060648401526084830190612707565b0393165af190829082612fd6575050612fc857612fa2612f03565b5050505050600190565b6009548110156130d95760096000527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0190600090565b634e487b7160e01b600052603260045260246000fd5b156130f657565b60405162461bcd60e51b81526020600482015260116024820152703ab730b8383937bb32b21031b0b63632b960791b6044820152606490fd5b60209081818403126117c6578051906001600160401b0382116117c657019180601f840112156117c65782516131648161291d565b9361317260405195866127ac565b818552838086019260051b8201019283116117c6578301905b828210613199575050505090565b8151815290830190830161318b565b908160209103126117c657516001600160801b03811681036117c65790565b156131ce57565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b60e0906040918291825161322681612747565b600092818480935282602082015282868201528260608201528260808201528260a08201528260c082015201528152600e60205220906132e681519261326b84612747565b600560018060a01b0391828154168652826001820154166020870152600281015492831692838688015260a01c606087015260038101546001600160801b038116608088015260801c60a0870152600481015460c0870152015460e085015260018060a01b0316600052600d60205260ff6040600020541690565b156132ef575090565b5162461bcd60e51b8152602060048201526012602482015271706f6f6c206d75737420626520616c69766560701b6044820152606490fd5b81835290916001600160fb1b0383116117c65760209260051b809284830137010190565b80518210156130d95760209160051b010190565b91949360005b8151811015613489576001600160a01b0385811690613384838561334b565b5190823b156117c65760408051632142170760e11b81526001600160a01b03888116600480840191909152908d166024830152604482019490945290929060008160648183895af1801561347e5761346f575b5030828c16146133ee575b50505050600101613365565b6133f8858761334b565b5193803b156117c657835163095ea7b360e01b81529289166001600160a01b03169183019182526020820194909452909260009184919082908490829060400103925af190811561346557509060019291613456575b8192816133e2565b61345f90612763565b3861344e565b513d6000823e3d90fd5b61347890612763565b386133d7565b84513d6000823e3d90fd5b50505050509050565b6000828152600360205260409020549091906001600160a01b0316156134cc576134bb90612a60565b6001600160a01b0390811691161490565b5050600090565b156134da57565b60405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606490fd5b90919015613517575090565b8151156135275750805190602001fd5b60405162461bcd60e51b81526020600482015290819061245f906024830190612707565b1561355257565b60405162461bcd60e51b815260206004820152602760248201527f63616c6c207573654c50546f6b656e546f44657374726f7944697265637450616044820152666972455448282960c81b6064820152608490fdfea2646970667358221220413977c7ea349ce53a668851ebf1953be33447cf74f60cf846da6cdf6476300464736f6c63430008110033000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9

Deployed ByteCode

0x6080604052600436101561001b575b361561001957600080fd5b005b6000803560e01c80630110f188146125eb57806301ffc9a714612548578063029032e6146124ab57806306fd072d14611eac57806306fdde0314611e08578063081812fc14611de9578063095ea7b314611c6f578063150b7a0214611c4b57806318160ddd14611c2d5780632376583614611ba557806323b872dd14611b805780632f745c5914611ad35780633d7c1bfc14611a9657806342842e0e14611a6357806345b56380146118ba5780634f6ccce7146118285780636352211e146117f757806370a08231146117cb57806387141f021461120457806388934a06146111d25780638da5cb5b146111ab57806395d89b41146110c6578063a22cb46514610ff4578063b88d4fde14610fb2578063bc197c8114610f29578063c481d84114610bda578063c5cc6b6a14610b95578063c6d2562314610943578063c87b56dd14610835578063cdb71d0d146107a6578063e985e9c514610752578063ef8673691461053b578063f04e0634146102f5578063f23a6e611461029f5763f2fde38b146101a8575061000e565b3461029c57602036600319011261029c576101c161267e565b81546001600160a01b03338183160361028a5782168015610278578084926001600160601b0360a01b1617825560405192817f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc6861638480a23b610220575080f35b803b1561027457826024818480946314e8368d60e31b83523360048401525af19182610260575b505061025b57610255612f03565b50388180f35b388180f35b61026990612763565b610274578138610247565b5080fd5b604051633b7c6c7f60e21b8152600490fd5b604051635eee3ad160e01b8152600490fd5b80fd5b503461029c5760a036600319011261029c576102b961267e565b506102c2612694565b506084356001600160401b038111610274576102e29036906004016127e8565b5060405163f23a6e6160e01b8152602090f35b503461029c57606036600319011261029c576001600160a01b036004358181169081900361047157826024359260443580156000146104ba575061033c91541633146134d3565b60405163a9059cbb60e01b602080830191825233602484015260448084019590955293825290919061036f6064846127ac565b6040519261037c84612776565b8484527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656485850152823b15610475576103c79392869283809351925af16103c1612f03565b9061350b565b8051806103f7575b837f549639b4800706ffeb7175ba0c6b929284789667d40a584575117d43f5df269b8180a180f35b81839181010312610471578101518015908115036104715761041a5780806103cf565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b8280fd5b60405162461bcd60e51b815260048101869052601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b906104da6104df91838552600e6020526002604086200154169233613492565b6130ef565b803b15610274578180916044604051809481936350edcbc160e11b83528860048401528960248401525af180156105305761051c575b505061033c565b61052590612763565b610471578238610515565b6040513d84823e3d90fd5b503461029c57606036600319011261029c5761055561267e565b816024356001600160401b038111610274576105759036906004016128ed565b9060443580610645575061059360018060a01b0384541633146134d3565b9290925b6001600160a01b0390911690825b8481106105d457837ff0d8db23b8f0b8d1dea970ce598d5903cc446f99d2a1c3995ffdb1b770c1ba8e8180a180f35b823b1561063657604051632142170760e11b8152306004820152336024820152600582901b8301356044820152848160648183885af190811561063a578591610622575b50506001016105a5565b61062b90612763565b610636578338610618565b8380fd5b6040513d87823e3d90fd5b808452600e60205260408420906106dd6040519161066283612747565b6106cf6104da60018060a01b03928387541686528360018801541660208701526005600288015497858916988960408a015260a01c606089015260038101546001600160801b03811660808a015260801c60a0890152600481015460c0890152015460e087015233613492565b80881692511682141561354b565b813b1561074e5784906040519283916313edab8160e01b8352600483015260406024830152818381610713604482018a8a613327565b03925af190811561074357849161072f575b5050929092610597565b61073890612763565b610471578238610725565b6040513d86823e3d90fd5b8480fd5b503461029c57604036600319011261029c5761076c61267e565b6040610776612694565b9260018060a01b0380931681526006602052209116600052602052602060ff604060002054166040519015158152f35b503461029c57602036600319011261029c576101006107c6600435613213565b60e06040519160018060a01b0380825116845280602083015116602085015260408201511660408401526001600160601b0360608201511660608401526001600160801b0380608083015116608085015260a08201511660a084015260c081015160c0840152015160e0820152f35b503461029c576020908160031936011261029c5750600435600081815260036020526040902054610870906001600160a01b03161515612a14565b600052600b815260406000209060405191826000825461088f81612a83565b938484526001918683821691826000146109215750506001146108e2575b50506108bb925003836127ac565b60006040516108c981612791565b526108de604051928284938452830190612707565b0390f35b85925060005281600020906000915b8583106109095750506108bb935082010138806108ad565b805483890185015287945086939092019181016108f1565b92509350506108bb94915060ff191682840152151560051b82010138806108ad565b503461029c5780600319608036820112610b92576001600160a01b039060043582811690819003610b8d576001600160401b0390602435828111610b895761098f9036906004016128ed565b9092604435908111610a6d576109a99036906004016128ed565b956064359081610a71576109c2915088541633146134d3565b823b15610a6d576020879586610a168194610a069a6040519b8c9a8b99631759616b60e11b8b523060048c01523360248c015260a060448c015260a48b0191613327565b91858984030160648a0152613327565b85810392830160848701525201925af1801561053057610a59575b50807fcc85acda6e8701522b69958b6ba1a9043bf9befffda96482e4b8665d5746760591a180f35b610a6290612763565b61029c578038610a31565b8680fd5b610afe90828a52600e60205260408a2092610af46104da60405192610a9584612747565b84875416845284600188015416602085015260056002880154978689169889604088015260a01c606087015260038101546001600160801b038116608088015260801c60a0870152600481015460c0870152015460e085015233613492565b511685141561354b565b803b15610b855787610b3d8892878388610b4d8c6040519889978896879563a5ceac9960e01b87526004870152606060248701528d6064870191613327565b918483030160448501528a613327565b03925af1908115610b7a578891610b66575b50506109c2565b610b6f90612763565b610a6d578638610b5f565b6040513d8a823e3d90fd5b8780fd5b8580fd5b505050fd5b50fd5b503461029c578060031936011261029c576040517f000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c96001600160a01b03168152602090f35b503461029c57602036600319011261029c576004358152600e6020526040812060405190610c0782612747565b60018060a01b03815416825260018060a01b0360018201541691602081019283526002820154906005604082019360018060a01b03841685528360a01c606084015260038101546001600160801b038116608085015260801c60a0840152600481015460c0840152015460e0820152610c856104da60043533613492565b604051632f4fefaf60e01b81529085826004816001600160a01b0387165afa918215610f1e578692610efa575b50519351925160405163ddca3f4360e01b81526001600160a01b0395861695948516949182169390916020908390600490829085165afa918215610eef578792610eab575b5060405163025692b560e31b8152916020836004816001600160a01b0386165afa928315610b7a578893610e8a575b50604051630730905b60e31b8152956020876004816001600160a01b0387165afa928315610e7f576005978a94610e4e575b5060018060a01b03163194519560405198610d728a612747565b895260208901918252604089019081526001600160601b0360608a01931683526001600160801b0360808a01951685526001600160801b0360a08a019416845260c0890195865260e089019687526004358a52600e60205260408a209860018060a01b03905116916001600160601b0360a01b92838b5416178a5560018a019060018060a01b039051168382541617905560018060a01b03905116915160a01b161760028701556001600160801b0360038701925116878354926001600160801b0319905160801b169216171790555160048401555191015580f35b610e7191945060203d602011610e78575b610e6981836127ac565b8101906131a8565b9238610d58565b503d610e5f565b6040513d8b823e3d90fd5b610ea491935060203d602011610e7857610e6981836127ac565b9138610d26565b9091506020813d602011610ee7575b81610ec7602093836127ac565b81010312610a6d57516001600160601b0381168103610a6d579038610cf7565b3d9150610eba565b6040513d89823e3d90fd5b610f179192503d8088833e610f0f81836127ac565b81019061312f565b9038610cb2565b6040513d88823e3d90fd5b503461029c5760a036600319011261029c57610f4361267e565b50610f4c612694565b506001600160401b0360443581811161047157610f6d903690600401612982565b5060643581811161047157610f86903690600401612982565b5060843590811161027457610f9f9036906004016127e8565b5060405163bc197c8160e01b8152602090f35b503461029c57610ff1610fec610fc73661282f565b92610fdc610fd783949333612bd1565b612afb565b610fe7838383612c3f565b613027565b612bb1565b80f35b503461029c57604036600319011261029c5761100e61267e565b60243590811515809203610471576001600160a01b0316903382146110815733835260066020526040832082600052602052604060002060ff1981541660ff83161790556040519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a380f35b60405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606490fd5b503461029c578060031936011261029c5760405190806002546110e881612a83565b808552916001918083169081156111815750600114611126575b6108de85611112818703826127ac565b604051918291602083526020830190612707565b9250600283527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace5b828410611169575050508101602001611112826108de611102565b8054602085870181019190915290930192810161114e565b8695506108de9693506020925061111294915060ff191682840152151560051b8201019293611102565b503461029c578060031936011261029c57546040516001600160a01b039091168152602090f35b503461029c57604036600319011261029c5760206111fa6111f161267e565b60243590613492565b6040519015158152f35b5060c036600319011261029c5761121961267e565b602435906001600160a01b0382168203610471576044356001600160801b03811681036117c657606435906001600160601b03821682036117c657608435906001600160801b03821682036117c65760a4356001600160401b038111610a6d576112879036906004016128ed565b9390956112996002600c5414156131c7565b6002600c556112d56112ac36878a612934565b8730337f000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c961335f565b60405163ce9c095d60e01b81526001600160a01b03878116600483015282166024820152604481018990529660037f000000000000000000000000000000000000000000000000000000000000000210156117b25787806113996020937f000000000000000000000000000000000000000000000000000000000000000260648401526001600160801b03881660848401526001600160601b03871660a48401526001600160801b03891660c484015261010060e484015289610104840191613327565b0381347f000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c96001600160a01b03165af1968715610b7a57889761175f575b50916001600160601b036001600160801b039493928593604051986113fa8a612747565b6001600160a01b039081168a5290811660208a0152891660408901521660608701521660808501521660a08301523460c083015260e0820152600f5460001981146117495760018101600f55600181018452600e602052604084209160018060a01b03815116926001600160601b0360a01b93848254161781556001810160018060a01b0360208401511685825416179055600560e060018060a01b036040850151169386606082015160a01b1685176002850155600384016001600160801b036080830151168154908b6001600160801b031960a086015160801b1692161717905560c0810151600485015501519101558452600d60205260408420600160ff198254161790557f8a1767404395cfcd1267c6537e872277dde277a29ac6dea742a111469f324a586020604051600184018152a160405191602083018381106001600160401b038211176117335760405284835233156116ef57600182016000908152600360205260409020546001600160a01b03166116aa57600954600183018652600a602052806040872055600160401b811015611696576115a88160016115c593016009556130a2565b600185019082549060031b600019811b9283911b16911916179055565b6115ce3361299d565b3386526007602052604086208187526020526001830160408720556001830186526008602052604086205533855260046020526040852080549060018201809211611682579260209661166b9593600193610fec9655838301825260038952604082209033908254161790558282019033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a40133612f33565b6001600c556040516001600160a01b039091168152f35b634e487b7160e01b87526011600452602487fd5b634e487b7160e01b86526041600452602486fd5b60405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606490fd5b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b9096506020939293813d6020116117aa575b8161177e602093836127ac565b81010312610b855751926001600160a01b0384168403610b855792959192916001600160601b036113d6565b3d9150611771565b634e487b7160e01b89526021600452602489fd5b600080fd5b503461029c57602036600319011261029c5760206117ef6117ea61267e565b61299d565b604051908152f35b503461029c57602036600319011261029c576020611816600435612a60565b6040516001600160a01b039091168152f35b503461029c57602036600319011261029c57600435600954811015611860576118526020916130a2565b90546040519160031b1c8152f35b60405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608490fd5b503461029c576020908160031936011261029c5760e0906004358152600e83526040812090604051916118ec83612747565b60018060a01b0392838254168152600193808584015416878301526002830154908116604083015260a01c606082015260038201546001600160801b038116608083015260801c60a082015260056004830154928360c084015201549485910152838102938185041490151715611a4f57508082600160801b811015611a3d575b80600160401b6008921015611a31575b640100000000811015611a25575b62010000811015611a19575b610100811015611a0d575b6010811015611a00575b10156119f9575b80830401811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c8091048181106119f1575b50604051908152f35b9050386119e8565b811b6119b3565b60041c9160021b916119ac565b811c9160041b916119a2565b60101c91811b91611997565b851c9160101b9161198b565b60401c91851b9161197d565b50600160401b9050608083901c61196d565b634e487b7160e01b81526011600452602490fd5b503461029c57610ff1610fec611a78366128b8565b9060405192611a8684612791565b868452610fdc610fd78433612bd1565b503461029c57602036600319011261029c5760206111fa611ab561267e565b6001600160a01b03166000908152600d602052604090205460ff1690565b503461029c57604036600319011261029c57611aed61267e565b60243591611afa8261299d565b831015611b275760209260409260018060a01b031682526007845282822090825283522054604051908152f35b60405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608490fd5b503461029c57610ff1611b92366128b8565b91611ba0610fd78433612bd1565b612c3f565b503461029c57602036600319011261029c57600480358252600e6020526040808320600201549051632f4fefaf60e01b815291839183919082906001600160a01b03165afa90811561053057826108de9392611c12575b5050604051918291602083526020830190612884565b611c2692503d8091833e610f0f81836127ac565b3880611bfc565b503461029c578060031936011261029c576020600954604051908152f35b503461029c57611c5a3661282f565b505050506020604051630a85bd0160e11b8152f35b503461029c57604036600319011261029c57611c8961267e565b602435906001600160a01b038080611ca085612a60565b16921691808314611d9a57803314908115611d77575b5015611d0c57600083815260056020526040902080546001600160a01b03191683179055611ce383612a60565b167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600080a480f35b60405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608490fd5b905084526006602052604084203360005260205260ff6040600020541638611cb6565b60405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608490fd5b503461029c57602036600319011261029c576020611816600435612abd565b503461029c578060031936011261029c5760405190806001805491611e2c83612a83565b808652928281169081156111815750600114611e52576108de85611112818703826127ac565b92508083527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b828410611e94575050508101602001611112826108de611102565b80546020858701810191909152909301928101611e79565b503461029c576020806003193601126102745760043590611ed26002600c5414156131c7565b6002600c55818352600e8152604083209160405192611ef084612747565b60018060a01b039081815416908186526001958387830154168682015260e060056002840154936040840194878116865260a01c606085015260038101546001600160801b038116608086015260801c60a0850152600481015460c08501520154910152604051606081018181106001600160401b0382111761249757604052602181527f6f6e6c7920746f6b656e206f776e65722063616e2064657374726f7920706f6f86820152601b60fa1b6040820152848852600e865283600260408a2001541690818952600d875260ff60408a20541615612463575b611fd48633613492565b1561243d57506040516311bb2c1b60e11b81526004810186905260249389828681305afa918215612432578a92612416575b50823b156123f4576040516313edab8160e01b81528160048201526040868201528a81806120376044820187612884565b038183885af1801561240b576123f8575b50894793803b15610274578180916004604051809481936390386bbf60e01b83525af18015610530576123e0575b5050479283039283116123cb578980936120b58294839433307f000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c961335f565b335af16120c0612f03565b5015612390575182168652600d845260408620805460ff191690556120e483612a60565b91821691826122f15750600954838752600a8552806040882055600160401b8110156122de578361211d828861213894016009556130a2565b90919082549060031b600019811b9283911b16911916179055565b60095460001991908281019081116122cb57848852600a865261215f6040892054916130a2565b90549060031b1c6121738161211d846130a2565b8852600a865260408820558387526000604088205560095480156122b857820161219c816130a2565b8482549160031b1b191690556009556121b484612eaf565b82875260048552604087209081549283019283116122a6575055818552600383526040852080546001600160a01b0319169055819085907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4600b82526122206040852054612a83565b61222d575b5050600c5580f35b8352600b815260408320906122428254612a83565b8061224e575b50612225565b601f8111600114612268575050600090555b388080612248565b908291859384528480601f848720930160051c830192015b828110612297575050506000908320915555612260565b60008155879550869101612280565b634e487b7160e01b8852601160045287fd5b50634e487b7160e01b8752603160045286fd5b50634e487b7160e01b8752601160045286fd5b50634e487b7160e01b8652604160045285fd5b6122fa9061299d565b600019810190811161237d57838752600885526040872054818103612341575b50838752600060408820558287526007855260408720908752845260006040872055612138565b8388526007865260408820828952865260408820548489526007875260408920828a5287528060408a205588526008865260408820553861231a565b50634e487b7160e01b8652601160045285fd5b60405162461bcd60e51b815260048101869052601481840152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606490fd5b84634e487b7160e01b60005260116004526000fd5b6123e990612763565b6123f4578938612076565b8980fd5b612404909a919a612763565b9838612048565b6040513d8d823e3d90fd5b61242b9192503d808c833e610f0f81836127ac565b9038612006565b6040513d8c823e3d90fd5b8661245f60405192839262461bcd60e51b845260048401526024830190612707565b0390fd5b5060405161247081612776565b60168152751c1bdbdb08185b1c9958591e4819195cdd1c9bde595960521b87820152611fca565b634e487b7160e01b89526041600452602489fd5b503461029c5760206124ca6124bf366126aa565b939490919294613213565b80516001600160a01b03958616908616149490929085612536575b50508361251b575b5082612500575b50506040519015158152f35b608001516001600160801b03918216911614905082806124f4565b60608201516001600160601b039182169116149250846124ed565b868401518116911614935085806124e5565b503461029c57602036600319011261029c5760043563ffffffff60e01b81168091036102745760209063780e9d6360e01b811490811561258e575b506040519015158152f35b6380ac58cd60e01b8114915081156125da575b81156125af575b5082612583565b630271189760e51b8114915081156125c9575b50826125a8565b6301ffc9a760e01b149050826125c2565b635b5e139f60e01b811491506125a1565b503461029c5760206125ff6124bf366126aa565b80516001600160a01b0395861690861614949092908561266c575b505083612650575b50826126345750506040519015158152f35b608001516001600160801b0390811691161015905082806124f4565b60608201516001600160601b0390811691161015925084612622565b8684015181169116149350858061261a565b600435906001600160a01b03821682036117c657565b602435906001600160a01b03821682036117c657565b60a09060031901126117c657600435906001600160a01b039060243582811681036117c6579160443590811681036117c657906064356001600160601b03811681036117c657906084356001600160801b03811681036117c65790565b919082519283825260005b848110612733575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201612712565b61010081019081106001600160401b0382111761173357604052565b6001600160401b03811161173357604052565b604081019081106001600160401b0382111761173357604052565b602081019081106001600160401b0382111761173357604052565b90601f801991011681019081106001600160401b0382111761173357604052565b6001600160401b03811161173357601f01601f191660200190565b81601f820112156117c6578035906127ff826127cd565b9261280d60405194856127ac565b828452602083830101116117c657816000926020809301838601378301015290565b9060806003198301126117c6576001600160a01b039160043583811681036117c6579260243590811681036117c6579160443591606435906001600160401b0382116117c657612881916004016127e8565b90565b90815180825260208080930193019160005b8281106128a4575050505090565b835185529381019392810192600101612896565b60609060031901126117c6576001600160a01b039060043582811681036117c6579160243590811681036117c6579060443590565b9181601f840112156117c6578235916001600160401b0383116117c6576020808501948460051b0101116117c657565b6001600160401b0381116117335760051b60200190565b929161293f8261291d565b9161294d60405193846127ac565b829481845260208094019160051b81019283116117c657905b8282106129735750505050565b81358152908301908301612966565b9080601f830112156117c65781602061288193359101612934565b6001600160a01b031680156129bd57600052600460205260406000205490565b60405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608490fd5b15612a1b57565b60405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606490fd5b6000908152600360205260409020546001600160a01b0316612881811515612a14565b90600182811c92168015612ab3575b6020831014612a9d57565b634e487b7160e01b600052602260045260246000fd5b91607f1691612a92565b600081815260036020526040902054612ae0906001600160a01b03161515612a14565b6000908152600560205260409020546001600160a01b031690565b15612b0257565b60405162461bcd60e51b815260206004820152602e60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526d1c881b9bdc88185c1c1c9bdd995960921b6064820152608490fd5b60809060208152603260208201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60608201520190565b15612bb857565b60405162461bcd60e51b81528061245f60048201612b5e565b906001600160a01b038080612be584612a60565b16931691838314938415612c18575b508315612c02575b50505090565b612c0e91929350612abd565b1614388080612bfc565b909350600052600660205260406000208260005260205260ff604060002054169238612bf4565b90612c4983612a60565b6001600160a01b0383811692918116839003612e5c578116928315612e0b5782612d75575060095484600052600a60205280604060002055600160401b811015611733578461211d826001612ca194016009556130a2565b818303612d42575b50612cb383612eaf565b60008181526004602052604081208054600019810191908211612d2e575582815260046020526040812080549060018201809211612d2e575583815260036020526040812080546001600160a01b031916841790557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b634e487b7160e01b83526011600452602483fd5b612d4b9061299d565b60406000848152600760205281812083825260205285828220558581526008602052205538612ca9565b838303612d83575b50612ca1565b612d8c9061299d565b6000198101908111611749576000908582526020906008825260409182842054828103612dd4575b508784528383812055858452600781528284209184525281205538612d7d565b8685526007825283852083865282528385205487865260078352848620828752835280858720558552600882528385205538612db4565b60405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b60405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608490fd5b600081815260056020526040812080546001600160a01b03191690556001600160a01b03612edc83612a60565b167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258280a4565b3d15612f2e573d90612f14826127cd565b91612f2260405193846127ac565b82523d6000602084013e565b606090565b9091600091803b1561301e57612f7e6020918493604051948580948193630a85bd0160e11b9a8b84523360048501528460248501526044840152608060648401526084830190612707565b03926001600160a01b03165af190829082612fd6575b5050612fc857612fa2612f03565b80519081612fc35760405162461bcd60e51b81528061245f60048201612b5e565b602001fd5b6001600160e01b0319161490565b909192506020813d8211613016575b81612ff2602093836127ac565b810103126102745751906001600160e01b03198216820361029c5750903880612f94565b3d9150612fe5565b50505050600190565b91926000929190813b156130985760209161307d9185604051958680958194630a85bd0160e11b9b8c845233600485015260018060a01b0380951660248501526044840152608060648401526084830190612707565b0393165af190829082612fd6575050612fc857612fa2612f03565b5050505050600190565b6009548110156130d95760096000527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0190600090565b634e487b7160e01b600052603260045260246000fd5b156130f657565b60405162461bcd60e51b81526020600482015260116024820152703ab730b8383937bb32b21031b0b63632b960791b6044820152606490fd5b60209081818403126117c6578051906001600160401b0382116117c657019180601f840112156117c65782516131648161291d565b9361317260405195866127ac565b818552838086019260051b8201019283116117c6578301905b828210613199575050505090565b8151815290830190830161318b565b908160209103126117c657516001600160801b03811681036117c65790565b156131ce57565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b60e0906040918291825161322681612747565b600092818480935282602082015282868201528260608201528260808201528260a08201528260c082015201528152600e60205220906132e681519261326b84612747565b600560018060a01b0391828154168652826001820154166020870152600281015492831692838688015260a01c606087015260038101546001600160801b038116608088015260801c60a0870152600481015460c0870152015460e085015260018060a01b0316600052600d60205260ff6040600020541690565b156132ef575090565b5162461bcd60e51b8152602060048201526012602482015271706f6f6c206d75737420626520616c69766560701b6044820152606490fd5b81835290916001600160fb1b0383116117c65760209260051b809284830137010190565b80518210156130d95760209160051b010190565b91949360005b8151811015613489576001600160a01b0385811690613384838561334b565b5190823b156117c65760408051632142170760e11b81526001600160a01b03888116600480840191909152908d166024830152604482019490945290929060008160648183895af1801561347e5761346f575b5030828c16146133ee575b50505050600101613365565b6133f8858761334b565b5193803b156117c657835163095ea7b360e01b81529289166001600160a01b03169183019182526020820194909452909260009184919082908490829060400103925af190811561346557509060019291613456575b8192816133e2565b61345f90612763565b3861344e565b513d6000823e3d90fd5b61347890612763565b386133d7565b84513d6000823e3d90fd5b50505050509050565b6000828152600360205260409020549091906001600160a01b0316156134cc576134bb90612a60565b6001600160a01b0390811691161490565b5050600090565b156134da57565b60405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606490fd5b90919015613517575090565b8151156135275750805190602001fd5b60405162461bcd60e51b81526020600482015290819061245f906024830190612707565b1561355257565b60405162461bcd60e51b815260206004820152602760248201527f63616c6c207573654c50546f6b656e546f44657374726f7944697265637450616044820152666972455448282960c81b6064820152608490fdfea2646970667358221220413977c7ea349ce53a668851ebf1953be33447cf74f60cf846da6cdf6476300464736f6c63430008110033