Providing liquidity to a decentralized exchange is one of the prime ways to earn a yield on DeFi platforms, but there is a significant caveat. If you supply a token pair to an AMM pool, you risk incurring a loss if the prices of the two tokens diverge.
How Automated Market Makers Work
The problem with first-generation automated market makers (AMMs) which are used by most decentralized exchanges is that they naively assume that the USD-value of both token pools stays constant at all times, typically at a 50/50 weighting. This is why you need to send the AMM two tokens whenever you want to supply liquidity.
For example, when you want to supply 1 ETH to an ETH/USDT pool and the price of Ether is 1000 USDT, you send 1 ETH and 1000 USDT to the AMM. Let’s further suppose that you are the only liquidity provider. If someone now comes along and sells ETH worth 50 USDT, this will take 50 USDT out of the pool and add approximately 0.05 ETH. As result, there are now 1.05 ETH and 950 USDT in the token pool.
Since the AMM assumes that both sides are equivalent, it will now quote (950 USDT / 1.05 ETH) = 904.8 USDT/ETH as the new price. If this is not the correct market price (i.e. the price on centralized exchanges hasn’t changed from the original 1000 USDT), anyone can now rebalance the pool by buying ETH worth 50 USDT and pocketing the price difference. Whenever the price of a token on a decentralized exchange diverges from the correct market price, there is, therefore, an incentive for traders to adjust the price again.
So where is the Problem?
Remember that when supplying liquidity, you need to deposit two tokens of equivalent value. Whenever you withdraw liquidity, the AMM will send you the same two tokens with the equivalent value in turn.
Let’s stick to the example above. In this case, you have deposited ETH and USDT for a combined value of $2000. Now, if over the course of one month, the market price of ETH rises by 50%, traders on the exchange will adjust the AMM price to match the market price again. When you want to withdraw the liquidity now, the AMM will send you both ETH and USDT, both worth $1000.
As result, there would now be 1250 USDT (assuming 1 USDT = $1) and 0.667 ETH in the pool for you to withdraw and you would receive them for a combined value of $2250. However, you had held on to both your 1000 USDT and 1 ETH, not providing them as liquidity, they would now be at a combined value of $2500. Hence, you have incurred an impermanent loss of $250.
(Not so) Impermanent Loss
Many people have criticized the term impermanent loss to be a misnomer. The term seeks to portray those price movements to both sides cancel each other out. Let’s suppose that another month passes in our example and the price of 1 ETH drops to 1000 USDT once more, you would be able to withdraw both for a combined value of 2000 USDT again, plus any of the trading fees and liquidity mining rewards you have earned. In that case, you wouldn’t incur any loss.
The tweet below illustrates under which market conditions you are likely to incur a loss.
After several months of rigorous mathematical analysis I figured out under which price conditions it is generally good and bad to provide liquidity on @UniswapProtocol pic.twitter.com/NGbWxh2eLW
— fiskantes ⭐️🩸 (@Fiskantes) October 9, 2020
In essence, you should only provide liquidity to token pairs when you believe that their prices will move in the same direction in the long run to avoid impermanent loss. This could be the case for tokens that are highly correlated to each other, or stablecoin pairs.
Several DeFi projects are experimenting with dynamic market makers that are trying to minimize the risk of impermanent loss. An example of this is the single-exposure AMM of Bancor. Under their business model, AMMs require only deposits of a single token and use the elastic supply of Bancor’s BNT token as the counterparty, which can automatically mint or burn tokens to reimburse liquidity providers if they incur a loss.
Another approach is to use price feeds instead of simply assuming that both token pools are equivalent. Kyber Network attempts this with their protocol upgrade to version 3.0. Balancer tries to alleviate the problem by giving pool creators the option to set their own weights outside of the regular 50/50 weighting and to allow liquidity pools with up to eight tokens instead of only two.
How to use AMMs to your Advantage
While the impermanent loss is generally regarded as something to avoid, you can also use it to your advantage by building an auto-balancing crypto portfolio. Suppose you want to invest $1000 in two cryptocurrencies, for example, Wrapped Bitcoin and Ether and you want the value of both positions to be equivalent at all times.
Instead of rebalancing the positions manually through a centralized or decentralized exchange, you can simply provide both as liquidity to an AMM. Not only will the AMM keep the value of both positions equivalent automatically, but you can also earn an additional yield on top of that from the trading fees the AMM charges and you might be eligible to stake the LP tokens to a liquidity mining program or a yield farming platform.
If you want to add more tokens to your self-balancing portfolio, you need to add more liquidity pools as well. For example, if you want to add Binance Coin as the third token, you need to provide an equivalent amount of liquidity to the BTC/ETH, BNB/ETH, and BTC/BNB pool.
This however gets increasingly complex. For a fourth token (let’s say Cardano), you additionally need to provide liquidity to the BTC/ADA, ETH/ADA, and BNB/ADA pool. If you want to build more complex portfolios, Balancer might be an attractive option, since it supports pools with up to eight tokens. Additionally, you are able to set custom weights on Balancer, so if you want to invest $1000 in Bitcoin and $500 in ETH, BNB, and ADA each, you would open a Balancer pool for these four tokens with weights set as 40% for Bitcoin and 20% for the other three.