What does the "best price" in DeFi really mean?

In DeFi, the hidden costs of DEX trading can lead to drastic differences in the quoted price you’re showing users and the actual value they receive.

July 23, 2024

Under the Hood

Are your users getting the best prices, all-in?

We all know the frustration of getting to the checkout page of a vacation rental or ticketing platform only to find that you’re paying much more than the advertised price after factoring in every fee under the sun. When expectations don’t meet reality, users are left feeling shortchanged. 

In DeFi, the hidden costs of DEX trading can lead to drastic differences in the quoted price you’re showing users and the actual value they receive - creating a poor trading experience for users.

Many applications in DeFi today still only show the quoted price, which doesn’t take into account the range of variables that can alter the final price of a trade, such as gas fees and slippage. Providing the best all-in price across every token pair, trade size, and chain is a multi-dimensional problem that requires a holistic understanding of tokens and their liquidity.

In this article, we’ll peel back the curtain on execution quality in DeFi and take a look at how 0x’s next-gen pricing engine delivers the best all-in prices.

Looking beyond the “quoted price”

Order execution quality is a measure of how effectively a trading platform fulfills buy or sell orders. In other words, how closely the quoted price reflects the final value that a user receives. In DeFi, there are essentially three different prices that are important throughout a trade: quoted, executed, and all-in price.

When trading through an app, users are often attracted to using one over the other because of the quoted price of the token they’re looking to trade. As a result, this metric is often used to measure the performance of aggregators.

The importance placed on quoted prices creates a perverse incentive for aggregators to quote the best price and thus win the trade, regardless of whether users can actually trade at that price.

So, which price really matters?

Quoted price: The quoted price is the “sticker price” of the token, the price that users are advertised and see for a given trade on an app. This price should be taken as an estimate that can vary in accuracy.

Executed price: The executed price is the price at which a trade was completed, after accounting for factors that impacted the price or completion of the trade during the time it takes to settle. 

All-in (settled) price: The all-in price is the final amount a user receives after completing a trade that accounts for the cost of executing it and any variability that happens on-chain, including gas fees. This is the Golden Metric that we optimize for.

Why execution quality matters

Our next-generation pricing engine, 0x v2, was built to optimize for execution quality - identifying the route expected to deliver the best all-in price. To understand how, we need to look at the factors that impact the settled price of a trade.

Liquidity, liquidity, liquidity

Liquidity and price impact can drastically affect trading outcomes. Price impact is the influence that an order can have on the market price of the token being traded. It is directly correlated to a token’s liquidity, but is also dependent on a variety of other factors, including the size of the trade and the volatility of the token.

For trading pairs with limited liquidity, like long tail pairs, price impact can be particularly high. But even pairs with significant volume can suffer from thin liquidity between the buy and sell token. In these cases, the ability to hop across multiple intermediate tokens, going from Token A to B to C to D, enables the optimal use of on-chain liquidity. 

For example, let’s say a user is trying to trade a large amount of WBTC to DAI. Both are large market cap tokens with lots of liquidity, but there is very little direct liquidity between these two tokens. To get the best price for this swap, the trade needs to be routed through a multitude of liquidity sources and intermediate tokens along the way.

Deep liquidity and advanced routing are key to getting the best prices and avoiding significant price impact. 0x’s new Argon Router utilizes a state-of-the-art algorithm to deliver the optimal execution path for a trade, optimizing on two dimensions:

1. Multiplex: Splitting a trade across multiple liquidity sources.

2. Multihop: Identifying intermediate token steps which open up deeper liquidity.

Alongside aggregating liquidity from 120+ AMMs, 0x v2 also features a revamped RFQ (request for quote) system, unlocking exclusive CEX-like liquidity from sophisticated market makers and opening up additional avenues for trade route optimization. 0x RFQ outperforms AMMs on price 46% of the time where available.

Gas (un)aware 

All trades on decentralized exchanges require gas for token approvals and to submit transactions onchain. Often, DEX aggregators will be over-optimistic when it comes to estimating how much gas a trade will cost. Inaccurate gas estimation can impact the all-in price or lead to the trade failing - resulting in poor prices and high revert rates, both of which can lead to user churn.

With 0x v2, advanced gas awareness ensures real-world gas costs are factored into the quoted price. v2’s gas estimation is 1.5 times more accurate than v1, resulting in more accurate quoted prices and near-zero revert rates.

