ETH Price: $3,213.64 (-6.70%)
Gas: 10 Gwei

Contract

0xe8870bc16702f451F35e6d15E27509efD73E3ab0
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Approve194828592024-03-21 11:51:35125 days ago1711021895IN
0xe8870bc1...fD73E3ab0
0 ETH0.0013412727.51227345
Redeem NFT194823662024-03-21 10:12:11125 days ago1711015931IN
0xe8870bc1...fD73E3ab0
0 ETH0.0068666132.56802602
Approve194627202024-03-18 15:59:47128 days ago1710777587IN
0xe8870bc1...fD73E3ab0
0 ETH0.0019125139.22949239
Approve194602062024-03-18 7:29:59128 days ago1710746999IN
0xe8870bc1...fD73E3ab0
0 ETH0.0014519729.89319995
Approve194601882024-03-18 7:26:23128 days ago1710746783IN
0xe8870bc1...fD73E3ab0
0 ETH0.0010244921.01437731
Approve194600662024-03-18 7:01:47128 days ago1710745307IN
0xe8870bc1...fD73E3ab0
0 ETH0.0010579621.81366656
Approve194600652024-03-18 7:01:35128 days ago1710745295IN
0xe8870bc1...fD73E3ab0
0 ETH0.0013138326.91623154
Deposit NFT194600632024-03-18 7:01:11128 days ago1710745271IN
0xe8870bc1...fD73E3ab0
0 ETH0.0060595421.62277779
Deposit NFT194600602024-03-18 7:00:35128 days ago1710745235IN
0xe8870bc1...fD73E3ab0
0 ETH0.0059971822.79092123
Deposit NFT194600512024-03-18 6:58:47128 days ago1710745127IN
0xe8870bc1...fD73E3ab0
0 ETH0.0055295821.01393503
Approve194600372024-03-18 6:55:59128 days ago1710744959IN
0xe8870bc1...fD73E3ab0
0 ETH0.0011174622.92138193
Approve194600282024-03-18 6:54:11128 days ago1710744851IN
0xe8870bc1...fD73E3ab0
0 ETH0.001138523.46861557
Approve194600282024-03-18 6:54:11128 days ago1710744851IN
0xe8870bc1...fD73E3ab0
0 ETH0.0012023524.63229033
Approve194600282024-03-18 6:54:11128 days ago1710744851IN
0xe8870bc1...fD73E3ab0
0 ETH0.0021255543.54579033
Approve194600252024-03-18 6:53:35128 days ago1710744815IN
0xe8870bc1...fD73E3ab0
0 ETH0.0010175920.98128105
Approve194600252024-03-18 6:53:35128 days ago1710744815IN
0xe8870bc1...fD73E3ab0
0 ETH0.0012389125.38128105
Approve194600252024-03-18 6:53:35128 days ago1710744815IN
0xe8870bc1...fD73E3ab0
0 ETH0.0012389125.38128105
Approve194600232024-03-18 6:53:11128 days ago1710744791IN
0xe8870bc1...fD73E3ab0
0 ETH0.0014886330.49725575
Approve194600222024-03-18 6:52:59128 days ago1710744779IN
0xe8870bc1...fD73E3ab0
0 ETH0.0009127618.81981069
Approve194600212024-03-18 6:52:47128 days ago1710744767IN
0xe8870bc1...fD73E3ab0
0 ETH0.0011396223.3759744
Approve194600202024-03-18 6:52:35128 days ago1710744755IN
0xe8870bc1...fD73E3ab0
0 ETH0.0011690323.94971319
Approve194600192024-03-18 6:52:23128 days ago1710744743IN
0xe8870bc1...fD73E3ab0
0 ETH0.0011709524.01860324
Approve194600172024-03-18 6:51:59128 days ago1710744719IN
0xe8870bc1...fD73E3ab0
0 ETH0.0010709621.96762486
Approve194600152024-03-18 6:51:35128 days ago1710744695IN
0xe8870bc1...fD73E3ab0
0 ETH0.0009928520.4711523
Approve194600142024-03-18 6:51:23128 days ago1710744683IN
0xe8870bc1...fD73E3ab0
0 ETH0.0010565121.78391435
View all transactions

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block From To
194389042024-03-15 7:37:59131 days ago1710488279  Contract Creation0 ETH
Loading...
Loading

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

Contract Name:
X404

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 20 runs

Other Settings:
paris EvmVersion
File 1 of 27 : X404.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {ERC404} from "./ERC404.sol";
import {IX404Hub} from "./interfaces/IX404Hub.sol";
import {IPeripheryImmutableState} from "./interfaces/IPeripheryImmutableState.sol";
import {IUniswapV2Router} from "./interfaces/IUniswapV2Router.sol";
import {DataTypes} from "./lib/DataTypes.sol";
import {Errors} from "./lib/Errors.sol";
import {Events} from "./lib/Events.sol";
import {LibCalculatePair} from "./lib/LibCalculatePair.sol";
import {X404Storage} from "./storage/X404Storage.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

