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

# Hyperliquid

> Trade BTC and ETH perpetuals on Hyperliquid from your own account: the one-time lock, funding, what the agent can do, and what is not live yet

**In short:** your account on HyperEVM is your Hyperliquid account. You sign one lock that caps the money, the leverage and the price band. The agent then deposits, opens, closes and cancels orders on BTC and ETH perpetuals from your account, inside that lock. Nothing is sent to an address of ours, and the agent cannot withdraw to anyone but your own account.

Hyperliquid works differently from Binance and Lighter. Your money does not sit with an outside key. Your own account contract holds the Hyperliquid account, and orders are queued on chain. Read [trading venues](https://docs.defiloops.com/venues/overview.md) first for the security model all venues share.

> [!NOTE]
>
> An order can carry a take-profit price and a stop-loss price. After the fill, the agent places reduce-only trigger orders at those prices. Setting, moving or cancelling take-profit and stop-loss on a position that is already open is **not available yet**. For funding, hourly rates and open interest, see the [Hyperliquid data page](https://docs.defiloops.com/data/hyperliquid.md).

## Set up once

You do this on the Hyperliquid page in the app.

1. **Sign the lock** with your wallet. It sets:
   * **a cap**, the most USDC that may go to Hyperliquid
   * **the highest leverage**, from 1x to 5x
   * **which perps**: BTC, ETH or both
   * **a price band** for opening orders, 200 basis points by default and at most 1,000
2. **Our fee payer sends the lock** on HyperEVM. You pay no gas and need no HYPE.
3. **The trading key connects itself** after your first deposit lands. The key is derived inside the enclave from a sealed secret, so it is never stored. Your account registers it as its Hyperliquid API wallet. It lives about 90 days and is then replaced, never reused.

Margin is **isolated only**. Cross margin is refused. Nothing loosens the lock unless you sign again.

## Fund it

USDC on HyperEVM is not margin. Margin is USDC on Hyperliquid's own ledger, and only a deposit step puts it there.

* **From Base, Arbitrum or Ethereum:** bridge USDC to your account on HyperEVM, then deposit. A card does both: `bridge 100 USDC to HyperEVM`, then `move it to Hyperliquid`.
* **From your wallet:** the app can send USDC straight into your Hyperliquid account. You need USDC and HYPE (for gas) on HyperEVM.
* **The first deposit costs 1 USDC.** Hyperliquid charges it to open a new account, so send at least 2 USDC the first time. Size your margin from what arrives, not from what you sent.
* **The credit arrives a moment later**, not in the same transaction. Place the order as a second step after it lands.

Only USDC moves, and only into your own account at Hyperliquid. A deposit is refused if the total sent would pass your cap. **A loss at Hyperliquid never frees room under the cap.** Only a withdrawal home lowers what counts as sent.

## What you can trade

* **Markets:** BTC and ETH perpetuals. Nothing else. No spot, vaults, sub-accounts, TWAP or builder fees.
* **Leverage:** 1x up to your lock's ceiling, 5x at most. The trading key sets it before the order.
* **Take-profit and stop-loss:** set when you create the order. Not available yet for a position that is already open.
* **Order types:** *post only* (rests on the book and never takes), *good till cancelled* (rests until filled or cancelled) and *immediate or cancel* (fills what it can now).
* **Minimum order:** \$10 of size times price. Below it Hyperliquid rejects the order after the transaction succeeds, so a card with a smaller opening order is refused when you save it.
* **Price:** an opening price must sit inside your lock's band around the market price when the order is placed. A price better for you passes however far it is.
* **Size:** a whole number of lots. An off-lot size is refused and never rounded.

There is **no position limit, no notional limit and no order-count limit**. The lock is the limit: the cap, the leverage ceiling, the markets and the band.

### Queued is not filled

Orders go on chain and Hyperliquid takes them a few seconds later. Hyperliquid can still reject one. The receipt looks the same either way. The app says an order is placed only when a fill shows.

## As a card

See [writing a card](https://docs.defiloops.com/cards/writing.md) for the language. On Hyperliquid:

```
move 200 USDC to Hyperliquid
open a 3x long ETH perp with 200 USDC at $3,000
close my ETH perp at $2,400
close 50% of my ETH perp at $2,400
move 200 USDC back from Hyperliquid
```

An opening order can add a take-profit price and a stop-loss price, in dollars. In chat you can give a percentage, and the chat converts it to a price. Each card writes its prices. A card with no price, such as "at most 1% below market", is refused. A card that waits on a condition or a clock is refused too: "open a long if funding turns negative" and "buy every day" are not cards on Hyperliquid yet. Fund and open are two separate cards that each run once.

## Close, cancel and withdraw

* **Close** is a reduce-only, immediate-or-cancel order. You can close all or part of a position. The worst price must be within 2% of the market. It needs no lock and no grant, so it works even if the lock is gone.
* **Cancel** cancels one resting order. You can switch cancel off for your account. Then only you cancel, from the app.
* **Withdraw** brings USDC home to your account on HyperEVM. From margin it takes **two runs**: the first moves margin to spot, the second sends it. A small reserve of 0.01 USDC stays behind for Hyperliquid's fee. Margin held by an open position cannot be withdrawn, so close first.

During an emergency halt, new deposits, opening orders and new connections are refused. Close, cancel and withdraw still run.

## Reading your account

The app does not show your Hyperliquid positions, orders or balance yet. Read them on Hyperliquid's own site at your account's address on HyperEVM. The Hyperliquid page in the app shows your lock.

## Taking control back

* **Tighten the lock.** Set the cap to zero or turn the markets off. New deposits and orders stop at once. Closes, cancels and withdrawals stay open.
* **Close and withdraw** from the app, as above.
* **Remove the trading key.** Your wallet is the root authority of your account. It can make your account call Hyperliquid's own system contracts itself: cancel, close, remove the key, withdraw and bridge home. We have **not** built a page that prepares those calls for Hyperliquid. Lighter has one. Today this takes a developer.

## What the trading key can and cannot do

The trading key signs only a short list of actions: set leverage and margin, place take-profit and stop-loss triggers after a fill, and cancel its own triggers. It has no opening order. It cannot withdraw, send or transfer, because Hyperliquid itself does not let an agent key do those. Opening orders come from your account, on chain, inside the lock.

| if this is compromised | it could | it could not |
| - | - | - |
| our servers | delay requests, ask for orders your lock allows | place an order outside the lock, bind a key of its own |
| the agent's signing key | open orders inside the price band and leverage ceiling, cancel orders, close at prices the chain bounds, move money between your account and its own Hyperliquid account | open outside the lock, send money to anyone else |
| the enclave, if a bad build were approved | mis-set leverage on a new position inside your ceiling, place or remove a trigger | open a position through the trading key, withdraw |
| Hyperliquid itself | halt, delist, settle at its own prices | move your funds without your account |

The worst case is a bounded loss. Bad-priced opens stay inside your band and ceiling. Total money sent stays under the cap you signed. It is not zero. See [the weakest link](https://docs.defiloops.com/venues/overview.md#the-weakest-link-stated-plainly).

## Under the hood

*For readers who want the mechanism.*

* Your account contract on HyperEVM is the Hyperliquid account. Its address is the account's address on Hyperliquid's own ledger.
* Orders are queued by the account itself through Hyperliquid's system contract. That is why they arrive a few seconds late.
* The lock is a contract on HyperEVM. It stores the cap, leverage, markets and band. The write needs your signature and a receipt from the enclave for the trading key it binds.
* The cap counts USDC sent. The deposit operation checks it on chain.
* The trading key is registered once, ever. A revoked key is never registered again, so its old signed actions cannot be replayed.
* Order ids are derived from your account and the task, so a retry finds the same order.
* Hyperliquid operations on HyperEVM went live on the 3-day delay described on [the contracts](https://docs.defiloops.com/protocol.md).


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