Skip to content
· 8 min LIVE

We Let an Agent Swap EURC for USDC Into Its Own Budget Vault - Then Spent Seven Review Rounds Proving It Cannot Pay Twice

EURC->USDC->BudgetVault through the Peach Arc Aggregator, live on testnet: an atomic tx journal written before broadcast, same-hash adoption on resume with zero resends, block-body proofs for 'never sent', and a pre-sign checklist that pins the signed calldata word-by-word. Seven review rounds (6 Arc Studio + an on-chain re-check) plus an independent Nemotron pass - and the sharpest bugs were in the vendor's API: an unadvertised router, a millisecond timestamp, a missing deviation field.

AB
AgentBadge Team
Agency for the Agentic Web
We Let an Agent Swap EURC for USDC Into Its Own Budget Vault - Then Spent Seven Review Rounds Proving It Cannot Pay Twice
🤖 For AI agents: Machine-readable: JSON Markdown llms.txt Agent Guide

An AI agent holding a USDC budget should be fundable in whatever the customer has. We proved 5 EURC converts to USDC through the Peach Arc Aggregator and lands in a real BudgetVault - with a journal that persists intent, hash, and raw signed bytes atomically before broadcast, so a killed process resumes to the same txHash and can never resend. Six audit rounds converged at 0 Critical/0 High, the vendor-side re-check found one High and three Mediums (all fixed and re-drilled live), and the most interesting findings were on the vendor's side: an execution router the status endpoint never advertises, a quote timestamp in milliseconds, and a deviation_ratio that never arrives. Decision: CONDITIONAL GO.

The problem: "convert currency" is three problems wearing a trenchcoat

For a junior: our BudgetVault is a USDC piggy bank for AI agents - it streams funds on a schedule, with a payee allowlist and per-tx caps. Customers in Europe hold EURC. So the agent needs a conversion step before the vault sees a cent.

This is part of the Arc campaign series. Previous published episode: the settlement layer for agents paying agents (EPIC-227 - what decides when the money is allowed to move). This article is EPIC-254: plugging an external DEX aggregator into the agent's funding path - without trusting it.

That sounds like one API call. It is actually three separate problems:

  • The swap - easy part. Ask the aggregator for a quote, sign a transaction, collect USDC.
  • The crash - hard part. Your process can die at any point between "I signed a transaction" and "I saw its receipt". A naive retry broadcasts the same intent twice. A naive "it failed, resend" pays twice. The only safe answer is a journal that knows exactly what was already signed and sent.
  • The vendor - sneaky part. The SDK you depend on returns routers, quotes and flags. If any of them lie or drift shape, your checklist has to notice before the signature, not after the loss.

We proved all three live on Arc testnet (chain 5042002), in public, with transactions anyone can verify on the explorer.

What actually shipped

EURC to BudgetVault crash-safe pipeline: pre-sign checklist with router match, 0x02fcde22 calldata word-pin, gas and payee checks, atomic journal write before broadcast; money path through broadcast, on-chain verify, approve, deposit to DEPOSITED; crash zone showing process killed after broadcast with same-hash adoption and zero resends; never-sent block-body proof box; vendor API bug panel

Write the journal first - then the money moves.

The happy path, end to end. 5 EURC in, quote fetched, the router verified against what the API advertises, intent + txHash + raw signed bytes written to the journal in one atomic write, then - and only then - broadcast. The swap returned 9.709 USDC, provenance-verified against actual token movements (not just the receipt status), and the full amount was deposited into the vault, which flipped to DEPOSITED and started streaming. Three full cycles, all on-chain:

  • swap 0x4e2669ae…2339006 / deposit 0xa91b386f…dbc7b51
  • swap 0x6d6a830f…df1355 / deposit 0x04c485a9…85beb3
  • swap 0x758710f6…f36b60 / deposit 0xf29c17cc…c76651

The crash drill, for real this time. Not a mock - we killed the process after the swap was broadcast, restarted, and ran resume. It read the journal, found the signed intent, located the transaction on-chain under its same hash, adopted it, and finished the deposit. Zero resends. Then we did it again after all the audit fixes landed, on the hardened code, and it still worked.

Crash drill split panel: left half a robot at a swap broadcast console struck by lightning with the screen dark; right half a resume robot holding the paper ledger up to a chain of blocks, a magnifier finding the same hash token already in a block, a green checkmark reading adopted - resends 0, and a red bin of duplicate transactions

Kill it after broadcast. The journal finishes the job.

Real journal entry screenshot: swap intent with sender 0x9264, nonce 20, advertised router, 5 EURC amountIn, 9709033 expected output verified on-chain, signed raw bytes and txHash 0x4e2669ae persisted before broadcast, plus the FSM history showing an earlier ABORTED stage from the router mismatch check

A real entry from state/peach-e2e.json - signed bytes and hash persisted before broadcast; below it, the run that aborted on the router mismatch.

"Never sent" means provably never sent. This is the part most retry logic gets wrong. An RPC timeout, a dropped connection, a misleading error name - none of that proves a transaction died. Our journal only marks an intent never-sent after a block-body proof: binary-search the signer's nonce across archive blocks, read the block where the nonce moved, and require the consuming transaction to be physically present. Until that proof exists, the intent is unknown - and unknown blocks the run, it does not guess.

The escape hatch is a loaded gun with a safety. If a transaction is genuinely stuck, an operator can abandon the intent - but only after two probes at least a block apart confirm it is not in any mempool or block, and then the next signature is nonce-pinned so two transactions can never fight over the same slot.

Seven rounds of review - and where the bugs actually were

Seven checkpoint doors receding into the distance: the first glowing red BLOCK, four amber doors with bug icons swept out, the sixth glowing green PASS with 0 critical and 0 high; behind it a second inspector robot in vendor colors holding a red card 1 High and three amber cards Medium, handing a fix-it list to the first robot who nails a green plaque f528fd3 fixed, re-drilled live

The bugs moved into the fixes - then ran out of places to hide.

We ran the same playbook as the settlement layer: adversarial audit rounds in Arc Studio until converged, then a second reviewer on the final tree. Six rounds went BLOCK -> FAIL x4 -> PASS (0 Critical / 0 High). The honest detail: several of the late-round findings were bugs inside the previous round's fix - remediation is attack surface, and it earns its keep.

Then Randy - the Peach-side reviewer - did something better than a code read. He verified our transactions on-chain and sent back a re-check with one High and three Mediums, all reproduced:

  • High: we signed calldata we never decoded. The aggregator API builds the transaction; we were trusting its shape. If the layout ever shifts - a router upgrade, a different path count - we would happily sign a transaction sending money somewhere else. Now the pre-sign checklist pins the 0x02fcde22 layout word by word: chainId, router, signer, tokenIn/Out, amountIn, amountOutMin, expectedOut, deadline, path echo. One word moves, we refuse to sign.
  • Medium: a lock race that reproduced 11/25 double-holders. Two processes could both believe they owned the journal lock. Fixed with an atomic rename - Randy literally reproduced the race and counted.
  • Medium: a resume wedge on dead:"reverted" entries, and an ABORTED state with no reclaim path for transactions that mined anyway. Both fixed; the post-fix drill re-ran live.

Plus a fresh independent checklist run by a different model family (Nemotron 3.5 Lightning): PASS. bun test scripts/lib/: 80 pass, 0 fail.

The twist: the vendor's API was the bug report

Robot detective with a magnifying glass inspecting a Peach API vending machine: the posted sign reads router 0x5FF5 but a service hatch reveals a second unlabelled pipe stamped 0xfcf7 feeding the same slot; two more bubbles show a wildly spinning clock labelled quote_ts ms not s and an empty receipt field stamped deviation_ratio absent; a clipboard reads 5 questions for the vendor

The sign says one router. The hatch shows another.

While auditing our handling of their API, we found real issues on the Peach/Arc side:

1. Two routers, one advertisement. getStatus() proudly reports the execution router 0x5FF5…0607. But the V2 swapAllowance() endpoint returns a different router, 0xfcf781…0663 - an address the status endpoint does not mention at all. Both are ERC1967 upgrade proxies with different implementations. Our checklist aborted on the mismatch (that is what it is for). Is 0xfcf781… legitimate? We asked. If a checklist treats the API's own self-report as truth, this is exactly the class of thing that becomes an incident.

2. quote_ts is in milliseconds. The field looks like seconds. A naive age = now - quote_ts in seconds makes an expired quote look fresh forever - we only caught it because a negative test fed a stale quote and watched the deadline check wave it through. Units are a security boundary.

3. deviation_ratio just isn't there. Testnet quotes for EURC->USDC omit the field entirely. An earlier version of our code silently treated missing as 0 - which is how "the API didn't say" becomes "the API said zero". Now missing means unknown, and unknown fails closed.

4. Arc's USDC is also the gas token. Gas is charged on the USDC address itself and a second Transfer event fires on 0xffff…fffe at 18 decimals. Any verifier that diffs USDC Transfer logs naively misreads every transaction. We subtract gasUsed x effectiveGasPrice explicitly.

5. Testnet prices are synthetic and drifting. Our five executed 5-EURC swaps returned 15.514, 13.484, 11.829, 10.460, 9.709 USDC - declining, consistent with our own price impact on a thin pool. Nothing on testnet should ever be quoted as a price. On mainnet, the read-only sweep says EURC->USDC sits at ~1.097 across 5-500 EURC, median quote latency 799 ms.

Honest residuals

  • Peach's answers are still open on: the unadvertised V2 router, quote_ts units, the missing deviation_ratio, whether the 0x02fcde22 calldata layout is stable across router upgrades, and cirBTC on testnet. Decision is CONDITIONAL GO until those land.
  • A second model-family verifier (Luna) never ran - our org's weekly quota ran out. It's on the record as an open residual, not swept.
  • ~18 USDC residue sits in the signer wallet from an early swap that mined after its pre-journaling run aborted. Reported as a finding, not hidden.
  • Testnet prices are synthetic - cite the mainnet ~1.097 sweep only, never the 3.10->1.94 testnet numbers.

Why this matters beyond one swap

The generic lesson is not "DEX aggregators work on Arc". It is that plugging a third-party financial API into an autonomous agent is an audit problem, not an integration problem. The API's self-reported status lied by omission (the router). Its types lied by unit (the timestamp). Its schema lied by absence (the ratio). None of that is malice - it is just what production APIs do. The only defence is a checklist that treats the vendor as untrusted input, a journal that treats every crash as survivable, and reviewers who verify on the chain instead of believing the code.

The full evidence pack - transcripts, sweep JSON, audit findings, the letter we sent the Peach team - ships in the repo under spike-evidence/ on branch spike/epic-254-peach.


C57 in the Arc Campaign series. Built on Arc: testnet 5042002 live, mainnet 5042 read-only. No contracts harmed in the making of this spike.

Read the arc:

  • The A2A settlement layer (C55, EPIC-227) - the same audit-arc DNA: fifteen rounds where half the late findings lived inside the previous fix. Our 7-round version had the same shape.
  • The direct USDC verification engine (C48, EPIC-222) - the live on-chain read our provenance checks follow: receipts plus token deltas, not status alone.
  • Agent commerce (C51, EPIC-224) - the six-state deal machines whose payouts this funding path eventually feeds.
  • The money layer (C3) - how agents pay each other from any chain and settle on Arc; this spike adds EURC as an on-ramp into that USDC rail.