/install liberfi-perpetuals
LiberFi Perpetuals
Perpetuals data and signed order relay flow via LiberFi OpenAPI (/v1/perpetuals/… → perpetuals-server).
Pre-flight
See bootstrap.md for CLI install and lfi ping.
- Read endpoints (coins, markets, orderbook, …): no auth.
- User-scoped reads (
positions,orders,fills): pass the walletaddress(0x) as the positional argument. For first-person queries ("我的持仓", "my positions", etc.), the skill MUST auto-resolve the user's TEE EVM address vialfi status→lfi login key(if needed) →lfi whoami→ use the returnedevmAddress. NEVER ask the user for an address — the TEE wallet is server-managed and the user does not know it. - Order writes (
order-prepare/order-submit, cancel variants): require a user wallet to sign typed data; agents must not fabricate signatures. - Deposit (recommended
deposit-place): requires authentication (lfi statusthenlfi login key) — the server's TEE wallet signs and broadcasts on the user's behalf. The atomicdeposit-quote/deposit-submitescape hatches do not require auth but the caller is then responsible for signing the SOL tx and broadcasting it themselves.
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 |
|---|---|
lfi perpetuals coins |
List tradable perp coins |
lfi perpetuals markets |
Market snapshots (--symbols optional) |
lfi perpetuals market \x3Csymbol> |
Single market |
lfi perpetuals orderbook \x3Csymbol> |
L2 book (--max-level) |
lfi perpetuals trades \x3Csymbol> |
Recent trades (--limit) |
lfi perpetuals klines \x3Csymbol> |
Candles (--interval required) |
lfi perpetuals positions \x3Caddress> |
Positions + margin summary |
lfi perpetuals orders \x3Caddress> |
Open orders |
lfi perpetuals fills \x3Caddress> |
Fill history |
lfi perpetuals order-prepare |
Build typed data for place order |
lfi perpetuals order-submit --body '\x3Cjson>' |
Submit signed place order |
lfi perpetuals cancel-prepare |
Build typed data for cancel |
lfi perpetuals cancel-submit --body '\x3Cjson>' |
Submit signed cancel |
lfi perpetuals deposit-place --gross-lamports \x3Cn> |
Recommended: TEE one-click Solana → Hyperliquid deposit (server quotes, signs, broadcasts, submits). Auth required. |
lfi perpetuals deposit-quote --user-solana-address \x3Ca> --hyperliquid-recipient \x3Ca> --gross-lamports \x3Cn> |
Escape hatch step 1: returns unsigned SOL tx + breakdown. Caller signs + broadcasts within ~30s, then calls deposit-submit. |
lfi perpetuals deposit-submit --body '\x3Cjson>' |
Escape hatch step 2: record the broadcasted SOL tx hash. Idempotent on solanaTxHash. |
lfi perpetuals deposit-status \x3CintentId> [--refresh] |
Read deposit lifecycle. --refresh bypasses any server-side cache (server-reserved knob; today both endpoints behave identically). |
Common flags: --provider \x3Cname> (e.g. hyperliquid), global --json.
Funding / Deposit (Solana → Hyperliquid via Relay)
The deposit pipeline moves SOL from the user's Solana wallet to the user's Hyperliquid perp account via the Relay bridge service. The recommended path is the one-click TEE auto-flow:
- Authenticate (only first time):
lfi status --json; if not logged in,lfi login key --role AGENT --name "\x3Cagent>" --json. - Confirm intent with the user (amount in SOL, recipient if non-default).
- Place:
lfi perpetuals deposit-place --gross-lamports \x3Clamports> --jsonlamports = SOL × 1_000_000_000(1 SOL = 1e9 lamports).--hyperliquid-recipientis optional — defaults to the user's TEE EVM address (lfi whoami evmAddress), which is what 99% of users want.
- Capture the returned
intentIdandsolanaTxHash. - Poll:
lfi perpetuals deposit-status \x3CintentId> --jsonuntilstatusissettled(typical: 30–120 s).
Server returns status: "broadcasted" immediately after step 3; the
reconciliation loop progresses through relay_waiting → relay_pending → settled (or failed_* states). On failure consult the
statusHistory[] and lastError fields for the recoverable / non-
recoverable distinction.
For the atomic escape-hatch flow (when the user controls their own SOL
private key outside the TEE, or recovering from a partial failure where
the SOL tx has been broadcasted but submit did not succeed), see
reference/deposit-flow.md.
Typical 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", "我自己")
If the user says "我有什么永续持仓", "我的合约持仓", "my perp positions", "我在 Hyperliquid 上挂了哪些单", "我永续盈亏", "show my fills" or any first-person variant — DO NOT ask for a wallet address. Run this exact sequence:
- Check session:
lfi status --json - If not authenticated:
lfi login key --role AGENT --name "OpenClawAgent" --json - Fetch TEE wallet address:
lfi whoami --json→ returnsevmAddress(the user's TEE EVM address managed by the LiberFi server). - Run the matching query with the EVM address as the positional arg:
- Positions:
lfi perpetuals positions \x3CevmAddress> --json - Open orders:
lfi perpetuals orders \x3CevmAddress> --json - Fill history:
lfi perpetuals fills \x3CevmAddress> --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.
The user does not know their EVM address — the LiberFi server holds the TEE
wallet. The skill must resolve "我" → TEE wallet via whoami, transparently.
Place 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
typedDatawith their wallet (e.g. MetaMasketh_signTypedData_v4). - Build
SignedAction:action,nonce,signature(0x), optionalvaultAddressfrom prepare response. - After explicit confirmation:
lfi perpetuals order-submit --body '{"action":…,"nonce":…,"signature":"0x…"}' --json
API path reminder
All CLI calls hit OpenAPI paths under /v1/perpetuals/…, which the gateway proxies to perpetuals-server /v1/…. Configure the gateway with UPSTREAM_PERPETUALS_SERVICE_BASE_URL (default local example: http://localhost:8083 — avoid colliding with openapi :8080 and prediction :8082; run perpetuals-server with SERVER_PORT=8083 when colocated).
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install liberfi-perpetuals - 安装完成后,直接呼叫该 Skill 的名称或使用
/liberfi-perpetuals触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Liberfi Perpetuals 是什么?
Query and trade perpetual futures through LiberFi's unified perpetuals API (openapi-server → perpetuals-server, Hyperliquid in MVP): list coins and markets,... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 107 次。
如何安装 Liberfi Perpetuals?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install liberfi-perpetuals」即可一键安装,无需额外配置。
Liberfi Perpetuals 是免费的吗?
是的,Liberfi Perpetuals 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Liberfi Perpetuals 支持哪些平台?
Liberfi Perpetuals 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Liberfi Perpetuals?
由 bombmod(@bombmod)开发并维护,当前版本 v1.1.1。