@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-DEX support — Trade on Hyperliquid and other perpetual DEXes through one API
- Streaming — Subscribe to live price feeds, orderbook updates, fills, and order status via WebSocket
- Two signing modes — Choose between direct wallet signing (
USER) or agent wallet signing (USER_AGENT) for a seamless experience - Take profit & stop loss — Attach TP/SL triggers to any order
- Agent wallets — One-time approval, then trade without wallet popups
- Authorization discovery — Dynamically discover required DEX authorizations via
GET /dexes - Unified order type — Consistent order representation across all supported DEXes
- Withdrawals — Built-in withdrawal flow via
/createWithdrawaland/withdrawalendpoints - 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.
Hyperliquid: Withdrawals are processed via the Perps SDK’s
/createWithdrawal and /withdrawal endpoints. This withdraws USDC from the Hyperliquid unified USDC balance to Arbitrum USDC. Withdrawal mechanics may differ for other DEXes in the future.Order Flow
All mutating operations (orders, cancellations, authorizations) follow the create → sign → submit pattern: InUSER_AGENT mode, the SDK signs automatically with a local agent wallet. In USER mode, your application signs each typedData with the user’s connected wallet.
Next steps
- Getting Started — Install and configure the SDK
- Concepts — Understand signing modes, authorization, and the action pattern
- SDK / Trading — Place your first order
- SDK / Streaming — Subscribe to live market data and user events via WebSocket