contract X404 is IERC721Receiver, ERC404, Ownable, X404Storage {
    using EnumerableSet for EnumerableSet.UintSet;

    address public immutable creator;
    address public immutable blueChipNftAddr;
    address public immutable x404Hub;

    modifier onlyX404Hub() {
        if (msg.sender != x404Hub) {
            revert Errors.OnlyCallByFactory();
        }
        _;
    }

    constructor() Ownable(msg.sender) {
        decimals = 18;
        (blueChipNftAddr, creator, maxRedeemDeadline) = IX404Hub(msg.sender)
            ._parameters();

        units = 10 ** 18;
        address newOwner = IX404Hub(msg.sender).owner();
        string memory oriName = IERC721Metadata(blueChipNftAddr).name();
        string memory oriSymbol = IERC721Metadata(blueChipNftAddr).symbol();
        name = string.concat("X404-", oriName);
        symbol = string.concat("X404-", oriSymbol);
        DataTypes.SwapRouter[] memory swapRouterStruct = IX404Hub(msg.sender)
            .getSwapRouter();
        _setRouterTransferExempt(swapRouterStruct);
        _setERC721TransferExempt(address(this), true);
        x404Hub = msg.sender;
        _transferOwnership(newOwner);
    }

    /// @notice redeem nfts from contract when user hold n * units erc20 token
    /// @param tokenIds The array tokenid of deposit nft.
    /// @param redeemDeadline The redeemDeadline. means before deadline, Only you can redeem your nft. after deadline, anyone who hold more than units erc20 token can redeem your nft.
    function depositNFT(
        uint256[] memory tokenIds,
        uint256 redeemDeadline
    ) external {
        if (
            redeemDeadline < block.timestamp ||
            redeemDeadline > block.timestamp + maxRedeemDeadline
        ) {
            revert Errors.InvalidDeadLine();
        }
        uint256 len = tokenIds.length;
        if (len == 0) {
            revert Errors.InvalidLength();
        }
        for (uint256 i = 0; i < len; ) {
            IERC721Metadata(blueChipNftAddr).transferFrom(
                msg.sender,
                address(this),
                tokenIds[i]
            );
            if (tokenIdSet.add(tokenIds[i])) {
                NFTDepositInfo storage subInfo = nftDepositInfo[tokenIds[i]];
                subInfo.caller = msg.sender;
                subInfo.oriOwner = msg.sender;
                subInfo.redeemDeadline = redeemDeadline;
            } else {
                revert InvalidTokenId();
            }
            emit Events.X404DepositNFT(
                msg.sender,
                msg.sender,
                tokenIds[i],
                redeemDeadline
            );
            unchecked {
                i++;
            }
        }
        _transferERC20WithERC721(address(0x0), msg.sender, len * units);
    }

    /// @notice redeem nfts from contract when user hold n * units erc20 token
    /// @param tokenIds The array tokenid of redeem nft.
    function redeemNFT(uint256[] memory tokenIds) external payable {
        uint256 len = tokenIds.length;
        if (len == 0) {
            revert Errors.InvalidLength();
        }
        if (redeemFee > 0) {
            //revert if msg.value < redeemFee
            uint256 totalRedeemFee = len * redeemFee;
            if (msg.value < totalRedeemFee) {
                revert Errors.MsgValueNotEnough();
            }
            //send redeemFee
            (bool sucess, ) = payable(owner()).call{value: totalRedeemFee}("");
            if (!sucess) {
                revert Errors.SendETHFailed();
            }
            //refund if msg.value > redeemFee
            if (msg.value > totalRedeemFee) {
                (bool sucess1, ) = payable(msg.sender).call{
                    value: msg.value - totalRedeemFee
                }("");
                if (!sucess1) {
                    revert Errors.SendETHFailed();
                }
            }
        } else {
            //refund if not charge redeemFee
            if (msg.value > 0) {
                (bool sucess2, ) = payable(msg.sender).call{value: msg.value}(
                    ""
                );
                if (!sucess2) {
                    revert Errors.SendETHFailed();
                }
            }
        }

        _transferERC20WithERC721(msg.sender, address(0), units * len);

        for (uint256 i = 0; i < tokenIds.length; ) {
            address oriOwner = nftDepositInfo[tokenIds[i]].oriOwner;
            if (
                oriOwner != msg.sender &&
                nftDepositInfo[tokenIds[i]].redeemDeadline > block.timestamp
            ) {
                revert Errors.NFTCannotRedeem();
            }
            if (!tokenIdSet.remove(tokenIds[i])) {
                revert Errors.RemoveFailed();
            }
            IERC721Metadata(blueChipNftAddr).safeTransferFrom(
                address(this),
                msg.sender,
                tokenIds[i]
            );
            emit Events.X404RedeemNFT(msg.sender, oriOwner, tokenIds[i]);
            delete nftDepositInfo[tokenIds[i]];
            unchecked {
                i++;
            }
        }
    }

    /// @notice when user send nft to this contract by "safeTransferFrom"
    /// @param caller caller who call function "safeTransferFrom".
    /// @param from The Nft owner
    /// @param tokenId The nft tokenid
    /// @param data The redeem deadline
    function onERC721Received(
        address caller,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4) {
        if (msg.sender != blueChipNftAddr) {
            revert Errors.InvalidNFTAddress();
        }
        uint256 redeemDeadline = abi.decode(data, (uint256));
        if (
            redeemDeadline < block.timestamp ||
            redeemDeadline > block.timestamp + maxRedeemDeadline
        ) {
            revert Errors.InvalidDeadLine();
        }
        _transferERC20WithERC721(address(0), caller, units);
        if (tokenIdSet.add(tokenId)) {
            NFTDepositInfo storage subInfo = nftDepositInfo[tokenId];
            subInfo.caller = caller;
            subInfo.oriOwner = from;
            subInfo.redeemDeadline = redeemDeadline;
        } else {
            revert InvalidTokenId();
        }
        emit Events.X404DepositNFT(caller, from, tokenId, redeemDeadline);

        return IERC721Receiver.onERC721Received.selector;
    }

    function getTokenIdSet() external view returns (uint256[] memory) {
        return tokenIdSet.values();
    }

    function checkTokenIdExsit(uint256 tokenId) external view returns (bool) {
        return tokenIdSet.contains(tokenId);
    }

    /**************Only Call By Factory Function **********/

    function setContractURI(
        string calldata newContractUri
    ) external onlyX404Hub returns (bool) {
        if (bytes(newContractUri).length == 0) {
            revert Errors.InvalidLength();
        }
        contractURI = newContractUri;
        emit Events.SetContractURI(contractURI);
        return true;
    }

    function setRedeemFee(
        uint256 newRedeemFee
    ) external onlyX404Hub returns (bool) {
        if (newRedeemFee > 0.2 ether) {
            revert Errors.RedeemFeeTooHigh();
        }
        redeemFee = newRedeemFee;
        emit Events.SetRedeemFee(redeemFee);
        return true;
    }

    function setTokenURI(string calldata _tokenURI) external onlyX404Hub {
        if (bytes(_tokenURI).length == 0) {
            revert Errors.InvalidLength();
        }
        baseURI = _tokenURI;
        emit Events.SetTokenURI(baseURI);
    }

    function tokenURI(uint256 id) public view override returns (string memory) {
        address erc721Owner = _getOwnerOf(id);
        if (erc721Owner == address(0x0)) {
            revert NotFound();
        }
        return string.concat(baseURI, Strings.toString(id));
    }

    /**************Internal Function **********/
    function _setRouterTransferExempt(
        DataTypes.SwapRouter[] memory swapRouterStruct
    ) private {
        address thisAddress = address(this);
        for (uint i = 0; i < swapRouterStruct.length; ) {
            address routerAddr = swapRouterStruct[i].routerAddr;
            if (routerAddr == address(0)) {
                revert Errors.CantBeZeroAddress();
            }
            _setERC721TransferExempt(routerAddr, true);

            if (swapRouterStruct[i].bV2orV3) {
                address weth_ = IUniswapV2Router(routerAddr).WETH();
                address swapFactory = IUniswapV2Router(routerAddr).factory();
                address pair = LibCalculatePair._getUniswapV2Pair(
                    swapFactory,
                    thisAddress,
                    weth_
                );
                _setERC721TransferExempt(pair, true);
            } else {
                address weth_ = IPeripheryImmutableState(routerAddr).WETH9();
                address swapFactory = IPeripheryImmutableState(routerAddr)
                    .factory();
                address v3NonfungiblePositionManager = swapRouterStruct[i]
                    .uniswapV3NonfungiblePositionManager;
                if (v3NonfungiblePositionManager == address(0)) {
                    revert Errors.CantBeZeroAddress();
                }
                if (
                    IPeripheryImmutableState(v3NonfungiblePositionManager)
                        .factory() !=
                    swapFactory ||
                    IPeripheryImmutableState(v3NonfungiblePositionManager)
                        .WETH9() !=
                    weth_
                ) {
                    revert Errors.X404SwapV3FactoryMismatch();
                }
                _setERC721TransferExempt(v3NonfungiblePositionManager, true);
                _setV3SwapTransferExempt(swapFactory, thisAddress, weth_);
            }
            unchecked {
                ++i;
            }
        }
    }

    function _setV3SwapTransferExempt(
        address swapFactory,
        address tokenA,
        address tokenB
    ) private {
        uint24[4] memory feeTiers = [
            uint24(100),
            uint24(500),
            uint24(3_000),
            uint24(10_000)
        ];

        for (uint256 i = 0; i < feeTiers.length; ) {
            address v3PairAddr = LibCalculatePair._getUniswapV3Pair(
                swapFactory,
                tokenA,
                tokenB,
                feeTiers[i]
            );
            // Set the v3 pair as exempt.
            _setERC721TransferExempt(v3PairAddr, true);
            unchecked {
                ++i;
            }
        }
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

File 3 of 27 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

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

File 4 of 27 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721Receiver.sol)

pragma solidity ^0.8.20;

import {IERC721Receiver} from "../token/ERC721/IERC721Receiver.sol";

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

pragma solidity ^0.8.20;

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

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

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

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

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

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

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

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }
}

File 14 of 27 : ERC404.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC721Receiver} from "@openzeppelin/contracts/interfaces/IERC721Receiver.sol";
import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
import {IERC404} from "./interfaces/IERC404.sol";
import {ERC721Events} from "./lib/ERC721Events.sol";
import {ERC20Events} from "./lib/ERC20Events.sol";
import {DoubleEndedQueue} from "./lib/DoubleEndedQueue.sol";

