Skip to content
Verified contractPartialMIT

ArchetypeLogicErc721a

Address0x2f40c8c1b5437a297779838677f23675beb66a6f
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.36

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.36+commit.8a079791
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,382,957
Creation transaction
0xfce9cbe530…ed7f5acb34
Libraries
src/ERC721a/ArchetypeLogicErc721a.sol:ArchetypeLogicErc721a0x2f40…b66a6f

src/ERC721a/ArchetypeLogicErc721a.sol

// SPDX-License-Identifier: MIT
// ArchetypeLogic v10.0
//
//        d8888                 888               888
//       d88888                 888               888
//      d88P888                 888               888
//     d88P 888 888d888 .d8888b 88888b.   .d88b.  888888 888  888 88888b.   .d88b.
//    d88P  888 888P"  d88P"    888 "88b d8P  Y8b 888    888  888 888 "88b d8P  Y8b
//   d88P   888 888    888      888  888 88888888 888    888  888 888  888 88888888
//  d8888888888 888    Y88b.    888  888 Y8b.     Y88b.  Y88b 888 888 d88P Y8b.
// d88P     888 888     "Y8888P 888  888  "Y8888   "Y888  "Y88888 88888P"   "Y8888
//                                                            888 888
//                                                       Y8b d88P 888
//                                                        "Y88P"  888

pragma solidity ^0.8.20;
import {IMintPricing} from "./IMintPricing.sol";

import "../ArchetypePayouts.sol";
import "../IArchetypeBatch.sol";
import "openzeppelin-v4/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../AffiliateAuthorization.sol";
import {AffiliateSignerRegistry} from "../AffiliateSignerRegistry.sol";
import {MintConstraints} from "../MintConstraints.sol";
import "solady/src/utils/MerkleProofLib.sol";

error InvalidConfig();
error MintNotYetStarted();
error MintEnded();
error WalletUnauthorizedToMint();
error InsufficientEthSent();
error ExcessiveEthSent();
error Erc20BalanceTooLow();
error MaxSupplyExceeded();
error ListMaxSupplyExceeded();
error NumberOfMintsExceeded();
error MintingPaused();
error InvalidReferral();
error MaxBatchSizeExceeded();
error BurnToMintDisabled();
error NotTokenOwner();
error NotPlatform();
error NotOwner();
error NotApprovedToTransfer();
error InvalidAmountOfTokens();
error WrongPassword();
error LockedForever();
error Blacklisted();
error MintCostOverflow();
error ExcessiveCurrencyCost();

struct Auth {
    bytes32 key;
    bytes32[] proof;
}

struct BonusDiscount {
    uint16 numMints;
    uint16 numBonusMints;
}

struct Config {
    string baseUri;
    uint32 maxSupply;
    uint32 maxBatchSize;
    uint16 affiliateFee; //BPS
    uint16 affiliateDiscount; //BPS
    uint16 defaultRoyalty; //BPS
}

// allocation splits for mint proceeds, must sum to 100%
struct PayoutConfig {
    uint16 ownerBps;
    uint16 platformBps;
    uint16 partnerBps;
    uint16 superAffiliateBps;
    address partner;
    address superAffiliate;
    address ownerAltPayout;
}

struct Options {
    bool uriLocked;
    bool maxSupplyLocked;
    bool affiliateFeeLocked;
    bool ownerAltPayoutLocked;
}

struct Invite {
    uint128 price;
    uint32 start;
    uint32 end;
    uint32 limit;
    uint32 maxSupply;
    uint32 unitSize; // mint 1 get x
    address tokenAddress;
    bool isBlacklist;
}

struct BurnInvite {
    IERC721 burnErc721;
    address burnAddress;
    address tokenAddress;
    uint128 price; // flat price - does not support discounts
    bool reversed; // side of the ratio (false=burn {ratio} get 1, true=burn 1 get {ratio})
    uint16 ratio;
    uint32 start;
    uint32 end;
    uint64 limit;
}

struct ValidationArgs {
    address owner;
    address sender;
    address affiliate;
    uint256 quantity;
    uint256 curSupply;
    uint256 listSupply;
}

struct ArchetypeAddresses {
    address platform;
    address payouts;
    address batch;
}

struct MintPayment {
    uint128 currencyCost;
    uint256 nativeValue;
    uint256 platformSurcharge;
}

struct Erc721BatchMint {
    address[] recipients;
    uint256[] quantities;
    address affiliate;
    bytes affiliateAuthorization;
    MintConstraints constraints;
}

uint16 constant MAXBPS = 5000; // max fee or discount is 50%
uint32 constant UINT32_MAX = 2 ** 32 - 1;

struct MintPricing {
    address calculator;
    uint256 sold;
}

