Glossary · Principles

What is Atomic swap?

An atomic swap completes both legs of a trade or none of them. The mechanism (hash time-locked contracts historically, pooled liquidity with atomic settlement now) guarantees there is no window where one side has paid and the other has not delivered.

Atomicity is the property that makes non-custodial trading coherent: you never sign a transaction that could leave you with neither asset.

How Atomic swap works

An atomic swap completes both sides of a trade or neither: the design guarantees no state where one party has paid and the other has not delivered. Historically this meant hash time-locked contracts across two chains; today the dominant form is the pooled swap, where a single transaction exchanges both assets atomically as a matter of the chain's own execution.

The property is what makes non-custodial trading coherent. A trade you sign is a trade that completes; there is no settlement leg to wait on while your side is already gone, and no counterparty whose failure leaves you exposed mid-exchange. Multi-hop routes compose the same guarantee: each hop is atomic, and the composition leaves no resting state in anyone's custody.

The user-visible consequence is the trade's failure mode: a swap that cannot execute reverts. You are never half-in. The number you approved is either the number that happened or nothing moved, with the network fee as the only cost of a reverted attempt.

Atomic swap in practice

A swap from one token to another across a routed path executes as one transaction: assets leave, the route fills, output arrives, all in one settlement event. If any pool along the path cannot fill at the approved bound, the whole transaction reverts and nothing moved but the fee.

Atomic swap on U.CASH

Every swap on U.CASH settles atomically in one signed transaction: the asset you spend leaves and the asset you receive arrives in the same settlement event.

For conversion-heavy operations, atomicity is the property that makes automated treasury safe: a scheduled conversion either completes at its approved bounds or fails cleanly, with no partial fills to reconcile and no exposure window between legs. U.CASH swaps settle this way by construction. On automation: because failure is clean, automated flows can treat a reverted swap as a retry signal rather than an incident. A scheduled treasury conversion that misses its bound simply re-quotes next cycle; nothing needs unwinding, and no human needs to reconcile a partial state that cannot exist.

Related principles terms

Non-custodialConfirmation policySettlement finality

See also

DEX routingGuide: swap across chains

Atomic swap: FAQ

What makes a swap atomic?
Both legs settle in one transaction. There is no intermediate state where the trade is half-done, so no counterparty can end up holding your funds without delivering theirs.
Do all DEX swaps work this way?
Single-transaction swaps do. Multi-hop routes compose several atomic steps; each hop is atomic, and the route's design keeps the whole path from resting in anyone's custody.
What does atomic mean here?
All-or-nothing execution. The two sides of the exchange settle in one transaction, so there is no intermediate state where one side is done and the other pending.
What happens if a swap cannot complete?
It reverts: nothing moves except the network fee for the attempt. Your assets remain as they were, and you can re-quote.
Do multi-hop routes keep the guarantee?
Yes: each hop is atomic within the same transaction, and the composition leaves no step where value rests outside your control.
Keep reading

The glossary, A to Z

Every term behind the rails, the assets, and the settlement.