Automated Market Making and Arbitrage Profits in the Presence of Fees, Ciamac Moallemi | a16z crypto

21 Sept 2023 · 1:03:33

Columbia professor Ciamac Moallemi presents an a16z crypto research talk on automated market making and arbitrage profits in the presence of trading fees. He extends the loss-versus-rebalancing framework to show how fees and discrete block times change the value extracted by arbitrageurs trading against an AMM.

Speakers

Topics

Transcript

uh very happy to introduce my colleague at Columbia CMAC molemi who's in the business school there um he's going to be talking about automated Market making and loss versus rebalancing including some more recent work involving trading fees so thanks uh um Tim I'm glad to to be here today um I'm going to talk today about some joint work with a number of co-authors um Tim included so uh um I won't be new for him but hopefully new for the the rest of you um before I launch into it um just by way of background um uh because hopefully be meeting with uh um a bunch of you throughout the week to tell you a little bit about me my background is I'm basically an applied

mathematician my PhD is in electrical engineering and on the methodology side I'm pretty interested in things like stochastic control approximate dynamic programming reinforcement learning and so on um that said I teach in a business school so the main kind of applications I think about are related to finance so in particular things like quantitative trading high frequency trading market microstructure and these days blockchain so um one way to I think view this talk is um this is sort of uh ideas from you know microstructure and Black Shoals applied in a novel context text which is a automated on market makers which kind of brings me to my second point just to calibrate a little bit how many people know what a constant function Market maker is

good most of you some so most people know how uniswap V2 say works okay so there's some of that stuff in there because I wasn't sure but I'll try to uh to go through it relatively quickly um so what I'm going to talk about today are sort of uh fundamental questions involving the economics of of liquidity provision of being a liquidity provider in a automated Market making protocol like a uniswap or or curve or or whatever and kind of the high level motivating questions or things like how can we measure performance of of liquidity providers how do we decide whether um providing liquidity in in one of these pools is a good strategy either uh um x-post analyzing past performance or

xante I'm thinking about making a future investment how does that performance depend on things like the the Dynamics of the asset that's being traded characteristics of the pool maybe even characteristics of the blockchain that of the pool is operating on on top of and ultimately like the you know the the the real um uh you know eventual goal is um how can we improve these amm designs in a way that improves the economics from the perspective of liquidity providers therefore allowing them to provide more liquidity and get more gains from trade and more social welfare and so on and so forth so what I'm going to talk about is a a combination of of two papers um uh um I'm not going to get through

all the other details obviously but I just want to point out that um you know if you are interested in the details they are both available uh on my website or on on archive okay so as a starting point um uh let's you know talk about the way um you know people in in industry in practitioners usually sort of talk about things like amms and thinking about investing in an amm this is a screenshot from um uh you know uniswap V2 usdc pool and on this screenshot um you see a bunch of things this pool had about 125 million dollars in Assets in the past 24 hours um uh 20 million dollars traded and it generated about um 66 000 in fees um uh during that a period so usually

the way um people sort of talk about it is they do a yield calculation or an apy an annual percentage yield or something like that they say look if you're making sixty six thousand dollars a day on a pool that's valued 100 uh 25 million dollars what is that as a percentage um well that if you annualize that that turns out to be 19 so that looks like a a real a a good juicy a number and then it looks sort of sort of quite attractive and and um our starting point is that maybe this is not the right model for uh we're not the right way to think about a liquidity provision in in the sense that uh when you look at fees um here you're kind of ignoring things like adverse selection costs which are quite important right so our kind of view

um and and what will establish um through this talk is at a high level we can think of um the profit or loss of a liquidity provider what I'm going to call an LP is it's going to have three components the first component is Market risk right if you are a LP in this pool this pool owns a lot of ethereum tokens right and the price of ethereum goes up and down every day sometimes a lot right so maybe one large component of whether you're going to make or lose money is is simply uh you know you're long ethereum right and so that's what I'm going to call market risk right and in in some ways that's the uh um the dominant source of of of profit and loss but in some ways it's not interesting right

it's not interesting um in the first Direction because if that's the thing that we really care about the price movements of something like ethereum it can potentially be hedged right if you own ethereum by virtue of being an LP in a amm you could simultaneously enter into a short contract or or and and profit if the ethereum price Falls by trading on a centralized exchange so that's one reason we're sort of not so interested in this the second reason we're not so interested in this is because that's sort of you know a different question like will ethereum price go up or go down I don't know may be interesting to some but I don't have particular views on that what I am interested in and what I do have views is how is um investing in an amm different than just owning a ethereum right and in order to

understand that we're going to subtract the market risk part the part that comes from just uh owning ethereum and what we're going to end up with is if you do what's called Delta hedging in the in the options pricing language right again you hedge away this risk your um of the profit that you're left up um left with is this trading fee um income that we saw below however you have to charge yourself something called adverse selection right adverse selection is a universal concept throughout Market making and basically the idea is some fraction of the time you're trading against people who have more or um better information than you and Xposed you're going to regret those trades right so um this paper is basically can be thought of as a black Shoal style model to to sort of quantify

this and in the end understand what are the drivers of uh whether or not the uh um the liquidity provider is a maker or lose money in particular we're gonna have a black Shoal style formula for um adverse selection costs it's going to highlight again those components that that drive these returns you know on particularly things like the volatility of the asset the the curvature of the um of the pool um how the trading fees are are done and so on um and um quantitatively it's simple enough that we can we can actually bring it to uh to to data all right so the hedging cost of removing the market reasons are gonna affect the economics of the liquidity providers so the reason why you're ignoring it is because if

your liquidity provider in centralized exchange you'll have to apply the same costs or so what what hygiene costs are you talking about from the Delta so because you're Delta hedging on a center and there might be cost to that so in my model I'm sort of ignoring that um I um uh for the purposes of this model in um uh in in in the real world context I imagine most of these um uh the people who are um uh um uh uh you know someone who may want to be a market maker Also may be a market maker on a uncentralized exchange right and um they can just sort of add this risk to their overall risk book and if you're already I'm making markets on a centralized exchange it's quite possible that you could do this hedging um uh in a very low-cost way but I'm going to assume

