Research: Introducing the AMM simulator / Cyrille Pastour

Prague DeFi Summit 2023 · June 2023 · 24:23

Cyrille Pastour introduces an AMM simulator from recent research that tests a range of market-making strategies, including oracle-based and oracle-free designs, with Uniswap V2, Curve V2 and Swaap V1 among them. At Prague DeFi Summit 2023 he shows how the findings could help scale DeFi adoption by letting any investor benefit from passive, profitable yield strategies based on market making while reducing risk.

Speakers

Topics

From Prague DeFi Summit 2023, hosted by Prague DeFi Summit 2023.

Transcript

hi everyone thank you very much um so very excited to be here um so essentially um when you look at uh how people measure amm performance it's really confusing you hear the words training apy um boosted token emissions impermanent loss it's really hard even for power defy users to really understand what they're getting and the risks they are taking and what's confusing for the for the G5 power users is even more confusing for um the uh the new users that we want to

onboard in into D5 and so that's that's a real barrier that makes it filthy and difficult for those users to be on board into crypto so um I believe that is key for in the industry to better apprehend the way that performances in amms are measured and better understand the risks that we face and this is key because amms are the one of the biggest D5 Primitives with 17 billions uh tvl locked today I think lsds are at par right now um so so today what I want to do is first like reflect on why amms are so

cool and it's critical to maybe have more information and more clarity on how to analyze their performances second I will deep dive on a framework to better understand how to analyze performances and last but not least I will introduce the results of a simulator that we've built at Swap the company that I'm the co-founder that essentially allows us to bring Clarity to this topic and I will share with you the learnings from this study so um maybe just a quick refresher like why I think personally that amms are amazing and they solve a lot of problems and

that's why it's key to really understand how they perform to have full clarity on their design and better innovate there so um first amms are accessible to anyone of course anyone can LP can trade this is very interesting because when you compare to the equivalent the chartify equivalents of amms which is Market making funds those funds are only accessible to the best connected and the richest LPS you have to have significant size to be able to LP into a market making fund and have the right connections second they are transparent it's very easy to audit the yield that

is done by an amm and to understand how the yield is done this is key also because it avoids some of the terrible catastrophes that happen in our industry and also in traffic examples of that and Compass subscribers Capital which was essentially borrowing uh USD and Luna I mean betting taking some leverage on USD and Luna without having its LPS um Alameda of course which was playing with the fans from the FTX customers and um Bernard Madoff who was delivering 12 yields to its investors by using the funds of the inflows of the LPS

amms of course are non-custodial and I think I don't need to remind you why this is key um and I think one of their very interesting properties that we haven't start that we are just starting to touch is the interoperability of the lp tokens which enables to maximize Capital efficiency essentially the capital that you have into an amm is not locked like it would be into a in a traditional fund it can be used in other protocols so for instance borrowing against it in the learning protocol minting a stablecoin etc um in terms of drawbacks I think the the first thing that is uh as I mentioned

which is key is to understand okay what are how can we assess their performances because it seems that there's no Clarity on the market on whether those amms are really profitable for LPS or not and which risks you are taking um and another drawback is comes with the um the uh the proliferation of concentrated amms is that sophistication is required for such designs so as I said today let's focus on on the performances which to me is I mean aliens kind of tick all the boxes in terms of um a great infrastructure and solution to um provide security transparency and efficiency of the capital for Market

making there's just this performance issue that we need to sort out um so how can we assess financial performance I think this is very important to reflect on that and this is something that is not done very well in crypto today so um as an investor you want to assess two things first the returns and second the risk the returns is pretty straightforward it's the average return that you can make on the year if you do like the investment a thousand times for instance the return should be Nets there is no such thing as okay trading API impermanent plus whatever trading API doesn't mean anything

what's important is you have what you have in the beginning of the year and what you have at the end of the year and the average of this return and this is on the only thing that you should measure returns I mean I think in crypto we tend to focus on returns um but we should not um forget risks risks are very important risk can be are a bit trickier to measure than returns um one you you probably need several indicators one of which is the viability of the return so for instance if like you have an investment that is giving you a five percent yield every year it's of course less risky than an investment that is uh giving you 30 then

-10 then 20 whatever another good indicator is um the like the stress test so what's the maximum loss that you can expect from an investment in the stress scenario um then the big question is so yeah just to come back on the risk why is risk important is because a stable investment is what is worth much more than um a risk investment essentially with the stable cash flow you're able for instance to borrow um your your bank for instance can give you uh a credit for for your home if you have a stable salary because it's easy to predict your cash flows and um so you can anticipate that also um it's better for financial planning if

