Skip to main content

Overview

CompositeClient is the main entry point for interacting with the LFG DEX. It combines the IndexerClient (read operations) and ValidatorClient (write operations) into a unified interface.

Static Methods

connect()

Connect to a network and create a CompositeClient instance.
Network
required
Network configuration to connect to
Returns: Promise<CompositeClient>

Properties

indexerClient

Access the IndexerClient for read-only operations.

validatorClient

Access the ValidatorClient for blockchain operations.

Configuration Methods

setSelectedGasDenom()

Set which token to use for gas fees.
SelectedGasDenom
required
SelectedGasDenom.USDC or SelectedGasDenom.NATIVE

populateAccountNumberCache()

Pre-populate the account number cache for faster transactions.
string
required
Address to cache account number for

Trading Methods

placeShortTermOrder()

Place a short-term order that expires based on block height.
SubaccountInfo
required
Subaccount placing the order
string
required
Market identifier (e.g., “ETH-USD”)
OrderSide
required
OrderSide.BUY or OrderSide.SELL
number
required
Order price in quote currency
number
required
Order size in base currency
number
required
Unique order identifier
number
required
Block height when order expires
Order_TimeInForce
required
Time in force policy
boolean
required
Whether order can only reduce position
Returns: Promise<BroadcastTxResponse>

placeOrder()

Place a long-term order with timestamp-based expiration.
OrderType
required
Order type (LIMIT, MARKET, STOP_LIMIT, STOP_MARKET)
OrderTimeInForce
required
GTT (Good-til-time), IOC (Immediate-or-cancel), or FOK (Fill-or-kill)
number
required
Seconds from now until order expires
OrderExecution
required
Execution type (DEFAULT, POST_ONLY, IOC)
boolean
required
Whether order must be maker
Returns: Promise<BroadcastTxResponse>

cancelOrder()

Cancel an existing order.
SubaccountInfo
required
Subaccount that placed the order
number
required
Client ID of order to cancel
OrderFlags
required
Order type flags (SHORT_TERM or LONG_TERM)
string
required
Market identifier
number
required
New expiration block (for short-term)
number
required
Seconds until expiration (for long-term)
Returns: Promise<BroadcastTxResponse>

Fund Management Methods

depositToSubaccount()

Deposit funds from wallet to subaccount.
SubaccountInfo
required
Destination subaccount
string
required
Amount in USDC (as string)
string
Optional transaction memo
Returns: Promise<BroadcastTxResponse>

withdrawFromSubaccount()

Withdraw funds from subaccount to wallet.
SubaccountInfo
required
Source subaccount
string
required
Amount in USDC (as string)
string
required
Recipient address
string
Optional transaction memo
Returns: Promise<BroadcastTxResponse>

transferToSubaccount()

Transfer funds between subaccounts.
SubaccountInfo
required
Source subaccount
string
required
Recipient wallet address
number
required
Recipient subaccount number
string
required
Amount in USDC (as string)
string
Optional transaction memo
Returns: Promise<BroadcastTxResponse>

Authentication Methods

getAuthenticators()

Get authenticators for an address (used for API key trading).
string
required
Address to query authenticators for
Returns: Promise<{ accountAuthenticators: Authenticator[] }>

Complete Example

IndexerClient

Read-only market data queries

ValidatorClient

Blockchain transaction operations

SubaccountInfo

Trading account management

Orders Guide

Complete orders guide