Clients
The SDK separates read requests, signed actions, on-chain deposits, and real-time subscriptions into five clients.
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:
getAssetgetResolutionPricegetLastResolutionPricegetBalancegetOrderBookgetBookOrdersgetTopOfBookgetPositiongetAgentApprovalgetAgentApprovalNoncegetExchangeConfig
Create a client:
Constructor options:
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:
placeOrderplaceAgentOrdercancelOrdercancelAllcancelReplaceOrdercancelAgentOrdercancelAllAgentcancelReplaceAgentOrderclaimclaimAgentwithdrawapproveAgentrevokeAgentsignAgentApproval
Create a client:
Constructor options:
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:
getSettlementTokengetPermit2getAccountLedgergetPendingBalancegetProcessedBalancegetPendingDepositCountgetNextPendingDepositIdgetProcessedDepositIndexgetMinBlockWaitcanProcessNextgetSettlementTokenBalancegetSettlementTokenAllowanceapproveDepositLedgerapprovePermit2depositsignDepositPermitdepositWithPermitparseAmount
Create a client:
Constructor options:
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:
connectionStateconnectclosesubscribeOrderBookunsubscribeOrderBook
Create a client:
Subscription handlers:
onUpdateonOrderonTradeonCancelonResolutiononErroronResyncRequired
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:
connectionStateconnectclosesubscribePriceunsubscribePrice
Create a client:
Subscription handlers:
onPriceonErroronStale
After a reconnect or stale-price event, accept the next live price update.
Last updated