Sub topic 2
Liquidity Pools and How Thin Liquidity Makes Prices Fragile
This chapter assumes you know what a crypto wallet, token, and blockchain transaction are. You should also understand that a decentralized exchange can trade tokens without a traditional order book.
What a liquidity pool does
A liquidity pool is a smart contract holding reserves of two assets, such as ETH and a newly issued token. Traders swap one asset for the other directly against the pool. People who deposit assets are called liquidity providers (LPs). In return, they may receive trading fees or pool-share tokens.
Many pools use an automated market maker (AMM). An AMM is a program that calculates the exchange rate from the pool's current reserves. A common rule is the constant-product formula:
x × y = k
Here, x and y are the two reserves, and k is intended to remain constant after accounting for fees. A trade changes the reserves, so the next trade receives a different price.
Why liquidity controls price impact
Liquidity is the amount of assets available in the pool. Price impact is the change in the pool's price caused by a particular trade. Slippage is the difference between the expected execution price and the actual execution price.
A trade that is small compared with both reserves usually has limited price impact. A trade that is large compared with the reserves moves the price sharply. Thin liquidity makes this effect worse because even a modest sale can consume much of the pool's valuable reserve.
The following Python function models a constant-product swap. It includes a 0.3% trading fee, similar to a common AMM design.
def amount_out(amount_in, reserve_in, reserve_out, fee=0.003):
"""Return the output of a constant-product AMM swap."""
amount_in_after_fee = amount_in * (1 - fee)
return reserve_out * amount_in_after_fee / (
reserve_in + amount_in_after_fee
)
eth_reserve = 100.0
token_reserve = 1_000_000.0
normal_sale = amount_out(100_000, token_reserve, eth_reserve)
thin_sale = amount_out(
100_000,
token_reserve * 0.1,
eth_reserve * 0.1,
)
print(f"Normal pool: {normal_sale:.4f} ETH")
print(f"Thin pool: {thin_sale:.4f} ETH")The same token sale receives about 9.0661 ETH from the larger pool but only about 4.9925 ETH from the smaller pool. The starting token-to-ETH ratio is the same in both pools. The difference is that the sale is much larger relative to the thin pool's reserves.
How a liquidity withdrawal creates danger
A liquidity provider can usually withdraw some or all deposited assets. If a token creator controls most of the pool's liquidity, the creator may remove it suddenly. This is commonly called a liquidity rug pull.
After withdrawal, the token may still appear to have a high quoted price. However, the pool contains too little ETH or another valuable asset for ordinary holders to sell without extreme slippage. The displayed market capitalization can therefore remain misleading while practical sellable value collapses.
Check these facts before trading:
- The pool's total reserves and their dollar value.
- Who owns or controls the liquidity position.
- Whether liquidity is locked, for how long, and under what conditions.
- The size of your intended trade compared with the pool reserves.
- Whether other pools provide meaningful exit liquidity.
Exercise
A pool has 10 ETH and 100,000 tokens. Why can a sale of 50,000 tokens receive much less than half of the pool's ETH?
Show answer
The AMM price changes during the trade. The sale removes a large share of the ETH reserve, so constant-product pricing applies increasing price impact to later portions of the sale.