How Liquidity Pools Work in Decentralized Finance
All liquidity pools operate on a similar principle and allow tokens to be exchanged in a decentralized way within one blockchain through smart contracts. But in order to swap tokens in different directions, liquidity is required. Centralized exchanges usually do not face this issue because they almost always have sufficient liquidity.
But how is this problem solved in decentralized swaps, where there are no traditional order books like on centralized exchanges? Decentralized exchanges work on the basis of smart contracts with liquidity pools. These liquidity pools are filled by users for each token pair. Any user can become a liquidity provider for any available pair.
In return, they receive a percentage of the fees from every transaction executed within the smart contract for that trading pair.
Let’s take the ETH–USDT pair as an example. Trading pairs can consist of any two tokens. Liquidity providers add liquidity to this pair in a fifty-fifty proportion. Let’s denote the ETH portion in the pool as X and the stablecoin portion as Y. The total liquidity of the pool is calculated using the formula:
X × Y = K
The value of K must remain constant, meaning that the total liquidity structure of the pool must stay in balance.
Imagine I have one thousand USDT and want to buy one ETH using this trading pair on Uniswap. I deposit one thousand USDT into the pool and withdraw one ETH. As a result, the pool contains less ETH and more USDT. This increases the price of ETH in this pair because the value of K must remain constant.
This mechanism determines the price of an asset in decentralized trading pairs. The more a purchase transaction disturbs the balance between X and Y, the higher the price becomes. In other words, the larger the transaction size, the stronger the imbalance between X and Y—and the higher the effective purchase price of the asset.
Now let’s discuss liquidity providers. They receive a percentage of every transaction executed in the trading pair to which they supplied liquidity.
Again, using the ETH–USDT pair as an example: imagine the total liquidity in the pool is one million dollars. A user deposits ten thousand dollars into this pool, giving them a one-percent share of the total. In the case of Uniswap, the transaction fee for any trading pair is 0.3%.
Liquidity providers receive a 0.3% fee from every transaction executed in a trading pair — proportional to their share of the liquidity pool. For example, Alex exchanges five thousand dollars for five ETH in that pair. He pays a 0.3% fee, excluding the Ethereum network fee. This equals fifteen dollars.
These fifteen dollars are distributed among all liquidity providers according to their share in the pool. Thus, Peter receives one percent of these fifteen dollars because his share in the pool is one percent.
As mentioned earlier, users provide liquidity in a fifty-fifty ratio. Therefore, if Peter wants to contribute two thousand dollars of liquidity, he must deposit one thousand USDT and one ETH. For simplicity, we assume that one ETH equals one thousand dollars.
Let’s assume the pool contains ten ETH and ten thousand dollars in total. In this case, Peter’s share is ten percent.
Now impermanent loss comes into play. Suppose that after Peter supplied one ETH and one thousand USDT, the price of ETH increased from one thousand to four thousand dollars. Peter’s share remains ten percent, and he can withdraw only this share — plus the fees earned.
Because the price of ETH increased, the X and Y values in the pool changed, while the product K must remain constant. The pool now contains five ETH and twenty thousand dollars.
Peter withdraws his ten percent share and receives half an ETH and two thousand dollars, totaling four thousand dollars.
At first glance, it seems Peter earned a profit. But if he had simply held one ETH and one thousand USDT instead of providing liquidity, his assets would now be worth five thousand dollars, not four thousand. He missed out on one thousand dollars of potential profit. This is impermanent loss, and in this example it equals twenty percent.
It is important to note that in this example we did not include the fees Peter could have earned while providing liquidity.
Suppose it took two years for the price of Ethereum to rise from one thousand dollars to four thousand dollars, as in the previous example. During these two years, Peter earned one thousand five hundred dollars in fees for providing liquidity. In this case, the impermanent loss of one thousand dollars is fully covered by the earned fees of one thousand five hundred dollars, and Peter’s net profit is five hundred dollars.
Thus, the longer liquidity is provided, the less noticeable impermanent loss becomes, because fees accumulate with every swap in the pair, while impermanent loss depends on price fluctuations of the assets. This can be clearly seen on the graph: accumulated fees grow continuously. Moreover, impermanent loss can completely disappear if asset prices return to the level at which you initially added them to the pool.
That is why it is called impermanent — because it can disappear over time.
What conclusion can be drawn from all of this?
Providing liquidity may be unprofitable due to impermanent loss caused by price fluctuations of one or both assets. But if liquidity is provided over a long period — for example, two to three years — the losses from impermanent loss are, in most cases, fully covered by accumulated fees.
The strongest effect of impermanent loss is seen when providing liquidity to a pool with two volatile assets, such as the ETH–BTC pair. These assets are highly volatile, and impermanent loss in such a pair will be much more noticeable than in a pair where one asset is stable.
For example, if you provide liquidity to ETH–USDT, only ETH is exposed to impermanent loss because the second asset’s price remains stable.
You can also provide liquidity to pairs consisting of two stablecoins. In this case, impermanent loss does not occur at all because both assets maintain a constant value. However, yield in such pools is significantly lower. The choice of pair depends on your risk management and investment approach.
It is important to understand that providing liquidity is not a quick way to make money. Over a long period it can be a profitable strategy, but in the short term it is essential to remember the impact of impermanent loss.
These materials are created for educational purposes only and do not constitute financial advice.
If you want this delivered without the code block, or formatted for GitBook / WIX / X, just tell me.