perp-cli
Multi-DEX perpetual futures trading MCP server (Pacifica, Hyperliquid, Lighter). 18 tools for market data, trade execution with dry-run safety, funding rate arbitrage, and portfolio analytics.
README
perp-cli
Multi-DEX perpetual futures CLI — Pacifica (Solana), Hyperliquid (HyperEVM), Lighter (Ethereum).
npm install -g perp-cli # global install
perp --json portfolio
# Or without global install (restricted environments)
npx -y perp-cli --json portfolio
Features
- 3 Exchanges — trade, bridge, arbitrage across Pacifica, Hyperliquid, Lighter
- Funding Rate Arb — perp-perp + spot-perp scan & one-command dual-leg execution
- Portfolio — single call returns balances, positions, risk level across all exchanges
- Funds — deposit, withdraw, CCTP bridge, internal transfer in one group
- Bots — TWAP, grid, DCA, trailing-stop with background job management
- Agent-First Design —
--json,--fields,--ndjson,--dry-run, runtime schema introspection - Safety — pre-trade validation, response sanitization, client-id deduplication
Setup
# Set exchange keys
perp wallet set hl <EVM_KEY> # Hyperliquid
perp wallet set pac <SOLANA_KEY> # Pacifica
perp wallet set lt <EVM_KEY> # Lighter (API key auto-generated)
# Verify
perp wallet show
Same EVM key works for both Hyperliquid and Lighter.
Lighter API Key Index: Indexes 0–3 are reserved by Lighter's frontend (web/mobile). perp-cli defaults to index
4. Override withLIGHTER_API_KEY_INDEXenv var or--key-indexflag onmanage setup-api-key. Valid range: 4–254.
Command Groups
| Group | Description |
|---|---|
market |
Prices, orderbook, funding, klines, HIP-3 dexes |
account |
Balance, positions, orders, margin |
trade |
Market/limit/stop orders, close, scale, split execution |
arb |
Funding rate arb — scan, exec, close, monitor (perp-perp & spot-perp) |
bot |
TWAP, grid, DCA, trailing-stop bots |
funds |
Deposit, withdraw, transfer, CCTP bridge |
bridge |
Cross-chain USDC bridge (deBridge DLN) |
risk |
Risk limits, liquidation distance, guardrails |
wallet |
Multi-wallet management & on-chain balances |
history |
Execution log, PnL, performance breakdown |
manage |
Margin mode, subaccount, API keys, builder |
portfolio |
Cross-exchange unified overview |
dashboard |
Live web dashboard |
settings |
CLI settings (referrals, defaults) |
backtest |
Strategy backtesting |
plan |
Multi-step composite execution plans |
rebalance |
Cross-exchange balance management |
jobs |
Background job management (tmux) |
alerts |
Telegram funding rate alerts with background daemon |
agent |
Schema introspection, capabilities, health check |
Core Commands
# Portfolio (balances + positions + risk across all exchanges)
perp --json portfolio
# Market data
perp --json -e <EX> market list
perp --json -e <EX> market book <SYM>
perp --json -e <EX> market mid <SYM> # fast mid-price lookup
perp --json -e <EX> market funding <SYM>
perp --json -e <EX> market kline <SYM> 1h # candlestick data
perp --json -e hl market hip3 # list HIP-3 deployed dexes
# Trading
perp --json -e <EX> trade buy <SYM> <SIZE> # shortcut for market buy
perp --json -e <EX> trade sell <SYM> <SIZE> # shortcut for market sell
perp --json -e <EX> trade market <SYM> buy <SIZE> --smart # IOC limit (less slippage)
perp --json -e <EX> trade split <SYM> buy 5000 # orderbook-aware split (large orders)
perp --json -e <EX> trade close <SYM>
perp --json -e <EX> trade flatten # close ALL positions on exchange
perp --json -e <EX> trade reduce <SYM> 50 # reduce position by 50%
perp --json -e <EX> trade cancel <SYM> # cancel by symbol (or orderId)
perp --json -e <EX> trade tpsl <SYM> long # set take-profit / stop-loss
perp --json -e <EX> trade leverage <SYM> <N>
# Account
perp --json -e <EX> account balance
perp --json -e <EX> account positions
perp --json -e <EX> account pnl # realized + unrealized + funding
perp --json -e <EX> account funding # personal funding payment history
perp --json -e <EX> account settings # per-market leverage & margin mode
# Funding rate arbitrage
perp --json arb scan --min 5 # perp-perp opportunities
perp --json arb scan --mode spot-perp # spot+perp opportunities
perp --json arb scan --rates # funding rates across all exchanges
perp --json arb scan --basis # cross-exchange basis opportunities
perp --json arb scan --gaps # cross-exchange price gaps
perp --json arb scan --hip3 # HIP-3 cross-dex funding spreads
perp --json arb scan --live # continuous live monitoring
perp --json arb exec <SYM> <longEx> <shortEx> <$> # perp-perp dual-leg entry
perp --json arb exec <SYM> spot:<exch> <perpEx> <$> # spot+perp entry
perp --json arb config # show arb defaults
perp --json arb history # past arb trade performance (alias: log)
# Funds (deposit, withdraw, transfer)
perp --json funds deposit hyperliquid 100
perp --json funds withdraw pacifica 50
perp --json funds transfer 100 <ADDRESS> # HL internal transfer
perp --json funds info # all routes & limits
# Risk
perp --json risk limits --max-leverage 5
perp --json risk liquidation-distance
# Bots
perp --json bot twap <SYM> buy <SIZE> 30m
perp --json bot grid <SYM> --range 5 --grids 10 --size 100
# Bridge (cross-chain USDC)
perp --json bridge quote --from solana --to arbitrum --amount 100
perp --json bridge send --from solana --to arbitrum --amount 100
Telegram Alerts
Funding rate alerts via Telegram with background daemon support.
# Interactive setup (BotFather token + chat ID auto-detection)
perp alerts setup
# Add alert rules
perp alerts add ETH 30 # alert when ETH funding > 30% annualized
perp alerts add --all 50 # alert for any symbol > 50%
# Test & manage
perp alerts test # send test message
perp alerts list # show active rules
# Run daemon
perp alerts start # foreground
perp alerts start --background # tmux background daemon
perp alerts stop # stop background daemon
Setup flow: BotFather token → bot validation → send /start to bot → auto-detect chat ID → test message.
Exchange flag: -e hyperliquid / -e pacifica / -e lighter (aliases: hl, pac, lt).
Global flags: --json, --fields <f>, --ndjson, --dry-run, --dex <name> (HIP-3), -w, --wallet <name>.
MCP Server
perp-cli includes a full-featured MCP server (18 tools, 3 resources, 2 prompts) for Claude Desktop, Cursor, and other MCP clients.
{
"mcpServers": {
"perp-cli": {
"command": "npx",
"args": ["-y", "-p", "perp-cli", "perp-mcp"],
"env": {
"HYPERLIQUID_PRIVATE_KEY": "your-evm-key",
"PACIFICA_PRIVATE_KEY": "your-solana-key"
}
}
}
}
Tools: market data, portfolio, orderbook, funding rates, arb scanning, trade preview/execute (with dry-run safety), funding analysis, PnL analysis, arb comparison.
Resources: market://prices, market://funding-rates, perp://schema
Prompts: trading-guide, arb-strategy
AI Agent Skill
Install as a skill for Claude Code, Cursor, Codex, Gemini CLI, etc.:
# Using npx (recommended)
npx skills add hypurrquant/perp-cli
# Or via Claude Code slash command
/install-skill hypurrquant/perp-cli
See skills/perp-cli/SKILL.md for the full agent guide.
Agent-First CLI Design
Built following agent-first CLI principles:
# Every command returns structured JSON envelope
perp --json portfolio
# → { "ok": true, "data": {...}, "meta": { "timestamp": "..." } }
# Runtime schema introspection (don't guess commands — query this)
perp --json agent schema
# Filter output to specific fields (saves tokens)
perp --json --fields totalEquity,risk portfolio
# Stream large lists as NDJSON (one JSON per line)
perp --json --ndjson -e hl market list
# Pre-validate before executing
perp --json -e hl trade check BTC buy 0.01
perp --json --dry-run -e hl trade market BTC buy 0.01
# Idempotent orders with client ID
perp --json -e hl trade market BTC buy 0.01 --client-id my-unique-id
All responses are auto-sanitized (control chars stripped, prompt injection patterns blocked).
Errors include retryable flag — only retry when true.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。