Skip to content
Lattice

MarketplaceZoneLib

Git Source

Title: MarketplaceZoneLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Seaport (https://github.com/ProjectOpenSea/seaport)

Logic + ERC-7201 storage for the Seaport MarketplaceZone facet. authorizeOrder (pre-fulfillment) enforces the pause + offerer/fulfiller blocklist; validateOrder (post-fulfillment) enforces that opt-in collections receive their ERC-2981 royalty in the order's consideration. Each returns its own selector as Seaport's magic value, else reverts (Seaport then rejects the order).

v1 royalty enforcement assumes a single fungible payment currency per order: salePrice is the sum of the fungible consideration the zone sees (never an externally-supplied value), and royaltyInfo is consulted best-effort (a non-ERC-2981 token whose royaltyInfo reverts is not enforceable → skipped).

Functions

marketplaceZoneStorage

function marketplaceZoneStorage() internal pure returns (MarketplaceZoneStorage storage $);

Returns

NameTypeDescription
$MarketplaceZoneStorage

__MarketplaceZone_init

Registers the Seaport ZoneInterface ERC-165 id.

function __MarketplaceZone_init() internal;

registerInterface

Writes true to the ERC-165 map slot for ZoneInterface (OpenSea zone introspection).

function registerInterface() internal;

zonePaused

function zonePaused() internal view returns (bool);

Returns

NameTypeDescription
<none>bool

isRoyaltyRequired

function isRoyaltyRequired(address collection) internal view returns (bool);

Parameters

NameTypeDescription
collectionaddress

Returns

NameTypeDescription
<none>bool

blockedRole

function blockedRole() internal pure returns (bytes32);

Returns

NameTypeDescription
<none>bytes32

setPaused

function setPaused(bool paused_) internal;

Parameters

NameTypeDescription
paused_bool

setRoyaltyRequired

function setRoyaltyRequired(address collection, bool required) internal;

Parameters

NameTypeDescription
collectionaddress
requiredbool

authorizeOrder

Pre-fulfillment hook: enforce pause + blocklist, then authorize. Reverting here lets Seaport skip the order in fulfillAvailable* (a non-magic return would revert the whole tx instead).

function authorizeOrder(ZoneParameters calldata zoneParameters) internal view returns (bytes4);

Parameters

NameTypeDescription
zoneParametersZoneParameters

Returns

NameTypeDescription
<none>bytes4

validateOrder

Post-fulfillment hook: enforce per-collection ERC-2981 royalties (v1: single-NFT ask listings; see _enforceRoyalties), then validate. View-only policy — harmless if called by a non-Seaport caller (no state changes; the returned magic value only matters to Seaport itself).

function validateOrder(ZoneParameters calldata zoneParameters) internal view returns (bytes4);

Parameters

NameTypeDescription
zoneParametersZoneParameters

Returns

NameTypeDescription
<none>bytes4

getSeaportMetadata

SIP introspection.

function getSeaportMetadata() internal pure returns (string memory name, Schema[] memory schemas);

Returns

NameTypeDescription
namestring
schemasSchema[]

_checkGate

Reverts if paused or if either party is on the blocklist.

function _checkGate(address offerer, address fulfiller) private view;

Parameters

NameTypeDescription
offereraddress
fulfilleraddress

_enforceRoyalties

v1 royalty enforcement: for a single opted-in NFT sold as an ASK listing in one fungible currency, require the consideration to pay >= royaltyInfo(tokenId, salePrice) to the 2981 receiver. To never silently bypass, every case v1 cannot cleanly decide REVERTS: an opted-in NFT on the consideration (bid) side, a multi-NFT bundle, a zero fungible price, or an opted-in collection whose royaltyInfo reverts. salePrice is the gross fungible consideration the zone sees (offerer-controlled, never an external input) — including fees, so the floor is conservative (favors the creator), never understated.

function _enforceRoyalties(ZoneParameters calldata zp) private view;

Parameters

NameTypeDescription
zpZoneParameters

_royaltyInfo

Queries ERC-2981 royaltyInfo. A revert on an opted-in collection is a HARD failure (RoyaltyInfoUnavailable) — the order is rejected, never allowed royalty-free.

function _royaltyInfo(address token, uint256 tokenId, uint256 salePrice)
        private
        view
        returns (address receiver, uint256 royaltyAmount);

Parameters

NameTypeDescription
tokenaddress
tokenIduint256
salePriceuint256

Returns

NameTypeDescription
receiveraddress
royaltyAmountuint256

_saleCurrency

Sums the fungible consideration into salePrice, requiring a single currency. Reverts MixedPaymentCurrency if two distinct fungible currencies appear (v1 limitation).

function _saleCurrency(ReceivedItem[] calldata consideration)
        private
        pure
        returns (ItemType curType, address curToken, uint256 salePrice);

Parameters

NameTypeDescription
considerationReceivedItem[]

Returns

NameTypeDescription
curTypeItemType
curTokenaddress
salePriceuint256

_isNFT

function _isNFT(ItemType t) private pure returns (bool);

Parameters

NameTypeDescription
tItemType

Returns

NameTypeDescription
<none>bool

_isFungible

function _isFungible(ItemType t) private pure returns (bool);

Parameters

NameTypeDescription
tItemType

Returns

NameTypeDescription
<none>bool