New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

The truth about bonding curves Demystifying concentrated liquidity - Aleeza Howitt

Ethereum DenverMon, Oct 9, 2023, 12:00 AM

This talk will be a layperson’s introduction to the use, design and technical architecture of bonding curves. We plan to discuss why and how bonding curves are used and their relationship to liquidity concentration in a liquidity pool. We will cover the strengths and limitations of traditional bonding curve shapes to help new listeners develop an intuition for AMMs. Then touch on some of the novel approaches to bonding curves (Uniswap V3) and conclude by introducing the Proteus AMM (from Shell Protocol) as a new powerful tool to design custom bonding curves. https://twitter.com/aleezagroks Aleeza Howitt Head of BD Shell Protocol Aleeza is head of BD at Cowri Labs, the creators of Shell Protocol. She's excited about improving DeFi so it becomes more reliable and accessible for everyone. She got into crypto through research in community currencies, government-independent universal basic income (UBI), and decentralized personhood projects. Jess is an applied mathematician working on Shell Protocol. She loves doing math in a corner. She does medicine on the side.

Transcript

foreign [Music] my name is Elisa I'm here from Shell protocol this is Jess she is also an engineer from Shell protocol and we are here to tell you the truth about amms demystifying concentrated liquidity this talk is a layperson's introduction to amm's and concentrated liquidity first we're going to go over how amms work we're going to talk about impermanent loss and how they relate to concentrated liquidity or how it relates to concentrated liquidity and finally we're gonna take a look into the future of amms so if you don't make it through this entire talk um here we go the tldr amms are riskier for real retail lpers than we'd like to think concentrated liquidity increases fee revenue for LPS but it exacerbates in permanent loss and it's ultimately harmful for most liquidity providers so we need to think critically about how we use amms so that we stop harming lpers keep liquidity in the system and ensure that Defy is sustainable I wanted to show you guys uh this quote that I kind of love from a balancer white paper a bouncer so it goes bouncer turns the concept of an index fund on its head instead of paying fees to portfolio managers to rebalance your portfolio you collect fees from traders who rebalance your portfolio by following Arbitrage opportunities so this sounds great but in reality the arbitragers are dumping on you as shown by this popular meme on crypto Twitter amms are in fact losing money um there is a recent analysis that on uniswap that showed a negative 30 average Roi so basically for every dollar deposited LPS Lost 30 cents another analysis estimated that the usdc youth pool had 100 million of toxic order flow um all right so let's just uh start at the beginning quick background on amms first came the order book order books are pretty simple they list buy and sell orders for bid ask prices that are added manually by Traders one of the big problems with them in the crypto world is that they require an intermediary uh so automated market makers is actually a pretty general term um it's used it's been used for a couple decades um but these determine prices algorithmic algorithmically and they're really important because amm's on blockchains allow you to so first of all bypass intermediaries um and they're actually they're great for bootstrapping liquidity for small tokens especially erc20s with low liquidity anything hard to get listed on an exchange like a centralized Exchange um and let's go one step further and consider the idea of a decentralized autonomous automated Market maker um so really an amm probably shouldn't have um any sort of centralized source for Price data um so no intermediaries as I said and presumably a good amm lives on a quality blockchain too so it's relatively censorship censorship resistant and no intermediaries can shut down your transaction um so uh I want to help you get an intuition for how amms work if you are not a math person or a finance person and not a crypto person and amm is basically a market making robot entrusted with an inventory of assets so for example US Dollars and eth now this robot is a very simple robot it doesn't know or care about the world about Real World prices the only thing it knows about is its own the contents of its own inventory um so how could it possibly determine the correct exchange rate between uh these assets that it's holding well it uses math that is programmed into it to determine the exchange ratios of the tokens that it's holding um for a very very simple example um uh suppose Robert has a hundred dollars and a hundred each and it's 2015 so the rate is the exchange rate is one dollar to one eighth um Alice swaps one dollar for one eth and now the robot has 99.101 each um so imagine and math might not be you know great here but imagine that the rate now changes to 99 dollars to 101 East um now an Arbitrage Trader can come along and swap one eighth back for one dollar which resets the price um for the amm and it also you know is a good deal for that Arbitrage Trader who just made a profit all right uh intro to bonding curves so the problem is that um basically the ratio of EFT usdc changes when you make a swap um the exchange rate will change on a sliding scale the bigger the swap the bigger the change in exchange rate this is also called price impact um how do you calculate the change in exchange rate well you use a bonding curve for a pricing curve this is very similar to an indifference curve in economics if you're familiar with that and a popular example of a very common bonding curve that you find everywhere is the constant product curve so this one's pretty simple also the formula is XY equals K or x times y equals K and here X and Y would be the two assets that you've got in your inventory so it could be a eth and usdc or dollars in Euros or whatever you want and K is the constant it's the also known as the invariant and here is a a little graph of a bonding curve that we'll get back to you later um all right so how does the amm get its inventory of tokens well it gets them from liquidity providers like you and me or hypothetically you know um why on Earth would you provide liquidity to the amm why would you entrust your tokens to this very simple robot well hypothetically you're going to earn fees from Traders um you'll also sometimes earn extra incentives provided by a protocol um each time a trade occurs through the amm the pool or the the liquidity providers collect a fee um usually on the order of a few basis points the pool keeps us money and then divides it up among the the lpers so it's the catch well as stated earlier you're probably going to lose money um so the the robot the amm doesn't know Real World prices and it's slower than Chad fi because it's on a blockchain in other words it's always going to be a step behind lpers are basically through the amm they're always buying high and selling low um that is the major downside uh we yeah so you may have heard the term floating around impermanent loss this is the opportunity cost of keeping your assets in an LP position instead of huddle or holding them huddling them this happens when the price of the tokens deviate from when you originally lp'd so you might still make money um on while suffering from impermanent loss through fees but you're gonna make less money than if you just kept your tokens in the first place and I'll turn it over to Jeff I hey I'm bad at words and good at graphs so I'll try my best to walk you through this uh so by way of example this we're going to talk about impermanent loss let's say that you are an LP in a balanced pool so right now this pool that I arbitrarily put together has token X and token y there's 40 of each you have decided to put in 4X and 4y the price because it's balanced is that 1X is equal to 1y if you're a math person the you can tell the price by the instantaneous derivative at whatever the point is so the change rate there if you were to swap one next it equal one way if you wanted to calculate your initial value of your portfolio well you put in 4X and 4y they're each equal to 1. so omitting units right now your value would be eight your the total pool value is 40 plus 40 or 80 you own eight you own eight percent of that so when you withdraw your funds you'll get or ten percent sorry when you withdraw your funds you'll get 10 of the fees of the pool let's say now that some time passes and X goes up in value a lot the price quadruples it's now worth 4y as a result Traders have come into the pool they've bought the they've bought up all the X and driven the supply down so now you're hanging out way up here on the Curve um where you have 20 of X and 80 of Y at this time you decide to withdraw your money you are entitled to 10 of the pool so you get 2X and 8y your final portfolio value then is you have the 8y so that's eight and then 2x each of those is worth 4y you have 16. great you like doubled your money that's awesome well it's awesome until you consider what your value would have been if you had just held the coins in the first place so if you just held on to that 4X and the 4y you'd have the 4y and then 16 4 times 4 so you'd have a value of 20. so by just simply alping into the pool and hanging out you lost 20 percent of your potential profits which unfortunately is true no matter how the price deviates if there's any deviation in price from one ulp you're going to lose money via permanent loss there we go so on this graph the holding price of your tokens or your your value is represented on the red line and if you were to LP that's the Blue Line the space in between represents impermanent loss so we made this assuming that you lp'd when the price was three so at any change you can see your impermanent loss there this maybe is a duh slide but LPS are only profitable when the fees you make outweigh the impermanent loss and our job is D5 protocols is to make sure that that happens to figure out ways to improve the odds of that so in the last few years that's been a a subject of great debate the first attempt was to try and address this issue of capital inefficiency and I'll try and walk through that and talk about how we've addressed it so people realize that okay well a lot of these assets are like pretty tightly correlated a lot of the trades are happening over just a like a small band of prices so if you look at your bonding curve let's say most of the time the trades are happening within like this 10 percent well when you LP ulp into all of it so your liquidity is spread over 100 of the curve but you're only collecting fees on the 10 that the trades are happening in that's what we call Capital inefficiency uniswap's big innovation with their V3 was to concentrate the liquidity and improve the capital efficiency basically they said okay well LP is now instead of putting your liquidity everywhere you can pick the two bands where you put your prices the two price bands where you put your liquidity so instead of spreading it everywhere let's say you can instead of putting a hundred dollars over the whole curve you can put ten dollars in between the two prices where you think most of the trades are going to happen and if if indeed most of the trades happen there you could make the same amount in fees using that ten dollars as you would of investing the whole 100.

this is called leveraged liquidity the idea of it behind this is that if you increase the efficiency and leverage your liquidity you only you'll make more money in fees but also the Traders will get better uh swap rates leading to more trade volume than there's a virtuous cycle where you get more fees from that too important caveats is that you don't make any money when the prices deviate from the bounds that you've set so if you are familiar with uniswap maybe you've seen this before I just took a screenshot like last night um but this is like a this is the ethusdc pool this is the typical or build liquidity distribution at the time I took the screenshot you can see those two really tall blue lines that's where most of the liquidity providers have chosen to put their liquidity at the time I took the screenshot the price is this it's kind of hard to see it's this tiny little pink dot over here so it's outside of that band so if you were unfortunate enough to have your liquidity in that big blue block and not over there you wouldn't be making any money and furthermore you would be losing a ton to impermanent loss because all of your assets would be tied up in the underperforming asset indeed the math checks out on this um when you graph it the you can see here the dashed line represents unit swap V2 and most constant product amms and their impermanent loss with prices the Bold line is uniswap V3 the red in between is just some arbitrary boundaries that I put there but you can see that with any price deviation you're actually losing more to impermanent loss with concentrated liquidity where does the money go well if you're losing money someone else is gaining money I call that the law of conservation of money and if if it's not going to use going to Arbitrage Traders so there we go um to summarize pros and cons of concentrated liquidity concentrated liquidity actually does work great if you can accurately predict where the price is going to go if the assets are stable or highly correlated it's also super profitable for highly engaged LPS like those providing just in time liquidity and Traders get better swap rates but it comes at the expense of someone else and usually that someone else is the liquidity provider indeed the research has shown this to be the case the caveat to this is this is like a super nascent science and no one can agree on how best to measure profit and loss and everyone has a different idea but but most analysis show that nearly all retail LPS are losing money by providing liquidity and concentrated liquidity pools I really like this graph because it was the most intuitive to me this was I think a bancor did this uh analysis in 2021 they now analyzed um is there a bunch of different trading pools here on the x-axis and the fees collected in those pools are represented by the blue lines the impermanent losses represented by the orange line so you can see in nearly every single pool in permanent loss outweighs fees this is just a bunch of screenshots of the intense internet debate about the best way to measure impermanent loss but you can see most all the lines are going down that's bad for us so to recap amms have an existential problem these are not enough to outweigh impermanent loss soon enough LPS are going to get wise to this and realize they're playing a losing game and they're going to withdraw their liquidity no liquidity means no defy so to make D5 sustainable we got to fix this experts have been talking about this recently these are not our ideas but we think they're really interesting uh one maybe we could charge premiums for arbitragers to have exclusive access to the pool here's a graph that our CEO put together of that maybe it would look something like this maybe we could charge Dynamic fees identify the arbitragers and charge them more maybe we can rethink when and where we use amms maybe how we're using them is not actually the best use case maybe there are different bonding curve shapes and maybe there's just a way to get pools that have less arbitragers in them I'll walk through a few of those in our last like minute and a half Croc swap I was they put a really interesting medium article out where they basically said okay well based on our analysis it's it's possible to figure out who's an arbitrager and who's not swap size among many other things is one of the ways you can you can identify who it is so what if we just find those people and charge them more they also pose this other idea which is well maybe um unit swap is so good maybe they're like they're they're they're such low slippage that arbitragers are not disincentivized there's not enough um price impact so maybe we deliberately increase slippage to disincentivize Arbor Treasures um this professor Alexander neslobin by the way he has this like really awesome medium article um series I highly recommend it it taught me a ton I loved this idea of his which is real let's think of an amm more like an order book what if we created a dynamically evolving curve you could change the curve in response not only to time passing but also to trades and reduce the bid ask spread our solution well we don't we don't know the right answer in fact we don't even like really know the right question to be asking but we think this is a really important question to work together on to improve this ecosystem we know that it can only be solved with empirical data that we need to test a whole bunch of these ideas and just see what works so we have been working on Proteus which is an amm engine it's just basically a way to build a super super flexible amm and test out a whole bunch of these ideas it can generate bonding curves of any shape those can change dynamically in response to trades or over time you can include fees dynamically or you can include fees statically and we're just excited to talk and collaborate more we think it's an important issue and we realize um Defy is kind of at risk if we don't work together on this so thanks for listening with that all close [Music]

Automatic transcript — names and jargon may be misspelled.