Liquidity Provision and Automated Market Making with Ciamac Moallemi | a16z crypto research talks
28 Oct 2022 · 1:06:34
Columbia Business School professor Ciamac Moallemi presents an a16z crypto research talk on liquidity provision and automated market making, reconciling constant function market makers with traditional limit order books under a single framework. He breaks down a liquidity provider's returns into a market risk component and a predictable adverse selection cost he calls loss-versus-rebalancing, and discusses how it informs both LP investment decisions and CFMM protocol design.
Speakers
Topics
Transcript
Um all right, so welcome back everyone. So I feel like this week it's kind of like it's a microcosm of the multi-disciplinaryness of web 3, right? I mean the governance on Monday, yesterday we had a consensus this morning. Um and this afternoon we're going to hear a little bit about DeFi specifically by Su Mac Molemi who's my colleague at Columbia. He's in the business school there uh talking about liquidity provision in AMMs. Thanks um Tim uh And uh this is joint work with Jason who is a PhD student at Columbia and of course Tim who you all know. Um just to begin by way of background, um you know, what I mainly work on is I'm an operations research person. I mainly
work at the intersection of you know stochastic modeling and and optimization. And main applications I think about are in quantitative finance. So things like quantitative trading, um you know, market microstructure, high-frequency trading, those sorts of things. And you know recently I've become you know let's say around 2017 came interested in blockchain. And been looking at you know sort of blockchain and particularly now DeFi through that lens, through those particular sort of quantitative finance kind of tools. And so this will be be be an example of that. Um so having having said that Tim has warned me that
some of these tools specifically ideas like you know sort of Black-Scholes pricing and stochastic differential equations and so on aren't really so well known in this community. So I do have to use those tools. However, I'm going to try and be sort of very informal and focus more on the intuition rather than than getting you know sort of the being very precise about the technical details. So I will try to be gentle on that topic. Um but I'll simultaneously also ask you to be gentle because this is a sort of preliminary work and we are very much looking for sort of feedback and comments.
So with that let me go ahead and and and get started. So what we're talking about here is liquidity provision market making mechanisms for for exchange. It's helpful just to sort of take a step back and see what are the dominant mechanisms for for exchange for trading. Right? So um the problem is suppose you want to exchange assets. So for example, you you have Ethereum and you want to buy dollars or you know vice versa that will be our our running example. If you look at what the traditional solution for that is in in the TradFi world, maybe 90 plus percent of the TradFi world certainly like liquid assets have converged on one sort of market
structure and that's the the electronic limit order book. Right? So there might be some variation in terms of how this is sort of precisely implemented and so on. But the the basic structure is you collect these things called limit orders which are orders each attached with a assigned quantity like either you want to buy or you want to sell and there's a certain quantity and also attached to a price the other so-called limit price. And the exchange be it Nasdaq or Coinbase or whatever, they accept these offers and they collect them and they try to greedily match them. Right? And so after things are matched, what you're left with is something like the list over here in the lower right where you have a bunch of sell orders with
different quantities at different prices and at lower price levels you have a bunch of buy orders and that's the available liquidity. And someone can sort of show up and either buy at one of those higher prices or sell at one of those lower prices and so on. And again you know, for the most part the market has really converged to this this this structure. But there there are a number of issues that it has however, right? And first issue relates to trying to do this on chain, right? So naturally it would be nice to maybe have an electronic limit order book, but maybe not have you know Coinbase or whoever sitting in the middle have something sort of completely decentralized. But the
problem is there's a lot of you know storage and and computation and updating here. You have to keep track of all these orders. The matching process you have to sort of walk through the order book. Moreover, you know, these are typically updated at very high rates like in you know you know exchange like Nasdaq you might have you know a thousand updates on the time scale of a millisecond in terms of you know people adjusting their orders and so on. So you know again in the context of something like uh Ethereum which has sort of very limited kind of computational capacity doesn't really work on chain. And and the second kind of issue is you can't just set up a limit order book and immediately start that trading. You have to have someone
providing liquidity, right? You have to have market makers that are basically going to you know provide liquidity over time. So Tim shows up and and wants to buy, he's an organic buyer and I'm an organic seller. I might not show up till till 10 minutes later, right? So ideally we'd like to be matched, but someone has to intermediate in the middle and that's the job of a market maker. Right? Now market making in these these limit order books is a very labor-intensive strategy. As I mentioned they're sort of constantly updating their quotes. There is a lot of you know sort of proprietary knowledge in terms of sort of how to do that effectively. People sort of compete on that. So if you just sort of sort of set up an order book for you know some new token and say okay you
know market go, it's not going to happen, right? The market makers won't participate unless it's already a liquid market and they already know they're they're going to make money or alternatively unless you pay them. Right? So if you're trying to trade maybe long-tail assets, right? This isn't really effective by itself, right? You also have to have to sort of bribe these these these market makers. So as an alternative, what has been suggested is this idea of automated market making, right? And this isn't an idea that I think you know emerged earlier in the prediction markets sort of literature.
Not exactly in this form, but inspired by that the key idea is to have these sort of liquidity providers, but rather than this kind of active trading, it's going to be something much more passive and such more much more rule-based, right? So the liquidity providers will supply pools of the other two assets. So in this case ETH and USD. They will always provide quotes to either buy or sell either one of these in exchange for the for the other. But these quotes are done by an automated mechanism, right? So in the context of a smart contract they would be done by the smart contract itself. You wouldn't have to have these these market makers
actively managing a market making strategy. And of course once you suggest this the the key question is well how do you do this? How do you set the price? What is the quoting mechanism? And again the key idea sort of proposed by Vitalik and subsequently elaborated on by others is to sort of leverage this this prediction market idea. And and and this is the idea of a of a constant function market maker. The idea of this is as follows. You're going to have two assets, right? And you're going to maintain reserves in those two assets.
So in this case X would be maybe Ethereum, Y would be um the US dollar or USDC or or whatever. And what you would the rule of the pool would require that an invariant be maintained. In other words, there would be some function F and we require that f of xy equals L, but otherwise you can transfer as long as you maintain that invariant you can move between any configuration of X and Y. So for example, if you're at the at the purple point you can jump over to the other green point and that would involve buying Y from the pool and in exchange depositing X to the pool.
Right? So this is the idea of a constant function market maker this bonding function being the so-called constant function. And so for example, the most prevalent rule is the the constant product market maker where you require the product of the reserves in the two pools to be to be constant. Or equivalently we could require that the square root of the product i.e. the geometric mean be constant. Right? And that's what's used in the older version of of Uniswap. And what you can see if you look at this for a little bit is if you have a a mechanism like this, if you have an invariant curve and you observe where you are in the invariant curve.
For example, if you're at the red point in terms of what are the reserves on the horizontal axis for X and what are the reserves on the vertical axis for Y, that implies a price. Indeed the slope over here is giving you sort of the local trade-off for how much of Y you have to give up for for a certain amount of X. So that slope I can interpret as a spot price i.e. the price for a very very small trade an infinitesimal trade. And there we go. There's my quoting mechanism. Right? So I have an automated kind of quoting mechanism as process as promised. There are minimal storage needs. I don't need to store all these limit orders for buying and selling and whatever. All I have to basically do is store one number that number which is sort of the aggregate level of liquidity
which tells me what level set am I on in terms of the the invariant function. And you know computations can be done very quickly, right? So in a limit order book to sort of figure out a trade I have to sort of walk through these orders and sort them and so on and so forth. Here the computations are sort of very easy and are are typically done with closed form algebra i.e. like addition, subtraction, square roots and so on. So very amenable for smart contract implementation, very amenable for for gas golfing and and so on. So, yes. What does the square root do here?
X and Y are fixed. Sorry, if X and Y are fixed or constant, it doesn't really matter to take the square root. It doesn't really take matter for the purposes of this talk, it won't matter. You could take X and Y you could sort of get rid of the square root, but including the square root makes the other function homogeneous and that allows us to actually interpret L as some kind of additive level of liquidity. So, there are reasons I take the square root, but for purposes of this talk it doesn't matter. And you if if it if it, you know, you can just imagine constant product. So, you know, I presented two mechanisms here. We have the electronic limit order book, we have this constant function market maker. They look quite different on the surface and the agenda here is to sort of think about these
things and and and try and understand and see, you know, are they the same? Are they different? How can we compare them and and and what's the what's the best mechanism if you will? And so, what I'm going to talk about today is I'm going to talk about sort of two things. First, I'm going to take these two mechanisms that I showed you and I'm going to redefine them in in sort of a common framework. So, I do have the language to speak of them in the same at the same time. And so, we will begin to sort of see what are the tradeoffs and they'll sort of, you know, we'll see how they fall into the same framework albeit with different design choices in the the two cases. So, that'll be the the first part of the agenda. The second part of the agenda I'm going to specifically
focus in on constant function market makers because indeed they they are new certainly relative to electronic limit order books. And what we're going to do is we're going to try to understand the economics. And what I mean by that is if you were a liquidity provider, if you're thinking of depositing money in one of these pools depositing ETH and and USD, what are your considerations in terms of is that a I'm I'm going to be a good investment or not? Right? So, that's our plan. Any questions before I launch into it? Okay.
So, and just in the interest of time, I'm not going to go over the literature. I will just say at a high level there's three strands of literature I think are are quite relevant. There is the classical options pricing literature and in particular in finance there's also a literature that applies options pricing theory to market microstructure thinking about things like limit orders. So, that's a sort of quite relevant. There is a second strand of literature from the the, you know, really, you know, maybe Hanson's paper is a good starting point and talking about the sort of prediction markets and as I mentioned before that's the inspiration. And you know, starting with Buterin, Koppelman and and Liu and sort of really with DeFi summer in 2020 and so on, there's been kind of an explosion of more recent
literature just really focusing on what I'm talking about today which is using these AMMs for for exchange and not for for prediction markets. And now since why is options pricing taking a better hit? I'm sorry? Why are options taking a better hit than the regular options? Well, I think you'll see in a second, but just to sort of you'll see in the second half of the talk, but just to sort of give you a preview, at some level you can think of a limit order as an option, right? Like you leave an order in the market and someone later can come and sort of exercise it and it looks like, you know, at some level like a call or a put, right? So, those ideas are going to come back and be be relevant. So, that's sort of the classical thing we'll see in the second half of the talk how options
pricing comes in. By the way, Andy was explaining to me today that he had a prior life as an options trader, so he's going to keep me honest when we get to to that part of the talk. All right, so let's talk about a general framework for for exchanges. So, again, our agenda here is to try and understand different design choices in making exchanges and you know, prerequisite is to have a common notion of exchange which simultaneously can sort of think about something like a limit order book as well as a constant function market maker.
And if, you know, if you can incorporate both of those things, it must be a very rich design space and the question that we would like to answer and I think we do answer is what is the right parameterization to think of choices in that design space. Okay, so let's start. We're going to imagine we have two assets. The X asset will be a quote unquote risky asset which, you know, we'll take ETH as the running example. The Y asset will be what people in finance like to call the numeraire and that just means the unit of account. In other words, what do we express our prices in, right? So, this is just for convenience, it's not sort of fundamental, but when I talk about prices, it'll be the price of one unit of X in terms of units of Y. So, in particular, how much USD for for one
ETH. Sort of typically the common way we we we think about that particular coin pair. And if I'm going to tell you a framework for exchange, there are sort of two sides that that I have to explain. One is the side of what do the the liquidity providers see? In other words, what's the API that they are kind of exposed to? And then the flip side is if someone comes to trade, what is the mechanisms of that? So, let's start with the API for liquidity provision. The idea is as follows. You're going to have a bunch of liquidity providers and each of them is going to submit a demand curve. So, the ETH liquidity provider will submit a demand curve called XI. This will be a function of
prices and this specifies the quantity of risky asset of ETH that that liquidity provider would like to hold at a given price level across all price levels, right? So, this terminology is a little bit weird because we have these liquidity providers, so we think of it as the supply side of the market, but really the demand I'm talking about here is not is is kind of their demand for the risky asset. And because it'll it's going to turn out that these demand functions are downward sloping, so that's why I use this terminology. But even though I say demand, I'm really talking about the supply side of the market. So, we have these demand curves from each liquidity provider. The next thing that
we'll do is we'll aggregate across all the liquidity providers by simply summing their their demand curves and I get some aggregate liquidity. And then of course, over time, you know, we might have new liquidity providers arrive, we might have some of them depart or maybe they want to change their the demand curve that they've submitted. So, this X will be updated over time to at any time be the sum of the then current individual demand curves. So, that's the API from the perspective of the liquidity providers.
How about the traders? So, again, these are people who are arriving and they want to trade against this particular mechanism or exchange. At any given time we're going to call the quote unquote state of the exchange to be this aggregate liquidity curve object and also a price. So, let's say the price is a P0. When a trader arrives, they observe the price P0 and what they can declare is they can declare that they want to move that price P0 to another price, let's say P1, right? And so, what happens when they do that? Well, they get a certain quantity of the the asset, right? So, if in aggregate the pool wanted to hold X of P0 at P0 and then it's going to move to X of P1
at P1, this is the quantity that should go to the trader. So, if it's positive the trader is buying, if it's negative the trader is depositing that quantity of coins. Now, of course, they're they're going to get these coins, they have to pay something and so that's the second part of the trading API. And so, here's the payment rule and I'll walk you through this, but I'll tell you at the onset this is sort of the obvious thing you you would do. The idea is that if you're moving from the price P0 over to the price P1, there's a whole bunch of intermediate price levels, right? And we have this aggregate demand curve which is telling us how much liquidity is supplied across those price levels. So, what I want to do is I
want to sum across the intermediate prices and I'm going to take that price and I'm going to take the marginal quantity that is offered at that price, right? And I'm going to, you know, multiply those two and and add them up and and that should be the cost to sweep through the aggregate demand curve from the price level P0 to to P1. Now, of course, here this is I'm imagining that prices are continuous, right? So, I can't really do a sum, I have to do an integral. So, for example, if the the aggregate demand curve was differentiable, I could, you know, sort of generalize the sum to the integral where I integrate over prices, I take price times marginal quantity at that level and I have to do a sign
correction, so that's the the negative sign right? But we're actually going to be even more general than that because we want to allow for demand curves that have jumps, right? We want to allow for things like a step functions. So, we're going to take the generalization of this sum as not just like a Riemann integral, but Riemann-Stieltjes integral which, you know, basically I'm integrating directly against increments of this object. So, you can just view the last expression as a generalization of you know, regular integral that allows me to integrate against increments of something with jumps.
Any questions so far? Okay, so so far hopefully this seems reasonable. What I'm about to argue is in fact this is really the only thing you can do, right? And so, why is that? So, I'm going to define a notion of incentive compatibility and what incentive compatibility means before I go through the definition is basically I've been honest about what I've been saying, right? So, I've been saying that this is the demand that's going to be held by the pool at different sort of price levels, but why is that? Who is enforcing that? Well, incentives are enforcing that. In particular, we're going to say that this exchange is incentive compatible if whenever the trader values the the risky asset at some price P tilde, no matter what the price on the exchange is when they
arrive, they're going to move the exchange price to P tilde. Right? So, that's the definition of incentive compatible. And simply by the fact that I've used those words, maybe some of you who are familiar with mechanism design should sort of start to realize that this is a setting which is is actually familiar. This is a setting where we can apply Myerson's lemma. Right? And so, what does Myerson's lemma say interpreted in this setting? It says that this exchange mechanism I'm describing is incentive compatible under under two conditions. The first condition is that the aggregate demand curve is non-increasing.
In other words, it has to be sort of downward sloping as I promised. As prices get higher, the pool has to hold less of the risky asset, number one. And number two, that payment rule that I argued is intuitive is in fact really the only thing you can you can do. Right? There's really no other kind of flexibility. Right? So, for those of you who maybe know some of this theory, let me just give you a quick glossary. What in mechanism design would be called the type in this case is the price. So, we have a single parameter type space that is one-dimensional and continuous. What mechanism design people would call the alternatives, those are the
the quantities. The utility function is linear. We're just being we're just valuing one unit at the price P tilde. And finally, when I talk about the demand curve in mechanism design language, that is the the allocation function. Right? But all of this kind of maps exactly. And in some sense, this is telling you that this is this is sort of the fundamental object, this X. There is nothing sort of you know in in in a general sense leveraging on all this work in in mechanism design, there's sort of kind of nothing else you can do in terms of you can't allow other X's if they're if they're if they're not monotone in this way, they won't be incentive
compatible. And you can't have any other function in terms of how you charge for for for the quantity. Yes. So, like this model kind of assumes that like LPs are just kind of static. Like there's no incentive like I see for the liquidity providers here, right? I'm sorry? There's like no sense of IC for the LPs here. There's no sense for the IC. So, I'm assuming the the the LPs are static. And that's going to be sort of running throughout. So, you're right that as conditions may change, LPs may exit and enter and so on. But I'm going to you know throughout this talk, I'm going to imagine where time zero, the LPs commit to something and then maybe over you know some kind of short time scale, maybe a day, you know whatever what what you know, how does that work out? That's going to be the setting
we're looking at. And this is purely from the buyer's perspective. Okay. So, if if if this is you know sort of the design space, what are the kinds of alternatives we're seeing? Well, all the alternatives that I presented to you so far in terms of the limit order book and the constant function market makers, they fall into this simply with restrictions on the demand curves that are allowed. Right? And in particular, all of those mechanisms, you're not allowed an arbitrary curve X. However, you're allowed curves X that are determined by some basis functions.
Right? So, if I require that either X or XI be in the be parameterized by some basis functions. If those basis functions are non-increasing and if I combine them with positive coefficients, in other words, I look at something in the cone generated by by basis functions, then the the aggregate function will also be a non-increasing. And so, therefore everything will be incentive compatible and I will be be fine. And maybe sort of the thing to think about is exactly what are those primitive basis functions and how many of them are there and so on. And maybe one notion to think about how complex a mechanism you have is something about you know the size or the cardinality of the number of basis functions. So, let me give a bunch
of examples. Any questions before I show the I show the examples? Okay. So, let's talk about a limit order book. If we think about a limit order book, I showed you it's a collection of orders with quantities at different price levels. If I view that as an aggregate demand curve, what you're seeing is you're seeing a step function as you cross each of those price levels. And as you increase the price and you take liquidity, the remaining available decreases according to a step function. Right? So, the way to think about those liquidity jumps at discrete price levels is to say that my quote-unquote basis functions are are are are something like this. This is like a limit order. Right?
It's a limit order to to sell where if the price is below the price of the limit order, you own the the risky asset. Once the price goes above, someone buys it from you and your position is zero. But your demand curve, i.e. you go from here from L to to zero, that is given by a step function. Right? And moreover, the price levels are only at discrete indices, multiples of a of a tick size. Right? So, here you can you know, this tick size is typically usually small, often is very small. So, by taking combinations of of of basis functions, you can get pretty close to any monotone decreasing function or non-increasing, I should say. But maybe you need a lot of
these basis functions. Right? So, this is a you know, a setup where you have a lot of fidelity in terms of you can express whatever curve you want or hopefully get close. But maybe you need a lot of information. I need to give you a lot of bits in terms of the the coefficients. On the other hand, if we look at you know, the constant product where the the market the bonding function is is given there. If you decide to participate in this mechanism, all you can do is decide how much of this do I want. Right? So, in other words, that's like you have a single basis function.
And you're simply deciding what multiple. And if you go back and you sort of look at the curve and you do some calculus and so on relating prices to quantities in the invariant curve I showed you for for this bonding function for the constant product market, what the the um implied demand curve is is that it falls off as the square root. Right? So, so here you you can only take multiples of one over square root of P. That's sort of the only option. So, you know, very low complexity, but also not so expressive.
Right? And so, let me give you a third choice. This choice is Uniswap V3. And so, Uniswap V3 is a variation an improvement, I would say, over Uniswap V2 that was introduced, I think maybe 6 months or a year ago or something on on on on that kind of time scale. And the primitive in Uniswap V3 is to take this Uniswap V2 constant product thing, but to do it over a compact interval. Right? And so, that's the concept of a range order. It's like the constant product formula where you're falling off as one over square root of P, but instead of falling off as one over square root of P over the entire real line, it's concentrated on a a range between a lower end PA and an
upper end PB. The benefit of this is this is more capital efficient. Right? When you have the the sort of the function over here which is you know, over the entire real line, you're depositing tokens that may never ever trade because you know, the price would have to be really really high for for those tokens to to trade. Right? On the other hand, here you're guaranteed that once you hit the price of PB, all of your risky tokens are gone. And that's good in the sense that you know, they're doing something. They're being traded. They're not just you know, sitting there and and and sort of wasting space somewhere. Right? So, these these points are also on a discrete price grid.
The tick size is a basis point. It's a geometric grid, not an additive grid, which is typical which is larger than the typical tick size for a limit order book, which is you know, something like a penny. So, you know, on like a you know, $100 stock, this would be a tenth of that. Right? So, so on one hand, it's it's coarser. Also, I think the expectation is you know, you would use not as many of these you you wouldn't use a huge number of these orders to express your preferences because the amount of gas required to sort of be a liquidity provider is going to scale with the number of subcomponent range orders you have. But you can start to see this is something
in the middle. Right? By maybe using a handful of these, by maybe not you know, having PA and PB just be one tick, but having them be over longer ranges, you can start to get sort of an intermediate outcome where you're somewhere between a limit order book which has you know, which is very kind of expressive, um but on the other hand, very complex. And something like a constant product market maker which is really sort of you know, one-dimensional and you know, easy to handle, but on the other hand, maybe not so so expressive. So, that's the sort of the spirit of the the idea. Again, as I mentioned, this is sort of ongoing research. I think it's a very nice and kind of classical framework we're in in terms of this kind
of Myerson framework. But I think the big open question we're thinking about right now is is what is the right measure of fidelity. Right? So, how do we know how much expressiveness is is is we need. How close we need to get to whatever the the the optimal demand function is. So, in order to sort of have this this trade-off, we can sort of quantify the the left side, you know, the complexity in terms of number of basis function, but we need to understand what's what's there on the on the right. But, I think the the main insight of you know, what I'm telling you right now is that this these demand curves are really the sort of the right object, right? They're the right object, you know, when people sort of usually talk about constant function market makers,
they really focus on the the bonding function F. In my mind, F is a computational device. It's great if you're writing a smart contract cuz you want to be efficient in that dimension and so on, but it doesn't lead you much economic intuition. Here, thinking about the demand curve, not only does it unify these these different objects, but it also has a lot of economic meaning both in terms of what we saw with with Myerson's lemma, but also in terms of what we're about to see in terms of options pricing. So, I'm going to pause here before I move to the second half of the talk and see if there are any questions.
Yes. So, like for the Uniswap V3 like basis functions, in what sense are those like as good as the like step functions for approximating any like downward sloping demand curve? I think if you had enough of these and they were fairly spaced, I mean, you could you could you could sort of you know, get pretty close in in in both cases. So, I think if you sort of formally took a limit where you had sets of this type of basis function versus just a step function for a limit order book and you send the tick size tick size to zero, you would get some kind of convergence to you know, sort of whatever whatever function you wanted.
I would I would say two just things that are not fundamental but conventions is you know, the V3 basis functions first of all, like usually it's a wider range. For the order books, I think that the tick sizes are being like a pain in the butt basically or whatever the word is. And then the other one is is actually I believe Uniswap V3 uses intervals that are constant size in log space. You know, so it's basically like every 10% increase will get you to a new kind of bucket basically. But, so in the limit, presumably you're getting all sort of monotone, you know, non-increasing functions for either one.
This is exactly how you see it. So, it's sort of like the range you are approximating that you care about, they suggest using sort of the tick sizes or the actual sizes accordingly. So, there's some dependence there. Does that make sense? Yeah, okay. A question from Zoom. So, Uniswap V3 tick ranges technically are are supported from PA to PB. I know we need this decreasing assumption but like in if we're being exact, right? I mean, you wouldn't have any liquidity between zero and PA for a for a single Uniswap V3 pool, right?
Wouldn't it be all in one asset? Like if your order is out of range, if your range order if the current price is not within the range, wouldn't you all be in either asset X or asset Y? I'm not sure. I didn't know I wasn't sure if trades occurred for that single pool. but trades don't occur, but what that means is the tokens you've deposited are all one kind of token. But, if if people can't trade using that token, is that liquid is that liquidity? Well, they can't trade at the current price level, but if the price level moves so that your order is in becomes in range, then they will be able to trade.
Okay. So, what I'm going to do now is move to the second half of the talk and here we're we're thinking about the economics. And so again, I'm I'd like to assess the the constant function market maker from the perspective of someone who is providing liquidity. And you know, sort of at a at a high level, you know, is this a good investment? Should I become a liquidity provider? What are the factors to sort of think about? And I'm going to break that down into three sub questions. Right? So, the first sub question is as follows. If you in invest in a CFMM as a liquidity provider, you're going to be impacted by market risk. What do I mean by that?
Again, if you have this ETH-USD pool, what are you literally going to do? You're going to deposit ETH and USD, right? And in particular, you own ETH, right? At this instance, you own some ETH that are that is that is in the pool. And so, one aspect of your performance is not to do necessarily with the particulars of the pool and and that mechanism and who's trading against you and so on, but simply like does the ETH price go up or go down? Right? If the ETH price is going down rapidly, then maybe no matter what the structure of the pool is, you're going to lose money and maybe if it's going up rapidly, you're going to make money, right? And what we'd ideally like to do is we'd like to disambiguate these two.
We'd like to sort of separate it, right? Because if you want to make a you know, a directional bet on what the ETH price is going to be, there are other ways to do that. Right? And so, as phrased differently, that market risk can potentially be hedged. Right? So, sort of what do I mean by that? Again, so suppose you want to provide liquidity, but you don't have a view on the price of ETH. What you might do is you might put a bunch of money into a CFMM, have a bunch of ETH there, but again, you don't want to be long ETH. So, what you would do is you would come up with some other contractual mechanism, perhaps you go to FTX or Binance and you trade ETH futures and you go short. Right? So, the idea there is whatever the profit and loss you have
because the ETH price is going up and down in the pool will be offset by your futures position on Binance. Right? And so, you know, so that allows us to sort of really isolate what's specific to the pool as opposed to you know, you know, being long the the underlying assets. So, that's sort of you know, one thing it allows us to disentangle these two things. The other thing is even if you don't want to hedge or maybe you can't hedge because there's no way to go short or something, I think it's nevertheless interesting to sort of separate the the profit and loss of this pool investment into something which has to do with what did the market do and something which has to do with what are the characteristics of this mechanism.
Right? So, that's one question we're going to try to answer. All these questions are related by the way. The second question we're trying to going to look at is we have this idea from the first half of the talk of this liquidity demand curve. Right? So, you know, again, I'm imagining at time zero, a liquidity provider shows up. They are committing to this liquidity demand curve, right? And then that's going to sit there in the on the chain for for for a while. They're somehow giving up optionality, right? So, they're they're committing to this thing and then later prices evolve, people come and trade against it and so on, but you've sort of committed to to this thing and and there should be some value for for sort of moving first if you will and having other people who may possibly take advantage of you, right?
And so, the question is what is the cost for for giving up that optionality? That's the second question. And the third question is if you're going to be paying a cost, there has to be some kind of benefit also and that benefit is trading fees. Right? So, a different way to look at sort of the second question is if there is some kind of cost due to optionality, we want it offset by by trading fees and to the extent we understand that cost, we can understand what are good rules for fee generation. Right? Because again, we'd like these two things to be commensurate. Your fee income versus your your option cost, both of which I'll be more more specific about, should should sort of net out. So, these are
three different questions which are sort of slightly different lenses into the same underlying point, which is what is you know, CFMM from the economic perspective of a liquidity provider and our contribution here is we're basically going to answer these. Right? We're going to introduce some metric called lever or loss versus rebalancing, which will simultaneously address all of these. So, that's a little bit vague right now, but let's let's sort of dive into it and and and see what I mean by by all this. All right.
Before let me just give you a preview of the the the kind of results we're going to have. So, what I'll show you at the end is this result. I'll I'll I'll justify this. And what you can see is the output of this theory, this this lever idea is going to be sort of very concrete tradeable implications. So, let me give you such a concrete example. Consider, you know, not Uniswap V3 but the old Uniswap or any other constant product trading pool where you're trading ETH versus a USD. Right? So, in Uniswap V2, the trading fees were 30 basis points. So, if someone comes in to trade, you earn 30 basis points of that trading volume. An important ingredient in our model is going to be the volatility of the risky asset. In other words, how much does it
move today to day? And just to use a ballpark number for the volatility of the ETH-USD pair, you know, maybe 5% is a reasonable number. Our analysis would yield that there is a daily sort of running pre-commitment cost, this thing we call lever, of about three basis points on the value of the pool. Right? So, imagine let's say this pool was worth $100 million, three basis points means every day you bleed $30,000 in terms of this pre-commitment cost. The flip side, of course, is you get trading revenue.
And if we want to equalize the revenue earned from trading to how much you're you're paying in terms of this this this pre-commitment cost, the break even if you do the algebra is you need to be trading on a daily basis about 10% of the pool. Right? So, you know, again, a $100 million pool, you're going to be paying $30,000 a day in terms of lever cost. In order to recover that lever cost in from the fees, you need to be trading $100 million of ETH every day to generate $30,000 of fees. Yes.
Are we assuming anything about correlations between sigma and volume? So, I'm assuming sigma is constant. Um but that's a good point. In a more sophisticated model, usually volume is high when sigma is high. But for the purposes of this discussion, it's just sort of the starting point. Sigma is going to be constant. Right? So, so you know, this gives you something very concrete. You can look at this pool and you know, to decide whether to join or not is basically assessment of do I think 10% of the volume is going to trade in the next day or not, right? And moreover, you our theory will tell us how this varies with things like both the structure of the CFMM, in other words, it's demand curve, but also with market conditions, in
other words, how it scales with things like a volatility. Right? So, this is just a preview of what the kind of output of of our model is going to be. Let me dive into it. All right. So, the setup is going to be a continuous time Black-Scholes kind of classical options pricing setup. And so, there's going to be stochastic differential equations and so forth, as I already alluded to. The downside of this kind of setup is that it's technically more complicated, but there's a huge upside in that we're going to get closed-form formulas for everything, right? And that's sort of part of the upside of the original Black-Scholes model is that you get nice closed-form expressions for everything.
Again, without loss of generality, two assets, a risky asset and a numeraire. The model easily extends to more than two assets. Without loss of generality, I'm going to assume the risk-free rate is zero. So, in other words, if you just have dollars sitting on the side, you don't earn any any interest on them. I'm going to define P of T to be the market price of the risky asset, and I assume that this is something that's externally evolving and is observable. So, I think sort of the mental model here is you're trying to sort of value this this ETH-USD pool on Uniswap V2, but maybe also you have access to trade on
Binance, and let's assume that you know, trading on Binance is frictionless and you can see the price and you know, so on. Again, it's a model, right? So, we're going to we're going to make some assumptions, but our assumption is that there is an observable external price. And we have to give sort of dynamics for this price, and so the most sort of natural thing is to assume that it's a random walk, or you know, more properly a martingale, right? And so, in other words, if you know, if I sort of think about what's you know, the most immediate martingale I would sort of write down, you know, probably the increments would be something like a normal distribution, right? And so, in particular, sort of in in finance, the typical convention is we
don't work directly with the prices, we work in terms of returns, because you know, that's better. So, sort of a baseline model might be to think that okay, if I look over a short period of time ahead, if I'm at time T and I look at up to delta T, this is my percentage return, I want that to be normally distributed, right? And the way you kind of make that rigorous, the the proper sort of technical device, is to write down this stochastic differential equation. Right? So, this is sort of you know, maybe the informal description on the left, on the right is sort of the formal stochastic differential equation, where I say the instantaneous return, so here I was going over delta T, now I'm sort of shrinking the delta T to zero, the instantaneous return is the product of a constant, the volatility,
and a Brownian increment, something that looks like something's normally distributed, right? So, you know, again, I have a random walk as a price process, and I'll just point out that this is very standard. This is sort of the basically the Black-Scholes setup. Any question? Okay. Let's talk about the CFMM. So, again, we're going to assume there's a constraint set, that's the same picture we saw below. We're going to make a couple of assumptions. Speaking to Pronov's point, we're going to assume that you know, the set of liquidity providers and their their demand curve stays constant, right? So, we're going to you know, ignore minting and burning of LP
shares, we're going to you know, imagine we're looking at a short interval of time. We're going to ignore trading fees for now, and we'll come back to that, cuz that's quite quite important. We will also ignore a bunch of other low-level stuff. So, we're going to ignore the ignore the fact that there's gas, we're going to ignore the fact that you know, in blockchain really the world is discrete time, it's not continuous time and so on and so forth, but that's going to be our abstraction. So, our starting point for the analysis is going to be to write down this object. This is what I call the value function.
It's I'm going to denote it by V of P, the input is a price level, and what I'm doing here is I'm solving an optimization problem, where I'm looking across all feasible sets of reserves according to my invariant, and I'm trying to find the the pair XY, which has the least value if the price of the risky asset is P. Right? And so, this is pretty standard sort of device to sort of mathematical device to sort of you know, look at these these pools. You can sort of think about it as kind of a coordinate change, where or reparameterization, if you will, where instead of sort of thinking so much about the reserves, I'm going to think instead about prices.
And this is something that's been done by by a number of others, in particular, series of papers by Engers et al. really kind of leverage this type of function. And I'm going to make an assumption about this. This will be my my one technical assumption. Number one, I'm going to assume that an optimal solution exists. And number two, I'm going to assume that this value function itself is well-behaved, namely it's it's smooth in the sense of being twice continuously differentiable. So, these are technical assumptions that I need, but they're basically satisfied by every AMM that that I've seen.
So, so it's not really much that I'm that I'm asking for here. And and one thing I'll I'll point out, why is this function important? If you sort of think about this for a second, if you solve this problem for all the different values of P, the X star of you the P that you have is the demand curve. That is the same object we saw in the first half of the talk. And why is that? Well, sort of you know, imagine the price level is P, right? And imagine that everybody knows the price level is P. If the reserves what what what someone will do, let's say an arbitrageur, they will show up at the pool, and they will try to extract as much money from the pool as possible, right?
Assuming that the price level is P, and this transaction is zero-sum between the arbitrageur and the pool, right? So, the arbitrageur trying to extract as much money is the same as the value of the pool being minimized under that price assumption, right? So, if everything is you know, incentive compatible and so on, and the price level is P, you should expect the value of the pool to be V of P by the action of the of these these arbitrageurs. Right? So, this is exactly the same object as we saw, this X star in the first half of the talk. Okay. So, just to give sort of a concrete example, you know, all of this is you know, maybe dressed up in you know, some some math, but it's all sort of very basic algebra.
So, for example, for constant product case in Uniswap V2, the demand curve I I showed below is goes as one over square root of P, and Uniswap V2 has constant product, I should say, has a nice property that you know, along the demand curve, you hold the same dollar value in the risky asset and in the in the numeraire, and so this is the value function simply by you know, plugging in those formulas. So, this is just simply you know, write down the Lagrangian, take derivatives, do some algebra, and so on. There's nothing really magical happening happening here.
It's just a better representation. Right? So, now getting back to the So, let me do an intermediate lemma. One more sort of technical lemma that's also a little bit elementary. First part is that if I take the derivative of the value function, that gives me the the the the the demand curve. In other words, the quantity of the uh asset, the risky asset held at the price P. That's the first part. And the second part is that if I take the second derivative, the second derivative is actually negative.
In other words, this is a concave function, right? So, I'll just sort of quickly you know, write write down the proof. Again, this is sort of a fairly elementary. The first part is basically what economists call the envelope theorem, but Tim has convinced me it doesn't really deserve a special name. It's basically just combining first-order conditions and the implicit function theorem, and so on. It's an elementary rule about taking the derivative of the value of of an optimization program. In terms of the second feature, you know, if if you've ever seen convex analysis, if you have the maximum of a bunch of linear functions, that gives you a convex function. If you have the minimum, that gives you a concave. This is a minimum, and so this is this is concave. So,
again, these are sort of elementary facts about optimization, but we're going to leverage these two heavily in in what comes. So, now we're going to start to get to the valuation part. Again, our assumption is that we have these arbitrageurs, what you know, blockchain world people call searchers, who are continuously monitoring the market, who are also able to trade in the the external market, and who are sort of trying to get those two to converge. And so, by the same logic I you know, explained before, these arbitrageurs trying to extract the maximum value from the pool corresponds to putting the pool into the state where it has minimum value for the LP owners.
Right? And so, in other words, if I want to look at the value of reserves at any time, I'm going to denote by V of T the value of the reserves at time T. That has to be the function V evaluated at PT. Again, because of the actions of these arbitrageurs who are continuously monitoring, they will always move the pool into the lowest value state at the then current price, because they want to make money. And again, it's a zero-sum. Right? So, again, using the running constant product market maker example, that means that V of T is proportional to the square root of P of T in a constant product setting. This is just simply plugging in the formula from before.
Right? Now, if you recall at the beginning when we were talking about motivation, the first question I asked is how do we understand the risk inherent in in this pool, right? So, in order to think about that, I'm going to try to generate the same kind of risk in a different way, right? What I'm going to try to do is I'm going to try to separately mirror the risk that's embedded in that pool, except I'm not going to do it via a CFMM or a pool. I'm going to do it by trading on my own in the external market. Right? And so, that's the idea, and that's what we're going to call the rebalancing strategy.
Right? So, to be precise about what we're doing, the rebalancing strategy is going to be a self-financing trading strategy which starts out holding exactly what the pool held at period zero. Again, X star evaluated at X star and Y star evaluated at P zero, but at every time T afterwards, it will adjust the risky holdings to match what the pool would have held. Right? So, here we're imagining a dynamic trading strategy that's sort of trading over time, and again, its main goal is to just do what it thinks the arbitrageurs should put but have the risky asset that it thinks the arbitrageurs should induce in the pool at that time. The idea being if you're holding the exact same amount of
the risky asset, maybe that's going to mirror the overall risk of the other pool. And indeed, we're going to see that's the case. But, one one thing we're going to need is we're going to try to understand what is the value of this rebalancing portfolio. And so, I need to do a little bit of algebra to do that. The idea is that if this strategy is a self-financing strategy, you're going to start out with some initial value, the same initial value as the pool. And if it's self-financing, there's no way money could have come in. The only way money could could go in and leave is through trading profit and losses. And my per period trading profit and loss, if I discretize time every delta T, is, you know, I held some position at the
beginning of the period, and then there was a price movement, and then that's how much I made in the ith period. And then if I sum across that overall periods, I should get, you know, how much money I have at the end. And of course, you know, passing the limit to sort of a continuous time, I can write that down as an integral of the of the position process against increments of the price process, because that's exactly what I had in the sum over here. Right? So, again, this is just motivating this this this this integral. We will see this formula later, but there's one other point I want to make right now is that it's not hard to see also that this is a martingale. Right? In other words, it's also a random walk. If you take, for example, the expectation of what will its value be in the future,
it's the same as its value now. Now, why is that? Well, at some level it shouldn't be surprising. Right? At some level you have an underlying asset that's a random walk, the the X, the, you know, the P process is, you know, a martingale, right? If I'm trading on top of that, it should also be a martingale. Right? And indeed, that's true. It's true for any self-financing um trading strategy. And one way maybe to more technically see that is if you look at the this sort of discrete formula at the top and you take tower property of expectation, you will see that I'm always taking an expectation against a future price increment, which is zero mean. Right?
It's a martingale difference. Right? So, that's going to be an important property, too. All right. So, we have all the the the technology set up. Now, we're ready for the the the main result. What we're going to do is we're going to define loss versus rebalancing as the difference between the rebalance value of the rebalancing strategy portfolio versus the pool value. Phrased differently, we can write the pool value as taking the rebalancing portfolio value and subtracting this loss versus rebalancing.
And the main result is to characterize that loss versus rebalancing, which is as follows. The loss versus rebalancing is the integral of some function L, which depends on price, and where this function L is always greater than or equal to zero. So, there's a formula over here. I'll come back and parse it over the course of the next couple slides and give you some intuition of of of what's going on here, but I want to make a couple of points which should be should be immediate. One is that first of all, this is non-negative, right? You're integrating something which is positive, it's also going to be positive. So, indeed, it is a loss, it is a cost.
Right? It will never be negative, it will never be a gain. Number one. Number two, it's non-decreasing, it will always be sort of increasing. So, in that way, it's a sort of a running cost that's increasing over time. The predictable thing we will come back to in a second what I mean by that. And I want to make one more point, which is that probably many people have heard of something called impermanent loss, or sometimes people call it divergence loss, or so on. That is not this. That is something else, and we'll I'll come back in a bunch of slides to relate this back to the, you know, much better known concept of impermanent loss.
So, what you're reminding people of V double prime is non-positive, right? The concavity of V is showing up here. Yes, so this is where the concavity of V is important. and you say it's non-decreasing, which is a fact that V is concave. Yes. And it always has to be concave. So, that's that's okay. All right. Then let me let me let me just sort of give you a quick intuition and I'll jump to sort of more formal results. So, basically, the intuition is if I write down the expression I had above, this was the formula for the um value of the rebalancing portfolio. This is the formula for lever, right? And if I write that same equation in differential form, this dVt, that's telling me over the next instant in time, what do I expect the value to do?
I see there's two components, a red component and a blue component. The red component has a dP. It has a price increment. This has market risk. Could go up, could go down, right? So, that's what I'm calling the market risk component, and it is exactly the same as the rebalancing strategy. On the other hand, this blue component, there's just a dT there. So, over a very short interval of time, you know that that's going to go up a particular direction, and in in a local sense, in an instantaneous sense, this part is riskless, whereas this part has market risk. So, what we've done is we've isolated the market risk into one segment.
Where does this cost arise from? So, it arises from the following. If you call the rebalancing strategy, remember that X star, the demand curve, was downward sloping. What that means is the rebalancing strategy sells when prices are high and buys when prices are low. In other words, as prices are fluctuating, it makes money. On the other hand, the CFMM pool, its value is path independent. It just depends on what's the price at the end. So, what's going on here is the CFMM pool does not make money from the price fluctuations, its value is path independent. Instead, the money goes to arbitrageurs, right? So, the arbitrageurs aren't here for, you know, for fun. They're doing it to make money.
And where is this money coming from? There's only one other participant in the system, it's the LPs, right? And so, basically, the lever is is the profits earned by the arbs who uh um rebalance the pool. And obviously, that's going to be positive, and obviously, that's going to be non-decreasing over time, because otherwise, the arbs wouldn't trade. In this way, it is an adverse selection cost. It is a cost you're paying to people who are more informed than you, because they're arriving later with better information about the then current prices. Just in terms of the functional form, I can write it out in terms of two things. If you look at that formula, the first component has to do with the price variance of the risky asset, something with the the volatility and so on, but
volatility squared, so we're talking about variance. And the second term, V double prime, recall that V double prime is X star prime, which you may recall from the first half is the instantaneous liquidity at this price level. Right? So, again, this formula makes a lot of sense. This lever cost is higher the more volatile the asset is, and also the more liquidity there is at that price level. Why? Because the more volatile it is, the more money the arbs make, right? Similarly, the more liquidity there is at that price level, the more the arbs can trade against the pool, and they can make more money. So, again, this feeds into all of that intuition. Let me try to wrap up quickly. So, we can do these calculations for Uniswap V2 in in particular, just plugging in that formula, we get this expression over
here. It has the the nice property that the lever cost is proportional to the value of the pool. So, in other words, we can interpret it as like kind of a running tax on the the pool value. And this is the result I showed you at the beginning, right? You know, on a daily basis, if the we assume 5% volatility, the running cost is sigma squared over eight, which, you know, plugging 5% evaluates to three basis points a day. Just to briefly talk about impermanent loss. Impermanent loss is basically what we would call a versus holding. The idea is you just start with the portfolio at the beginning that this the pool had, and you just maintain that
portfolio. Well, if you do that, the expression that you get is that the loss versus holding is your your level loss plus some other term which involves market risk. Right? So, you know, loss versus holding or impermanent loss, that's another metric, but it does not separate market risk and does not separate into cleanly into market risk versus adverse selection. So, in some sort of very specific sense and you know, sense of the Do My RV composition and so on, the the loss versus rebalancing our metric is extremal and it's the only one that that that sort of cleanly accomplishes this the separation.
So, what about fees? So, you know, just to sort of superimpose fees on top, let's have a simple model where we have the arbitrageurs as they are, and then we have some noise traders who arrive and and they pay fees. And I'm not going to be specific about this, I'm just going to say define that f of t is the the cumulative fee process collected up to time t. And without going through all this algebra, just in the interest of time, the upshot is if you want this to be fairly priced, if we want the value of the pool at time zero to be the same as as it's initial cost, we need the the the lever to to to sort of balance out with the with the fees.
Right? And so, that gets me to sort of where I was at the beginning, right? If, you know, for example, in this pool, the fees are 30 basis points of the volume, that suggests that the trading volume needs to be about 10% of the pool value in order for this to a balance out. And interestingly, this this 3.125, that comes from the 5%, it scales with the square. Right? So, for example, I just looked at a a chart today. If I look at how volatile has Ethereum been over the past 2 years, it's varied by a factor of 10. There are points in time where it was not very volatile at all, and points in time when it was sort of 10x more more volatile. And that suggests that the trading fees should also vary on that scale, right? You should have two orders of magnitude difference in the
trading fees in times versus where where it's not volatile versus times when it's volatile, because you know, that's what's fair to the liquidity providers, because that's the cost they're paying in terms of adverse selection. Right? And so, that sort of you know, leads to the idea of you know, maybe we should have dynamic fees. It's sort of natural to sort of think about uh scaling fees with volatility. That happens in traditional markets, too. When market makers are quoting prices, when they're quoting bid and ask spreads, they widen them in volatile times and narrow them in times that's not volatile. But, you know, if we want this to happen over two orders of magnitude, maybe it should be baked in the contract. And you can imagine doing things like looking at recent volatility and scaling the fee
um level by volatility, or looking at maybe what is the lever been in the recent past, right? Has been higher or lower than the fees that are collected. And doing some kind of procedure where you adjust fees to try and equilibrate those two. So, our hope is that you know, this idea gives a lot of nice clean closed-form expressions that they can be the basis of better mechanisms for sort of figuring out how to set the the fees. So, I apologize for going over time, but I'll stop there. Can I ask a very broad question? I guess in the long run, suppose the traditional markets continue to exist and the good AMMs that you're
designing are also there, do you envision the liquidity equilibrium to like be Do you see one winning over the other? Are there like Do you Do you envision a stratification of like different kinds of liquidity demand to happen, or is it like hard to predict? I haven't I haven't thought about that. Uh My my sort of prediction would be that the CFMMs, it's there's really like a lot of cleverness in them and a lot of you know, sort of great engineering, but it's really oriented around the limitations of a blockchain, right? If you had sort of unlimited computation, if you could run your own servers, it
seems like the rest of the world has converged into this limit order book structure. So, so I I don't know, but my personal belief is that the real value of CFMMs is not that it's a better mechanism, but that it runs on the blockchain and that it plugs into all the other DeFi Legos and so on. So, my prediction, I mean, I think I'm pretty sure it's currently true that it's more expensive to trade on CFMMs, certainly for for for popular tokens. I think that'll persist because their their utility is not that you know, again, it's a better mechanism, but that it's an on-chain mechanism. Does this LVR exist for like the limit order books, too?
A similar concept exists, but not like this. And the thing that breaks down is uh the twice differentiability. So, you can There is a There is a Do My RV decomposition. You can have a martingale and a decreasing piece, but it is not this. It's It's something more complicated and you would you know, get it out of the Black-Scholes formula and so on. So, do people pay fees in traditional like exchanges based on that, or is that a difference? So, on traditional exchanges, what happens is that the participants aren't passive. They're constantly modifying their orders, right? So, you know, the model in an AMM is that you give your liquidity curve, and
because it's expensive to interact with the blockchain, you leave it there for a while. On you know, on Nasdaq, it's not expensive to send orders to Nasdaq. So, on a second-by-second basis, you're constantly adjusting. And if it all of a sudden it looks like there's a Fed announcement, the market is volatile, they will widen their quotes immediately, right? And then so, it it really happens in real time, but it's not part of the mechanism. It's that the market makers are smart and they do it themselves. It's an open question is will there be passive liquidity provision as we take time to to infinity or large in the future, I mean?
So, like like 5 years from now, is there any market for passive liquidity provision? It's not clear, right? Yeah, maybe I mean, I think maybe another point you could like So, let's say the blockchain scales so that the computation isn't a problem. Maybe the the second point though was that you do have to attract market makers. So, I think if you have illiquid assets, there is a And by the way, when I said the rest of the world is limit order books, you know, I'm making up numbers here, but you know, 90% of it is. The 10% that isn't is illiquid stuff. So, for example, if you're trading corporate bonds, which are really not fungible and there are hundreds of thousands of them and you know, it's sort of a market by appointment, that does not trade on a limit order book. You sort of call
people and there's you know, a search market and so on. So, it could be a place for these for for illiquid assets. Limit order books don't work well there. Thank you for coming.