← 返回
未分类

Liberfi Perpetuals

Query and trade perpetual futures through LiberFi's unified perpetuals API (openapi-server → perpetuals-server, Hyperliquid in MVP): list coins and markets,...
通过 LiberFi 的统一永续 API(openapi‑server → perpetuals‑server,Hyperliquid 在 MVP 中)查询并交易永续期货:列出币种和市场,...
bombmod
未分类 clawhub v1.1.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 381
下载
💾 1
安装
1
版本
#latest

概述

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 wallet

address (0x) as the positional argument. For first-person queries

("我的持仓", "my positions", etc.), the skill MUST auto-resolve the user's

TEE EVM address via lfi statuslfi login key (if needed) →

lfi whoami → use the returned evmAddress. 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 status then lfi login key) — the server's TEE wallet signs and broadcasts on the user's behalf. The atomic deposit-quote / deposit-submit escape hatches do not require auth but the caller is then responsible for signing the SOL tx and broadcasting it themselves.

Skill routing

User intentSkill
---------------------
Spot swap, bridge, gas sendliberfi-swap
Trending spot tokens, new listingsliberfi-market
Polymarket / Kalshiliberfi-predict
Spot token audit, DEX pools for a tokenliberfi-token
Perp markets, HL-style orderbook, perp positionsliberfi-perpetuals
Funding the perp account (Solana → Hyperliquid via Relay), checking deposit lifecycleliberfi-perpetuals
Spot wallet holdings on a chain (not perp account)liberfi-portfolio

CLI index

CommandDescription
----------------------
lfi perpetuals coinsList tradable perp coins
lfi perpetuals marketsMarket snapshots (--symbols optional)
lfi perpetuals market Single market
lfi perpetuals orderbook L2 book (--max-level)
lfi perpetuals trades Recent trades (--limit)
lfi perpetuals klines Candles (--interval required)
lfi perpetuals positions
Positions + margin summary
lfi perpetuals orders
Open orders
lfi perpetuals fills
Fill history
lfi perpetuals order-prepareBuild typed data for place order
lfi perpetuals order-submit --body ''Submit signed place order
lfi perpetuals cancel-prepareBuild typed data for cancel
lfi perpetuals cancel-submit --body ''Submit signed cancel
lfi perpetuals deposit-place --gross-lamports Recommended: TEE one-click Solana → Hyperliquid deposit (server quotes, signs, broadcasts, submits). Auth required.
lfi perpetuals deposit-quote --user-solana-address --hyperliquid-recipient --gross-lamports Escape hatch step 1: returns unsigned SOL tx + breakdown. Caller signs + broadcasts within ~30s, then calls deposit-submit.
lfi perpetuals deposit-submit --body ''Escape hatch step 2: record the broadcasted SOL tx hash. Idempotent on solanaTxHash.
lfi perpetuals deposit-status [--refresh]Read deposit lifecycle. --refresh bypasses any server-side cache (server-reserved knob; today both endpoints behave identically).

Common flags: --provider (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:

  1. Authenticate (only first time): lfi status --json; if not logged in,

lfi login key --role AGENT --name "" --json.

  1. Confirm intent with the user (amount in SOL, recipient if non-default).
  2. Place: lfi perpetuals deposit-place --gross-lamports --json
    • lamports = SOL × 1_000_000_000 (1 SOL = 1e9 lamports).
    • --hyperliquid-recipient is optional — defaults to the user's TEE

EVM address (lfi whoami evmAddress), which is what 99% of users want.

  1. Capture the returned intentId and solanaTxHash.
  2. Poll: lfi perpetuals deposit-status --json until

status is settled (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

  1. lfi perpetuals markets --json
  2. Present symbol, mark price, funding where present.

Depth + tape

  1. lfi perpetuals orderbook BTC --json
  2. lfi perpetuals trades BTC --limit 20 --json

Positions for a known wallet

  1. 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:**

  1. Check session: lfi status --json
  2. If not authenticated: lfi login key --role AGENT --name "OpenClawAgent" --json
  3. Fetch TEE wallet address: lfi whoami --json → returns evmAddress

(the user's TEE EVM address managed by the LiberFi server).

  1. Run the matching query with the EVM address as the positional arg:
    • Positions: lfi perpetuals positions --json
    • Open orders: lfi perpetuals orders --json
    • Fill history: lfi perpetuals fills --limit 20 --json
  2. 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)

  1. lfi perpetuals order-prepare --user-address 0x… --symbol BTC --side long --order-type limit --amount 0.01 --price 95000 --json
  2. User signs returned typedData with their wallet (e.g. MetaMask eth_signTypedData_v4).
  3. Build SignedAction: action, nonce, signature (0x), optional vaultAddress from prepare response.
  4. 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).

版本历史

共 1 个版本

  • v1.1.1 当前
    2026-05-07 08:45 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Liberfi Token

bombmod
Research and analyze tokens on supported blockchains: search tokens by keyword, get token details (price, market cap, vo
★ 0 📥 384

Liberfi Market

bombmod
发现热门代币和支持的区块链上新上线的代币:按链和时间窗口查看热门代币排名,寻找新上线的代币
★ 0 📥 401

Liberfi Predict

bombmod
浏览和交易预测市场:筛选和搜索活动列表,查看活动详情和嵌入市场,查看Kalshi和Polyma上的USDC余额...
★ 0 📥 416