How to Estimate a Swap That Uses Two Pools
A two-pool route can trade assets without a direct market, but the estimate must apply each pool’s fee and price impact to the amount that reaches it.
The Chain Media Editors3 min read
A two-pool route estimates a swap by sending the first asset through one pool, then using the resulting amount in a second pool. This can make a trade possible when no direct pool connects the starting and target assets. The final output depends on both pools: the first determines how much reaches the second, and the second prices that amount against its own reserves.
For example, a route from asset A to asset C might use asset B as an intermediary: A becomes B in the first trade, then B becomes C in the next. A route estimate needs to calculate those trades in order. A fuller discussion of route choice appears in chainflip. The key point is that the second pool receives the first trade’s output, not the original input.
Why does a swap use two pools?
A swap uses two pools when they share an intermediary asset but do not offer a direct market for the pair being traded. Each pool holds reserves of two assets and applies its own pricing rule to trades. In a constant-product pool, for instance, a larger trade shifts the reserve ratio and gets a worse average price than a smaller trade. Other pool designs can use different curves, so a route estimator must use the pricing rule of each pool it quotes.
The route can provide access to more asset pairs, but it adds a second source of price impact and fees. The intermediate asset may also have limited liquidity in either pool. A route with two individually liquid pools can still produce a weaker quote than expected if one leg is shallow relative to the amount passing through it.
How do you calculate the route’s output?
Calculate the first pool’s output after its fee, then use that net output as the second pool’s input. Apply the second pool’s fee and pricing rule to find the final amount. The two trades are sequential, so estimating each leg against the full starting amount gives the wrong result.
A useful quote should make the route’s main costs visible. Check:
- the intermediate asset and the pools used for each leg;
- the amount expected after the first trade and the final estimated output;
- the fee charged by each pool and any separate network or execution costs;
- the quoted rate compared with a reference price for the starting and target assets.
That comparison helps distinguish fees from price impact. Fees are explicit charges; price impact is the change in the pool’s effective price caused by the trade size. A quote may combine both into its displayed output, so inspect the breakdown when available.
How should you compare a two-pool quote?
Compare the final output for the same input amount, network conditions and execution settings. A direct pool, if available, may avoid one fee and one price impact, but it is not automatically better: its liquidity could be thinner. The route with the highest quoted output is usually the better starting point, provided the quote reflects all relevant costs and can be executed under the stated conditions.
An estimate is not a guaranteed fill. Pool reserves can change before execution, and the realized output may differ from the quote. Slippage tolerance sets how far execution may move from the quoted result before a transaction is rejected; it does not improve the quote or remove price impact. For most readers, compare the net output and route details first, then set tolerance only as wide as needed for the trade to execute.