Suppose I'm performing swaps form Uniswap, sushiswap etc Can they MEV my funds? What are the things MEV bots can do?
2 Answers
MEV can be the difference in the balance of reserves across two pools, it can be the opportunity created by bad swap setting, (100% slippage or ignoring price impact). It can be the bid a searcher makes to take an MEV opportunity which in turn creates an opportunity, MEV can be recursive like that.
MEV in itself isn't bad, it is inevitable, but a back run arbitrage only takes advantage of MEV a transaction would have organically created, and is providing a service to the ecosystem by normalizing price across exchanges.
In this context the concern would be over frontrunning
, or being sandwiched
. These have a likelihood of giving the victim a poor execution price in efforts to maximise the amount to which the sandwich bot can sell a token back into the pool, in the final transaction.
There are several ways to protect against this. The simplest is by using sane settings that will revert your transaction if it falls outside of those parameters.
Using a tight slippage setting. This is setting the minimum amount one is willing to accept, or the max amount one is willing to pay. The aim is to use a number as close as possible to the desired amount, while still allowing enough of a buffer to let 1 or 2 organic swaps on the same pool land before yours, without pushing price so far that your transaction reverts (where you will waste gas and potentially miss the moment you are buying/selling for).
Taking note of price impact and not swapping on pools with very low liquidity. This way you will not create a massive price disparity to take advantage of. You will be warned of price impact if using a UI, else should calculate it. Price impact is the effect the size of your trade has on the eventual price per unit that you will pay.
Using flashbots protect RPC, or similar service to hide the transaction details from public mem pool. This can be as simple as using their rpc endpoint in your metamask instance.
if you're performing a swap, you don't want to be "sandwiched" because you will get a worse price for your trade.