that the hedging is Costless for the purposes of this talk okay so you know what are our contributions um we're going to look at Delta hedge lppnl right we're going to see that that once you Delta hedge against once you um short enough of the risky asset to uh that's equivalent to the risk you're hold what you're left is this um the the fee income stream and lever and lever is that adverse selection cost right it stands for um uh loss versus a rebalancing it'll become uh clear a little bit later where that terminology comes from and the idea is that uh this is a form of a a slippage right so in in the sense that you know if you have an amm that's um on chain um it's not updating its price unless

there are trades right but out there um let's say in centralized markets on coinbase or on binance or whatever um the prices are updating continuously right as the prices update let's say the price goes up on uh um on binance um arbitrageurs or in you know in in crypto parlance Searchers they will notice that right and they will buy um uh um at the sale price on the amm sell at the higher price on the centralized exchange and they will make money right and of course this is a 0 throw some trade in between the the ammlps and the arbitrager so any money that the arbitrager is make comes from the other the the pockets of the LPS right so this is the adverse selection because the pool does not know the current price and

there are arbitragers who do know the current price and are exploiting it our contribution is to identify that um and I'll give a give a close form expression right in particular um uh the the rate at which the lp will sort of bleed away money to uh to these arbitragers is a product of of two things there shouldn't be a half there a a second term it's something to do with the the the characteristics of the assets namely it's uh its price variance and then something to do with the other pool namely um what we'll see the marginal liquidity in the pool at that price so we get a nice formula that expresses the adverse selection costs um we can verify that porn formula empirically in other words we will compute the other Delta hedge p l

without a model and we will see it matches the uh um the predictions of our model and we can um sort of think of that in terms of guiding a downstream amm design now um this isn't the uh um uh the end of the story of course because uh the way we um uh derive this adverse selection cost we imagined um arbitragers who are continuously monitoring the uh um the pool and are trading against it but are not paying the trading fees right again recall this um the um of the pool has a trading field I'll be more more explicit about that um we did that as a kind of a a simplification but in reality the arbitragers do pay trading fees and that's a friction on their trading and

at the same time this formula was also derived assuming that arbitragers can trade um uh continuously and reality um uh on a blockchain actually it's it's literally a discrete time system you can only in some sense you can only trade when when blocks are generated right so these are two frictions on on the ability of arbitragers to um uh trade that lever idea does not capture and so um uh as an extension what we've done is we've been able to analyze what the arbitrager profits are assuming that they pay fees and in addition in a world where um uh um you only trade at times when blocks are generated according to a a poisson process um what we find in that setting is uh in

a particular asymptotic regime I'll become clearer about the Arbitrage profits are simply the the quantity lever I defined um before again this idealized quantity of uh um of of trading continuously and not paying fees but scaled down by the probability that an arbitrager arrives or or let's say the incident block is generated that um the um pool is mispriced enough that a a trade can occur right so this um uh we sort of thin down um the amount of money the arbitragers make by the fraction of time that they're able to trade and this depends on simple easy to understand um quantities like for example gamma here is the fee level Sigma square root of delta T is a typical price movement over the the interblock time and so on so we

have nice Expressions there what we also see is that once there are fees um uh as um in the flashback regime if we imagine delta T here the time between blocks shrinking um to a zero also the Arbitrage profits shrink you can kind of see it in that expression there but what that immediately uh suggests is from the perspective of of minimizing um how much is paid to Arbitrage yours for minimizing this type of a of Mev faster blockchains will work better according to the uh the square root rule and finally um we end up with this um really interesting um result where we have a lever again um how much money is is is paid out in an idealized setting

and it turns out that that is roughly equivalent to how much the arbs pay um a net of fees plus that the fees that they pay so in other words we can think of introducing fees as this quantity lever is going to be conserved if there are no fees that goes all to the arbs if we start introducing fees what happens is we start shifting some of that away from the Arbitrage profits and and more towards the uh the the the LPS what's the intuition that the um that while you put why does lever go away when I guess so like why do profits go down as the block regime gets faster I'll get to that that's a very good question though okay so um uh that's um uh the high level picture just to show you um uh um

that this is sort of practical and immediately uh um uh yield sort of uh uh insight and so on and is indeed very simple this is the same slide I showed before again the fees would suggest that you're going to make 19 annually our model if you apply it to a constant product Market says that well no there's this adverse selection cost also it takes the value Sigma squared over eight where Sigma is a volatility y Sigma squared over eight well we'll see uh I'm underring this talk but if you plug in the numbers it says well over this period if this was the volatility you probably you should have lost around forty thousand dollars in terms of address selection costs so in reality um maybe you made a quite a bit less than was a advertised at the beginning right so again we'll see a much more

systematic uh empirical analysis but um but this is uh um uh kind of the idea okay so I'm going to start with the model I'm going to assume that there are two assets and we can do more than two this is without a loss of generality so my running example will be a pool where um there's a risky asset I denote in general with X and so we can imagine that that's ethereum and um there's a cache or numerator asset um uh which you know we can assume is some U.S dollar coin I'll call that y so we're going to be dealing with a pool that trades a risky asset against cash I'm going to assume that um interest rates are zero just so I don't have to write the um the r everywhere and that's without loss of generality

and I'm going to assume that there's a process P of T this is the market price of that risky asset in terms of the numer error and this is what I imagine the price to be on an infinitely deep centralized exchange let's say binance and um that's going to be the place where uh in my model price Discovery occurs and so I'm going to need a model for this um this market price and so I'm just going to use the basic black shoals model in other words I'm going to assume that the returns are approximately normal and um the way you would write that as a stochastic a differential equation is you'd say that the instantaneous return has as has two things it has a drift term right and then it has a um a a sort

