liberfi-perpetuals
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLiberFi Perpetuals
LiberFi Perpetuals
Perpetuals data and signed order relay flow via LiberFi OpenAPI ( → ).
/v1/perpetuals/…perpetuals-server通过LiberFi OpenAPI( → )实现永续合约数据查询与签名订单转发流程。
/v1/perpetuals/…perpetuals-serverPre-flight
前置准备
See bootstrap.md for CLI install and .
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
CLI安装及操作请参考bootstrap.md。
lfi ping- 只读端点(币种、市场、订单簿等):无需认证。
- 用户范围只读操作(、
positions、orders):需传入钱包fills(0x开头)作为位置参数。对于第一人称查询(如“我的持仓”、“my positions”等),技能必须通过address→lfi status(如需) →lfi login key自动解析用户的TEE EVM地址,并使用返回的lfi whoami。绝对不要向用户索要地址——TEE钱包由服务器管理,用户并不知晓该地址。evmAddress - 订单写入操作(/
order-prepare及撤单变体):需要用户钱包对类型数据进行签名;代理不得伪造签名。order-submit - 入金(推荐使用):需要认证(
deposit-place后执行lfi status)——服务器的TEE钱包代表用户签名并广播交易。原子化的lfi login key/deposit-quote备选方案无需认证,但调用者需自行签署SOL交易并广播。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 |
| 用户意图 | 技能 |
|---|---|
| 现货兑换、跨链桥、Gas转账 | liberfi-swap |
| 热门现货代币、新上线代币 | liberfi-market |
| Polymarket/Kalshi预测市场 | liberfi-predict |
| 现货代币审计、代币的DEX资金池 | liberfi-token |
| 永续合约市场、HL风格订单簿、永续持仓 | liberfi-perpetuals |
| 永续合约账户入金(Solana → Hyperliquid via Relay)、查询入金生命周期 | liberfi-perpetuals |
| 链上现货钱包持仓(非永续合约账户) | liberfi-portfolio |
CLI index
CLI命令索引
| 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. |
Common flags: (e.g. ), global .
--provider <name>hyperliquid--json| 命令 | 描述 |
|---|---|
| 列出可交易的永续合约币种 |
| 市场快照(可选 |
| 单个市场详情 |
| L2订单簿(可选 |
| 近期成交记录(可选 |
| K线数据(必填 |
| 持仓及保证金汇总 |
| 当前挂单 |
| 成交历史 |
| 构建下单所需的类型数据 |
| 提交已签名的下单请求 |
| 构建撤单所需的类型数据 |
| 提交已签名的撤单请求 |
| 推荐:TEE一键式Solana → Hyperliquid入金(服务器报价、签名、广播、提交)。需要认证。 |
| 备选方案步骤1:返回未签名的SOL交易及明细。调用者需在约30秒内签名并广播,然后执行 |
| 备选方案步骤2:记录已广播的SOL交易哈希。基于 |
| 查询入金生命周期。 |
通用参数:(例如),全局参数。
--provider <name>hyperliquid--jsonFunding / Deposit (Solana → Hyperliquid via Relay)
入金流程(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): ; 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
Server returns immediately after step 3; the
reconciliation loop progresses through (or states). On failure consult the
and fields for the recoverable / non-
recoverable distinction.
status: "broadcasted"relay_waiting → relay_pending → settledfailed_*statusHistory[]lastErrorFor 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 did not succeed), see
reference/deposit-flow.md.
submit入金管道通过Relay桥接服务将SOL从用户的Solana钱包转移至用户的Hyperliquid永续合约账户。推荐使用一键式TEE自动流程:
- 认证(仅首次需要):;若未登录,执行
lfi status --json。lfi login key --role AGENT --name "<agent>" --json - 与用户确认意图(SOL金额,非默认接收方需确认)。
- 发起入金:
lfi perpetuals deposit-place --gross-lamports <lamports> --json- (1 SOL = 1e9 lamports)。
lamports = SOL × 1_000_000_000 - 为可选参数——默认值为用户的TEE EVM地址(
--hyperliquid-recipient),99%的用户使用默认值即可。lfi whoami evmAddress
- 记录返回的和
intentId。solanaTxHash - 轮询状态:,直到
lfi perpetuals deposit-status <intentId> --json变为status(通常耗时30–120秒)。settled
步骤3执行后,服务器立即返回;对账流程会依次经历(或状态)。若失败,请查看和字段判断是否可恢复。
status: "broadcasted"relay_waiting → relay_pending → settledfailed_*statusHistory[]lastError关于原子化备选方案(当用户在TEE外自行控制SOL私钥,或SOL交易已广播但未成功的部分失败恢复场景),请参考reference/deposit-flow.md。
submitTypical flows
典型流程
Market overview
市场概览
lfi perpetuals markets --json- Present symbol, mark price, funding where present.
lfi perpetuals markets --json- 展示交易对、标记价格、资金费率(若有)。
Depth + tape
深度行情与成交记录
lfi perpetuals orderbook BTC --jsonlfi perpetuals trades BTC --limit 20 --json
lfi perpetuals orderbook BTC --jsonlfi perpetuals trades BTC --limit 20 --json
Positions for a known wallet
已知钱包的持仓查询
lfi perpetuals positions 0xYourAddr --json
lfi perpetuals positions 0xYourAddr --json
"My ..." auto-flow (CRITICAL — covers "我的", "my", "我自己")
“我的...”自动流程(重要——覆盖“我的”、“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: → 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.
The user does not know their EVM address — the LiberFi server holds the TEE
wallet. The skill must resolve "我" → TEE wallet via , transparently.
whoami若用户说“我有什么永续持仓”、“我的合约持仓”、“my perp positions”、“我在 Hyperliquid 上挂了哪些单”、“我永续盈亏”、“show my fills”或任何第一人称变体——请勿向用户索要钱包地址。请严格执行以下步骤:
- 检查会话状态:
lfi status --json - 若未认证:
lfi login key --role AGENT --name "OpenClawAgent" --json - 获取TEE钱包地址:→ 返回
lfi whoami --json(LiberFi服务器管理的用户TEE EVM地址)。evmAddress - 执行匹配查询,将EVM地址作为位置参数传入:
- 持仓:
lfi perpetuals positions <evmAddress> --json - 当前挂单:
lfi perpetuals orders <evmAddress> --json - 成交历史:
lfi perpetuals fills <evmAddress> --limit 20 --json
- 持仓:
- 展示结果。若持仓/挂单/成交记录为空,请直接告知用户——不要使用其他地址重试;对于全新的TEE钱包,空结果是正确响应。
用户不知道自己的EVM地址——LiberFi服务器持有TEE钱包。技能必须通过透明地将“我”解析为TEE钱包。
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
lfi perpetuals order-prepare --user-address 0x… --symbol BTC --side long --order-type limit --amount 0.01 --price 95000 --json- 用户使用钱包对返回的进行签名(例如MetaMask的
typedData)。eth_signTypedData_v4 - 构建:包含
SignedAction、action、nonce(0x开头),可选signature来自prepare响应。vaultAddress - 获得明确确认后:
lfi perpetuals order-submit --body '{"action":…,"nonce":…,"signature":"0x…"}' --json
API path reminder
API路径提示
All CLI calls hit OpenAPI paths under , which the gateway proxies to perpetuals-server . Configure the gateway with (default local example: — avoid colliding with openapi and prediction ; run perpetuals-server with when colocated).
/v1/perpetuals/…/v1/…UPSTREAM_PERPETUALS_SERVICE_BASE_URLhttp://localhost:8083:8080:8082SERVER_PORT=8083所有CLI调用均指向OpenAPI路径,网关会将请求代理至perpetuals-server的路径。请使用配置网关(默认本地示例:——避免与openapi的和预测服务的冲突;当部署在同一服务器时,请使用启动perpetuals-server)。
/v1/perpetuals/…/v1/…UPSTREAM_PERPETUALS_SERVICE_BASE_URLhttp://localhost:8083:8080:8082SERVER_PORT=8083