DeFi is booming for many reasons. One of the more important factors behind this boom has been the development of the concept of liquidity pools, be it for lending or exchange trading. Liquidity pools rendered the complicated task of order matching obsolete. Liquidity providers offer their liquidity to pools and ear interest in return. The concept is tailor made for decentralized systems and works so seamlessly it’s giving centralized exchanges a run for their money.
This is how pool trading works
There’s two players in pool trading. The exchangers, who use the pools to exchange tokens, and the liquidity providers, who offer their liquidity to the exchangers. In rough terms, liquidity providers are acting like an exchange platform. They earn exchange fees whenever exchangers make use of their liquidity.
Every trading pair is essentially made up of two pools. If we take the ETH/LEND pair as an example, one pool will be made up of ETH tokens, and the other will consist of LEND tokens.
The price is determined by the current ratio of both coins in the pool. Let’s consider for the sake of simplification that we have 1,000 ETH in the Ether pool, and 10,000 LEND in the LEND pool, the price would be equal to ETH/LEND=10.
If somebody wants to add liquidity to the pools, they would have to add both coins at their current ratio, to maintain the same price for the trading pair. So in our case a liquidity provider would need to provide 10 times more LEND than he is providing ETH.
One very important factor to keep in consideration as a liquidity provider is the so called impermanent loss. In order to understand it we have to first look at the math behind pool trading. We assume the liquidity in the pool to remain constant, so no tokens are added or removed from the pool. This wouldn’t change anything for liquidity providers either.
There is a constant “k”, calculated by multiplying the number of tokens in both pools. To keep it with our example, k=1,000*10,000=10,000,000. The price “p” is the ratio of tokens in both pools as already described before, in this case Lend-Pool/Ether-Pool=10. The pool size of Ether can be calculated as “square root(k/p)”, and the size of the Lend-Pool would be “square root (k*p)”.
We assume that the price of LEND is halved, while ETH is able to keep the same price. The market price ratio will be ETH/LEND=20, whereas the price in the pools is still ETH/LEND=10. Traders and bots will use this to readjust the price in the pools through arbitrage. In this case they would add LEND to the pool and buy ETH, because they can get 20 LEND for their ETH on the free market, which they would then exchange for 2 ETH. After this readjustment the ETH pool size will be: “square root(k/p)”=707.1 ETH, and the LEND pool size will be: “square root(k*p)”=14,142.13.
By comparison, both pools were worth a combined 2000 ETH prior to the change in price. After the price change the total value in both pools will become 1414.2 ETH. Liquidity providers always hold the same percentage of the pool. So in this case, a liquidity provider would lose about 30% of his original ETH value if he tried to withdraw his liquidity.
The loss is call impermanent because it is made up for later when the price increases. The same happens in the opposite direction. So when the token price increases, the total value of the pool would increase.
Because of this, it is important to choose which tokens to provide in liquidity pools. If the token’s price drastically loses value, it will be difficult to make up for the impermanent loss with the earned fees.
With the follwing formula you can calculate impermanent loss:#
The positive x show the current value of the invested capital in relation to the value of the invested capital at the time of the investment in %. If the difference is 50% i.e. or the value of one token is halved in comparison to the other, the liquidity provider’s capital will have only 94.281% of the value at the time of the deposit, then he will lose around 5.72%.
The negative x indicates the increase in the price of the token in %. 50% loss is the same as 100% gain. We get the same result for 100x/(x-100) as for x. For example if we put 50 in the formula we will get the same result as if we put -100 (the same proportional price change).
The interest on Uniswap or similar liquidity pool exchanges on other blockchains, e.g. Defibox on EOS, are very high for certain trading pairs. Yearly interest of 100%+ are not necessarily a rarity. But how can it come to such high interest values?
First off, the field is fairly new, and many still don’t know what liquidity pools are or how high the interest is. Furthermore, providing liquidity comes with risks, since it’s still new and prone to mistakes. A larger mistake in the code could mean total loss for users. Pool trading has advantages when compared to CEXs, all the tokens can be listed fairly easily, there is no KYC requirement and the costs are low when not considering transaction fees. Therefore, many trade on pool trading platforms which generates high interest in the form of fees.
This interest should in theory adjust over time and drop significantly, since more investors will want to use them to generate fees. With more liquidity in the pools the interest rate falls, since the collected fees will be divided on more staked capital.