you know that you want to buy a house in two years of course you'd rather have a safe investment than a risky one so a safe investment is worth more than a risky one the second question is around the Benchmark so I would say for amms the best Benchmark is probably huddle um so you want to compare your returns and your risk to as if you were huddling the tokens that you deposited into the ammo but that can vary depending on your objective um and then the question and that I that I would like to address today is the methodology so um I'm like my conviction is that we should mix two approaches in order to understand like the performances of an investment and the risks first realize

data and second simulated data so realize data of course is very interesting because it enables you to um see what actually happens right the main issue with realized data is that in real life only one of the multiple scenarios that could have happened happens so let me give you a very concrete example until April 22 you could see UST as a perfectly stable stable coin with realized data you would have had no chances to anticipate that it would just go to zero so realized data can be a poor predictor of Market events because it's it shows

only what's happened in the past and the past does not necessarily reflect what's going to happen in the future so that's why I believe that it is key to ads simulated data to complement the approach simulate data of course are not perfect because um you're going to your there are some things that you cannot modelize and that you cannot anticipate but they help you to modalize stress scenarios and understand what can happen especially if you have a limited subset of data one of the issues that we have in D5 is that we're a very young industry D5 is maybe like three years old device summer maybe okay six years old Max and it's a very small subset of data so um so that's why I believe that

simulated data is key to to Access Financial performances and risk so regarding amms what can we see from both approaches so first if we look at realized performances we see that they are heavily in the red unfortunately so a report by bancor approximately two years ago showed that 50 of LPS reports negative performances on Univision you're going to tell me okay Bangor is a competitor of uni swap they obviously cheated on their report well another study made by a scimitar Capital which was actually later confirmed uh indirectly by the union swap team

so that LPS on University had a negative unrealized p l of 100 million so yeah I would say on so that's only on the East usdc5 basis point pool but I think this basically shows a trend there that overall LPS on Unison V3 are probably losing money so then what can we see from simulated data and that's where the amm simulator comes so at Swap we invest heavily on Research we've partner with the mathematicians and researchers in Market making that come from and we've developed with them a simulator that enables us to test any amm strategy in

thousands of market conditions turning the three four years of data that we have in D5 into 1000 years um so how does the simulator Works essentially we have some inputs which encompass thousands of market conditions so different price trajectory and then we input a trading demand so the training demand is are essentially hypothesis around um the size and the frequency of Trades that happen uh during the time period that we measure and essentially by using those inputs we're able to test uh amm strategies across thousands of market conditions so how does it work concretely so

basically we have this kind of metrics where we run let's say 1000 runs each time we do a run we compute we look at the return of the amm strategy against huddle um so so yeah so then we compute the average of the return and this is the dimension that you can see here which is like the uh like the return access and then we measure the variability of the return which is the risk Dimension right um so essentially what that means is that you can Define then uh several zones in this chart right you have the we're going to make it Zone which is uh on the top Corner top left corner so

high return low variability and you have the gambling Zone which is uh the Zone where you're at the casino right when you have a negative return and super high risk in other words you can um you can make a lot of money but you have more chances to lose a lot of money so what does that teach us well unfortunately it seems that current traditional amms have returns that are more casino-like than investment like um so what you can see here are various implementations of univ2 and curve with different parameters so on univ 2 those are the three parameters and on curve

those are like more like the the parameters of the that are that are used in the curved internal pricing model this is only for assets that are uncorrelated not for stable coins and what we can see is that unfortunately you need to a curve or in the gambling Zone um another very interesting learning is that if we Implement an approach which relies only on oracles and that adds fees on top of that um we can see that actually just introducing an oracle uh significantly improves the the results of these these amm strategies um so so that's that's also a very

interesting result because here we only added an oracle we did not do any complicated math or whatever so there is significant room for improvement um then I have a good news actually is that we actually found an efficient model thanks to this uh like simulator um so what what you can see the dots that you can see here are two models so first swap V1 which is a product that has already been live for approximately a year on polygon and then a new model that we found which is called swap V2 and which uh so those are the yellow dots that you can see here for which we have various risk parameters that allow us to to do to get much more yield than

um the current like swab V1 product which is essentially as you can see a very low risk very low return uh um so how does this model work actually um so it's it's a model that uses the most advanced Market making models that you can find in threadfy and adapts them to um the like the infrastructure of G5 so our models use these different parameters so first hypotheses that are based on unchain analysis uh with like the trace frequency and size uh the Traders demand sensitivity and the evolution of the prices and it also includes a risk component essentially we

can tailor the the aggressiveness of the model to decide to have to either like go for a more like high risk uh High return strategy or lower score return strategy um so the model uses all of those parameters to maximize the p l of LP into the amm minus huddle so it's it's aimed at outperforming huddle essentially and what it acts mainly is on the fees so essentially we modify the spread of the asset pair with two two elements first we increase essentially we increase fees when there is high volatility on the market because it's more risky for as a as a market maker to quote prices when the