library ArchetypeLogicErc721a {
    using SafeERC20 for IERC20;

    function setMintPricing(Invite storage invite, MintPricing storage pricing, bytes32 key, address calculator)
        public
    {
        if (
            calculator != address(0)
                && (calculator == address(this) || calculator.code.length == 0 || !isPublicInvite(invite, key))
        ) revert InvalidConfig();
        pricing.calculator = calculator;
    }

    event Invited(bytes32 indexed key, bytes32 indexed cid);
    event BurnInvited(bytes32 indexed key, bytes32 indexed cid);
    event Referral(address indexed affiliate, address token, uint128 wad, uint256 numMints, uint256 paymentValue);

    // calculate price based on affiliate usage and mint discounts
    function computePrice(
        Invite storage invite,
        MintPricing storage pricing,
        bytes32 key,
        uint16 affiliateDiscount,
        uint256 numTokens,
        bool affiliateUsed
    ) public view returns (uint128) {
        uint256 cost;
        if (pricing.calculator == address(0)) {
            cost = uint256(invite.price) * numTokens;
        } else {
            if (!isPublicInvite(invite, key)) revert InvalidConfig();
            cost = IMintPricing(pricing.calculator).getQuote(key, pricing.sold, numTokens);
            if (cost > type(uint128).max) revert MintCostOverflow();
        }

        if (affiliateUsed) {
            cost = cost - ((cost * affiliateDiscount) / 10000);
        }

        if (cost > type(uint128).max) revert MintCostOverflow();
        return uint128(cost);
    }

    function computeMintPayment(
        Invite storage invite,
        Config storage config,
        PayoutConfig storage payoutConfig,
        MintPricing storage pricing,
        bytes32 key,
        uint256 paidQuantity,
        bool affiliateUsed,
        uint256 nativeMinimumFee
    ) public view returns (MintPayment memory payment) {
        payment.currencyCost = computePrice(invite, pricing, key, config.affiliateDiscount, paidQuantity, affiliateUsed);

        bool isPublic = isPublicInvite(invite, key);
        if (!isPublic) {
            if (invite.tokenAddress == address(0)) payment.nativeValue = payment.currencyCost;
            return payment;
        }

        uint256 minimumFee = nativeMinimumFee * paidQuantity;
        if (invite.tokenAddress != address(0)) {
            payment.nativeValue = minimumFee;
            payment.platformSurcharge = minimumFee;
            return payment;
        }

        uint256 affiliateWad = affiliateUsed ? (payment.currencyCost * config.affiliateFee) / 10000 : 0;
        uint256 platformFee = ((payment.currencyCost - affiliateWad) * payoutConfig.platformBps) / 10000;
        if (minimumFee > platformFee) payment.platformSurcharge = minimumFee - platformFee;
        payment.nativeValue = payment.currencyCost + payment.platformSurcharge;
    }

    function bonusMintsAwarded(uint256 numNfts, uint256 packedDiscount) internal pure returns (uint256) {
        for (uint8 i = 0; i < 8; i++) {
            uint32 discount = uint32((packedDiscount >> (32 * i)) & 0xFFFFFFFF);
            uint16 tierNumMints = uint16(discount >> 16);
            uint16 tierBonusMints = uint16(discount);

            if (tierNumMints == 0) {
                break; // End of valid discounts
            }

            if (numNfts >= tierNumMints) {
                return (numNfts / tierNumMints) * tierBonusMints;
            }
        }
        return 0;
    }

    function isPublicInvite(Invite storage invite, bytes32 key) internal view returns (bool) {
        return invite.isBlacklist || uint256(key) <= 0xff || key == keccak256(abi.encodePacked(invite.tokenAddress));
    }

    function validateMint(
        ArchetypeAddresses memory addrs,
        Invite storage i,
        Config storage config,
        Auth calldata auth,
        mapping(address => mapping(bytes32 => uint256)) storage minted,
        bytes calldata affiliateAuthorization,
        AffiliateSignerRegistry affiliateSignerRegistry,
        ValidationArgs memory args,
        uint128 cost,
        uint256 nativeValue
    ) public view {
        address msgSender = args.sender;
        if (args.affiliate != address(0)) {
            if (args.affiliate == addrs.platform || args.affiliate == args.owner || args.affiliate == msgSender) {
                revert InvalidReferral();
            }
            AffiliateAuthorization.validate(
                args.affiliate, msgSender, affiliateAuthorization, affiliateSignerRegistry.affiliateSigner()
            );
        } else if (affiliateAuthorization.length != 0) {
            revert InvalidAffiliateAuthorization();
        }

        if (i.limit == 0) {
            revert MintingPaused();
        }

        if (!i.isBlacklist) {
            if (!verify(auth, i.tokenAddress, msgSender)) {
                revert WalletUnauthorizedToMint();
            }
        } else {
            if (verify(auth, i.tokenAddress, msgSender)) {
                revert Blacklisted();
            }
        }

        if (block.timestamp < i.start) {
            revert MintNotYetStarted();
        }

        if (i.end > i.start && block.timestamp > i.end) {
            revert MintEnded();
        }

        if (i.limit < i.maxSupply) {
            uint256 totalAfterMint = minted[msgSender][auth.key] + args.quantity;

            if (totalAfterMint > i.limit) {
                revert NumberOfMintsExceeded();
            }
        }

        if (i.maxSupply < config.maxSupply) {
            uint256 totalAfterMint = args.listSupply + args.quantity;
            if (totalAfterMint > i.maxSupply) {
                revert ListMaxSupplyExceeded();
            }
        }

        if (args.quantity > config.maxBatchSize) {
            revert MaxBatchSizeExceeded();
        }

        if ((args.curSupply + args.quantity) > config.maxSupply) {
            revert MaxSupplyExceeded();
        }

        if (i.tokenAddress != address(0)) {
            IERC20 erc20Token = IERC20(i.tokenAddress);
            if (erc20Token.allowance(msgSender, address(this)) < cost) {
                revert NotApprovedToTransfer();
            }

            if (erc20Token.balanceOf(msgSender) < cost) {
                revert Erc20BalanceTooLow();
            }

            if (nativeValue == 0 && msg.value != 0) {
                revert ExcessiveEthSent();
            }
        }

        if (msg.value < nativeValue) {
            revert InsufficientEthSent();
        }
    }

    function creditPlatformSurcharge(ArchetypeAddresses memory addrs, uint256 surcharge) public {
        if (surcharge == 0) return;

        address[] memory recipients = new address[](1);
        recipients[0] = addrs.platform;
        uint16[] memory splits = new uint16[](1);
        splits[0] = 10000;
        ArchetypePayouts(addrs.payouts).updateBalances{value: surcharge}(surcharge, address(0), recipients, splits);
    }

    function validateBurnToMint(
        ArchetypeAddresses memory addrs,
        BurnInvite storage burnInvite,
        Config storage config,
        Auth calldata auth,
        uint256[] calldata tokenIds,
        uint256 curSupply,
        mapping(address => mapping(bytes32 => uint256)) storage minted,
        uint128 cost
    ) public view {
        if (burnInvite.limit == 0) {
            revert MintingPaused();
        }

        if (block.timestamp < burnInvite.start) {
            revert MintNotYetStarted();
        }

        if (burnInvite.end > burnInvite.start && block.timestamp > burnInvite.end) {
            revert MintEnded();
        }

        // check if msgSender owns tokens and has correct approvals
        address msgSender = _msgSender(addrs);
        for (uint256 i; i < tokenIds.length;) {
            if (burnInvite.burnErc721.ownerOf(tokenIds[i]) != msgSender) {
                revert NotTokenOwner();
            }
            unchecked {
                ++i;
            }
        }

        if (!verify(auth, burnInvite.tokenAddress, msgSender)) {
            revert WalletUnauthorizedToMint();
        }

        if (!burnInvite.burnErc721.isApprovedForAll(msgSender, address(this))) {
            revert NotApprovedToTransfer();
        }

        uint256 quantity;
        if (burnInvite.reversed) {
            quantity = tokenIds.length * burnInvite.ratio;
        } else {
            if (tokenIds.length % burnInvite.ratio != 0) {
                revert InvalidAmountOfTokens();
            }
            quantity = tokenIds.length / burnInvite.ratio;
        }

        if (quantity > config.maxBatchSize) {
            revert MaxBatchSizeExceeded();
        }

        if (burnInvite.limit < config.maxSupply) {
            uint256 totalAfterMint = minted[msgSender][keccak256(abi.encodePacked("burn", auth.key))] + quantity;

            if (totalAfterMint > burnInvite.limit) {
                revert NumberOfMintsExceeded();
            }
        }

        if ((curSupply + quantity) > config.maxSupply) {
            revert MaxSupplyExceeded();
        }

        if (burnInvite.tokenAddress != address(0)) {
            IERC20 erc20Token = IERC20(burnInvite.tokenAddress);
            if (erc20Token.allowance(msgSender, address(this)) < cost) {
                revert NotApprovedToTransfer();
            }

            if (erc20Token.balanceOf(msgSender) < cost) {
                revert Erc20BalanceTooLow();
            }

            if (msg.value != 0) {
                revert ExcessiveEthSent();
            }
        } else {
            if (msg.value < cost) {
                revert InsufficientEthSent();
            }
        }
    }

    function updateBalances(
        ArchetypeAddresses memory addrs,
        address tokenAddress,
        Config storage config,
        PayoutConfig storage payoutConfig,
        address owner,
        address sender,
        address affiliate,
        uint256 quantity,
        uint128 value,
        uint256 platformSurcharge
    ) public {
        uint128 affiliateWad;
        if (affiliate != address(0)) {
            affiliateWad = (value * config.affiliateFee) / 10000;
        }

        if (tokenAddress != address(0)) {
            IERC20 erc20Token = IERC20(tokenAddress);
            uint256 balanceBefore = erc20Token.balanceOf(address(this));
            erc20Token.safeTransferFrom(sender, address(this), value);
            if (erc20Token.balanceOf(address(this)) != balanceBefore + value) {
                revert UnexpectedTokenBalanceChange();
            }
        }

        uint128 payoutWad = value - affiliateWad;
        if (tokenAddress == address(0) && value == 0 && platformSurcharge == 0) {
            if (affiliate != address(0)) emit Referral(affiliate, tokenAddress, 0, quantity, 0);
            return;
        }

        address[] memory recipients;
        uint16[] memory splits;
        if (payoutWad > 0) {
            address ownerRecipient = payoutConfig.ownerAltPayout;
            if (ownerRecipient == address(0)) ownerRecipient = owner == address(0) ? addrs.platform : owner;

            uint256 recipientCount = 2;
            if (payoutConfig.partnerBps > 0) ++recipientCount;
            if (payoutConfig.superAffiliateBps > 0) ++recipientCount;

            recipients = new address[](recipientCount);
            recipients[0] = ownerRecipient;
            recipients[1] = addrs.platform;

            splits = new uint16[](recipientCount);
            splits[0] = payoutConfig.ownerBps;
            splits[1] = payoutConfig.platformBps;

            uint256 recipientIndex = 2;
            if (payoutConfig.partnerBps > 0) {
                recipients[recipientIndex] = payoutConfig.partner;
                splits[recipientIndex++] = payoutConfig.partnerBps;
            }
            if (payoutConfig.superAffiliateBps > 0) {
                recipients[recipientIndex] = payoutConfig.superAffiliate;
                splits[recipientIndex] = payoutConfig.superAffiliateBps;
            }

            if (tokenAddress != address(0)) {
                ArchetypePayouts(addrs.payouts).updateBalances(payoutWad, tokenAddress, recipients, splits);
            }
        }

        if (tokenAddress == address(0)) {
            if (affiliate == address(0) && platformSurcharge == 0) {
                ArchetypePayouts(addrs.payouts).updateBalances{value: payoutWad}(
                    payoutWad, tokenAddress, recipients, splits
                );
            } else {
                NativeMintCredit memory credit = NativeMintCredit({
                    payoutAmount: payoutWad,
                    affiliateAmount: affiliateWad,
                    platformSurcharge: platformSurcharge,
                    affiliate: affiliate,
                    platform: addrs.platform
                });
                ArchetypePayouts(addrs.payouts).creditMint{value: uint256(value) + platformSurcharge}(
                    credit, recipients, splits
                );
            }
            if (affiliate != address(0)) {
                emit Referral(affiliate, tokenAddress, affiliateWad, quantity, uint256(value) + platformSurcharge);
            }
            return;
        }

        if (affiliate != address(0)) {
            if (affiliateWad > 0) {
                address[] memory affiliateRecipients = new address[](1);
                affiliateRecipients[0] = affiliate;
                uint16[] memory affiliateSplits = new uint16[](1);
                affiliateSplits[0] = 10000;
                ArchetypePayouts(addrs.payouts)
                    .updateBalances(affiliateWad, tokenAddress, affiliateRecipients, affiliateSplits);
            }
            emit Referral(affiliate, tokenAddress, affiliateWad, quantity, value);
        }
        if (platformSurcharge > 0) creditPlatformSurcharge(addrs, platformSurcharge);
    }

    function verify(Auth calldata auth, address tokenAddress, address account) public pure returns (bool) {
        // keys 0-255 and tokenAddress are public
        if (uint256(auth.key) <= 0xff || auth.key == keccak256(abi.encodePacked(tokenAddress))) {
            return true;
        }

        return MerkleProofLib.verify(auth.proof, auth.key, keccak256(abi.encodePacked(account)));
    }

    function _msgSender(ArchetypeAddresses memory addrs) internal view returns (address) {
        if (msg.sender != addrs.batch) return msg.sender;
        address caller = IArchetypeBatch(addrs.batch).currentCaller();
        return caller == address(0) ? msg.sender : caller;
    }
}

lib/openzeppelin-contracts/contracts/access/Ownable.sol

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)

pragma solidity >=0.6.2;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)

pragma solidity >=0.4.16;

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

lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;

import {IERC20} from "../token/ERC20/IERC20.sol";

lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol

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

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

lib/openzeppelin-contracts/contracts/utils/Context.sol

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

pragma solidity ^0.8.20;

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

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

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

lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

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

lib/openzeppelin-v4-contracts/contracts/token/ERC721/IERC721.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

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

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

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

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

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

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

lib/openzeppelin-v4-contracts/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

lib/solady/src/utils/ECDSA.sol

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

/// @notice Gas optimized ECDSA wrapper.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ECDSA.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ECDSA.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol)
///
/// @dev Note:
/// - The recovery functions use the ecrecover precompile (0x1).
/// - As of Solady version 0.0.68, the `recover` variants will revert upon recovery failure.
///   This is for more safety by default.
///   Use the `tryRecover` variants if you need to get the zero address back
///   upon recovery failure instead.
/// - As of Solady version 0.0.134, all `bytes signature` variants accept both
///   regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures.
///   See: https://eips.ethereum.org/EIPS/eip-2098
///   This is for calldata efficiency on smart accounts prevalent on L2s.
///
/// WARNING! Do NOT directly use signatures as unique identifiers:
/// - The recovery operations do NOT check if a signature is non-malleable.
/// - Use a nonce in the digest to prevent replay attacks on the same contract.
/// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts.
///   EIP-712 also enables readable signing of typed data for better user safety.
/// - If you need a unique hash from a signature, please use the `canonicalHash` functions.
library ECDSA {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The order of the secp256k1 elliptic curve.
    uint256 internal constant N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141;

    /// @dev `N/2 + 1`. Used for checking the malleability of the signature.
    uint256 private constant _HALF_N_PLUS_1 =
        0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a1;

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

    /// @dev The signature is invalid.
    error InvalidSignature();

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

    /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
    function recover(bytes32 hash, bytes memory signature) internal view returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            let m := mload(0x40) // Cache the free memory pointer.
            for {} 1 {} {
                mstore(0x00, hash)
                mstore(0x40, mload(add(signature, 0x20))) // `r`.
                if eq(mload(signature), 64) {
                    let vs := mload(add(signature, 0x40))
                    mstore(0x20, add(shr(255, vs), 27)) // `v`.
                    mstore(0x60, shr(1, shl(1, vs))) // `s`.
                    break
                }
                if eq(mload(signature), 65) {
                    mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
                    mstore(0x60, mload(add(signature, 0x40))) // `s`.
                    break
                }
                result := 0
                break
            }
            result :=
                mload(
                    staticcall(
                        gas(), // Amount of gas left for the transaction.
                        result, // Address of `ecrecover`.
                        0x00, // Start of input.
                        0x80, // Size of input.
                        0x01, // Start of output.
                        0x20 // Size of output.
                    )
                )
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            if iszero(returndatasize()) {
                mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
                revert(0x1c, 0x04)
            }
            mstore(0x60, 0) // Restore the zero slot.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
    function recoverCalldata(bytes32 hash, bytes calldata signature)
        internal
        view
        returns (address result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x00, hash)
            for {} 1 {} {
                if eq(signature.length, 64) {
                    let vs := calldataload(add(signature.offset, 0x20))
                    mstore(0x20, add(shr(255, vs), 27)) // `v`.
                    mstore(0x40, calldataload(signature.offset)) // `r`.
                    mstore(0x60, shr(1, shl(1, vs))) // `s`.
                    break
                }
                if eq(signature.length, 65) {
                    mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.
                    calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`.
                    break
                }
                result := 0
                break
            }
            result :=
                mload(
                    staticcall(
                        gas(), // Amount of gas left for the transaction.
                        result, // Address of `ecrecover`.
                        0x00, // Start of input.
                        0x80, // Size of input.
                        0x01, // Start of output.
                        0x20 // Size of output.
                    )
                )
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            if iszero(returndatasize()) {
                mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
                revert(0x1c, 0x04)
            }
            mstore(0x60, 0) // Restore the zero slot.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Recovers the signer's address from a message digest `hash`,
    /// and the EIP-2098 short form signature defined by `r` and `vs`.
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal view returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x00, hash)
            mstore(0x20, add(shr(255, vs), 27)) // `v`.
            mstore(0x40, r)
            mstore(0x60, shr(1, shl(1, vs))) // `s`.
            result :=
                mload(
                    staticcall(
                        gas(), // Amount of gas left for the transaction.
                        1, // Address of `ecrecover`.
                        0x00, // Start of input.
                        0x80, // Size of input.
                        0x01, // Start of output.
                        0x20 // Size of output.
                    )
                )
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            if iszero(returndatasize()) {
                mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
                revert(0x1c, 0x04)
            }
            mstore(0x60, 0) // Restore the zero slot.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Recovers the signer's address from a message digest `hash`,
    /// and the signature defined by `v`, `r`, `s`.
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)
        internal
        view
        returns (address result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x00, hash)
            mstore(0x20, and(v, 0xff))
            mstore(0x40, r)
            mstore(0x60, s)
            result :=
                mload(
                    staticcall(
                        gas(), // Amount of gas left for the transaction.
                        1, // Address of `ecrecover`.
                        0x00, // Start of input.
                        0x80, // Size of input.
                        0x01, // Start of output.
                        0x20 // Size of output.
                    )
                )
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            if iszero(returndatasize()) {
                mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
                revert(0x1c, 0x04)
            }
            mstore(0x60, 0) // Restore the zero slot.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   TRY-RECOVER OPERATIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    // WARNING!
    // These functions will NOT revert upon recovery failure.
    // Instead, they will return the zero address upon recovery failure.
    // It is critical that the returned address is NEVER compared against
    // a zero address (e.g. an uninitialized address variable).

    /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
    function tryRecover(bytes32 hash, bytes memory signature)
        internal
        view
        returns (address result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            let m := mload(0x40) // Cache the free memory pointer.
            for {} 1 {} {
                mstore(0x00, hash)
                mstore(0x40, mload(add(signature, 0x20))) // `r`.
                if eq(mload(signature), 64) {
                    let vs := mload(add(signature, 0x40))
                    mstore(0x20, add(shr(255, vs), 27)) // `v`.
                    mstore(0x60, shr(1, shl(1, vs))) // `s`.
                    break
                }
                if eq(mload(signature), 65) {
                    mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
                    mstore(0x60, mload(add(signature, 0x40))) // `s`.
                    break
                }
                result := 0
                break
            }
            pop(
                staticcall(
                    gas(), // Amount of gas left for the transaction.
                    result, // Address of `ecrecover`.
                    0x00, // Start of input.
                    0x80, // Size of input.
                    0x40, // Start of output.
                    0x20 // Size of output.
                )
            )
            mstore(0x60, 0) // Restore the zero slot.
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            result := mload(xor(0x60, returndatasize()))
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
    function tryRecoverCalldata(bytes32 hash, bytes calldata signature)
        internal
        view
        returns (address result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x00, hash)
            for {} 1 {} {
                if eq(signature.length, 64) {
                    let vs := calldataload(add(signature.offset, 0x20))
                    mstore(0x20, add(shr(255, vs), 27)) // `v`.
                    mstore(0x40, calldataload(signature.offset)) // `r`.
                    mstore(0x60, shr(1, shl(1, vs))) // `s`.
                    break
                }
                if eq(signature.length, 65) {
                    mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.
                    calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`.
                    break
                }
                result := 0
                break
            }
            pop(
                staticcall(
                    gas(), // Amount of gas left for the transaction.
                    result, // Address of `ecrecover`.
                    0x00, // Start of input.
                    0x80, // Size of input.
                    0x40, // Start of output.
                    0x20 // Size of output.
                )
            )
            mstore(0x60, 0) // Restore the zero slot.
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            result := mload(xor(0x60, returndatasize()))
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Recovers the signer's address from a message digest `hash`,
    /// and the EIP-2098 short form signature defined by `r` and `vs`.
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs)
        internal
        view
        returns (address result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x00, hash)
            mstore(0x20, add(shr(255, vs), 27)) // `v`.
            mstore(0x40, r)
            mstore(0x60, shr(1, shl(1, vs))) // `s`.
            pop(
                staticcall(
                    gas(), // Amount of gas left for the transaction.
                    1, // Address of `ecrecover`.
                    0x00, // Start of input.
                    0x80, // Size of input.
                    0x40, // Start of output.
                    0x20 // Size of output.
                )
            )
            mstore(0x60, 0) // Restore the zero slot.
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            result := mload(xor(0x60, returndatasize()))
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Recovers the signer's address from a message digest `hash`,
    /// and the signature defined by `v`, `r`, `s`.
    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)
        internal
        view
        returns (address result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x00, hash)
            mstore(0x20, and(v, 0xff))
            mstore(0x40, r)
            mstore(0x60, s)
            pop(
                staticcall(
                    gas(), // Amount of gas left for the transaction.
                    1, // Address of `ecrecover`.
                    0x00, // Start of input.
                    0x80, // Size of input.
                    0x40, // Start of output.
                    0x20 // Size of output.
                )
            )
            mstore(0x60, 0) // Restore the zero slot.
            // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
            result := mload(xor(0x60, returndatasize()))
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

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

    /// @dev Returns an Ethereum Signed Message, created from a `hash`.
    /// This produces a hash corresponding to the one signed with the
    /// [`eth_sign`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign)
    /// JSON-RPC method as part of EIP-191.
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x20, hash) // Store into scratch space for keccak256.
            mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32") // 28 bytes.
            result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`.
        }
    }

    /// @dev Returns an Ethereum Signed Message, created from `s`.
    /// This produces a hash corresponding to the one signed with the
    /// [`eth_sign`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign)
    /// JSON-RPC method as part of EIP-191.
    /// Note: Supports lengths of `s` up to 999999 bytes.
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            let sLength := mload(s)
            let o := 0x20
            mstore(o, "\x19Ethereum Signed Message:\n") // 26 bytes, zero-right-padded.
            mstore(0x00, 0x00)
            // Convert the `s.length` to ASCII decimal representation: `base10(s.length)`.
            for { let temp := sLength } 1 {} {
                o := sub(o, 1)
                mstore8(o, add(48, mod(temp, 10)))
                temp := div(temp, 10)
                if iszero(temp) { break }
            }
            let n := sub(0x3a, o) // Header length: `26 + 32 - o`.
            // Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes.
            returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20))
            mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header.
            result := keccak256(add(s, sub(0x20, n)), add(n, sLength))
            mstore(s, sLength) // Restore the length.
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  CANONICAL HASH FUNCTIONS                  */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    // The following functions returns the hash of the signature in it's canonicalized format,
    // which is the 65-byte `abi.encodePacked(r, s, uint8(v))`, where `v` is either 27 or 28.
    // If `s` is greater than `N / 2` then it will be converted to `N - s`
    // and the `v` value will be flipped.
    // If the signature has an invalid length, or if `v` is invalid,
    // a uniquely corrupt hash will be returned.
    // These functions are useful for "poor-mans-VRF".

    /// @dev Returns the canonical hash of `signature`.
    function canonicalHash(bytes memory signature) internal pure returns (bytes32 result) {
        // @solidity memory-safe-assembly
        assembly {
            let l := mload(signature)
            for {} 1 {} {
                mstore(0x00, mload(add(signature, 0x20))) // `r`.
                let s := mload(add(signature, 0x40))
                let v := mload(add(signature, 0x41))
                if eq(l, 64) {
                    v := add(shr(255, s), 27)
                    s := shr(1, shl(1, s))
                }
                if iszero(lt(s, _HALF_N_PLUS_1)) {
                    v := xor(v, 7)
                    s := sub(N, s)
                }
                mstore(0x21, v)
                mstore(0x20, s)
                result := keccak256(0x00, 0x41)
                mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.
                break
            }

            // If the length is neither 64 nor 65, return a uniquely corrupted hash.
            if iszero(lt(sub(l, 64), 2)) {
                // `bytes4(keccak256("InvalidSignatureLength"))`.
                result := xor(keccak256(add(signature, 0x20), l), 0xd62f1ab2)
            }
        }
    }

    /// @dev Returns the canonical hash of `signature`.
    function canonicalHashCalldata(bytes calldata signature)
        internal
        pure
        returns (bytes32 result)
    {
        // @solidity memory-safe-assembly
        assembly {
            let l := signature.length
            for {} 1 {} {
                mstore(0x00, calldataload(signature.offset)) // `r`.
                let s := calldataload(add(signature.offset, 0x20))
                let v := calldataload(add(signature.offset, 0x21))
                if eq(l, 64) {
                    v := add(shr(255, s), 27)
                    s := shr(1, shl(1, s))
                }
                if iszero(lt(s, _HALF_N_PLUS_1)) {
                    v := xor(v, 7)
                    s := sub(N, s)
                }
                mstore(0x21, v)
                mstore(0x20, s)
                result := keccak256(0x00, 0x41)
                mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.
                break
            }
            // If the length is neither 64 nor 65, return a uniquely corrupted hash.
            if iszero(lt(sub(l, 64), 2)) {
                calldatacopy(mload(0x40), signature.offset, l)
                // `bytes4(keccak256("InvalidSignatureLength"))`.
                result := xor(keccak256(mload(0x40), l), 0xd62f1ab2)
            }
        }
    }

    /// @dev Returns the canonical hash of `signature`.
    function canonicalHash(bytes32 r, bytes32 vs) internal pure returns (bytes32 result) {
        // @solidity memory-safe-assembly
        assembly {
            mstore(0x00, r) // `r`.
            let v := add(shr(255, vs), 27)
            let s := shr(1, shl(1, vs))
            mstore(0x21, v)
            mstore(0x20, s)
            result := keccak256(0x00, 0x41)
            mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.
        }
    }

    /// @dev Returns the canonical hash of `signature`.
    function canonicalHash(uint8 v, bytes32 r, bytes32 s) internal pure returns (bytes32 result) {
        // @solidity memory-safe-assembly
        assembly {
            mstore(0x00, r) // `r`.
            if iszero(lt(s, _HALF_N_PLUS_1)) {
                v := xor(v, 7)
                s := sub(N, s)
            }
            mstore(0x21, v)
            mstore(0x20, s)
            result := keccak256(0x00, 0x41)
            mstore(0x21, 0) // Restore the overwritten part of the free memory pointer.
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   EMPTY CALLDATA HELPERS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns an empty calldata bytes.
    function emptySignature() internal pure returns (bytes calldata signature) {
        /// @solidity memory-safe-assembly
        assembly {
            signature.length := 0
        }
    }
}

lib/solady/src/utils/MerkleProofLib.sol

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

/// @notice Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol)
library MerkleProofLib {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*            MERKLE PROOF VERIFICATION OPERATIONS            */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf)
        internal
        pure
        returns (bool isValid)
    {
        /// @solidity memory-safe-assembly
        assembly {
            if mload(proof) {
                // Initialize `offset` to the offset of `proof` elements in memory.
                let offset := add(proof, 0x20)
                // Left shift by 5 is equivalent to multiplying by 0x20.
                let end := add(offset, shl(5, mload(proof)))
                // Iterate over proof elements to compute root hash.
                for {} 1 {} {
                    // Slot of `leaf` in scratch space.
                    // If the condition is true: 0x20, otherwise: 0x00.
                    let scratch := shl(5, gt(leaf, mload(offset)))
                    // Store elements to hash contiguously in scratch space.
                    // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.
                    mstore(scratch, leaf)
                    mstore(xor(scratch, 0x20), mload(offset))
                    // Reuse `leaf` to store the hash to reduce stack operations.
                    leaf := keccak256(0x00, 0x40)
                    offset := add(offset, 0x20)
                    if iszero(lt(offset, end)) { break }
                }
            }
            isValid := eq(leaf, root)
        }
    }

    /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf)
        internal
        pure
        returns (bool isValid)
    {
        /// @solidity memory-safe-assembly
        assembly {
            if proof.length {
                // Left shift by 5 is equivalent to multiplying by 0x20.
                let end := add(proof.offset, shl(5, proof.length))
                // Initialize `offset` to the offset of `proof` in the calldata.
                let offset := proof.offset
                // Iterate over proof elements to compute root hash.
                for {} 1 {} {
                    // Slot of `leaf` in scratch space.
                    // If the condition is true: 0x20, otherwise: 0x00.
                    let scratch := shl(5, gt(leaf, calldataload(offset)))
                    // Store elements to hash contiguously in scratch space.
                    // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.
                    mstore(scratch, leaf)
                    mstore(xor(scratch, 0x20), calldataload(offset))
                    // Reuse `leaf` to store the hash to reduce stack operations.
                    leaf := keccak256(0x00, 0x40)
                    offset := add(offset, 0x20)
                    if iszero(lt(offset, end)) { break }
                }
            }
            isValid := eq(leaf, root)
        }
    }

    /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`,
    /// given `proof` and `flags`.
    ///
    /// Note:
    /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length`
    ///   will always return false.
    /// - The sum of the lengths of `proof` and `leaves` must never overflow.
    /// - Any non-zero word in the `flags` array is treated as true.
    /// - The memory offset of `proof` must be non-zero
    ///   (i.e. `proof` is not pointing to the scratch space).
    function verifyMultiProof(
        bytes32[] memory proof,
        bytes32 root,
        bytes32[] memory leaves,
        bool[] memory flags
    ) internal pure returns (bool isValid) {
        // Rebuilds the root by consuming and producing values on a queue.
        // The queue starts with the `leaves` array, and goes into a `hashes` array.
        // After the process, the last element on the queue is verified
        // to be equal to the `root`.
        //
        // The `flags` array denotes whether the sibling
        // should be popped from the queue (`flag == true`), or
        // should be popped from the `proof` (`flag == false`).
        /// @solidity memory-safe-assembly
        assembly {
            // Cache the lengths of the arrays.
            let leavesLength := mload(leaves)
            let proofLength := mload(proof)
            let flagsLength := mload(flags)

            // Advance the pointers of the arrays to point to the data.
            leaves := add(0x20, leaves)
            proof := add(0x20, proof)
            flags := add(0x20, flags)

            // If the number of flags is correct.
            for {} eq(add(leavesLength, proofLength), add(flagsLength, 1)) {} {
                // For the case where `proof.length + leaves.length == 1`.
                if iszero(flagsLength) {
                    // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`.
                    isValid := eq(mload(xor(leaves, mul(xor(proof, leaves), proofLength))), root)
                    break
                }

                // The required final proof offset if `flagsLength` is not zero, otherwise zero.
                let proofEnd := add(proof, shl(5, proofLength))
                // We can use the free memory space for the queue.
                // We don't need to allocate, since the queue is temporary.
                let hashesFront := mload(0x40)
                // Copy the leaves into the hashes.
                // Sometimes, a little memory expansion costs less than branching.
                // Should cost less, even with a high free memory offset of 0x7d00.
                leavesLength := shl(5, leavesLength)
                for { let i := 0 } iszero(eq(i, leavesLength)) { i := add(i, 0x20) } {
                    mstore(add(hashesFront, i), mload(add(leaves, i)))
                }
                // Compute the back of the hashes.
                let hashesBack := add(hashesFront, leavesLength)
                // This is the end of the memory for the queue.
                // We recycle `flagsLength` to save on stack variables (sometimes save gas).
                flagsLength := add(hashesBack, shl(5, flagsLength))

                for {} 1 {} {
                    // Pop from `hashes`.
                    let a := mload(hashesFront)
                    // Pop from `hashes`.
                    let b := mload(add(hashesFront, 0x20))
                    hashesFront := add(hashesFront, 0x40)

                    // If the flag is false, load the next proof,
                    // else, pops from the queue.
                    if iszero(mload(flags)) {
                        // Loads the next proof.
                        b := mload(proof)
                        proof := add(proof, 0x20)
                        // Unpop from `hashes`.
                        hashesFront := sub(hashesFront, 0x20)
                    }

                    // Advance to the next flag.
                    flags := add(flags, 0x20)

                    // Slot of `a` in scratch space.
                    // If the condition is true: 0x20, otherwise: 0x00.
                    let scratch := shl(5, gt(a, b))
                    // Hash the scratch space and push the result onto the queue.
                    mstore(scratch, a)
                    mstore(xor(scratch, 0x20), b)
                    mstore(hashesBack, keccak256(0x00, 0x40))
                    hashesBack := add(hashesBack, 0x20)
                    if iszero(lt(hashesBack, flagsLength)) { break }
                }
                isValid :=
                    and(
                        // Checks if the last value in the queue is same as the root.
                        eq(mload(sub(hashesBack, 0x20)), root),
                        // And whether all the proofs are used, if required.
                        eq(proofEnd, proof)
                    )
                break
            }
        }
    }

    /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`,
    /// given `proof` and `flags`.
    ///
    /// Note:
    /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length`
    ///   will always return false.
    /// - Any non-zero word in the `flags` array is treated as true.
    /// - The calldata offset of `proof` must be non-zero
    ///   (i.e. `proof` is from a regular Solidity function with a 4-byte selector).
    function verifyMultiProofCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32[] calldata leaves,
        bool[] calldata flags
    ) internal pure returns (bool isValid) {
        // Rebuilds the root by consuming and producing values on a queue.
        // The queue starts with the `leaves` array, and goes into a `hashes` array.
        // After the process, the last element on the queue is verified
        // to be equal to the `root`.
        //
        // The `flags` array denotes whether the sibling
        // should be popped from the queue (`flag == true`), or
        // should be popped from the `proof` (`flag == false`).
        /// @solidity memory-safe-assembly
        assembly {
            // If the number of flags is correct.
            for {} eq(add(leaves.length, proof.length), add(flags.length, 1)) {} {
                // For the case where `proof.length + leaves.length == 1`.
                if iszero(flags.length) {
                    // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`.
                    // forgefmt: disable-next-item
                    isValid := eq(
                        calldataload(
                            xor(leaves.offset, mul(xor(proof.offset, leaves.offset), proof.length))
                        ),
                        root
                    )
                    break
                }

                // The required final proof offset if `flagsLength` is not zero, otherwise zero.
                let proofEnd := add(proof.offset, shl(5, proof.length))
                // We can use the free memory space for the queue.
                // We don't need to allocate, since the queue is temporary.
                let hashesFront := mload(0x40)
                // Copy the leaves into the hashes.
                // Sometimes, a little memory expansion costs less than branching.
                // Should cost less, even with a high free memory offset of 0x7d00.
                calldatacopy(hashesFront, leaves.offset, shl(5, leaves.length))
                // Compute the back of the hashes.
                let hashesBack := add(hashesFront, shl(5, leaves.length))
                // This is the end of the memory for the queue.
                // We recycle `flagsLength` to save on stack variables (sometimes save gas).
                flags.length := add(hashesBack, shl(5, flags.length))

                // We don't need to make a copy of `proof.offset` or `flags.offset`,
                // as they are pass-by-value (this trick may not always save gas).

                for {} 1 {} {
                    // Pop from `hashes`.
                    let a := mload(hashesFront)
                    // Pop from `hashes`.
                    let b := mload(add(hashesFront, 0x20))
                    hashesFront := add(hashesFront, 0x40)

                    // If the flag is false, load the next proof,
                    // else, pops from the queue.
                    if iszero(calldataload(flags.offset)) {
                        // Loads the next proof.
                        b := calldataload(proof.offset)
                        proof.offset := add(proof.offset, 0x20)
                        // Unpop from `hashes`.
                        hashesFront := sub(hashesFront, 0x20)
                    }

                    // Advance to the next flag offset.
                    flags.offset := add(flags.offset, 0x20)

                    // Slot of `a` in scratch space.
                    // If the condition is true: 0x20, otherwise: 0x00.
                    let scratch := shl(5, gt(a, b))
                    // Hash the scratch space and push the result onto the queue.
                    mstore(scratch, a)
                    mstore(xor(scratch, 0x20), b)
                    mstore(hashesBack, keccak256(0x00, 0x40))
                    hashesBack := add(hashesBack, 0x20)
                    if iszero(lt(hashesBack, flags.length)) { break }
                }
                isValid :=
                    and(
                        // Checks if the last value in the queue is same as the root.
                        eq(mload(sub(hashesBack, 0x20)), root),
                        // And whether all the proofs are used, if required.
                        eq(proofEnd, proof.offset)
                    )
                break
            }
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   EMPTY CALLDATA HELPERS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns an empty calldata bytes32 array.
    function emptyProof() internal pure returns (bytes32[] calldata proof) {
        /// @solidity memory-safe-assembly
        assembly {
            proof.length := 0
        }
    }

    /// @dev Returns an empty calldata bytes32 array.
    function emptyLeaves() internal pure returns (bytes32[] calldata leaves) {
        /// @solidity memory-safe-assembly
        assembly {
            leaves.length := 0
        }
    }

    /// @dev Returns an empty calldata bool array.
    function emptyFlags() internal pure returns (bool[] calldata flags) {
        /// @solidity memory-safe-assembly
        assembly {
            flags.length := 0
        }
    }
}

src/AffiliateAuthorization.sol

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

import {ECDSA} from "solady/src/utils/ECDSA.sol";

error InvalidAffiliateAuthorization();
error ExpiredAffiliateAuthorization();

library AffiliateAuthorization {
    bytes32 internal constant DOMAIN_TYPEHASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    bytes32 internal constant AUTHORIZATION_TYPEHASH =
        keccak256("AffiliateAuthorization(address affiliate,address minter,uint256 deadline)");

    function validate(address affiliate, address minter, bytes calldata authorization, address affiliateSigner)
        internal
        view
    {
        if (authorization.length != 97) revert InvalidAffiliateAuthorization();

        uint256 deadline = uint256(bytes32(authorization[:32]));
        if (block.timestamp > deadline) revert ExpiredAffiliateAuthorization();

        bytes32 domainSeparator = keccak256(
            abi.encode(DOMAIN_TYPEHASH, keccak256("Archetype"), keccak256("1"), block.chainid, address(this))
        );
        bytes32 structHash = keccak256(abi.encode(AUTHORIZATION_TYPEHASH, affiliate, minter, deadline));
        bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));

        if (ECDSA.recoverCalldata(digest, authorization[32:]) != affiliateSigner) {
            revert InvalidAffiliateAuthorization();
        }
    }
}

