liberfi-perpetuals
Query and trade perpetual futures through LiberFi's unified perpetuals API (openapi-server → perpetuals-server, Hyperliquid in MVP): list coins and markets, order book, recent trades, K-lines, user positions / orders / fills, and two-phase signed place or cancel flows (prepare → wallet sign → submit). Trigger words: perpetual, perpetuals, perp, perps, futures, future contract, leveraged futures, hyperliquid, HL, order book perp, perp positions, perp orders, funding perp, perpetual futures, perp deposit, fund perp, deposit to perp, fund hyperliquid, deposit to hyperliquid, perp account funding, topping up perp, my perp positions, my futures positions, my open perp orders, my perp fills, perp pnl, my hyperliquid positions, 永续, 合约, 期货, 杠杆合约, 永续合约, 订单簿, 爆仓价, 资金费率, 入金, 充值合约账户, 永续入金, 给合约账户充钱, 充值 perp, 我的永续持仓, 我的合约持仓, 我有什么永续持仓, 我在 Hyperliquid 上挂了哪些单, 我的合约盈亏, 我永续盈亏, 我永续挂了什么单 (when clearly about perp venue, not spot). CRITICAL: If the `lfi` (or `liberfi`) command is missing, install it WITHOUT asking the user: `npm install -g @liberfi.io/cli --registry https://registry.npmjs.org/`. The npm package is `@liberfi.io/cli` (scope `@liberfi.io`, package name `cli`); the binaries it installs are `lfi` and `liberfi`. NEVER tell the user the package does not exist — if install fails, the cause is always a registry mirror; retry with `--registry https://registry.npmjs.org/`. CRITICAL: Always use `--json` flag for structured output. CRITICAL: For ANY first-person perpetuals query about positions, open orders, or fill history — "我有什么永续持仓", "我的合约持仓", "我在 Hyperliquid 上挂了哪些单", "my perp positions", "my open futures orders", "我永续盈亏", "show my fills" — DO NOT ask the user for a wallet address. Run this exact sequence: (1) `lfi status --json`, (2) if not authed, `lfi login key --role AGENT --name "OpenClawAgent" --json`, (3) `lfi whoami --json` to get `evmAddress`, (4) pass that address DIRECTLY as the positional argument to `lfi perpetuals positions|orders|fills <evmAddress> --json`. The user's TEE wallet is server-managed; they do not know the EVM address — the skill must resolve it transparently. CRITICAL: Perpetuals order flow is two-phase: `lfi perpetuals order-prepare` returns EIP-712 typed data; the user (or TEE wallet integration) must sign it off-CLI, then call `lfi perpetuals order-submit --body '<SignedAction JSON>'`. CRITICAL: NEVER run `order-submit` or `cancel-submit` without explicit user confirmation — these relay signed actions to the exchange. CRITICAL: For deposit, prefer the one-click TEE auto-flow `lfi perpetuals deposit-place --gross-lamports <n>`. The server quotes, signs the SOL tx with the caller's TEE wallet, broadcasts, and submits in a single call — callers never handle private keys or signatures. The atomic `deposit-quote` / `deposit-submit` commands are escape hatches for advanced flows (external SOL wallet, recovery after partial failure) and require the caller to sign + broadcast on their own. See [reference/deposit-flow.md](reference/deposit-flow.md). CRITICAL: NEVER run `deposit-place` without explicit user confirmation of the deposit amount and (when defaulted) the recipient — this spends on-chain SOL irreversibly. Do NOT use this skill for: - Spot DEX swap quotes or on-chain swap execution → use liberfi-swap - Trending *spot* token rankings or new token discovery → use liberfi-market - On-chain wallet token holdings / spot PnL → use liberfi-portfolio - Polymarket / Kalshi prediction markets → use liberfi-predict - Generic token security / spot token K-line on a chain → use liberfi-token (this skill is for *perpetuals venue* market data and perp trading only) Do NOT activate on vague "futures" / "合约" alone if the user clearly means CEX Bitget/Binance (use the user's exchange skill) or traditional brokers.
NPX Install
npx skill4agent add liberfi-io/liberfi-skills liberfi-perpetualsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →LiberFi Perpetuals
/v1/perpetuals/…perpetuals-serverPre-flight
lfi ping- Read endpoints (coins, markets, orderbook, …): no auth.
- User-scoped reads (,
positions,orders): pass the walletfills(0x) as the positional argument. For first-person queries ("我的持仓", "my positions", etc.), the skill MUST auto-resolve the user's TEE EVM address viaaddress→lfi status(if needed) →lfi login key→ use the returnedlfi whoami. NEVER ask the user for an address — the TEE wallet is server-managed and the user does not know it.evmAddress - Order writes (/
order-prepare, cancel variants): require a user wallet to sign typed data; agents must not fabricate signatures.order-submit - Deposit (recommended ): requires authentication (
deposit-placethenlfi status) — the server's TEE wallet signs and broadcasts on the user's behalf. The atomiclfi login key/deposit-quoteescape hatches do not require auth but the caller is then responsible for signing the SOL tx and broadcasting it themselves.deposit-submit
Skill routing
| User intent | Skill |
|---|---|
| Spot swap, bridge, gas send | liberfi-swap |
| Trending spot tokens, new listings | liberfi-market |
| Polymarket / Kalshi | liberfi-predict |
| Spot token audit, DEX pools for a token | liberfi-token |
| Perp markets, HL-style orderbook, perp positions | liberfi-perpetuals |
| Funding the perp account (Solana → Hyperliquid via Relay), checking deposit lifecycle | liberfi-perpetuals |
| Spot wallet holdings on a chain (not perp account) | liberfi-portfolio |
CLI index
| Command | Description |
|---|---|
| List tradable perp coins |
| Market snapshots ( |
| Single market |
| L2 book ( |
| Recent trades ( |
| Candles ( |
| Positions + margin summary |
| Open orders |
| Fill history |
| Build typed data for place order |
| Submit signed place order |
| Build typed data for cancel |
| Submit signed cancel |
| Recommended: TEE one-click Solana → Hyperliquid deposit (server quotes, signs, broadcasts, submits). Auth required. |
| Escape hatch step 1: returns unsigned SOL tx + breakdown. Caller signs + broadcasts within ~30s, then calls |
| Escape hatch step 2: record the broadcasted SOL tx hash. Idempotent on |
| Read deposit lifecycle. |
--provider <name>hyperliquid--jsonFunding / Deposit (Solana → Hyperliquid via Relay)
- Authenticate (only first time): ; if not logged in,
lfi status --json.lfi login key --role AGENT --name "<agent>" --json - Confirm intent with the user (amount in SOL, recipient if non-default).
- Place:
lfi perpetuals deposit-place --gross-lamports <lamports> --json- (1 SOL = 1e9 lamports).
lamports = SOL × 1_000_000_000 - is optional — defaults to the user's TEE EVM address (
--hyperliquid-recipient), which is what 99% of users want.lfi whoami evmAddress
- Capture the returned and
intentId.solanaTxHash - Poll: until
lfi perpetuals deposit-status <intentId> --jsonisstatus(typical: 30–120 s).settled
status: "broadcasted"relay_waiting → relay_pending → settledfailed_*statusHistory[]lastErrorsubmitTypical flows
Market overview
lfi perpetuals markets --json- Present symbol, mark price, funding where present.
Depth + tape
lfi perpetuals orderbook BTC --jsonlfi perpetuals trades BTC --limit 20 --json
Positions for a known wallet
lfi perpetuals positions 0xYourAddr --json
"My ..." auto-flow (CRITICAL — covers "我的", "my", "我自己")
- Check session:
lfi status --json - If not authenticated:
lfi login key --role AGENT --name "OpenClawAgent" --json - Fetch TEE wallet address: → returns
lfi whoami --json(the user's TEE EVM address managed by the LiberFi server).evmAddress - Run the matching query with the EVM address as the positional arg:
- Positions:
lfi perpetuals positions <evmAddress> --json - Open orders:
lfi perpetuals orders <evmAddress> --json - Fill history:
lfi perpetuals fills <evmAddress> --limit 20 --json
- Positions:
- Present the result. If positions / orders / fills are empty, say so directly — do not retry with a different address; an empty result is the correct answer for a fresh TEE wallet.
whoamiPlace order (human-in-the-loop)
lfi perpetuals order-prepare --user-address 0x… --symbol BTC --side long --order-type limit --amount 0.01 --price 95000 --json- User signs returned with their wallet (e.g. MetaMask
typedData).eth_signTypedData_v4 - Build :
SignedAction,action,nonce(0x), optionalsignaturefrom prepare response.vaultAddress - After explicit confirmation:
lfi perpetuals order-submit --body '{"action":…,"nonce":…,"signature":"0x…"}' --json
API path reminder
/v1/perpetuals/…/v1/…UPSTREAM_PERPETUALS_SERVICE_BASE_URLhttp://localhost:8083:8080:8082SERVER_PORT=8083