Liquidity Pools - A beginner's guide

Do repost and rate:

Do you really know what a liquidity pool is or how it works? You may be a 'King of Crypto Trading' but you might not be aware of what a liquidity pool really is, how it operates or why is it important in the crypto industry. With this article, I would like to share some information about liquidity pools so that you can understand it better without having to look somewhere else. Do note this is a long article and I recommend watching this video by Whiteboard Crypto to have a visual understanding if you prefer that format.

TLDR version: Liquidity pools are just pure code, i.e., smart contracts that allow traders to trade tokens and coins, even if there are no buyers or sellers. They are able to do so because of an algorithm known as Automated Market Maker which dictates the price at which a sale can happen. People who invest money in a liquidity pool is known as liquidity providers.

Let's understand it in details

How traditional stock markets work

Before going into the liquidity pools, it is essential to understand how the traditional stock market works so that we can draw parallels with it because essentially cryptocurrencies are being traded like stocks. A traditional stock market works on something known as - Order Book Model. What is it? In this model, buyers and sellers of various stocks or securities, simply write down how much of which stock they are willing to buy or sell at what price. The order book collects all the details and when it finds a buyer's bid meeting a seller's ask, then a trade happens. Buyer gets the stock and the seller gets the money. Both the parties are happy.

But this model is inefficient for many reasons. First, a buyer needs to set a price at which some seller is selling a particular stock. There are methods to simply put up a price and wait for the stock price to rise/fall but if the buyer wants to get it immediately, then that person has to comply with the price the seller sets. That's not all. Stock market opens in the morning at around 9:30 AM and closes in the evening at around 3:30 PM. No trading can happen post this timing. Also there is another catch, a stock can only be bought, if someone is selling it. If there are no sellers, there are no stocks for the buyers to buy. This limits both the buyers and sellers with their capabilities. So what is the solution?

Enter Liquidity Pools

Liquidity pools are brought forward to the world with the invention of blockchains and smart contracts which enabled the functioning of decentralized exchanges. Essentially a liquidity pool is a smart contract, which uses an algorithm to facilitate trade between between buyers and sellers such that anyone can always buy or sell assets no matter how high or low the price is, no matter what time of the day it is or no matter whether there is a buyer or seller to execute the trade.

How does this happen? Well, as mentioned before, the liquidity pool uses an algorithm to do this functioning automatically. In most of the cases, the algorithm that is used is known as Automated Market Maker algorithm, or to be specific - constant product automated market maker algorithm. Automated Market Maker or AMM is a type of algorithm that allow traders to buy or sell certain coins or tokens by dictating how expensive that asset should be based on how much of it there is. In layman's terms, this means that if a lot of people buys a lot of asset X from the pool, then the quantity of that asset in the pool becomes less than before and it will drive it's price higher making it more expensive. Similarly, if a lot of people sells a lot of asset Y to the pool, then the quantity of that asset in the pool increases which will drive the price down making it more cheaper than before. This is a simple case of 'Supply and Demand'.

That's a lot to take in but let's understand it better with some detailed explanation and examples. I recommend watching this fantastic video made by this YouTube channel - Whiteboard Crypto (I am not affiliated to them in anyways) which explains everything there is to know about AMM. Definitely check it out if you want visual explanation.

Automated Market Maker (AMM)

Let's go into an example and it is going to be a long one but please bear with me -

Imagine there is an island X where all the farmers in the island grows potatoes and nothing else. The island produces a lot of potatoes but no one is interested in buying it since every household produces apples. The farmers in the village wants to their potatoes for something else like apples. Suddenly, there arrives a trader in a ship and that person tells the farmers of the island X that there is another island Y where all the farmers produce apples. The trader invites the island X's farmers to invest in a trade between both the islands such that they can exchange potatoes for apples. Happily the island X's farmers agreed.

The trader informed them that island Y's farmers have put up 50,000 apples to the 'Apple - Potato trade business'. If the island X's farmers wants to participate, they will have to put up 50,000 potatoes to get things started. They did so. So now, the trader stored 50,000 apples and 50,000 potatoes in the ship's super secure store rooms where the produce doesn't get spoiled and will stay evergreen. Now this trader has got a strict accountant who wants to keep a perfect ratio of value, 50:50 for both these produce. So the accountant said in order to keep the perfect ratio between potatoes and apples as 50:50, when produce X (potatoes) is multiplied with produce Y (apples) it should be always equal to K, 2.5 billion (50,000 X 50,000 = 2,50,00,00,000). This way, if the number of a product is less during a harvest season, that product will become more expensive to buy.

The accountant continues and states that there are at the moment a perfect 50:50 ratio of potatoes to apples because this person has priced them at $1 each. He warned that when these products are being traded, one of them will become more valuable than the other and then it should be priced more than a $1. As he was talking about it, there came a farmer from island X with 7000 potatoes. The farmer gave his potatoes to the trader hoping to get apples in return. Trader asked the accountant to do the calculation and return apples to the farmer. So the accountant started his work. There were 50000 potatoes and 50000 apples in the pool. Now there are 57000 potatoes in the pool and the number of potatoes multiplied by the number of apples should be 2.5 billion. So he divided 2.5 billion with 57000 in order to get the number of apples there should be in the pool in order to keep the constant at 2.5 billion and he got a result of 43859. So from 50000, 43859 apples should remain in the pool and the remainder, i.e. 50000 - 43859 = 6140 can be given to the potato farmer in exchange for his potatoes. 57000 multiplied by 43859 gives 2.5 billion so the formula remains unchanged.

Why did he get less apples (6140) for his 7000 potatoes? Well, by putting in 7000 more potatoes to the pool, he increased the amount of potatoes in the pool thereby driving it's price lower, i.e. 50000/57000 = $0.87 per potato. He was hoping the accountant would price the potatoes at $1 per potato but the increase in supply lowered it's price and it drove up the price of apples, i.e. 50000/43859 = $1.14 per apple, because the number of apples reduced after the accountant gave some to the potato farmer. So, he got less apples for his potatoes as apples became more expensive than potatoes.

Now another potato farmer brings in 10000 potatoes to the pool to get apples in return. This will drive up the price for the apples even higher because the pool is getting more & more potatoes and apples are given away reducing it's supply driving up it's demand. So the total potatoes became 67000 from 57000. 2.5 billion divided by 67000 = 37313 apples should remain in the pool. That means the second potato farmer would get 43859 - 37313 = 6546 apples. This is even lesser than what the first farmer got! That's how the liquidity pool works. The price is inversely proportional to the available amount of the product, i.e., the lower the amount of product, the higher it's price and vice versa. That means now the price of each potato has become $50000/67000 = $0.75 and price for each apple is $50000/37313 = $1.34. At the end of the day, there will be $50000 worth of potatoes and $50000 worth of apples in the lot.

This is exactly how an automated market maker algorithm works. In this analogy, the farmers are users who wants to buy or sell various assets, the trader is the liquidity pool and the strict accountant is the algorithm. The formula the 'accountant' used is an oversimplified formula the constant product automated market maker algorithm uses to facilitate trade in the liquidity pool, which is X * Y = k where X and Y are the assets that it has to trade and k is a constant which always has to remains the same in order to facilitate the trade.

How does a liquidity pool works

A liquidity pool typically contains 2 or more assets to trade for. For the sake of simplicity, let's assume there are only two at the moment. Let's consider ETH and SHIB as these two assets in the liquidity pool. A liquidity pool is essential a smart contract written in a way to hold certain funds (in this example ETH and SHIB), do some math with the funds and let the users trade based on the outcome of the math that it did. The pool starts off with both ETH and SHIB is 50:50 ratio. That means if a user wants to put in $1000 into the pool, that person needs to put $500 worth ETH and $500 worth SHIB (it's not the amount of coins, it's the value of the coins). As stated before, the pool is governed by constant product automated market maker algorithm. As the users slowly buy or swap more and more SHIB coins by giving the pool ETH, the value of SHIB rises as each sale goes by. For example - the first sale might have happened at $1.20. The second one would be at $1.20 and 1/10 of a penny and so on; the hundredth sale, going by the trend, would happen at $1.50. Why? because the value increases exponentially as discussed in the previous paragraph. As more and more SHIB exists the pool, the available amount of SHIB decreases which will increase it's price based on the formula = X * Y = k in order to keep the perfect 50:%0 ratio of ETH and SHIB. Also note that every transaction in a liquidity pool comes with a tax which is generally a very small percentage of the trade. We will discuss what it is being used for in a minute.

