lootex - v0.2.0

Lootex SDK

  • Node.js >= 18
  • A https://*.lootex.dev domain if you are developing client-side applications
npm install lootex

First, initialize the Lootex client:

import { createLootexClient } from 'lootex';

const lootex = createLootexClient({
environment: 'development',
apiKey: 'your-api-key', // currently not required
});

You can fetch orders using the API client:

const { orders } = await lootex.apiClient.getOrders({
chainId: 137,
limit: 10,
page: 1,
});

To fulfill orders, create an aggregator instance:

import { createAggregator } from 'lootex/aggregator';

const aggregator = createAggregator({
client: lootex,
});

The fulfillment process typically involves multiple steps:

  1. Generate the execution plan:
const execution = await aggregator.fulfillOrders([orders[0]]);
  1. 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
  1. Execute the exchange:
const exchangeTxData = await execution.actions[1].buildTransaction();
const exchangeTx = await yourWallet.sendTransaction(exchangeTxData);
// Wait for exchange transaction to be confirmed

Once all transactions are confirmed, the order fulfillment is complete!