Logo

Front-running on Uniswap

Image Description
dnaclan2 Feb 8, 2021

EIR at Pool2 Ventures. Avid gamer and loves to tinker with web3 and dapps.

Not every profitable idea has to be big and complex. Profitable niches are possible via doing small, simple DeFi experiments.

Front-running on Uniswap

A simple 500 line Node.js script was run to continuously (every few secs) monitor profitable (>3 ETH & > 0.6% slippage) pending Uniswap transactions (out of a list of 1000 token pairs) within the Ethereum mempool.

The idea was to send out a ETH buy order with a higher gas fee to allow the transaction to be mined at an earlier position within the same block of the mempool transaction. The gist of the design is as below.

Image Description

Surprisingly, this simple strategy has demonstrated that it can 30-40% of the time successfully outrun impatient and careless Dex users. There is preliminary evidence that there still exists frontrunning opportunities for Dexes, though many risks await, e.g. honeypot ERC-20 contracts.

Further improvements can be made with the usage of flash swaps/ loans, that reduces to 1 onchain transaction and ensures atomicity of the buy and sell process. Logic to cater for feeOnTransfer tokens and more complex buy/ sell strategies can also be introduced.

Finally, the process unveiled 2 very interesting addresses:

  1. Uniswap IDO-frontrunning scam - 0x285DeA42Ba0a16c4c728a3dbe64A284D6d1212bE
  2. A sophisticated Uniswap frontrunning bot - 0x000000000000084e91743124a982076c59f10084

This is the end of this article.