Circuit

Build a Hyperliquid trading agent in TypeScript

Updated by the Circuit team

What you write

A Circuit agent exports a TypeScript agent({ every, watch, run }) definition. Circuit runs it on its schedule and whenever a declared watch fires. Your code requests typed actions through the agent context. Signing happens outside the agent's sandbox under the user's passkey-signed permit. Your code never handles private keys. See the execution model.

Set up

Install the CLI with curl -fsSL https://api.circuit.org/dev | bash. If the installer prints an export line, run it or open a new terminal. Then run circuit new --name my-agent to create index.ts, circuit.toml, and DESCRIPTION.md, and edit all three together. They hold the code, its triggers and settings, and the user-facing description. The quickstart walks through each file.

Place a Hyperliquid order

agent.hyperliquid.orders.create accepts an order proposal: { kind: "perpOpen", asset: "BTC", side: "long", amount: { value: "100" } } opens a 100 USDC BTC long as a market order within 1% of the mid. Pass execution: { kind: "limit", price, timeInForce: "ioc" | "gtc" | "alo" } for limits, and attach takeProfit and stopLoss triggers on perpOpen and perpReduce. perpReduce, spotBuy, and spotSell complete the order set, with "max" sizing a reduce to the session's full position. See the Hyperliquid SDK reference for schemas and Hyperliquid trading agents for trading details.

Read state the right way

Size every order from agent.allocation, which tracks the session's own holdings and excludes the rest of the wallet. Reduces cap automatically at what the session holds so your agent never touches manual positions. Log your reasoning with agent.log so users can audit why each trade happened.

Test before you upload

Run circuit check --json to validate the project, circuit backtest --from <ISO> --to <ISO> --usd 1000 --json to replay recorded Hyperliquid, Lighter, or Lighter Robinhood markets with no wallet or network writes, and circuit run --simulated to paper trade live markets. When ready, run circuit auth login and circuit upload to publish the agent to the Circuit app.

Docs for AI coding tools

Circuit's docs publish llms.txt and llms-full.txt for language models, plus an MCP server you can add to Claude Code with claude mcp add circuit --transport http https://docs.circuit.org/mcp so your coding assistant writes against the current SDK. See trade with Claude for more.

Keys and permits

Agents run on a self-custodial wallet you create in Circuit or import by private key. Signing keys stay inside an attested hardware enclave where agents can never see them. Instead, agents request typed actions through Circuit's SDK, and nothing is signed without the passkey permit you approve at start.

You can export your private key from Settings or stop an agent at any time. Stopping revokes the permit while leaving existing positions and resting orders open until you close them in Circuit.

Trade it on Circuit.

Build it or fork it. Backtest it and run it in Paper trading before using real money.

Run It