DEV Community

Cover image for Treasury Guard: Pay for the Move, Not the Seat
OpenCode Audit
OpenCode Audit

Posted on Edited on

Treasury Guard: Pay for the Move, Not the Seat

A concept for a DAO treasury agent that buys a Swap.io quote only when the rebalance trigger actually fires.

https://x.com/i_am_ahero/status/2119884149406265716

Most treasury agents are built like a subscription. They hold an API key, pay for a monthly seat, and call a swap endpoint whether or not there is anything to do. For an agent that rebalances a few times a month, most of that spend is idle capacity.

Treasury Guard is the opposite: a narrow agent that watches a DAO's SOL/USDC ratio against a target band, does nothing while the band holds, and pays for exactly one quote when it breaks.

The scenario

A DAO treasury targets 70% SOL and 30% USDC, with a ±3% band. A free price feed is enough to monitor the ratio. When SOL rallies and the treasury drifts to 71.8%, the agent has a decision to make: sell 12.4 SOL into USDC, or wait.

At that moment it needs a trustworthy route. It calls Swap.io's Hermes Agent API:

POST https://hermes.swap.io/v1/swap/quote
Enter fullscreen mode Exit fullscreen mode

The first request is unpaid. The endpoint answers HTTP 402 Payment Required and names its price: maxAmountRequired: "3007", or 3,007 atomic USDC — $0.003007. The body also lists the Solana USDC mint, the payTo address, and a facilitator fee payer, so the payer needs no SOL for the payment itself. Base is offered as a second rail.

In production, the agent attaches the x402 payment, receives ranked quotes, asks the API to build an unsigned transaction, and hands that transaction to the DAO's multisig. The keys never leave the treasury. The agent pays for the quote; the DAO decides whether to sign. A quote and a build-tx are separate metered calls, but the round trip is still under a cent at the published prices.

The live check

I captured the first half of that flow on 9 November 2026 at 17:03 UTC against the live endpoint. The response was a real HTTP/2 402, not a mockup. Trimmed to the payment terms:

{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "solana",
    "maxAmountRequired": "3007",
    "payTo": "BPz2u6eoWLervxEqfpsMCVmKk7h6fEVsd7L5rvEibMfD",
    "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "extra": { "feePayer": "2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4" }
  }, {
    "network": "base",
    "maxAmountRequired": "3007",
    "payTo": "0xC22f661733B85C1349F7C83EE0B2BCF3234603dE"
  }]
}
Enter fullscreen mode Exit fullscreen mode

The full response is 906 bytes. The video shows the command, the status line, and the payment terms, trimmed only for legibility.

This entry stops at the challenge. I did not execute a paid call or an on-chain transaction, so there is no Solscan link and no bonus claim. The useful part is still visible: the endpoint publishes its price and payment terms before anyone commits a cent.

Why x402 fits this agent

  • No API key. There is no credential to create, store, rotate, or leak. The payment is the authorization.
  • No monthly seat. The agent pays $0.003007 per quote. Ten rebalances a month is about three cents at the published price — not a $99 subscription.
  • Machine-native. The 402 response is the price list. An agent can read it, decide, and pay without a signup flow.
  • Receipts. A paid 200 carries an on-chain settlement receipt in X-PAYMENT-RESPONSE. A 200 without a receipt was not charged and should not be trusted as paid.
  • Failure-safe. Swap.io documents that failed upstream requests pass through without settlement, so a bad route or an upstream error is not billed.

For a rare-event agent, metering beats seats. The budget becomes the API.

What I would build next

A production Treasury Guard would use a dedicated payer wallet with a hard monthly cap, a policy engine that only allows the target token pair and a maximum slippage, and a multisig handoff for every transaction. The agent would never hold the treasury's keys. It would only buy the quote and prepare the transaction.

That is the pitch: a treasury that pays for the move, not the seat.


Links: Swap.io · Hermes Agent API quickstart · x402 protocol · Live service info

Disclosure: this is an independent concept pitch for the Swap.io × Superteam x402 bounty. It is not an official Swap.io product. The voiceover is AI-generated; the script, slides, and edit are original. No paid API call or on-chain transaction was executed for this entry.

Top comments (1)

Collapse
 
giovafasulo profile image
Giovanni Fasulo •

Hey OpenCode Audit, swapping bloated monthly SaaS seats for sub-cent x402 micropayments is the kind of lean treasury architecture every DAO CFO secretly dreams about! Your live HTTP 402 walkthrough and clear multisig boundaries show serious systems thinking—excited to see where you take this next.