July 14, 2023

Best Execution in DeFi

tldr;

  • Best Execution has multiple factors – price, speed and privacy being the most important.
  • Each trading venue, optimizes for a different set of factors. Which factors matter more depends on what type of trade you make.
  • You can categorize trades simply by two factors: size (small or large trades) and signal (does your trade aim to capture signal or will it impact the market – or is it just transactional (no-signal)).
  • For each of the four categories of trades (small-signal, small-no-signal, large-signal, large-no-signal) a different venue will give you the best execution.

Introduction

Many venues promise best execution. But what is best execution?

This article defines the execution factors that matter for swaps, compares solutions head-to-head, and demonstrates which venue best suits each type of trade.

We aim to answer the question: Where should you swap?

First let’s look at the factors that make up good execution.

(Skip to the section “Four answers for four types of trades” if you just want to know where to swap).

Price, speed and privacy

Three main factors matter in defi execution: Price, speed and privacy.

Price

Price is the average exchange rate you received on your swap – net of any trading costs, such as gas fees.

It might seem obvious to compare venues by price, until you look more closely.

Comparing venues by price is surprisingly hard

You can't make the same trade simultaneously at two different venues on the same block. So comparing venues directly, trade-by-trade, is unrealistic.

What you can do is compare venues against a benchmark (e.g., Binance mid price). But this only works in aggregate, and not for individual trades.

And unfortunately, aggregates that average over many trades are not a meaningful guide for your specific trade – because price quality on the same venue varies strongly by the type of trade and how you execute it.

Quotes don’t tell you the best price either

Comparing quotes between two venues is inviting. But quotes don’t equal settlement prices.

You can open two exchanges in two windows, and then compare quotes.

But quotes don’t predict the price at which you settle. In fact, the chance that you settle for a better or worse price than your quote (price-to-quote ratio) differs by venue. And the chance of your transaction failing (failure rate) also differs by venue.

When you compare quotes, you want to know which venue gives you a better settlement price.

$$settlement\_price = \text{quote} * \text{price-to-quote_ratio} * (1 - \text{failure_rate})$$

But, price-to-quote and failure rate are unknown, and to make it more complicated – they both differ by the type of trade you make. So, quotes don’t tell you where you will get the best price either.

How you trade affects the price you get

Two traders using the same venue can achieve very different price quality.

Are you in a rush and willing to tolerate high slippage and high gas costs? Or can you wait for lower gas costs, take care to set the right slippage, and use a private RPC?

Do you buy everything in one go, or split it into several trades over time?

Same venue, different outcomes.

Two trades, same time, same pool (Uniswap) – but 0xa0 sold for 10% higher price than 0x7f – who got sandwiched. And the sandwicher (0xae) made the best deal of all. 3 traders on the same venue, with different execution strategies getting very different outcomes.

No-one offers the best price

Look at prices from different venues and this is what you’ll find: No venue consistently has the best price.

In fact, the price quality you get depends largely on how you execute your trade.

Now, picking a venue with a good price and executing well on it is important. But, sometimes, if you don’t settle fast enough, it’s all for nothing.

Speed

Most trades are time sensitive.

A signal drops, and traders race to capture it. Settling too late can turn a winning trade into a losing one.

Speed is not just the time between sending a tx and it being mined. The clock starts earlier: From when the idea for the trade is set in your mind, until the full trade amount has successfully settled on-chain.

How fast you can expect to settle varies significantly by venue. 

Luckily, as opposed to price, this – as we’ll see – is much easier to measure and compare.

But settling a good quote quickly is often not enough. You can still get rekt if your trade is not private.

Privacy

A trade is private when no-one knows about your swap until it’s settled1.

If your swap has information that could impact the market then you usually care about privacy – so that no one frontruns you.

Privacy also matters if your swap can be manipulated – for example when you set high slippage in a volatile market, but don’t want to get sandwiched.

Privacy is not binary

As we'll see, privacy isn’t binary. Depending on the venue, a smaller or larger set of people will know about your trade before it goes through. And this directly affects your execution quality.

Price, speed and privacy heavily shape how your trade will go. But there are a few more quite important factors.

Other factors for optimal execution

  • Gas costs: Gas can differ drastically (10x, 100x) depending on when and where you trade.
  • Failure rate: If your trade fails, it usually becomes public (you lose privacy); costs additional gas; gets delayed; and when it eventually executes, might get a worse price because you’re too late to capture the signal.
  • Quote-to-price ratio: Depending on the venue and the swap, the ratio of quote to settlement price (i.e. slippage) will vary.
  • Trading features: To what degree you can customize the execution of your trade on a venue also affects execution quality.

There is still more to swaps, but this should cover the most important factors.

How much each factor matters, however, depends entirely on your trade.

Grouping trades by signal and size

Here is a simple framework by which you can group your trade.

