Skip to content
Verified contractExactMIT

UnVaultRoyaltyRegistry

Address0x149313ca993385bbdbaa26d16b010bf0ed21e306
Balance

0 ETH

 

Transactions

4

 

Compiler

solc 0.8.24

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,423,431
Creation transaction
0x52535d41db…563db43f93

ethereum/UnVaultRoyaltyRegistry.sol

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

import "@openzeppelin/contracts/access/Ownable.sol";

/// @title UnVault Royalty Registry
/// @notice Single source of truth for per-collection royalty splits used by
///         `UnVaultMarketplace`, `UnVaultAuction`, and any future UnVault settlement
///         surface. Up to `MAX_ROYALTY_RECEIVERS` receivers per collection, total
///         `<= MAX_ROYALTY_BPS` (100% — founder decision 2026-09-14: creator royalties are configurable
///         0–100%; the only bound kept is that the configured total cannot exceed the sale price).
///
///         A collection with NO registered split falls back to the collection's own ERC-2981
///         `royaltyInfo`, clamped to `MAX_ROYALTY_BPS` (the sale price), then to Limit Break's backfill. The quote
///         comes back 0% (`SOURCE_NONE`) only when ERC-2981 answers zero or the collection's ERC-165 explicitly denies
///         ERC-2981; a read that cannot be trusted is `SOURCE_UNKNOWN` and the plain quotes revert (UV-1103). The
///         fallback exists so external collections brought into
///         the marketplace still earn their royalties instead of silently being paid nothing — see
///         the note at the fallback itself. (This header previously said "there is no ERC-2981
///         fallback, by design", which stopped being true when the fallback was added on
///         2026-07-30 and was flagged as stale in the closeout review §10.10.)
/// @dev Configuration is gated on-chain by the collection's `Ownable.owner()`. The
///      registry itself does NOT move funds; it only stores the configuration and
///      exposes views that callers iterate to perform the distribution.
contract UnVaultRoyaltyRegistry {
    /// @notice Basis-point denominator (100% = 10_000).
    uint256 public constant BPS_DENOMINATOR = 10_000;
    /// @notice Hard cap on the total royalty bps that can be configured per collection: 100%.
    /// @dev Founder decision 2026-09-14 (configurability round): the former 10% ceiling is removed —
    ///      creator royalties are configurable 0–100%. What stays is solvency: a collection's total can
    ///      never exceed the sale price, and every settlement surface separately keeps
    ///      `protocol fee + royalty <= price` (the zone refuses, the auction trims the royalty).
    ///      The value is read back by `UnVaultSignedZone` / `UnVaultAuction` at construction (Closeout
    ///      L-24) as a generation check, so a pre-2026-09-14 (10%) registry cannot be wired to them.
    uint256 public constant MAX_ROYALTY_BPS = 10_000;
    /// @notice Maximum number of receivers per collection.
    uint256 public constant MAX_ROYALTY_RECEIVERS = 3;

    /// @dev `bps` is in basis points of sale price.
    struct RoyaltySplit {
        address receiver;
        uint96 bps;
    }

    /// @dev Stored splits per collection. Empty / cleared == NO override: quotes fall back to the
    ///      collection's own ERC-2981 `royaltyInfo` (clamped to the sale price), and only a collection with no
    ///      usable ERC-2981 answer quotes 0% (Closeout I-02).
    mapping(address => RoyaltySplit[]) private _splits;
    /// @notice Sum of bps across the configured splits (0 = no override configured; the quote then
    ///         resumes the ERC-2981 fallback — Closeout I-02). G-22: computed from the bounded
    ///         split array (≤ 3 entries) rather than persisted beside it.
    function totalBpsOf(address nftContract) public view returns (uint256 total) {
        RoyaltySplit[] storage splits = _splits[nftContract];
        uint256 len = splits.length;
        for (uint256 i = 0; i < len; i++) {
            total += uint256(splits[i].bps);
        }
    }

    /// @notice G-17: purpose-specific errors (were revert strings).
    error InvalidContract();
    error LengthMismatch();
    error ReceiverCountOutOfRange();
    error SplitterAuthoritative();
    error ZeroReceiver();
    error ZeroBps();
    error DuplicateReceiver();
    error TotalBpsExceedsCap();
    error NotCollectionOwner();
    error CollectionNotOwnable();
    /// @notice UV-312 (review M-3 / Limit Break point 2): a royalty read failed because the CALLER left it too little
    ///         gas (the 1/64 rule), not because the collection has no royalty. The sale must stop; a retry with more
    ///         gas reads it properly. A fulfiller can therefore never starve the read into "no royalty".
    error RoyaltyReadStarved();
    /// @notice The collection's royalty could not be read (`SOURCE_UNKNOWN`). The plain quotes refuse instead of quoting 0%,
    ///         so a settlement that prices through them (the auction) stops rather than paying no royalty.
    error RoyaltyUnknown(address nftContract);

    // ── UV-312: where a quote came from. A settlement surface that must pay the creator refuses NONE and UNKNOWN. ──
    uint8 public constant SOURCE_NONE = 0; // no royalty: ERC-2981 answered zero, or ERC-165 explicitly denies ERC-2981 (no backfill)
    uint8 public constant SOURCE_SPLITTER = 1; // an UnVault wrapper's pinned RoyaltySplitter
    uint8 public constant SOURCE_CONFIGURED = 2; // a split configured here by the collection's owner/admin
    uint8 public constant SOURCE_ERC2981 = 3; // the collection's own royaltyInfo
    uint8 public constant SOURCE_LB_BACKFILL = 4; // Limit Break's CollectionSettingsRegistry royalty backfill
    uint8 public constant SOURCE_UNKNOWN = 5; // ERC-2981 could not answer and is not denied: malformed answer, any revert (empty included), out of its gas (no backfill)

    // ── UV-312 (andskur, finding 1): how a collection's ERC-2981 read ended ──
    uint8 private constant READ_VALUE = 0; // a receiver and a non-zero amount
    uint8 private constant READ_ZERO = 1; // answered: zero receiver or zero amount
    uint8 private constant READ_UNSUPPORTED = 2; // a failed read (not out of gas) on a collection whose supportsInterface(0x2a55205a) == false
    uint8 private constant READ_UNKNOWN = 3; // malformed answer, out of its gas, or a failed read (empty revert included) not denied by ERC-165

    /// @notice UV-312 (review §8a, Q10): gas forwarded to a collection's `royaltyInfo` (was 30,000) and to the wrapper probe
    ///         `royaltySplitter()` (was 20,000). Bounded on purpose: the auction escrows assets and must stay settleable.
    /// @dev    No separate gas RESERVE constant: when less than `ROYALTY_READ_GAS` is available the EVM itself forwards only
    ///         63/64 of what is left (EIP-150) and keeps 1/64 for this frame, which is enough to run the starvation check
    ///         and revert. That 1/64 is the reserve. The check `gasleft() <= forwarded / 63` after a failed read then
    ///         distinguishes "the caller ran short" (revert `RoyaltyReadStarved`) from "the collection used up its 100,000"
    ///         (`SOURCE_UNKNOWN`): with enough gas the remainder after a 100,000 failure is far above 100,000 / 63 ≈ 1,587.
    uint256 public constant ROYALTY_READ_GAS = 100_000;
    uint256 public constant SPLITTER_PROBE_GAS = 50_000;
    /// @notice Limit Break's Payment Processor v3 CollectionSettingsRegistry (`0x9A1D001A842c5e6C74b33F2aeEdEc07F0Cb20BC4`,
    ///         the same address on all seven chains, code read 2026-10-14), set at deployment; zero = no fallback. Its
    ///         per-collection royalty backfill (receiver + numerator, set by the collection's owner or AccessControl admin)
    ///         is the on-chain fallback when ERC-2981 gives no royalty. An address without code is treated as zero.
    address public immutable lbSettingsRegistry;

    constructor(address lbSettingsRegistry_) {
        lbSettingsRegistry = lbSettingsRegistry_;
    }
    uint256 public constant LB_READ_GAS = 100_000;

    /// @notice Emitted when a collection owner configures (or replaces) splits.
    event CollectionRoyaltiesUpdated(
        address indexed nftContract,
        address indexed updatedBy,
        address[] receivers,
        uint96[] bps,
        uint256 totalBps
    );
    /// @notice Emitted when a collection owner clears the configured splits.
    event CollectionRoyaltiesCleared(address indexed nftContract, address indexed updatedBy);

    /// @notice Configure (or replace) the royalty split for a collection.
    /// @dev Caller MUST be the collection's `Ownable.owner()`. Up to
    ///      `MAX_ROYALTY_RECEIVERS` entries, each with non-zero `bps`, with
    ///      `sum(bps) <= MAX_ROYALTY_BPS` (100%).
    function setCollectionRoyalties(
        address nftContract,
        address[] calldata receivers,
        uint96[] calldata bpsAmounts
    ) external {
        if (nftContract == address(0)) revert InvalidContract();
        if (receivers.length != bpsAmounts.length) revert LengthMismatch();
        if (receivers.length < 1 || receivers.length > MAX_ROYALTY_RECEIVERS) revert ReceiverCountOutOfRange();
        _requireCollectionOwner(nftContract, msg.sender);
        // Closeout M-11(d): a UnVault wrapper's canonical RoyaltySplitter carries BOTH the creator
        // and the PROTOCOL leg and is authoritative. A creator must not be able to register a
        // registry split that drops the protocol leg, so overrides are refused for wrappers; their
        // royalty always resolves through the pinned splitter (see quoteRoyaltyForToken). External
        // (non-wrapper) collections are unaffected.
        // The guard keys on "this is a wrapper", not "a splitter is pinned": a wrapper of an original without
        // ERC-2981 never gets a splitter, its `royaltyInfo` carries the protocol leg alone, and a creator override
        // would take that leg. So any contract whose `royaltySplitter()` answers (even with zero) is refused. A
        // creator's way in stays the bridge's splitter initialisation, which keeps the protocol leg.
        (bool answered,) = _probeSplitter(nftContract);
        if (answered) revert SplitterAuthoritative();

        delete _splits[nftContract];

        uint256 totalBps;
        for (uint256 i = 0; i < receivers.length; i++) {
            if (receivers[i] == address(0)) revert ZeroReceiver();
            if (bpsAmounts[i] == 0) revert ZeroBps();
            for (uint256 j = 0; j < i; j++) {
                if (receivers[j] == receivers[i]) revert DuplicateReceiver();
            }
            totalBps += uint256(bpsAmounts[i]);
            _splits[nftContract].push(RoyaltySplit({receiver: receivers[i], bps: bpsAmounts[i]}));
        }
        if (totalBps > MAX_ROYALTY_BPS) revert TotalBpsExceedsCap();
        emit CollectionRoyaltiesUpdated(nftContract, msg.sender, receivers, bpsAmounts, totalBps);
    }

    /// @notice Remove the configured override for a collection — quotes RESUME the collection's own
    ///         ERC-2981 fallback (Closeout I-02); this is not a 0% royalty.
    /// @dev Caller MUST be the collection's `Ownable.owner()`.
    function clearCollectionRoyalties(address nftContract) external {
        if (nftContract == address(0)) revert InvalidContract();
        _requireCollectionOwner(nftContract, msg.sender);
        delete _splits[nftContract];
        emit CollectionRoyaltiesCleared(nftContract, msg.sender);
    }

    /// @notice Read the configured splits for a collection.
    /// @return receivers  array of receiver addresses, length 0 when unconfigured
    /// @return bps        array of basis-point shares, parallel to `receivers`
    /// @return totalBps   sum of bps (0 when unconfigured)
    function getCollectionRoyalties(address nftContract)
        external
        view
        returns (address[] memory receivers, uint96[] memory bps, uint256 totalBps)
    {
        RoyaltySplit[] storage splits = _splits[nftContract];
        uint256 len = splits.length;
        receivers = new address[](len);
        bps = new uint96[](len);
        for (uint256 i = 0; i < len; i++) {
            receivers[i] = splits[i].receiver;
            bps[i] = splits[i].bps;
            totalBps += uint256(splits[i].bps);
        }
    }

    /// @notice Compute the per-receiver royalty amounts for a hypothetical `salePrice`.
    /// @dev Settlement contracts (marketplace, auction) call this and then distribute the
    ///      amounts via their own pull-payment escrow logic. Enforces
    ///      `total <= MAX_ROYALTY_BPS * salePrice` at call time as defense-in-depth against bps drift.
    /// @dev Closeout I-02 (verification pass 2026-09-09): this said "Returns empty arrays when no
    ///      splits are configured", which was the last surviving statement of the belief the finding
    ///      is about — and the false one. Removing an override does NOT mean zero royalty: with no
    ///      stored split the quote falls back to the collection's ERC-2981 `royaltyInfo` and returns a
    ///      ONE-ELEMENT array (and, for a recognised UnVault wrapper, the address-pinned splitter per
    ///      M-11 (d)). Empty arrays come back only when the collection has no override AND no
    ///      ERC-2981 receiver, or when `salePrice` is zero.
    function quoteRoyalty(address nftContract, uint256 salePrice)
        external
        view
        returns (address[] memory receivers, uint256[] memory amounts, uint256 totalAmount)
    {
        return quoteRoyaltyForToken(nftContract, 0, salePrice);
    }

    /// @notice Token-aware variant of {quoteRoyalty}.
    /// @dev Identical to {quoteRoyalty} for a collection with configured splits (they are
    ///      collection-wide). It only differs on the ERC-2981 fallback, where `royaltyInfo` is a
    ///      PER-TOKEN view: quoting every token as id 0 silently mis-prices any collection that varies
    ///      royalties by token. Callers that know the concrete token id should use this one.
    ///      Closeout I-20 (verification 2026-09-08): token id 0 is NOT a collection-level input - it is a
    ///      concrete token id like any other, and on an ERC-2981 collection with per-token rates it
    ///      returns TOKEN 0 royalty, not a collection-wide one. A criteria (collection-level) order must
    ///      quote a token id it will actually settle; there is no collection-level ERC-2981 query.
    ///      A royalty that cannot be read (`SOURCE_UNKNOWN`) reverts `RoyaltyUnknown`; it is never quoted as 0%. No
    ///      royalty at all (`SOURCE_NONE`) still quotes empty arrays. {quoteRoyaltyWithSource} returns both cases.
    /// @param nftContract the collection being sold
    /// @param tokenId     the concrete token id being sold (I-20: there is no collection-level id)
    /// @param salePrice   the sale price the royalty is a percentage of
    function quoteRoyaltyForToken(address nftContract, uint256 tokenId, uint256 salePrice)
        public
        view
        returns (address[] memory receivers, uint256[] memory amounts, uint256 totalAmount)
    {
        uint8 source;
        (receivers, amounts, totalAmount, source) = _quote(nftContract, tokenId, salePrice);
        if (source == SOURCE_UNKNOWN) revert RoyaltyUnknown(nftContract);
    }

    /// @notice UV-312: {quoteRoyaltyForToken} plus WHERE the royalty came from (`SOURCE_*`). The zone uses this to refuse a
    ///         sale with no royalty source (`SOURCE_NONE`) or an unreadable one (`SOURCE_UNKNOWN`) instead of settling at
    ///         0%. Order: wrapper splitter → configured split → ERC-2981 → Limit Break backfill. Quotes at `salePrice` (the
    ///         real price). Reverts `RoyaltyReadStarved` when the caller's gas, not the collection, failed a read.
    function quoteRoyaltyWithSource(address nftContract, uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address[] memory receivers, uint256[] memory amounts, uint256 totalAmount, uint8 source)
    {
        return _quote(nftContract, tokenId, salePrice);
    }

    function _one(address receiver, uint256 amount, uint256 salePrice, uint8 source)
        private
        pure
        returns (address[] memory receivers, uint256[] memory amounts, uint256 totalAmount, uint8 src)
    {
        uint256 cap = (salePrice * MAX_ROYALTY_BPS) / BPS_DENOMINATOR;
        if (amount > cap) amount = cap; // clamp untrusted external answers to the sale price, never revert the sale
        receivers = new address[](1);
        amounts = new uint256[](1);
        receivers[0] = receiver;
        amounts[0] = amount;
        return (receivers, amounts, amount, source);
    }

    function _quote(address nftContract, uint256 tokenId, uint256 salePrice)
        internal
        view
        returns (address[] memory receivers, uint256[] memory amounts, uint256 totalAmount, uint8 source)
    {
        if (salePrice == 0) {
            return (new address[](0), new uint256[](0), 0, SOURCE_NONE);
        }
        // Closeout M-11(d): for a recognized UnVault wrapper the canonical RoyaltySplitter (creator + protocol legs) is
        // authoritative and non-overridable: route the wrapper's ERC-2981 amount to the PINNED splitter.
        address unvaultSplitter = _unvaultSplitter(nftContract);
        if (unvaultSplitter != address(0)) {
            (uint8 wread,, uint256 wamount) = _staticRoyaltyInfo(nftContract, tokenId, salePrice);
            if (wread == READ_UNKNOWN) return (new address[](0), new uint256[](0), 0, SOURCE_UNKNOWN);
            if (wread != READ_VALUE || wamount == 0) return (new address[](0), new uint256[](0), 0, SOURCE_NONE);
            return _one(unvaultSplitter, wamount, salePrice, SOURCE_SPLITTER);
        }
        // G-22: "no override configured" == an empty split array (every stored share is nonzero).
        if (_splits[nftContract].length == 0) {
            // FREEZE AUDIT 2026-07-30 — ERC-2981 FALLBACK (external collections earn their royalties). Closeout M-16: read
            // with a bounded staticcall into a fixed buffer that requires EXACTLY the canonical (address,uint256) return.
            // UV-312: a failed read is UNKNOWN (never 0%), a starved read reverts, and Limit Break's backfill is tried
            // before giving up.
            (uint8 read, address receiver, uint256 amount) = _staticRoyaltyInfo(nftContract, tokenId, salePrice);
            if (read == READ_VALUE) return _one(receiver, amount, salePrice, SOURCE_ERC2981);
            // Limit Break's backfill, applied as their Payment Processor v3 applies it (`_computePaymentSplits`): when
            // the ERC-2981 read fails OR returns a zero amount.
            (address bReceiver, uint256 bNumerator) = _lbBackfill(nftContract);
            if (bReceiver != address(0) && bNumerator != 0) {
                return _one(bReceiver, (salePrice * bNumerator) / BPS_DENOMINATOR, salePrice, SOURCE_LB_BACKFILL);
            }
            return (new address[](0), new uint256[](0), 0, read == READ_UNKNOWN ? SOURCE_UNKNOWN : SOURCE_NONE);
        }
        RoyaltySplit[] storage splits = _splits[nftContract];
        uint256 len = splits.length;
        receivers = new address[](len);
        amounts = new uint256[](len);
        uint256 totalBps;
        for (uint256 i = 0; i < len; i++) {
            receivers[i] = splits[i].receiver;
            amounts[i] = (salePrice * uint256(splits[i].bps)) / BPS_DENOMINATOR;
            totalBps += splits[i].bps;
        }
        // Quit follow-up 2026-09-14 (royalty rounding): the aggregate is floored ONCE; `sum(amounts) <= totalAmount`.
        totalAmount = (salePrice * totalBps) / BPS_DENOMINATOR;
        source = SOURCE_CONFIGURED;
    }

    /// @dev Who may configure a collection's split (UV-312, matching Limit Break's Payment Processor): its `Ownable.owner()`,
    ///      an account holding AccessControl `DEFAULT_ADMIN_ROLE` on it, or the collection contract itself. Low-level reads,
    ///      so a target that returns no data or garbage gives `CollectionNotOwnable` (review L-6: a `try` cannot catch the
    ///      decode failure, which surfaced as a panic).
    function _requireCollectionOwner(address nftContract, address caller) internal view {
        if (caller == nftContract) return;
        (bool ok, bytes memory ret) = nftContract.staticcall(abi.encodeWithSignature("owner()"));
        bool readable = ok && ret.length == 32;
        if (readable && uint256(bytes32(ret)) <= type(uint160).max && address(uint160(uint256(bytes32(ret)))) == caller) return;
        // AccessControl: hasRole(DEFAULT_ADMIN_ROLE = 0x00, caller)
        (bool ok2, bytes memory ret2) =
            nftContract.staticcall(abi.encodeWithSignature("hasRole(bytes32,address)", bytes32(0), caller));
        bool adminReadable = ok2 && ret2.length == 32;
        if (adminReadable && uint256(bytes32(ret2)) == 1) return;
        if (!readable && !adminReadable) revert CollectionNotOwnable();
        revert NotCollectionOwner();
    }

    /// @dev UV-312: the 1/64 rule. After a failed sub-call that was offered `forwarded` gas, a remainder this small means the
    ///      callee got less than `forwarded` because the CALLER ran short — not that the collection misbehaved.
    function _requireNotStarved(uint256 forwarded) private view {
        if (gasleft() <= forwarded / 63) revert RoyaltyReadStarved();
    }

    /// @dev andskur #422 follow-up: decide starvation BEFORE the read too. Under EIP-150 a callee gets at most 63/64 of
    ///      what is left, so it receives its full `forwarded` only if `gasleft() >= forwarded + forwarded / 63` (plus the
    ///      call's own cost; 5,000 covers a cold account access and memory). Without this, a callee that fails INSIDE
    ///      (a proxy whose inner call is starved) can revert empty and hand back enough gas to pass the after-the-fact
    ///      check, so a starved read would classify as "unsupported" (NONE) instead of reverting.
    function _requireBudget(uint256 forwarded) private view {
        if (gasleft() < forwarded + forwarded / 63 + 5_000) revert RoyaltyReadStarved();
    }

    /// @dev UV-312: Limit Break's royalty backfill for `nftContract` from its CollectionSettingsRegistry
    ///      (`getCollectionSettings(collection, [], [])` → `collectionCoreSettings{initialized, paymentSettingsType,
    ///      paymentMethodWhitelistId, royaltyBackfillReceiver, royaltyBackfillNumerator, ...}`). Any failure = none.
    function _lbBackfill(address nftContract) private view returns (address receiver, uint256 numerator) {
        address reg = lbSettingsRegistry;
        if (reg == address(0) || reg.code.length == 0) return (address(0), 0);
        bytes memory cd = abi.encodeWithSelector(0xf88770c9, nftContract, new bytes32[](0), new bytes32[](0));
        bool success;
        uint256 initialized;
        uint256 rawReceiver;
        uint256 rawNumerator;
        uint256 size;
        uint256 forwarded = LB_READ_GAS;
        _requireBudget(forwarded);
        assembly {
            let out := mload(0x40)
            success := staticcall(forwarded, reg, add(cd, 0x20), mload(cd), out, 0xa0)
            size := returndatasize()
            initialized := mload(out)
            rawReceiver := mload(add(out, 0x60))
            rawNumerator := mload(add(out, 0x80))
        }
        if (!success) {
            _requireNotStarved(forwarded);
            return (address(0), 0);
        }
        if (size < 0xa0 || initialized != 1 || rawReceiver > type(uint160).max || rawNumerator > MAX_ROYALTY_BPS) {
            return (address(0), 0);
        }
        return (address(uint160(rawReceiver)), rawNumerator);
    }

    /// @dev Bounded-gas ERC-2981 read that never reverts the caller except when the CALLER starved it (UV-312). Requires
    ///      the exact canonical 64-byte `(address,uint256)` return. Classifies the outcome (`READ_*`):
    ///      VALUE / ZERO for a clean answer; UNSUPPORTED for a failed call that did not exhaust the forwarded gas on a
    ///      collection whose ERC-165 explicitly says it does not support ERC-2981; UNKNOWN for a malformed answer (wrong
    ///      length, dirty address), any failed call on a collection that does not explicitly deny ERC-2981, or running out
    ///      of its 100,000. `royaltyInfo(uint256,uint256)` selector = 0x2a55205a.
    ///      UV-1103 (SBSecurity #89): an empty revert is no longer read as "no ERC-2981". A proxy whose implementation runs
    ///      out of gas keeps its 1/64 under EIP-150 and bubbles an empty revert below the 100,000 threshold, so only the
    ///      collection's explicit ERC-165 denial (not a gas measurement) can make a failed read NONE.
    function _staticRoyaltyInfo(address nftContract, uint256 tokenId, uint256 salePrice)
        private
        view
        returns (uint8 read, address receiver, uint256 amount)
    {
        bytes memory cd = abi.encodeWithSelector(0x2a55205a, tokenId, salePrice);
        uint256 forwarded = ROYALTY_READ_GAS;
        bool success;
        uint256 size;
        uint256 word0;
        uint256 word1;
        _requireBudget(forwarded);
        uint256 g0 = gasleft();
        assembly {
            let out := mload(0x40)
            // UV-312: 100,000 gas (was 30,000; review §8a, Q10). Bounded so an escrowed auction stays settleable.
            success := staticcall(forwarded, nftContract, add(cd, 0x20), mload(cd), out, 0x40)
            size := returndatasize()
            word0 := mload(out)
            word1 := mload(add(out, 0x20))
        }
        if (success) {
            if (size != 0x40 || word0 > type(uint160).max) return (READ_UNKNOWN, address(0), 0);
            if (word0 == 0 || word1 == 0) return (READ_ZERO, address(word0 == 0 ? address(0) : address(uint160(word0))), word1);
            return (READ_VALUE, address(uint160(word0)), word1);
        }
        _requireNotStarved(forwarded);
        // Out of its own gas: it consumed everything it was given (no cheaper way to fail with an empty return).
        if (g0 - gasleft() >= forwarded) return (READ_UNKNOWN, address(0), 0);
        // UV-1103: an empty revert (no royaltyInfo, a bare revert, or a proxy's inner failure) is NONE only on a denial.
        return (_deniesErc2981(nftContract) ? READ_UNSUPPORTED : READ_UNKNOWN, address(0), 0);
    }

    /// @dev True only when the collection answers ERC-165 `supportsInterface(0x2a55205a)` with an explicit false: exactly
    ///      32 bytes equal to 0. No ERC-165, a revert, a malformed answer or running out of its 30,000 is not a denial.
    function _deniesErc2981(address nftContract) private view returns (bool) {
        _requireBudget(30_000);
        (bool ok, bytes memory ret) =
            nftContract.staticcall{gas: 30_000}(abi.encodeWithSelector(0x01ffc9a7, bytes4(0x2a55205a)));
        return ok && ret.length == 32 && uint256(bytes32(ret)) == 0;
    }

    /// @dev Closeout M-11(d): recognize a UnVault wrapper collection by its public
    ///      `royaltySplitter()` accessor. Bounded-gas staticcall that NEVER reverts the caller;
    ///      returns the splitter address, or address(0) when the target is not a recognizable
    ///      wrapper (the call fails, returns the wrong size, or yields a zero/dirty address).
    ///      The selector is computed by `abi.encodeWithSignature` below rather than hard-coded, so
    ///      there is no literal to drift. (Doc pass 2026-09-09: this line read
    ///      "`royaltySplitter()` selector = 0x`" — the value was missing and the backtick unbalanced.)
    function _unvaultSplitter(address nftContract) private view returns (address splitter) {
        (, splitter) = _probeSplitter(nftContract);
    }

    /// @dev The `royaltySplitter()` probe behind `_unvaultSplitter`. `answered` is true when the call succeeded with
    ///      exactly one 32-byte word, whatever its value: the contract implements the wrapper convention.
    ///      `splitter` is that word when it is a clean address, else zero.
    function _probeSplitter(address nftContract) private view returns (bool answered, address splitter) {
        bytes memory cd = abi.encodeWithSignature("royaltySplitter()");
        uint256 forwarded = SPLITTER_PROBE_GAS;
        _requireBudget(forwarded); // a starved probe must not turn a wrapper into "not a wrapper"
        bool success;
        assembly {
            let out := mload(0x40)
            success := staticcall(forwarded, nftContract, add(cd, 0x20), mload(cd), out, 0x20)
            answered := and(success, eq(returndatasize(), 0x20))
            if answered {
                let word := mload(out)
                if iszero(shr(160, word)) { splitter := word }
            }
        }
    }
}

@openzeppelin/contracts/access/Ownable.sol

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

pragma solidity ^0.8.0;

import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. 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;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @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 {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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);
    }
}

@openzeppelin/contracts/utils/Context.sol

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

pragma solidity ^0.8.0;

/**
 * @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;
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.