HTLCs eliminate custodian risk in multi-leg agent trades
Baris Sozen argues that true atomicity in multi-leg agent trades requires hashed timelock contracts (HTLCs) — not escrow intermediaries — so that either all legs of a trade settle or all refund, with no partial outcomes possible.
Score breakdown
The HTLC-based model removes the need for a trusted custodian in multi-leg agent trades by making conditionality native to the lock structure itself, so that no coordinator is added as the number of trade legs grows.
- 01The post is authored by Baris Sozen and frames multi-leg trade atomicity as the core primitive for agent-based trading.
- 02A two-sided trade (e.g., USDC for wETH) requires two legs; both must clear or neither should — a partial fill means value is lost.
- 03Escrow-based solutions relocate the settlement gap into a custodian rather than eliminating it, converting counterparty risk into custodian risk.
Baris Sozen opens by distinguishing payment from trading: a payment rail moves value in one direction and its data model is a transfer, but a trade — even the simplest USDC-for-wETH swap — requires two legs that must both clear or both refund. The moment one leg settles without the other, value is lost. Real agent trades compound this: cross-chain swaps involve two ledgers with no shared clock; multi-party rings (A wants what B has, B wants what C has, C wants what A has) require all three legs to fire simultaneously; and bundled sequences like "swap, then post collateral, then open position" leave the agent worse off with a partial fill than with no trade at all.
The naive sequential approach — send, wait, receive — creates a window between steps where a counterparty can walk away, a chain can reorg, or an agent can crash mid-sequence.
The naive sequential approach — send, wait, receive — creates a window between steps where a counterparty can walk away, a chain can reorg, or an agent can crash mid-sequence. The common "fix" of inserting an escrow intermediary doesn't close this window; it relocates it. The trust assumption shifts from the counterparty to the custodian's solvency and integrity, which Sozen characterizes as "orchestration wearing settlement's clothes."
The proposed solution is the hashed timelock contract (HTLC), extended across all legs of a trade. A random secret `s` is chosen, its hash `h = SHA256(s)` is computed, and every leg is locked under the condition "claimable by revealing the preimage of `h`, refundable after timeout T." This produces exactly two possible outcomes: the secret is revealed (claiming any one leg publishes `s` on-chain, making every other leg claimable — full settlement cascades automatically) or the secret is never revealed (every leg's timeout passes and all amounts refund to their original owners). Sozen emphasizes that timeout windows must be staggered in the correct order so the party who reveals the secret is never left exposed, and that this timeout/refund logic is formally verified using Slither, Halmos, Echidna, Stryker, and a runtime invariant monitor. The key architectural distinction is that the HTLC's native data model is a conditional lock, not a transfer — adding a leg adds another lock under the same hash, not another coordinator.
Key facts
- 01The post is authored by Baris Sozen and frames multi-leg trade atomicity as the core primitive for agent-based trading.
- 02A two-sided trade (e.g., USDC for wETH) requires two legs; both must clear or neither should — a partial fill means value is lost.
- 03Escrow-based solutions relocate the settlement gap into a custodian rather than eliminating it, converting counterparty risk into custodian risk.
- 04HTLCs bind all legs under a single hash `h = SHA256(s)`: revealing the secret `s` to claim any one leg cascades settlement to all legs.
- 05If the secret is never revealed, every leg's timeout passes and all amounts refund — there is no third, partial-settlement state.
- 06Timeout windows across legs must be staggered so the party revealing the secret is never left exposed; incorrect ordering reintroduces a gap.
- 07The timeout/refund paths are formally verified using Slither, Halmos, Echidna, Stryker, and a runtime invariant monitor.
Topics
Summary and scoring are generated automatically from the original article. We always link back to the publisher and never republish images or paywalled content. Last processed Jun 19, 2026 · 10:25 UTC. How this works →