Lootex SDK
Prerequisites
- Node.js >= 18
- A
https://*.lootex.devdomain if you are developing client-side applications
Installation
npm install lootexUsage Guide
1. Create a Lootex Client
First, initialize the Lootex client:
import { createLootexClient } from 'lootex';
const lootex = createLootexClient({
environment: 'development',
apiKey: 'your-api-key', // currently not required
});2. Fetch Orders
You can fetch orders using the API client:
const { orders } = await lootex.apiClient.getOrders({
chainId: 137,
limit: 10,
page: 1,
});3. Create an Aggregator
To fulfill orders, create an aggregator instance:
import { createAggregator } from 'lootex/aggregator';
const aggregator = createAggregator({
client: lootex,
});4. Fulfill Orders
The fulfillment process typically involves multiple steps:
- Generate the execution plan:
const execution = await aggregator.fulfillOrders([orders[0]]);- Handle token approval (if needed):
const approveTxData = await execution.actions[0].buildTransaction();
const approveTx = await yourWallet.sendTransaction(approveTxData);
// Wait for approval transaction to be confirmed- Execute the exchange:
const exchangeTxData = await execution.actions[1].buildTransaction();
const exchangeTx = await yourWallet.sendTransaction(exchangeTxData);
// Wait for exchange transaction to be confirmedOnce all transactions are confirmed, the order fulfillment is complete!
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago