ETH Price: $2,101.66 (-0.48%)

Token

Wei Name Service (WEI)
 

Overview

Max Total Supply

0 WEI

Holders

355

Transfers

-
4

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A

Other Info

Loading...
Loading
Loading...
Loading
Loading...
Loading

OVERVIEW

A simple namespace on ethereum named after the smallest unit of ether

# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
NameNFT

Compiler Version
v0.8.33+commit.64118f21

Optimization Enabled:
Yes with 20 runs

Other Settings:
prague EvmVersion
File 1 of 8 : NameNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

import {Base64} from "solady/utils/Base64.sol";
import {ERC721} from "solady/tokens/ERC721.sol";
import {Ownable} from "solady/auth/Ownable.sol";
import {LibString} from "solady/utils/LibString.sol";
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";
import {ReentrancyGuard} from "soledge/utils/ReentrancyGuard.sol";

/// @title NameNFT
/// @notice ENS-style naming system for .wei TLD with ERC721 ownership
/// @dev Token ID = uint256(namehash). ENS-compatible resolution.
///
/// Unicode Support:
/// - This contract validates UTF-8 encoding and accepts valid UTF-8 labels (including emoji)
/// - ASCII letters A-Z are automatically lowercased on-chain
/// - For proper Unicode normalization, callers SHOULD pre-normalize using ENSIP-15
/// - Off-chain: use adraffy/ens-normalize library or equivalent before calling
/// - Example: normalize("RaFFY🚴‍♂️") => "raffy🚴‍♂" (do this off-chain, then call contract)
contract NameNFT is ERC721, Ownable, ReentrancyGuard {
    using LibString for uint256;

    /*//////////////////////////////////////////////////////////////
                                 ERRORS
    //////////////////////////////////////////////////////////////*/

    error Expired();
    error TooDeep();
    error EmptyLabel();
    error InvalidName();
    error InvalidLength();
    error LengthMismatch();
    error NotParentOwner();
    error PremiumTooHigh();
    error InsufficientFee();
    error AlreadyCommitted();
    error CommitmentTooNew();
    error CommitmentTooOld();
    error AlreadyRegistered();
    error CommitmentNotFound();
    error DecayPeriodTooLong();

    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event NameRegistered(
        uint256 indexed tokenId, string label, address indexed owner, uint256 expiresAt
    );
    event SubdomainRegistered(uint256 indexed tokenId, uint256 indexed parentId, string label);
    event NameRenewed(uint256 indexed tokenId, uint256 newExpiresAt);
    event PrimaryNameSet(address indexed addr, uint256 indexed tokenId);
    event Committed(bytes32 indexed commitment, address indexed committer);

    // ENS-compatible resolver events (use bytes32 node for tooling compatibility)
    event AddrChanged(bytes32 indexed node, address addr);
    event ContenthashChanged(bytes32 indexed node, bytes contenthash);
    event AddressChanged(bytes32 indexed node, uint256 coinType, bytes addr);
    event TextChanged(bytes32 indexed node, string indexed key, string value);

    // Admin events
    event DefaultFeeChanged(uint256 fee);
    event LengthFeeChanged(uint256 indexed length, uint256 fee);
    event LengthFeeCleared(uint256 indexed length);
    event PremiumSettingsChanged(uint256 maxPremium, uint256 decayPeriod);

    /*//////////////////////////////////////////////////////////////
                                CONSTANTS
    //////////////////////////////////////////////////////////////*/

    /// @dev Namehash of "wei" TLD - kept public for off-chain tooling
    bytes32 public constant WEI_NODE =
        0xa82820059d5df798546bcc2985157a77c3eef25eba9ba01899927333efacbd6f;

    uint256 constant MAX_LABEL_LENGTH = 255;
    uint256 constant MIN_LABEL_LENGTH = 1;
    uint256 constant MIN_COMMITMENT_AGE = 60;
    uint256 constant MAX_COMMITMENT_AGE = 86400;
    uint256 constant REGISTRATION_PERIOD = 365 days;
    uint256 constant GRACE_PERIOD = 90 days;
    uint256 constant MAX_SUBDOMAIN_DEPTH = 10;
    uint256 constant COIN_TYPE_ETH = 60;
    uint256 constant MAX_PREMIUM_CAP = 10000 ether;
    uint256 constant MAX_DECAY_PERIOD = 3650 days;
    uint256 constant DEFAULT_FEE = 0.001 ether;

    /*//////////////////////////////////////////////////////////////
                                 STORAGE
    //////////////////////////////////////////////////////////////*/

    struct NameRecord {
        string label;
        uint256 parent;
        uint64 expiresAt;
        uint64 epoch;
        uint64 parentEpoch;
    }

    uint256 public defaultFee;
    uint256 public maxPremium;
    uint256 public premiumDecayPeriod;

    mapping(uint256 => uint256) public lengthFees;
    mapping(uint256 => bool) public lengthFeeSet;
    mapping(uint256 => NameRecord) public records;
    mapping(uint256 => uint256) public recordVersion;
    mapping(bytes32 => uint256) public commitments;
    mapping(address => uint256) public primaryName;

    // Versioned resolver data
    mapping(uint256 => mapping(uint256 => address)) internal _resolvedAddress;
    mapping(uint256 => mapping(uint256 => bytes)) internal _contenthash;
    mapping(uint256 => mapping(uint256 => mapping(uint256 => bytes))) internal _coinAddr;
    mapping(uint256 => mapping(uint256 => mapping(string => string))) internal _text;

    /*//////////////////////////////////////////////////////////////
                              CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor() payable {
        _initializeOwner(tx.origin);
        defaultFee = DEFAULT_FEE;
        maxPremium = 100 ether;
        premiumDecayPeriod = 21 days;
    }

    /*//////////////////////////////////////////////////////////////
                             ERC721 METADATA
    //////////////////////////////////////////////////////////////*/

    function name() public pure override(ERC721) returns (string memory) {
        return "Wei Name Service";
    }

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

    /// @dev Blocks transfers of inactive tokens, but allows mint (from==0) and burn (to==0)
    /// This matches ENS behavior: expired names cannot be traded
    function _beforeTokenTransfer(address from, address to, uint256 tokenId)
        internal
        virtual
        override(ERC721)
    {
        // Allow mint and burn, block transfers of inactive tokens
        if (from != address(0) && to != address(0)) {
            if (!_isActive(tokenId)) revert Expired();
        }
    }

    function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) {
        if (!_recordExists(tokenId)) revert TokenDoesNotExist();

        NameRecord storage record = records[tokenId];

        // Check for stale subdomain FIRST (parent epoch mismatch)
        if (record.parent != 0) {
            NameRecord storage parentRecord = records[record.parent];
            if (record.parentEpoch != parentRecord.epoch) {
                return string.concat(
                    "data:application/json;base64,",
                    Base64.encode(
                        bytes(
                            '{"name":"[Invalid]","description":"This subdomain is no longer valid.","image":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MDAgNDAwIj48cmVjdCB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgZmlsbD0iIzk5OSIvPjx0ZXh0IHg9IjIwMCIgeT0iMjAwIiBmb250LWZhbWlseT0ic2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iI2ZmZiI+W0ludmFsaWRdPC90ZXh0Pjwvc3ZnPg=="}'
                        )
                    )
                );
            }
        }

        // Check for expired (top-level or parent chain expired)
        if (!_isActive(tokenId)) {
            return string.concat(
                "data:application/json;base64,",
                Base64.encode(
                    bytes(
                        '{"name":"[Expired]","description":"This name has expired.","image":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MDAgNDAwIj48cmVjdCB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgZmlsbD0iIzk5OSIvPjx0ZXh0IHg9IjIwMCIgeT0iMjAwIiBmb250LWZhbWlseT0ic2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iI2ZmZiI+W0V4cGlyZWRdPC90ZXh0Pjwvc3ZnPg=="}'
                    )
                )
            );
        }

        string memory fullName = _buildFullName(tokenId);
        fullName = string.concat(fullName, ".wei");
        string memory displayName = bytes(fullName).length <= 20
            ? fullName
            : string.concat(_truncateUTF8(fullName, 17), "...");

        // Build attributes with expiry info for marketplace compatibility
        string memory attributes;
        if (record.parent == 0) {
            // Top-level name: show expiry
            attributes = string.concat(
                ',"attributes":[{"trait_type":"Expires","display_type":"date","value":',
                uint256(record.expiresAt).toString(),
                "}]"
            );
        } else {
            // Subdomain: no direct expiry
            attributes = ',"attributes":[{"trait_type":"Type","value":"Subdomain"}]';
        }

        string memory escapedName = _escapeJSON(fullName);

        return string.concat(
            "data:application/json;base64,",
            Base64.encode(
                bytes(
                    string.concat(
                        '{"name":"',
                        escapedName,
                        '","description":"Wei Name Service: ',
                        escapedName,
                        '","image":"data:image/svg+xml;base64,',
                        Base64.encode(bytes(_generateSVG(displayName))),
                        '"',
                        attributes,
                        "}"
                    )
                )
            )
        );
    }

    /*//////////////////////////////////////////////////////////////
                            COMMIT-REVEAL
    //////////////////////////////////////////////////////////////*/

    function makeCommitment(string calldata label, address owner, bytes32 secret)
        public
        pure
        returns (bytes32)
    {
        bytes memory normalized = _validateAndNormalize(bytes(label));
        return keccak256(abi.encode(normalized, owner, secret));
    }

    function commit(bytes32 commitment) public {
        if (
            commitments[commitment] != 0
                && block.timestamp <= commitments[commitment] + MAX_COMMITMENT_AGE
        ) {
            revert AlreadyCommitted();
        }
        commitments[commitment] = block.timestamp;
        emit Committed(commitment, msg.sender);
    }

    function reveal(string calldata label, bytes32 secret)
        external
        payable
        nonReentrant
        returns (uint256 tokenId)
    {
        uint256 fee = getFee(bytes(label).length);
        bytes memory normalized = _validateAndNormalize(bytes(label));

        tokenId = uint256(keccak256(abi.encodePacked(WEI_NODE, keccak256(normalized))));
        uint256 premium = getPremium(tokenId);
        uint256 total = fee + premium;

        if (msg.value < total) revert InsufficientFee();

        bytes32 commitment = keccak256(abi.encode(normalized, msg.sender, secret));
        uint256 committedAt = commitments[commitment];

        if (committedAt == 0) revert CommitmentNotFound();
        if (block.timestamp < committedAt + MIN_COMMITMENT_AGE) revert CommitmentTooNew();
        if (block.timestamp > committedAt + MAX_COMMITMENT_AGE) revert CommitmentTooOld();

        delete commitments[commitment];
        _register(string(normalized), 0, msg.sender);

        if (msg.value > total) {
            SafeTransferLib.safeTransferETH(msg.sender, msg.value - total);
        }
    }

    /*//////////////////////////////////////////////////////////////
                          SUBDOMAIN REGISTRATION
    //////////////////////////////////////////////////////////////*/

    function registerSubdomain(string calldata label, uint256 parentId)
        external
        nonReentrant
        returns (uint256)
    {
        if (!_isActive(parentId)) revert Expired();
        if (ownerOf(parentId) != msg.sender) revert NotParentOwner();
        return _register(label, parentId, msg.sender);
    }

    function registerSubdomainFor(string calldata label, uint256 parentId, address to)
        external
        nonReentrant
        returns (uint256)
    {
        if (!_isActive(parentId)) revert Expired();
        if (ownerOf(parentId) != msg.sender) revert NotParentOwner();
        return _register(label, parentId, to);
    }

    /*//////////////////////////////////////////////////////////////
                               RENEWAL
    //////////////////////////////////////////////////////////////*/

    function renew(uint256 tokenId) public payable nonReentrant {
        NameRecord storage record = records[tokenId];
        if (bytes(record.label).length == 0) revert TokenDoesNotExist();
        if (record.parent != 0) revert Unauthorized();
        if (block.timestamp > record.expiresAt + GRACE_PERIOD) revert Expired();

        uint256 fee = getFee(bytes(record.label).length);
        if (msg.value < fee) revert InsufficientFee();

        // Always extend from current expiry (ENS-style)
        // This is consistent whether renewing early or during grace
        record.expiresAt = record.expiresAt + uint64(REGISTRATION_PERIOD);

        emit NameRenewed(tokenId, record.expiresAt);

        if (msg.value > fee) {
            SafeTransferLib.safeTransferETH(msg.sender, msg.value - fee);
        }
    }

    function isExpired(uint256 tokenId) public view returns (bool) {
        uint64 exp = records[tokenId].expiresAt;
        return exp != 0 && block.timestamp > exp + GRACE_PERIOD;
    }

    function inGracePeriod(uint256 tokenId) public view returns (bool) {
        uint64 exp = records[tokenId].expiresAt;
        return exp != 0 && block.timestamp > exp && block.timestamp <= exp + GRACE_PERIOD;
    }

    function expiresAt(uint256 tokenId) public view returns (uint256) {
        return records[tokenId].expiresAt;
    }

    /*//////////////////////////////////////////////////////////////
                              RESOLUTION
    //////////////////////////////////////////////////////////////*/

    function setAddr(uint256 tokenId, address addr) public {
        if (!_isActive(tokenId)) revert Expired();
        if (ownerOf(tokenId) != msg.sender) revert Unauthorized();
        _resolvedAddress[tokenId][recordVersion[tokenId]] = addr;
        emit AddrChanged(bytes32(tokenId), addr);
    }

    function setPrimaryName(uint256 tokenId) public {
        if (tokenId != 0) {
            if (!_isActive(tokenId)) revert Expired();
            address resolved = resolve(tokenId);
            if (ownerOf(tokenId) != msg.sender && resolved != msg.sender) revert Unauthorized();
        }
        primaryName[msg.sender] = tokenId;
        emit PrimaryNameSet(msg.sender, tokenId);
    }

    function resolve(uint256 tokenId) public view returns (address) {
        if (!_isActive(tokenId)) return address(0);
        address addr = _resolvedAddress[tokenId][recordVersion[tokenId]];
        return addr != address(0) ? addr : ownerOf(tokenId);
    }

    function reverseResolve(address addr) public view returns (string memory) {
        uint256 tokenId = primaryName[addr];
        if (tokenId == 0 || !_isActive(tokenId) || resolve(tokenId) != addr) return "";
        return string.concat(_buildFullName(tokenId), ".wei");
    }

    /*//////////////////////////////////////////////////////////////
                         ENS-COMPATIBLE RESOLVER
    //////////////////////////////////////////////////////////////*/

    function setContenthash(uint256 tokenId, bytes calldata hash) public {
        if (!_isActive(tokenId)) revert Expired();
        if (ownerOf(tokenId) != msg.sender) revert Unauthorized();
        _contenthash[tokenId][recordVersion[tokenId]] = hash;
        emit ContenthashChanged(bytes32(tokenId), hash);
    }

    function contenthash(uint256 tokenId) public view returns (bytes memory) {
        if (!_isActive(tokenId)) return "";
        return _contenthash[tokenId][recordVersion[tokenId]];
    }

    function setAddrForCoin(uint256 tokenId, uint256 coinType, bytes calldata addr) public {
        if (!_isActive(tokenId)) revert Expired();
        if (ownerOf(tokenId) != msg.sender) revert Unauthorized();
        _coinAddr[tokenId][recordVersion[tokenId]][coinType] = addr;
        emit AddressChanged(bytes32(tokenId), coinType, addr);
    }

    function addr(uint256 tokenId, uint256 coinType) public view returns (bytes memory) {
        if (!_isActive(tokenId)) return "";
        uint256 v = recordVersion[tokenId];
        if (coinType == COIN_TYPE_ETH) {
            bytes memory a = _coinAddr[tokenId][v][COIN_TYPE_ETH];
            if (a.length > 0) return a;
            address resolved = resolve(tokenId);
            if (resolved != address(0)) return abi.encodePacked(resolved);
        }
        return _coinAddr[tokenId][v][coinType];
    }

    function setText(uint256 tokenId, string calldata key, string calldata value) public {
        if (!_isActive(tokenId)) revert Expired();
        if (ownerOf(tokenId) != msg.sender) revert Unauthorized();
        _text[tokenId][recordVersion[tokenId]][key] = value;
        emit TextChanged(bytes32(tokenId), key, value);
    }

    function text(uint256 tokenId, string calldata key) public view returns (string memory) {
        if (!_isActive(tokenId)) return "";
        return _text[tokenId][recordVersion[tokenId]][key];
    }

    // bytes32 overloads for ENS compatibility
    function addr(bytes32 node) public view returns (address) {
        return resolve(uint256(node));
    }

    function addr(bytes32 node, uint256 coinType) public view returns (bytes memory) {
        uint256 tokenId = uint256(node);
        if (!_isActive(tokenId)) return "";
        uint256 v = recordVersion[tokenId];
        if (coinType == COIN_TYPE_ETH) {
            bytes memory a = _coinAddr[tokenId][v][COIN_TYPE_ETH];
            if (a.length > 0) return a;
            address resolved = resolve(tokenId);
            if (resolved != address(0)) return abi.encodePacked(resolved);
        }
        return _coinAddr[tokenId][v][coinType];
    }

    function text(bytes32 node, string calldata key) public view returns (string memory) {
        uint256 tokenId = uint256(node);
        if (!_isActive(tokenId)) return "";
        return _text[tokenId][recordVersion[tokenId]][key];
    }

    function contenthash(bytes32 node) public view returns (bytes memory) {
        uint256 tokenId = uint256(node);
        if (!_isActive(tokenId)) return "";
        return _contenthash[tokenId][recordVersion[tokenId]];
    }

    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == 0x3b3b57de || interfaceId == 0xf1cb7e06 || interfaceId == 0x59d1d43c
            || interfaceId == 0xbc1c58d1 || super.supportsInterface(interfaceId);
    }

    /*//////////////////////////////////////////////////////////////
                               LOOKUPS
    //////////////////////////////////////////////////////////////*/

    function computeId(string calldata fullName) public pure returns (uint256) {
        return uint256(computeNamehash(fullName));
    }

    /// @notice Compute namehash for a full name (e.g. "sub.name.wei" or "name")
    /// @dev This function is intentionally permissive - it lowercases and hashes any input.
    ///      Registration enforces validation: valid UTF-8, no space/control chars/dot.
    ///      Use normalize() to check if a label is valid for registration.
    function computeNamehash(string calldata fullName) public pure returns (bytes32 node) {
        bytes memory b = bytes(fullName);
        if (b.length == 0) return WEI_NODE;

        uint256 len = b.length;

        // Strip .wei suffix if present
        if (
            len >= 4 && b[len - 4] == 0x2e && (b[len - 3] == 0x77 || b[len - 3] == 0x57)
                && (b[len - 2] == 0x65 || b[len - 2] == 0x45)
                && (b[len - 1] == 0x69 || b[len - 1] == 0x49)
        ) {
            len -= 4;
        }

        if (len == 0) return WEI_NODE;
        if (b[0] == 0x2e || b[len - 1] == 0x2e) revert EmptyLabel();

        node = WEI_NODE;
        uint256 labelEnd = len;

        for (uint256 i = len; i > 0; --i) {
            if (b[i - 1] == 0x2e) {
                if (i >= labelEnd) revert EmptyLabel();
                node = keccak256(abi.encodePacked(node, keccak256(_toLowerSlice(b, i, labelEnd))));
                labelEnd = i - 1;
            }
        }

        if (labelEnd > 0) {
            node = keccak256(abi.encodePacked(node, keccak256(_toLowerSlice(b, 0, labelEnd))));
        }
    }

    /// @notice Check if a label is available for registration
    /// @dev For subdomains, returns false if subdomain exists and is active, even though
    ///      the parent owner can overwrite it. Parent owners should use registerSubdomain()
    ///      directly - it will succeed for reclaim even when isAvailable() returns false.
    function isAvailable(string calldata label, uint256 parentId) public view returns (bool) {
        bytes memory b = bytes(label);
        if (b.length < MIN_LABEL_LENGTH || b.length > MAX_LABEL_LENGTH) return false;

        // UTF-8 validation and normalization (mirrors _validateAndNormalize but returns false instead of reverting)
        bytes memory normalized = new bytes(b.length);
        uint256 i;

        while (i < b.length) {
            uint8 cb = uint8(b[i]);

            // Reject control chars, space, dot, DEL
            if (cb <= 0x20 || cb == 0x7f || cb == 0x2e) return false;

            if (cb < 0x80) {
                // ASCII: lowercase A-Z
                normalized[i] = (cb >= 0x41 && cb <= 0x5a) ? bytes1(cb + 32) : b[i];
                i++;
            } else if (cb < 0xC2) {
                return false; // Invalid UTF-8 start byte
            } else if (cb < 0xE0) {
                if (i + 1 >= b.length) return false;
                uint8 b1 = uint8(b[i + 1]);
                if (b1 < 0x80 || b1 > 0xBF) return false;
                normalized[i] = b[i];
                normalized[i + 1] = b[i + 1];
                i += 2;
            } else if (cb < 0xF0) {
                if (i + 2 >= b.length) return false;
                uint8 b1 = uint8(b[i + 1]);
                uint8 b2 = uint8(b[i + 2]);
                if (b1 < 0x80 || b1 > 0xBF || b2 < 0x80 || b2 > 0xBF) return false;
                if (cb == 0xE0 && b1 < 0xA0) return false; // Overlong
                if (cb == 0xED && b1 >= 0xA0) return false; // Surrogate
                normalized[i] = b[i];
                normalized[i + 1] = b[i + 1];
                normalized[i + 2] = b[i + 2];
                i += 3;
            } else if (cb < 0xF5) {
                if (i + 3 >= b.length) return false;
                uint8 b1 = uint8(b[i + 1]);
                uint8 b2 = uint8(b[i + 2]);
                uint8 b3 = uint8(b[i + 3]);
                if (b1 < 0x80 || b1 > 0xBF || b2 < 0x80 || b2 > 0xBF || b3 < 0x80 || b3 > 0xBF) {
                    return false;
                }
                if (cb == 0xF0 && b1 < 0x90) return false; // Overlong
                if (cb == 0xF4 && b1 > 0x8F) return false; // Above U+10FFFF
                normalized[i] = b[i];
                normalized[i + 1] = b[i + 1];
                normalized[i + 2] = b[i + 2];
                normalized[i + 3] = b[i + 3];
                i += 4;
            } else {
                return false; // Invalid UTF-8
            }
        }

        // Hyphen rules
        if (normalized[0] == 0x2d || normalized[b.length - 1] == 0x2d) return false;

        bytes32 parentNode = parentId == 0 ? WEI_NODE : bytes32(parentId);
        uint256 tokenId = uint256(keccak256(abi.encodePacked(parentNode, keccak256(normalized))));

        if (parentId != 0 && !_isActive(parentId)) return false;
        if (parentId != 0 && _getDepth(parentId) >= MAX_SUBDOMAIN_DEPTH) return false;
        if (!_recordExists(tokenId)) return true;

        NameRecord storage record = records[tokenId];
        if (record.parent == 0) return isExpired(tokenId);

        if (parentId != 0) {
            return record.parentEpoch != records[parentId].epoch;
        }
        return false;
    }

    function getFullName(uint256 tokenId) public view returns (string memory) {
        string memory baseName = _buildFullName(tokenId);
        if (bytes(baseName).length == 0) return "";
        return string.concat(baseName, ".wei");
    }

    /// @notice On-chain normalization (lowercases ASCII only)
    /// @dev For full Unicode normalization, use ENSIP-15 library off-chain
    function normalize(string calldata label) public pure returns (string memory) {
        return string(_validateAndNormalize(bytes(label)));
    }

    /// @notice Check if label contains only ASCII characters
    /// @dev If true, on-chain normalize() is sufficient. If false, use ENSIP-15 off-chain.
    function isAsciiLabel(string calldata label) public pure returns (bool) {
        bytes memory b = bytes(label);
        for (uint256 i; i < b.length; ++i) {
            if (uint8(b[i]) > 127) return false;
        }
        return true;
    }

    /*//////////////////////////////////////////////////////////////
                            FEE MANAGEMENT
    //////////////////////////////////////////////////////////////*/

    function getFee(uint256 length) public view returns (uint256) {
        return lengthFeeSet[length] ? lengthFees[length] : defaultFee;
    }

    function getPremium(uint256 tokenId) public view returns (uint256) {
        NameRecord storage record = records[tokenId];
        if (bytes(record.label).length == 0 || record.parent != 0) return 0;
        if (maxPremium == 0 || premiumDecayPeriod == 0) return 0;

        uint256 gracePeriodEnd = record.expiresAt + GRACE_PERIOD;
        if (block.timestamp <= gracePeriodEnd) return 0;

        uint256 elapsed = block.timestamp - gracePeriodEnd;
        if (elapsed >= premiumDecayPeriod) return 0;

        return maxPremium * (premiumDecayPeriod - elapsed) / premiumDecayPeriod;
    }

    /*//////////////////////////////////////////////////////////////
                            ADMIN FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    function setDefaultFee(uint256 fee) public onlyOwner {
        defaultFee = fee;
        emit DefaultFeeChanged(fee);
    }

    function setLengthFees(uint256[] calldata lengths, uint256[] calldata fees) public onlyOwner {
        if (lengths.length != fees.length) revert LengthMismatch();
        for (uint256 i; i < lengths.length; ++i) {
            lengthFees[lengths[i]] = fees[i];
            lengthFeeSet[lengths[i]] = true;
            emit LengthFeeChanged(lengths[i], fees[i]);
        }
    }

    function clearLengthFee(uint256 length) public onlyOwner {
        delete lengthFees[length];
        delete lengthFeeSet[length];
        emit LengthFeeCleared(length);
    }

    function setPremiumSettings(uint256 _maxPremium, uint256 _decayPeriod) public onlyOwner {
        if (_maxPremium > MAX_PREMIUM_CAP) revert PremiumTooHigh();
        if (_decayPeriod > MAX_DECAY_PERIOD) revert DecayPeriodTooLong();
        maxPremium = _maxPremium;
        premiumDecayPeriod = _decayPeriod;
        emit PremiumSettingsChanged(_maxPremium, _decayPeriod);
    }

    function withdraw() public onlyOwner nonReentrant {
        SafeTransferLib.safeTransferAllETH(msg.sender);
    }

    /*//////////////////////////////////////////////////////////////
                          INTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    function _register(string memory label, uint256 parentId, address to)
        internal
        returns (uint256 tokenId)
    {
        bytes memory normalized = _validateAndNormalize(bytes(label));
        bytes32 parentNode = parentId == 0 ? WEI_NODE : bytes32(parentId);
        tokenId = uint256(keccak256(abi.encodePacked(parentNode, keccak256(normalized))));

        // Invariant: subdomain registration requires parent ownership
        if (parentId != 0) {
            if (ownerOf(parentId) != msg.sender) revert NotParentOwner();
            if (_getDepth(parentId) >= MAX_SUBDOMAIN_DEPTH) revert TooDeep();
        }

        NameRecord storage existing = records[tokenId];
        uint64 newEpoch = 1;

        if (bytes(existing.label).length > 0) {
            if (parentId == 0) {
                // Top-level: must be expired past grace
                if (block.timestamp <= existing.expiresAt + GRACE_PERIOD) {
                    revert AlreadyRegistered();
                }
            }
            // Subdomain overwrites: parent owner can always reclaim (checked above)
            // Stale subdomains can also be overwritten by new parent owner

            newEpoch = existing.epoch + 1;
            address oldOwner = ownerOf(tokenId); // Safe: _burn allows burning inactive tokens
            _burn(tokenId);
            if (primaryName[oldOwner] == tokenId) delete primaryName[oldOwner];
            recordVersion[tokenId]++;
        }

        records[tokenId] = NameRecord({
            label: string(normalized),
            parent: parentId,
            expiresAt: parentId == 0 ? uint64(block.timestamp + REGISTRATION_PERIOD) : 0,
            epoch: newEpoch,
            parentEpoch: parentId == 0 ? 0 : records[parentId].epoch
        });

        _safeMint(to, tokenId);

        emit NameRegistered(tokenId, string(normalized), to, records[tokenId].expiresAt);
        if (parentId != 0) emit SubdomainRegistered(tokenId, parentId, string(normalized));
    }

    /// @notice Validates UTF-8 encoding and lowercases ASCII. Unicode normalization should be done off-chain.
    /// @dev Validates UTF-8 structure (rejects invalid sequences, overlong encodings, surrogates).
    ///      Only ASCII A-Z is lowercased. For full Unicode normalization, use ENSIP-15 off-chain.
    function _validateAndNormalize(bytes memory b) internal pure returns (bytes memory) {
        if (b.length < MIN_LABEL_LENGTH || b.length > MAX_LABEL_LENGTH) revert InvalidLength();

        bytes memory result = new bytes(b.length);
        uint256 i;

        while (i < b.length) {
            uint8 cb = uint8(b[i]);

            // Reject control characters (0x00-0x1F), space (0x20), dot (0x2E), and DEL (0x7F)
            if (cb <= 0x20 || cb == 0x7f || cb == 0x2e) revert InvalidName();

            if (cb < 0x80) {
                // ASCII: lowercase A-Z
                if (cb >= 0x41 && cb <= 0x5a) {
                    result[i] = bytes1(cb + 32);
                } else {
                    result[i] = b[i];
                }
                i++;
            } else if (cb < 0xC2) {
                // 0x80-0xC1: invalid (continuation bytes or overlong)
                revert InvalidName();
            } else if (cb < 0xE0) {
                // 2-byte sequence: 0xC2-0xDF followed by 1 continuation byte
                if (i + 1 >= b.length) revert InvalidName();
                if (uint8(b[i + 1]) < 0x80 || uint8(b[i + 1]) > 0xBF) revert InvalidName();
                result[i] = b[i];
                result[i + 1] = b[i + 1];
                i += 2;
            } else if (cb < 0xF0) {
                // 3-byte sequence: 0xE0-0xEF followed by 2 continuation bytes
                if (i + 2 >= b.length) revert InvalidName();
                uint8 b1 = uint8(b[i + 1]);
                uint8 b2 = uint8(b[i + 2]);
                // Check continuation bytes are valid
                if (b1 < 0x80 || b1 > 0xBF || b2 < 0x80 || b2 > 0xBF) revert InvalidName();
                // Reject overlong (0xE0 must be followed by 0xA0-0xBF)
                if (cb == 0xE0 && b1 < 0xA0) revert InvalidName();
                // Reject surrogates (0xED followed by 0xA0-0xBF = U+D800-U+DFFF)
                if (cb == 0xED && b1 >= 0xA0) revert InvalidName();
                result[i] = b[i];
                result[i + 1] = b[i + 1];
                result[i + 2] = b[i + 2];
                i += 3;
            } else if (cb < 0xF5) {
                // 4-byte sequence: 0xF0-0xF4 followed by 3 continuation bytes
                if (i + 3 >= b.length) revert InvalidName();
                uint8 b1 = uint8(b[i + 1]);
                uint8 b2 = uint8(b[i + 2]);
                uint8 b3 = uint8(b[i + 3]);
                // Check continuation bytes are valid
                if (b1 < 0x80 || b1 > 0xBF || b2 < 0x80 || b2 > 0xBF || b3 < 0x80 || b3 > 0xBF) {
                    revert InvalidName();
                }
                // Reject overlong (0xF0 must be followed by 0x90-0xBF)
                if (cb == 0xF0 && b1 < 0x90) revert InvalidName();
                // Reject above U+10FFFF (0xF4 must be followed by 0x80-0x8F)
                if (cb == 0xF4 && b1 > 0x8F) revert InvalidName();
                result[i] = b[i];
                result[i + 1] = b[i + 1];
                result[i + 2] = b[i + 2];
                result[i + 3] = b[i + 3];
                i += 4;
            } else {
                // 0xF5-0xFF: invalid
                revert InvalidName();
            }
        }

        // Hyphen rules: can't start or end with hyphen
        if (result[0] == 0x2d || result[b.length - 1] == 0x2d) revert InvalidName();

        return result;
    }

    function _toLowerSlice(bytes memory b, uint256 start, uint256 end)
        internal
        pure
        returns (bytes memory)
    {
        unchecked {
            uint256 len = end - start;
            bytes memory result = new bytes(len);
            for (uint256 i; i < len; ++i) {
                bytes1 c = b[start + i];
                result[i] = (c >= 0x41 && c <= 0x5a) ? bytes1(uint8(c) + 32) : c;
            }
            return result;
        }
    }

    /// @dev Truncate string to maxBytes, ensuring we don't cut in the middle of a UTF-8 character
    function _truncateUTF8(string memory str, uint256 maxBytes)
        internal
        pure
        returns (string memory)
    {
        bytes memory b = bytes(str);
        if (b.length <= maxBytes) return str;

        // Find safe cut point - step back over UTF-8 continuation bytes (0x80-0xBF)
        // This ensures we don't cut in the middle of a multi-byte character
        uint256 cutPoint = maxBytes;
        while (cutPoint > 0 && uint8(b[cutPoint]) >= 0x80 && uint8(b[cutPoint]) <= 0xBF) {
            unchecked {
                --cutPoint;
            }
        }
        // cutPoint is now at either:
        // - An ASCII byte (will be included as it's a complete character)
        // - A multi-byte start byte (won't be included since we copy 0..cutPoint-1)

        bytes memory result = new bytes(cutPoint);
        for (uint256 i; i < cutPoint; ++i) {
            result[i] = b[i];
        }
        return string(result);
    }

    function _recordExists(uint256 tokenId) internal view returns (bool) {
        return bytes(records[tokenId].label).length > 0;
    }

    function _getDepth(uint256 tokenId) internal view returns (uint256 depth) {
        uint256 current = tokenId;
        while (current != 0) {
            uint256 parent = records[current].parent;
            if (parent == 0) break;
            depth++;
            if (depth > MAX_SUBDOMAIN_DEPTH) return depth;
            current = parent;
        }
    }

    function _isActive(uint256 tokenId) internal view returns (bool) {
        return _isActiveWithDepth(tokenId, 0);
    }

    function _isActiveWithDepth(uint256 tokenId, uint256 depth) internal view returns (bool) {
        if (depth > MAX_SUBDOMAIN_DEPTH) return false;
        NameRecord storage record = records[tokenId];
        if (bytes(record.label).length == 0) return false;

        if (record.parent != 0) {
            if (record.parentEpoch != records[record.parent].epoch) return false;
            return _isActiveWithDepth(record.parent, depth + 1);
        }
        // ENS-like: active only until expiresAt (not through grace)
        // Grace period is for renewal only, not transfers/resolver writes
        return block.timestamp <= record.expiresAt;
    }

    function _buildFullName(uint256 tokenId) internal view returns (string memory) {
        return _buildFullNameWithDepth(tokenId, 0);
    }

    function _buildFullNameWithDepth(uint256 tokenId, uint256 depth)
        internal
        view
        returns (string memory)
    {
        if (tokenId == 0 || depth > MAX_SUBDOMAIN_DEPTH) return "";
        NameRecord storage record = records[tokenId];
        if (bytes(record.label).length == 0) return "";

        if (record.parent != 0 && record.parentEpoch != records[record.parent].epoch) return "";
        if (record.parent == 0) return record.label;

        string memory parentName = _buildFullNameWithDepth(record.parent, depth + 1);
        if (bytes(parentName).length == 0) return "";
        return string.concat(record.label, ".", parentName);
    }

    function _generateSVG(string memory displayName) internal pure returns (string memory) {
        return string.concat(
            '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><rect width="400" height="400" fill="#fff"/><text x="200" y="200" font-family="sans-serif" font-size="24" text-anchor="middle" dominant-baseline="middle">',
            _escapeXML(displayName),
            "</text></svg>"
        );
    }

    /// @dev Escape JSON special characters for safe metadata embedding
    function _escapeJSON(string memory input) internal pure returns (string memory) {
        bytes memory b = bytes(input);

        // First pass: count output length
        uint256 outLen;
        unchecked {
            for (uint256 i; i < b.length; ++i) {
                bytes1 c = b[i];
                if (c == 0x22 || c == 0x5c) {
                    outLen += 2;
                } else if (c == 0x0a || c == 0x0d || c == 0x09) {
                    outLen += 2;
                } else if (uint8(c) >= 0x20) {
                    outLen += 1;
                }
            }
        }

        if (outLen == b.length) return input;

        bytes memory result = new bytes(outLen);
        uint256 j;

        unchecked {
            for (uint256 i; i < b.length; ++i) {
                bytes1 c = b[i];
                if (c == 0x22) {
                    result[j++] = "\\";
                    result[j++] = '"';
                } else if (c == 0x5c) {
                    result[j++] = "\\";
                    result[j++] = "\\";
                } else if (c == 0x0a) {
                    result[j++] = "\\";
                    result[j++] = "n";
                } else if (c == 0x0d) {
                    result[j++] = "\\";
                    result[j++] = "r";
                } else if (c == 0x09) {
                    result[j++] = "\\";
                    result[j++] = "t";
                } else if (uint8(c) >= 0x20) {
                    result[j++] = c;
                }
            }
        }

        return string(result);
    }

    /// @dev Escape XML special characters for safe SVG embedding
    function _escapeXML(string memory input) internal pure returns (string memory) {
        bytes memory b = bytes(input);

        // Count how much extra space we need
        uint256 extraLen;
        unchecked {
            for (uint256 i; i < b.length; ++i) {
                bytes1 c = b[i];
                if (c == 0x26) extraLen += 4;
                else if (c == 0x3c) extraLen += 3;
                else if (c == 0x3e) extraLen += 3;
                else if (c == 0x22) extraLen += 5;
                else if (c == 0x27) extraLen += 5;
            }
        }

        if (extraLen == 0) return input;

        bytes memory result = new bytes(b.length + extraLen);
        uint256 j;

        unchecked {
            for (uint256 i; i < b.length; ++i) {
                bytes1 c = b[i];
                if (c == 0x26) {
                    result[j++] = "&";
                    result[j++] = "a";
                    result[j++] = "m";
                    result[j++] = "p";
                    result[j++] = ";";
                } else if (c == 0x3c) {
                    result[j++] = "&";
                    result[j++] = "l";
                    result[j++] = "t";
                    result[j++] = ";";
                } else if (c == 0x3e) {
                    result[j++] = "&";
                    result[j++] = "g";
                    result[j++] = "t";
                    result[j++] = ";";
                } else if (c == 0x22) {
                    result[j++] = "&";
                    result[j++] = "q";
                    result[j++] = "u";
                    result[j++] = "o";
                    result[j++] = "t";
                    result[j++] = ";";
                } else if (c == 0x27) {
                    result[j++] = "&";
                    result[j++] = "a";
                    result[j++] = "p";
                    result[j++] = "o";
                    result[j++] = "s";
                    result[j++] = ";";
                } else {
                    result[j++] = c;
                }
            }
        }

        return string(result);
    }
}

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

/// @notice Library to encode strings in Base64.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/Base64.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Base64.sol)
/// @author Modified from (https://github.com/Brechtpd/base64/blob/main/base64.sol) by Brecht Devos - <[email protected]>.
library Base64 {
    /// @dev Encodes `data` using the base64 encoding described in RFC 4648.
    /// See: https://datatracker.ietf.org/doc/html/rfc4648
    /// @param fileSafe  Whether to replace '+' with '-' and '/' with '_'.
    /// @param noPadding Whether to strip away the padding.
    function encode(bytes memory data, bool fileSafe, bool noPadding)
        internal
        pure
        returns (string memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let dataLength := mload(data)

            if dataLength {
                // Multiply by 4/3 rounded up.
                // The `shl(2, ...)` is equivalent to multiplying by 4.
                let encodedLength := shl(2, div(add(dataLength, 2), 3))

                // Set `result` to point to the start of the free memory.
                result := mload(0x40)

                // Store the table into the scratch space.
                // Offsetted by -1 byte so that the `mload` will load the character.
                // We will rewrite the free memory pointer at `0x40` later with
                // the allocated size.
                // The magic constant 0x0670 will turn "-_" into "+/".
                mstore(0x1f, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef")
                mstore(0x3f, xor("ghijklmnopqrstuvwxyz0123456789-_", mul(iszero(fileSafe), 0x0670)))

                // Skip the first slot, which stores the length.
                let ptr := add(result, 0x20)
                let end := add(ptr, encodedLength)

                let dataEnd := add(add(0x20, data), dataLength)
                let dataEndValue := mload(dataEnd) // Cache the value at the `dataEnd` slot.
                mstore(dataEnd, 0x00) // Zeroize the `dataEnd` slot to clear dirty bits.

                // Run over the input, 3 bytes at a time.
                for {} 1 {} {
                    data := add(data, 3) // Advance 3 bytes.
                    let input := mload(data)

                    // Write 4 bytes. Optimized for fewer stack operations.
                    mstore8(0, mload(and(shr(18, input), 0x3F)))
                    mstore8(1, mload(and(shr(12, input), 0x3F)))
                    mstore8(2, mload(and(shr(6, input), 0x3F)))
                    mstore8(3, mload(and(input, 0x3F)))
                    mstore(ptr, mload(0x00))

                    ptr := add(ptr, 4) // Advance 4 bytes.
                    if iszero(lt(ptr, end)) { break }
                }
                mstore(dataEnd, dataEndValue) // Restore the cached value at `dataEnd`.
                mstore(0x40, add(end, 0x20)) // Allocate the memory.
                // Equivalent to `o = [0, 2, 1][dataLength % 3]`.
                let o := div(2, mod(dataLength, 3))
                // Offset `ptr` and pad with '='. We can simply write over the end.
                mstore(sub(ptr, o), shl(240, 0x3d3d))
                // Set `o` to zero if there is padding.
                o := mul(iszero(iszero(noPadding)), o)
                mstore(sub(ptr, o), 0) // Zeroize the slot after the string.
                mstore(result, sub(encodedLength, o)) // Store the length.
            }
        }
    }

    /// @dev Encodes `data` using the base64 encoding described in RFC 4648.
    /// Equivalent to `encode(data, false, false)`.
    function encode(bytes memory data) internal pure returns (string memory result) {
        result = encode(data, false, false);
    }

    /// @dev Encodes `data` using the base64 encoding described in RFC 4648.
    /// Equivalent to `encode(data, fileSafe, false)`.
    function encode(bytes memory data, bool fileSafe)
        internal
        pure
        returns (string memory result)
    {
        result = encode(data, fileSafe, false);
    }

    /// @dev Decodes base64 encoded `data`.
    ///
    /// Supports:
    /// - RFC 4648 (both standard and file-safe mode).
    /// - RFC 3501 (63: ',').
    ///
    /// Does not support:
    /// - Line breaks.
    ///
    /// Note: For performance reasons,
    /// this function will NOT revert on invalid `data` inputs.
    /// Outputs for invalid inputs will simply be undefined behaviour.
    /// It is the user's responsibility to ensure that the `data`
    /// is a valid base64 encoded string.
    function decode(string memory data) internal pure returns (bytes memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            let dataLength := mload(data)

            if dataLength {
                let decodedLength := mul(shr(2, dataLength), 3)

                for {} 1 {} {
                    // If padded.
                    if iszero(and(dataLength, 3)) {
                        let t := xor(mload(add(data, dataLength)), 0x3d3d)
                        // forgefmt: disable-next-item
                        decodedLength := sub(
                            decodedLength,
                            add(iszero(byte(30, t)), iszero(byte(31, t)))
                        )
                        break
                    }
                    // If non-padded.
                    decodedLength := add(decodedLength, sub(and(dataLength, 3), 1))
                    break
                }
                result := mload(0x40)

                // Write the length of the bytes.
                mstore(result, decodedLength)

                // Skip the first slot, which stores the length.
                let ptr := add(result, 0x20)
                let end := add(ptr, decodedLength)

                // Load the table into the scratch space.
                // Constants are optimized for smaller bytecode with zero gas overhead.
                // `m` also doubles as the mask of the upper 6 bits.
                let m := 0xfc000000fc00686c7074787c8084888c9094989ca0a4a8acb0b4b8bcc0c4c8cc
                mstore(0x5b, m)
                mstore(0x3b, 0x04080c1014181c2024282c3034383c4044484c5054585c6064)
                mstore(0x1a, 0xf8fcf800fcd0d4d8dce0e4e8ecf0f4)

                for {} 1 {} {
                    // Read 4 bytes.
                    data := add(data, 4)
                    let input := mload(data)

                    // Write 3 bytes.
                    // forgefmt: disable-next-item
                    mstore(ptr, or(
                        and(m, mload(byte(28, input))),
                        shr(6, or(
                            and(m, mload(byte(29, input))),
                            shr(6, or(
                                and(m, mload(byte(30, input))),
                                shr(6, mload(byte(31, input)))
                            ))
                        ))
                    ))
                    ptr := add(ptr, 3)
                    if iszero(lt(ptr, end)) { break }
                }
                mstore(0x40, add(end, 0x20)) // Allocate the memory.
                mstore(end, 0) // Zeroize the slot after the bytes.
                mstore(0x60, 0) // Restore the zero slot.
            }
        }
    }
}

File 3 of 8 : ERC721.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Simple ERC721 implementation with storage hitchhiking.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC721.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC721/ERC721.sol)
///
/// @dev Note:
/// - The ERC721 standard allows for self-approvals.
///   For performance, this implementation WILL NOT revert for such actions.
///   Please add any checks with overrides if desired.
/// - For performance, methods are made payable where permitted by the ERC721 standard.
/// - The `safeTransfer` functions use the identity precompile (0x4)
///   to copy memory internally.
///
/// If you are overriding:
/// - NEVER violate the ERC721 invariant:
///   the balance of an owner MUST always be equal to their number of ownership slots.
///   The transfer functions do not have an underflow guard for user token balances.
/// - Make sure all variables written to storage are properly cleaned
///   (e.g. the bool value for `isApprovedForAll` MUST be either 1 or 0 under the hood).
/// - Check that the overridden function is actually used in the function you want to
///   change the behavior of. Much of the code has been manually inlined for performance.
abstract contract ERC721 {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev An account can hold up to 4294967295 tokens.
    uint256 internal constant _MAX_ACCOUNT_BALANCE = 0xffffffff;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Only the token owner or an approved account can manage the token.
    error NotOwnerNorApproved();

    /// @dev The token does not exist.
    error TokenDoesNotExist();

    /// @dev The token already exists.
    error TokenAlreadyExists();

    /// @dev Cannot query the balance for the zero address.
    error BalanceQueryForZeroAddress();

    /// @dev Cannot mint or transfer to the zero address.
    error TransferToZeroAddress();

    /// @dev The token must be owned by `from`.
    error TransferFromIncorrectOwner();

    /// @dev The recipient's balance has overflowed.
    error AccountBalanceOverflow();

    /// @dev Cannot safely transfer to a contract that does not implement
    /// the ERC721Receiver interface.
    error TransferToNonERC721ReceiverImplementer();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           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 `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;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                          STORAGE                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The ownership data slot of `id` is given by:
    /// ```
    ///     mstore(0x00, id)
    ///     mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
    ///     let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
    /// ```
    /// Bits Layout:
    /// - [0..159]   `addr`
    /// - [160..255] `extraData`
    ///
    /// The approved address slot is given by: `add(1, ownershipSlot)`.
    ///
    /// See: https://notes.ethereum.org/%40vbuterin/verkle_tree_eip
    ///
    /// The balance slot of `owner` is given by:
    /// ```
    ///     mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
    ///     mstore(0x00, owner)
    ///     let balanceSlot := keccak256(0x0c, 0x1c)
    /// ```
    /// Bits Layout:
    /// - [0..31]   `balance`
    /// - [32..255] `aux`
    ///
    /// The `operator` approval slot of `owner` is given by:
    /// ```
    ///     mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, operator))
    ///     mstore(0x00, owner)
    ///     let operatorApprovalSlot := keccak256(0x0c, 0x30)
    /// ```
    uint256 private constant _ERC721_MASTER_SLOT_SEED = 0x7d8825530a5a2e7a << 192;

    /// @dev Pre-shifted and pre-masked constant.
    uint256 private constant _ERC721_MASTER_SLOT_SEED_MASKED = 0x0a5a2e7a00000000;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      ERC721 METADATA                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

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

    /// @dev Returns the token collection symbol.
    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);

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           ERC721                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns the owner of token `id`.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function ownerOf(uint256 id) public view virtual returns (address result) {
        result = _ownerOf(id);
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(result) {
                mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Returns the number of tokens owned by `owner`.
    ///
    /// Requirements:
    /// - `owner` must not be the zero address.
    function balanceOf(address owner) public view virtual returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            // Revert if the `owner` is the zero address.
            if iszero(owner) {
                mstore(0x00, 0x8f4eb604) // `BalanceQueryForZeroAddress()`.
                revert(0x1c, 0x04)
            }
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            mstore(0x00, owner)
            result := and(sload(keccak256(0x0c, 0x1c)), _MAX_ACCOUNT_BALANCE)
        }
    }

    /// @dev Returns the account approved to manage token `id`.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function getApproved(uint256 id) public view virtual returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            if iszero(shl(96, sload(ownershipSlot))) {
                mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`.
                revert(0x1c, 0x04)
            }
            result := sload(add(1, ownershipSlot))
        }
    }

    /// @dev Sets `account` as the approved account to manage token `id`.
    ///
    /// 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 account, uint256 id) public payable virtual {
        _approve(msg.sender, account, id);
    }

    /// @dev Returns whether `operator` is approved to manage the tokens of `owner`.
    function isApprovedForAll(address owner, address operator)
        public
        view
        virtual
        returns (bool result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x1c, operator)
            mstore(0x08, _ERC721_MASTER_SLOT_SEED_MASKED)
            mstore(0x00, owner)
            result := sload(keccak256(0x0c, 0x30))
        }
    }

    /// @dev Sets whether `operator` is approved to manage the tokens of the caller.
    ///
    /// Emits an {ApprovalForAll} event.
    function setApprovalForAll(address operator, bool isApproved) public virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // Convert to 0 or 1.
            isApproved := iszero(iszero(isApproved))
            // Update the `isApproved` for (`msg.sender`, `operator`).
            mstore(0x1c, operator)
            mstore(0x08, _ERC721_MASTER_SLOT_SEED_MASKED)
            mstore(0x00, caller())
            sstore(keccak256(0x0c, 0x30), isApproved)
            // Emit the {ApprovalForAll} event.
            mstore(0x00, isApproved)
            // forgefmt: disable-next-item
            log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), shr(96, shl(96, operator)))
        }
    }

    /// @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 {
        _beforeTokenTransfer(from, to, id);
        /// @solidity memory-safe-assembly
        assembly {
            // Clear the upper 96 bits.
            let bitmaskAddress := shr(96, not(0))
            from := and(bitmaskAddress, from)
            to := and(bitmaskAddress, to)
            // Load the ownership data.
            mstore(0x00, id)
            mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, caller()))
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            let ownershipPacked := sload(ownershipSlot)
            let owner := and(bitmaskAddress, ownershipPacked)
            // Revert if the token does not exist, or if `from` is not the owner.
            if iszero(mul(owner, eq(owner, from))) {
                // `TokenDoesNotExist()`, `TransferFromIncorrectOwner()`.
                mstore(shl(2, iszero(owner)), 0xceea21b6a1148100)
                revert(0x1c, 0x04)
            }
            // Load, check, and update the token approval.
            {
                mstore(0x00, from)
                let approvedAddress := sload(add(1, ownershipSlot))
                // Revert if the caller is not the owner, nor approved.
                if iszero(or(eq(caller(), from), eq(caller(), approvedAddress))) {
                    if iszero(sload(keccak256(0x0c, 0x30))) {
                        mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
                        revert(0x1c, 0x04)
                    }
                }
                // Delete the approved address if any.
                if approvedAddress { sstore(add(1, ownershipSlot), 0) }
            }
            // Update with the new owner.
            sstore(ownershipSlot, xor(ownershipPacked, xor(from, to)))
            // Decrement the balance of `from`.
            {
                let fromBalanceSlot := keccak256(0x0c, 0x1c)
                sstore(fromBalanceSlot, sub(sload(fromBalanceSlot), 1))
            }
            // Increment the balance of `to`.
            {
                mstore(0x00, to)
                let toBalanceSlot := keccak256(0x0c, 0x1c)
                let toBalanceSlotPacked := add(sload(toBalanceSlot), 1)
                // Revert if `to` is the zero address, or if the account balance overflows.
                if iszero(mul(to, and(toBalanceSlotPacked, _MAX_ACCOUNT_BALANCE))) {
                    // `TransferToZeroAddress()`, `AccountBalanceOverflow()`.
                    mstore(shl(2, iszero(to)), 0xea553b3401336cea)
                    revert(0x1c, 0x04)
                }
                sstore(toBalanceSlot, toBalanceSlotPacked)
            }
            // Emit the {Transfer} event.
            log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)
        }
        _afterTokenTransfer(from, to, id);
    }

    /// @dev Equivalent to `safeTransferFrom(from, to, id, "")`.
    function safeTransferFrom(address from, address to, uint256 id) public payable virtual {
        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
    {
        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))
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  INTERNAL QUERY FUNCTIONS                  */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns if token `id` exists.
    function _exists(uint256 id) internal view virtual returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            result := iszero(iszero(shl(96, sload(add(id, add(id, keccak256(0x00, 0x20)))))))
        }
    }

    /// @dev Returns the owner of token `id`.
    /// Returns the zero address instead of reverting if the token does not exist.
    function _ownerOf(uint256 id) internal view virtual returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            result := shr(96, shl(96, sload(add(id, add(id, keccak256(0x00, 0x20))))))
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*            INTERNAL DATA HITCHHIKING FUNCTIONS             */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    // For performance, no events are emitted for the hitchhiking setters.
    // Please emit your own events if required.

    /// @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 (uint224 result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            mstore(0x00, owner)
            result := shr(32, sload(keccak256(0x0c, 0x1c)))
        }
    }

    /// @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, uint224 value) internal virtual {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            mstore(0x00, owner)
            let balanceSlot := keccak256(0x0c, 0x1c)
            let packed := sload(balanceSlot)
            sstore(balanceSlot, xor(packed, shl(32, xor(value, shr(32, packed)))))
        }
    }

    /// @dev Returns the extra data for token `id`.
    /// Minting, transferring, burning a token will not change the extra data.
    /// The extra data can be set on a non-existent token.
    function _getExtraData(uint256 id) internal view virtual returns (uint96 result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            result := shr(160, sload(add(id, add(id, keccak256(0x00, 0x20)))))
        }
    }

    /// @dev Sets the extra data for token `id` to `value`.
    /// Minting, transferring, burning a token will not change the extra data.
    /// The extra data can be set on a non-existent token.
    function _setExtraData(uint256 id, uint96 value) internal virtual {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            let packed := sload(ownershipSlot)
            sstore(ownershipSlot, xor(packed, shl(160, xor(value, shr(160, packed)))))
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  INTERNAL MINT FUNCTIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Mints token `id` to `to`.
    ///
    /// Requirements:
    ///
    /// - Token `id` must not exist.
    /// - `to` cannot be the zero address.
    ///
    /// Emits a {Transfer} event.
    function _mint(address to, uint256 id) internal virtual {
        _beforeTokenTransfer(address(0), to, id);
        /// @solidity memory-safe-assembly
        assembly {
            // Clear the upper 96 bits.
            to := shr(96, shl(96, to))
            // Load the ownership data.
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            let ownershipPacked := sload(ownershipSlot)
            // Revert if the token already exists.
            if shl(96, ownershipPacked) {
                mstore(0x00, 0xc991cbb1) // `TokenAlreadyExists()`.
                revert(0x1c, 0x04)
            }
            // Update with the owner.
            sstore(ownershipSlot, or(ownershipPacked, to))
            // Increment the balance of the owner.
            {
                mstore(0x00, to)
                let balanceSlot := keccak256(0x0c, 0x1c)
                let balanceSlotPacked := add(sload(balanceSlot), 1)
                // Revert if `to` is the zero address, or if the account balance overflows.
                if iszero(mul(to, and(balanceSlotPacked, _MAX_ACCOUNT_BALANCE))) {
                    // `TransferToZeroAddress()`, `AccountBalanceOverflow()`.
                    mstore(shl(2, iszero(to)), 0xea553b3401336cea)
                    revert(0x1c, 0x04)
                }
                sstore(balanceSlot, balanceSlotPacked)
            }
            // Emit the {Transfer} event.
            log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, 0, to, id)
        }
        _afterTokenTransfer(address(0), to, id);
    }

    /// @dev Mints token `id` to `to`, and updates the extra data for token `id` to `value`.
    /// Does NOT check if token `id` already exists (assumes `id` is auto-incrementing).
    ///
    /// Requirements:
    ///
    /// - `to` cannot be the zero address.
    ///
    /// Emits a {Transfer} event.
    function _mintAndSetExtraDataUnchecked(address to, uint256 id, uint96 value) internal virtual {
        _beforeTokenTransfer(address(0), to, id);
        /// @solidity memory-safe-assembly
        assembly {
            // Clear the upper 96 bits.
            to := shr(96, shl(96, to))
            // Update with the owner and extra data.
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            sstore(add(id, add(id, keccak256(0x00, 0x20))), or(shl(160, value), to))
            // Increment the balance of the owner.
            {
                mstore(0x00, to)
                let balanceSlot := keccak256(0x0c, 0x1c)
                let balanceSlotPacked := add(sload(balanceSlot), 1)
                // Revert if `to` is the zero address, or if the account balance overflows.
                if iszero(mul(to, and(balanceSlotPacked, _MAX_ACCOUNT_BALANCE))) {
                    // `TransferToZeroAddress()`, `AccountBalanceOverflow()`.
                    mstore(shl(2, iszero(to)), 0xea553b3401336cea)
                    revert(0x1c, 0x04)
                }
                sstore(balanceSlot, balanceSlotPacked)
            }
            // Emit the {Transfer} event.
            log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, 0, to, id)
        }
        _afterTokenTransfer(address(0), to, id);
    }

    /// @dev Equivalent to `_safeMint(to, id, "")`.
    function _safeMint(address to, uint256 id) internal virtual {
        _safeMint(to, id, "");
    }

    /// @dev Mints token `id` to `to`.
    ///
    /// Requirements:
    ///
    /// - Token `id` must not exist.
    /// - `to` cannot be the zero address.
    /// - If `to` refers to a smart contract, it must implement
    ///   {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
    ///
    /// Emits a {Transfer} event.
    function _safeMint(address to, uint256 id, bytes memory data) internal virtual {
        _mint(to, id);
        if (_hasCode(to)) _checkOnERC721Received(address(0), to, id, data);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  INTERNAL BURN FUNCTIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Equivalent to `_burn(address(0), id)`.
    function _burn(uint256 id) internal virtual {
        _burn(address(0), id);
    }

    /// @dev Destroys token `id`, using `by`.
    ///
    /// Requirements:
    ///
    /// - Token `id` must exist.
    /// - If `by` is not the zero address,
    ///   it must be the owner of the token, or be approved to manage the token.
    ///
    /// Emits a {Transfer} event.
    function _burn(address by, uint256 id) internal virtual {
        address owner = ownerOf(id);
        _beforeTokenTransfer(owner, address(0), id);
        /// @solidity memory-safe-assembly
        assembly {
            // Clear the upper 96 bits.
            by := shr(96, shl(96, by))
            // Load the ownership data.
            mstore(0x00, id)
            mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, by))
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            let ownershipPacked := sload(ownershipSlot)
            // Reload the owner in case it is changed in `_beforeTokenTransfer`.
            owner := shr(96, shl(96, ownershipPacked))
            // Revert if the token does not exist.
            if iszero(owner) {
                mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`.
                revert(0x1c, 0x04)
            }
            // Load and check the token approval.
            {
                mstore(0x00, owner)
                let approvedAddress := sload(add(1, ownershipSlot))
                // If `by` is not the zero address, do the authorization check.
                // Revert if the `by` is not the owner, nor approved.
                if iszero(or(iszero(by), or(eq(by, owner), eq(by, approvedAddress)))) {
                    if iszero(sload(keccak256(0x0c, 0x30))) {
                        mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
                        revert(0x1c, 0x04)
                    }
                }
                // Delete the approved address if any.
                if approvedAddress { sstore(add(1, ownershipSlot), 0) }
            }
            // Clear the owner.
            sstore(ownershipSlot, xor(ownershipPacked, owner))
            // Decrement the balance of `owner`.
            {
                let balanceSlot := keccak256(0x0c, 0x1c)
                sstore(balanceSlot, sub(sload(balanceSlot), 1))
            }
            // Emit the {Transfer} event.
            log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, owner, 0, id)
        }
        _afterTokenTransfer(owner, address(0), id);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                INTERNAL APPROVAL FUNCTIONS                 */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns whether `account` is the owner of token `id`, or is approved to manage it.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function _isApprovedOrOwner(address account, uint256 id)
        internal
        view
        virtual
        returns (bool result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            // Clear the upper 96 bits.
            account := shr(96, shl(96, account))
            // Load the ownership data.
            mstore(0x00, id)
            mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, account))
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            let owner := shr(96, shl(96, sload(ownershipSlot)))
            // Revert if the token does not exist.
            if iszero(owner) {
                mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`.
                revert(0x1c, 0x04)
            }
            // Check if `account` is the `owner`.
            if iszero(eq(account, owner)) {
                mstore(0x00, owner)
                // Check if `account` is approved to manage the token.
                if iszero(sload(keccak256(0x0c, 0x30))) {
                    result := eq(account, sload(add(1, ownershipSlot)))
                }
            }
        }
    }

    /// @dev Returns the account approved to manage token `id`.
    /// Returns the zero address instead of reverting if the token does not exist.
    function _getApproved(uint256 id) internal view virtual returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, id)
            mstore(0x1c, _ERC721_MASTER_SLOT_SEED)
            result := sload(add(1, add(id, add(id, keccak256(0x00, 0x20)))))
        }
    }

    /// @dev Equivalent to `_approve(address(0), account, id)`.
    function _approve(address account, uint256 id) internal virtual {
        _approve(address(0), account, id);
    }

    /// @dev Sets `account` as the approved account to manage token `id`, using `by`.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    /// - If `by` is not the zero address, `by` must be the owner
    ///   or an approved operator for the token owner.
    ///
    /// Emits a {Approval} event.
    function _approve(address by, address account, uint256 id) internal virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // Clear the upper 96 bits.
            let bitmaskAddress := shr(96, not(0))
            account := and(bitmaskAddress, account)
            by := and(bitmaskAddress, by)
            // Load the owner of the token.
            mstore(0x00, id)
            mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, by))
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            let owner := and(bitmaskAddress, sload(ownershipSlot))
            // Revert if the token does not exist.
            if iszero(owner) {
                mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`.
                revert(0x1c, 0x04)
            }
            // If `by` is not the zero address, do the authorization check.
            // Revert if `by` is not the owner, nor approved.
            if iszero(or(iszero(by), eq(by, owner))) {
                mstore(0x00, owner)
                if iszero(sload(keccak256(0x0c, 0x30))) {
                    mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
                    revert(0x1c, 0x04)
                }
            }
            // Sets `account` as the approved account to manage `id`.
            sstore(add(1, ownershipSlot), account)
            // Emit the {Approval} event.
            log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, owner, account, id)
        }
    }

    /// @dev Approve or remove the `operator` as an operator for `by`,
    /// without authorization checks.
    ///
    /// Emits an {ApprovalForAll} event.
    function _setApprovalForAll(address by, address operator, bool isApproved) internal virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // Clear the upper 96 bits.
            by := shr(96, shl(96, by))
            operator := shr(96, shl(96, operator))
            // Convert to 0 or 1.
            isApproved := iszero(iszero(isApproved))
            // Update the `isApproved` for (`by`, `operator`).
            mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, operator))
            mstore(0x00, by)
            sstore(keccak256(0x0c, 0x30), isApproved)
            // Emit the {ApprovalForAll} event.
            mstore(0x00, isApproved)
            log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, by, operator)
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                INTERNAL TRANSFER FUNCTIONS                 */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Equivalent to `_transfer(address(0), from, to, id)`.
    function _transfer(address from, address to, uint256 id) internal virtual {
        _transfer(address(0), 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.
    /// - If `by` is not the zero address,
    ///   it must be the owner of the token, or be approved to manage the token.
    ///
    /// Emits a {Transfer} event.
    function _transfer(address by, address from, address to, uint256 id) internal virtual {
        _beforeTokenTransfer(from, to, id);
        /// @solidity memory-safe-assembly
        assembly {
            // Clear the upper 96 bits.
            let bitmaskAddress := shr(96, not(0))
            from := and(bitmaskAddress, from)
            to := and(bitmaskAddress, to)
            by := and(bitmaskAddress, by)
            // Load the ownership data.
            mstore(0x00, id)
            mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, by))
            let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20)))
            let ownershipPacked := sload(ownershipSlot)
            let owner := and(bitmaskAddress, ownershipPacked)
            // Revert if the token does not exist, or if `from` is not the owner.
            if iszero(mul(owner, eq(owner, from))) {
                // `TokenDoesNotExist()`, `TransferFromIncorrectOwner()`.
                mstore(shl(2, iszero(owner)), 0xceea21b6a1148100)
                revert(0x1c, 0x04)
            }
            // Load, check, and update the token approval.
            {
                mstore(0x00, from)
                let approvedAddress := sload(add(1, ownershipSlot))
                // If `by` is not the zero address, do the authorization check.
                // Revert if the `by` is not the owner, nor approved.
                if iszero(or(iszero(by), or(eq(by, from), eq(by, approvedAddress)))) {
                    if iszero(sload(keccak256(0x0c, 0x30))) {
                        mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
                        revert(0x1c, 0x04)
                    }
                }
                // Delete the approved address if any.
                if approvedAddress { sstore(add(1, ownershipSlot), 0) }
            }
            // Update with the new owner.
            sstore(ownershipSlot, xor(ownershipPacked, xor(from, to)))
            // Decrement the balance of `from`.
            {
                let fromBalanceSlot := keccak256(0x0c, 0x1c)
                sstore(fromBalanceSlot, sub(sload(fromBalanceSlot), 1))
            }
            // Increment the balance of `to`.
            {
                mstore(0x00, to)
                let toBalanceSlot := keccak256(0x0c, 0x1c)
                let toBalanceSlotPacked := add(sload(toBalanceSlot), 1)
                // Revert if `to` is the zero address, or if the account balance overflows.
                if iszero(mul(to, and(toBalanceSlotPacked, _MAX_ACCOUNT_BALANCE))) {
                    // `TransferToZeroAddress()`, `AccountBalanceOverflow()`.
                    mstore(shl(2, iszero(to)), 0xea553b3401336cea)
                    revert(0x1c, 0x04)
                }
                sstore(toBalanceSlot, toBalanceSlotPacked)
            }
            // Emit the {Transfer} event.
            log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)
        }
        _afterTokenTransfer(from, to, id);
    }

    /// @dev Equivalent to `_safeTransfer(from, to, id, "")`.
    function _safeTransfer(address from, address to, uint256 id) internal virtual {
        _safeTransfer(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 _safeTransfer(address from, address to, uint256 id, bytes memory data)
        internal
        virtual
    {
        _transfer(address(0), from, to, id);
        if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);
    }

    /// @dev Equivalent to `_safeTransfer(by, from, to, id, "")`.
    function _safeTransfer(address by, address from, address to, uint256 id) internal virtual {
        _safeTransfer(by, 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.
    /// - If `by` is not the zero address,
    ///   it 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 _safeTransfer(address by, address from, address to, uint256 id, bytes memory data)
        internal
        virtual
    {
        _transfer(by, from, to, id);
        if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                    HOOKS FOR OVERRIDING                    */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

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

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

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      PRIVATE HELPERS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

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

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

/// @notice Simple single owner authorization mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)
///
/// @dev Note:
/// This implementation does NOT auto-initialize the owner to `msg.sender`.
/// You MUST call the `_initializeOwner` in the constructor / initializer.
///
/// While the ownable portion follows
/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,
/// the nomenclature for the 2-step ownership handover may be unique to this codebase.
abstract contract Ownable {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The caller is not authorized to call the function.
    error Unauthorized();

    /// @dev The `newOwner` cannot be the zero address.
    error NewOwnerIsZeroAddress();

    /// @dev The `pendingOwner` does not have a valid handover request.
    error NoHandoverRequest();

    /// @dev Cannot double-initialize.
    error AlreadyInitialized();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           EVENTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The ownership is transferred from `oldOwner` to `newOwner`.
    /// This event is intentionally kept the same as OpenZeppelin's Ownable to be
    /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),
    /// despite it not being as lightweight as a single argument event.
    event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);

    /// @dev An ownership handover to `pendingOwner` has been requested.
    event OwnershipHandoverRequested(address indexed pendingOwner);

    /// @dev The ownership handover to `pendingOwner` has been canceled.
    event OwnershipHandoverCanceled(address indexed pendingOwner);

    /// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`.
    uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =
        0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;

    /// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`.
    uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =
        0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;

    /// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`.
    uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =
        0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                          STORAGE                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The owner slot is given by:
    /// `bytes32(~uint256(uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))))`.
    /// It is intentionally chosen to be a high value
    /// to avoid collision with lower slots.
    /// The choice of manual storage layout is to enable compatibility
    /// with both regular and upgradeable contracts.
    bytes32 internal constant _OWNER_SLOT =
        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;

    /// The ownership handover slot of `newOwner` is given by:
    /// ```
    ///     mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))
    ///     let handoverSlot := keccak256(0x00, 0x20)
    /// ```
    /// It stores the expiry timestamp of the two-step ownership handover.
    uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                     INTERNAL FUNCTIONS                     */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Override to return true to make `_initializeOwner` prevent double-initialization.
    function _guardInitializeOwner() internal pure virtual returns (bool guard) {}

    /// @dev Initializes the owner directly without authorization guard.
    /// This function must be called upon initialization,
    /// regardless of whether the contract is upgradeable or not.
    /// This is to enable generalization to both regular and upgradeable contracts,
    /// and to save gas in case the initial owner is not the caller.
    /// For performance reasons, this function will not check if there
    /// is an existing owner.
    function _initializeOwner(address newOwner) internal virtual {
        if (_guardInitializeOwner()) {
            /// @solidity memory-safe-assembly
            assembly {
                let ownerSlot := _OWNER_SLOT
                if sload(ownerSlot) {
                    mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.
                    revert(0x1c, 0x04)
                }
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Store the new value.
                sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
            }
        } else {
            /// @solidity memory-safe-assembly
            assembly {
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Store the new value.
                sstore(_OWNER_SLOT, newOwner)
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
            }
        }
    }

    /// @dev Sets the owner directly without authorization guard.
    function _setOwner(address newOwner) internal virtual {
        if (_guardInitializeOwner()) {
            /// @solidity memory-safe-assembly
            assembly {
                let ownerSlot := _OWNER_SLOT
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
                // Store the new value.
                sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
            }
        } else {
            /// @solidity memory-safe-assembly
            assembly {
                let ownerSlot := _OWNER_SLOT
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
                // Store the new value.
                sstore(ownerSlot, newOwner)
            }
        }
    }

    /// @dev Throws if the sender is not the owner.
    function _checkOwner() internal view virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // If the caller is not the stored owner, revert.
            if iszero(eq(caller(), sload(_OWNER_SLOT))) {
                mstore(0x00, 0x82b42900) // `Unauthorized()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Returns how long a two-step ownership handover is valid for in seconds.
    /// Override to return a different value if needed.
    /// Made internal to conserve bytecode. Wrap it in a public function if needed.
    function _ownershipHandoverValidFor() internal view virtual returns (uint64) {
        return 48 * 3600;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  PUBLIC UPDATE FUNCTIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Allows the owner to transfer the ownership to `newOwner`.
    function transferOwnership(address newOwner) public payable virtual onlyOwner {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(shl(96, newOwner)) {
                mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.
                revert(0x1c, 0x04)
            }
        }
        _setOwner(newOwner);
    }

    /// @dev Allows the owner to renounce their ownership.
    function renounceOwnership() public payable virtual onlyOwner {
        _setOwner(address(0));
    }

    /// @dev Request a two-step ownership handover to the caller.
    /// The request will automatically expire in 48 hours (172800 seconds) by default.
    function requestOwnershipHandover() public payable virtual {
        unchecked {
            uint256 expires = block.timestamp + _ownershipHandoverValidFor();
            /// @solidity memory-safe-assembly
            assembly {
                // Compute and set the handover slot to `expires`.
                mstore(0x0c, _HANDOVER_SLOT_SEED)
                mstore(0x00, caller())
                sstore(keccak256(0x0c, 0x20), expires)
                // Emit the {OwnershipHandoverRequested} event.
                log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())
            }
        }
    }

    /// @dev Cancels the two-step ownership handover to the caller, if any.
    function cancelOwnershipHandover() public payable virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute and set the handover slot to 0.
            mstore(0x0c, _HANDOVER_SLOT_SEED)
            mstore(0x00, caller())
            sstore(keccak256(0x0c, 0x20), 0)
            // Emit the {OwnershipHandoverCanceled} event.
            log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())
        }
    }

    /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.
    /// Reverts if there is no existing ownership handover requested by `pendingOwner`.
    function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute and set the handover slot to 0.
            mstore(0x0c, _HANDOVER_SLOT_SEED)
            mstore(0x00, pendingOwner)
            let handoverSlot := keccak256(0x0c, 0x20)
            // If the handover does not exist, or has expired.
            if gt(timestamp(), sload(handoverSlot)) {
                mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.
                revert(0x1c, 0x04)
            }
            // Set the handover slot to 0.
            sstore(handoverSlot, 0)
        }
        _setOwner(pendingOwner);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   PUBLIC READ FUNCTIONS                    */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns the owner of the contract.
    function owner() public view virtual returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := sload(_OWNER_SLOT)
        }
    }

    /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.
    function ownershipHandoverExpiresAt(address pendingOwner)
        public
        view
        virtual
        returns (uint256 result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute the handover slot.
            mstore(0x0c, _HANDOVER_SLOT_SEED)
            mstore(0x00, pendingOwner)
            // Load the handover slot.
            result := sload(keccak256(0x0c, 0x20))
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         MODIFIERS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Marks a function as only callable by the owner.
    modifier onlyOwner() virtual {
        _checkOwner();
        _;
    }
}

