HYPE Price: $30.87 (+24.02%)
 

Overview

HYPE Balance

HyperEVM LogoHyperEVM LogoHyperEVM Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Register With Si...227671072025-12-25 7:26:0033 days ago1766647560IN
0xCd0A58e0...085E2AC65
0.63757438 HYPE0.00001750.1
Register With Si...223740322025-12-20 20:02:0938 days ago1766260929IN
0xCd0A58e0...085E2AC65
0.62599364 HYPE0.000230061.1
Register With Si...221931182025-12-18 18:34:5640 days ago1766082896IN
0xCd0A58e0...085E2AC65
0.67021276 HYPE0.000102470.53340572
Register With Si...208399072025-12-03 8:49:4655 days ago1764751786IN
0xCd0A58e0...085E2AC65
0.45752963 HYPE0.000021190.10132171
Register With Si...207649042025-12-02 12:20:1256 days ago1764678012IN
0xCd0A58e0...085E2AC65
0.49261854 HYPE0.00001920.1
Register With Si...205026972025-11-29 12:41:4459 days ago1764420104IN
0xCd0A58e0...085E2AC65
0.87269704 HYPE0.000720693.44631503
Register With Si...204684822025-11-29 3:19:2959 days ago1764386369IN
0xCd0A58e0...085E2AC65
0.45356371 HYPE0.000299511.432
Register With Si...204087732025-11-28 11:00:3960 days ago1764327639IN
0xCd0A58e0...085E2AC65
0.4368932 HYPE0.000075590.36142865
Register With Si...201918842025-11-25 23:45:0563 days ago1764114305IN
0xCd0A58e0...085E2AC65
0.46593497 HYPE0.000043520.20810154
Register With Si...175745622025-10-27 4:32:4592 days ago1761539565IN
0xCd0A58e0...085E2AC65
0.64800148 HYPE0.000019330.11053157
Register With Si...175744032025-10-27 4:30:0892 days ago1761539408IN
0xCd0A58e0...085E2AC65
1.2930769 HYPE0.001039184.96988404
Register With Si...172799082025-10-23 20:01:0496 days ago1761249664IN
0xCd0A58e0...085E2AC65
1.59821405 HYPE0.000026820.12829503
Register With Si...172760602025-10-23 18:58:0096 days ago1761245880IN
0xCd0A58e0...085E2AC65
0.40028464 HYPE0.000027540.13167862
Register With Si...172734862025-10-23 18:15:4896 days ago1761243348IN
0xCd0A58e0...085E2AC65
0.4003864 HYPE0.000041830.2
Register With Si...172597032025-10-23 14:29:5196 days ago1761229791IN
0xCd0A58e0...085E2AC65
0.39286605 HYPE0.001364496.52329231
Register With Si...172145942025-10-23 2:10:2196 days ago1761185421IN
0xCd0A58e0...085E2AC65
0.41598436 HYPE0.00128256.12992892
Register With Si...171960762025-10-22 21:06:4797 days ago1761167207IN
0xCd0A58e0...085E2AC65
0.44475192 HYPE0.001705688.15534601
Register With Si...171481512025-10-22 8:01:0797 days ago1761120067IN
0xCd0A58e0...085E2AC65
0.45332872 HYPE0.000070460.3369
Register With Si...170903242025-10-21 16:13:0898 days ago1761063188IN
0xCd0A58e0...085E2AC65
0.41516197 HYPE0.00007230.34562664
Register With Si...170784532025-10-21 12:58:3298 days ago1761051512IN
0xCd0A58e0...085E2AC65
0.430469 HYPE0.000712973.40755573
Register With Si...166990522025-10-17 5:17:39102 days ago1760678259IN
0xCd0A58e0...085E2AC65
1.80713017 HYPE0.000833273.98243815
Register With Si...166202272025-10-16 7:45:26103 days ago1760600726IN
0xCd0A58e0...085E2AC65
1.75268931 HYPE0.000026240.1254
Register With Si...165399542025-10-15 9:49:27104 days ago1760521767IN
0xCd0A58e0...085E2AC65
0.38567965 HYPE0.00026661.2741503
Register With Si...163127162025-10-12 19:43:00107 days ago1760298180IN
0xCd0A58e0...085E2AC65
0.39434151 HYPE0.000020990.12
Register With Si...163125332025-10-12 19:40:00107 days ago1760298000IN
0xCd0A58e0...085E2AC65
0.3930131 HYPE0.000020210.11552
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
227671072025-12-25 7:26:0033 days ago1766647560
0xCd0A58e0...085E2AC65
0.03036068 HYPE
227671072025-12-25 7:26:0033 days ago1766647560
0xCd0A58e0...085E2AC65
0.60721369 HYPE
223740322025-12-20 20:02:0938 days ago1766260929
0xCd0A58e0...085E2AC65
0.02976182 HYPE
223740322025-12-20 20:02:0938 days ago1766260929
0xCd0A58e0...085E2AC65
0.59623181 HYPE
221931182025-12-18 18:34:5640 days ago1766082896
0xCd0A58e0...085E2AC65
0.0317247 HYPE
221931182025-12-18 18:34:5640 days ago1766082896
0xCd0A58e0...085E2AC65
0.63848806 HYPE
208399072025-12-03 8:49:4655 days ago1764751786
0xCd0A58e0...085E2AC65
0.02167317 HYPE
208399072025-12-03 8:49:4655 days ago1764751786
0xCd0A58e0...085E2AC65
0.43585645 HYPE
207649042025-12-02 12:20:1256 days ago1764678012
0xCd0A58e0...085E2AC65
0.02354605 HYPE
207649042025-12-02 12:20:1256 days ago1764678012
0xCd0A58e0...085E2AC65
0.46907248 HYPE
205026972025-11-29 12:41:4459 days ago1764420104
0xCd0A58e0...085E2AC65
0.04128059 HYPE
205026972025-11-29 12:41:4459 days ago1764420104
0xCd0A58e0...085E2AC65
0.83141645 HYPE
204684822025-11-29 3:19:2959 days ago1764386369
0xCd0A58e0...085E2AC65
0.02167289 HYPE
204684822025-11-29 3:19:2959 days ago1764386369
0xCd0A58e0...085E2AC65
0.43189081 HYPE
204087732025-11-28 11:00:3960 days ago1764327639
0xCd0A58e0...085E2AC65
0.02082752 HYPE
204087732025-11-28 11:00:3960 days ago1764327639
0xCd0A58e0...085E2AC65
0.41606568 HYPE
201918842025-11-25 23:45:0563 days ago1764114305
0xCd0A58e0...085E2AC65
0.0221086 HYPE
201918842025-11-25 23:45:0563 days ago1764114305
0xCd0A58e0...085E2AC65
0.44382637 HYPE
175745622025-10-27 4:32:4592 days ago1761539565
0xCd0A58e0...085E2AC65
0.03114907 HYPE
175745622025-10-27 4:32:4592 days ago1761539565
0xCd0A58e0...085E2AC65
0.6168524 HYPE
175744032025-10-27 4:30:0892 days ago1761539408
0xCd0A58e0...085E2AC65
0.06056319 HYPE
175744032025-10-27 4:30:0892 days ago1761539408
0xCd0A58e0...085E2AC65
1.23251371 HYPE
172799082025-10-23 20:01:0496 days ago1761249664
0xCd0A58e0...085E2AC65
0.07664582 HYPE
172799082025-10-23 20:01:0496 days ago1761249664
0xCd0A58e0...085E2AC65
1.52156822 HYPE
172760602025-10-23 18:58:0096 days ago1761245880
0xCd0A58e0...085E2AC65
0.01898364 HYPE
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DotHypeDutchAuction

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 10000 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

import "./DotHypeController.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

/**
 * @title DotHypeDutchAuction
 * @dev Extension of DotHypeController that implements Dutch auction functionality
 * Dutch auctions start at a higher price and decrease linearly over time
 * Domain prices include both the auction premium and the base registration fee
 */
contract DotHypeDutchAuction is DotHypeController {
    using ECDSA for bytes32;

    error AuctionNotActive();
    error InvalidBatchId();
    error DomainNotInAuction();
    error DomainAlreadyInAuction();
    error InvalidAuctionConfig();
    error AuctionAlreadyStarted();

    bytes32 private constant DUTCH_AUCTION_REGISTRATION_TYPEHASH = keccak256(
        "DutchAuctionRegistration(string name,address owner,uint256 duration,uint256 maxPrice,uint256 deadline,uint256 nonce)"
    );

    struct DutchAuctionConfig {
        uint256 startPrice;
        uint256 endPrice;
        uint256 auctionDuration;
        uint256 startTime;
        bool isActive;
    }

    mapping(uint256 => DutchAuctionConfig) public auctionBatches;
    mapping(bytes32 => uint256) public domainToBatchId;
    uint256 public nextBatchId = 1;

    event DutchAuctionBatchCreated(
        uint256 indexed batchId, uint256 startPrice, uint256 endPrice, uint256 duration, uint256 startTime
    );
    event DomainAddedToAuctionBatch(uint256 indexed batchId, bytes32 indexed nameHash, string name);
    event DomainRemovedFromAuctionBatch(uint256 indexed batchId, bytes32 indexed nameHash, string name);
    event DutchAuctionPurchase(
        string name, address owner, uint256 duration, uint256 basePrice, uint256 auctionPrice, uint256 totalPrice
    );

    /**
     * @dev Constructor
     * @param _registry Address of the registry contract
     * @param _signer Address authorized to sign minting requests
     * @param _priceOracle Address of the price oracle for USD conversion
     * @param _owner Initial owner of the contract
     */
    constructor(address _registry, address _signer, address _priceOracle, address _owner)
        DotHypeController(_registry, _signer, _priceOracle, _owner)
    {}

    /**
     * @dev Create a new Dutch auction batch
     * @param domains Array of domain names to include in this auction
     * @param startPrice Starting price in USD (1e18 = $1)
     * @param endPrice Ending price in USD (typically 0)
     * @param auctionDuration Duration of the auction in seconds
     * @param startTime Timestamp when the auction starts (use 0 for immediate start)
     * @return batchId The ID of the created auction batch
     */
    function createDutchAuctionBatch(
        string[] calldata domains,
        uint256 startPrice,
        uint256 endPrice,
        uint256 auctionDuration,
        uint256 startTime
    ) external onlyOwner returns (uint256 batchId) {
        if (startPrice <= endPrice) {
            revert InvalidAuctionConfig();
        }
        if (auctionDuration == 0) {
            revert InvalidAuctionConfig();
        }

        if (startTime == 0) {
            startTime = block.timestamp;
        } else if (startTime < block.timestamp) {
            revert InvalidAuctionConfig();
        }

        batchId = nextBatchId++;

        auctionBatches[batchId] = DutchAuctionConfig({
            startPrice: startPrice,
            endPrice: endPrice,
            auctionDuration: auctionDuration,
            startTime: startTime,
            isActive: true
        });

        for (uint256 i = 0; i < domains.length; i++) {
            _addDomainToAuction(batchId, domains[i]);
        }

        emit DutchAuctionBatchCreated(batchId, startPrice, endPrice, auctionDuration, startTime);

        return batchId;
    }

    /**
     * @dev Internal function to add a domain to an auction batch
     * @param batchId The ID of the auction batch
     * @param name The domain name to add
     */
    function _addDomainToAuction(uint256 batchId, string memory name) internal {
        bytes32 nameHash = keccak256(bytes(name));

        if (domainToBatchId[nameHash] != 0) {
            revert DomainAlreadyInAuction();
        }

        domainToBatchId[nameHash] = batchId;
        emit DomainAddedToAuctionBatch(batchId, nameHash, name);
    }

    /**
     * @dev Calculate current Dutch auction price for a domain
     * @param name Domain name
     * @param duration Registration duration in seconds
     * @return basePrice The base registration price for the domain length
     * @return auctionPrice The current auction price component
     * @return totalPrice The total price (base + auction)
     */
    function calculateDutchAuctionPrice(string memory name, uint256 duration)
        public
        view
        returns (uint256 basePrice, uint256 auctionPrice, uint256 totalPrice)
    {
        bytes32 nameHash = keccak256(bytes(name));
        uint256 batchId = domainToBatchId[nameHash];

        // Get base price in USD
        uint256 basePriceUsd = super._calculateBasePrice(name, duration);

        // If not in auction, just convert and return base price
        if (batchId == 0 || !auctionBatches[batchId].isActive) {
            basePrice = priceOracle.usdToHype(basePriceUsd);
            return (basePrice, 0, basePrice);
        }

        DutchAuctionConfig memory config = auctionBatches[batchId];

        // Calculate auction price in USD
        uint256 auctionPriceUsd;

        if (block.timestamp < config.startTime) {
            // Before auction starts - use start price
            auctionPriceUsd = config.startPrice;
        } else if (block.timestamp >= config.startTime + config.auctionDuration) {
            // After auction ends - use end price
            auctionPriceUsd = config.endPrice;
        } else {
            // During auction - calculate current price based on time elapsed
            uint256 elapsed = block.timestamp - config.startTime;
            uint256 priceDrop = config.startPrice - config.endPrice;
            auctionPriceUsd = config.startPrice - (priceDrop * elapsed / config.auctionDuration);
        }

        // Calculate total USD price
        uint256 totalPriceUsd = basePriceUsd + auctionPriceUsd;

        // Convert prices from USD to HYPE with a single oracle call
        totalPrice = priceOracle.usdToHype(totalPriceUsd);

        // Since we need to return the individual components too, we'll calculate them
        // based on the proportions of the USD prices
        if (totalPriceUsd > 0) {
            basePrice = (totalPrice * basePriceUsd) / totalPriceUsd;
            auctionPrice = totalPrice - basePrice; // Avoid rounding errors by subtracting
        } else {
            revert InvalidAuctionConfig();
        }

        return (basePrice, auctionPrice, totalPrice);
    }

    /**
     * @dev Verify a signature for Dutch auction domain registration
     * @param name Domain name to register (without .hype)
     * @param owner Address that will own the domain
     * @param duration Registration duration in seconds
     * @param maxPrice Maximum price willing to pay (to prevent front-running)
     * @param deadline Timestamp after which signature expires
     * @param signature EIP-712 signature authorizing the registration
     * @return True if signature is valid
     */
    function _verifyDutchAuctionSignature(
        string calldata name,
        address owner,
        uint256 duration,
        uint256 maxPrice,
        uint256 deadline,
        bytes calldata signature
    ) internal returns (bool) {
        if (block.timestamp > deadline) {
            revert SignatureExpired();
        }

        uint256 nonce = nonces[owner]++;

        bytes32 structHash = keccak256(
            abi.encode(
                DUTCH_AUCTION_REGISTRATION_TYPEHASH, keccak256(bytes(name)), owner, duration, maxPrice, deadline, nonce
            )
        );
        bytes32 hash = _hashTypedDataV4(structHash);

        address recoveredSigner = ECDSA.recover(hash, signature);
        require(recoveredSigner == signer, InvalidSigner());

        return true;
    }

    /**
     * @dev Check if a domain is in an active auction
     * @param name Domain name to check
     * @return isInAuction Whether the domain is in an active auction
     * @return batchId The batch ID the domain is in (0 if not in auction)
     */
    function isDomainInAuction(string memory name) public view returns (bool isInAuction, uint256 batchId) {
        bytes32 nameHash = keccak256(bytes(name));
        batchId = domainToBatchId[nameHash];

        if (batchId == 0) {
            return (false, 0);
        }

        isInAuction = auctionBatches[batchId].isActive;
        return (isInAuction, batchId);
    }

    /**
     * @dev Internal function to handle Dutch auction domain registration
     * @param name Domain name to register
     * @param owner Address that will own the domain
     * @param duration Registration duration in seconds
     * @param maxPrice Maximum price willing to pay
     * @return tokenId The token ID of the registered domain
     * @return expiry The expiry timestamp of the registration
     */
    function _registerDutchAuctionDomain(string memory name, address owner, uint256 duration, uint256 maxPrice)
        internal
        returns (uint256 tokenId, uint256 expiry)
    {
        if (duration < MIN_REGISTRATION_LENGTH) {
            revert DurationTooShort(duration, MIN_REGISTRATION_LENGTH);
        }

        (uint256 basePrice, uint256 auctionPrice, uint256 totalPrice) = calculateDutchAuctionPrice(name, duration);

        (bool isInAuction, uint256 batchId) = isDomainInAuction(name);
        if (!isInAuction) {
            revert DomainNotInAuction();
        }

        if (totalPrice > maxPrice) {
            revert InsufficientPayment(totalPrice, maxPrice);
        }

        bytes32 nameHash = keccak256(bytes(name));
        address reservedFor = reservedNames[nameHash];
        if (reservedFor != address(0) && reservedFor != owner) {
            revert NameIsReserved(nameHash, reservedFor);
        }

        _processPayment(totalPrice);

        (tokenId, expiry) = registry.register(name, owner, duration);

        emit DomainRemovedFromAuctionBatch(batchId, nameHash, name);
        domainToBatchId[nameHash] = 0;

        emit DutchAuctionPurchase(name, owner, duration, basePrice, auctionPrice, totalPrice);

        return (tokenId, expiry);
    }

    /**
     * @dev Register a domain from a Dutch auction with signature-based authorization
     * @param name Domain name to register (without .hype)
     * @param owner Address that will own the domain
     * @param duration Registration duration in seconds
     * @param maxPrice Maximum price willing to pay (to prevent front-running)
     * @param deadline Timestamp after which signature expires
     * @param signature EIP-712 signature authorizing the registration
     */
    function registerDutchAuctionWithSignature(
        string calldata name,
        address owner,
        uint256 duration,
        uint256 maxPrice,
        uint256 deadline,
        bytes calldata signature
    ) external payable returns (uint256 tokenId, uint256 expiry) {
        _verifyDutchAuctionSignature(name, owner, duration, maxPrice, deadline, signature);
        return _registerDutchAuctionDomain(name, owner, duration, maxPrice);
    }

    /**
     * @dev Direct purchase of a domain from a Dutch auction (without signature verification)
     * @param name Domain name to register (without .hype)
     * @param duration Registration duration in seconds
     * @param maxPrice Maximum price willing to pay
     */
    function purchaseDutchAuction(string calldata name, uint256 duration, uint256 maxPrice)
        external
        payable
        onlyOwner
        returns (uint256 tokenId, uint256 expiry)
    {
        return _registerDutchAuctionDomain(name, msg.sender, duration, maxPrice);
    }

    /**
     * @dev Get current auction status and details
     * @param batchId The auction batch ID to check
     * @return config The auction configuration
     * @return currentPrice Current Dutch auction price in USD
     * @return timeRemaining Time remaining in the auction in seconds
     * @return isActive Whether the auction is currently active
     * @return hasStarted Whether the auction has started
     * @return isComplete Whether the auction is complete
     */
    function getAuctionStatus(uint256 batchId)
        external
        view
        returns (
            DutchAuctionConfig memory config,
            uint256 currentPrice,
            uint256 timeRemaining,
            bool isActive,
            bool hasStarted,
            bool isComplete
        )
    {
        if (batchId == 0 || batchId >= nextBatchId) {
            revert InvalidBatchId();
        }

        config = auctionBatches[batchId];
        isActive = config.isActive;
        hasStarted = block.timestamp >= config.startTime;

        uint256 auctionEndTime = config.startTime + config.auctionDuration;
        isComplete = block.timestamp >= auctionEndTime;

        timeRemaining = isComplete ? 0 : auctionEndTime - block.timestamp;

        if (!hasStarted) {
            currentPrice = config.startPrice;
        } else if (isComplete) {
            currentPrice = config.endPrice;
        } else {
            uint256 elapsed = block.timestamp - config.startTime;
            uint256 priceDrop = config.startPrice - config.endPrice;
            currentPrice = config.startPrice - (priceDrop * elapsed / config.auctionDuration);
        }

        return (config, currentPrice, timeRemaining, isActive, hasStarted, isComplete);
    }

    /**
     * @dev Override to check if domain is in an active auction before allowing registration
     * @param name Domain name to check
     */
    function _checkDomainNotInAuction(string memory name) internal view override {
        bytes32 nameHash = keccak256(bytes(name));
        uint256 batchId = domainToBatchId[nameHash];

        if (batchId == 0) {
            return; // Domain not in any auction
        }

        DutchAuctionConfig memory config = auctionBatches[batchId];

        // Check if auction is active AND not expired
        if (config.isActive) {
            uint256 auctionEndTime = config.startTime + config.auctionDuration;
            bool isExpired = block.timestamp >= auctionEndTime;

            if (!isExpired) {
                revert DomainInAuction(name);
            }
        }
    }
}

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

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "../interfaces/IDotHypeRegistry.sol";
import "../interfaces/IPriceOracle.sol";

