day 4 of 5
Wiring it up
Use your IronClaw agent + Mentat tools to monitor funding, alert on edge cases, and paper-trade end-to-end.
The course has been theory-first up to now because the strategy doesn't work without the math. Today is hands-on. By the end of this lesson your IronClaw agent should be able to:
- Pull current funding rates from HL + Nado
- Compute optimal sizing for a stated capital + leverage
- Place paper-mode entries (no real fills)
- Track open paper positions across both venues
- Alert you (Telegram) when an edge case fires
Architecture
┌─────────────────────────────────────────────────────┐
│ Your IronClaw agent (TEE-encrypted, lives in NEAR) │
│ │
│ brain → tools │
│ │ │
│ ├─ hl_get_funding_rate(asset) │
│ ├─ nado_get_funding_rate(asset) │
│ ├─ hl_calc_delta_neutral_size(...) │
│ ├─ open_paper_position(side, notional) │
│ ├─ close_paper_position(id) │
│ ├─ list_open_positions() │
│ └─ alert_telegram(message) │
└─────────────────────────────────────────────────────┘
Each tool is a small Python function. The brain composes them based on your prompt.
A typical session
You wake up. Open Telegram. Send your agent:
"Check funding on ETH and BTC. If either is paying me >5% APR on the short side and the spread between HL and Nado is >0.005%, paper-enter $1000 delta-neutral and tell me."
The agent:
- Calls
hl_get_funding_rate('ETH')→ returns 0.013%/h (113% APR, longs pay shorts) - Calls
nado_get_funding_rate('ETH')→ returns 0.011%/h - Sees the spread is 0.002%/h — below your threshold. Skips ETH.
- Calls
hl_get_funding_rate('BTC')→ returns 0.008%/h (70% APR) - Calls
nado_get_funding_rate('BTC')→ returns 0.005%/h. Spread 0.003%/h. Below threshold. Skips. - Replies: "No qualifying setups right now. Closest was ETH on HL at 113% APR but the HL/Nado spread is only 0.002%/h, below your 0.005 floor."
That's the loop. You're not running the strategy yourself — you're running the judgment on top of an agent that runs the strategy.
Building the tools yourself
The Mentat Hyperliquid deputy already exposes most of these via MCP. You can either:
Option A: Point your IronClaw agent at the Mentat MCP server (instructions in /docs). Option B: Re-implement the tools natively in your own agent's codebase. Slower but lets you customise.
For Day 4 paper-trading, Option A is sufficient. Many graduates stay on it permanently.
Paper-mode vs dry-run
- Dry-run: the tool simulates the call and returns what would have happened. No state change. Cheap, instant, useful in tests.
- Paper-mode: the tool actually opens a tracked simulated position with timestamps, mark prices, funding accruals. Maintains a portfolio. Closes when conditions are met. Reports PnL.
For the next 7 days, run paper-mode only. The kill-switches in day 5 are easier to reason about when you've watched them fire on simulated capital first.
quiz · 3 questions
Q1. An agent monitoring funding-arb should paper-trade for at least:
- 1 hour
- 1 day
- 7 days across both directions of funding
- 30 days
explain → Funding flips. A 7-day paper window catches enough regime change to validate the close-path logic.
Q2. When wiring tool calls, the safest default for the trade verb is:
- auto-execute live
- paper-mode (no real fills, simulated PnL)
- dry-run (returns a plan, no submission)
- either b or c — never default to live
explain → Both paper-mode and dry-run are safe defaults; live is opt-in only after you've watched paper-mode behave for 7+ days.
Q3. An IronClaw agent calling Hyperliquid is most safely structured as:
- One single 'do funding arb' tool with all the logic baked in
- Many small tools (read-funding, calc-size, place-order, close-position) that the brain composes
- A monolithic Python script that the agent shells out to
- An off-chain worker that the agent observes but cannot control
explain → Small composable tools means the brain can react to edge cases. A monolithic 'do everything' tool can't pause when something looks wrong.
homework
Sketch the tool list your agent will call (4-8 tools). For each: name, one-line description, and whether it reads or writes.
1. hl_get_funding_rate(asset) → reads, returns current funding 2. hl_calc_delta_neutral_size(...) → reads, returns sizing ...
Homework is acknowledged, never graded — do it for yourself.