A Bumpy Road Ahead: Understanding Impermanent Loss in DeFi
Last week we gave you a 10,000-foot view of DeFi to provide you with the base knowledge to understand what is going on in the space. Today we will focus on the risks of participating in such pools.
We will focus on Uniswap because it is the largest and simplest protocol, but the lessons we will draw from this analysis can be applied to any other liquidity pool: Balancer, SushiSwap, curve.fi etc.
Liquidity Pools 101
Before looking into how a liquidity pool works, let’s take a step back and look at decentralized exchanges, or DEXs (for a deeper dive, our friends over at BitMEX published a thorough timeline recently). A DEX is a collection of smart contracts interacting together to fill the functions of an exchange, such as order-book management, price discovery, trade matching and settlement.
It quickly became obvious that a DEX would struggle to replicate the versatility and low latency of a centralized exchange, or CEX. Bringing a Continuous Limit Order Book (CLOB) on chain is an operational nightmare, a costly endeavor and an invitation to get front-running bots involved. But what if users interested in DEXs did not care that much about CLOBs and only wanted a decentralized and trustless solution to swapping A for B at a fair market rate? In other words, forget all the features one might expect from an exchange, and only keep the essentials: at-market execution and trustless settlement.
Liquidity pools are an elegant implementation of a simplistic trading platform. This is how it works:
- One trading pair = one smart contract = one pool
- One pool contains two assets = TokenA and TokenB
- nTokenA = number of TokenA in the pool
- nTokenB = number of TokenB in the pool
- nTokenA x nTokenB = K
- Ignoring transaction fees, K is a constant. K has no meaning in of itself, it is merely used as an anchor to determine the price of a token swap of any size.
- If I want to buy TokenA, I need to bring a sufficient amount of TokenB to keep K constant, and vice versa.
For example:
- ETH/USDT pool smart contract: https://uniswap.info/pair/0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852
- TokenA = ETH / TokenB = USDT
- nETH = 591,805 ETH
- nUSDT = 193,268,424 USDT
- K = 591,805 x 193,268,424 = 114,377,219,665,320
This is all great, but where is the ETH/USDT bid/offer here? Keeping K constant:
So there you have it: 326.57 / 326.58 - 1 ETH up, 326.52 / 326.63 - 100 ETH up.
$0.11 wide on 100 ETH is impressive! Compare that to the Binance ETH/USDT book (the outright price is meaningless here as the market moved between those screenshots):
The larger the Uniswap pool gets, the tighter that bid/offer becomes on large sizes. For an in-depth look into how Uniswap (and other DeFi protocols) got so big so fast, this article is for you.
Liquidity pools and trading fees
Trading fees are implemented in a very simple way when it comes to liquidity pools: if you want to buy TokenA for TokenB, you have to bring a little extra TokenA for the same amount of TokenB. On Uniswap, that “little extra” is the trading fee, currently set at 0.30%. Going back to the example of buying 1 ETH from the USDT pool, you would need to bring 326.58 x (1+0.30%) = 327.56.
This means K is not a constant: K increases every time a trader swaps TokenA for TokenB, or vice versa.
This is important to keep in mind when we will look at the economics of providing liquidity on Uniswap later on.
Providing liquidity to a pool
The beauty of a liquidity pool lies in the fact that anyone can become a liquidity provider (LP): simply add nTokenA and nTokenB to a pool of your choice and you are officially an LP. That’s for the how. As for the why, there are two incentives to providing liquidity to a pool:
- LPs collect a portion of the trading fees charged by the pool.
- LPs collect the pool’s reward token, if any. In Uniswap’s case, that is UNI.
Liquidity pools and global prices
Q: How do liquidity pools reflect global crypto prices?
A: By the invisible hand of arbitrageurs.
An example will make it easier to understand:
- nETH = 591,805 ETH
- nUSDT = 193,268,424 USDT
- Implied ETH/USDT price = 193,268,424 / 591,805 = 326.57
Let’s say that a ETH whale starts aggressively selling ETH on CEXs, pushing ETH/USDT price from 326.57 to 300.00. If I am an arbitrageur with access to USDT, there is an obvious trade:
- Buy 1 ETH for 300 USDT on a CEX
- Swap 1 ETH for 326.57 USDT on Uniswap, clearing 26.57 USDT
- Repeat
Each trade increases nETH and reduces nUSDT, pushing the implied ETH/USDT price lower. The arb opportunity closes when there is no more PnL to be extracted from this loop.
Assuming K is constant throughout that process (i.e. no liquidity is added or removed and no transaction fees are collected), the arb closes when:
- nETH’ = sqrt (K / [ETH/USDT price]) = 617,460
- nUSDT’ = sqrt (K / [ETH/USDT price]) = 185,238,133
Notice something crucial: on the move lower, nETH’ > nETH and nUSDT’ < nUSDT. Everything else being equal:
- when ETH/USDT goes down, nETH increases and nUSDT decreases.
- when ETH/USDT goes up, nETH decreases and nUSDT increases.
In other words, whenever the market moves, LPs are getting longer the asset that is depreciating and shorter the asset that is appreciating.
This is—by definition—a money-losing position. In traditional finance, this position is akin to a short gamma. In DeFi circles, it was given the catchy name of impermanent loss.
Short gamma or the cost of being an LP
We have seen in the previous section that providing liquidity to a pool was similar to being short gamma on the assets of the pool. It is trivial to compare the PnL of an LP compared to that of a passive holder with respect to the change in spot price:
It looks like the PnL loss is less steep on the way up, but that is only an optical illusion. Indeed, a log scale shows you more clearly that the gamma position is symmetrical in log returns, meaning that you lose the same PnL whether spot price doubles or halves.
Three things are worth pointing out here:
1. A short gamma position is always negative PnL: market moves up or down, the position loses money. The best case scenario is that the market is unchanged between the day one adds liquidity and the day one withdraws it.
2. Short gamma is only realized by LPs when they withdraw their liquidity. As long as the liquidity stays in the pool, the market might revert back to where it was when liquidity was added, thereby bringing the short gamma PnL to zero (in the above graphs, this price is 193,268,424 USDT/ 591,805 ETH = 326.57 ETH/USDT).
3. There is a negative feedback loop arising from this. For example in a dropping ETH/USDT market, LPs will get longer and longer ETH. LPs will realize this when withdrawing their liquidity as panic sets in: they get back a lot more ETH and a lot less USDT than they put in originally. To rebalance this position, LPs will tend to sell ETH for USDT, adding downside pressure to ETH/USDT price.
Against this short gamma position, LPs earn trading fees. In the graph below we plotted the break even volume of our ETH-USDT pool, that is the volume a pool has to experience to compensate for the short gamma:
Some takeaways here:
1. As expected, if ETH/USDT price is about unchanged, the break even trading volume is very low: the negative gamma PnL (“impermanent loss”) is small so even a negligible trading volume can compensate for it
2. Once ETH/USDT moves, the break-even volume increases exponentially. If ETH/USDT trades @ 400.00, b/e volume is 0.7bn USDT. a 5% move higher in ETH/USDT takes b/e volume to 1.2bn USDT.
In conclusion: Liquidity pools are democratizing short gamma
We have talked about the rise in popularity of liquidity pools in the last couple of months, mostly due to the reward tokens generously distributed to LPs. Uniswap is a perfect example of the effect a token—or the expectation of a token—can have on a protocol’s pools size:
There are more liquidity pools than ever before, attracting more capital than ever before: Uniswap, Curve.fi, Balancer, SushiSwap are just the biggest examples. As liquidity pools increase in size, so does the negative gamma in the market as a whole, and that negative gamma is overwhelmingly carried by LPs that only become aware of it when the time comes to withdraw their liquidity. This new state of affairs should create a price environment where market movements are exacerbated to the upside or downside as soon as such movements are large enough to have the negative gamma kick in.
What daily move are we looking at? This will solely depend on LPs’ collective tolerance for carrying large delta positions in volatile markets. So fasten your seatbelts: there’s a bumpy road ahead.
Legal Notice
This blog post is being distributed by Amalgamated Token Services Inc., dba “CoinList,” or one of its subsidiaries. This blog post and use of the CoinList website is subject to certain disclosures, restrictions and risks, available here.