How every action works
- Prepare. Call the endpoint for the action: an order, a leverage change, a withdrawal. It returns
typed_data,actionandnonce. - Sign. The user signs
typed_dataas EIP-712 typed data in their wallet. Nothing is broadcast. - Execute. Send
action,nonceand thesignaturetoPOST /v2/perpetual_trading/execute. Compass forwards it to Hyperliquid and returns the result.
Before you start
- An API key. See the Quick Start.
- An Arbitrum wallet of your own, holding ETH for gas. Deposits go through Hyperliquid’s bridge on Arbitrum, and your wallet sends that transaction. Keep its key on your server.
1. Deposit USDC
The user signs a USDC permit, and your wallet sends the bridge transaction on Arbitrum.1
Get the permit
2
Send the bridge transaction
Pass the user’s signature to The response is a
POST /v2/perpetual_trading/deposit/sponsor_prepare:transaction for your sponsor wallet to sign and send on Arbitrum. Hyperliquid credits the user’s account once it confirms. Check withdrawable on the positions endpoint before showing the deposit as complete.2. One-time setup per user
- Account mode. Call
POST /v2/perpetual_trading/enable_unified_account. Iftyped_dataisnull, there’s nothing to do. Otherwise the user signs it and you execute it. - Leverage. Call
POST /v2/perpetual_trading/set_leveragewithassetandleveragebefore the first order on each asset. Leave outleverageto use the market’s maximum. Ifleverage_okistrue, there’s nothing to sign. Leverage stays set per asset until you change it. - Your fee. If you charge a fee, the user approves your builder address once. See Charge a fee.
3. Place an order
Buy 1 AAPL contract at market, then execute the signed action:
For a limit order, call
POST /v2/perpetual_trading/limit_order with a price and time_in_force (gtc or alo), and cancel it with POST /v2/perpetual_trading/cancel_order. Both follow the same sign-and-execute steps.
4. Track positions
side, size, entry_price, mark_price, liquidation_price, leverage, unrealized_pnl and funding_accrued. The response also carries account_value and withdrawable, the USDC the user can take out. For fills and open orders as well, use GET /v2/perpetual_trading/activity. For price charts, use GET /v2/perpetual_trading/candles.
5. Withdraw
CallPOST /v2/perpetual_trading/withdraw with owner and amount, and optionally a destination on Arbitrum. The user signs and you execute it. The USDC arrives on Arbitrum once Hyperliquid processes the withdrawal, which takes from minutes to a few hours.
Charge a fee
Hyperliquid lets you add a builder fee to your users’ fills. It’s charged on top of Hyperliquid’s own fee and credited in USDC to an address you control.- Approve once per user. Call
POST /v2/perpetual_trading/approve_builder_feewithbuilder: {"address": "0xYourBuilderAddress", "max_fee_rate": "0.01%"}. The user signs and you execute it. To raise the rate later, approve again. Lowering it needs no new approval. - Add
builderto each order. Pass the sameaddressand amax_fee_rateat or below what the user approved. Orders withoutbuilderpay no fee. - Read what you earned. Each fill in
activitycarries itsbuilder_fee, andbuilder_approvalshows the user’s current approval when you pass yourbuilderaddress.
0.1%, in steps of 0.001%. The builder address must be a regular wallet holding at least 100 USDC in its Hyperliquid perps account before the first approval; otherwise execute returns 502 Builder has insufficient balance to be approved. Fees accumulate in that address’s Hyperliquid account under the xyz DEX, separate from its main perps balance. Your users, their fills and their approval state also appear on the Hyperliquid tab of your dashboard.
Good to know
- Higher leverage means a closer liquidation price. Hyperliquid checks leverage when a position opens. Watching
liquidation_priceand margin afterwards is up to you. - Markets.
GET /v2/perpetual_trading/opportunitieslists every market withmark_price,funding_rate,max_leverage, open interest and volume. Filter bycategory:stock,commodityorforex. - Funding. Positions pay or receive funding every hour. It shows per position as
funding_accrued. - Rejected actions.
executereturnsstatus: "error"with Hyperliquid’s message, for example when margin is insufficient. Show it to the user.
Endpoints
Next
Tokenized Assets
Real tokenized stocks and RWAs, held as ERC-20s.
Crypto-Backed Loans
Borrow USDC against crypto to fund trading.
Bridging
Move USDC to Arbitrum from another chain.