/**
 * @title DotHypeController
 * @dev Controller contract for managing domain registration and renewal
 * Implements EIP-712 typed data signature-based minting to prevent front-running
 * Prices are always in USD, converted to HYPE tokens via price oracle
 */
contract DotHypeController is Ownable, EIP712 {
    using ECDSA for bytes32;

    error SignatureExpired();
    error InvalidSignature();
    error InvalidSigner();
    error InsufficientPayment(uint256 required, uint256 provided);
    error WithdrawalFailed();
    error PricingNotSet();
    error InvalidCharacterCount(uint256 count);
    error CharacterLengthNotAvailable(uint256 count);
    error InvalidPriceConfig();
    error OracleNotSet();
    error FundsTransferFailed();
    error NameIsReserved(bytes32 nameHash, address reservedFor);
    error NotReserved(string name);
    error NotAuthorized(address caller, bytes32 nameHash);
    error InvalidMerkleProof();
    error MerkleRootNotSet();
    error AlreadyMinted(address minter);
    error DurationTooShort(uint256 provided, uint256 minimum);
    error DomainInAuction(string name);

    struct RegistrationParams {
        string name;
        address owner;
        uint256 duration;
        uint256 maxPrice;
        uint256 deadline;
        bytes signature;
    }

    IDotHypeRegistry public registry;
    address public signer;

    uint256[6] public annualPrices;
    uint256[6] public annualRenewalPrices;

    IPriceOracle public priceOracle;
    address public paymentRecipient;

    mapping(bytes32 => address) public reservedNames;
    bytes32 public merkleRoot;
    mapping(address => bool) public hasUsedMerkleProof;

    bytes32 private constant REGISTRATION_TYPEHASH = keccak256(
        "Registration(string name,address owner,uint256 duration,uint256 maxPrice,uint256 deadline,uint256 nonce)"
    );

    uint256 public constant MIN_REGISTRATION_LENGTH = 365 days;

    mapping(address => uint256) public nonces;

    event DomainRegistered(string name, address owner, uint256 duration, uint256 price);
    event DomainRenewed(uint256 tokenId, uint256 duration, uint256 price);
    event SignerUpdated(address newSigner);
    event AnnualPriceUpdated(uint256 charCount, uint256 price);
    event PaymentRecipientUpdated(address recipient);
    event Withdrawn(address recipient, uint256 amount);
    event PriceOracleUpdated(address oracle);
    event NameReserved(bytes32 indexed nameHash, address indexed reservedFor);
    event NameReservationRemoved(bytes32 indexed nameHash);
    event ReservedNameRegistered(string name, address owner, uint256 duration);
    event MerkleRootUpdated(bytes32 merkleRoot);
    event MerkleProofRegistration(string name, address owner, uint256 duration);
    event AnnualRenewalPriceUpdated(uint256 charCount, uint256 price);

    /**
     * @dev Constructor
     * @param _registry Address of the registry contract
     * @param _signer Address authorized to sign minting requests
     * @param _priceOracle Address of the price oracle for USD conversion
     * @param _owner Initial owner of the contract
     */
    constructor(address _registry, address _signer, address _priceOracle, address _owner)
        Ownable(_owner)
        EIP712("DotHypeController", "1")
    {
        require(_priceOracle != address(0), OracleNotSet());

        registry = IDotHypeRegistry(_registry);
        signer = _signer;
        priceOracle = IPriceOracle(_priceOracle);
        paymentRecipient = _owner;
    }

    /**
     * @dev Verify a signature for domain registration
     * @param name Domain name to register (without .hype)
     * @param owner Address that will own the domain
     * @param duration Registration duration in seconds
     * @param maxPrice Maximum price willing to pay (to prevent front-running)
     * @param deadline Timestamp after which signature expires
     * @param signature EIP-712 signature authorizing the registration
     * @return True if signature is valid
     */
    function _verifySignature(
        string calldata name,
        address owner,
        uint256 duration,
        uint256 maxPrice,
        uint256 deadline,
        bytes calldata signature
    ) internal returns (bool) {
        require(block.timestamp <= deadline, SignatureExpired());
        require(msg.value <= maxPrice, InsufficientPayment(maxPrice, msg.value));

        uint256 nonce = nonces[owner]++;

        bytes32 structHash = keccak256(
            abi.encode(REGISTRATION_TYPEHASH, keccak256(bytes(name)), owner, duration, maxPrice, deadline, nonce)
        );
        bytes32 hash = _hashTypedDataV4(structHash);

        address recoveredSigner = ECDSA.recover(hash, signature);
        require(recoveredSigner == signer, InvalidSigner());

        return true;
    }

    /**
     * @dev Process a registration payment
     * @param price The price to pay
     * @return The processed payment amount
     */
    function _processPayment(uint256 price) internal returns (uint256) {
        require(msg.value >= price, InsufficientPayment(price, msg.value));

        if (price > 0 && paymentRecipient != address(0)) {
            (bool success,) = paymentRecipient.call{value: price}("");
            require(success, FundsTransferFailed());
        }

        if (msg.value > price) {
            (bool success,) = payable(msg.sender).call{value: msg.value - price}("");
            require(success, FundsTransferFailed());
        }

        return price;
    }

    /**
     * @dev Internal function to handle domain registration
     * @param name Domain name to register
     * @param owner Address that will own the domain
     * @param duration Registration duration in seconds
     * @return tokenId The token ID of the registered domain
     * @return expiry The expiry timestamp of the registration
     */
    function _registerDomain(string memory name, address owner, uint256 duration)
        internal
        returns (uint256 tokenId, uint256 expiry)
    {
        if (duration < MIN_REGISTRATION_LENGTH) {
            revert DurationTooShort(duration, MIN_REGISTRATION_LENGTH);
        }

        // Check if domain is in an active auction
        _checkDomainNotInAuction(name);

        bytes32 nameHash = keccak256(bytes(name));
        address reservedFor = reservedNames[nameHash];
        if (reservedFor != address(0) && reservedFor != owner) {
            revert NameIsReserved(nameHash, reservedFor);
        }

        uint256 price = calculatePrice(name, duration);

        _processPayment(price);

        (tokenId, expiry) = registry.register(name, owner, duration);

        emit DomainRegistered(name, owner, duration, price);
    }

    /**
     * @dev Check if domain is in an active auction and revert if it is
     * @param name Domain name to check
     * @dev This function can be overridden by contracts that implement auction functionality
     */
    function _checkDomainNotInAuction(string memory name) internal view virtual {
        // Base implementation does nothing - no auction functionality
        // DotHypeDutchAuction will override this to add auction checks
    }

    /**
     * @dev Register a domain with EIP-712 signature-based authorization
     * @param name Domain name to register (without .hype)
     * @param owner Address that will own the domain
     * @param duration Registration duration in seconds
     * @param maxPrice Maximum price willing to pay (to prevent front-running)
     * @param deadline Timestamp after which signature expires
     * @param signature EIP-712 signature authorizing the registration
     */
    function registerWithSignature(
        string calldata name,
        address owner,
        uint256 duration,
        uint256 maxPrice,
        uint256 deadline,
        bytes calldata signature
    ) external payable returns (uint256 tokenId, uint256 expiry) {
        _verifySignature(name, owner, duration, maxPrice, deadline, signature);
        return _registerDomain(name, owner, duration);
    }

    /**
     * @dev Register a reserved domain
     * @param name Domain name to register (without .hype)
     * @param duration Registration duration in seconds
     */
    function registerReserved(string calldata name, uint256 duration)
        external
        payable
        returns (uint256 tokenId, uint256 expiry)
    {
        bytes32 nameHash = keccak256(bytes(name));
        address reservedFor = reservedNames[nameHash];

        if (reservedFor == address(0)) {
            revert NotReserved(name);
        }
        if (reservedFor != msg.sender) {
            revert NotAuthorized(msg.sender, nameHash);
        }

        (tokenId, expiry) = _registerDomain(name, msg.sender, duration);

        reservedNames[nameHash] = address(0);
        emit NameReservationRemoved(nameHash);
        emit ReservedNameRegistered(name, msg.sender, duration);
    }

    /**
     * @dev Renew a domain - anyone can renew any domain
     * @param tokenId Token ID of the domain to renew
     * @param duration Renewal duration in seconds
     */
    function renew(uint256 tokenId, uint256 duration) external payable returns (uint256 expiry) {
        string memory name = registry.tokenIdToName(tokenId);
        uint256 price = calculateRenewalPrice(name, duration);

        _processPayment(price);

        expiry = registry.renew(tokenId, duration);

        emit DomainRenewed(tokenId, duration, price);
    }

    /**
     * @dev Get the next nonce for an address
     * @param owner The address to get the nonce for
     * @return The next nonce for this address
     */
    function getNextNonce(address owner) external view returns (uint256) {
        return nonces[owner];
    }

    /**
     * @dev Calculate price for domain registration or renewal
     * @param name Domain name
     * @param duration Registration/renewal duration in seconds
     * @return price Final price in HYPE tokens
     */
    function calculatePrice(string memory name, uint256 duration) public view returns (uint256 price) {
        uint256 p = _calculateBasePrice(name, duration);
        require(p > 0, PricingNotSet());
        return priceOracle.usdToHype(p);
    }

    function _calculateBasePrice(string memory name, uint256 duration) internal view returns (uint256 price) {
        bytes memory nameBytes = bytes(name);
        uint256 charCount = nameBytes.length;

        uint256 priceIndex = charCount < 5 ? charCount : 5;

        require(priceIndex > 0, InvalidCharacterCount(charCount));

        uint256 annualRegistrationPrice = annualPrices[priceIndex];
        uint256 annualRenewalPrice = annualRenewalPrices[priceIndex];

        // For durations up to MIN_REGISTRATION_LENGTH, use registration price
        if (duration <= MIN_REGISTRATION_LENGTH) {
            uint256 usdPrice1 = (annualRegistrationPrice * duration) / 365 days;
            return usdPrice1;
        }

        // For longer durations:
        // 1. First MIN_REGISTRATION_LENGTH uses registration price
        // 2. Remaining duration uses renewal price
        uint256 registrationPeriodPrice = annualRegistrationPrice;
        uint256 remainingDuration = duration - MIN_REGISTRATION_LENGTH;
        uint256 renewalPeriodPrice = (annualRenewalPrice * remainingDuration) / 365 days;

        uint256 usdPrice = registrationPeriodPrice + renewalPeriodPrice;

        return usdPrice;
    }

    /**
     * @dev Calculate price for domain renewal
     * @param name Domain name
     * @param duration Renewal duration in seconds
     * @return price Final price in HYPE tokens
     */
    function calculateRenewalPrice(string memory name, uint256 duration) public view returns (uint256 price) {
        bytes memory nameBytes = bytes(name);
        uint256 charCount = nameBytes.length;

        uint256 priceIndex = charCount < 5 ? charCount : 5;

        require(priceIndex > 0, InvalidCharacterCount(charCount));

        uint256 annualPrice = annualRenewalPrices[priceIndex];

        require(annualPrice > 0, PricingNotSet());

        uint256 usdPrice = (annualPrice * duration) / 365 days;

        price = priceOracle.usdToHype(usdPrice);

        return price;
    }

    /**
     * @dev Set a name reservation
     * @param name Domain name to reserve (without .hype)
     * @param reservedFor Address that can register the reserved name (use address(0) to remove reservation)
     */
    function setReservation(string calldata name, address reservedFor) external onlyOwner {
        bytes32 nameHash = keccak256(bytes(name));
        reservedNames[nameHash] = reservedFor;

        if (reservedFor == address(0)) {
            emit NameReservationRemoved(nameHash);
        } else {
            emit NameReserved(nameHash, reservedFor);
        }
    }

    /**
     * @dev Set multiple name reservations at once
     * @param names Array of domain names to reserve (without .hype)
     * @param reservedAddresses Array of addresses that can register the reserved names (use address(0) to remove reservation)
     */
    function setBatchReservations(string[] calldata names, address[] calldata reservedAddresses) external onlyOwner {
        require(names.length == reservedAddresses.length, "Array lengths mismatch");

        for (uint256 i = 0; i < names.length; i++) {
            bytes32 nameHash = keccak256(bytes(names[i]));
            reservedNames[nameHash] = reservedAddresses[i];

            if (reservedAddresses[i] == address(0)) {
                emit NameReservationRemoved(nameHash);
            } else {
                emit NameReserved(nameHash, reservedAddresses[i]);
            }
        }
    }

    /**
     * @dev Check if a name is reserved and for whom
     * @param name Domain name to check (without .hype)
     * @return isReserved Whether the name is reserved
     * @return reservedFor Address the name is reserved for (address(0) if not reserved)
     */
    function checkReservation(string calldata name) external view returns (bool isReserved, address reservedFor) {
        bytes32 nameHash = keccak256(bytes(name));
        reservedFor = reservedNames[nameHash];
        isReserved = reservedFor != address(0);
        return (isReserved, reservedFor);
    }

    /**
     * @dev Update signer address
     * @param _signer New signer address
     */
    function setSigner(address _signer) external onlyOwner {
        signer = _signer;
        emit SignerUpdated(_signer);
    }

    /**
     * @dev Set annual price for a specific character count
     * @param charCount Character count (1-5, with 5 representing 5+ characters)
     * @param annualPrice Annual price in USD (1e18 = $1)
     */
    function setAnnualPrice(uint256 charCount, uint256 annualPrice) external onlyOwner {
        require(charCount >= 1 && charCount <= 5, InvalidCharacterCount(charCount));

        annualPrices[charCount] = annualPrice;

        emit AnnualPriceUpdated(charCount, annualPrice);
    }

    /**
     * @dev Set annual renewal price for a specific character count
     * @param charCount Character count (1-5, with 5 representing 5+ characters)
     * @param annualPrice Annual renewal price in USD (1e18 = $1)
     */
    function setAnnualRenewalPrice(uint256 charCount, uint256 annualPrice) external onlyOwner {
        require(charCount >= 1 && charCount <= 5, InvalidCharacterCount(charCount));

        annualRenewalPrices[charCount] = annualPrice;

        emit AnnualRenewalPriceUpdated(charCount, annualPrice);
    }

    /**
     * @dev Set all annual prices at once
     * @param prices Array of 5 prices in USD (1e18 = $1)
     *               [1-char, 2-char, 3-char, 4-char, 5+ char]
     */
    function setAllAnnualPrices(uint256[5] calldata prices) external onlyOwner {
        for (uint256 i = 0; i < 5; i++) {
            annualPrices[i + 1] = prices[i];
            emit AnnualPriceUpdated(i + 1, prices[i]);
        }
    }

    /**
     * @dev Set all annual renewal prices at once
     * @param prices Array of 5 prices in USD (1e18 = $1)
     *               [1-char, 2-char, 3-char, 4-char, 5+ char]
     */
    function setAllAnnualRenewalPrices(uint256[5] calldata prices) external onlyOwner {
        for (uint256 i = 0; i < 5; i++) {
            annualRenewalPrices[i + 1] = prices[i];
            emit AnnualRenewalPriceUpdated(i + 1, prices[i]);
        }
    }

    /**
     * @dev Set payment recipient address
     * @param _paymentRecipient Address to receive all payments
     */
    function setPaymentRecipient(address _paymentRecipient) external onlyOwner {
        paymentRecipient = _paymentRecipient;
        emit PaymentRecipientUpdated(_paymentRecipient);
    }

    /**
     * @dev Set the price oracle address
     * @param _priceOracle Address of the price oracle contract
     */
    function setPriceOracle(address _priceOracle) external onlyOwner {
        require(_priceOracle != address(0), OracleNotSet());
        priceOracle = IPriceOracle(_priceOracle);
        emit PriceOracleUpdated(_priceOracle);
    }

    /**
     * @dev Withdraw contract balance if any remains
     * @param recipient Address to receive funds
     */
    function withdraw(address recipient) external onlyOwner {
        uint256 balance = address(this).balance;
        if (balance == 0) return;

        (bool success,) = recipient.call{value: balance}("");
        require(success, WithdrawalFailed());

        emit Withdrawn(recipient, balance);
    }

    /**
     * @dev Update registry address
     * @param _registry New registry address
     */
    function setRegistry(address _registry) external onlyOwner {
        registry = IDotHypeRegistry(_registry);
    }

    /**
     * @dev Set the merkle root for the allowlist
     * @param _merkleRoot New merkle root
     */
    function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
        merkleRoot = _merkleRoot;
        emit MerkleRootUpdated(_merkleRoot);
    }

    /**
     * @dev Register a domain using a merkle proof to verify allowlist inclusion
     * @param name Domain name to register (without .hype)
     * @param duration Registration duration in seconds
     * @param merkleProof Merkle proof verifying the sender is in the allowlist
     */
    function registerWithMerkleProof(string calldata name, uint256 duration, bytes32[] calldata merkleProof)
        external
        payable
        returns (uint256 tokenId, uint256 expiry)
    {
        if (merkleRoot == bytes32(0)) {
            revert MerkleRootNotSet();
        }

        if (hasUsedMerkleProof[msg.sender]) {
            revert AlreadyMinted(msg.sender);
        }

        bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
        if (!MerkleProof.verify(merkleProof, merkleRoot, leaf)) {
            revert InvalidMerkleProof();
        }
        hasUsedMerkleProof[msg.sender] = true;
        (tokenId, expiry) = _registerDomain(name, msg.sender, duration);

        emit MerkleProofRegistration(name, msg.sender, duration);
    }

    /**
     * @dev Check if an address has already minted using their merkle proof
     * @param user Address to check
     * @return True if the address has already minted
     */
    function hasAddressUsedMerkleProof(address user) external view returns (bool) {
        return hasUsedMerkleProof[user];
    }

    /**
     * @dev Reset merkle proof usage for addresses (admin only)
     * @param users Array of addresses to reset
     */
    function resetMerkleProofUsage(address[] calldata users) external onlyOwner {
        for (uint256 i = 0; i < users.length; i++) {
            hasUsedMerkleProof[users[i]] = false;
        }
    }

    /**
     * @dev Receive function
     */
    receive() external payable {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS
    }

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function tryRecover(
        bytes32 hash,
        bytes memory signature
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly ("memory-safe") {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            uint8 v = uint8((uint256(vs) >> 255) + 27);
            return tryRecover(hash, v, r, s);
        }
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS, s);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.20;