volatility is high and the second thing is the model also acts on the reserves to ensure that when there is an imbalance compared to huddle it's putting it's been put back to balance and reduces fees to give incentives to people to rebalance it essentially um this model also uses um so essentially price feeds it relies on a like oracles essentially and um we also innovate on the architecture side uh to maximize uh the the performance of uh of our model so essentially what we found is that by implementing a an architecture which is hybrid you can

actually benefit from the security the transparency the composability and the accessibility that you can find on chain with the performances that you can find off chain in terms of latency of data feeds for instance so our new architecture relies on a hybrid implementation where the liquidity pools are on chain so you can you this is non-custodial you just deposit the liquidity into public pools and then you have another module which is a quotes module which is done partially off chain so the trade codes are generated off chain using the complex models that I just shared this enables us to have access to super fast

um price data and computes uh like harsh computations essentially the quotes are then verified on chain to ensure that they don't uh rug the LPS or that's a dysfunctioning of the back end cannot hurt the LPS um and the last thing is the all the trade settlements is done on chain so there is no uh yeah essentially you get kind of The Best of Both Worlds the performance of the off chain with the security and the transparency uh of the on chain um so actually we're launching this so yeah our V1 had uh as I described was a like really low risk chloriton products

um it was a BTC East usdc pool that launched approximately a year agon polygon which had um 0.1 percent in impermanent loss a net yield uh around 1.5 percent um and yeah essentially um with V2 with this new infrastructure and this um this those new equations we think that we can strongly improve that um we're going to launch actually in uh in approximately one month we are running a white list program actually uh for uh to test uh the the products thanks to the white list you can also have access to exclusive benefits so if you want to to try it don't hesitate to

flash this code uh yeah and join the white list foreign now it's time for a few audience questions let's see one over there hi perhaps uh an unfriendly question but is it not similar to running an arbit trash bot basically which then kind of rewards the LPS because like the off chain infrastructure probably has to know the prices of the assets and all the other venues and then somehow uh process it and then push it on chain is that not how it works um so I'm not familiar with exactly how like the flashbot infrastructure works but uh I I don't think it's similar no it's not it is not rely on Arbitrage

it's uh it's it's just uh like purely like the so essentially the prices of the other uh the venues like are they are more computed at a meta level not uh on the instant level by the trading demand function essentially so by modalizing and analyzing the trading demand uh function you are able to understand okay what are the Dynamics of pricing in other venues so that the quotes are tailored to be maximizing the p l for LPS but it does not rely on Arbitrage it's not a module that we have added for now it could be in the future foreign so you mentioned that you benchmarked

the model against holding the assets and you also had the statistics that 50 of the liquidity pools have negative pnl have you modified that or not modify the number but have you benchmarked that historical performance against holding and how does that change it because I it's is it 50 negative p l or if you Benchmark that historical data against holding does it change to Better or Worse um so to be honest we haven't like converted the the yeah the numbers of the simulator into like this specific kpi of like number of people in the red um I think I would expect it to be

higher than 50 given what we see is that the Returns on average are negative hey thanks so your simulation and then um this amm proposal like whatever your your version of uh so the constant function whatever you guys are using it seems like this is specifically for large the the largest tokens so the most liquidity multiple very deep uh pools that's this is true right like this doesn't really true yeah it doesn't really seem like it's their coins or any like vast majority of alts even so essentially

um what one needs to understand is that if you don't have private information it's impossible to be a profitable Market maker for coins because um essentially in a like in general in financial markets um you always lose against someone who is better informed than you and that's also one of the big reasons why amms are not profitable is because they don't rely on any external data and they just pay arbitrages to give them those information points um so if you start trading like Market making coins without private information which is illegal and by the way to to trade with the private information um but if you do that you're essentially trading OS against insiders because usually people who hold coins are

mostly insiders so so it's it's very unlikely to be profitable for such assets or you would have to put very large spreads hi thanks for the presentation coming to the risk I have a question of course there is a impermanent loss but when we coming to the worst scenario for example I'm putting liquidity into unisweb LP and the pool gets tracked so what is the percentage of this it can happen basically in your eyes or like if you calculated assessing the risk reward of the strategies so not sure so what you mean is like what are this what are the risks besides the financial risk of the strategy or know exactly if you calculated what is the percentage risk of pool get rucked

for example a if USD on the unit swap so of a rug of the pool well I think so on uni swap I think this never happened like a rug of a pull like it's not possible in the smart contract here what we measure in this presentation is only the financial risk of the strategy so it's really about okay depending on the evolution of the prices and given like the the formulas that are used by curve by uniswap Etc um what are the financial risks but you are right there are other risks that you take when you're an LP you face a smart contract risk you face maybe a rug risk or whatever which I think to me is kind of similar to the smart contract risk but um those are not measured here in this presentation

awesome thank you so much a big round of applause for sale [Applause] [Music]