Skip to main content

Fetch a Quote

The returned SwapQuote includes the cheapest/fastest route across all enabled protocols, plus quoteId (used for subsequent executeSwap and tracking calls). AbortSignal is supported for cancellation:

Stream Quotes

For UI use cases — display the first quote in ~200ms instead of waiting for every protocol:
StreamQuoteCallbacks exposes typed events: StreamingQuoteInitEvent, StreamingQuoteQuoteEvent, StreamingQuoteFinalEvent, StreamingQuoteErrorEvent, StreamingQuoteFinishedEvent. The streaming endpoint is documented at Streaming Quotes.

Execute a Swap

SwapResult contains txHash (or txHashes for multi-tx flows like ERC20 approve + swap), the chosen protocol, and any depositInstruction data. ERC20 approvals are auto-handled when needed. The SDK inserts the approval transaction first, then the swap. See the ERC20 approvals guide for details.

Plain Transfer (no swap)

sdk.transfer() sends native or token assets directly without going through a protocol:
Useful when your app needs simple “move funds” capability that’s not part of a swap.

Transaction Lifecycle

After broadcasting, save the hash so the LeoKit backend can track and emit webhooks:
Poll once:
Or watch with backoff:
watchTransaction polls /leokit/status and exits cleanly when the swap settles or fails.

Assets & Balances

The asset list is cached for 20 seconds (per-client); refreshAssets() bypasses the cache.

Events

LeoKitEvents is fully typed. Listeners can be removed via the returned Unsubscribe function or sdk.off("transaction", listener).