MEV, toxic flow and its consequences
ETHCC 6 · July 2023 · 24:06
Robert Paluba explains the trading supply chain around decentralized exchanges and MEV-Boost. The speaker examines how retail traders fare when interacting with high-frequency trading firms.
Speakers
Topics
From ETHCC 6, hosted by Ethereum France.
Transcript
mechanism group formerly known as Rook Protocol. Uh I borrowed just a tiny bit from them. Okay. So first question is why do we care? First who we even are. So we are ZeroX. Uh we uh build the entire stock in DeFi. So we start with Xerx protocol which is a set of smart contract on Ethereum and seven other EVM compatible blockchains. We build Xerx API which aggregates liquidity from various dexes and also from private market makers and finally we develop matcha which is uh from userfacing front-end applications.
So we care about the entire stack uh and in particular the middle part which is trade execution and routing and this is closely related to what I will be talking about today. Uh right. So why Uni Swap D3? It's super simple like this is this this DEX moves the most liquidity move moves the most volume uh in the aggregator space or just in DeFi trading and it's not going to change. So if you look at these two charts uh on the left one on the left side you have the the gray bar this is unis on zerx API but this distribution looks more or less the same on every dex aggregator uh be it bit paras swap bit one inch cow swap it's it's just amm
so the gray one is unis swap you can see that it moves around 60% of our entire liquidity on zerx api and on the right uh if we take a look on e2sdc pair which moves the most volume in D5. Uh it's even more dominant. It's around 7 70 to 80% of all volume. It's just routed through unis swap v3 five basis points pool. And this is the main competitor to our RFQ. We care about this because uh we do the routing and when we do the routing we need to decide whether we'll use our RFQ which does not suffer any MEV or will we will use unis swap that actually does and uh we just want to understand what's actually going on in
there and how good that liquidity is and the simple fact is that unis swap v3 has not been challenged since it inception maybe recently there are some developments ambient finance for example but uh it's out there. It's to stay. The It's out there to stay. The the ETHUSDC five basis points pool has like $300 million of liquidity. This is the main liquidity of ETH and USDC. And um uh that's how this game is played. So, a few words about toxic flow like we're just trying to figure out what it is like which orders are undesirable uh on unis swap. And uh this AM liquidity overall is is ripe for abuse.
Uh there are various reasons. First one is constant spread and it's if we talk about five basis points pool it's it's 10 basis points and just real markets they don't work like that. When there's volatility the spread goes up. Uh at the time when I checked which was a week ago there are 2,000 active tick ranges on unis swap v3 in this pool which is a lot. It's a it's a lot of positions and uh people just don't manage it uh with time and they keep this liquidity stale.
This liquidity is at risk of stale even if you manage it for at least one block. If you don't manage it it's uh it's going to be unproductive or inefficient. And uh another reason is that centralized exchanges they move just faster than than the decentralized exchanges. There is a lot so on Ethereum we settle blocks every 12 seconds. There is a lot that can happen in 12 seconds. I will have I will show you examples of this. Uh MEV boost actually allows for new quality of arbitrage. Uh which I'll also show example of and you would like to understand who are the most toxic entities and can we even quantify the losses that the LPS are suffering. So I'll say a few words about the markout.
This is based on the discrimination of toxic flow in unis swap. Again I can't recom I cannot recommend it enough. go and read it. It's very interesting. So on the on this picture you see the liquidity distribution of so every time it'll say ETHUSDC it means unis swap five basis points ETHUSDC pair you can see that this liquidity even right now just cursory look it doesn't look like liquidity on like on a centralized exchange it's it's kind of skewed and this is used in high frequency trading the markout it just tracks the difference between the realized price and the price at the future time. So if we bought ETH at 2000 and uh five minutes later is at 2001 the our our P&L is plus five basis points and for unis swap the study uses the realized price
versus the Binance price uh from Binance candle data and this will describe the relevant micro structure of this market and yeah we focus on unis swap v3 eusd five basis points throughout this entire talk I'm not going to change it and uh markout will not touch LP P's profits when the price does a round trip. So if the price goes up and down, the LP made a profit from the fees and the price is the same. So they actually made money and mark will not catch it. However, it will catch everything that happens in the short term and it should uh and yeah it should describe the micro structure and the markouts of toxic flows like informed traders should be consistently
positive and we will see that they are uh right. So first question is how to actually determine the right period and uh it's it's quite simple. You just look at the autocorrelation of swap direction series and a 10 plus swap. So you you do plus minus one if it's sell or buy in the pool and at test 10 plus swaps the autocorrelation is 0.01. It means that there's no new information afterwards and 90% of the swaps that's something you can check on chain will occur in this five minute window. So five minute markouts will encapsulate the most relevant micro microsstructure. Sure there's something might happen outside but it's a it's a good proxy and uh we can compute the P&L of every
single trade that happens on unis swap and uh you can see this is the right chart that the flow from the dex aggregators so this is one in zerox cow swap uh unis swap router metam mask everyone that aggregates liquidity this flow is highly uninformed it means that the lps are actually making money these people do losing trades and the larger the trade the more profitable it is for the LPS and uh you can see that also in the distribution that it's uh pretty topheavy uh so the on the right uh the these large trades they do a lot of volume and this is these are the best trades for DLPs so if someone comes to 1 in or 0x or paras swap or anywhere and
swaps million dollars this is probably a very good trade for DLPs and you can also see that these aggregator tors are constantly making money for DLPs. This is not just a month or half a year. It's entire year of data that that show that shows that these aggregate traders that use aggregators are just making losing trades and they are good for uh for the LPS. Obviously, these people I mean they usually don't care about a single basis point uh and uh they are still happy with their experience. This is just to uh ju just to show that these trades in if we look closely to them are they are not the best and uh this is another very interesting chart and it shows that how how
profitable are the trades if you bucket them by size and uh you can see that LPS they make money on average on trades below the 75th percentile which is around $100,000. So on average, if someone trades less than $100,000 on unis swap, it's a good trade for the LPS. The bottom, the least profitable trades uh is at minus three basis points. And this is for the larger swaps. Uh this is you may think it's not much, but they mo they make the most volume. And this actually contradicts a bit what I just said that the large trades are the most profitable for the LPS. And we'll see why. Uh this the the thing is that these the
these traders they are not DEX aggregators they are just five entities that trade directly with the pools and they do 70% of the volume on unis swap. So there are five addresses that do almost all volume on unis swap in that pool and you can see that uh the profit the profit you can compute the P&L of every every swap and you can see that the P&L of of the LPS is it's not good. it it it's negative in tens of millions of dollars. Uh there are some periods when one of the pool is profitable, the other one is not. This is five versus 30 basis points. Uh you can maybe toggle between them, but overall just don't LP on this pel. You will you will be relentlessly
picked off by smarter traders. As I said, there are just few entities that are responsible for major majority of volume. Majority of volume like we can find them like they are they are out there and these are high frequency market makers. Uh uh so yeah two of three of them are they are just tagged if you go to nansen or ether scan you will see they're SCP winter mutant jump uh the second from the top is also a very big hedge fund uh and the last one I don't know who they are however yeah if someone trades these people they do they make markets they know the prices very well they are happy to arb everything that they can and uh if they are market makers they need to be competitive versus unis swap v3 so this is completely natural and
Most of the volume of unis swap to stable coins, ether through stable coins is just arbitrage between centralized and decentralized exchanges. If you look closer, you can get that the composition o of the of the volume on on in this pool and you can see that it consistently consistently isove about 50% it gets up to 70. I picked two these two months for a very for very particular reason that I'll describe. However, like most of the volume, the blue one, this is just centralized to decentralized arbitrage and these few entities that are consistently making money of of their trades.
Uh so I wanted to say a few words about me boost which is the new way of uh interacting with Ethereum. This was deployed after the merge and uh people are using it for searching basically. So if they want to make good trades and they don't want others to see them, they will use me boost. They will submit their their trades directly to the block builders. And the main difference between me boost which is a proof ofstake network and the previous version which was I think it was called MEV GEF on the uh on the proofof work network is that currently the builders they submit full blocks to the validators.
Previously there was a searcher. Searcher was submitting a bundle or a good trade directly to the builder and builder was the miner. It was the same entity that he was using all the bundles to create the a good block and make money. Right now these entities which are called block builders they propose full blocks instead of just bundles. So I mean people probably have seen this uh supply chain of me. Uh and the thing is yeah that currently builders and searchers are basically the same thing.
Uh and uh right 90% of Ethereum blocks are relayed using MEV boost and uh there at le there are over 30 builders who build more than thousand blocks which sounds like a reasonable number and uh and sign of decentralization. However, there are only four builders through ZX69, Flashbots, BeaverBuild, and Arsync. And they're building 80% of all all blocks. And uh MEV boost is centralizing force in the ecosystem especially in volatile volatile times when most of the activity happens. And here is like screenshot of how the blocks look like when there is volatility. It's like three or four builders building everything. Uh
and like why is that the case? Flashboards they have brand recognition and their builder is zero margin. They are not trying to make money of their builder at least for now. So they can give away the most to to the block builders. ZX69 is a specialite X miner. Beaverbuild builds builds with their own transactions which I will describe in a second and RSYNC used to build with their own flow as well. Now it's just a profitable builder and uh using the data from unis swap v3 we can actually check which builders are responsible for the most of the toxic flow because in general the blocks P&L is centered around zero. However there are builders
whose blocks are skewed towards toxic flow. For example uh manta builder they they they turned their builder off but they were producing consistently uh a lot of toxic flow. and uh manta beuild arsen and flashbots they relay the most of the toxic flow on unis swap which means that their blocks contain statistical arbitrage versus unis swap lps and like the ggo go it's manta builder it's the same entity so you can see that there are a few entities that generate uh all of the losses to the lps and this is how how a block by such a such a builder looks like it starts with 10 20 sometimes even up to 60 transactions that they put on the top of
the block. They build the block so they control what's in there and uh they put their transactions first and uh this is the these are all arbitrageers. They are just taking on the decks and the hedging what happened on a centralized exchange. Uh it's easy to figure out who those builders are and you can yeah you can see who starts their blocks. Like if you're a builder and you run a bot, you want your transactions to be first in the block obviously, so no one will interfere with your transactions. And you can see that the that the addresses that start these blocks are like 0x58, arsync is 0x28, beaverbuild is 0x69.
We've seen these addresses few slides before. The the most successful builders are just HF high frequency firms vertically integrating their bots with their builders. So they do not only do the searching which was the way to do arbitrage in proof of work network. They first they search and then they also build the block and it took them three months to dominate the building space which which to me means this is it's a pretty easy game for them. Yeah. So this is the state. There are onchain searchers. They are sad. There are centralized to decentralized searchers which are happy and there are centralized to decentralized searchers that actually build blocks and they are the happiest and the smartest and they make the most money
and yeah integrating centralized to decentralized arbitrage bot with a builder allows for allows for a very aggressive value extraction because the builder controls the ordering. They have full guarantees with respect to transaction to transaction execution. They know they will not get sandwiched. They will not they will not get from Trump. node will be the first in the block. This is much more capital intensive than dextox atomic arbitrage which can be done basically with no capital using flash swaps. There are no flash loans. So you actually really have to have the money and many of these ARB swaps are half a million or more in size and this is just substantial risk to do this stuff if you don't own the builder.
Someone will front you. Someone someone will do bad stuff. It's a lot of money. An interesting to see thing to note was that manta builder did not accept any private flow. Uh they were just building for whatever arbitrage they can create plus what they found in a public mele. Other builders they build with what they create but they also accept for example sandwiching bundles from other searchers. Manta did not do that. And uh Xerox 9507 that's jump. They did not submit traits to winter mutter SCP. pretty obvious and there is just less competition because this is much more difficult to do than than onchain searching and uh when the market moves all the pairs on centralized exchanges can be instantly arbitrageed versus
decentralized exchanges and there is a block that's an example I picked it two weeks ago it was talked on Twitter last week I picked it before so I'm not copying everything from them there are many blocks like this from by beaver build some of them start with even 60 arbitragees but the thing is they started with block with 37 arbitragees and they actually allocated $10 million in swaps. That's a lot of money that they needed to have and they also need to have money on centralized exchange. These operations, yeah, they're not cheap and uh and it's not easy to do this stuff. However, they're perfectly happy to to block $10 million if they know that it's them who are going to win the block. they control everything in the block and uh they they can they are
they are just calm and they know that they will make money. So this is what happened in that block. On the left left left side of each chart is the price on Binance while the while on the right you see the bids from the block builder and you can see and it covers the entire block and you can see that as the time moves in these 12 seconds when Ethereum is stopped and paused price on Binance moved by almost one and a half%. So when the price moved to the right uh uh the blue line sorry the yellow line uh and the price went up the builder instantly took it on a centralized exchange and then build the
block with the arbitragees on a decentralized exchange. Last thing I wanted to talk was LPS, how how how LPS and takers actually interact in this game because at Zerx we mostly care about the slippage which is the measure of trade execution quality. It measures the difference between the quoted price so what user should get and the realized price so what user actually got. And it happens or quite even quite often happens that this is not the same amount and uh understanding slippage and behavior of underlying liquidity sources allows for more informed routing decisions. We run our router and better uh execute better uh utilization of RFQ
liquidity which does not suffer any slippage. Uh so if we can understand how the underlying liquidity source behaves will there will be there a slippage or there will not be any slippage we can allocate more allocate more or less uh resources into RFQ and uh we have understanding of these LP losses caused by the toxic flow and uh the question I asked to myself like does it have any impact on realizes on realized prices for retail users and this is actually how I found about everything In this presentation, it didn't start with with toxic flow. It started with the slippage stuff that we look at at every day at ZX. And the February and April were very similar months and the
trade distribution size. And you can see that on the bottom left uh chart, these trays which are on the top like that's one oneth of percentile, they slip 30 basis points. And uh trades that are a bit smaller, they also slip quite a lot. So there is nothing and it falls off the cliff. This is you getting sandwiched. However, on the right in April, the slippage was gone. And uh I found it pretty puzzling. Wh why why is that the case? You could trade million and a million $2 million on unis swap and and nothing bad would happen to you. And uh why is it the case? The thing is that slip sandwich attacks are very cost inefficient because you need to pay the fee for the frontr run transaction and
for the backr transaction. So in the five basis points pool you pay you start with 10 basis points of fees. And uh if the transaction moves the price in order for this to happen the transaction needs to move the price by at least 10 basis points. And if the transaction moves the price by at least 10 basis points, there's almost always an arbitrage between centralized and decentralized exchange with better margins or there is an opportunity for just in time liquidity provision. And this has much better margins and this means that the builders who actually do this uh can build more profitable blocks. They have just more profit to share with the validator.
So two things that were happening a lot in April that were not happening before uh or when the blog builders slash highfrequency trading firms ramped up their activity was this which is this is not a sandwich it looks like a sandwich it's not a sandwich in the first transaction the the searcher mints a very big LP position in the tick range where this trade on unis swap will happen and uh this way they collect all the fee and in the third transaction here they just burned this position. So they're basically just being becoming they see the transaction in the mele, they become the counterparty to that trade and they're happy to to to to be the maker for it. And I think of it like of a risk
risk-free RFQ because normally on RFQ the market maker needs to commit the funds for probably a minute at least on slower chains. Here they just see stuff they're happy with it they'll they'll provide liquidity. And the second thing that was happening a lot is just ordinary back running. And uh instead of sandwiching here win back run two unis swap pools and this does not affect users price and again it has much better margins than sandwiching. The transaction I picked is actually our transaction where winter mute was a part of it. They were a part on RFQ. However, they still managed to back run uh our trade and uh again the margins are much better because you don't pay the fee twice. you can assume that these big big
firms their fees on on centralized exchanges are not particularly high. So that's the entire thing. They the sandwich bonds were driven away. And one thing I wanted to show sorry I'll come back here that on the right the purple sandwich and in April sandwiching volume was just gone because uh because the searchers were able to execute much more profitable strategies and combine them with block building. So to summarize the LPS they suffer consistent losses and they are being armed relentlessly by a few sophisticated firms. Uh these high frequency shops they took over Ethereum block space in less than three months.
And these strategies they require a lot of capital. Average searchers or arbitrers they cannot really participate. And as in that example it probably requires at least $15 million of hard money to to perform it. This is a highly centralizing force on in Ethereum and sandwich bots were actually driven away by more profitable strategies and as a result retail traders they get better prices. So LPS are unhappy because they are being consistently picked off and the sandwiches are gone. Sandwiches are good for LPS and retail traders are happy. So there is uh that's how it looks like. Thank you.
[Applause] [Music] [Music]