Skip to content

lifinance/perps-sdk

Repository files navigation

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, 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'] })

Trade with PerpsClient

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',
})

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.

About

Placeholder repository for a minimal implementation of the documented perps-sdk

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors