Besides yield farming, liquidity mining has become one of the hottest DeFi trends. Liquidity pools enable investors to earn interest via liquidity mining. But how do these liquidity pools work, and what are they?
Currently, Uniswap is still the leader in terms of total value locked (TVL) in their liquidity pools, with a locked value of $1.38 billion. Sushiswap closely follows Uniswap with a $1.03 billion TVL.
This article explores how liquidity pools work, rebalancing, automated market makers, how they prevent slippage, and the investors' incentive to add liquidity?
To better understand the need for liquidity pools, let’s first examine what problems they solve. Traditional peer-to-peer decentralized exchanges often lack liquidity. This lack of liquidity is a significant user experience (UX) problem for its users as they frequently experience slippage.
“Slippage refers to the difference between the expected price of a trade and the price at which the trade is executed.” - Investopedia
To illustrate this with an example, imagine you place an order for a particular cryptocurrency at the price of $9.50. However, due to a lack of volatility, your order closes at the price of $9.60 or even higher.
In other words, you’ve just paid more money than you expect to pay for your order. Slippage can be dangerous for trading bots that rely on predictable pricing. Even a small percentage of slippage can turn a profitable trade into an unprofitable trade like arbitrage trading.
This problem led to the introduction of liquidity pools.
Liquidity pools guarantee liquidity at every price level. A liquidity pool always consists of two cryptocurrencies. When participating in a liquidity pool, we’ve to add equal value for both currencies. On top of that, we want to maintain a fixed 50/50 ratio for the value in both pools. If that value deviates, we have to rebalance the pool.
Imagine we’ve created a fictive liquidity pool that allows traders to swap lemons and strawberries. We have to set a constant value that determines the balance between both currencies. For example, each lemon is worth five strawberries.
Now, Carly wants to sell one lemon in return for five strawberries. Therefore, this swap adds one lemon to the lemons pool and removes five strawberries from the corresponding pool. However, this means that there’s no 50/50 ratio anymore.
In this case, we have to rebalance the pool. We can rebalance the pool by adjusting the price between lemons and strawberries. As there are fewer strawberries, the price for strawberries increases. In contrast, there are more lemons. Therefore, the price for lemons decreases.
All these actions are controlled by an automated smart contract that holds both balances and automatically adjusts prices. People often refer to this mechanism as automated market makers (AMM).
Rebalancing is essential to guarantee liquidity at each pricing level. You might wonder why, as the pool will eventually run out of lemons or strawberries.
Yes, you are right about that. However, we also have to consider economic rules.
Every time a user swaps lemons for strawberries, the price for strawberries will increase. As this is a y = k/x graph (hyperbola graph), the price increases rapidly the more people swap lemons for strawberries.
At some point, users will spot this opportunity and will start swapping strawberries for lemons as they have become incredibly cheap. This event is known as market efficiency or market balancing. Often, arbitrage bots are good at maintaining a healthy balance for open markets.
To understand how liquidity pools prevent slippage, we must understand the difference between traditional P2P exchanges and liquidity pool exchanges (or swap exchanges).
A traditional P2P exchange maintains an order book where traders can add orders. Often, there aren’t plenty of orders for more exotic trading pairs, making it hard to use these exchanges.
However, liquidity exchanges don’t rely on an order book to enable trading. Investors add funds to these pools to guarantee liquidity. By automatically adjusting the price, there’s always liquidity at each price level.
It is great because we can create any new trading pair and add immediate liquidity as long as plenty of people add funds to the pool.
For example, you want to swap USDT for USDC. However, no centralized exchange offers this trading pair, you don’t want to make additional trading steps to end up with USDC, and there’s not sufficient liquidity on a P2P exchange to fulfill your large order.
We can quickly create a new USDT/USDC trading pool and wait for people to add tokens to the pool. Now, you can easily swap your USDT for USDC. It’s an excellent alternative for traders who want to enjoy a great user experience while staying within the decentralized space.
Here comes the juicy part: gain more profits! For each swap, a trader pays a small fee. For example, Uniswap charges a 0.3% fee. This fee gets added to the pool.
Imagine the same USDT/USDC pool. As both coins are stablecoins worth one dollar, we have to add equal amounts of both tokens. Therefore, we decide to add $100 of USDT and $100 of USDC.
Every time a trader swaps tokens in any direction, the fee gets added to the pool. As a liquidity provider, we can claim a proportional stake of this pool’s fees based on our stake in the pool.
For example, our $200 investment represents 0.8% of the pool’s balance. Therefore, we can claim 0.8% of the accrued fees when withdrawing our investment from the pool.
No, this is not true. We’ve mentioned the 50/50 ratio we want to maintain for each pool. Our underlying smart contract (automated market maker) takes care of managing this ratio.
Your funds' distribution will indeed shift. In our lemons and strawberries example, Carly sells one lemon for five strawberries. Imagine the pool consisted of 100 lemons and 500 strawberries. Now, the balance has shifted towards 101 lemons and 495 strawberries. The smart contract will adjust the price, so the value of each pool is equal.
As you can see, your investment will shift over time between both currencies, but the invested value remains the same due to the 50/50 ratio.
To conclude this article, let’s take a look at the arguments for using a liquidity pool exchange. Here they are.
If you consider investing in liquidity pools, stick to well-established liquidity pools. We’ve seen several rug pulls for scam tokens being listed as new liquidity pools where the token creators remove their liquidity after attracting some initial liquidity.