Uniswap’s Financial Alchemy


Uniswap LP getting rich by getting mercilessly arbed (source).

1. The Question

On October 14th, Charlie Noyes posted on Twitter a question that he and Dan Robinson had been debating:

For any Uniswap pair, what is the optimal fee?Can this optimal fee beat an unrebalanced portfolio, achieving “no impermanent loss” or even excess growth (in expectation)?https://t.co/Ceuup6MY1Q— Charlie Noyes (@_charlienoyes) October 14, 2020

1.1. Context

An automated market maker is a type of decentralized exchange that lets customers trade between on-chain assets like USDC and ETH.

Uniswap is the most popular AMM on Ethereum. Like most AMMs, Uniswap facilitates trading between a particular pair of assets by holding reserves of both assets. It sets the trading price between them based on the size of its reserves in such a way that prices will stay in line with the broader market.

Anybody who would like to can join the “pool” for a particular pair and become a liquidity provider, or LP, so-called because they provide liquid assets for others to trade against. LPs contribute assets to both reserves simultaneously, taking on some of the risk of trading in exchange for a share of the returns.

1.2. The Problem Setting

The problem supposes that the pool is providing liquidity between cash and a risky asset whose price moves randomly. It also makes the particularly brutal assumption that all incoming trades are informed — arbitrage transactions that take place only when the AMM’s price is out of line.

In other words, the pool loses money on every trade.

1.3. Conventional Wisdom

At first glance, it seems that being a Uniswap LP in these circumstances would be a costly mistake.

Because market makers demand a lower price to buy than to sell, they directly profit when asset prices don’t move and they get a roughly balanced amount of incoming buys and sells. These are often called “uninformed” trades, because they aren’t correlated with short term price movements.

On the other hand, market makers lose money when they buy the asset just before prices drop, or when they sell it just before prices rise. Accordingly, one of the market maker’s most feared counterparties is the arbitrageur, who comes to trade only when prices have changed and left the market maker behind. Every trade she executes is pure profit for her and pure loss for the market maker.

Since there are no uninformed trades in our Uniswap problem setting (literally every trade is an arbitrage trade), it seems obvious that the LPs should lose out big time.

1.4. The Challenge

Nevertheless, Dan and Charlie intuited that there might be more to the story.

For some underlying price dynamics, they suspected, it could still make sense to be an LP on Uniswap even if it meant getting run over on every single trade.

They brought their problem to mathematical finance legend Steven Shreve before setting it loose on crypto Twitter, where Martin Tassy and I independently produced partial solutions before collaborating to extend his nearly complete solution to the general case.

The four of us spent some time over the next few weeks discussing the results over Telegram, probing for errors and building our intuitions. Those discussions are the basis of this post.

2. The Solution

If the volatility of an asset is high enough relative to its average rate of return, LPs on Uniswap will do better than HODLers over time, even when the only incoming trades are arbs.

This is due to a phenomenon known as volatility harvesting: under certain conditions, it is possible to outperform any static portfolio of two assets by periodically rebalancing them. In this case, to “rebalance” means to make trades such that the proportion of total portfolio value held in each asset returns to a fixed allocation, such as 50/50.

So, when they get arbed, LPs essentially pay a fee to the market to rebalance their portfolios for them. In this particular mathematical setting, it turns out that when this rebalancing is beneficial, you want to do it as often as possible. This means liquidity providers should set their fee, which determines the width of the price window in which rebalances occur, to be as low as possible without being zero.

This is good news for Uniswap, because it means that even in circumstances where arbitrage trades dominate, low fees can still make sense, enabling Uniswap to stay competitive as on-chain orderbooks proliferate and begin to offer tighter spreads.

That said, it’s worth repeating that these results hold for a very particular stylized mathematical setting, which involves assumptions very similar to those of the Black-Scholes Options Pricing Model. We also assume a different fee structure than the one used in production Uniswap for mathematical convenience.

2.1. Standard of Comparison

We evaluate different strategies by comparing their asymptotic wealth growth rates, which measure how fast they compound (or lose) value over long periods of time.

This quantity is important because strategies that optimize it perform better than strategies that don’t almost surely as time goes on.

We compare all strategies to the “unrebalanced portfolio,” which holds half of its value in cash and half of its value in the risky asset to start, and is never changed after that point. This is the community standard for measuring so-called “impermanent loss” in AMMs.

The unrebalanced portfolio will always hold the same amount of cash no matter what happens. That means that in the worst case, when the risky asset loses all of its value, the unrebalanced portfolio will consist almost entirely of cash, and will therefore have a growth rate of zero in the long run.

On the other hand, if the risky asset sees exponential growth, it will quickly come to dominate the unrebalanced portfolio, which therefore have the same growth rate as the risky asset.

