Onboarding to Portfolio Margin
Portfolio Margin (PM) is live on production and open to every account. It margins your options and your Hyperliquid perps together on worst-case portfolio risk, so a hedged book needs far less collateral than it does under Standard Margin. This page covers how to get onto it. For how the margin itself is calculated, see Portfolio Margin.
In short: use a new manager wallet, create its Hypercall account, turn on HyperCore unified account mode, switch to Portfolio mode, and only then deposit.
Why you start from a new wallet
A Standard Margin (SM) account with a balance or an open book cannot be flipped to Portfolio Margin in place. Hypercall accepts a switch to Portfolio mode only when all of these hold for the manager wallet:
| Requirement | What it means |
|---|---|
| Exactly one Hypercall account | The manager controls one Account contract. None, or more than one, is rejected. |
| Zero Standard balance | The wallet's Standard Margin cash balance is zero. Any withdrawable balance blocks the switch. |
| Flat | No open positions and no open orders, on the manager wallet or its Account. |
These rules exist because the two modes are different kinds of account, not one account with a setting:
- Your collateral is held differently. Moving from Standard to Portfolio Margin means moving your funds, not flipping a switch.
- Positions are margined under different rules. An open position would have to be re-margined from one set of rules to the other.
- So the switch happens from an empty account. Doing both safely in one step is not supported, which is why the account must be flat and empty first.
Margin mode is set per manager wallet, so one wallet cannot run both modes. The simplest path is a fresh manager wallet for PM, which lets your existing SM account keep quoting while you set up. You can also empty your existing wallet (close everything, cancel all orders, withdraw all Standard cash) and switch it, but you cannot keep that SM book running meanwhile.
Before you start
- A new manager wallet (an EOA you control, ideally on a hardware or otherwise secured key).
- HYPE on HyperEVM in that wallet, for the account creation deposit plus gas.
- The USDC you plan to use as collateral.
Setup steps
Do these in order. Step 4 must come before step 5.
-
Create a new manager wallet. Do not reuse your SM manager, an API wallet, or an agent key.
-
Create your Hypercall account. From the manager wallet, call
createAccount(salt)on the Factory contract with the HYPE creation deposit. This deploys your Account contract and activates it on HyperCore. See Onboarding (contracts). Create only one account for this manager. -
Turn on HyperCore unified account mode for the Account. Submit the
hl_set_abstractionaction, signed by the manager wallet, withuserset to your Account address andabstractionset to2(unified account).POST /v1/actions/hl_set_abstraction/typed-datareturns the exact typed data to sign, andPOST /v1/actions/hl_set_abstractionsubmits it. Wait until HyperCore reports the Account asunifiedAccount. Hyperliquid's other account modes, including its own portfolio margin mode, are not supported. -
Switch to Portfolio mode. Send
POST /margin-modewithwalletset to your manager address andmargin_modeset toportfolio, signed by the manager wallet (see Authentication). The response returns your Account address as the PM wallet. Do this before depositing: while a wallet is still in Standard mode, a Hypercall deposit is credited as Standard cash, and that balance then blocks the switch until you withdraw it again. -
Deposit USDC into your Account. Deposit through the app, which routes by margin mode, or send USDC on HyperCore to your Account address. The funds count toward margin once Hypercall's next HyperCore snapshot shows them.
-
Set up your signing keys. Approvals on your old SM wallet do not carry over.
- Options (REST): approve your trading key for the new manager wallet with
POST /approve-agent. See Agent Authorization. - Perps (on-chain directives): register an API wallet on your Account with the manager-signed
hc_update_api_walletaction. An API wallet can be active on only one Account. See EIP-712 Signing.
- Options (REST): approve your trading key for the new manager wallet with
-
Trade. Keep sending your manager address as
walleton options requests; Hypercall routes them to your PM account. Order types, the order API, and signing are the same as on Standard Margin. For Hyperliquid perps from the app, see Perps on Hypercall.
In the app, choosing Portfolio under Settings > Margin Mode opens a setup checklist. Complete its Approve your trading agent step first: Enable stays disabled until that approval is in place. The Enable step then runs steps 2 to 4 for you: it creates the account if you have none, turns on unified account mode, and switches the mode.
Hypercall values a PM account from its HyperCore equity, which HyperCore only publishes for Accounts in unified account mode. If the Account is not in that mode, step 4 is refused with 400 pm_account_not_unified. Complete step 3, wait for HyperCore to confirm the mode, then retry.
If an Account later leaves unified account mode, portfolio reads return 503 pm_account_equity_pending (or 409 pm_account_not_unified if HyperCore never published equity for it), and orders fail with an error like missing HyperCore account equity for PM wallet 0x.... Re-enable unified account mode to fix it. See Errors & Rejection Reasons.
FAQ
Can I keep my Standard Margin account running? Yes. Onboard PM on a new manager wallet and leave your SM account as it is.
Why was my margin-mode switch rejected?
The error names the rule: the wallet has no Account (or more than one), it has a Standard balance, it has open positions or orders, or the Account is not yet in HyperCore unified account mode (pm_account_not_unified). See Why you start from a new wallet.
I deposited before switching. What now? The deposit was credited as Standard cash. Withdraw it, then switch to Portfolio mode and deposit into your Account.
Do I need new API keys? You need new approvals. Options agent approvals are tied to the manager wallet, so approve your key again for the new one. A perps API wallet can be active on only one Account, so use a new key or remove it from your old Account first (step 6).
Where do I learn how PM margin, liquidation, and settlement work? See Portfolio Margin, PM Margin Worked Examples, Margin Floor, Liquidation, and Settlement.