Cross roll-up arbitrage and impact of Decun on swap fees

ETHCC 7 · 10 Jul 2024 · 19:43

Krzysztof Gogol, a researcher at Matter Labs, one of the companies developing ZKsync Era, and a PhD student, presents research on cross-rollup arbitrage and how the Dencun upgrade changed trading on layer 2s. He says blobs cut rollup gas fees by around 90 percent, so the average swap size on ZKsync fell to about ten dollars. He separates harmful MEV such as sandwich attacks from back-running arbitrage, which he calls beneficial, and describes how searchers on layer 2s compete through server location, priority fees and transaction spam. He reports unexploited arbitrage worth millions over a few months and discusses time-boost auctions and shared sequencers.

Speakers

Topics

From ETHCC 7, hosted by Ethereum France.

Transcript

I am a member of a research team of MatterLamps. MatterLamps is one of the companies that is developing CK Sync era. I'm also a PhD student in computer science, researching scalability and security of decentralized finance and layer tools. And actually, today my talk will be on the intersection of those two of those two areas. And simply in my talk today, I'm going to give you a brief overview of decentralized finance and access on the layer tools, how the landscape look.

Then I underline how actually it's different from what we have on the interior mainnet. And then yeah, finally, yeah, uh, I will show you our research about the cross-related arbitrage and how it can be uh exploited using um using yeah uh L2 uh MEV. So Jenny uh uh DeFi and the decentralized exchanges uh were born on uh Ethereum with the Uniswap being being the first decentralized uh exchange. It introduced a so-called automated uh market makers that were using liquidity pools instead of order book to determine the price of uh two uh tokens.

And then yeah, over time, decentralized exchanges gain a big popularity. You can see here that actually the trading volume uh at those exchanges is on the is on the rise. Also, it's important uh to know that the training volume is much better metric for exchanges than uh TVL, total value locked, because with a better form of AMMs, you can have more trading volume, but with the lower uh with the lower uh TVL. That's why I'm focusing now on that trading volume. And here the important thing is you can see that now a lot of trading volume is happening outside of the uh outside of the Ethereum.

And actually it's not only uh it's not only Solana outside of the uh outside of the Ethereum, but it's also uh layer tools. Here you can see uh in percentages how that trading volume is split between the Ethereum uh layer twos that are running on top of the Ethereum and another uh layer, uh and another another layer ones. And you can see that yeah, with time, simply the dominance of Ethereum is decreasing from like 80 percent, yeah, now going down to you know less than 40 percent. However, when we look at the whole ecosystem, including also uh L2s, yeah, uh Ethereum ecosystem is standing at still at around 60 uh uh 60 uh percent, so the majority of the whole uh DeFi.

And then there was a very important upgrade, the biggest upgrade since the March last year, it was the uh DaCoon upgrade that took place on the 14th of March uh earlier this year, and it introduced uh blobs. Blobs are a special uh temporary data storage units that were designed to uh that were designed for the uh for the roll-ups. And thanks to the uh thanks to those blobs, the gas fees on the roll-ups went significantly down by like 90 90 uh percent. You can see that after that mid-March, the gas fees on the roll-ups are really uh low. They are around one cent uh per uh per transaction, so also yeah, one uh one cent per uh swap transaction.

And that has impact on the swap because it simply caused the users to do or allowed users to do more smaller swaps. I mean, these are a little maybe uh it's a little complex chart, but uh on the chart on the right, you can see a distribution of uh swap sizes before the blobs were introduced on uh on the ZK sync. And you can see that back then the swap volume range uh between uh zero and one hundred dollars. So people were buying or yeah, or selling uh of uh the trading volume. However, after the blobs were introduced, you can see it on the left side, the average uh swap volume is just ten dollars.

Something that is yeah, unthinking unthinkable on the mainnet, because yeah, uh there you need to pay uh quite often more gas fees. So, yeah, thanks to those blobs, those micropayments became possible on uh became possible on the rollups. I mean, currently, just to give you a comparison, here we average uh so volume on the um on the rollups is around 200 compared to 400 that is uh on Ethereum uh mainnet. So the difference is huge, and yeah, it's uh actually decreasing with the swaps becoming even smaller. But actually, the DeFi and the DEXs on layer twos, it's not only about the lower uh gas fees.

There are some other important factors that uh yeah, we should uh bear in mind. I mean, it's of course the security, because once the rollup reaches the the transactions from the rollup reach the uh hard finality, they are secured by all of the stake uh Ethereum by Ethereum consensus. But the block production on the rollups is much, much faster than on the Ethereum main ad. Like on the Ethereum, it takes uh around 12 seconds to produce a block uh a block, whereas on the L2s, like ZK Sync era, it's around one second. On optimism base, it's two seconds, arbitrum 200 millisecond.

