MB

Market Bender

Agent Arena · MVP blueprint
Spec · Jul 2026 t3code base Self · VS Hyperliquid · native + xyz
Spec sheet · t3code-additive

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).

t3code base → agentic integrations done Privy → login + wallet Cloudflare → UI + game/wager layer Hyperliquid → native + xyz perps
System evolution

From clicks to a real agent loop

01 · Previous assumption

Human-clicked trades

Synthetic portfolio trades with a human in the loop; a from-scratch agent + exchange build was the path.

02 · Clarified model

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.

03 · MVP target

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.

t3code is the base; we don't touch its infra. Trading actions (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.
The product model

Authorities, deliberately separated

Colour = role
Strategy authority

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.

Safety authority

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.

Execution authority

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.

Identity authority

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.

Operator authority

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.

Platform authority

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.

Hackathon verdict

What creates the wow

Buildable in a focused sprint
The wow: wager battles

VS mode — wager money, 3-min agent-vs-agent, winner takes the pool. The spectacle that sells the game.

Visible agent mind

Stream rationale, confidence, rejected intents, and risk vetoes beside the live P&L — the agent's reasoning on display.

Real market plumbing

Hyperliquid orders, fills, order book, and fees across native + xyz HIP-3 markets — not a fake price simulator.

Instant replay

Scrub intent → risk verdict → order → fill → equity on one cinematic timeline; settle the wager from a frozen snapshot.

Hot path

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.

No MCP setup · no t3code changes
YouPrivy login · fund · steer
t3code agentClaude · unmodified runtime
Trading toolsrisk kernel · agent key · auto
Hyperliquidnative + xyz HIP-3
Credential boundaries

Nothing crosses the wrong boundary

t3code stays unmodified

The agent runtime, subagents, and WS run as upstream t3code. We add config + additive packages — never patch t3code core, so rebases stay clean.

Privy owns wallet onboarding

The Privy embedded wallet is the master. It funds the account and signs the one-time Hyperliquid approveAgent to register a server agent key.

Agent key never reaches the model or browser

It lives in the trading-tool/signing service (Cloudflare Secrets). The agent calls a tool; the tool signs — the model never sees the key.

Model receives data, not secrets

Market state in; tool calls out. The agent key can place/cancel orders but cannot withdraw — only the master can move funds.

What runs where

t3code (unmodified) + Cloudflare additive

1
t3code — agent runtime (unmodified)

Node WS server spawning Claude via the Agent SDK; subagents, streaming, WS protocol, its own auth. Runs how t3code runs.

2
Market Bender UI — over t3code's WS

A fine-tuned agentic trading cockpit (portfolio, elemental pools, Self/VS, match HUD, agent-mind). Hosted on Cloudflare Pages.

3
Trading tools / signing service — Cloudflare

Auto-exposes place_order etc. to the agent. Enforces the risk kernel, holds the agent key, signs + submits to Hyperliquid via @nktkas/hyperliquid.

4
Game/wager layer — Cloudflare

Privy auth edge, matchmaking (X challenge / House), 3-min timer, winner-takes-all settlement, replay. Trust-minimized custody of pools.

Match state machine

Self drives · VS settles

LobbyPrivy login · fund
ConsentapproveAgent · Unified mode
ReadyFeeds · agent key · t3code online
Live · 03:00Self: agent trades · VS: battle
LockedNo new risk at deadline
SnapshotEquity freeze (VS)
FlatteningCancel + reduce-only IOC
SettledVS: payout · replay
VS fairness (trust-minimized, not trustless). The winner is decided from a deadline equity snapshot taken from Hyperliquid exchange truth — not from sequential closing fills. The Cloudflare layer custodies the wager pools and settles deterministically; the agent key can trade but cannot withdraw. Harden the mark with a robust reference price (TWAP or official close) and disallow marking against a player's own trades. Self mode has no wager and no settlement.
Interaction prototype

Agent driving console

Agent driving
BTC mark$64,280
PositionLong 0.18×
Equity$1,004.20
Clock02:41
Model lane Claude
HOLD
Waiting for a material change before invoking the model…
CONF
Agent mind
Venue + risk gate HyperCore
$64,280
Risk kernel verdict
ACCEPT Within budget; exposure clamped to 0.18×.
Every model intent — and every human command — passes this deterministic gate before it touches the exchange.
Human lane Steer / override
Risk budget50%
Strategy suggestions
Direct commands
Decision cadence

Fast exchange, thoughtful agent

Event-driven · roughly 1–5 seconds
Market WS50–100ms events
Feature windowbook, trades, P&L
Event gatematerial change?
Agent turntyped TradeIntent
Risk + executesub-second deterministic

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.

Exchange

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.

@nktkas/hyperliquid · SymbolConverter
Elemental asset pools — all USDC, all Hyperliquid (native or 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).
PoolAsset 1Asset 2Type
🪨 EarthSAND (native)xyz:GOLDGaming · Commodities
🔥 Firexyz:BRENTOILxyz:TSLACommodities · Stocks
💨 AirAERO (native)xyz:SPCXDeFi · Pre-IPO
💧 WaterFET (native)SUI (native)AI · Layer1
Unified path · HIP-3 mechanics

What an implementer must handle

Same signing, different asset ID

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).

Run in Unified margin mode

One USDC balance collateralizes native + USDC HIP-3 DEXs. In Standard mode you'd need master-signed sendAsset per DEX — Unified avoids that.

!
Per-DEX discovery

Deployer markets do NOT appear in the default meta. Call perpDexs() then metaAndAssetCtxs({dex}) per DEX; use the SDK's SymbolConverter(dexs:true).

!
HIP-3 operational caveats

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.

!
Agent can trade, not move funds

usdSend, usdClassTransfer, sendAsset, withdraw3 are master-signed. The master funds the account and sets Unified mode; the agent only places/cancels/modifies.

Non-negotiable risks

Build constraints, not footnotes

One agent wallet per process

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.

Wager game

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.

Trust-minimized, not trustless

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.

Fastest credible implementation

Four vertical slices

t3code unmodified · Cloudflare additive
Slice 1

Login → fund → trade

Privy master login; fund the Hyperliquid account; one-time approveAgent + Unified margin mode. Market Bender UI shell over t3code's WS.

Slice 2

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.

Slice 3

Self mode loop

Agent trades your book continuously on Hyperliquid native + xyz HIP-3 via @nktkas/hyperliquid; stream rationale, fills, P&L.

Slice 4

VS mode + spectacle

Wager, matchmaking (X challenge / House), 3-min timer, winner-takes-all settlement from a frozen snapshot, replay, cinematic winner.

Repository shape

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
Demo acceptance

The five-minute judge path

1
Privy login → fund

Master wallet connects; fund the Hyperliquid account; one approveAgent + Unified mode. No popups during play.

2
Self mode

The t3code agent trades your book continuously via the auto-exposed tools; watch rationale + real testnet fills.

3
VS mode

Wager, match (X friend or House), 3-min battle — both agents stream decisions and real order states.

4
Steer then panic

A suggestion changes a model decision; Exit All cancels, flattens, verifies FLAT.

5
Settle + replay

VS: winner-takes-all from the frozen snapshot; replay intent → risk verdict → order → fill → equity.

Starter contracts

Code boundaries the agent should preserve


      
Copy into your coding agent

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.