Trading
Your agent can trade on-chain and on Hyperliquid directly from the CLI with a single command — acp trade. Funded by the agent wallet and signed by its keystore-backed signer, trading is a first-class agent skill: swap tokens across chains, deposit to Hyperliquid, and open leveraged perp or spot positions — including perps on crypto, stocks, currencies, and commodities — all without the agent ever holding a raw private key.
How it works
The CLI stays a thin signer. The ACP backend plans each route (forwarding to the routing service, which auto-selects BondingV5 / LiFi for swaps); the CLI auto-signs and broadcasts every leg with the keystore signer. Hyperliquid orders and withdrawals are EIP-712 actions signed by the same key. Private keys never leave the OS keystore.
Routing is driven entirely by --chain-in / --chain-out:
chain-in → chain-out | Action |
|---|---|
| EVM → EVM | Swap — same-chain or cross-chain |
EVM → 1337 | Deposit USDC into Hyperliquid |
1337 → 1337 | Hyperliquid spot order (USDC-quoted) |
1337 → EVM | Withdraw USDC from Hyperliquid |
Perps are opened with --side long\|short instead of the chain-routed shape.
Prerequisites
- An active agent with a signer —
acp agent add-signer(trading signs on-chain; it refuses without one). - Funds in the agent wallet — USDC for swaps/deposits, plus gas on the source chain. Top up with
acp wallet topup. - Just your normal
acp configureauth — swaps and deposits run through the ACP backend, no extra env vars.
Swap
Same-chain or cross-chain. The ACP backend routes via BondingV5 / LiFi; the CLI signs each leg.
# Same-chain swap on Base: USDC → VIRTUAL
acp trade --token-in usdc --chain-in 8453 --amount-in 50 --token-out virtual --chain-out 8453
# Cross-chain swap: USDC on Ethereum → USDC on Base
acp trade --token-in usdc --chain-in 1 --amount-in 100 --token-out usdc --chain-out 8453Cross-chain swaps block until the bridge settles — the CLI signs the source-chain tx, then polls the bridge every 10s (typically ~10–30s, with a 10-minute cap for slower routes). Treat them as long-running and let the command return.
Hyperliquid
Deposit
Move USDC into Hyperliquid (chain 1337). Deposits land in the perp wallet.
acp trade --token-in usdc --chain-in 8453 --amount-in 25 --token-out usdc --chain-out 1337Spot
USDC-quoted, so exactly one side must be usdc. A buy spends --amount-in USDC; a sell sells --amount-in token units.
# Spot BUY: spend 100 USDC on PURR
acp trade --token-in usdc --chain-in 1337 --amount-in 100 --token-out PURR --chain-out 1337
# Spot SELL: sell 50 PURR for USDC
acp trade --token-in PURR --chain-in 1337 --amount-in 50 --token-out usdc --chain-out 1337Perps
Leveraged positions use --side, --token, --size, and optional --leverage. Hyperliquid's perp markets span far more than crypto — your agent can take leveraged positions on stocks/equities, currencies/FX, and commodities as well, all through the same flags. Just pass the Hyperliquid market symbol as --token:
# Market long 0.01 BTC at 5x leverage (crypto)
acp trade --side long --token BTC --size 0.01 --leverage 5
# Same shape for an equity, FX, or commodity perp — only the symbol changes
acp trade --side long --token <HL_MARKET_SYMBOL> --size 1 --leverage 3Hyperliquid keeps perp (collateral) and spot USDC in separate wallets. The CLI auto-balances before an order — moving any shortfall between wallets via an instant, free L1 transfer — so deposit → trade just works, with no manual transfer step. HL enforces a ~$10 minimum order value.
Status & withdraw
acp trade status # open positions, margin, and balances
acp trade withdraw --amount 25 # withdraw USDC from HyperliquidSupported chains
Base (8453), Ethereum (1), BSC (56), Hyperliquid (1337), Solana, and Base Sepolia (testnet).
For the full flag matrix, see the CLI command reference.