How much token liquidity is required in the liquidity pool? What factors do you need to consider when building a liquidity pool? How exactly do liquidity pools work?
Liquidity pools are a critical part of the Web3 project and I will answer all these questions in this article.
Token liquidity, the ability to buy and sell tokens, is a core part of token economics and any Web3 project. Liquidity pools are the key innovation that enables this, and they are one of the most elegant, important, and cool parts of DeFi. Liquidity pools are the basis for two key parts of DeFi:
Trade tokens freely between everything – without anyone’s permission or going through any “gatekeepers” (which forms the basis of the DeFi matrix).
DeFi’s revenue base and capital opportunity cost.
All in all, fully understanding liquidity pools and how they work as users, investors, and builders is an important part of understanding and designing token economics.
In this article, we will introduce:
What is a liquidity pool?
How do liquidity pools work?
The impact of price slippage, arbitrage, and impermanent losses in liquidity pools on investors, builders, and users.
What is a liquidity pool?
A liquidity pool is a mechanism that allows trading between two tokens in a completely decentralized manner. This is in contrast to the traditional approach, which is managed by a centralized market maker that matches buy and sell orders in an order book. Liquidity pools use smart contracts instead of centralized market makers. They determine asset prices through an algorithm that takes into account the ratio between two tokens in a liquidity pool. Because this all happens automatically, they are called "automated market makers", or AMMs for short.
Imagine that in a bowl you put two different currencies: dollars and euros. The bowl is placed outside and anyone can exchange dollars for euros at any time. Transactions come with a small fee, which is used to reward those who provide liquidity. Anyone can add USD and EUR to the bowl (i.e. liquidity) and receive their fair share of the reward fees. Because all of this runs on open source, anyone can create a pool between two assets.
How do liquidity pools work?
There are three main components of a liquidity pool:
Providing liquidity: which tokens will be traded against each other;
Setting the price of the token: pricing algorithm;
Reward liquidity providers (LP).
Liquidity Pool: Provide liquidity
Anyone can set up a liquidity pool using protocols like Uniswap or Sushiswap (on Ethereum). Each blockchain has its most popular AMM protocol as well as some competitors. A pool is established by depositing two different tokens into the pool. These tokens can then be exchanged for each other. For example, depositing ETH and USDC into a new liquidity pool will create a pool where USDC can be traded for ETH.
Once the pool has liquidity, anyone can swap between the two tokens. The question now is: at what cost?
Liquidity Pool Pricing
The price between assets is determined through a formula that reflects the ratio between the two assets. When there are more A tokens than B tokens in the pool, purchasing one B token requires more A tokens. For example, if a pool has 10 ETH and 1000 USDC, the ratio between ETH: USDC is 1:100. Essentially, the current price of ETH, every 1 ETH = 100 USDC.
The formula that gives the exact price is very simple (which is part of the reason liquidity pools are so elegant) and is known as the “constant product” formula: X * Y = K.
The constant product formula looks at the pool assets before the swap happens: how many A tokens and B tokens are in the pool. It then creates the constant "K" by multiplying the number of A's by the number of B's. Using this constant, the price of Token A can be calculated using Token B.
For example, a pool has 10 ETH tokens and 1000 USDC tokens. The "K" value will be 10,000 (because 10 * 1000 = 10,000). Now, in order to calculate the price of ETH, all we have to do is solve a simple equation without omitting variables, giving the price of each ETH = 100 USDC. The math is actually quite simple.
While it’s good to understand the math, from a token economics perspective, it’s most important to understand the impact of the “constant product formula” on token prices both inside and outside the token pool. Whether you are building a liquidity pool or trading, these implications are important to you.
The main impacts are as follows:
Assets traded in the pool have price slippage. It is necessary to understand the ratio between the volume of any given trade and the total trading volume locked in the pool (TVL).
Pool prices may deviate significantly from prices on other exchanges. For example, the price of ETH/USDC in the pool may be very different from the price at which ETH/USDC trades on Coinbase or other exchanges.
Liquidity providers may suffer “impermanent losses” and need to be compensated for this.
Let’s analyze each meaning in more depth.
Price slippage in liquidity pools
The x * y = k formula creates a very specific way of trading one asset in the pool for another. It's a curve function that looks like this
Any point on the curve is represented by the number of A and B tokens in the pool. The ratio between them determines the price. A pool with 100 A tokens and 2 B tokens means it takes 50 A tokens to get 1 B token¹.
As token ratios become extreme and move toward the edge of the curve, the cost of exchanging between abundant tokens and depleted tokens will rise exponentially, making it increasingly expensive.
Each successive transaction significantly affects the token price. While this happens with every AMM trade, the more extreme the ratio, the greater its impact.
As we saw with the dynamic curve, when the pool reaches its limit, the curve approaches infinity - meaning the curve is never completely exhausted. Since the fewer A tokens in the pool, the more B tokens we have to pay, when the pool approaches the end of its A tokens, the price will skyrocket to unlimited B tokens for every A token.
Price slippage has a significant impact on token prices and needs to be managed carefully or it can be exploited by traders. The primary way to reduce slippage is to have a large amount of liquidity in the pool on each trade. The smaller the relationship between trading volume and liquidity in the pool, the smaller the price fluctuations.
For example, a trade exchanging 10% of the TVL amount in a pool would move the price by approximately 9%, while a trade exchanging 0.1% of the TVL would move the price only 0.09% – virtually no movement.
Simply put: more liquidity means greater trading range, lower slippage, and more stable prices.
price arbitrage
The second implication to note is that the price of tokens in liquidity pools will differ significantly from the price of those tokens on other exchanges!
Since the price in the pool is set purely by a constant product formula, there are no external variables affecting the pool token price. The only thing that affects the price is actual trading: it has to do with the amount of liquidity in the pool and the volume or size someone wants to trade.
For example, in a illiquid ETH/USDC pool, a trader can move the price to an extreme. But this will not affect the price of ETH on any other exchange like Coinbase, Binance or any other AMM!
This opens the door to market and price manipulation and arbitrage. If the price of a token in a liquidity pool is materially different from the price on an external exchange, arbitrageurs should enter the market and conduct arbitrage to bring the price between the AMM and other exchanges into equilibrium.
What this means for builders is that if AMM is used as an oracle price for any application, governance or DeFi - what you need to be aware of is not a question of whether this is possible, but rather a question of whether someone will The question of how much it would cost to take price manipulation to the extreme. As users or investors, it is still best for us to always check other exchanges to see if we are getting the market price now.
impermanent loss
Impermanent Loss (IL) is the loss in value that an LP may suffer by putting an asset into a pool compared to simply holding the same asset. Like LPs holding ETH and USDC, in some cases LPs holding ETH and USDC can see more price increases than adding ETH and USDC to liquidity pools.
How did this happen? The calculation is relatively simple, when you put 1 ETH and 100 USDC into a liquidity pool, you will give up some upside if the price of ETH rises. Why? Assets in a liquidity pool are always balanced in value. This means that the pool automatically "gives up" a portion of the price appreciation to ensure that the constant product formula remains correct.
Here's an example:
The price of ETH increased in the market (outside of liquidity pools) from 100 to 120 USDC per ETH.
The arbitrageur saw an opportunity and bought ETH in the liquidity pool for $100 and sold it on the market for $120 (a nice $20 profit). This brings the price in the pool into equilibrium with the rest of the market.
Using the constant product formula, the balance of the tokens in the pool is now 0.91 ETH and 109 USDC (the price per ETH is approximately 120 USDC).
If the LP share is calculated in US dollars, the value is: (0.91 * 120) + 109 = 218.2. If you put 1 ETH and 100 USD in your wallet, it will be worth 220. So now we have an impermanent loss of 1.8 points!
This is because of the rebalancing inherent in the constant product formula AMM. This is called an impermanent loss because if the price of ETH drops from 120 USDC to 100 USDC, the loss disappears. Losses depend on price fluctuations. The greater the price change of the underlying asset, the greater the IL.
It should be noted that the loss is not absolute, but relative to holding assets outside the liquidity pool. In this case, the important implication for LPs is that when liquidity is increased, IL's risk increases LP's risk.
LPs have two financial risks that need to be mitigated: opportunity cost and IL. The higher the risk, the higher the fees LPs can expect to receive. Higher risk can generally be quantified into two aspects: how long we need the funds to be liquid and the volatility of the underlying asset. The longer the lock-in period, the more volatile the underlying assets will be, and the more fees the LP can expect to receive.
Since most projects use the Uniswap protocol (or similar protocols), there is a direct fee of 0.3% per transaction - usually not enough to compensate LPs for their risk. This is why most projects reward LP with additional tokens. Without these additional tokens, the benefits of providing liquidity to the project cannot outweigh the risks, because projects know that liquidity is critical to the token, so they need to allocate their budget accordingly.
Liquidity Pools: The Core Building Blocks of DeFi
DeFi is built on constant product AMM liquidity pools. It is these trustless, permissionless liquidity pools that form the basis of the DeFi matrix and DeFi revenue.
Understanding the core concepts of how prices are set, how prices change or are manipulated, and the impact these have on builders, users, and investors is an important part of designing token economics.