abstract contract ERC404 is IERC404 {
    using DoubleEndedQueue for DoubleEndedQueue.Uint256Deque;

    /// @dev The queue of ERC-721 tokens stored in the contract.
    DoubleEndedQueue.Uint256Deque private _storedERC721Ids;

    /// @dev Token name
    string public name;

    /// @dev Token symbol
    string public symbol;

    /// @dev Decimals for ERC-20 representation
    uint8 public decimals;

    /// @dev Units for ERC-20 representation
    uint256 public units;

    /// @dev Total supply in ERC-20 representation
    uint256 public totalSupply;

    /// @dev Current mint counter which also represents the highest
    ///      minted id, monotonically increasing to ensure accurate ownership
    uint256 public minted;

    /// @dev Balance of user in ERC-20 representation
    mapping(address => uint256) public balanceOf;

    /// @dev Allowance of user in ERC-20 representation
    mapping(address => mapping(address => uint256)) public allowance;

    /// @dev Approval in ERC-721 representaion
    mapping(uint256 => address) public getApproved;

    /// @dev Approval for all in ERC-721 representation
    mapping(address => mapping(address => bool)) public isApprovedForAll;

    /// @dev Packed representation of ownerOf and owned indices
    mapping(uint256 => uint256) internal _ownedData;

    /// @dev Array of owned ids in ERC-721 representation
    mapping(address => uint256[]) internal _owned;

    /// @dev Addresses that are exempt from ERC-721 transfer, typically for gas savings (pairs, routers, etc)
    mapping(address => bool) internal _erc721TransferExempt;

    /// @dev Address bitmask for packed ownership data
    uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;

    /// @dev Owned index bitmask for packed ownership data
    uint256 private constant _BITMASK_OWNED_INDEX = ((1 << 96) - 1) << 160;

    /// @notice Function to find owner of a given ERC-721 token
    function ownerOf(
        uint256 id_
    ) public view virtual returns (address erc721Owner) {
        erc721Owner = _getOwnerOf(id_);

        if (!_isValidTokenId(id_)) {
            revert InvalidTokenId();
        }

        if (erc721Owner == address(0)) {
            revert NotFound();
        }
    }

    function owned(
        address owner_
    ) public view virtual returns (uint256[] memory) {
        return _owned[owner_];
    }

    function erc721BalanceOf(
        address owner_
    ) public view virtual returns (uint256) {
        return _owned[owner_].length;
    }

    function erc20BalanceOf(
        address owner_
    ) public view virtual returns (uint256) {
        return balanceOf[owner_];
    }

    function erc20TotalSupply() public view virtual returns (uint256) {
        return totalSupply;
    }

    function erc721TotalSupply() public view virtual returns (uint256) {
        return minted - _storedERC721Ids.length();
    }

    function getERC721QueueLength() public view virtual returns (uint256) {
        return _storedERC721Ids.length();
    }

    function getERC721TokensInQueue(
        uint256 start_,
        uint256 count_
    ) public view virtual returns (uint256[] memory) {
        uint256[] memory tokensInQueue = new uint256[](count_);

        for (uint256 i = start_; i < start_ + count_; ) {
            tokensInQueue[i - start_] = _storedERC721Ids.at(i);

            unchecked {
                ++i;
            }
        }

        return tokensInQueue;
    }

    /// @notice tokenURI must be implemented by child contract
    function tokenURI(uint256 id_) public view virtual returns (string memory);

    /// @notice Function for token approvals
    /// @dev This function assumes the operator is attempting to approve
    ///      an ERC-721 if valueOrId_ is a possibly valid ERC-721 token id.
    ///      Unlike setApprovalForAll, spender_ must be allowed to be 0x0 so
    ///      that approval can be revoked.
    function approve(
        address spender_,
        uint256 valueOrId_
    ) public virtual returns (bool) {
        if (_isValidTokenId(valueOrId_)) {
            erc721Approve(spender_, valueOrId_);
        } else {
            return erc20Approve(spender_, valueOrId_);
        }

        return true;
    }

    function erc721Approve(address spender_, uint256 id_) public virtual {
        // Intention is to approve as ERC-721 token (id).
        address erc721Owner = _getOwnerOf(id_);

        if (
            msg.sender != erc721Owner &&
            !isApprovedForAll[erc721Owner][msg.sender]
        ) {
            revert Unauthorized();
        }

        getApproved[id_] = spender_;

        emit ERC721Events.Approval(erc721Owner, spender_, id_);
    }

    /// @dev Providing type(uint256).max for approval value results in an
    ///      unlimited approval that is not deducted from on transfers.
    function erc20Approve(
        address spender_,
        uint256 value_
    ) public virtual returns (bool) {
        // Prevent granting 0x0 an ERC-20 allowance.
        if (spender_ == address(0)) {
            revert InvalidSpender();
        }

        allowance[msg.sender][spender_] = value_;

        emit ERC20Events.Approval(msg.sender, spender_, value_);

        return true;
    }

    /// @notice Function for ERC-721 approvals
    function setApprovalForAll(
        address operator_,
        bool approved_
    ) public virtual {
        // Prevent approvals to 0x0.
        if (operator_ == address(0)) {
            revert InvalidOperator();
        }
        isApprovedForAll[msg.sender][operator_] = approved_;
        emit ERC721Events.ApprovalForAll(msg.sender, operator_, approved_);
    }

    /// @notice Function for mixed transfers from an operator that may be different than 'from'.
    /// @dev This function assumes the operator is attempting to transfer an ERC-721
    ///      if valueOrId is a possible valid token id.
    function transferFrom(
        address from_,
        address to_,
        uint256 valueOrId_
    ) public virtual returns (bool) {
        if (_isValidTokenId(valueOrId_)) {
            erc721TransferFrom(from_, to_, valueOrId_);
        } else {
            // Intention is to transfer as ERC-20 token (value).
            return erc20TransferFrom(from_, to_, valueOrId_);
        }

        return true;
    }

    /// @notice Function for ERC-721 transfers from.
    /// @dev This function is recommended for ERC721 transfers.
    function erc721TransferFrom(
        address from_,
        address to_,
        uint256 id_
    ) public virtual {
        // Prevent minting tokens from 0x0.
        if (from_ == address(0)) {
            revert InvalidSender();
        }

        // Prevent burning tokens to 0x0.
        if (to_ == address(0)) {
            revert InvalidRecipient();
        }

        if (from_ != _getOwnerOf(id_)) {
            revert Unauthorized();
        }

        // Check that the operator is either the sender or approved for the transfer.
        if (
            msg.sender != from_ &&
            !isApprovedForAll[from_][msg.sender] &&
            msg.sender != getApproved[id_]
        ) {
            revert Unauthorized();
        }

        // We only need to check ERC-721 transfer exempt status for the recipient
        // since the sender being ERC-721 transfer exempt means they have already
        // had their ERC-721s stripped away during the rebalancing process.
        if (erc721TransferExempt(to_)) {
            revert RecipientIsERC721TransferExempt();
        }

        // Transfer 1 * units ERC-20 and 1 ERC-721 token.
        // ERC-721 transfer exemptions handled above. Can't make it to this point if either is transfer exempt.
        _transferERC20(from_, to_, units);
        _transferERC721(from_, to_, id_);
    }

    /// @notice Function for ERC-20 transfers from.
    /// @dev This function is recommended for ERC20 transfers
    function erc20TransferFrom(
        address from_,
        address to_,
        uint256 value_
    ) public virtual returns (bool) {
        // Prevent minting tokens from 0x0.
        if (from_ == address(0)) {
            revert InvalidSender();
        }

        // Prevent burning tokens to 0x0.
        if (to_ == address(0)) {
            revert InvalidRecipient();
        }

        uint256 allowed = allowance[from_][msg.sender];

        // Check that the operator has sufficient allowance.
        if (allowed != type(uint256).max && from_ != msg.sender) {
            allowance[from_][msg.sender] = allowed - value_;
        }

        // Transferring ERC-20s directly requires the _transferERC20WithERC721 function.
        // Handles ERC-721 exemptions internally.
        return _transferERC20WithERC721(from_, to_, value_);
    }

    /// @notice Function for ERC-20 transfers.
    /// @dev This function assumes the operator is attempting to transfer as ERC-20
    ///      given this function is only supported on the ERC-20 interface.
    ///      Treats even large amounts that are valid ERC-721 ids as ERC-20s.
    function transfer(
        address to_,
        uint256 value_
    ) public virtual returns (bool) {
        // Prevent burning tokens to 0x0.
        if (to_ == address(0)) {
            revert InvalidRecipient();
        }

        // Transferring ERC-20s directly requires the _transferERC20WithERC721 function.
        // Handles ERC-721 exemptions internally.
        return _transferERC20WithERC721(msg.sender, to_, value_);
    }

    /// @notice Function for ERC-721 transfers with contract support.
    /// This function only supports moving valid ERC-721 ids, as it does not exist on the ERC-20
    /// spec and will revert otherwise.
    function safeTransferFrom(
        address from_,
        address to_,
        uint256 id_
    ) public virtual {
        safeTransferFrom(from_, to_, id_, "");
    }

    /// @notice Function for ERC-721 transfers with contract support and callback data.
    /// This function only supports moving valid ERC-721 ids, as it does not exist on the
    /// ERC-20 spec and will revert otherwise.
    function safeTransferFrom(
        address from_,
        address to_,
        uint256 id_,
        bytes memory data_
    ) public virtual {
        if (!_isValidTokenId(id_)) {
            revert InvalidTokenId();
        }

        erc721TransferFrom(from_, to_, id_);

        if (
            to_.code.length != 0 &&
            IERC721Receiver(to_).onERC721Received(
                msg.sender,
                from_,
                id_,
                data_
            ) !=
            IERC721Receiver.onERC721Received.selector
        ) {
            revert UnsafeRecipient();
        }
    }

    function supportsInterface(
        bytes4 interfaceId
    ) public view virtual returns (bool) {
        return
            interfaceId == type(IERC404).interfaceId ||
            interfaceId == type(IERC165).interfaceId;
    }

    /// @notice Function for self-exemption
    function setSelfERC721TransferExempt(bool state_) public virtual {
        _setERC721TransferExempt(msg.sender, state_);
    }

    /// @notice Function to check if address is transfer exempt
    function erc721TransferExempt(
        address target_
    ) public view virtual returns (bool) {
        return target_ == address(0) || _erc721TransferExempt[target_];
    }

    function _isValidTokenId(uint256 id_) internal view returns (bool) {
        return id_ <= minted && id_ > 0;
    }

    /// @notice This is the lowest level ERC-20 transfer function, which
    ///         should be used for both normal ERC-20 transfers as well as minting.
    /// Note that this function allows transfers to and from 0x0.
    function _transferERC20(
        address from_,
        address to_,
        uint256 value_
    ) internal virtual {
        // Minting is a special case for which we should not check the balance of
        // the sender, and we should increase the total supply.
        if (from_ == address(0)) {
            totalSupply += value_;
        } else {
            // Deduct value from sender's balance.
            balanceOf[from_] -= value_;
        }

        if (to_ == address(0)) {
            totalSupply -= value_;
        } else {
            // Update the recipient's balance.
            // Can be unchecked because on mint, adding to totalSupply is checked, and on transfer balance deduction is checked.
            unchecked {
                balanceOf[to_] += value_;
            }
        }

        emit ERC20Events.Transfer(from_, to_, value_);
    }

    /// @notice Consolidated record keeping function for transferring ERC-721s.
    /// @dev Assign the token to the new owner, and remove from the old owner.
    /// Note that this function allows transfers to and from 0x0.
    /// Does not handle ERC-721 exemptions.
    function _transferERC721(
        address from_,
        address to_,
        uint256 id_
    ) internal virtual {
        // If this is not a mint, handle record keeping for transfer from previous owner.
        if (from_ != address(0)) {
            // On transfer of an NFT, any previous approval is reset.
            delete getApproved[id_];

            uint256 updatedId = _owned[from_][_owned[from_].length - 1];
            if (updatedId != id_) {
                uint256 updatedIndex = _getOwnedIndex(id_);
                // update _owned for sender
                _owned[from_][updatedIndex] = updatedId;
                // update index for the moved id
                _setOwnedIndex(updatedId, updatedIndex);
            }

            // pop
            _owned[from_].pop();
        }

        // Check if this is a burn.
        if (to_ != address(0)) {
            // If not a burn, update the owner of the token to the new owner.
            // Update owner of the token to the new owner.
            _setOwnerOf(id_, to_);
            // Push token onto the new owner's stack.
            _owned[to_].push(id_);
            // Update index for new owner's stack.
            _setOwnedIndex(id_, _owned[to_].length - 1);
        } else {
            // If this is a burn, reset the owner of the token to 0x0 by deleting the token from _ownedData.
            delete _ownedData[id_];
        }

        emit ERC721Events.Transfer(from_, to_, id_);
    }

    /// @notice Internal function for ERC-20 transfers. Also handles any ERC-721 transfers that may be required.
    // Handles ERC-721 exemptions.
    function _transferERC20WithERC721(
        address from_,
        address to_,
        uint256 value_
    ) internal virtual returns (bool) {
        uint256 erc20BalanceOfSenderBefore = erc20BalanceOf(from_);
        uint256 erc20BalanceOfReceiverBefore = erc20BalanceOf(to_);

        _transferERC20(from_, to_, value_);

        // Preload for gas savings on branches
        bool isFromERC721TransferExempt = erc721TransferExempt(from_);
        bool isToERC721TransferExempt = erc721TransferExempt(to_);

        // Skip _withdrawAndStoreERC721 and/or _retrieveOrMintERC721 for ERC-721 transfer exempt addresses
        // 1) to save gas
        // 2) because ERC-721 transfer exempt addresses won't always have/need ERC-721s corresponding to their ERC20s.
        if (isFromERC721TransferExempt && isToERC721TransferExempt) {
            // Case 1) Both sender and recipient are ERC-721 transfer exempt. No ERC-721s need to be transferred.
            // NOOP.
        } else if (isFromERC721TransferExempt) {
            // Case 2) The sender is ERC-721 transfer exempt, but the recipient is not. Contract should not attempt
            //         to transfer ERC-721s from the sender, but the recipient should receive ERC-721s
            //         from the bank/minted for any whole number increase in their balance.
            // Only cares about whole number increments.
            uint256 tokensToRetrieveOrMint = (balanceOf[to_] / units) -
                (erc20BalanceOfReceiverBefore / units);
            for (uint256 i = 0; i < tokensToRetrieveOrMint; ) {
                _retrieveOrMintERC721(to_);
                unchecked {
                    ++i;
                }
            }
        } else if (isToERC721TransferExempt) {
            // Case 3) The sender is not ERC-721 transfer exempt, but the recipient is. Contract should attempt
            //         to withdraw and store ERC-721s from the sender, but the recipient should not
            //         receive ERC-721s from the bank/minted.
            // Only cares about whole number increments.
            uint256 tokensToWithdrawAndStore = (erc20BalanceOfSenderBefore /
                units) - (balanceOf[from_] / units);
            for (uint256 i = 0; i < tokensToWithdrawAndStore; ) {
                _withdrawAndStoreERC721(from_);
                unchecked {
                    ++i;
                }
            }
        } else {
            // Case 4) Neither the sender nor the recipient are ERC-721 transfer exempt.
            // Strategy:
            // 1. First deal with the whole tokens. These are easy and will just be transferred.
            // 2. Look at the fractional part of the value:
            //   a) If it causes the sender to lose a whole token that was represented by an NFT due to a
            //      fractional part being transferred, withdraw and store an additional NFT from the sender.
            //   b) If it causes the receiver to gain a whole new token that should be represented by an NFT
            //      due to receiving a fractional part that completes a whole token, retrieve or mint an NFT to the recevier.

            // Whole tokens worth of ERC-20s get transferred as ERC-721s without any burning/minting.
            uint256 nftsToTransfer = value_ / units;
            for (uint256 i = 0; i < nftsToTransfer; ) {
                // Pop from sender's ERC-721 stack and transfer them (LIFO)
                uint256 indexOfLastToken = _owned[from_].length - 1;
                uint256 tokenId = _owned[from_][indexOfLastToken];
                _transferERC721(from_, to_, tokenId);
                unchecked {
                    ++i;
                }
            }

            // If the transfer changes either the sender or the recipient's holdings from a fractional to a non-fractional
            // amount (or vice versa), adjust ERC-721s.

            // First check if the send causes the sender to lose a whole token that was represented by an ERC-721
            // due to a fractional part being transferred.
            //
            // Process:
            // Take the difference between the whole number of tokens before and after the transfer for the sender.
            // If that difference is greater than the number of ERC-721s transferred (whole units), then there was
            // an additional ERC-721 lost due to the fractional portion of the transfer.
            // If this is a self-send and the before and after balances are equal (not always the case but often),
            // then no ERC-721s will be lost here.
            if (
                erc20BalanceOfSenderBefore /
                    units -
                    erc20BalanceOf(from_) /
                    units >
                nftsToTransfer
            ) {
                _withdrawAndStoreERC721(from_);
            }

            // Then, check if the transfer causes the receiver to gain a whole new token which requires gaining
            // an additional ERC-721.
            //
            // Process:
            // Take the difference between the whole number of tokens before and after the transfer for the recipient.
            // If that difference is greater than the number of ERC-721s transferred (whole units), then there was
            // an additional ERC-721 gained due to the fractional portion of the transfer.
            // Again, for self-sends where the before and after balances are equal, no ERC-721s will be gained here.
            if (
                erc20BalanceOf(to_) /
                    units -
                    erc20BalanceOfReceiverBefore /
                    units >
                nftsToTransfer
            ) {
                _retrieveOrMintERC721(to_);
            }
        }

        return true;
    }

    /// @notice Internal function for ERC-721 minting and retrieval from the bank.
    /// @dev This function will allow minting of new ERC-721s up to the total fractional supply. It will
    ///      first try to pull from the bank, and if the bank is empty, it will mint a new token.
    /// Does not handle ERC-721 exemptions.
    function _retrieveOrMintERC721(address to_) internal virtual {
        if (to_ == address(0)) {
            revert InvalidRecipient();
        }

        uint256 id;
        if (!_storedERC721Ids.empty()) {
            // If there are any tokens in the bank, use those first.
            // Pop off the end of the queue (FIFO).
            id = _storedERC721Ids.popBack();
        } else {
            // Otherwise, mint a new token, should not be able to go over the total fractional supply.
            ++minted;

            // Reserve max uint256 for approvals
            if (minted == type(uint256).max) {
                revert MintLimitReached();
            }

            id = minted;
        }
        address erc721Owner = _getOwnerOf(id);

        // The token should not already belong to anyone besides 0x0 or this contract.
        // If it does, something is wrong, as this should never happen.
        if (erc721Owner != address(0)) {
            revert AlreadyExists();
        }

        // Transfer the token to the recipient, either transferring from the contract's bank or minting.
        // Does not handle ERC-721 exemptions.
        _transferERC721(erc721Owner, to_, id);
    }

    /// @notice Internal function for ERC-721 deposits to bank (this contract).
    /// @dev This function will allow depositing of ERC-721s to the bank, which can be retrieved by future minters.
    // Does not handle ERC-721 exemptions.
    function _withdrawAndStoreERC721(address from_) internal virtual {
        if (from_ == address(0)) {
            revert InvalidSender();
        }

        // Retrieve the latest token added to the owner's stack (LIFO).
        uint256 id = _owned[from_][_owned[from_].length - 1];

        // Transfer to 0x0.
        // Does not handle ERC-721 exemptions.
        _transferERC721(from_, address(0), id);
        _storedERC721Ids.pushFront(id);
    }

    /// @notice Initialization function to set pairs / etc, saving gas by avoiding mint / burn on unnecessary targets
    function _setERC721TransferExempt(
        address target_,
        bool state_
    ) internal virtual {
        if (target_ == address(0)) {
            revert InvalidExemption();
        }

        // Adjust the ERC721 balances of the target to respect exemption rules.
        // Despite this logic, it is still recommended practice to exempt prior to the target
        // having an active balance.
        if (state_) {
            _clearERC721Balance(target_);
        } else {
            _reinstateERC721Balance(target_);
        }

        _erc721TransferExempt[target_] = state_;
    }

    /// @notice Function to reinstate balance on exemption removal
    function _reinstateERC721Balance(address target_) private {
        uint256 expectedERC721Balance = erc20BalanceOf(target_) / units;
        uint256 actualERC721Balance = erc721BalanceOf(target_);

        for (uint256 i = 0; i < expectedERC721Balance - actualERC721Balance; ) {
            // Transfer ERC721 balance in from pool
            _retrieveOrMintERC721(target_);
            unchecked {
                ++i;
            }
        }
    }

    /// @notice Function to clear balance on exemption inclusion
    function _clearERC721Balance(address target_) private {
        uint256 erc721Balance = erc721BalanceOf(target_);

        for (uint256 i = 0; i < erc721Balance; ) {
            // Transfer out ERC721 balance
            _withdrawAndStoreERC721(target_);
            unchecked {
                ++i;
            }
        }
    }

    function _getOwnerOf(
        uint256 id_
    ) internal view virtual returns (address ownerOf_) {
        uint256 data = _ownedData[id_];

        assembly {
            ownerOf_ := and(data, _BITMASK_ADDRESS)
        }
    }

    function _setOwnerOf(uint256 id_, address owner_) internal virtual {
        uint256 data = _ownedData[id_];

        assembly {
            data := add(
                and(data, _BITMASK_OWNED_INDEX),
                and(owner_, _BITMASK_ADDRESS)
            )
        }

        _ownedData[id_] = data;
    }

    function _getOwnedIndex(
        uint256 id_
    ) internal view virtual returns (uint256 ownedIndex_) {
        uint256 data = _ownedData[id_];

        assembly {
            ownedIndex_ := shr(160, data)
        }
    }

    function _setOwnedIndex(uint256 id_, uint256 index_) internal virtual {
        uint256 data = _ownedData[id_];

        if (index_ > _BITMASK_OWNED_INDEX >> 160) {
            revert OwnedIndexOverflow();
        }

        assembly {
            data := add(and(data, _BITMASK_ADDRESS), shl(160, index_))
        }

        _ownedData[id_] = data;
    }
}

File 15 of 27 : IERC404.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";

interface IERC404 is IERC165 {
    error NotFound();
    error InvalidTokenId();
    error NoAvaiableTokenID();
    error AlreadyExists();
    error InvalidRecipient();
    error InvalidSender();
    error InvalidSpender();
    error InvalidOperator();
    error UnsafeRecipient();
    error RecipientIsERC721TransferExempt();
    error Unauthorized();
    error InsufficientAllowance();
    error DecimalsTooLow();
    error PermitDeadlineExpired();
    error InvalidSigner();
    error InvalidApproval();
    error OwnedIndexOverflow();
    error MintLimitReached();
    error InvalidExemption();

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

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

    function decimals() external view returns (uint8);

    function totalSupply() external view returns (uint256);

    function erc20TotalSupply() external view returns (uint256);

    function erc721TotalSupply() external view returns (uint256);

    function balanceOf(address owner_) external view returns (uint256);

    function erc721BalanceOf(address owner_) external view returns (uint256);

    function erc20BalanceOf(address owner_) external view returns (uint256);

    function erc721TransferExempt(
        address account_
    ) external view returns (bool);

    function isApprovedForAll(
        address owner_,
        address operator_
    ) external view returns (bool);

    function allowance(
        address owner_,
        address spender_
    ) external view returns (uint256);

    function owned(address owner_) external view returns (uint256[] memory);

    function ownerOf(uint256 id_) external view returns (address erc721Owner);

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

    function approve(
        address spender_,
        uint256 valueOrId_
    ) external returns (bool);

    function erc20Approve(
        address spender_,
        uint256 value_
    ) external returns (bool);

    function erc721Approve(address spender_, uint256 id_) external;

    function setApprovalForAll(address operator_, bool approved_) external;

    function transferFrom(
        address from_,
        address to_,
        uint256 valueOrId_
    ) external returns (bool);

    function erc20TransferFrom(
        address from_,
        address to_,
        uint256 value_
    ) external returns (bool);

