ETH Price: $3,324.02 (-1.09%)

Token

FreedomWrld (FREE)
 

Overview

Max Total Supply

4,484.6 FREE

Holders

599

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Balance
1 FREE

Value
$0.00
0x73c51b6cf362cea1665878662ff3191b60dafd8f
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
FreedomWrld

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 10000 runs

Other Settings:
paris EvmVersion
File 1 of 11 : FreedomWrld.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "./DN404.sol";
import "./DN404Mirror.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";

interface FreedomPresale {
    function enteredAmount(address) external view returns(uint256);
}

contract FreedomWrld is DN404, Ownable, ReentrancyGuard, Pausable {
    bool public IS_PUBLIC_MINT_LIVE = false;
    bool public IS_WHITELIST_MINT_LIVE = false;
    bool public IS_CLAIM_LIVE = false;

    uint256 public PUBLIC_MINT_PRICE_PER_STEP;
    uint256 public WHITELIST_MINT_PRICE_PER_STEP;

    uint256 public MINT_STEP = 10 ** 17; // 0.1

    uint256 public MAX_TOTAL_SUPPLY = 6000 * _unit();

    uint256 public AVAILABLE_WHITELIST_MINT_SUPPLY;

    uint256 public PUBLIC_MINT_MAX_PER_WALLET = 4 * _unit();

    bytes32 public WHITELIST_MINT_MERKLE_ROOT = 0x0;
    bytes32 public CLAIM_MERKLE_ROOT = 0x0;

    struct Wallet {
        uint256 publicMints;
        uint256 whitelistMints;
        uint256 partnerClaims;
        uint256 presaleClaims;
    }

    mapping(address => Wallet) public wallets;

    mapping(address => bool) public unpausablePerAddress;

    address private _PRESALE_ADDRESS_1;
    address private _PRESALE_ADDRESS_2;

    string public baseURI = "";

    bool private _pausedApprovalsAndTransfers = true;

    constructor(
        uint256 _publicMintPricePerStep,
        uint256 _whitelistMintPricePerStep,
        uint256 _availableWhitelistMintSupply,
        uint256 _initialTokenSupply,
        address _presaleAddress1,
        address _presaleAddress2
    ) Ownable(msg.sender) {
        unpausablePerAddress[msg.sender] = true;

        PUBLIC_MINT_PRICE_PER_STEP = _publicMintPricePerStep;
        WHITELIST_MINT_PRICE_PER_STEP = _whitelistMintPricePerStep;

        AVAILABLE_WHITELIST_MINT_SUPPLY = _availableWhitelistMintSupply;

        _PRESALE_ADDRESS_1 = _presaleAddress1;
        _PRESALE_ADDRESS_2 = _presaleAddress2;

        address mirror = address(new DN404Mirror(msg.sender));

        _initializeDN404(_initialTokenSupply, msg.sender, mirror);
    }

    function name() public pure override returns (string memory) {
        return "FreedomWrld";
    }

    function symbol() public pure override returns (string memory) {
        return "FREE";
    }

    function mintPublic(uint256 _amount) external payable nonReentrant {
        require(IS_PUBLIC_MINT_LIVE, "Public mint not live");
        require(_amount > 0, "Cannot mint zero");
        require(wallets[msg.sender].publicMints > 0 || _amount >= _unit(), "Must mint at least 1");
        require(totalSupply() + _amount <= MAX_TOTAL_SUPPLY, "Max total supply reached");
        require(wallets[msg.sender].publicMints + _amount <= PUBLIC_MINT_MAX_PER_WALLET, "Max public mints per wallet reached");

        require(_amount % MINT_STEP == 0, "Incorrect mint amount");
        uint256 amountSteps = _amount / MINT_STEP;
        require(amountSteps * PUBLIC_MINT_PRICE_PER_STEP <= msg.value, "Not enough ETH");

        unchecked {
            wallets[msg.sender].publicMints += _amount;
        }

        _mint(msg.sender, _amount);
    }

    function mintWhitelist(uint256 _amount, uint256 _maxAmount, bytes32[] calldata _proof) external payable nonReentrant {
        require(IS_WHITELIST_MINT_LIVE, "Whitelist mint not live");

        bytes32 proofLeaf = keccak256(abi.encodePacked(msg.sender, _maxAmount));
        require(MerkleProof.verifyCalldata(_proof, WHITELIST_MINT_MERKLE_ROOT, proofLeaf), "Not allowed to mint from whitelist");

        require(_amount > 0, "Cannot mint zero");
        require(wallets[msg.sender].whitelistMints > 0 || _amount >= _unit(), "Must mint at least 1");
        require(totalSupply() + _amount <= MAX_TOTAL_SUPPLY, "Max total supply reached");
        require(AVAILABLE_WHITELIST_MINT_SUPPLY > 0, "Max whitelist supply reached");
        require(wallets[msg.sender].whitelistMints + _amount <= _maxAmount, "Max whitelist amount reached");

        require(_amount % MINT_STEP == 0, "Incorrect mint amount");
        uint256 amountSteps = _amount / MINT_STEP;
        require(amountSteps * WHITELIST_MINT_PRICE_PER_STEP <= msg.value, "Not enough ETH");

        unchecked {
            wallets[msg.sender].whitelistMints += _amount;
            AVAILABLE_WHITELIST_MINT_SUPPLY -= _amount;
        }

        _mint(msg.sender, _amount);
    }

    function claimPartner(uint256 _amount, uint256 _maxAmount, bytes32[] calldata _proof) external nonReentrant {
        require(IS_CLAIM_LIVE, "Claim not live");

        bytes32 proofLeaf = keccak256(abi.encodePacked(msg.sender, _maxAmount));
        require(MerkleProof.verifyCalldata(_proof, CLAIM_MERKLE_ROOT, proofLeaf), "Not allowed to claim");

        require(totalSupply() + _amount <= MAX_TOTAL_SUPPLY, "Max total supply reached");
        require(wallets[msg.sender].partnerClaims + _amount <= _maxAmount, "Max whitelist amount reached");

        unchecked {
            wallets[msg.sender].partnerClaims += _amount;
        }

        _mint(msg.sender, _amount);
    }

    function claimPresale(uint256 _amount) external nonReentrant {
        require(IS_CLAIM_LIVE, "Claim not live");

        FreedomPresale presale1 = FreedomPresale(_PRESALE_ADDRESS_1);
        FreedomPresale presale2 = FreedomPresale(_PRESALE_ADDRESS_2);
        uint256 presaleAmount1 = presale1.enteredAmount(msg.sender);
        uint256 presaleAmount2 = presale2.enteredAmount(msg.sender);
        uint256 maxAmount = (presaleAmount1 + presaleAmount2) * _unit();

        require(maxAmount > 0, "Not part of presale");
        require(wallets[msg.sender].presaleClaims + _amount <= maxAmount, "Max available presale amount reached");
        require(totalSupply() + _amount <= MAX_TOTAL_SUPPLY, "Max total supply reached");

        unchecked {
            wallets[msg.sender].presaleClaims += _amount;
        }

        _mint(msg.sender, _amount);
    }

    function setPublicMintMaxPerWallet(uint256 _newValue) external onlyOwner {
        PUBLIC_MINT_MAX_PER_WALLET = _newValue;
    }

    function setAvailableWhitelistMintSupply(uint256 _newValue) external onlyOwner {
        AVAILABLE_WHITELIST_MINT_SUPPLY = _newValue;
    }

    function setPublicMintPrice(uint256 _newValue) external onlyOwner {
        PUBLIC_MINT_PRICE_PER_STEP = _newValue;
    }

    function setWhitelistMintPrice(uint256 _newValue) external onlyOwner {
        WHITELIST_MINT_PRICE_PER_STEP = _newValue;
    }

    function togglePublicMintIsLive() external onlyOwner {
        IS_PUBLIC_MINT_LIVE = !IS_PUBLIC_MINT_LIVE;
    }

    function toggleWhitelistMintIsLive() external onlyOwner {
        IS_WHITELIST_MINT_LIVE = !IS_WHITELIST_MINT_LIVE;
    }

    function toggleClaimIsLive() external onlyOwner {
        IS_CLAIM_LIVE = !IS_CLAIM_LIVE;
    }

    function setWhitelistMintMerkleRoot(bytes32 _newValue) external onlyOwner {
        WHITELIST_MINT_MERKLE_ROOT = _newValue;
    }

    function setClaimMerkleRoot(bytes32 _newValue) external onlyOwner {
        CLAIM_MERKLE_ROOT = _newValue;
    }

    function setBaseURI(string calldata _newValue) external onlyOwner {
        baseURI = _newValue;
    }

    function setMintStep(uint256 _newValue) external onlyOwner {
        MINT_STEP = _newValue;
    }

    function tokenURI(uint256 tokenId) public view override returns (string memory result) {
        if (bytes(baseURI).length != 0) {
            result = string(abi.encodePacked(baseURI, Strings.toString(tokenId)));
        }
    }

    function withdrawEthBalance() external onlyOwner {
        payable(owner()).transfer(address(this).balance);
    }

    function togglePausedApprovalsAndTransfers() external onlyOwner {
        _pausedApprovalsAndTransfers = !_pausedApprovalsAndTransfers;
    }

    function setUnpausableAddress(address _newValue, bool unpausable) external onlyOwner {
        unpausablePerAddress[_newValue] = unpausable;
    }

    function paused() public view override returns (bool) {
        return _pausedApprovalsAndTransfers && !unpausablePerAddress[msg.sender];
    }

    function approve(address spender, uint256 amount) public override whenNotPaused returns (bool) {
        return super.approve(spender, amount);
    }

    function transfer(address to, uint256 amount) public override whenNotPaused returns (bool) {
        return super.transfer(to, amount);
    }

    function transferFrom(address from, address to, uint256 amount) public override whenNotPaused returns (bool) {
        return super.transferFrom(from, to, amount);
    }
}

File 2 of 11 : 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 11 : 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 4 of 11 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.20;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the Merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates Merkle trees that are safe
 * against this attack out of the box.
 */