import {MessageHashUtils} from "./MessageHashUtils.sol";
import {ShortStrings, ShortString} from "../ShortStrings.sol";
import {IERC5267} from "../../interfaces/IERC5267.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
 * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
 * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
 * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 *
 * @custom:oz-upgrades-unsafe-allow state-variable-immutable
 */
abstract contract EIP712 is IERC5267 {
    using ShortStrings for *;

    bytes32 private constant TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _cachedDomainSeparator;
    uint256 private immutable _cachedChainId;
    address private immutable _cachedThis;

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

    ShortString private immutable _name;
    ShortString private immutable _version;
    // slither-disable-next-line constable-states
    string private _nameFallback;
    // slither-disable-next-line constable-states
    string private _versionFallback;

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        _name = name.toShortStringWithFallback(_nameFallback);
        _version = version.toShortStringWithFallback(_versionFallback);
        _hashedName = keccak256(bytes(name));
        _hashedVersion = keccak256(bytes(version));

        _cachedChainId = block.chainid;
        _cachedDomainSeparator = _buildDomainSeparator();
        _cachedThis = address(this);
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @inheritdoc IERC5267
     */
    function eip712Domain()
        public
        view
        virtual
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _EIP712Name(),
            _EIP712Version(),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }

    /**
     * @dev The name parameter for the EIP712 domain.
     *
     * NOTE: By default this function reads _name which is an immutable value.
     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
     */
    // solhint-disable-next-line func-name-mixedcase
    function _EIP712Name() internal view returns (string memory) {
        return _name.toStringWithFallback(_nameFallback);
    }

    /**
     * @dev The version parameter for the EIP712 domain.
     *
     * NOTE: By default this function reads _version which is an immutable value.
     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
     */
    // solhint-disable-next-line func-name-mixedcase
    function _EIP712Version() internal view returns (string memory) {
        return _version.toStringWithFallback(_versionFallback);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MerkleProof.sol)
// This file was procedurally generated from scripts/generate/templates/MerkleProof.js.

pragma solidity ^0.8.20;

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

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the Merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates Merkle trees that are safe
 * against this attack out of the box.
 *
 * IMPORTANT: Consider memory side-effects when using custom hashing functions
 * that access memory in an unsafe way.
 *
 * NOTE: This library supports proof verification for merkle trees built using
 * custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
 * leaf inclusion in trees built using non-commutative hashing functions requires
 * additional logic that is not supported by this library.
 */
library MerkleProof {
    /**
     *@dev The multiproof provided is not valid.
     */
    error MerkleProofInvalidMultiproof();

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

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

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

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

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

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with the default hashing function.
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with a custom hashing function.
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processProofCalldata(proof, leaf, hasher) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with a custom hashing function.
     */
    function processProofCalldata(
        bytes32[] calldata proof,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = hasher(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in memory with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProof}.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

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

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

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

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

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in memory with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProof}.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processMultiProof(proof, proofFlags, leaves, hasher) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in memory with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

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

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

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

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in calldata with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProofCalldata}.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in calldata with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

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

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

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

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in calldata with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProofCalldata}.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in calldata with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

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

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

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

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

/**
 * @title IDotHypeRegistry
 * @dev Interface for the DotHype registry contract
 */
interface IDotHypeRegistry {
    /**
     * @dev Event emitted when a name is registered
     * @param tokenId The token ID of the registered name
     * @param name The name of the registered name
     * @param owner The address that owns the name
     * @param expiry The timestamp when the registration expires
     */
    event NameRegistered(uint256 indexed tokenId, string name, address indexed owner, uint256 expiry);

    /**
     * @dev Event emitted when a name registration is renewed
     * @param tokenId The token ID of the renewed name
     * @param expiry The new expiry timestamp
     */
    event NameRenewed(uint256 indexed tokenId, uint256 expiry);

    /**
     * @dev Registers a new name
     * @param name The name to register
     * @param owner The address that will own the name
     * @param duration The duration in seconds for the registration
     * @return tokenId The token ID of the registered name
     * @return expiry The timestamp when the registration expires
     */
    function register(string calldata name, address owner, uint256 duration)
        external
        returns (uint256 tokenId, uint256 expiry);

    /**
     * @dev Renews an existing name registration
     * @param tokenId The token ID of the name to renew
     * @param duration The additional duration in seconds
     * @return expiry The new expiry timestamp
     */
    function renew(uint256 tokenId, uint256 duration) external returns (uint256 expiry);

    /**
     * @dev Gets the expiry time of a name
     * @param tokenId The token ID of the name to query
     * @return expiry The expiry timestamp
     */
    function expiryOf(uint256 tokenId) external view returns (uint256 expiry);

    /**
     * @dev Checks if a name is available for registration
     * @param name The name to check
     * @return available True if the name is available
     */
    function available(string calldata name) external view returns (bool available);

    /**
     * @dev Gets the token ID for a label
     * @param label The label to query (without .hype)
     * @return tokenId The token ID
     */
    function nameToTokenId(string calldata label) external pure returns (uint256 tokenId);

    /**
     * @dev Gets the name for a token ID
     * @param tokenId The token ID to query
     * @return name The name
     */
    function tokenIdToName(uint256 tokenId) external view returns (string memory name);
}

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

/**
 * @title IPriceOracle
 * @dev Interface for Hyperliquid price oracle functions
 */
interface IPriceOracle {
    /**
     * @dev Converts a USD amount to HYPE tokens
     * @param usdAmount 18-decimal USD amount (e.g. 1e18 = $1)
     * @return hypeAmount 18-decimal HYPE amount
     */
    function usdToHype(uint256 usdAmount) external view returns (uint256 hypeAmount);

    /**
     * @dev Gets the raw HYPE/USD price from the precompile
     * @return price Raw price in the precompile format (scaled by 1e6)
     */
    function getRawPrice() external view returns (uint64 price);
}

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

pragma solidity ^0.8.20;

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/MessageHashUtils.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
 *
 * The library provides methods for generating a hash of a message that conforms to the
 * https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
 * specifications.
 */
library MessageHashUtils {
    /**
     * @dev Returns the keccak256 digest of an ERC-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing a bytes32 `messageHash` with
     * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
     * hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
     * keccak256, although any bytes32 value can be safely used because the final digest will
     * be re-hashed.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
        assembly ("memory-safe") {
            mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an ERC-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing an arbitrary `message` with
     * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
     * hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
        return
            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
    }

    /**
     * @dev Returns the keccak256 digest of an ERC-191 signed data with version
     * `0x00` (data with intended validator).
     *
     * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
     * `validator` address. Then hashing the result.
     *
     * See {ECDSA-recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(hex"19_00", validator, data));
    }

    /**
     * @dev Variant of {toDataWithIntendedValidatorHash-address-bytes} optimized for cases where `data` is a bytes32.
     */
    function toDataWithIntendedValidatorHash(
        address validator,
        bytes32 messageHash
    ) internal pure returns (bytes32 digest) {
        assembly ("memory-safe") {
            mstore(0x00, hex"19_00")
            mstore(0x02, shl(96, validator))
            mstore(0x16, messageHash)
            digest := keccak256(0x00, 0x36)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).
     *
     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
     * `\x19\x01` and hashing the result. It corresponds to the hash signed by the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
     *
     * See {ECDSA-recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            mstore(ptr, hex"19_01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            digest := keccak256(ptr, 0x42)
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.20;

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

// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |
// | length  | 0x                                                              BB |
type ShortString is bytes32;

/**
 * @dev This library provides functions to convert short memory strings
 * into a `ShortString` type that can be used as an immutable variable.
 *
 * Strings of arbitrary length can be optimized using this library if
 * they are short enough (up to 31 bytes) by packing them with their
 * length (1 byte) in a single EVM word (32 bytes). Additionally, a
 * fallback mechanism can be used for every other case.
 *
 * Usage example:
 *
 * ```solidity
 * contract Named {
 *     using ShortStrings for *;
 *
 *     ShortString private immutable _name;
 *     string private _nameFallback;
 *
 *     constructor(string memory contractName) {
 *         _name = contractName.toShortStringWithFallback(_nameFallback);
 *     }
 *
 *     function name() external view returns (string memory) {
 *         return _name.toStringWithFallback(_nameFallback);
 *     }
 * }
 * ```
 */
library ShortStrings {
    // Used as an identifier for strings longer than 31 bytes.
    bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;

    error StringTooLong(string str);
    error InvalidShortString();

    /**
     * @dev Encode a string of at most 31 chars into a `ShortString`.
     *
     * This will trigger a `StringTooLong` error is the input string is too long.
     */
    function toShortString(string memory str) internal pure returns (ShortString) {
        bytes memory bstr = bytes(str);
        if (bstr.length > 31) {
            revert StringTooLong(str);
        }
        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
    }

    /**
     * @dev Decode a `ShortString` back to a "normal" string.
     */
    function toString(ShortString sstr) internal pure returns (string memory) {
        uint256 len = byteLength(sstr);
        // using `new string(len)` would work locally but is not memory safe.
        string memory str = new string(32);
        assembly ("memory-safe") {
            mstore(str, len)
            mstore(add(str, 0x20), sstr)
        }
        return str;
    }

    /**
     * @dev Return the length of a `ShortString`.
     */
    function byteLength(ShortString sstr) internal pure returns (uint256) {
        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
        if (result > 31) {
            revert InvalidShortString();
        }
        return result;
    }

    /**
     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
     */
    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
        if (bytes(value).length < 32) {
            return toShortString(value);
        } else {
            StorageSlot.getStringSlot(store).value = value;
            return ShortString.wrap(FALLBACK_SENTINEL);
        }
    }

    /**
     * @dev Decode a string that was encoded to `ShortString` or written to storage using {toShortStringWithFallback}.
     */
    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
            return toString(value);
        } else {
            return store;
        }
    }

    /**
     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using
     * {toShortStringWithFallback}.
     *
     * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
     */
    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
            return byteLength(value);
        } else {
            return bytes(store).length;
        }
    }
}

