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~~~ ~~~~~~~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~~ ~~~~ ~~~~~~

Methods​

MAGIC_VALUE_ORDER_NONCE_EXECUTED​

function MAGIC_VALUE_ORDER_NONCE_EXECUTED() external view returns (bytes32)

Magic value nonce returned if executed (or cancelled).

Returns​

NameTypeDescription
_0bytes32undefined

WETH​

function WETH() external view returns (address)

Wrapped ETH.

Returns​

NameTypeDescription
_0addressundefined

_getUnitsHeldByHypercertFractions​

function _getUnitsHeldByHypercertFractions(address collection, uint256[] itemIds) external view returns (uint256 unitsHeldByItems)

Parameters​

NameTypeDescription
collectionaddressundefined
itemIdsuint256[]undefined

Returns​

NameTypeDescription
unitsHeldByItemsuint256undefined

addStrategy​

function addStrategy(uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) external nonpayable

This function allows the owner to add a new execution strategy to the protocol.

Strategies have an id that is incremental. Only callable by owner.

Parameters​

NameTypeDescription
standardProtocolFeeBpuint16Standard protocol fee (in basis point)
minTotalFeeBpuint16Minimum total fee (in basis point)
maxProtocolFeeBpuint16Maximum protocol fee (in basis point)
selectorbytes4Function selector for the strategy
isMakerBidboolWhether the function selector is for maker bid
implementationaddressImplementation address

cancelOrderNonces​

function cancelOrderNonces(uint256[] orderNonces) external nonpayable

This function allows a user to cancel an array of order nonces.

It does not check the status of the nonces to save gas and to prevent revertion if one of the orders is filled in the same block.

Parameters​

NameTypeDescription
orderNoncesuint256[]Array of order nonces

cancelOwnershipTransfer​

function cancelOwnershipTransfer() external nonpayable

This function is used to cancel the ownership transfer.

This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership.

cancelSubsetNonces​

function cancelSubsetNonces(uint256[] subsetNonces) external nonpayable

This function allows a user to cancel an array of subset nonces.

It does not check the status of the nonces to save gas.

Parameters​

NameTypeDescription
subsetNoncesuint256[]Array of subset nonces

chainId​

function chainId() external view returns (uint256)

Current chainId.

Returns​

NameTypeDescription
_0uint256undefined

confirmOwnershipRenouncement​

function confirmOwnershipRenouncement() external nonpayable

This function is used to confirm the ownership renouncement.

confirmOwnershipTransfer​

function confirmOwnershipTransfer() external nonpayable

This function is used to confirm the ownership transfer.

This function can only be called by the current potential owner.

creatorFeeManager​

function creatorFeeManager() external view returns (contract ICreatorFeeManager)

Creator fee manager.

Returns​

NameTypeDescription
_0contract ICreatorFeeManagerundefined

domainSeparator​

function domainSeparator() external view returns (bytes32)

Current domain separator.

Returns​

NameTypeDescription
_0bytes32undefined

executeMultipleTakerBids​

function executeMultipleTakerBids(OrderStructs.Taker[] takerBids, OrderStructs.Maker[] makerAsks, bytes[] makerSignatures, OrderStructs.MerkleTree[] merkleTrees, bool isAtomic) external payable

Parameters​

NameTypeDescription
takerBidsOrderStructs.Taker[]undefined
makerAsksOrderStructs.Maker[]undefined
makerSignaturesbytes[]undefined
merkleTreesOrderStructs.MerkleTree[]undefined
isAtomicboolundefined

executeTakerAsk​

function executeTakerAsk(OrderStructs.Taker takerAsk, OrderStructs.Maker makerBid, bytes makerSignature, OrderStructs.MerkleTree merkleTree) external nonpayable

Parameters​

NameTypeDescription
takerAskOrderStructs.Takerundefined
makerBidOrderStructs.Makerundefined
makerSignaturebytesundefined
merkleTreeOrderStructs.MerkleTreeundefined

executeTakerBid​

function executeTakerBid(OrderStructs.Taker takerBid, OrderStructs.Maker makerAsk, bytes makerSignature, OrderStructs.MerkleTree merkleTree) external payable

Parameters​

