Why This Matters
Building a global-markets trading product on-chain means integrating with perp DEXes, handling EIP-712 signing flows, managing deposits and withdrawals across bridges, and tracking positions with funding rates. We’ve done that - you get one API that covers everything to get your trading product live in days.What It Does
Let users trade stocks (AAPL, TSLA, NVDA, etc.), commodities (GOLD, OIL, NATGAS), and forex pairs (EUR, GBP, JPY) as perpetual futures. Build products that offer leveraged exposure to stock, commodity, and forex markets, portfolio diversification beyond crypto, or automated trading strategies - all through a single API. You call our API, we return EIP-712 typed data. Your users sign off-chain (no gas needed for trades). Users trade real-world assets on-chain, you capture fees. How it works: Global Markets runs on Hyperliquid’s builder-deployed perpetual futures DEX. Users deposit USDC on Arbitrum, which bridges to Hyperliquid where they can trade perps tracking real-world asset prices.Supported Assets
Assets are organized into three categories:| Category | Examples |
|---|---|
| Stocks | AAPL, TSLA, NVDA, AMZN, GOOGL, META, MSFT, and more |
| Commodities | GOLD, SILVER, OIL, NATGAS, COPPER, URANIUM, CORN |
| Forex | EUR, GBP, JPY, AUD, CAD, CHF, CNH |
/v2/global_markets_perps/opportunities endpoint to get the full live list with open interest, 24h volume, funding rates, and max leverage for each market.
Getting Started
1. Deposit USDC
Depositing is a two-step flow with two different actors:- Compass prepares the permit (gasless for the end-user). Your client calls
POST /v2/global_markets_perps/depositand Compass returns an EIP-2612 permit struct. The end-user signs it off-chain — no gas, no Arbitrum tx from their wallet. - You broadcast the bridge tx (you pay the gas). With the signed permit, you call
batchedDepositWithPermiton Hyperliquid’s Bridge2 contract on Arbitrum (0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7) from a sponsor wallet you fund. Hyperliquid’s validators watch Bridge2 events and credit the user’s HL trading account automatically — no/exchangecall is needed.
The gas sponsor for the bridge tx is your wallet, not Compass. Compass does not run a sponsor key on Arbitrum for this product. Pre-fund an Arbitrum hot wallet with enough ETH for bridge gas before going live, and keep its private key in your server-side secrets.
Step 1 — get the permit
Request (POST /v2/global_markets_perps/deposit):
owner— the end-user’s EOA address on Arbitrumamount— USDC amount to deposit, human-readable (e.g."100")
permit— EIP-712 typed data for the USDC permit; pass to the user’s wallet for signingamount_raw— USDC amount in raw 6-decimal units; pass to the bridge call in Step 2destination— the address that will be credited on Hyperliquid (equals the deposit owner EOA — HL keys accounts by EVM address)
Step 2 — broadcast the bridge tx
CallPOST /v2/global_markets_perps/deposit/sponsor_prepare. Compass returns a fully-encoded unsigned Bridge2.batchedDepositWithPermit tx. You sign and broadcast it from your sponsor wallet on Arbitrum — no ABI/encoding work on your side, no Compass-side key custody.
Request:
owner— the user’s EOA address on Arbitrum (the permit signer)amount_raw— from the/depositresponse in Step 1deadline— frompermit.message.deadlinein the Step 1 responsesignature— the user’s signed permit (65-byte hex, 0x-prefixed)sender— your sponsor wallet address on Arbitrum (setsfromandnonceon the returned tx)
transaction— an unsigned Arbitrum tx; sign with your sponsor key and submit via any RPC
2. One-Time Setup
Before placing the first trade, two one-time actions are needed: Enable Unified Account - Call/v2/global_markets_perps/enable_unified_account to check and enable unified margin mode. If already enabled, returns null typed data (no action needed).
Approve Builder Fee - Call /v2/global_markets_perps/approve_builder_fee to authorize the builder address that should receive trading fees from this end-user’s orders, naming a maximum fee rate. Sign the returned EIP-712 data and submit via /execute. The builder block is required on this endpoint — the Compass customer specifies the address and rate. The full setup, viewing flow, and troubleshooting live in the Collecting Builder Fees section below.
3. Place Orders
Market Order:/v2/global_markets_perps/limit_order with a price parameter and optional time_in_force (GTC or ALO). Same sign-and-execute flow.
Cancel Order:
Call /v2/global_markets_perps/cancel_order with the order ID to cancel an open limit order.
4. Execute Signed Actions
All prepare endpoints (market_order, limit_order, cancel_order, withdraw, approve_builder_fee) return EIP-712 typed data. After the user signs, submit the signature to the execute endpoint:5. Track Positions
Call/v2/global_markets_perps/positions to get open positions with size, entry price, mark price, PnL, liquidation price, leverage, and cumulative funding.
Collecting Builder Fees
When your users open positions, every fill on Hyperliquid charges a trading fee. By attaching abuilder block to each order, that fee is
routed to an address you control. You choose the rate (up to whatever
each end-user has authorized), Hyperliquid pays the fee on settlement,
and the USDC accumulates on your builder address — no custody, no
invoicing.
Mental Model
Hyperliquid enforces builder fees with a strict two-rule consent model:One-time consent (per end-user, per builder)
Before any order with a
builder field will be accepted, the
end-user must sign an approveBuilderFee action naming your
builder address and the maximum rate they authorize. This
signature is submitted once and recorded on the L1 order book.Where do the trades actually happen? Global Markets runs on
Hyperliquid’s xyz HIP-3 builder DEX — an off-chain order book on
Hyperliquid L1. The fills and fee payments live entirely on L1, not on
HyperEVM (HL’s EVM chain). This is why you will not find any of this on
Arbiscan / Etherscan / hyperevmscan.io — see Where to see your fees.
Prerequisites
Checklist before your first trade:- Builder address — a regular EOA you control. Don’t use a smart-contract address unless you’ve validated HL accepts it.
- Builder pre-funding — deposit ≥100 USDC into the builder’s
Hyperliquid perps account. Use the HL UI, an L1 transfer from another
HL account, or bridge from Arbitrum through Bridge2 + a
usdClassTransferaction. - End-user margin — the end-user must have enough USDC margin on HL
to actually place the order. Compass provides
/v2/global_markets_perps/depositfor the Arbitrum → HL bridge step.
TypeScript Walkthrough
Pin the SDK to a tested release and point at staging while validating:(end-user, builder) pair. To later charge a higher
rate, re-run with a larger maxFeeRate — the user signs again. Lower
rates require no re-approval.
Step 2 — Place an order that pays the fee
builder field is accepted on globalMarketsPerpsLimitOrder.
cancel_order and withdraw do not take a builder field — fees are
charged on fills only.
Step 3 — Verify the fee was earmarked
builderFee figure here is what HL has earmarked. The actual
credit to your builder address may post later — see Settlement
Timing.
Where to See Your Fees
Because Hyperliquid trades live on an off-chain L1 order book, there is no Etherscan-style transaction trace for the fee payment. Use the right view for the level you care about: 1. Lifetime totals —userFees info API. Updates as soon as HL
recognizes the fee.
feesEarnedAsBuilder / builderFees / similar — Hyperliquid
adds builder-specific roll-ups incrementally, exact key names vary by
release.
2. Current spendable balance — clearinghouseState.
userNonFundingLedgerUpdates. Every
non-funding balance change on your builder address.
https://app.hyperliquid.xyz/portfolio/0xYOUR_BUILDER_ADDRESS — there’s
a DEX selector at the top (defaults to “Main”); switch to xyz to see
balances there.
5. Compass dashboard. Every end-user attributed to your API key shows
up in the Hyperliquid tab at https://compasslabs.ai/dashboard/hyperliquid
with their positions, recent fills (each fill carries builder_fee), and
their current approval state.
Settlement Timing
ThebuilderFee field on a fill is earmarked the instant the trade
matches, but the credit to your builder address may post later:
- Immediate — credit appears in
clearinghouseState(xyz-DEX-scoped) within seconds. - Hourly settlement — HL settles certain HIP-3 builder-fee accruals
at the funding interval (top of each UTC hour). If your trade was at
15:27 UTCand you query at15:35 UTC, the credit may not have posted yet. Re-check after16:00 UTC.
userFees is the most reliable “did HL recognize the fee at all?”
signal — it ticks up regardless of when the credit posts to your balance.
Economics
For a single fill:feeon the fill — total fee charged to the end-user, in USDC.builderFeeon the fill — portion offeeearmarked for your builder, in USDC. Equalsfee × (builder.max_fee_rate / total_user_fee_rate).- The remainder of
feeaccrues to Hyperliquid (validators / DEX operator).
max_fee_rate = "0.01%" (1bp) the typical split is roughly:
| Component | Approximate share |
|---|---|
| Builder fee → your address | ~54% of the gross fee |
| HL validator + xyz DEX fee | ~46% of the gross fee |
Withdrawing Your Fees
Builder fees accumulate as USDC margin on your builder’s HL perps account (xyz-DEX-scoped for Global Markets). To move them to Arbitrum:- Transfer USDC from the xyz DEX-scoped perps account to the main perps
account (HL
usdClassTransferwithdex: "xyz"). - Withdraw from HL to Arbitrum via Compass’s
/v2/global_markets_perps/withdraw(sign +/execute), or via HL’s own UI / Python SDK. - The withdrawal arrives as a Bridge2 USDC
Transferto your builder address on Arbitrum — this step shows up on Arbiscan.
Troubleshooting
`/execute` returns 502 with 'Builder has insufficient balance to be approved'
`/execute` returns 502 with 'Builder has insufficient balance to be approved'
Your builder address has less than 100 USDC margin on its HL perps
account. Pre-fund it once with ≥100 USDC and retry. Verify with:The runnable test script (see below) pre-flights this check before
asking the user to sign anything.
`/execute` returns 502 with 'Builder fee not approved'
`/execute` returns 502 with 'Builder fee not approved'
The end-user hasn’t signed an
approveBuilderFee for this builder
address, or the rate on the order exceeds the approved max. Either
re-run Step 1 with a higher maxFeeRate, or lower the per-order
maxFeeRate on the order itself.Pre-check with /activity?builder=…:The fill shows `builderFee: 0.000893` but my builder balance hasn't moved
The fill shows `builderFee: 0.000893` but my builder balance hasn't moved
Two most likely causes:
- DEX scope — query
clearinghouseStatewithdex: "xyz". The fee landed on the xyz-DEX-scoped account, not main perps. - Settlement timing — HL may settle the credit at the next hourly funding interval. Re-query after the next UTC hour rolls.
userFees info call is the canary: it ticks up as soon as HL
recognizes the fee, regardless of where/when the balance credit
posts.I can't see the fee on Etherscan / Arbiscan / hyperevmscan
I can't see the fee on Etherscan / Arbiscan / hyperevmscan
Expected — Global Markets trades happen on HL’s off-chain L1 order
book, not on any EVM chain. No EVM transaction is emitted for the
fee. Use the HL
info API queries or
https://app.hyperliquid.xyz/portfolio/0xYOUR_BUILDER_ADDRESS (xyz
DEX selector) instead.My builder address is a smart contract / Safe / Privy wallet
My builder address is a smart contract / Safe / Privy wallet
HL builder approval is keyed to a regular EOA. Multisigs and contract
wallets may not be honoured as builders. Use a controlled EOA whose
private key you can rotate (e.g. a dedicated treasury EOA, or a
sub-account on the customer’s wallet provider).
Runnable Test Script
A complete TypeScript script that exercises the full approve-then-trade-then-verify flow against staging lives atapi/scripts/examples/builder-fees
in the monorepo. It pre-flights the builder-funding rule, signs both
typed-data payloads with viem, polls /activity for the resulting fill,
and prints the collected fee.
Key Concepts
Perpetual Futures - These are not spot tokens. Users trade perps that track real-world asset prices. Positions accrue funding rates and can be leveraged. EIP-712 Signing - Unlike Yield or Credit which return unsigned Ethereum transactions, Global Markets returns EIP-712 typed data for Hyperliquid’s off-chain order system. Users sign off-chain and submit signatures - no gas is needed for trades. Prepare + Execute Flow - Every action follows a two-step flow: (1) call a prepare endpoint to get EIP-712 typed data, (2) user signs, (3) call/execute with the signature.
USDC on Arbitrum - Deposits and withdrawals use USDC on Arbitrum, bridged to/from Hyperliquid.
Use Cases
Brokerage App: Build a stock trading app where users trade stock perps with crypto. Show familiar stock tickers, price charts, and portfolio views while executing trades on-chain. Example: User deposits 1,000 USDC, buys 2 AAPL perps at 200 each. AAPL rises 5%, user’s position is worth 1,020. Close position for 20 profit. Diversification Tool: Let crypto-native users diversify into stock, commodity, and forex exposure without leaving the on-chain ecosystem. Offer one-click allocation across stocks, gold, and forex. Example: User allocates 10,000 USDC — 40% NVDA, 30% GOLD, 30% EUR — all as perps with a single deposit from their existing Arbitrum wallet. Automated Trading: Build bots that execute strategies across stock, commodity, and forex markets on-chain. Arbitrage between crypto and real-world asset perps, or run momentum strategies on stock perps.Next Steps
Earn
Earn yield on idle USDC while not trading.
Credit
Borrow against crypto holdings for more trading capital.
Bridging
Move assets across chains to fund your trading account.