of a Brownian term of volatility times a uh a Brownian increment and yeah um this is sort of the standard um a black Shoals type of modeling assumption so um now I'm going to describe how the constant function market makers work it sounded like most people are are pretty familiar so I'm going to go through this um relatively quickly the idea of a constant function Market maker is that you start out with a bonding function f which specifies an invariant in quantities of reserves of the two assets the risky asset X and the uh the cash asset Y and um uh so so that is that invariant curve f of x y equals l and so for example the my um you know the most common example is to have F be

the product function that is the a constant product Market maker and the way these works is initially the pool starts at some point um uh here the uh the LPS endow the pool with reserves let's say x0 y zero and is at that point and after the pool is uh endowed with these assets the pool will allow um users to come in and trade and any trade is permitted so long as um you stay on the invariant curve so for example over here um if we start at the purple um Dot and a move over to the um a user moves us over to the Green Dot over here what they are doing is they are withdrawing the cash asset and contributing the risky asset right so this is somebody

selling um eth to the pool and um uh I'm getting this quantity of USD in return to it so the average price they pay is going to be simply the ratio of those two or the uh the slope of that line uh um in the uh in the Triangle that's how the mechanism works and so one thing to kind of notice is if we shrink the amount that's traded um uh and and Shrink um make these points close to each other if I'm at a particular point and I look at the uh um the instantaneous slope this is kind of the spot price this is the slope there is the uh the quantity to uh um a trade an infinitesimal quantity of that asset right it's simply shrinking that triangle to be a uh um a

tangent line and um in addition to trading the uh um uh um the the cash uh sorry the risky asset for cash or or vice versa there is um a a proportional fee also collected on um uh um the the the traded quantity so for example uniswap V2 you collect um a 30 basis points on the uh um uh um contributed asset right so there's oftentimes a fee so that's um a kind of the uh the the basic structure um in terms of doing analysis as sort of a very important object in order to understand this um structure is um something we call the pool value

function so the idea of the pull value function V of P it's going to take as an input a price and this is um let's say what um the price of the asset on the uh the centralized market and what it will tell you is the value of the CFM Reserve Holdings when the price is p how does it do that out of all um the sets of uh X and Y that are feasible that satisfy this invariant it finds the combination with minimal value why minimal value again we're looking at this from the perspective of the other pool owner they're trading against um Traders Traders will try to trade against this pool to maximize their gains from trade and because it's that immediate trade is

zero sum what will happen is they will move the pool in a configuration where its value is minimized right so because you're in an adversarial environment and as the price changes Traders will trade against you to try and make the most money possible when they're making money it's minimizing the value of the the Assets in the pool so this um a minimization problem becomes important right and so the idea here is if I know the external um a value of the asset is p and I know that there's a Trader who's willing to trade against the pool and can also trade at that external value of the P they will push the pool into a configuration where um uh that's an optimal solution to this optimization program right so um uh um we're also going to make an assumption that the

optimal solution always exists and that things are smooth and so on this is typically always satisfied so again just to give sort of a little bit of a running example these are just very simple algebraic calculations if you had a uniswap V2 a constant a product pool if you um a plugged in um you know x y equals L into that constraint and you did your sort of undergrad kind of calculus you would get that you know what are the uh um reserves in the risky asset and in the uh um uh the cash asset given the price right this would be the the XY that minimize that and we would also get the value of the pool right so again here

are these relatively simple Algebra I just want to illustrate that these aren't um a particularly complex calculations um I do want to make two other points also um if you look at this x star again this is the Holdings of the risky asset as a function of its price what you'll observe is that um uh this decreases at a rate of a one over the square root of price right so in other words as the price of the asset goes up what will happen is that arbitragers will buy the asset from the uh the pool and the pool will hold less of uh the asset and it will occur at that rate right um this is going to be a very important object and um because of that description we call it the demand curve for the risky asset

now this is the demand for the of the LPS for the risky asset because at every price level they're going to hold this much right so we're going to come back to it because because that's quite important second point I I want to make is that a constant product market makers they have this very interesting property that if you look at how much is held in the risky asset versus how much is held in cash because the risky of asset is valued by Price p if I want to Value this in dollars I multiply this by P and it turns out it's holding the exact same value in dollars in the risky asset in cash that's actually a really special property right and that's actually um I think what makes this um this very nice it's not that the constant product is easy is a good formula it's this

behavior of holding a balancing to hold the same dollar amount in two assets um that that is a very nice behavior yes so in the model are you assuming that liquidity providers are not reacting uh by removing liquidity because it seems like that if they anticipate significant adverse election they might maybe choose to remove liquidity and that may affect also uh the trading costs and the quantities so I'm I'm going to assume that um the liquidity I'm gonna assume you're looking at a horizon where you've committed to provide liquidity for that Horizon and you're not going to revisit it till the end of The Horizon so I'm going to assume that there's no minting and burning of LP shares when I show you the

empirical results obviously in the real world there is minting and burning and will account for that but for purposes of the model I'm going to assume the liquidity provision is static you're also going to calculate the instantaneous lever right so it'll just be with respect to whatever capital L is at that time right that's right so in some sense you could imagine they're coming and going and you're just focusing you just have to have the snapshot of time exactly at the end there was it's going to be a little an instantaneous result the other thing I'll say is I really wish we could turn back the clock to 2018 to get everybody to think about uniswap in terms of this equal value split property as opposed to XY equals K yeah much more natural okay so that's all the preliminaries let me talk about lever

so imagine we have a stylized Market with two types of Traders we have these arbitrageurs um these are agents which are sophisticated they're able to trade either in the cfmm pool or on a centralized exchange they're continuously monitoring the market they have infinite Arbitrage Capital available and um so what they will do is they will ARB those CFM prices in um until they're equal to prices on the centralized exchange and in particular they they do this because we're going to assume that they're not paying fees right we're going to come back to that but for now they're not paying fees so they'll Force the prices to be equal because that's uh um that's a profit maximizing for them on the other hand there's going to be