library MerkleProof {
    /**
     *@dev The multiproof provided is not valid.
     */
    error MerkleProofInvalidMultiproof();

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Sorts the pair (a, b) and hashes the result.
     */
    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    /**
     * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
     */
    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 5 of 11 : 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 6 of 11 : 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 7 of 11 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

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

pragma solidity ^0.8.20;

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

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

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

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

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

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

File 9 of 11 : 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 10 of 11 : DN404.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @title DN404
/// @notice DN404 is a hybrid ERC20 and ERC721 implementation that mints
/// and burns NFTs based on an account's ERC20 token balance.
///
/// @author vectorized.eth (@optimizoor)
/// @author Quit (@0xQuit)
/// @author Michael Amadi (@AmadiMichaels)
/// @author cygaar (@0xCygaar)
/// @author Thomas (@0xjustadev)
/// @author Harrison (@PopPunkOnChain)
///
/// @dev Note:
/// - The ERC721 data is stored in this base DN404 contract, however a
///   DN404Mirror contract ***MUST*** be deployed and linked during
///   initialization.
abstract contract DN404 {
    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                           EVENTS                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Emitted when `amount` tokens is transferred from `from` to `to`.
    event Transfer(address indexed from, address indexed to, uint256 amount);

    /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`.
    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /// @dev Emitted when `target` sets their skipNFT flag to `status`.
    event SkipNFTSet(address indexed target, bool status);

    /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`.
    uint256 private constant _TRANSFER_EVENT_SIGNATURE =
    0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`.
    uint256 private constant _APPROVAL_EVENT_SIGNATURE =
    0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;

    /// @dev `keccak256(bytes("SkipNFTSet(address,bool)"))`.
    uint256 private constant _SKIP_NFT_SET_EVENT_SIGNATURE =
    0xb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d6420393;

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                        CUSTOM ERRORS                       */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Thrown when attempting to double-initialize the contract.
    error DNAlreadyInitialized();

    /// @dev Thrown when attempting to transfer or burn more tokens than sender's balance.
    error InsufficientBalance();

    /// @dev Thrown when a spender attempts to transfer tokens with an insufficient allowance.
    error InsufficientAllowance();

    /// @dev Thrown when minting an amount of tokens that would overflow the max tokens.
    error TotalSupplyOverflow();

    /// @dev The unit cannot be zero.
    error UnitIsZero();

    /// @dev Thrown when the caller for a fallback NFT function is not the mirror contract.
    error SenderNotMirror();

    /// @dev Thrown when attempting to transfer tokens to the zero address.
    error TransferToZeroAddress();

    /// @dev Thrown when the mirror address provided for initialization is the zero address.
    error MirrorAddressIsZero();

    /// @dev Thrown when the link call to the mirror contract reverts.
    error LinkMirrorContractFailed();

    /// @dev Thrown when setting an NFT token approval
    /// and the caller is not the owner or an approved operator.
    error ApprovalCallerNotOwnerNorApproved();

    /// @dev Thrown when transferring an NFT
    /// and the caller is not the owner or an approved operator.
    error TransferCallerNotOwnerNorApproved();

    /// @dev Thrown when transferring an NFT and the from address is not the current owner.
    error TransferFromIncorrectOwner();

    /// @dev Thrown when checking the owner or approved address for a non-existent NFT.
    error TokenDoesNotExist();

    /// @dev The function selector is not recognized.
    error FnSelectorNotRecognized();

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                         CONSTANTS                          */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev The flag to denote that the address data is initialized.
    uint8 internal constant _ADDRESS_DATA_INITIALIZED_FLAG = 1 << 0;

    /// @dev The flag to denote that the address should skip NFTs.
    uint8 internal constant _ADDRESS_DATA_SKIP_NFT_FLAG = 1 << 1;

    /// @dev The flag to denote that the address has overridden the default Permit2 allowance.
    uint8 internal constant _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG = 1 << 2;

    /// @dev The canonical Permit2 address.
    /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.
    /// To enable, override `_givePermit2DefaultInfiniteAllowance()`.
    /// [Github](https://github.com/Uniswap/permit2)
    /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)
    address internal constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                          STORAGE                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Struct containing an address's token data and settings.
    struct AddressData {
        // Auxiliary data.
        uint88 aux;
        // Flags for `initialized` and `skipNFT`.
        uint8 flags;
        // The alias for the address. Zero means absence of an alias.
        uint32 addressAlias;
        // The number of NFT tokens.
        uint32 ownedLength;
        // The token balance in wei.
        uint96 balance;
    }

    /// @dev A uint32 map in storage.
    struct Uint32Map {
        uint256 spacer;
    }

    /// @dev A bitmap in storage.
    struct Bitmap {
        uint256 spacer;
    }

    /// @dev A struct to wrap a uint256 in storage.
    struct Uint256Ref {
        uint256 value;
    }

    /// @dev A mapping of an address pair to a Uint256Ref.
    struct AddressPairToUint256RefMap {
        uint256 spacer;
    }

    /// @dev Struct containing the base token contract storage.
    struct DN404Storage {
        // Current number of address aliases assigned.
        uint32 numAliases;
        // Next NFT ID to assign for a mint.
        uint32 nextTokenId;
        // The head of the burned pool.
        uint32 burnedPoolHead;
        // The tail of the burned pool.
        uint32 burnedPoolTail;
        // Total number of NFTs in existence.
        uint32 totalNFTSupply;
        // Total supply of tokens.
        uint96 totalSupply;
        // Address of the NFT mirror contract.
        address mirrorERC721;
        // Mapping of a user alias number to their address.
        mapping(uint32 => address) aliasToAddress;
        // Mapping of user operator approvals for NFTs.
        AddressPairToUint256RefMap operatorApprovals;
        // Mapping of NFT approvals to approved operators.
        mapping(uint256 => address) nftApprovals;
        // Bitmap of whether an non-zero NFT approval may exist.
        Bitmap mayHaveNFTApproval;
        // Bitmap of whether a NFT ID exists. Ignored if `_useExistsLookup()` returns false.
        Bitmap exists;
        // Mapping of user allowances for ERC20 spenders.
        AddressPairToUint256RefMap allowance;
        // Mapping of NFT IDs owned by an address.
        mapping(address => Uint32Map) owned;
        // The pool of burned NFT IDs.
        Uint32Map burnedPool;
        // Even indices: owner aliases. Odd indices: owned indices.
        Uint32Map oo;
        // Mapping of user account AddressData.
        mapping(address => AddressData) addressData;
    }

    /// @dev Returns a storage pointer for DN404Storage.
    function _getDN404Storage() internal pure virtual returns (DN404Storage storage $) {
        /// @solidity memory-safe-assembly
        assembly {
        // `uint72(bytes9(keccak256("DN404_STORAGE")))`.
            $.slot := 0xa20d6e21d0e5255308 // Truncate to 9 bytes to reduce bytecode size.
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                         INITIALIZER                        */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Initializes the DN404 contract with an
    /// `initialTokenSupply`, `initialTokenOwner` and `mirror` NFT contract address.
    function _initializeDN404(
        uint256 initialTokenSupply,
        address initialSupplyOwner,
        address mirror
    ) internal virtual {
        DN404Storage storage $ = _getDN404Storage();

        if (_unit() == 0) revert UnitIsZero();
        if ($.mirrorERC721 != address(0)) revert DNAlreadyInitialized();
        if (mirror == address(0)) revert MirrorAddressIsZero();

        /// @solidity memory-safe-assembly
        assembly {
        // Make the call to link the mirror contract.
            mstore(0x00, 0x0f4599e5) // `linkMirrorContract(address)`.
            mstore(0x20, caller())
            if iszero(and(eq(mload(0x00), 1), call(gas(), mirror, 0, 0x1c, 0x24, 0x00, 0x20))) {
                mstore(0x00, 0xd125259c) // `LinkMirrorContractFailed()`.
                revert(0x1c, 0x04)
            }
        }

        $.nextTokenId = 1;
        $.mirrorERC721 = mirror;

        if (initialTokenSupply != 0) {
            if (initialSupplyOwner == address(0)) revert TransferToZeroAddress();
            if (_totalSupplyOverflows(initialTokenSupply)) revert TotalSupplyOverflow();

            $.totalSupply = uint96(initialTokenSupply);
            AddressData storage initialOwnerAddressData = _addressData(initialSupplyOwner);
            initialOwnerAddressData.balance = uint96(initialTokenSupply);

            /// @solidity memory-safe-assembly
            assembly {
            // Emit the {Transfer} event.
                mstore(0x00, initialTokenSupply)
                log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, initialSupplyOwner)))
            }

            _setSkipNFT(initialSupplyOwner, true);
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*               BASE UNIT FUNCTION TO OVERRIDE               */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Amount of token balance that is equal to one NFT.
    function _unit() internal view virtual returns (uint256) {
        return 10 ** 18;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*               METADATA FUNCTIONS TO OVERRIDE               */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the name of the token.
    function name() public view virtual returns (string memory);

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

    /// @dev Returns the Uniform Resource Identifier (URI) for token `id`.
    function tokenURI(uint256 id) public view virtual returns (string memory);

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                       CONFIGURABLES                        */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns if direct NFT transfers should be used during ERC20 transfers
    /// whenever possible, instead of burning and re-minting.
    function _useDirectTransfersIfPossible() internal view virtual returns (bool) {
        return true;
    }

    /// @dev Returns if burns should be added to the burn pool.
    /// This returns false by default, which means the NFT IDs are re-minted in a cycle.
    function _addToBurnedPool(uint256 totalNFTSupplyAfterBurn, uint256 totalSupplyAfterBurn)
    internal
    view
    virtual
    returns (bool)
    {
        // Silence unused variable compiler warning.
        totalSupplyAfterBurn = totalNFTSupplyAfterBurn;
        return false;
    }

    /// @dev Returns whether to use the exists bitmap for more efficient
    /// scanning of an empty token ID slot.
    /// Recommended for collections that do not use the burn pool,
    /// and are expected to have nearly all possible NFTs materialized.
    ///
    /// Note: The returned value must be constant after initialization.
    function _useExistsLookup() internal view virtual returns (bool) {
        return true;
    }

    /// @dev Hook that is called after any NFT token transfers, including minting and burning.
    function _afterNFTTransfer(address from, address to, uint256 id) internal virtual {}

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                      ERC20 OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the decimals places of the token. Always 18.
    function decimals() public pure returns (uint8) {
        return 18;
    }

    /// @dev Returns the amount of tokens in existence.
    function totalSupply() public view virtual returns (uint256) {
        return uint256(_getDN404Storage().totalSupply);
    }

    /// @dev Returns the amount of tokens owned by `owner`.
    function balanceOf(address owner) public view virtual returns (uint256) {
        return _getDN404Storage().addressData[owner].balance;
    }

    /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`.
    function allowance(address owner, address spender) public view returns (uint256) {
        if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {
            uint8 flags = _getDN404Storage().addressData[owner].flags;
            if (flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG == 0) return type(uint256).max;
        }
        return _ref(_getDN404Storage().allowance, owner, spender).value;
    }

    /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
    ///
    /// Emits a {Approval} event.
    function approve(address spender, uint256 amount) public virtual returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    /// @dev Transfer `amount` tokens from the caller to `to`.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is
    /// set to false.
    ///
    /// Requirements:
    /// - `from` must at least have `amount`.
    ///
    /// Emits a {Transfer} event.
    function transfer(address to, uint256 amount) public virtual returns (bool) {
        _transfer(msg.sender, to, amount);
        return true;
    }

    /// @dev Transfers `amount` tokens from `from` to `to`.
    ///
    /// Note: Does not update the allowance if it is the maximum uint256 value.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is
    /// set to false.
    ///
    /// Requirements:
    /// - `from` must at least have `amount`.
    /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`.
    ///
    /// Emits a {Transfer} event.
    function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {
        Uint256Ref storage a = _ref(_getDN404Storage().allowance, from, msg.sender);

        uint256 allowed = _givePermit2DefaultInfiniteAllowance() && msg.sender == _PERMIT2
        && (_getDN404Storage().addressData[from].flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG) == 0
            ? type(uint256).max
            : a.value;

        if (allowed != type(uint256).max) {
            if (amount > allowed) revert InsufficientAllowance();
            unchecked {
                a.value = allowed - amount;
            }
        }
        _transfer(from, to, amount);
        return true;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                          PERMIT2                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Whether Permit2 has infinite allowances by default for all owners.
    /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.
    /// To enable, override this function to return true.
    function _givePermit2DefaultInfiniteAllowance() internal view virtual returns (bool) {
        return false;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                  INTERNAL MINT FUNCTIONS                   */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Mints `amount` tokens to `to`, increasing the total supply.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.
    ///
    /// Emits a {Transfer} event.
    function _mint(address to, uint256 amount) internal virtual {
        if (to == address(0)) revert TransferToZeroAddress();

        AddressData storage toAddressData = _addressData(to);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        _DNMintTemps memory t;
        unchecked {
            uint256 toBalance = uint256(toAddressData.balance) + amount;
            toAddressData.balance = uint96(toBalance);
            t.toEnd = toBalance / _unit();
        }
        uint256 maxId;
        unchecked {
            uint256 totalSupply_ = uint256($.totalSupply) + amount;
            $.totalSupply = uint96(totalSupply_);
            uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));
            if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();
            maxId = totalSupply_ / _unit();
        }
        unchecked {
            if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
                Uint32Map storage toOwned = $.owned[to];
                Uint32Map storage oo = $.oo;
                uint256 toIndex = toAddressData.ownedLength;
                _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));

                if (packedLogs.logs.length != 0) {
                    _packedLogsSet(packedLogs, to, 0);
                    $.totalNFTSupply += uint32(packedLogs.logs.length);
                    toAddressData.ownedLength = uint32(t.toEnd);
                    t.toAlias = _registerAndResolveAlias(toAddressData, to);
                    uint32 burnedPoolHead = $.burnedPoolHead;
                    t.burnedPoolTail = $.burnedPoolTail;
                    t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);
                    // Mint loop.
                    do {
                        uint256 id;
                        if (burnedPoolHead != t.burnedPoolTail) {
                            id = _get($.burnedPool, burnedPoolHead++);
                        } else {
                            id = t.nextTokenId;
                            while (_get(oo, _ownershipIndex(id)) != 0) {
                                id = _useExistsLookup()
                                    ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId + 1), maxId)
                                    : _wrapNFTId(id + 1, maxId);
                            }
                            t.nextTokenId = _wrapNFTId(id + 1, maxId);
                        }
                        if (_useExistsLookup()) _set($.exists, id, true);
                        _set(toOwned, toIndex, uint32(id));
                        _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));
                        _packedLogsAppend(packedLogs, id);
                        _afterNFTTransfer(address(0), to, id);
                    } while (toIndex != t.toEnd);

                    $.nextTokenId = uint32(t.nextTokenId);
                    $.burnedPoolHead = burnedPoolHead;
                    _packedLogsSend(packedLogs, $.mirrorERC721);
                }
            }
        }
        /// @solidity memory-safe-assembly
        assembly {
        // Emit the {Transfer} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))
        }
    }

    /// @dev Mints `amount` tokens to `to`, increasing the total supply.
    /// This variant mints NFT tokens starting from ID `preTotalSupply / _unit() + 1`.
    /// This variant will not touch the `burnedPool` and `nextTokenId`.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.
    ///
    /// Emits a {Transfer} event.
    function _mintNext(address to, uint256 amount) internal virtual {
        if (to == address(0)) revert TransferToZeroAddress();

        AddressData storage toAddressData = _addressData(to);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        _DNMintTemps memory t;
        unchecked {
            uint256 toBalance = uint256(toAddressData.balance) + amount;
            toAddressData.balance = uint96(toBalance);
            t.toEnd = toBalance / _unit();
        }
        uint256 startId;
        uint256 maxId;
        unchecked {
            uint256 preTotalSupply = uint256($.totalSupply);
            startId = preTotalSupply / _unit() + 1;
            uint256 totalSupply_ = uint256(preTotalSupply) + amount;
            $.totalSupply = uint96(totalSupply_);
            uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));
            if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();
            maxId = totalSupply_ / _unit();
        }
        unchecked {
            if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
                Uint32Map storage toOwned = $.owned[to];
                Uint32Map storage oo = $.oo;
                uint256 toIndex = toAddressData.ownedLength;
                _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));

                if (packedLogs.logs.length != 0) {
                    _packedLogsSet(packedLogs, to, 0);
                    $.totalNFTSupply += uint32(packedLogs.logs.length);
                    toAddressData.ownedLength = uint32(t.toEnd);
                    t.toAlias = _registerAndResolveAlias(toAddressData, to);
                    // Mint loop.
                    do {
                        uint256 id = startId;
                        while (_get(oo, _ownershipIndex(id)) != 0) {
                            id = _useExistsLookup()
                                ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId + 1), maxId)
                                : _wrapNFTId(id + 1, maxId);
                        }
                        startId = _wrapNFTId(id + 1, maxId);
                        if (_useExistsLookup()) _set($.exists, id, true);
                        _set(toOwned, toIndex, uint32(id));
                        _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));
                        _packedLogsAppend(packedLogs, id);
                        _afterNFTTransfer(address(0), to, id);
                    } while (toIndex != t.toEnd);

                    _packedLogsSend(packedLogs, $.mirrorERC721);
                }
            }
        }
        /// @solidity memory-safe-assembly
        assembly {
        // Emit the {Transfer} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                  INTERNAL BURN FUNCTIONS                   */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Burns `amount` tokens from `from`, reducing the total supply.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Emits a {Transfer} event.
    function _burn(address from, uint256 amount) internal virtual {
        AddressData storage fromAddressData = _addressData(from);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        uint256 fromBalance = fromAddressData.balance;
        if (amount > fromBalance) revert InsufficientBalance();

        unchecked {
            fromAddressData.balance = uint96(fromBalance -= amount);
            uint256 totalSupply_ = uint256($.totalSupply) - amount;
            $.totalSupply = uint96(totalSupply_);

            Uint32Map storage fromOwned = $.owned[from];
            uint256 fromIndex = fromAddressData.ownedLength;
            uint256 numNFTBurns = _zeroFloorSub(fromIndex, fromBalance / _unit());

            if (numNFTBurns != 0) {
                _DNPackedLogs memory packedLogs = _packedLogsMalloc(numNFTBurns);
                _packedLogsSet(packedLogs, from, 1);
                bool addToBurnedPool;
                {
                    uint256 totalNFTSupply = uint256($.totalNFTSupply) - numNFTBurns;
                    $.totalNFTSupply = uint32(totalNFTSupply);
                    addToBurnedPool = _addToBurnedPool(totalNFTSupply, totalSupply_);
                }

                Uint32Map storage oo = $.oo;
                uint256 fromEnd = fromIndex - numNFTBurns;
                fromAddressData.ownedLength = uint32(fromEnd);
                uint32 burnedPoolTail = $.burnedPoolTail;
                // Burn loop.
                do {
                    uint256 id = _get(fromOwned, --fromIndex);
                    _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);
                    _packedLogsAppend(packedLogs, id);
                    if (_useExistsLookup()) _set($.exists, id, false);
                    if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));
                    if (_get($.mayHaveNFTApproval, id)) {
                        _set($.mayHaveNFTApproval, id, false);
                        delete $.nftApprovals[id];
                    }
                    _afterNFTTransfer(from, address(0), id);
                } while (fromIndex != fromEnd);

                if (addToBurnedPool) $.burnedPoolTail = burnedPoolTail;
                _packedLogsSend(packedLogs, $.mirrorERC721);
            }
        }
        /// @solidity memory-safe-assembly
        assembly {
        // Emit the {Transfer} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0)
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                INTERNAL TRANSFER FUNCTIONS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Moves `amount` of tokens from `from` to `to`.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is
    /// set to false.
    ///
    /// Emits a {Transfer} event.
    function _transfer(address from, address to, uint256 amount) internal virtual {
        if (to == address(0)) revert TransferToZeroAddress();

        AddressData storage fromAddressData = _addressData(from);
        AddressData storage toAddressData = _addressData(to);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        _DNTransferTemps memory t;
        t.fromOwnedLength = fromAddressData.ownedLength;
        t.toOwnedLength = toAddressData.ownedLength;
        t.totalSupply = $.totalSupply;

        if (amount > (t.fromBalance = fromAddressData.balance)) revert InsufficientBalance();

        unchecked {
            fromAddressData.balance = uint96(t.fromBalance -= amount);
            toAddressData.balance = uint96(t.toBalance = uint256(toAddressData.balance) + amount);

            t.numNFTBurns = _zeroFloorSub(t.fromOwnedLength, t.fromBalance / _unit());

            if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
                if (from == to) t.toOwnedLength = t.fromOwnedLength - t.numNFTBurns;
                t.numNFTMints = _zeroFloorSub(t.toBalance / _unit(), t.toOwnedLength);
            }

            while (_useDirectTransfersIfPossible()) {
                uint256 n = _min(t.fromOwnedLength, _min(t.numNFTBurns, t.numNFTMints));
                if (n == 0) break;
                t.numNFTBurns -= n;
                t.numNFTMints -= n;
                if (from == to) {
                    t.toOwnedLength += n;
                    break;
                }
                _DNDirectLogs memory directLogs = _directLogsMalloc(n, from, to);
                Uint32Map storage fromOwned = $.owned[from];
                Uint32Map storage toOwned = $.owned[to];
                t.toAlias = _registerAndResolveAlias(toAddressData, to);
                uint256 toIndex = t.toOwnedLength;
                // Direct transfer loop.
                do {
                    uint256 id = _get(fromOwned, --t.fromOwnedLength);
                    _set(toOwned, toIndex, uint32(id));
                    _setOwnerAliasAndOwnedIndex($.oo, id, t.toAlias, uint32(toIndex++));
                    _directLogsAppend(directLogs, id);
                    if (_get($.mayHaveNFTApproval, id)) {
                        _set($.mayHaveNFTApproval, id, false);
                        delete $.nftApprovals[id];
                    }
                    _afterNFTTransfer(from, to, id);
                } while (--n != 0);

                toAddressData.ownedLength = uint32(t.toOwnedLength = toIndex);
                fromAddressData.ownedLength = uint32(t.fromOwnedLength);
                _directLogsSend(directLogs, $.mirrorERC721);
                break;
            }

            t.totalNFTSupply = uint256($.totalNFTSupply) + t.numNFTMints - t.numNFTBurns;
            $.totalNFTSupply = uint32(t.totalNFTSupply);

            Uint32Map storage oo = $.oo;
            _DNPackedLogs memory packedLogs = _packedLogsMalloc(t.numNFTBurns + t.numNFTMints);

            t.burnedPoolTail = $.burnedPoolTail;
            if (t.numNFTBurns != 0) {
                _packedLogsSet(packedLogs, from, 1);
                bool addToBurnedPool = _addToBurnedPool(t.totalNFTSupply, t.totalSupply);
                Uint32Map storage fromOwned = $.owned[from];
                uint256 fromIndex = t.fromOwnedLength;
                fromAddressData.ownedLength = uint32(t.fromEnd = fromIndex - t.numNFTBurns);
                uint32 burnedPoolTail = t.burnedPoolTail;
                // Burn loop.
                do {
                    uint256 id = _get(fromOwned, --fromIndex);
                    _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);
                    _packedLogsAppend(packedLogs, id);
                    if (_useExistsLookup()) _set($.exists, id, false);
                    if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));
                    if (_get($.mayHaveNFTApproval, id)) {
                        _set($.mayHaveNFTApproval, id, false);
                        delete $.nftApprovals[id];
                    }
                    _afterNFTTransfer(from, address(0), id);
                } while (fromIndex != t.fromEnd);

                if (addToBurnedPool) $.burnedPoolTail = (t.burnedPoolTail = burnedPoolTail);
            }

            if (t.numNFTMints != 0) {
                _packedLogsSet(packedLogs, to, 0);
                Uint32Map storage toOwned = $.owned[to];
                t.toAlias = _registerAndResolveAlias(toAddressData, to);
                uint256 maxId = t.totalSupply / _unit();
                t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);
                uint256 toIndex = t.toOwnedLength;
                toAddressData.ownedLength = uint32(t.toEnd = toIndex + t.numNFTMints);
                uint32 burnedPoolHead = $.burnedPoolHead;
                // Mint loop.
                do {
                    uint256 id;
                    if (burnedPoolHead != t.burnedPoolTail) {
                        id = _get($.burnedPool, burnedPoolHead++);
                    } else {
                        id = t.nextTokenId;
                        while (_get(oo, _ownershipIndex(id)) != 0) {
                            id = _useExistsLookup()
                                ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId + 1), maxId)
                                : _wrapNFTId(id + 1, maxId);
                        }
                        t.nextTokenId = _wrapNFTId(id + 1, maxId);
                    }
                    if (_useExistsLookup()) _set($.exists, id, true);
                    _set(toOwned, toIndex, uint32(id));
                    _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));
                    _packedLogsAppend(packedLogs, id);
                    _afterNFTTransfer(address(0), to, id);
                } while (toIndex != t.toEnd);

                $.burnedPoolHead = burnedPoolHead;
                $.nextTokenId = uint32(t.nextTokenId);
            }

            if (packedLogs.logs.length != 0) _packedLogsSend(packedLogs, $.mirrorERC721);
        }
        /// @solidity memory-safe-assembly
        assembly {
        // Emit the {Transfer} event.
            mstore(0x00, amount)
        // forgefmt: disable-next-item
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))
        }
    }

    /// @dev Transfers token `id` from `from` to `to`.
    ///
    /// Requirements:
    ///
    /// - Call must originate from the mirror contract.
    /// - Token `id` must exist.
    /// - `from` must be the owner of the token.
    /// - `to` cannot be the zero address.
    ///   `msgSender` must be the owner of the token, or be approved to manage the token.
    ///
    /// Emits a {Transfer} event.
    function _transferFromNFT(address from, address to, uint256 id, address msgSender)
    internal
    virtual
    {
        if (to == address(0)) revert TransferToZeroAddress();

        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        Uint32Map storage oo = $.oo;

        if (from != $.aliasToAddress[_get(oo, _ownershipIndex(_restrictNFTId(id)))]) {
            revert TransferFromIncorrectOwner();
        }

        if (msgSender != from) {
            if (_ref($.operatorApprovals, from, msgSender).value == 0) {
                if (msgSender != $.nftApprovals[id]) {
                    revert TransferCallerNotOwnerNorApproved();
                }
            }
        }

        AddressData storage fromAddressData = _addressData(from);
        AddressData storage toAddressData = _addressData(to);

        uint256 unit = _unit();
        mapping(address => Uint32Map) storage owned = $.owned;
        Uint32Map storage fromOwned = owned[from];

        unchecked {
            uint256 fromBalance = fromAddressData.balance;
            if (unit > fromBalance) revert InsufficientBalance();
            fromAddressData.balance = uint96(fromBalance - unit);
            toAddressData.balance += uint96(unit);
        }
        if (_get($.mayHaveNFTApproval, id)) {
            _set($.mayHaveNFTApproval, id, false);
            delete $.nftApprovals[id];
        }
        unchecked {
            uint32 updatedId = _get(fromOwned, --fromAddressData.ownedLength);
            uint32 i = _get(oo, _ownedIndex(id));
            _set(fromOwned, i, updatedId);
            _set(oo, _ownedIndex(updatedId), i);
        }
        unchecked {
            uint32 n = toAddressData.ownedLength++;
            _set(owned[to], n, uint32(id));
            _setOwnerAliasAndOwnedIndex(oo, id, _registerAndResolveAlias(toAddressData, to), n);
        }
        _afterNFTTransfer(from, to, id);
        /// @solidity memory-safe-assembly
        assembly {
        // Emit the {Transfer} event.
            mstore(0x00, unit)
        // forgefmt: disable-next-item
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                 INTERNAL APPROVE FUNCTIONS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`.
    ///
    /// Emits a {Approval} event.
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {
            _getDN404Storage().addressData[owner].flags |= _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG;
        }
        _ref(_getDN404Storage().allowance, owner, spender).value = amount;
        /// @solidity memory-safe-assembly
        assembly {
        // Emit the {Approval} event.
            mstore(0x00, amount)
        // forgefmt: disable-next-item
            log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, shl(96, owner)), shr(96, shl(96, spender)))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                 DATA HITCHHIKING FUNCTIONS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the auxiliary data for `owner`.
    /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.
    /// Auxiliary data can be set for any address, even if it does not have any tokens.
    function _getAux(address owner) internal view virtual returns (uint88) {
        return _getDN404Storage().addressData[owner].aux;
    }

    /// @dev Set the auxiliary data for `owner` to `value`.
    /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.
    /// Auxiliary data can be set for any address, even if it does not have any tokens.
    function _setAux(address owner, uint88 value) internal virtual {
        _getDN404Storage().addressData[owner].aux = value;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     SKIP NFT FUNCTIONS                     */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs.
    /// Returns false otherwise.
    function getSkipNFT(address owner) public view virtual returns (bool) {
        AddressData storage d = _getDN404Storage().addressData[owner];
        if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) return _hasCode(owner);
        return d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0;
    }

    /// @dev Sets the caller's skipNFT flag to `skipNFT`. Returns true.
    ///
    /// Emits a {SkipNFTSet} event.
    function setSkipNFT(bool skipNFT) public virtual returns (bool) {
        _setSkipNFT(msg.sender, skipNFT);
        return true;
    }

    /// @dev Internal function to set account `owner` skipNFT flag to `state`
    ///
    /// Initializes account `owner` AddressData if it is not currently initialized.
    ///
    /// Emits a {SkipNFTSet} event.
    function _setSkipNFT(address owner, bool state) internal virtual {
        AddressData storage d = _addressData(owner);
        if ((d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0) != state) {
            d.flags ^= _ADDRESS_DATA_SKIP_NFT_FLAG;
        }
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, iszero(iszero(state)))
            log2(0x00, 0x20, _SKIP_NFT_SET_EVENT_SIGNATURE, shr(96, shl(96, owner)))
        }
    }

    /// @dev Returns a storage data pointer for account `owner` AddressData
    ///
    /// Initializes account `owner` AddressData if it is not currently initialized.
    function _addressData(address owner) internal virtual returns (AddressData storage d) {
        d = _getDN404Storage().addressData[owner];
        unchecked {
            if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) {
                uint256 skipNFT = _toUint(_hasCode(owner)) * _ADDRESS_DATA_SKIP_NFT_FLAG;
                d.flags = uint8(skipNFT | _ADDRESS_DATA_INITIALIZED_FLAG);
            }
        }
    }

    /// @dev Returns the `addressAlias` of account `to`.
    ///
    /// Assigns and registers the next alias if `to` alias was not previously registered.
    function _registerAndResolveAlias(AddressData storage toAddressData, address to)
    internal
    virtual
    returns (uint32 addressAlias)
    {
        DN404Storage storage $ = _getDN404Storage();
        addressAlias = toAddressData.addressAlias;
        if (addressAlias == 0) {
            unchecked {
                addressAlias = ++$.numAliases;
            }
            toAddressData.addressAlias = addressAlias;
            $.aliasToAddress[addressAlias] = to;
            if (addressAlias == 0) revert(); // Overflow.
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     MIRROR OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the address of the mirror NFT contract.
    function mirrorERC721() public view virtual returns (address) {
        return _getDN404Storage().mirrorERC721;
    }

    /// @dev Returns the total NFT supply.
    function _totalNFTSupply() internal view virtual returns (uint256) {
        return _getDN404Storage().totalNFTSupply;
    }

    /// @dev Returns `owner` NFT balance.
    function _balanceOfNFT(address owner) internal view virtual returns (uint256) {
        return _getDN404Storage().addressData[owner].ownedLength;
    }

    /// @dev Returns the owner of token `id`.
    /// Returns the zero address instead of reverting if the token does not exist.
    function _ownerAt(uint256 id) internal view virtual returns (address) {
        DN404Storage storage $ = _getDN404Storage();
        return $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];
    }

    /// @dev Returns the owner of token `id`.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function _ownerOf(uint256 id) internal view virtual returns (address) {
        if (!_exists(id)) revert TokenDoesNotExist();
        return _ownerAt(id);
    }

    /// @dev Returns if token `id` exists.
    function _exists(uint256 id) internal view virtual returns (bool) {
        return _ownerAt(id) != address(0);
    }

    /// @dev Returns the account approved to manage token `id`.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function _getApproved(uint256 id) internal view virtual returns (address) {
        if (!_exists(id)) revert TokenDoesNotExist();
        return _getDN404Storage().nftApprovals[id];
    }

    /// @dev Sets `spender` as the approved account to manage token `id`, using `msgSender`.
    ///
    /// Requirements:
    /// - `msgSender` must be the owner or an approved operator for the token owner.
    function _approveNFT(address spender, uint256 id, address msgSender)
    internal
    virtual
    returns (address owner)
    {
        DN404Storage storage $ = _getDN404Storage();

        owner = $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];

        if (msgSender != owner) {
            if (_ref($.operatorApprovals, owner, msgSender).value == 0) {
                revert ApprovalCallerNotOwnerNorApproved();
            }
        }

        $.nftApprovals[id] = spender;
        _set($.mayHaveNFTApproval, id, spender != address(0));
    }

    /// @dev Approve or remove the `operator` as an operator for `msgSender`,
    /// without authorization checks.
    function _setApprovalForAll(address operator, bool approved, address msgSender)
    internal
    virtual
    {
        _ref(_getDN404Storage().operatorApprovals, msgSender, operator).value = _toUint(approved);
    }

    /// @dev Returns the NFT IDs of `owner` in range `[begin, end)`.
    /// Optimized for smaller bytecode size, as this function is intended for off-chain calling.
    function _ownedIds(address owner, uint256 begin, uint256 end)
    internal
    view
    virtual
    returns (uint256[] memory ids)
    {
        DN404Storage storage $ = _getDN404Storage();
        Uint32Map storage owned = $.owned[owner];
        uint256 n = _min($.addressData[owner].ownedLength, end);
        /// @solidity memory-safe-assembly
        assembly {
            ids := mload(0x40)
            let i := begin
            for {} lt(i, n) { i := add(i, 1) } {
                let s := add(shl(96, owned.slot), shr(3, i)) // Storage slot.
                let id := and(0xffffffff, shr(shl(5, and(i, 7)), sload(s)))
                mstore(add(add(ids, 0x20), shl(5, sub(i, begin))), id) // Append to.
            }
            mstore(ids, sub(i, begin)) // Store the length.
            mstore(0x40, add(add(ids, 0x20), shl(5, sub(i, begin)))) // Allocate memory.
        }
    }

    /// @dev Fallback modifier to dispatch calls from the mirror NFT contract
    /// to internal functions in this contract.
    modifier dn404Fallback() virtual {
        DN404Storage storage $ = _getDN404Storage();

        uint256 fnSelector = _calldataload(0x00) >> 224;
        address mirror = $.mirrorERC721;

        // `transferFromNFT(address,address,uint256,address)`.
        if (fnSelector == 0xe5eb36c8) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _transferFromNFT(
                address(uint160(_calldataload(0x04))), // `from`.
                address(uint160(_calldataload(0x24))), // `to`.
                _calldataload(0x44), // `id`.
                address(uint160(_calldataload(0x64))) // `msgSender`.
            );
            _return(1);
        }
        // `setApprovalForAll(address,bool,address)`.
        if (fnSelector == 0x813500fc) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _setApprovalForAll(
                address(uint160(_calldataload(0x04))), // `spender`.
                _calldataload(0x24) != 0, // `status`.
                address(uint160(_calldataload(0x44))) // `msgSender`.
            );
            _return(1);
        }
        // `isApprovedForAll(address,address)`.
        if (fnSelector == 0xe985e9c5) {
            if (msg.sender != mirror) revert SenderNotMirror();
            Uint256Ref storage ref = _ref(
                $.operatorApprovals,
                address(uint160(_calldataload(0x04))), // `owner`.
                address(uint160(_calldataload(0x24))) // `operator`.
            );
            _return(ref.value);
        }
        // `ownerOf(uint256)`.
        if (fnSelector == 0x6352211e) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(uint160(_ownerOf(_calldataload(0x04))));
        }
        // `ownerAt(uint256)`.
        if (fnSelector == 0x24359879) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(uint160(_ownerAt(_calldataload(0x04))));
        }
        // `approveNFT(address,uint256,address)`.
        if (fnSelector == 0xd10b6e0c) {
            if (msg.sender != mirror) revert SenderNotMirror();
            address owner = _approveNFT(
                address(uint160(_calldataload(0x04))), // `spender`.
                _calldataload(0x24), // `id`.
                address(uint160(_calldataload(0x44))) // `msgSender`.
            );
            _return(uint160(owner));
        }
        // `getApproved(uint256)`.
        if (fnSelector == 0x081812fc) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(uint160(_getApproved(_calldataload(0x04))));
        }
        // `balanceOfNFT(address)`.
        if (fnSelector == 0xf5b100ea) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(_balanceOfNFT(address(uint160(_calldataload(0x04)))));
        }
        // `totalNFTSupply()`.
        if (fnSelector == 0xe2c79281) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(_totalNFTSupply());
        }
        // `implementsDN404()`.
        if (fnSelector == 0xb7a94eb8) {
            _return(1);
        }
        _;
    }

    /// @dev Fallback function for calls from mirror NFT contract.
    /// Override this if you need to implement your custom
    /// fallback with utilities like Solady's `LibZip.cdFallback()`.
    /// And always remember to always wrap the fallback with `dn404Fallback`.
    fallback() external payable virtual dn404Fallback {
        revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.
    }

    /// @dev This is to silence the compiler warning.
    /// Override and remove the revert if you want your contract to receive ETH via receive.
    receive() external payable virtual {
        if (msg.value != 0) revert();
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                 INTERNAL / PRIVATE HELPERS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns `(i - 1) << 1`.
    function _ownershipIndex(uint256 i) internal pure returns (uint256) {
        unchecked {
            return (i - 1) << 1; // Minus 1 as token IDs start from 1.
        }
    }

    /// @dev Returns `((i - 1) << 1) + 1`.
    function _ownedIndex(uint256 i) internal pure returns (uint256) {
        unchecked {
            return ((i - 1) << 1) + 1; // Minus 1 as token IDs start from 1.
        }
    }

    /// @dev Returns the uint32 value at `index` in `map`.
    function _get(Uint32Map storage map, uint256 index) internal view returns (uint32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.
            result := and(0xffffffff, shr(shl(5, and(index, 7)), sload(s)))
        }
    }

    /// @dev Updates the uint32 value at `index` in `map`.
    function _set(Uint32Map storage map, uint256 index, uint32 value) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.
            let o := shl(5, and(index, 7)) // Storage slot offset (bits).
            let v := sload(s) // Storage slot value.
            sstore(s, xor(v, shl(o, and(0xffffffff, xor(value, shr(o, v))))))
        }
    }

    /// @dev Sets the owner alias and the owned index together.
    function _setOwnerAliasAndOwnedIndex(
        Uint32Map storage map,
        uint256 id,
        uint32 ownership,
        uint32 ownedIndex
    ) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let i := sub(id, 1) // Index of the uint64 combined value.
            let s := add(shl(96, map.slot), shr(2, i)) // Storage slot.
            let v := sload(s) // Storage slot value.
            let o := shl(6, and(i, 3)) // Storage slot offset (bits).
            let combined := or(shl(32, ownedIndex), and(0xffffffff, ownership))
            sstore(s, xor(v, shl(o, and(0xffffffffffffffff, xor(shr(o, v), combined)))))
        }
    }

    /// @dev Returns the boolean value of the bit at `index` in `bitmap`.
    function _get(Bitmap storage bitmap, uint256 index) internal view returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.
            result := and(1, shr(and(0xff, index), sload(s)))
        }
    }

    /// @dev Updates the bit at `index` in `bitmap` to `value`.
    function _set(Bitmap storage bitmap, uint256 index, bool value) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.
            let o := and(0xff, index) // Storage slot offset (bits).
            sstore(s, or(and(sload(s), not(shl(o, 1))), shl(o, iszero(iszero(value)))))
        }
    }

    /// @dev Returns the index of the least significant unset bit in `[begin, end)`.
    /// If no unset bit is found, returns `type(uint256).max`.
    function _findFirstUnset(Bitmap storage bitmap, uint256 begin, uint256 end)
    internal
    view
    returns (uint256 unsetBitIndex)
    {
        /// @solidity memory-safe-assembly
        assembly {
            unsetBitIndex := not(0) // Initialize to `type(uint256).max`.
            let s := shl(96, bitmap.slot) // Storage offset of the bitmap.
            let bucket := add(s, shr(8, begin))
            let negBits := shl(and(0xff, begin), shr(and(0xff, begin), not(sload(bucket))))
            if iszero(negBits) {
                let lastBucket := add(s, shr(8, end))
                for {} 1 {} {
                    bucket := add(bucket, 1)
                    negBits := not(sload(bucket))
                    if or(negBits, gt(bucket, lastBucket)) { break }
                }
                if gt(bucket, lastBucket) {
                    negBits := shr(and(0xff, not(end)), shl(and(0xff, not(end)), negBits))
                }
            }
            if negBits {
            // Find-first-set routine.
                let b := and(negBits, add(not(negBits), 1)) // Isolate the least significant bit.
                let r := shl(7, lt(0xffffffffffffffffffffffffffffffff, b))
                r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, b))))
                r := or(r, shl(5, lt(0xffffffff, shr(r, b))))
            // For the remaining 32 bits, use a De Bruijn lookup.
            // forgefmt: disable-next-item
                r := or(r, byte(and(div(0xd76453e0, shr(r, b)), 0x1f),
                    0x001f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405))
                r := or(shl(8, sub(bucket, s)), r)
                unsetBitIndex := or(r, sub(0, or(iszero(lt(r, end)), lt(r, begin))))
            }
        }
    }

    /// @dev Returns a storage reference to the value at (`a0`, `a1`) in `map`.
    function _ref(AddressPairToUint256RefMap storage map, address a0, address a1)
    internal
    pure
    returns (Uint256Ref storage ref)
    {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x28, a1)
            mstore(0x14, a0)
            mstore(0x00, map.slot)
            ref.slot := keccak256(0x00, 0x48)
        // Clear the part of the free memory pointer that was overwritten.
            mstore(0x28, 0x00)
        }
    }

    /// @dev Wraps the NFT ID.
    function _wrapNFTId(uint256 id, uint256 maxId) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := or(mul(iszero(gt(id, maxId)), id), gt(id, maxId))
        }
    }

    /// @dev Returns `id > type(uint32).max ? 0 : id`.
    function _restrictNFTId(uint256 id) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mul(id, lt(id, 0x100000000))
        }
    }

    /// @dev Returns whether `amount` is a valid `totalSupply`.
    function _totalSupplyOverflows(uint256 amount) internal view returns (bool result) {
        uint256 unit = _unit();
        /// @solidity memory-safe-assembly
        assembly {
            result := iszero(iszero(or(shr(96, amount), lt(0xfffffffe, div(amount, unit)))))
        }
    }

    /// @dev Returns `max(0, x - y)`.
    function _zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(gt(x, y), sub(x, y))
        }
    }

    /// @dev Returns `x < y ? x : y`.
    function _min(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), lt(y, x)))
        }
    }

    /// @dev Returns `b ? 1 : 0`.
    function _toUint(bool b) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := iszero(iszero(b))
        }
    }

    /// @dev Struct containing direct transfer log data for {Transfer} events to be
    /// emitted by the mirror NFT contract.
    struct _DNDirectLogs {
        uint256 offset;
        address from;
        address to;
        uint256[] logs;
    }

    /// @dev Initiates memory allocation for direct logs with `n` log items.
    function _directLogsMalloc(uint256 n, address from, address to)
    private
    pure
    returns (_DNDirectLogs memory p)
    {
        /// @solidity memory-safe-assembly
        assembly {
        // Note that `p` implicitly allocates and advances the free memory pointer by
        // 4 words, which we can safely mutate in `_directLogsSend`.
            let logs := mload(0x40)
            mstore(logs, n) // Store the length.
            let offset := add(0x20, logs) // Skip the word for `p.logs.length`.
            mstore(0x40, add(offset, shl(5, n))) // Allocate memory.
            mstore(add(0x60, p), logs) // Set `p.logs`.
            mstore(add(0x40, p), to) // Set `p.to`.
            mstore(add(0x20, p), from) // Set `p.from`.
            mstore(p, offset) // Set `p.offset`.
        }
    }

    /// @dev Adds a direct log item to `p` with token `id`.
    function _directLogsAppend(_DNDirectLogs memory p, uint256 id) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            let offset := mload(p)
            mstore(offset, id)
            mstore(p, add(offset, 0x20))
        }
    }

    /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.
    function _directLogsSend(_DNDirectLogs memory p, address mirror) private {
        /// @solidity memory-safe-assembly
        assembly {
            let logs := mload(add(p, 0x60))
            let n := add(0x84, shl(5, mload(logs))) // Length of calldata to send.
            let o := sub(logs, 0x80) // Start of calldata to send.
            mstore(o, 0x144027d3) // `logDirectTransfer(address,address,uint256[])`.
            let from := mload(add(0x20, p))
            let to := mload(add(0x40, p))
            mstore(add(o, 0x20), from)
            mstore(add(o, 0x40), to)
            mstore(add(o, 0x60), 0x60) // Offset of `logs` in the calldata to send.
            if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {
                revert(o, 0x00)
            }
        }
    }

    /// @dev Struct containing packed log data for {Transfer} events to be
    /// emitted by the mirror NFT contract.
    struct _DNPackedLogs {
        uint256 offset;
        uint256 addressAndBit;
        uint256[] logs;
    }

    /// @dev Initiates memory allocation for packed logs with `n` log items.
    function _packedLogsMalloc(uint256 n) private pure returns (_DNPackedLogs memory p) {
        /// @solidity memory-safe-assembly
        assembly {
        // Note that `p` implicitly allocates and advances the free memory pointer by
        // 3 words, which we can safely mutate in `_packedLogsSend`.
            let logs := mload(0x40)
            mstore(logs, n) // Store the length.
            let offset := add(0x20, logs) // Skip the word for `p.logs.length`.
            mstore(0x40, add(offset, shl(5, n))) // Allocate memory.
            mstore(add(0x40, p), logs) // Set `p.logs`.
            mstore(p, offset) // Set `p.offset`.
        }
    }

    /// @dev Set the current address and the burn bit.
    function _packedLogsSet(_DNPackedLogs memory p, address a, uint256 burnBit) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(add(p, 0x20), or(shl(96, a), burnBit)) // Set `p.addressAndBit`.
        }
    }

    /// @dev Adds a packed log item to `p` with token `id`.
    function _packedLogsAppend(_DNPackedLogs memory p, uint256 id) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            let offset := mload(p)
            mstore(offset, or(mload(add(p, 0x20)), shl(8, id))) // `p.addressAndBit | (id << 8)`.
            mstore(p, add(offset, 0x20))
        }
    }

    /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.
    function _packedLogsSend(_DNPackedLogs memory p, address mirror) private {
        /// @solidity memory-safe-assembly
        assembly {
            let logs := mload(add(p, 0x40))
            let o := sub(logs, 0x40) // Start of calldata to send.
            mstore(o, 0x263c69d6) // `logTransfer(uint256[])`.
            mstore(add(o, 0x20), 0x20) // Offset of `logs` in the calldata to send.
            let n := add(0x44, shl(5, mload(logs))) // Length of calldata to send.
            if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {
                revert(o, 0x00)
            }
        }
    }

    /// @dev Struct of temporary variables for transfers.
    struct _DNTransferTemps {
        uint256 numNFTBurns;
        uint256 numNFTMints;
        uint256 fromBalance;
        uint256 toBalance;
        uint256 fromOwnedLength;
        uint256 toOwnedLength;
        uint256 totalSupply;
        uint256 totalNFTSupply;
        uint256 fromEnd;
        uint256 toEnd;
        uint32 toAlias;
        uint256 nextTokenId;
        uint32 burnedPoolTail;
    }

    /// @dev Struct of temporary variables for mints.
    struct _DNMintTemps {
        uint256 nextTokenId;
        uint32 burnedPoolTail;
        uint256 toEnd;
        uint32 toAlias;
    }

    /// @dev Returns if `a` has bytecode of non-zero length.
    function _hasCode(address a) private view returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := extcodesize(a) // Can handle dirty upper bits.
        }
    }

    /// @dev Returns the calldata value at `offset`.
    function _calldataload(uint256 offset) private pure returns (uint256 value) {
        /// @solidity memory-safe-assembly
        assembly {
            value := calldataload(offset)
        }
    }

    /// @dev Executes a return opcode to return `x` and end the current call frame.
    function _return(uint256 x) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, x)
            return(0x00, 0x20)
        }
    }
}

File 11 of 11 : DN404Mirror.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/Pausable.sol";

/// @title DN404Mirror
/// @notice DN404Mirror provides an interface for interacting with the
/// NFT tokens in a DN404 implementation.
///
/// @author vectorized.eth (@optimizoor)
/// @author Quit (@0xQuit)
/// @author Michael Amadi (@AmadiMichaels)
/// @author cygaar (@0xCygaar)
/// @author Thomas (@0xjustadev)
/// @author Harrison (@PopPunkOnChain)
///
/// @dev Note:
/// - The ERC721 data is stored in the base DN404 contract.

interface DN404Base {
    function paused() external view returns (bool);
}

contract DN404Mirror is Pausable {
    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                           EVENTS                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Emitted when token `id` is transferred from `from` to `to`.
    event Transfer(address indexed from, address indexed to, uint256 indexed id);

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

    /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.
    event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);

    /// @dev The ownership is transferred from `oldOwner` to `newOwner`.
    /// This is for marketplace signaling purposes. This contract has a `pullOwner()`
    /// function that will sync the owner from the base contract.
    event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);

    /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`.
    uint256 private constant _TRANSFER_EVENT_SIGNATURE =
    0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`.
    uint256 private constant _APPROVAL_EVENT_SIGNATURE =
    0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;

    /// @dev `keccak256(bytes("ApprovalForAll(address,address,bool)"))`.
    uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =
    0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                        CUSTOM ERRORS                       */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Thrown when a call for an NFT function did not originate
    /// from the base DN404 contract.
    error SenderNotBase();

    /// @dev Thrown when a call for an NFT function did not originate from the deployer.
    error SenderNotDeployer();

    /// @dev Thrown when transferring an NFT to a contract address that
    /// does not implement ERC721Receiver.
    error TransferToNonERC721ReceiverImplementer();

    /// @dev Thrown when linking to the DN404 base contract and the
    /// DN404 supportsInterface check fails or the call reverts.
    error CannotLink();

    /// @dev Thrown when a linkMirrorContract call is received and the
    /// NFT mirror contract has already been linked to a DN404 base contract.
    error AlreadyLinked();

    /// @dev Thrown when retrieving the base DN404 address when a link has not
    /// been established.
    error NotLinked();

    /// @dev The function selector is not recognized.
    error FnSelectorNotRecognized();

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                          STORAGE                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Struct contain the NFT mirror contract storage.
    struct DN404NFTStorage {
        // Address of the ERC20 base contract.
        address baseERC20;
        // The deployer, if provided. If non-zero, the initialization of the
        // ERC20 <-> ERC721 link can only be done be the deployer via the ERC20 base contract.
        address deployer;
        // The owner of the ERC20 base contract. For marketplace signaling.
        address owner;
    }

    /// @dev Returns a storage pointer for DN404NFTStorage.
    function _getDN404NFTStorage() internal pure virtual returns (DN404NFTStorage storage $) {
        /// @solidity memory-safe-assembly
        assembly {
        // `uint72(bytes9(keccak256("DN404_MIRROR_STORAGE")))`.
            $.slot := 0x3602298b8c10b01230 // Truncate to 9 bytes to reduce bytecode size.
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                        CONSTRUCTOR                         */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    constructor(address deployer) {
        // For non-proxies, we will store the deployer so that only the deployer can
        // link the base contract.
        _getDN404NFTStorage().deployer = deployer;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     ERC721 OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the token collection name from the base DN404 contract.
    function name() public view virtual returns (string memory) {
        return _readString(0x06fdde03, 0); // `name()`.
    }

    /// @dev Returns the token collection symbol from the base DN404 contract.
    function symbol() public view virtual returns (string memory) {
        return _readString(0x95d89b41, 0); // `symbol()`.
    }

    /// @dev Returns the Uniform Resource Identifier (URI) for token `id` from
    /// the base DN404 contract.
    function tokenURI(uint256 id) public view virtual returns (string memory) {
        return _readString(0xc87b56dd, id); // `tokenURI()`.
    }

    /// @dev Returns the total NFT supply from the base DN404 contract.
    function totalSupply() public view virtual returns (uint256) {
        return _readWord(0xe2c79281, 0, 0); // `totalNFTSupply()`.
    }

    /// @dev Returns the number of NFT tokens owned by `nftOwner` from the base DN404 contract.
    ///
    /// Requirements:
    /// - `nftOwner` must not be the zero address.
    function balanceOf(address nftOwner) public view virtual returns (uint256) {
        return _readWord(0xf5b100ea, uint160(nftOwner), 0); // `balanceOfNFT(address)`.
    }

    /// @dev Returns the owner of token `id` from the base DN404 contract.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function ownerOf(uint256 id) public view virtual returns (address) {
        return address(uint160(_readWord(0x6352211e, id, 0))); // `ownerOf(uint256)`.
    }

    /// @dev Returns the owner of token `id` from the base DN404 contract.
    /// Returns `address(0)` instead of reverting if the token does not exist.
    function ownerAt(uint256 id) public view virtual returns (address) {
        return address(uint160(_readWord(0x24359879, id, 0))); // `ownerAt(uint256)`.
    }

    /// @dev Sets `spender` as the approved account to manage token `id` in
    /// the base DN404 contract.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    /// - The caller must be the owner of the token,
    ///   or an approved operator for the token owner.
    ///
    /// Emits an {Approval} event.
    function approve(address spender, uint256 id) public payable virtual whenNotPaused {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            spender := shr(96, shl(96, spender))
            let m := mload(0x40)
            mstore(0x00, 0xd10b6e0c) // `approveNFT(address,uint256,address)`.
            mstore(0x20, spender)
            mstore(0x40, id)
            mstore(0x60, caller())
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.
                    call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
            mstore(0x40, m) // Restore the free memory pointer.
            mstore(0x60, 0) // Restore the zero pointer.
        // Emit the {Approval} event.
            log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, shr(96, mload(0x0c)), spender, id)
        }
    }

    /// @dev Returns the account approved to manage token `id` from
    /// the base DN404 contract.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function getApproved(uint256 id) public view virtual returns (address) {
        return address(uint160(_readWord(0x081812fc, id, 0))); // `getApproved(uint256)`.
    }

    /// @dev Sets whether `operator` is approved to manage the tokens of the caller in
    /// the base DN404 contract.
    ///
    /// Emits an {ApprovalForAll} event.
    function setApprovalForAll(address operator, bool approved) public virtual whenNotPaused {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            operator := shr(96, shl(96, operator))
            let m := mload(0x40)
            mstore(0x00, 0x813500fc) // `setApprovalForAll(address,bool,address)`.
            mstore(0x20, operator)
            mstore(0x40, iszero(iszero(approved)))
            mstore(0x60, caller())
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    eq(mload(0x00), 1), // The call must return 1.
                    call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
        // Emit the {ApprovalForAll} event.
        // The `approved` value is already at 0x40.
            log3(0x40, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), operator)
            mstore(0x40, m) // Restore the free memory pointer.
            mstore(0x60, 0) // Restore the zero pointer.
        }
    }

    /// @dev Returns whether `operator` is approved to manage the tokens of `nftOwner` from
    /// the base DN404 contract.
    function isApprovedForAll(address nftOwner, address operator)
    public
    view
    virtual
    returns (bool)
    {
        // `isApprovedForAll(address,address)`.
        return _readWord(0xe985e9c5, uint160(nftOwner), uint160(operator)) != 0;
    }

    /// @dev Transfers token `id` from `from` to `to`.
    ///
    /// Requirements:
    ///
    /// - Token `id` must exist.
    /// - `from` must be the owner of the token.
    /// - `to` cannot be the zero address.
    /// - The caller must be the owner of the token, or be approved to manage the token.
    ///
    /// Emits a {Transfer} event.
    function transferFrom(address from, address to, uint256 id) public payable virtual whenNotPaused {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            from := shr(96, shl(96, from))
            to := shr(96, shl(96, to))
            let m := mload(0x40)
            mstore(m, 0xe5eb36c8) // `transferFromNFT(address,address,uint256,address)`.
            mstore(add(m, 0x20), from)
            mstore(add(m, 0x40), to)
            mstore(add(m, 0x60), id)
            mstore(add(m, 0x80), caller())
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    eq(mload(m), 1), // The call must return 1.
                    call(gas(), base, callvalue(), add(m, 0x1c), 0x84, m, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
        // Emit the {Transfer} event.
            log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)
        }
    }

    /// @dev Equivalent to `safeTransferFrom(from, to, id, "")`.
    function safeTransferFrom(address from, address to, uint256 id) public payable virtual whenNotPaused {
        transferFrom(from, to, id);
        if (_hasCode(to)) _checkOnERC721Received(from, to, id, "");
    }

    /// @dev Transfers token `id` from `from` to `to`.
    ///
    /// Requirements:
    ///
    /// - Token `id` must exist.
    /// - `from` must be the owner of the token.
    /// - `to` cannot be the zero address.
    /// - The caller must be the owner of the token, or be approved to manage the token.
    /// - 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 id, bytes calldata data)
    public
    payable
    virtual
    whenNotPaused
    {
        transferFrom(from, to, id);
        if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);
    }

    /// @dev Returns true if this contract implements the interface defined by `interfaceId`.
    /// See: https://eips.ethereum.org/EIPS/eip-165
    /// This function call must use less than 30000 gas.
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            let s := shr(224, interfaceId)
        // ERC165: 0x01ffc9a7, ERC721: 0x80ac58cd, ERC721Metadata: 0x5b5e139f.
            result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                  OWNER SYNCING OPERATIONS                  */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the `owner` of the contract, for marketplace signaling purposes.
    function owner() public view virtual returns (address) {
        return _getDN404NFTStorage().owner;
    }

    /// @dev Permissionless function to pull the owner from the base DN404 contract
    /// if it implements ownable, for marketplace signaling purposes.
    function pullOwner() public virtual returns (bool) {
        address newOwner;
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, 0x8da5cb5b) // `owner()`.
            let success := staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x20)
            newOwner := mul(shr(96, mload(0x0c)), and(gt(returndatasize(), 0x1f), success))
        }
        DN404NFTStorage storage $ = _getDN404NFTStorage();
        address oldOwner = $.owner;
        if (oldOwner != newOwner) {
            $.owner = newOwner;
            emit OwnershipTransferred(oldOwner, newOwner);
        }
        return true;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     MIRROR OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the address of the base DN404 contract.
    function baseERC20() public view virtual returns (address base) {
        base = _getDN404NFTStorage().baseERC20;
        if (base == address(0)) revert NotLinked();
    }

    /// @dev Fallback modifier to execute calls from the base DN404 contract.
    modifier dn404NFTFallback() virtual {
        DN404NFTStorage storage $ = _getDN404NFTStorage();

        uint256 fnSelector = _calldataload(0x00) >> 224;

        // `logTransfer(uint256[])`.
        if (fnSelector == 0x263c69d6) {
            if (msg.sender != $.baseERC20) revert SenderNotBase();
            /// @solidity memory-safe-assembly
            assembly {
                let o := add(0x24, calldataload(0x04)) // Packed logs offset.
                let end := add(o, shl(5, calldataload(sub(o, 0x20))))
                for {} iszero(eq(o, end)) { o := add(0x20, o) } {
                    let d := calldataload(o) // Entry in the packed logs.
                    let a := shr(96, d) // The address.
                    let b := and(1, d) // Whether it is a burn.
                    log4(
                        codesize(),
                        0x00,
                        _TRANSFER_EVENT_SIGNATURE,
                        mul(a, b), // `from`.
                        mul(a, iszero(b)), // `to`.
                        shr(168, shl(160, d)) // `id`.
                    )
                }
                mstore(0x00, 0x01)
                return(0x00, 0x20)
            }
        }
        // `logDirectTransfer(address,address,uint256[])`.
        if (fnSelector == 0x144027d3) {
            if (msg.sender != $.baseERC20) revert SenderNotBase();
            /// @solidity memory-safe-assembly
            assembly {
                let from := calldataload(0x04)
                let to := calldataload(0x24)
                let o := add(0x24, calldataload(0x44)) // Direct logs offset.
                let end := add(o, shl(5, calldataload(sub(o, 0x20))))
                for {} iszero(eq(o, end)) { o := add(0x20, o) } {
                    log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, calldataload(o))
                }
                mstore(0x00, 0x01)
                return(0x00, 0x20)
            }
        }
        // `linkMirrorContract(address)`.
        if (fnSelector == 0x0f4599e5) {
            if ($.deployer != address(0)) {
                if (address(uint160(_calldataload(0x04))) != $.deployer) {
                    revert SenderNotDeployer();
                }
            }
            if ($.baseERC20 != address(0)) revert AlreadyLinked();
            $.baseERC20 = msg.sender;
            /// @solidity memory-safe-assembly
            assembly {
                mstore(0x00, 0x01)
                return(0x00, 0x20)
            }
        }
        _;
    }

    /// @dev Fallback function for calls from base DN404 contract.
    /// Override this if you need to implement your custom
    /// fallback with utilities like Solady's `LibZip.cdFallback()`.
    /// And always remember to always wrap the fallback with `dn404NFTFallback`.
    fallback() external payable virtual dn404NFTFallback {
        revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.
    }

    /// @dev This is to silence the compiler warning.
    /// Override and remove the revert if you want your contract to receive ETH via receive.
    receive() external payable virtual {
        if (msg.value != 0) revert();
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                      PRIVATE HELPERS                       */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Helper to read a string from the base DN404 contract.
    function _readString(uint256 fnSelector, uint256 arg0)
    private
    view
    returns (string memory result)
    {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            mstore(0x00, fnSelector)
            mstore(0x20, arg0)
            if iszero(staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x00)) {
                returndatacopy(result, 0x00, returndatasize())
                revert(result, returndatasize())
            }
            returndatacopy(0x00, 0x00, 0x20) // Copy the offset of the string in returndata.
            returndatacopy(result, mload(0x00), 0x20) // Copy the length of the string.
            returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result)) // Copy the string.
            let end := add(add(result, 0x20), mload(result))
            mstore(end, 0) // Zeroize the word after the string.
            mstore(0x40, add(end, 0x20)) // Allocate memory.
        }
    }

    /// @dev Helper to read a word from the base DN404 contract.
    function _readWord(uint256 fnSelector, uint256 arg0, uint256 arg1)
    private
    view
    returns (uint256 result)
    {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(0x00, fnSelector)
            mstore(0x20, arg0)
            mstore(0x40, arg1)
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.
                    staticcall(gas(), base, 0x1c, 0x44, 0x00, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
            mstore(0x40, m) // Restore the free memory pointer.
            result := mload(0x00)
        }
    }

    /// @dev Returns the calldata value at `offset`.
    function _calldataload(uint256 offset) private pure returns (uint256 value) {
        /// @solidity memory-safe-assembly
        assembly {
            value := calldataload(offset)
        }
    }

    /// @dev Returns if `a` has bytecode of non-zero length.
    function _hasCode(address a) private view returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := extcodesize(a) // Can handle dirty upper bits.
        }
    }

    /// @dev Perform a call to invoke {IERC721Receiver-onERC721Received} on `to`.
    /// Reverts if the target does not support the function correctly.
    function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data)
    private
    {
        /// @solidity memory-safe-assembly
        assembly {
        // Prepare the calldata.
            let m := mload(0x40)
            let onERC721ReceivedSelector := 0x150b7a02
            mstore(m, onERC721ReceivedSelector)
            mstore(add(m, 0x20), caller()) // The `operator`, which is always `msg.sender`.
            mstore(add(m, 0x40), shr(96, shl(96, from)))
            mstore(add(m, 0x60), id)
            mstore(add(m, 0x80), 0x80)
            let n := mload(data)
            mstore(add(m, 0xa0), n)
            if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) }
        // Revert if the call reverts.
            if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) {
                if returndatasize() {
                // Bubble up the revert if the call reverts.
                    returndatacopy(m, 0x00, returndatasize())
                    revert(m, returndatasize())
                }
            }
        // Load the returndata and compare it.
            if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) {
                mstore(0x00, 0xd1a57ed6) // `TransferToNonERC721ReceiverImplementer()`.
                revert(0x1c, 0x04)
            }
        }
    }

    function paused() public view override returns (bool) {
        return DN404Base(baseERC20()).paused();
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_publicMintPricePerStep","type":"uint256"},{"internalType":"uint256","name":"_whitelistMintPricePerStep","type":"uint256"},{"internalType":"uint256","name":"_availableWhitelistMintSupply","type":"uint256"},{"internalType":"uint256","name":"_initialTokenSupply","type":"uint256"},{"internalType":"address","name":"_presaleAddress1","type":"address"},{"internalType":"address","name":"_presaleAddress2","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"DNAlreadyInitialized","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FnSelectorNotRecognized","type":"error"},{"inputs":[],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"LinkMirrorContractFailed","type":"error"},{"inputs":[],"name":"MirrorAddressIsZero","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":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"SenderNotMirror","type":"error"},{"inputs":[],"name":"TokenDoesNotExist","type":"error"},{"inputs":[],"name":"TotalSupplyOverflow","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"UnitIsZero","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":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"SkipNFTSet","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"AVAILABLE_WHITELIST_MINT_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CLAIM_MERKLE_ROOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IS_CLAIM_LIVE","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IS_PUBLIC_MINT_LIVE","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IS_WHITELIST_MINT_LIVE","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TOTAL_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_STEP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLIC_MINT_MAX_PER_WALLET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLIC_MINT_PRICE_PER_STEP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELIST_MINT_MERKLE_ROOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELIST_MINT_PRICE_PER_STEP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","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":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxAmount","type":"uint256"},{"internalType":"bytes32[]","name":"_proof","type":"bytes32[]"}],"name":"claimPartner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"claimPresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getSkipNFT","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintPublic","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxAmount","type":"uint256"},{"internalType":"bytes32[]","name":"_proof","type":"bytes32[]"}],"name":"mintWhitelist","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mirrorERC721","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newValue","type":"uint256"}],"name":"setAvailableWhitelistMintSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newValue","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_newValue","type":"bytes32"}],"name":"setClaimMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newValue","type":"uint256"}],"name":"setMintStep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newValue","type":"uint256"}],"name":"setPublicMintMaxPerWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newValue","type":"uint256"}],"name":"setPublicMintPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"skipNFT","type":"bool"}],"name":"setSkipNFT","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newValue","type":"address"},{"internalType":"bool","name":"unpausable","type":"bool"}],"name":"setUnpausableAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_newValue","type":"bytes32"}],"name":"setWhitelistMintMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newValue","type":"uint256"}],"name":"setWhitelistMintPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"toggleClaimIsLive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePausedApprovalsAndTransfers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePublicMintIsLive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleWhitelistMintIsLive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"result","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":"amount","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":"amount","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":[{"internalType":"address","name":"","type":"address"}],"name":"unpausablePerAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wallets","outputs":[{"internalType":"uint256","name":"publicMints","type":"uint256"},{"internalType":"uint256","name":"whitelistMints","type":"uint256"},{"internalType":"uint256","name":"partnerClaims","type":"uint256"},{"internalType":"uint256","name":"presaleClaims","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawEthBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526002805463ffffff001916905567016345785d8a000060055562000033670de0b6b3a7640000611770620004ca565b6006556200004b670de0b6b3a76400006004620004ca565b60085560006009819055600a8190556040805160208101909152908152600f906200007790826200059b565b506010805460ff191660011790553480156200009257600080fd5b5060405162005d5d38038062005d5d833981016040819052620000b5916200067f565b3380620000dc57604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000e781620001ae565b5060018080556002805460ff19908116909155336000818152600c60205260408082208054909416909417909255600389905560048890556007879055600d80546001600160a01b038781166001600160a01b031992831617909255600e80549287169290911691909117905591519091906200016490620004bc565b6001600160a01b039091168152602001604051809103906000f08015801562000191573d6000803e3d6000fd5b509050620001a1843383620001fe565b50505050505050620006dc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b0316156200023c57604051633ab534b960e21b815260040160405180910390fd5b6001600160a01b03821662000264576040516339a84a7b60e01b815260040160405180910390fd5b630f4599e560005233602052602060006024601c6000865af160016000511416620002975763d125259c6000526004601cfd5b805463ffffffff60201b19166401000000001781556001810180546001600160a01b0384166001600160a01b03199091161790558315620003ba576001600160a01b038316620002fa57604051633a954ecd60e21b815260040160405180910390fd5b606084901c670de0b6b3a7640000850463fffffffe101715620003305760405163e5cfe95760e01b815260040160405180910390fd5b80546001600160a01b0316600160a01b6001600160601b0386160217815560006200035b84620003c0565b80546001600160601b038716600160a01b026001600160a01b0391821617825560008781529192508516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3620003b88460016200042b565b505b50505050565b6001600160a01b038116600090815268a20d6e21d0e525531360205260408120805490916b01000000000000000000000090910460011690036200042657805460ff60581b19166b01000000000000000000000060ff843b151560020260011716021781555b919050565b60006200043883620003c0565b80549091506b01000000000000000000000090046002161515821515146200048457805460ff6b01000000000000000000000080830482166002189091160260ff60581b199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b6110ad8062004cb083390190565b8082028115828204841417620004f057634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200052157607f821691505b6020821081036200054257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200059657600081815260208120601f850160051c81016020861015620005715750805b601f850160051c820191505b8181101562000592578281556001016200057d565b5050505b505050565b81516001600160401b03811115620005b757620005b7620004f6565b620005cf81620005c884546200050c565b8462000548565b602080601f831160018114620006075760008415620005ee5750858301515b600019600386901b1c1916600185901b17855562000592565b600085815260208120601f198616915b82811015620006385788860151825594840194600190910190840162000617565b5085821015620006575787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b80516001600160a01b03811681146200042657600080fd5b60008060008060008060c087890312156200069957600080fd5b86519550602087015194506040870151935060608701519250620006c06080880162000667565b9150620006d060a0880162000667565b90509295509295509295565b6145c480620006ec6000396000f3fe6080604052600436106103225760003560e01c80638859bc09116101a5578063ce4c6169116100ec578063eb1b4b1711610095578063efd0cbf91161006f578063efd0cbf914610deb578063f126d78414610dfe578063f2fde38b14610e2e578063fd1e296214610e4e57610334565b8063eb1b4b1714610dad578063ecd5f76214610dc3578063ee49382414610dd857610334565b8063e41c28e4116100c6578063e41c28e414610d59578063e4effacb14610d78578063e8ddf15a14610d9857610334565b8063ce4c616914610ce5578063d472835e14610d05578063dd62ed3e14610d1a57610334565b806398c9e60c1161014e578063bb9ae99011610128578063bb9ae99014610c8f578063c29564de14610caf578063c87b56dd14610cc557610334565b806398c9e60c14610c2f578063a611708e14610c4f578063a9059cbb14610c6f57610334565b80638bb6fd5b1161017f5780638bb6fd5b14610bb55780638da5cb5b14610bcb57806395d89b4114610be957610334565b80638859bc0914610b1d578063894b344c14610b3357806389b08f1114610b5357610334565b80634c10b605116102695780635d82cf6e1161021257806370a08231116101ec57806370a0823114610a8e578063715018a614610af25780637321cb7f14610b0757610334565b80635d82cf6e14610a4457806364bc987314610a645780636c0360eb14610a7957610334565b80634f09abf4116102435780634f09abf4146109ee57806355f804b314610a0f5780635c975abb14610a2f57610334565b80634c10b605146109895780634e7357931461099e5780634ef41efc146109b457610334565b8063274e430b116102cb578063313ce567116102a5578063313ce5671461093757806333039d3d146109535780633e023e2d1461096957610334565b8063274e430b146108d75780632a6a935d146108f75780632c73bc8a1461091757610334565b806318160ddd116102fc57806318160ddd146108545780631dff93351461089757806323b872dd146108b757610334565b806306fdde03146107a8578063095ea7b31461080057806315d720381461083057610334565b3661033457341561033257600080fd5b005b68a20d6e21d0e52553095468a20d6e21d0e52553089060003560e01c906001600160a01b031663e5eb36c88290036103c657336001600160a01b038216146103a8576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6103bc600435602435604435606435610e6e565b6103c66001611396565b8163813500fc0361044757336001600160a01b03821614610413576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b6000908152604881209152602435151590556104476001611396565b8163e985e9c5036104be57336001600160a01b03821614610494576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602435602890815260043560145260038401600090815260488120915280546104bc90611396565b505b81636352211e0361052757336001600160a01b0382161461050b576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105276105196004356113a0565b6001600160a01b0316611396565b8163243598790361058257336001600160a01b03821614610574576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105826105196004356113f0565b8163d10b6e0c036105f857336001600160a01b038216146105cf576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006105e260043560243560443561144d565b90506105f6816001600160a01b0316611396565b505b8163081812fc0361065357336001600160a01b03821614610645576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610653610519600435611576565b8163f5b100ea036106e657336001600160a01b038216146106a0576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0360043516600090815268a20d6e21d0e525531360205260409020546106e690700100000000000000000000000000000000900463ffffffff16611396565b8163e2c792810361076157336001600160a01b03821614610733576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b68a20d6e21d0e52553085461076190700100000000000000000000000000000000900463ffffffff16611396565b8163b7a94eb803610776576107766001611396565b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3480156107b457600080fd5b5060408051808201909152600b81527f46726565646f6d57726c6400000000000000000000000000000000000000000060208201525b6040516107f79190613fa9565b60405180910390f35b34801561080c57600080fd5b5061082061081b366004614011565b6115db565b60405190151581526020016107f7565b34801561083c57600080fd5b50610846600a5481565b6040519081526020016107f7565b34801561086057600080fd5b5068a20d6e21d0e5255308547401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16610846565b3480156108a357600080fd5b506103326108b236600461403b565b6115f6565b3480156108c357600080fd5b506108206108d23660046140be565b611837565b3480156108e357600080fd5b506108206108f23660046140fa565b611854565b34801561090357600080fd5b50610820610912366004614125565b6118af565b34801561092357600080fd5b50610332610932366004614140565b6118c3565b34801561094357600080fd5b50604051601281526020016107f7565b34801561095f57600080fd5b5061084660065481565b34801561097557600080fd5b50610332610984366004614140565b6118d0565b34801561099557600080fd5b506103326118dd565b3480156109aa57600080fd5b5061084660075481565b3480156109c057600080fd5b5068a20d6e21d0e5255309546001600160a01b03165b6040516001600160a01b0390911681526020016107f7565b3480156109fa57600080fd5b50600254610820906301000000900460ff1681565b348015610a1b57600080fd5b50610332610a2a366004614159565b61191f565b348015610a3b57600080fd5b50610820611939565b348015610a5057600080fd5b50610332610a5f366004614140565b611963565b348015610a7057600080fd5b50610332611970565b348015610a8557600080fd5b506107ea6119b4565b348015610a9a57600080fd5b50610846610aa93660046140fa565b6001600160a01b0316600090815268a20d6e21d0e525531360205260409020547401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1690565b348015610afe57600080fd5b50610332611a42565b348015610b1357600080fd5b5061084660055481565b348015610b2957600080fd5b5061084660085481565b348015610b3f57600080fd5b50610332610b4e366004614140565b611a56565b348015610b5f57600080fd5b50610b95610b6e3660046140fa565b600b6020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016107f7565b348015610bc157600080fd5b5061084660095481565b348015610bd757600080fd5b506000546001600160a01b03166109d6565b348015610bf557600080fd5b5060408051808201909152600481527f465245450000000000000000000000000000000000000000000000000000000060208201526107ea565b348015610c3b57600080fd5b50610332610c4a3660046141cb565b611a63565b348015610c5b57600080fd5b50610332610c6a366004614140565b611ab4565b348015610c7b57600080fd5b50610820610c8a366004614011565b611ac1565b348015610c9b57600080fd5b50610332610caa366004614140565b611ad5565b348015610cbb57600080fd5b5061084660035481565b348015610cd157600080fd5b506107ea610ce0366004614140565b611e15565b348015610cf157600080fd5b506002546108209062010000900460ff1681565b348015610d1157600080fd5b50610332611e5e565b348015610d2657600080fd5b50610846610d353660046141fe565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b348015610d6557600080fd5b5060025461082090610100900460ff1681565b348015610d8457600080fd5b50610332610d93366004614140565b611e98565b348015610da457600080fd5b50610332611ea5565b348015610db957600080fd5b5061084660045481565b348015610dcf57600080fd5b50610332611ee7565b610332610de636600461403b565b611f2a565b610332610df9366004614140565b61236e565b348015610e0a57600080fd5b50610820610e193660046140fa565b600c6020526000908152604090205460ff1681565b348015610e3a57600080fd5b50610332610e493660046140fa565b6126a0565b348015610e5a57600080fd5b50610332610e69366004614140565b6126f4565b6001600160a01b038316610eae576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b0316610ed657600080fd5b600a8101600282016000610f2083610efc640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b03878116911614610f7b576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b0316836001600160a01b03161461100a57602883815260148790526003830160009081526048812091525460000361100a5760008481526004830160205260409020546001600160a01b0384811691161461100a576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061101587612701565b9050600061102287612701565b6001600160a01b038916600090815260088601602081905260409091208454929350670de0b6b3a7640000927401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16808411156110ae576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b85546bffffffffffffffffffffffff918590038216740100000000000000000000000000000000000000009081026001600160a01b039283161788558654818104841687019093160291161784556005870160601b60088a901c015460ff8a161c60011615611168576005870160601b60088a901c018054600160ff8c161b191690556000898152600488016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b84547fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff81167001000000000000000000000000000000009182900463ffffffff90811660001901808216909302919091178755606083901b631fffffff600384901c16015460009260e060059190911b161c16905060006111f3886000198d01600190811b01610efc565b606084901b631fffffff600383901c1601805460e0600584901b1681811c861863ffffffff16901b18905590506112618860001963ffffffff851601600190811b01838160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b50508354600163ffffffff7001000000000000000000000000000000008084048216928301909116027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff9092169190911785556001600160a01b038b1660009081526020849052604090206112fd90828c8160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b611350878b61130c888f61278c565b84600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b50826000528960601b60601c8b60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a35050505050505050505050565b8060005260206000f35b60006113ab8261287c565b6113e1576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113ea826113f0565b92915050565b600068a20d6e21d0e525530868a20d6e21d0e525530a8261142668a20d6e21d0e5255312610efc64010000000088108802610ef2565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a8261148368a20d6e21d0e5255312610efc64010000000089108902610ef2565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214611502576028838152601483905260038201600090815260488120915254600003611502576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848152600482016020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b60006115818261287c565b6115b7576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b60006115e5612899565b6115ef83836128d8565b9392505050565b6115fe6128ee565b6002546301000000900460ff1661165c5760405162461bcd60e51b815260206004820152600e60248201527f436c61696d206e6f74206c69766500000000000000000000000000000000000060448201526064015b60405180910390fd5b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018490526000906054016040516020818303038152906040528051906020012090506116bd8383600a5484612931565b6117095760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f77656420746f20636c61696d0000000000000000000000006044820152606401611653565b60065468a20d6e21d0e52553085486907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff166117499190614257565b11156117975760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b336000908152600b602052604090206002015484906117b7908790614257565b11156118055760405162461bcd60e51b815260206004820152601c60248201527f4d61782077686974656c69737420616d6f756e742072656163686564000000006044820152606401611653565b336000818152600b602052604090206002018054870190556118279086612949565b5061183160018055565b50505050565b6000611841612899565b61184c848484612e4d565b949350505050565b6001600160a01b038116600090815268a20d6e21d0e52553136020526040812080546b010000000000000000000000900460011682036118945750503b90565b546b0100000000000000000000009004600216151592915050565b60006118bb3383612ed4565b506001919050565b6118cb612f7d565b600855565b6118d8612f7d565b600755565b6118e5612f7d565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b611927612f7d565b600f61193482848361433a565b505050565b60105460009060ff16801561195e5750336000908152600c602052604090205460ff16155b905090565b61196b612f7d565b600355565b611978612f7d565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffff811663010000009182900460ff1615909102179055565b600f80546119c190614299565b80601f01602080910402602001604051908101604052809291908181526020018280546119ed90614299565b8015611a3a5780601f10611a0f57610100808354040283529160200191611a3a565b820191906000526020600020905b815481529060010190602001808311611a1d57829003601f168201915b505050505081565b611a4a612f7d565b611a546000612fc3565b565b611a5e612f7d565b600555565b611a6b612f7d565b6001600160a01b03919091166000908152600c6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b611abc612f7d565b600455565b6000611acb612899565b6115ef838361302b565b611add6128ee565b6002546301000000900460ff16611b365760405162461bcd60e51b815260206004820152600e60248201527f436c61696d206e6f74206c6976650000000000000000000000000000000000006044820152606401611653565b600d54600e546040517f6591e6db0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0392831692909116906000908390636591e6db90602401602060405180830381865afa158015611ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc79190614419565b6040517f6591e6db0000000000000000000000000000000000000000000000000000000081523360048201529091506000906001600160a01b03841690636591e6db90602401602060405180830381865afa158015611c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4e9190614419565b90506000670de0b6b3a7640000611c658385614257565b611c6f9190614432565b905060008111611cc15760405162461bcd60e51b815260206004820152601360248201527f4e6f742070617274206f662070726573616c65000000000000000000000000006044820152606401611653565b336000908152600b60205260409020600301548190611ce1908890614257565b1115611d545760405162461bcd60e51b8152602060048201526024808201527f4d617820617661696c61626c652070726573616c6520616d6f756e742072656160448201527f63686564000000000000000000000000000000000000000000000000000000006064820152608401611653565b60065468a20d6e21d0e52553085487907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16611d949190614257565b1115611de25760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b336000818152600b60205260409020600301805488019055611e049087612949565b5050505050611e1260018055565b50565b6060600f8054611e2490614299565b159050611e5957600f611e3683613038565b604051602001611e47929190614449565b60405160208183030381529060405290505b919050565b611e66612f7d565b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b611ea0612f7d565b600955565b611ead612f7d565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015611e12573d6000803e3d6000fd5b611eef612f7d565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b611f326128ee565b60025462010000900460ff16611f8a5760405162461bcd60e51b815260206004820152601760248201527f57686974656c697374206d696e74206e6f74206c6976650000000000000000006044820152606401611653565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b16602082015260348101849052600090605401604051602081830303815290604052805190602001209050611feb838360095484612931565b61205d5760405162461bcd60e51b815260206004820152602260248201527f4e6f7420616c6c6f77656420746f206d696e742066726f6d2077686974656c6960448201527f73740000000000000000000000000000000000000000000000000000000000006064820152608401611653565b600085116120ad5760405162461bcd60e51b815260206004820152601060248201527f43616e6e6f74206d696e74207a65726f000000000000000000000000000000006044820152606401611653565b336000908152600b60205260409020600101541515806120d55750670de0b6b3a76400008510155b6121215760405162461bcd60e51b815260206004820152601460248201527f4d757374206d696e74206174206c6561737420310000000000000000000000006044820152606401611653565b60065468a20d6e21d0e52553085486907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff166121619190614257565b11156121af5760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b6000600754116122015760405162461bcd60e51b815260206004820152601c60248201527f4d61782077686974656c69737420737570706c792072656163686564000000006044820152606401611653565b336000908152600b60205260409020600101548490612221908790614257565b111561226f5760405162461bcd60e51b815260206004820152601c60248201527f4d61782077686974656c69737420616d6f756e742072656163686564000000006044820152606401611653565b60055461227c908661451d565b156122c95760405162461bcd60e51b815260206004820152601560248201527f496e636f7272656374206d696e7420616d6f756e7400000000000000000000006044820152606401611653565b6000600554866122d99190614531565b905034600454826122ea9190614432565b11156123385760405162461bcd60e51b815260206004820152600e60248201527f4e6f7420656e6f756768204554480000000000000000000000000000000000006044820152606401611653565b336000818152600b602052604090206001018054880190556007805488900390556123639087612949565b505061183160018055565b6123766128ee565b600254610100900460ff166123cd5760405162461bcd60e51b815260206004820152601460248201527f5075626c6963206d696e74206e6f74206c6976650000000000000000000000006044820152606401611653565b6000811161241d5760405162461bcd60e51b815260206004820152601060248201527f43616e6e6f74206d696e74207a65726f000000000000000000000000000000006044820152606401611653565b336000908152600b60205260409020541515806124425750670de0b6b3a76400008110155b61248e5760405162461bcd60e51b815260206004820152601460248201527f4d757374206d696e74206174206c6561737420310000000000000000000000006044820152606401611653565b60065468a20d6e21d0e52553085482907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff166124ce9190614257565b111561251c5760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b600854336000908152600b602052604090205461253a908390614257565b11156125ae5760405162461bcd60e51b815260206004820152602360248201527f4d6178207075626c6963206d696e7473207065722077616c6c6574207265616360448201527f68656400000000000000000000000000000000000000000000000000000000006064820152608401611653565b6005546125bb908261451d565b156126085760405162461bcd60e51b815260206004820152601560248201527f496e636f7272656374206d696e7420616d6f756e7400000000000000000000006044820152606401611653565b6000600554826126189190614531565b905034600354826126299190614432565b11156126775760405162461bcd60e51b815260206004820152600e60248201527f4e6f7420656e6f756768204554480000000000000000000000000000000000006044820152606401611653565b336000818152600b602052604090208054840190556126969083612949565b50611e1260018055565b6126a8612f7d565b6001600160a01b0381166126eb576040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152602401611653565b611e1281612fc3565b6126fc612f7d565b600a55565b6001600160a01b038116600090815268a20d6e21d0e525531360205260408120805490916b0100000000000000000000009091046001169003611e595780547fffffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffff166b01000000000000000000000060ff933b1515600202600117939093169290920291909117815590565b81546c01000000000000000000000000900463ffffffff1668a20d6e21d0e525530860008290036128755780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008116600163ffffffff92831601918216908117835585547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c0100000000000000000000000082021786556000818152600284016020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038816179055919350900361287557600080fd5b5092915050565b600080612888836113f0565b6001600160a01b0316141592915050565b6128a1611939565b15611a54576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006128e53384846130d8565b50600192915050565b60026001540361292a576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600155565b60008261293f86868561313a565b1495945050505050565b6001600160a01b038216612989576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061299483612701565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b03166129bf57600080fd5b60408051608081018252600080825260208201819052918101829052606081019190915282546bffffffffffffffffffffffff7401000000000000000000000000000000000000000080830482168701918216026001600160a01b03909216919091178455670de0b6b3a7640000810460408301525081546001600160a01b03811674010000000000000000000000000000000000000000918290046bffffffffffffffffffffffff908116870190811690920217835560009081612a9b606083901c670de0b6b3a7640000840463fffffffe10171515151590565b9050868210811715612ad9576040517fe5cfe95700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508454670de0b6b3a764000090910491506b0100000000000000000000009004600216600003612e10576001600160a01b03861660009081526008840160205260408082208654918501519092600a870192700100000000000000000000000000000000900463ffffffff1691612b569083810390841002613186565b9050806040015151600014612e0b5760608a901b602082015260408082015151885463ffffffff7001000000000000000000000000000000008083048216909301811683027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff928316178b55928901518b5493169091029116178855612bdc888b61278c565b63ffffffff908116606088015287546c01000000000000000000000000810482166020890152640100000000810482168781118015909102178852680100000000000000009004165b6000876020015163ffffffff168263ffffffff1614612c74576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050612cce565b5086515b612c8985600019830160011b610efc565b63ffffffff1615612cbe57612cb7612cab8a600601836001018a6001016131cd565b88811180159091021790565b9050612c78565b6001810187811180159091021788525b600881901c60068a0160601b018054600160ff84161b8019909116179055600384901c606087901b018054600586901b60e01681811c841863ffffffff16901b189055612d6585828a6060015187806001019850600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8251602080850151600884901b1782520183525086604001518303612c25578651885463ffffffff83811668010000000000000000027fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff9190931664010000000002167fffffffffffffffffffffffffffffffffffffffff0000000000000000ffffffff909116171788556001880154612e099083906001600160a01b03166132b4565b505b505050505b60008581526001600160a01b038716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3505050505050565b336028908152601484905268a20d6e21d0e525530f6000908152604881209181905281549091906000198114612ebd5780841115612eb7576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83810382555b612ec88686866132f0565b50600195945050505050565b6000612edf83612701565b80549091506b0100000000000000000000009004600216151582151514612f4557805460ff6b0100000000000000000000008083048216600218909116027fffffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffff9091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b6000546001600160a01b03163314611a54576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611653565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006128e53384846132f0565b6060600061304583613e20565b600101905060008167ffffffffffffffff8111156130655761306561426a565b6040519080825280601f01601f19166020018201604052801561308f576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461309957509392505050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b600081815b8481101561317d576131698287878481811061315d5761315d614545565b90506020020135613f02565b91508061317581614574565b91505061313f565b50949350505050565b6131aa60405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b80613222578460081c83015b60018301925082541991508083118217156131f657808311156132205760ff86191691821b90911c905b505b80156132aa5782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff1060061b1781811c63ffffffff1060051b1790811c63d76453e004601f169190911a171785811015878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af160018251141661183157600081fd5b6001600160a01b038216613330576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061333b84612701565b9050600061334884612701565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b031661337357600080fd5b6133ea604051806101a0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b835463ffffffff700100000000000000000000000000000000808304821660808501528554041660a083015282546bffffffffffffffffffffffff7401000000000000000000000000000000000000000091829004811660c085015291041660408201819052851115613489576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040810180518690039081905284546bffffffffffffffffffffffff918216740100000000000000000000000000000000000000009081026001600160a01b0392831617875585548181048416890160608601819052909316029116178355608081015161351c90613500670de0b6b3a764000090565b836040015181613512576135126144ee565b0480821191030290565b815282546b010000000000000000000000900460021660000361359357856001600160a01b0316876001600160a01b03160361356057805160808201510360a08201525b61358d670de0b6b3a764000082606001518161357e5761357e6144ee565b048260a0015180821191030290565b60208201525b60006135c082608001516135b584600001518560200151808218908211021890565b808218908211021890565b9050806000036135d05750613839565b8151819003825260208201805182900390526001600160a01b03808816908916036136055760a0820180519091019052613839565b604080516080810182526000808252602080830182815283850183815260608086019081528651888152600589901b81018501885290819052908d9052908d9052810183526001600160a01b03808d16835260088801909152838220908b168252929020909190613676878b61278c565b63ffffffff1661014086015260a08501515b6080860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff16606084901b600384901c01805460e0600586901b1681811c63ffffffff948516908118909416901b189055905061373788600a018289610140015185806001019650600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b84518181526020018552600881901c6005890160601b015460ff82161c600116156137ad576005880160601b600882901c018054600160ff84161b191690556000818152600489016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b506000198501946000036001016136885760a08601819052875463ffffffff8083167001000000000000000000000000000000009081027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff938416178b5560808901518c54921602911617895560018701546138339085906001600160a01b0316613f31565b50505050505b80516020820151835463ffffffff7001000000000000000000000000000000008083048216840185900360e08701819052909116027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff909116178455600a8401916000916138a79101613186565b84546c01000000000000000000000000900463ffffffff16610180850152835190915015613af057606089901b6001176020828101919091526001600160a01b038a16600090815260088601909152604081206080850151855181036101008701819052895463ffffffff909116700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff9091161789556101808601515b60001991909101600381901c606084901b0154909190600090600584901b60e0161c63ffffffff1663ffffffff166000198101600281901c60608a901b01805460069290921b60c01682811c67ffffffffffffffff16901b909118905590508551602080880151600884901b1782520186526001156139ea576006890160601b600882901c018054600160ff84161b191690555b8415613a24576009890160601b631fffffff600384901c1601805460e0600585901b1681811c841863ffffffff16901b1890556001909101905b600881901c60058a0160601b015460ff82161c60011615613a90576005890160601b600882901c018054600160ff84161b19169055600081815260048a016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b508661010001518203613956578315613aeb5763ffffffff8116610180880181905288547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c010000000000000000000000009091021788555b505050505b602083015115613db957606088901b60208201526001600160a01b03881660009081526008850160205260409020613b28868a61278c565b63ffffffff166101408501526000670de0b6b3a76400008560c0015181613b5157613b516144ee565b87549190049150640100000000900463ffffffff1681811180159091021761016086015260a085015160208601518101610120870181905288547fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000063ffffffff928316021789558754680100000000000000009004165b600087610180015163ffffffff168263ffffffff1614613c2b576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050613c8d565b506101608701515b613c4487600019830160011b610efc565b63ffffffff1615613c7957613c72613c668a60060183600101876001016131cd565b85811180159091021790565b9050613c33565b600181018481118015909102176101608901525b600881901c60068a0160601b018054600160ff84161b8019909116179055600383901c606086901b018054600585901b60e01681811c841863ffffffff16901b189055613d2587828a610140015186806001019750600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8551602080880151600884901b178252018652508661012001518203613bdb57875461016088015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff919093166801000000000000000002167fffffffffffffffffffffffffffffffffffffffff0000000000000000ffffffff909116171787555050505b60408101515115613ddd576001840154613ddd9082906001600160a01b03166132b4565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613e69577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310613e95576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310613eb357662386f26fc10000830492506010015b6305f5e1008310613ecb576305f5e100830492506008015b6127108310613edf57612710830492506004015b60648310613ef1576064830492506002015b600a83106113ea5760010192915050565b6000818310613f1e5760008281526020849052604090206115ef565b60008381526020839052604090206115ef565b6060820151805160051b60840160808203915063144027d3825283602001518460400151816020850152806040850152505060608083015260208282601c85016000875af160018351141661183157600082fd5b60005b83811015613fa0578181015183820152602001613f88565b50506000910152565b6020815260008251806020840152613fc8816040850160208701613f85565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b80356001600160a01b0381168114611e5957600080fd5b6000806040838503121561402457600080fd5b61402d83613ffa565b946020939093013593505050565b6000806000806060858703121561405157600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561407757600080fd5b818701915087601f83011261408b57600080fd5b81358181111561409a57600080fd5b8860208260051b85010111156140af57600080fd5b95989497505060200194505050565b6000806000606084860312156140d357600080fd5b6140dc84613ffa565b92506140ea60208501613ffa565b9150604084013590509250925092565b60006020828403121561410c57600080fd5b6115ef82613ffa565b80358015158114611e5957600080fd5b60006020828403121561413757600080fd5b6115ef82614115565b60006020828403121561415257600080fd5b5035919050565b6000806020838503121561416c57600080fd5b823567ffffffffffffffff8082111561418457600080fd5b818501915085601f83011261419857600080fd5b8135818111156141a757600080fd5b8660208285010111156141b957600080fd5b60209290920196919550909350505050565b600080604083850312156141de57600080fd5b6141e783613ffa565b91506141f560208401614115565b90509250929050565b6000806040838503121561421157600080fd5b61421a83613ffa565b91506141f560208401613ffa565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156113ea576113ea614228565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600181811c908216806142ad57607f821691505b6020821081036142e6577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f82111561193457600081815260208120601f850160051c810160208610156143135750805b601f850160051c820191505b818110156143325782815560010161431f565b505050505050565b67ffffffffffffffff8311156143525761435261426a565b614366836143608354614299565b836142ec565b6000601f84116001811461439a57600085156143825750838201355b600019600387901b1c1916600186901b178355614412565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b828110156143e957868501358255602094850194600190920191016143c9565b50868210156144065760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60006020828403121561442b57600080fd5b5051919050565b80820281158282048414176113ea576113ea614228565b600080845461445781614299565b6001828116801561446f57600181146144a2576144d1565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00841687528215158302870194506144d1565b8860005260208060002060005b858110156144c85781548a8201529084019082016144af565b50505082870194505b5050505083516144e5818360208801613f85565b01949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261452c5761452c6144ee565b500690565b600082614540576145406144ee565b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000600019820361458757614587614228565b506001019056fea26469706673582212202aaf947a2c757f945c560320a757bd2e9da782521ad33ab7d1f87750296bf9b764736f6c63430008140033608060405234801561001057600080fd5b506040516110ad3803806110ad83398101604081905261002f91610066565b6000805460ff19169055683602298b8c10b0123180546001600160a01b0319166001600160a01b0392909216919091179055610096565b60006020828403121561007857600080fd5b81516001600160a01b038116811461008f57600080fd5b9392505050565b611008806100a56000396000f3fe6080604052600436106101485760003560e01c80636352211e116100c057806397e5311c11610074578063b88d4fde11610059578063b88d4fde14610659578063c87b56dd1461066c578063e985e9c51461068c5761015a565b806397e5311c14610624578063a22cb465146106395761015a565b806370a08231116100a557806370a08231146105bc5780638da5cb5b146105dc57806395d89b411461060f5761015a565b80636352211e146105875780636cef16e6146105a75761015a565b806318160ddd1161011757806324359879116100fc578063243598791461053f57806342842e0e1461055f5780635c975abb146105725761015a565b806318160ddd1461050957806323b872dd1461052c5761015a565b806301ffc9a71461043d57806306fdde031461048f578063081812fc146104b1578063095ea7b3146104f65761015a565b3661015a57341561015857600080fd5b005b683602298b8c10b0123060003560e01c63263c69d681900361023657815473ffffffffffffffffffffffffffffffffffffffff1633146101c6576040517f363cb31200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602401602081033560051b81015b8082146102295781358060601c816001168260a01b60a81c811583028284027fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a45050508160200191506101d7565b5050600160005260206000f35b8063144027d3036102f257815473ffffffffffffffffffffffffffffffffffffffff163314610291576040517f363cb31200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602435604435602401602081033560051b81015b8082146102e357813583857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a48160200191506102a8565b50505050600160005260206000f35b80630f4599e50361040b57600182015473ffffffffffffffffffffffffffffffffffffffff161561038857600182015473ffffffffffffffffffffffffffffffffffffffff1660043573ffffffffffffffffffffffffffffffffffffffff1614610388576040517fc59ec47a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b815473ffffffffffffffffffffffffffffffffffffffff16156103d7576040517fbf656a4600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317825560016000908152602090f35b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b34801561044957600080fd5b5061047a610458366004610d27565b6301ffc9a760e09190911c9081146380ac58cd821417635b5e139f9091141790565b60405190151581526020015b60405180910390f35b34801561049b57600080fd5b506104a46106ac565b6040516104869190610d70565b3480156104bd57600080fd5b506104d16104cc366004610ddc565b6106c2565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610486565b610158610504366004610e1e565b6106da565b34801561051557600080fd5b5061051e610768565b604051908152602001610486565b61015861053a366004610e48565b61077a565b34801561054b57600080fd5b506104d161055a366004610ddc565b610811565b61015861056d366004610e48565b610823565b34801561057e57600080fd5b5061047a61085d565b34801561059357600080fd5b506104d16105a2366004610ddc565b6108d5565b3480156105b357600080fd5b5061047a6108e7565b3480156105c857600080fd5b5061051e6105d7366004610e84565b6109d4565b3480156105e857600080fd5b50683602298b8c10b012325473ffffffffffffffffffffffffffffffffffffffff166104d1565b34801561061b57600080fd5b506104a46109fc565b34801561063057600080fd5b506104d1610a0d565b34801561064557600080fd5b50610158610654366004610eb0565b610a68565b610158610667366004610ee7565b610af3565b34801561067857600080fd5b506104a4610687366004610ddc565b610b56565b34801561069857600080fd5b5061047a6106a7366004610f82565b610b66565b60606106bd6306fdde036000610bac565b905090565b60006106d463081812fc836000610c12565b92915050565b6106e2610c5a565b60006106ec610a0d565b90508260601b60601c925060405163d10b6e0c600052836020528260405233606052602060006064601c34865af1601f3d111661072c573d6000823e3d81fd5b806040525060006060528183600c5160601c7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600038a4505050565b60006106bd63e2c79281600080610c12565b610782610c5a565b600061078c610a0d565b90508360601b60601c93508260601b60601c925060405163e5eb36c881528460208201528360408201528260608201523360808201526020816084601c840134865af16001825114166107e2573d6000823e3d81fd5b508183857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a450505050565b60006106d46324359879836000610c12565b61082b610c5a565b61083683838361077a565b813b156108585761085883838360405180602001604052806000815250610c9b565b505050565b6000610867610a0d565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106bd9190610fb5565b60006106d4636352211e836000610c12565b60008060006108f4610a0d565b9050638da5cb5b600052602060006004601c845afa600c51683602298b8c10b0123254601f3d119290921660609190911c029250683602298b8c10b012309073ffffffffffffffffffffffffffffffffffffffff90811690841681146109c9576002820180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86811691821790925560405190918316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35b600194505050505090565b60006106d463f5b100ea8373ffffffffffffffffffffffffffffffffffffffff166000610c12565b60606106bd6395d89b416000610bac565b683602298b8c10b012305473ffffffffffffffffffffffffffffffffffffffff1680610a65576040517f5b2a47ae00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b90565b610a70610c5a565b6000610a7a610a0d565b90508260601b60601c925060405163813500fc6000528360205282151560405233606052602060006064601c34865af160016000511416610abe573d6000823e3d81fd5b83337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206040a36040525050600060605250565b610afb610c5a565b610b0685858561077a565b833b15610b4f57610b4f85858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610c9b92505050565b5050505050565b60606106d463c87b56dd83610bac565b6000610ba363e985e9c58473ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16610c12565b15159392505050565b60606000610bb8610a0d565b9050604051915083600052826020526000806024601c845afa610bde573d6000833e3d82fd5b60206000803e6020600051833e8151602060005101602084013e815160208301016000815260208101604052505092915050565b600080610c1d610a0d565b9050604051856000528460205283604052602060006044601c855afa601f3d1116610c4b573d6000823e3d81fd5b60405250506000519392505050565b610c6261085d565b15610c99576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b60405163150b7a028082523360208301528560601b60601c604083015283606083015260808083015282518060a08401528015610ce2578060c08401826020870160045afa505b60208360a48301601c860160008a5af1610d05573d15610d05573d6000843e3d83fd5b508060e01b825114610d1f5763d1a57ed66000526004601cfd5b505050505050565b600060208284031215610d3957600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610d6957600080fd5b9392505050565b600060208083528351808285015260005b81811015610d9d57858101830151858201604001528201610d81565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b600060208284031215610dee57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610e1957600080fd5b919050565b60008060408385031215610e3157600080fd5b610e3a83610df5565b946020939093013593505050565b600080600060608486031215610e5d57600080fd5b610e6684610df5565b9250610e7460208501610df5565b9150604084013590509250925092565b600060208284031215610e9657600080fd5b610d6982610df5565b8015158114610ead57600080fd5b50565b60008060408385031215610ec357600080fd5b610ecc83610df5565b91506020830135610edc81610e9f565b809150509250929050565b600080600080600060808688031215610eff57600080fd5b610f0886610df5565b9450610f1660208701610df5565b935060408601359250606086013567ffffffffffffffff80821115610f3a57600080fd5b818801915088601f830112610f4e57600080fd5b813581811115610f5d57600080fd5b896020828501011115610f6f57600080fd5b9699959850939650602001949392505050565b60008060408385031215610f9557600080fd5b610f9e83610df5565b9150610fac60208401610df5565b90509250929050565b600060208284031215610fc757600080fd5b8151610d6981610e9f56fea2646970667358221220e5e3c53aa98911d4d1b4ef3a48d909fc9eea8764589fab8cb0c8810868d39ea864736f6c63430008140033000000000000000000000000000000000000000000000000001550f7dca700000000000000000000000000000000000000000000000000000011c37937e0800000000000000000000000000000000000000000000000005c283d41039410000000000000000000000000000000000000000000000000001b1ae4d6e2ef500000000000000000000000000000d41e849492fcdd2461b9468049f59e9bad7d33e0000000000000000000000000433bc4349ae65c4975fe1bde06de6e427ea72d42