File 5 of 8 : LibString.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

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

/// @notice Library for converting numbers into strings and other string operations.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibString.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol)
///
/// @dev Note:
/// For performance and bytecode compactness, most of the string operations are restricted to
/// byte strings (7-bit ASCII), except where otherwise specified.
/// Usage of byte string operations on charsets with runes spanning two or more bytes
/// can lead to undefined behavior.
library LibString {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                          STRUCTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Goated string storage struct that totally MOGs, no cap, fr.
    /// Uses less gas and bytecode than Solidity's native string storage. It's meta af.
    /// Packs length with the first 31 bytes if <255 bytes, so it’s mad tight.
    struct StringStorage {
        bytes32 _spacer;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                        CUSTOM ERRORS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The length of the output is too small to contain all the hex digits.
    error HexLengthInsufficient();

    /// @dev The length of the string is more than 32 bytes.
    error TooBigForSmallString();

    /// @dev The input string must be a 7-bit ASCII.
    error StringNot7BitASCII();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The constant returned when the `search` is not found in the string.
    uint256 internal constant NOT_FOUND = type(uint256).max;

    /// @dev Lookup for '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
    uint128 internal constant ALPHANUMERIC_7_BIT_ASCII = 0x7fffffe07fffffe03ff000000000000;

    /// @dev Lookup for 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
    uint128 internal constant LETTERS_7_BIT_ASCII = 0x7fffffe07fffffe0000000000000000;

    /// @dev Lookup for 'abcdefghijklmnopqrstuvwxyz'.
    uint128 internal constant LOWERCASE_7_BIT_ASCII = 0x7fffffe000000000000000000000000;

    /// @dev Lookup for 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
    uint128 internal constant UPPERCASE_7_BIT_ASCII = 0x7fffffe0000000000000000;

    /// @dev Lookup for '0123456789'.
    uint128 internal constant DIGITS_7_BIT_ASCII = 0x3ff000000000000;

    /// @dev Lookup for '0123456789abcdefABCDEF'.
    uint128 internal constant HEXDIGITS_7_BIT_ASCII = 0x7e0000007e03ff000000000000;

    /// @dev Lookup for '01234567'.
    uint128 internal constant OCTDIGITS_7_BIT_ASCII = 0xff000000000000;

    /// @dev Lookup for '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'.
    uint128 internal constant PRINTABLE_7_BIT_ASCII = 0x7fffffffffffffffffffffff00003e00;

    /// @dev Lookup for '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.
    uint128 internal constant PUNCTUATION_7_BIT_ASCII = 0x78000001f8000001fc00fffe00000000;

    /// @dev Lookup for ' \t\n\r\x0b\x0c'.
    uint128 internal constant WHITESPACE_7_BIT_ASCII = 0x100003e00;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                 STRING STORAGE OPERATIONS                  */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Sets the value of the string storage `$` to `s`.
    function set(StringStorage storage $, string memory s) internal {
        LibBytes.set(bytesStorage($), bytes(s));
    }

    /// @dev Sets the value of the string storage `$` to `s`.
    function setCalldata(StringStorage storage $, string calldata s) internal {
        LibBytes.setCalldata(bytesStorage($), bytes(s));
    }

    /// @dev Sets the value of the string storage `$` to the empty string.
    function clear(StringStorage storage $) internal {
        delete $._spacer;
    }

    /// @dev Returns whether the value stored is `$` is the empty string "".
    function isEmpty(StringStorage storage $) internal view returns (bool) {
        return uint256($._spacer) & 0xff == uint256(0);
    }

    /// @dev Returns the length of the value stored in `$`.
    function length(StringStorage storage $) internal view returns (uint256) {
        return LibBytes.length(bytesStorage($));
    }

    /// @dev Returns the value stored in `$`.
    function get(StringStorage storage $) internal view returns (string memory) {
        return string(LibBytes.get(bytesStorage($)));
    }

    /// @dev Helper to cast `$` to a `BytesStorage`.
    function bytesStorage(StringStorage storage $)
        internal
        pure
        returns (LibBytes.BytesStorage storage casted)
    {
        /// @solidity memory-safe-assembly
        assembly {
            casted.slot := $.slot
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                     DECIMAL OPERATIONS                     */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns the base 10 decimal representation of `value`.
    function toString(uint256 value) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but
            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
            // We will need 1 word for the trailing zeros padding, 1 word for the length,
            // and 3 words for a maximum of 78 digits.
            result := add(mload(0x40), 0x80)
            mstore(0x40, add(result, 0x20)) // Allocate memory.
            mstore(result, 0) // Zeroize the slot after the string.

            let end := result // Cache the end of the memory to calculate the length later.
            let w := not(0) // Tsk.
            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            for { let temp := value } 1 {} {
                result := add(result, w) // `sub(result, 1)`.
                // Store the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(result, add(48, mod(temp, 10)))
                temp := div(temp, 10) // Keep dividing `temp` until zero.
                if iszero(temp) { break }
            }
            let n := sub(end, result)
            result := sub(result, 0x20) // Move the pointer 32 bytes back to make room for the length.
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the base 10 decimal representation of `value`.
    function toString(int256 value) internal pure returns (string memory result) {
        if (value >= 0) return toString(uint256(value));
        unchecked {
            result = toString(~uint256(value) + 1);
        }
        /// @solidity memory-safe-assembly
        assembly {
            // We still have some spare memory space on the left,
            // as we have allocated 3 words (96 bytes) for up to 78 digits.
            let n := mload(result) // Load the string length.
            mstore(result, 0x2d) // Store the '-' character.
            result := sub(result, 1) // Move back the string pointer by a byte.
            mstore(result, add(n, 1)) // Update the string length.
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   HEXADECIMAL OPERATIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns the hexadecimal representation of `value`,
    /// left-padded to an input length of `byteCount` bytes.
    /// The output is prefixed with "0x" encoded using 2 hexadecimal digits per byte,
    /// giving a total length of `byteCount * 2 + 2` bytes.
    /// Reverts if `byteCount` is too small for the output to contain all the digits.
    function toHexString(uint256 value, uint256 byteCount)
        internal
        pure
        returns (string memory result)
    {
        result = toHexStringNoPrefix(value, byteCount);
        /// @solidity memory-safe-assembly
        assembly {
            let n := add(mload(result), 2) // Compute the length.
            mstore(result, 0x3078) // Store the "0x" prefix.
            result := sub(result, 2) // Move the pointer.
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the hexadecimal representation of `value`,
    /// left-padded to an input length of `byteCount` bytes.
    /// The output is not prefixed with "0x" and is encoded using 2 hexadecimal digits per byte,
    /// giving a total length of `byteCount * 2` bytes.
    /// Reverts if `byteCount` is too small for the output to contain all the digits.
    function toHexStringNoPrefix(uint256 value, uint256 byteCount)
        internal
        pure
        returns (string memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            // We need 0x20 bytes for the trailing zeros padding, `byteCount * 2` bytes
            // for the digits, 0x02 bytes for the prefix, and 0x20 bytes for the length.
            // We add 0x20 to the total and round down to a multiple of 0x20.
            // (0x20 + 0x20 + 0x02 + 0x20) = 0x62.
            result := add(mload(0x40), and(add(shl(1, byteCount), 0x42), not(0x1f)))
            mstore(0x40, add(result, 0x20)) // Allocate memory.
            mstore(result, 0) // Zeroize the slot after the string.

            let end := result // Cache the end to calculate the length later.
            // Store "0123456789abcdef" in scratch space.
            mstore(0x0f, 0x30313233343536373839616263646566)

            let start := sub(result, add(byteCount, byteCount))
            let w := not(1) // Tsk.
            let temp := value
            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            for {} 1 {} {
                result := add(result, w) // `sub(result, 2)`.
                mstore8(add(result, 1), mload(and(temp, 15)))
                mstore8(result, mload(and(shr(4, temp), 15)))
                temp := shr(8, temp)
                if iszero(xor(result, start)) { break }
            }
            if temp {
                mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`.
                revert(0x1c, 0x04)
            }
            let n := sub(end, result)
            result := sub(result, 0x20)
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the hexadecimal representation of `value`.
    /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte.
    /// As address are 20 bytes long, the output will left-padded to have
    /// a length of `20 * 2 + 2` bytes.
    function toHexString(uint256 value) internal pure returns (string memory result) {
        result = toHexStringNoPrefix(value);
        /// @solidity memory-safe-assembly
        assembly {
            let n := add(mload(result), 2) // Compute the length.
            mstore(result, 0x3078) // Store the "0x" prefix.
            result := sub(result, 2) // Move the pointer.
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the hexadecimal representation of `value`.
    /// The output is prefixed with "0x".
    /// The output excludes leading "0" from the `toHexString` output.
    /// `0x00: "0x0", 0x01: "0x1", 0x12: "0x12", 0x123: "0x123"`.
    function toMinimalHexString(uint256 value) internal pure returns (string memory result) {
        result = toHexStringNoPrefix(value);
        /// @solidity memory-safe-assembly
        assembly {
            let o := eq(byte(0, mload(add(result, 0x20))), 0x30) // Whether leading zero is present.
            let n := add(mload(result), 2) // Compute the length.
            mstore(add(result, o), 0x3078) // Store the "0x" prefix, accounting for leading zero.
            result := sub(add(result, o), 2) // Move the pointer, accounting for leading zero.
            mstore(result, sub(n, o)) // Store the length, accounting for leading zero.
        }
    }

    /// @dev Returns the hexadecimal representation of `value`.
    /// The output excludes leading "0" from the `toHexStringNoPrefix` output.
    /// `0x00: "0", 0x01: "1", 0x12: "12", 0x123: "123"`.
    function toMinimalHexStringNoPrefix(uint256 value)
        internal
        pure
        returns (string memory result)
    {
        result = toHexStringNoPrefix(value);
        /// @solidity memory-safe-assembly
        assembly {
            let o := eq(byte(0, mload(add(result, 0x20))), 0x30) // Whether leading zero is present.
            let n := mload(result) // Get the length.
            result := add(result, o) // Move the pointer, accounting for leading zero.
            mstore(result, sub(n, o)) // Store the length, accounting for leading zero.
        }
    }

    /// @dev Returns the hexadecimal representation of `value`.
    /// The output is encoded using 2 hexadecimal digits per byte.
    /// As address are 20 bytes long, the output will left-padded to have
    /// a length of `20 * 2` bytes.
    function toHexStringNoPrefix(uint256 value) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,
            // 0x02 bytes for the prefix, and 0x40 bytes for the digits.
            // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0.
            result := add(mload(0x40), 0x80)
            mstore(0x40, add(result, 0x20)) // Allocate memory.
            mstore(result, 0) // Zeroize the slot after the string.

            let end := result // Cache the end to calculate the length later.
            mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup.

            let w := not(1) // Tsk.
            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            for { let temp := value } 1 {} {
                result := add(result, w) // `sub(result, 2)`.
                mstore8(add(result, 1), mload(and(temp, 15)))
                mstore8(result, mload(and(shr(4, temp), 15)))
                temp := shr(8, temp)
                if iszero(temp) { break }
            }
            let n := sub(end, result)
            result := sub(result, 0x20)
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the hexadecimal representation of `value`.
    /// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte,
    /// and the alphabets are capitalized conditionally according to
    /// https://eips.ethereum.org/EIPS/eip-55
    function toHexStringChecksummed(address value) internal pure returns (string memory result) {
        result = toHexString(value);
        /// @solidity memory-safe-assembly
        assembly {
            let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...`
            let o := add(result, 0x22)
            let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... `
            let t := shl(240, 136) // `0b10001000 << 240`
            for { let i := 0 } 1 {} {
                mstore(add(i, i), mul(t, byte(i, hashed)))
                i := add(i, 1)
                if eq(i, 20) { break }
            }
            mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask)))))
            o := add(o, 0x20)
            mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask)))))
        }
    }

    /// @dev Returns the hexadecimal representation of `value`.
    /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte.
    function toHexString(address value) internal pure returns (string memory result) {
        result = toHexStringNoPrefix(value);
        /// @solidity memory-safe-assembly
        assembly {
            let n := add(mload(result), 2) // Compute the length.
            mstore(result, 0x3078) // Store the "0x" prefix.
            result := sub(result, 2) // Move the pointer.
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the hexadecimal representation of `value`.
    /// The output is encoded using 2 hexadecimal digits per byte.
    function toHexStringNoPrefix(address value) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            // Allocate memory.
            // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,
            // 0x02 bytes for the prefix, and 0x28 bytes for the digits.
            // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80.
            mstore(0x40, add(result, 0x80))
            mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup.

            result := add(result, 2)
            mstore(result, 40) // Store the length.
            let o := add(result, 0x20)
            mstore(add(o, 40), 0) // Zeroize the slot after the string.
            value := shl(96, value)
            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            for { let i := 0 } 1 {} {
                let p := add(o, add(i, i))
                let temp := byte(i, value)
                mstore8(add(p, 1), mload(and(temp, 15)))
                mstore8(p, mload(shr(4, temp)))
                i := add(i, 1)
                if eq(i, 20) { break }
            }
        }
    }

    /// @dev Returns the hex encoded string from the raw bytes.
    /// The output is encoded using 2 hexadecimal digits per byte.
    function toHexString(bytes memory raw) internal pure returns (string memory result) {
        result = toHexStringNoPrefix(raw);
        /// @solidity memory-safe-assembly
        assembly {
            let n := add(mload(result), 2) // Compute the length.
            mstore(result, 0x3078) // Store the "0x" prefix.
            result := sub(result, 2) // Move the pointer.
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the hex encoded string from the raw bytes.
    /// The output is encoded using 2 hexadecimal digits per byte.
    function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            let n := mload(raw)
            result := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix.
            mstore(result, add(n, n)) // Store the length of the output.

            mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup.
            let o := add(result, 0x20)
            let end := add(raw, n)
            for {} iszero(eq(raw, end)) {} {
                raw := add(raw, 1)
                mstore8(add(o, 1), mload(and(mload(raw), 15)))
                mstore8(o, mload(and(shr(4, mload(raw)), 15)))
                o := add(o, 2)
            }
            mstore(o, 0) // Zeroize the slot after the string.
            mstore(0x40, add(o, 0x20)) // Allocate memory.
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   RUNE STRING OPERATIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns the number of UTF characters in the string.
    function runeCount(string memory s) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            if mload(s) {
                mstore(0x00, div(not(0), 255))
                mstore(0x20, 0x0202020202020202020202020202020202020202020202020303030304040506)
                let o := add(s, 0x20)
                let end := add(o, mload(s))
                for { result := 1 } 1 { result := add(result, 1) } {
                    o := add(o, byte(0, mload(shr(250, mload(o)))))
                    if iszero(lt(o, end)) { break }
                }
            }
        }
    }

    /// @dev Returns if this string is a 7-bit ASCII string.
    /// (i.e. all characters codes are in [0..127])
    function is7BitASCII(string memory s) internal pure returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            let mask := shl(7, div(not(0), 255))
            let n := mload(s)
            if n {
                let o := add(s, 0x20)
                let end := add(o, n)
                let last := mload(end)
                mstore(end, 0)
                for {} 1 {} {
                    if and(mask, mload(o)) {
                        result := 0
                        break
                    }
                    o := add(o, 0x20)
                    if iszero(lt(o, end)) { break }
                }
                mstore(end, last)
            }
        }
    }

    /// @dev Returns if this string is a 7-bit ASCII string,
    /// AND all characters are in the `allowed` lookup.
    /// Note: If `s` is empty, returns true regardless of `allowed`.
    function is7BitASCII(string memory s, uint128 allowed) internal pure returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            if mload(s) {
                let allowed_ := shr(128, shl(128, allowed))
                let o := add(s, 0x20)
                for { let end := add(o, mload(s)) } 1 {} {
                    result := and(result, shr(byte(0, mload(o)), allowed_))
                    o := add(o, 1)
                    if iszero(and(result, lt(o, end))) { break }
                }
            }
        }
    }

    /// @dev Converts the bytes in the 7-bit ASCII string `s` to
    /// an allowed lookup for use in `is7BitASCII(s, allowed)`.
    /// To save runtime gas, you can cache the result in an immutable variable.
    function to7BitASCIIAllowedLookup(string memory s) internal pure returns (uint128 result) {
        /// @solidity memory-safe-assembly
        assembly {
            if mload(s) {
                let o := add(s, 0x20)
                for { let end := add(o, mload(s)) } 1 {} {
                    result := or(result, shl(byte(0, mload(o)), 1))
                    o := add(o, 1)
                    if iszero(lt(o, end)) { break }
                }
                if shr(128, result) {
                    mstore(0x00, 0xc9807e0d) // `StringNot7BitASCII()`.
                    revert(0x1c, 0x04)
                }
            }
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   BYTE STRING OPERATIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    // For performance and bytecode compactness, byte string operations are restricted
    // to 7-bit ASCII strings. All offsets are byte offsets, not UTF character offsets.
    // Usage of byte string operations on charsets with runes spanning two or more bytes
    // can lead to undefined behavior.

    /// @dev Returns `subject` all occurrences of `needle` replaced with `replacement`.
    function replace(string memory subject, string memory needle, string memory replacement)
        internal
        pure
        returns (string memory)
    {
        return string(LibBytes.replace(bytes(subject), bytes(needle), bytes(replacement)));
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from left to right, starting from `from`.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function indexOf(string memory subject, string memory needle, uint256 from)
        internal
        pure
        returns (uint256)
    {
        return LibBytes.indexOf(bytes(subject), bytes(needle), from);
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from left to right.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function indexOf(string memory subject, string memory needle) internal pure returns (uint256) {
        return LibBytes.indexOf(bytes(subject), bytes(needle), 0);
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from right to left, starting from `from`.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function lastIndexOf(string memory subject, string memory needle, uint256 from)
        internal
        pure
        returns (uint256)
    {
        return LibBytes.lastIndexOf(bytes(subject), bytes(needle), from);
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from right to left.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function lastIndexOf(string memory subject, string memory needle)
        internal
        pure
        returns (uint256)
    {
        return LibBytes.lastIndexOf(bytes(subject), bytes(needle), type(uint256).max);
    }

    /// @dev Returns true if `needle` is found in `subject`, false otherwise.
    function contains(string memory subject, string memory needle) internal pure returns (bool) {
        return LibBytes.contains(bytes(subject), bytes(needle));
    }

    /// @dev Returns whether `subject` starts with `needle`.
    function startsWith(string memory subject, string memory needle) internal pure returns (bool) {
        return LibBytes.startsWith(bytes(subject), bytes(needle));
    }

    /// @dev Returns whether `subject` ends with `needle`.
    function endsWith(string memory subject, string memory needle) internal pure returns (bool) {
        return LibBytes.endsWith(bytes(subject), bytes(needle));
    }

    /// @dev Returns `subject` repeated `times`.
    function repeat(string memory subject, uint256 times) internal pure returns (string memory) {
        return string(LibBytes.repeat(bytes(subject), times));
    }

    /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).
    /// `start` and `end` are byte offsets.
    function slice(string memory subject, uint256 start, uint256 end)
        internal
        pure
        returns (string memory)
    {
        return string(LibBytes.slice(bytes(subject), start, end));
    }

    /// @dev Returns a copy of `subject` sliced from `start` to the end of the string.
    /// `start` is a byte offset.
    function slice(string memory subject, uint256 start) internal pure returns (string memory) {
        return string(LibBytes.slice(bytes(subject), start, type(uint256).max));
    }

    /// @dev Returns all the indices of `needle` in `subject`.
    /// The indices are byte offsets.
    function indicesOf(string memory subject, string memory needle)
        internal
        pure
        returns (uint256[] memory)
    {
        return LibBytes.indicesOf(bytes(subject), bytes(needle));
    }

    /// @dev Returns a arrays of strings based on the `delimiter` inside of the `subject` string.
    function split(string memory subject, string memory delimiter)
        internal
        pure
        returns (string[] memory result)
    {
        bytes[] memory a = LibBytes.split(bytes(subject), bytes(delimiter));
        /// @solidity memory-safe-assembly
        assembly {
            result := a
        }
    }

    /// @dev Returns a concatenated string of `a` and `b`.
    /// Cheaper than `string.concat()` and does not de-align the free memory pointer.
    function concat(string memory a, string memory b) internal pure returns (string memory) {
        return string(LibBytes.concat(bytes(a), bytes(b)));
    }

    /// @dev Returns a copy of the string in either lowercase or UPPERCASE.
    /// WARNING! This function is only compatible with 7-bit ASCII strings.
    function toCase(string memory subject, bool toUpper)
        internal
        pure
        returns (string memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let n := mload(subject)
            if n {
                result := mload(0x40)
                let o := add(result, 0x20)
                let d := sub(subject, result)
                let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff)
                for { let end := add(o, n) } 1 {} {
                    let b := byte(0, mload(add(d, o)))
                    mstore8(o, xor(and(shr(b, flags), 0x20), b))
                    o := add(o, 1)
                    if eq(o, end) { break }
                }
                mstore(result, n) // Store the length.
                mstore(o, 0) // Zeroize the slot after the string.
                mstore(0x40, add(o, 0x20)) // Allocate memory.
            }
        }
    }

    /// @dev Returns a string from a small bytes32 string.
    /// `s` must be null-terminated, or behavior will be undefined.
    function fromSmallString(bytes32 s) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            let n := 0
            for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\0'.
            mstore(result, n) // Store the length.
            let o := add(result, 0x20)
            mstore(o, s) // Store the bytes of the string.
            mstore(add(o, n), 0) // Zeroize the slot after the string.
            mstore(0x40, add(result, 0x40)) // Allocate memory.
        }
    }

    /// @dev Returns the small string, with all bytes after the first null byte zeroized.
    function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\0'.
            mstore(0x00, s)
            mstore(result, 0x00)
            result := mload(0x00)
        }
    }

    /// @dev Returns the string as a normalized null-terminated small string.
    function toSmallString(string memory s) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(s)
            if iszero(lt(result, 33)) {
                mstore(0x00, 0xec92f9a3) // `TooBigForSmallString()`.
                revert(0x1c, 0x04)
            }
            result := shl(shl(3, sub(32, result)), mload(add(s, result)))
        }
    }

    /// @dev Returns a lowercased copy of the string.
    /// WARNING! This function is only compatible with 7-bit ASCII strings.
    function lower(string memory subject) internal pure returns (string memory result) {
        result = toCase(subject, false);
    }

    /// @dev Returns an UPPERCASED copy of the string.
    /// WARNING! This function is only compatible with 7-bit ASCII strings.
    function upper(string memory subject) internal pure returns (string memory result) {
        result = toCase(subject, true);
    }

    /// @dev Escapes the string to be used within HTML tags.
    function escapeHTML(string memory s) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            let end := add(s, mload(s))
            let o := add(result, 0x20)
            // Store the bytes of the packed offsets and strides into the scratch space.
            // `packed = (stride << 5) | offset`. Max offset is 20. Max stride is 6.
            mstore(0x1f, 0x900094)
            mstore(0x08, 0xc0000000a6ab)
            // Store "&quot;&amp;&#39;&lt;&gt;" into the scratch space.
            mstore(0x00, shl(64, 0x2671756f743b26616d703b262333393b266c743b2667743b))
            for {} iszero(eq(s, end)) {} {
                s := add(s, 1)
                let c := and(mload(s), 0xff)
                // Not in `["\"","'","&","<",">"]`.
                if iszero(and(shl(c, 1), 0x500000c400000000)) {
                    mstore8(o, c)
                    o := add(o, 1)
                    continue
                }
                let t := shr(248, mload(c))
                mstore(o, mload(and(t, 0x1f)))
                o := add(o, shr(5, t))
            }
            mstore(o, 0) // Zeroize the slot after the string.
            mstore(result, sub(o, add(result, 0x20))) // Store the length.
            mstore(0x40, add(o, 0x20)) // Allocate memory.
        }
    }

    /// @dev Escapes the string to be used within double-quotes in a JSON.
    /// If `addDoubleQuotes` is true, the result will be enclosed in double-quotes.
    function escapeJSON(string memory s, bool addDoubleQuotes)
        internal
        pure
        returns (string memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            let o := add(result, 0x20)
            if addDoubleQuotes {
                mstore8(o, 34)
                o := add(1, o)
            }
            // Store "\\u0000" in scratch space.
            // Store "0123456789abcdef" in scratch space.
            // Also, store `{0x08:"b", 0x09:"t", 0x0a:"n", 0x0c:"f", 0x0d:"r"}`.
            // into the scratch space.
            mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672)
            // Bitmask for detecting `["\"","\\"]`.
            let e := or(shl(0x22, 1), shl(0x5c, 1))
            for { let end := add(s, mload(s)) } iszero(eq(s, end)) {} {
                s := add(s, 1)
                let c := and(mload(s), 0xff)
                if iszero(lt(c, 0x20)) {
                    if iszero(and(shl(c, 1), e)) {
                        // Not in `["\"","\\"]`.
                        mstore8(o, c)
                        o := add(o, 1)
                        continue
                    }
                    mstore8(o, 0x5c) // "\\".
                    mstore8(add(o, 1), c)
                    o := add(o, 2)
                    continue
                }
                if iszero(and(shl(c, 1), 0x3700)) {
                    // Not in `["\b","\t","\n","\f","\d"]`.
                    mstore8(0x1d, mload(shr(4, c))) // Hex value.
                    mstore8(0x1e, mload(and(c, 15))) // Hex value.
                    mstore(o, mload(0x19)) // "\\u00XX".
                    o := add(o, 6)
                    continue
                }
                mstore8(o, 0x5c) // "\\".
                mstore8(add(o, 1), mload(add(c, 8)))
                o := add(o, 2)
            }
            if addDoubleQuotes {
                mstore8(o, 34)
                o := add(1, o)
            }
            mstore(o, 0) // Zeroize the slot after the string.
            mstore(result, sub(o, add(result, 0x20))) // Store the length.
            mstore(0x40, add(o, 0x20)) // Allocate memory.
        }
    }

    /// @dev Escapes the string to be used within double-quotes in a JSON.
    function escapeJSON(string memory s) internal pure returns (string memory result) {
        result = escapeJSON(s, false);
    }

    /// @dev Encodes `s` so that it can be safely used in a URI,
    /// just like `encodeURIComponent` in JavaScript.
    /// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
    /// See: https://datatracker.ietf.org/doc/html/rfc2396
    /// See: https://datatracker.ietf.org/doc/html/rfc3986
    function encodeURIComponent(string memory s) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            // Store "0123456789ABCDEF" in scratch space.
            // Uppercased to be consistent with JavaScript's implementation.
            mstore(0x0f, 0x30313233343536373839414243444546)
            let o := add(result, 0x20)
            for { let end := add(s, mload(s)) } iszero(eq(s, end)) {} {
                s := add(s, 1)
                let c := and(mload(s), 0xff)
                // If not in `[0-9A-Z-a-z-_.!~*'()]`.
                if iszero(and(1, shr(c, 0x47fffffe87fffffe03ff678200000000))) {
                    mstore8(o, 0x25) // '%'.
                    mstore8(add(o, 1), mload(and(shr(4, c), 15)))
                    mstore8(add(o, 2), mload(and(c, 15)))
                    o := add(o, 3)
                    continue
                }
                mstore8(o, c)
                o := add(o, 1)
            }
            mstore(result, sub(o, add(result, 0x20))) // Store the length.
            mstore(o, 0) // Zeroize the slot after the string.
            mstore(0x40, add(o, 0x20)) // Allocate memory.
        }
    }

    /// @dev Returns whether `a` equals `b`.
    function eq(string memory a, string memory b) internal pure returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))
        }
    }

    /// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small string.
    function eqs(string memory a, bytes32 b) internal pure returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            // These should be evaluated on compile time, as far as possible.
            let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.
            let x := not(or(m, or(b, add(m, and(b, m)))))
            let r := shl(7, iszero(iszero(shr(128, x))))
            r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x))))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(r, shl(3, lt(0xff, shr(r, x))))
            // forgefmt: disable-next-item
            result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),
                xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))
        }
    }

    /// @dev Returns 0 if `a == b`, -1 if `a < b`, +1 if `a > b`.
    /// If `a` == b[:a.length]`, and `a.length < b.length`, returns -1.
    function cmp(string memory a, string memory b) internal pure returns (int256) {
        return LibBytes.cmp(bytes(a), bytes(b));
    }

    /// @dev Packs a single string with its length into a single word.
    /// Returns `bytes32(0)` if the length is zero or greater than 31.
    function packOne(string memory a) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            // We don't need to zero right pad the string,
            // since this is our own custom non-standard packing scheme.
            result :=
                mul(
                    // Load the length and the bytes.
                    mload(add(a, 0x1f)),
                    // `length != 0 && length < 32`. Abuses underflow.
                    // Assumes that the length is valid and within the block gas limit.
                    lt(sub(mload(a), 1), 0x1f)
                )
        }
    }

    /// @dev Unpacks a string packed using {packOne}.
    /// Returns the empty string if `packed` is `bytes32(0)`.
    /// If `packed` is not an output of {packOne}, the output behavior is undefined.
    function unpackOne(bytes32 packed) internal pure returns (string memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40) // Grab the free memory pointer.
            mstore(0x40, add(result, 0x40)) // Allocate 2 words (1 for the length, 1 for the bytes).
            mstore(result, 0) // Zeroize the length slot.
            mstore(add(result, 0x1f), packed) // Store the length and bytes.
            mstore(add(add(result, 0x20), mload(result)), 0) // Right pad with zeroes.
        }
    }

    /// @dev Packs two strings with their lengths into a single word.
    /// Returns `bytes32(0)` if combined length is zero or greater than 30.
    function packTwo(string memory a, string memory b) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            let aLen := mload(a)
            // We don't need to zero right pad the strings,
            // since this is our own custom non-standard packing scheme.
            result :=
                mul(
                    or( // Load the length and the bytes of `a` and `b`.
                    shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), mload(sub(add(b, 0x1e), aLen))),
                    // `totalLen != 0 && totalLen < 31`. Abuses underflow.
                    // Assumes that the lengths are valid and within the block gas limit.
                    lt(sub(add(aLen, mload(b)), 1), 0x1e)
                )
        }
    }

    /// @dev Unpacks strings packed using {packTwo}.
    /// Returns the empty strings if `packed` is `bytes32(0)`.
    /// If `packed` is not an output of {packTwo}, the output behavior is undefined.
    function unpackTwo(bytes32 packed)
        internal
        pure
        returns (string memory resultA, string memory resultB)
    {
        /// @solidity memory-safe-assembly
        assembly {
            resultA := mload(0x40) // Grab the free memory pointer.
            resultB := add(resultA, 0x40)
            // Allocate 2 words for each string (1 for the length, 1 for the byte). Total 4 words.
            mstore(0x40, add(resultB, 0x40))
            // Zeroize the length slots.
            mstore(resultA, 0)
            mstore(resultB, 0)
            // Store the lengths and bytes.
            mstore(add(resultA, 0x1f), packed)
            mstore(add(resultB, 0x1f), mload(add(add(resultA, 0x20), mload(resultA))))
            // Right pad with zeroes.
            mstore(add(add(resultA, 0x20), mload(resultA)), 0)
            mstore(add(add(resultB, 0x20), mload(resultB)), 0)
        }
    }

    /// @dev Directly returns `a` without copying.
    function directReturn(string memory a) internal pure {
        /// @solidity memory-safe-assembly
        assembly {
            // Assumes that the string does not start from the scratch space.
            let retStart := sub(a, 0x20)
            let retUnpaddedSize := add(mload(a), 0x40)
            // Right pad with zeroes. Just in case the string is produced
            // by a method that doesn't zero right pad.
            mstore(add(retStart, retUnpaddedSize), 0)
            mstore(retStart, 0x20) // Store the return offset.
            // End the transaction, returning the string.
            return(retStart, and(not(0x1f), add(0x1f, retUnpaddedSize)))
        }
    }
}

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

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol)
///
/// @dev Note:
/// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection.
library SafeTransferLib {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The ETH transfer has failed.
    error ETHTransferFailed();

    /// @dev The ERC20 `transferFrom` has failed.
    error TransferFromFailed();

    /// @dev The ERC20 `transfer` has failed.
    error TransferFailed();

    /// @dev The ERC20 `approve` has failed.
    error ApproveFailed();

    /// @dev The ERC20 `totalSupply` query has failed.
    error TotalSupplyQueryFailed();

    /// @dev The Permit2 operation has failed.
    error Permit2Failed();

    /// @dev The Permit2 amount must be less than `2**160 - 1`.
    error Permit2AmountOverflow();

    /// @dev The Permit2 approve operation has failed.
    error Permit2ApproveFailed();

    /// @dev The Permit2 lockdown operation has failed.
    error Permit2LockdownFailed();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.
    uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;

    /// @dev Suggested gas stipend for contract receiving ETH to perform a few
    /// storage reads and writes, but low enough to prevent griefing.
    uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;

    /// @dev The unique EIP-712 domain domain separator for the DAI token contract.
    bytes32 internal constant DAI_DOMAIN_SEPARATOR =
        0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;

    /// @dev The address for the WETH9 contract on Ethereum mainnet.
    address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

    /// @dev The canonical Permit2 address.
    /// [Github](https://github.com/Uniswap/permit2)
    /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)
    address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       ETH OPERATIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.
    //
    // The regular variants:
    // - Forwards all remaining gas to the target.
    // - Reverts if the target reverts.
    // - Reverts if the current contract has insufficient balance.
    //
    // The force variants:
    // - Forwards with an optional gas stipend
    //   (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).
    // - If the target reverts, or if the gas stipend is exhausted,
    //   creates a temporary contract to force send the ETH via `SELFDESTRUCT`.
    //   Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.
    // - Reverts if the current contract has insufficient balance.
    //
    // The try variants:
    // - Forwards with a mandatory gas stipend.
    // - Instead of reverting, returns whether the transfer succeeded.

    /// @dev Sends `amount` (in wei) ETH to `to`.
    function safeTransferETH(address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Sends all the ETH in the current contract to `to`.
    function safeTransferAllETH(address to) internal {
        /// @solidity memory-safe-assembly
        assembly {
            // Transfer all the ETH and check if it succeeded or not.
            if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
    function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if lt(selfbalance(), amount) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
            if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.
    function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.
    function forceSafeTransferETH(address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if lt(selfbalance(), amount) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
            if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.
    function forceSafeTransferAllETH(address to) internal {
        /// @solidity memory-safe-assembly
        assembly {
            // forgefmt: disable-next-item
            if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
    function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)
        }
    }

    /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.
    function trySafeTransferAllETH(address to, uint256 gasStipend)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      ERC20 OPERATIONS                      */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
    /// Reverts upon failure.
    ///
    /// The `from` account must have at least `amount` approved for
    /// the current contract to manage.
    function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x60, amount) // Store the `amount` argument.
            mstore(0x40, to) // Store the `to` argument.
            mstore(0x2c, shl(96, from)) // Store the `from` argument.
            mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.
            let success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
            if iszero(and(eq(mload(0x00), 1), success)) {
                if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {
                    mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
                    revert(0x1c, 0x04)
                }
            }
            mstore(0x60, 0) // Restore the zero slot to zero.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
    ///
    /// The `from` account must have at least `amount` approved for the current contract to manage.
    function trySafeTransferFrom(address token, address from, address to, uint256 amount)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x60, amount) // Store the `amount` argument.
            mstore(0x40, to) // Store the `to` argument.
            mstore(0x2c, shl(96, from)) // Store the `from` argument.
            mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.
            success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
            if iszero(and(eq(mload(0x00), 1), success)) {
                success := lt(or(iszero(extcodesize(token)), returndatasize()), success)
            }
            mstore(0x60, 0) // Restore the zero slot to zero.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Sends all of ERC20 `token` from `from` to `to`.
    /// Reverts upon failure.
    ///
    /// The `from` account must have their entire balance approved for the current contract to manage.
    function safeTransferAllFrom(address token, address from, address to)
        internal
        returns (uint256 amount)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x40, to) // Store the `to` argument.
            mstore(0x2c, shl(96, from)) // Store the `from` argument.
            mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`.
            // Read the balance, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    gt(returndatasize(), 0x1f), // At least 32 bytes returned.
                    staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)
                )
            ) {
                mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`.
            amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it.
            // Perform the transfer, reverting upon failure.
            let success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
            if iszero(and(eq(mload(0x00), 1), success)) {
                if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {
                    mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
                    revert(0x1c, 0x04)
                }
            }
            mstore(0x60, 0) // Restore the zero slot to zero.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.
    /// Reverts upon failure.
    function safeTransfer(address token, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, to) // Store the `to` argument.
            mstore(0x34, amount) // Store the `amount` argument.
            mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.
            // Perform the transfer, reverting upon failure.
            let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
            if iszero(and(eq(mload(0x00), 1), success)) {
                if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {
                    mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
                    revert(0x1c, 0x04)
                }
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Sends all of ERC20 `token` from the current contract to `to`.
    /// Reverts upon failure.
    function safeTransferAll(address token, address to) internal returns (uint256 amount) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`.
            mstore(0x20, address()) // Store the address of the current contract.
            // Read the balance, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    gt(returndatasize(), 0x1f), // At least 32 bytes returned.
                    staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)
                )
            ) {
                mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x14, to) // Store the `to` argument.
            amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it.
            mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.
            // Perform the transfer, reverting upon failure.
            let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
            if iszero(and(eq(mload(0x00), 1), success)) {
                if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {
                    mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
                    revert(0x1c, 0x04)
                }
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.
    /// Reverts upon failure.
    function safeApprove(address token, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, to) // Store the `to` argument.
            mstore(0x34, amount) // Store the `amount` argument.
            mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
            let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
            if iszero(and(eq(mload(0x00), 1), success)) {
                if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {
                    mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.
                    revert(0x1c, 0x04)
                }
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.
    /// If the initial attempt to approve fails, attempts to reset the approved amount to zero,
    /// then retries the approval again (some tokens, e.g. USDT, requires this).
    /// Reverts upon failure.
    function safeApproveWithRetry(address token, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, to) // Store the `to` argument.
            mstore(0x34, amount) // Store the `amount` argument.
            mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
            // Perform the approval, retrying upon failure.
            let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
            if iszero(and(eq(mload(0x00), 1), success)) {
                if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {
                    mstore(0x34, 0) // Store 0 for the `amount`.
                    mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
                    pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval.
                    mstore(0x34, amount) // Store back the original `amount`.
                    // Retry the approval, reverting upon failure.
                    success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                    if iszero(and(eq(mload(0x00), 1), success)) {
                        // Check the `extcodesize` again just in case the token selfdestructs lol.
                        if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) {
                            mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.
                            revert(0x1c, 0x04)
                        }
                    }
                }
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Returns the amount of ERC20 `token` owned by `account`.
    /// Returns zero if the `token` does not exist.
    function balanceOf(address token, address account) internal view returns (uint256 amount) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, account) // Store the `account` argument.
            mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.
            amount :=
                mul( // The arguments of `mul` are evaluated from right to left.
                    mload(0x20),
                    and( // The arguments of `and` are evaluated from right to left.
                        gt(returndatasize(), 0x1f), // At least 32 bytes returned.
                        staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)
                    )
                )
        }
    }

    /// @dev Returns the total supply of the `token`.
    /// Reverts if the token does not exist or does not implement `totalSupply()`.
    function totalSupply(address token) internal view returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, 0x18160ddd) // `totalSupply()`.
            if iszero(
                and(gt(returndatasize(), 0x1f), staticcall(gas(), token, 0x1c, 0x04, 0x00, 0x20))
            ) {
                mstore(0x00, 0x54cd9435) // `TotalSupplyQueryFailed()`.
                revert(0x1c, 0x04)
            }
            result := mload(0x00)
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
    /// If the initial attempt fails, try to use Permit2 to transfer the token.
    /// Reverts upon failure.
    ///
    /// The `from` account must have at least `amount` approved for the current contract to manage.
    function safeTransferFrom2(address token, address from, address to, uint256 amount) internal {
        if (!trySafeTransferFrom(token, from, to, amount)) {
            permit2TransferFrom(token, from, to, amount);
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2.
    /// Reverts upon failure.
    function permit2TransferFrom(address token, address from, address to, uint256 amount)
        internal
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(add(m, 0x74), shr(96, shl(96, token)))
            mstore(add(m, 0x54), amount)
            mstore(add(m, 0x34), to)
            mstore(add(m, 0x20), shl(96, from))
            // `transferFrom(address,address,uint160,address)`.
            mstore(m, 0x36c78516000000000000000000000000)
            let p := PERMIT2
            let exists := eq(chainid(), 1)
            if iszero(exists) { exists := iszero(iszero(extcodesize(p))) }
            if iszero(
                and(
                    call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00),
                    lt(iszero(extcodesize(token)), exists) // Token has code and Permit2 exists.
                )
            ) {
                mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.
                revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)
            }
        }
    }

    /// @dev Permit a user to spend a given amount of
    /// another user's tokens via native EIP-2612 permit if possible, falling
    /// back to Permit2 if native permit fails or is not implemented on the token.
    function permit2(
        address token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        bool success;
        /// @solidity memory-safe-assembly
        assembly {
            for {} shl(96, xor(token, WETH9)) {} {
                mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.
                if iszero(
                    and( // The arguments of `and` are evaluated from right to left.
                        lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.
                        // Gas stipend to limit gas burn for tokens that don't refund gas when
                        // an non-existing function is called. 5K should be enough for a SLOAD.
                        staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)
                    )
                ) { break }
                // After here, we can be sure that token is a contract.
                let m := mload(0x40)
                mstore(add(m, 0x34), spender)
                mstore(add(m, 0x20), shl(96, owner))
                mstore(add(m, 0x74), deadline)
                if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {
                    mstore(0x14, owner)
                    mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.
                    mstore(
                        add(m, 0x94),
                        lt(iszero(amount), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))
                    )
                    mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.
                    // `nonces` is already at `add(m, 0x54)`.
                    // `amount != 0` is already stored at `add(m, 0x94)`.
                    mstore(add(m, 0xb4), and(0xff, v))
                    mstore(add(m, 0xd4), r)
                    mstore(add(m, 0xf4), s)
                    success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)
                    break
                }
                mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.
                mstore(add(m, 0x54), amount)
                mstore(add(m, 0x94), and(0xff, v))
                mstore(add(m, 0xb4), r)
                mstore(add(m, 0xd4), s)
                success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)
                break
            }
        }
        if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);
    }

    /// @dev Simple permit on the Permit2 contract.
    function simplePermit2(
        address token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(m, 0x927da105) // `allowance(address,address,address)`.
            {
                let addressMask := shr(96, not(0))
                mstore(add(m, 0x20), and(addressMask, owner))
                mstore(add(m, 0x40), and(addressMask, token))
                mstore(add(m, 0x60), and(addressMask, spender))
                mstore(add(m, 0xc0), and(addressMask, spender))
            }
            let p := mul(PERMIT2, iszero(shr(160, amount)))
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.
                    staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)
                )
            ) {
                mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.
                revert(add(0x18, shl(2, iszero(p))), 0x04)
            }
            mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).
            // `owner` is already `add(m, 0x20)`.
            // `token` is already at `add(m, 0x40)`.
            mstore(add(m, 0x60), amount)
            mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.
            // `nonce` is already at `add(m, 0xa0)`.
            // `spender` is already at `add(m, 0xc0)`.
            mstore(add(m, 0xe0), deadline)
            mstore(add(m, 0x100), 0x100) // `signature` offset.
            mstore(add(m, 0x120), 0x41) // `signature` length.
            mstore(add(m, 0x140), r)
            mstore(add(m, 0x160), s)
            mstore(add(m, 0x180), shl(248, v))
            if iszero( // Revert if token does not have code, or if the call fails.
            mul(extcodesize(token), call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00))) {
                mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Approves `spender` to spend `amount` of `token` for `address(this)`.
    function permit2Approve(address token, address spender, uint160 amount, uint48 expiration)
        internal
    {
        /// @solidity memory-safe-assembly
        assembly {
            let addressMask := shr(96, not(0))
            let m := mload(0x40)
            mstore(m, 0x87517c45) // `approve(address,address,uint160,uint48)`.
            mstore(add(m, 0x20), and(addressMask, token))
            mstore(add(m, 0x40), and(addressMask, spender))
            mstore(add(m, 0x60), and(addressMask, amount))
            mstore(add(m, 0x80), and(0xffffffffffff, expiration))
            if iszero(call(gas(), PERMIT2, 0, add(m, 0x1c), 0xa0, codesize(), 0x00)) {
                mstore(0x00, 0x324f14ae) // `Permit2ApproveFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Revokes an approval for `token` and `spender` for `address(this)`.
    function permit2Lockdown(address token, address spender) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(m, 0xcc53287f) // `Permit2.lockdown`.
            mstore(add(m, 0x20), 0x20) // Offset of the `approvals`.
            mstore(add(m, 0x40), 1) // `approvals.length`.
            mstore(add(m, 0x60), shr(96, shl(96, token)))
            mstore(add(m, 0x80), shr(96, shl(96, spender)))
            if iszero(call(gas(), PERMIT2, 0, add(m, 0x1c), 0xa0, codesize(), 0x00)) {
                mstore(0x00, 0x96b3de23) // `Permit2LockdownFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }
}

File 7 of 8 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @notice Reentrancy guard mixin.
/// @author Soledge (https://github.com/vectorized/soledge/blob/main/src/utils/ReentrancyGuard.sol)
///
/// Note: This implementation utilizes the `TSTORE` and `TLOAD` opcodes.
/// Please ensure that the chain you are deploying on supports them.
abstract contract ReentrancyGuard {
    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                       CUSTOM ERRORS                        */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Unauthorized reentrant call.
    error Reentrancy();

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

    /// @dev Equivalent to: `uint72(bytes9(keccak256("_REENTRANCY_GUARD_SLOT")))`.
    /// 9 bytes is large enough to avoid collisions in practice,
    /// but not too large to result in excessive bytecode bloat.
    uint256 private constant _REENTRANCY_GUARD_SLOT = 0x929eee149b4bd21268;

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                      REENTRANCY GUARD                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Guards a function from reentrancy.
    modifier nonReentrant() virtual {
        /// @solidity memory-safe-assembly
        assembly {
            if tload(_REENTRANCY_GUARD_SLOT) {
                mstore(0x00, 0xab143c06) // `Reentrancy()`.
                revert(0x1c, 0x04)
            }
            tstore(_REENTRANCY_GUARD_SLOT, address())
        }
        _;
        /// @solidity memory-safe-assembly
        assembly {
            tstore(_REENTRANCY_GUARD_SLOT, 0)
        }
    }

    /// @dev Guards a view function from read-only reentrancy.
    modifier nonReadReentrant() virtual {
        /// @solidity memory-safe-assembly
        assembly {
            if tload(_REENTRANCY_GUARD_SLOT) {
                mstore(0x00, 0xab143c06) // `Reentrancy()`.
                revert(0x1c, 0x04)
            }
        }
        _;
    }
}

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

/// @notice Library for byte related operations.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibBytes.sol)
library LibBytes {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                          STRUCTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Goated bytes storage struct that totally MOGs, no cap, fr.
    /// Uses less gas and bytecode than Solidity's native bytes storage. It's meta af.
    /// Packs length with the first 31 bytes if <255 bytes, so it’s mad tight.
    struct BytesStorage {
        bytes32 _spacer;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The constant returned when the `search` is not found in the bytes.
    uint256 internal constant NOT_FOUND = type(uint256).max;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  BYTE STORAGE OPERATIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Sets the value of the bytes storage `$` to `s`.
    function set(BytesStorage storage $, bytes memory s) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let n := mload(s)
            let packed := or(0xff, shl(8, n))
            for { let i := 0 } 1 {} {
                if iszero(gt(n, 0xfe)) {
                    i := 0x1f
                    packed := or(n, shl(8, mload(add(s, i))))
                    if iszero(gt(n, i)) { break }
                }
                let o := add(s, 0x20)
                mstore(0x00, $.slot)
                for { let p := keccak256(0x00, 0x20) } 1 {} {
                    sstore(add(p, shr(5, i)), mload(add(o, i)))
                    i := add(i, 0x20)
                    if iszero(lt(i, n)) { break }
                }
                break
            }
            sstore($.slot, packed)
        }
    }

    /// @dev Sets the value of the bytes storage `$` to `s`.
    function setCalldata(BytesStorage storage $, bytes calldata s) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let packed := or(0xff, shl(8, s.length))
            for { let i := 0 } 1 {} {
                if iszero(gt(s.length, 0xfe)) {
                    i := 0x1f
                    packed := or(s.length, shl(8, shr(8, calldataload(s.offset))))
                    if iszero(gt(s.length, i)) { break }
                }
                mstore(0x00, $.slot)
                for { let p := keccak256(0x00, 0x20) } 1 {} {
                    sstore(add(p, shr(5, i)), calldataload(add(s.offset, i)))
                    i := add(i, 0x20)
                    if iszero(lt(i, s.length)) { break }
                }
                break
            }
            sstore($.slot, packed)
        }
    }

    /// @dev Sets the value of the bytes storage `$` to the empty bytes.
    function clear(BytesStorage storage $) internal {
        delete $._spacer;
    }

    /// @dev Returns whether the value stored is `$` is the empty bytes "".
    function isEmpty(BytesStorage storage $) internal view returns (bool) {
        return uint256($._spacer) & 0xff == uint256(0);
    }

    /// @dev Returns the length of the value stored in `$`.
    function length(BytesStorage storage $) internal view returns (uint256 result) {
        result = uint256($._spacer);
        /// @solidity memory-safe-assembly
        assembly {
            let n := and(0xff, result)
            result := or(mul(shr(8, result), eq(0xff, n)), mul(n, iszero(eq(0xff, n))))
        }
    }

    /// @dev Returns the value stored in `$`.
    function get(BytesStorage storage $) internal view returns (bytes memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            let o := add(result, 0x20)
            let packed := sload($.slot)
            let n := shr(8, packed)
            for { let i := 0 } 1 {} {
                if iszero(eq(or(packed, 0xff), packed)) {
                    mstore(o, packed)
                    n := and(0xff, packed)
                    i := 0x1f
                    if iszero(gt(n, i)) { break }
                }
                mstore(0x00, $.slot)
                for { let p := keccak256(0x00, 0x20) } 1 {} {
                    mstore(add(o, i), sload(add(p, shr(5, i))))
                    i := add(i, 0x20)
                    if iszero(lt(i, n)) { break }
                }
                break
            }
            mstore(result, n) // Store the length of the memory.
            mstore(add(o, n), 0) // Zeroize the slot after the bytes.
            mstore(0x40, add(add(o, n), 0x20)) // Allocate memory.
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      BYTES OPERATIONS                      */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns `subject` all occurrences of `needle` replaced with `replacement`.
    function replace(bytes memory subject, bytes memory needle, bytes memory replacement)
        internal
        pure
        returns (bytes memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            let needleLen := mload(needle)
            let replacementLen := mload(replacement)
            let d := sub(result, subject) // Memory difference.
            let i := add(subject, 0x20) // Subject bytes pointer.
            mstore(0x00, add(i, mload(subject))) // End of subject.
            if iszero(gt(needleLen, mload(subject))) {
                let subjectSearchEnd := add(sub(mload(0x00), needleLen), 1)
                let h := 0 // The hash of `needle`.
                if iszero(lt(needleLen, 0x20)) { h := keccak256(add(needle, 0x20), needleLen) }
                let s := mload(add(needle, 0x20))
                for { let m := shl(3, sub(0x20, and(needleLen, 0x1f))) } 1 {} {
                    let t := mload(i)
                    // Whether the first `needleLen % 32` bytes of `subject` and `needle` matches.
                    if iszero(shr(m, xor(t, s))) {
                        if h {
                            if iszero(eq(keccak256(i, needleLen), h)) {
                                mstore(add(i, d), t)
                                i := add(i, 1)
                                if iszero(lt(i, subjectSearchEnd)) { break }
                                continue
                            }
                        }
                        // Copy the `replacement` one word at a time.
                        for { let j := 0 } 1 {} {
                            mstore(add(add(i, d), j), mload(add(add(replacement, 0x20), j)))
                            j := add(j, 0x20)
                            if iszero(lt(j, replacementLen)) { break }
                        }
                        d := sub(add(d, replacementLen), needleLen)
                        if needleLen {
                            i := add(i, needleLen)
                            if iszero(lt(i, subjectSearchEnd)) { break }
                            continue
                        }
                    }
                    mstore(add(i, d), t)
                    i := add(i, 1)
                    if iszero(lt(i, subjectSearchEnd)) { break }
                }
            }
            let end := mload(0x00)
            let n := add(sub(d, add(result, 0x20)), end)
            // Copy the rest of the bytes one word at a time.
            for {} lt(i, end) { i := add(i, 0x20) } { mstore(add(i, d), mload(i)) }
            let o := add(i, d)
            mstore(o, 0) // Zeroize the slot after the bytes.
            mstore(0x40, add(o, 0x20)) // Allocate memory.
            mstore(result, n) // Store the length.
        }
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from left to right, starting from `from`.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function indexOf(bytes memory subject, bytes memory needle, uint256 from)
        internal
        pure
        returns (uint256 result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := not(0) // Initialize to `NOT_FOUND`.
            for { let subjectLen := mload(subject) } 1 {} {
                if iszero(mload(needle)) {
                    result := from
                    if iszero(gt(from, subjectLen)) { break }
                    result := subjectLen
                    break
                }
                let needleLen := mload(needle)
                let subjectStart := add(subject, 0x20)

                subject := add(subjectStart, from)
                let end := add(sub(add(subjectStart, subjectLen), needleLen), 1)
                let m := shl(3, sub(0x20, and(needleLen, 0x1f)))
                let s := mload(add(needle, 0x20))

                if iszero(and(lt(subject, end), lt(from, subjectLen))) { break }

                if iszero(lt(needleLen, 0x20)) {
                    for { let h := keccak256(add(needle, 0x20), needleLen) } 1 {} {
                        if iszero(shr(m, xor(mload(subject), s))) {
                            if eq(keccak256(subject, needleLen), h) {
                                result := sub(subject, subjectStart)
                                break
                            }
                        }
                        subject := add(subject, 1)
                        if iszero(lt(subject, end)) { break }
                    }
                    break
                }
                for {} 1 {} {
                    if iszero(shr(m, xor(mload(subject), s))) {
                        result := sub(subject, subjectStart)
                        break
                    }
                    subject := add(subject, 1)
                    if iszero(lt(subject, end)) { break }
                }
                break
            }
        }
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from left to right.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function indexOf(bytes memory subject, bytes memory needle) internal pure returns (uint256) {
        return indexOf(subject, needle, 0);
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from right to left, starting from `from`.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function lastIndexOf(bytes memory subject, bytes memory needle, uint256 from)
        internal
        pure
        returns (uint256 result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            for {} 1 {} {
                result := not(0) // Initialize to `NOT_FOUND`.
                let needleLen := mload(needle)
                if gt(needleLen, mload(subject)) { break }
                let w := result

                let fromMax := sub(mload(subject), needleLen)
                if iszero(gt(fromMax, from)) { from := fromMax }

                let end := add(add(subject, 0x20), w)
                subject := add(add(subject, 0x20), from)
                if iszero(gt(subject, end)) { break }
                // As this function is not too often used,
                // we shall simply use keccak256 for smaller bytecode size.
                for { let h := keccak256(add(needle, 0x20), needleLen) } 1 {} {
                    if eq(keccak256(subject, needleLen), h) {
                        result := sub(subject, add(end, 1))
                        break
                    }
                    subject := add(subject, w) // `sub(subject, 1)`.
                    if iszero(gt(subject, end)) { break }
                }
                break
            }
        }
    }

    /// @dev Returns the byte index of the first location of `needle` in `subject`,
    /// needleing from right to left.
    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
    function lastIndexOf(bytes memory subject, bytes memory needle)
        internal
        pure
        returns (uint256)
    {
        return lastIndexOf(subject, needle, type(uint256).max);
    }

    /// @dev Returns true if `needle` is found in `subject`, false otherwise.
    function contains(bytes memory subject, bytes memory needle) internal pure returns (bool) {
        return indexOf(subject, needle) != NOT_FOUND;
    }

    /// @dev Returns whether `subject` starts with `needle`.
    function startsWith(bytes memory subject, bytes memory needle)
        internal
        pure
        returns (bool result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let n := mload(needle)
            // Just using keccak256 directly is actually cheaper.
            let t := eq(keccak256(add(subject, 0x20), n), keccak256(add(needle, 0x20), n))
            result := lt(gt(n, mload(subject)), t)
        }
    }

    /// @dev Returns whether `subject` ends with `needle`.
    function endsWith(bytes memory subject, bytes memory needle)
        internal
        pure
        returns (bool result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let n := mload(needle)
            let notInRange := gt(n, mload(subject))
            // `subject + 0x20 + max(subject.length - needle.length, 0)`.
            let t := add(add(subject, 0x20), mul(iszero(notInRange), sub(mload(subject), n)))
            // Just using keccak256 directly is actually cheaper.
            result := gt(eq(keccak256(t, n), keccak256(add(needle, 0x20), n)), notInRange)
        }
    }

    /// @dev Returns `subject` repeated `times`.
    function repeat(bytes memory subject, uint256 times)
        internal
        pure
        returns (bytes memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let l := mload(subject) // Subject length.
            if iszero(or(iszero(times), iszero(l))) {
                result := mload(0x40)
                subject := add(subject, 0x20)
                let o := add(result, 0x20)
                for {} 1 {} {
                    // Copy the `subject` one word at a time.
                    for { let j := 0 } 1 {} {
                        mstore(add(o, j), mload(add(subject, j)))
                        j := add(j, 0x20)
                        if iszero(lt(j, l)) { break }
                    }
                    o := add(o, l)
                    times := sub(times, 1)
                    if iszero(times) { break }
                }
                mstore(o, 0) // Zeroize the slot after the bytes.
                mstore(0x40, add(o, 0x20)) // Allocate memory.
                mstore(result, sub(o, add(result, 0x20))) // Store the length.
            }
        }
    }

    /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).
    /// `start` and `end` are byte offsets.
    function slice(bytes memory subject, uint256 start, uint256 end)
        internal
        pure
        returns (bytes memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let l := mload(subject) // Subject length.
            if iszero(gt(l, end)) { end := l }
            if iszero(gt(l, start)) { start := l }
            if lt(start, end) {
                result := mload(0x40)
                let n := sub(end, start)
                let i := add(subject, start)
                let w := not(0x1f)
                // Copy the `subject` one word at a time, backwards.
                for { let j := and(add(n, 0x1f), w) } 1 {} {
                    mstore(add(result, j), mload(add(i, j)))
                    j := add(j, w) // `sub(j, 0x20)`.
                    if iszero(j) { break }
                }
                let o := add(add(result, 0x20), n)
                mstore(o, 0) // Zeroize the slot after the bytes.
                mstore(0x40, add(o, 0x20)) // Allocate memory.
                mstore(result, n) // Store the length.
            }
        }
    }

    /// @dev Returns a copy of `subject` sliced from `start` to the end of the bytes.
    /// `start` is a byte offset.
    function slice(bytes memory subject, uint256 start)
        internal
        pure
        returns (bytes memory result)
    {
        result = slice(subject, start, type(uint256).max);
    }

    /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).
    /// `start` and `end` are byte offsets. Faster than Solidity's native slicing.
    function sliceCalldata(bytes calldata subject, uint256 start, uint256 end)
        internal
        pure
        returns (bytes calldata result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            end := xor(end, mul(xor(end, subject.length), lt(subject.length, end)))
            start := xor(start, mul(xor(start, subject.length), lt(subject.length, start)))
            result.offset := add(subject.offset, start)
            result.length := mul(lt(start, end), sub(end, start))
        }
    }

    /// @dev Returns a copy of `subject` sliced from `start` to the end of the bytes.
    /// `start` is a byte offset. Faster than Solidity's native slicing.
    function sliceCalldata(bytes calldata subject, uint256 start)
        internal
        pure
        returns (bytes calldata result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            start := xor(start, mul(xor(start, subject.length), lt(subject.length, start)))
            result.offset := add(subject.offset, start)
            result.length := mul(lt(start, subject.length), sub(subject.length, start))
        }
    }

    /// @dev Reduces the size of `subject` to `n`.
    /// If `n` is greater than the size of `subject`, this will be a no-op.
    function truncate(bytes memory subject, uint256 n)
        internal
        pure
        returns (bytes memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := subject
            mstore(mul(lt(n, mload(result)), result), n)
        }
    }

    /// @dev Returns a copy of `subject`, with the length reduced to `n`.
    /// If `n` is greater than the size of `subject`, this will be a no-op.
    function truncatedCalldata(bytes calldata subject, uint256 n)
        internal
        pure
        returns (bytes calldata result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result.offset := subject.offset
            result.length := xor(n, mul(xor(n, subject.length), lt(subject.length, n)))
        }
    }

    /// @dev Returns all the indices of `needle` in `subject`.
    /// The indices are byte offsets.
    function indicesOf(bytes memory subject, bytes memory needle)
        internal
        pure
        returns (uint256[] memory result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let searchLen := mload(needle)
            if iszero(gt(searchLen, mload(subject))) {
                result := mload(0x40)
                let i := add(subject, 0x20)
                let o := add(result, 0x20)
                let subjectSearchEnd := add(sub(add(i, mload(subject)), searchLen), 1)
                let h := 0 // The hash of `needle`.
                if iszero(lt(searchLen, 0x20)) { h := keccak256(add(needle, 0x20), searchLen) }
                let s := mload(add(needle, 0x20))
                for { let m := shl(3, sub(0x20, and(searchLen, 0x1f))) } 1 {} {
                    let t := mload(i)
                    // Whether the first `searchLen % 32` bytes of `subject` and `needle` matches.
                    if iszero(shr(m, xor(t, s))) {
                        if h {
                            if iszero(eq(keccak256(i, searchLen), h)) {
                                i := add(i, 1)
                                if iszero(lt(i, subjectSearchEnd)) { break }
                                continue
                            }
                        }
                        mstore(o, sub(i, add(subject, 0x20))) // Append to `result`.
                        o := add(o, 0x20)
                        i := add(i, searchLen) // Advance `i` by `searchLen`.
                        if searchLen {
                            if iszero(lt(i, subjectSearchEnd)) { break }
                            continue
                        }
                    }
                    i := add(i, 1)
                    if iszero(lt(i, subjectSearchEnd)) { break }
                }
                mstore(result, shr(5, sub(o, add(result, 0x20)))) // Store the length of `result`.
                // Allocate memory for result.
                // We allocate one more word, so this array can be recycled for {split}.
                mstore(0x40, add(o, 0x20))
            }
        }
    }

    /// @dev Returns a arrays of bytess based on the `delimiter` inside of the `subject` bytes.
    function split(bytes memory subject, bytes memory delimiter)
        internal
        pure
        returns (bytes[] memory result)
    {
        uint256[] memory indices = indicesOf(subject, delimiter);
        /// @solidity memory-safe-assembly
        assembly {
            let w := not(0x1f)
            let indexPtr := add(indices, 0x20)
            let indicesEnd := add(indexPtr, shl(5, add(mload(indices), 1)))
            mstore(add(indicesEnd, w), mload(subject))
            mstore(indices, add(mload(indices), 1))
            for { let prevIndex := 0 } 1 {} {
                let index := mload(indexPtr)
                mstore(indexPtr, 0x60)
                if iszero(eq(index, prevIndex)) {
                    let element := mload(0x40)
                    let l := sub(index, prevIndex)
                    mstore(element, l) // Store the length of the element.
                    // Copy the `subject` one word at a time, backwards.
                    for { let o := and(add(l, 0x1f), w) } 1 {} {
                        mstore(add(element, o), mload(add(add(subject, prevIndex), o)))
                        o := add(o, w) // `sub(o, 0x20)`.
                        if iszero(o) { break }
                    }
                    mstore(add(add(element, 0x20), l), 0) // Zeroize the slot after the bytes.
                    // Allocate memory for the length and the bytes, rounded up to a multiple of 32.
                    mstore(0x40, add(element, and(add(l, 0x3f), w)))
                    mstore(indexPtr, element) // Store the `element` into the array.
                }
                prevIndex := add(index, mload(delimiter))
                indexPtr := add(indexPtr, 0x20)
                if iszero(lt(indexPtr, indicesEnd)) { break }
            }
            result := indices
            if iszero(mload(delimiter)) {
                result := add(indices, 0x20)
                mstore(result, sub(mload(indices), 2))
            }
        }
    }

    /// @dev Returns a concatenated bytes of `a` and `b`.
    /// Cheaper than `bytes.concat()` and does not de-align the free memory pointer.
    function concat(bytes memory a, bytes memory b) internal pure returns (bytes memory result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            let w := not(0x1f)
            let aLen := mload(a)
            // Copy `a` one word at a time, backwards.
            for { let o := and(add(aLen, 0x20), w) } 1 {} {
                mstore(add(result, o), mload(add(a, o)))
                o := add(o, w) // `sub(o, 0x20)`.
                if iszero(o) { break }
            }
            let bLen := mload(b)
            let output := add(result, aLen)
            // Copy `b` one word at a time, backwards.
            for { let o := and(add(bLen, 0x20), w) } 1 {} {
                mstore(add(output, o), mload(add(b, o)))
                o := add(o, w) // `sub(o, 0x20)`.
                if iszero(o) { break }
            }
            let totalLen := add(aLen, bLen)
            let last := add(add(result, 0x20), totalLen)
            mstore(last, 0) // Zeroize the slot after the bytes.
            mstore(result, totalLen) // Store the length.
            mstore(0x40, add(last, 0x20)) // Allocate memory.
        }
    }

    /// @dev Returns whether `a` equals `b`.
    function eq(bytes memory a, bytes memory b) internal pure returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))
        }
    }

    /// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small bytes.
    function eqs(bytes memory a, bytes32 b) internal pure returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            // These should be evaluated on compile time, as far as possible.
            let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.
            let x := not(or(m, or(b, add(m, and(b, m)))))
            let r := shl(7, iszero(iszero(shr(128, x))))
            r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x))))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(r, shl(3, lt(0xff, shr(r, x))))
            // forgefmt: disable-next-item
            result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),
                xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))
        }
    }

    /// @dev Returns 0 if `a == b`, -1 if `a < b`, +1 if `a > b`.
    /// If `a` == b[:a.length]`, and `a.length < b.length`, returns -1.
    function cmp(bytes memory a, bytes memory b) internal pure returns (int256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            let aLen := mload(a)
            let bLen := mload(b)
            let n := and(xor(aLen, mul(xor(aLen, bLen), lt(bLen, aLen))), not(0x1f))
            if n {
                for { let i := 0x20 } 1 {} {
                    let x := mload(add(a, i))
                    let y := mload(add(b, i))
                    if iszero(or(xor(x, y), eq(i, n))) {
                        i := add(i, 0x20)
                        continue
                    }
                    result := sub(gt(x, y), lt(x, y))
                    break
                }
            }
            // forgefmt: disable-next-item
            if iszero(result) {
                let l := 0x201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201
                let x := and(mload(add(add(a, 0x20), n)), shl(shl(3, byte(sub(aLen, n), l)), not(0)))
                let y := and(mload(add(add(b, 0x20), n)), shl(shl(3, byte(sub(bLen, n), l)), not(0)))
                result := sub(gt(x, y), lt(x, y))
                if iszero(result) { result := sub(gt(aLen, bLen), lt(aLen, bLen)) }
            }
        }
    }

    /// @dev Directly returns `a` without copying.
    function directReturn(bytes memory a) internal pure {
        /// @solidity memory-safe-assembly
        assembly {
            // Assumes that the bytes does not start from the scratch space.
            let retStart := sub(a, 0x20)
            let retUnpaddedSize := add(mload(a), 0x40)
            // Right pad with zeroes. Just in case the bytes is produced
            // by a method that doesn't zero right pad.
            mstore(add(retStart, retUnpaddedSize), 0)
            mstore(retStart, 0x20) // Store the return offset.
            // End the transaction, returning the bytes.
            return(retStart, and(not(0x1f), add(0x1f, retUnpaddedSize)))
        }
    }

    /// @dev Directly returns `a` with minimal copying.
    function directReturn(bytes[] memory a) internal pure {
        /// @solidity memory-safe-assembly
        assembly {
            let n := mload(a) // `a.length`.
            let o := add(a, 0x20) // Start of elements in `a`.
            let u := a // Highest memory slot.
            let w := not(0x1f)
            for { let i := 0 } iszero(eq(i, n)) { i := add(i, 1) } {
                let c := add(o, shl(5, i)) // Location of pointer to `a[i]`.
                let s := mload(c) // `a[i]`.
                let l := mload(s) // `a[i].length`.
                let r := and(l, 0x1f) // `a[i].length % 32`.
                let z := add(0x20, and(l, w)) // Offset of last word in `a[i]` from `s`.
                // If `s` comes before `o`, or `s` is not zero right padded.
                if iszero(lt(lt(s, o), or(iszero(r), iszero(shl(shl(3, r), mload(add(s, z))))))) {
                    let m := mload(0x40)
                    mstore(m, l) // Copy `a[i].length`.
                    for {} 1 {} {
                        mstore(add(m, z), mload(add(s, z))) // Copy `a[i]`, backwards.
                        z := add(z, w) // `sub(z, 0x20)`.
                        if iszero(z) { break }
                    }
                    let e := add(add(m, 0x20), l)
                    mstore(e, 0) // Zeroize the slot after the copied bytes.
                    mstore(0x40, add(e, 0x20)) // Allocate memory.
                    s := m
                }
                mstore(c, sub(s, o)) // Convert to calldata offset.
                let t := add(l, add(s, 0x20))
                if iszero(lt(t, u)) { u := t }
            }
            let retStart := add(a, w) // Assumes `a` doesn't start from scratch space.
            mstore(retStart, 0x20) // Store the return offset.
            return(retStart, add(0x40, sub(u, retStart))) // End the transaction.
        }
    }

    /// @dev Returns the word at `offset`, without any bounds checks.
    function load(bytes memory a, uint256 offset) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(add(add(a, 0x20), offset))
        }
    }

    /// @dev Returns the word at `offset`, without any bounds checks.
    function loadCalldata(bytes calldata a, uint256 offset)
        internal
        pure
        returns (bytes32 result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := calldataload(add(a.offset, offset))
        }
    }

    /// @dev Returns a slice representing a static struct in the calldata. Performs bounds checks.
    function staticStructInCalldata(bytes calldata a, uint256 offset)
        internal
        pure
        returns (bytes calldata result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let l := sub(a.length, 0x20)
            result.offset := add(a.offset, offset)
            result.length := sub(a.length, offset)
            if or(shr(64, or(l, a.offset)), gt(offset, l)) { revert(l, 0x00) }
        }
    }

    /// @dev Returns a slice representing a dynamic struct in the calldata. Performs bounds checks.
    function dynamicStructInCalldata(bytes calldata a, uint256 offset)
        internal
        pure
        returns (bytes calldata result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let l := sub(a.length, 0x20)
            let s := calldataload(add(a.offset, offset)) // Relative offset of `result` from `a.offset`.
            result.offset := add(a.offset, s)
            result.length := sub(a.length, s)
            if or(shr(64, or(s, or(l, a.offset))), gt(offset, l)) { revert(l, 0x00) }
        }
    }

    /// @dev Returns bytes in calldata. Performs bounds checks.
    function bytesInCalldata(bytes calldata a, uint256 offset)
        internal
        pure
        returns (bytes calldata result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let l := sub(a.length, 0x20)
            let s := calldataload(add(a.offset, offset)) // Relative offset of `result` from `a.offset`.
            result.offset := add(add(a.offset, s), 0x20)
            result.length := calldataload(add(a.offset, s))
            // forgefmt: disable-next-item
            if or(shr(64, or(result.length, or(s, or(l, a.offset)))),
                or(gt(add(s, result.length), l), gt(offset, l))) { revert(l, 0x00) }
        }
    }

    /// @dev Returns empty calldata bytes. For silencing the compiler.
    function emptyCalldata() internal pure returns (bytes calldata result) {
        /// @solidity memory-safe-assembly
        assembly {
            result.length := 0
        }
    }
}

