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

# Perps

> Non-custodial perpetual futures on Hyperliquid, live today through the Perps API, and how the Trade API adds Lighter and maps onto it.

Perps are live today through the Perps API, which offers non-custodial perpetual futures on Hyperliquid, including markets that track stock prices. Users sign their own deposits and withdrawals. Orders are signed by the user's wallet or by an optional trading key that your app creates and holds; that key can trade but cannot withdraw. Yield.xyz submits the signed orders to Hyperliquid, and your project can earn a builder fee on every fill once you configure one. [Perps API today](#perps-api-today) covers the live API.

The Trade API trades perps as `perps` markets with `buy` to go long, `sell` to go short and `manage` to close or adjust a position. Three integrations are in its first set:

| Integration | What it is | Collateral |
| - | - | - |
| `hyperliquid-perps` | Hyperliquid's main perpetual dex | USDC on Hyperliquid |
| `hyperliquid-xyz-perps` | The HIP-3 builder-deployed `xyz` dex on Hyperliquid. Other builder dexes become further integrations of the same kind | USDC on Hyperliquid |
| `lighter-perps` | Lighter, a ZK rollup on Ethereum | USDC on Lighter |

`hyperliquid-xyz-perps` markets are perpetual contracts, including ones that track an equity's price. They are not share ownership and are not part of [Tokenized Stocks](https://docs.yield.xyz/documentation/trade/tokenized-stocks.md).

