#DappCon22 : Day 2 - Do CoWs Slip-Page Less? Gent Rexha

DappCon 2022 · September 2022 · 19:08

Gent Rexha examines whether CoW Swap's batch auction model reduces slippage compared to conventional automated market makers at DappCon 2022. The talk covers how CoWs, or coincidences of wants, let trades settle directly against each other before touching an AMM's liquidity pool.

Speakers

Topics

From DappCon 2022, hosted by Dappcon Berlin.

Transcript

uh thank you very much Ben and yeah as already said I I was already been told you I'm gent I'm a data engineer at Cal protocol and the team behind carlsweb and I'll be I'm really happy here to show to present you the talk do cows Sleepless which is basically just an exploratory analysis of the difference between expected and executed prices in tax aggregators so let's get started right away um let me highlight just briefly what I'll be talking about today I'll give you a short introduction I'll tell you what slippage is how it works and how it impacts Traders and we'll be talking about the data and how it was collected for the visualizations we'll be showing

uh we'll be going over the most interesting visual exploration visual explorations of the slippage across aggregators and at the end we'll summarize this with our most noteworthy findings and a short conclusion as always there is also time at the end for questions before we start being a data engineer myself I want to gather some data from you and I'd like to ask here everyone ideally buy a show of hands who here knows what slippage actually is awesome and I would love to follow live up with a follow-up question of like who here got less in their wallet compared to what they were shown in the aisle while trading at an exchanger aggregator obviously so a lot of here are already

aware of that and that's really nice and this is the reason because we we should look more into that because slippage impacts a lot of our traders in every day and traditionally slippage is just simply the difference between the expected and executed prices while trading and just happens because when an aggregator shows you a quote time can pass the prices can change and once you sign and execute your trade the prices have changed and so this is that that's just how it works and traditionally there's also a very tricky problem for aggregators because for them they always want to show you the best price possible but they also don't want to like over promise you anything or under promise

because if they offer promise and they don't get the prices they've shown you're like unsatisfied and if you show the less you may be enticed to trade at another aggregator which showed you a better price and this leads to the question of like if someone says Hey again I'm have a really fast finger and I immediately sign the transaction the quote when I see it I should be safe and unfortunately that's not really the case because like the biggest reason for slippage traditional is that two when two people want the same thing one of them is always going to get the worst price and this is just because of how liquidity pools work uh the first person going and putting in one token and getting the other there's going to be less tokens in what they got from and

the second person will always get a worst price so there's like no way of working around that another and basically this is here where the slippage tolerance parameter comes in handy because this lets you like say how much of the price you're shown in the quote how much less you're willing to accept and this is really this is like and you can see this in every aggregator and if you go and you can see the slippage torrents and you can set that and in this case if you want to trade like 0.1 if for 192 die with a slippage tolerance parameter of 0.5 you're just saying that I'm willing to accept one dollar less just so my trade gets executed and if you look actually at the data when you sign your

transaction you can always see that this is it can have different names but usually it's like the amount of minimum returned and here in this case we can see that's 192 die and basically you're saying that yeah I'm okay with that and I'm willing to take that but I'll like albeit another less frequent reason for slippage is just that uh there are Bad actors who can exploit your slippage tolerance and these people because these people can exploit your slippage torrent because once you sign the transaction they are great aggregator puts uh your transaction in the public mempool and it's out of their control on our viewer control as well so basically they're bad actors can take advantage of your slippage tolerance parameter exploit it

and do a trade before you and give you a negative prize and then gain profit from that and these are known as Mev attacks and basically we won't be going into much detail and how they work what they are and what type of Mev attacks they are but let's just move on with the knowledge that there are Bad actors who can exploit our slippage torrents and gain profit from it and before we start to get to the good stuff uh of the actual visual Explorations uh let me just uh talk about talking to you about the data collection process and which aggregators we've compared as you can see here uh we have data from Xerox cow swap in one inch and Xerox in a blog Post article uh

released I think in April this this year released over 16 670 000 trades which happened during April and November of 2021 and that had gone through the Azure X API and on the ethereum Block mainnet for cloud swap we analyzed over 36 000 trades that happened during the last two months more specifically between 4th of July and 4th of September and last but not least for one inch we'll also look the trades for the last two months that happened also between the same time frame but as you can see here because not all uh because not all one-inch trades uh contain the quoted price in the car on chain call data uh these trades we've analyzed only represent 14

of all their trades that happen during that time which leads nicely to what is actually required to calculate slippage and for that three data points are the most important you need the worst price which you usually can get from the chain data you need the quoted price which traditionally you can get from internal databases like in the case of call Swap and Xerox but for one of one inch in this case it is also encoded in the Unchained data and you need the executed price so basically the price that you got into your wallet and that got you got executed with and as you can see here basically the first natural question that comes to

mind is like what type of flippage is there the most of in trades and as you can see here like zero slip is just the majority of Trades get executed with zero slippage it is worth mentioning though that this doesn't equal actually zero 100 zero slippage but this is like this includes like a boundary of 0.1 percent above zero and below zero just so that we can also like widen the Gap a little bit and we can as you can see like the remainder of the trades really are very differ different from E for each aggregator as you can see on the left for zero X around 33 of the remaining trades are with negative slippage and 17 are with positive one

whereas for Cal swap in the middle it's actually almost the polar opposite where you can see that 36 percent of their trades have positive slippage and only 15 of them have negative slippage and one probable reason for that is that the existence of cows in a cow swap which I believe Anna mentioned earlier which enables the peer-to-peer trading for you for the Traders on car swap gives them both parties better with positive slippage and therefore increases the positive slippage percentage and on the right where you can see one inch which differs I think the most uh from all from the two other aggregators for two reasons uh one you can see that they have a higher the percentage of negatives of zero zero percent slippage rate of almost 68 and they have 31 of

negative slippage trade but only one percent of positive surface trade and this is just because now the one-inch business model operates uh which by the direct vote of their governance system one inch takes positive slippage and forwards it to their user referrals and also to their treasury so in in realistically if that would have wouldn't be the case it would probably look very similar to Xerox but because we're looking at this from a user's perspective that's what the user sees so they they see only one percent positive slippage positive slippage and another interesting thing to look at is actually Superstars parameters the users use across different aggregators for this these values are usually around

so we've categorized them into five big categories namely three percent two percent one percent 0.5 and others and immediately here you can see the default uh slippage tolerance parameters for each aggregator if you look at zero X you can see that most of our trades are like executed with three percent which was their default parameter 2021. the next two most popular categories are one and zero point five percent which is which are the default values from for matcha which is uh aggregator which uses the 0x API in the background in the middle for call swab you can see that most of most of the trades get executed with a 0.5 slippage tolerance value and on the the next interesting thing is that the

others category compared to Xerox has a steady rise from seven to almost to 21 which lets us lets us tell that the users actually are far more customizing the slippage tolerance values on call swap compared to xerx and this rise continues for one inch where except the default slippage parameter the default slippage parameter like of one percent which is the most popular one for one inch with 36 the next most popular category is others with almost 33 which um further tells us that users like customizing their values a lot more in one inch compared to the two previous aggregators it is also worth mentioning that on call swap there are actually no three percent slippage tolerance trades so actually

the category is not missing but there aren't any and if we look now at the slippage histograms of uh each aggregator we can see that the two previous findings and Explorations we saw already have an impact here uh for example if we look at 0x we can see that they have a lot more even distribution but due to their higher negative slippage trades which we saw in the first in the first visualization the distribution is a little bit skewed to the left all the way to -3 slippage on the other hand the high value of the 0.5 minus 0.5 slippage tolerance for Cal swap you can see that the negative slippage stops a lot earlier for there because of the high 75 percent slippage

tolerance usage and the distribution is skewed a lot more to the right and for one inch as you can see uh the ball like the positive side is almost non-existent because it is only one percent and the distribution is very skewed to the left all the way to 10 minus ten percent and uh as you can furthermore uh and one interesting thing that all of the aggregator is sharing common are these upticks at the minus uh at the negative slippage values of minus 0.5 minus 1 minus two and minus three which could be possible indications of Mev attacks we will go and look into those further a little bit later another interesting pattern emerges if

we start categorizing our slippage histogram traits by trade size and this is really interesting because we categorize the trade sizes from minus from less than ten dollars into six into six categories up to more than a hundred thousand dollars and here we can see that the smaller the trade size the more even the distribution but when the trade size goes it starts going up the spikes become a lot more apparent and a possible reason for that is let's just there is more to exploit from those trade sizes basically in the end it's just that one percent of 100K is a lot more money than one percent of ten dollars and an interesting thing uh Xerox proposed is a new metric called Mev