src/AffiliateSignerRegistry.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.20;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

error InvalidAffiliateSigner();

contract AffiliateSignerRegistry is Ownable {
    address public affiliateSigner;

    event AffiliateSignerChanged(address indexed previousSigner, address indexed newSigner);

    constructor(address initialOwner, address initialSigner) Ownable(initialOwner) {
        _setAffiliateSigner(initialSigner);
    }

    function setAffiliateSigner(address newSigner) external onlyOwner {
        _setAffiliateSigner(newSigner);
    }

    function _setAffiliateSigner(address newSigner) internal {
        if (newSigner == address(0)) revert InvalidAffiliateSigner();
        address previousSigner = affiliateSigner;
        affiliateSigner = newSigner;
        emit AffiliateSignerChanged(previousSigner, newSigner);
    }
}

src/ArchetypePayouts.sol

// SPDX-License-Identifier: BUSL-1.1
// ArchetypePayouts v0.8.0
//
//        d8888                 888               888
//       d88888                 888               888
//      d88P888                 888               888
//     d88P 888 888d888 .d8888b 88888b.   .d88b.  888888 888  888 88888b.   .d88b.
//    d88P  888 888P"  d88P"    888 "88b d8P  Y8b 888    888  888 888 "88b d8P  Y8b
//   d88P   888 888    888      888  888 88888888 888    888  888 888  888 88888888
//  d8888888888 888    Y88b.    888  888 Y8b.     Y88b.  Y88b 888 888 d88P Y8b.
// d88P     888 888     "Y8888P 888  888  "Y8888   "Y888  "Y88888 88888P"   "Y8888
//                                                            888 888
//                                                       Y8b d88P 888
//
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

