Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

tradesSubscription

Subscribe to live spot trades for a pair. Uses WebSocket when available; falls back to HTTP polling.

Signature

function tradesSubscription(
  client: Client,
  parameters: SubscriptionCallbacks<{
    trades: Trade
  }> & {
    baseDenom: Denom
    quoteDenom: Denom
    httpInterval?: number
  },
): () => void

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const unsubscribe = client.tradesSubscription({
  baseDenom: "dango",
  quoteDenom: "bridge/usdc",
  next: ({ trades }) => console.log(trades.clearingPrice, trades.filledBase),
})

Parameters

baseDenomDenom. Base asset.

quoteDenomDenom. Quote asset.

httpIntervalnumber, optional, default 3000. Poll interval (ms) used when WS is unavailable.

next, error, complete — callbacks.

Returns

() => void — unsubscribe.

See also