For small trade sizes, this becomes particularly important. And if a user is swapping frequently, the cost can become significant. You want your users to get the best price even when the trade is small and gas is high. 0x can do both, complex or simple depending on what a user needs (trade pair and size) and when they need it (gas price). 

Slippage

DEX trades also suffer from slippage. Price slippage refers to the change in the price of an asset caused by external market factors and not the trader’s individual trade, often by MEV attacks.

After a price is quoted and the trade is confirmed, it enters the public mempool among other transactions that are awaiting to be settled upon the mining of a new block.

While the average user isn’t aware of the trades others are making, there are others that are actively watching the sequencing of transactions and use bots to reorder transactions prior to the block mining in order to skim value off of trades.

In just the past month, MEV bots have extracted over $72 million from traders. Slippage also increases as trade size increases. For large trades, slippage can be the difference in tens of thousands of dollars. Slippage is only visible after trade settlement and typically goes unreported to the end user. 

Enter 0x RFQ yet again. RFQ provides a quote that is “custom” for the trader and the rate of exchange defined by the quote is enforced at the smart contract level. Meaning, quoted price equals executed price, period. RFQ opens up slippage-free trade routes to help shield users from MEV attacks.

Failed trades

What good is the best quoted price if trades constantly fail? When a trade fails, it costs users time, money, and opportunity. Trades can fail for a variety of reasons, including lack of liquidity sources and insufficient gas.

0x v2 puts an end to failed transactions with the lowest revert rates in the industry, up to 10x lower than 1inch. Lower revert rates mean more successful trades and a better trading experience for your users.

Optimal trade execution at the best all-in prices

It’s clear that the “best price” in DeFi is not just about the “quoted price”. We need to optimize for the best all-in price - accounting for gas, slippage, and other factors that impact the actual value users receive when they complete a swap.

Along with optimizing for the best all-in price, swaps also need to be fast and reliable. What good is the best price if users are constantly wasting gas on failed trades or missing out on the latest opportunity?

0x v2 utilizes a brand new state-of-the-art pricing engine to identify the route expected to yield the best all-in price, all at lightning fast speed and with the lowest revert rate in the industry. 0x v2 beats 1inch ~90% of the time across all trade sizes, with up to 10x lower reverts.

Deliver the execution quality and trading experience your users deserve with 0x v2.

Ready to get serious?

0x v2 is currently in open beta. Book a v2 onboarding call to get started.

We’ll be sharing more details about our redesigned router, aggregation capabilities, and smart contracts over the next few weeks.

Contents

Subscribe to 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.

Up next

Fundamentals: Smart Contract Wallets

Oct 15, 2024

Compliance made easy with 0x Address Screening

Sep 26, 2024

0x's next-gen pricing engine is now live

Sep 25, 2024

Introducing state-of-the-art Buy/Sell Tax support

Sep 4, 2024

Take control of your balance sheet with 0x v2

Aug 15, 2024

0x v2 bug bounty program

Jul 30, 2024

Eliminate allowance risk with Permit2

Jul 17, 2024

Introducing 0x's next-gen pricing engine

Jul 15, 2024

0x Dev Digest: May 2024

May 31, 2024

Frame spotlight: Paycaster

May 21, 2024

Frame spotlight: Airstack

May 9, 2024

Power up your Farcaster Frames with 0x swaps

May 2, 2024

0x Dev Digest: April 2024

Apr 30, 2024

Introducing 0x Trade Analytics

Mar 12, 2024

Coinbase Case Study

Jan 30, 2024

Introducing gasless swaps and approvals with Gasless API

Jan 22, 2024

Bitcoin ETFs have arrived

Jan 12, 2024

Building in the open: 0x pricing update

Dec 11, 2023

Matcha leverages Gasless API to bring users the most frictionless trading experience in DeFi

Nov 30, 2023

0x Dev Digest: October 2023

Nov 2, 2023

Monetize crypto trading in your app with Swap API

Oct 26, 2023

0x Dev Digest: September 2023

Oct 3, 2023

A comprehensive analysis of RFQ performance

Sep 26, 2023

Unlock optimal trades in Swap API with 0x RFQ liquidity

Sep 20, 2023

0x Dev Digest: August 2023

Aug 31, 2023

Portal launches swaps in its white label MPC wallet powered by 0x

Aug 16, 2023

0x Swap API is now live on Base

Aug 9, 2023

Introducing paid plans for Swap API

Jul 24, 2023

Decreasing Frictions in DeFi hackathon recap

Jul 12, 2023

0x's pricing principles

