Decentralized Exchanges Have a Problem

The perils of front-running on the blockchain

Illustrations by Lea Filipo.

There’s an unsettling contradiction in the cryptocurrency space: Decentralized assets are almost exclusively traded on centralized exchanges.

This isn’t breaking news. A number of projects have already launched alternative decentralized exchanges (or DEXs) — notably IDEX and Ether Delta — to resolve this mismatch.

It’s a noble pursuit. DEXs promise to cut out the middleman and give crypto-holders full custody over their assets. But so far they’ve gained relatively little traction — while today’s decentralized exchanges measure daily volume by the thousand, centralized exchanges measure daily volume by the billion.

There are some obvious culprits for this pretty massive gap in use.

Compared to their centralized counterparts, DEXs can have poor liquidity, lousy user interfaces, and lack more advanced trading tools like margin or leverage. While all these shortcomings are undeniably valid, there’s another problem with DEXs that is consistently understated: order front-running.

In what follows, I’ll explain what front-running is, why it flourishes on DEXs, and how we can fix it.

In a Nutshell

Front-running occurs when someone with advanced market information steps in front of a trade for economic gain.

Here’s the basic recipe:

Gain access to market order information that will increase the price of X. Buy X before the guaranteed price increase. Sell X after the guaranteed price increase. Profit.

The practice of market front-running first gained traction in the centralized exchanges of Wall Street, as popularized by Michael Lewis’s Flash Boys.

A decentralized exchange, however, shifts the playing field for front-runners, introducing new parameters that must be accounted for. Two of these new considerations are especially noteworthy.

With DEXs:

Market information is public. Anyone plugged into the blockchain can monitor (and capitalize on) incoming bid orders, sell orders and even cancellations. Trading is slow. In decentralized exchanges, there is an inevitable time delay between when a blockchain transaction is broadcast and when it is ‘mined’ or validated.

The key takeaway here is that decentralized exchanges make it easier for anyone to exploit temporary market inefficiencies for a profit. In other words, it’s easier to front-run the market.

Mining Profits

The problem of front-running really escalates when you introduce cryptocurrency miners into the equation. Miners can directly affect the order in which transactions on a DEX are executed — an ability which can lead to all kinds of unsavory outcomes.

Picture two actors who star in a short but tragic play: a malicious miner and an absent-minded trader. In the opening scene, the trader — brimming with confidence that he’s detected an opportunity to ‘buy the dip’ — places an order on his favorite DEX. In his haste, the trader mistakenly types an extra zero for the order quantity. Realizing the mistake, the trader cancels the order. But it may be too late.

A malicious miner spots the transactions on the blockchain and willfully sandwiches a sell order between the traders’ mistaken buy order and subsequent cancellation request. The trader’s fate is sealed: the original trade goes through, pumping the price, the miner unloads their unwanted crypto-tokens at an above-market price, and the subsequent cancellation request simply fizzles out.

This is just one (slightly simplified and dramatized) example of how miners can game DEXs for a profit.

By the Numbers

DEX transparency gives front-runners an advantage. But it also gives academics like Cornell Tech’s Philip Daian an inviting research opportunity. (I strongly recommend checking out a recent talk he gave at Devcon iv here.)

Daian and his team conducted a series of tests to measure the potential profits of front-runners on Etherdelta, most recently the third largest decentralized exchange by trading volume.

Their findings?

In August 2017, a clever front-runner could net ~$4,500 per day or $1.6+ million a year through Etherdelta alone. If you adjust this to today’s ETH price of ~$150, it would be a more modest, but still substantial, $1.5 million a year income (assuming equal trading behavior and volume).

That’s not a bad salary if it’s only split between a few people. But it’s also peanuts relative to the broader market. The real problem arises if DEX adoption and overall trading volume ramp up and a $1 million opportunity becomes a $1 billion opportunity.