error InvalidLength();
error InvalidSplitShares();
error InvalidRecipient();
error TransferFailed();
error BalanceEmpty();
error NotApprovedToWithdraw();
error InvalidNativeValue();
error UnexpectedTokenBalanceChange();
error InvalidPayouts();

struct NativeMintCredit {
    uint256 payoutAmount;
    uint128 affiliateAmount;
    uint256 platformSurcharge;
    address affiliate;
    address platform;
}

contract ArchetypePayouts {
    using SafeERC20 for IERC20;

    event Withdrawal(address indexed src, address token, uint256 wad);
    event FundsAdded(address indexed source, address indexed recipient, address token, uint256 amount);

    mapping(address => mapping(address => uint256)) private _balance;
    mapping(address => mapping(address => bool)) private _approvals;

    function updateBalances(uint256 totalAmount, address token, address[] calldata recipients, uint16[] calldata splits)
        public
        payable
    {
        _validateSplits(recipients, splits);

        if (token == address(0)) {
            // ETH payments
            _creditBalances(msg.value, token, recipients, splits);
        } else {
            // ERC20 payments
            IERC20 paymentToken = IERC20(token);
            uint256 balanceBefore = paymentToken.balanceOf(address(this));
            paymentToken.safeTransferFrom(msg.sender, address(this), totalAmount);
            if (paymentToken.balanceOf(address(this)) != balanceBefore + totalAmount) {
                revert UnexpectedTokenBalanceChange();
            }

            _creditBalances(totalAmount, token, recipients, splits);
        }
    }

    function creditMint(NativeMintCredit calldata credit, address[] calldata recipients, uint16[] calldata splits)
        external
        payable
    {
        if (msg.value != credit.payoutAmount + credit.affiliateAmount + credit.platformSurcharge) {
            revert InvalidNativeValue();
        }
        if (credit.affiliate == address(0) && credit.affiliateAmount != 0) revert InvalidRecipient();
        if (credit.platform == address(0) && credit.platformSurcharge != 0) revert InvalidRecipient();

        if (credit.payoutAmount != 0) {
            _validateSplits(recipients, splits);
            _creditBalances(credit.payoutAmount, address(0), recipients, splits);
        }

        if (credit.affiliate != address(0) && credit.affiliateAmount != 0) {
            _credit(credit.affiliate, address(0), credit.affiliateAmount);
        }

        if (credit.platformSurcharge != 0) {
            _credit(credit.platform, address(0), credit.platformSurcharge);
        }
    }

    function _validateSplits(address[] calldata recipients, uint16[] calldata splits) internal pure {
        if (recipients.length != splits.length) {
            revert InvalidLength();
        }

        uint256 totalShares = 0;
        for (uint256 i = 0; i < splits.length; i++) {
            if (splits[i] > 0 && recipients[i] == address(0)) {
                revert InvalidRecipient();
            }
            totalShares += splits[i];
        }
        if (totalShares != 10000) {
            revert InvalidSplitShares();
        }
    }

    function _creditBalances(
        uint256 totalAmount,
        address token,
        address[] calldata recipients,
        uint16[] calldata splits
    ) internal {
        uint256 residualIndex;
        while (splits[residualIndex] == 0) {
            residualIndex++;
        }

        uint256 residual = totalAmount;
        for (uint256 i = 0; i < recipients.length; i++) {
            if (splits[i] == 0 || i == residualIndex) continue;
            uint256 amount = (totalAmount * splits[i]) / 10000;
            residual -= amount;
            _credit(recipients[i], token, amount);
        }

        _credit(recipients[residualIndex], token, residual);
    }

    function _credit(address recipient, address token, uint256 amount) internal {
        _balance[recipient][token] += amount;
        emit FundsAdded(msg.sender, recipient, token, amount);
    }

    function withdraw() external {
        address msgSender = msg.sender;
        _withdraw(msgSender, msgSender, address(0));
    }

    function withdrawTokens(address[] calldata tokens) external {
        address msgSender = msg.sender;

        for (uint256 i = 0; i < tokens.length; i++) {
            _withdraw(msgSender, msgSender, tokens[i]);
        }
    }

    function withdrawFrom(address from, address to) public {
        if (from != msg.sender && !_approvals[from][to]) {
            revert NotApprovedToWithdraw();
        }
        _withdraw(from, to, address(0));
    }

    function withdrawTokensFrom(address from, address to, address[] calldata tokens) public {
        if (from != msg.sender && !_approvals[from][to]) {
            revert NotApprovedToWithdraw();
        }
        for (uint256 i = 0; i < tokens.length; i++) {
            _withdraw(from, to, tokens[i]);
        }
    }

    function _withdraw(address from, address to, address token) internal {
        uint256 wad;

        wad = _balance[from][token];
        _balance[from][token] = 0;

        if (wad == 0) {
            revert BalanceEmpty();
        }

        if (token == address(0)) {
            bool success = false;
            (success,) = to.call{value: wad}("");
            if (!success) {
                revert TransferFailed();
            }
        } else {
            IERC20 erc20Token = IERC20(token);
            erc20Token.safeTransfer(to, wad);
        }
        emit Withdrawal(from, token, wad);
    }

    function approveWithdrawal(address delegate, bool approved) external {
        _approvals[msg.sender][delegate] = approved;
    }

    function isApproved(address from, address delegate) external view returns (bool) {
        return _approvals[from][delegate];
    }

    function balance(address recipient) external view returns (uint256) {
        return _balance[recipient][address(0)];
    }

    function balanceToken(address recipient, address token) external view returns (uint256) {
        return _balance[recipient][token];
    }
}

