Swap
API
“As we push the envelope on advanced trade execution, we chose 0x as a key partner because of their stellar track record in onchain routing and execution. We trust the reliability of their infrastructure and ability to stay ahead of the curve in terms of multi-chain surface area and liquidity coverage. 0x v2 consistently offers very competitive quotes on Definitive.”
- Blake Arnold, Co-Founder and CTO of Definitive
Highlights
- Definitive, an advanced onchain trading platform, uses Swap API v2 as a key integration in its smart order router to provide end users with the best execution in DeFi.
- Best-in-class execution: v2’s advanced trade routing helps Definitive deliver the best all-in prices while ensuring trades hit the chain reliably.
- Quick integration: The Definitive team was able to integrate 0x v2 in one day.
- Wide coverage: With support for 8 chains and 140+ liquidity sources, 0x v2 provides Definitive with the deep liquidity required for advanced trade execution.
What is Definitive?
Built by Coinbase Institutional Trading alumni and active DeFi experts, Definitive is an advanced onchain trading platform servicing pro-traders, HNWIs, onchain institutions, DeFi hedge funds, and more.
With a mission to unlock the next era of onchain finance, Definitive is an onchain trading platform democratizing advanced trading tools for the masses. Definitive supports gasless, multi-chain EVM & SVM trading with Limit and TWAP orders across 100+ DEXs and liquidity venues. Definitive’s trading algorithms deliver the most powerful onchain trading experience without the need for users to understand all the complexities of trade configuration and optimization.
In this case study, we’ll take a look at how 0x v2 helps Definitive to provide the best trade execution for end users.
The challenges of onchain execution
One of Definitive’s core tenets is delivering the best execution for customers’ trades. Historically, trade execution in DeFi has never been able to match the power and quality of tooling that is commonplace on CeFi exchanges and prime brokers.
Delivering the best trade execution is a multi-faceted challenge that requires a number of capabilities, including inspecting onchain liquidity conditions ahead of each trade, setting guardrail parameters such as slippage and price impact, controlling execution costs such as gas fees, and bundling it all up for execution in a way that is not prone to MEV or frontrunning.
On top of this, liquidity has become increasingly fragmented with even more tokens, DEXs, and chains, adding complexity to the problem of delivering reliable, high-quality execution.
With traders facing fragmented liquidity, shallow markets, and lack of compliance and reporting, Definitive’s drive to deliver best-in-class swap execution led them to 0x.
When Definitive approached 0x, the team was looking to ensure that they were routing swaps to available liquidity from as many venues as possible (both DEXs and professional market makers) to return the best prices to end traders.
With both Definitive and 0x building in Web3 for years, the team naturally saw 0x as a market leader in the onchain routing and execution space. Time-in-market (without incidents and exploits) and a wide multi-chain and liquidity surface area were important factors in the Definitive team’s decision to integrate 0x.
Solution: Best-in-class trade execution with 0x v2
Definitive’s core execution engine leverages 0x v2 as one of its key integrations to achieve the best execution possible on nearly every chain Definitive supports.
Optimal execution
Order execution quality is a measure of how effectively a trading platform fulfills a trade intent. For Definitive, this means successfully fulfilling a trader’s intent with minimal attempts and adverse effects while still delivering the best execution price. As an advanced trading product, Definitive takes the complexity of configuring a trade for best execution out of the trader’s hands and into the hands of a finely tuned machine algorithm.
For instance, take slippage. Slippage is one of the most misunderstood concepts in onchain trading, and yet traders are expected to set arbitrary values for slippage tolerance ahead of each trade.
On top of this, it’s not enough to minimize MEV losses but also important to avoid reverts. On average, 8-10% of DEX transactions fail, and that number can spike to as high as 20%. What good is the best price if users are constantly wasting gas on failed trades or missing out on the latest opportunity?
0x v2 helps solve these complexities with advanced trade routing built to optimize for execution quality. v2 identifies the route expected to yield the best all-in price across all pairs and trade sizes at lightning fast speed and with the lowest revert rate in the industry.
0x’s state-of-the-art Argon Router delivers the optimal execution path by optimizing on two dimensions: multiplex and multihop. By splitting a trade across multiple liquidity sources and identifying intermediate token steps which open up even deeper liquidity, v2 can make optimal use of onchain liquidity.
To open up additional, slippage-free venues for trade route optimization, 0x v2 also features a revamped RFQ (request for quote) system, unlocking exclusive CEX-like liquidity from sophisticated market makers. Designed to minimize the impact of sandwich attacks and MEV, 0x saves users an average of ~50-80% on slippage.
Onchain trades also require gas for token approvals and to submit transactions onchain. DEX aggregators can be over optimistic when it comes to estimating how much gas a trade will cost, which can impact the price or lead to the trade failing. With 0x v2, advanced gas awareness ensures real-world gas costs are factored into the quoted price, resulting in more accurate quotes and near-zero revert rates.
Together with 0x v2, Definitive minimizes price impact, slippage, and gas, while ensuring trades hit the chain reliably, offering every user a real-time quant algorithm that optimizes swap parameters to perfection ahead of every trade.
The result? Measurable improvements even in trades of near perfectly correlated pairs. For example, Definitive has seen swapping WBTC for cbBTC through 0x v2 on Definitive can result in 0.2% more cbBTC than swapping on Uniswap.
Best all-in prices
As we’ve seen, execution quality matters when it comes to onchain trading. These hidden costs - slippage, gas, and buy/sell taxes, can lead to drastic differences in the quoted price apps show users and the actual value they receive. When reality doesn’t meet expectations, users are left feeling shortchanged.
Quoted price should be taken as an estimate that can vary in accuracy. 0x v2 is specifically built to optimize for all-in prices, that 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.
And yet, many apps still only rely on quoted prices, despite the fact that they may not be representative of all-in prices. One solution to this problem is to simulate trades beforehand to verify the accuracy of quotes and ensure users are getting the best all-in prices.
Being committed to delivering the best execution, Definitive does just that. Because multiple parties are involved in executing trades, simulations are crucial to validating the reliability of quotes and ensuring the best trades for users. Simulating trades allows Definitive to track when simulations and actual execution drift in real-time and adjust routing accordingly.
This enables Definitive to compare multiple aggregators against each other to ensure the best execution, and thus best all-in prices, for end users. By simulating all aggregators quotes in the same block, the team ensures a fair comparison for the gas-inclusive swap rate without having to rely on quoted amounts.
Definitive’s Smart Order Router finds the best price for every trade across the full universe of onchain venues - continuously profiling which venues are most reliable and non-exploitative for successful trading and dynamically adjusting order routing to ensure the smoothest experience for the end user.
Definitive has found that 0x v2 consistently offers reliable and competitive quotes. In the 3 week period post-integration, 0x v2 accounted for 20% of all volume on Definitive.
Ease of integration
Definitive was able to tap into 0x’s wide range of token and chain coverage with just one day of coding and testing, ensuring the deep liquidity required for best execution across a multitude of chains.
Built for developers, 0x Swap API v2 makes it easy for onchain apps to access 7+ million tokens across 10 chains with liquidity from 140+ exchanges - all with just a few lines of code.
Start building with 0x v2
Built to meet the needs of growing Web3 businesses, 0x v2 offers the most seamless swap product for developers with optimal trade execution, powerful new monetization controls, and enhanced security baked in at the ground level.
0x v2 is the next-generation trading engine for serious onchain apps. Join over a dozen teams, including Definitive, Matcha, and Coinbase, already building with 0x v2.
Sign-up for a free account on the 0x Dashboard to get started.
1 day
to integrate
20% of volume
supported in first 3 weeks
Ready to get started?
Create a 0x account and embed swaps in your app, for free, in less than five minutes.