noise Traders these are traders that only trade on the cffm they trade for idiosyncratic reasons in particular they have no information about prices anywhere or future prices or or anything they do pay fees and we're going to collect um that cumulative stream of fees in this a variable called fee and um if you think about it if you're an LP there's only um two sources of money there's the reserves in the pool and there's a stream of fees so your profit and loss after time p is the change in value of the pool plus the fees that you've earned um cumulative over that time and by the argument that I just made the value of the pool has got to be given by that

pool value function evaluated at the current price right why if it was anything different than that some Arbitrage would would jump in and uh um and trade until those two reports to be the same right because this is the only point at which arbitragers cannot make any money if the current price is PT okay so we'd like to try to analyze this we're going to focus on the change in value of the pool we're going to ignore the uh the the fees that are collected for a second and in order to understand um this the the how the pool changed in value we're going to define something called the rebalancing strategy that motivates the name loss versus rebalancing and the idea of the rebalancing strategy is it's going to hold the same positions in the

risky asset in other words it's going to do the same trades in terms of the quantity the risky asset as the other pool does however instead of you know trading against arbitragers that are arriving it's going to directly trade against the uh at the centralized price right so to just be a little bit more formal about that initially this is going to be a self-financing trading strategy initially it holds the exact same amount of of eth and USD as the as the pool and what happens is as time evolves at every point in time it matches um of the position of the risky asset in the pool and it does so in a way that's self-financing right so you're not injecting money or taking out a money of this trading strategy right so if you

sort of think about it if you're not putting in or taking out money the only way you can make or lose money is because of fluctuations of the risky asset right so the value of the pool at the end is going to be its initial Value Plus like each interval of Time how much of the risky asset do you have and then how what does the price do over the next delta T and if you sort of take the continuous time limit you can write that as an Edo integral right so um the value of this rebalancing portfolio is um uh simply the it's in the initial value of the pool plus the the the quantity of risky asset that the pool holds integrated against the price changes that occur okay so loss versus rebalancing as the name suggests is how much is the pool

worth less than um the rebalancing value oh sorry I I guess it doesn't really matter what's what's the Assumption on the movement of the price is it just like a Martingale um uh so I assumed it's a geometric Brownian motion okay cool sorry so not a Martingale but a nice processor um and so um this is the main result the main result is that um first of all this thing is always positive it's positive and it's increasing so you're always losing more and more money to these uh arbitrageurs right and um moreover we have a close form expression for it so if I look at how fast it's increasing the derivative of this uh this process

it increases as a product of uh um uh formula I showed you earlier which is um one sort of the quadratic variation or or the price variance this has to do with the asset right the Dynamics of the asset and then the second thing it um has to do only with the pool and that is the marginal liquidity at the price so why do I call this marginal liquidity recall that X star was the demand curve it's how much the pool is going to hold in the risky asset at a given Price p right so the derivative with respect to P that's how much the Holdings are going to change if I make an infinitesimal price move around P so I'm going to interpret this this derivative as kind of the instantaneous or marginal

liquidity at that price right it's how much is going to get traded in order to sort of a move through uh through that price right so it's it's a product of of these two I'm going to quickly walk you through where this comes from because it's actually quite an um uh intuitive one other thing I'll point out probably many of you have heard of impermanent loss that is not this it is different it is related to impermanent loss I would rather not talk about impermanent loss but I'm happy to sort of take it offline but maybe a one way to sort of think about this is this is uh impermanent loss done rigorously but happy to come back to that if uh um if someone wants to talk about that um okay so let me give you some intuition for um I'll wear

this uh um this this this loss comes from so suppose we start out um uh at the pool and so here I have the Y asset and the the X asset right this is the the um and and the blue is the uh um the invariant curve and I'm starting out when prices are P which is tangent at Point a right so when prices are P the pool is in a state at uh on point a suppose the external prices drop from P to P minus DP so P minus DP is uh is this line over here and that is passing through point B so the pool and the arbs are going to start um show up here they're going to see it's at Point a but the right price is over there and they're going to trade against it until it moves to point B

so how much will they uh will they um uh um uh trade um they will trade a quantity um a DX and um the starting price in the pool is p the ending price is p minus DP as they trade through that whole range the average price that they get are going to get is actually half the price change it's the average of of exactly the average of the uh the two endpoints and so what's the the profit and loss of the uh the arbitrageur um uh they um sold at this price on the amm they bought at this price on the external market right so what they made is they made half the price change on the uh the amount that they traded but we know that if they trade a small um if they want to move the price a small

amount um the the derivative of x with respect to P tells us um uh um uh how much asset they're going to trade so I can write this DX I can write it as DX DP times DP I get a DP squared right so now this is my expression and so now I have the marginal liquidity here times the square of the price change and um for those of you who know um uh stochastic a calculus this is simply the quadratic variation right the uh the square of uh of of an infinitesimal a price change is um is is simply that right and so that um is is where the uh the formula comes from right so you can see you know again over a small instant in time um uh the price moved by DP the ARB traded against it profited by this much

if we want to see how much we lose to arbs overall we simply integrate this over time and and that's the formula I gave you before all right so it's very mechanically I'm showing uh um how losses being uh incurred okay so I'm going back to uh um uh I'm thinking about um the p l of the uh the lp what I had written before was a p l of the LPS accumulated fees plus the change in uh Reserve pool value the theorem I just had says this is the p l of the rebalancing strategy minus lever so that's just plugging in the theorem um uh um now if I if I if I sort of look at this um and I look at this term this term is something integrated against prices this

is this is price risk so what I can do is I can Delta hedge I can take it at every instant s take exactly this quantity and take a negative position on the centralized exchange um uh in in that size and by doing that I will fully hedge this and I will come up with a Delta hedged p l right you know again exactly as in the black shoals model right where um my income is coming from the fees and my costs are coming from the lever right so this is exactly what I advertised to you at the beginning this is the lp pnl decomposition this is the market risk this is a trading fee income this is adverse selection costs um I just want to show you um uh some some numbers that this works if I do this for um for

uniswap v2 again the formulas I had before I had the demand curve was a x star a p is L over root P if I want to compute um uh the rate at which this uh of these losses are being generated this is the formula I had before and um uh what's nice about a geometric mean bonding functions uh for example um constant product is that the amount you're losing to lever is proportional to the value of the the pool and in particular you lose money at a rate Sigma squared over eight times the uh the value of the pool so this is where the sigma squared over 8 at the beginning of the uh the talk comes from so you know again Sigma is a volatility so if I plug in like a volatility of

five percent this suggests that you know uniswap a V2 pool should be losing about three basis points a day on its value due to this uh adverse selection costs so for example if the um the trading fees are 30 basis points which is 10 times that right it suggests that you need to turn over around 10 of the pool in terms of actual trades in order to make enough money to balance this adverse selection yeah so just section you're kind of including the arbitraries and like people who pay fees right because some of the volume on the I am including the arms yeah so some of that is going to be uh I'm from people too and in fact maybe a lot of it let me show you a um a slightly more systematic analysis and then um we'll

talk about the impact of fees so here's the empirical test um we had this um equality exactly on the slide before on the left side is the Delta hedged p l which is the actual p l minus the p l of uh taking the same positions on on the centralized exchange on the right side we have a fees minus lever and if I look at the the left side I can compute this without any model right I can um for the lpp now I can go to the the ethereum blockchain I can pull the uh um pull the events for that pool and um I can directly measure um how much the pool value is uh increasing or decreasing properly accounting for mints and burns and stuff so you know that's

just accounting to compute the lpp now the Delta hedging p l I can imagine I can't Delta hygiene continuous time but I can imagine discreetly Delta hedging like maybe um once every minute once every five minutes once every hour you know whatever and again I can do that without any kind of model so this the left side is model free on the right side I have my fee income that's also model free I simply look on chain and see what was paid in terms of fees and the only place I have a model is that last lever expression and there I'm simply you know because this is a constant a product pool I'm simply gonna look at what was the volatility on that day and I'm going to say it's Sigma squared over 8 times the value of the pool is how much I'm going

to lose to lever right so if the left side of this e is close to the right side of this it says that lever is accurate at least in the sense of uh um of measuring lppnl so when you actually um uh um do this the kind of questions you know we want to understand if the formula is accurate we also want to understand if LPN is actually attractive so um here's an analysis on one year of data from August 2021 to August 2022 we're looking at the uniswap V2 wrapped eth usdc pool and also we need centralized exchange prices so we're going to get those from uh from from binance there's a lot going on here but let me um I'll walk you through it this is the pool I showed you um a screenshot of earlier this pool has

let's say a couple hundred million dollars of assets at any given time if you look at the blue curve that's the total cumulative p l of the pool right so over this interval at some point it was up 80 million dollars at some point it was down 40 million dollars it ends up maybe down 10 million dollars it you know that that blue curve is you know first of all it loses money but it's it's entirely unclear on what's going on if you just look at the raw p l and and that's because this pool owns an incredibly risky asset and owns eth and eth can move up or down 20 in a single day right so just looking at the blue curve um is not really giving us a sense of of what's going on what I start to look at these other curves what I'm

doing here is I'm I'm removing that market risk to try and get a clear sense of is this pool making or losing money I'm doing it at different frequencies I start out Delta hedging once a day um I could do it more frequently once every four hours once every hour five minutes one minute and all of those curves are are down there you can see that actually this pool is is kind of steadily making money and if you can hedge frequently even at a potentially a very high sharp ratio right so um you know again what's going on is the market risk here obscurus kind of um everything once you start Delta hedging and you take away the market risk you can see come on what's going on and at the end um a fees minus lever it's it's just in the middle there

right so it's it's actually I'm I'm pretty reasonable in terms of the kinds of actual returns you get if you try to estimate your hedged p l in a in in a model freeway right I'm going back to the point of uh is this uh pool attractive or not this pool appears attractive if you can hedge and that's a big if there's maybe hedging costs and so on that uh that I haven't factored in it looks like there's a high single digit um a return available in the school this kind of result is not Universal um we haven't looked at all kinds of pools but for example looking at um the five basis point unit swap V3 pool that pool seems to systematically lose money um while this one is systematically I'm making money so I think there's interesting um uh um cross-sectional questions to ask

um in terms of you know what pools are doing well and and what pools aren't um but in in all the cases we've looked at fees minus lever is a reasonable approximation of the uh the overall piano so dude what's your current hypothesis about the V2 V3 difference um I think too many people provide liquidity in V3 because it's uh more Capital efficient so I think um there's just excess liquidity provision and I think that's why that pool loses money I think the fact that V2 makes money is I think the fact that V3 loses money I feel like that's sort of broadly known on Twitter I think the fact that V2 makes money is is maybe not broadly about but also at the same time this is a very capital and efficient strategy so maybe you know that dissuades a lot of people from doing something like this

okay so um uh my assumption so far has been that when the arbitragers come and they pick off the stale prices in this pool that they're not paying fees we did that for tractability but in reality of course they uh um they do pay fees and fees can be a potentially significant um friction right and so it's important to understand how that um is going to impact the amount of Mev that they can pull from the uh the pool so let's add fees let's imagine we have a proportional fee given by gamma like let's say gamma is 30 basis points now I'm going to have two prices I have PT the same external market price I have before but I have to separately track P tilde T the implied price of the pool and that's because these two are no longer always equal right because

