JSPM

  • Created
  • Published
  • Downloads 61
  • Score
    100M100P100Q94768F
  • License Apache-2.0

LI.FI Perps SDK for perpetuals trading

Package Exports

  • @lifi/perps-sdk
  • @lifi/perps-sdk/package.json
  • @lifi/perps-sdk/utils/hyperliquid

Readme

license npm latest package npm downloads Follow on Twitter

LI.FI Perps SDK

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

Installation

pnpm add @lifi/perps-sdk
# or
npm install @lifi/perps-sdk

Quick Start

Get an API key from the LI.FI Partner Portal.

Fetch Market Data

import { createPerpsClient, getProviders, getAssets, getPrices } from '@lifi/perps-sdk'

const client = createPerpsClient({ integrator: 'my-app', apiKey: 'your-api-key' })

const { providers } = await getProviders(client)
const { assets } = await getAssets(client, { provider: 'hyperliquid' })
const { prices } = await getPrices(client, { provider: 'hyperliquid', symbols: ['BTC', 'ETH'] })

Trade with PerpsClient

import { PerpsClient, OrderSide, OrderType } 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({
  provider: 'hyperliquid',
  address,
  asset: { assetId: 'BTC', market: 'hyperliquid' },
  side: OrderSide.BUY,
  type: OrderType.MARKET,
  size: '0.1',
  price: '95000.00',
})

Examples

See the examples/ folder for runnable code covering market data, account management, trading, agent-based signing, error handling, and custom storage.

Documentation

Changelog

See CHANGELOG.md.