@lifi/perps-sdk is a TypeScript SDK for perpetual futures trading across multiple decentralized exchanges through a single, unified interface. It handles trading, account management, and withdrawals. For deposits (swapping any token into USDC and bridging it to the venue), use the @lifi/sdk as a sibling dependency — both packages are required at the application level.
Features
- Multi-provider support — Trade on Hyperliquid and other perpetual exchanges through one API
- Streaming — Subscribe to live price feeds, orderbook updates, fills, and order status via WebSocket
- Agent-based trade signing — The SDK provisions a per-user signing agent so trades execute without wallet popups (one-time wallet signature for setup)
- 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
/createActionand/executeActionendpoints - LI.FI integration — Use
@lifi/sdkas a sibling dependency for deposits (ANY token → USDC) and bridging
Architecture
@lifi/sdkhandles deposits: swapping any token on any chain into USDC and bridging it to the DEX venue. Use this to fund a perps account.@lifi/perps-sdkhandles trading and withdrawals. It communicates with the LI.FI Perps API, which acts as a unified backend abstracting away the differences between underlying DEX protocols. Each DEX has its own signing requirements and authorization flows — the SDK handles these details transparently.
Performing Trading Actions
All mutating operations (orders, cancellations, setup, withdrawals) follow the create → sign → submit pattern: Trades are signed by an SDK-managed agent (or, on Lighter, the registered API key) — the user’s wallet is not prompted per trade. The user’s wallet is only invoked for one-time setup actions: agent approval, builder-fee approval, the L1 half of the Lighter API-key registration, and on-chain deposits. Withdrawals are signed according to each provider’s signing model — user-signed on some providers, signed by the SDK-managed signer on others. See the provider’s section for its withdrawal signer.Next steps
- Getting Started — Install and configure the SDK
- Concepts — Understand the action pattern, streaming, and multi-provider support
- SDK / Trading — Place your first order
- SDK / Streaming — Subscribe to live market data and user events via WebSocket