# DeFiDay - The impact of slippage in DEXes, Theo Gonella (0x)

- Channel: [CryptoCanal](https://streameth.org/cryptocanal)
- Date: 2022-10-07
- Duration: 23:08
- Watch: https://streameth.org/watch/yt-6Gdfyvs29pI
- YouTube: https://www.youtube.com/watch?v=6Gdfyvs29pI

## Description

On April 25th 2022 we hosted DeFi Day during Devconnect in Amsterdam. Enjoy this keynote with Theo Gonella,  Group Product Manager at 0x https://www.0x.org/

Join our TG community https://t.me/CryptoCanalCommunity

We would like to thank our partners and sponsors that made this event possible. 🌷

Ethereum Foundation https://ethereum.org/en/
Balancer https://balancer.fi/
Oasis https://oasis.app/
Perpetual Protocol https://perp.com/
Lido https://lido.fi/
Figment: https://www.figment.io/
Uniswap: https://uniswap.org/

## Transcript

foreign [Music] I'm Theo from Xerox and uh yeah as Jonathan said we're gonna talk about the impact of slippage on taxes and I have shamelessly caught taken the slides from Robert from my team and I'm basically gonna present them today and yeah as we were saying this is a an unprecedented analysis actually that we ran on data that we had at Xerox and we are very excited to to share share it with you looking forward to your questions as well uh the extended report is actually available on our blog so check it out at blog0x.org there you will see more in details this data and uh yeah as as we as I was saying we've been actually presenting this this week also with other at other conferences so hopefully you haven't seen it before as a bit of a background Xerox is basically a family of endpoints and smart contracts that are aimed to help Dax applications plug into this this world we build tax infrastructure for the internet and we connect tens of applications with tons of liquidity sources most of the time zero X maybe might be seen as a the old relayer Network and stuff like that but we actually evolved a lot since 2017. right now we have a Dax aggregator infrastructure online available on seven blockchains so we are literally connecting hundreds of thousands of users with um with these liquidity sources on the left so if you're interested in knowing more about the data you have also resources there on the bottom left to yeah follow what we're doing all right to the topic of the talk we want to talk about slippage and we want to give numbers hard numbers on that there's a lot of misconception of what slippage is when you go to a DEX interface like here is matcha displayed you typically see different numbers you see a spot price which is the mid Market on the top left then you input your trade and you are you get a quoted prices recorded price in in return that quoted price includes price impact but does not include slippage and that's the if you want the message that we want to send today slippage actually is not shown in any uh pretty much any UI index and why is that well that's because price impact is known before the trade and that typically depends on the trade size versus the pool you're you're trading with on an amm whereas slippage is not deterministic sleeper jump ends in the dark Forest it happens once you submit the transaction on the main pool and that not easily calculated before because actually it's impossible and you're actually real realized price depends on the ordering of the transactions and that affects directly what your price is going to be ultimately typically the effects on your realized price come from random collisions but there are some instances where there are some Mev attacks such as you you might have heard of Sanji sandwich boss and in those cases you are getting a worse price than anticipated not because it was random but because actively acted against you so we wanted to analyze the data and make some assumptions hypotheses and see whether our hypothesis matched what we had in mind typically the way that you protect yourself against slippage is setting these slippage tolerance it's usually a bit hidden you need to click on you know settings and things like that and uh yeah basically that allows to introduce some protections meaning that once your trade is submitted on the man pool if it drifts too much then it reverts so basically that's your protection there without it you would be basically armed pretty bad but yeah sleepage tolerance is not enough as we said before after your transaction hits the man pool there are some attacks like sandwich attacks that are kind of displayed here they typically happen um in a series of three actions you are the one in the middle there you you see the momentum on etherscan typically you see that that's first the MAV attacker that basically front runs you and move the price up if you're buying then your transaction happens at the price you set the slippage tolerance at which is your worst acceptable price and then the VLAN instantly sells and they pocket the difference and typically also the miner gets something back because they uh the VLAN so to speak they're also bidding using flashbots typically to reorder the the transactions so we started creating you know hypothesizing a little bit how does a distribution of sleep sleep Edge looks like and in our hypothesis we thought that in the presence of a lot of Mev Bots we think that the ultimate realized price that you will obtain is actually equal to the acceptable price so in an Ideal World you will always get what you were quoted but with these Mev Bots basically your price is moved towards your worst acceptable price the slippage tolerance basically so we had the data and we thought okay let's figure out whether this distribution uh actually happens in reality we analyzed 700 000 zero X trades that happened between April and November of last year over all the Xerox API applications so matcha metamask coinbase wallet zapper they're using all Xerox API and we focused on amm trades so when the trades were routed to amms like uni swap V2 V3 and Sushi swap and we are we had all the data points to compute that distribution so the quoted price slippage tolerance and realized price the first data point that we learned and we basically started reflected on was the distribution of slippage tolerance this is what users said on the UI we actually realized that for for that data set most of the slippage tolerance was pretty was pretty high was over two percent and that's because two very popular applications coinbase wallet and metamask have a slippage tolerance of default of two three percent so it's pretty high Mata is 0.5 percent is the is the green slice here but from here actually another conclusion is the fact that users actually do not change slippage tolerance they pick what the UI tells them to pick because as you can see over 90 percent are set at the 0.5 1 2 3 that are set in the defaults of the UI and here's the distribution that we were trying to compute and uh this is very interesting it gives you there's a lot to digest here but pretty much first of all you can see that it's slightly tilted towards the negative side but there's a cap at three percent pretty much that's because mostly none of the applications have over three percent slippage tolerance by default and the other interesting thing there are all the where the arrows are there are interesting Optics at uh you you guessed it at 0.5 one two and three percent and these Optics happen because I mean it's pretty uh obvious at this point Mev Bots targeted your trade to push it to the worst susceptible price other things that we can uh like infer from this is that yeah it's bigger on the left side near zero so this is actually the mostly the trade collisions that happen randomly but also another interesting thing on the right hand side we see that there's a smooth Decay and that's also because your xpi does does not collect positive slippage and is returned to the user so all those instances where you actually had a better price than than expected that value was returned to you so we wanted to dig deeper on the left side where we have these Optics and by breaking it down by trade sizes you actually see that the bigger the trade the the bigger the Optics and that's another confirmation of the suspicion that these are Mev Bots attacking your trade because there's more money to be made for them foreign s on pretty much all pairs it happens a lot actually on long tail pairs where there's lower liquidity so there are more more opportunities to to sway the price but it also happens on the very popular ones as you can see here on the x-axis we have the trade size as the trade size increases we see actually the slippage the average sleep is growing a lot and in certain instances you see that here we have a roughly 30 beeps for large trades on if type but yeah 30 Pips is is very high in terms of slippage foreign that is maybe 0.5 percent but maybe the slippage tolerance was three percent um we then divided the slippage tolerance and normalized the data to basically have a metric called the Mev exhaustion meaning that the trade was basically pushed to the extender it was possible to push and we actually see the the uptick that we were thinking about meaning that for some instances where we have a basically trades that are pushed towards the slippers tolerance we see the the the frequency picking up and that's even more evident so actually it's it's matching the the hypothesis that that we had at the beginning as you can see the the shape of this uh the histograms are pretty similar and it's becoming more and more obvious when the trade sizes are higher so basically a way to read this is if you're trading more than ten thousand dollars on AMS you will sleep and the likelihood is actually pretty high it reaches over 10 percent when you're actually yeah trading more than ten thousand dollars so it's pretty pretty impactful the good news is that there's a source of liquidity indexes called RFQ request for quote that is Mev resistant Xerox API Aggregates both both types of liquidity amms and RFQ connecting directly to private market makers and the best price is always offered to the user the interesting thing about this type of liquidity is that it produces a quote that is personalized just for you at that time so when you are receiving a quote from market makers that's just for you only you can take it there's no Enemy No slippers no one can from you and it's available on all Xerox API applications it's picking up more and more we already are trafficking over one billion dollar per the volume per month the interesting takeaway is the the centers at the bottom here is that um due to sleep Edge there are actually a pretty sizable number of Trades and users that would have had a better price with an RFQ order because they actually slipped so that's the Our intention that is to use this data to embed it in the routing algorithm the interesting thing about RFQ is also that it allows for peer-to-peer gas illustrating it's available on your matcha for now but it's a wave to embed basically gas costs into the the quoted price and again no sleep is no reverts and if you want to check it out it's so much so to wrap up and I'm looking forward to your questions what we learned is that lipids is real is hidden to users but he's real and and it's not going anywhere and we calculated actually that there was over 10 million dollars lost in slippage by users in q1 of this year so it's it's definitely real and if you if your trade can slip it will there will be Bots like taking that advantage of you but our plan the good news is that we're gonna monitor on an ongoing basis this this data for ethereum and polygon and all the other things that we are present in and we will try and model the slippage prior to the trade so Danny can be taken into account in the routing algorithm and basically get you a better price in case we think that you're gonna get flippage with that I think I'm done with the yeah with the talk thank you [Applause] amazing um thanks so much dear and thank you to you guys so uh this way the way we're going to ask questions is we're going to hand out the microphone this time so if you have a question yeah um so the opposite of nav was exporting um slippage um so getting worse execution encoded price as you indexed is when MV was provide just in time liquidity on Unison V3 specifically this happens is there a way to observe that in your data as well or you are asking if Universal B3 is subject to sleep Edge in the same way that any amm is yes but one of the things that we've seen over the past years and so if there's a large transaction in the mempool on V3 that an Mev bot might in real time provide a huge amount of liquidity and wrap the user transaction in this liquidity so then the user actually gets a better pricing quoted I was wondering if you could just if you could see that in the charts that you that you indexed or we haven't looked into that but I guess it's something that we will look into and uh yeah that's another interesting aspect of that but what would be the advantage to the Mev bot then in that case I'm wondering um because like they wrap their the rapid transaction atomically so they have for that moment they have 90 of a liquidity in the pool so they capture all the fees um and the passive LPS get nothing okay yeah well we'll look into that and update our our blog post thank you are there any other questions come on guys this is your opportunity hi I wanted to ask what do you think about Oracle extracted value as opposed to minor extracted value because oracles are also kind of playing a key role in many protocols so can they use their position to extract value out of the transactions and have you done any analysis on it and why don't we hear about it more often foreign I'm not really familiar with that but I can imagine that yeah Oracles in certain Protocols are used to yeah Peg basically the system towards a number and yes it's definitely an information that can be exploited um to an extent prices are and price of symmetries and information are basically what's our bubble and that's also what market makers do by the way because they ads on centralizes changes when you they give it a price to you but yeah I never heard of the this aspect of it but I guess aggregators like Xerox API can find where what the best prices are is on in all these venues and protect the user in that way okay so like the Bots that are doing these this type of extraction of value is there any way of labeling these Bots and finding out like tracking their activity and saying like who's the one who's controlling these Bots like which sources are they coming from has any this kind of analysis been done by you they operate on well a lot of them operate using flashbots and it's a public system with sealed auctions so it's a bit you know the the I guess the solution you're proposing is to put people on the block list pretty much and addresses it's not really in the spirit of peer-to-peer trading but yeah it's maybe something that we could look look into that but that would mean basically tracking addresses and yeah deep prioritizing addresses based on their past activity that feels a bit yeah slippery slope in terms of control of exchanges so we prefer probably to be agnostic of that but that's a good intuition hey so so flashbots has a public uh RPC now that like users can submit to through their metamask and stuff um does submitting to through your transactions like matcha transactions through flashbots protect you from these sandwich attacks yes that would be one way to protect your trade too you would yeah you would have to change the RPC utilizing flashbots however then obviously you would have to trust flashbots not to front run the bids or things like that but yeah that's a that's a solution one thing that we learned though is that as you've seen from the slippage tolerance distribution users do not really take actions maybe people in this room yes now we've heard you can use the flashbot RPC and you can do it yourself but the next generation of users probably don't even know what an RPC is or they don't want to you know you know mingle with that we also connect with the applications that don't even give you that possibility so but yeah to answer your question yes uh I have a question um what do you think at a high level is when it comes to dex's what's actually like the biggest issue at the moment yeah more than taxes and if I mean abstract to D5 typically when we talk to maybe candidates or people external from the from the from the space is always obvious the obvious question the obvious answer is onboarding and explaining what's going to happen what's not going to happen and uh yeah try to hide it as much as possible I don't I think Dax is I have a evolved a lot in terms of pricing and efficiency through aggregators through the evolution of amms like the race to the bottom so to speak of efficiency I think it's converging I think where where it's going to get interesting and we see that with the at Xerox when we onboard maybe companies that are not as familiar with with Dex is what is the concept of allowance or okay great you offer grassless trading but still I need to I cannot do that with a native token all of these concepts are still appeal battle but I think it's important yeah super important and stating the obvious here but yeah making it easier for other applications to onboard the next generation of users and and oh you have a question um so in that chart of the slippage exhaustion likelihood so even for a trade of 100K you've only got a likelihood of 15 or so so why is that so low um is that uh people using RPC flashbots to protect themselves or where's the 85 percent were you expecting it to be higher I guess when you talk to the the Mev guys they they sort of uh think that it's almost 100 foreign well well I guess yeah one intuition is that maybe a portion of that 85 percent yes uses uh since they're they're you know they're launching large trades they are uh yeah using flashbots however yeah I feel like uh we were kind of shocked when we saw 15 uh because that means that uh yeah users are really yeah leaving money to the table but foreign [Music] on it but obviously we've been talking about cross chain we've been talking about layer twos like and again with liquidity you're splitting it across many different points so what is your thought on that and kind of the future of the ecosystem yeah there's there's a lot of misconception misconceptions there too um it helps maybe to think about how we we think about this problem with at Xerox API we are chain agnostic we will go where users are and uh we observed that yes the typical Evolution was a new chain comes up they have a big incentive program and they will incentivize these amms to basically spin up liquidity and then we start seeing users maybe subsidize maybe not and we just follow where liquidity emerges and where users are we're pretty much agnostic to to where to go in terms of fragmentation of liquidity I think arbitragers not necessarily Mev like even simpler simple arbitragers will will make sure that the prices are aligned and they I actually think that uh the price the concept of price alignment across multiple chains will be resolved very very easily one thing that is going to be interesting to to see for us for example is how to leverage rfqs to actually align prices and make sure that there's a good liquidity on other chains to cool well well we'll see how it evolves thank you so much Theo please give a round of applause [Applause] [Music]
