> ## Documentation Index
> Fetch the complete documentation index at: https://public-perps-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Introduction to @lifi/perps-sdk

`@lifi/perps-sdk` is a TypeScript SDK for perpetual futures trading across multiple venues through one interface. It handles provider discovery, direct venue reads, setup, trading, deposits, and withdrawals. Use [`@lifi/sdk`](https://docs.li.fi/integrate-li.fi-js-sdk/install-li.fi-sdk) as a sibling dependency to route source tokens into the exact collateral and destination returned by `getDepositFlow()`.

## Features

* **Multi-provider support** — Trade on Hyperliquid, Lighter deployments, Ondo, and future venues through one API
* **Streaming** — Subscribe to live market context, orderbook updates, fills, and order status via WebSocket
* **Provider-owned authorization** — Each registered plugin manages its venue-specific agent, native key, HMAC key, or session so trades execute without per-order wallet prompts
* **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 `/createAction` and `/executeAction` endpoints
* **LI.FI integration** — Route into provider-declared deposit assets and destinations with `@lifi/sdk`

## Architecture

```mermaid theme={null}
graph TB
    APP["Your Application"]

    LIFI["@lifi/sdk<br/><i>Cross-chain swap & deposit</i>"]:::existing
    LIFIAPI["LI.FI API<br/><i>li.quest/v1/*</i>"]:::existing
    SDK["@lifi/perps-sdk<br/><i>Perps Trading</i>"]

    API["LI.FI Perps API<br/><i>develop.li.quest/v1/perps/*</i>"]

    APP --> LIFI
    LIFI -->|HTTP| LIFIAPI
    APP --> SDK
    SDK -->|HTTP| API
    SDK -.->|REST / WebSocket reads| HL["Hyperliquid"]
    SDK -.->|REST / WebSocket reads| FD["Lighter deployments"]
    SDK -.->|REST / WebSocket reads| OD["Ondo / other venues"]
    API -->|Create / execute actions| HL
    API -->|Create / execute actions| FD
    API -->|Create / execute actions| OD

    classDef existing stroke-dasharray: 5 5
```

* **`@lifi/perps-sdk`** owns the provider registry, direct venue reads, action orchestration, and the provider-declared deposit flow.
* **`@lifi/sdk`** routes funds into the flow's exact collateral asset and destination.
* The **LI.FI Perps API** builds and executes audited action payloads; registered provider plugins own client-side authorization and direct venue credentials.

## Performing Trading Actions

Most mutating operations follow the **create → authorize → execute** pattern. Client-only `session` setup actions are completed directly by the provider plugin and skip the execute round trip:

```mermaid theme={null}
sequenceDiagram
    participant App as Consumer App
    participant SDK as Perps SDK
    participant API as LI.FI Perps API
    participant DEX as Perps Venue

    App->>SDK: placeOrder(params)
    SDK->>API: POST /createAction
    API-->>SDK: ActionStep[]
    SDK->>SDK: Authorize via wallet or provider plugin
    SDK->>API: POST /executeAction (except session steps)
    API->>DEX: Submit to chain
    DEX-->>API: Result
    API-->>SDK: results[]
    SDK-->>App: ExecuteActionResponse
```

Trading actions use the registered plugin's `SDK` authorization path: a Hyperliquid agent, a Lighter native key, or an Ondo HMAC key. The wallet is used only when an action descriptor declares `USER`, such as setup signatures, SIWE, EVM deposits, and Hyperliquid transfers or withdrawals. Always follow `ProviderAction.signers` and `signingMethod` rather than inferring a credential from the venue name.

## Next steps

* [Getting Started](/getting-started) — Install and configure the SDK
* [Concepts](/concepts/action-pattern) — Understand the action pattern, streaming, and multi-provider support
* [SDK / Trading](/sdk/trading/placing-orders) — Place your first order
* [SDK / Streaming](/sdk/streaming) — Subscribe to live market data and user events via WebSocket