NameTypeDescription
takerBidOrderStructs.Takerundefined
makerAskOrderStructs.Makerundefined
makerSignaturebytesundefined
merkleTreeOrderStructs.MerkleTreeundefined

hashBatchOrder​

function hashBatchOrder(bytes32 root, uint256 proofLength) external pure returns (bytes32 batchOrderHash)

This function returns the hash of the concatenation of batch order type hash and merkle root.

Parameters​

NameTypeDescription
rootbytes32Merkle root
proofLengthuint256Merkle proof length

Returns​

NameTypeDescription
batchOrderHashbytes32The batch order hash

incrementBidAskNonces​

function incrementBidAskNonces(bool bid, bool ask) external nonpayable

This function increments a user's bid/ask nonces.

The logic for computing the quasi-random number is inspired by Seaport v1.2. The pseudo-randomness allows non-deterministic computation of the next ask/bid nonce. A deterministic increment would make the cancel-all process non-effective in certain cases (orders signed with a greater ask/bid nonce). The same quasi-random number is used for incrementing both the bid and ask nonces if both values are incremented in the same transaction. If this function is used twice in the same block, it will return the same quasiRandomNumber but this will not impact the overall business logic.

Parameters​

NameTypeDescription
bidboolWhether to increment the user bid nonce
askboolWhether to increment the user ask nonce

initiateOwnershipRenouncement​

function initiateOwnershipRenouncement() external nonpayable

This function is used to initiate the ownership renouncement.

initiateOwnershipTransfer​

function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable

This function is used to initiate the transfer of ownership to a new owner.

Parameters​

NameTypeDescription
newPotentialOwneraddressNew potential owner address

isCurrencyAllowed​

function isCurrencyAllowed(address) external view returns (bool)

It checks whether the currency is allowed for transacting.

Parameters​

NameTypeDescription
_0addressundefined

Returns​

NameTypeDescription
_0boolundefined

maxCreatorFeeBp​

function maxCreatorFeeBp() external view returns (uint16)

Maximum creator fee (in basis point).

Returns​

NameTypeDescription
_0uint16undefined

owner​

function owner() external view returns (address)

Address of the current owner.

Returns​

NameTypeDescription
_0addressundefined

ownershipStatus​

function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status)

Ownership status.

Returns​

NameTypeDescription
_0enum IOwnableTwoSteps.Statusundefined

potentialOwner​

function potentialOwner() external view returns (address)

Address of the potential owner.

Returns​

NameTypeDescription
_0addressundefined

protocolFeeRecipient​

function protocolFeeRecipient() external view returns (address)

Protocol fee recipient.

Returns​

NameTypeDescription
_0addressundefined

restrictedExecuteTakerBid​

function restrictedExecuteTakerBid(OrderStructs.Taker takerBid, OrderStructs.Maker makerAsk, address sender, bytes32 orderHash) external nonpayable returns (uint256 protocolFeeAmount)

Parameters​

NameTypeDescription
takerBidOrderStructs.Takerundefined
makerAskOrderStructs.Makerundefined
senderaddressundefined
orderHashbytes32undefined

Returns​

NameTypeDescription
protocolFeeAmountuint256undefined

strategyInfo​

function strategyInfo(uint256) external view returns (bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation)

This returns the strategy information for a strategy id.

Parameters​

NameTypeDescription
_0uint256undefined

Returns​

NameTypeDescription
isActiveboolundefined
standardProtocolFeeBpuint16undefined
minTotalFeeBpuint16undefined
maxProtocolFeeBpuint16undefined
selectorbytes4undefined
isMakerBidboolundefined
implementationaddressundefined

transferManager​

function transferManager() external view returns (contract TransferManager)

Transfer manager for ERC721, ERC1155 and Hypercerts.

Returns​

NameTypeDescription
_0contract TransferManagerundefined

updateCreatorFeeManager​

function updateCreatorFeeManager(address newCreatorFeeManager) external nonpayable

This function allows the owner to update the creator fee manager address.

Only callable by owner.

Parameters​

NameTypeDescription
newCreatorFeeManageraddressAddress of the creator fee manager

updateCurrencyStatus​

function updateCurrencyStatus(address currency, bool isAllowed) external nonpayable

This function allows the owner to update the status of a currency.

Only callable by owner.

Parameters​

