What is a liquidity pool?
A liquidity pool is a sum of funds locked in a smart contract by liquidity providers (LPs), where anyone can deposit specific assets and obtain rewards for delivering liquidity to that platform.
A single liquidity pool usually integrates two tokens and each pool creates a market for that specific pair of token (e.g. EGLD/MEX, EGLD/USDC).
It is used to permit decentralized trading, borrowing or lending and it usually represents the backbone of a decentralized exchange (DEX). A liquidity pool is the most important component of any DeFi platform and it substitutes the traditional order book model, used by a centralized exchange.
A liquidity pool can also represent the intersection of orders which decides whether an asset will move uptrend or downtrend. The liquidity pool is a very important aspect of automated market makers (AMM), yield farming, borrow-lend protocols, on-chain insurance, synthetic assets, blockchain-based games etc.
What are the existing types of liquidity pools?
There are two types of platforms using liquidity pools:
- Lending platforms – a single asset liquidity pool. The lender will deposit a type of token and will get cTokens, which are derivatives that derive their value from the assets deposited by the lender. A borrower deposits collateral to get a cToken and obtain a loan. In both cases, the transactions are between the lender and a smart contract on one hand and between the borrower and a smart contract on the other hand. Best known such platforms are Compound, AAVE and Maker.
- Decentralized exchanges (DEX) – dual asset liquidity pool. The most popular DEXs are Uniswap, Bancor, Sushiswap and Curve Finance.
What is a liquidity provider (LP)?
Liquidity providers (LPs) contribute with an equal value of two tokens and this way create a market. In exchange for this, they gain trading fees corresponding to the trades that take place in the pool, proportional with their contribution in the total liquidity.
The interaction is this case is between a trader and the liquidity pool, without any other counterparty. If you want to buy an asset, you don’t need a seller of that asset, only enough liquidity in the pool.
When a LP provides liquidity to a pool, they get LP tokens, proportional to the liquidity they provided in that pool. When a trade facilitated by the pool happens, the corresponding fee is proportionally distributed to all the LP tokens holders. When a LP decides to withdraw their liquidity, plus the yielded fees, they must burn their LP tokens.
What’s the mechanism of a liquidity pool?
Specific for a liquidity pool is the constant product equation:
x * y = k
If a pool consists of units in token x and units in token y, any trades would take place in the pool, the quantities in x and y obtained after the trade, if multiplied, remain unchanged and it’s equal to the constant k.
The price of the assets in the pool is established by the ratio between them in the pool. The ratio of the assets changes, but liquidity in the pool remains constant.
A liquidity pool use a constant product market maker algorithm. This makes it possible that the product of the amounts of the two given tokens always remains constant. Thanks to the algorithm, a pool can provide liquidity, no matter how big a trade is. That’s because the algorithm asymptotically increases the price of the most desired token. If a person buys MEX from a MEX/EGLD pool, they reduce the supply of MEX and adds the supply of EGLD, which will lead to an increase in the price of MEX and a decrease in the price of EGLD. Bigger pools mean a smaller move in the price of the contained tokens.
How about the incentives in a liquidity pool?
Rewards can be different, depending on the platform: on a DEX, they could be a share in the trading fee, but on a lending platform they could represent a share of the interest received from the borrowers.
Yield farming or liquidity mining refers to the fact that liquidity pools are used to generate yield. The yielded tokens are first distributed algorithmically to the liquidity providers who contributed to the pool. In the second stage, the newly minted tokens are distributed proportionally to the users.
Some decentralized exchanges started to incentivize LPs with extra tokens for providing liquidity to specific pools, a process which is called “liquidity mining”. Extra tokens serve as a stimulus in creating larger liquidity pools and thus less slippage and a higher quality trading experience.
Minting of synthetic assets is another achievement one can benefit from liquidity pools. Users need to add collateral to a pool and get information about pricing from oracle services. They get a synthetic token, which can be pegged to precious metals, stocks etc.
What is impermanent loss in a liquidity pool?
Impermanent loss takes place when the price of the tokens provided in the liquidity pool changes, compared with the moment they were deposited in that pool. The greater the change is, the greater the impermanent loss. The loss means less value at withdrawal time than at deposit time. Impermanent loss can be minimized by the trading fees in many situations.
e.g. A liquidity provider deposits 1 eGLD and 100 USDC in a liquidity pool. The deposited pair must be of equivalent value, which means that the price of 1 eGLD is 100 USDC at the moment of depositing. The dollar value of the deposit is 200 USD when creating the deposit and let’s assume that there is a total of 100 eGLD and 10,000 USDC in the pool, so the share of the LP in the pool will be 1%. The constant k is 100 * 10,000 = 1,000,000.
Further, let’s imagine a scenario where users swap USDC for eGLD, thus adding USDC and removing eGLD from the pool, until the pool reaches 80 eGLD and 12,500 USDC. In this case, 1 eGLD is now equivalent to 156.25 USDC, the ratio between both tokens will be changed, but the constant k is the same (80 * 12,500 = 1,000,000).
At this moment, when the LP decides to withdraw their funds, the LP will get 1% from the pool (0.8 eGLD and 125 USDC) and the deposit values 250 USD. The profit is obvious, but a loss took place: if they holded 1 eGLD and 100 USDC, the total value could have been 256.25 USD. The impermanent loss is 256.25 USD – 250 USD = 6.25 USD. There are circumstances when impermanent loss can bring big losses and it’s recommended to take this concept into account when providing tokens in a liquidity pool.
If the trading fees for the EGLD/USDC pool are 0.3%, the LP from this example is entitled to 1% of 0.3% of the total value of all successful trades. This way, the impermanent loss is minimized by the trading fees a LP gains by participating to a liquidity pool.
What are the advantages and disadvantages of liquidity pools?
- Anyone can become a liquidity provider if they hold the appropriate asset(s)
- There are no intermediary entities, users can trade directly from their wallets
- Earning transaction fees can be very profitable
- The opportunity to gain yield farming reward tokens
- A liquidity pool doesn’t need a buyer and a seller of a certain asset, but the leverage of a pre-funded liquidity pool.
- In a liquidity pool, trades take place with limited slippage for the pairs involved, as long as there is a large liquidity pool.
- The implementation of insurance protocols is an advantage, because it provides protection if funds are stolen or lost
- Smart contract bugs
- Admin keys
- Impermanent loss
- Systemic risks
- Slippage due to high orders
- The pricing algorithm may fail
How can anyone join a liquidity pool?
The method to join to a liquidity pool differs, according to the chosen platform. You usually must create an account on the platform, connect your wallet and deposit the tokens into the liquidity pool.