creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable\n    struct OwnableStorage {\n        address _owner;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Ownable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;\n\n    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {\n        assembly {\n            $.slot := OwnableStorageLocation\n        }\n    }\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    function __Ownable_init(address initialOwner) internal onlyInitializing {\n        __Ownable_init_unchained(initialOwner);\n    }\n\n    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        OwnableStorage storage $ = _getOwnableStorage();\n        return $._owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        OwnableStorage storage $ = _getOwnableStorage();\n        address oldOwner = $._owner;\n        $._owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Storage of the initializable contract.\n     *\n     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n     * when using with upgradeable contracts.\n     *\n     * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n     */\n    struct InitializableStorage {\n        /**\n         * @dev Indicates that the contract has been initialized.\n         */\n        uint64 _initialized;\n        /**\n         * @dev Indicates that the contract is in the process of being initialized.\n         */\n        bool _initializing;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n    /**\n     * @dev The contract is already initialized.\n     */\n    error InvalidInitialization();\n\n    /**\n     * @dev The contract is not initializing.\n     */\n    error NotInitializing();\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint64 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n     * production.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        // Cache values to avoid duplicated sloads\n        bool isTopLevelCall = !$._initializing;\n        uint64 initialized = $._initialized;\n\n        // Allowed calls:\n        // - initialSetup: the contract is not in the initializing state and no previous version was\n        //                 initialized\n        // - construction: the contract is initialized at version 1 (no reininitialization) and the\n        //                 current contract is just being deployed\n        bool initialSetup = initialized == 0 && isTopLevelCall;\n        bool construction = initialized == 1 && address(this).code.length == 0;\n\n        if (!initialSetup && !construction) {\n            revert InvalidInitialization();\n        }\n        $._initialized = 1;\n        if (isTopLevelCall) {\n            $._initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            $._initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint64 version) {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing || $._initialized >= version) {\n            revert InvalidInitialization();\n        }\n        $._initialized = version;\n        $._initializing = true;\n        _;\n        $._initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        _checkInitializing();\n        _;\n    }\n\n    /**\n     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n     */\n    function _checkInitializing() internal view virtual {\n        if (!_isInitializing()) {\n            revert NotInitializing();\n        }\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing) {\n            revert InvalidInitialization();\n        }\n        if ($._initialized != type(uint64).max) {\n            $._initialized = type(uint64).max;\n            emit Initialized(type(uint64).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint64) {\n        return _getInitializableStorage()._initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _getInitializableStorage()._initializing;\n    }\n\n    /**\n     * @dev Returns a pointer to the storage namespace.\n     */\n    // solhint-disable-next-line var-name-mixedcase\n    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n        assembly {\n            $.slot := INITIALIZABLE_STORAGE\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts/interfaces/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../utils/introspection/IERC165.sol\";\n"
      },
      "@openzeppelin/contracts/interfaces/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../token/ERC20/IERC20.sol\";\n"
      },
      "@openzeppelin/contracts/interfaces/IERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../token/ERC721/IERC721.sol\";\n"
      },
      "@openzeppelin/contracts/interfaces/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721Receiver.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721Receiver} from \"../token/ERC721/IERC721Receiver.sol\";\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n     *   {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be\n     * reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Muldiv operation overflow.\n     */\n    error MathOverflowedMulDiv();\n\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            return a / b;\n        }\n\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0 = x * y; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                revert MathOverflowedMulDiv();\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n            // works in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n     * towards zero.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Strings.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n    uint8 private constant ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev The `value` string doesn't fit in the specified `length`.\n     */\n    error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toStringSigned(int256 value) internal pure returns (string memory) {\n        return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        uint256 localValue = value;\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = HEX_DIGITS[localValue & 0xf];\n            localValue >>= 4;\n        }\n        if (localValue != 0) {\n            revert StringsInsufficientHexLength(value, length);\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n     * representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "contracts/ERC404.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\nimport {ERC404 as ERC404Base} from \"ERC404/contracts/ERC404.sol\";\n\ncontract ERC404 is Ownable, ERC404Base {\n  string public placeholderURI;\n  string public baseTokenURI;\n\n  constructor(\n    uint256 totalNonfungibleSupply_,\n    address owner_,\n    string memory name_,\n    string memory symbol_,\n    string memory placeholderURI_\n  ) ERC404Base(name_, symbol_, 18) Ownable(owner_) {\n    _setERC721TransferExempt(owner_, true);\n    _mintERC20(owner_, totalNonfungibleSupply_ * units);\n    placeholderURI = placeholderURI_;\n  }\n\n  function tokenURI(uint256 id) public view override returns (string memory) {\n    if (bytes(baseTokenURI).length > 0) {\n      return string.concat(baseTokenURI, Strings.toString(id));\n    } else {\n      return placeholderURI;\n    }\n  }\n\n  function setBaseTokenURI(string memory baseTokenURI_) external onlyOwner {\n    baseTokenURI = baseTokenURI_;\n  }\n\n  function setPlaceholderTokenURI(\n    string memory placeholderURI_\n  ) external onlyOwner {\n    placeholderURI = placeholderURI_;\n  }\n\n  function setERC721TransferExempt(\n    address account_,\n    bool value_\n  ) external onlyOwner {\n    _setERC721TransferExempt(account_, value_);\n  }\n}\n"
      },
      "contracts/Factory404V2.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {ERC404} from \"./ERC404.sol\";\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {Initializable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/interfaces/IERC721.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/interfaces/IERC20.sol\";\nimport {INonfungiblePositionManager} from \"./interfaces/INonfungiblePositionManager.sol\";\nimport {ILocker} from \"./interfaces/ILocker.sol\";\n\ncontract Factory404V2 is Initializable, OwnableUpgradeable {\n  /*************************************************/\n  /*                    ERRORS                     */\n  /*************************************************/\n\n  error NotLockOwner();\n\n  /*************************************************/\n  /*                    STRUCTS                    */\n  /*************************************************/\n\n  struct LPParam {\n    uint256 amount;\n    int24 tickLower;\n    int24 tickUpper;\n  }\n\n  struct LockData {\n    address owner;\n    address token;\n    uint256 tokenId;\n  }\n\n  /*************************************************/\n  /*                    EVENTS                     */\n  /*************************************************/\n\n  event TokenCreated(address indexed owner, address indexed token);\n\n  event LPCreated(\n    address indexed owner,\n    uint256 indexed lockId,\n    uint256 indexed tokenId\n  );\n\n  event PoolCreated(\n    address indexed token,\n    address indexed pool,\n    uint160 sqrtPriceX96\n  );\n\n  /*************************************************/\n  /*                   CONSTANTS                   */\n  /*************************************************/\n\n  uint24 private constant UNIV3_FEE_TIER = 10_000;\n  uint256 private constant FEE = 95_000;\n  uint256 private constant AIRDROP_FEE = 5_000;\n  uint256 private constant FEE_DENOMINATOR = 100_000;\n\n  /*************************************************/\n  /*                    STORAGE                    */\n  /*************************************************/\n\n  address public airdrop;\n  address public WETH;\n  address public locker;\n  address public uniswapV3NonfungiblePositionManager;\n  address public uniswapV3Factory;\n  address public uniswapV3Router;\n\n  function initialize(\n    address owner_,\n    address airdrop_,\n    address locker_,\n    address uniswapV3NonfungiblePositionManager_,\n    address uniswapV3Router_\n  ) public initializer {\n    // Set airdrop and fee addresses\n    airdrop = airdrop_;\n\n    // Set locker state\n    locker = locker_;\n    IERC721(uniswapV3NonfungiblePositionManager_).setApprovalForAll(\n      locker_,\n      true\n    );\n\n    // Set uniswap v3 state\n    _setUniswapV3State(uniswapV3NonfungiblePositionManager_, uniswapV3Router_);\n\n    // Initialize ownership\n    __Ownable_init(owner_);\n  }\n\n  function create404(\n    uint256 totalNonfungibleSupply_,\n    string memory name_,\n    string memory symbol_,\n    string memory placeholderURI_,\n    uint160 sqrtPriceX96Token0_,\n    uint160 sqrtPriceX96Token1_\n  ) external {\n    // Create 404\n    address token = _create404(\n      totalNonfungibleSupply_,\n      name_,\n      symbol_,\n      placeholderURI_\n    );\n\n    // Initialize pool\n    _createPool(token, sqrtPriceX96Token0_, sqrtPriceX96Token1_);\n\n    // Finalize creation step\n    _postCreate404(token);\n  }\n\n  function supplyLiquidity(\n    address token_,\n    address lockOwner_,\n    uint256 unlockTimestamp_,\n    LPParam[] memory lpParams_\n  ) external {\n    // Supply liquidity\n    _supplyLiquidity(token_, lockOwner_, unlockTimestamp_, lpParams_);\n  }\n\n  /*************************************************/\n  /*                    SETTERS                    */\n  /*************************************************/\n\n  function setAirdrop(address airdrop_) external onlyOwner {\n    airdrop = airdrop_;\n  }\n\n  function setUniswapV3State(\n    address uniswapV3NonfungiblePositionManager_,\n    address uniswapV3Router_\n  ) external onlyOwner {\n    _setUniswapV3State(uniswapV3NonfungiblePositionManager_, uniswapV3Router_);\n  }\n\n  /*************************************************/\n  /*                   INTERNAL                    */\n  /*************************************************/\n\n  function _create404(\n    uint256 totalNonfungibleSupply_,\n    string memory name_,\n    string memory symbol_,\n    string memory placeholderURI_\n  ) internal returns (address) {\n    // Create token\n    ERC404 token = new ERC404(\n      totalNonfungibleSupply_,\n      address(this),\n      name_,\n      symbol_,\n      placeholderURI_\n    );\n\n    // Exempt and transfer airdrop fee\n    uint256 fee = ((totalNonfungibleSupply_ * 10 ** token.decimals()) *\n      AIRDROP_FEE) / FEE_DENOMINATOR;\n    token.setERC721TransferExempt(airdrop, true);\n    token.transfer(airdrop, fee);\n\n    // Exempt pools, position manager, router, fee recipient and locker\n    token.setERC721TransferExempt(uniswapV3Router, true);\n    token.setERC721TransferExempt(uniswapV3NonfungiblePositionManager, true);\n    token.setERC721TransferExempt(locker, true);\n    token.setERC721TransferExempt(ILocker(locker).feeRecipient(), true);\n    token.setERC721TransferExempt(\n      _getUniswapV3Pair(address(token), UNIV3_FEE_TIER),\n      true\n    );\n\n    emit TokenCreated(msg.sender, address(token));\n    return address(token);\n  }\n\n  function _postCreate404(address token_) internal {\n    ERC404 token = ERC404(token_);\n\n    // Transfer tokens and ownership\n    token.setERC721TransferExempt(msg.sender, true);\n    token.transfer(msg.sender, token.balanceOf(address(this)));\n    token.transferOwnership(msg.sender);\n  }\n\n  function _createPool(\n    address token_,\n    uint160 sqrtPriceX96Token0_,\n    uint160 sqrtPriceX96Token1_\n  ) internal {\n    address token0;\n    address token1;\n    uint160 sqrtPriceX96;\n\n    if (WETH < token_) {\n      token0 = WETH;\n      token1 = token_;\n      sqrtPriceX96 = sqrtPriceX96Token1_;\n    } else {\n      token0 = token_;\n      token1 = WETH;\n      sqrtPriceX96 = sqrtPriceX96Token0_;\n    }\n\n    // Create a target fee tier pool\n    address pool = INonfungiblePositionManager(\n      uniswapV3NonfungiblePositionManager\n    ).createAndInitializePoolIfNecessary(\n        token0,\n        token1,\n        UNIV3_FEE_TIER,\n        sqrtPriceX96\n      );\n\n    emit PoolCreated(token_, pool, sqrtPriceX96);\n  }\n\n  function _supplyLiquidity(\n    address token_,\n    address lockOwner_,\n    uint256 unlockTimestamp_,\n    LPParam[] memory lpParams_\n  ) internal {\n    ERC404 token = ERC404(token_);\n    token.approve(uniswapV3NonfungiblePositionManager, type(uint256).max);\n\n    // Get ordered tokens\n    (address token0, address token1) = WETH < token_\n      ? (WETH, token_)\n      : (token_, WETH);\n\n    // Add liquidity for each provided range\n    for (uint256 i = 0; i < lpParams_.length; ) {\n      token.transferFrom(msg.sender, address(this), lpParams_[i].amount);\n\n      // Only adding one-sided liquidity\n      (uint256 amount0Desired, uint256 amount1Desired) = token0 == WETH\n        ? (uint256(0), lpParams_[i].amount)\n        : (lpParams_[i].amount, uint256(0));\n\n      INonfungiblePositionManager.MintParams\n        memory params = INonfungiblePositionManager.MintParams(\n          token0,\n          token1,\n          UNIV3_FEE_TIER,\n          lpParams_[i].tickLower,\n          lpParams_[i].tickUpper,\n          amount0Desired,\n          amount1Desired,\n          0,\n          0,\n          address(this),\n          block.timestamp\n        );\n\n      // Add underlying liquidity\n      (uint256 tokenId, , , ) = INonfungiblePositionManager(\n        uniswapV3NonfungiblePositionManager\n      ).mint(params);\n\n      // Lock liquidity\n      uint256 lockId = _lock(lockOwner_, tokenId, unlockTimestamp_);\n\n      emit LPCreated(msg.sender, lockId, tokenId);\n\n      unchecked {\n        ++i;\n      }\n    }\n  }\n\n  function _lock(\n    address lockOwner_,\n    uint256 tokenId_,\n    uint256 unlockTimestamp_\n  ) internal returns (uint256) {\n    // Lock liquidity\n    return\n      ILocker(locker).createLock(\n        lockOwner_,\n        address(0),\n        uniswapV3NonfungiblePositionManager,\n        tokenId_,\n        unlockTimestamp_\n      );\n  }\n\n  function _getUniswapV3Pair(\n    address token_,\n    uint24 fee_\n  ) internal view returns (address) {\n    (address token0, address token1) = token_ < WETH\n      ? (token_, WETH)\n      : (WETH, token_);\n\n    return\n      address(\n        uint160(\n          uint256(\n            keccak256(\n              abi.encodePacked(\n                hex\"ff\",\n                uniswapV3Factory,\n                keccak256(abi.encode(token0, token1, fee_)),\n                hex\"e34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54\"\n              )\n            )\n          )\n        )\n      );\n  }\n\n  function _setUniswapV3State(\n    address uniswapV3NonfungiblePositionManager_,\n    address uniswapV3Router_\n  ) internal {\n    uniswapV3NonfungiblePositionManager = uniswapV3NonfungiblePositionManager_;\n    uniswapV3Router = uniswapV3Router_;\n    uniswapV3Factory = INonfungiblePositionManager(\n      uniswapV3NonfungiblePositionManager\n    ).factory();\n    WETH = INonfungiblePositionManager(uniswapV3NonfungiblePositionManager)\n      .WETH9();\n  }\n}\n"
      },
      "contracts/interfaces/ILocker.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ILocker {\n  function createLock(\n    address owner_,\n    address collector_,\n    address uniswapV3NonfungiblePositionManager_,\n    uint256 tokenId_,\n    uint256 unlockTimestamp_\n  ) external returns (uint256 lockId);\n\n  function withdraw(uint256 lockId) external;\n\n  function collect(\n    uint256 lockId_,\n    uint128 amount0Max_,\n    uint128 amount1Max_,\n    address to_\n  ) external;\n\n  function relock(uint256 lockId_, uint256 unlockTimestamp_) external;\n\n  function setCollector(uint256 lockId_, address collector_) external;\n\n  function transferLock(uint256 lockId_, address owner_) external;\n\n  function feeRecipient() external view returns (address payable);\n}\n"
      },
      "contracts/interfaces/INonfungiblePositionManager.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface INonfungiblePositionManager {\n  function approve(address to, uint256 tokenId) external;\n\n  function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n  function transferFrom(address from, address to, uint256 tokenId) external;\n\n  struct MintParams {\n    address token0;\n    address token1;\n    uint24 fee;\n    int24 tickLower;\n    int24 tickUpper;\n    uint256 amount0Desired;\n    uint256 amount1Desired;\n    uint256 amount0Min;\n    uint256 amount1Min;\n    address recipient;\n    uint256 deadline;\n  }\n\n  function mint(\n    MintParams calldata params\n  )\n    external\n    payable\n    returns (\n      uint256 tokenId,\n      uint128 liquidity,\n      uint256 amount0,\n      uint256 amount1\n    );\n\n  struct Position {\n    uint96 nonce;\n    address operator;\n    address token0;\n    address token1;\n    uint24 fee;\n    int24 tickLower;\n    int24 tickUpper;\n    uint128 liquidity;\n    uint256 feeGrowthInside0LastX128;\n    uint256 feeGrowthInside1LastX128;\n    uint128 tokensOwed0;\n    uint128 tokensOwed1;\n  }\n\n  function positions(\n    uint256 tokenId\n  )\n    external\n    view\n    returns (\n      uint96 nonce,\n      address operator,\n      address token0,\n      address token1,\n      uint24 fee,\n      int24 tickLower,\n      int24 tickUpper,\n      uint128 liquidity,\n      uint256 feeGrowthInside0LastX128,\n      uint256 feeGrowthInside1LastX128,\n      uint128 tokensOwed0,\n      uint128 tokensOwed1\n    );\n\n  struct IncreaseLiquidityParams {\n    uint256 tokenId;\n    uint256 amount0Desired;\n    uint256 amount1Desired;\n    uint256 amount0Min;\n    uint256 amount1Min;\n    uint256 deadline;\n  }\n\n  /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\n  /// @param params tokenId The ID of the token for which liquidity is being increased,\n  /// amount0Desired The desired amount of token0 to be spent,\n  /// amount1Desired The desired amount of token1 to be spent,\n  /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\n  /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\n  /// deadline The time by which the transaction must be included to effect the change\n  /// @return liquidity The new liquidity amount as a result of the increase\n  /// @return amount0 The amount of token0 to acheive resulting liquidity\n  /// @return amount1 The amount of token1 to acheive resulting liquidity\n  function increaseLiquidity(\n    IncreaseLiquidityParams calldata params\n  )\n    external\n    payable\n    returns (uint128 liquidity, uint256 amount0, uint256 amount1);\n\n  struct DecreaseLiquidityParams {\n    uint256 tokenId;\n    uint128 liquidity;\n    uint256 amount0Min;\n    uint256 amount1Min;\n    uint256 deadline;\n  }\n\n  /// @notice Decreases the amount of liquidity in a position and accounts it to the position\n  /// @param params tokenId The ID of the token for which liquidity is being decreased,\n  /// amount The amount by which liquidity will be decreased,\n  /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\n  /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\n  /// deadline The time by which the transaction must be included to effect the change\n  /// @return amount0 The amount of token0 accounted to the position's tokens owed\n  /// @return amount1 The amount of token1 accounted to the position's tokens owed\n  function decreaseLiquidity(\n    DecreaseLiquidityParams calldata params\n  ) external payable returns (uint256 amount0, uint256 amount1);\n\n  struct CollectParams {\n    uint256 tokenId;\n    address recipient;\n    uint128 amount0Max;\n    uint128 amount1Max;\n  }\n\n  function collect(\n    CollectParams calldata params\n  ) external payable returns (uint256 amount0, uint256 amount1);\n\n  function factory() external view returns (address);\n\n  function WETH9() external view returns (address);\n\n  function burn(uint256 tokenId) external payable;\n\n  function createAndInitializePoolIfNecessary(\n    address token0,\n    address token1,\n    uint24 fee,\n    uint160 sqrtPriceX96\n  ) external payable returns (address pool);\n}\n"
      },
      "ERC404/contracts/ERC404.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {IERC721Receiver} from \"@openzeppelin/contracts/interfaces/IERC721Receiver.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport {IERC404} from \"./interfaces/IERC404.sol\";\nimport {DoubleEndedQueue} from \"./lib/DoubleEndedQueue.sol\";\nimport {ERC721Events} from \"./lib/ERC721Events.sol\";\nimport {ERC20Events} from \"./lib/ERC20Events.sol\";\n\nabstract contract ERC404 is IERC404 {\n  using DoubleEndedQueue for DoubleEndedQueue.Uint256Deque;\n\n  /// @dev The queue of ERC-721 tokens stored in the contract.\n  DoubleEndedQueue.Uint256Deque private _storedERC721Ids;\n\n  /// @dev Token name\n  string public name;\n\n  /// @dev Token symbol\n  string public symbol;\n\n  /// @dev Decimals for ERC-20 representation\n  uint8 public immutable decimals;\n\n  /// @dev Units for ERC-20 representation\n  uint256 public immutable units;\n\n  /// @dev Total supply in ERC-20 representation\n  uint256 public totalSupply;\n\n  /// @dev Current mint counter which also represents the highest\n  ///      minted id, monotonically increasing to ensure accurate ownership\n  uint256 public minted;\n\n  /// @dev Initial chain id for EIP-2612 support\n  uint256 internal immutable _INITIAL_CHAIN_ID;\n\n  /// @dev Initial domain separator for EIP-2612 support\n  bytes32 internal immutable _INITIAL_DOMAIN_SEPARATOR;\n\n  /// @dev Balance of user in ERC-20 representation\n  mapping(address => uint256) public balanceOf;\n\n  /// @dev Allowance of user in ERC-20 representation\n  mapping(address => mapping(address => uint256)) public allowance;\n\n  /// @dev Approval in ERC-721 representaion\n  mapping(uint256 => address) public getApproved;\n\n  /// @dev Approval for all in ERC-721 representation\n  mapping(address => mapping(address => bool)) public isApprovedForAll;\n\n  /// @dev Packed representation of ownerOf and owned indices\n  mapping(uint256 => uint256) internal _ownedData;\n\n  /// @dev Array of owned ids in ERC-721 representation\n  mapping(address => uint256[]) internal _owned;\n\n  /// @dev Addresses that are exempt from ERC-721 transfer, typically for gas savings (pairs, routers, etc)\n  mapping(address => bool) internal _erc721TransferExempt;\n\n  /// @dev EIP-2612 nonces\n  mapping(address => uint256) public nonces;\n\n  /// @dev Address bitmask for packed ownership data\n  uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;\n\n  /// @dev Owned index bitmask for packed ownership data\n  uint256 private constant _BITMASK_OWNED_INDEX = ((1 << 96) - 1) << 160;\n\n  /// @dev Constant for token id encoding\n  uint256 public constant ID_ENCODING_PREFIX = 1 << 255;\n\n  constructor(string memory name_, string memory symbol_, uint8 decimals_) {\n    name = name_;\n    symbol = symbol_;\n\n    if (decimals_ < 18) {\n      revert DecimalsTooLow();\n    }\n\n    decimals = decimals_;\n    units = 10 ** decimals;\n\n    // EIP-2612 initialization\n    _INITIAL_CHAIN_ID = block.chainid;\n    _INITIAL_DOMAIN_SEPARATOR = _computeDomainSeparator();\n  }\n\n  /// @notice Function to find owner of a given ERC-721 token\n  function ownerOf(\n    uint256 id_\n  ) public view virtual returns (address erc721Owner) {\n    erc721Owner = _getOwnerOf(id_);\n\n    if (!_isValidTokenId(id_)) {\n      revert InvalidTokenId();\n    }\n\n    if (erc721Owner == address(0)) {\n      revert NotFound();\n    }\n  }\n\n  function owned(\n    address owner_\n  ) public view virtual returns (uint256[] memory) {\n    return _owned[owner_];\n  }\n\n  function erc721BalanceOf(\n    address owner_\n  ) public view virtual returns (uint256) {\n    return _owned[owner_].length;\n  }\n\n  function erc20BalanceOf(\n    address owner_\n  ) public view virtual returns (uint256) {\n    return balanceOf[owner_];\n  }\n\n  function erc20TotalSupply() public view virtual returns (uint256) {\n    return totalSupply;\n  }\n\n  function erc721TotalSupply() public view virtual returns (uint256) {\n    return minted;\n  }\n\n  function getERC721QueueLength() public view virtual returns (uint256) {\n    return _storedERC721Ids.length();\n  }\n\n  function getERC721TokensInQueue(\n    uint256 start_,\n    uint256 count_\n  ) public view virtual returns (uint256[] memory) {\n    uint256[] memory tokensInQueue = new uint256[](count_);\n\n    for (uint256 i = start_; i < start_ + count_; ) {\n      tokensInQueue[i - start_] = _storedERC721Ids.at(i);\n\n      unchecked {\n        ++i;\n      }\n    }\n\n    return tokensInQueue;\n  }\n\n  /// @notice tokenURI must be implemented by child contract\n  function tokenURI(uint256 id_) public view virtual returns (string memory);\n\n  /// @notice Function for token approvals\n  /// @dev This function assumes the operator is attempting to approve\n  ///      an ERC-721 if valueOrId_ is a possibly valid ERC-721 token id.\n  ///      Unlike setApprovalForAll, spender_ must be allowed to be 0x0 so\n  ///      that approval can be revoked.\n  function approve(\n    address spender_,\n    uint256 valueOrId_\n  ) public virtual returns (bool) {\n    if (_isValidTokenId(valueOrId_)) {\n      erc721Approve(spender_, valueOrId_);\n    } else {\n      return erc20Approve(spender_, valueOrId_);\n    }\n\n    return true;\n  }\n\n  function erc721Approve(address spender_, uint256 id_) public virtual {\n    // Intention is to approve as ERC-721 token (id).\n    address erc721Owner = _getOwnerOf(id_);\n\n    if (\n      msg.sender != erc721Owner && !isApprovedForAll[erc721Owner][msg.sender]\n    ) {\n      revert Unauthorized();\n    }\n\n    getApproved[id_] = spender_;\n\n    emit ERC721Events.Approval(erc721Owner, spender_, id_);\n  }\n\n  /// @dev Providing type(uint256).max for approval value results in an\n  ///      unlimited approval that is not deducted from on transfers.\n  function erc20Approve(\n    address spender_,\n    uint256 value_\n  ) public virtual returns (bool) {\n    // Prevent granting 0x0 an ERC-20 allowance.\n    if (spender_ == address(0)) {\n      revert InvalidSpender();\n    }\n\n    allowance[msg.sender][spender_] = value_;\n\n    emit ERC20Events.Approval(msg.sender, spender_, value_);\n\n    return true;\n  }\n\n  /// @notice Function for ERC-721 approvals\n  function setApprovalForAll(address operator_, bool approved_) public virtual {\n    // Prevent approvals to 0x0.\n    if (operator_ == address(0)) {\n      revert InvalidOperator();\n    }\n    isApprovedForAll[msg.sender][operator_] = approved_;\n    emit ERC721Events.ApprovalForAll(msg.sender, operator_, approved_);\n  }\n\n  /// @notice Function for mixed transfers from an operator that may be different than 'from'.\n  /// @dev This function assumes the operator is attempting to transfer an ERC-721\n  ///      if valueOrId is a possible valid token id.\n  function transferFrom(\n    address from_,\n    address to_,\n    uint256 valueOrId_\n  ) public virtual returns (bool) {\n    if (_isValidTokenId(valueOrId_)) {\n      erc721TransferFrom(from_, to_, valueOrId_);\n    } else {\n      // Intention is to transfer as ERC-20 token (value).\n      return erc20TransferFrom(from_, to_, valueOrId_);\n    }\n\n    return true;\n  }\n\n  /// @notice Function for ERC-721 transfers from.\n  /// @dev This function is recommended for ERC721 transfers.\n  function erc721TransferFrom(\n    address from_,\n    address to_,\n    uint256 id_\n  ) public virtual {\n    // Prevent minting tokens from 0x0.\n    if (from_ == address(0)) {\n      revert InvalidSender();\n    }\n\n    // Prevent burning tokens to 0x0.\n    if (to_ == address(0)) {\n      revert InvalidRecipient();\n    }\n\n    if (from_ != _getOwnerOf(id_)) {\n      revert Unauthorized();\n    }\n\n    // Check that the operator is either the sender or approved for the transfer.\n    if (\n      msg.sender != from_ &&\n      !isApprovedForAll[from_][msg.sender] &&\n      msg.sender != getApproved[id_]\n    ) {\n      revert Unauthorized();\n    }\n\n    // We only need to check ERC-721 transfer exempt status for the recipient \n    // since the sender being ERC-721 transfer exempt means they have already \n    // had their ERC-721s stripped away during the rebalancing process.\n    if (erc721TransferExempt(to_)) {\n      revert RecipientIsERC721TransferExempt();\n    }\n\n    // Transfer 1 * units ERC-20 and 1 ERC-721 token.\n    // ERC-721 transfer exemptions handled above. Can't make it to this point if either is transfer exempt.\n    _transferERC20(from_, to_, units);\n    _transferERC721(from_, to_, id_);\n  }\n\n  /// @notice Function for ERC-20 transfers from.\n  /// @dev This function is recommended for ERC20 transfers\n  function erc20TransferFrom(\n    address from_,\n    address to_,\n    uint256 value_\n  ) public virtual returns (bool) {\n    // Prevent minting tokens from 0x0.\n    if (from_ == address(0)) {\n      revert InvalidSender();\n    }\n\n    // Prevent burning tokens to 0x0.\n    if (to_ == address(0)) {\n      revert InvalidRecipient();\n    }\n\n    uint256 allowed = allowance[from_][msg.sender];\n\n    // Check that the operator has sufficient allowance.\n    if (allowed != type(uint256).max) {\n      allowance[from_][msg.sender] = allowed - value_;\n    }\n\n    // Transferring ERC-20s directly requires the _transferERC20WithERC721 function.\n    // Handles ERC-721 exemptions internally.\n    return _transferERC20WithERC721(from_, to_, value_);\n  }\n\n  /// @notice Function for ERC-20 transfers.\n  /// @dev This function assumes the operator is attempting to transfer as ERC-20\n  ///      given this function is only supported on the ERC-20 interface.\n  ///      Treats even large amounts that are valid ERC-721 ids as ERC-20s.\n  function transfer(address to_, uint256 value_) public virtual returns (bool) {\n    // Prevent burning tokens to 0x0.\n    if (to_ == address(0)) {\n      revert InvalidRecipient();\n    }\n\n    // Transferring ERC-20s directly requires the _transferERC20WithERC721 function.\n    // Handles ERC-721 exemptions internally.\n    return _transferERC20WithERC721(msg.sender, to_, value_);\n  }\n\n  /// @notice Function for ERC-721 transfers with contract support.\n  /// This function only supports moving valid ERC-721 ids, as it does not exist on the ERC-20\n  /// spec and will revert otherwise.\n  function safeTransferFrom(\n    address from_,\n    address to_,\n    uint256 id_\n  ) public virtual {\n    safeTransferFrom(from_, to_, id_, \"\");\n  }\n\n  /// @notice Function for ERC-721 transfers with contract support and callback data.\n  /// This function only supports moving valid ERC-721 ids, as it does not exist on the\n  /// ERC-20 spec and will revert otherwise.\n  function safeTransferFrom(\n    address from_,\n    address to_,\n    uint256 id_,\n    bytes memory data_\n  ) public virtual {\n    if (!_isValidTokenId(id_)) {\n      revert InvalidTokenId();\n    }\n\n    transferFrom(from_, to_, id_);\n\n    if (\n      to_.code.length != 0 &&\n      IERC721Receiver(to_).onERC721Received(msg.sender, from_, id_, data_) !=\n      IERC721Receiver.onERC721Received.selector\n    ) {\n      revert UnsafeRecipient();\n    }\n  }\n\n  /// @notice Function for EIP-2612 permits (ERC-20 only).\n  /// @dev Providing type(uint256).max for permit value results in an\n  ///      unlimited approval that is not deducted from on transfers.\n  function permit(\n    address owner_,\n    address spender_,\n    uint256 value_,\n    uint256 deadline_,\n    uint8 v_,\n    bytes32 r_,\n    bytes32 s_\n  ) public virtual {\n    if (deadline_ < block.timestamp) {\n      revert PermitDeadlineExpired();\n    }\n\n    // permit cannot be used for ERC-721 token approvals, so ensure\n    // the value does not fall within the valid range of ERC-721 token ids.\n    if (_isValidTokenId(value_)) {\n      revert InvalidApproval();\n    }\n\n    if (spender_ == address(0)) {\n      revert InvalidSpender();\n    }\n\n    unchecked {\n      address recoveredAddress = ecrecover(\n        keccak256(\n          abi.encodePacked(\n            \"\\x19\\x01\",\n            DOMAIN_SEPARATOR(),\n            keccak256(\n              abi.encode(\n                keccak256(\n                  \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n                ),\n                owner_,\n                spender_,\n                value_,\n                nonces[owner_]++,\n                deadline_\n              )\n            )\n          )\n        ),\n        v_,\n        r_,\n        s_\n      );\n\n      if (recoveredAddress == address(0) || recoveredAddress != owner_) {\n        revert InvalidSigner();\n      }\n\n      allowance[recoveredAddress][spender_] = value_;\n    }\n\n    emit ERC20Events.Approval(owner_, spender_, value_);\n  }\n\n  /// @notice Returns domain initial domain separator, or recomputes if chain id is not equal to initial chain id\n  function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n    return\n      block.chainid == _INITIAL_CHAIN_ID\n        ? _INITIAL_DOMAIN_SEPARATOR\n        : _computeDomainSeparator();\n  }\n\n  function supportsInterface(\n    bytes4 interfaceId\n  ) public view virtual returns (bool) {\n    return\n      interfaceId == type(IERC404).interfaceId ||\n      interfaceId == type(IERC165).interfaceId;\n  }\n\n  /// @notice Function for self-exemption\n  function setSelfERC721TransferExempt(bool state_) public virtual {\n    _setERC721TransferExempt(msg.sender, state_);\n  }\n\n  /// @notice Function to check if address is transfer exempt\n  function erc721TransferExempt(\n    address target_\n  ) public view virtual returns (bool) {\n    return target_ == address(0) || _erc721TransferExempt[target_];\n  }\n\n  /// @notice For a token token id to be considered valid, it just needs\n  ///         to fall within the range of possible token ids, it does not\n  ///         necessarily have to be minted yet.\n  function _isValidTokenId(uint256 id_) internal pure returns (bool) {\n    return id_ > ID_ENCODING_PREFIX && id_ != type(uint256).max;\n  }\n\n  /// @notice Internal function to compute domain separator for EIP-2612 permits\n  function _computeDomainSeparator() internal view virtual returns (bytes32) {\n    return\n      keccak256(\n        abi.encode(\n          keccak256(\n            \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n          ),\n          keccak256(bytes(name)),\n          keccak256(\"1\"),\n          block.chainid,\n          address(this)\n        )\n      );\n  }\n\n  /// @notice This is the lowest level ERC-20 transfer function, which\n  ///         should be used for both normal ERC-20 transfers as well as minting.\n  /// Note that this function allows transfers to and from 0x0.\n  function _transferERC20(\n    address from_,\n    address to_,\n    uint256 value_\n  ) internal virtual {\n    // Minting is a special case for which we should not check the balance of\n    // the sender, and we should increase the total supply.\n    if (from_ == address(0)) {\n      totalSupply += value_;\n    } else {\n      // Deduct value from sender's balance.\n      balanceOf[from_] -= value_;\n    }\n\n    // Update the recipient's balance.\n    // Can be unchecked because on mint, adding to totalSupply is checked, and on transfer balance deduction is checked.\n    unchecked {\n      balanceOf[to_] += value_;\n    }\n\n    emit ERC20Events.Transfer(from_, to_, value_);\n  }\n\n  /// @notice Consolidated record keeping function for transferring ERC-721s.\n  /// @dev Assign the token to the new owner, and remove from the old owner.\n  /// Note that this function allows transfers to and from 0x0.\n  /// Does not handle ERC-721 exemptions.\n  function _transferERC721(\n    address from_,\n    address to_,\n    uint256 id_\n  ) internal virtual {\n    // If this is not a mint, handle record keeping for transfer from previous owner.\n    if (from_ != address(0)) {\n      // On transfer of an NFT, any previous approval is reset.\n      delete getApproved[id_];\n\n      uint256 updatedId = _owned[from_][_owned[from_].length - 1];\n      if (updatedId != id_) {\n        uint256 updatedIndex = _getOwnedIndex(id_);\n        // update _owned for sender\n        _owned[from_][updatedIndex] = updatedId;\n        // update index for the moved id\n        _setOwnedIndex(updatedId, updatedIndex);\n      }\n\n      // pop\n      _owned[from_].pop();\n    }\n\n    // Check if this is a burn.\n    if (to_ != address(0)) {\n      // If not a burn, update the owner of the token to the new owner.\n      // Update owner of the token to the new owner.\n      _setOwnerOf(id_, to_);\n      // Push token onto the new owner's stack.\n      _owned[to_].push(id_);\n      // Update index for new owner's stack.\n      _setOwnedIndex(id_, _owned[to_].length - 1);\n    } else {\n      // If this is a burn, reset the owner of the token to 0x0 by deleting the token from _ownedData.\n      delete _ownedData[id_];\n    }\n\n    emit ERC721Events.Transfer(from_, to_, id_);\n  }\n\n  /// @notice Internal function for ERC-20 transfers. Also handles any ERC-721 transfers that may be required.\n  // Handles ERC-721 exemptions.\n  function _transferERC20WithERC721(\n    address from_,\n    address to_,\n    uint256 value_\n  ) internal virtual returns (bool) {\n    uint256 erc20BalanceOfSenderBefore = erc20BalanceOf(from_);\n    uint256 erc20BalanceOfReceiverBefore = erc20BalanceOf(to_);\n\n    _transferERC20(from_, to_, value_);\n\n    // Preload for gas savings on branches\n    bool isFromERC721TransferExempt = erc721TransferExempt(from_);\n    bool isToERC721TransferExempt = erc721TransferExempt(to_);\n\n    // Skip _withdrawAndStoreERC721 and/or _retrieveOrMintERC721 for ERC-721 transfer exempt addresses\n    // 1) to save gas\n    // 2) because ERC-721 transfer exempt addresses won't always have/need ERC-721s corresponding to their ERC20s.\n    if (isFromERC721TransferExempt && isToERC721TransferExempt) {\n      // Case 1) Both sender and recipient are ERC-721 transfer exempt. No ERC-721s need to be transferred.\n      // NOOP.\n    } else if (isFromERC721TransferExempt) {\n      // Case 2) The sender is ERC-721 transfer exempt, but the recipient is not. Contract should not attempt\n      //         to transfer ERC-721s from the sender, but the recipient should receive ERC-721s\n      //         from the bank/minted for any whole number increase in their balance.\n      // Only cares about whole number increments.\n      uint256 tokensToRetrieveOrMint = (balanceOf[to_] / units) -\n        (erc20BalanceOfReceiverBefore / units);\n      for (uint256 i = 0; i < tokensToRetrieveOrMint; ) {\n        _retrieveOrMintERC721(to_);\n        unchecked {\n          ++i;\n        }\n      }\n    } else if (isToERC721TransferExempt) {\n      // Case 3) The sender is not ERC-721 transfer exempt, but the recipient is. Contract should attempt\n      //         to withdraw and store ERC-721s from the sender, but the recipient should not\n      //         receive ERC-721s from the bank/minted.\n      // Only cares about whole number increments.\n      uint256 tokensToWithdrawAndStore = (erc20BalanceOfSenderBefore / units) -\n        (balanceOf[from_] / units);\n      for (uint256 i = 0; i < tokensToWithdrawAndStore; ) {\n        _withdrawAndStoreERC721(from_);\n        unchecked {\n          ++i;\n        }\n      }\n    } else {\n      // Case 4) Neither the sender nor the recipient are ERC-721 transfer exempt.\n      // Strategy:\n      // 1. First deal with the whole tokens. These are easy and will just be transferred.\n      // 2. Look at the fractional part of the value:\n      //   a) If it causes the sender to lose a whole token that was represented by an NFT due to a\n      //      fractional part being transferred, withdraw and store an additional NFT from the sender.\n      //   b) If it causes the receiver to gain a whole new token that should be represented by an NFT\n      //      due to receiving a fractional part that completes a whole token, retrieve or mint an NFT to the recevier.\n\n      // Whole tokens worth of ERC-20s get transferred as ERC-721s without any burning/minting.\n      uint256 nftsToTransfer = value_ / units;\n      for (uint256 i = 0; i < nftsToTransfer; ) {\n        // Pop from sender's ERC-721 stack and transfer them (LIFO)\n        uint256 indexOfLastToken = _owned[from_].length - 1;\n        uint256 tokenId = _owned[from_][indexOfLastToken];\n        _transferERC721(from_, to_, tokenId);\n        unchecked {\n          ++i;\n        }\n      }\n\n      // If the transfer changes either the sender or the recipient's holdings from a fractional to a non-fractional\n      // amount (or vice versa), adjust ERC-721s.\n\n      // First check if the send causes the sender to lose a whole token that was represented by an ERC-721\n      // due to a fractional part being transferred.\n      //\n      // Process:\n      // Take the difference between the whole number of tokens before and after the transfer for the sender.\n      // If that difference is greater than the number of ERC-721s transferred (whole units), then there was\n      // an additional ERC-721 lost due to the fractional portion of the transfer.\n      // If this is a self-send and the before and after balances are equal (not always the case but often),\n      // then no ERC-721s will be lost here.\n      if (\n        erc20BalanceOfSenderBefore / units - erc20BalanceOf(from_) / units >\n        nftsToTransfer\n      ) {\n        _withdrawAndStoreERC721(from_);\n      }\n\n      // Then, check if the transfer causes the receiver to gain a whole new token which requires gaining\n      // an additional ERC-721.\n      //\n      // Process:\n      // Take the difference between the whole number of tokens before and after the transfer for the recipient.\n      // If that difference is greater than the number of ERC-721s transferred (whole units), then there was\n      // an additional ERC-721 gained due to the fractional portion of the transfer.\n      // Again, for self-sends where the before and after balances are equal, no ERC-721s will be gained here.\n      if (\n        erc20BalanceOf(to_) / units - erc20BalanceOfReceiverBefore / units >\n        nftsToTransfer\n      ) {\n        _retrieveOrMintERC721(to_);\n      }\n    }\n\n    return true;\n  }\n\n  /// @notice Internal function for ERC20 minting\n  /// @dev This function will allow minting of new ERC20s.\n  ///      If mintCorrespondingERC721s_ is true, and the recipient is not ERC-721 exempt, it will\n  ///      also mint the corresponding ERC721s.\n  /// Handles ERC-721 exemptions.\n  function _mintERC20(address to_, uint256 value_) internal virtual {\n    /// You cannot mint to the zero address (you can't mint and immediately burn in the same transfer).\n    if (to_ == address(0)) {\n      revert InvalidRecipient();\n    }\n\n    if (totalSupply + value_ > ID_ENCODING_PREFIX) {\n      revert MintLimitReached();\n    }\n\n    _transferERC20WithERC721(address(0), to_, value_);\n  }\n\n  /// @notice Internal function for ERC-721 minting and retrieval from the bank.\n  /// @dev This function will allow minting of new ERC-721s up to the total fractional supply. It will\n  ///      first try to pull from the bank, and if the bank is empty, it will mint a new token.\n  /// Does not handle ERC-721 exemptions.\n  function _retrieveOrMintERC721(address to_) internal virtual {\n    if (to_ == address(0)) {\n      revert InvalidRecipient();\n    }\n\n    uint256 id;\n\n    if (!_storedERC721Ids.empty()) {\n      // If there are any tokens in the bank, use those first.\n      // Pop off the end of the queue (FIFO).\n      id = _storedERC721Ids.popBack();\n    } else {\n      // Otherwise, mint a new token, should not be able to go over the total fractional supply.\n      ++minted;\n\n      // Reserve max uint256 for approvals\n      if (minted == type(uint256).max) {\n        revert MintLimitReached();\n      }\n\n      id = ID_ENCODING_PREFIX + minted;\n    }\n\n    address erc721Owner = _getOwnerOf(id);\n\n    // The token should not already belong to anyone besides 0x0 or this contract.\n    // If it does, something is wrong, as this should never happen.\n    if (erc721Owner != address(0)) {\n      revert AlreadyExists();\n    }\n\n    // Transfer the token to the recipient, either transferring from the contract's bank or minting.\n    // Does not handle ERC-721 exemptions.\n    _transferERC721(erc721Owner, to_, id);\n  }\n\n  /// @notice Internal function for ERC-721 deposits to bank (this contract).\n  /// @dev This function will allow depositing of ERC-721s to the bank, which can be retrieved by future minters.\n  // Does not handle ERC-721 exemptions.\n  function _withdrawAndStoreERC721(address from_) internal virtual {\n    if (from_ == address(0)) {\n      revert InvalidSender();\n    }\n\n    // Retrieve the latest token added to the owner's stack (LIFO).\n    uint256 id = _owned[from_][_owned[from_].length - 1];\n\n    // Transfer to 0x0.\n    // Does not handle ERC-721 exemptions.\n    _transferERC721(from_, address(0), id);\n\n    // Record the token in the contract's bank queue.\n    _storedERC721Ids.pushFront(id);\n  }\n\n  /// @notice Initialization function to set pairs / etc, saving gas by avoiding mint / burn on unnecessary targets\n  function _setERC721TransferExempt(\n    address target_,\n    bool state_\n  ) internal virtual {\n    if (target_ == address(0)) {\n      revert InvalidExemption();\n    }\n\n    // Adjust the ERC721 balances of the target to respect exemption rules.\n    // Despite this logic, it is still recommended practice to exempt prior to the target\n    // having an active balance.\n    if (state_) {\n      _clearERC721Balance(target_);\n    } else {\n      _reinstateERC721Balance(target_);\n    }\n\n    _erc721TransferExempt[target_] = state_;\n  }\n\n  /// @notice Function to reinstate balance on exemption removal\n  function _reinstateERC721Balance(address target_) private {\n    uint256 expectedERC721Balance = erc20BalanceOf(target_) / units;\n    uint256 actualERC721Balance = erc721BalanceOf(target_);\n\n    for (uint256 i = 0; i < expectedERC721Balance - actualERC721Balance; ) {\n      // Transfer ERC721 balance in from pool\n      _retrieveOrMintERC721(target_);\n      unchecked {\n        ++i;\n      }\n    }\n  }\n\n  /// @notice Function to clear balance on exemption inclusion\n  function _clearERC721Balance(address target_) private {\n    uint256 erc721Balance = erc721BalanceOf(target_);\n\n    for (uint256 i = 0; i < erc721Balance; ) {\n      // Transfer out ERC721 balance\n      _withdrawAndStoreERC721(target_);\n      unchecked {\n        ++i;\n      }\n    }\n  }\n\n  function _getOwnerOf(\n    uint256 id_\n  ) internal view virtual returns (address ownerOf_) {\n    uint256 data = _ownedData[id_];\n\n    assembly {\n      ownerOf_ := and(data, _BITMASK_ADDRESS)\n    }\n  }\n\n  function _setOwnerOf(uint256 id_, address owner_) internal virtual {\n    uint256 data = _ownedData[id_];\n\n    assembly {\n      data := add(\n        and(data, _BITMASK_OWNED_INDEX),\n        and(owner_, _BITMASK_ADDRESS)\n      )\n    }\n\n    _ownedData[id_] = data;\n  }\n\n  function _getOwnedIndex(\n    uint256 id_\n  ) internal view virtual returns (uint256 ownedIndex_) {\n    uint256 data = _ownedData[id_];\n\n    assembly {\n      ownedIndex_ := shr(160, data)\n    }\n  }\n\n  function _setOwnedIndex(uint256 id_, uint256 index_) internal virtual {\n    uint256 data = _ownedData[id_];\n\n    if (index_ > _BITMASK_OWNED_INDEX >> 160) {\n      revert OwnedIndexOverflow();\n    }\n\n    assembly {\n      data := add(\n        and(data, _BITMASK_ADDRESS),\n        and(shl(160, index_), _BITMASK_OWNED_INDEX)\n      )\n    }\n\n    _ownedData[id_] = data;\n  }\n}\n"
      },
      "ERC404/contracts/interfaces/IERC404.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/interfaces/IERC165.sol\";\n\ninterface IERC404 is IERC165 {\n  error NotFound();\n  error InvalidTokenId();\n  error AlreadyExists();\n  error InvalidRecipient();\n  error InvalidSender();\n  error InvalidSpender();\n  error InvalidOperator();\n  error UnsafeRecipient();\n  error RecipientIsERC721TransferExempt();\n  error Unauthorized();\n  error InsufficientAllowance();\n  error DecimalsTooLow();\n  error PermitDeadlineExpired();\n  error InvalidSigner();\n  error InvalidApproval();\n  error OwnedIndexOverflow();\n  error MintLimitReached();\n  error InvalidExemption();\n\n  function name() external view returns (string memory);\n  function symbol() external view returns (string memory);\n  function decimals() external view returns (uint8);\n  function totalSupply() external view returns (uint256);\n  function erc20TotalSupply() external view returns (uint256);\n  function erc721TotalSupply() external view returns (uint256);\n  function balanceOf(address owner_) external view returns (uint256);\n  function erc721BalanceOf(address owner_) external view returns (uint256);\n  function erc20BalanceOf(address owner_) external view returns (uint256);\n  function erc721TransferExempt(address account_) external view returns (bool);\n  function isApprovedForAll(\n    address owner_,\n    address operator_\n  ) external view returns (bool);\n  function allowance(\n    address owner_,\n    address spender_\n  ) external view returns (uint256);\n  function owned(address owner_) external view returns (uint256[] memory);\n  function ownerOf(uint256 id_) external view returns (address erc721Owner);\n  function tokenURI(uint256 id_) external view returns (string memory);\n  function approve(\n    address spender_,\n    uint256 valueOrId_\n  ) external returns (bool);\n  function erc20Approve(\n    address spender_,\n    uint256 value_\n  ) external returns (bool);\n  function erc721Approve(address spender_, uint256 id_) external;\n  function setApprovalForAll(address operator_, bool approved_) external;\n  function transferFrom(\n    address from_,\n    address to_,\n    uint256 valueOrId_\n  ) external returns (bool);\n  function erc20TransferFrom(\n    address from_,\n    address to_,\n    uint256 value_\n  ) external returns (bool);\n  function erc721TransferFrom(address from_, address to_, uint256 id_) external;\n  function transfer(address to_, uint256 amount_) external returns (bool);\n  function getERC721QueueLength() external view returns (uint256);\n  function getERC721TokensInQueue(\n    uint256 start_,\n    uint256 count_\n  ) external view returns (uint256[] memory);\n  function setSelfERC721TransferExempt(bool state_) external;\n  function safeTransferFrom(address from_, address to_, uint256 id_) external;\n  function safeTransferFrom(\n    address from_,\n    address to_,\n    uint256 id_,\n    bytes calldata data_\n  ) external;\n  function DOMAIN_SEPARATOR() external view returns (bytes32);\n  function permit(\n    address owner_,\n    address spender_,\n    uint256 value_,\n    uint256 deadline_,\n    uint8 v_,\n    bytes32 r_,\n    bytes32 s_\n  ) external;\n}\n"
      },
      "ERC404/contracts/lib/DoubleEndedQueue.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/DoubleEndedQueue.sol)\n// Modified by Pandora Labs to support native uint256 operations\npragma solidity ^0.8.20;\n\n/**\n * @dev A sequence of items with the ability to efficiently push and pop items (i.e. insert and remove) on both ends of\n * the sequence (called front and back). Among other access patterns, it can be used to implement efficient LIFO and\n * FIFO queues. Storage use is optimized, and all operations are O(1) constant time. This includes {clear}, given that\n * the existing queue contents are left in storage.\n *\n * The struct is called `Uint256Deque`. This data structure can only be used in storage, and not in memory.\n *\n * ```solidity\n * DoubleEndedQueue.Uint256Deque queue;\n * ```\n */\nlibrary DoubleEndedQueue {\n  /**\n   * @dev An operation (e.g. {front}) couldn't be completed due to the queue being empty.\n   */\n  error QueueEmpty();\n\n  /**\n   * @dev A push operation couldn't be completed due to the queue being full.\n   */\n  error QueueFull();\n\n  /**\n   * @dev An operation (e.g. {at}) couldn't be completed due to an index being out of bounds.\n   */\n  error QueueOutOfBounds();\n\n  /**\n   * @dev Indices are 128 bits so begin and end are packed in a single storage slot for efficient access.\n   *\n   * Struct members have an underscore prefix indicating that they are \"private\" and should not be read or written to\n   * directly. Use the functions provided below instead. Modifying the struct manually may violate assumptions and\n   * lead to unexpected behavior.\n   *\n   * The first item is at data[begin] and the last item is at data[end - 1]. This range can wrap around.\n   */\n  struct Uint256Deque {\n    uint128 _begin;\n    uint128 _end;\n    mapping(uint128 index => uint256) _data;\n  }\n\n  /**\n   * @dev Inserts an item at the end of the queue.\n   *\n   * Reverts with {QueueFull} if the queue is full.\n   */\n  function pushBack(Uint256Deque storage deque, uint256 value) internal {\n    unchecked {\n      uint128 backIndex = deque._end;\n      if (backIndex + 1 == deque._begin) revert QueueFull();\n      deque._data[backIndex] = value;\n      deque._end = backIndex + 1;\n    }\n  }\n\n  /**\n   * @dev Removes the item at the end of the queue and returns it.\n   *\n   * Reverts with {QueueEmpty} if the queue is empty.\n   */\n  function popBack(\n    Uint256Deque storage deque\n  ) internal returns (uint256 value) {\n    unchecked {\n      uint128 backIndex = deque._end;\n      if (backIndex == deque._begin) revert QueueEmpty();\n      --backIndex;\n      value = deque._data[backIndex];\n      delete deque._data[backIndex];\n      deque._end = backIndex;\n    }\n  }\n\n  /**\n   * @dev Inserts an item at the beginning of the queue.\n   *\n   * Reverts with {QueueFull} if the queue is full.\n   */\n  function pushFront(Uint256Deque storage deque, uint256 value) internal {\n    unchecked {\n      uint128 frontIndex = deque._begin - 1;\n      if (frontIndex == deque._end) revert QueueFull();\n      deque._data[frontIndex] = value;\n      deque._begin = frontIndex;\n    }\n  }\n\n  /**\n   * @dev Removes the item at the beginning of the queue and returns it.\n   *\n   * Reverts with `QueueEmpty` if the queue is empty.\n   */\n  function popFront(\n    Uint256Deque storage deque\n  ) internal returns (uint256 value) {\n    unchecked {\n      uint128 frontIndex = deque._begin;\n      if (frontIndex == deque._end) revert QueueEmpty();\n      value = deque._data[frontIndex];\n      delete deque._data[frontIndex];\n      deque._begin = frontIndex + 1;\n    }\n  }\n\n  /**\n   * @dev Returns the item at the beginning of the queue.\n   *\n   * Reverts with `QueueEmpty` if the queue is empty.\n   */\n  function front(\n    Uint256Deque storage deque\n  ) internal view returns (uint256 value) {\n    if (empty(deque)) revert QueueEmpty();\n    return deque._data[deque._begin];\n  }\n\n  /**\n   * @dev Returns the item at the end of the queue.\n   *\n   * Reverts with `QueueEmpty` if the queue is empty.\n   */\n  function back(\n    Uint256Deque storage deque\n  ) internal view returns (uint256 value) {\n    if (empty(deque)) revert QueueEmpty();\n    unchecked {\n      return deque._data[deque._end - 1];\n    }\n  }\n\n  /**\n   * @dev Return the item at a position in the queue given by `index`, with the first item at 0 and last item at\n   * `length(deque) - 1`.\n   *\n   * Reverts with `QueueOutOfBounds` if the index is out of bounds.\n   */\n  function at(\n    Uint256Deque storage deque,\n    uint256 index\n  ) internal view returns (uint256 value) {\n    if (index >= length(deque)) revert QueueOutOfBounds();\n    // By construction, length is a uint128, so the check above ensures that index can be safely downcast to uint128\n    unchecked {\n      return deque._data[deque._begin + uint128(index)];\n    }\n  }\n\n  /**\n   * @dev Resets the queue back to being empty.\n   *\n   * NOTE: The current items are left behind in storage. This does not affect the functioning of the queue, but misses\n   * out on potential gas refunds.\n   */\n  function clear(Uint256Deque storage deque) internal {\n    deque._begin = 0;\n    deque._end = 0;\n  }\n\n  /**\n   * @dev Returns the number of items in the queue.\n   */\n  function length(Uint256Deque storage deque) internal view returns (uint256) {\n    unchecked {\n      return uint256(deque._end - deque._begin);\n    }\n  }\n\n  /**\n   * @dev Returns true if the queue is empty.\n   */\n  function empty(Uint256Deque storage deque) internal view returns (bool) {\n    return deque._end == deque._begin;\n  }\n}\n"
      },
      "ERC404/contracts/lib/ERC20Events.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary ERC20Events {\n  event Approval(address indexed owner, address indexed spender, uint256 value);\n  event Transfer(address indexed from, address indexed to, uint256 amount);\n}\n"
      },
      "ERC404/contracts/lib/ERC721Events.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nlibrary ERC721Events {\n  event ApprovalForAll(\n    address indexed owner,\n    address indexed operator,\n    bool approved\n  );\n  event Approval(\n    address indexed owner,\n    address indexed spender,\n    uint256 indexed id\n  );\n  event Transfer(\n    address indexed from,\n    address indexed to,\n    uint256 indexed id\n  );\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 10
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}