src/ERC721a/IMintPricing.sol

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

interface IMintPricing {
    function getQuote(bytes32 listKey, uint256 listSold, uint256 quantity) external view returns (uint256 totalCost);
}

src/IArchetypeBatch.sol

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

interface IArchetypeBatch {
    function currentCaller() external view returns (address);
}

src/MintConstraints.sol

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

error UnexpectedMintCurrency();
error InsufficientMintOutput();
error ExcessiveNativeValue();
error UnexpectedBurnCollection();
error UnexpectedBurnRecipient();

struct MintConstraints {
    address currency;
    uint128 maxCurrencyCost;
    uint256 maxNativeValue;
    uint256 minTotalMints;
}

struct BurnConstraints {
    MintConstraints mint;
    address burnCollection;
    address burnRecipient;
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {
    "src/ERC721a/ArchetypeLogicErc721a.sol": {
      "ArchetypeLogicErc721a": "0x2f40c8c1B5437A297779838677f23675BEb66A6f"
    }
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "viaSSACFG": false,
  "evmVersion": "cancun",
  "remappings": [
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "openzeppelin-v4/=lib/openzeppelin-v4-contracts/contracts/",
    "openzeppelin-v4-upgradeable/=lib/openzeppelin-v4-contracts-upgradeable/contracts/",
    "erc721a-upgradeable/=lib/ERC721A-Upgradeable/",
    "solady/=lib/solady/",
    "createx/=lib/createx/src/",
    "dn404/=lib/dn404/",
    "forge-std/=lib/forge-std/src/",
    "seaport-types/=lib/seaport/lib/seaport-types/",
    "seaport-core/=lib/seaport/lib/seaport-core/src/",
    "seaport-sol/=lib/seaport/lib/seaport-sol/src/",
    "solarray/=lib/seaport/lib/solarray/src/",
    "lib/createx/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/createx/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/createx/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/createx/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/murky/lib/forge-std/:ds-test/=lib/seaport/lib/murky/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/murky/lib/forge-std/:ds-test/=lib/seaport/lib/murky/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/seaport/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/seaport/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/seaport-sol/lib/forge-std/:ds-test/=lib/seaport/lib/seaport-sol/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/seaport-sol/lib/forge-std/:ds-test/=lib/seaport/lib/seaport-sol/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/seaport-sol/lib/solady/:ds-test/=lib/seaport/lib/seaport-sol/lib/solady/lib/ds-test/src/",
    "lib/seaport/lib/seaport-sol/lib/solady/:ds-test/=lib/seaport/lib/seaport-sol/lib/solady/lib/ds-test/src/",
    "lib/seaport/lib/solady/lib/solmate/:ds-test/=lib/seaport/lib/solady/lib/solmate/lib/ds-test/src/",
    "lib/seaport/lib/solady/lib/solmate/:ds-test/=lib/seaport/lib/solady/lib/solmate/lib/ds-test/src/",
    "lib/seaport/lib/solarray/lib/forge-std/:ds-test/=lib/seaport/lib/solarray/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/solarray/lib/forge-std/:ds-test/=lib/seaport/lib/solarray/lib/forge-std/lib/ds-test/src/",
    "lib/createx/lib/forge-std/:ds-test/=lib/createx/lib/forge-std/lib/ds-test/src/",
    "lib/createx/lib/forge-std/:ds-test/=lib/createx/lib/forge-std/lib/ds-test/src/",
    "lib/createx/lib/openzeppelin-contracts/:erc4626-tests/=lib/createx/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/createx/lib/openzeppelin-contracts/:erc4626-tests/=lib/createx/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/createx/lib/solady/:ds-test/=lib/createx/lib/solady/lib/ds-test/src/",
    "lib/createx/lib/solady/:ds-test/=lib/createx/lib/solady/lib/ds-test/src/",
    "lib/openzeppelin-v4-contracts-upgradeable/lib/forge-std/:ds-test/=lib/openzeppelin-v4-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
    "lib/openzeppelin-v4-contracts-upgradeable/lib/forge-std/:ds-test/=lib/openzeppelin-v4-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
    "lib/openzeppelin-v4-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-v4-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/openzeppelin-v4-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-v4-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/forge-std/:ds-test/=lib/seaport/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/forge-std/:ds-test/=lib/seaport/lib/forge-std/lib/ds-test/src/",
    "lib/seaport/lib/murky/:openzeppelin-contracts/=lib/seaport/lib/murky/lib/openzeppelin-contracts/",
    "lib/seaport/lib/murky/:openzeppelin-contracts/=lib/seaport/lib/murky/lib/openzeppelin-contracts/",
    "lib/seaport/lib/openzeppelin-contracts/:erc4626-tests/=lib/seaport/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/seaport/lib/openzeppelin-contracts/:erc4626-tests/=lib/seaport/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/seaport/lib/seaport-sol/:seaport/=lib/seaport/lib/seaport-sol/lib/seaport/contracts/",
    "lib/seaport/lib/seaport-sol/:seaport/=lib/seaport/lib/seaport-sol/lib/seaport/contracts/",
    "lib/seaport/lib/seaport-sol/:ds-test/=lib/seaport/lib/seaport-sol/lib/ds-test/src/",
    "lib/seaport/lib/seaport-sol/:ds-test/=lib/seaport/lib/seaport-sol/lib/ds-test/src/",
    "lib/seaport/lib/solady/:solmate/=lib/seaport/lib/solady/lib/solmate/src/",
    "lib/seaport/lib/solady/:solmate/=lib/seaport/lib/solady/lib/solmate/src/",
    "lib/seaport/lib/solarray/:ds-test/=lib/seaport/lib/solarray/lib/ds-test/src/",
    "lib/seaport/lib/solarray/:ds-test/=lib/seaport/lib/solarray/lib/ds-test/src/",
    "lib/seaport/lib/solmate/:ds-test/=lib/seaport/lib/solmate/lib/ds-test/src/",
    "lib/seaport/lib/solmate/:ds-test/=lib/seaport/lib/solmate/lib/ds-test/src/",
    "lib/createx/:openzeppelin-contracts/=lib/createx/lib/openzeppelin-contracts/",
    "lib/createx/:openzeppelin-contracts/=lib/createx/lib/openzeppelin-contracts/",
    "lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/openzeppelin-v4-contracts-upgradeable/:erc4626-tests/=lib/openzeppelin-v4-contracts-upgradeable/lib/erc4626-tests/",
    "lib/openzeppelin-v4-contracts-upgradeable/:erc4626-tests/=lib/openzeppelin-v4-contracts-upgradeable/lib/erc4626-tests/",
    "lib/openzeppelin-v4-contracts/:erc4626-tests/=lib/openzeppelin-v4-contracts/lib/erc4626-tests/",
    "lib/openzeppelin-v4-contracts/:erc4626-tests/=lib/openzeppelin-v4-contracts/lib/erc4626-tests/",
    "lib/seaport/:seaport/=lib/seaport/contracts/",
    "lib/seaport/:seaport/=lib/seaport/contracts/",
    "lib/seaport/:ds-test/=lib/seaport/lib/ds-test/src/",
    "lib/seaport/:ds-test/=lib/seaport/lib/ds-test/src/",
    "lib/seaport/:openzeppelin-contracts/=lib/seaport/lib/openzeppelin-contracts/",
    "lib/seaport/:openzeppelin-contracts/=lib/seaport/lib/openzeppelin-contracts/",
    "lib/seaport/:solmate/=lib/seaport/lib/solmate/src/",
    "lib/seaport/:solmate/=lib/seaport/lib/solmate/src/",
    "@rari-capital/solmate/=lib/seaport/lib/solmate/",
    "ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
    "ds-test/=lib/seaport/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "murky/=lib/seaport/lib/murky/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin-v4-contracts-upgradeable/=lib/openzeppelin-v4-contracts-upgradeable/",
    "openzeppelin-v4-contracts/=lib/openzeppelin-v4-contracts/",
    "openzeppelin/=lib/openzeppelin-v4-contracts/contracts/",
    "seaport/=lib/seaport/",
    "solmate/=lib/seaport/lib/solmate/src/"
  ],
  "experimental": false
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.