Deployed Bytecode

0x6080604052600436106103225760003560e01c80638859bc09116101a5578063ce4c6169116100ec578063eb1b4b1711610095578063efd0cbf91161006f578063efd0cbf914610deb578063f126d78414610dfe578063f2fde38b14610e2e578063fd1e296214610e4e57610334565b8063eb1b4b1714610dad578063ecd5f76214610dc3578063ee49382414610dd857610334565b8063e41c28e4116100c6578063e41c28e414610d59578063e4effacb14610d78578063e8ddf15a14610d9857610334565b8063ce4c616914610ce5578063d472835e14610d05578063dd62ed3e14610d1a57610334565b806398c9e60c1161014e578063bb9ae99011610128578063bb9ae99014610c8f578063c29564de14610caf578063c87b56dd14610cc557610334565b806398c9e60c14610c2f578063a611708e14610c4f578063a9059cbb14610c6f57610334565b80638bb6fd5b1161017f5780638bb6fd5b14610bb55780638da5cb5b14610bcb57806395d89b4114610be957610334565b80638859bc0914610b1d578063894b344c14610b3357806389b08f1114610b5357610334565b80634c10b605116102695780635d82cf6e1161021257806370a08231116101ec57806370a0823114610a8e578063715018a614610af25780637321cb7f14610b0757610334565b80635d82cf6e14610a4457806364bc987314610a645780636c0360eb14610a7957610334565b80634f09abf4116102435780634f09abf4146109ee57806355f804b314610a0f5780635c975abb14610a2f57610334565b80634c10b605146109895780634e7357931461099e5780634ef41efc146109b457610334565b8063274e430b116102cb578063313ce567116102a5578063313ce5671461093757806333039d3d146109535780633e023e2d1461096957610334565b8063274e430b146108d75780632a6a935d146108f75780632c73bc8a1461091757610334565b806318160ddd116102fc57806318160ddd146108545780631dff93351461089757806323b872dd146108b757610334565b806306fdde03146107a8578063095ea7b31461080057806315d720381461083057610334565b3661033457341561033257600080fd5b005b68a20d6e21d0e52553095468a20d6e21d0e52553089060003560e01c906001600160a01b031663e5eb36c88290036103c657336001600160a01b038216146103a8576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6103bc600435602435604435606435610e6e565b6103c66001611396565b8163813500fc0361044757336001600160a01b03821614610413576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b6000908152604881209152602435151590556104476001611396565b8163e985e9c5036104be57336001600160a01b03821614610494576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602435602890815260043560145260038401600090815260488120915280546104bc90611396565b505b81636352211e0361052757336001600160a01b0382161461050b576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105276105196004356113a0565b6001600160a01b0316611396565b8163243598790361058257336001600160a01b03821614610574576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105826105196004356113f0565b8163d10b6e0c036105f857336001600160a01b038216146105cf576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006105e260043560243560443561144d565b90506105f6816001600160a01b0316611396565b505b8163081812fc0361065357336001600160a01b03821614610645576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610653610519600435611576565b8163f5b100ea036106e657336001600160a01b038216146106a0576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0360043516600090815268a20d6e21d0e525531360205260409020546106e690700100000000000000000000000000000000900463ffffffff16611396565b8163e2c792810361076157336001600160a01b03821614610733576040517fce5a776b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b68a20d6e21d0e52553085461076190700100000000000000000000000000000000900463ffffffff16611396565b8163b7a94eb803610776576107766001611396565b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3480156107b457600080fd5b5060408051808201909152600b81527f46726565646f6d57726c6400000000000000000000000000000000000000000060208201525b6040516107f79190613fa9565b60405180910390f35b34801561080c57600080fd5b5061082061081b366004614011565b6115db565b60405190151581526020016107f7565b34801561083c57600080fd5b50610846600a5481565b6040519081526020016107f7565b34801561086057600080fd5b5068a20d6e21d0e5255308547401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16610846565b3480156108a357600080fd5b506103326108b236600461403b565b6115f6565b3480156108c357600080fd5b506108206108d23660046140be565b611837565b3480156108e357600080fd5b506108206108f23660046140fa565b611854565b34801561090357600080fd5b50610820610912366004614125565b6118af565b34801561092357600080fd5b50610332610932366004614140565b6118c3565b34801561094357600080fd5b50604051601281526020016107f7565b34801561095f57600080fd5b5061084660065481565b34801561097557600080fd5b50610332610984366004614140565b6118d0565b34801561099557600080fd5b506103326118dd565b3480156109aa57600080fd5b5061084660075481565b3480156109c057600080fd5b5068a20d6e21d0e5255309546001600160a01b03165b6040516001600160a01b0390911681526020016107f7565b3480156109fa57600080fd5b50600254610820906301000000900460ff1681565b348015610a1b57600080fd5b50610332610a2a366004614159565b61191f565b348015610a3b57600080fd5b50610820611939565b348015610a5057600080fd5b50610332610a5f366004614140565b611963565b348015610a7057600080fd5b50610332611970565b348015610a8557600080fd5b506107ea6119b4565b348015610a9a57600080fd5b50610846610aa93660046140fa565b6001600160a01b0316600090815268a20d6e21d0e525531360205260409020547401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1690565b348015610afe57600080fd5b50610332611a42565b348015610b1357600080fd5b5061084660055481565b348015610b2957600080fd5b5061084660085481565b348015610b3f57600080fd5b50610332610b4e366004614140565b611a56565b348015610b5f57600080fd5b50610b95610b6e3660046140fa565b600b6020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016107f7565b348015610bc157600080fd5b5061084660095481565b348015610bd757600080fd5b506000546001600160a01b03166109d6565b348015610bf557600080fd5b5060408051808201909152600481527f465245450000000000000000000000000000000000000000000000000000000060208201526107ea565b348015610c3b57600080fd5b50610332610c4a3660046141cb565b611a63565b348015610c5b57600080fd5b50610332610c6a366004614140565b611ab4565b348015610c7b57600080fd5b50610820610c8a366004614011565b611ac1565b348015610c9b57600080fd5b50610332610caa366004614140565b611ad5565b348015610cbb57600080fd5b5061084660035481565b348015610cd157600080fd5b506107ea610ce0366004614140565b611e15565b348015610cf157600080fd5b506002546108209062010000900460ff1681565b348015610d1157600080fd5b50610332611e5e565b348015610d2657600080fd5b50610846610d353660046141fe565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b348015610d6557600080fd5b5060025461082090610100900460ff1681565b348015610d8457600080fd5b50610332610d93366004614140565b611e98565b348015610da457600080fd5b50610332611ea5565b348015610db957600080fd5b5061084660045481565b348015610dcf57600080fd5b50610332611ee7565b610332610de636600461403b565b611f2a565b610332610df9366004614140565b61236e565b348015610e0a57600080fd5b50610820610e193660046140fa565b600c6020526000908152604090205460ff1681565b348015610e3a57600080fd5b50610332610e493660046140fa565b6126a0565b348015610e5a57600080fd5b50610332610e69366004614140565b6126f4565b6001600160a01b038316610eae576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b0316610ed657600080fd5b600a8101600282016000610f2083610efc640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b03878116911614610f7b576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b0316836001600160a01b03161461100a57602883815260148790526003830160009081526048812091525460000361100a5760008481526004830160205260409020546001600160a01b0384811691161461100a576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061101587612701565b9050600061102287612701565b6001600160a01b038916600090815260088601602081905260409091208454929350670de0b6b3a7640000927401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16808411156110ae576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b85546bffffffffffffffffffffffff918590038216740100000000000000000000000000000000000000009081026001600160a01b039283161788558654818104841687019093160291161784556005870160601b60088a901c015460ff8a161c60011615611168576005870160601b60088a901c018054600160ff8c161b191690556000898152600488016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b84547fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff81167001000000000000000000000000000000009182900463ffffffff90811660001901808216909302919091178755606083901b631fffffff600384901c16015460009260e060059190911b161c16905060006111f3886000198d01600190811b01610efc565b606084901b631fffffff600383901c1601805460e0600584901b1681811c861863ffffffff16901b18905590506112618860001963ffffffff851601600190811b01838160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b50508354600163ffffffff7001000000000000000000000000000000008084048216928301909116027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff9092169190911785556001600160a01b038b1660009081526020849052604090206112fd90828c8160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b611350878b61130c888f61278c565b84600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b50826000528960601b60601c8b60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a35050505050505050505050565b8060005260206000f35b60006113ab8261287c565b6113e1576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113ea826113f0565b92915050565b600068a20d6e21d0e525530868a20d6e21d0e525530a8261142668a20d6e21d0e5255312610efc64010000000088108802610ef2565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a8261148368a20d6e21d0e5255312610efc64010000000089108902610ef2565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214611502576028838152601483905260038201600090815260488120915254600003611502576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848152600482016020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b60006115818261287c565b6115b7576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b60006115e5612899565b6115ef83836128d8565b9392505050565b6115fe6128ee565b6002546301000000900460ff1661165c5760405162461bcd60e51b815260206004820152600e60248201527f436c61696d206e6f74206c69766500000000000000000000000000000000000060448201526064015b60405180910390fd5b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018490526000906054016040516020818303038152906040528051906020012090506116bd8383600a5484612931565b6117095760405162461bcd60e51b815260206004820152601460248201527f4e6f7420616c6c6f77656420746f20636c61696d0000000000000000000000006044820152606401611653565b60065468a20d6e21d0e52553085486907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff166117499190614257565b11156117975760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b336000908152600b602052604090206002015484906117b7908790614257565b11156118055760405162461bcd60e51b815260206004820152601c60248201527f4d61782077686974656c69737420616d6f756e742072656163686564000000006044820152606401611653565b336000818152600b602052604090206002018054870190556118279086612949565b5061183160018055565b50505050565b6000611841612899565b61184c848484612e4d565b949350505050565b6001600160a01b038116600090815268a20d6e21d0e52553136020526040812080546b010000000000000000000000900460011682036118945750503b90565b546b0100000000000000000000009004600216151592915050565b60006118bb3383612ed4565b506001919050565b6118cb612f7d565b600855565b6118d8612f7d565b600755565b6118e5612f7d565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b611927612f7d565b600f61193482848361433a565b505050565b60105460009060ff16801561195e5750336000908152600c602052604090205460ff16155b905090565b61196b612f7d565b600355565b611978612f7d565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffff811663010000009182900460ff1615909102179055565b600f80546119c190614299565b80601f01602080910402602001604051908101604052809291908181526020018280546119ed90614299565b8015611a3a5780601f10611a0f57610100808354040283529160200191611a3a565b820191906000526020600020905b815481529060010190602001808311611a1d57829003601f168201915b505050505081565b611a4a612f7d565b611a546000612fc3565b565b611a5e612f7d565b600555565b611a6b612f7d565b6001600160a01b03919091166000908152600c6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b611abc612f7d565b600455565b6000611acb612899565b6115ef838361302b565b611add6128ee565b6002546301000000900460ff16611b365760405162461bcd60e51b815260206004820152600e60248201527f436c61696d206e6f74206c6976650000000000000000000000000000000000006044820152606401611653565b600d54600e546040517f6591e6db0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0392831692909116906000908390636591e6db90602401602060405180830381865afa158015611ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc79190614419565b6040517f6591e6db0000000000000000000000000000000000000000000000000000000081523360048201529091506000906001600160a01b03841690636591e6db90602401602060405180830381865afa158015611c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4e9190614419565b90506000670de0b6b3a7640000611c658385614257565b611c6f9190614432565b905060008111611cc15760405162461bcd60e51b815260206004820152601360248201527f4e6f742070617274206f662070726573616c65000000000000000000000000006044820152606401611653565b336000908152600b60205260409020600301548190611ce1908890614257565b1115611d545760405162461bcd60e51b8152602060048201526024808201527f4d617820617661696c61626c652070726573616c6520616d6f756e742072656160448201527f63686564000000000000000000000000000000000000000000000000000000006064820152608401611653565b60065468a20d6e21d0e52553085487907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16611d949190614257565b1115611de25760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b336000818152600b60205260409020600301805488019055611e049087612949565b5050505050611e1260018055565b50565b6060600f8054611e2490614299565b159050611e5957600f611e3683613038565b604051602001611e47929190614449565b60405160208183030381529060405290505b919050565b611e66612f7d565b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b611ea0612f7d565b600955565b611ead612f7d565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015611e12573d6000803e3d6000fd5b611eef612f7d565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b611f326128ee565b60025462010000900460ff16611f8a5760405162461bcd60e51b815260206004820152601760248201527f57686974656c697374206d696e74206e6f74206c6976650000000000000000006044820152606401611653565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b16602082015260348101849052600090605401604051602081830303815290604052805190602001209050611feb838360095484612931565b61205d5760405162461bcd60e51b815260206004820152602260248201527f4e6f7420616c6c6f77656420746f206d696e742066726f6d2077686974656c6960448201527f73740000000000000000000000000000000000000000000000000000000000006064820152608401611653565b600085116120ad5760405162461bcd60e51b815260206004820152601060248201527f43616e6e6f74206d696e74207a65726f000000000000000000000000000000006044820152606401611653565b336000908152600b60205260409020600101541515806120d55750670de0b6b3a76400008510155b6121215760405162461bcd60e51b815260206004820152601460248201527f4d757374206d696e74206174206c6561737420310000000000000000000000006044820152606401611653565b60065468a20d6e21d0e52553085486907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff166121619190614257565b11156121af5760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b6000600754116122015760405162461bcd60e51b815260206004820152601c60248201527f4d61782077686974656c69737420737570706c792072656163686564000000006044820152606401611653565b336000908152600b60205260409020600101548490612221908790614257565b111561226f5760405162461bcd60e51b815260206004820152601c60248201527f4d61782077686974656c69737420616d6f756e742072656163686564000000006044820152606401611653565b60055461227c908661451d565b156122c95760405162461bcd60e51b815260206004820152601560248201527f496e636f7272656374206d696e7420616d6f756e7400000000000000000000006044820152606401611653565b6000600554866122d99190614531565b905034600454826122ea9190614432565b11156123385760405162461bcd60e51b815260206004820152600e60248201527f4e6f7420656e6f756768204554480000000000000000000000000000000000006044820152606401611653565b336000818152600b602052604090206001018054880190556007805488900390556123639087612949565b505061183160018055565b6123766128ee565b600254610100900460ff166123cd5760405162461bcd60e51b815260206004820152601460248201527f5075626c6963206d696e74206e6f74206c6976650000000000000000000000006044820152606401611653565b6000811161241d5760405162461bcd60e51b815260206004820152601060248201527f43616e6e6f74206d696e74207a65726f000000000000000000000000000000006044820152606401611653565b336000908152600b60205260409020541515806124425750670de0b6b3a76400008110155b61248e5760405162461bcd60e51b815260206004820152601460248201527f4d757374206d696e74206174206c6561737420310000000000000000000000006044820152606401611653565b60065468a20d6e21d0e52553085482907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff166124ce9190614257565b111561251c5760405162461bcd60e51b815260206004820152601860248201527f4d617820746f74616c20737570706c79207265616368656400000000000000006044820152606401611653565b600854336000908152600b602052604090205461253a908390614257565b11156125ae5760405162461bcd60e51b815260206004820152602360248201527f4d6178207075626c6963206d696e7473207065722077616c6c6574207265616360448201527f68656400000000000000000000000000000000000000000000000000000000006064820152608401611653565b6005546125bb908261451d565b156126085760405162461bcd60e51b815260206004820152601560248201527f496e636f7272656374206d696e7420616d6f756e7400000000000000000000006044820152606401611653565b6000600554826126189190614531565b905034600354826126299190614432565b11156126775760405162461bcd60e51b815260206004820152600e60248201527f4e6f7420656e6f756768204554480000000000000000000000000000000000006044820152606401611653565b336000818152600b602052604090208054840190556126969083612949565b50611e1260018055565b6126a8612f7d565b6001600160a01b0381166126eb576040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152602401611653565b611e1281612fc3565b6126fc612f7d565b600a55565b6001600160a01b038116600090815268a20d6e21d0e525531360205260408120805490916b0100000000000000000000009091046001169003611e595780547fffffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffff166b01000000000000000000000060ff933b1515600202600117939093169290920291909117815590565b81546c01000000000000000000000000900463ffffffff1668a20d6e21d0e525530860008290036128755780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008116600163ffffffff92831601918216908117835585547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c0100000000000000000000000082021786556000818152600284016020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038816179055919350900361287557600080fd5b5092915050565b600080612888836113f0565b6001600160a01b0316141592915050565b6128a1611939565b15611a54576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006128e53384846130d8565b50600192915050565b60026001540361292a576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600155565b60008261293f86868561313a565b1495945050505050565b6001600160a01b038216612989576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061299483612701565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b03166129bf57600080fd5b60408051608081018252600080825260208201819052918101829052606081019190915282546bffffffffffffffffffffffff7401000000000000000000000000000000000000000080830482168701918216026001600160a01b03909216919091178455670de0b6b3a7640000810460408301525081546001600160a01b03811674010000000000000000000000000000000000000000918290046bffffffffffffffffffffffff908116870190811690920217835560009081612a9b606083901c670de0b6b3a7640000840463fffffffe10171515151590565b9050868210811715612ad9576040517fe5cfe95700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508454670de0b6b3a764000090910491506b0100000000000000000000009004600216600003612e10576001600160a01b03861660009081526008840160205260408082208654918501519092600a870192700100000000000000000000000000000000900463ffffffff1691612b569083810390841002613186565b9050806040015151600014612e0b5760608a901b602082015260408082015151885463ffffffff7001000000000000000000000000000000008083048216909301811683027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff928316178b55928901518b5493169091029116178855612bdc888b61278c565b63ffffffff908116606088015287546c01000000000000000000000000810482166020890152640100000000810482168781118015909102178852680100000000000000009004165b6000876020015163ffffffff168263ffffffff1614612c74576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050612cce565b5086515b612c8985600019830160011b610efc565b63ffffffff1615612cbe57612cb7612cab8a600601836001018a6001016131cd565b88811180159091021790565b9050612c78565b6001810187811180159091021788525b600881901c60068a0160601b018054600160ff84161b8019909116179055600384901c606087901b018054600586901b60e01681811c841863ffffffff16901b189055612d6585828a6060015187806001019850600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8251602080850151600884901b1782520183525086604001518303612c25578651885463ffffffff83811668010000000000000000027fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff9190931664010000000002167fffffffffffffffffffffffffffffffffffffffff0000000000000000ffffffff909116171788556001880154612e099083906001600160a01b03166132b4565b505b505050505b60008581526001600160a01b038716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3505050505050565b336028908152601484905268a20d6e21d0e525530f6000908152604881209181905281549091906000198114612ebd5780841115612eb7576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83810382555b612ec88686866132f0565b50600195945050505050565b6000612edf83612701565b80549091506b0100000000000000000000009004600216151582151514612f4557805460ff6b0100000000000000000000008083048216600218909116027fffffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffff9091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b6000546001600160a01b03163314611a54576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611653565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006128e53384846132f0565b6060600061304583613e20565b600101905060008167ffffffffffffffff8111156130655761306561426a565b6040519080825280601f01601f19166020018201604052801561308f576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461309957509392505050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b600081815b8481101561317d576131698287878481811061315d5761315d614545565b90506020020135613f02565b91508061317581614574565b91505061313f565b50949350505050565b6131aa60405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b80613222578460081c83015b60018301925082541991508083118217156131f657808311156132205760ff86191691821b90911c905b505b80156132aa5782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff1060061b1781811c63ffffffff1060051b1790811c63d76453e004601f169190911a171785811015878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af160018251141661183157600081fd5b6001600160a01b038216613330576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061333b84612701565b9050600061334884612701565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b031661337357600080fd5b6133ea604051806101a0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b835463ffffffff700100000000000000000000000000000000808304821660808501528554041660a083015282546bffffffffffffffffffffffff7401000000000000000000000000000000000000000091829004811660c085015291041660408201819052851115613489576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040810180518690039081905284546bffffffffffffffffffffffff918216740100000000000000000000000000000000000000009081026001600160a01b0392831617875585548181048416890160608601819052909316029116178355608081015161351c90613500670de0b6b3a764000090565b836040015181613512576135126144ee565b0480821191030290565b815282546b010000000000000000000000900460021660000361359357856001600160a01b0316876001600160a01b03160361356057805160808201510360a08201525b61358d670de0b6b3a764000082606001518161357e5761357e6144ee565b048260a0015180821191030290565b60208201525b60006135c082608001516135b584600001518560200151808218908211021890565b808218908211021890565b9050806000036135d05750613839565b8151819003825260208201805182900390526001600160a01b03808816908916036136055760a0820180519091019052613839565b604080516080810182526000808252602080830182815283850183815260608086019081528651888152600589901b81018501885290819052908d9052908d9052810183526001600160a01b03808d16835260088801909152838220908b168252929020909190613676878b61278c565b63ffffffff1661014086015260a08501515b6080860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff16606084901b600384901c01805460e0600586901b1681811c63ffffffff948516908118909416901b189055905061373788600a018289610140015185806001019650600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b84518181526020018552600881901c6005890160601b015460ff82161c600116156137ad576005880160601b600882901c018054600160ff84161b191690556000818152600489016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b506000198501946000036001016136885760a08601819052875463ffffffff8083167001000000000000000000000000000000009081027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff938416178b5560808901518c54921602911617895560018701546138339085906001600160a01b0316613f31565b50505050505b80516020820151835463ffffffff7001000000000000000000000000000000008083048216840185900360e08701819052909116027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff909116178455600a8401916000916138a79101613186565b84546c01000000000000000000000000900463ffffffff16610180850152835190915015613af057606089901b6001176020828101919091526001600160a01b038a16600090815260088601909152604081206080850151855181036101008701819052895463ffffffff909116700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff9091161789556101808601515b60001991909101600381901c606084901b0154909190600090600584901b60e0161c63ffffffff1663ffffffff166000198101600281901c60608a901b01805460069290921b60c01682811c67ffffffffffffffff16901b909118905590508551602080880151600884901b1782520186526001156139ea576006890160601b600882901c018054600160ff84161b191690555b8415613a24576009890160601b631fffffff600384901c1601805460e0600585901b1681811c841863ffffffff16901b1890556001909101905b600881901c60058a0160601b015460ff82161c60011615613a90576005890160601b600882901c018054600160ff84161b19169055600081815260048a016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b508661010001518203613956578315613aeb5763ffffffff8116610180880181905288547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c010000000000000000000000009091021788555b505050505b602083015115613db957606088901b60208201526001600160a01b03881660009081526008850160205260409020613b28868a61278c565b63ffffffff166101408501526000670de0b6b3a76400008560c0015181613b5157613b516144ee565b87549190049150640100000000900463ffffffff1681811180159091021761016086015260a085015160208601518101610120870181905288547fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000063ffffffff928316021789558754680100000000000000009004165b600087610180015163ffffffff168263ffffffff1614613c2b576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050613c8d565b506101608701515b613c4487600019830160011b610efc565b63ffffffff1615613c7957613c72613c668a60060183600101876001016131cd565b85811180159091021790565b9050613c33565b600181018481118015909102176101608901525b600881901c60068a0160601b018054600160ff84161b8019909116179055600383901c606086901b018054600585901b60e01681811c841863ffffffff16901b189055613d2587828a610140015186806001019750600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8551602080880151600884901b178252018652508661012001518203613bdb57875461016088015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff919093166801000000000000000002167fffffffffffffffffffffffffffffffffffffffff0000000000000000ffffffff909116171787555050505b60408101515115613ddd576001840154613ddd9082906001600160a01b03166132b4565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613e69577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310613e95576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310613eb357662386f26fc10000830492506010015b6305f5e1008310613ecb576305f5e100830492506008015b6127108310613edf57612710830492506004015b60648310613ef1576064830492506002015b600a83106113ea5760010192915050565b6000818310613f1e5760008281526020849052604090206115ef565b60008381526020839052604090206115ef565b6060820151805160051b60840160808203915063144027d3825283602001518460400151816020850152806040850152505060608083015260208282601c85016000875af160018351141661183157600082fd5b60005b83811015613fa0578181015183820152602001613f88565b50506000910152565b6020815260008251806020840152613fc8816040850160208701613f85565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b80356001600160a01b0381168114611e5957600080fd5b6000806040838503121561402457600080fd5b61402d83613ffa565b946020939093013593505050565b6000806000806060858703121561405157600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561407757600080fd5b818701915087601f83011261408b57600080fd5b81358181111561409a57600080fd5b8860208260051b85010111156140af57600080fd5b95989497505060200194505050565b6000806000606084860312156140d357600080fd5b6140dc84613ffa565b92506140ea60208501613ffa565b9150604084013590509250925092565b60006020828403121561410c57600080fd5b6115ef82613ffa565b80358015158114611e5957600080fd5b60006020828403121561413757600080fd5b6115ef82614115565b60006020828403121561415257600080fd5b5035919050565b6000806020838503121561416c57600080fd5b823567ffffffffffffffff8082111561418457600080fd5b818501915085601f83011261419857600080fd5b8135818111156141a757600080fd5b8660208285010111156141b957600080fd5b60209290920196919550909350505050565b600080604083850312156141de57600080fd5b6141e783613ffa565b91506141f560208401614115565b90509250929050565b6000806040838503121561421157600080fd5b61421a83613ffa565b91506141f560208401613ffa565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156113ea576113ea614228565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600181811c908216806142ad57607f821691505b6020821081036142e6577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f82111561193457600081815260208120601f850160051c810160208610156143135750805b601f850160051c820191505b818110156143325782815560010161431f565b505050505050565b67ffffffffffffffff8311156143525761435261426a565b614366836143608354614299565b836142ec565b6000601f84116001811461439a57600085156143825750838201355b600019600387901b1c1916600186901b178355614412565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b828110156143e957868501358255602094850194600190920191016143c9565b50868210156144065760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60006020828403121561442b57600080fd5b5051919050565b80820281158282048414176113ea576113ea614228565b600080845461445781614299565b6001828116801561446f57600181146144a2576144d1565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00841687528215158302870194506144d1565b8860005260208060002060005b858110156144c85781548a8201529084019082016144af565b50505082870194505b5050505083516144e5818360208801613f85565b01949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261452c5761452c6144ee565b500690565b600082614540576145406144ee565b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000600019820361458757614587614228565b506001019056fea26469706673582212202aaf947a2c757f945c560320a757bd2e9da782521ad33ab7d1f87750296bf9b764736f6c63430008140033

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

