|
| 1 | +# Perpetuals (Hyperliquid) — @phantom/cli |
| 2 | + |
| 3 | +The Phantom CLI exposes a full suite of perpetuals commands backed by [Hyperliquid](https://hyperliquid.xyz/). This document covers each command, its options, and common workflows. |
| 4 | + |
| 5 | +When running in MCP server mode (`phantom --mcp`), all commands are exposed as MCP tools under the `perps_` prefix. |
| 6 | + |
| 7 | +## Command Reference |
| 8 | + |
| 9 | +### `phantom perps markets` — MCP: `perps_markets` |
| 10 | + |
| 11 | +List all available perpetual markets on Hyperliquid with current prices, funding rates, open interest, 24h volume, max leverage, and asset IDs. Use this to discover tradeable markets and get current prices before opening positions. |
| 12 | + |
| 13 | +**Options:** none required |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +### `phantom perps account` — MCP: `perps_account` |
| 18 | + |
| 19 | +Get your perpetuals account balance including total account value, available balance, and withdrawable amount. The account is funded with USDC on Hyperliquid. |
| 20 | + |
| 21 | +**Options:** |
| 22 | + |
| 23 | +- `--walletId` (optional) — wallet ID, defaults to authenticated wallet |
| 24 | +- `--derivationIndex` (optional) — derivation index, default 0 |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +### `phantom perps positions` — MCP: `perps_positions` |
| 29 | + |
| 30 | +Get your open perpetual positions including entry price, mark price, unrealized PnL, and margin used. |
| 31 | + |
| 32 | +**Options:** |
| 33 | + |
| 34 | +- `--walletId` (optional) |
| 35 | +- `--derivationIndex` (optional) |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +### `phantom perps orders` — MCP: `perps_orders` |
| 40 | + |
| 41 | +Get your open perpetual orders (resting limit orders waiting to be filled). |
| 42 | + |
| 43 | +**Options:** |
| 44 | + |
| 45 | +- `--walletId` (optional) |
| 46 | +- `--derivationIndex` (optional) |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +### `phantom perps history` — MCP: `perps_history` |
| 51 | + |
| 52 | +Get your perpetual trade history (filled orders). |
| 53 | + |
| 54 | +**Options:** |
| 55 | + |
| 56 | +- `--walletId` (optional) |
| 57 | +- `--derivationIndex` (optional) |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### `phantom perps open` — MCP: `perps_open` |
| 62 | + |
| 63 | +Open a perpetual position on Hyperliquid. Supports market and limit orders in long or short direction. The position size is specified in USD. |
| 64 | + |
| 65 | +**Options:** |
| 66 | + |
| 67 | +- `--market` — market symbol, e.g. `BTC`, `ETH`, `SOL` |
| 68 | +- `--direction` — `long` or `short` |
| 69 | +- `--sizeUsd` — position size in USD (e.g. `100` for $100 notional) |
| 70 | +- `--leverage` — leverage multiplier (e.g. `1` for 1x, `10` for 10x) |
| 71 | +- `--orderType` — `market` or `limit` |
| 72 | +- `--limitPrice` (required for limit orders) — the limit price |
| 73 | +- `--marginType` — `isolated` (default) or `cross` |
| 74 | +- `--reduceOnly` (optional) — if set, can only reduce an existing position |
| 75 | +- `--walletId` (optional) |
| 76 | +- `--derivationIndex` (optional) |
| 77 | + |
| 78 | +**Notes:** |
| 79 | + |
| 80 | +- Run `phantom perps markets` first to verify the market symbol and current price. |
| 81 | +- Market orders apply a 10% slippage buffer automatically. |
| 82 | +- Requires USDC in the perps account. Use `phantom perps deposit` then `phantom perps transfer` if needed. |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +### `phantom perps close` — MCP: `perps_close` |
| 87 | + |
| 88 | +Close an open perpetual position. Submits a market order in the opposite direction to fully close the position. |
| 89 | + |
| 90 | +**Options:** |
| 91 | + |
| 92 | +- `--market` — market symbol of the position to close |
| 93 | +- `--walletId` (optional) |
| 94 | +- `--derivationIndex` (optional) |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +### `phantom perps cancel` — MCP: `perps_cancel` |
| 99 | + |
| 100 | +Cancel an open perpetual order by order ID. |
| 101 | + |
| 102 | +**Options:** |
| 103 | + |
| 104 | +- `--orderId` — the order ID to cancel |
| 105 | +- `--market` — market symbol of the order |
| 106 | +- `--walletId` (optional) |
| 107 | +- `--derivationIndex` (optional) |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +### `phantom perps leverage` — MCP: `perps_leverage` |
| 112 | + |
| 113 | +Update the leverage multiplier for a market without changing any positions. |
| 114 | + |
| 115 | +**Options:** |
| 116 | + |
| 117 | +- `--market` — market symbol |
| 118 | +- `--leverage` — new leverage multiplier |
| 119 | +- `--marginType` — `isolated` or `cross` |
| 120 | +- `--walletId` (optional) |
| 121 | +- `--derivationIndex` (optional) |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +### `phantom perps transfer` — MCP: `perps_transfer` |
| 126 | + |
| 127 | +Move USDC from the Hyperliquid spot account into the perpetuals account. This is an internal Hyperliquid transfer — both accounts live on Hypercore (Hyperliquid's chain). |
| 128 | + |
| 129 | +**Options:** |
| 130 | + |
| 131 | +- `--amountUsdc` — amount of USDC to transfer (e.g. `100`) |
| 132 | +- `--walletId` (optional) |
| 133 | +- `--derivationIndex` (optional) |
| 134 | + |
| 135 | +**Note:** USDC must already be in your Hyperliquid spot account. Use `phantom perps deposit` to bridge tokens from external chains first. |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +### `phantom perps deposit` — MCP: `perps_deposit` |
| 140 | + |
| 141 | +Bridge tokens from an external chain (Solana, Arbitrum, Base, Ethereum, Polygon) into Hyperliquid as USDC via a cross-chain swap. USDC is delivered to your Hyperliquid spot account. Run `phantom perps transfer` afterwards to move it into the perp account. |
| 142 | + |
| 143 | +**Options:** |
| 144 | + |
| 145 | +- `--sourceChainId` — CAIP-2 source chain ID (e.g. `solana:mainnet`, `eip155:42161` for Arbitrum, `eip155:8453` for Base) |
| 146 | +- `--amount` — amount to send in human-readable units (e.g. `100` for 100 USDC) |
| 147 | +- `--sellTokenMint` (optional) — token to sell on source chain; defaults to USDC on source chain |
| 148 | +- `--sellTokenIsNative` (optional) — set to sell native SOL or ETH |
| 149 | +- `--execute` — omit to preview quote only; pass `--execute` to sign and broadcast |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +### `phantom perps withdraw` — MCP: `perps_withdraw` |
| 154 | + |
| 155 | +Bridge USDC from the Hyperliquid perpetuals account to an external chain (Solana, Base, Ethereum, Arbitrum, Polygon) via the Relay bridge. |
| 156 | + |
| 157 | +**Options:** |
| 158 | + |
| 159 | +- `--amountUsdc` — amount of USDC to withdraw (e.g. `50`) |
| 160 | +- `--destinationChainId` — CAIP-2 destination chain (e.g. `solana:mainnet`, `eip155:8453` for Base) |
| 161 | +- `--buyToken` (optional) — CAIP-19 token to receive; defaults to USDC on destination chain |
| 162 | +- `--walletId` (optional) |
| 163 | +- `--derivationIndex` (optional) |
| 164 | + |
| 165 | +**Note:** Run `phantom perps account` to check the withdrawable balance before withdrawing. |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +## Common Workflows |
| 170 | + |
| 171 | +### Fund and open a position |
| 172 | + |
| 173 | +```bash |
| 174 | +# 1. Bridge USDC from Solana to Hyperliquid spot |
| 175 | +phantom perps deposit --sourceChainId solana:mainnet --amount 100 --execute |
| 176 | + |
| 177 | +# 2. Move USDC from Hyperliquid spot into perps account |
| 178 | +phantom perps transfer --amountUsdc 100 |
| 179 | + |
| 180 | +# 3. Check available markets and current price |
| 181 | +phantom perps markets |
| 182 | + |
| 183 | +# 4. Open a long position |
| 184 | +phantom perps open --market BTC --direction long --sizeUsd 100 --leverage 5 --orderType market |
| 185 | + |
| 186 | +# 5. Verify the position |
| 187 | +phantom perps positions |
| 188 | +``` |
| 189 | + |
| 190 | +### Close and withdraw |
| 191 | + |
| 192 | +```bash |
| 193 | +# 1. Check open positions |
| 194 | +phantom perps positions |
| 195 | + |
| 196 | +# 2. Close the position |
| 197 | +phantom perps close --market BTC |
| 198 | + |
| 199 | +# 3. Check withdrawable balance |
| 200 | +phantom perps account |
| 201 | + |
| 202 | +# 4. Bridge USDC back to Solana |
| 203 | +phantom perps withdraw --amountUsdc 100 --destinationChainId solana:mainnet |
| 204 | +``` |
| 205 | + |
| 206 | +### Place and manage a limit order |
| 207 | + |
| 208 | +```bash |
| 209 | +# 1. Place a limit order |
| 210 | +phantom perps open --market ETH --direction long --sizeUsd 50 --leverage 3 --orderType limit --limitPrice 3000 |
| 211 | + |
| 212 | +# 2. Check the order is on the book |
| 213 | +phantom perps orders |
| 214 | + |
| 215 | +# 3. Cancel the order if needed |
| 216 | +phantom perps cancel --orderId <orderId> --market ETH |
| 217 | +``` |
0 commit comments