DeFi

·

July 15, 2024

Order routing in Matcha on 0x v2

Anthony Allen

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

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!
Low liquidity can lead to high price impact and bad pricing.

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
Notice that the route updates as markets change between blocks.

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. 

Matcha order routing achieves just 0.4% price impact on a $10M trade!

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. 

Contents
Subscribe to our newsletter
By submitting you're confirming that you agree with our Terms and Conditions.
Yay! You’re signed up.
Oops! Something went wrong, but it's not your fault.
DeFi

·

July 15, 2024

Order routing in Matcha on 0x v2

Order routing for serious pricing

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

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!
Low liquidity can lead to high price impact and bad pricing.

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
Notice that the route updates as markets change between blocks.

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. 

Matcha order routing achieves just 0.4% price impact on a $10M trade!

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. 

Subscribe for an instantly better inbox

By submitting you're confirming that you agree with our Terms and Conditions.
Yay! You’re signed up.
Oops! Something went wrong while submitting the form.