Credit default swaps on the services AI agents pay for. Before an agent acts on data it bought, Hazard tells it the market's odds that the supplier fails this week and sizes its trade from those odds. When a failure is proven cryptographically, everyone who bought cover beforehand is paid, from the operator's own bond first.
Who uses it: agents that spend money on paid APIs buy cover to hedge a supplier failing them, underwriters earn the premiums for carrying that risk, and any agent can read the odds for free before it trusts a supplier.
The whole story ran live, end to end, on rehearsal-1.hazard.eth (3 December 2026):
- A failure was caught. The insured price oracle served a 40-minute-old quote. The buyer agent paid for it over x402 and traded on it, and a zkTLS proof showed the quote was 2,402 seconds old against a 60-second SLA (the trade on HashScan).
- The odds reacted. A hunter agent bet $2,000 against the oracle, the odds jumped from 6.46% to 28.92%, and the buyer agent refused its next trade (
SPREAD_EXCEEDS_MAX_BPS, logged on HCS). - It settled with no keeper. The market froze on a signed attestation (Sepolia). Hedera's self-scheduled settlement sent the verdict over Chainlink CCIP (CCIP message), and three cover lots were paid $1 per $1: $500, $416 and $500.
- A late bet got nothing. $2,000 of cover bought 58 seconds after the failure is refused by the live contract (
POST_BREACH_SNIPE_REFUSED). You can re-run that refusal yourself with onecast call(below).
| Built for | ETHGlobal Agentic Markets: Hedera (Smartest DeFi Agent), ENS (AI Agents), Uniswap (v4 hook) |
| Runs on | Sepolia (Uniswap v4 hook, ENSv2 names) and Hedera testnet (HIP-1215, HCS, x402, ERC-8004, SaucerSwap), joined by Chainlink CCIP |
| Proofs | Reclaim zkTLS proofs, verified on-chain on Hedera against a pinned attestor (a real proof verified) |
| Tests | 45 Foundry tests, including stateful invariants against a real v4 PoolManager and a real Reclaim proof; 8 app tests |
| License | MIT |
| Honest scope | Testnets only. hzUSD is labelled test collateral. The insured oracle is ours, and its failures are switched on deliberately so the story can be run. See the known limitations. |
Live demo · For judges · How it works · Every claim, checked · Prize fit · What we hit · Limits
The live terminal. The odds come from the Uniswap v4 hook; the decision is the buyer agent's rule applied to them. Drag the stop limit and the decision changes.
AI agents buy data from other agents and APIs, then act on it with real money. When a supplier goes stale or quietly changes its terms, the agent finds out after the loss. Nothing prices "how far should I trust this supplier right now", and nothing pays when it fails.
Hazard is a market for that price. Anyone can buy cover on a supplier, which is a bet that it fails this week, or underwrite it and earn the premiums if it doesn't. The price of cover is the market's odds of failure. The agent reads those odds before every paid call and sizes its trade from them, and a proven failure pays cover holders from the operator's own bond.
- Read the odds. The agent resolves the supplier's ENS name, for example
price-oracle.hazard.eth. Its risk records are served by CCIP-Read, so the odds are read live from the market at lookup time. - Size and insure. The agent applies its own rule: full size below 2.5%, shrinking to nothing at its stop limit. It buys cover through the v4 pool, whose hook prices it on a bounded curve, so the more cover people buy, the higher the odds.
- Pay and trade. It pays the supplier per call in USDC over x402 on Hedera, trades on SaucerSwap at the size the odds allow, and writes the decision to Hedera Consensus Service.
- Prove. If a paid
200 OKwas stale or had the wrong schema, a Reclaim zkTLS proof of that exact response is checked on Hedera. The breach time is the notary's signed timestamp, so no one can backdate it. - Settle. Each week closes itself: the controller scheduled its own settlement with HIP-1215 when the week opened. A proven breach settles at once. The verdict goes to Sepolia over Chainlink CCIP.
- Pay out. The operator's whole bond pays first, then underwriters. Every $1 of cover bought before the breach pays $1, and cover bought after it pays nothing.
Slowness and 5xx errors are deliberately not payout triggers. They are warnings that move the odds, because anyone can make a server look slow.
One command (about 5 minutes on a fresh clone, spends nothing, needs no key):
git clone --recurse-submodules https://github.com/fexx301/hazard && cd hazard
./scripts/review.sh # 45 contract tests, 8 app tests, a full live breach read back from Sepolia and Hedera, the hosted demo
# ... ALL CHECKS PASSEDIt needs Foundry, Node 20+ and network access. AI reviewers: AGENTS.md says what to run and what not to. The run it checks is written up, step by step with every transaction, in evidence/2026-12-04-price-feed-run.
No install (2 minutes). Open hazard-cds.fly.dev. "Replay a recorded run" walks through the full rehearsal above, in order, with every transaction, instantly. Or run the story yourself: each step is a real transaction and takes 15 to 60 seconds. With MetaMask on Sepolia you can buy cover or underwrite from your own wallet and watch the odds move.
Check the live contracts (1 minute, needs Foundry's cast):
RPC=https://ethereum-sepolia-rpc.publicnode.com
HOOK=0x13b78c64dEa00389A698d2b07967AdF76A2E8888
# today's odds for price-oracle.hazard.eth, in basis points
cast call $HOOK "currentSpreadBps(bytes32)(uint16)" $(cast namehash price-oracle.hazard.eth) --rpc-url $RPC
# 180
# what $500 of cover costs: cost (6-decimals), marginal, effective and post-trade odds in bps
cast call $HOOK "quoteBreachBuy(bytes32,uint256)(uint256,uint16,uint16,uint16)" $(cast namehash price-oracle.hazard.eth) 500000000 --rpc-url $RPC
# 9968442 [9.968e6] 180 199 238
# the sniper tries to redeem $2,000 of cover bought 58 s after the breach
cast call $HOOK "redeemBreachLot(uint256)" 5 --from 0xfBea61ACDF8B20231f1CCc209D80819C331Fd857 --rpc-url $RPC
# execution reverted, data: "0x8b9076a5" = POST_BREACH_SNIPE_REFUSED()Run the tests (about 5 minutes):
git clone --recurse-submodules https://github.com/fexx301/hazard && cd hazard
(cd contracts && forge test) # 45 passed, 0 failed
(cd app && npm install && npm test) # 8 passed, 0 failed| Claim | How to check | Expected |
|---|---|---|
| The hook prices cover on Hazard's curve, live | quoteBreachBuy above |
9968442: $9.97 for $500 of cover, odds 1.80% → 2.38% after the trade |
| The agent sizes real trades from the odds | the buyer's swaps on HashScan: 1.80% odds, 4.12% odds | 1.0 HBAR at 1.80%; 0.76 HBAR at 4.12% with a 9.5% stop; nothing at 28.92% |
| A zkTLS proof of a stale quote is verified on-chain | verify transaction on HashScan; forge test --match-contract RealReclaimProof |
BreachVerified; 5 passed |
| Cover bought before a breach pays $1 per $1 | cast call $HOOK "lots(uint256)(bytes32,uint32,address,uint256,uint64,bool)" 4 --rpc-url $RPC |
bought at 1796337768, 14 s before the breach at 1796337782; redeemed: true; paid $500 |
| Cover bought after a breach pays nothing | redeemBreachLot(5) above |
0x8b9076a5 (POST_BREACH_SNIPE_REFUSED) |
| Settlement needs no keeper | breach verdict over CCIP; a clean week settled 56 s after its scheduled close | the HIP-1215 schedule fired on its own |
| An operator can't rewrite its own risk record on ENS | cast call 0xdd82401e40bfd78b69e217fd50a65afebf565455 "setText(bytes32,string,string)" $(cast namehash price-oracle.hazard.eth) agent.sla.hash forged --from 0xE05Dc8531E7db5EfdaAF70dFf28f35C335f7730d --rpc-url $RPC |
reverts 0x4b27a133 (EACUnauthorizedAccountRoles) |
| Slowness and 5xx can't trigger a payout | forge test --match-test test_latencyOr5xxCodesRejected |
passed |
| Failing on purpose never pays the operator | forge test --match-test testFuzz_selfSabotageStrictlyNegative |
passed: fuzzed over bond, liquidity, starting odds and cover sold, the operator always loses |
| Money is conserved and late cover is never paid, under random sequences of trades | forge test --match-contract HazardInvariants |
6 invariants passed, against a real v4 PoolManager |
| Every decision is on an audit log | HCS topic 0.0.11716623 | one message per decision, refusal and proof |
| The agents have on-chain identities | ERC-8004 on Hedera: #211 price-oracle, #212 buyer, #213 hunter | each linked from its ENS name (ENSIP-25) |
The buyer is a Hedera Agent Kit agent that trades on SaucerSwap. Its size comes from a market price of its supplier's risk, and it is never trusted with more than its rule allows.
| What | Where |
|---|---|
| Agent Kit tools: insured paid fetch, SaucerSwap swap | plugin.ts L67, L138 |
| Agent Kit policy: refuses any trade above the odds limit before HBAR moves | policies.ts L21 |
| Agent Kit hook: every tool call written to HCS | hooks.ts L23, hcs.ts L80 |
| An LLM (Claude) proposes the trade size; the policy caps it, so the model can trade less but never more | llm.ts, hazardFetch.ts L266 |
| HIP-1215: the week schedules its own settlement, with no keeper | HazardEpochController.sol L107-L130, L168-L187 |
| x402 payments in USDC on Hedera, one per call | for example transaction [email protected]; every paid call is in the HCS log |
| zkTLS breach verifier on Hedera's EVM | HazardBreachVerifier.sol L94 |
| ERC-8004 identities for every agent | agents #211 to #213 (table above) |
ENS is how agents find a supplier, learn its risk, and check who it is. Risk records are written by the protocol and read live from the market. The supplier can't edit them.
| What | Where |
|---|---|
ENSv2 names on Sepolia; PermissionedResolver with per-record roles (risk and SLA records protocol-only, description and endpoints operator-editable) |
ens_setup.py L142; try it: Attack lab #3 |
ENSIP-10 resolver with CCIP-Read: odds, cover and status computed from the hook at lookup time and signed by the gateway (0x1900) |
HazardEnsResolver.sol L96-L121, gateway.ts |
| ENSIP-25: each name links to its ERC-8004 identity on Hedera | ens_setup.py L152 |
| ENSIP-28: each agent's wallets, with EIP-712 consent proofs | ens_setup.py L260 |
| ENSIP-31 payment preference: the x402 terms an agent should expect | ens_setup.py L215 |
hazard.fetch() resolves the supplier by name before every paid call |
hazardFetch.ts L163 |
Every credit-default-swap purchase is a real swap through the Uniswap v4 PoolManager on Sepolia, priced and filled by a custom-curve hook. The pool holds no AMM liquidity: the hook prices cover on Hazard's bounded cubic credit-spread curve and settles the trade itself through beforeSwapReturnDelta.
- Hook (Sepolia):
HazardHook0x13b78c64dEa00389A698d2b07967AdF76A2E8888. Its CREATE2-mined address ends in…8888, which sets the flagsbeforeAddLiquidity | beforeSwap | beforeSwapReturnDelta. - Pool: hzUSD (labelled test collateral) / BREACH, pool id
0x42b17998fb15abdee17cc768014e82f82b3abb3b030c6ef6cffd4fb31c10e7ca, on the canonical SepoliaPoolManager0xE03A1074c86CFeDd5C142C4F04F1a1536e203543.
| What | Where |
|---|---|
Hook contract implementing IHooks |
HazardHook.sol L30 |
Hook permissions (beforeSwap, beforeSwapReturnDelta, beforeAddLiquidity) |
HazardHook.sol L156-L160 |
Pool initialisation on the PoolManager |
HazardHook.sol L164-L171 |
beforeSwap: custom-curve pricing, cap, WATCH gate, premium split, lot record, return delta |
HazardHook.sol L289-L326 |
| Only the Hazard router may swap (every BREACH unit has a timestamped lot) | HazardHook.sol L295 |
| Hook takes the premium and mints/settles BREACH via flash accounting | HazardHook.sol L318-L322 |
toBeforeSwapDelta(-shares, +cost): exact-output fill, AMM bypassed |
HazardHook.sol L325 |
| Native v4 liquidity disabled (underwriting is first-loss/senior, in hook storage) | HazardHook.sol L473-L480 |
Router: unlock → sync/settle premium → swap → take BREACH |
HazardCoverRouter.sol L37-L62 |
Buy entry point (buyBreachCover) |
HazardHook.sol L280 |
| Live quote: marginal spread, effective rate, post-trade spread | HazardHook.sol L241-L256 |
Closed-form curve Cost(q0→q1) = p0·Δq + (1−p0)(q1³−q0³)/(3Q²) |
HazardCurve.sol L20-L27 |
Anti-snipe redemption (acquiredTs < breach time) |
HazardHook.sol L404-L417 |
| First-loss waterfall on CCIP breach verdict | HazardHook.sol L362-L402 |
| LP exit blocked during WATCH / while backing open cover | HazardHook.sol L219-L237 |
Live evidence: a $500 cover purchase through the v4 pool on Sepolia priced at $9.968 (marginal 180 bps → effective 199 bps → post-trade 238 bps), exactly the spec's closed form. Tests (forge test in contracts/): 45 tests, including a handler-driven invariant suite against a real v4 PoolManager (collateral conservation, open interest ≤ cap ≤ bond + liquidity, reserve covers every unredeemed lot, no post-breach lot paid) and fuzzed proofs that self-sabotage is strictly negative-EV.
Real behaviour of the platforms we built on, found live and fixed in the code:
- Uniswap v4 skips hook callbacks when the hook calls
swapon itself. Cover is bought through a separate router (HazardCoverRouter.sol), sobeforeSwapalways runs. - On Hedera,
block.timestampis the start of a roughly 2-second record block. A call that HIP-1215 scheduled for second T can see T−1 or T−2, so a strict "is it due yet" check fails. We allow 3 seconds of slack (BLOCK_TIME_SLACK). - HIP-1215
scheduleCalldoesn't revert when it fails; it returns a response code. Both outputs are checked (L116-L123). - CCIP 2.0 delivered the sender as raw 20 bytes, not a 32-byte ABI-encoded address. The receiver accepts both (
_decodeSender). - The CCIP receiver ran out of gas at 600k on the first live breach. A breach settlement does the whole payout waterfall, so it now gets 2M.
- Sepolia's Glamsterdam gas pricing made
forge scriptsimulate gas about 5× too low. The CREATE2-mined hook took 43.95M gas. We deploy with the node's own estimates. - viem's default Universal Resolver can't see ENSv2 names. Hazard pins
UniversalResolverV2(0x85edf8b6…92cf) on Sepolia. - The zkTLS proof must cover every field the verdict reads. Without the extra fields, a valid quote was misclassified as a schema violation, so the proof's
responseMatchesnow name every field.
Uniswap-specific notes are in FEEDBACK.md.
Hazard ships an MCP server, so Claude Desktop, Claude Code or any MCP client can check a supplier's live risk before acting on it.
git clone https://github.com/fexx301/hazard && cd hazard/app && npm installAdd it to your MCP client's config, using the absolute path to your clone:
{
"mcpServers": {
"hazard": {
"command": "npx",
"args": ["-y", "tsx", "/absolute/path/to/hazard/app/packages/mcp/src/server.ts"]
}
}
}Tools:
hazard_get_risk_quoteneeds no keys and spends nothing. Ask for an agent such asprice-oracle.hazard.ethand it returns the live odds of failure from the v4 hook, how much an agent may trade at those odds, and what $500 of cover costs right now.hazard_paid_fetchmakes an insured paid call: it reads the odds through ENS, buys cover on the hook, pays for the API over x402 on Hedera, proves the response with zkTLS, and logs the decision to Hedera Consensus Service. It needs your own testnet account: setHAZARD_BUYER_ACCOUNT_ID(Hedera, e.g.0.0.12345) andHAZARD_BUYER_PRIVATE_KEY(ECDSA, the same key holds Sepolia ETH for gas and Circle test USDC0.0.429274on Hedera) in the server'senv.
| Contract | Network | Address |
|---|---|---|
HazardHook (v4 hook, CREATE2-mined …8888) |
Sepolia | 0x13b78c64…2E8888 |
| HazardCoverRouter | Sepolia | 0xFbe687F9…3F0F0d |
| BREACH (cover token) / hzUSD (test collateral) | Sepolia | 0xD5f6B1aB…dA818 / 0xB8B3fF0c…2a55fF |
| HazardEnsResolver (ENSIP-10, CCIP-Read) | Sepolia | 0x30A3E06B…508f06 |
| HazardEpochController (HIP-1215 + CCIP) | Hedera testnet | 0xeF64303D…E8EcFC |
| HazardBreachVerifier (zkTLS) | Hedera testnet | 0x52D449be…99070A |
| HCS audit topic | Hedera testnet | 0.0.11716623 |
Every address and transaction is also in contracts/deployments/.
An end-to-end review (contracts, servers, frontend, hosting, secrets) found the issues below. This table is their status in the deployed system. Everything runs on testnets with test dollars.
| # | Finding | Status |
|---|---|---|
| 1 | verifyHederaTxDrift accepts any USDC transfer on Hedera as "term drift". It cannot tell the operator's own x402 settlement from a stranger's transfer, or from someone deliberately overpaying the operator. |
Mitigated. Every live market's SLA is re-pinned with a tokenHash that no string hashes to (script/disable_term_drift.py), so drift filings always revert. Stale-data and schema breaches, which are the ones the product uses, are unaffected. Tests: test_termDrift_unrelatedTransfer_isAccepted_knownHole, test_termDrift_disabledByUnmatchableTokenHash_staleStillWorks, test_realProof_acceptedWithTermDriftDisabled. The real fix is to prove the operator's own signed 402 terms rather than a Mirror Node transfer. Drift detections are still written to the HCS audit log. |
| 2 | Clean-epoch senior yield is credited only when someone calls claimCleanYield, so a deposit made between settlement and that call shares yield it never underwrote. depositSeniorLiquidity can also mint 0 shares for a tiny deposit. |
Open in the deployed hook. Fixing it means re-mining and redeploying the hook. The fix: crystallise seniorPremiumsAccrued inside _onEpochSettled on a clean verdict, and revert when shares == 0. |
| 3 | Rate limit and operator-only dial trusted a client-supplied X-Forwarded-For. |
Fixed. The server uses Fly's Fly-Client-IP, and loopback is checked only from the socket itself. |
| 4 | /oracle/admin/* was reachable through the public proxy. |
Fixed. It now returns 403; the story steps change the oracle server-side. |
| 5 | The action lock was released when the browser disconnected, while transactions were still in flight. | Fixed. The lock is released in finally once the handler itself ends. |
| 6 | Request bodies had no size limit. | Fixed. Bodies are capped at 64 KB, with a 413 response, in the demo server, oracle and ENS gateway. |
| 7 | Unbounded hbarAmount and sharesUsdc, and an arbitrary ensName on reset. |
Fixed. Inputs are clamped to 1–50 HBAR and $50–$2,500; reset accepts only the configured demo markets. |
| 8 | The WATCH attestation always signed breach type 2. | Fixed. It signs the type Hedera recorded. |
| 9 | The verifier doesn't check that the proof's notary time falls inside the target epoch, and jsonField takes the first matching key without checking nesting. |
Open. One proof can be filed only once (usedProofs), and only the protocol pins SLAs. The fix: store the epoch's open time on the controller, require open <= notaryTs <= expiry, and scope field lookups to extractedParameters. |
| 10 | registerMarket is permissionless, so a name can be squatted with a 1-unit bond. |
Open. The fix: require a minimum bond, or require the caller to own the ENS node. |
| 11 | Wallet panel: a public client was created on every render, and Underwrite $500 was enabled with less than 500 hzUSD. | Fixed. |
| 12 | A new JSON-RPC provider is created per request. | Open. It's a performance issue only. |
| 13 | HazardEnsResolver reads data[:4] without a length check. A breach with zero senior shares strands funds in seniorLiquidity. A 1-unit quote can show an effective rate above 100%. |
Open, all edge cases. |
contracts/: Foundry.HazardHook,HazardCoverRouterandHazardEnsResolver(Sepolia);HazardBreachVerifierandHazardEpochController(Hedera); tests and deploy scripts.app/:hazard.fetch()SDK, MCP server, the three agent desks, ENS gateway, oracle, and the Risk Terminal (app/web).shared/: interfaces frozen between the two: deployments, HCS schema, ENS record keys.
All code was written after hacking began on 2026-12-03 17:00 UTC. Licensed under the MIT License. Demo video: all footage is real screen capture of the live app at real speed, narrated by the builder; background music: "LoFi hold music", generated with ElevenLabs. How AI tools were used: AI_DISCLOSURE.md.