And it's also impacting a lot the MAV strategies and uh in general the trading strategies. And also, last thing, which is very important, uh, there are no MAV auctions on the rollups uh yet. So most of the rollups implement the the rule uh first come first, a transaction in the mempool is simply included in that super short uh super short block. So you can't participate in a kind of a flashbot uh auction that you know from the uh that you know from the Ethereum. I mean, just uh maybe a quick uh background on how the MAV is running on the uh Ethereum.

On the Ethereum, it's about uh validators, uh simply reordering a transactions in the block or adding some special uh transactions in the block. Like one of the most typical type of the uh MEV on Ethereum is simply a back running. When the you can see it here in the uh green, when the uh MEV bot is simply placing a transaction just after a tra uh just after a target transaction. In the uh front running, the uh MAV bot is placing a transaction uh just uh before the target uh transaction, and there are interesting combinations of those two. For example, a sandwich attack when you are targeting a swap, and then the MAV bot is uh um inserting a transaction in a block just before and just after that, uh just after uh that target swap.

And generally front running and uh front running and uh the forms of the attacks are detrimental for the uh users, like sandwich attacks, especially for the traders and just in time liquidity attacks that are detrimental for the liquidity uh providers. It's very different when it comes to the back running uh MEV. Because back running MEV is used uh mostly in uh two cases in the arbitrage and in the liquidations. Liquidation is about uh DeFi landing.

For example, you are uh looking at the block with the latest price of if and USDC, and then you are spotting the non-AVE compound, there is some bad debt, and then yeah, you are the first one to liquidate it, and you are simply getting a reward uh for it. It's also linked to the oracle extractable value. But I mean in a nutshell, uh that front running uh MAV and it its combinations is uh bad uh MMV, it's something that we do not want uh at all. We don't want it on the Ethereum mainnet, we don't want it on the L2s, whereas the back running uh MEV is a good uh MEV because it's beneficial for the uh DeFi.

It's beneficial for the uh for the for the users because it's making the whole ecosystem more uh fair. And I mean here you can see example of such uh arbitrage. Um this is arbitrage between the ZK swap, which is uh the fork of uni uh uniswap on ZK sync era and the Binance, and you can see here that uh you can buy, for example, uh one if on ZK swap, uh and you pay for that one if uh $2300, and then you can sell it uh on Binance for uh $2,400, meaning that you are making one uh $100 uh profit. This is simply an example of uh uh arbitrage.

When you want to uh buy uh cheap at one uh DEX blockchain and sell more expensive at uh central six cents or another uh DAX. And on Ethereum, actually, according to the flashbots, more than 70% of MAV is that uh is rated to the uh arbitrage. Another 20% is about liquidations, and only 10% are sandwich uh attacks. So at the end of the day, uh MAV is actually not as uh not uh so bad as we uh are uh afraid of. There are two types of the arbitrage, depending whether we are doing it with uh uh C5 like Binance Kraken or we are doing it between a DXs on the same roll-up.

So uh and also it's important to remember that that arbitrage or MAV, uh MEV arbitrage with a C5 is much larger on Ethereum, because yeah, it's over 60% of uh yeah arbitrage that we are having uh there. And now so on, but I mean let's uh now talk about uh let's now talk about uh L2s. Because on Ethereum we have the flashboards and other relayers that we can use. On L2, we don't have it because the sequences are not running and uh yeah, auctions uh yet. And what you can easily do is for example, you notice there is a different price at um, for example, ZK swap on ZK Sync era and Uniswap v3 on ZK uh Sync era, and you can simply do that DEX to DEX arbitrage within the same L2.

And that you can do as atomic transaction, so you are relatively don't have much uh big uh risk. However, because the rollups are producing blocks so quickly, uh most likely your uh your transaction that is doing that uh MEV uh arbitrage will not be in the same uh block as the uh transaction that caused that price uh uh disparity, but will be in the two blocks, uh two blocks farther. So it will happen something like uh four seconds uh yeah, between two and four seconds uh later. And you can see that people are already doing that uh type of the atomic arbitrage between uh DAXs on the uh roll-ups.

It's like uh even at some uh at some weeks uh 200 uh million uh in volume. But I mean, remember what I was showing you on the previous charts in Ethereum, that such atomic arbitrage uh is only 40% all of the opportunity. There is a much bigger uh part of the cake, which is a non-atomic arbitrage happening between the uh centralized uh finals and yeah, uh those uh DAXs. Then I mean the question can be how can you do such thing on the uh on the role on the rollup? And then some roll ups, for example, base, they have so-called uh they have so-called uh gas priority fee.

