For the complete documentation index, see llms.txt. This page is also available as Markdown.

Clients

The SDK separates read requests, signed actions, on-chain deposits, and real-time subscriptions into five clients.

Client
Primary use
Wallet required

InfoClient

Read exchange and account data

No

ExchangeClient

Submit signed exchange actions

Yes

DepositClient

Read and write deposit-contract state

Yes

ExchangeWebSocketClient

Subscribe to market updates

No

OracleWebSocketClient

Subscribe to oracle prices

No

InfoClient

Use InfoClient for unsigned, read-only HTTP requests.

Available methods:

  • getAsset

  • getResolutionPrice

  • getLastResolutionPrice

  • getBalance

  • getOrderBook

  • getBookOrders

  • getTopOfBook

  • getPosition

  • getAgentApproval

  • getAgentApprovalNonce

  • getExchangeConfig

Create a client:

Constructor options:

Option
Required
Description

apiUrl

Yes

Exchange HTTP API base URL

fetch

No

Replacement for globalThis.fetch

headers

No

Headers added to every request

No wallet or signature is required.

ExchangeClient

Use ExchangeClient for wallet-signed exchange actions.

Available methods:

  • placeOrder

  • placeAgentOrder

  • cancelOrder

  • cancelAll

  • cancelReplaceOrder

  • cancelAgentOrder

  • cancelAllAgent

  • cancelReplaceAgentOrder

  • claim

  • claimAgent

  • withdraw

  • approveAgent

  • revokeAgent

  • signAgentApproval

Create a client:

Constructor options:

Option
Required
Description

apiUrl

Yes

Exchange HTTP API base URL

wallet

Yes

ethers wallet used for signing

chainId

Yes

Chain ID included in EIP-712 signatures

contracts

No

Contract-address overrides

fetch

No

Replacement for globalThis.fetch

headers

No

Headers added to every request

infoClient

No

Existing InfoClient instance

nonceManager

No

Custom action nonce manager

The SDK fills signing fields, hashes the action, creates the EIP-712 signature, and serializes the request body.

DepositClient

Use DepositClient for direct contract reads and deposit transactions.

Available methods:

  • getSettlementToken

  • getPermit2

  • getAccountLedger

  • getPendingBalance

  • getProcessedBalance

  • getPendingDepositCount

  • getNextPendingDepositId

  • getProcessedDepositIndex

  • getMinBlockWait

  • canProcessNext

  • getSettlementTokenBalance

  • getSettlementTokenAllowance

  • approveDepositLedger

  • approvePermit2

  • deposit

  • signDepositPermit

  • depositWithPermit

  • parseAmount

Create a client:

Constructor options:

Option
Required
Description

rpcUrl

Yes

EVM JSON-RPC URL

wallet

Yes

Wallet used for reads, approvals, and deposits

chainId

Yes

Expected RPC network chain ID

depositLedger

No

Deposit-ledger address override

contracts

No

Contract-address overrides

settlementTokenDecimals

No

Settlement-token decimals; currently required to be 6

The client communicates directly with chain contracts rather than the Exchange HTTP API.

ExchangeWebSocketClient

Use ExchangeWebSocketClient for live market events by assetId.

Available methods and properties:

  • connectionState

  • connect

  • close

  • subscribeOrderBook

  • unsubscribeOrderBook

Create a client:

Subscription handlers:

  • onUpdate

  • onOrder

  • onTrade

  • onCancel

  • onResolution

  • onError

  • onResyncRequired

One client can subscribe to multiple asset IDs. Multiple local handlers for the same asset share one server subscription.

OracleWebSocketClient

Use OracleWebSocketClient for live oracle prices by symbolId.

Available methods and properties:

  • connectionState

  • connect

  • close

  • subscribePrice

  • unsubscribePrice

Create a client:

Subscription handlers:

  • onPrice

  • onError

  • onStale

After a reconnect or stale-price event, accept the next live price update.

Last updated