Jul 3, 2023

0x Dev Digest: June 2023

Jun 30, 2023

App spotlight: tastycrypto

Jun 27, 2023

App spotlight: 31Third

Jun 22, 2023

0x 101: Intro to gasless API

Jun 13, 2023

Inspiration for building with Swap API

Jun 8, 2023

0x Dev Digest: May 2023

May 31, 2023

Fundamentals: What are gas fees?

May 25, 2023

Decreasing Frictions in DeFi Hackathon

May 12, 2023

Swap API liquidity management

May 18, 2023

0x 101: Getting started with Swap API

May 16, 2023

0x 101: Intro to Swap API

May 9, 2023

0x 101: Intro to 0x Orders

May 4, 2023

0x 101: Intro to 0x Protocol

Apr 27, 2023

A new home for 0x Protocol

Apr 24, 2023

Say hi to the new 0x

Apr 20, 2023

0x Year in Review 2022

Jan 5, 2023

0x Swap API expands to Arbitrum

Sep 22, 2022

Managed liquidity

Apr 23, 2020

0x Smart Order Routing

May 19, 2020

App spotlight: Taho

Mar 8, 2022

Fundamentals: What is a Layer 2 chain?

Apr 19, 2023

Fundamentals: What is the difference between quoted, executed, and adjusted prices?

Apr 19, 2023

Fundamentals: What is price impact?

Apr 19, 2023

Fundamentals: What is slippage?

Apr 19, 2023

Fundamentals: What is an automated market maker (AMM)?

Apr 19, 2023

Fundamentals: What is market making?

Apr 19, 2023

Fundamentals: What is a DEX aggregator?

Apr 19, 2023

Fundamentals: What is liquidity?

Apr 19, 2023

Fundamentals: What is a decentralized exchange (DEX)?

Apr 19, 2023

0x at ETHDenver 2023

Mar 21, 2023

The 0x Mission and Values

Jun 7, 2018

Announcing support for new testnets

Aug 10, 2022

0x Swap API expands to Binance Smart Chain

Mar 17, 2021

Scaling DeFi — Layer One

Sep 1, 2021

Introducing Slippage Protection

Jul 14, 2022

San Francisco Blockchain Week 2022 Recap

Nov 21, 2022

0x Swap API adds new liquidity sources

Jul 11, 2022

Review of slippage performance

Sep 14, 2022

Phuture case study

Oct 20, 2022

Measuring the impact of hidden DEX costs

Apr 14, 2022

Market making in DeFi

Aug 12, 2021

Introducing 0x Labs

Jun 22, 2020

Introducing 0x Explorer

Oct 26, 2022

Growing DeFi with professional market makers

Aug 26, 2020

0x 101: How to Access 0x Data

Apr 25, 2023

GameStop chooses 0x Swap API

Jul 8, 2022

Build on Base with 0x

Feb 23, 2023

A comprehensive analysis on DEX liquidity aggregators’ performance

Oct 1, 2020

Announcing 0x Swap API v1

Oct 1, 2020

Access all DEX liquidity through 0x Swap API

Jan 28, 2020

Announcing the 0xpo Summit 2022

Aug 24, 2022

0x Protocol, a preview of what’s to come

Mar 16, 2023

Update to our Privacy Policy

Mar 14, 2023

Price Impact Protection has arrived

Dec 14, 2022

0x Limit Orders Go Multi-Chain

Dec 23, 2021

0x Labs raises $70M Series B led by Greylock to continue expanding Web3’s core exchange infrastructure

Apr 26, 2022

0x launches Tx Relay API in beta, with Robinhood Wallet as first partner

Mar 1, 2023

0x Labs raises $15M Series A to bring decentralized exchange markets to a global audience

Feb 5, 2021

App spotlight: Zerion

Jun 22, 2022

App spotlight: Matcha

Nov 24, 2021

App spotlight: DexGuru

Jun 17, 2021

App spotlight: DEXTools

Sep 23, 2021

App spotlight: DODO

Aug 10, 2021

App spotlight: DappRadar

Dec 16, 2021

App spotlight: DeFi Saver

Jul 20, 2021

0x + Brave partner to make crypto and DeFi more accessible to everyone

Jul 7, 2021

0x Swap API now supports 0x Protocol v4

Mar 1, 2021

0x Swap API is now available on Fantom

Oct 26, 2021

0x Swap API is now live on Optimism

Jan 11, 2022

0x Swap API is now available on Polygon

May 31, 2021