there's now a friction it costs money for the arbitrager to trade on this pool it won't necessarily equate all these two prices right and so we're going to sort of keep track of that by keeping track of the mispricing between the pool and the external Market through this variable on Z of t question sorry I missed previously then the source of the fees was driven by noise Traders um here like what I did before I wasn't specific about that so whatever fees are collected it's going to turn out a lot of it is coming from arbitragers we'll see that in the second part of the talk but here I I just see the fees on chain I don't know where it came from okay so you didn't take a stand on how my what's the fraction of noise Traders versus Roger's at this right right okay so if you sort

of think about it if Z T is the mispricing and I have a fee given by gamma I'm only going to trade if the mispricing exceeds the the um the the fee right so if um uh for example the missed pricing is above gamma um uh um uh what that would mean is that um and the pool the asset is undervalued by more than gamma I would trade against that until it reaches exactly gamma at that point it's no longer profitable for me to trade because even though I can make a spread of gamma trading it I'm also paying a fee of gamma right similarly if the the um the missed pricing is below negative gamma an arbitrager can come in and push it to negative gamma but um they're not going to push it beyond that because at that point they're not making any money or if you

show up and the fee is in the middle of this interval you're not going to trade because if mispricing is too small for the uh um uh the um uh um for the fees that you have to pay so if you sort of think about this if you have these arbitragers continuously monitoring and um they sort of um push this thing back when it hits the uh the boundary what you're going to end up with is you're going to end up with this um process as a reflected Brownian motion right and that's actually a a problem because if you know a little bit about reflected Brownian motion if I have reflected Brownian motion on an interval it spends fraction zero of its time on the boundaries of the interval and the boundaries of the interval are the only times that the arbitrager can make money

right so in a way um I'll show a formerly a little bit later in fact if I write this model above here the r profits are zero right so now of course we know that there are real arbitragers in in the world they're called Searchers and presumably they make money because they haven't gone out of business so um my assumption would be if they exist in the real market and they don't exist in my model probably something's wrong with my model right and so the thing that's wrong with the model here is the Assumption of continuous Trading right um You Can't continuously trade you can only really trade at instances of block generation right and that's going to be a quite important for reasons we're going to see in a second right so in order to add fees we also simultaneously have to add the fact that

um we can only trade discreetly um uh and uh at instances that that blocks are generated so I'm going to make an assumption I'm going to assume that the blocks are generated according to a poisson process right and that poisson process is going to be uh have rate Lambda so a delta T which is Lambda inverse that's going to be we're going to calibrate that to be the mean interblock time um mean time between blocks so for proof of work this is perfect I mean proof of work is fairly a poisson certainly at this kind of time scales for proof of stake I mean it seems like 99 of proofs or at least everyone I've seen is has deterministic interblock times so this is not the right model for proof of stake nevertheless it's a model we can make progress with so um that's what

we're going to do um so we're going to assume that blocks are generated according to a poisson process um we're going to assume that arbs can only trade at block generation times I mean that is the reality that's the only time you can change the state on a a blockchain we're also going to assume that there's perfect competition between ours right that there's a lot of them they have a lot of capital um uh um so on and so forth there's no barriers to entry so in in that setting when an ARB arrives if the mispricing is greater than gamma ZT minus is the mispricing the incident before they arrive if it's bigger than plus gamma again they'll trade down to gamma if it's less than minus gamma they'll trade up to minus gamma in the middle they won't do anything right this is how the um uh

arbs behave and I think it's important to note that the arbs are behaving myopically they behave like this because when you get to that point there's zero marginal profit if um and this is coming from the perfect competition if there was only one ARB if it was a monopolist this may not be optimal you may want to wait for larger price changes because um before you trade because of the presence of the fee but because there's many arbs if I see that the fee exists of the opportunity exists gamma and an ARB doesn't trade some other ARB will take it right so um uh the the fact that um there's perfect competition forces these uh um arbs to sort of trade myopically according to this rule and so if an ARB arrives at an instant

the mispricing jumps according to this rule other instances of time while I Define Z of T to be the uh um the log on price difference and I can apply um Edo's formula and I can see that it would drift effusively right because P of T is is a diffusion it's a log normal it's diffusing around P tilde T is not as constant as long as there's no uh nobody arriving to trade at the pool so um uh the the log price is also going to diffuse around and uh so the ZT is a jump diffusion process these are the jumps that's the diffusion I'm going to make an assumption this is not important but makes the formulas a lot easier I'm going to make the assumption that the drift is equal to half the uh um the variance and that will make this random

walk on driftless it'll make this a symmetric random walk right again this is not critical we have the more complex formulas in the paper but it um it reduces the the algebraic complexity a lot okay so just to kind of illustrate what this looks like we can imagine here ZT is the mispricing this band gamma minus gamma around zero defines the no trade region on the horizontal axis um uh um is time and each of these red dots which hopefully you can see corresponds to the arrival of a of an arbitrager or sorry the instant a block is generated excuse me and so um you can see what's going on here initially the price kind of diffuses here we have an arbitrager arriving but kind of nothing

happens there because there's no trade to be done on the other hand here we have an arbitrager arriving or block being generated and the price instantly jumps up there because here when um the block was generated the the mispricing exceeded um uh the fee to trade right so you have this process it's going to generally diffuse when arms arrive if it's outside this band it's going to jump to the the nearest point of the band yes you said the red dots are when blocks are generated yes and Arbitrage is are always searching where they I'm I'm my mental model is Imagine The arbitrager is vertically integrated with the builder right so my mental model is whoever is going to build the next block he has in his mind that he's going to do an Arbitrage trade the instant before he

proposes that block he puts in the right Arbitrage trade so it's kind of continuously monitoring it always adjusting his Arbitrage trade for what would be the right trade if if that block was generated right now okay so um uh the nice thing um about this is we can actually solve for everything in close form so in particular this mispricing process Z of T it's not going to blow up it's not going to go off to Infinity it's ergotic it's going to have a stationary distribution and the stationary distribution is going to look like um uh this there's going to be um this region in the no trade region it's going to have a uniform distribution right and outside the no trade region this is where um arbs can profitably trade it's going to fall off uh

exponentially right and if you think about this um uh this just sort of makes sense for those who are familiar with normal reflected Brownian motion that's the way reflected Brownian motion works also it has a uniform distribution in the the interval that's being reflected so that uniform part based on that intuition makes some sense the fact that these are falling off exponentially they're falling off exponentially with rate Sigma square root of delta T right and that also makes sense because um uh if a if after a block is generated I'm always within this interval and if I somehow manage to end up outside this interval probably I was close to the edge and the amount I can move is you know kind of Sigma square root of delta T I'm roughly over uh Delta t period right so this is the uh uh um the the

the the um the distribution and critically the probability that you end up in one of these regions that a block is generated in that instant there is a a trade for the arbitrager is given by a very simple formula which again just depends on the fee the volatility and the time between blocks right so um I can um sort of illustrate that the way to interpret this formula would be um uh this would be the fraction of blocks that contain an Arbitrage trade at the top of the block right and um a plugging in fixing the daily volatility at five percent which is a reasonable number for something like ethereum I can try sort of various fees and various uh interblock times and you can see for

example if I have a 30 basis point fee and like I'm on ethereum blockchain with 12 seconds uh in between blocks I get about you know 12 percent of blocks have an Arbitrage trade versus if I jump down to five percent you get you know 45 percent um something like that right but of course um that's that's only the first part of it we'd also like to know not only um how often are they trading but how much money are we losing to them and so um uh um I'm gonna I'm go through that now so I'm going to Define ARB of T to be the cumulative Arbitrage profits over zero T so this is a jump process right every time an arbitrager arrives this moves up positively some amount maybe it moves up zero if the arbitrager can't make a trade but it's only um uh

it's never moving down it's uh only staying the same or moving up and it's also only moving at instances where arbs arrive so it's a jump process and um if I want to think about how fast this is growing the usual Technique we use to think about jump processes is we think about their intensity we think about um how fast is it going to grow over a short period if I take out all the other the randomness so here I'm looking at the expected Arbitrage profits over an interval from zero to t a relative to that size of the interval and I'm going to shrink it to a zero this is going to be the intensity of Arbitrage profits and our theorem um uh is that as delta T goes to zero so as blocks are occurring more more and more

frequently which is uh the the the correct regime um the arbor profits are given by this formula plus stuff that's smaller than order squared of delta T and um I'm not going to ask you to sort of think about the algebra real time but just take my word for it this is about lever plus something small uh if you recall the lever formula um if this was just y star Prime that would be um uh like uh the demand curve in the the riskless asset and multiply by a p and I'd get the lever formula but um for now just trust me that this is a lever formula plus an order a gamma correction for gamma small this is basically a lever so what I'm left with is um a lever times the probability of trade and then um a lower Order of Things

right so um again I'm up to the my my approximation this um sort of suggests that um uh once a fees are in place what's going to happen is that um uh lever still exists it's simply just going to get Scaled down by the fraction of time an arbitrager can show up and uh um actually um uh collect the uh the fee moreover we um all we see is delta T gets small if the fee rate is greater than zero if this gamma is is non-zero this is going to be an expression that's order square root of delta T right so in other words how much money we lose to arbitrageurs is um uh um order a square root of delta T we'll lose less the factor the uh the the the blockchain now

what is the intuition for this right that was a question from earlier the intuition is you should think about the arrival of blocks and how um what intensity that occurs with that's something about the intensity of competition between arbitragers right if arbitragers are applying more arriving more and more frequently they're competing over smaller and smaller price discrepancies and um they're making on less and less money and we saw in the continuous time limit I argued intuitively if they're continuously monitoring and their fees they will make nothing that's the limit where they sort of fully compete away everything right but again even absent The Continuous time a limit um uh um there's their profits or order delta T there is a discontinuity here right so if I plug in gamma equals zero if I have literally zero fees then um

the block time doesn't matter you lose roughly the same amount to uh the arbitragers right but um this is kind of the the relevant regime here because the fees are positive I mean you sort of going back and forth between two interpretations of the arrivals right one in terms of just block generation and one in terms of just part of arrivals yeah I view those as synonymous yeah I should make that clear because the arbs can only trade at instances where blocks are generated and I assume they're monitoring that process continuously right um uh they're you know part of the consensus process right or at least monitoring it so I'm assuming that arbs arrive when blocks are generated and vice versa so because there's a kind of two axes of

competition right one is just when there is a window of opportunity right then you're sort of assuming that there's multiple people competing for it right like the myopic assumption come true right right and then the second competition which you just mentioned only on this slide is kind of the distance between how like how frequently that would have up right so if the if the more frequent they're competing over smaller opportunities and how are these changes going to affect the revenue from fees okay so um that's the other than the next part um I can do the same analysis here so this is a little bit different than the fees I had before the fees I had before were all fees here now I'm going to focus on the fees paid just by arbitrageurs right and again that's

going to be a jump process so I'm going to do the same thing I'm going to look at its in intensity we get another expression um and I'm not going to parse that up for you um but I'll just jump to the punch line which that the amount of fees paid is approximately lever times one minus the probability of trade right so if I put those two results together this is how much the arbs are making money um how much money they're making net of profits is lever times P trade what are the fees that they're paying that are that are included in that is is lever times one minus P trade so this kind of looks like here like lever is a conserved quantity and it is indeed the sum of how much money the arbs make net of fees plus what the fees are that they

pay into the pool right so in other words um we can sort of think of imposing a fee as redirecting some of this lever away from the the top bucket which is how much money the arbs make into the second bucket which is uh um uh um fees at the Arabs I'm paying to the pool and in continuous time limit they end up paying all those fees into the uh on the pool so they're making nothing okay so um uh um um those are the um the the main um theoretical results um what I do want to point out is that we analyzed a specific model right specific model with a certain fee and so on our our hope is that this technique can be applied to analyze

other models and variations of uh of um um sort of the base amms and um the goal here should be to minimize Arbitrage profits right Arbitrage profits are like a zero-sum cost paid intermediaries um uh um and so by reducing them um we're going to increase the uh the gains from trade where there's going to be more um trade possible on the part of the uh the noise Traders and and thus we're going to improve on social welfare and so the goal should be to come up with designs that mitigate that right so one immediate thing is to run a faster blockchain right if you um uh you know um uh run 10x faster you'll pick up a factor of square root of 10 in terms of

a reduction of a Arbitrage profits right um other types of things we can think about are um maybe um uh you know um more complicated rules for setting fees maybe we can think about not just a proportional fee but um maybe you know other types of non-linear fees we can think about Dynamic fees we saw that there was a strong dependence of uh um uh um either Arbitrage profits or lever on volatility right so reasons for example that when volatility is higher the fees should be higher than when volatility is low right and and volatility even within the same pair of Assets in the data can vary by a factor of 10 over you know over a year in in for example the data set I have right so you know what one can think about um uh um uh you know rules to sort of uh

optimally set fees we feel that we have the base ingredient to do that and that we understand the the cost of uh um uh of of and how that evolves the part that we don't have an understanding of is you know our Theory right now would say okay set the fees very high and then the arbitragers aren't going to make money off you right but that's not satisfying because also the noise Traders won't trade against you if you have a very high fee pool no one will trade and you'll make no money right and so the other side that we need is we need to understand the sensitivity of noise traders to things like the effective spread and so on and and think about leveraging that to set optimal fees um we can also think about other things for example um the whole source of this loss

is that the pool does not know what the fair price is maybe if we had oracles things would be better right and um the pool could adjust its price without an arbitrager I'm taking money from the pool and um there's sort of a you know different um also different ideas to think about monetizing that for example might there be mechanisms where um we do something like we uh um auction the right to be a very low-cost arbitrager and try to recover um some of the money that uh that the arbitragers will make you say more complex people is there are you thinking more about when you're collecting from Traders or redistributing to LPS um no I'm thinking of collecting from Traders I'm viewing the LPS as one aggregate entity that's still Pro rotted

to the LPS Pro audit to the LPS yeah then on the faster blockchains thing I mean that is a more nuanced conversation that we had there probably right I mean like for example you kind of have to believe the price process to like it was more if the actual price process was more like a jump process yes right then that's a fair point yes I would say that's that's I would call that speculative like like maybe it's true but I feel like we need to do more work there so that's a good point yeah the noise Traders may also not be so time uh worried so you might have like a possibility of saying uh if you

want to trade in the next second your fees are higher than if you want to trade over the next you know day or two yeah absolutely and I think I think that's a great cost of mechanism which is uh underexplored I think in traditional um uh financial markets people do do that to some degree I mean the dominant way for example institutional investors accumulate positions in the stock market is they leave algorithmic orders over time and like if you're not in a rush you can leave your order over a long period of time and effectively you get in at a lower price but in some way like it would be nice to have a mechanism where you could directly signal hey like I don't have information I'm willing to trade slowly give me a better price I think I think that's a very very interesting Direction

so do you just feels based on Market Edition kind of assumes that the LPS are static over time right because they should dynamically adjust this amount of liquidity based on volatility as well then or like I'm just trying to think like if you assume that like the LP the lp to this model are totally known the LPS are static right now they're totally stacked like if they like adjust based on Market condition like the C is somewhere somewhere like if you think LP I think lpo they're like watching them I'd have to think about that I'm not sure um because I think there's a certain amount of adverse selection that occurs um like okay it's like so stylized fact is that um uh and again in traditional

financial markets the analogous thing to a fee is a bit ask spread and so stylized fact is it scales with volatility right um uh and so I think it's not just how much you're participating I think people like a blow out their prices um so I'm not sure yeah I was because I was thinking of it also like people blow out the spread when the ball but that's not what uh so if you pull from uh like by adjusting how much you're investing in the pool that doesn't achieve that effect yeah but in the sense the beta spread increases during times of volatility it's kind of like reflecting almost Dynamic transaction costs right so the transactions costs are going to adjust to the volatility that's what you want yeah exactly so so that exists in

the No No but okay but so let me let me be more precise um what from like I guess standard microstructure Theory what you'd expect is the bid ask spread for an infinitesimal trade to widen if it's more volatile even for an infinitesimal trade right so with by adjusting the curve you could adjust the bid ask spread for like a large trade but not an infinitesimal trade so you talked about like adjusting for Market Risk by like hedging against like eth or something right so can you think of hedging against lvr by potentially taking like a consensus position like you know you are a block Builder and that's why when you're building the block you can um take Arbitrage profits yourself which would which you would have lost yeah or

just an LP yeah so if you were if you can um always be the one who does the Arbitrage trades you will not suffer lever your level will be zero right now but the question is how do you how do you uh um gain that so um one proposed I sort of didn't dive into here but um uh um the idea here is uh suppose you give um uh um one person the right to trade with no fees right if that person can trade with no fees in some sense they're going to have priority over other arbitragers right because they can you know if if I'm paying a 30 basis point fee and you're not paying any fee and the missed pricing is 10 basis points you can trade that and make money I can't right so you could auction off the right to to be whitelisted and to trade

with no fees and presumably because that's valuable you could you know monetize some of the lever so I think there are sort of ideas like that but I think yes if the LPS themselves could adjust the prices and take the Arbitrage profits there would be no lever the question is what is a mechanism that achieves that I think one way they can do that is by becoming like Builders themselves but then presumably you have to compete with other builders right or like they're basically they're competing with other builders but they'll still get some percentage of the Arbitrage profit that will reduce their lvr right sure but I feel like that's sort of almost orthogonal right I mean anybody could choose to be an arbitrager and get some percentage of that lever right all right thank you

foreign