NameTypeDescription
currencyaddressCurrency address (address(0) for ETH)
isAllowedboolWhether the currency should be allowed for trading

updateDomainSeparator​

function updateDomainSeparator() external nonpayable

This function allows the owner to update the domain separator (if possible).

Only callable by owner. If there is a fork of the network with a new chainId, it allows the owner to reset the domain separator for the new chain id.

updateETHGasLimitForTransfer​

function updateETHGasLimitForTransfer(uint256 newGasLimitETHTransfer) external nonpayable

This function allows the owner to update the maximum ETH gas limit for a standard transfer.

Only callable by owner.

Parameters​

NameTypeDescription
newGasLimitETHTransferuint256New gas limit for ETH transfer

updateMaxCreatorFeeBp​

function updateMaxCreatorFeeBp(uint16 newMaxCreatorFeeBp) external nonpayable

This function allows the owner to update the maximum creator fee (in basis point).

The maximum value that can be set is 25%. Only callable by owner.

Parameters​

NameTypeDescription
newMaxCreatorFeeBpuint16New maximum creator fee (in basis point)

updateProtocolFeeRecipient​

function updateProtocolFeeRecipient(address newProtocolFeeRecipient) external nonpayable

This function allows the owner to update the protocol fee recipient.

Only callable by owner.

Parameters​

NameTypeDescription
newProtocolFeeRecipientaddressNew protocol fee recipient address

updateStrategy​

function updateStrategy(uint256 strategyId, bool isActive, uint16 newStandardProtocolFee, uint16 newMinTotalFee) external nonpayable

This function allows the owner to update parameters for an existing execution strategy.

Only callable by owner.

Parameters​

NameTypeDescription
strategyIduint256Strategy id
isActiveboolWhether the strategy must be active
newStandardProtocolFeeuint16New standard protocol fee (in basis point)
newMinTotalFeeuint16New minimum total fee (in basis point)

userBidAskNonces​

function userBidAskNonces(address) external view returns (uint256 bidNonce, uint256 askNonce)

This tracks the bid and ask nonces for a user address.

Parameters​

NameTypeDescription
_0addressundefined

Returns​

NameTypeDescription
bidNonceuint256undefined
askNonceuint256undefined

userOrderNonce​

function userOrderNonce(address, uint256) external view returns (bytes32)

This checks whether the order nonce for a user was executed or cancelled.

Parameters​

NameTypeDescription
_0addressundefined
_1uint256undefined

Returns​

NameTypeDescription
_0bytes32undefined

userSubsetNonce​

function userSubsetNonce(address, uint256) external view returns (bool)

This checks whether the subset nonce for a user was cancelled.

Parameters​

NameTypeDescription
_0addressundefined
_1uint256undefined

Returns​

NameTypeDescription
_0boolundefined

Events​

CancelOwnershipTransfer​

event CancelOwnershipTransfer()

This is emitted if the ownership transfer is cancelled.

CurrencyStatusUpdated​

event CurrencyStatusUpdated(address currency, bool isAllowed)

It is emitted if the currency status in the allowlist is updated.

Parameters​

NameTypeDescription
currencyaddressundefined
isAllowedboolundefined

InitiateOwnershipRenouncement​

event InitiateOwnershipRenouncement()

This is emitted if the ownership renouncement is initiated.

InitiateOwnershipTransfer​

event InitiateOwnershipTransfer(address previousOwner, address potentialOwner)

This is emitted if the ownership transfer is initiated.

Parameters​

NameTypeDescription
previousOwneraddressundefined
potentialOwneraddressundefined

NewBidAskNonces​

event NewBidAskNonces(address user, uint256 bidNonce, uint256 askNonce)

It is emitted when there is an update of the global bid/ask nonces for a user.

Parameters​

NameTypeDescription
useraddressundefined
bidNonceuint256undefined
askNonceuint256undefined

NewCreatorFeeManager​

event NewCreatorFeeManager(address creatorFeeManager)

It is issued when there is a new creator fee manager.

Parameters​

NameTypeDescription
creatorFeeManageraddressundefined

NewDomainSeparator​

event NewDomainSeparator()

It is emitted if there is a change in the domain separator.

NewGasLimitETHTransfer​