exhaustion which is just basically the slippage tolerance exhaustion which is just a new x-axis which redefine is defined as the slippage divided by the slippage tolerance and basically when this gets close to 100 it just means that this uh the trade of the user got executed at the worst possible price and here a very interesting pattern emerges you can see that the distribution is very closely stacked on the left near the zero and it starts going down but near to 100 100 Mev exhaustion it starts going up radically again and basically this tells us that those trades could be potential Mev attack trades because this

could be the intention of a bad actor that exploited all of the slippage tolerance of an user and these trades are very good these trades are very potential trades that could be attacked and therefore should be analyzed by each aggregator further and that's uh that's what basically we did and Xerox and their analysis basically took a subset of those trades with a very high slippage tolerance and there were around 5000 trades with literally analyzed and looked at the trades using a naive heuristic basically where they said if the person trading before and after is the same the trade was Mev attacked and they concluded that 90 of all of those trades with a very close to 100 Mev exhaustion where Mev attacked

we did the same for Cal's web and took a look at those 100 closely to 100 Mev MAV exhausted trades and there we found that none of them were actually Mev attacked and this is probably likely this is probably prone because of the way uh orders are first uh put into the order book for carlswald and then executed only 15 to 30 minutes later 15 to 30 seconds later excuse me and usually because people trade at the same time when it and want to buy tokens when they're growing up and when they're selling whether they're going down there is a more like this is more likely for the price to not change in their favor and therefore uh the waiting waiting time uh is not in their favor and could

cause the high slippage High Mev exhaustion we see there whereas for one inch we did the same time but due to the high number of uh 100 mov exhausted trades we only looked at two subsets of 25 trades each for from the 100 Mev exhausted trades and we took a random subset and we took a subset and we took the sub of the the trades with the highest slippage tolerance slippage value and the from those trades analyzed we found that 50 50 of those were actually Mev attacked and having uh finished having done having analyzed the visualizations let us recap our most noteworthy findings

one more time and basically what we learned is that the majority of Trades have zero slippage but the remainder really differs from aggregator to aggregator different defaults different slippers torrentices so different aggregators have different slippage default slippage tolerance values and these impact the distribution of slippage tolerance and basically slippage increases at specific points which are usually negative round numbers and these could be possible indicators of Mev attacks this becomes even more apparent when trades are categorized by value and basically the slippage exhaustion parameter reveals an intriguing pattern of Shifting up to the right and those 100 Mev exhausted trades should always be analyzed further by each aggregator

and to finally conclude basically there are very big differences between first in regards of slippage between aggregators and slippage tolerance values and I'd like for you all to keep the slippage footprint of aggregators in mind when considering your next trading venue and now Having learned more about slippage and slippage torrents be aware that what you see is not always what you get I'd like to give a shout out to the Xerox team for starting this discussion with your blog article uh they did a very good at a very good job and provided some really new references for which we used and also I'd like to provide the cow Swap and one inch data in Dune where you can look up the data we've analyzed thank you for your attention and we're

not open for questions so unfortunately due to time constraints we probably only have time for one or two questions two because you he we actually wound up starting a minute or two later than originally scheduled okay yeah I just had a quick question uh so when you put the slippage tolerance does it actually limit slippage both ways like it limits the positive and the negative slippage or excuse me because I couldn't hear you when you put a slippage tolerance like on Cal swap or on on other dexters too does it actually limit the slippage both ways that's a very good question um the slippage tolerance only limits you towards the negative slippers so if

we go back quickly so I think it was yeah this only limits you to the negative slippage so it says that you're the worst acceptable price you accept is 0.5 less so in this case you're willing to accept for your 0.1 each 192 die but you could at the same time get 200 and uh it's like it doesn't limit you to the positive side at least for 0x and car swap because of one inches business model where they take the positive Surplus and they forward it to your users and to the treasury there you're less likely to get positive slippage compared to the two other aggregators so the the reason usually users would

like to set sleep larger sleep restorance is to avoid the the transaction failed to fail and did you analyze also the rate of failed transactions because uh that's a very good question as well in the end slippage torrents is just a trade-off of like uh how save like How likely your trade is be is going to like the risk of your trade failing and how safe you want to be so the slow the lower the slippage torrents the more likely uh like your trade is going to fail but the more protected you are so and here we actually didn't look at very specific like which trades failed but it is worth mentioning like for example for

Cal Swap this problem doesn't exist because you don't sign your your order doesn't get like put put directly in the public mempool but it only gets signed uh into the order book where it stays there and it doesn't get executed you don't get charged anything all right thank you for an excellent presentation thank you very much