MarketplaceZoneLib
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
| Name | Type | Description |
|---|---|---|
| $ | 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
| Name | Type | Description |
|---|---|---|
| <none> | bool |
isRoyaltyRequired
function isRoyaltyRequired(address collection) internal view returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| collection | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
blockedRole
function blockedRole() internal pure returns (bytes32);Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 |
setPaused
function setPaused(bool paused_) internal;Parameters
| Name | Type | Description |
|---|---|---|
| paused_ | bool |
setRoyaltyRequired
function setRoyaltyRequired(address collection, bool required) internal;Parameters
| Name | Type | Description |
|---|---|---|
| collection | address | |
| required | bool |
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
| Name | Type | Description |
|---|---|---|
| zoneParameters | ZoneParameters |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| zoneParameters | ZoneParameters |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes4 |
getSeaportMetadata
SIP introspection.
function getSeaportMetadata() internal pure returns (string memory name, Schema[] memory schemas);Returns
| Name | Type | Description |
|---|---|---|
| name | string | |
| schemas | Schema[] |
_checkGate
Reverts if paused or if either party is on the blocklist.
function _checkGate(address offerer, address fulfiller) private view;Parameters
| Name | Type | Description |
|---|---|---|
| offerer | address | |
| fulfiller | address |
_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
| Name | Type | Description |
|---|---|---|
| zp | ZoneParameters |
_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
| Name | Type | Description |
|---|---|---|
| token | address | |
| tokenId | uint256 | |
| salePrice | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| receiver | address | |
| royaltyAmount | uint256 |
_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
| Name | Type | Description |
|---|---|---|
| consideration | ReceivedItem[] |
Returns
| Name | Type | Description |
|---|---|---|
| curType | ItemType | |
| curToken | address | |
| salePrice | uint256 |
_isNFT
function _isNFT(ItemType t) private pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| t | ItemType |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
_isFungible
function _isFungible(ItemType t) private pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| t | ItemType |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |