262189
Matcha swap: how routing turns a token trade into a transaction
A Matcha swap searches available liquidity, builds an executable route, then asks your wallet to authorize and submit an onchain transaction that can still fail.
The Hashbeam Desk··5 min read

A matcha swap on an EVM network turns a token pair and trade size into a routed transaction: Matcha finds available liquidity, assembles the route, and your wallet submits the resulting call to the chain. Matcha is the interface; the swap itself is settled by smart contracts and the network’s transaction rules. The route can use one pool, split across venues, or pass through intermediate tokens when that improves the quoted execution.
Matcha is built on 0x infrastructure, whose Swap API aggregates liquidity and returns executable swap data. A source reference for the interface is matchaswap.pro; the route and settlement mechanics depend on the selected chain and trade. A displayed quote is a proposed execution at a point in time, not a guarantee that the same output will be available when a transaction is included.
How does a Matcha swap find its route?
The routing system evaluates available liquidity for the selected sell token, buy token, amount, and chain, then constructs a path intended to maximize the trade’s output after execution costs. A direct pair is only one possible path. If liquidity between the two tokens is shallow, a route can trade through an intermediate asset, or divide the sell amount among several liquidity sources.
Those choices create trade-offs. Splitting a trade can reach deeper combined liquidity and reduce price impact, but it can also add contract calls and gas cost. A multihop route can connect pools that have no strong direct market, while each hop adds another price and execution dependency. The useful comparison is therefore not simply the quoted token price: it is the expected amount received after route effects and network fees.
0x’s published Matcha example illustrates the mechanism with a large MKR-to-USDT trade: the route used intermediate tokens and multiple liquidity sources, including Uniswap v2 and 0x RFQ fills. That example establishes what the router can do, not what every Matcha trade will do. The route is rebuilt for the pair, amount, chain, and liquidity available when the quote is requested.
What does your wallet authorize in a Matcha swap?
For an ERC-20 sell token, the wallet may first need to authorize a spender to transfer the tokens. This is an allowance recorded by the token contract; it is separate from the swap transaction. The required spender depends on the execution flow. In 0x’s API v2 AllowanceHolder flow, the approval target is the AllowanceHolder contract returned for the quote, while the Settler contract is the execution entry point and should not receive token allowances.
If the token allowance is already sufficient, there may be no new approval transaction. Otherwise the wallet asks the user to sign an approval, which is submitted and confirmed onchain before the swap can proceed. An approval does not itself exchange tokens: it grants spending permission up to the approved amount. The wallet then presents the swap transaction, including the destination, calldata, network fee, and the expected trade details, for a separate signature.
Check that the wallet is connected to the intended network and that the token contract addresses match the assets you mean to trade. Review the spender shown by the transaction flow, the sell amount, the expected output, and any minimum-output or slippage setting before signing. A token with unusual transfer behavior can also make a route fail even when the displayed balance appears sufficient.
What happens when the swap transaction is submitted?
Once signed, the transaction is broadcast to the selected chain. Validators or block builders order it with other pending transactions, and the chain executes the transaction’s calls against the state at inclusion. The route’s contracts attempt each leg: taking the sell asset, executing the selected pool or market-maker fills, and delivering the buy asset to the recipient. The trade is atomic onchain: if a required call reverts, the swap does not partially settle, although the sender can still pay gas for the failed transaction.
The quoted output can change between quote and inclusion because pool reserves, competing trades, and transaction ordering may change. A minimum-output bound limits how far execution may move from the accepted terms; if the transaction cannot satisfy that bound, it reverts instead of completing at worse output. Tight bounds can reject more price movement but make a transaction more likely to fail. Loose bounds improve the chance of execution while permitting a larger shortfall.
After confirmation, verify the actual token balance changes and the transaction receipt, not just the interface’s pending state. The receipt shows whether execution succeeded and the emitted token-transfer events reveal the amounts delivered. For a reader deciding whether to proceed, the practical test is whether the final quoted output still compensates for route complexity, gas, and the slippage bound. A Matcha swap is not a single exchange price: it is a proposed path whose result becomes final only when the network executes it.