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

Reduce error rates and enhance the swap experience for your users with real-time buy/sell tax detection and intelligent trade routing.

September 4, 2024

News

The rise of memecoins has led to an explosion of tokens with a buy or sell tax, also known as fee-on-transfer tokens (FoT), with ~25% of DEX users now trading these tokens on Ethereum. This category of tokens is part of a larger group of ERC20 tokens with custom properties – in this case, a “tax” is taken as a percentage of the swap when the token is bought or sold.

Buy/sell taxes throw a wrench into well built swap products, leading to not only high error and revert rates, causing headaches for developers, but also inaccurate quotes, leading to poor user experiences. They are the #1 cause of custom token related errors.

Until now, there hasn’t been a reliable way to get accurate, real-time information needed to properly support buy/sell taxes, leaving apps to rely on hacky workarounds, such as dynamically adjusting slippage tolerance, that don’t always work.

0x v2 solves this problem with real-time buy/sell tax detection and intelligent trade routing for the most reliable onchain execution in DeFi, minimizing error rates and enhancing the swap experience for your users.

“Whoops, something went wrong”

Custom token behavior isn’t a new phenomena that’s isolated to long-tail tokens and memecoins. Some of the most popular tokens have custom functionality that may not be apparent until you dig into the source code.

For example, USDC has custom rules that allow Circle to block, freeze, or directly modify the balance of any address. This is necessary for Circle to ensure compliance, mint and redeem USDC in exchange for US dollars, and transfer USDC across chains using CCTP.

Custom logic allows ERC20 tokens to be adapted for interesting new use cases, but the recent explosion of this new category of tokens with buy/sell taxes has also created challenges that impact developers and users alike.

Buy/sell taxes in particular wreak havoc on settlement contracts, as they wind up attempting to sell or receive less than what the quote demands. Some 0x integrators have reported up to 80% of all errors are due to custom token behaviors.

The lack of reliable buy/sell tax support in DeFi today results in high error and revert rates and inaccurate quotes, preventing apps from offering a truly robust swap product to their end users. Revert rates for trades that include tokens with buy/sell taxes on top aggregators can reach as high as 30% and aggregators often exclude taxes in quotes, potentially misleading users about the final amount they will receive.

The slippage of it all

Many current solutions to the buy/sell tax problem rely on querying an external static database of token properties to determine the buy/sell tax. This assumes a fixed percentage tax that applies uniformly to every trade. In reality, many taxes are dynamic and can vary by time, trade size, trade direction, liquidity source, volume, and apply to wallets in a non-uniform way. External data sources are also often incomplete or outdated.

In order to successfully execute trades with buy/sell tax tokens, swap products may attempt to use this static data to dynamically adjust slippage to account for the tax. However, hacky workarounds don’t always work.

Meddling with slippage to account for potential tax is a slippery slope. While it may lower error and revert rates in your app, if the slippage tolerance is set too low, the trade will revert. If it’s set too high, it opens users up to MEV attacks. Is it worth the trade-off? Not if there’s a better way.

Slippage is fundamentally a different concept from buy/sell tax, and it’s simply the wrong tool for the job.

Buy/sell tax support that just works

The most reliable method for delivering precise taxes to ensure that swaps go through every time is to run onchain simulations for a particular wallet and trade before returning a quote. That’s exactly what 0x v2 does. 

Instead of relying on static data, 0x v2 simulates each trade to detect and calculate the correct buy/sell tax in real-time and intelligently routes the trade through liquidity sources that support buy/sell tax tokens, minimizing errors and reducing reverts. 0x v2 also enables you to accurately surface the precise tax for a given trade to your users.

And it’s not just for a handful of tokens. With 0x v2, you’re guaranteed to have the widest coverage of tokens with buy/sell taxes because 0x APIs natively detect and factor in these costs upfront. From the time these tokens hit the chain, v2 is able to generate executable routes within an hour.

All of this means dramatically reduced error and revert rates, expanded token coverage, and an improved experience for your users. With 0x v2, you can say goodbye to hacky workarounds with buy/sell tax support that just works.

0x API v2 features
  • Returns valid quotes and calldata for tokens with a buy/sell tax in /price and /quote APIs
  • Returns the token’s custom behavior status via the API (buy/sell tax)
  • Returns the value of the tax via the API so that you can display it to your users
  • Returns the actual amount that the user will receive accounting for the buy/sell tax

Are you ready to get serious?

0x’s next-gen pricing engine is in open beta! v2 offers the most seamless swap experience at the best all-in prices with optimal trade execution, powerful new monetization features, and enhanced security.

Book a v2 onboarding call to get started.

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

Unlock powerful onchain insights with 0x Trade Analytics API

Nov 5, 2024

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

Take control of your balance sheet with 0x v2

Aug 15, 2024

0x v2 bug bounty program

Jul 30, 2024

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

Jul 23, 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