> [!WARNING]
>
> Perps trading carries jurisdictional restrictions. Read the [perpetuals disclaimer](https://docs.yield.xyz/legal/perpetuals-disclaimer.md) before integrating.

> [!NOTE]
>
> The Trade API is not live yet. Hyperliquid perps are live today through the Perps API: see [Perps API today](#perps-api-today) for the mapping between the two. Names and shapes on this page can change before launch.

## Opening and closing a position

`buy` opens or adds to a long and `sell` opens or adds to a short. The opposite side reduces the position, and an order that would flip it is rejected. A market ID such as `hyperliquid-btc-usdc` or `lighter-eth-usdc` comes from `GET /v1/markets?integrationId=`.

* `amount` is margin in the collateral token; `quantity` is contracts in the base asset. Pass exactly one. Reducing always uses `quantity`.
* `leverage` must sit inside the market's leverage range. `marginMode` is `cross` or `isolated` and cannot change while a position or order is open.
* Without `orderType` the order is a market order, filled as an immediate-or-cancel limit at the worst price allowed by `maxSlippageBps`. Set `orderType: "limit"` with a `limitPrice` for a resting good-till-canceled order.
* `takeProfitPrice` and `stopLossPrice` on the same request attach a take profit and a stop loss to the entry in one action.
* `reduceOnly: true` guarantees the order only shrinks the position.

`manage closePosition` closes a market's position with a reduce-only market order. Omit `quantity` to close it in full:

```json theme={null}
POST /v1/actions/manage
{
  "action": "closePosition",
  "marketId": "hyperliquid-btc-usdc",
  "address": "0xAb5C...",
  "arguments": {}
}
```

## Managing a position

| Action | What it does |
| - | - |
| `setTpSl` | Sets, replaces or cancels the position's take profit and stop loss (`null` cancels, an omitted field is left unchanged) |
| `updateLeverage` | Changes leverage, and the margin mode while no position or order is open |
| `updateMargin` | Adds margin to an isolated position |
| `cancelOrder` | Cancels a resting order by `orderId` |

Editing an order is planned; until then, cancel and place a new order. Positions, orders and balances carry `pendingActions` with these requests prefilled, so you can send them as they are.

## Funding and account setup

Simulate lists what a user needs before their first trade, in order: funding, then the fee approval, then an optional trading key. Each comes back as a pending action.

* `manage fund` deposits collateral into the venue account. On Hyperliquid, USDC on Arbitrum goes to the Hyperliquid bridge and is credited in about a minute. Funds on another chain or token come back as a `funding` requirement with the pending action to complete first.
* `manage withdraw` sends collateral back to the owner's address.
* `manage approveBuilderFee` approves your project's fee once per user. The first `buy` includes it automatically.
* `manage approveAgent` registers a trading key your client generated and holds. After it, orders need no wallet prompt. The key is optional on Hyperliquid and required on Lighter.
* `manage setUnifiedAccount` switches a Hyperliquid account to shared collateral across perps, spot and HIP-3 dexes. The first `buy` includes it where it is needed.

## Hyperliquid

The user's EVM address is the account, with no creation step. Every transaction is EIP-712 typed data (`signingFormat: eip712_typed_data`, `submissionTarget: venue`). Orders, cancels, leverage and margin changes are signed by the owner wallet or by an approved trading key; `approveAgent`, `approveBuilderFee`, `withdraw` and `setUnifiedAccount` are always signed by the owner. The venue returns each order's outcome on submit (resting, filled or rejected), so the transaction is `CONFIRMED` as soon as it is accepted. Positions, balances, orders, fills, candles and the order book are all public, so no read grant is needed.

## Lighter

Lighter is a ZK rollup on Ethereum that is coming with the Trade API. Every Lighter order is signed by a Lighter API key that your client holds, so a trading key is required, and setup is funding, then the trading key, then fees. Yield.xyz publishes the details when Lighter goes live.

## Perps API today

Hyperliquid perps are live through the Perps API at `https://perps.yield.xyz/v1`, with the providers `hyperliquid` and `hyperliquid-xyz`. Integrate it today through the [Perps guide](https://docs.yield.xyz/guides/perps/index.md), the [Quickstart](https://docs.yield.xyz/documentation/get-started/quickstart.md#perps-api) and the [Perps API reference](https://docs.yield.xyz/api-reference/perps-api/discovery/list-providers.md). The Trade API is the next version of the Perps API, and every Perps API operation except `editOrder` has a direct equivalent in it:

| Perps API | Trade API |
| - | - |
| Providers `hyperliquid`, `hyperliquid-xyz` | Integrations `hyperliquid-perps`, `hyperliquid-xyz-perps` |
| Market ID `{providerId}-{coin}-{quote}` | Market ID `{integration prefix}-{base}-{quote}`, such as `hyperliquid-btc-usdc` |
| `POST /v1/actions` with `action` and `args` | `POST /v1/actions/buy`, `/sell` or `/manage` with `arguments` |
| `open` with `side: long` or `short`, `amount` or `size` | `buy` or `sell` with `amount` (margin) or `quantity` (contracts) |
| `open` with `limitPrice`, `stopLossPrice`, `takeProfitPrice` | `buy` or `sell` with `orderType: limit` and `limitPrice`, `stopLossPrice`, `takeProfitPrice` |
| `close` | `manage closePosition`, with optional `quantity` |
| `updateLeverage`, `updateMargin` | `manage updateLeverage`, `manage updateMargin` |
| `stopLoss`, `takeProfit`, `setTpAndSl` | `manage setTpSl` |
| `editOrder` | Planned; cancel and place a new order meanwhile |
| `cancelOrder` | `manage cancelOrder` |
| `fund` with `fromToken` | `manage fund` |
| `withdraw`, `approveAgent`, `approveBuilderFee`, `setUnifiedAccount` | The same names under `manage` |
| `POST /v1/positions`, `POST /v1/orders`, `POST /v1/balances` | `GET /v1/positions`, `GET /v1/orders`, `GET /v1/balances` with `address` and `integrationId` |
| `GET /v1/events`, `GET /v1/activity` | `GET /v1/fills` |

On the Perps API today, `POST /v1/actions` returns `403` when the caller's IP is in a banned region and `403` `EXECUTE_FORBIDDEN` when your project is disabled for the provider or for Perps. See [Perps API objects](https://docs.yield.xyz/api-reference/perps-api/objects.md) for its error codes.

## Geo-restrictions

Actions and simulate return `403` for requests from a banned region, and integrations and markets disclose `restrictedJurisdictions` so you can filter before showing them. Venue rejections are returned to you as they are. See [Geo-blocking](https://docs.yield.xyz/documentation/advanced-setup/geo-blocking/index.md) for how bans are configured.

## Monetization

Perps orders carry your project's builder fee on Hyperliquid, from 0.01% to 0.1% of each fill, or its partner fee on Lighter. See [Monetization](https://docs.yield.xyz/documentation/trade/monetization.md).

## Ready-made interfaces

To launch Perps without building your own UI, host the [Perps widget](https://docs.yield.xyz/guides/widgets-dashboard/perps-widget.md) or the [Perps dashboard](https://docs.yield.xyz/guides/widgets-dashboard/perps-dashboard.md). The widget is a compact module for an existing screen. The dashboard is a full desktop trading terminal. Both run on the Perps API with your project key.

## Next steps

> [card] [Perps guide](https://docs.yield.xyz/guides/perps/index.md)
>
> Open a position end to end on the live Perps API: find a market, open, sign, submit, check positions.

> [card] [Core concepts](https://docs.yield.xyz/documentation/trade/core-concepts/index.md)
>
> Integrations, markets, arguments, simulate, signing and statuses on the Trade API.

> [card] [Perps API reference](https://docs.yield.xyz/api-reference/perps-api/discovery/list-markets.md)
>
> Every live Perps API endpoint, argument schema and response field.

> [card] [Perpetuals disclaimer](https://docs.yield.xyz/legal/perpetuals-disclaimer.md)
>
> Jurisdictional restrictions that apply to perps trading.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.