A brief introduction to arbitrage bots, normally bots look for target transactions in the mempool and try to front-run them according to a predetermined algorithm often times looking for the most profitable opportunity. Theoretically these types of transactions come with no risk involved hence why this is a rising issue. According to MEV-Explore v1 in the last 30 day $8,769,338 USD has been extracted from the mempool. But let’s take a brief overview on how this actually works.
Arbitrage
The word ‘Arbitrage’ might sound fancy to some but it’s a simple idea. You are essentially taking advantage of the difference in prices and usually making risk-free profits. Here is a very basic example:
A farmer named Joe is selling apples for $10 each. In the next town over, another farmer Alice is selling apples for $15 each. (Please do not message me about how expensive these apples are). Each apple is exactly identical with no differences in appearance or taste. Knowing this information, how do we exploit the difference in prices? We can buy an apple from Joe for $10 and then head over to Alice’s town and sell that apple for $15 to make a grand profit of $5. This concept will be important as we go deeper into the article.
We are decreasing the supply of apples in Joe’s town and increasing the supply of apples in Alice’s town. The idea would be to iterate this strategy as many times as possible until it’s no longer profitable.
Front Running
Another key concept for us to understand is front-running, a subset of high frequency trading. Front Running is a strategy that is predatory in nature and capitalizes on mistakes and asymmetric information. In our case, this means having privileged knowledge of a future transaction that is about to change in price substantially. Let’s visualize what this means. In this example, we have a dApp user, Alice, who would like to swap 1 ETH for 1 RND token. Alice goes to a decentralized exchange (DEX) and places an order. She is looking for someone to exchange their 1 RND token for her 1 ETH.
Unfortunately life is unfair and brutal, we can only hope that all the miners have an altruistic life view but for the most part that is simply not the case. From a rational agent point of view, miner’s are simply making the best decision at that instance, it would simply make sense for the miner to take the transaction that’s most profitable in this case it would be Mevia’s transaction since she’s paying more in transaction fees to the miner. But typos are just one of the many arbitrage sources. Some bots compete to cheat humans, some bots even compete against each other. This is a very basic overview of the type of atrocity that goes on in the MEV forest. Unfortunately this is just one example of an arbitrage opportunity, There is a whole ecosystem of bots who are competing against each other. Biting up transaction fees in order to front run and exploit decentralized markets such as the Uniswap V2 protocol who’s responsible for 63% of the MEV extracted.
MEV
But what exactly does MEV mean? it stands for “Miner Extractable Value” although please note that the community has been trying to change the name to “Maximum Extractable Value”. The memory pool or mempool for short is where the transactions go while they wait to be picked up by the miners. This is where all the bots can scan for profitable transactions. Such as the example we gave above with our friend Alice. Oftentimes these are pure revenue strategies if done correctly. Pure revenue refers to those trades that the bot profit on every single asset being traded and even after gas and fees have been deducted some of the actors still manage to bring vast amount of profits. But this is just one of many pure revenue opportunities on this new emerging market.
Pure Trade
Another example of a pure trade is shown below. Let say a decentralized exchange has multiple orders that cross in the order book so that one order offers to buy something at a higher price that another order is selling it. Due to the nature of the way transactions are processed in the blockchain it’s possible to build bots that work with smart contracts in order to trade across multiple Decentralized exchanges. Smart contract arbitrage opportunities have an additional, distinctive characteristic absent in traditional cross-exchange arbitrage. Bots can actually curate multiple orders from the same or different decentralized exchanges into a single order and execute the transaction atomically meaning that if any transaction fails in this bundle of transaction the whole order will not be executed. In a way safeguarding the bot from being on the bad end of the trade (Not always the case).
In the above case a bot can noticed that one of these orders is magnitude higher than the other meaning some sort of information asymmetry or mistake was made. The algorithm can quickly recognizes this and try to front run the user, making it almost humanly impossible to react. One of the most captivating part is that from a humble user perspective all of this would go virtually unnoticed.
Putting this together
We can quickly begin to see that running this at a larger scale can be quite profitable. Let’s take a look at some of these transactions that have been document on the blockchain to get a general idea of how some of these actors operate. The following data is from MEV-explore we’ll take a look at the top transactions and break down the their strategy at a basic level.
Let’s look at the first transaction that was executed on February 23 2021 at 9:17 am. This was actually one of the top transaction coming in at 3,264,587.08 USD in gross profit. This transaction is incorporating some the concepts we discuss earlier. We’ll see how this transaction bundle multiple orders in one to be performed atomically thus facilitating the liquidation strategy.
This particular transaction began in sushiSwap a decentralized exchange. The bot was capable of making multiple transactions into one making sure that all this happened within the same block (11912422) to secure profit. But this is just one of the many ways we can interact with the blockchain. Smart-contracts open a new door and many possibilities allowing people to come up with clever and creative ideas.
Where is this headed ?
With the fast-paced growth of DeFi and the increased liquidity in decentralized exchanges, profits have grown rapidly. According to Mev-explore the total extracted mev that has been documented has been $611,839,862 USD. From the following graph we can see that MEV bots have been trending, seeing tremendous growth in the last couple of months.
But besides the “number go up” and “big profits”, these graphs represent something bigger: they represent innovative use-cases of technology and information asymmetry. Regular users would be oblivious that deep down in the blockchain, there are predatory bots lurking in the mempool looking to profit on their mistakes. At the end of the day this does not benefit the humble user. The more volume that comes into DeFi and the crypto markets in general, the more profitable and solid some of these strategies will become. But as we make the transition into this space, it is our duty to be aware and try to make the best decision for the future.
The author is a Software Engineer intern at Polygon interested in Blockchain and L2 solutions. Some of their hobbies include looking at different ZK proofs, Flash Loans and DeFi. They are also one of the founders of the Queen’s college Blockchain club in New York City. In his free time, he enjoys exploring Brooklyn and eating sushi.
How do we avoid these mev bots? Create a blacklist? Or create limit orders on dex's?