File 12 of 19 : IERC5267.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.20;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/Hashes.sol)

pragma solidity ^0.8.20;

/**
 * @dev Library of standard hash functions.
 *
 * _Available since v5.1._
 */
library Hashes {
    /**
     * @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
     *
     * NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
     */
    function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
        return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);
    }

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

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

pragma solidity ^0.8.20;

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

/**
 * @dev String operations.
 */
library Strings {
    using SafeCast for *;

    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;
    uint256 private constant SPECIAL_CHARS_LOOKUP =
        (1 << 0x08) | // backspace
            (1 << 0x09) | // tab
            (1 << 0x0a) | // newline
            (1 << 0x0c) | // form feed
            (1 << 0x0d) | // carriage return
            (1 << 0x22) | // double quote
            (1 << 0x5c); // backslash

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

    /**
     * @dev The string being parsed contains characters that are not in scope of the given base.
     */
    error StringsInvalidChar();

    /**
     * @dev The string being parsed is not a properly formatted address.
     */
    error StringsInvalidAddressFormat();

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

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

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

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

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

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
     * representation, according to EIP-55.
     */
    function toChecksumHexString(address addr) internal pure returns (string memory) {
        bytes memory buffer = bytes(toHexString(addr));

        // hash the hex part of buffer (skip length + 2 bytes, length 40)
        uint256 hashValue;
        assembly ("memory-safe") {
            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
        }

        for (uint256 i = 41; i > 1; --i) {
            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
                // case shift by xoring with 0x20
                buffer[i] ^= 0x20;
            }
            hashValue >>= 4;
        }
        return string(buffer);
    }

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

    /**
     * @dev Parse a decimal string and returns the value as a `uint256`.
     *
     * Requirements:
     * - The string must be formatted as `[0-9]*`
     * - The result must fit into an `uint256` type
     */
    function parseUint(string memory input) internal pure returns (uint256) {
        return parseUint(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `[0-9]*`
     * - The result must fit into an `uint256` type
     */
    function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
        (bool success, uint256 value) = tryParseUint(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
        return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
     * character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseUint(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, uint256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseUintUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseUintUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, uint256 value) {
        bytes memory buffer = bytes(input);

        uint256 result = 0;
        for (uint256 i = begin; i < end; ++i) {
            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
            if (chr > 9) return (false, 0);
            result *= 10;
            result += chr;
        }
        return (true, result);
    }

    /**
     * @dev Parse a decimal string and returns the value as a `int256`.
     *
     * Requirements:
     * - The string must be formatted as `[-+]?[0-9]*`
     * - The result must fit in an `int256` type.
     */
    function parseInt(string memory input) internal pure returns (int256) {
        return parseInt(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `[-+]?[0-9]*`
     * - The result must fit in an `int256` type.
     */
    function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
        (bool success, int256 value) = tryParseInt(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
     * the result does not fit in a `int256`.
     *
     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
     */
    function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
        return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
    }

    uint256 private constant ABS_MIN_INT256 = 2 ** 255;

    /**
     * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
     * character or if the result does not fit in a `int256`.
     *
     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
     */
    function tryParseInt(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, int256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseIntUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseIntUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, int256 value) {
        bytes memory buffer = bytes(input);

        // Check presence of a negative sign.
        bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        bool positiveSign = sign == bytes1("+");
        bool negativeSign = sign == bytes1("-");
        uint256 offset = (positiveSign || negativeSign).toUint();

        (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);

        if (absSuccess && absValue < ABS_MIN_INT256) {
            return (true, negativeSign ? -int256(absValue) : int256(absValue));
        } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
            return (true, type(int256).min);
        } else return (false, 0);
    }

    /**
     * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
     *
     * Requirements:
     * - The string must be formatted as `(0x)?[0-9a-fA-F]*`
     * - The result must fit in an `uint256` type.
     */
    function parseHexUint(string memory input) internal pure returns (uint256) {
        return parseHexUint(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
     * - The result must fit in an `uint256` type.
     */
    function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
        (bool success, uint256 value) = tryParseHexUint(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
        return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
     * invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseHexUint(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, uint256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseHexUintUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseHexUintUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, uint256 value) {
        bytes memory buffer = bytes(input);

        // skip 0x prefix if present
        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        uint256 offset = hasPrefix.toUint() * 2;

        uint256 result = 0;
        for (uint256 i = begin + offset; i < end; ++i) {
            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
            if (chr > 15) return (false, 0);
            result *= 16;
            unchecked {
                // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
                // This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
                result += chr;
            }
        }
        return (true, result);
    }

    /**
     * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
     *
     * Requirements:
     * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
     */
    function parseAddress(string memory input) internal pure returns (address) {
        return parseAddress(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
     */
    function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
        (bool success, address value) = tryParseAddress(input, begin, end);
        if (!success) revert StringsInvalidAddressFormat();
        return value;
    }

    /**
     * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
     * formatted address. See {parseAddress-string} requirements.
     */
    function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
        return tryParseAddress(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
     * formatted address. See {parseAddress-string-uint256-uint256} requirements.
     */
    function tryParseAddress(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, address value) {
        if (end > bytes(input).length || begin > end) return (false, address(0));

        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        uint256 expectedLength = 40 + hasPrefix.toUint() * 2;

        // check that input is the correct length
        if (end - begin == expectedLength) {
            // length guarantees that this does not overflow, and value is at most type(uint160).max
            (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
            return (s, address(uint160(v)));
        } else {
            return (false, address(0));
        }
    }

    function _tryParseChr(bytes1 chr) private pure returns (uint8) {
        uint8 value = uint8(chr);

        // Try to parse `chr`:
        // - Case 1: [0-9]
        // - Case 2: [a-f]
        // - Case 3: [A-F]
        // - otherwise not supported
        unchecked {
            if (value > 47 && value < 58) value -= 48;
            else if (value > 96 && value < 103) value -= 87;
            else if (value > 64 && value < 71) value -= 55;
            else return type(uint8).max;
        }

        return value;
    }

    /**
     * @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
     *
     * WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
     *
     * NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
     * RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
     * characters that are not in this range, but other tooling may provide different results.
     */
    function escapeJSON(string memory input) internal pure returns (string memory) {
        bytes memory buffer = bytes(input);
        bytes memory output = new bytes(2 * buffer.length); // worst case scenario
        uint256 outputLength = 0;

        for (uint256 i; i < buffer.length; ++i) {
            bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
            if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
                output[outputLength++] = "\\";
                if (char == 0x08) output[outputLength++] = "b";
                else if (char == 0x09) output[outputLength++] = "t";
                else if (char == 0x0a) output[outputLength++] = "n";
                else if (char == 0x0c) output[outputLength++] = "f";
                else if (char == 0x0d) output[outputLength++] = "r";
                else if (char == 0x5c) output[outputLength++] = "\\";
                else if (char == 0x22) {
                    // solhint-disable-next-line quotes
                    output[outputLength++] = '"';
                }
            } else {
                output[outputLength++] = char;
            }
        }
        // write the actual length and deallocate unused memory
        assembly ("memory-safe") {
            mstore(output, outputLength)
            mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
        }

        return string(output);
    }

    /**
     * @dev Reads a bytes32 from a bytes array without bounds checking.
     *
     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
     * assembly block as such would prevent some optimizations.
     */
    function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
        // This is not memory safe in the general case, but all calls to this private function are within bounds.
        assembly ("memory-safe") {
            value := mload(add(buffer, add(0x20, offset)))
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC-1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct Int256Slot {
        int256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Int256Slot` with member `value` located at `slot`.
     */
    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns a `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }
}

File 16 of 19 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Return the 512-bit addition of two uint256.
     *
     * The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
     */
    function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        assembly ("memory-safe") {
            low := add(a, b)
            high := lt(low, a)
        }
    }

    /**
     * @dev Return the 512-bit multiplication of two uint256.
     *
     * The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
     */
    function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        // 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
        // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
        // variables such that product = high * 2²⁵⁶ + low.
        assembly ("memory-safe") {
            let mm := mulmod(a, b, not(0))
            low := mul(a, b)
            high := sub(sub(mm, low), lt(mm, low))
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a + b;
            success = c >= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a - b;
            success = c <= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a * b;
            assembly ("memory-safe") {
                // Only true when the multiplication doesn't overflow
                // (c / a == b) || (a == 0)
                success := or(eq(div(c, a), b), iszero(a))
            }
            // equivalent to: success ? c : 0
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `DIV` opcode returns zero when the denominator is 0.
                result := div(a, b)
            }
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `MOD` opcode returns zero when the denominator is 0.
                result := mod(a, b)
            }
        }
    }

    /**
     * @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryAdd(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
     */
    function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
        (, uint256 result) = trySub(a, b);
        return result;
    }

    /**
     * @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryMul(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * SafeCast.toUint(condition));
        }
    }

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

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

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

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

        // The following calculation ensures accurate ceiling division without overflow.
        // Since a is non-zero, (a - 1) / b will not overflow.
        // The largest possible result occurs when (a - 1) / b is type(uint256).max,
        // but the largest value we can obtain is type(uint256).max - 1, which happens
        // when a = type(uint256).max and b = 1.
        unchecked {
            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
        }
    }

    /**
     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     *
     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            (uint256 high, uint256 low) = mul512(x, y);

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

            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
            if (denominator <= high) {
                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
            }

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

            // Make division exact by subtracting the remainder from [high low].
            uint256 remainder;
            assembly ("memory-safe") {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

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

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

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

                // Divide [high low] by twos.
                low := div(low, twos)

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

            // Shift in bits from high into low.
            low |= high * twos;

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

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
            inverse *= 2 - denominator * inverse; // inverse mod 2³²
            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶

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

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

    /**
     * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
     */
    function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
        unchecked {
            (uint256 high, uint256 low) = mul512(x, y);
            if (high >= 1 << n) {
                Panic.panic(Panic.UNDER_OVERFLOW);
            }
            return (high << (256 - n)) | (low >> n);
        }
    }

    /**
     * @dev Calculates x * y >> n with full precision, following the selected rounding direction.
     */
    function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
        return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
    }

    /**
     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
     *
     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
     *
     * If the input value is not inversible, 0 is returned.
     *
     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
     */
    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
        unchecked {
            if (n == 0) return 0;

            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
            // Used to compute integers x and y such that: ax + ny = gcd(a, n).
            // When the gcd is 1, then the inverse of a modulo n exists and it's x.
            // ax + ny = 1
            // ax = 1 + (-y)n
            // ax ≡ 1 (mod n) # x is the inverse of a modulo n

            // If the remainder is 0 the gcd is n right away.
            uint256 remainder = a % n;
            uint256 gcd = n;

            // Therefore the initial coefficients are:
            // ax + ny = gcd(a, n) = n
            // 0a + 1n = n
            int256 x = 0;
            int256 y = 1;

            while (remainder != 0) {
                uint256 quotient = gcd / remainder;

                (gcd, remainder) = (
                    // The old remainder is the next gcd to try.
                    remainder,
                    // Compute the next remainder.
                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
                    // where gcd is at most n (capped to type(uint256).max)
                    gcd - remainder * quotient
                );

                (x, y) = (
                    // Increment the coefficient of a.
                    y,
                    // Decrement the coefficient of n.
                    // Can overflow, but the result is casted to uint256 so that the
                    // next value of y is "wrapped around" to a value between 0 and n - 1.
                    x - y * int256(quotient)
                );
            }

            if (gcd != 1) return 0; // No inverse exists.
            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
        }
    }

    /**
     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
     *
     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.
     *
     * NOTE: this function does NOT check that `p` is a prime greater than `2`.
     */
    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
        unchecked {
            return Math.modExp(a, p - 2, p);
        }
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
     *
     * Requirements:
     * - modulus can't be zero
     * - underlying staticcall to precompile must succeed
     *
     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
     * sure the chain you're using it on supports the precompiled contract for modular exponentiation
     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly
     * interpreted as 0.
     */
    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
        (bool success, uint256 result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
     * to operate modulo 0 or if the underlying precompile reverted.
     *
     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
     * of a revert, but the result may be incorrectly interpreted as 0.
     */
    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
        if (m == 0) return (false, 0);
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            // | Offset    | Content    | Content (Hex)                                                      |
            // |-----------|------------|--------------------------------------------------------------------|
            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x60:0x7f | value of b | 0x<.............................................................b> |
            // | 0x80:0x9f | value of e | 0x<.............................................................e> |
            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |
            mstore(ptr, 0x20)
            mstore(add(ptr, 0x20), 0x20)
            mstore(add(ptr, 0x40), 0x20)
            mstore(add(ptr, 0x60), b)
            mstore(add(ptr, 0x80), e)
            mstore(add(ptr, 0xa0), m)

            // Given the result < m, it's guaranteed to fit in 32 bytes,
            // so we can use the memory scratch space located at offset 0.
            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
            result := mload(0x00)
        }
    }

    /**
     * @dev Variant of {modExp} that supports inputs of arbitrary length.
     */
    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
        (bool success, bytes memory result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.
     */
    function tryModExp(
        bytes memory b,
        bytes memory e,
        bytes memory m
    ) internal view returns (bool success, bytes memory result) {
        if (_zeroBytes(m)) return (false, new bytes(0));

        uint256 mLen = m.length;

        // Encode call args in result and move the free memory pointer
        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);

        assembly ("memory-safe") {
            let dataPtr := add(result, 0x20)
            // Write result on top of args to avoid allocating extra memory.
            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
            // Overwrite the length.
            // result.length > returndatasize() is guaranteed because returndatasize() == m.length
            mstore(result, mLen)
            // Set the memory pointer after the returned data.
            mstore(0x40, add(dataPtr, mLen))
        }
    }

    /**
     * @dev Returns whether the provided byte array is zero.
     */
    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
        for (uint256 i = 0; i < byteArray.length; ++i) {
            if (byteArray[i] != 0) {
                return false;
            }
        }
        return true;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only
     * using integer operations.
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        unchecked {
            // Take care of easy edge cases when a == 0 or a == 1
            if (a <= 1) {
                return a;
            }

            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
            // the current value as `ε_n = | x_n - sqrt(a) |`.
            //
            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
            // bigger than any uint256.
            //
            // By noticing that
            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
            // to the msb function.
            uint256 aa = a;
            uint256 xn = 1;

            if (aa >= (1 << 128)) {
                aa >>= 128;
                xn <<= 64;
            }
            if (aa >= (1 << 64)) {
                aa >>= 64;
                xn <<= 32;
            }
            if (aa >= (1 << 32)) {
                aa >>= 32;
                xn <<= 16;
            }
            if (aa >= (1 << 16)) {
                aa >>= 16;
                xn <<= 8;
            }
            if (aa >= (1 << 8)) {
                aa >>= 8;
                xn <<= 4;
            }
            if (aa >= (1 << 4)) {
                aa >>= 4;
                xn <<= 2;
            }
            if (aa >= (1 << 2)) {
                xn <<= 1;
            }

            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
            //
            // We can refine our estimation by noticing that the middle of that interval minimizes the error.
            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
            // This is going to be our x_0 (and ε_0)
            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)

            // From here, Newton's method give us:
            // x_{n+1} = (x_n + a / x_n) / 2
            //
            // One should note that:
            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
            //              = ((x_n² + a) / (2 * x_n))² - a
            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
            //              = (x_n² - a)² / (2 * x_n)²
            //              = ((x_n² - a) / (2 * x_n))²
            //              ≥ 0
            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
            //
            // This gives us the proof of quadratic convergence of the sequence:
            // ε_{n+1} = | x_{n+1} - sqrt(a) |
            //         = | (x_n + a / x_n) / 2 - sqrt(a) |
            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
            //         = | (x_n - sqrt(a))² / (2 * x_n) |
            //         = | ε_n² / (2 * x_n) |
            //         = ε_n² / | (2 * x_n) |
            //
            // For the first iteration, we have a special case where x_0 is known:
            // ε_1 = ε_0² / | (2 * x_0) |
            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))
            //     ≤ 2**(e-3) / 3
            //     ≤ 2**(e-3-log2(3))
            //     ≤ 2**(e-4.5)
            //
            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
            // ε_{n+1} = ε_n² / | (2 * x_n) |
            //         ≤ (2**(e-k))² / (2 * 2**(e-1))
            //         ≤ 2**(2*e-2*k) / 2**e
            //         ≤ 2**(e-2*k)
            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above
            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5
            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9
            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18
            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36
            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72

            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
            // sqrt(a) or sqrt(a) + 1.
            return xn - SafeCast.toUint(xn > a / xn);
        }
    }

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

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // If upper 8 bits of 16-bit half set, add 8 to result
        r |= SafeCast.toUint((x >> r) > 0xff) << 3;
        // If upper 4 bits of 8-bit half set, add 4 to result
        r |= SafeCast.toUint((x >> r) > 0xf) << 2;

        // Shifts value right by the current result and use it as an index into this lookup table:
        //
        // | x (4 bits) |  index  | table[index] = MSB position |
        // |------------|---------|-----------------------------|
        // |    0000    |    0    |        table[0] = 0         |
        // |    0001    |    1    |        table[1] = 0         |
        // |    0010    |    2    |        table[2] = 1         |
        // |    0011    |    3    |        table[3] = 1         |
        // |    0100    |    4    |        table[4] = 2         |
        // |    0101    |    5    |        table[5] = 2         |
        // |    0110    |    6    |        table[6] = 2         |
        // |    0111    |    7    |        table[7] = 2         |
        // |    1000    |    8    |        table[8] = 3         |
        // |    1001    |    9    |        table[9] = 3         |
        // |    1010    |   10    |        table[10] = 3        |
        // |    1011    |   11    |        table[11] = 3        |
        // |    1100    |   12    |        table[12] = 3        |
        // |    1101    |   13    |        table[13] = 3        |
        // |    1110    |   14    |        table[14] = 3        |
        // |    1111    |   15    |        table[15] = 3        |
        //
        // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
        assembly ("memory-safe") {
            r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
        }
    }

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

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

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

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
        return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
    }

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

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

File 17 of 19 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }

    /**
     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
     */
    function toUint(bool b) internal pure returns (uint256 u) {
        assembly ("memory-safe") {
            u := iszero(iszero(b))
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
        }
    }

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

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

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

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
            // taking advantage of the most significant (or "sign" bit) in two's complement representation.
            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
            int256 mask = n >> 255;

            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
            return uint256((n + mask) ^ mask);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)

pragma solidity ^0.8.20;

/**
 * @dev Helper library for emitting standardized panic codes.
 *
 * ```solidity
 * contract Example {
 *      using Panic for uint256;
 *
 *      // Use any of the declared internal constants
 *      function foo() { Panic.GENERIC.panic(); }
 *
 *      // Alternatively
 *      function foo() { Panic.panic(Panic.GENERIC); }
 * }
 * ```
 *
 * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
 *
 * _Available since v5.1._
 */
// slither-disable-next-line unused-state
library Panic {
    /// @dev generic / unspecified error
    uint256 internal constant GENERIC = 0x00;
    /// @dev used by the assert() builtin
    uint256 internal constant ASSERT = 0x01;
    /// @dev arithmetic underflow or overflow
    uint256 internal constant UNDER_OVERFLOW = 0x11;
    /// @dev division or modulo by zero
    uint256 internal constant DIVISION_BY_ZERO = 0x12;
    /// @dev enum conversion error
    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
    /// @dev invalid encoding in storage
    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
    /// @dev empty array pop
    uint256 internal constant EMPTY_ARRAY_POP = 0x31;
    /// @dev array out of bounds access
    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
    /// @dev resource error (too large allocation or too large array)
    uint256 internal constant RESOURCE_ERROR = 0x41;
    /// @dev calling invalid internal function
    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;

    /// @dev Reverts with a panic code. Recommended to use with
    /// the internal constants with predefined codes.
    function panic(uint256 code) internal pure {
        assembly ("memory-safe") {
            mstore(0x00, 0x4e487b71)
            mstore(0x20, code)
            revert(0x1c, 0x24)
        }
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@ens/=lib/ens-contracts/contracts/",
    "forge-std/=lib/forge-std/src/",
    "ens-contracts/=lib/ens-contracts/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "hypercore-sim/=lib/hypercore-sim/contracts/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": true,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_registry","type":"address"},{"internalType":"address","name":"_signer","type":"address"},{"internalType":"address","name":"_priceOracle","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"minter","type":"address"}],"name":"AlreadyMinted","type":"error"},{"inputs":[],"name":"AuctionAlreadyStarted","type":"error"},{"inputs":[],"name":"AuctionNotActive","type":"error"},{"inputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"name":"CharacterLengthNotAvailable","type":"error"},{"inputs":[],"name":"DomainAlreadyInAuction","type":"error"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"DomainInAuction","type":"error"},{"inputs":[],"name":"DomainNotInAuction","type":"error"},{"inputs":[{"internalType":"uint256","name":"provided","type":"uint256"},{"internalType":"uint256","name":"minimum","type":"uint256"}],"name":"DurationTooShort","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"FundsTransferFailed","type":"error"},{"inputs":[{"internalType":"uint256","name":"required","type":"uint256"},{"internalType":"uint256","name":"provided","type":"uint256"}],"name":"InsufficientPayment","type":"error"},{"inputs":[],"name":"InvalidAuctionConfig","type":"error"},{"inputs":[],"name":"InvalidBatchId","type":"error"},{"inputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"name":"InvalidCharacterCount","type":"error"},{"inputs":[],"name":"InvalidMerkleProof","type":"error"},{"inputs":[],"name":"InvalidPriceConfig","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidSigner","type":"error"},{"inputs":[],"name":"MerkleRootNotSet","type":"error"},{"inputs":[{"internalType":"bytes32","name":"nameHash","type":"bytes32"},{"internalType":"address","name":"reservedFor","type":"address"}],"name":"NameIsReserved","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"bytes32","name":"nameHash","type":"bytes32"}],"name":"NotAuthorized","type":"error"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"NotReserved","type":"error"},{"inputs":[],"name":"OracleNotSet","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"PricingNotSet","type":"error"},{"inputs":[],"name":"SignatureExpired","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"WithdrawalFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"charCount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"AnnualPriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"charCount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"AnnualRenewalPriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"batchId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"nameHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"DomainAddedToAuctionBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"DomainRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"batchId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"nameHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"DomainRemovedFromAuctionBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"DomainRenewed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"batchId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"}],"name":"DutchAuctionBatchCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"basePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"auctionPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalPrice","type":"uint256"}],"name":"DutchAuctionPurchase","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"MerkleProofRegistration","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"MerkleRootUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"nameHash","type":"bytes32"}],"name":"NameReservationRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"nameHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"reservedFor","type":"address"}],"name":"NameReserved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"PaymentRecipientUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oracle","type":"address"}],"name":"PriceOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"ReservedNameRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newSigner","type":"address"}],"name":"SignerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"MIN_REGISTRATION_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"annualPrices","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"annualRenewalPrices","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"auctionBatches","outputs":[{"internalType":"uint256","name":"startPrice","type":"uint256"},{"internalType":"uint256","name":"endPrice","type":"uint256"},{"internalType":"uint256","name":"auctionDuration","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"calculateDutchAuctionPrice","outputs":[{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"auctionPrice","type":"uint256"},{"internalType":"uint256","name":"totalPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"calculatePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"calculateRenewalPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"checkReservation","outputs":[{"internalType":"bool","name":"isReserved","type":"bool"},{"internalType":"address","name":"reservedFor","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string[]","name":"domains","type":"string[]"},{"internalType":"uint256","name":"startPrice","type":"uint256"},{"internalType":"uint256","name":"endPrice","type":"uint256"},{"internalType":"uint256","name":"auctionDuration","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"}],"name":"createDutchAuctionBatch","outputs":[{"internalType":"uint256","name":"batchId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"domainToBatchId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"batchId","type":"uint256"}],"name":"getAuctionStatus","outputs":[{"components":[{"internalType":"uint256","name":"startPrice","type":"uint256"},{"internalType":"uint256","name":"endPrice","type":"uint256"},{"internalType":"uint256","name":"auctionDuration","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"bool","name":"isActive","type":"bool"}],"internalType":"struct DotHypeDutchAuction.DutchAuctionConfig","name":"config","type":"tuple"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"uint256","name":"timeRemaining","type":"uint256"},{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"bool","name":"hasStarted","type":"bool"},{"internalType":"bool","name":"isComplete","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getNextNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"hasAddressUsedMerkleProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"hasUsedMerkleProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"isDomainInAuction","outputs":[{"internalType":"bool","name":"isInAuction","type":"bool"},{"internalType":"uint256","name":"batchId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextBatchId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracle","outputs":[{"internalType":"contract IPriceOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"}],"name":"purchaseDutchAuction","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"registerDutchAuctionWithSignature","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"registerReserved","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"registerWithMerkleProof","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"registerWithSignature","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"contract IDotHypeRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"renew","outputs":[{"internalType":"uint256","name":"expiry","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"reservedNames","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"}],"name":"resetMerkleProofUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[5]","name":"prices","type":"uint256[5]"}],"name":"setAllAnnualPrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[5]","name":"prices","type":"uint256[5]"}],"name":"setAllAnnualRenewalPrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"charCount","type":"uint256"},{"internalType":"uint256","name":"annualPrice","type":"uint256"}],"name":"setAnnualPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"charCount","type":"uint256"},{"internalType":"uint256","name":"annualPrice","type":"uint256"}],"name":"setAnnualRenewalPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"address[]","name":"reservedAddresses","type":"address[]"}],"name":"setBatchReservations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_paymentRecipient","type":"address"}],"name":"setPaymentRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceOracle","type":"address"}],"name":"setPriceOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"name":"setRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"reservedFor","type":"address"}],"name":"setReservation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"}],"name":"setSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101608060405234610256576080816137398038038091610020828561025a565b8339810103126102565761003381610291565b61003f60208301610291565b610057606061005060408601610291565b9401610291565b926040519361006760408661025a565b601185526020850190702237ba243cb832a1b7b73a3937b63632b960791b82526040519161009660408461025a565b60018352603160f81b602084019081526001600160a01b03909216968715610243575f80546001600160a01b031981168a17825589916001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3610105816102a5565b6101205261011284610440565b61014052519020918260e05251902080610100524660a0526040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a0815261017b60c08261025a565b5190206080523060c0526001600160a01b031691821561023457600380546001600160a01b03199081166001600160a01b039384161790915560048054821693909216929092179055601180548216929092179091556012805490911691909117905560016019556040516131c09081610579823960805181612f13015260a05181612fd0015260c05181612ee4015260e05181612f6201526101005181612f8801526101205181610dbd01526101405181610de60152f35b633e1e538160e21b5f5260045ffd5b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b601f909101601f19168101906001600160401b0382119082101761027d57604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b038216820361025657565b908151602081105f1461031f575090601f8151116102df5760208151910151602082106102d0571790565b5f198260200360031b1b161790565b604460209160405192839163305a27a960e01b83528160048401528051918291826024860152018484015e5f828201840152601f01601f19168101030190fd5b6001600160401b03811161027d57600154600181811c91168015610436575b602082101461042257601f81116103ef575b50602092601f821160011461038e57928192935f92610383575b50508160011b915f199060031b1c19161760015560ff90565b015190505f8061036a565b601f1982169360015f52805f20915f5b8681106103d757508360019596106103bf575b505050811b0160015560ff90565b01515f1960f88460031b161c191690555f80806103b1565b9192602060018192868501518155019401920161039e565b60015f52601f60205f20910160051c810190601f830160051c015b8181106104175750610350565b5f815560010161040a565b634e487b7160e01b5f52602260045260245ffd5b90607f169061033e565b908151602081105f1461046b575090601f8151116102df5760208151910151602082106102d0571790565b6001600160401b03811161027d57600254600181811c9116801561056e575b602082101461042257601f811161053b575b50602092601f82116001146104da57928192935f926104cf575b50508160011b915f199060031b1c19161760025560ff90565b015190505f806104b6565b601f1982169360025f52805f20915f5b868110610523575083600195961061050b575b505050811b0160025560ff90565b01515f1960f88460031b161c191690555f80806104fd565b919260206001819286850151815501940192016104ea565b60025f52601f60205f20910160051c810190601f830160051c015b818110610563575061049c565b5f8155600101610556565b90607f169061048a56fe608080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c908163114ccb9814611c2357508063238ac93314611bfd5780632630c12f14611bd75780632983c4b814611b575780632b1eaf2914611b315780632eb4a7ab14611b14578063389c074814611ae15780633b10faf514611ac85780633c4cb59014611a505780634b4e9f2a1461197b5780634e86501c146118e657806351cff8d9146118bd578063530e784f1461180e578063547b34b5146117965780636a1f45af146117435780636b1f2520146117175780636c19e78314611697578063715018a6146116285780637602206a146115df5780637765c52c1461144a5780637b103999146114245780637bd666c31461120b5780637cb64759146111bf5780637de68b931461112c5780637ecebe0014610d485780638022376414610ed65780638462a7f814610eb957806384b0196e14610da55780638da5cb5b14610d8057806390193b7c14610d4857806391101b7814610c64578063991fa9de14610aab578063a692bf7d14610941578063a91ee0dc146108ea578063ad2e56b81461088f578063b4054eae14610854578063bbe6847014610828578063c4557747146107fe578063c475abff14610630578063c8078d63146105f3578063cb5a7c541461046d578063dd2cdaf214610380578063f28da5561461035f578063f2fde38b146102ab578063f8c373e4146102445763ff3e982914610222575f61000f565b34610240575f6003193601126102405760206040516301e133808152f35b5f80fd5b346102405760206003193601126102405760043567ffffffffffffffff81116102405761027861027f913690600401611da5565b3691611d09565b602081519101205f52601360205260406001600160a01b03815f20541681519080151582526020820152f35b34610240576020600319360112610240576001600160a01b036102cc611c5c565b6102d46124f7565b168015610333576001600160a01b035f54827fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f55167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b3461024057602061037861037236611d5d565b9061245f565b604051908152f35b346102405760a0600319360112610240573660a411610240576103a16124f7565b5f5b600581106103ad57005b6103b6816121a6565b3590600181018082116104405760068110156104135760407f9ccab05fb2d456a6b8f1e4b0131e9bfabc426ca148464c5b027ecfef165f391891600194600c850155610401846121a6565b3582519182526020820152a1016103a3565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b60406003193601126102405760043567ffffffffffffffff811161024057610499903690600401611da5565b906024356104a8368484611d09565b6020815191012092835f5260136020526001600160a01b0360405f20541680156105b3573303610583577f8034d8fda3d279e347445354cfc5c28522ccec743d5bf18f0d015952e142f5539060409461057461050f853361050a36878b611d09565b6128ba565b959096835f526013602052885f207fffffffffffffffffffffffff0000000000000000000000000000000000000000815416905588519485947f27708016161f21df5a88a54264eed7ce7344b062c77faa396229f8ceb59834215f80a23391856121f6565b0390a182519182526020820152f35b837fa4e1a97e000000000000000000000000000000000000000000000000000000005f523360045260245260445ffd5b6040517fe0b762d000000000000000000000000000000000000000000000000000000000815260206004820152806105ef6024820185886121b8565b0390fd5b34610240576020600319360112610240576001600160a01b03610614611c5c565b165f526015602052602060ff60405f2054166040519015158152f35b602461063b36611d8f565b5f6001600160a01b0360039493945416604051938480927fda2bfdb10000000000000000000000000000000000000000000000000000000082528760048301525afa918215610771575f9261077c575b50610697815f9361245f565b6106a081612ac8565b5060206001600160a01b03600354166044604051809681937fc475abff0000000000000000000000000000000000000000000000000000000083528960048401528760248401525af1928315610771575f9361073a575b5060408051948552602080860193909352840152917fae68301bb68924e9d4c9082934bc3a65a03b5778aee54c29e3ed972166ec9ae190606090a1604051908152f35b919092506020823d602011610769575b8161075760209383611c8e565b810103126102405790519160206106f7565b3d915061074a565b6040513d5f823e3d90fd5b91503d805f843e61078d8184611c8e565b8201916020818403126102405780519067ffffffffffffffff8211610240570182601f82011215610240578051906107c482611ccf565b936107d26040519586611c8e565b82855260208383010111610240575f938460208461069795828896018386015e8301015293505061068b565b34610240576020600319360112610240576004355f526018602052602060405f2054604051908152f35b346102405760206003193601126102405760043560068110156102405760209060050154604051908152f35b346102405761088b61086e61086836611d5d565b90612223565b604080519384526020840192909252908201529081906060820190565b0390f35b34610240576020600319360112610240576004355f52601760205260a060405f20805490600181015490600281015460ff60046003840154930154169260405194855260208501526040840152606083015215156080820152f35b34610240576020600319360112610240576001600160a01b0361090b611c5c565b6109136124f7565b167fffffffffffffffffffffffff000000000000000000000000000000000000000060035416176003555f80f35b61094a36611dd3565b9092829796979594954211610a8357610a2a93610a13610a1b92610a2195610976348380341115612a91565b8b6001600160a01b038a1691825f5260166020526109a88d60405f209384549461099f86612119565b90553691611d09565b60208151910120936040519360208501957f562736d27893c5a2e53960cc41ec255b8eb9f05780a7d188194fac9ee284530f8752604086015260608501528c608085015260a084015260c083015260e082015260e08152610a0b61010082611c8e565b519020612b94565b923691611d09565b90612ff6565b90929192613030565b6001600160a01b038060045416911603610a5b5761050a610a4f936040953691611d09565b82519182526020820152f35b7f815e1d64000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f0819bdcd000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102405760406003193601126102405760043567ffffffffffffffff811161024057610adc903690600401611e45565b60243567ffffffffffffffff811161024057610afc903690600401611e45565b91610b056124f7565b828103610c06575f5b818110610b1757005b80610b286102786001938589612146565b60208151910120610b42610b3d838888611fa6565b611fb6565b815f5260136020526001600160a01b0360405f2091167fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790556001600160a01b03610b95610b3d848989611fa6565b16610bc5577f27708016161f21df5a88a54264eed7ce7344b062c77faa396229f8ceb59834215f80a25b01610b0e565b6001600160a01b03610bdb610b3d848989611fa6565b16907fccfd1e8567bc1749489631ff7b34c5d322a22795659e114ae37dc021099de4e05f80a3610bbf565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4172726179206c656e67746873206d69736d61746368000000000000000000006044820152fd5b346102405760406003193601126102405760043567ffffffffffffffff811161024057610c95903690600401611da5565b602435916001600160a01b03831680930361024057610cb6916102786124f7565b6020815191012090815f52601360205260405f20817fffffffffffffffffffffffff000000000000000000000000000000000000000082541617905580155f14610d2157507f27708016161f21df5a88a54264eed7ce7344b062c77faa396229f8ceb59834215f80a2005b907fccfd1e8567bc1749489631ff7b34c5d322a22795659e114ae37dc021099de4e05f80a3005b34610240576020600319360112610240576001600160a01b03610d69611c5c565b165f526016602052602060405f2054604051908152f35b34610240575f6003193601126102405760206001600160a01b035f5416604051908152f35b34610240575f60031936011261024057610e5d610de17f0000000000000000000000000000000000000000000000000000000000000000612c94565b610e0a7f0000000000000000000000000000000000000000000000000000000000000000612e0a565b6020610e6b60405192610e1d8385611c8e565b5f84525f3681376040519586957f0f00000000000000000000000000000000000000000000000000000000000000875260e08588015260e0870190611e76565b908582036040870152611e76565b4660608501523060808501525f60a085015283810360c08501528180845192838152019301915f5b828110610ea257505050500390f35b835185528695509381019392810192600101610e93565b34610240575f600319360112610240576020601954604051908152f35b60606003193601126102405760043567ffffffffffffffff811161024057610f02903690600401611da5565b906024359060443567ffffffffffffffff811161024057610f27903690600401611e45565b93909260145493841561110457335f52601560205260ff60405f2054166110d85760405160208101903360601b825260148152610f65603482611c8e565b5190209067ffffffffffffffff87116110ab578660051b6020810197610f8e604051998a611c8e565b8852602088019082019136831161024057905b82821061109b57505050925f935b8651851015610ff15760208560051b88010151908181105f14610fe0575f52602052600160405f205b940193610faf565b905f52602052600160405f20610fd8565b8503611073577f8773e1d4834c49732c2070bd8402075b70195f6d5eae9807704fb956cebd338461057491604094335f526015602052855f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055611063853361050a368587611d09565b94909587519384933391856121f6565b7fb05e92fa000000000000000000000000000000000000000000000000000000005f5260045ffd5b8135815260209182019101610fa1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f893cc576000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b7f9f8a28f2000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102405760a0600319360112610240573660a4116102405761114d6124f7565b5f5b6005811061115957005b611162816121a6565b3590600181018082116104405760068110156104135760407f7b902ac6425cebe69042a3b5057c557f8ad66c3d5aa0fcf2bb4903140ee158169160019460068501556111ad846121a6565b3582519182526020820152a10161114f565b34610240576020600319360112610240577f90004c04698bc3322499a575ed3752dd4abf33e0a7294c06a787a0fe01bea94160206004356111fe6124f7565b80601455604051908152a1005b346102405760a06003193601126102405760043567ffffffffffffffff81116102405761123c903690600401611e45565b90602435906064356044356084356112526124f7565b80828611156113fc5783156113fc57806113f157505042925b6019549561127887612119565b60195560405161128781611c72565b868152600460208201918583526040810187815260608201908982526080830194600186528c5f52601760205260405f2093518455516001840155516002830155516003820155019051151560ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691161790555f5b81811061134f57602088807f313a78a5f20cc946067de183e96e29f791e32f9407e559d0cc2832fe4c78cde360808b8b8b8b6040519384528884015260408301526060820152a2604051908152f35b61135d610278828486612146565b9081516020830120805f52601860205260405f20546113c957897f6e03d38755c7f97e70ff44ab359d646241746ab5ab53faf3130e1c115a1a4e256113c0600195845f5260186020528360405f2055604051918291602083526020830190611e76565b0390a301611300565b7f441c0b4b000000000000000000000000000000000000000000000000000000005f5260045ffd5b93909342111561126b575b7f453b7de0000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610240575f6003193601126102405760206001600160a01b0360035416604051908152f35b34610240576020600319360112610240576004355f608060405161146d81611c72565b8281528260208201528260408201528260608201520152801580156115d3575b6115ab575f52601760205261014060405f20604051906114ac82611c72565b8054825260018101546020830190815260028201546040840181815260038401549260ff600460608801968688520154166114f46080880191151594858352864210966120b5565b958642101596875f1461159a57505f935b861561154e578851935b60405199518a525160208a0152516040890152516060880152511515608087015260a086015260c085015260e084015215610100830152610120820152f35b871561155c5783519361150f565b61159461156a8351426120c2565b61158e61158661157d8d518951906120c2565b928d51936120cf565b8451906120e2565b906120c2565b9361150f565b6115a59042906120c2565b93611505565b7f3b98df65000000000000000000000000000000000000000000000000000000005f5260045ffd5b5060195481101561148d565b346102405760206003193601126102405760043567ffffffffffffffff81116102405761161a6116156040923690600401611d3f565b61207d565b825191151582526020820152f35b34610240575f600319360112610240576116406124f7565b5f6001600160a01b0381547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b34610240576020600319360112610240577f5553331329228fbd4123164423717a4a7539f6dfa1c3279a923b98fd681a6c7360206001600160a01b036116db611c5c565b6116e36124f7565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000006004541617600455604051908152a1005b3461024057602060031936011261024057600435600681101561024057602090600b0154604051908152f35b60606003193601126102405760043567ffffffffffffffff811161024057610a4f6117746040923690600401611da5565b9061177d6124f7565b604435916117916024359233923691611d09565b612604565b34610240576117a436611d8f565b6117ac6124f7565b60018210158281611802575b6117c191611f73565b60068210156104135781816040927f9ccab05fb2d456a6b8f1e4b0131e9bfabc426ca148464c5b027ecfef165f391894600b015582519182526020820152a1005b600581111591506117b8565b34610240576020600319360112610240576001600160a01b0361182f611c5c565b6118376124f7565b168015611895576020817fefe8ab924ca486283a79dc604baa67add51afb82af1db8ac386ebbba643cdffd927fffffffffffffffffffffffff00000000000000000000000000000000000000006011541617601155604051908152a1005b7ff8794e04000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102405760206003193601126102405761001a6118d9611c5c565b6118e16124f7565b611ff9565b346102405760206003193601126102405760043567ffffffffffffffff811161024057611917903690600401611e45565b61191f6124f7565b5f5b81811061192a57005b806001600160a01b03611943610b3d6001948688611fa6565b165f52601560205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00815416905501611921565b61198436611dd3565b829796979593954211610a8357610a1b610a2192610a13611a2b956001600160a01b038816805f5260166020528c6119c78d60405f209283549361099f85612119565b60208151910120926040519260208401947f4163a4e6c32c6c6b2bf592a1f25f7b89d1b183f424b2cbb5f6e67976617618148652604085015260608401528b60808401528c60a084015260c083015260e082015260e08152610a0b61010082611c8e565b6001600160a01b038060045416911603610a5b57611791610a4f946040963691611d09565b3461024057611a5e36611d8f565b611a666124f7565b60018210158281611abc575b611a7b91611f73565b60068210156104135781816040927f7b902ac6425cebe69042a3b5057c557f8ad66c3d5aa0fcf2bb4903140ee15816946005015582519182526020820152a1005b60058111159150611a72565b34610240576020610378611adb36611d5d565b90611eb9565b34610240576020600319360112610240576004355f52601360205260206001600160a01b0360405f205416604051908152f35b34610240575f600319360112610240576020601454604051908152f35b34610240575f6003193601126102405760206001600160a01b0360125416604051908152f35b34610240576020600319360112610240577f694f4a35894884360636162607be63896d92aff456c086ea693e15e2f209100560206001600160a01b03611b9b611c5c565b611ba36124f7565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000006012541617601255604051908152a1005b34610240575f6003193601126102405760206001600160a01b0360115416604051908152f35b34610240575f6003193601126102405760206001600160a01b0360045416604051908152f35b34610240576020600319360112610240576020906001600160a01b03611c47611c5c565b165f526015825260ff60405f20541615158152f35b600435906001600160a01b038216820361024057565b60a0810190811067ffffffffffffffff8211176110ab57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176110ab57604052565b67ffffffffffffffff81116110ab57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b929192611d1582611ccf565b91611d236040519384611c8e565b829481845281830111610240578281602093845f960137010152565b9080601f8301121561024057816020611d5a93359101611d09565b90565b6040600319820112610240576004359067ffffffffffffffff821161024057611d8891600401611d3f565b9060243590565b6003196040910112610240576004359060243590565b9181601f840112156102405782359167ffffffffffffffff8311610240576020838186019501011161024057565b60c06003198201126102405760043567ffffffffffffffff81116102405781611dfe91600401611da5565b929092916024356001600160a01b0381168103610240579160443591606435916084359160a4359067ffffffffffffffff821161024057611e4191600401611da5565b9091565b9181601f840112156102405782359167ffffffffffffffff8311610240576020808501948460051b01011161024057565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b90611ec391612536565b8015611f4b5760206001600160a01b0360115416916024604051809481937ff1dc104d00000000000000000000000000000000000000000000000000000000835260048301525afa908115610771575f91611f1c575090565b90506020813d602011611f43575b81611f3760209383611c8e565b81010312610240575190565b3d9150611f2a565b7f631d667b000000000000000000000000000000000000000000000000000000005f5260045ffd5b15611f7b5750565b7f7566cabb000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b91908110156104135760051b0190565b356001600160a01b03811681036102405790565b3d15611ff4573d90611fdb82611ccf565b91611fe96040519384611c8e565b82523d5f602084013e565b606090565b478015612079575f80808084865af1612010611fca565b5015612051577f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5916040916001600160a01b038351921682526020820152a1565b7f27fcd9d1000000000000000000000000000000000000000000000000000000005f5260045ffd5b5050565b602081519101205f52601860205260405f20549081156120ae57815f52601760205260ff600460405f200154169190565b5f91508190565b9190820180921161044057565b9190820391821161044057565b8181029291811591840414171561044057565b81156120ec570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146104405760010190565b91908110156104135760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561024057019081359167ffffffffffffffff8311610240576020018236038113610240579190565b60058110156104135760051b60040190565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b906122186001600160a01b0391604094979695976060855260608501916121b8565b951660208201520152565b9061224190825160208401205f52601860205260405f205492612536565b9080158015612445575b6123ba57906024915f5260176020526122be60405f2060405161226d81611c72565b81548152600182015491602082019283526002810154906040830191808352600382015460ff60046060870194838652015416151560808601528042105f1461236857505050509050515b826120b5565b60206001600160a01b0360115416604051948580927ff1dc104d0000000000000000000000000000000000000000000000000000000082528560048301525afa928315610771575f93612334575b5080156113fc5761232061232592846120cf565b6120e2565b9161233083836120c2565b9190565b9092506020813d602011612360575b8161235060209383611c8e565b810103126102405751915f61230c565b3d9150612343565b90612372916120b5565b421061238157505050516122b8565b906123ad6123b5946123a561239a61158e9551426120c2565b9186519051906120c2565b9451946120cf565b9051906120e2565b6122b8565b5060206001600160a01b0360115416916024604051809481937ff1dc104d00000000000000000000000000000000000000000000000000000000835260048301525afa908115610771575f91612413575b5080915f9190565b90506020813d60201161243d575b8161242e60209383611c8e565b8101031261024057515f61240b565b3d9150612421565b50805f52601760205260ff600460405f200154161561224b565b5160058110156124ec57612476815b821515611f73565b600681101561041357600b01548015611f4b576301e1338091612498916120cf565b0460206001600160a01b0360115416916024604051809481937ff1dc104d00000000000000000000000000000000000000000000000000000000835260048301525afa908115610771575f91611f1c575090565b61247660059161246e565b6001600160a01b035f5416330361250a57565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b5160058110156125c35761254c81821515611f73565b600681101561041357806005015490600b0154916301e133808111156125af577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1ecc808101908111610440576125a86301e1338091611d5a946120cf565b04906120b5565b6301e1338092506125bf916120cf565b0490565b61254c60059161246e565b9190826040910312610240576020825192015190565b6001600160a01b0361221860409396959496606084526060840190611e76565b909391936301e1338085106128865761261d8583612223565b916126278561207d565b97901561285e5780841161282f57508451602086012097885f5260136020526001600160a01b0360405f205416988915158061281c575b6127ec576126ba9798995061267285612ac8565b506040826001600160a01b0360035416885f8b85519d8e95869485937fd393c871000000000000000000000000000000000000000000000000000000008552600485016125e4565b03925af1998a15610771575f985f9b612780575b5091817f42f107a565c6dff87215764583e59cb32baaf0512e8998f4d934079d0e7d7ac19896949261275e9896947f9f049aa460e86f8a4030f7a4ac75a6acfc43c596f576b8c8cd4e7fcf14b0f0a46040516020815280612732602082018d611e76565b0390a35f5260186020525f60408120556001600160a01b0360405197889760c0895260c0890190611e76565b9516602087015260408601526060850152608084015260a08301520390a19190565b61275e979593919b50829950916127d27f42f107a565c6dff87215764583e59cb32baaf0512e8998f4d934079d0e7d7ac19997959360403d6040116127e5575b6127ca8183611c8e565b8101906125ce565b9a909a9c929496985092949698506126ce565b503d6127c0565b89907f4b37167f000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b506001600160a01b0386168a141561265e565b837fb99e2ab7000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b7f51ced31e000000000000000000000000000000000000000000000000000000005f5260045ffd5b847f810ce066000000000000000000000000000000000000000000000000000000005f526004526301e1338060245260445ffd5b929091926301e133808410612a5d576128d281612bd5565b80516020820120805f5260136020526001600160a01b0360405f2054169081151580612a4a575b612a1c5750506129098482611eb9565b9261291384612ac8565b506001600160a01b0360035416936040805180967fd393c871000000000000000000000000000000000000000000000000000000008252815f8161295c8c898b600485016125e4565b03925af18015610771575f955f916129cc575b50917f87fd548bf5794610496e606965e724cec5c33f621c084067a46c43a81a1887e793916129b69396976001600160a01b03604051958695608087526080870190611e76565b93166020850152604084015260608301520390a1565b7f87fd548bf5794610496e606965e724cec5c33f621c084067a46c43a81a1887e7949296506129b6939150612a0f9060403d6040116127e5576127ca8183611c8e565b969096919350919361296f565b7f4b37167f000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b506001600160a01b0385168214156128f9565b837f810ce066000000000000000000000000000000000000000000000000000000005f526004526301e1338060245260445ffd5b15612a9a575050565b7fb99e2ab7000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b612ad6348280341015612a91565b80151580612b80575b612b38575b803411612aee5790565b5f808080612afc85346120c2565b335af1612b07611fca565b5015612b105790565b7f4a66f903000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f808080846001600160a01b03601254165af1612b53611fca565b50612ae4577f4a66f903000000000000000000000000000000000000000000000000000000005f5260045ffd5b506001600160a01b03601254161515612adf565b604290612b9f612eda565b90604051917f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201522090565b805160208201205f52601860205260405f20548015612079575f52601760205260405f20604051612c0581611c72565b8154815260018201546020820152608060028301549182604082015260ff600460038601549586606085015201541615159182910152612c4457505050565b612c4d916120b5565b4210612c565750565b6105ef906040519182917fba3cb877000000000000000000000000000000000000000000000000000000008352602060048401526024830190611e76565b60ff8114612cf35760ff811690601f8211612ccb5760405191612cb8604084611c8e565b6020808452838101919036833783525290565b7fb3512b0c000000000000000000000000000000000000000000000000000000005f5260045ffd5b506040515f6001548060011c9160018216918215612e00575b602084108314612dd3578385528492908115612d965750600114612d37575b611d5a92500382611c8e565b5060015f90815290917fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b818310612d7a575050906020611d5a92820101612d2b565b6020919350806001915483858801015201910190918392612d62565b60209250611d5a9491507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001682840152151560051b820101612d2b565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b92607f1692612d0c565b60ff8114612e2e5760ff811690601f8211612ccb5760405191612cb8604084611c8e565b506040515f6002548060011c9160018216918215612ed0575b602084108314612dd3578385528492908115612d965750600114612e7157611d5a92500382611c8e565b5060025f90815290917f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace5b818310612eb4575050906020611d5a92820101612d2b565b6020919350806001915483858801015201910190918392612e9c565b92607f1692612e47565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016301480612fcd575b15612f35577f000000000000000000000000000000000000000000000000000000000000000090565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f000000000000000000000000000000000000000000000000000000000000000060408201527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260a08152612fc760c082611c8e565b51902090565b507f00000000000000000000000000000000000000000000000000000000000000004614612f0c565b81519190604183036130265761301f9250602082015190606060408401519301515f1a90613108565b9192909190565b50505f9160029190565b60048110156130db5780613042575050565b60018103613072577ff645eedf000000000000000000000000000000000000000000000000000000005f5260045ffd5b600281036130a657507ffce698f7000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b6003146130b05750565b7fd78bce0c000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161317f579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa15610771575f516001600160a01b0381161561317557905f905f90565b505f906001905f90565b5050505f916003919056fea26469706673582212201c2fba4781a934ebd67b609855ff85499e47445a76bc4e5442412d4c0fc4ab7964736f6c634300081b0033000000000000000000000000505b7a6345adf0c89749fc5d631941fdfc73460f00000000000000000000000096ed7f93c6c7e0d77abc3508636e93e1238ee98600000000000000000000000036877d3399acc80a32cd8df60ec3f8db12fe620f00000000000000000000000096ed7f93c6c7e0d77abc3508636e93e1238ee986