So you can simply pay a little more, and then yeah, you know that your transaction will be faster uh executed. And by doing that, you can guarantee that you will uh yeah, your transaction will be executed faster than the others that maybe spot the same arbitrage opportunity. But I mean, a lot of uh or most of the rollups they do not offer such a priority uh fee, like I mean ZK sync era, uh arbitrum, they uh don't have it. So what uh actually MEV searches are doing, they are simply trying to locate where the sequencer is located. For example, if a sequence is located in a Tokyo, then yeah, you want your server also to be located in Tokyo close to it, so that uh yeah, your uh transactions will get faster to the mempool and will be faster executed than uh the others.

Another possibility to do such MEV arbitrage is to spam the network. Because gas fees are so cheap on the uh L2s, you really don't risk much uh don't risk much. You can send huge amount of the transactions that are trying to do uh that are trying to do arbitrage, and then even if they fail, yeah, you don't lose much, you only pay for the gas fees. And you can see that actually after the introduction of the blobs uh and uh decrease in the gas fees, amount of the reverted transaction really skyrocketed on the rollups, showing that this is how uh MMV searches are exploiting uh arbitrage uh on the L2s uh today. And you can think how big is the uh how big is the opportunity.

This is actually the result of the research that we were doing at uh Matter Labs. We compare the price differences between the uh Ethereum, between Binance and uh Uniswap v3 on the different uh rollups. We look at the price of uniswap, uh we look at the price of if against USTC and simply calculated how big is the arbitrage opportunity for the few months. And you can see uh here that actually changes. This is a logarithmic scale. So a four means a 10 to the power of four, which is like 10,000. I mean uh 10 to the power of seven would be like 10 uh 10 million.

So there is definitely a big opportunity out there when it comes to the cross rollup uh arbitrage, especially with those rollups where you have more uh trading uh activities. You can really really exploit like uh a few millions uh over a few uh months. And also important thing, that estimation is only showing you the arbitrage which is unexploited. We observe that uh those price differences on the rollups, they disappeared after eight, between eight and even three hundred seconds, which means that they last for uh a good like 20 uh 20 blocks. So there is still like opportunity to uh uh yeah uh to take part in that race.

You can read more about that research in this paper that you can see here at the bottom of this uh page. It's like everything is publicly uh available. And then maybe there is a one trick with the uh rollups, is that it's not only about the price differences, how you are making the uh the money, because of course when the price difference between the rollup and the binance is big, yeah, you can uh yeah, it's good for the arbitrager. But there's the second thing equally important, and it's how big is the liquidity pool uh inside the automated market maker. And when the you can see it here that when the uh the when the size of the liquidity pool uh went down, uh then simply uh also the arbitrage opportunities, uh profit from arbitrage a little went down, even though the price differences with the binals were uh were happening.

So generally uh when you are an MMV searcher, you are looking for the big price differences on the tokens with uh big liquidity uh pools in uh AMMs. And then you can think what actually can uh what can go wrong. So as that uh arbitrage is non-atomic, it's between typically a rollup or a cross rollup, between a rollup and a binars or a cross rollups, it's a non-atomic transaction. So it can happen that you see there is a big price difference between uh you know uniswap on uh CKSync and Uniswap on um arbitrum, but before you execute those two transactions, then actually uh the price changes on Arbitrum. Uh and what uh you can do about that.

There's actually uh so right now nothing is implemented, but there are different options under discussion. One option that is uh being discussed between the rollups is a time boost uh auctions, where simply inside the uh inside uh uh sequencer you are paying uh for the boost of your transaction. But the important thing is such auction uh will enable only a back running MAV. So that front running, which is bad on Ethereum, because it's causing those different fronts of the attacks, will no longer be possible on the will no longer be possible on the rollups, but you'll be able to do that good uh MEV arbitrage liquidation simply faster without looking for uh the physical location of the sequencer. And the second option is actually the shared sequencer, which is I think like the biggest topic of the FCC this year, because one of the applications of the shared sequencer is that you can have those closer lab transactions atomic.

So when you you will be be, for example, buying something cheap on the uh arbitrum and saying more expensive on ZK sync, it will be one transaction, so you will not face that price shift uh risk. Maybe yeah, to conclude, not all of the uh MMV is bad, and we want on the uh R2s only that good, uh only that good MIV. And if you are interested in what I was presenting to you, yeah, please have a look at the papers that we wrote or visit our uh website of our uh research team. You can see there also more research papers on sequencers, provers, and yeah, a lot of interesting stuff.

Then yeah, thank you, and I welcome your uh questions. We have time for two questions. Yeah, if you if if you go back to this graph that you have with square and uh bluish, uh greenish. If I understand it correctly, in CK sync, like the arbitrage cross-roll of arbitrary opportunities, like very low. Is that the way to read this?

Uh so uh currently yes, and it's because uh that research we did on Uniswap uh we compared on Uniswap V3 pools, and Uniswap V3 was just recently launched on the CKSync era like a few months ago, and simply those uh pools, the yellowish line is currently low on CK Sync, but it's yeah, going up very uh going up very quickly.

Related talks