मुख्य विषय में जाएं

Execution Strategies

Order matching relies on a concept of execution strategies that define the rules of how trades must be matched: (1) price, (2) itemIds, (3) amounts, (4) whether the trade invalidates the maker order (isNonceInvalidated). The strategies are mapped with a strategyId, which is defined by the signer at the creation of a maker order.

LooksRare's execution strategies enable the integration of customizable sets of rules, which can be expanded over time to effortlessly incorporate new functionalities, such as dutch auctions, into the protocol. The strategy is defined in the maker order through the use of a field named strategyId, which contains the strategy id used by the ExecutionManager to handle and route the order details to the correct strategy for execution.

  1. The total price of the transaction.
  2. An array containing the itemIds being transacted.
  3. An array containing the amounts of each token id being transacted (ERC-721: 1 /ERC-1155: 1+).
  4. The isNonceInvalidated flag defines whether the trade invalidates the maker order.

In the Solidity codebase, standard transactions use the native strategy with strategyId = 0. Standard transactions means the maker decides the price, the itemIds, and the amounts. The transaction is atomic and it cannot be partially filled.

Strategy IDs List

strategyIdDescription
0Standard strategy
1Collection offer strategy

Advanced strategies documentation

In this section, we will document how to take advantage of non-standard strategies which require additionalParameters or the user of a Merkle tree.

Collection offer

When creating a collection offer the only differences from a standard MakerBid relies on the strategyId being set to 1 and the itemIds array set to [0].

As shown below.

const makerBid: Maker = {
...
strategyId: 1
itemIds: [0]
...
}

When accepting a collection offer the tokenId of the asset being sold needs to be encoded in the additionalParameters of the TakerAsk. That can be achieved by using the encodeParams function from the LooksRare SDK v2.

As shown below.

const takerAsk: Taker = {
...
additionalParameters: encodeParams([TOKEN_ID], ["uint256"])
}

An alternative to the encodeParams included within our SDK is to do the following.

const takerAsk: Taker = {
...
additionalParameters: ethers.utils.defaultAbiCoder.encode(["uint256"], [TOKEN_ID]);
}

The TOKEN_ID placeholder should be replaced with the token id of the asset being sold.