Passa al contenuto principale

StrategyChainlinkFloor

These strategies allow a seller to make a floor price + premium ask and a buyer to make a floor price - discount collection bid. Currently Chainlink only has price feeds for ERC721 tokens, but these strategies can also support ERC1155 tokens as long as the trade amount is 1.

WETH

address WETH

Wrapped ether (WETH) address.

constructor

constructor(address _owner, address _weth) public

Constructor

Parameters

NameTypeDescription
_owneraddressOwner address
_wethaddressAddress of WETH

executeFixedPremiumStrategyWithTakerBid

function executeFixedPremiumStrategyWithTakerBid(struct OrderStructs.Taker takerBid, struct OrderStructs.Maker makerAsk) external view returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated)

This function validates the order under the context of the chosen strategy and returns the fulfillable items/amounts/price/nonce invalidation status This strategy looks at the seller's desired execution price in ETH (floor + premium) and minimum execution price and chooses the higher price.

The client has to provide the bidder's desired premium amount in ETH from the floor price as the additionalParameters.

Parameters

NameTypeDescription
takerBidstruct OrderStructs.TakerTaker bid struct (taker bid-specific parameters for the execution)
makerAskstruct OrderStructs.MakerMaker ask struct (maker ask-specific parameters for the execution)

Return Values

NameTypeDescription
priceuint256The final execution price
itemIdsuint256[]The final item ids to be traded
amountsuint256[]The corresponding amounts for each item id. It should always be 1 for any collection type.
isNonceInvalidatedboolWhether the order's nonce will be invalidated after executing the order

executeBasisPointsPremiumStrategyWithTakerBid

function executeBasisPointsPremiumStrategyWithTakerBid(struct OrderStructs.Taker takerBid, struct OrderStructs.Maker makerAsk) external view returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated)

This function validates the order under the context of the chosen strategy and returns the fulfillable items/amounts/price/nonce invalidation status. This strategy looks at the seller's desired execution price in ETH (floor * (1 + premium)) and minimum execution price and chooses the higher price.

The client has to provide the bidder's desired premium basis points from the floor price as the additionalParameters.

Parameters

NameTypeDescription
takerBidstruct OrderStructs.TakerTaker bid struct (taker bid-specific parameters for the execution)
makerAskstruct OrderStructs.MakerMaker ask struct (maker ask-specific parameters for the execution)

Return Values

NameTypeDescription
priceuint256The final execution price
itemIdsuint256[]The final item ids to be traded
amountsuint256[]The corresponding amounts for each item id. It should always be 1 for any collection type.
isNonceInvalidatedboolWhether the order's nonce will be invalidated after executing the order

executeFixedDiscountCollectionOfferStrategyWithTakerAsk

function executeFixedDiscountCollectionOfferStrategyWithTakerAsk(struct OrderStructs.Taker takerAsk, struct OrderStructs.Maker makerBid) external view returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated)

This function validates the order under the context of the chosen strategy and returns the fulfillable items/amounts/price/nonce invalidation status. This strategy looks at the bidder's desired execution price in ETH (floor - discount) and maximum execution price and chooses the lower price.

The client has to provide the bidder's desired discount amount in ETH from the floor price as the additionalParameters.

Parameters

NameTypeDescription
takerAskstruct OrderStructs.TakerTaker ask struct (taker ask-specific parameters for the execution)
makerBidstruct OrderStructs.MakerMaker bid struct (maker bid-specific parameters for the execution)

Return Values

NameTypeDescription
priceuint256The final execution price
itemIdsuint256[]The final item ids to be traded
amountsuint256[]The corresponding amounts for each item id. It should always be 1 for any collection type.
isNonceInvalidatedboolWhether the order's nonce will be invalidated after executing the order

executeBasisPointsDiscountCollectionOfferStrategyWithTakerAsk

function executeBasisPointsDiscountCollectionOfferStrategyWithTakerAsk(struct OrderStructs.Taker takerAsk, struct OrderStructs.Maker makerBid) external view returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated)

This function validates the order under the context of the chosen strategy and returns the fulfillable items/amounts/price/nonce invalidation status. This strategy looks at the bidder's desired execution price in ETH (floor * (1 - discount)) and maximum execution price and chooses the lower price.

The client has to provide the bidder's desired discount basis points from the floor price as the additionalParameters.

Parameters

NameTypeDescription
takerAskstruct OrderStructs.TakerTaker ask struct (taker ask-specific parameters for the execution)
makerBidstruct OrderStructs.MakerMaker bid struct (maker bid-specific parameters for the execution)

Return Values

NameTypeDescription
priceuint256The final execution price
itemIdsuint256[]The final item ids to be traded
amountsuint256[]The corresponding amounts for each item id. It should always be 1 for any collection type.
isNonceInvalidatedboolWhether the order's nonce will be invalidated after executing the order

isMakerOrderValid

function isMakerOrderValid(struct OrderStructs.Maker makerOrder, bytes4 functionSelector) external view returns (bool isValid, bytes4 errorSelector)

Validate only the maker order under the context of the chosen strategy. It does not revert if the maker order is invalid. Instead it returns false and the error's 4 bytes selector.

Parameters

NameTypeDescription
makerOrderstruct OrderStructs.MakerMaker struct (maker specific parameters for the execution)
functionSelectorbytes4Function selector for the strategy

Return Values

NameTypeDescription
isValidboolWhether the maker struct is valid
errorSelectorbytes4If isValid is false, it returns the error's 4 bytes selector

_calculateFixedPremium

function _calculateFixedPremium(uint256 floorPrice, uint256 premium) internal pure returns (uint256 desiredPrice)

There is no fixed premium verification. We will let the runtime reverts the transaction if there is an overflow.

_calculateBasisPointsPremium

function _calculateBasisPointsPremium(uint256 floorPrice, uint256 premium) internal pure returns (uint256 desiredPrice)

There is no basis points premium verification. We will let the runtime reverts the transaction if there is an overflow.

_calculateFixedDiscount

function _calculateFixedDiscount(uint256 floorPrice, uint256 discount) internal pure returns (uint256 desiredPrice)

There is a fixed discount verification, unlike the premium calculation. This is not to catch an underflow, but to demonstrate the fact that there is a limit to the discount while the only limit to the premium is the size of uint256.

_calculateBasisPointsDiscount

function _calculateBasisPointsDiscount(uint256 floorPrice, uint256 discount) internal pure returns (uint256 desiredPrice)

There is a basis points discount verification (max 99%), unlike the premium calculation. This is not to catch an underflow, but to demonstrate the fact that there is a limit to the discount while the only limit to the premium is the size of uint256.