Settings
{
  "remappings": [
    "@solady/=lib/solady/",
    "@soledge/=lib/soledge/",
    "@forge/=lib/forge-std/src/",
    "@zamm/=lib/ZAMM/src/",
    "ZAMM/=lib/ZAMM/",
    "forge-std/=lib/forge-std/src/",
    "solady/=lib/solady/src/",
    "soledge/=lib/soledge/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 20
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "prague",
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"payable","type":"constructor"},{"inputs":[],"name":"AccountBalanceOverflow","type":"error"},{"inputs":[],"name":"AlreadyCommitted","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"AlreadyRegistered","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"CommitmentNotFound","type":"error"},{"inputs":[],"name":"CommitmentTooNew","type":"error"},{"inputs":[],"name":"CommitmentTooOld","type":"error"},{"inputs":[],"name":"DecayPeriodTooLong","type":"error"},{"inputs":[],"name":"EmptyLabel","type":"error"},{"inputs":[],"name":"Expired","type":"error"},{"inputs":[],"name":"InsufficientFee","type":"error"},{"inputs":[],"name":"InvalidLength","type":"error"},{"inputs":[],"name":"InvalidName","type":"error"},{"inputs":[],"name":"LengthMismatch","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"NotOwnerNorApproved","type":"error"},{"inputs":[],"name":"NotParentOwner","type":"error"},{"inputs":[],"name":"PremiumTooHigh","type":"error"},{"inputs":[],"name":"Reentrancy","type":"error"},{"inputs":[],"name":"TokenAlreadyExists","type":"error"},{"inputs":[],"name":"TokenDoesNotExist","type":"error"},{"inputs":[],"name":"TooDeep","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"addr","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"coinType","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"addr","type":"bytes"}],"name":"AddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"isApproved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"commitment","type":"bytes32"},{"indexed":true,"internalType":"address","name":"committer","type":"address"}],"name":"Committed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"contenthash","type":"bytes"}],"name":"ContenthashChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"DefaultFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"length","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"LengthFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"length","type":"uint256"}],"name":"LengthFeeCleared","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"label","type":"string"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"expiresAt","type":"uint256"}],"name":"NameRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newExpiresAt","type":"uint256"}],"name":"NameRenewed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxPremium","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"decayPeriod","type":"uint256"}],"name":"PremiumSettingsChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"PrimaryNameSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"parentId","type":"uint256"},{"indexed":false,"internalType":"string","name":"label","type":"string"}],"name":"SubdomainRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"string","name":"key","type":"string"},{"indexed":false,"internalType":"string","name":"value","type":"string"}],"name":"TextChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"WEI_NODE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"addr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"coinType","type":"uint256"}],"name":"addr","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"coinType","type":"uint256"}],"name":"addr","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"clearLengthFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commitment","type":"bytes32"}],"name":"commit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"commitments","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"fullName","type":"string"}],"name":"computeId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"fullName","type":"string"}],"name":"computeNamehash","outputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"contenthash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"contenthash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"expiresAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"getFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFullName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getPremium","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"inGracePeriod","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"result","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"label","type":"string"}],"name":"isAsciiLabel","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"label","type":"string"},{"internalType":"uint256","name":"parentId","type":"uint256"}],"name":"isAvailable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isExpired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lengthFeeSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lengthFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"label","type":"string"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"bytes32","name":"secret","type":"bytes32"}],"name":"makeCommitment","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"maxPremium","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"label","type":"string"}],"name":"normalize","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"premiumDecayPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"primaryName","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"recordVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"records","outputs":[{"internalType":"string","name":"label","type":"string"},{"internalType":"uint256","name":"parent","type":"uint256"},{"internalType":"uint64","name":"expiresAt","type":"uint64"},{"internalType":"uint64","name":"epoch","type":"uint64"},{"internalType":"uint64","name":"parentEpoch","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"label","type":"string"},{"internalType":"uint256","name":"parentId","type":"uint256"}],"name":"registerSubdomain","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"label","type":"string"},{"internalType":"uint256","name":"parentId","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"registerSubdomainFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"renew","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"resolve","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"label","type":"string"},{"internalType":"bytes32","name":"secret","type":"bytes32"}],"name":"reveal","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"reverseResolve","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"addr","type":"address"}],"name":"setAddr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"coinType","type":"uint256"},{"internalType":"bytes","name":"addr","type":"bytes"}],"name":"setAddrForCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"hash","type":"bytes"}],"name":"setContenthash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setDefaultFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"lengths","type":"uint256[]"},{"internalType":"uint256[]","name":"fees","type":"uint256[]"}],"name":"setLengthFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPremium","type":"uint256"},{"internalType":"uint256","name":"_decayPeriod","type":"uint256"}],"name":"setPremiumSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"setPrimaryName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"name":"setText","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"key","type":"string"}],"name":"text","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"key","type":"string"}],"name":"text","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405232638b78c6d81955325f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a366038d7ea4c680005f5568056bc75e2d63100000600155621baf8060025560405161530490816100608239f3fe6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a7146119925750806306fdde0314611940578063081812fc146118ef578063095ea7b31461183a57806317c95709146118045780631bf1fffb146117e65780631c0c70cc146116dc57806323b872dd146116ca5780632569296214611681578063308e33861461166757806334461067146115ef5780633b3b57de1461131d5780633ccfd60b146115945780633fb24782146113ca57806342842e0e14611389578063465411c11461136a5780634de0c05a1461133b5780634f896d4f1461131d57806351b79d551461130057806354d1f13d146112bc57806359d1d43c1461127d5780635a6c72d0146112615780635baa75091461114857806362894d12146110be5780636352211e1461108e57806369243129146110675780636abaaa441461104a5780636f40aeb51461102057806370a0823114610fcd578063715018a614610f97578063724474cd14610f7d5780637b22f8cb14610f19578063839df94514610eef57806385a8df9e14610e8557806388f97a6714610de85780638da5cb5b14610dbc5780638f449b8514610d555780638f8dc38614610d3c57806395d89b4114610cf75780639aa4bf3314610ccd5780639af8b7aa14610ca95780639f10f4b514610c69578063a22cb46514610bf8578063a435a04614610b1e578063a4f6965714610a73578063acd6476e14610a38578063b88d4fde146109ce578063bc1c58d114610945578063c87b56dd146109af578063c93a6c8414610964578063cb323d7614610945578063d3c08b131461034e578063d9548e531461091d578063df456c9014610859578063e985e9c514610815578063ea9384fa14610678578063eba36dbd146105b0578063eba951aa14610578578063f04e283e1461052b578063f14fcbc814610482578063f1cb7e0614610448578063f2fde38b1461040b578063f49826be14610389578063fb0219391461034e578063fcee45f4146103285763fee81cf4146102f2575f80fd5b346103245760203660031901126103245761030b611a65565b63389a75e1600c525f52602080600c2054604051908152f35b5f80fd5b34610324576020366003190112610324576020610346600435613b73565b604051908152f35b34610324576020366003190112610324576004356001600160401b038111610324576103466103836020923690600401611afb565b9061373f565b34610324576060366003190112610324576004356001600160401b038111610324576103d96103f26104006103de6103c76020953690600401611afb565b94906103d1611a7b565b9536916123e0565b614401565b604051928391868301956044359187613b47565b03601f198101835282611bae565b519020604051908152f35b60203660031901126103245761041f611a65565b610427613b9e565b8060601b1561043b5761043990613c5b565b005b637448fbae5f526004601cfd5b346103245760403660031901126103245761047e61046a602435600435612123565b604051918291602083526020830190611a41565b0390f35b3461032457602036600319011261032457600435805f52600760205260405f20541515806104f4575b6104e557805f5260076020524260405f205533907ffda886b5d38d5d61e432b3acc9f19640a2b8c83c87a9c584a780d3854b309b9c5f80a3005b6317fd8aab60e31b5f5260045ffd5b50805f52600760205260405f2054620151808101809111610517574211156104ab565b634e487b7160e01b5f52601160045260245ffd5b60203660031901126103245761053f611a65565b610547613b9e565b63389a75e1600c52805f526020600c20908154421161056b575f6104399255613c5b565b636f5e88185f526004601cfd5b34610324576020366003190112610324576001600160a01b03610599611a65565b165f526008602052602060405f2054604051908152f35b34610324576040366003190112610324576004356105cc611a7b565b6105d65f83614b3d565b15610669576105e4826120f6565b336001600160a01b039091160361065b575f8281526009602090815260408083206006835281842054845282529182902080546001600160a01b0319166001600160a01b03909416938417905590519182527f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd291a2005b6282b42960e81b5f5260045ffd5b630407b05b60e31b5f5260045ffd5b6040366003190112610324576004356001600160401b038111610324576106a3903690600401611afb565b9068929eee149b4bd212685c610808576103d96106d7913068929eee149b4bd212685d6106cf84613b73565b9336916123e0565b906107218251602084012060405160208101915f51602061528f5f395f51905f52835260408201526040815261070e606082611bae565b5190209161071b83611d16565b90611cfc565b8034106107fa576040516020810190610742816103f2602435338987613b47565b519020805f52600760205260405f205480156107eb57603c81018082116105175742106107dc576201518081018091116105175742116107cd57602093610796915f52600785525f60408120553390613c85565b508034116107b4575b505f68929eee149b4bd212685d604051908152f35b6107c16107c79134611d09565b33613c4c565b8261079f565b63cfef9a9560e01b5f5260045ffd5b63cba3a53b60e01b5f5260045ffd5b635b34156960e11b5f5260045ffd5b62976f7560e21b5f5260045ffd5b63ab143c065f526004601cfd5b346103245760403660031901126103245761082e611a65565b610836611a7b565b601c5263052d173d60211b6008525f526030600c20546040519015158152602090f35b34610324576060366003190112610324576004356001600160401b03811161032457610889903690600401611afb565b906044356024356001600160a01b03821682036103245768929eee149b4bd212685c610808573068929eee149b4bd212685d6108c55f82614b3d565b15610669576108d3816120f6565b336001600160a01b039091160361090e576108f56108fa9360209536916123e0565b613fb8565b5f68929eee149b4bd212685d604051908152f35b632588f19b60e11b5f5260045ffd5b3461032457602036600319011261032457602061093b600435613b0e565b6040519015158152f35b346103245760203660031901126103245761047e61046a600435612ae8565b34610324576020366003190112610324577f47c26d86c0cb4918d3bd962b301c7862a23ebc8bd9be594cbb8517e7fa4a4d3b60206004356109a3613b9e565b805f55604051908152a1005b346103245760203660031901126103245761047e61046a600435612be7565b6080366003190112610324576109e2611a65565b6109ea611a7b565b906044356064356001600160401b03811161032457610a0d903690600401611afb565b610a1b838686979497611e07565b813b610a2357005b61043994610a329136916123e0565b92613bba565b34610324576020366003190112610324576004356001600160401b0381116103245761093b610a6d6020923690600401611afb565b90612aa8565b346103245760203660031901126103245760043580610ac2575b335f5260086020528060405f2055337f41f2b80eda6de6f23cab2e867951d054a48d6794db479c1d252bb840a374b62c5f80a3005b610acc5f82614b3d565b1561066957610ada8161208b565b610ae3826120f6565b6001600160a01b03163314159081610b0a575b5015610a8d576282b42960e81b5f5260045ffd5b6001600160a01b0316331415905082610af6565b34610324576060366003190112610324576004356024356044356001600160401b03811161032457610b54903690600401611afb565b9091610b605f85614b3d565b1561066957610b6e846120f6565b336001600160a01b039091160361065b57610bf37f65412581168e88a1e60c6459d7f44ae83ad0832e670826c05a4e2476b57af75293855f52600b60205260405f20865f52600660205260405f20545f5260205260405f20835f52602052610bda848260405f2061232b565b604051938493845260406020850152604084019161200a565b0390a2005b3461032457604036600319011261032457610c11611a65565b6024358015158091036103245781601c5263052d173d60211b600852335f52806030600c20555f5260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160205fa3005b34610324576020366003190112610324576004356001600160401b0381116103245761046a6103d9610ca261047e933690600401611afb565b36916123e0565b346103245760203660031901126103245761047e61046a610cc8611a65565b612a39565b34610324576020366003190112610324576004355f526003602052602060405f2054604051908152f35b34610324575f3660031901126103245761047e604051610d18604082611bae565b600381526257454960e81b6020820152604051918291602083526020830190611a41565b3461032457602061093b610d4f36611c85565b91612479565b3461032457610d6336611c85565b919068929eee149b4bd212685c610808573068929eee149b4bd212685d610d8a5f84614b3d565b1561066957610d98836120f6565b336001600160a01b039091160361090e576020926108f56108fa93339336916123e0565b34610324575f36600319011261032457638b78c6d819546040516001600160a01b039091168152602090f35b3461032457610df636611b28565b90610e015f84614b3d565b1561066957610e0f836120f6565b336001600160a01b039091160361065b577fe379c1624ed7e714cc0937528a32359d69d5281337765313dba4e081b72d757891835f52600a60205260405f20845f52600660205260405f20545f52602052610e6e818360405f2061232b565b610bf360405192839260208452602084019161200a565b34610324576020366003190112610324576004355f5260056020526001600160401b03600260405f2001541680151580610ee6575b80610ecd575b6020906040519015158152f35b506276a700810180911161051757602090421115610ec0565b50804211610eba565b34610324576020366003190112610324576004355f526007602052602060405f2054604051908152f35b3461032457602036600319011261032457600435610f35613b9e565b805f5260036020525f6040812055805f52600460205260405f2060ff1981541690557fe568324f7fe10f2a008b436131dc6e3cba1f4900d03672cb7c2f0bc6014d874c5f80a2005b346103245761047e61046a610f9136611c6f565b90612123565b5f36600319011261032457610faa613b9e565b5f638b78c6d819545f51602061524f5f395f51905f528280a35f638b78c6d81955005b3461032457602036600319011261032457610fe6611a65565b801561101357673ec412a9852d173d60c11b601c525f52602063ffffffff601c600c205416604051908152f35b638f4eb6045f526004601cfd5b34610324576020366003190112610324576004355f526006602052602060405f2054604051908152f35b34610324575f366003190112610324576020600254604051908152f35b34610324575f3660031901126103245760206040515f51602061528f5f395f51905f528152f35b346103245760203660031901126103245760206110ac6004356120f6565b6040516001600160a01b039091168152f35b34610324576110cc36611c6f565b6110d4613b9e565b69021e19e0c9bab24000008211611139576312cc0300811161112a57816040917fbe7168e0341c58e1a3650ad4e471ae8361f53ececb9c508468660ad4762d4d43936001558060025582519182526020820152a1005b63b79f442360e01b5f5260045ffd5b636a435c3f60e01b5f5260045ffd5b60203660031901126103245760043568929eee149b4bd212685c610808573068929eee149b4bd212685d805f52600560205260405f209081549161118b83611b5b565b1561125257600181015461065b576002016001600160401b03815416926276a7008401808511610517574211610669576111c76111cc91611b5b565b613b73565b928334106107fa576301e1338001906001600160401b038211610517576001600160401b03602091817f9b87a00e30f1ac65d898f070f8a3488fe60517182d0a2098e1b4b93a54aa9bd6941682198254161781555416604051908152a280341161123f575b5f68929eee149b4bd212685d005b6107c161124c9134611d09565b80611231565b63677510db60e11b5f5260045ffd5b34610324575f3660031901126103245760205f54604051908152f35b34610324576040366003190112610324576024356001600160401b0381116103245761046a6112b361047e923690600401611afb565b90600435611f31565b5f3660031901126103245763389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2005b34610324575f366003190112610324576020600154604051908152f35b346103245760203660031901126103245760206110ac60043561208b565b34610324576020366003190112610324576004355f526004602052602060ff60405f2054166040519015158152f35b346103245760203660031901126103245761047e61046a600435612062565b61139236611ac1565b61139f8183859495611e07565b823b6113a757005b610439926113b45f611cb7565b926113c26040519485611bae565b5f8452613bba565b34610324576060366003190112610324576004356024356001600160401b038111610324576113fd903690600401611afb565b90916044356001600160401b0381116103245761141e903690600401611afb565b926114295f84614b3d565b1561066957611437836120f6565b336001600160a01b039091160361065b57825f52600c60205260405f20835f52600660205260405f20545f5260205260405f20602060405180928489833784820190815203019020946001600160401b038511611580576114a28561149c8854611b5b565b88611f9a565b5f95601f861160011461150e576114d286805f5160206151ef5f395f51905f529798995f91611503575b50611ff8565b90555b81604051928392833781015f8152039020936114fe60405192839260208452602084019161200a565b0390a3005b90508601358a6114cc565b601f19861696815f5260205f20975f5b818110611568575090875f5160206151ef5f395f51905f52979899921061154f575b5050600187811b0190556114d5565b8501355f1960038a901b60f8161c191690558780611540565b868301358a556001909901986020928301920161151e565b634e487b7160e01b5f52604160045260245ffd5b34610324575f366003190112610324576115ac613b9e565b68929eee149b4bd212685c610808573068929eee149b4bd212685d5f38818047335af1156115e2575f68929eee149b4bd212685d005b63b12d13eb5f526004601cfd5b34610324576020366003190112610324576004355f52600560205261164160405f2061161a81611bcf565b906001600160401b036002600183015492015460405194859460a0865260a0860190611a41565b9260208501528181166040850152818160401c16606085015260801c1660808301520390f35b346103245761047e61046a61167b36611b28565b91611f31565b5f3660031901126103245763389a75e1600c52335f526202a30042016020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a2005b6104396116d636611ac1565b91611e07565b34610324576040366003190112610324576004356001600160401b0381116103245761170c903690600401611a91565b906024356001600160401b0381116103245761172c903690600401611a91565b91611735613b9e565b8284036117d7575f5b84811061174757005b806117556001928686611de3565b35611761828886611de3565b355f52600360205260405f2055611779818785611de3565b355f52600460205260405f208260ff1982541617905561179a818785611de3565b357fadd2efedcdc5598ad566905ef80acdf7f8d770d29412b8dbeebff48a07f0c6b460206117c9848989611de3565b35604051908152a20161173e565b631fec674760e31b5f5260045ffd5b34610324576020366003190112610324576020610346600435611d16565b34610324576020366003190112610324576004355f52600560205260206001600160401b03600260405f20015416604051908152f35b60403660031901126103245761184e611a65565b6024355f818152673ec412a9852d173d60c11b3317601c526020902081018101805491926001600160a01b0390811692169081156118e2578290823314331517156118be575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a4005b9050815f526030600c2054156118d5578290611894565b634b6e7f185f526004601cfd5b63ceea21b65f526004601cfd5b34610324576020366003190112610324576004355f818152673ec412a9852d173d60c11b601c5260209020810101805460601b156118e257600101546040516001600160a01b039091168152602090f35b34610324575f3660031901126103245761047e604051611961604082611bae565b601081526f576569204e616d65205365727669636560801b6020820152604051918291602083526020830190611a41565b3461032457602036600319011261032457600435906001600160e01b0319821680830361032457602092631d9dabef60e11b8214918215611a30575b8215611a1f575b8215611a0e575b5081156119eb575b5015158152f35b905060e01c635b5e139f8114906301ffc9a76380ac58cd821491141717836119e4565b63bc1c58d160e01b149150846119dc565b631674750f60e21b811492506119d5565b6378e5bf0360e11b811492506119ce565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b038216820361032457565b602435906001600160a01b038216820361032457565b9181601f84011215610324578235916001600160401b038311610324576020808501948460051b01011161032457565b6060906003190112610324576004356001600160a01b038116810361032457906024356001600160a01b0381168103610324579060443590565b9181601f84011215610324578235916001600160401b038311610324576020838186019501011161032457565b9060406003198301126103245760043591602435906001600160401b03821161032457611b5791600401611afb565b9091565b90600182811c92168015611b89575b6020831014611b7557565b634e487b7160e01b5f52602260045260245ffd5b91607f1691611b6a565b60a081019081106001600160401b0382111761158057604052565b90601f801991011681019081106001600160401b0382111761158057604052565b9060405191825f825492611be284611b5b565b8084529360018116908115611c4d5750600114611c09575b50611c0792500383611bae565b565b90505f9291925260205f20905f915b818310611c31575050906020611c07928201015f611bfa565b6020919350806001915483858901015201910190918492611c18565b905060209250611c0794915060ff191682840152151560051b8201015f611bfa565b6040906003190112610324576004359060243590565b604060031982011261032457600435906001600160401b03821161032457611caf91600401611afb565b909160243590565b6001600160401b03811161158057601f01601f191660200190565b611cdb5f611cb7565b90611ce96040519283611bae565b5f8252565b906001820180921161051757565b9190820180921161051757565b9190820391821161051757565b5f52600560205260405f20611d2b8154611b5b565b158015611dd6575b611dd157600154801591828015611dc7575b611dc05760026001600160401b03910154166276a70081018091116105175780421115611dc057611d769042611d09565b916002549283811015611db857611d8d9084611d09565b808302928304141715610517578115611da4570490565b634e487b7160e01b5f52601260045260245ffd5b505050505f90565b5050505f90565b5060025415611d45565b505f90565b5060018101541515611d33565b9190811015611df35760051b0190565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b038116151580611f1f575b611f02575b5f838152673ec412a9852d173d60c11b3317601c52602090208301830180546001600160a01b0393841693928316928116808414810215611eed5750825f528160010180548033148533141715611ed6575b611ecd575b50838318189055601c600c205f198154019055815f52601c600c2060018154019063ffffffff8216840215611eb857555f51602061526f5f395f51905f525f80a4565b67ea553b3401336cea841560021b526004601cfd5b5f90555f611e75565b6030600c2054611e7057634b6e7f185f526004601cfd5b67ceea21b6a1148100901560021b526004601cfd5b611f0c5f84614b3d565b611e1e57630407b05b60e31b5f5260045ffd5b506001600160a01b0382161515611e19565b919091611f3e5f82614b3d565b15611f8357611f8092816020925f52600c835260405f20905f526006835260405f20545f52825260405f20836040519485938437820190815203019020611bcf565b90565b505050604051611f94602082611bae565b5f815290565b919091601f8311611fab575b505050565b818311611fb757505050565b5f5260205f206020601f830160051c9210611ff0575b81601f9101920160051c03905f5b82811015611fa6575f82820155600101611fdb565b5f9150611fcd565b8160011b915f199060031b1c19161790565b908060209392818452848401375f828201840152601f01601f1916010190565b90611c076004602080946040519581879251918291018484015e8101632e77656960e01b838201520301601b19810185520183611bae565b5f61206c91614cbf565b80511561207c57611f809061202a565b50604051611f94602082611bae565b6120955f82614b3d565b15611dd1575f818152600960209081526040808320600683528184205484529091529020546001600160a01b03169081156120ce575090565b611f8091506120f6565b6001600160401b036001911601906001600160401b03821161051757565b5f818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b03169081156118e257565b61212d5f82614b3d565b1561231b57805f52600660205260405f205490603c8314612205575b5f52600b60205260405f20905f5260205260405f20905f5260205260405f2060405190815f82549261217a84611b5b565b80845293600181169081156121e3575060011461219f575b50611f8092500382611bae565b90505f9291925260205f20905f915b8183106121c7575050906020611f80928201015f612192565b60209193508060019154838588010152019101909183926121ae565b905060209250611f8094915060ff191682840152151560051b8201015f612192565b805f52600b60205260405f20825f5260205260405f20603c5f5260205260405f2060405190815f82549261223884611b5b565b80845293600181169081156122f957506001146122b5575b5061225d92500382611bae565b80516122ae575061226d8161208b565b6001600160a01b0381166122815750612149565b60405160609190911b6001600160601b0319166020820152601481529250611f8091506034905082611bae565b9250505090565b90505f9291925260205f20905f915b8183106122dd57505090602061225d928201015f612250565b60209193508060019154838588010152019101909183926122c4565b90506020925061225d94915060ff191682840152151560051b8201015f612250565b5050604051611f94602082611bae565b9092916001600160401b038111611580576123508161234a8454611b5b565b84611f9a565b5f601f82116001146123815781906123729394955f92612376575b5050611ff8565b9055565b013590505f8061236b565b601f19821694835f5260205f20915f5b8781106123c85750836001959697106123af575b505050811b019055565b01355f19600384901b60f8161c191690555f80806123a5565b90926020600181928686013581550194019101612391565b9291926123ec82611cb7565b916123fa6040519384611bae565b829481845281830111610324578281602093845f960137010152565b9061242082611cb7565b61242d6040519182611bae565b828152809261243e601f1991611cb7565b0190602036910137565b908151811015611df3570160200190565b60ff60209116019060ff821161051757565b5f1981146105175760010190565b6124849136916123e0565b8051600181108015612a2f575b611dc05761249e90612416565b905f5b81518110156128de576124b48183612448565b5160f81c602081118015906128d4575b80156128ca575b6125e957608081101561254557908160416125179310158061253a575b1561251f576001600160f81b03199061250090612459565b60f81b165b5f1a6125118286612448565b5361246b565b925b926124a1565b506001600160f81b03196125338285612448565b5116612505565b50605a8111156124e8565b60c28110156125575750505050505f90565b60e08110156125fd5750600181018082116105175782518110156125e95761257f8184612448565b5160f81c608081109081156125f2575b506125e9576001600160f81b03196125a78385612448565b51165f1a6125b58386612448565b536125d76001600160f81b03196125cc8386612448565b51165f1a9185612448565b53600281018091116105175792612519565b50505050505f90565b60bf9150115f61258f565b60f08110156127395760028201908183116105175783518210156126ec576001830190818411610517576126318286612448565b5160f81c906126408487612448565b5160f81c6080831090811561272e575b8115612723575b8115612718575b506127025760e081148061270e575b6127025760ed1490816126f6575b506126ec576001600160f81b03196126938486612448565b51165f1a6126a18487612448565b536126c36001600160f81b03196126b88387612448565b51165f1a9186612448565b536126da6001600160f81b03196125cc8386612448565b53600381018091116105175792612519565b5050505050505f90565b60a0915010155f61267b565b50505050505050505f90565b5060a0821061266d565b60bf9150115f61265e565b608081109150612657565b60bf84119150612650565b60f58110156125e95760038201908183116105175783518210156126ec57600183018084116105175761276c8186612448565b5160f81c6002850192838611610517576127868488612448565b5160f81c6127948689612448565b5160f81c608084109182156128bf575b82156128b4575b82156128a9575b50811561289e575b8115612893575b5061287c5760f0811480612889575b61287c5760f4149081612871575b50612866576001600160f81b03196127f68587612448565b51165f1a6128048588612448565b536128266001600160f81b031961281b8388612448565b51165f1a9187612448565b5361283d6001600160f81b03196126b88387612448565b536128546001600160f81b03196125cc8386612448565b53600481018091116105175792612519565b505050505050505f90565b608f9150115f6127de565b5050505050505050505f90565b50609082106127d0565b60bf9150115f6127c1565b6080811091506127ba565b60bf1091505f6127b2565b6080811092506127ab565b60bf851192506127a4565b50602e81146124cb565b50607f81146124c4565b5090805115611df3576020810191602d60f81b60ff60f81b845116149081156129ff575b50611dc05782159182156129f8575f51602061528f5f395f51905f52915b5190206040519060208201928352604082015260408152612942606082611bae565b519020901580806129e7575b611dc05780806129d4575b611dc057612966826143e8565b156129cc57815f52600560205260405f20916001830154156129bf575061298d5750505f90565b60026001600160401b0391015460801c16905f5260056020526001600160401b03600260405f20015460401c16141590565b915050611f809150613b0e565b505050600190565b50600a6129e0846143a7565b1015612959565b506129f25f84614b3d565b1561294e565b8391612920565b515f1981019150811161051757602d60f81b906001600160f81b031990612a269084612448565b5116145f612902565b5060ff8111612491565b6001600160a01b03165f81815260086020526040902054908115908115612a95575b8115612a79575b5061207c57612a745f611f8092614cbf565b61202a565b90506001600160a01b03612a8c8361208b565b1614155f612a62565b9050612aa15f83614b3d565b1590612a5b565b612ab39136916123e0565b5f5b8151811015612ae157607f612aca8284612448565b5160f81c11612adb57600101612ab5565b50505f90565b5050600190565b612af25f82614b3d565b1561207c57805f52600a60205260405f20905f52600660205260405f20545f5260205260405f2060405190815f825492612b2b84611b5b565b80845293600181169081156121e35750600114612b4f5750611f8092500382611bae565b90505f9291925260205f20905f915b818310612b77575050906020611f80928201015f612192565b6020919350806001915483858801015201910190918392612b5e565b90611c07603d6020936040519485917f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000828401528051918291018484015e81015f838201520301601f198101845283611bae565b612bf0816143e8565b1561125257805f52600560205260405f20906001820154908115918215613461575b50612c1d5f82614b3d565b156131bf57612a745f612c2f92614cbf565b916014835111155f1461317b5782915b1561310c5760026001600160401b0391015416604051600a608082019260a083016040525f8452925b5f190192603082820601845304918215612c8457600a90612c68565b6020925060f8612d39612d33600d93612d2d60026065612e7498608085601f19810192030181526040519485917f2c2261747472696275746573223a5b7b2274726169745f74797065223a2245788d8401527f7069726573222c22646973706c61795f74797065223a2264617465222c227661604084015264363ab2911d60d91b60608401525180918484015e8101617d5d60f01b838201520301601d19810184520182611bae565b97614933565b95614d91565b6040519485917f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f3230828401527f30302f737667222076696577426f783d223020302034303020343030223e3c7260408401527f6563742077696474683d2234303022206865696768743d22343030222066696c60608401527f6c3d2223666666222f3e3c7465787420783d223230302220793d22323030222060808401527f666f6e742d66616d696c793d2273616e732d73657269662220666f6e742d736960a08401527f7a653d2232342220746578742d616e63686f723d226d6964646c652220646f6d60c08401527734b730b73a16b130b9b2b634b7329e9136b4b2323632911f60411b60e08401528051918291018484015e81016c1e17ba32bc3a1f1e17b9bb339f60991b838201520301601219810184520182611bae565b80516060918082613043575b5050506001612f68926025602060299660238286976040519a8b97683d913730b6b2911d1160b91b848a0152805190848101918083858d015e8a01907f222c226465736372697074696f6e223a22576569204e616d652053657276696384830152620329d160ed1b6049830152518092604c83015e0101907f222c22696d616765223a22646174613a696d6167652f7376672b786d6c3b626184830152641cd94d8d0b60da1b6043830152805192839101604883015e010190601160f91b84830152805192839101602683015e0101607d60f81b838201520301601e19810184520182611bae565b8060609080519283612f81575b5050611f809150612b93565b9091506003600284010460021b90604051925f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f5260208401948385019560208281890194010190600460038351965f85525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f51815201908482101561301857600490600390612fd7565b509250611f80965f9460409252016040526003613d3d60f01b91066002048203525281525f80612f75565b91939092506003600285010460021b92604051945f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f52602086019685870197602083818b0195010190600460038351985f85525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f5181520190858210156130dc5760049060039061309b565b509590526040978801909752613d3d60f01b6003909106600204840352505f909152908252906001826025612e80565b506020612e74600d60f8612d39612d3360405161312a606082611bae565b603981527f2c2261747472696275746573223a5b7b2274726169745f74797065223a22547987820152787065222c2276616c7565223a22537562646f6d61696e227d5d60381b604082015297614933565b60206131b960038261318c87614892565b6040519481869251918291018484015e81016217171760e91b838201520301601c19810184520182611bae565b91612c3f565b5050506101c06131d26040519182611bae565b61018c81527f7b226e616d65223a225b457870697265645d222c226465736372697074696f6e60208201527f223a2254686973206e616d652068617320657870697265642e222c22696d616760408201527f65223a22646174613a696d6167652f7376672b786d6c3b6261736536342c504860608201527f4e325a79423462577875637a30696148523063446f764c336433647935334d7960808201527f3576636d63764d6a41774d43397a646d636949485a705a58644362336739496a60a08201527f41674d4341304d4441674e444177496a3438636d566a6443423361575230614460c08201527f30694e4441774969426f5a576c6e61485139496a51774d4349675a6d6c73624460e08201527f3069497a6b354f534976506a78305a58683049486739496a49774d43496765546101008201527f30694d6a41774969426d623235304c575a6862576c73655430696332467563796101208201527f317a5a584a705a6949675a6d39756443317a6158706c505349794e43496764476101408201527f563464433168626d4e6f62334939496d31705a4752735a5349675a6d6c7362446101608201527f306949325a6d5a69492b5730563463476c795a575264504339305a586830506a6101808201526b777663335a6e50673d3d227d60a01b6101a082015280604051905f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f5260208201906101ac6102308401910191600460038451965f86525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f51815201908282101561344157600490600390613400565b50939091525061025081016040525f9091526102108152611f8090612b93565b5f52600560205260405f206001600160401b036002818187015460801c1692015460401c1603613491575f612c12565b5050506101c06134a46040519182611bae565b61019881527f7b226e616d65223a225b496e76616c69645d222c226465736372697074696f6e60208201527f223a225468697320737562646f6d61696e206973206e6f206c6f6e676572207660408201527f616c69642e222c22696d616765223a22646174613a696d6167652f7376672b7860608201527f6d6c3b6261736536342c50484e325a79423462577875637a306961485230634460808201527f6f764c336433647935334d793576636d63764d6a41774d43397a646d6369494860a08201527f5a705a58644362336739496a41674d4341304d4441674e444177496a3438636d60c08201527f566a6443423361575230614430694e4441774969426f5a576c6e61485139496a60e08201527f51774d4349675a6d6c7362443069497a6b354f534976506a78305a58683049486101008201527f6739496a49774d434967655430694d6a41774969426d623235304c575a6862576101208201527f6c7365543069633246756379317a5a584a705a6949675a6d39756443317a61586101408201527f706c505349794e4349676447563464433168626d4e6f62334939496d31705a476101608201527f52735a5349675a6d6c736244306949325a6d5a69492b57306c75646d46736157610180820152775264504339305a586830506a777663335a6e50673d3d227d60401b6101a082015280604051905f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f5260208201906101b86102408401910191600460038451965f86525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f51815201908282101561371f576004906003906136de565b50939091525061026081016040525f9091526102208152611f8090612b93565b61374a9136916123e0565b80519081156139a95781600481101580613adf575b80613a85575b80613a2b575b806139d2575b6139bc575b5081156139a957805115611df35760208101516001600160f81b031916601760f91b14801561397b575b61396c575f51602061528f5f395f51905f529180805b6138715750806137c557505090565b6137ce81612416565b915f5b82811061380757505050602081519101206040519060208201928352604082015260408152613801606082611bae565b51902090565b8061381460019284612448565b516001600160f81b03198116604160f81b81101580613863575b1561385c575060f890811c602001901b6001600160f81b0319165b5f1a6138558287612448565b53016137d1565b9050613849565b50602d60f91b81111561382e565b5f19810181811161051757601760f91b6001600160f81b03196138948387612448565b5116146138ac575b508015610517575f1901806137b6565b9390918083101561396c578290036138c381612416565b905f5b8181106139005750506020815191012060405190602082019283526040820152604081526138f5606082611bae565b51902092905f61389c565b8061390f600192870188612448565b516001600160f81b03198116604160f81b8110158061395e575b15613957575060f890811c602001901b6001600160f81b0319165b5f1a6139508286612448565b53016138c6565b9050613944565b50602d60f91b811115613929565b63cccf65f560e01b5f5260045ffd5b505f19820182811161051757601760f91b906001600160f81b0319906139a19084612448565b5116146137a0565b50505f51602061528f5f395f51905f5290565b909150600319810190811161051757905f613776565b505f19810181811161051757606960f81b6001600160f81b03196139f68386612448565b511614908115613a07575b50613771565b604960f81b91506001600160f81b031990613a229085612448565b5116145f613a01565b50600119810181811161051757606560f81b6001600160f81b0319613a508386612448565b511614908115613a61575b5061376b565b604560f81b91506001600160f81b031990613a7c9085612448565b5116145f613a5b565b50600219810181811161051757607760f81b6001600160f81b0319613aaa8386612448565b511614908115613abb575b50613765565b605760f81b91506001600160f81b031990613ad69085612448565b5116145f613ab5565b50600319810181811161051757601760f91b906001600160f81b031990613b069085612448565b51161461375f565b5f5260056020526001600160401b03600260405f200154168015159081613b33575090565b90506276a700810180911161051757421190565b613b5f60409295949395606083526060830190611a41565b6001600160a01b0390951660208201520152565b805f52600460205260ff60405f2054165f14613b98575f52600360205260405f205490565b505f5490565b638b78c6d819543303613bad57565b6382b429005f526004601cfd5b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152613c38575b505001905f601c8401915af115613c2a575b5163757a42ff60e11b01613c1d57565b63d1a57ed65f526004601cfd5b3d15613c0d573d5f823e3d90fd5b818760c08801920160045afa50805f613bfb565b5f80809338935af1156115e257565b60018060a01b031680638b78c6d819545f51602061524f5f395f51905f525f80a3638b78c6d81955565b613c9190929192614401565b915f51602061528f5f395f51905f52835160208501206040519060208201928352604082015260408152613cc6606082611bae565b51902092835f52600560205260405f2090600191613ce48154611b5b565b613f0b575b506301e133804201804211610517576001600160401b0316604051613d0d81611b93565b82815260208101935f85526001600160401b0360408301931683526001600160401b03606083019116815260808201915f8352885f52600560205260405f2090519586516001600160401b038111611580578a97613d7582613d6f8654611b5b565b86611f9a565b602090601f8311600114613e82575f51602061522f5f395f51905f52989694613e60989694613db9856001600160401b039687966002965f92613e77575050611ff8565b82555b51600182015501945116166001600160401b031984541617835551908254906001600160401b0360801b905160801b16916001600160401b0360401b9060401b1690600160401b600160c01b03191617179055613e32613e1b5f611cb7565b613e286040519182611bae565b5f81528587615106565b835f5260056020526001600160401b03600260405f2001541694604051928392604084526040840190611a41565b60208301969096526001600160a01b0316940390a3565b015190505f8061236b565b90601f19831691855f52815f20925f5b818110613ef05750946001856001600160401b0396956002955f51602061522f5f395f51905f529e9c9a958998613e609f9d9b10613ed8575b505050811b018255613dbc565b01515f1960f88460031b161c191690555f8080613ecb565b8284015185558f9c5060019094019360209384019301613e92565b6002919250016001600160401b038154166276a700810180911161051757421115613fa9576001600160401b03613f46915460401c166120d8565b90613f50856120f6565b613f5986615037565b6001600160a01b03165f818152600860205260409020548614613f96575b50845f52600660205260405f20613f8e815461246b565b90555f613ce9565b5f5260086020525f60408120555f613f77565b630ea075bf60e21b5f5260045ffd5b613fc490939193614401565b8315939084156143a1575f51602061528f5f395f51905f525b815160208301206040519060208201928352604082015260408152614003606082611bae565b5190209385159081614368575b855f52600560205260405f209660019761402a8154611b5b565b6142b3575b5080156142ac576301e133804201804211610517576001600160401b0316905b1561428b575f5b604051986140638a611b93565b858a5260208a0199878b526001600160401b0360408201941684526001600160401b0360608201921682526001600160401b036080820193168352895f52600560205260405f2090519a8b519b6001600160401b038d11611580578c906140ce82613d6f8654611b5b565b601f6020921160011461421657926001600160401b0393926141028e9f9d9e9c9d8060029588975f92613e77575050611ff8565b82555b51600182015501945116166001600160401b031984541617835551908254906001600160401b0360801b905160801b16916001600160401b0360401b9060401b1690600160401b600160c01b0319161717905561417b6141645f611cb7565b6141716040519182611bae565b5f81528583615106565b835f526005602052835f51602061522f5f395f51905f526001600160401b03600260405f20015416926040518091604082526141ba6040830189611a41565b60208301969096526001600160a01b0316940390a36141d857505050565b6142117f380897ee9752efc3f5bd42b9d305b9445504e347e953bd955691a654c20f6b5891604051918291602083526020830190611a41565b0390a3565b908d601f191691845f52815f20925f5b81811061427357508e9f9d9e9c9d6002946001600160401b039794889794836001951061425b575b505050811b018255614105565b01515f1960f88460031b161c191690555f808061424e565b92936020600181928786015181550195019301614226565b845f5260056020526001600160401b03600260405f20015460401c16614056565b5f9061404f565b90809850614338575b6001600160401b0360026142d592015460401c166120d8565b966142df876120f6565b6142e888615037565b6001600160a01b03165f818152600860205260409020548814614325575b50865f52600660205260405f2061431d815461246b565b90555f61402f565b5f5260086020525f60408120555f614306565b6001600160401b036002820154166276a70081018091116105175742116142bc57630ea075bf60e21b5f5260045ffd5b614371846120f6565b336001600160a01b039091160361090e57600a61438d856143a7565b10614010576388ac5cad60e01b5f5260045ffd5b81613fdd565b905f91805b6143b35750565b5f526005602052600160405f2001549182156143e4576143d29061246b565b91600a83116143e157806143ac565b50565b9150565b5f5260056020526143fc60405f2054611b5b565b151590565b805160018110908115614887575b506148785761441e8151612416565b905f5b815181101561481b576144348183612448565b5160f81c60208111801590614811575b8015614807575b6145565760808110156144b55790816041614480931015806144aa575b15614488576001600160f81b03199061250090612459565b925b92614421565b506001600160f81b031961449c8285612448565b51165f1a6125118286612448565b50605a811115614468565b60c28110156144cd5763430f13b360e01b5f5260045ffd5b60e081101561457e575060018101808211610517578251811015614556575f60806144f88386612448565b5160f81c108015614565575b614556576001600160f81b031961451b8486612448565b51165f1a6145298487612448565b53610517576145446001600160f81b03196125cc8386612448565b53600281018091116105175792614482565b63430f13b360e01b5f5260045ffd5b50505f60bf6145748386612448565b5160f81c11614504565b60f0811015614699576002820190818311610517578351821015614556576001830190818411610517576145b28286612448565b5160f81c906145c18487612448565b5160f81c6080831090811561468e575b8115614683575b8115614678575b506145565760e081148061466e575b6145565760ed149081614662575b50614556576001600160f81b03196146148486612448565b51165f1a6146228487612448565b536146396001600160f81b03196126b88387612448565b536146506001600160f81b03196125cc8386612448565b53600381018091116105175792614482565b60a0915010155f6145fc565b5060a082106145ee565b60bf9150115f6145df565b6080811091506145d8565b60bf841191506145d1565b60f58110156145565760038201908183116105175783518210156145565760018301808411610517576146cc8186612448565b5160f81c6002850192838611610517576146e68488612448565b5160f81c6146f48689612448565b5160f81c608084109182156147fc575b82156147f1575b82156147e6575b5081156147db575b81156147d0575b506145565760f08114806147c6575b6145565760f41490816147bb575b50614556576001600160f81b03196147568587612448565b51165f1a6147648588612448565b5361477b6001600160f81b031961281b8388612448565b536147926001600160f81b03196126b88387612448565b536147a96001600160f81b03196125cc8386612448565b53600481018091116105175792614482565b608f9150115f61473e565b5060908210614730565b60bf9150115f614721565b60808110915061471a565b60bf1091505f614712565b60808110925061470b565b60bf85119250614704565b50602e811461444b565b50607f8114614444565b50815115611df35760208201516001600160f81b031916602d60f81b14908115614848575b506145565790565b515f1981019150811161051757602d60f81b906001600160f81b03199061486f9084612448565b5116145f614840565b63251f56a160e21b5f5260045ffd5b60ff9150115f61440f565b601181511115611f805760115b8015158061491b575b80614903575b156148bb575f190161489f565b9190916148c781612416565b905f5b8181106148d8575090925050565b6001906001600160f81b03196148ee8288612448565b51165f1a6148fc8286612448565b53016148ca565b5060bf6149108284612448565b5160f81c11156148ae565b5060806149288284612448565b5160f81c10156148a8565b905f5f5b83518110156149ed5761494a8185612448565b516001600160f81b03198116601160f91b811480156149e0575b1561497a57505090600260019101915b01614937565b600560f91b81149081156149d2575b81156149c4575b50156149a457509060026001910191614974565b60209060f81c10156149b9575b600190614974565b6001909101906149b1565b600960f81b1490505f614990565b600d60f81b81149150614989565b50601760fa1b8114614964565b50825181146143e1576149ff90612416565b5f805b8451821015614b3657614a158286612448565b516001600160f81b031981169290601160f91b8403614a5d57508192506022614a546002600180950195605c614a4b828a612448565b53019486612448565b535b0190614a02565b601760fa1b8403614a8a5750819250605c614a84600260018095019583614a4b828a612448565b53614a56565b600560f91b8403614ab25750819250606e614a846002600180950195605c614a4b828a612448565b600d60f81b8403614ada57508192506072614a846002600180950195605c614a4b828a612448565b600960f81b8403614b0257508192506074614a846002600180950195605c614a4b828a612448565b60209060f81c1015614b19575b6001919250614a56565b81614b2d600180949201945f1a9186612448565b53829150614b0f565b5090925050565b600a8211612adb57614b57905f52600560205260405f2090565b90614b628254611b5b565b15612adb57600182015480614b9757505060020154614b91906001600160401b03165b6001600160401b031690565b42111590565b90916002614bb19101546001600160401b039060801c1690565b6001600160401b03614be4614b856002614bd3865f52600560205260405f2090565b015460401c6001600160401b031690565b911603612adb57614bf7611f8092611cee565b90614b3d565b919060405180935f90805490614c1282611b5b565b9160018116908115614c9a5750600114614c59575b505090602082611c0794601760f91b600195528051928391018583015e015f838201520301601f198101845283611bae565b9091505f5260205f205f905b828210614c7e5750508101602090810190611c07614c27565b602091929350806001915483858a010152019101859291614c65565b60ff1916602080870191909152831515909302850183019350611c079150614c279050565b80158015614d87575b614d2957614cde905f52600560205260405f2090565b90614ce98254611b5b565b15614d29576001820154908115801580614d4a575b614d3e57614d335790614d13614d1992611cee565b90614cbf565b805115614d2957611f8091614bfd565b5050611f80611cd2565b5050611f8090611bcf565b50505050611f80611cd2565b50600284015460801c6001600160401b03166001600160401b03614d7e614b856002614bd3885f52600560205260405f2090565b91161415614cfe565b50600a8211614cc8565b5f5f5b8251811015614e36576001600160f81b0319614db08285612448565b5116601360f91b8103614dcd575090600460019101915b01614d94565b600f60fa1b8103614de657509060036001910191614dc7565b601f60f91b8103614dff57509060036001910191614dc7565b601160f91b8103614e1857509060056001910191614dc7565b602760f81b14614e2b575b600190614dc7565b600590910190614e23565b50801561503357614e4b614e50918351611cfc565b612416565b5f805b835182101561502c576001600160f81b0319614e6f8386612448565b511691601360f91b8303614ed2578192506026614e8e60019386612448565b536061614e9d83850186612448565b53606d614ead6002850186612448565b53603b614ec9600560048601956070614a4b600383018a612448565b535b0190614e53565b600f60fa1b8303614f1f578192506026614eee60019386612448565b53606c614efd83850186612448565b53603b614f19600460038601956074614a4b600283018a612448565b53614ecb565b601f60f91b8303614f4a578192506026614f3b60019386612448565b536067614efd83850186612448565b601160f91b8303614fb1578192506026614f6660019386612448565b536071614f7583850186612448565b536075614f856002850186612448565b53606f614f956003850186612448565b53603b614f19600660058601956074614a4b600483018a612448565b602760f81b8303615018578192506026614fcd60019386612448565b536061614fdc83850186612448565b536070614fec6002850186612448565b53606f614ffc6003850186612448565b53603b614f19600660058601956073614a4b600483018a612448565b81614f19600180949201945f1a9186612448565b5050905090565b5090565b6001600160a01b03615048826120f6565b161515806150ff575b6150e2575b5f818152673ec412a9852d173d60c11b601c5260209020810181018054906001600160a01b0382169081156118e257815f52806001019283548015600117156150d0575b905f9484926150c7575b50189055601c600c20821981540190555f51602061526f5f395f51905f528280a4565b8590555f6150a4565b906030600c2054156118d5579061509a565b6150ec5f82614b3d565b61505657630407b05b60e31b5f5260045ffd5b505f615051565b9060018060a01b038216815f52673ec412a9852d173d60c11b601c5260205f208201820180548060601b6151e15782179055805f52601c600c2060018154019063ffffffff82168302156151cc575581905f5f51602061526f5f395f51905f528180a4813b61517457505050565b60209160a460405194859363150b7a02855233868601525f6040860152606085015260808085015280518091818060a0880152613c3857505001905f601c8401915af115613c2a575163757a42ff60e11b01613c1d57565b67ea553b3401336cea831560021b526004601cfd5b63c991cbb15f526004601cfdfed8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a75504142434445464748494a4b4c4d4e4f505152535455565758595a616263646566e9b829b8676c143f46f458c54ab9eedea80dc58eaec9c3df7e0134aabf7f9d288be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa82820059d5df798546bcc2985157a77c3eef25eba9ba01899927333efacbd6f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fa264697066735822122003737a7d71c178842e4c8cf547fd8d5a55c8747a23c6ff009ddb658e6fde2a5b64736f6c63430008210033

Deployed Bytecode

0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a7146119925750806306fdde0314611940578063081812fc146118ef578063095ea7b31461183a57806317c95709146118045780631bf1fffb146117e65780631c0c70cc146116dc57806323b872dd146116ca5780632569296214611681578063308e33861461166757806334461067146115ef5780633b3b57de1461131d5780633ccfd60b146115945780633fb24782146113ca57806342842e0e14611389578063465411c11461136a5780634de0c05a1461133b5780634f896d4f1461131d57806351b79d551461130057806354d1f13d146112bc57806359d1d43c1461127d5780635a6c72d0146112615780635baa75091461114857806362894d12146110be5780636352211e1461108e57806369243129146110675780636abaaa441461104a5780636f40aeb51461102057806370a0823114610fcd578063715018a614610f97578063724474cd14610f7d5780637b22f8cb14610f19578063839df94514610eef57806385a8df9e14610e8557806388f97a6714610de85780638da5cb5b14610dbc5780638f449b8514610d555780638f8dc38614610d3c57806395d89b4114610cf75780639aa4bf3314610ccd5780639af8b7aa14610ca95780639f10f4b514610c69578063a22cb46514610bf8578063a435a04614610b1e578063a4f6965714610a73578063acd6476e14610a38578063b88d4fde146109ce578063bc1c58d114610945578063c87b56dd146109af578063c93a6c8414610964578063cb323d7614610945578063d3c08b131461034e578063d9548e531461091d578063df456c9014610859578063e985e9c514610815578063ea9384fa14610678578063eba36dbd146105b0578063eba951aa14610578578063f04e283e1461052b578063f14fcbc814610482578063f1cb7e0614610448578063f2fde38b1461040b578063f49826be14610389578063fb0219391461034e578063fcee45f4146103285763fee81cf4146102f2575f80fd5b346103245760203660031901126103245761030b611a65565b63389a75e1600c525f52602080600c2054604051908152f35b5f80fd5b34610324576020366003190112610324576020610346600435613b73565b604051908152f35b34610324576020366003190112610324576004356001600160401b038111610324576103466103836020923690600401611afb565b9061373f565b34610324576060366003190112610324576004356001600160401b038111610324576103d96103f26104006103de6103c76020953690600401611afb565b94906103d1611a7b565b9536916123e0565b614401565b604051928391868301956044359187613b47565b03601f198101835282611bae565b519020604051908152f35b60203660031901126103245761041f611a65565b610427613b9e565b8060601b1561043b5761043990613c5b565b005b637448fbae5f526004601cfd5b346103245760403660031901126103245761047e61046a602435600435612123565b604051918291602083526020830190611a41565b0390f35b3461032457602036600319011261032457600435805f52600760205260405f20541515806104f4575b6104e557805f5260076020524260405f205533907ffda886b5d38d5d61e432b3acc9f19640a2b8c83c87a9c584a780d3854b309b9c5f80a3005b6317fd8aab60e31b5f5260045ffd5b50805f52600760205260405f2054620151808101809111610517574211156104ab565b634e487b7160e01b5f52601160045260245ffd5b60203660031901126103245761053f611a65565b610547613b9e565b63389a75e1600c52805f526020600c20908154421161056b575f6104399255613c5b565b636f5e88185f526004601cfd5b34610324576020366003190112610324576001600160a01b03610599611a65565b165f526008602052602060405f2054604051908152f35b34610324576040366003190112610324576004356105cc611a7b565b6105d65f83614b3d565b15610669576105e4826120f6565b336001600160a01b039091160361065b575f8281526009602090815260408083206006835281842054845282529182902080546001600160a01b0319166001600160a01b03909416938417905590519182527f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd291a2005b6282b42960e81b5f5260045ffd5b630407b05b60e31b5f5260045ffd5b6040366003190112610324576004356001600160401b038111610324576106a3903690600401611afb565b9068929eee149b4bd212685c610808576103d96106d7913068929eee149b4bd212685d6106cf84613b73565b9336916123e0565b906107218251602084012060405160208101915f51602061528f5f395f51905f52835260408201526040815261070e606082611bae565b5190209161071b83611d16565b90611cfc565b8034106107fa576040516020810190610742816103f2602435338987613b47565b519020805f52600760205260405f205480156107eb57603c81018082116105175742106107dc576201518081018091116105175742116107cd57602093610796915f52600785525f60408120553390613c85565b508034116107b4575b505f68929eee149b4bd212685d604051908152f35b6107c16107c79134611d09565b33613c4c565b8261079f565b63cfef9a9560e01b5f5260045ffd5b63cba3a53b60e01b5f5260045ffd5b635b34156960e11b5f5260045ffd5b62976f7560e21b5f5260045ffd5b63ab143c065f526004601cfd5b346103245760403660031901126103245761082e611a65565b610836611a7b565b601c5263052d173d60211b6008525f526030600c20546040519015158152602090f35b34610324576060366003190112610324576004356001600160401b03811161032457610889903690600401611afb565b906044356024356001600160a01b03821682036103245768929eee149b4bd212685c610808573068929eee149b4bd212685d6108c55f82614b3d565b15610669576108d3816120f6565b336001600160a01b039091160361090e576108f56108fa9360209536916123e0565b613fb8565b5f68929eee149b4bd212685d604051908152f35b632588f19b60e11b5f5260045ffd5b3461032457602036600319011261032457602061093b600435613b0e565b6040519015158152f35b346103245760203660031901126103245761047e61046a600435612ae8565b34610324576020366003190112610324577f47c26d86c0cb4918d3bd962b301c7862a23ebc8bd9be594cbb8517e7fa4a4d3b60206004356109a3613b9e565b805f55604051908152a1005b346103245760203660031901126103245761047e61046a600435612be7565b6080366003190112610324576109e2611a65565b6109ea611a7b565b906044356064356001600160401b03811161032457610a0d903690600401611afb565b610a1b838686979497611e07565b813b610a2357005b61043994610a329136916123e0565b92613bba565b34610324576020366003190112610324576004356001600160401b0381116103245761093b610a6d6020923690600401611afb565b90612aa8565b346103245760203660031901126103245760043580610ac2575b335f5260086020528060405f2055337f41f2b80eda6de6f23cab2e867951d054a48d6794db479c1d252bb840a374b62c5f80a3005b610acc5f82614b3d565b1561066957610ada8161208b565b610ae3826120f6565b6001600160a01b03163314159081610b0a575b5015610a8d576282b42960e81b5f5260045ffd5b6001600160a01b0316331415905082610af6565b34610324576060366003190112610324576004356024356044356001600160401b03811161032457610b54903690600401611afb565b9091610b605f85614b3d565b1561066957610b6e846120f6565b336001600160a01b039091160361065b57610bf37f65412581168e88a1e60c6459d7f44ae83ad0832e670826c05a4e2476b57af75293855f52600b60205260405f20865f52600660205260405f20545f5260205260405f20835f52602052610bda848260405f2061232b565b604051938493845260406020850152604084019161200a565b0390a2005b3461032457604036600319011261032457610c11611a65565b6024358015158091036103245781601c5263052d173d60211b600852335f52806030600c20555f5260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160205fa3005b34610324576020366003190112610324576004356001600160401b0381116103245761046a6103d9610ca261047e933690600401611afb565b36916123e0565b346103245760203660031901126103245761047e61046a610cc8611a65565b612a39565b34610324576020366003190112610324576004355f526003602052602060405f2054604051908152f35b34610324575f3660031901126103245761047e604051610d18604082611bae565b600381526257454960e81b6020820152604051918291602083526020830190611a41565b3461032457602061093b610d4f36611c85565b91612479565b3461032457610d6336611c85565b919068929eee149b4bd212685c610808573068929eee149b4bd212685d610d8a5f84614b3d565b1561066957610d98836120f6565b336001600160a01b039091160361090e576020926108f56108fa93339336916123e0565b34610324575f36600319011261032457638b78c6d819546040516001600160a01b039091168152602090f35b3461032457610df636611b28565b90610e015f84614b3d565b1561066957610e0f836120f6565b336001600160a01b039091160361065b577fe379c1624ed7e714cc0937528a32359d69d5281337765313dba4e081b72d757891835f52600a60205260405f20845f52600660205260405f20545f52602052610e6e818360405f2061232b565b610bf360405192839260208452602084019161200a565b34610324576020366003190112610324576004355f5260056020526001600160401b03600260405f2001541680151580610ee6575b80610ecd575b6020906040519015158152f35b506276a700810180911161051757602090421115610ec0565b50804211610eba565b34610324576020366003190112610324576004355f526007602052602060405f2054604051908152f35b3461032457602036600319011261032457600435610f35613b9e565b805f5260036020525f6040812055805f52600460205260405f2060ff1981541690557fe568324f7fe10f2a008b436131dc6e3cba1f4900d03672cb7c2f0bc6014d874c5f80a2005b346103245761047e61046a610f9136611c6f565b90612123565b5f36600319011261032457610faa613b9e565b5f638b78c6d819545f51602061524f5f395f51905f528280a35f638b78c6d81955005b3461032457602036600319011261032457610fe6611a65565b801561101357673ec412a9852d173d60c11b601c525f52602063ffffffff601c600c205416604051908152f35b638f4eb6045f526004601cfd5b34610324576020366003190112610324576004355f526006602052602060405f2054604051908152f35b34610324575f366003190112610324576020600254604051908152f35b34610324575f3660031901126103245760206040515f51602061528f5f395f51905f528152f35b346103245760203660031901126103245760206110ac6004356120f6565b6040516001600160a01b039091168152f35b34610324576110cc36611c6f565b6110d4613b9e565b69021e19e0c9bab24000008211611139576312cc0300811161112a57816040917fbe7168e0341c58e1a3650ad4e471ae8361f53ececb9c508468660ad4762d4d43936001558060025582519182526020820152a1005b63b79f442360e01b5f5260045ffd5b636a435c3f60e01b5f5260045ffd5b60203660031901126103245760043568929eee149b4bd212685c610808573068929eee149b4bd212685d805f52600560205260405f209081549161118b83611b5b565b1561125257600181015461065b576002016001600160401b03815416926276a7008401808511610517574211610669576111c76111cc91611b5b565b613b73565b928334106107fa576301e1338001906001600160401b038211610517576001600160401b03602091817f9b87a00e30f1ac65d898f070f8a3488fe60517182d0a2098e1b4b93a54aa9bd6941682198254161781555416604051908152a280341161123f575b5f68929eee149b4bd212685d005b6107c161124c9134611d09565b80611231565b63677510db60e11b5f5260045ffd5b34610324575f3660031901126103245760205f54604051908152f35b34610324576040366003190112610324576024356001600160401b0381116103245761046a6112b361047e923690600401611afb565b90600435611f31565b5f3660031901126103245763389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2005b34610324575f366003190112610324576020600154604051908152f35b346103245760203660031901126103245760206110ac60043561208b565b34610324576020366003190112610324576004355f526004602052602060ff60405f2054166040519015158152f35b346103245760203660031901126103245761047e61046a600435612062565b61139236611ac1565b61139f8183859495611e07565b823b6113a757005b610439926113b45f611cb7565b926113c26040519485611bae565b5f8452613bba565b34610324576060366003190112610324576004356024356001600160401b038111610324576113fd903690600401611afb565b90916044356001600160401b0381116103245761141e903690600401611afb565b926114295f84614b3d565b1561066957611437836120f6565b336001600160a01b039091160361065b57825f52600c60205260405f20835f52600660205260405f20545f5260205260405f20602060405180928489833784820190815203019020946001600160401b038511611580576114a28561149c8854611b5b565b88611f9a565b5f95601f861160011461150e576114d286805f5160206151ef5f395f51905f529798995f91611503575b50611ff8565b90555b81604051928392833781015f8152039020936114fe60405192839260208452602084019161200a565b0390a3005b90508601358a6114cc565b601f19861696815f5260205f20975f5b818110611568575090875f5160206151ef5f395f51905f52979899921061154f575b5050600187811b0190556114d5565b8501355f1960038a901b60f8161c191690558780611540565b868301358a556001909901986020928301920161151e565b634e487b7160e01b5f52604160045260245ffd5b34610324575f366003190112610324576115ac613b9e565b68929eee149b4bd212685c610808573068929eee149b4bd212685d5f38818047335af1156115e2575f68929eee149b4bd212685d005b63b12d13eb5f526004601cfd5b34610324576020366003190112610324576004355f52600560205261164160405f2061161a81611bcf565b906001600160401b036002600183015492015460405194859460a0865260a0860190611a41565b9260208501528181166040850152818160401c16606085015260801c1660808301520390f35b346103245761047e61046a61167b36611b28565b91611f31565b5f3660031901126103245763389a75e1600c52335f526202a30042016020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a2005b6104396116d636611ac1565b91611e07565b34610324576040366003190112610324576004356001600160401b0381116103245761170c903690600401611a91565b906024356001600160401b0381116103245761172c903690600401611a91565b91611735613b9e565b8284036117d7575f5b84811061174757005b806117556001928686611de3565b35611761828886611de3565b355f52600360205260405f2055611779818785611de3565b355f52600460205260405f208260ff1982541617905561179a818785611de3565b357fadd2efedcdc5598ad566905ef80acdf7f8d770d29412b8dbeebff48a07f0c6b460206117c9848989611de3565b35604051908152a20161173e565b631fec674760e31b5f5260045ffd5b34610324576020366003190112610324576020610346600435611d16565b34610324576020366003190112610324576004355f52600560205260206001600160401b03600260405f20015416604051908152f35b60403660031901126103245761184e611a65565b6024355f818152673ec412a9852d173d60c11b3317601c526020902081018101805491926001600160a01b0390811692169081156118e2578290823314331517156118be575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a4005b9050815f526030600c2054156118d5578290611894565b634b6e7f185f526004601cfd5b63ceea21b65f526004601cfd5b34610324576020366003190112610324576004355f818152673ec412a9852d173d60c11b601c5260209020810101805460601b156118e257600101546040516001600160a01b039091168152602090f35b34610324575f3660031901126103245761047e604051611961604082611bae565b601081526f576569204e616d65205365727669636560801b6020820152604051918291602083526020830190611a41565b3461032457602036600319011261032457600435906001600160e01b0319821680830361032457602092631d9dabef60e11b8214918215611a30575b8215611a1f575b8215611a0e575b5081156119eb575b5015158152f35b905060e01c635b5e139f8114906301ffc9a76380ac58cd821491141717836119e4565b63bc1c58d160e01b149150846119dc565b631674750f60e21b811492506119d5565b6378e5bf0360e11b811492506119ce565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b038216820361032457565b602435906001600160a01b038216820361032457565b9181601f84011215610324578235916001600160401b038311610324576020808501948460051b01011161032457565b6060906003190112610324576004356001600160a01b038116810361032457906024356001600160a01b0381168103610324579060443590565b9181601f84011215610324578235916001600160401b038311610324576020838186019501011161032457565b9060406003198301126103245760043591602435906001600160401b03821161032457611b5791600401611afb565b9091565b90600182811c92168015611b89575b6020831014611b7557565b634e487b7160e01b5f52602260045260245ffd5b91607f1691611b6a565b60a081019081106001600160401b0382111761158057604052565b90601f801991011681019081106001600160401b0382111761158057604052565b9060405191825f825492611be284611b5b565b8084529360018116908115611c4d5750600114611c09575b50611c0792500383611bae565b565b90505f9291925260205f20905f915b818310611c31575050906020611c07928201015f611bfa565b6020919350806001915483858901015201910190918492611c18565b905060209250611c0794915060ff191682840152151560051b8201015f611bfa565b6040906003190112610324576004359060243590565b604060031982011261032457600435906001600160401b03821161032457611caf91600401611afb565b909160243590565b6001600160401b03811161158057601f01601f191660200190565b611cdb5f611cb7565b90611ce96040519283611bae565b5f8252565b906001820180921161051757565b9190820180921161051757565b9190820391821161051757565b5f52600560205260405f20611d2b8154611b5b565b158015611dd6575b611dd157600154801591828015611dc7575b611dc05760026001600160401b03910154166276a70081018091116105175780421115611dc057611d769042611d09565b916002549283811015611db857611d8d9084611d09565b808302928304141715610517578115611da4570490565b634e487b7160e01b5f52601260045260245ffd5b505050505f90565b5050505f90565b5060025415611d45565b505f90565b5060018101541515611d33565b9190811015611df35760051b0190565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b038116151580611f1f575b611f02575b5f838152673ec412a9852d173d60c11b3317601c52602090208301830180546001600160a01b0393841693928316928116808414810215611eed5750825f528160010180548033148533141715611ed6575b611ecd575b50838318189055601c600c205f198154019055815f52601c600c2060018154019063ffffffff8216840215611eb857555f51602061526f5f395f51905f525f80a4565b67ea553b3401336cea841560021b526004601cfd5b5f90555f611e75565b6030600c2054611e7057634b6e7f185f526004601cfd5b67ceea21b6a1148100901560021b526004601cfd5b611f0c5f84614b3d565b611e1e57630407b05b60e31b5f5260045ffd5b506001600160a01b0382161515611e19565b919091611f3e5f82614b3d565b15611f8357611f8092816020925f52600c835260405f20905f526006835260405f20545f52825260405f20836040519485938437820190815203019020611bcf565b90565b505050604051611f94602082611bae565b5f815290565b919091601f8311611fab575b505050565b818311611fb757505050565b5f5260205f206020601f830160051c9210611ff0575b81601f9101920160051c03905f5b82811015611fa6575f82820155600101611fdb565b5f9150611fcd565b8160011b915f199060031b1c19161790565b908060209392818452848401375f828201840152601f01601f1916010190565b90611c076004602080946040519581879251918291018484015e8101632e77656960e01b838201520301601b19810185520183611bae565b5f61206c91614cbf565b80511561207c57611f809061202a565b50604051611f94602082611bae565b6120955f82614b3d565b15611dd1575f818152600960209081526040808320600683528184205484529091529020546001600160a01b03169081156120ce575090565b611f8091506120f6565b6001600160401b036001911601906001600160401b03821161051757565b5f818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b03169081156118e257565b61212d5f82614b3d565b1561231b57805f52600660205260405f205490603c8314612205575b5f52600b60205260405f20905f5260205260405f20905f5260205260405f2060405190815f82549261217a84611b5b565b80845293600181169081156121e3575060011461219f575b50611f8092500382611bae565b90505f9291925260205f20905f915b8183106121c7575050906020611f80928201015f612192565b60209193508060019154838588010152019101909183926121ae565b905060209250611f8094915060ff191682840152151560051b8201015f612192565b805f52600b60205260405f20825f5260205260405f20603c5f5260205260405f2060405190815f82549261223884611b5b565b80845293600181169081156122f957506001146122b5575b5061225d92500382611bae565b80516122ae575061226d8161208b565b6001600160a01b0381166122815750612149565b60405160609190911b6001600160601b0319166020820152601481529250611f8091506034905082611bae565b9250505090565b90505f9291925260205f20905f915b8183106122dd57505090602061225d928201015f612250565b60209193508060019154838588010152019101909183926122c4565b90506020925061225d94915060ff191682840152151560051b8201015f612250565b5050604051611f94602082611bae565b9092916001600160401b038111611580576123508161234a8454611b5b565b84611f9a565b5f601f82116001146123815781906123729394955f92612376575b5050611ff8565b9055565b013590505f8061236b565b601f19821694835f5260205f20915f5b8781106123c85750836001959697106123af575b505050811b019055565b01355f19600384901b60f8161c191690555f80806123a5565b90926020600181928686013581550194019101612391565b9291926123ec82611cb7565b916123fa6040519384611bae565b829481845281830111610324578281602093845f960137010152565b9061242082611cb7565b61242d6040519182611bae565b828152809261243e601f1991611cb7565b0190602036910137565b908151811015611df3570160200190565b60ff60209116019060ff821161051757565b5f1981146105175760010190565b6124849136916123e0565b8051600181108015612a2f575b611dc05761249e90612416565b905f5b81518110156128de576124b48183612448565b5160f81c602081118015906128d4575b80156128ca575b6125e957608081101561254557908160416125179310158061253a575b1561251f576001600160f81b03199061250090612459565b60f81b165b5f1a6125118286612448565b5361246b565b925b926124a1565b506001600160f81b03196125338285612448565b5116612505565b50605a8111156124e8565b60c28110156125575750505050505f90565b60e08110156125fd5750600181018082116105175782518110156125e95761257f8184612448565b5160f81c608081109081156125f2575b506125e9576001600160f81b03196125a78385612448565b51165f1a6125b58386612448565b536125d76001600160f81b03196125cc8386612448565b51165f1a9185612448565b53600281018091116105175792612519565b50505050505f90565b60bf9150115f61258f565b60f08110156127395760028201908183116105175783518210156126ec576001830190818411610517576126318286612448565b5160f81c906126408487612448565b5160f81c6080831090811561272e575b8115612723575b8115612718575b506127025760e081148061270e575b6127025760ed1490816126f6575b506126ec576001600160f81b03196126938486612448565b51165f1a6126a18487612448565b536126c36001600160f81b03196126b88387612448565b51165f1a9186612448565b536126da6001600160f81b03196125cc8386612448565b53600381018091116105175792612519565b5050505050505f90565b60a0915010155f61267b565b50505050505050505f90565b5060a0821061266d565b60bf9150115f61265e565b608081109150612657565b60bf84119150612650565b60f58110156125e95760038201908183116105175783518210156126ec57600183018084116105175761276c8186612448565b5160f81c6002850192838611610517576127868488612448565b5160f81c6127948689612448565b5160f81c608084109182156128bf575b82156128b4575b82156128a9575b50811561289e575b8115612893575b5061287c5760f0811480612889575b61287c5760f4149081612871575b50612866576001600160f81b03196127f68587612448565b51165f1a6128048588612448565b536128266001600160f81b031961281b8388612448565b51165f1a9187612448565b5361283d6001600160f81b03196126b88387612448565b536128546001600160f81b03196125cc8386612448565b53600481018091116105175792612519565b505050505050505f90565b608f9150115f6127de565b5050505050505050505f90565b50609082106127d0565b60bf9150115f6127c1565b6080811091506127ba565b60bf1091505f6127b2565b6080811092506127ab565b60bf851192506127a4565b50602e81146124cb565b50607f81146124c4565b5090805115611df3576020810191602d60f81b60ff60f81b845116149081156129ff575b50611dc05782159182156129f8575f51602061528f5f395f51905f52915b5190206040519060208201928352604082015260408152612942606082611bae565b519020901580806129e7575b611dc05780806129d4575b611dc057612966826143e8565b156129cc57815f52600560205260405f20916001830154156129bf575061298d5750505f90565b60026001600160401b0391015460801c16905f5260056020526001600160401b03600260405f20015460401c16141590565b915050611f809150613b0e565b505050600190565b50600a6129e0846143a7565b1015612959565b506129f25f84614b3d565b1561294e565b8391612920565b515f1981019150811161051757602d60f81b906001600160f81b031990612a269084612448565b5116145f612902565b5060ff8111612491565b6001600160a01b03165f81815260086020526040902054908115908115612a95575b8115612a79575b5061207c57612a745f611f8092614cbf565b61202a565b90506001600160a01b03612a8c8361208b565b1614155f612a62565b9050612aa15f83614b3d565b1590612a5b565b612ab39136916123e0565b5f5b8151811015612ae157607f612aca8284612448565b5160f81c11612adb57600101612ab5565b50505f90565b5050600190565b612af25f82614b3d565b1561207c57805f52600a60205260405f20905f52600660205260405f20545f5260205260405f2060405190815f825492612b2b84611b5b565b80845293600181169081156121e35750600114612b4f5750611f8092500382611bae565b90505f9291925260205f20905f915b818310612b77575050906020611f80928201015f612192565b6020919350806001915483858801015201910190918392612b5e565b90611c07603d6020936040519485917f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000828401528051918291018484015e81015f838201520301601f198101845283611bae565b612bf0816143e8565b1561125257805f52600560205260405f20906001820154908115918215613461575b50612c1d5f82614b3d565b156131bf57612a745f612c2f92614cbf565b916014835111155f1461317b5782915b1561310c5760026001600160401b0391015416604051600a608082019260a083016040525f8452925b5f190192603082820601845304918215612c8457600a90612c68565b6020925060f8612d39612d33600d93612d2d60026065612e7498608085601f19810192030181526040519485917f2c2261747472696275746573223a5b7b2274726169745f74797065223a2245788d8401527f7069726573222c22646973706c61795f74797065223a2264617465222c227661604084015264363ab2911d60d91b60608401525180918484015e8101617d5d60f01b838201520301601d19810184520182611bae565b97614933565b95614d91565b6040519485917f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f3230828401527f30302f737667222076696577426f783d223020302034303020343030223e3c7260408401527f6563742077696474683d2234303022206865696768743d22343030222066696c60608401527f6c3d2223666666222f3e3c7465787420783d223230302220793d22323030222060808401527f666f6e742d66616d696c793d2273616e732d73657269662220666f6e742d736960a08401527f7a653d2232342220746578742d616e63686f723d226d6964646c652220646f6d60c08401527734b730b73a16b130b9b2b634b7329e9136b4b2323632911f60411b60e08401528051918291018484015e81016c1e17ba32bc3a1f1e17b9bb339f60991b838201520301601219810184520182611bae565b80516060918082613043575b5050506001612f68926025602060299660238286976040519a8b97683d913730b6b2911d1160b91b848a0152805190848101918083858d015e8a01907f222c226465736372697074696f6e223a22576569204e616d652053657276696384830152620329d160ed1b6049830152518092604c83015e0101907f222c22696d616765223a22646174613a696d6167652f7376672b786d6c3b626184830152641cd94d8d0b60da1b6043830152805192839101604883015e010190601160f91b84830152805192839101602683015e0101607d60f81b838201520301601e19810184520182611bae565b8060609080519283612f81575b5050611f809150612b93565b9091506003600284010460021b90604051925f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f5260208401948385019560208281890194010190600460038351965f85525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f51815201908482101561301857600490600390612fd7565b509250611f80965f9460409252016040526003613d3d60f01b91066002048203525281525f80612f75565b91939092506003600285010460021b92604051945f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f52602086019685870197602083818b0195010190600460038351985f85525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f5181520190858210156130dc5760049060039061309b565b509590526040978801909752613d3d60f01b6003909106600204840352505f909152908252906001826025612e80565b506020612e74600d60f8612d39612d3360405161312a606082611bae565b603981527f2c2261747472696275746573223a5b7b2274726169745f74797065223a22547987820152787065222c2276616c7565223a22537562646f6d61696e227d5d60381b604082015297614933565b60206131b960038261318c87614892565b6040519481869251918291018484015e81016217171760e91b838201520301601c19810184520182611bae565b91612c3f565b5050506101c06131d26040519182611bae565b61018c81527f7b226e616d65223a225b457870697265645d222c226465736372697074696f6e60208201527f223a2254686973206e616d652068617320657870697265642e222c22696d616760408201527f65223a22646174613a696d6167652f7376672b786d6c3b6261736536342c504860608201527f4e325a79423462577875637a30696148523063446f764c336433647935334d7960808201527f3576636d63764d6a41774d43397a646d636949485a705a58644362336739496a60a08201527f41674d4341304d4441674e444177496a3438636d566a6443423361575230614460c08201527f30694e4441774969426f5a576c6e61485139496a51774d4349675a6d6c73624460e08201527f3069497a6b354f534976506a78305a58683049486739496a49774d43496765546101008201527f30694d6a41774969426d623235304c575a6862576c73655430696332467563796101208201527f317a5a584a705a6949675a6d39756443317a6158706c505349794e43496764476101408201527f563464433168626d4e6f62334939496d31705a4752735a5349675a6d6c7362446101608201527f306949325a6d5a69492b5730563463476c795a575264504339305a586830506a6101808201526b777663335a6e50673d3d227d60a01b6101a082015280604051905f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f5260208201906101ac6102308401910191600460038451965f86525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f51815201908282101561344157600490600390613400565b50939091525061025081016040525f9091526102108152611f8090612b93565b5f52600560205260405f206001600160401b036002818187015460801c1692015460401c1603613491575f612c12565b5050506101c06134a46040519182611bae565b61019881527f7b226e616d65223a225b496e76616c69645d222c226465736372697074696f6e60208201527f223a225468697320737562646f6d61696e206973206e6f206c6f6e676572207660408201527f616c69642e222c22696d616765223a22646174613a696d6167652f7376672b7860608201527f6d6c3b6261736536342c50484e325a79423462577875637a306961485230634460808201527f6f764c336433647935334d793576636d63764d6a41774d43397a646d6369494860a08201527f5a705a58644362336739496a41674d4341304d4441674e444177496a3438636d60c08201527f566a6443423361575230614430694e4441774969426f5a576c6e61485139496a60e08201527f51774d4349675a6d6c7362443069497a6b354f534976506a78305a58683049486101008201527f6739496a49774d434967655430694d6a41774969426d623235304c575a6862576101208201527f6c7365543069633246756379317a5a584a705a6949675a6d39756443317a61586101408201527f706c505349794e4349676447563464433168626d4e6f62334939496d31705a476101608201527f52735a5349675a6d6c736244306949325a6d5a69492b57306c75646d46736157610180820152775264504339305a586830506a777663335a6e50673d3d227d60401b6101a082015280604051905f51602061520f5f395f51905f52601f526106705f5160206152af5f395f51905f5218603f5260208201906101b86102408401910191600460038451965f86525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f51815201908282101561371f576004906003906136de565b50939091525061026081016040525f9091526102208152611f8090612b93565b61374a9136916123e0565b80519081156139a95781600481101580613adf575b80613a85575b80613a2b575b806139d2575b6139bc575b5081156139a957805115611df35760208101516001600160f81b031916601760f91b14801561397b575b61396c575f51602061528f5f395f51905f529180805b6138715750806137c557505090565b6137ce81612416565b915f5b82811061380757505050602081519101206040519060208201928352604082015260408152613801606082611bae565b51902090565b8061381460019284612448565b516001600160f81b03198116604160f81b81101580613863575b1561385c575060f890811c602001901b6001600160f81b0319165b5f1a6138558287612448565b53016137d1565b9050613849565b50602d60f91b81111561382e565b5f19810181811161051757601760f91b6001600160f81b03196138948387612448565b5116146138ac575b508015610517575f1901806137b6565b9390918083101561396c578290036138c381612416565b905f5b8181106139005750506020815191012060405190602082019283526040820152604081526138f5606082611bae565b51902092905f61389c565b8061390f600192870188612448565b516001600160f81b03198116604160f81b8110158061395e575b15613957575060f890811c602001901b6001600160f81b0319165b5f1a6139508286612448565b53016138c6565b9050613944565b50602d60f91b811115613929565b63cccf65f560e01b5f5260045ffd5b505f19820182811161051757601760f91b906001600160f81b0319906139a19084612448565b5116146137a0565b50505f51602061528f5f395f51905f5290565b909150600319810190811161051757905f613776565b505f19810181811161051757606960f81b6001600160f81b03196139f68386612448565b511614908115613a07575b50613771565b604960f81b91506001600160f81b031990613a229085612448565b5116145f613a01565b50600119810181811161051757606560f81b6001600160f81b0319613a508386612448565b511614908115613a61575b5061376b565b604560f81b91506001600160f81b031990613a7c9085612448565b5116145f613a5b565b50600219810181811161051757607760f81b6001600160f81b0319613aaa8386612448565b511614908115613abb575b50613765565b605760f81b91506001600160f81b031990613ad69085612448565b5116145f613ab5565b50600319810181811161051757601760f91b906001600160f81b031990613b069085612448565b51161461375f565b5f5260056020526001600160401b03600260405f200154168015159081613b33575090565b90506276a700810180911161051757421190565b613b5f60409295949395606083526060830190611a41565b6001600160a01b0390951660208201520152565b805f52600460205260ff60405f2054165f14613b98575f52600360205260405f205490565b505f5490565b638b78c6d819543303613bad57565b6382b429005f526004601cfd5b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152613c38575b505001905f601c8401915af115613c2a575b5163757a42ff60e11b01613c1d57565b63d1a57ed65f526004601cfd5b3d15613c0d573d5f823e3d90fd5b818760c08801920160045afa50805f613bfb565b5f80809338935af1156115e257565b60018060a01b031680638b78c6d819545f51602061524f5f395f51905f525f80a3638b78c6d81955565b613c9190929192614401565b915f51602061528f5f395f51905f52835160208501206040519060208201928352604082015260408152613cc6606082611bae565b51902092835f52600560205260405f2090600191613ce48154611b5b565b613f0b575b506301e133804201804211610517576001600160401b0316604051613d0d81611b93565b82815260208101935f85526001600160401b0360408301931683526001600160401b03606083019116815260808201915f8352885f52600560205260405f2090519586516001600160401b038111611580578a97613d7582613d6f8654611b5b565b86611f9a565b602090601f8311600114613e82575f51602061522f5f395f51905f52989694613e60989694613db9856001600160401b039687966002965f92613e77575050611ff8565b82555b51600182015501945116166001600160401b031984541617835551908254906001600160401b0360801b905160801b16916001600160401b0360401b9060401b1690600160401b600160c01b03191617179055613e32613e1b5f611cb7565b613e286040519182611bae565b5f81528587615106565b835f5260056020526001600160401b03600260405f2001541694604051928392604084526040840190611a41565b60208301969096526001600160a01b0316940390a3565b015190505f8061236b565b90601f19831691855f52815f20925f5b818110613ef05750946001856001600160401b0396956002955f51602061522f5f395f51905f529e9c9a958998613e609f9d9b10613ed8575b505050811b018255613dbc565b01515f1960f88460031b161c191690555f8080613ecb565b8284015185558f9c5060019094019360209384019301613e92565b6002919250016001600160401b038154166276a700810180911161051757421115613fa9576001600160401b03613f46915460401c166120d8565b90613f50856120f6565b613f5986615037565b6001600160a01b03165f818152600860205260409020548614613f96575b50845f52600660205260405f20613f8e815461246b565b90555f613ce9565b5f5260086020525f60408120555f613f77565b630ea075bf60e21b5f5260045ffd5b613fc490939193614401565b8315939084156143a1575f51602061528f5f395f51905f525b815160208301206040519060208201928352604082015260408152614003606082611bae565b5190209385159081614368575b855f52600560205260405f209660019761402a8154611b5b565b6142b3575b5080156142ac576301e133804201804211610517576001600160401b0316905b1561428b575f5b604051986140638a611b93565b858a5260208a0199878b526001600160401b0360408201941684526001600160401b0360608201921682526001600160401b036080820193168352895f52600560205260405f2090519a8b519b6001600160401b038d11611580578c906140ce82613d6f8654611b5b565b601f6020921160011461421657926001600160401b0393926141028e9f9d9e9c9d8060029588975f92613e77575050611ff8565b82555b51600182015501945116166001600160401b031984541617835551908254906001600160401b0360801b905160801b16916001600160401b0360401b9060401b1690600160401b600160c01b0319161717905561417b6141645f611cb7565b6141716040519182611bae565b5f81528583615106565b835f526005602052835f51602061522f5f395f51905f526001600160401b03600260405f20015416926040518091604082526141ba6040830189611a41565b60208301969096526001600160a01b0316940390a36141d857505050565b6142117f380897ee9752efc3f5bd42b9d305b9445504e347e953bd955691a654c20f6b5891604051918291602083526020830190611a41565b0390a3565b908d601f191691845f52815f20925f5b81811061427357508e9f9d9e9c9d6002946001600160401b039794889794836001951061425b575b505050811b018255614105565b01515f1960f88460031b161c191690555f808061424e565b92936020600181928786015181550195019301614226565b845f5260056020526001600160401b03600260405f20015460401c16614056565b5f9061404f565b90809850614338575b6001600160401b0360026142d592015460401c166120d8565b966142df876120f6565b6142e888615037565b6001600160a01b03165f818152600860205260409020548814614325575b50865f52600660205260405f2061431d815461246b565b90555f61402f565b5f5260086020525f60408120555f614306565b6001600160401b036002820154166276a70081018091116105175742116142bc57630ea075bf60e21b5f5260045ffd5b614371846120f6565b336001600160a01b039091160361090e57600a61438d856143a7565b10614010576388ac5cad60e01b5f5260045ffd5b81613fdd565b905f91805b6143b35750565b5f526005602052600160405f2001549182156143e4576143d29061246b565b91600a83116143e157806143ac565b50565b9150565b5f5260056020526143fc60405f2054611b5b565b151590565b805160018110908115614887575b506148785761441e8151612416565b905f5b815181101561481b576144348183612448565b5160f81c60208111801590614811575b8015614807575b6145565760808110156144b55790816041614480931015806144aa575b15614488576001600160f81b03199061250090612459565b925b92614421565b506001600160f81b031961449c8285612448565b51165f1a6125118286612448565b50605a811115614468565b60c28110156144cd5763430f13b360e01b5f5260045ffd5b60e081101561457e575060018101808211610517578251811015614556575f60806144f88386612448565b5160f81c108015614565575b614556576001600160f81b031961451b8486612448565b51165f1a6145298487612448565b53610517576145446001600160f81b03196125cc8386612448565b53600281018091116105175792614482565b63430f13b360e01b5f5260045ffd5b50505f60bf6145748386612448565b5160f81c11614504565b60f0811015614699576002820190818311610517578351821015614556576001830190818411610517576145b28286612448565b5160f81c906145c18487612448565b5160f81c6080831090811561468e575b8115614683575b8115614678575b506145565760e081148061466e575b6145565760ed149081614662575b50614556576001600160f81b03196146148486612448565b51165f1a6146228487612448565b536146396001600160f81b03196126b88387612448565b536146506001600160f81b03196125cc8386612448565b53600381018091116105175792614482565b60a0915010155f6145fc565b5060a082106145ee565b60bf9150115f6145df565b6080811091506145d8565b60bf841191506145d1565b60f58110156145565760038201908183116105175783518210156145565760018301808411610517576146cc8186612448565b5160f81c6002850192838611610517576146e68488612448565b5160f81c6146f48689612448565b5160f81c608084109182156147fc575b82156147f1575b82156147e6575b5081156147db575b81156147d0575b506145565760f08114806147c6575b6145565760f41490816147bb575b50614556576001600160f81b03196147568587612448565b51165f1a6147648588612448565b5361477b6001600160f81b031961281b8388612448565b536147926001600160f81b03196126b88387612448565b536147a96001600160f81b03196125cc8386612448565b53600481018091116105175792614482565b608f9150115f61473e565b5060908210614730565b60bf9150115f614721565b60808110915061471a565b60bf1091505f614712565b60808110925061470b565b60bf85119250614704565b50602e811461444b565b50607f8114614444565b50815115611df35760208201516001600160f81b031916602d60f81b14908115614848575b506145565790565b515f1981019150811161051757602d60f81b906001600160f81b03199061486f9084612448565b5116145f614840565b63251f56a160e21b5f5260045ffd5b60ff9150115f61440f565b601181511115611f805760115b8015158061491b575b80614903575b156148bb575f190161489f565b9190916148c781612416565b905f5b8181106148d8575090925050565b6001906001600160f81b03196148ee8288612448565b51165f1a6148fc8286612448565b53016148ca565b5060bf6149108284612448565b5160f81c11156148ae565b5060806149288284612448565b5160f81c10156148a8565b905f5f5b83518110156149ed5761494a8185612448565b516001600160f81b03198116601160f91b811480156149e0575b1561497a57505090600260019101915b01614937565b600560f91b81149081156149d2575b81156149c4575b50156149a457509060026001910191614974565b60209060f81c10156149b9575b600190614974565b6001909101906149b1565b600960f81b1490505f614990565b600d60f81b81149150614989565b50601760fa1b8114614964565b50825181146143e1576149ff90612416565b5f805b8451821015614b3657614a158286612448565b516001600160f81b031981169290601160f91b8403614a5d57508192506022614a546002600180950195605c614a4b828a612448565b53019486612448565b535b0190614a02565b601760fa1b8403614a8a5750819250605c614a84600260018095019583614a4b828a612448565b53614a56565b600560f91b8403614ab25750819250606e614a846002600180950195605c614a4b828a612448565b600d60f81b8403614ada57508192506072614a846002600180950195605c614a4b828a612448565b600960f81b8403614b0257508192506074614a846002600180950195605c614a4b828a612448565b60209060f81c1015614b19575b6001919250614a56565b81614b2d600180949201945f1a9186612448565b53829150614b0f565b5090925050565b600a8211612adb57614b57905f52600560205260405f2090565b90614b628254611b5b565b15612adb57600182015480614b9757505060020154614b91906001600160401b03165b6001600160401b031690565b42111590565b90916002614bb19101546001600160401b039060801c1690565b6001600160401b03614be4614b856002614bd3865f52600560205260405f2090565b015460401c6001600160401b031690565b911603612adb57614bf7611f8092611cee565b90614b3d565b919060405180935f90805490614c1282611b5b565b9160018116908115614c9a5750600114614c59575b505090602082611c0794601760f91b600195528051928391018583015e015f838201520301601f198101845283611bae565b9091505f5260205f205f905b828210614c7e5750508101602090810190611c07614c27565b602091929350806001915483858a010152019101859291614c65565b60ff1916602080870191909152831515909302850183019350611c079150614c279050565b80158015614d87575b614d2957614cde905f52600560205260405f2090565b90614ce98254611b5b565b15614d29576001820154908115801580614d4a575b614d3e57614d335790614d13614d1992611cee565b90614cbf565b805115614d2957611f8091614bfd565b5050611f80611cd2565b5050611f8090611bcf565b50505050611f80611cd2565b50600284015460801c6001600160401b03166001600160401b03614d7e614b856002614bd3885f52600560205260405f2090565b91161415614cfe565b50600a8211614cc8565b5f5f5b8251811015614e36576001600160f81b0319614db08285612448565b5116601360f91b8103614dcd575090600460019101915b01614d94565b600f60fa1b8103614de657509060036001910191614dc7565b601f60f91b8103614dff57509060036001910191614dc7565b601160f91b8103614e1857509060056001910191614dc7565b602760f81b14614e2b575b600190614dc7565b600590910190614e23565b50801561503357614e4b614e50918351611cfc565b612416565b5f805b835182101561502c576001600160f81b0319614e6f8386612448565b511691601360f91b8303614ed2578192506026614e8e60019386612448565b536061614e9d83850186612448565b53606d614ead6002850186612448565b53603b614ec9600560048601956070614a4b600383018a612448565b535b0190614e53565b600f60fa1b8303614f1f578192506026614eee60019386612448565b53606c614efd83850186612448565b53603b614f19600460038601956074614a4b600283018a612448565b53614ecb565b601f60f91b8303614f4a578192506026614f3b60019386612448565b536067614efd83850186612448565b601160f91b8303614fb1578192506026614f6660019386612448565b536071614f7583850186612448565b536075614f856002850186612448565b53606f614f956003850186612448565b53603b614f19600660058601956074614a4b600483018a612448565b602760f81b8303615018578192506026614fcd60019386612448565b536061614fdc83850186612448565b536070614fec6002850186612448565b53606f614ffc6003850186612448565b53603b614f19600660058601956073614a4b600483018a612448565b81614f19600180949201945f1a9186612448565b5050905090565b5090565b6001600160a01b03615048826120f6565b161515806150ff575b6150e2575b5f818152673ec412a9852d173d60c11b601c5260209020810181018054906001600160a01b0382169081156118e257815f52806001019283548015600117156150d0575b905f9484926150c7575b50189055601c600c20821981540190555f51602061526f5f395f51905f528280a4565b8590555f6150a4565b906030600c2054156118d5579061509a565b6150ec5f82614b3d565b61505657630407b05b60e31b5f5260045ffd5b505f615051565b9060018060a01b038216815f52673ec412a9852d173d60c11b601c5260205f208201820180548060601b6151e15782179055805f52601c600c2060018154019063ffffffff82168302156151cc575581905f5f51602061526f5f395f51905f528180a4813b61517457505050565b60209160a460405194859363150b7a02855233868601525f6040860152606085015260808085015280518091818060a0880152613c3857505001905f601c8401915af115613c2a575163757a42ff60e11b01613c1d57565b67ea553b3401336cea831560021b526004601cfd5b63c991cbb15f526004601cfdfed8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a75504142434445464748494a4b4c4d4e4f505152535455565758595a616263646566e9b829b8676c143f46f458c54ab9eedea80dc58eaec9c3df7e0134aabf7f9d288be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa82820059d5df798546bcc2985157a77c3eef25eba9ba01899927333efacbd6f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fa264697066735822122003737a7d71c178842e4c8cf547fd8d5a55c8747a23c6ff009ddb658e6fde2a5b64736f6c63430008210033

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.