Skip to main content

Build Your First Trading Bot

This quickstart guide will walk you through connecting to the LFG DEX, querying market data, and placing your first order.
1

Install the SDK

Install the SDK package in your project:
Make sure you have Node.js 18+ installed
2

Create a Wallet

Generate a new wallet or import an existing one:
wallet-setup.ts
Never commit private keys or mnemonics to version control. Use environment variables.
3

Connect to the Network

Initialize the CompositeClient with network configuration:
connect.ts
Always use Network.staging() for development and testing.
4

Query Market Data

Fetch available markets and their current prices:
market-data.ts
5

Check Your Balance

Query your subaccount balance before trading:
check-balance.ts
You need USDC deposited in your subaccount to trade. See the Transfers guide for details.
6

Place Your First Order

Place a limit order on the ETH-USD market:
place-order.ts
Your order is now on the orderbook! Track it using the client ID.

Complete Example

Here’s the complete code combining all steps:
complete-example.ts

What’s Next?

Configuration

Learn about network configuration and custom RPC endpoints

Wallet Management

Deep dive into wallets and subaccount management

Order Types

Explore different order types and trading strategies

Market Data

Query orderbooks, funding rates, and market statistics