It’s worth noting that two portfolios can share the same asymptotic wealth growth rate while behaving quite differently close-up. For example, if the risky asset has a growth rate of zero, then zero-fee Uniswap shares will always be worth less than the unrebalanced portfolio, but since neither is expected to compound growth or loss over time, both will have a wealth growth rate of zero.

2.2. Volatility Drag


Volatility drag in action for the 50% loss / 75% gain process (source).

To understand these results, it helps to first understand the concept of volatility drag. Let’s say that every year the price of our risky asset either drops or rises , with equal probability of either happening.

In any given year, if we invest in the asset, our “expected value” is . If we simply buy and hold, the expected value of our portfolio will keep increasing by each year. This seems like a pretty good deal.

Unfortunately, in the real world, our profits will not materialize. If we buy and hold this security, we will eventually lose everything.

This is because losses are disastrous when compounding wealth over time.

If we suffer a loss one year, and see a gain the next year, we will have only of what we had when we started.

Similarly, if we have a good year and make , but then lose the next year, we will again be left with of what we had when we started.

Over time, the law of large numbers guarantees that our internal rate of return will be per year, and we will inevitably go bankrupt.

2.3. Wait, What?

If you have been trained to analyze gambles through the lens of expected value, there’s a good chance that the previous section seems extremely weird and perhaps flat-out incorrect.

In fact, we had the full, closed-form mathematical solution to this problem for over a week before I had any idea what it meant at an intuitive level due to precisely this issue.

The root of it is this: expected value is a theoretical quantity that measures what would happen if we replicated a given gamble simultaneously across an infinite number of parallel universes.

Reality, however, doesn’t work that way. We get only one shot at each gamble, and the effects of the gambles we make aren’t instantaneous, but instead compound over time.

We can view it from another angle to help reconcile the math. As we repeat the gamble over and over, reinvesting our bankroll each time, the expected value grows largely due to the very small number of paths where everything goes exactly right, resulting in astronomical returns.

As time goes on, these paths represent a smaller and smaller proportion of all those that are possible, and our chance of actually seeing one of them realized shrinks to zero.

2.4. The Value of Rebalancing

In the face of volatility drag, it pays to keep some of your money in reserve even when you’re looking at a bet with positive expected value. That way, you lose less when things go wrong, boosting your compounded wealth in the long run.

As far as trading is concerned, all of this shakes out to some pretty familiar concepts. When prices go up, it sometimes makes sense to close out part of your position to lock in profits in case prices fall again. When prices go down, it sometimes makes sense to buy the dip to get access to expected future returns at a favorable price.

In certain settings, such as this one, the optimal strategy is to continually rebalance your portfolio, such that you always have a constant proportion of your wealth invested in each position — say, half cash, half risky asset. This is not always the optimal balance, and in general you want more of the risky asset in your portfolio the higher its returns relative to its volatility, but we defer further exploration to future work.

The benefits of rebalancing to long-term wealth growth can be massive, and can mean the difference between becoming exponentially wealthy and going bankrupt. This is true even when, as in our setting, each individual rebalance trade is at an unfavorable price and causes an instantaneous loss.

2.5. Resources

There’s a good chance you are feeling unsatisfied by these explanations and would like to learn more.

You might start by reviewing The Kelly Criterion, a theoretically optimal betting strategy based on these principles. @wpoundstone’s Fortune’s Formula is a highly regarded and accessible book on its history and implications.

Alternately, for an in-depth mathematical treatment of the mathematics of wealth growth, I highly recommend @ole_b_petersErgodicity Economics Lecture Notes or his article in Nature.

If you choose to investigate for yourself, be careful. This is poorly understood territory, and many of the sources I found during the course of my own research contained errors that set my understanding back by hours or days.

In particular, if you see anyone making an appeal to mean reversion or logarithmic utility functions, I advise you to move on. The key results in this area do not require you to assume any particular return distribution or utility function.

2.6. Fee Alchemy


Wealth growth discontinuity at 0% fee (source).

When it’s beneficial to be an LP in this setting, LPs should rebalance as often as possible to stay maximally balanced at minimal cost.

The fee should therefore be set as low as possible without being zero so that rebalances are triggered by increasingly tiny price movements. Dan Robinson calls this “picking up pennies in the quantum foam.”

However, when the fee is exactly zero, all the benefits of rebalancing disappear, and in most cases LPs are worse off than they would be if they just held the unrebalanced portfolio.

Understanding this seeming anomaly helps shed light on the rest of the problem.

Uniswap uses the “constant product” invariant, which means that in the absence of fees, each trade must leave the product of the reserve balances constant. We express this as in our notation, although readers already familiar with Uniswap may be more used to writing it as .

However, it turns out that this product is exactly the quantity that must increase in order for rebalancing to provide us with excess wealth growth.

Why is so important? One way of looking at it is that is the geometric mean of our reserve balances and . Like the arithmetic mean, the geometric mean increases as the reserve quantities grow. Unlike the arithmetic mean, however, the geometric mean shrinks as the reserve quantities get out of balance, even if their arithmetic mean stays the same.

In the no-fee case, remains constant, so trades always lead to either bigger reserves or more balanced reserves. It’s never both. As a result, there’s no engine for wealth growth.

However, a nonzero fee, implemented as in either real-world Uniswap or our setting, guarantees that increases with every trade. When increases over time, it means the reserves are not only growing, but staying balanced as well, providing the benefits discussed above.

To see the precise mathematics of how this works out, see prop 3.1 in Martin’s and my proof.

3. The Math

With all that said, we can now precisely answer the questions laid out in Charlie’s original problem statement.

To restate, they concern the wealth growth rate of a Uniswap-style AMM with percentage fee making a market between cash and an asset whose price moves as a Geometric Brownian Motion with parameters (drift) and (volatility).

3.1. Growth Rate of LP Wealth

G=E[limT→inf1Tlog(W(T))]={d2((1+γ4dσ21−γ4dσ2)(1−γ1+γ)+1)if d≠0,γ∉{0,1}σ24logγγ−1γ+1if d=0,γ∉{0,1}max(μ−σ22,0)if γ=012(μ−σ22)if γ=1

3.2. Optimal Fee & Excess Return

It pays to be an LP vs. holding the unrebalanced portfolio of half cash and half the security if and only if and .

In these cases, LPs should set their fees as low as possible without being zero, and they will realize a wealth growth rate asymptotically approaching .

3.3. Interpretation

Since Geometric Brownian Motions model compound growth, they too are subject to volatility drag, which is mathematically expressed as the term of the GBM wealth growth rate:

That means the range of in which it makes sense to be an LP on Uniswap corresponds to HODL growth rates of .

This gives us a lens through which to view our results: rebalancing allows us to partially counteract the volatility drag on the underlying asset.

If the average return even without volatility drag is zero or negative, no amount of rebalancing will help us, and we are better off just holding cash, although the rebalanced portfolio will still do better than just HODLing the asset itself.

On the other hand, if the average return without volatility drag is positive:

  • If volatility drag costs the asset more than 200% of its average log return, rebalancing on Uniswap won’t be able to eliminate enough of the drag to make it worthwhile, and you are better off just holding cash.
  • If volatility drag costs the asset less than 66% of its average log return, offsetting drag by rebalancing on Uniswap will not be worth the cost, and you are better off simply holding the asset.
  • Within that range, being a Uniswap LP will eventually make you rich, and in fact richer than you could become by holding any unrebalanced portfolio consisting of cash and the asset. This includes both some assets that will eventually dwindle into nothing and some assets that will go parabolic.

3.4. The Proofs

A pre-print of the full proof can be found here. It works by modeling the dynamics for a discrete random walk and then taking the limit of the behavior as you shrink step size to zero.

You can also check out my original proof for the zero log drift case and play with some of the simulations of the problem here. It works by stretching time, variance, and fee into equivalent configurations to produce identities.

3.5. How much trust should we place in these results?

In my biased opinion: quite a lot.

We have two independent methods of proof which produce the same results where their domains overlap. We also have simulations that validate our predictions:


Simulated vs. predicted wealth growth rates (source).

Still, this is extremely confusing territory, and my understanding of it has changed many times in the past few weeks. If you do happen to spot an error, don’t hesitate to reach out.

4. Future Work

While we hope you agree that these results are theoretically interesting (and/or maddening), plenty of work remains to establish their relevance to the real world.

For example, many of our assumptions could be modified or expanded:

  • How do these results translate to the multi-asset case, or when LPs can choose to rebalance to proportions other than 50/50, as in Balancer?
  • What happens when we no longer allow infinite trades per unit of time?
  • How about as we introduce transaction costs, which could even be variable to reflect priority gas auction dynamics?

There are also empirical questions:

  • Can we estimate these parameters for securities trading in the market today?
  • How many actively traded tokens would have benefited from a rebalancing strategy such as the one we have described?
  • Can we determine what proportion of realized Uniswap LP return in the wild is due to volatility harvesting?

Finally, and perhaps most interestingly, there is the question of application. How can we take what we have learned here and use it to improve existing protocols, create new ones, and grow the DeFi ecosystem as a whole?

5. Let’s Talk

Questions? Thoughts? Potential applications?

We want to hear from you.


Thanks to Vitalik Buterin, Matt Huang, Georgios Konstantopoulos, and Alex Evans for conversations which contributed to this post.