event NewGasLimitETHTransfer(uint256 gasLimitETHTransfer)

It is emitted when there is a new gas limit for a ETH transfer (before it is wrapped to WETH).

Parameters​

NameTypeDescription
gasLimitETHTransferuint256undefined

NewMaxCreatorFeeBp​

event NewMaxCreatorFeeBp(uint256 maxCreatorFeeBp)

It is issued when there is a new maximum creator fee (in basis point).

Parameters​

NameTypeDescription
maxCreatorFeeBpuint256undefined

NewOwner​

event NewOwner(address newOwner)

This is emitted when there is a new owner.

Parameters​

NameTypeDescription
newOwneraddressundefined

NewProtocolFeeRecipient​

event NewProtocolFeeRecipient(address protocolFeeRecipient)

It is issued when there is a new protocol fee recipient address.

Parameters​

NameTypeDescription
protocolFeeRecipientaddressundefined

NewStrategy​

event NewStrategy(uint256 strategyId, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation)

It is emitted when a new strategy is added.

Parameters​

NameTypeDescription
strategyIduint256undefined
standardProtocolFeeBpuint16undefined
minTotalFeeBpuint16undefined
maxProtocolFeeBpuint16undefined
selectorbytes4undefined
isMakerBidboolundefined
implementationaddressundefined

OrderNoncesCancelled​

event OrderNoncesCancelled(address user, uint256[] orderNonces)

It is emitted when order nonces are cancelled for a user.

Parameters​

NameTypeDescription
useraddressundefined
orderNoncesuint256[]undefined

StrategyUpdated​

event StrategyUpdated(uint256 strategyId, bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp)

It is emitted when an existing strategy is updated.

Parameters​

NameTypeDescription
strategyIduint256undefined
isActiveboolundefined
standardProtocolFeeBpuint16undefined
minTotalFeeBpuint16undefined

SubsetNoncesCancelled​

event SubsetNoncesCancelled(address user, uint256[] subsetNonces)

It is emitted when subset nonces are cancelled for a user.

Parameters​

NameTypeDescription
useraddressundefined
subsetNoncesuint256[]undefined

TakerAsk​

event TakerAsk(ILooksRareProtocol.NonceInvalidationParameters nonceInvalidationParameters, address askUser, address bidUser, uint256 strategyId, address currency, address collection, uint256[] itemIds, uint256[] amounts, address[2] feeRecipients, uint256[3] feeAmounts)

It is emitted when a taker ask transaction is completed.

Parameters​

NameTypeDescription
nonceInvalidationParametersILooksRareProtocol.NonceInvalidationParametersundefined
askUseraddressundefined
bidUseraddressundefined
strategyIduint256undefined
currencyaddressundefined
collectionaddressundefined
itemIdsuint256[]undefined
amountsuint256[]undefined
feeRecipientsaddress[2]undefined
feeAmountsuint256[3]undefined

TakerBid​

event TakerBid(ILooksRareProtocol.NonceInvalidationParameters nonceInvalidationParameters, address bidUser, address bidRecipient, uint256 strategyId, address currency, address collection, uint256[] itemIds, uint256[] amounts, address[2] feeRecipients, uint256[3] feeAmounts)

It is emitted when a taker bid transaction is completed.

Parameters​

NameTypeDescription
nonceInvalidationParametersILooksRareProtocol.NonceInvalidationParametersundefined
bidUseraddressundefined
bidRecipientaddressundefined
strategyIduint256undefined
currencyaddressundefined
collectionaddressundefined
itemIdsuint256[]undefined
amountsuint256[]undefined
feeRecipientsaddress[2]undefined
feeAmountsuint256[3]undefined

Errors​

CallerInvalid​

error CallerInvalid()

It is returned if the function cannot be called by the sender.

ChainIdInvalid​

error ChainIdInvalid()

It is returned if the domain separator should change.

CollectionTypeInvalid​

error CollectionTypeInvalid()

It is returned is the collection type is not supported. For instance if the strategy is specific to hypercerts.

CreatorFeeBpTooHigh​

error CreatorFeeBpTooHigh()

It is returned if the creator fee (in basis point) is too high.

CurrencyInvalid​

error CurrencyInvalid()

It is returned if the currency is invalid.

