The model drives. The human bends the model.
An agent-driven Web3 portfolio trading game. A t3code agent (Claude-first) trades continuously on Hyperliquid — native perps + xyz HIP-3 markets — through auto-exposed tools gated by a deterministic risk kernel. Log in with Privy, load money, and trade. Play Self (your agent manages your book) or VS (wager money, 3-minute winner-takes-all battle).
From clicks to a real agent loop
Human-clicked trades
Synthetic portfolio trades with a human in the loop; a from-scratch agent + exchange build was the path.
t3code runs unmodified
Adopt t3code as-is — its agent runtime, subagents, streaming, and WS are reused untouched. Market Bender is an additive UI + trading-tools + game layer on top; clean rebases when t3code updates.
Self + VS on Hyperliquid
Privy login → fund → trade. Self mode: your agent trades your book. VS mode: wager, 3-min winner-takes-all. Hyperliquid native perps + xyz HIP-3 markets.
place_order, list_orders, cancel, close, flatten, get_portfolio) are auto-exposed to the agent as tools — the user never configures an MCP. The deterministic risk kernel lives inside those tools, so the model can't bypass it.
Authorities, deliberately separated
t3code agent · Claude
Runs in t3code's unmodified runtime via the Claude Agent SDK. Reads market state, clock, opponent state, risk budget, and your suggestions. Calls trading tools — it never signs transactions itself.
Risk kernel
Clamps leverage, size, assets, cadence, price bands, and deadlines. Lives inside the trading tools, so it can veto the model and cannot be bypassed by prompts.
Agent key · Hyperliquid
A standard secp256k1 key, approved once by the Privy master via approveAgent. Signs L1 trade actions on native + xyz HIP-3 markets — it cannot withdraw. The model never sees it.
Privy
Self-custodial embedded EVM wallet = master (identity = wallet address = the JWT sub). Replaces t3code's Clerk auth. Login → fund → one-time approveAgent; custodies funds.
You, the player
Self: your agent trades your book. VS: wager, 3-min battle, winner takes the pool. Direct controls preempt the model: pause, bounded enter, close, flatten.
Cloudflare additive
Hosts the UI and the game/wager layer (matchmaking, 3-min timer, winner-takes-all settlement, replay) + Privy auth + the trading-tool/signing service. t3code runs alongside, unmodified.
What creates the wow
VS mode — wager money, 3-min agent-vs-agent, winner takes the pool. The spectacle that sells the game.
Stream rationale, confidence, rejected intents, and risk vetoes beside the live P&L — the agent's reasoning on display.
Hyperliquid orders, fills, order book, and fees across native + xyz HIP-3 markets — not a fake price simulator.
Scrub intent → risk verdict → order → fill → equity on one cinematic timeline; settle the wager from a frozen snapshot.
t3code runs unmodified · Market Bender is additive
The agent runs in t3code's own runtime (Claude Agent SDK, subagents, streaming, WS) — untouched. It calls auto-exposed trading tools that enforce the risk kernel and sign with the agent key. The Cloudflare additive layer (UI, game/wager, Privy auth, the tool/signing service) wraps this path without modifying t3code.
Nothing crosses the wrong boundary
The agent runtime, subagents, and WS run as upstream t3code. We add config + additive packages — never patch t3code core, so rebases stay clean.
The Privy embedded wallet is the master. It funds the account and signs the one-time Hyperliquid approveAgent to register a server agent key.
It lives in the trading-tool/signing service (Cloudflare Secrets). The agent calls a tool; the tool signs — the model never sees the key.
Market state in; tool calls out. The agent key can place/cancel orders but cannot withdraw — only the master can move funds.
t3code (unmodified) + Cloudflare additive
Node WS server spawning Claude via the Agent SDK; subagents, streaming, WS protocol, its own auth. Runs how t3code runs.
A fine-tuned agentic trading cockpit (portfolio, elemental pools, Self/VS, match HUD, agent-mind). Hosted on Cloudflare Pages.
Auto-exposes place_order etc. to the agent. Enforces the risk kernel, holds the agent key, signs + submits to Hyperliquid via @nktkas/hyperliquid.
Privy auth edge, matchmaking (X challenge / House), 3-min timer, winner-takes-all settlement, replay. Trust-minimized custody of pools.
Self drives · VS settles
Agent driving console
Fast exchange, thoughtful agent
Do not market this as HFT. The chain can be fast; model inference is the strategic control loop. Stops, deadlines, cancel/replace, reconciliation, and panic flattening belong to ordinary code — not to the model.
Hyperliquid only — native perps + xyz HIP-3
One agent key, one approveAgent, one EIP-712 path trades both native Hyperliquid perps and xyz-deployed HIP-3 markets (stocks, commodities, pre-IPO). Same /exchange endpoint, same WS, same order types. Everything settles in USDC.
xyz: HIP-3). Two substitutions from the original flavor: WTI → xyz:BRENTOIL (no live USDC WTI market) and OCEAN → FET (OCEAN delisted; FET is its ASI successor).
| Pool | Asset 1 | Asset 2 | Type |
|---|---|---|---|
| 🪨 Earth | SAND (native) | xyz:GOLD | Gaming · Commodities |
| 🔥 Fire | xyz:BRENTOIL | xyz:TSLA | Commodities · Stocks |
| 💨 Air | AERO (native) | xyz:SPCX | DeFi · Pre-IPO |
| 💧 Water | FET (native) | SUI (native) | AI · Layer1 |
What an implementer must handle
HIP-3 orders are ordinary L1 actions; only the asset ID differs — native = index, xyz = 100000 + dex_index*10000 + index. approveAgent is account-wide (no per-market setup).
One USDC balance collateralizes native + USDC HIP-3 DEXs. In Standard mode you'd need master-signed sendAsset per DEX — Unified avoids that.
Deployer markets do NOT appear in the default meta. Call perpDexs() then metaAndAssetCtxs({dex}) per DEX; use the SDK's SymbolConverter(dexs:true).
2× base fees (deployer takes a share); deployer oracle ~3s with stale-clamping; per-asset OI caps; deployer can haltTrading; no HLP backstop (ADL possible). Nonces are shared per agent key — use one agent wallet per trading process.
usdSend, usdClassTransfer, sendAsset, withdraw3 are master-signed. The master funds the account and sets Unified mode; the agent only places/cancels/modifies.
Build constraints, not footnotes
Atomic unique nonces
Nonces are shared per agent key across all DEXs — use a separate agent wallet per trading process/subaccount to avoid nonce collisions. Never reuse a deregistered agent address (replay risk). The protocol enforces per-signer uniqueness; an atomic counter is the recommended client-side pattern.
Derivatives · custody · scrutiny
Leveraged perps plus winner-takes-all wagering raises derivatives exposure, custody questions, and gambling-law scrutiny risk (a skill-dominant contest can be lawful — it is not automatically gambling). Testnet/points mode first; real-value pools need legal review.
Custody the wager pools on Cloudflare
The House/wager pools are custodied by the Cloudflare layer with deterministic, transparent settlement and replay — not a fully on-chain trustless vault. The agent key can trade but cannot withdraw; the master holds funds. On-chain trustless custody is a later phase if warranted.
Four vertical slices
Login → fund → trade
Privy master login; fund the Hyperliquid account; one-time approveAgent + Unified margin mode. Market Bender UI shell over t3code's WS.
Agent + trading tools
t3code runs Claude (query()) unmodified. Auto-expose place_order/cancel/close/get_portfolio tools with the risk kernel inside; sign via the agent key.
Self mode loop
Agent trades your book continuously on Hyperliquid native + xyz HIP-3 via @nktkas/hyperliquid; stream rationale, fills, P&L.
VS mode + spectacle
Wager, matchmaking (X challenge / House), 3-min timer, winner-takes-all settlement from a frozen snapshot, replay, cinematic winner.
t3code upstream + additive Market Bender packages
t3code/ upstream, unmodified (submodule/fork) apps/web, apps/server ... agent runtime + WS + subagents (run as-is) market-bender/ our additive layer apps/ui/ fine-tuned trading cockpit over t3code WS apps/game/ Cloudflare Worker + Match DO (wager, settle) packages/ trading-tools/ place_order/cancel/close/get_portfolio + risk kernel exchange-hyperliquid/ @nktkas/hyperliquid: SymbolConverter, agent-key signer privy-auth/ Privy ES256 verify (replaces Clerk) + wallet master contracts/ TradeIntent, MarketFrame, pool defs, game events replay/ append-only match timeline → R2
The five-minute judge path
Master wallet connects; fund the Hyperliquid account; one approveAgent + Unified mode. No popups during play.
The t3code agent trades your book continuously via the auto-exposed tools; watch rationale + real testnet fills.
Wager, match (X friend or House), 3-min battle — both agents stream decisions and real order states.
A suggestion changes a model decision; Exit All cancels, flattens, verifies FLAT.
VS: winner-takes-all from the frozen snapshot; replay intent → risk verdict → order → fill → equity.
Code boundaries the agent should preserve
Market Bender MVP kickoff prompt
This prompt encodes the approved spec — t3code unmodified, Cloudflare additive layer, Claude-first agent, auto-exposed trading tools, Privy, Hyperliquid (native + xyz HIP-3) — corrected against current (July 2026) primary sources.