Hyperliquid (read-only)
Implement read-only market-data queries for Hyperliquid using the Info HTTP endpoint:
Prefer HTTP snapshot flows for v1. WebSocket streaming can be added later.
Supported user input styles
Treat these as equivalent:
- - Natural language: “Hyperliquid quote BTC”, “top movers 24h”, “book ETH”, “1h candles for SOL last 48”
- Terminal style:
hl quote BTC, INLINECODE3 - Slash style:
/hl quote BTC, INLINECODE5
Parse /hl and hl first (deterministic). If no prefix, fall back to intent extraction from natural language.
Canonical commands (v1)
Market data:
- -
quote <coin>: show mark/mid/oracle, 24h change (prevDayPx), 24h notional volume, open interest (perps), funding (perps), premium, impact prices - INLINECODE9 : rank by 24h % change (markPx vs prevDayPx)
- INLINECODE10 : rank by funding (perps only)
- INLINECODE11 : show top 20 levels per side (and spread)
- INLINECODE12
- INLINECODE13 : concise dashboard: top movers, top funding, top OI, top volume
Account (read-only):
- -
positions <HL:0x..|0x..|label>: show perp positions + margin summary - INLINECODE15 : show spot balances
- INLINECODE16 : show open orders
- INLINECODE17 : show recent fills
Saved account aliases (stored locally in ~/.clawdbot/hyperliquid/config.json):
- - INLINECODE19
- INLINECODE20
- INLINECODE21
- INLINECODE22
Natural language equivalents should work too:
- - “store this address HL:0x... as sub account 1”
- “show me positions of sub account 1”
Data sources
Perpetuals:
- -
metaAndAssetCtxs (preferred): universe + asset contexts for all perps - INLINECODE24
- INLINECODE25
Spot (optional later):
- -
spotMetaAndAssetCtxs, INLINECODE27
See references/hyperliquid-api.md for request bodies and field meanings.
Implementation guidance
Use the bundled scripts:
- -
scripts/hyperliquid_api.mjs: thin HTTP client + helpers (safe defaults, timeouts) - INLINECODE30 : parses user text into an intent + args, calls API helpers, and prints a compact chat-friendly response
When responding:
- - Prefer short bullet output.
- Show units and timeframes.
- Handle missing fields gracefully (e.g., midPx sometimes null).
Quick manual test
Run locally:
CODEBLOCK0
Hyperliquid(只读)
使用 Info HTTP 端点实现 Hyperliquid 的只读市场数据查询:
- - POST https://api.hyperliquid.xyz/info
- Content-Type: application/json
对于 v1 版本,优先使用 HTTP 快照 流程。WebSocket 流式传输可后续添加。
支持的用户输入风格
以下输入视为等效:
- - 自然语言:Hyperliquid 报价 BTC、24小时最大涨跌幅、ETH 订单簿、SOL 最近48小时1小时K线
- 终端风格:hl quote BTC、hl movers --top 10 --window 24h
- 斜杠风格:/hl quote BTC、/hl overview
优先解析 /hl 和 hl(确定性)。若无前缀,则回退到从自然语言中提取意图。
标准命令(v1)
市场数据:
- - quote <币种>:显示标记价/中间价/预言机价、24小时变化(prevDayPx)、24小时名义交易量、未平仓合约(永续合约)、资金费率(永续合约)、溢价、影响价格
- movers [--window 24h] [--top N]:按24小时百分比变化排序(markPx vs prevDayPx)
- funding-top|funding-bottom [--n N]:按资金费率排序(仅永续合约)
- book <币种>:显示每侧前20档(及价差)
- candles <币种> --interval <1m|...|1M> (--last N | --start <毫秒> --end <毫秒>)
- overview:简洁仪表盘:最大涨跌幅、最高资金费率、最高未平仓合约、最高交易量
账户(只读):
- - positions :显示永续合约持仓 + 保证金摘要
- balances :显示现货余额
- orders :显示未成交订单
- fills [--n N]:显示近期成交记录
已保存账户别名(本地存储于 ~/.clawdbot/hyperliquid/config.json):
- - account list
- account add 子账户1 HL:0x... [--default]
- account remove 子账户1
- account default 子账户1
自然语言等效表达也应支持:
- - 将此地址 HL:0x... 存储为子账户1
- 显示子账户1的持仓
数据源
永续合约:
- - metaAndAssetCtxs(推荐):所有永续合约的资产列表及上下文
- l2Book
- candleSnapshot
现货(可选,后续添加):
- - spotMetaAndAssetCtxs、spotMeta
请求体及字段含义详见 references/hyperliquid-api.md。
实现指南
使用内置脚本:
- - scripts/hyperliquidapi.mjs:轻量级 HTTP 客户端 + 辅助函数(安全默认值、超时设置)
- scripts/hyperliquidchat.mjs:将用户文本解析为意图 + 参数,调用 API 辅助函数,输出简洁的聊天友好响应
响应时:
- - 优先使用简短列表输出。
- 显示单位和时间范围。
- 优雅处理缺失字段(例如,midPx 有时为 null)。
快速手动测试
本地运行:
bash
node skills/hyperliquid/scripts/hyperliquid_chat.mjs hl quote BTC
node skills/hyperliquid/scripts/hyperliquid_chat.mjs /hl movers --top 5