Skip to content

Just-in-Time Liquidity & MEV Ethics

Brian Crain
Brian Crain
2 min read

I've been pondering the ethics of MEV extraction and we've been discussing the topic at Chorus One. A particularly interesting example is Just-in-Time Liquidity Sandwiching. It works like this: A trader creates a transaction to swap tokens on Uniswap. Someone (the 'extractor') observes that transaction in the mempool and adds liquidity to the pool just before the trade and withdraws it just after the trade. This transaction sequence is executed via Flashbots or a miner could also execute it directly.

Let's compare a normal liquidity provider with the extractor. A normal liquidity provider might provide liquidity on USD/ETH from $3,500 to $4,500. And that money just sits in the pool permanently. The extractor only provides it from $4,008 to $4,015, because they know that the trade will execute in that range. And they withdraw the money immediately afterwards.

A trading fee is charged and paid to the liquidity providers. If you now compare the return on capital (ignoring gas costs) of the extractor vs the normal liquidity provider, the former will make orders of magnitude more. Essentially they provide liquidity with very high leverage and only for an instant.

Is this bad?

For the trader, it's fantastic. They will have less slippage and are happy about the outcome. For the normal liquidity provider, this is not good. Their revenues get diluted and they will earn less.

Is it good for Uniswap? If there wasn't liquidity already in the pool, then the protocol doesn't work. So it seems to be an issue. But at the same time, the user gets a good price and the whole thing is extremely capital efficient. Maybe it is a good thing. At least, a Uniswap product manager called it a great feature.

Maybe the protocol would have to evolve over time, if this decreases returns for normal LPs too much. One could imagine that a base amount of liquidity is locked and gets a fixed portion of the trading fees. This might allow the benefits of just-in-time liquidity while still providing incentives for long-term liquidity. (Cosmos DEX Osmosis already requires locking liquidity for at least 1 day to get liquidity mining rewards with longer lockups getting higher rewards.) Or maybe one could have a DEX run purely on just-in-time liquidity. Probably not on Ethereum because of the high gas costs, but it could be a cool idea on L2 or other chains like Solana or Osmosis.

Suffice to say, it's very unclear to me whether one should consider this an attack or actually desirable. What are miners and validators to do?

Phil Daian of Flashbots has a nice post in which he makes a coherent argument for why all MEV should be extracted. I would summarize his argument as follows: We want our decentralized systems to be game theoretically secure. That means that no attacker can come in and make a big profit by doing something that is possible from the code, but not done by others for some reason.

If validators and others fully extract MEV, then it will drive towards more game theoretically sound and secure systems in the long run.

I am not sure if this argument is entirely correct. For instance, Bitcoin has some game theoretic weaknesses such as selfish mining, but it seems that miners altruistically have not exploited this at scale.

Even so, I think Phil Daian's argument is at least directionally correct. Cryptoeconomic systems should function under assumption of profit-maximizing actors that do not refrain from exploiting flaws because of moral considerations. And the exploitation of MEV clearly accelerates the move in that direction.