To better explain how a Liquidity Pool works it is a good idea to talk about some points first.
I will try to explain a bit about the subjects below. If you already know enough about any of them you can skip to the next.
- Centralized Exchanges (CEX) and Order Book
- The concept of Liquidity
- Decentralized Exchanges (DEX)
- Liquidity Pool
- How the Liquidity Pool (LP) is created
- How the Liquidity Pool works and how it prices token/coins
There is a debate about cryptocurrencies being a security or not.
In this text I will consider any cryptocurrency, token, coins, etc., as securities for simplicity.
Centralized Exchange is basically a place where you go when you want to buy or sell a security.
Their job is to make people willing to buy a security and people willing to sell that security to meet each other.
If I want to buy Apple stocks using Dollar in my account, I can go to Charles Schwab (a Centralized Exchange) and check what the Apple's stock price is. At what price people are willing to buy this stock (and how much they want to buy) and at what price people are willing to sell it.
In the CEX they compile all the buy and sell orders and organize it in what we call an "Order Book".
An Order Book is a list of all the buy and sell orders (with prices and volumes) organized by prices.
Let's say Investor A places a Buy Order to buy 100 shares of Apple at $125, Investor B places a Buy order to buy 200 shares at $125 and Investor C places a Buy Order of 500 shares at $124.90.
At the same time, Investor D place a Sell Order to sell 300 shares of Apple at $125.20 and another 100 shares at $125.25 and Investor E places a Sell Order of 500 shares at $ 125.30.
The Order Book will look like this:
if, for instance, you wanted to buy 100 shares of Apple you could go to that Exchange, check the market prices and decide wheter you want to place an order to buy Apple at any price you want or even to close the deal at the best Ask Price (in this case, 125.20).
So you could:
- Place a Buy Order to buy 100 shares of Apple at $125.10, for example. The Order Book would then look like this:
- Or if you were not in a rush to buy it, you could try to buy it at an ever better price. Let's say 124.50. So you would place a Buy Order of 100 shares at $124.50 and the Order Book would look like this:
- Or you could just close the deal at the best Ask Price (125.20). You would buy 100 shares at $125.20 from Investor D and the Order Book would look like this after the transaction:
When you buy a security you expect two things (among others less important):
1- That the price of your security will go up so you will be able to profit.
2- That there will be people willing to buy your security whenever you want to sell it.
In the classic financial market, you have multiple Centralized Exchanges (CEX) around the world, trading all kinds of securities. Most of them have enough liquidity for you to trade.
The typical definition of "liquid" or "liquidity" is close to the Investopedia's:
"Liquidity refers to the ease with which an asset, or security, can be converted into ready cash without affecting its market price."
Well, I will give you my personal definition:
Liquidity for me is when I want to buy (or sell) a security and:
1- The spread is small.
Spread is the difference between the ask (price that the sellers is willing to sell the security) and the bid (price that the buyers is willing to buy the security).
2- There's enough contracts in the market to fulfill my order at a "fair price" (more on this below).
Let's go back to our Apple example but now I want to sell 1,000 shares of Apple that I bought a while ago for $100 each. I go to that Centralized Exchange and check the market prices.
Scenario 1, remembering our order book:
Well, the spread (difference between the best ask and the best bid prices) is pretty fair. 20 cents, which is about 0.16% of the stock price. Very good!
But if I want to sell the 1,000 shares of Apple, there won't be enough buyers at the best bid price (notice there's only 300 shares at the bid price of $125.00).
In this case, I still could sell 500 shares at a price of $124.90 (the second best bid price).
But, as the Order Book is right now, I would not be able to sell all my 1,000 shares of Apple. In this case, I would say that the Apple's market is not liquid because there's not enough buyers for all my 1,000 shares.
Scenario 2, a new hypothetical Order Book:
Well, for sure there are enough shares being bid to fulfill my will to sell 1,000 shares now.
But check the prices! If you want to sell Apple, you'll have sell it at a price of 90.00. On the other hand, if you want to buy Apple you'll have to do it at a price of 150.20 (67% more expensive!!!!).
For sure this market isn't liquid! The spread (difference between best ask price and best bid price) is too large ($60.20) compared to the "fair price" (let's say $120.10 - the mid price).
Two subjectivities to highlight:
a) The "fair price" is subjective.
Some consider it as being the mid price between the ask and bid prices. In our example, 125.10 -> (125.20 + 125.00)/2.
Some consider it as being the last price traded.
b) How far your weighted average has to be far from the "fair price" for the market to be considered iliquid? 1%? 2%? To be honest, there is no rule for this. But of course you want your weighted average price to be as close as possible to the “fair price”.
Not all securities are listed on Centralized Exchange (for several different reasons not worth mentioning here).
A new token just launched on the market, for example, usually is not directly listed in a Centralized Exchange. There are several conditions that have to be met for a CEX to list a token.
What can we do when we want to trade a security (let's say, a token) that isn't listed in a CEX?
Well, that's where the Decentralized Exchanges (DEX) come to scene.
DEX's are able to provide liquidity to people willing to buy or sell a security. And it does it through its Liquidity Pools.
Before we dive into the next topics ("Why we need a Liquidity Pool in the Decentralized Exchanges", "How the Liquidity Pool (LP) is created" and "How the Liquidity Pool works and how it prices token/coins"), I would like to explain the main difference between CEX's and DEX's.
Remember that one of the Centralized Exchanges' jobs is to put together buyers and sellers of same security?
That means that the Exchange itself only intermediate the deal between buyers and sellers.
When you buy a security in a CEX, you are buying it from another investor. The Exchange facilitates it through its platform (among other things they do, of course).
In a Decentralized Exchange, when you want to buy a token, you buy it FROM THE EXCHANGE, NOT FROM ANOTHER INVESTOR LIKE YOU.
Same thing when you want to sell a token in a DEX. You sell it TO THE EXCHANGE, NOT TO ANOTHER INVESTOR.
So if you want to buy a token in a DEX and who will be selling it to you is the DEX itself, it has to have some of that tokens in its possession (it can't sell what it doesn't have, right?!).
On the other hand, if you wanna sell a token in a DEX and who will be buying it from you is the DEX itself, it has to have in its possession whatever currency you want in exchange for your tokens, right?
That is where the Liquidity Pools come in.
If a DEX offers to trade, for example, Bitcoin against BUSD (so you could buy Bitcoins with your BUSD or sell your Bitcoins for BUSD), it has to have Bitcoin and BUSD in its possession.
And the place where those are allocated inside the DEX is the Liquidity Pool.
A Decentralized Exchange can offer several different pairs to trade, like Bitcoin x BUSD, Bitcoin x USDT, ETH x USDT, Safemoon x BNB, etc...
For each pair offered, the Exchange has to have a Liquidity Pool for that specific pair:
- A Liquidity Pool with Bitcoins and BUSD (for trading Bitcoin against BSUD)
- A Liquidity Pool with Bitcoins and USDT (for trading Bitcoin against USDT)
- A Liquidity Pool with ETH and USDT (for trading ETH against USDT)
- A Liquidity Pool with Safemoon and BNB (for trading Safemoon against BNB)
HOW IS THE LIQUIDITY POOL CREATED?
I will try to explain this using a hypothetical example where I create a token, sell it to private investors in a private sale and then list it on a DEX for them to be able to sell their tokens and for new investors to be able to buy the tokens.
* IMPORTANT: All the numbers here are hypothetical! It doesn't mean that all the tokens in real life are launched or listed this way. Much less that the percentage of tokens that goes to the Liquidity Pool is the same I will use here as example. This is just to illustrate the idea!
All right, pretend I created a token and:
- It is called BHM Token.
- I will not keep any tokens to myself. Not BHM's. Not any of the tokens I'll receive for selling those BHMs on the private sale.
- I will issue 100,000,000 tokens (that's the Initial Supply).
- The smart contract doesn't allow minting (issuing) new tokens. This means that the Total Supply will never be larger than 100,000,000 tokens. It can be (and will be in our example) smaller, but never larger.
- I already have some investors interested in buying my new token (otherwise I would have to go to a Launchpad or Pre-Sale Platform to find those investors).
Before I start the private sale and the launch of my token, I have some decisions to make:
- What other crypto will I accept for selling BHM tokens?
-> Let's say I'll use BUSD.
- How much will cost each BHM Token on the private sale?
-> In this example, I'll charge 1 BUSD per BHM Token on the private sale.
- How many tokens will I sell on the private sale?
-> Let's say 50,000,000 (half the Initial Supply).
* If I sell the whole supply (100.000.000 tokens) to those investors I will not have any tokens to add to the DEX's Liquidity Pool. In this case, if a new investor wants to buy the token he won't be able to do it, since the DEX would have no token to sell. And since the token is not listed in a CEX, he wouldn't be able to meet the first investors to buy the token from them. So I need to keep some tokens so I can add it later to the Liquidity Pool in a DEX!
- What will be the Initial Price of BHM Token in the Exchange.
-> I our example, I will launch it at 2 BUSD per BHM (twice as expensive as in the private sale).
- What will be the size of the Liquidity Pool (how many BHM tokens I will add to the Liquidity Pool compared to the supply of tokens in circulation).
This percentage varies among different tokens.
The higher the percentage in the LP, the smallest the impact on the token price on each trade.
The smaller the percentage in the LP, the larger will be this impact.
-> In this example, I'll add initially 33.3333% of the Total Supply on the Liquidity Pool.
Let's do the step-by-step of this process:
Step 1- I code the Smart Contracts.
Step 2- This Smart Contract issues 100,000,000 of a token called BHM Token.
Step 3- I sell 50,000,000 of those tokens for interested investors for 1 BUSD each. This means I will receive 50,000,000 BUSD.
3.1- At this moment I will have in my wallet: 50,000,000 BHMs (the ones not sold) and 50,000,000 BUSD.
* This actually is usually done automatically by the smart contract. I'm "doing" it manually here just to illustrate!
3.2- On the other hand, at this very same moment investors around the world will have, collectively, 50,000,000 BHMs in their wallets.
Step 4- The next step is to add BHM and BUSD Tokens in the Liquidity Pool in a DEX, so people can buy and/or sell it in that DEX.
4.1- Remember I said I will not keep any BUSD with me? Well, that means that I will have to add the whole 50,000,000 BUSD in my wallet now to the LP.
4.2- Also, remember that the Initial Price I decided to launch the token on the DEX was 2 BUSD per BHM. This means I have to add 25,000,000 BHM Tokens to the LP.
* The initial ratio between BUSD tokens and BHM Tokens will set the Launch Price at the DEX. So by adding 50,000,000 BUSD and 25,000,000 BHMs makes the Initial Price at the DEX to be 2 BUSD per each BHM Token.
So after all this transactions, the tokens are distributed like this:
- 50,000,000 inside initial investors' wallets
- 25,000,000 inside the LP
- 25,000,000 inside my wallet
- 50,000,000 inside the LP
Now, as Dave Matthews would say, "Remember two things":
1- I don’t want to keep any token in my wallet.
2- I want the Initial LP to have 33.3333% of the Total Supply of BHMs.
With this, I have two problems right now:
1- I have 25,000,000 BHM tokens in my wallet (I had 50,000,000 but added 25,000,000 to the LP), when I wanted to have none.
2- The percentage of BHM tokens in the LP is 25% (when I wanted it to be 33.33333%), afterall there's 25mm tokens in the LP, 50mm tokens in investors' hands and 25mm in my wallet.
That leads us to Step 5!
Step 5- To solve both problems listed above I will burn the 25,000,000 BHM Tokens in my wallet. When you "burn" a token, it goes to the "black hole" of the blockchain. Nobody can ever touch or trade those tokens again. It is like you literally burned a $100 dollar bill… It's over!
Let's check now if everything is ok:
- 50,000,000 inside initial investors' wallets
- 25,000,000 inside the LP
- 25,000,000 burnt
- 50,000,000 inside the LP
1- There's no token in my wallet. Check ✓
2- The Initial Price at the DEX should be 2 BUSD per BHM Token. Since I added 50mm BUSD and 25mm BHM, this ratio sets the price at 2 BUSD per BHM. Check ✓
3- The Initial LP has 33.3333% of the Total Supply of BHM Tokens. Remember that it has 25mm BHMs and the Total Supply now is 75mm (since I burned 25mm).
25,000,000 / 75,000,000 = 33.3333%... Check ✓
All right! Everything is set now for the trades to start!
Now the fun begins. All I have written above was only an introduction to how the LP works and how it prices the token... Sorry for that!
HOW THE LIQUIDITY POOL WORKS AND HOW IT PRICES TOKEN/COINS
First of all, it's worth mentioning that there are several different models being used on the DEXs.
The one I'll talk about here is the most simple one and the easiest to understand. And although the other models are more complex, the basic idea is pretty much the same.
So, the most used model for Liquidity Pools states the following:
"The quantity of one of the tokens in the trading pair in the LP (in our example 25,000,000 BHM Tokens) times the quantity of the other token in the LP (in our example 50,000,000 BUSD) must be constant (in our example 1,250,000,000,000,000, which is 25,000,000 * 50,000,000).”
This means, in our example, that if an investor wants to buy BHM Tokens from the LP, he will have to send BUSD to the LP in exchange for those BHM Tokens in a way that the final quantity of BHM Tokens in the LP times the final quantity of BUSD in the LP equals our constant (1,250,000,000,000,000).
The same way, if he wants to sell BHM Tokens to the LP, this investor will receive BUSD from the LP for the BHM Tokens he sold in a way that the final quantity of BHM Tokens in the LP times the final quantity of BUSD in the LP equals our constant (1,250,000,000,000,000). Just like above!
Let's see some examples:
OBS: We will call #BHM the quantity of BHM Tokens in the LP and #BUSD the quantity of BUSD in the LP.
The LP has just launched on the Decentralized Exchange, so it has 25,000,000 BHM Tokens and 50,000,000 BUSD.
Investor A wants to buy 100,000 BHM Tokens.
How much will the DEX's LP charge him in BUSD for these tokens?
After the transaction, the LP will hold 24,900,000 BHM Tokens (25,000,000 that were in LP initially minus the 100,000 BHM tokens Investor A will buy), right?
How many BUSD the LP will have to hold after the transaction? Right now, we don't know but we know the this quantity times 24,900,000 must be equal to our constant (1,250,000,000,000,000).
So if we call the final quantity of BUSD in the LP after the transaction as X, we can calculate X as follows:
24,900,000 * X = 1,250,000,000,000,000, so X must be 50,200,803.21285141.
Since the quantity of BUSD before the transaction was 50,000,000 and the final quantity of BUSD must be 50,200,803.21285141, Investor A must pay the difference (200,803.21285141 BUSD) to the LP.
Let's illustrate it:
What was the price paid by Investor A for each BHM Token he bought?
He bought 100,000 BHM Tokens for 200,803.21285141 BUSD.
This means that each BHM costed him 2.0080321285141 BUSD.
Notice that the price went up because of his purchase of BHM (it was initially 2 BUSD per BHM and he paid 2.0080321285141).
The prior trade affected the quantity of BHM and BUSD token sin the LP. Now it holds 24,900,000 BHMs and 50,200,803.21285141 BUSD.
Investor B wants to buy 1,000,000 BHMs. How much will it cost him?
The #BHM before the transaction in the LP is 24,900,000 and if Investor B really buys 1,000,000 BHM Tokens, the final #BHM in the LP will be 23,900,000 (24,900,000 – 1,000,000 = 23,900,000).
The #BUSD before the transaction in the LP is 50,200,803.21285141 and the final #BUSD in the LP after the transaction has to be equal to 52,301,255.23012552 (so that #BHM * #BUSD = 1,250,000,000,000,000 -> our constant).
If the final #BUSD in the LP must be 52,301,255.23012552 and now it is 50,200,803.21285141, it means that Investor B must pay the difference, 2,100,452.017274113 BUSD, for his 1,000,000 BHM Tokens.
Finally, what was the price paid by Investor B for each BHM he bought?
Easy: 2,100452017274113 (2,100,452.017274113 BUSD / 1,000,000 BHM = 2.100452017274113 BUSD / BHM).
Notice that each time someone buys BHM, the price of BHM goes up.
Let's now see what happens when someone sells BHM.
Investor C wants to sell 5,000,000 BHM tokens (that he bought at the BHM Token launch).
The #BHM Token before this transaction is now 23,900,000 and if Investor C really sells his 5,000,000 BHMs, the final #BHM in the LP will be 28,900,000 (23,900,000 + 5,000,000 = 28,900,000).
The #BUSD before this transaction is now 52,301,255.23012552 and if Investor C really sells his 5,000,000 BHMs, the final #BUSD must be 43,252,595.15570934 (so that #BHM * #BUSD = Constant or 28,900,000 * 43,252,595.15570934 = 1,250,000,000,000,000).
If the initial #BUSD was 52,301,255.23012552 and after the transaction the final #BUSD must be 43,252,595.15570934, that means the LP will pay 9,048,660.074416177 BUSD (52,301,255.23012552 – 43,252,595.15570934 = 9,048,660.074416177) for the 5,000,000 BHMs Investor C is selling.
The price in this transaction will be 1.809732614883235 (9,048,660.074416177 BUSD / 5,000,000 BHM = 1.809732614883235 BUSD / BHM).
And this is how the price goes down when someone sells BHM to the LP.
Hope this could help you understand how Liquidity Pools works and how it “sets” a token price whenever an investor buys or sells that token in a Decentralized Exchange!
RugBust Academy is a community driven project that aims to bring about the financial revolution through education. Help us build the best content on the internet by suggesting topics, writing content, creating videos, graphics and get rewards in $RUGBUST. Join our Telegram and reach out to an Admin to learn more!