You can categorize your trade by whether it trades on or is signal (or Alpha), and what volume you move.

We split trades into four groups by:

Signal:

  • No signal: You swap unrelated to a signal (simply a transactional trade).
  • Signal: You trade because you expect prices to move (signal motivated trade) – or your trade itself can cause changes in the market (trade with signal). 

Example of no-signal trades: You rebalance a portfolio, you swap some ETH to pay your designer, etc. – typical transactional trades.

Examples of signal trades: You ape on a memecoin, you sell investor shares, you want to catch the bottom, you trade on news, or your trade has a price impact > 1%. 

Size:

  • Small: Gas cost makes up more than 0.5% of your trade.
  • Large: Gas makes up less than 0.5% of your trade.

On eth mainnet the cutoff is roughly at 5-20k $, on L2s ~ 1k $. The boundary is roughly at the point where DEX fees impact your price more than gas costs – and complex routing becomes relevant.

Once you know where your trade fits in this McKinsey chart, then the priorities for your trade are roughly clear and you can compare and decide on a trading venue.

Four answers for four types of trades

Let's see what matters for each group and then, for each, which venue gets you the best trade-off. 

Small transactional trades

Small trades that have no signal don’t benefit from privacy. And a few extra seconds faster settlement is also not important.

Gas costs, however, are very important. On small trades, gas makes up most of the cost, and gas optimization can easily benefit your more than a slightly better price quote.

For the same reason, you can’t tolerate your trade failing and then having to pay gas twice.

So good execution for a smol, non-signal, trade means: Reasonable quote, low gas and no chance of failure.

The best for small, no alpha, trades: Public Auctions

In auction protocols like 1inch Fusion, UniswapX and CowSwap solvers compete on net price after costs, so they are incentivised to find you the most gas-efficient route.

You also don’t pay any gas if your trade fails, and you can resubmit it at no extra cost.

Useful trick: Pick a shallow slope for your auction (for example by choosing a long auction time (e.g. 1h) on 1inch Fusion). Your trade will take longer to settle, but solvers will find you the lucky block where gas is lower. This can easily improve your price 0.1 - 1%.

For large trades though, things are different.

Big transactional trades

Like a small non-signal trade, a large one doesn't benefit much from privacy and speed.

However, now, price matters more than gas.

To get the best price you need access to all liquidity – and smart routing.

There are three major sources of liquidity:

  • Protocols: DEXs, but also non-DEX swap paths (e.g., minting DAI on Maker PSM).
  • Market makers: Professional counterparties that quote on request. MMs trade on many venues (e.g. Binance orderbook), and give you access to that liquidity through their quotes.
  • Other traders: Smart solvers can batch your trade with other trades and find coincidences of wants. This cuts out middleman costs on your trade and can significantly improve your price.

Smart routing will also most likely improve your price on large trades.

Batch auctions, like CowSwap, are a very good venue for large, non-signal, trades because you get a good chance that someone else in the batch trades into the opposite direction and you save on DEX fees (a coincidence of want).

Because the auction is won by whoever gives you the best price net fees – you truly can expect to get close to the best market price.

Dutch auction limit order protocols, like UniswapX and 1inch Fusion, are also good candidates, since they give you access to the same solvers and market makers. Your order there can also, by default, be filled smaller chunks at a time – which can improve your average execution price on larger swaps.

Another benefit of Dutch auctions is that prices automatically adjust downward slowly. This helps you to fill your entire trade with more certainty, whereas large trades can easily get stuck on batch auctions if the market moves and solver can’t fill anymore at your quoted price.

However, Dutch limit order protocols – as they are currently designed – have the risk that you loose value in a gas bidding war between solvers: The amount that your limit price dips below the fillable rate within a block is currently bribed away to builders. The same thing happens, even more drastically, when the market price for your asset changes quickly.

The decision can vary trade by trade – but overall batch auctions atm give the better trade-off on large non-signal trades.

So far, we covered small and big trades that have no alpha, but many trades aim to capture alpha or are alpha themselves. For them, the answers differ.

Small signal trades

When you aim to capture a signal, you usually care about speed.

You’re more tolerant on price, depending on how big your signal is.

Whether privacy is important for small signal trades depends mostly on whether you expect a volatile market: If the market is volatile and you therefore set high-slippage to not have your trade fail, then you need your trade to be private, otherwise it will be sandwiched.

While auctions are good for non-signal trades, they are too slow and too public for signal trades.

Interesting venues for signal trades are:

DEX UIs (such as Uniswap): If you know the right pool, and you have a pre-existing spend approval with that DEX, you can settle directly with the DEX and probably get a reasonable price.

But this has a major drawback: Different tokens are liquid on different DEXs and you’ll need to determine which one to go to each time and have pre-existing approvals with all. It’s a lot of work, and easy to make a mistake in the heat of the moment.

