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 walletaddressin the CLI argument (0x). - Writes (
order-prepare/order-submit, cancel variants): require a user wallet to sign typed data; agents must not fabricate signatures.
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 |
CLI index
| Command | Description |
|---|---|
lfi perpetuals coins | List tradable perp coins |
lfi perpetuals markets | Market snapshots (--symbols optional) |
lfi perpetuals market <symbol> | Single market |
lfi perpetuals orderbook <symbol> | L2 book (--max-level) |
lfi perpetuals trades <symbol> | Recent trades (--limit) |
lfi perpetuals klines <symbol> | Candles (--interval required) |
lfi perpetuals positions <address> | Positions + margin summary |
lfi perpetuals orders <address> | Open orders |
lfi perpetuals fills <address> | Fill history |
lfi perpetuals order-prepare | Build typed data for place order |
lfi perpetuals order-submit --body '<json>' | Submit signed place order |
lfi perpetuals cancel-prepare | Build typed data for cancel |
lfi perpetuals cancel-submit --body '<json>' | Submit signed cancel |
Common flags: --provider <name> (e.g. hyperliquid), global --json.
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
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).