A collection of typescript tools to interact with LooksRare protocol V2 smart contracts 👀💎
This package has a peer dependency on etherjs V5.
yarn add @looksrare/sdk-v2 ethers
npm install @looksrare/sdk-v2 ethers --save
The SDK expose a main class used to perform all the onchain operations:
import { ChainId } from "@looksrare/sdk-v2";
const looksrare = new LooksRare(ChainId.MAINNET, provider, signer);
The signer is optional if you need access to read only data (:warning: Calls to function that need a signer will throw a Signer is undefined
exception):
import { ChainId } from "@looksrare/sdk-v2";
const looksrare = new LooksRare(ChainId.MAINNET, provider);
If you work on a hardhat setup, you can override the addresses as follow:
import { Addresses } from "@looksrare/sdk-v2";
const addresses: Addresses = {...};
const looksrare = new LooksRare(ChainId.HARDHAT, provider, signer, addresses);
ℹ️ Use JsonRpcProvider
from ethers v6
if you want to make batched RPC calls.
import { JsonRpcProvider, Network } from "ethers";
// Create a HTTP/HTTPS batch call provider
const provider = new JsonRpcProvider(RPC_URL, CHAIN_ID, { staticNetwork: Network.from(CHAIN_ID) });
// Create LooksRare instance using this provider
const looksrare = new LooksRare(ChainId.HARDHAT, provider, signer, addresses);
Prior to @looksrare/sdk-v2@0.9.2
, LooksRareSDK was making batched calls using 0xsequence/multicall
. But this is not natively supported since @looksrare/sdk-v2@1.0.0
.
Read the guides if you need help with the implementation.
You can also read the detailed api documentation.
The SDK exposes most of the LooksRare contract ABIs. For convenience, some commonly used ABIs are also exported.
import LooksRareProtocolABI from "@looksrare/sdk-v2/dist/abis/LooksRareProtocol.json";
Call the public api endpoint /orders/nonce, and use this nonce directly.
Use the public api endpoint /orders to push the order to the database. After that, the order will be visible by everyone using the API (looksrare.org, aggregators, etc..).
Merkle tree orders are used to create several orders with a single signature. You shouldn't use them when using a bot. Their main purpose is to facilitate orders creation using a user interface.
When you approve a collection to be traded on LooksRare, you approve the TransferManager instead of the exchange. Calling grantTransferManagerApproval
gives the exchange contract the right to call the transfer function on the TransferManager. You need to call this function only once, the first time you use the V2.
tl;dr subset nonces allow you to cancel all the orders sharing the same subset nonce.
Subset nonces allow you to group some orders together according to arbitrary rules (for example all your orders for a specific collection, all your orders above a certain threshold, etc). You can then cancel them all with a single call to cancelSubsetOrders
.
:information_source: Unlike order nonces, executing an order with a specific subset nonce doesn't invalidate other orders sharing the same subset nonce.