    function erc721TransferFrom(
        address from_,
        address to_,
        uint256 id_
    ) external;

    function transfer(address to_, uint256 amount_) external returns (bool);

    function setSelfERC721TransferExempt(bool state_) external;

    function safeTransferFrom(address from_, address to_, uint256 id_) external;

    function safeTransferFrom(
        address from_,
        address to_,
        uint256 id_,
        bytes calldata data_
    ) external;
}

File 16 of 27 : IPeripheryImmutableState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
    /// @return Returns the address of the Uniswap V3 factory
    function factory() external view returns (address);

    /// @return Returns the address of WETH9
    function WETH9() external view returns (address);
}

File 17 of 27 : IUniswapV2Router.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;

interface IUniswapV2Router {
    function factory() external view returns (address);

    function WETH() external view returns (address);

    function getAmountsOut(
        uint amountIn,
        address[] calldata path
    ) external view returns (uint[] memory amounts);
}

File 18 of 27 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IUniswapV3PoolState {
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );
}

File 19 of 27 : IX404Hub.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {DataTypes} from "../lib/DataTypes.sol";

interface IX404Hub {
    function _parameters()
        external
        view
        returns (address blueChipNft, address creator, uint256 deadline);

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

    function getSwapRouter()
        external
        view
        returns (DataTypes.SwapRouter[] memory);
}

File 20 of 27 : DataTypes.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

/**
 * @title DataTypes
 * @author Tomo Protocol
 *
 * @notice A standard library of data types used throughout the XRGB.
 */
library DataTypes {
    struct CreateX404Parameters {
        address nftContractAddr;
        address creator;
        uint256 redeemMaxDeadline;
    }

    struct SwapRouter {
        bool bV2orV3;
        address routerAddr;
        address uniswapV3NonfungiblePositionManager;
    }
}

File 21 of 27 : DoubleEndedQueue.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/DoubleEndedQueue.sol)
// Modified by Pandora Labs to support native uint256 operations
pragma solidity ^0.8.20;

/**
 * @dev A sequence of items with the ability to efficiently push and pop items (i.e. insert and remove) on both ends of
 * the sequence (called front and back). Among other access patterns, it can be used to implement efficient LIFO and
 * FIFO queues. Storage use is optimized, and all operations are O(1) constant time. This includes {clear}, given that
 * the existing queue contents are left in storage.
 *
 * The struct is called `Uint256Deque`. This data structure can only be used in storage, and not in memory.
 *
 * ```solidity
 * DoubleEndedQueue.Uint256Deque queue;
 * ```
 */
library DoubleEndedQueue {
    /**
     * @dev An operation (e.g. {front}) couldn't be completed due to the queue being empty.
     */
    error QueueEmpty();

    /**
     * @dev A push operation couldn't be completed due to the queue being full.
     */
    error QueueFull();

    /**
     * @dev An operation (e.g. {at}) couldn't be completed due to an index being out of bounds.
     */
    error QueueOutOfBounds();

    /**
     * @dev Indices are 128 bits so begin and end are packed in a single storage slot for efficient access.
     *
     * Struct members have an underscore prefix indicating that they are "private" and should not be read or written to
     * directly. Use the functions provided below instead. Modifying the struct manually may violate assumptions and
     * lead to unexpected behavior.
     *
     * The first item is at data[begin] and the last item is at data[end - 1]. This range can wrap around.
     */
    struct Uint256Deque {
        uint128 _begin;
        uint128 _end;
        mapping(uint128 index => uint256) _data;
    }

    /**
     * @dev Inserts an item at the end of the queue.
     *
     * Reverts with {QueueFull} if the queue is full.
     */
    function pushBack(Uint256Deque storage deque, uint256 value) internal {
        unchecked {
            uint128 backIndex = deque._end;
            if (backIndex + 1 == deque._begin) revert QueueFull();
            deque._data[backIndex] = value;
            deque._end = backIndex + 1;
        }
    }

    /**
     * @dev Removes the item at the end of the queue and returns it.
     *
     * Reverts with {QueueEmpty} if the queue is empty.
     */
    function popBack(
        Uint256Deque storage deque
    ) internal returns (uint256 value) {
        unchecked {
            uint128 backIndex = deque._end;
            if (backIndex == deque._begin) revert QueueEmpty();
            --backIndex;
            value = deque._data[backIndex];
            delete deque._data[backIndex];
            deque._end = backIndex;
        }
    }

    /**
     * @dev Inserts an item at the beginning of the queue.
     *
     * Reverts with {QueueFull} if the queue is full.
     */
    function pushFront(Uint256Deque storage deque, uint256 value) internal {
        unchecked {
            uint128 frontIndex = deque._begin - 1;
            if (frontIndex == deque._end) revert QueueFull();
            deque._data[frontIndex] = value;
            deque._begin = frontIndex;
        }
    }

    /**
     * @dev Removes the item at the beginning of the queue and returns it.
     *
     * Reverts with `QueueEmpty` if the queue is empty.
     */
    function popFront(
        Uint256Deque storage deque
    ) internal returns (uint256 value) {
        unchecked {
            uint128 frontIndex = deque._begin;
            if (frontIndex == deque._end) revert QueueEmpty();
            value = deque._data[frontIndex];
            delete deque._data[frontIndex];
            deque._begin = frontIndex + 1;
        }
    }

    /**
     * @dev Returns the item at the beginning of the queue.
     *
     * Reverts with `QueueEmpty` if the queue is empty.
     */
    function front(
        Uint256Deque storage deque
    ) internal view returns (uint256 value) {
        if (empty(deque)) revert QueueEmpty();
        return deque._data[deque._begin];
    }

    /**
     * @dev Returns the item at the end of the queue.
     *
     * Reverts with `QueueEmpty` if the queue is empty.
     */
    function back(
        Uint256Deque storage deque
    ) internal view returns (uint256 value) {
        if (empty(deque)) revert QueueEmpty();
        unchecked {
            return deque._data[deque._end - 1];
        }
    }

    /**
     * @dev Return the item at a position in the queue given by `index`, with the first item at 0 and last item at
     * `length(deque) - 1`.
     *
     * Reverts with `QueueOutOfBounds` if the index is out of bounds.
     */
    function at(
        Uint256Deque storage deque,
        uint256 index
    ) internal view returns (uint256 value) {
        if (index >= length(deque)) revert QueueOutOfBounds();
        // By construction, length is a uint128, so the check above ensures that index can be safely downcast to uint128
        unchecked {
            return deque._data[deque._begin + uint128(index)];
        }
    }

    /**
     * @dev Resets the queue back to being empty.
     *
     * NOTE: The current items are left behind in storage. This does not affect the functioning of the queue, but misses
     * out on potential gas refunds.
     */
    function clear(Uint256Deque storage deque) internal {
        deque._begin = 0;
        deque._end = 0;
    }

    /**
     * @dev Returns the number of items in the queue.
     */
    function length(
        Uint256Deque storage deque
    ) internal view returns (uint256) {
        unchecked {
            return uint256(deque._end - deque._begin);
        }
    }

    /**
     * @dev Returns true if the queue is empty.
     */
    function empty(Uint256Deque storage deque) internal view returns (bool) {
        return deque._end == deque._begin;
    }
}

File 22 of 27 : ERC20Events.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

library ERC20Events {
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );
    event Transfer(address indexed from, address indexed to, uint256 amount);
}

File 23 of 27 : ERC721Events.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

library ERC721Events {
    event ApprovalForAll(
        address indexed owner,
        address indexed operator,
        bool approved
    );
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 indexed id
    );
    event Transfer(
        address indexed from,
        address indexed to,
        uint256 indexed id
    );
}

File 24 of 27 : Errors.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

library Errors {
    error InvalidLength();
    error OnlyCallByFactory();
    error NotBlueChipNFT();
    error X404NotCreate();
    error CantBeZeroAddress();
    error X404SwapV3FactoryMismatch();
    error InvalidNFTAddress();
    error InvalidDeadLine();
    error NFTCannotRedeem();
    error RemoveFailed();
    error EmergencyClose();
    error InvaildRedeemMaxDeadline();
    error MsgValueNotEnough();
    error SendETHFailed();
    error RedeemFeeTooHigh();
}

File 25 of 27 : Events.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library Events {
    event X404Created(
        address indexed addr,
        address indexed blueChipNftAddr,
        address indexed creator
    );

    event X404DepositNFT(
        address indexed caller,
        address indexed from,
        uint256 indexed tokenId,
        uint256 redeemDeadline
    );

    event X404RedeemNFT(
        address indexed redeemer,
        address indexed depositor,
        uint256 indexed tokenId
    );

    event SetContractURI(string indexed contractURI);
    event SetTokenURI(string indexed tokenURI);
    event SetRedeemFee(uint256 indexed redeemFee);
}

File 26 of 27 : LibCalculatePair.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {DataTypes} from "./DataTypes.sol";
import {IUniswapV3PoolState} from "../interfaces/IUniswapV3PoolState.sol";
import {IUniswapV2Router} from "../interfaces/IUniswapV2Router.sol";
import {IPeripheryImmutableState} from "../interfaces/IPeripheryImmutableState.sol";

library LibCalculatePair {
    function _getUniswapV2Pair(
        address uniswapV2Factory_,
        address tokenA,
        address tokenB
    ) internal pure returns (address) {
        (address token0, address token1) = tokenA < tokenB
            ? (tokenA, tokenB)
            : (tokenB, tokenA);
        return
            address(
                uint160(
                    uint256(
                        keccak256(
                            abi.encodePacked(
                                hex"ff",
                                uniswapV2Factory_,
                                keccak256(abi.encodePacked(token0, token1)),
                                hex"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f"
                            )
                        )
                    )
                )
            );
    }

    function _getUniswapV3Pair(
        address uniswapV3Factory_,
        address tokenA,
        address tokenB,
        uint24 fee_
    ) internal pure returns (address) {
        (address token0, address token1) = tokenA < tokenB
            ? (tokenA, tokenB)
            : (tokenB, tokenA);
        return
            address(
                uint160(
                    uint256(
                        keccak256(
                            abi.encodePacked(
                                hex"ff",
                                uniswapV3Factory_,
                                keccak256(abi.encode(token0, token1, fee_)),
                                hex"e34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
                            )
                        )
                    )
                )
            );
    }
}

