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
Name | Type | Description |
---|---|---|
_owner | address | Owner address |
_weth | address | Address 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
Name | Type | Description |
---|---|---|
takerBid | struct OrderStructs.Taker | Taker bid struct (taker bid-specific parameters for the execution) |
makerAsk | struct OrderStructs.Maker | Maker ask struct (maker ask-specific parameters for the execution) |
Return Values
Name | Type | Description |
---|---|---|
price | uint256 | The final execution price |
itemIds | uint256[] | The final item ids to be traded |
amounts | uint256[] | The corresponding amounts for each item id. It should always be 1 for any collection type. |
isNonceInvalidated | bool | Whether 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
Name | Type | Description |
---|---|---|
takerBid | struct OrderStructs.Taker | Taker bid struct (taker bid-specific parameters for the execution) |
makerAsk | struct OrderStructs.Maker | Maker ask struct (maker ask-specific parameters for the execution) |
Return Values
Name | Type | Description |
---|---|---|
price | uint256 | The final execution price |
itemIds | uint256[] | The final item ids to be traded |
amounts | uint256[] | The corresponding amounts for each item id. It should always be 1 for any collection type. |
isNonceInvalidated | bool | Whether 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
Name | Type | Description |
---|---|---|
takerAsk | struct OrderStructs.Taker | Taker ask struct (taker ask-specific parameters for the execution) |
makerBid | struct OrderStructs.Maker | Maker bid struct (maker bid-specific parameters for the execution) |
Return Values
Name | Type | Description |
---|---|---|
price | uint256 | The final execution price |
itemIds | uint256[] | The final item ids to be traded |
amounts | uint256[] | The corresponding amounts for each item id. It should always be 1 for any collection type. |
isNonceInvalidated | bool | Whether 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
Name | Type | Description |
---|---|---|
takerAsk | struct OrderStructs.Taker | Taker ask struct (taker ask-specific parameters for the execution) |
makerBid | struct OrderStructs.Maker | Maker bid struct (maker bid-specific parameters for the execution) |
Return Values
Name | Type | Description |
---|---|---|
price | uint256 | The final execution price |
itemIds | uint256[] | The final item ids to be traded |
amounts | uint256[] | The corresponding amounts for each item id. It should always be 1 for any collection type. |
isNonceInvalidated | bool | Whether 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
Name | Type | Description |
---|---|---|
makerOrder | struct OrderStructs.Maker | Maker struct (maker specific parameters for the execution) |
functionSelector | bytes4 | Function selector for the strategy |
Return Values
Name | Type | Description |
---|---|---|
isValid | bool | Whether the maker struct is valid |
errorSelector | bytes4 | If 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.