Front Running and its Effect on Decentralized Exchanges

Jul 26, 2018 · 5 min read

Since the era of barter trade, traders lacking in scruples have sought ways to defraud their counterparty, with earlier tricksters employing modified scales as a way to cheat in commerce.

The invention of money and the internet created a globally networked marketplace with more opportunities for cheaters to exploit. Dishonest brokers leverage their superior knowledge and high-frequency trading algorithms to profit off schemes such as front running. Efforts to restrain immoral financial behavior relies on sophisticated financial legal systems and an enforcement network robust enough to punish offenders.

Today, decentralized financial infrastructure is being laid to achieve trustlessness, rendering judges and lawyers redundant.

In trustless systems, we do not rely on participant’s morals and ethics in maintaining the health of the system. Rather, the challenge lies in designing incentive mechanisms that make it unprofitable if not outright impossible to cheat, leaving fair-play as the only dominant strategy from a game theory perspective.

In trustless systems, we do not rely on participant’s morals and ethics in maintaining the health of the system. Rather, the challenge lies in designing incentive mechanisms that make it unprofitable if not outright impossible to cheat, leaving fair-play as the only dominant strategy from a game theory perspective.

Running from the front

In the traditional financial markets, front running is a tactic used by unsavoury brokers and other centralized entities to generate profit from their advanced knowledge of customer trades. Brokers can insert their own orders before executing their customers’ trades in anticipation of a price movement caused by the forthcoming trades. Bank of America Merrill Lynch agreed to pay $42 million in fines after they were caught falsifying paperwork on 16 million orders from their institutional clients.

Clients were under the impression that their trades were taking place in-house, all the while BoA had been routing their orders to electronic market makers. These market makers employ high-frequency trading algorithms, allowing them to hop in front of incoming trades and profit lucratively at the expense of Bank of America’s customers.

Front running on decentralized exchanges

While centralized systems have indeed provided some egregious examples of front running, decentralized exchanges are not entirely immune to the practice of front running. Once a trade is broadcast to the blockchain, it awaits verification from miners who decide which transactions to include in the following block. Since the frequency of incoming transactions often outweighs the capacity of the subsequent block, transactions not mined immediately sit in a pending transaction pool, also known as a mempool.

However, the transparent nature of a blockchain mempools enables front runners to enter their trades first, profiting on the resulting price movements when prior orders are finally executed. By setting a higher gas price and making it attractive for miners to prioritize their transaction, these malicious actors can ensure that their trade executes before the transaction they are attempting to front-run. Furthermore, miners can participate in front running themselves by choosing to execute their own trades ahead of time.

Find me a taker

Since a publicly-hosted order book is a honeypot attracting front runners, the simplest way to prevent front running is to avoid public markets altogether by finding a taker to fill a given order. Once the taker is found and a price negotiated, the exchange can take place trustlessly on-chain.

Airswap is a decentralized exchange that enables users to find counterparties for trade privately. An indexer aggregates ‘intent to trade’ from both makers and takers, opening up a channel of communication between them once they have been matched. Thereafter they agree on a price using Airswap’s price oracle as a starting point for negotiation.

Don’t stop the flow, create a better funnel

The 0x project is laying the foundations upon which a diverse decentralized exchange ecosystem is to be built and as such, they devote considerable effort to tackling the issue of front running. They propose a series of smart contracts through which orders can be funneled, removing execution control from the users and putting it in the hands of complex systems of logic. For example, a compliant securities exchange with enhanced Know Your Customer requirements could enforce compliance by funneling orders through a whitelist of acceptable Ethereum addresses. In this way, only traders who have satisfactorily undergone identity verification can access their order books. Similarly, the smart contract funnel can be utilized to enforce rules regarding trade execution in a way that eliminates unwanted trade collisions such as front running.


The challenge of preventing information leakage in multi-party transactions, when publicizing an individual’s decision may adversarially influence the behavior of said individual’s counter parties predates the blockchain and decentralized exchanges.

Auctioneers use first-price sealed-bid auctions, or blind auctions, as a way to entice bidders to bid their true valuation of an item, irrespective of the preferences of others. Commit-reveal schemes such as the blind auction can be employed on the blockchain in order to disclose information selectively such that front running is precluded. In the commit-reveal scheme proposed by the 0x framework, a maker initiates a trade by cryptographically signing an order which is then added to the open order book. A taker can then commit to an attractive offer by signing an order declaring intent to trade, effectively ruling out other parties from filling the order. While this transaction sits in the mempool, onlookers are prevented from viewing the order details. Once this transaction is mined, the order details are then revealed to the commit-reveal smart contract. However, since the order has already been preassigned to the taker, observers can look but they cannot touch this impending trade.

Just as designers of ‘analog’ economies need to preclude unethical behavior such as front running, so too in order to thrive, blockchain economies require efficient mechanisms for dealing with potential cheaters. However, while the traditional financial system deploys an army of lawyers and congressmen to legislate against dubious financial practices, the blockchain economy is occupied with designing protocols that preclude cheating. Using a combination of cryptograhpy and incentive mechanisms, blockchains allow for the creation of bespoke economies that can be stressed tested in real-time.

Successfully defending against front runners will provide decentralized exchanges, and by extension the entire crypto market, with a platform to reach mass adoption.

Written by: David Azaraf

Get Started with Totle

To start using Totle, access the API here: Build with Totle

Easily convert tokens with Totle: Totle Swap

Follow us on Twitter, Facebook, Telegram, or Medium for the most up-to-date news on Totle.


Decentralized Liquidity on Autopilot.


Written by


Decentralized Exchange Liquidity on Autopilot.



Decentralized Liquidity on Autopilot.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade