Getting the best price is rarely a direct token swap on one liquidity source, but a series of trades between multiple assets and liquidity sources. See how the magic works in Matcha on 0x v2!
There are many ways onchain trades can be handled. Decentralized exchanges (DEXs) simply take the asset you have and exchange it for an asset in their liquidity pool, at the current price calculated by the AMM. Being stuck with one liquidity source means you’ll often walk away from a DEX with a bad deal.
DEX aggregators get better prices by looking at all possible trade routes at once, across liquidity sources. Knowing the full scope of token liquidity, and exchange rates of many different tokens (not just the ones you are swapping), lets Matcha calculate the optimal way to get extra value from your trade.
While routing has always been a key feature of aggregators, Matcha on 0x v2 is the most effective DEX aggregator in Web3, outperforming on pricing for trades of any size. Read on to see how it works!
How order routing works
Trading on a DEX, you send your tokens to a smart contract that completes the exchange using tokens held in a liquidity pool and then sends you back the token you wanted. On a DEX aggregator, the process is vastly more complicated due to the amount of liquidity sources involved.
![Diagram showing differences between DEXs and DEX aggregators](https://cdn.prod.website-files.com/64b702e0e92a993f08b979ce/655ea31a090ee9ecd426772f_DEX%20vs%20DEX%20aggregator.png)
Trading on a DEX aggregator, you still interact with a smart contract to send your tokens, but the contract is connected to multiple liquidity sources, samples prices on each, and then simulates your trade against these data.
Matcha repeats this simulation with many different scenarios, splitting your trade into pieces that minimize price impact, looking for alternative routes through different pools and tokens, and ultimately combining multiple paths optimized into one single transaction for you to sign. Then, you can just place your trade and receive the tokens.
In many cases, you will find that aggregations saves you a huge portion of the traded amount, especially at larger sizes. Some DEXs have such shallow liquidity that a 5 ETH trade would cause 50%+ price movement, losing you thousands of dollars.
![53% price impact on a DEX, 0.02% on Matcha!](https://cdn.prod.website-files.com/64b702e0e92a993f08b979ce/668fc9d8a96015cfe6e19361_AD_4nXd-gn_HrkSSmbHNcu95oBnfS3XYVBxa-r4dbq46e9EmsbYei2KOZQAncASSFRFpaLMHorctqjqbRsp1fKaYay3Y7rRyKQdX3BrEGU4M6V_obVK2UvymCZrJ9jJI2F7JBgO6ZDAZ40Vsm8QDTOAfR7l1jmB4.png)
Matcha not only prevents this, it also outperforms the pricing of DEXs with deep liquidity like Uniswap, and even other aggregators like 1inch, simply because the routing is so efficient.
What a $10m trade looks like
When most of your trades are only a few hundred or thousand dollars, you’re not likely to run into liquidity issues very often. You still might gain an extra few percentage points on your trade, and will see huge benefits on new tokens with small pockets of liquidity spread all over the place. But to demonstrate the serious power of routing in Matcha, let’s go big!
The animation below shows actual trade routes for a $10 million trade between DAI and WETH. See it for yourself on Matcha.
![Order routing updating on a $10M trade of DAI to WETH](https://cdn.prod.website-files.com/64b702e0e92a993f08b979ce/668fca65a6f484e25746ddb9_route%20updating.webp)
As you can see, the trade is split into multiple pieces, with only one route going directly from DAI to WETH, combining with different routes in what’s known as a multiplex trade. With 120+ liquidity sources to choose from, Matcha can multiplex trades in the most efficient way, no matter what token you’re trading.
The other pieces of the trade are first swapped for another token such as USDC, USDT, and even WBTC being traded for WETH. This is called a multihop trade and there can be many hops to in-between tokens. Being able to use these intermediate tokens is particularly powerful because it lets Matcha consolidate your trade into more liquid token pairs before completing the trade in a second step.
All of this ensures that your trade:
- Finds the best liquidity for any token
- Has minimal price impact on any pool
- Gets the absolute best price
- Looks beautiful!
Of course, the more complex the route, the higher the gas costs, as transactions become more sophisticated. This is part of the reason why smaller trades made on Matcha will have simpler routing, since the improvements in efficiency can be offset by gas costs.
See the route for every trade you make!
You can try it for yourself now on Matcha by choosing any token pair and entering an amount. To see the chart (called a Sankey diagram), just click on the Best route button showing liquidity sources and the chart will open.
![](https://cdn.prod.website-files.com/64b702e0e92a993f08b979ce/668fcd16b52e46fbb03e2cc4_routing%20diagram.png)
You may notice that each time the quote refreshes, the route changes slightly. This is because as pricing changes across the liquidity sources, Matcha updates the route to ensure it is still getting the best price available!
With Matcha on 0x v2, you will know exactly how every trade you make is being executed, and rest assured that you’re getting a seriously good deal. Like what you see? Share a screenshot with your friends to show off Matcha’s new routing, and let everyone know where to get better prices on their trades.