An example of a liquidity pool is - Uniswap. Uniswap allows the trade almost any ETH token for any other ETH token for a small fee. Now let's see another example. What if we have a bunch of SHIB tokens and instead of ETH, we want GRAPH tokens which is not in this liquidity pool? Well most of the decentralized liquidity pools allows traders to perform this trade by connecting with another liquidity pool which sells GRAPH token. This usually happen with multiple swaps i.e., first pool A will take SHIB tokens and convert it to ETH, then swaps this ETH with GRAPH token in pool B and gives this GRAPH tokens to the user. Technically this is known as - routing. This allows a decentralized liquidity pool to exchange any token for any other tokens by routing the trade requests to appropriate liquidity pools even if they don't trade that token.

Investing in a Liquidity Pool

Anyone can be an investor in a liquidity pool. When someone puts money in a liquidity pool, that person is refereed to as a liquidity provider. Remember how each trade costs a small fee or tax? When more and more people trade on a liquidity pool, those fees begin to add up and where does it go? It goes to the liquidity providers, for providing that 'liquidity' for the traders to trade, based on how much money each of them have put up. Some decentralized exchanges offer up to 500% APR or Annual Percentage Rate to the liquidity providers because they make so much money by trading and there aren't many liquidity providers in the market as the crypto market is yet to reach out to a lot of people. As more and more people joins the pool, this rate comes down which is fairly expected.

As the pool grows in liquidity, i.e. as money money is put in to the liquidity pool, it takes much more money to move the price of the assets. For example, let's say in a $2000 liquidity pool if someone swaps $500 of ETH tokens for SHIB tokens, this will drive up the price of SHIB drastically, because they took out a lot of SHIB from the pool. But if the same happened in a $5,00,000 liquidity pool, this $500 swap barely dents the price because there is a lot of SHIB to be swapped with compared to the $2000 liquidity pool. This can be better termed as 'price impact', which refers to how much a liquidity provider can impact the price of a token within a liquidity pool. Price impact inversely depends on the size of the liquidity pool - smaller the pool, bigger the price impact; bigger the pool, smaller the price impact. When the pool grows, the price impact gets smaller and thereafter large buy-ins doesn't affect the price much.

Another thing worth mentioning about liquidity pools is - Arbitrage Trading. What is it? Well, say there is small liquidity pool of $2000 which trades in ETH and SHIB where 1 ETH = $500 and 1 SHIB is $1. If someone brought in a lot of ETH and swapped them for SHIB, in that particular pool, the price of ETH drops to say $450. Even if this person has to pay the small trading fee, they can buy ETH for $450 a piece and immediately sell it on other exchanges where it is priced at $500 thereby making $50 on 1 ETH. This is known as arbitrage trading. It sounds shady but it is allowed to happen so that the price of the assets remain the same across all the liquidity pools. After one trade, as the quantity of ETH lowers, the price stabilizes. They are also paying the fees so it is perfectly okay to do so.

There are some cons associated with liquidity pools. Two of the major ones are - impermanent loss and rug pulls. Decentralized liquidity pools are also vulnerable to various hacks as they are decentralized in nature. We will talk more about such in another article.

Examples of Liquidity Pools

The following are some examples decentralized liquidity pools:

  • Uniswap
  • SushiSwap
  • PancakeSwap
  •  

 

 

 

 

Regulation and Society adoption

Ждем новостей

Нет новых страниц

Следующая новость