Direct-to-solver: A good solver sees all pools on all DEXs and routes your swap to the pools with the best price, while optimizing for gas.

Ideally you also use an RPC that privately broadcasts to builders, to keep your trade private and increase the likelihood that your swap makes it right into the next block.

We’ve saved the most exciting trades for the end: Big signal.

Big signal trades

Large signal trades are the most sensitive trades and the easiest to get wrong.

These include:

  1. Big trades that try to capture a signal (e.g., “SEC approves Blackrock’s Bitcoin ETF”).
  2. Big trades that will impact the market (e.g., You make a big bet on a small token).

For these trades, you usually care about all three major factors: You don't want anyone to know about it before it settles on-chain, you want the best price, and you want it to settle quickly.

Making these trades on a batch or Dutch auction protocol will likely result in a worse price, because the orderbook APIs of auction like CowSwap and 1inch Fusion are public, and bots can see your trade and easily frontrun you – which will worsen your price or censor your trade.

For the same reason, asking for quotes from market makers is also negative EV since you make your intent, and its signal, public to the market.

Direct-to-solver swaps like PropellerSwap are the best venue to execute large signal trades. A solver quickly calculates the best route through all on-chain liquidity, while keeping your transaction private, and executes it directly without delay.

Private RPC: Additionally, use a private RPC that forwards your transaction directly to trusted builders, so that your trade does not become visible in the public mempool and can not be frontrun or sandwiched.

(Note: Many private RPCs have an orderflow auction attached to them. This is counterproductive for large signal trades – since it makes your intent public again and you can be frontrun. Counter to their marketing, OFAs can not protect you against being frontrun.)

DEX-UIs like Uniswap can also be an option when there is only one pool for the asset you trade and you know the dex to trade on. However you should still use a private RPC to keep your trade private. 

A few examples of big signal trades:

  • Buying or selling amounts of tokens that will move the market;
  • Trades that react to signals (reacting to news, airdrops, whales, price-changes);
  • Trades that contain signals (team, investor, whale buy or sell or big portfolio rebalances);
  • Cross-chain arbitrage trades.

Approval leakage: Be careful with DEX approvals close to the time of a large sell. If you approve to sell 1mio $ worth of a token on Uniswap, bots can guess your intent to sell and short the token. Try to either bundle approval and swap, or make your approval long before the trade.

Other factors come into play depending on the trade and market, so if we haven’t covered an important case, please reach out and we’ll add it.

Overview of trading options

In the previous discussion, we mentioned several different trading options; here's a more complete overview of them.

  • Direct-to-pool: If you know where the liquidity is, then direct-to-pool can be fast and private (if you use a private RPC). But if the liquidity is spread out, this won't give you the best price. It's also not very reliable (liquidity could move), but is somewhat gas efficient.
  • DEX router: Most newer DEXs have an in-built router. Prices are better, but still not ideal, since they only route via their own pools. You have similar speed and a little less privacy (since you communicate your intent to the off-chain routing API).
  • Protocol native mint/redeem: In some cases, this can be very interesting. Say you want to swap a large amount of ETH for stETH, or you want to mint a lot of DAI with USDC, then going directly through the respective protocols can give you the best rate. It's more or less private, since these protocols are permissionless and decentralized and you don't need to ask any off-chain service before you trade.
  • Limit orders: Limit orders can be useful as a stop-loss or take profit. But they’re suboptimal for market swaps, since it's hard to set the correct price (you either set too low a price, or too high a price).
  • Dutch auction limit orders: A very good approach. This lets you settle near the best price on many swaps. But trades aren’t private; so trades with signal can be frontrun and/or censored and get a worse price.
  • Batch auctions: Similar to Dutch auctions. However, batch auctions also give you gas savings and coincidence of wants, both of which generally improve on the price a Dutch auction can get you. Like Dutch auction they are also not private though (even if you use a private RPC), and slow, making them unsuitable for a trade you want to keep private and/or execute fast.
  • Direct-to-solver: A very good approach, especially for large signal trades. They route orders optimally to achieve the best price (like auctions) but are also as fast and private as going directly to a DEX.

This is not an exhaustive list. The market has more options, as well as nuances within the categories that we haven’t touched.

Summary

You can usefully categorize roughly by size and signal. Non-signal and smaller trades are best solved via auctions (UniswapX, CowSwap); and signal trades directly via solvers (PropellerSwap).

If we haven’t covered important trade cases or options, or you’re looking to solve a specific trade case that we haven’t touched, reach out.

Keep Reading

Good Arbitrage is a Myth

Retail traders with the help of solvers make markets more efficient than arbitrage.
Read More

Intents and where to find them

What are intents? And where can you use them? A straightforward definition and a list of use cases.
Read More

MEV is disappearing

The tools to eliminate most MEV at the wallet and dapp level already exist; we just need to use them.
Read More