Introducing Slippage Protection for 0x API
Say goodbye to MEV attacks and say hello 👋 to the best executed price with Slippage Protection.
Today we’re introducing Slippage Protection, a new feature in 0x API that enables MEV-aware smart order routing for DEX trades. Slippage Protection incorporates slippage statistics into 0x API’s smart order routing algorithm to deliver the optimal trade route. With Slippage Protection, 0x API enables developers to surface more reliable quotes and consistently deliver the best executed price to their users.
What is the executed price? It’s the price that the end user receives, inclusive of gas fees and slippage, after the swap transaction is executed on-chain. This is an important distinction because many DeFi applications today only show quoted prices, which do not incorporate slippage and are often drastically different from the executed price.
Why we’re launching Slippage Protection
Over the past couple of years, we’ve seen significant growth in adoption of DeFi products. In 2021 alone, DEXes reported more than $1 trillion in trading volume. While this volume growth has been incredible, we’ve also seen millions of dollars lost to MEV.
Since 2020, MEV bots have extracted over $650M from DEX users, with nearly $27M extracted in the last 30 days. These losses typically manifest as slippage, which is only visible after trade settlement (i.e. after the trade has been mined into a block). Slippage typically goes unreported to the affected user.
In April 2022, we published a research piece that quantifies the extent of slippage experienced by DEX users and in which circumstances slippage is more likely to occur. One key observation we found was that larger trades experience significantly greater slippage. The findings show that AMM trades larger than $100k incur an average of >20 basis points (bps) of slippage.
How Slippage Protection works
Slippage Protection ingests slippage measurements and their statistical properties to model and predict slippage outcomes for different liquidity sources, trading pairs, and trade sizes. These model predictions are then incorporated into 0x API’s smart order routing to identify the route(s) expected to yield the best executed price. The result is a more transparent and consistently better executed price than what users encounter today in wallets and DeFi applications.
The following waterfall chart illustrates how Slippage Protection impacts 0x API’s smart order routing. Without Slippage Protection, the user is routed to Liquidity Source A because it offers the best quoted price. However, if Slippage Protection is enabled, 0x API’s smart order routing instead attempts to maximize the executed price, so the user is routed to Liquidity Source B instead.
With Slippage Protection enabled, users will also experience fewer failed transactions and save on otherwise wasted gas fees, resulting in an overall improved experience.
Slippage Protection is currently supported on Ethereum for the most active trading pairs (ETH-USDC, ETH-DAI, ETH-USDT, ETH-WBTC, WETH-USDC, WETH-DAI, WETH-USDT, WETH-WBTC). Over time, Slippage Protection will continue to evolve and improve with the addition of more data sets.
Let’s take a look at an illustrative example of an ETH-USDC swap.
Without Slippage Protection, we see an ETH <> USDC trade being routed 100% through Uniswap V3. In the second trade with Slippage Protection enabled, we see the ETH <> USDC trade being broken into two smaller trades and being routed to 0x’s RFQ (60%) and Uniswap V3 (40%). In the transaction with Slippage Protection enabled, the user receives 42 more USDC than they would’ve received without Slippage Protection. The amount of money saved by using Slippage Protection will vary depending on trade size but, on average, users should expect to see an outsized benefit on larger trades.
Start building with 0x API today
We’re excited to equip DeFi developers and enterprise users with the tools and infrastructure to offer the best DEX trading experience for their users.
Starting today, Slippage Protection is auto-enabled in 0x API and no additional integration is necessary. If you are a developer looking for more information about Slippage Protection and 0x API, get started with our developer docs. Enterprise users who require an API key, please contact us directly.
In the coming weeks and months, we plan to support more pairs and chains. To stay updated, follow us on Twitter.
0x API is a professional-grade decentralized exchange aggregation API for Web3 developers. Using the API, developers can easily and reliably tap into aggregated multi-chain DEX liquidity so they can focus on what matters: their product. To deliver the best prices, the API aggregates DeFi liquidity across various liquidity sources on a growing number of blockchains, including Ethereum, BNB Chain, Polygon, Avalanche, Fantom, Celo, and Optimism.