File 27 of 27 : X404Storage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

abstract contract X404Storage {
    string public contractURI;
    string public baseURI;
    uint256 public redeemFee;

    //if not redeem your nft before deadline, others who hold units token maybe can get your nft, if no one get, you also can get your origin nft.
    uint256 public maxRedeemDeadline;

    struct NFTDepositInfo {
        address caller;
        address oriOwner;
        uint256 redeemDeadline;
    }

    EnumerableSet.UintSet internal tokenIdSet;
    mapping(uint256 => NFTDepositInfo) public nftDepositInfo;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 20,
    "details": {
      "yul": true
    }
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyExists","type":"error"},{"inputs":[],"name":"CantBeZeroAddress","type":"error"},{"inputs":[],"name":"DecimalsTooLow","type":"error"},{"inputs":[],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InvalidApproval","type":"error"},{"inputs":[],"name":"InvalidDeadLine","type":"error"},{"inputs":[],"name":"InvalidExemption","type":"error"},{"inputs":[],"name":"InvalidLength","type":"error"},{"inputs":[],"name":"InvalidNFTAddress","type":"error"},{"inputs":[],"name":"InvalidOperator","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidSigner","type":"error"},{"inputs":[],"name":"InvalidSpender","type":"error"},{"inputs":[],"name":"InvalidTokenId","type":"error"},{"inputs":[],"name":"MintLimitReached","type":"error"},{"inputs":[],"name":"MsgValueNotEnough","type":"error"},{"inputs":[],"name":"NFTCannotRedeem","type":"error"},{"inputs":[],"name":"NoAvaiableTokenID","type":"error"},{"inputs":[],"name":"NotFound","type":"error"},{"inputs":[],"name":"OnlyCallByFactory","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"OwnedIndexOverflow","type":"error"},{"inputs":[],"name":"PermitDeadlineExpired","type":"error"},{"inputs":[],"name":"QueueEmpty","type":"error"},{"inputs":[],"name":"QueueFull","type":"error"},{"inputs":[],"name":"QueueOutOfBounds","type":"error"},{"inputs":[],"name":"RecipientIsERC721TransferExempt","type":"error"},{"inputs":[],"name":"RedeemFeeTooHigh","type":"error"},{"inputs":[],"name":"RemoveFailed","type":"error"},{"inputs":[],"name":"SendETHFailed","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnsafeRecipient","type":"error"},{"inputs":[],"name":"X404SwapV3FactoryMismatch","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"contractURI","type":"string"}],"name":"SetContractURI","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"redeemFee","type":"uint256"}],"name":"SetRedeemFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"tokenURI","type":"string"}],"name":"SetTokenURI","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemDeadline","type":"uint256"}],"name":"X404DepositNFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"X404RedeemNFT","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"valueOrId_","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blueChipNftAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"checkTokenIdExsit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256","name":"redeemDeadline","type":"uint256"}],"name":"depositNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"erc20Approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"erc20BalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc20TotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"erc20TransferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"erc721Approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"erc721BalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc721TotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target_","type":"address"}],"name":"erc721TransferExempt","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"erc721TransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getERC721QueueLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start_","type":"uint256"},{"internalType":"uint256","name":"count_","type":"uint256"}],"name":"getERC721TokensInQueue","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokenIdSet","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemDeadline","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nftDepositInfo","outputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"address","name":"oriOwner","type":"address"},{"internalType":"uint256","name":"redeemDeadline","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"owned","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"erc721Owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"redeemNFT","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator_","type":"address"},{"internalType":"bool","name":"approved_","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newContractUri","type":"string"}],"name":"setContractURI","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRedeemFee","type":"uint256"}],"name":"setRedeemFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"state_","type":"bool"}],"name":"setSelfERC721TransferExempt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"valueOrId_","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"units","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"x404Hub","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x6080604052600436106102545760003560e01c80638a696e50116101405780638a696e50146105f95780638da5cb5b1461061957806392e8726b1461062e578063938e3d7b1461064e57806395d89b411461066e578063965fa21e14610683578063976a843514610699578063a22cb465146106af578063a9059cbb146106cf578063b1ab9317146106ef578063b31471521461070f578063b3f9ea3414610722578063b88d4fde14610742578063c5ab3ba614610762578063c87b56dd14610777578063d96ca0b914610797578063dc862c9c146107b7578063dd62ed3e146107eb578063dd63769914610823578063dfabc03314610843578063e0df5b6f14610863578063e194733a14610883578063e8a3d485146108b7578063e985e9c5146108cc578063f2fde38b14610907578063f780bc1a1461092757600080fd5b806301ffc9a71461025957806302519da31461028e57806302d05d3f146102bc57806306fdde03146102fd578063081812fc1461031f578063095ea7b31461035557806309674eb01461037557806309f0ef651461038a578063150b7a02146103aa57806318160ddd146103e357806323b872dd146103f9578063313ce5671461041957806335ef4ade1461044557806342842e0e146104655780634693aeb3146104875780634d966072146104df5780634f02c420146104ff5780635d841af5146105155780636352211e146105355780636acca766146105555780636c0360eb146105775780636c7ac14f1461058c57806370a08231146105a2578063715018a6146105cf57806389fb4c66146105e4575b600080fd5b34801561026557600080fd5b5061027961027436600461299f565b610947565b60405190151581526020015b60405180910390f35b34801561029a57600080fd5b506102ae6102a93660046129d3565b61097e565b604051908152602001610285565b3480156102c857600080fd5b506102f07f00000000000000000000000093b7867a0de4de04ac7497db7c14a470e12516b081565b60405161028591906129ee565b34801561030957600080fd5b50610312610999565b6040516102859190612a52565b34801561032b57600080fd5b506102f061033a366004612a65565b600a602052600090815260409020546001600160a01b031681565b34801561036157600080fd5b50610279610370366004612a7e565b610a27565b34801561038157600080fd5b506102ae610a60565b34801561039657600080fd5b506102796103a53660046129d3565b610a71565b3480156103b657600080fd5b506103ca6103c5366004612af0565b610aa3565b6040516001600160e01b03199091168152602001610285565b3480156103ef57600080fd5b506102ae60065481565b34801561040557600080fd5b50610279610414366004612b5e565b610c13565b34801561042557600080fd5b506004546104339060ff1681565b60405160ff9091168152602001610285565b34801561045157600080fd5b50610279610460366004612a65565b610c50565b34801561047157600080fd5b50610485610480366004612b5e565b610c5d565b005b34801561049357600080fd5b506104d06104a2366004612a65565b6016602052600090815260409020805460018201546002909201546001600160a01b03918216929091169083565b60405161028593929190612b9a565b3480156104eb57600080fd5b506102796104fa366004612a7e565b610c7d565b34801561050b57600080fd5b506102ae60075481565b34801561052157600080fd5b50610279610530366004612a65565b610d0a565b34801561054157600080fd5b506102f0610550366004612a65565b610db7565b34801561056157600080fd5b5061056a610e11565b6040516102859190612bbe565b34801561058357600080fd5b50610312610e1d565b34801561059857600080fd5b506102ae60135481565b3480156105ae57600080fd5b506102ae6105bd3660046129d3565b60086020526000908152604090205481565b3480156105db57600080fd5b50610485610e2a565b3480156105f057600080fd5b506006546102ae565b34801561060557600080fd5b50610485610614366004612c12565b610e3e565b34801561062557600080fd5b506102f0610e4b565b34801561063a57600080fd5b50610485610649366004612cf2565b610e5a565b34801561065a57600080fd5b50610279610669366004612d36565b611074565b34801561067a57600080fd5b50610312611137565b34801561068f57600080fd5b506102ae60125481565b3480156106a557600080fd5b506102ae60055481565b3480156106bb57600080fd5b506104856106ca366004612d77565b611144565b3480156106db57600080fd5b506102796106ea366004612a7e565b6111d7565b3480156106fb57600080fd5b5061056a61070a3660046129d3565b61120b565b61048561071d366004612daa565b611277565b34801561072e57600080fd5b506102ae61073d3660046129d3565b6116a3565b34801561074e57600080fd5b5061048561075d366004612de6565b6116be565b34801561076e57600080fd5b506102ae6117a5565b34801561078357600080fd5b50610312610792366004612a65565b6117be565b3480156107a357600080fd5b506102796107b2366004612b5e565b611827565b3480156107c357600080fd5b506102f07f000000000000000000000000524cab2ec69124574082676e6f654a18df49a04881565b3480156107f757600080fd5b506102ae610806366004612ea5565b600960209081526000928352604080842090915290825290205481565b34801561082f57600080fd5b5061048561083e366004612b5e565b6118fe565b34801561084f57600080fd5b5061048561085e366004612a7e565b611a41565b34801561086f57600080fd5b5061048561087e366004612d36565b611b04565b34801561088f57600080fd5b506102f07f00000000000000000000000016be924a3af57e1c293818894810b591adff82b181565b3480156108c357600080fd5b50610312611bc0565b3480156108d857600080fd5b506102796108e7366004612ea5565b600b60209081526000928352604080842090915290825290205460ff1681565b34801561091357600080fd5b506104856109223660046129d3565b611bcd565b34801561093357600080fd5b5061056a610942366004612ecf565b611c11565b60006001600160e01b0319821663d75fa48560e01b148061097857506001600160e01b031982166301ffc9a760e01b145b92915050565b6001600160a01b031660009081526008602052604090205490565b600280546109a690612ef1565b80601f01602080910402602001604051908101604052809291908181526020018280546109d290612ef1565b8015610a1f5780601f106109f457610100808354040283529160200191610a1f565b820191906000526020600020905b815481529060010190602001808311610a0257829003601f168201915b505050505081565b6000610a3282611cad565b15610a4657610a418383611a41565b610a57565b610a508383610c7d565b9050610978565b50600192915050565b6000610a6c6000611cc2565b905090565b60006001600160a01b03821615806109785750506001600160a01b03166000908152600e602052604090205460ff1690565b6000336001600160a01b037f000000000000000000000000524cab2ec69124574082676e6f654a18df49a0481614610aee576040516363cf3fad60e11b815260040160405180910390fd5b6000610afc83850185612a65565b905042811080610b175750601354610b149042612f41565b81115b15610b35576040516326d2ec8d60e11b815260040160405180910390fd5b610b43600088600554611ce0565b50610b4f601486611f1a565b15610b9957600085815260166020526040902080546001600160a01b03808a166001600160a01b0319928316178355600183018054918a1691909216179055600201819055610bb2565b6040516307ed98ed60e31b815260040160405180910390fd5b84866001600160a01b0316886001600160a01b03167faea7f4075120412c9eb2cd06b80fa77cff58a2fe8c0a32ed1cafedf3cf2cad4e84604051610bf891815260200190565b60405180910390a450630a85bd0160e11b9695505050505050565b6000610c1e82611cad565b15610c3357610c2e8484846118fe565b610c45565b610c3e848484611827565b9050610c49565b5060015b9392505050565b6000610978601483611f26565b610c78838383604051806020016040528060008152506116be565b505050565b60006001600160a01b038316610ca657604051635461585f60e01b815260040160405180910390fd5b3360008181526009602090815260408083206001600160a01b03881680855290835292819020869055518581529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350600192915050565b6000336001600160a01b037f00000000000000000000000016be924a3af57e1c293818894810b591adff82b11614610d555760405163542c971960e01b815260040160405180910390fd5b6702c68af0bb140000821115610d7e57604051638917e33360e01b815260040160405180910390fd5b601282905560405182907fc2045f7458ee2982ac24e8bc693c0924341b1d70475de942852d90e121fc776090600090a25060015b919050565b6000610dc282611f3e565b9050610dcd82611cad565b610dea576040516307ed98ed60e31b815260040160405180910390fd5b6001600160a01b038116610db25760405163c5723b5160e01b815260040160405180910390fd5b6060610a6c6014611f59565b601180546109a690612ef1565b610e32611f66565b610e3c6000611f98565b565b610e483382611fea565b50565b600f546001600160a01b031690565b42811080610e735750601354610e709042612f41565b81115b15610e91576040516326d2ec8d60e11b815260040160405180910390fd5b81516000819003610eb55760405163251f56a160e21b815260040160405180910390fd5b60005b81811015611054577f000000000000000000000000524cab2ec69124574082676e6f654a18df49a0486001600160a01b03166323b872dd3330878581518110610f0357610f03612f54565b60200260200101516040518463ffffffff1660e01b8152600401610f2993929190612b9a565b600060405180830381600087803b158015610f4357600080fd5b505af1158015610f57573d6000803e3d6000fd5b50505050610f88848281518110610f7057610f70612f54565b60200260200101516014611f1a90919063ffffffff16565b15610b9957600060166000868481518110610fa557610fa5612f54565b60209081029190910181015182528101919091526040016000208054336001600160a01b03199182168117835560018301805490921617905560020184905550838181518110610ff757610ff7612f54565b6020026020010151336001600160a01b0316336001600160a01b03167faea7f4075120412c9eb2cd06b80fa77cff58a2fe8c0a32ed1cafedf3cf2cad4e8660405161104491815260200190565b60405180910390a4600101610eb8565b5061106e600033600554846110699190612f6a565b611ce0565b50505050565b6000336001600160a01b037f00000000000000000000000016be924a3af57e1c293818894810b591adff82b116146110bf5760405163542c971960e01b815260040160405180910390fd5b60008290036110e15760405163251f56a160e21b815260040160405180910390fd5b60106110ee838583612fcf565b5060106040516110fe9190613102565b604051908190038120907f5ca9f750836b0b7efdace104f07b5c9f0df0650c0fd24f5163e99044ae36ea5290600090a250600192915050565b600380546109a690612ef1565b6001600160a01b03821661116b5760405163ccea9e6f60e01b815260040160405180910390fd5b336000818152600b602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006001600160a01b03831661120057604051634e46966960e11b815260040160405180910390fd5b610c49338484611ce0565b6001600160a01b0381166000908152600d602090815260409182902080548351818402810184019094528084526060939283018282801561126b57602002820191906000526020600020905b815481526020019060010190808311611257575b50505050509050919050565b8051600081900361129b5760405163251f56a160e21b815260040160405180910390fd5b601254156113d2576000601254826112b39190612f6a565b9050803410156112d657604051630df1795160e11b815260040160405180910390fd5b60006112e0610e4b565b6001600160a01b03168260405160006040518083038185875af1925050503d806000811461132a576040519150601f19603f3d011682016040523d82523d6000602084013e61132f565b606091505b505090508061135157604051632b3b0c0960e11b815260040160405180910390fd5b813411156113cb57600033611366843461310e565b604051600081818185875af1925050503d80600081146113a2576040519150601f19603f3d011682016040523d82523d6000602084013e6113a7565b606091505b50509050806113c957604051632b3b0c0960e11b815260040160405180910390fd5b505b5050611443565b341561144357604051600090339034908381818185875af1925050503d806000811461141a576040519150601f19603f3d011682016040523d82523d6000602084013e61141f565b606091505b505090508061144157604051632b3b0c0960e11b815260040160405180910390fd5b505b611457336000836005546110699190612f6a565b5060005b8251811015610c785760006016600085848151811061147c5761147c612f54565b6020908102919091018101518252810191909152604001600020600101546001600160a01b031690503381148015906114e3575042601660008685815181106114c7576114c7612f54565b6020026020010151815260200190815260200160002060020154115b156115015760405163165dee4f60e21b815260040160405180910390fd5b61152e84838151811061151657611516612f54565b6020026020010151601461205990919063ffffffff16565b61154b57604051631bdeb1bd60e11b815260040160405180910390fd5b7f000000000000000000000000524cab2ec69124574082676e6f654a18df49a0486001600160a01b03166342842e0e303387868151811061158e5761158e612f54565b60200260200101516040518463ffffffff1660e01b81526004016115b493929190612b9a565b600060405180830381600087803b1580156115ce57600080fd5b505af11580156115e2573d6000803e3d6000fd5b505050508382815181106115f8576115f8612f54565b6020026020010151816001600160a01b0316336001600160a01b03167f55585f5b6d3412be8ad70ddf268b532ea1d828bf1b6cd4c01bd0080e8428546660405160405180910390a46016600085848151811061165657611656612f54565b6020908102919091018101518252810191909152604001600090812080546001600160a01b031990811682556001808301805490921690915560029091019190915591909101905061145b565b6001600160a01b03166000908152600d602052604090205490565b6116c782611cad565b6116e4576040516307ed98ed60e31b815260040160405180910390fd5b6116ef8484846118fe565b6001600160a01b0383163b158015906117875750604051630a85bd0160e11b808252906001600160a01b0385169063150b7a0290611737903390899088908890600401613121565b6020604051808303816000875af1158015611756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177a919061315e565b6001600160e01b03191614155b1561106e57604051633da6393160e01b815260040160405180910390fd5b60006117b16000611cc2565b600754610a6c919061310e565b606060006117cb83611f3e565b90506001600160a01b0381166117f45760405163c5723b5160e01b815260040160405180910390fd5b60116117ff84612065565b60405160200161181092919061317b565b604051602081830303815290604052915050919050565b60006001600160a01b03841661185057604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b03831661187757604051634e46966960e11b815260040160405180910390fd5b6001600160a01b038416600090815260096020908152604080832033845290915290205460001981148015906118b657506001600160a01b0385163314155b156118ea576118c5838261310e565b6001600160a01b03861660009081526009602090815260408083203384529091529020555b6118f5858585611ce0565b95945050505050565b6001600160a01b03831661192557604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b03821661194c57604051634e46966960e11b815260040160405180910390fd5b61195581611f3e565b6001600160a01b0316836001600160a01b031614611985576040516282b42960e81b815260040160405180910390fd5b336001600160a01b038416148015906119c257506001600160a01b0383166000908152600b6020908152604080832033845290915290205460ff16155b80156119e557506000818152600a60205260409020546001600160a01b03163314155b15611a02576040516282b42960e81b815260040160405180910390fd5b611a0b82610a71565b15611a2957604051635ce7539760e01b815260040160405180910390fd5b611a3683836005546120f7565b610c788383836121ec565b6000611a4c82611f3e565b9050336001600160a01b03821614801590611a8b57506001600160a01b0381166000908152600b6020908152604080832033845290915290205460ff16155b15611aa8576040516282b42960e81b815260040160405180910390fd5b6000828152600a602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b336001600160a01b037f00000000000000000000000016be924a3af57e1c293818894810b591adff82b11614611b4d5760405163542c971960e01b815260040160405180910390fd5b6000819003611b6f5760405163251f56a160e21b815260040160405180910390fd5b6011611b7c828483612fcf565b506011604051611b8c9190613102565b604051908190038120907f9d3b637080c93cf84785a8e847e7c45118d18988dfbaf8acb02b53fcbb14dacb90600090a25050565b601080546109a690612ef1565b611bd5611f66565b6001600160a01b038116611c08576000604051631e4fbdf760e01b8152600401611bff91906129ee565b60405180910390fd5b610e4881611f98565b60606000826001600160401b03811115611c2d57611c2d612c2d565b604051908082528060200260200182016040528015611c56578160200160208202803683370190505b509050835b611c658486612f41565b811015611ca557611c776000826123c4565b82611c82878461310e565b81518110611c9257611c92612f54565b6020908102919091010152600101611c5b565b509392505050565b60006007548211158015610978575050151590565b546001600160801b03808216600160801b9092048116919091031690565b600080611cec8561097e565b90506000611cf98561097e565b9050611d068686866120f7565b6000611d1187610a71565b90506000611d1e87610a71565b9050818015611d2a5750805b611f0c578115611d9957600060055484611d4491906131a0565b6005546001600160a01b038a16600090815260086020526040902054611d6a91906131a0565b611d74919061310e565b905060005b81811015611d9257611d8a89612416565b600101611d79565b5050611f0c565b8015611dfb576005546001600160a01b0389166000908152600860205260408120549091611dc6916131a0565b600554611dd390876131a0565b611ddd919061310e565b905060005b81811015611d9257611df38a6124e6565b600101611de2565b600060055487611e0b91906131a0565b905060005b81811015611e8e576001600160a01b038a166000908152600d6020526040812054611e3d9060019061310e565b6001600160a01b038c166000908152600d602052604081208054929350909183908110611e6c57611e6c612f54565b90600052602060002001549050611e848c8c836121ec565b5050600101611e10565b5080600554611e9c8b61097e565b611ea691906131a0565b600554611eb390886131a0565b611ebd919061310e565b1115611ecc57611ecc896124e6565b8060055485611edb91906131a0565b600554611ee78b61097e565b611ef191906131a0565b611efb919061310e565b1115611f0a57611f0a88612416565b505b506001979650505050505050565b6000610c49838361256b565b60008181526001830160205260408120541515610c49565b6000908152600c60205260409020546001600160a01b031690565b60606000610c49836125ba565b33611f6f610e4b565b6001600160a01b031614610e3c573360405163118cdaa760e01b8152600401611bff91906129ee565b600f80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166120115760405163a41e3d3f60e01b815260040160405180910390fd5b80156120255761202082612614565b61202e565b61202e8261263d565b6001600160a01b03919091166000908152600e60205260409020805460ff1916911515919091179055565b6000610c498383612689565b606060006120728361277c565b60010190506000816001600160401b0381111561209157612091612c2d565b6040519080825280601f01601f1916602001820160405280156120bb576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846120c557509392505050565b6001600160a01b0383166121225780600660008282546121179190612f41565b909155506121509050565b6001600160a01b0383166000908152600860205260408120805483929061214a90849061310e565b90915550505b6001600160a01b03821661217b578060066000828254612170919061310e565b9091555061219a9050565b6001600160a01b03821660009081526008602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516121df91815260200190565b60405180910390a3505050565b6001600160a01b038316156122f7576000818152600a6020908152604080832080546001600160a01b03191690556001600160a01b0386168352600d9091528120805461223b9060019061310e565b8154811061224b5761224b612f54565b906000526020600020015490508181146122b8576000828152600c602052604081205460a01c6001600160a01b0386166000908152600d6020526040902080549192508391839081106122a0576122a0612f54565b6000918252602090912001556122b68282612852565b505b6001600160a01b0384166000908152600d602052604090208054806122df576122df6131c2565b60019003818190600052602060002001600090559055505b6001600160a01b0382161561236e576000818152600c6020908152604080832080546001600160a01b0319166001600160a01b038716908101909155808452600d83529083208054600181810183558286529385200185905592529054612369918391612364919061310e565b612852565b61237e565b6000818152600c60205260408120555b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006123cf83611cc2565b82106123ee5760405163580821e760e01b815260040160405180910390fd5b5081546001600160801b03908116820116600090815260018301602052604090205492915050565b6001600160a01b03811661243d57604051634e46966960e11b815260040160405180910390fd5b600080546001600160801b03808216600160801b909204161461246b5761246460006128af565b90506124a6565b60076000815461247a906131d8565b909155506007546001016124a15760405163303b682f60e01b815260040160405180910390fd5b506007545b60006124b182611f3e565b90506001600160a01b038116156124db5760405163119b4fd360e11b815260040160405180910390fd5b610c788184846121ec565b6001600160a01b03811661250d57604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b0381166000908152600d6020526040812080546125339060019061310e565b8154811061254357612543612f54565b9060005260206000200154905061255c826000836121ec565b61256760008261291f565b5050565b60008181526001830160205260408120546125b257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610978565b506000610978565b60608160000180548060200260200160405190810160405280929190818152602001828054801561126b57602002820191906000526020600020908154815260200190600101908083116112575750505050509050919050565b600061261f826116a3565b905060005b81811015610c7857612635836124e6565b600101612624565b600060055461264b8361097e565b61265591906131a0565b90506000612662836116a3565b905060005b612671828461310e565b81101561106e5761268184612416565b600101612667565b600081815260018301602052604081205480156127725760006126ad60018361310e565b85549091506000906126c19060019061310e565b90508082146127265760008660000182815481106126e1576126e1612f54565b906000526020600020015490508087600001848154811061270457612704612f54565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612737576127376131c2565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610978565b6000915050610978565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106127bb5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6904ee2d6d415b85acef8160201b83106127e5576904ee2d6d415b85acef8160201b830492506020015b662386f26fc10000831061280357662386f26fc10000830492506010015b6305f5e100831061281b576305f5e100830492506008015b612710831061282f57612710830492506004015b60648310612841576064830492506002015b600a83106109785760010192915050565b6000828152600c60205260409020546001600160601b0382111561288957604051633f2cd0e360e21b815260040160405180910390fd5b6000928352600c60205260409092206001600160a01b039290921660a09190911b019055565b80546000906001600160801b03600160801b82048116911681036128e6576040516375e52f4f60e01b815260040160405180910390fd5b600019016001600160801b039081166000818152600185016020526040812080549190558454909216600160801b909102179092555090565b81546001600160801b038082166000190191600160801b900481169082160361295b57604051638acb5f2760e01b815260040160405180910390fd5b6001600160801b0316600081815260018401602052604090209190915581546001600160801b031916179055565b6001600160e01b031981168114610e4857600080fd5b6000602082840312156129b157600080fd5b8135610c4981612989565b80356001600160a01b0381168114610db257600080fd5b6000602082840312156129e557600080fd5b610c49826129bc565b6001600160a01b0391909116815260200190565b60005b83811015612a1d578181015183820152602001612a05565b50506000910152565b60008151808452612a3e816020860160208601612a02565b601f01601f19169290920160200192915050565b602081526000610c496020830184612a26565b600060208284031215612a7757600080fd5b5035919050565b60008060408385031215612a9157600080fd5b612a9a836129bc565b946020939093013593505050565b60008083601f840112612aba57600080fd5b5081356001600160401b03811115612ad157600080fd5b602083019150836020828501011115612ae957600080fd5b9250929050565b600080600080600060808688031215612b0857600080fd5b612b11866129bc565b9450612b1f602087016129bc565b93506040860135925060608601356001600160401b03811115612b4157600080fd5b612b4d88828901612aa8565b969995985093965092949392505050565b600080600060608486031215612b7357600080fd5b612b7c846129bc565b9250612b8a602085016129bc565b9150604084013590509250925092565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6020808252825182820181905260009190848201906040850190845b81811015612bf657835183529284019291840191600101612bda565b50909695505050505050565b80358015158114610db257600080fd5b600060208284031215612c2457600080fd5b610c4982612c02565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612c6b57612c6b612c2d565b604052919050565b600082601f830112612c8457600080fd5b813560206001600160401b03821115612c9f57612c9f612c2d565b8160051b612cae828201612c43565b9283528481018201928281019087851115612cc857600080fd5b83870192505b84831015612ce757823582529183019190830190612cce565b979650505050505050565b60008060408385031215612d0557600080fd5b82356001600160401b03811115612d1b57600080fd5b612d2785828601612c73565b95602094909401359450505050565b60008060208385031215612d4957600080fd5b82356001600160401b03811115612d5f57600080fd5b612d6b85828601612aa8565b90969095509350505050565b60008060408385031215612d8a57600080fd5b612d93836129bc565b9150612da160208401612c02565b90509250929050565b600060208284031215612dbc57600080fd5b81356001600160401b03811115612dd257600080fd5b612dde84828501612c73565b949350505050565b60008060008060808587031215612dfc57600080fd5b612e05856129bc565b93506020612e148187016129bc565b93506040860135925060608601356001600160401b0380821115612e3757600080fd5b818801915088601f830112612e4b57600080fd5b813581811115612e5d57612e5d612c2d565b612e6f601f8201601f19168501612c43565b91508082528984828501011115612e8557600080fd5b808484018584013760008482840101525080935050505092959194509250565b60008060408385031215612eb857600080fd5b612ec1836129bc565b9150612da1602084016129bc565b60008060408385031215612ee257600080fd5b50508035926020909101359150565b600181811c90821680612f0557607f821691505b602082108103612f2557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561097857610978612f2b565b634e487b7160e01b600052603260045260246000fd5b808202811582820484141761097857610978612f2b565b601f821115610c7857600081815260208120601f850160051c81016020861015612fa85750805b601f850160051c820191505b81811015612fc757828155600101612fb4565b505050505050565b6001600160401b03831115612fe657612fe6612c2d565b612ffa83612ff48354612ef1565b83612f81565b6000601f84116001811461302e57600085156130165750838201355b600019600387901b1c1916600186901b178355613088565b600083815260209020601f19861690835b8281101561305f578685013582556020948501946001909201910161303f565b508682101561307c5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6000815461309c81612ef1565b600182811680156130b457600181146130c9576130f8565b60ff19841687528215158302870194506130f8565b8560005260208060002060005b858110156130ef5781548a8201529084019082016130d6565b50505082870194505b5050505092915050565b6000610c49828461308f565b8181038181111561097857610978612f2b565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061315490830184612a26565b9695505050505050565b60006020828403121561317057600080fd5b8151610c4981612989565b6000613187828561308f565b8351613197818360208801612a02565b01949350505050565b6000826131bd57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603160045260246000fd5b6000600182016131ea576131ea612f2b565b506001019056fea2646970667358221220ad785d83b43094fabe0668ca3775a433797d426125c1ae6f7994caeb4099b39d64736f6c63430008140033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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