ERC20TransferFromFail​

error ERC20TransferFromFail()

It is emitted if the ERC20 transferFrom fails.

LengthsInvalid​

error LengthsInvalid()

It is returned if there is either a mismatch or an error in the length of the array(s).

MerkleProofInvalid​

error MerkleProofInvalid()

It is returned if the merkle proof provided is invalid.

MerkleProofTooLarge​

error MerkleProofTooLarge(uint256 length)

It is returned if the length of the merkle proof provided is greater than tolerated.

Parameters​

NameTypeDescription
lengthuint256Proof length

NewGasLimitETHTransferTooLow​

error NewGasLimitETHTransferTooLow()

It is returned if the gas limit for a standard ETH transfer is too low.

NewProtocolFeeRecipientCannotBeNullAddress​

error NewProtocolFeeRecipientCannotBeNullAddress()

It is returned if the new protocol fee recipient is set to address(0).

NoOngoingTransferInProgress​

error NoOngoingTransferInProgress()

This is returned when there is no transfer of ownership in progress.

NoSelectorForStrategy​

error NoSelectorForStrategy()

It is returned if there is no selector for maker ask/bid for a given strategyId, depending on the quote type.

NoncesInvalid​

error NoncesInvalid()

It is returned if the nonces are invalid.

NotAContract​

error NotAContract()

It is emitted if the call recipient is not a contract.

NotOwner​

error NotOwner()

This is returned when the caller is not the owner.

NotV2Strategy​

error NotV2Strategy()

If the strategy has not set properly its implementation contract.

It can only be returned for owner operations.

NullSignerAddress​

error NullSignerAddress()

It is emitted if the signer is null.

OutsideOfTimeRange​

error OutsideOfTimeRange()

It is returned if the current block timestamp is not between start and end times in the maker order.

QuoteTypeInvalid​

error QuoteTypeInvalid()

It is returned if the maker quote type is invalid.

ReentrancyFail​

error ReentrancyFail()

This is returned when there is a reentrant call.

RenouncementNotInProgress​

error RenouncementNotInProgress()

This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement.

SameDomainSeparator​

error SameDomainSeparator()

It is returned if the domain separator cannot be updated (i.e. the chainId is the same).

SignatureEOAInvalid​

error SignatureEOAInvalid()

It is emitted if the signature is invalid for an EOA (the address recovered is not the expected one).

SignatureERC1271Invalid​

error SignatureERC1271Invalid()

It is emitted if the signature is invalid for a ERC1271 contract signer.

SignatureLengthInvalid​

error SignatureLengthInvalid(uint256 length)

It is emitted if the signature's length is neither 64 nor 65 bytes.

Parameters​

NameTypeDescription
lengthuint256undefined

SignatureParameterSInvalid​

error SignatureParameterSInvalid()

It is emitted if the signature is invalid due to S parameter.

SignatureParameterVInvalid​

error SignatureParameterVInvalid(uint8 v)

It is emitted if the signature is invalid due to V parameter.

Parameters​

NameTypeDescription
vuint8undefined

StrategyHasNoSelector​

error StrategyHasNoSelector()

It is returned if the strategy has no selector.

It can only be returned for owner operations.

StrategyNotAvailable​

error StrategyNotAvailable(uint256 strategyId)

It is returned if the strategy id has no implementation.

It is returned if there is no implementation address and the strategyId is strictly greater than 0.

Parameters​

NameTypeDescription
strategyIduint256undefined

StrategyNotUsed​

error StrategyNotUsed()

It is returned if the strategyId is invalid.

StrategyProtocolFeeTooHigh​

error StrategyProtocolFeeTooHigh()

It is returned if the strategy's protocol fee is too high.

It can only be returned for owner operations.

TransferAlreadyInProgress​

error TransferAlreadyInProgress()

This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer.

TransferNotInProgress​

error TransferNotInProgress()

This is returned when there is no ownership transfer in progress but the ownership change tries to be approved.

UnitAmountInvalid​

error UnitAmountInvalid()

It is returned if the available amount of fraction units is not available for the selected type of transaction. For instance, a split transaction cannot be executed if the amount of fraction units is not higher than the amount of fraction units available.

WrongPotentialOwner​

error WrongPotentialOwner()

This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner.