Skip to main content
@lifi/perps-sdk is a TypeScript SDK for perpetual futures trading across multiple venues through one interface. It handles provider discovery, direct venue reads, setup, trading, deposits, and withdrawals. Use @lifi/sdk as a sibling dependency to route source tokens into the exact collateral and destination returned by getDepositFlow().

Features

  • Multi-provider support — Trade on Hyperliquid, Lighter deployments, Ondo, and future venues through one API
  • Streaming — Subscribe to live market context, orderbook updates, fills, and order status via WebSocket
  • Provider-owned authorization — Each registered plugin manages its venue-specific agent, native key, HMAC key, or session so trades execute without per-order wallet prompts
  • Take profit & stop loss — Attach TP/SL triggers to any order
  • Setup discovery — Dynamically discover required account setup actions via GET /providers
  • Unified asset identity — Consistent asset representation across all supported DEXes
  • Withdrawals — Built-in withdrawal flow via the unified /createAction and /executeAction endpoints
  • LI.FI integration — Route into provider-declared deposit assets and destinations with @lifi/sdk

Architecture

  • @lifi/perps-sdk owns the provider registry, direct venue reads, action orchestration, and the provider-declared deposit flow.
  • @lifi/sdk routes funds into the flow’s exact collateral asset and destination.
  • The LI.FI Perps API builds and executes audited action payloads; registered provider plugins own client-side authorization and direct venue credentials.

Performing Trading Actions

Most mutating operations follow the create → authorize → execute pattern. Client-only session setup actions are completed directly by the provider plugin and skip the execute round trip: Trading actions use the registered plugin’s SDK authorization path: a Hyperliquid agent, a Lighter native key, or an Ondo HMAC key. The wallet is used only when an action descriptor declares USER, such as setup signatures, SIWE, EVM deposits, and Hyperliquid transfers or withdrawals. Always follow ProviderAction.signers and signingMethod rather than inferring a credential from the venue name.

Next steps