In my last article, I wrote about Wallstreetbets.com and providing liquidity. I thought I would dive deeper into what liquidity pools are, providing liquidity, and why it is important to a decentralized exchange (DEX).
Liquidity Pools
Liquidity pools are probably the most important aspect of a DEX. Really, without liquidity pools, you really don't have a DEX, as the ability to trade on a DEX requires them. A liquidity pool is a pooling of investors that have created liquidity pairs on the DEX. Examples would be ETH-USDT, BAT-USDC, ETH-BAT, and so on. If an investor goes on a DEX and wants to swap ETH for USDT there has to be enough liquidity to allow the trade or a method to convert the crypto for the trade. For example, an investor has 2 ETH and wants to swap to USDT, but there isn't an ETH-USDT pool. There is an ETH-BAT and USDT-BAT pool, so in order to swap from ETH-USDT, the investor will pay for two transactions, swapping ETH to BAT and then BAT to USDT. This is not opportune, as the principal way liquidity pool investors make money is through receiving fees. These fees vary from DEX to DEX. As the investor surely doesn't want to pay for two transactions, the DEX should also have an ETH-USDT pool with enough liquidity to allow trading as one transaction.
Liquidity Pairs
In order to create a liquidity pair to add to a liquidity pool, the investor needs equal amounts of each crypto they want to pair. If an investor had 1 ETH worth $3,000 and they wanted to pair it with USDT worth $1.00, they would need 1 ETH and 3,000 USDT. This will allow the pairing which also adds to the pool. When a liquidity pair is created on a DEX, it automatically is part of the overall liquidity pool and therefore immediately earning passive income per trade. Using the previous example, if the investor's pair accounted for 1% of the overall pool, they will receive 1% of the liquidity provider fees generated with each transaction. Liquidity pairs do not normally stay equal (As in the liquidity provider will not always be holding 1 ETH and 3,000 USDT if they destroy the liquidity pair). This is due to the nature of buying and selling within the pair.
Let's look at an example:
Investor A has one ETH worth $2,075.16 and they wish to pair it with USDT which is worth $1.00, to create the liquidity pair the investor would need one ETH and 2,075.16 USDT, totaling $ 4,150.32 US in value. Investor A is the sole investor in the newly created ETH-USDT liquidity pool. The DEX allows liquidity providers, Investor A, in this case, to earn a 0.3% fee on all trade proportional to their share of the pool.
When the liquidity pool is created, a calculation is executed solving for K:
X * Y = K
• X = ETH
• Y = USDT
• K = Constant Product
Therefore, with the addition of one ETH and 2,075.16 USDT:
1 * 2,075.16 = 2,075.16
The Constant Product K will not change unless liquidity is added or removed.
If Investor B wants to swap ETH for USDT, they will be creating a swapping transaction which will reduce their ETH by a calculated number and increase their USDT by 100 USDT. To complete the swap, Investor B must first approve trading ETH with the WSB DEX. This approval generally does not need to be given again after the initial approval. Upon giving approval Investor B may then click “Swap”. Under the “Swap” button is information on the transfer. The Liquidity Provider Fee reflects the fee Investor B shall pay to the liquidity pool. The fee is reflected in ETH, as it is the token Investor B is swapping. This fee represents the 0.3% fee paid to liquidity providers. As Investor A is the sole holder within the liquidity pool, that investor will receive the entire fee. If there were multiple liquidity pool investors, the fee would be divided to each investor based upon their percentage of holding.
The determination of the ETH price of buying 100 USDT is shown below. It is important to understand the Constant Product K must stay the same, therefore a new calculation is executed solving for x:
(A + x) * (B – C) = D
- A = Total number of Tokens in the additional pool (ETH)
- B = Total number of Tokens in the subtraction pool (USDT)
- C = Tokens to be purchased
- D = Constant Product
(1 + x) * (2,075.16 – 100) = 2,075.16
1 + x = 2,075.16 / (2,075.16 – 100)
1 + x = 2,075.16 / 1,975.16
1 + x = 1.05062881
x = 1.05062881 - 1
x = 0.05062881
In order for Investor B to buy 100 USDT, they have to pay 0.0506881 ETH. By doing this, Investor B is keeping the liquidity pool equal. At the end of the swap, the liquidity pool will have 1.0506881 ETH and 1,975.16 USDT. Using the Constant Product formula:
1.0506881 * 1,975.16 = 2,075.16
The value of the liquidity pool has changed as well. ETH is now worth $2,180.34592 and USDT is worth $1,975.16, bringing the value to $4,155.50592. In the swap Investor A made $5.1859176.
Investor A has a good night’s sleep and wakes up to find out that the price of ETH has reduced from $2,075.16 to $2,062.05. USDT’s value did not change from $1.00 due to it being a stable coin. Looking at their investment, Investor A now reviews their totals and finds their ETH is now worth $2,166.5714 and the USDT is still worth $1,975.16, bringing their value to $4,141.7314. The initial investment was worth $4,150.32 and is now worth $4,141.7314, resulting in an $8.5886 loss. Therefore, Investor A understands their investment has lost value, but only due to the lower price of ETH. This is impermanent loss in motion.
Impermanent Loss
Impermanent loss is the situation where just holding crypto would earn the investor more value than putting the crypto in a liquidity pairing. The reason for this is the loss in value of one of the paired crypto. As you can see, with each transaction you will gain and lose from the pairs. If for example, you had 1 ETH worth $2,500 and 2,800 BAT worth $2,500 and over time people were selling a lot of BAT for ETH, you may send up with .95 ETH. If the value of ETH went up in value to $2,800, the holding would have brought your value up to $2,800, however, due to the pairing you only have .75 ETH valued at $2,100. So you have effectively lost $700 in value. If BAT went up in value from $0.89 to $1.25 and from the pairing you have 3,500, that BAT is now valued at $4,375. In this case, while you lost $700 on ETH you gained $1,875 in BAT, therefore you have gained $1,175 from liquidity pairing. On the other hand, if the value of BAT went down from $0.89 to $0.75, your BAT would be worth $2,625. In this way, while BAT reduced in price, you gained $125, reducing your overall loss from $700 to $575.
One way to reduce the risk of impermanent loss is by pairing with a stable coin. Stable coins are coins that try to maintain the value of their respective currency such as USDT and USDC are pinned to the US dollar. The safest pairing would be stable coin to stable coin, such as USDT-USDC. This will provide the fees without the loss.
Okay, so it is complicated. It seems risky. Why not just hold? Why even deal with liquidity pools? Well, if you believe in a project the best way to support the project is to provide liquidity. You do earn a percentage on fees and that is a good thing. Also keep in mind impermanent loss is not permanent. Permanent loss is when you break up the pair and sell the crypto. The key to crypto is holding. Selling at the high end and buying at the low. Think long term investment. Putting your crypto in a liquidity pool provides passive income 24 hours a day, 7 days a week and generates fee payments per transaction. Remember, the crypto market never sleeps.