Get orders
The GET /orders
endpoint data
field returns an array of Order objects matching the request filters or an empty array if no order is found.
Get orders successful response schema:
{
"success": true,
"message": null,
"data": Order[] | []
}
Order object schema, see also Maker Orders | LooksRare Docs:
Field Name | Field Type | Description |
---|---|---|
hash | string | The order hash is a unique hash which identifies the order. See the Order Hash section to find out how it's calculated. |
collectionAddress | string | The address of the collection. |
tokenId | string | null | The id of the asset. If the order is a collection offer, this field will be null . |
isOrderAsk | boolean | If true , the order is a sell order (listing).If false , the order is a buy order (offer). |
signer | string | The address of the MakerOrder signer. |
strategy | string | The strategy address. See Addresses | LooksRare SDK for the possible values. |
currencyAddress | string | The currency address. See Addresses | LooksRare SDK for the possible values. The only whitelisted currency is WETH . |
amount | string | The amount of tokens to sell/purchase. It's 1 for ERC-721 and >= 1 for ERC-1155. |
price | string | The price in WEI. |
nonce | string | The order nonce. It's meant to be unique expect for conditional orders. Once executed, the order nonce becomes invalid rendering all the orders with the same nonce invalid. |
startTime | number | Start time timestamp in seconds (when the order starts to be valid). |
endTime | number | End time timestamp in seconds (when the order becomes invalid). |
minPercentageToAsk | number | The minPercentageToAsk represents the minimum percentage required to be transferred to the ask or the trade is rejected (e.g., 9800 = 98% of the trade price). It protects the ask user from an unexpected increase in fees. |
params | string | The order params are used for more advanced orders. For example to define the maximum price for a Dutch auction or recipient address for a private sale. Not used for standard orders. |
status | See the Order Status section. | The order status. Only VALID orders can be matched with a TakerOrder. |
signature | string | The full EIP-712 signature. |
r | string | The r parameter of the EIP-712 signature. |
s | string | The s parameter of the EIP-712 signature. |
v | number | The v parameter of the EIP-712 signature. |
Create an order
The POST /orders
endpoint is used to create a MakerOrder. If successful, it returns the newly created MakerOrder.
Create an order successful response schema:
{
"success": true,
"message": null,
"data": Order
}
See the Get orders - Order schema above for the response Order object schema. See below for the object the API expects to create an order.
MakerOrder object schema, see also MakerOrder | LooksRare SDK:
Field Name | Field Type | Description |
---|---|---|
isOrderAsk | boolean | Set to true , if the order is a sell order (listing).Set to false , if the order is a buy order (offer). |
signer | string | The address which will sign the MakerOrder object. If ask order, they must own the asset. |
collection | string | The collection address. |
price | string | The price in WEI. |
tokenId | string | The asset id. Must be null for collection offers. |
amount | string | The amount of tokens. Must be 1 for ERC-721, can be more for ERC-1155. |
strategy | string | The strategy address. See Deployed Contract Addresses | LooksRare Docs for the possible values. For listings or standard offers use StrategyStandardSaleForFixedPrice .For collection offer use StrategyAnyItemFromCollectionForFixedPrice . |
currency | string | The currency address. See Addresses | LooksRare SDK for the possible values. The only whitelisted currency is WETH . |
nonce | string | The order nonce. You can retrieve it with the Get order nonce endpoint. It's meant to be unique expect for conditional orders. Once executed, the order nonce becomes invalid rendering all the orders with the same nonce invalid. You can't create more than 20 orders with the same nonce. |
startTime | number | Start time timestamp in seconds.Math.floor(Date.now() / 1000) |
endTime | number | End time timestamp in seconds (when the order becomes invalid). |
minPercentageToAsk | number | The minPercentageToAsk represents the minimum percentage required to be transferred to the ask or the trade is rejected (e.g., 9800 = 98% of the trade price). Can't be higher than 9800 .It protects the ask user from an unexpected increase in fees. |
params | string[] | The order params are used for more advanced orders. For example to define the maximum price for a Dutch auction or recipient address for a private sale. Not used for standard orders. Can be set to [] . |
signature | string | The EIP-712 signature of the object with the previous params mentioned above. Must be added to the MakerOrder object before sending the POST request to the API endpoint. |
Get order nonce
The GET /orders/nonce
endpoint data
field returns the nonce to use when creating an order.
Get order nonce successful response schema:
{
"success": true,
"message": null,
"data": string
}
The data
field will contain the nonce to use to create a new MakerOrder.
Miscellaneous
Order Status
Status | Description |
---|---|
CANCELLED | The user cancelled the MakerOrder. |
ERC_APPROVAL | The user has not set, or has revoked, the approval (setApprovalForAll ) for the LooksrRare TransferManager contract to allow the asset to be transferred. |
ERC20_APPROVAL | The user has not set, or has revoked, the approval (approve ) for the LooksRare Exchange to allow the transfer of WETH. |
ERC20_BALANCE | The user-approved WETH balance is lower than the MakerOrder price . |
EXECUTED | The MakerOrder has been executed, meaning the listed asset was bought or the offer accepted. |
EXPIRED | The current timestamp is greater than the endTime timestamp. Meaning the MakerOrder is expired. |
INVALID_OWNER | The MakerOrder signer is no longer the asset owner. |
VALID | A valid MakerOrder that can be executed (can be matched with a TakerOrder). |
Order Hash
The order hash is the keccak256 hash of all the MakerOrder properties set when creating an order and a constant value.
NOTE: The order hash is automatically calculated at order creation. You don't need to worry about it.
Below is an example of how the order hash is obtained. In the following example, the order object is just a placeholder. The order object should contain a valid MakerOrder object.
import { encodeOrderParams } from "@looksrare/sdk";
import { defaultAbiCoder, keccak256 } from "ethers/lib/utils";
// NOTE: The order object is just a placeholder. The order object should contain a valid MakerOrder object.
const { encodedParams } = encodeOrderParams(order.params);
const types = [
"bytes32",
"bool",
"address",
"address",
"uint256",
"uint256",
"uint256",
"address",
"address",
"uint256",
"uint256",
"uint256",
"uint256",
"bytes32",
];
const values = [
// keccak256("MakerOrder(bool isOrderAsk,address signer,address collection,uint256 price,uint256 tokenId,uint256 amount,address strategy,address currency,uint256 nonce,uint256 startTime,uint256 endTime,uint256 minPercentageToAsk,bytes params)")
"0x40261ade532fa1d2c7293df30aaadb9b3c616fae525a0b56d3d411c841a85028",
order.isOrderAsk,
order.signer,
order.collection,
order.price,
order.tokenId,
order.amount,
order.strategy,
order.currency,
order.nonce,
order.startTime,
order.endTime,
order.minPercentageToAsk,
keccak256(encodedParams),
];
const hash = keccak256(defaultAbiCoder.encode(types, values));