LI.FI Perps SDK is a TypeScript SDK for trading perpetuals across multiple DEXes through a unified interface.
- Unified interface across perpetual DEXes (Hyperliquid and more)
- Two signing modes: USER (wallet signs each action) and USER_AGENT (agent auto-signs, no popups)
- Low-level service functions and high-level
PerpsClient - Real-time WebSocket subscriptions for prices, orderbook, and fills
- Full TypeScript support with all types exported
pnpm add @lifi/perps-sdk
# or
npm install @lifi/perps-sdkGet an API key from the LI.FI Partner Portal.
import { createPerpsClient, getDexes, getMarkets, getPrices } from '@lifi/perps-sdk'
const client = createPerpsClient({ integrator: 'my-app', apiKey: 'your-api-key' })
const { dexes } = await getDexes(client)
const { markets } = await getMarkets(client, { dex: 'hyperliquid' })
const { prices } = await getPrices(client, { dex: 'hyperliquid', symbols: ['BTC', 'ETH'] })import { PerpsClient } from '@lifi/perps-sdk'
const perps = new PerpsClient({ integrator: 'my-app', apiKey: 'your-api-key' })
// Enable agent signing mode (one-time setup, requires user wallet signature)
await perps.setSigningMode(address, 'hyperliquid', 'USER_AGENT')
// Place orders without wallet popups
const result = await perps.placeOrder({
dex: 'hyperliquid',
address,
symbol: 'BTC',
side: 'BUY',
type: 'MARKET',
size: '0.1',
price: '95000.00',
})See the examples/ folder for runnable code covering market data, account management, trading, agent-based signing, error handling, and custom storage.
See CHANGELOG.md.