000000000000000000000000000000000000000000000000001550f7dca700000000000000000000000000000000000000000000000000000011c37937e0800000000000000000000000000000000000000000000000005c283d41039410000000000000000000000000000000000000000000000000001b1ae4d6e2ef500000000000000000000000000000d41e849492fcdd2461b9468049f59e9bad7d33e0000000000000000000000000433bc4349ae65c4975fe1bde06de6e427ea72d42

-----Decoded View---------------
Arg [0] : _publicMintPricePerStep (uint256): 6000000000000000
Arg [1] : _whitelistMintPricePerStep (uint256): 5000000000000000
Arg [2] : _availableWhitelistMintSupply (uint256): 1700000000000000000000
Arg [3] : _initialTokenSupply (uint256): 500000000000000000000
Arg [4] : _presaleAddress1 (address): 0xd41e849492fCdD2461b9468049f59E9bad7d33E0
Arg [5] : _presaleAddress2 (address): 0x433bc4349AE65c4975fE1BDE06dE6e427Ea72D42

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000000000001550f7dca70000
Arg [1] : 0000000000000000000000000000000000000000000000000011c37937e08000
Arg [2] : 00000000000000000000000000000000000000000000005c283d410394100000
Arg [3] : 00000000000000000000000000000000000000000000001b1ae4d6e2ef500000
Arg [4] : 000000000000000000000000d41e849492fcdd2461b9468049f59e9bad7d33e0
Arg [5] : 000000000000000000000000433bc4349ae65c4975fe1bde06de6e427ea72d42


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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