Deployed Bytecode

0x608080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c908163114ccb9814611c2357508063238ac93314611bfd5780632630c12f14611bd75780632983c4b814611b575780632b1eaf2914611b315780632eb4a7ab14611b14578063389c074814611ae15780633b10faf514611ac85780633c4cb59014611a505780634b4e9f2a1461197b5780634e86501c146118e657806351cff8d9146118bd578063530e784f1461180e578063547b34b5146117965780636a1f45af146117435780636b1f2520146117175780636c19e78314611697578063715018a6146116285780637602206a146115df5780637765c52c1461144a5780637b103999146114245780637bd666c31461120b5780637cb64759146111bf5780637de68b931461112c5780637ecebe0014610d485780638022376414610ed65780638462a7f814610eb957806384b0196e14610da55780638da5cb5b14610d8057806390193b7c14610d4857806391101b7814610c64578063991fa9de14610aab578063a692bf7d14610941578063a91ee0dc146108ea578063ad2e56b81461088f578063b4054eae14610854578063bbe6847014610828578063c4557747146107fe578063c475abff14610630578063c8078d63146105f3578063cb5a7c541461046d578063dd2cdaf214610380578063f28da5561461035f578063f2fde38b146102ab578063f8c373e4146102445763ff3e982914610222575f61000f565b34610240575f6003193601126102405760206040516301e133808152f35b5f80fd5b346102405760206003193601126102405760043567ffffffffffffffff81116102405761027861027f913690600401611da5565b3691611d09565b602081519101205f52601360205260406001600160a01b03815f20541681519080151582526020820152f35b34610240576020600319360112610240576001600160a01b036102cc611c5c565b6102d46124f7565b168015610333576001600160a01b035f54827fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f55167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b3461024057602061037861037236611d5d565b9061245f565b604051908152f35b346102405760a0600319360112610240573660a411610240576103a16124f7565b5f5b600581106103ad57005b6103b6816121a6565b3590600181018082116104405760068110156104135760407f9ccab05fb2d456a6b8f1e4b0131e9bfabc426ca148464c5b027ecfef165f391891600194600c850155610401846121a6565b3582519182526020820152a1016103a3565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b60406003193601126102405760043567ffffffffffffffff811161024057610499903690600401611da5565b906024356104a8368484611d09565b6020815191012092835f5260136020526001600160a01b0360405f20541680156105b3573303610583577f8034d8fda3d279e347445354cfc5c28522ccec743d5bf18f0d015952e142f5539060409461057461050f853361050a36878b611d09565b6128ba565b959096835f526013602052885f207fffffffffffffffffffffffff0000000000000000000000000000000000000000815416905588519485947f27708016161f21df5a88a54264eed7ce7344b062c77faa396229f8ceb59834215f80a23391856121f6565b0390a182519182526020820152f35b837fa4e1a97e000000000000000000000000000000000000000000000000000000005f523360045260245260445ffd5b6040517fe0b762d000000000000000000000000000000000000000000000000000000000815260206004820152806105ef6024820185886121b8565b0390fd5b34610240576020600319360112610240576001600160a01b03610614611c5c565b165f526015602052602060ff60405f2054166040519015158152f35b602461063b36611d8f565b5f6001600160a01b0360039493945416604051938480927fda2bfdb10000000000000000000000000000000000000000000000000000000082528760048301525afa918215610771575f9261077c575b50610697815f9361245f565b6106a081612ac8565b5060206001600160a01b03600354166044604051809681937fc475abff0000000000000000000000000000000000000000000000000000000083528960048401528760248401525af1928315610771575f9361073a575b5060408051948552602080860193909352840152917fae68301bb68924e9d4c9082934bc3a65a03b5778aee54c29e3ed972166ec9ae190606090a1604051908152f35b919092506020823d602011610769575b8161075760209383611c8e565b810103126102405790519160206106f7565b3d915061074a565b6040513d5f823e3d90fd5b91503d805f843e61078d8184611c8e565b8201916020818403126102405780519067ffffffffffffffff8211610240570182601f82011215610240578051906107c482611ccf565b936107d26040519586611c8e565b82855260208383010111610240575f938460208461069795828896018386015e8301015293505061068b565b34610240576020600319360112610240576004355f526018602052602060405f2054604051908152f35b346102405760206003193601126102405760043560068110156102405760209060050154604051908152f35b346102405761088b61086e61086836611d5d565b90612223565b604080519384526020840192909252908201529081906060820190565b0390f35b34610240576020600319360112610240576004355f52601760205260a060405f20805490600181015490600281015460ff60046003840154930154169260405194855260208501526040840152606083015215156080820152f35b34610240576020600319360112610240576001600160a01b0361090b611c5c565b6109136124f7565b167fffffffffffffffffffffffff000000000000000000000000000000000000000060035416176003555f80f35b61094a36611dd3565b9092829796979594954211610a8357610a2a93610a13610a1b92610a2195610976348380341115612a91565b8b6001600160a01b038a1691825f5260166020526109a88d60405f209384549461099f86612119565b90553691611d09565b60208151910120936040519360208501957f562736d27893c5a2e53960cc41ec255b8eb9f05780a7d188194fac9ee284530f8752604086015260608501528c608085015260a084015260c083015260e082015260e08152610a0b61010082611c8e565b519020612b94565b923691611d09565b90612ff6565b90929192613030565b6001600160a01b038060045416911603610a5b5761050a610a4f936040953691611d09565b82519182526020820152f35b7f815e1d64000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f0819bdcd000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102405760406003193601126102405760043567ffffffffffffffff811161024057610adc903690600401611e45565b60243567ffffffffffffffff811161024057610afc903690600401611e45565b91610b056124f7565b828103610c06575f5b818110610b1757005b80610b286102786001938589612146565b60208151910120610b42610b3d838888611fa6565b611fb6565b815f5260136020526001600160a01b0360405f2091167fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790556001600160a01b03610b95610b3d848989611fa6565b16610bc5577f27708016161f21df5a88a54264eed7ce7344b062c77faa396229f8ceb59834215f80a25b01610b0e565b6001600160a01b03610bdb610b3d848989611fa6565b16907fccfd1e8567bc1749489631ff7b34c5d322a22795659e114ae37dc021099de4e05f80a3610bbf565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4172726179206c656e67746873206d69736d61746368000000000000000000006044820152fd5b346102405760406003193601126102405760043567ffffffffffffffff811161024057610c95903690600401611da5565b602435916001600160a01b03831680930361024057610cb6916102786124f7565b6020815191012090815f52601360205260405f20817fffffffffffffffffffffffff000000000000000000000000000000000000000082541617905580155f14610d2157507f27708016161f21df5a88a54264eed7ce7344b062c77faa396229f8ceb59834215f80a2005b907fccfd1e8567bc1749489631ff7b34c5d322a22795659e114ae37dc021099de4e05f80a3005b34610240576020600319360112610240576001600160a01b03610d69611c5c565b165f526016602052602060405f2054604051908152f35b34610240575f6003193601126102405760206001600160a01b035f5416604051908152f35b34610240575f60031936011261024057610e5d610de17f446f7448797065436f6e74726f6c6c6572000000000000000000000000000011612c94565b610e0a7f3100000000000000000000000000000000000000000000000000000000000001612e0a565b6020610e6b60405192610e1d8385611c8e565b5f84525f3681376040519586957f0f00000000000000000000000000000000000000000000000000000000000000875260e08588015260e0870190611e76565b908582036040870152611e76565b4660608501523060808501525f60a085015283810360c08501528180845192838152019301915f5b828110610ea257505050500390f35b835185528695509381019392810192600101610e93565b34610240575f600319360112610240576020601954604051908152f35b60606003193601126102405760043567ffffffffffffffff811161024057610f02903690600401611da5565b906024359060443567ffffffffffffffff811161024057610f27903690600401611e45565b93909260145493841561110457335f52601560205260ff60405f2054166110d85760405160208101903360601b825260148152610f65603482611c8e565b5190209067ffffffffffffffff87116110ab578660051b6020810197610f8e604051998a611c8e565b8852602088019082019136831161024057905b82821061109b57505050925f935b8651851015610ff15760208560051b88010151908181105f14610fe0575f52602052600160405f205b940193610faf565b905f52602052600160405f20610fd8565b8503611073577f8773e1d4834c49732c2070bd8402075b70195f6d5eae9807704fb956cebd338461057491604094335f526015602052855f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055611063853361050a368587611d09565b94909587519384933391856121f6565b7fb05e92fa000000000000000000000000000000000000000000000000000000005f5260045ffd5b8135815260209182019101610fa1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f893cc576000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b7f9f8a28f2000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102405760a0600319360112610240573660a4116102405761114d6124f7565b5f5b6005811061115957005b611162816121a6565b3590600181018082116104405760068110156104135760407f7b902ac6425cebe69042a3b5057c557f8ad66c3d5aa0fcf2bb4903140ee158169160019460068501556111ad846121a6565b3582519182526020820152a10161114f565b34610240576020600319360112610240577f90004c04698bc3322499a575ed3752dd4abf33e0a7294c06a787a0fe01bea94160206004356111fe6124f7565b80601455604051908152a1005b346102405760a06003193601126102405760043567ffffffffffffffff81116102405761123c903690600401611e45565b90602435906064356044356084356112526124f7565b80828611156113fc5783156113fc57806113f157505042925b6019549561127887612119565b60195560405161128781611c72565b868152600460208201918583526040810187815260608201908982526080830194600186528c5f52601760205260405f2093518455516001840155516002830155516003820155019051151560ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691161790555f5b81811061134f57602088807f313a78a5f20cc946067de183e96e29f791e32f9407e559d0cc2832fe4c78cde360808b8b8b8b6040519384528884015260408301526060820152a2604051908152f35b61135d610278828486612146565b9081516020830120805f52601860205260405f20546113c957897f6e03d38755c7f97e70ff44ab359d646241746ab5ab53faf3130e1c115a1a4e256113c0600195845f5260186020528360405f2055604051918291602083526020830190611e76565b0390a301611300565b7f441c0b4b000000000000000000000000000000000000000000000000000000005f5260045ffd5b93909342111561126b575b7f453b7de0000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610240575f6003193601126102405760206001600160a01b0360035416604051908152f35b34610240576020600319360112610240576004355f608060405161146d81611c72565b8281528260208201528260408201528260608201520152801580156115d3575b6115ab575f52601760205261014060405f20604051906114ac82611c72565b8054825260018101546020830190815260028201546040840181815260038401549260ff600460608801968688520154166114f46080880191151594858352864210966120b5565b958642101596875f1461159a57505f935b861561154e578851935b60405199518a525160208a0152516040890152516060880152511515608087015260a086015260c085015260e084015215610100830152610120820152f35b871561155c5783519361150f565b61159461156a8351426120c2565b61158e61158661157d8d518951906120c2565b928d51936120cf565b8451906120e2565b906120c2565b9361150f565b6115a59042906120c2565b93611505565b7f3b98df65000000000000000000000000000000000000000000000000000000005f5260045ffd5b5060195481101561148d565b346102405760206003193601126102405760043567ffffffffffffffff81116102405761161a6116156040923690600401611d3f565b61207d565b825191151582526020820152f35b34610240575f600319360112610240576116406124f7565b5f6001600160a01b0381547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b34610240576020600319360112610240577f5553331329228fbd4123164423717a4a7539f6dfa1c3279a923b98fd681a6c7360206001600160a01b036116db611c5c565b6116e36124f7565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000006004541617600455604051908152a1005b3461024057602060031936011261024057600435600681101561024057602090600b0154604051908152f35b60606003193601126102405760043567ffffffffffffffff811161024057610a4f6117746040923690600401611da5565b9061177d6124f7565b604435916117916024359233923691611d09565b612604565b34610240576117a436611d8f565b6117ac6124f7565b60018210158281611802575b6117c191611f73565b60068210156104135781816040927f9ccab05fb2d456a6b8f1e4b0131e9bfabc426ca148464c5b027ecfef165f391894600b015582519182526020820152a1005b600581111591506117b8565b34610240576020600319360112610240576001600160a01b0361182f611c5c565b6118376124f7565b168015611895576020817fefe8ab924ca486283a79dc604baa67add51afb82af1db8ac386ebbba643cdffd927fffffffffffffffffffffffff00000000000000000000000000000000000000006011541617601155604051908152a1005b7ff8794e04000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102405760206003193601126102405761001a6118d9611c5c565b6118e16124f7565b611ff9565b346102405760206003193601126102405760043567ffffffffffffffff811161024057611917903690600401611e45565b61191f6124f7565b5f5b81811061192a57005b806001600160a01b03611943610b3d6001948688611fa6565b165f52601560205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00815416905501611921565b61198436611dd3565b829796979593954211610a8357610a1b610a2192610a13611a2b956001600160a01b038816805f5260166020528c6119c78d60405f209283549361099f85612119565b60208151910120926040519260208401947f4163a4e6c32c6c6b2bf592a1f25f7b89d1b183f424b2cbb5f6e67976617618148652604085015260608401528b60808401528c60a084015260c083015260e082015260e08152610a0b61010082611c8e565b6001600160a01b038060045416911603610a5b57611791610a4f946040963691611d09565b3461024057611a5e36611d8f565b611a666124f7565b60018210158281611abc575b611a7b91611f73565b60068210156104135781816040927f7b902ac6425cebe69042a3b5057c557f8ad66c3d5aa0fcf2bb4903140ee15816946005015582519182526020820152a1005b60058111159150611a72565b34610240576020610378611adb36611d5d565b90611eb9565b34610240576020600319360112610240576004355f52601360205260206001600160a01b0360405f205416604051908152f35b34610240575f600319360112610240576020601454604051908152f35b34610240575f6003193601126102405760206001600160a01b0360125416604051908152f35b34610240576020600319360112610240577f694f4a35894884360636162607be63896d92aff456c086ea693e15e2f209100560206001600160a01b03611b9b611c5c565b611ba36124f7565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000006012541617601255604051908152a1005b34610240575f6003193601126102405760206001600160a01b0360115416604051908152f35b34610240575f6003193601126102405760206001600160a01b0360045416604051908152f35b34610240576020600319360112610240576020906001600160a01b03611c47611c5c565b165f526015825260ff60405f20541615158152f35b600435906001600160a01b038216820361024057565b60a0810190811067ffffffffffffffff8211176110ab57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176110ab57604052565b67ffffffffffffffff81116110ab57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b929192611d1582611ccf565b91611d236040519384611c8e565b829481845281830111610240578281602093845f960137010152565b9080601f8301121561024057816020611d5a93359101611d09565b90565b6040600319820112610240576004359067ffffffffffffffff821161024057611d8891600401611d3f565b9060243590565b6003196040910112610240576004359060243590565b9181601f840112156102405782359167ffffffffffffffff8311610240576020838186019501011161024057565b60c06003198201126102405760043567ffffffffffffffff81116102405781611dfe91600401611da5565b929092916024356001600160a01b0381168103610240579160443591606435916084359160a4359067ffffffffffffffff821161024057611e4191600401611da5565b9091565b9181601f840112156102405782359167ffffffffffffffff8311610240576020808501948460051b01011161024057565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b90611ec391612536565b8015611f4b5760206001600160a01b0360115416916024604051809481937ff1dc104d00000000000000000000000000000000000000000000000000000000835260048301525afa908115610771575f91611f1c575090565b90506020813d602011611f43575b81611f3760209383611c8e565b81010312610240575190565b3d9150611f2a565b7f631d667b000000000000000000000000000000000000000000000000000000005f5260045ffd5b15611f7b5750565b7f7566cabb000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b91908110156104135760051b0190565b356001600160a01b03811681036102405790565b3d15611ff4573d90611fdb82611ccf565b91611fe96040519384611c8e565b82523d5f602084013e565b606090565b478015612079575f80808084865af1612010611fca565b5015612051577f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5916040916001600160a01b038351921682526020820152a1565b7f27fcd9d1000000000000000000000000000000000000000000000000000000005f5260045ffd5b5050565b602081519101205f52601860205260405f20549081156120ae57815f52601760205260ff600460405f200154169190565b5f91508190565b9190820180921161044057565b9190820391821161044057565b8181029291811591840414171561044057565b81156120ec570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146104405760010190565b91908110156104135760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561024057019081359167ffffffffffffffff8311610240576020018236038113610240579190565b60058110156104135760051b60040190565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b906122186001600160a01b0391604094979695976060855260608501916121b8565b951660208201520152565b9061224190825160208401205f52601860205260405f205492612536565b9080158015612445575b6123ba57906024915f5260176020526122be60405f2060405161226d81611c72565b81548152600182015491602082019283526002810154906040830191808352600382015460ff60046060870194838652015416151560808601528042105f1461236857505050509050515b826120b5565b60206001600160a01b0360115416604051948580927ff1dc104d0000000000000000000000000000000000000000000000000000000082528560048301525afa928315610771575f93612334575b5080156113fc5761232061232592846120cf565b6120e2565b9161233083836120c2565b9190565b9092506020813d602011612360575b8161235060209383611c8e565b810103126102405751915f61230c565b3d9150612343565b90612372916120b5565b421061238157505050516122b8565b906123ad6123b5946123a561239a61158e9551426120c2565b9186519051906120c2565b9451946120cf565b9051906120e2565b6122b8565b5060206001600160a01b0360115416916024604051809481937ff1dc104d00000000000000000000000000000000000000000000000000000000835260048301525afa908115610771575f91612413575b5080915f9190565b90506020813d60201161243d575b8161242e60209383611c8e565b8101031261024057515f61240b565b3d9150612421565b50805f52601760205260ff600460405f200154161561224b565b5160058110156124ec57612476815b821515611f73565b600681101561041357600b01548015611f4b576301e1338091612498916120cf565b0460206001600160a01b0360115416916024604051809481937ff1dc104d00000000000000000000000000000000000000000000000000000000835260048301525afa908115610771575f91611f1c575090565b61247660059161246e565b6001600160a01b035f5416330361250a57565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b5160058110156125c35761254c81821515611f73565b600681101561041357806005015490600b0154916301e133808111156125af577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1ecc808101908111610440576125a86301e1338091611d5a946120cf565b04906120b5565b6301e1338092506125bf916120cf565b0490565b61254c60059161246e565b9190826040910312610240576020825192015190565b6001600160a01b0361221860409396959496606084526060840190611e76565b909391936301e1338085106128865761261d8583612223565b916126278561207d565b97901561285e5780841161282f57508451602086012097885f5260136020526001600160a01b0360405f205416988915158061281c575b6127ec576126ba9798995061267285612ac8565b506040826001600160a01b0360035416885f8b85519d8e95869485937fd393c871000000000000000000000000000000000000000000000000000000008552600485016125e4565b03925af1998a15610771575f985f9b612780575b5091817f42f107a565c6dff87215764583e59cb32baaf0512e8998f4d934079d0e7d7ac19896949261275e9896947f9f049aa460e86f8a4030f7a4ac75a6acfc43c596f576b8c8cd4e7fcf14b0f0a46040516020815280612732602082018d611e76565b0390a35f5260186020525f60408120556001600160a01b0360405197889760c0895260c0890190611e76565b9516602087015260408601526060850152608084015260a08301520390a19190565b61275e979593919b50829950916127d27f42f107a565c6dff87215764583e59cb32baaf0512e8998f4d934079d0e7d7ac19997959360403d6040116127e5575b6127ca8183611c8e565b8101906125ce565b9a909a9c929496985092949698506126ce565b503d6127c0565b89907f4b37167f000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b506001600160a01b0386168a141561265e565b837fb99e2ab7000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b7f51ced31e000000000000000000000000000000000000000000000000000000005f5260045ffd5b847f810ce066000000000000000000000000000000000000000000000000000000005f526004526301e1338060245260445ffd5b929091926301e133808410612a5d576128d281612bd5565b80516020820120805f5260136020526001600160a01b0360405f2054169081151580612a4a575b612a1c5750506129098482611eb9565b9261291384612ac8565b506001600160a01b0360035416936040805180967fd393c871000000000000000000000000000000000000000000000000000000008252815f8161295c8c898b600485016125e4565b03925af18015610771575f955f916129cc575b50917f87fd548bf5794610496e606965e724cec5c33f621c084067a46c43a81a1887e793916129b69396976001600160a01b03604051958695608087526080870190611e76565b93166020850152604084015260608301520390a1565b7f87fd548bf5794610496e606965e724cec5c33f621c084067a46c43a81a1887e7949296506129b6939150612a0f9060403d6040116127e5576127ca8183611c8e565b969096919350919361296f565b7f4b37167f000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b506001600160a01b0385168214156128f9565b837f810ce066000000000000000000000000000000000000000000000000000000005f526004526301e1338060245260445ffd5b15612a9a575050565b7fb99e2ab7000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b612ad6348280341015612a91565b80151580612b80575b612b38575b803411612aee5790565b5f808080612afc85346120c2565b335af1612b07611fca565b5015612b105790565b7f4a66f903000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f808080846001600160a01b03601254165af1612b53611fca565b50612ae4577f4a66f903000000000000000000000000000000000000000000000000000000005f5260045ffd5b506001600160a01b03601254161515612adf565b604290612b9f612eda565b90604051917f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201522090565b805160208201205f52601860205260405f20548015612079575f52601760205260405f20604051612c0581611c72565b8154815260018201546020820152608060028301549182604082015260ff600460038601549586606085015201541615159182910152612c4457505050565b612c4d916120b5565b4210612c565750565b6105ef906040519182917fba3cb877000000000000000000000000000000000000000000000000000000008352602060048401526024830190611e76565b60ff8114612cf35760ff811690601f8211612ccb5760405191612cb8604084611c8e565b6020808452838101919036833783525290565b7fb3512b0c000000000000000000000000000000000000000000000000000000005f5260045ffd5b506040515f6001548060011c9160018216918215612e00575b602084108314612dd3578385528492908115612d965750600114612d37575b611d5a92500382611c8e565b5060015f90815290917fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b818310612d7a575050906020611d5a92820101612d2b565b6020919350806001915483858801015201910190918392612d62565b60209250611d5a9491507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001682840152151560051b820101612d2b565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b92607f1692612d0c565b60ff8114612e2e5760ff811690601f8211612ccb5760405191612cb8604084611c8e565b506040515f6002548060011c9160018216918215612ed0575b602084108314612dd3578385528492908115612d965750600114612e7157611d5a92500382611c8e565b5060025f90815290917f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace5b818310612eb4575050906020611d5a92820101612d2b565b6020919350806001915483858801015201910190918392612e9c565b92607f1692612e47565b6001600160a01b037f000000000000000000000000cd0a58e078c57b69a3da6703213aa69085e2ac6516301480612fcd575b15612f35577f98a70e85b979e4c446778f6816fbdecf9305676d440d792c208ecd56097c276a90565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f28794d9fa637e5ba67d10647baf7c948ee6b08a3958218e20d63d01c6cce9c3960408201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260a08152612fc760c082611c8e565b51902090565b507f00000000000000000000000000000000000000000000000000000000000003e74614612f0c565b81519190604183036130265761301f9250602082015190606060408401519301515f1a90613108565b9192909190565b50505f9160029190565b60048110156130db5780613042575050565b60018103613072577ff645eedf000000000000000000000000000000000000000000000000000000005f5260045ffd5b600281036130a657507ffce698f7000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b6003146130b05750565b7fd78bce0c000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161317f579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa15610771575f516001600160a01b0381161561317557905f905f90565b505f906001905f90565b5050505f916003919056fea26469706673582212201c2fba4781a934ebd67b609855ff85499e47445a76bc4e5442412d4c0fc4ab7964736f6c634300081b0033

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

000000000000000000000000505b7a6345adf0c89749fc5d631941fdfc73460f00000000000000000000000096ed7f93c6c7e0d77abc3508636e93e1238ee98600000000000000000000000036877d3399acc80a32cd8df60ec3f8db12fe620f00000000000000000000000096ed7f93c6c7e0d77abc3508636e93e1238ee986

-----Decoded View---------------
Arg [0] : _registry (address): 0x505b7A6345adF0C89749fC5d631941FdfC73460F
Arg [1] : _signer (address): 0x96ED7F93C6C7E0d77Abc3508636e93E1238ee986
Arg [2] : _priceOracle (address): 0x36877d3399aCc80a32CD8df60eC3F8Db12FE620f
Arg [3] : _owner (address): 0x96ED7F93C6C7E0d77Abc3508636e93E1238ee986

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000505b7a6345adf0c89749fc5d631941fdfc73460f
Arg [1] : 00000000000000000000000096ed7f93c6c7e0d77abc3508636e93e1238ee986
Arg [2] : 00000000000000000000000036877d3399acc80a32cd8df60ec3f8db12fe620f
Arg [3] : 00000000000000000000000096ed7f93c6c7e0d77abc3508636e93e1238ee986


Block Transaction Gas Used Reward
view all blocks ##produced##

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

Validator Index Block Amount
View All Withdrawals

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

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