Front Running on PancakeSwap: Real examples from the front lines

Corgi Coin
4 min readMay 31, 2021


Cute, but perilous!

Decentralized exchanges like PancakeSwap and Uniswap are exciting innovations that enable anyone to swap between cryptocurrencies without going through a centralized exchange like CoinBase or Binance.

Unfortunately, it is common for crypto traders to get picked off by sophisticated automated bots practicing front running. This article will dive into the nitty gritty of what front running is, how it is done, and how to avoid getting hurt by it. If you follow along closely, you might even learn enough to become a front runner yourself and make risk-free profit on the blockchain!

If you’re new to PancakeSwap, first check out our tutorial!

What is front running?

Front running is an automated trading strategy that works on decentralized exchanges. It occurs when a normal person sends a large buy order to an exchange like PancakeSwap or Uniswap.

The pending buy order is noticed by an automated trading bot listening to all new BSC transactions. The trading bot knows that this big order is going to increase the price.

To exploit this price movement, the bot slips a buy order in right before the original buy order, and exits its position with a sell order for the same size right after the original order.

An example of front running

Front running on decentralized exchanges is best understood by example. Here we see an example from the cryptocurrency CorgiCoin. The image below is a screenshot from BscScan. BscScan is a blockchain explorer that lists every transaction that happens on the Binance Smart Chain.

Identifying front running is easy once you know what to look for. It always has these characteristics:

  • Three trades at the same time: the front runner buy, then the actual buy, then the front runner sell. (Note that on BscScan the most recent transactions show up first).
  • The two outside trades have the same address and same quantity: the front runner ends up with no position. In this case, the front runner doesn’t actually want to own CorgiCoin, he just wants to make risk-free profit.

In this case, we see that the front runner bought 6.279 million CorgiCoin and then sold 6.279 million CorgiCoin immediately afterward at a slightly higher price, locking in a risk-free profit.

Blockchain transactions are grouped into chunks called blocks

Why does front running work?

Front running works because time is discretized on the blockchain. This is a fancy way of saying that blockchain transactions are grouped into blocks, rather than occurring one at a time.

When someone sends a buy order to PancakeSwap, that order sits in a pool of pending transactions that have not yet been incorporated into the next block. These pending transactions are visible to anyone listening — that is, any computer running a full node.

How does the front runner guarantee that the trades occur in the right order?

In the example above, we saw that the order of the three trades was:

  • Front runner buys
  • Normal person buys
  • Front runner sells

This allows the front runner to exploit the price increase from the original buy order. But how does the front runner make sure that the transactions occur in the right order?

Through mining fees! Whenever you submit a transaction to the blockchain, you include a mining fee as an incentive for a miner to include your transaction in the next block. Generally, miners will prioritize transactions that have a higher fee.

Therefore, the front runner guarantees the order he wants by sending his buy order with fee larger than the original buy order, and giving his sell order a fee smaller than the original buy order.

How do you avoid getting front run?

The front runner makes risk-free profit, and that money has to come from somewhere. Unfortunately, the loss is incurred by the original buyer, who usually has no idea that he is even being front run!

Fortunately, there is a simple solution to avoid having your buy orders front run. Just break your order into smaller chunks. If the amount of potential profit is small, the front runner won’t bother because they have to pay transaction fees. I generally find that orders <$250 do not get front run.


Hopefully this clarifies what front running is and how you can avoid getting hurt by it!

To learn more about us, check out our website, our Twitter, our Reddit and our Telegram! Find the Corgi Coin contract address on BscScan!