Announcing 0x API v1

Announcing a new version of 0x API’s swap endpoint, the best DEX aggregator.


  • 7 out of 10 times 0x API offers better adjusted prices than 1inch, Dex Ag, Paraswap and Uniswap. That is, the price after transaction fees are paid.
  • 0x API v1 delivers market-leading gas efficiency. With a custom, highly-optimized architecture, accessing Uniswap’s liquidity through 0x API is now as cheap and often cheaper than going to Uniswap directly.
  • DeFi developers can find the 0x API docs here. Existing integrators can use this guide to migrate to v1.
  • Traders can go to Matcha — which uses 0x API under the hood — to buy and sell assets at the best price possible across all DEX liquidity sources.

In January 2020 we launched v0 of 0x API, a public tool designed to make it simple for DeFi developers to tap into all DEX liquidity in a fast and reliable way. Since launch, 0x API has processed over 29K trades that in total represent ~$550 million in trading volume.

0x API monthly volume since launch 🏒

The version 0 release represented a solid starting point, but it was clear that there was still plenty of room for improving and pushing the DEX aggregation space forward. So, we spent the last eight months gathering feedback and iterating, and today we are proud to launch a revamped 0x API v1: the highest-performing, professional-grade DEX aggregator in the industry. For 7 out of 10 trades, users get a better adjusted price through 0x API than through 1inch, DexAg, Paraswap and Uniswap.

With a simple http request, developers can fetch the best available price across 13 liquidity sources — including exclusive 0x liquidity from professional liquidity providers and proprietary AMMs, as well as 0x Mesh, Uniswap, Oasis, Kyber, Curve, Balancer, Bancor, mStable, Mooniswap, Sushiswap and Swerve. In addition to fetching prices from these liquidity sources, under the hood the /swap/quote endpoint leverages smart order routing algorithms to split orders across sources to reduce slippage and achieve the best price for a given trade.

Quoted versus Adjusted Prices

We built 0x API v1 with one goal in mind: offering the best prices after accounting for transaction costs.

These days it is not uncommon to see screenshots comparing quotes between DEX aggregators for a given trade on Twitter. The problem with this is that comparing aggregators on quoted prices is a bad business for users as often the best quoted price does not result in the best deal once transaction costs are paid. We believe that using adjusted price is a more objective metric and a better way to measure performance between aggregators as it is what the user ultimately gets in their wallet. Wait, but why?

Adjusted price is what a user receives after a transaction is completed on-chain and transaction costs (gas and fees) are paid. It can be calculated using the following formula:

adjusted_price = sold_amount_usd / ( bought_amount_usd — transaction_costs_usd )

Let’s use an example to illustrate this:

A user wants to trade 100 DAI for USDC. Aggregator #1 quotes 100 USDC with a transaction cost of $5. Using the formula above, we can determine that adjusted price = 100 / ( 100–5 ) = $1.05.

The same user checks out a second aggregator. Aggregator #2 quotes 104 USDC for the same 100 DAI, but with a transaction cost of $10. In this case, adjusted price = 100 / (104–10) = $1.06.

In this example, Aggregator 1 wins as it ultimately finds a cheaper rate for the user to convert 100 DAI to 100 USDC. While aggregator #2 initially quoted a better rate and bought more tokens, you can observe how the transaction cost impacted the adjusted price. In conclusion, spending an additional $5 to only receive an additional 4 USDC resulted in a more expensive deal for the user.

The majority of existing aggregators seem to optimize to win quoted prices and attract users, but we often see them failing at delivering the best adjusted price. By optimizing for adjusted prices and accounting for gas costs in 0x API smart order routing, 0x API offers the best adjusted prices 7 out of 10 times.

Quoted and adjusted prices winning rates for 0x API, 1inch, Dex Ag, Paraswap and Uniswap. 0x API outperforms other exchanges ~72% of the time by offering better prices after accounting for gas.

Reducing Gas Usage

Reducing gas usage has been a focus for our team for the past eight months. Our initial target was to cut down transaction costs by 50%, however, in 0x API v1 we achieved to cut down transaction costs, on average, by ~76% vs v0. Gas usage is currently around 460K gwei for a $50K trade, down from 1.5M gwei for the same trade in v0. These optimizations have turned 0x API into the most efficient aggregator across all trade sizes.

While, on average, 0x API uses more gas than Uniswap, 0x API offers better adjusted prices than Uniswap 7 out of 10 times. How is this possible? At 0x Labs we built a super optimized contract that allows 0x API to source liquidity that is 100% routed through Uniswap in a more gas efficient way than the default Uniswap contracts. This is particularly beneficial for smaller trades (<$5K), which are typically routed to a single source.

To exemplify this, let’s take a look at the following two transactions:

0x API v1 delivers market-leading gas efficiency. With a custom, highly-optimized architecture, accessing Uniswap’s liquidity through 0x API is now as cheap and often cheaper than going to Uniswap directly.

The first transaction (left) shows an ETH<>UNI trade made by going directly to Uniswap. The second transaction (right) shows an equivalent ETH<>UNI trade being 100% routed to Uniswap via 0x API. As shown in the “gas used by transaction” field, the Uniswap transaction cost ~114K gas and the 0x API transaction cost ~110K gas, that is 3.7% cheaper. Certain on-chain state and conditions can change the results (for example, if the user needs to set new allowances), but in general, using 0x API to trade on Uniswap is now as cheap and often cheaper than going to Uniswap directly.

What’s else is new in v1?

  • Nine new liquidity sources for a total of 13, with new ones being added frequently.
  • Two 0x API exclusive liquidity sources: 0x RFQT and 0x private AMM.
  • The 0x protocol fee is no longer incurred for external liquidity sources, lowering transaction costs further.
  • Last-minute, on-chain routing to adjust (and often improve) quotes for market movements that can occur between submission and on-chain confirmation.
  • A new settlement contract that allows us have more accurate fills and gas usage lower than any other aggregator.
  • Multi-hop, a new piece of logic in our smart order routing that allows us to bridge liquidity to illiquid markets.
  • A super optimized contract that allows 0x API to source Uniswap in a more gas efficient way than the default Uniswap contracts.
  • Support for ERC20>ETH trades.
  • Support for affiliateFee, a percentage based fee integrators can add to monetize their product.
  • excludedSources, a parameter that allows integrators to exclude specific sources from the routing.
  • New /meta_transaction endpoints that allow integrators to remove or defer the requirement that the user must pay for gas and protocol fees with ETH. It provides a superset of the liquidity available via the /swap/quote endpoint.

Integrate with 0x API v1

Join our existing integrators like Matcha and offer your users the very best prices across all DEXs.

If you are a developer looking to integrate with the best DEX aggregator you can find our updated docs here.

If you are an existing integrator using v0, the migration process to v1 is quite simple. We wrote this guide just in case.

Read more about how v1 outperforms 1inch, Dex Ag, Paraswap and Uniswap here.

Questions or feedback about 0x API? Join the conversation in our dedicated Discord channel #0x_API-help.


Sign in or become a 0x Blog member to join the conversation.

Ready to build on 0x?

Get Started

Chat with the community

Join 0x Discord