What Are Liquidity Pools? The Ultimate Guide to DeFi Mechanics
GM! And welcome back to the Empirica Blog. Today we will dive deeper into the topic of liquidity pools & their importance in the operations of automated market makers.
Liquidity pools are a mechanism based on smart contracts that regulate the token ratio in the pool and allow market participants to exchange ERC-20 tokens without any counterparties.
TL;DR: The whole space is running on liquidity pools. Without them, the instant money transfers you know from Uniswap would be almost impossible.
- Do you know how they ACTUALLY work?
- What are MEV attacks & how can you protect yourself from them?
- And what’s the role of liquidity pools in many important web3 projects?
All of that (and more) is in the newest article. Let’s dive deeper into the rabbit hole.
Check here for details on how we do market making for crypto projects
Table of contents
- How do liquidity pools work?
- What’s the role of liquidity pools in DeFi?
- Why is deep liquidity essential for the blockchain startup?
- Liquidity pools vs yield farming – the incentive formula for DeFi
- The main drawback of yield farming & liquidity mining
- Liquidity pools vs crypto security: what are sandwich MEV attacks?
1. How Do Liquidity Pools Work?
Let’s start from the beginning. Have you ever been wondering how the liquidity pools actually work? We mean, the coins you get doing the swap on Uniswap have to come from somewhere. That’s where the liquidity pools hit the floor. They are the base of DeFi, allowing market participants to successfully buy & sell crypto assets and providing the liquidity to cash out (or buy).
Liquidity pools vs order book formula
If you want a benchmark for liquidity pools, let’s take an example of centralized exchanges: when you buy BTC for USD on Binance, you need the second part of the transaction. The users can place the buy order (which makes it to the order book), and when the seller appears (selling BTC at a price request by you), you get crypto, and the other side gets fiat.
Liquidity pools allow crypto market participants to trade without waiting for the counterparty of the transaction because this role takes liquidity providers that are incentivized to “share” their cryptocurrencies as liquidity.
Liquidity Pools & Automated Market Makers
Moreover, liquidity pools are the base for the model of conducting transactions in the world of decentralized finance. It’s called AMM – automated market maker – which means the whole market-making process is now automated.
What’s the mechanism behind liquidity pools?
From the one side, there is the pool provided by the blockchain project itself and filled with liquidity by liquidity providers, aka DeFi Farmers, which simply are crypto-market participants who want to earn interest on their tokens). On the other side, we have traders. Now, let’s take an example:
- When a trader wants to conduct a sell transaction, she relies on the liquidity pool provided by the blockchain project and DeFi farmers.
- If the token A is sold, the amount of A is increased in the pool, and the amount of B is reduced (because the ultimate state of valuation is always a 50/50 ratio)
- When token A is bought, there are fewer A tokens in the pool and more B (the ratio of the token amount is changed, but the value will stay at 50/50).
The whole process is automated and regulated by the math algorithm.
Let’s take an example of the Uniswap V3 mechanism. The market depth is calculated using this formula: m (δ) = 1 s i0X +d(δ) i=i0 λx(i) + p −1 0 λy(i).
Each type of transaction or in-protocol operation has rules that, at the end of the day, regulate the token ratio in the pools and provide the proper functioning of the market. The liquidity provider gets LP tokens that represent his share in the pool. LP tokens will be the basis for calculating the value of the tokens when the liquidity provider decides to withdraw the assets. Learn more about the mechanism behind LP tokens here.
So in summary what are the liquidity pools?
These are tokens locked in a smart contract (called a pool). The whole amount is divided into 2 different crypto assets: for example, 50% of the token is paid in USDC, and 50% in the token of your protocol. If the initial value of the pool is set for $300k, you need $150k USDC and $150k in your token.
2. What’s The Role of Liquidity Pools in DeFi?
The entire crypto space is running on liquidity pools. No matter which protocol you take as an example, they exist there, providing a possibility to conduct transactions for the crypto market participants.
The role of the liquidity pool is to:
- allow your users the possibility of trading (buying and selling) the tokens
- facilitate the trading process
- increase the speed of financial exchange
But let’s get back to the main topic: the main benefit of a liquidity pool is the drawback of the centralized exchanges and NFT Market.
3. Why is Deep Liquidity Essential For The Blockchain Startup?
Now, let’s take an example from real life and put having deep liquidity pools into context.
Some founders still do not understand how low liquidity can negatively affect the price of their token.
So let us explain: as you read above, the liquidity pool formula is about regulating the token ratio in the pool due to the current market supply and demand for the token.
If you have high liquidity, there is no problem: anyone can make even big orders(and the price won’t react that much).
The problem is when massive sell pressure appears (during the FED meeting about interest rates, for example), and the holders will instantly start selling.
It might lead to a situation in which the price of the token falls much more than in the case of adequately deep pools of liquidity.
Why is that?
Because lower liquidity leads to higher price volatility.
For example, if there is $1M in tokens in the liquidity pool, and the user conducts a sell transaction for $100k, the price will drop by around 10%.
If the liquidity is around $10M, the $100k sell order will take down the price only by around 1%.
As the crypto space is one of the most volatile financial markets on Earth, during the panic-selling events, the capitalization of core crypto assets drops twice or more as stocks, not to mention the low-cap coins.
Such moments sometimes appear in history, especially when the recession is around the corner. That is why it is worth understanding how the liquidity mechanism works to prepare for a price crash potentially.
4. Crypto Liquidity Pools vs Yield Farming – The Incentive Formula For DeFi
Liquidity is one of the few things that matter in crypto. Without it, your token holders won’t be able to trade. But as a startup founder, most often, your liquidity is limited to what you raised from investors. So if you attract the DeFi farmers (independent investors, providing liquidity) and make them provide liquidity for the broad group of traders, the potential of increasing the liquidity depth would be unlimited.
That’s what yield farming is – people provide their cryptocurrencies for crypto/crypto or stablecoin/crypto pools, so the token’s price can be less volatile, even under large transactions.
But they aren’t doing it for free. The liquidity-providing activity is incentivized by the crypto protocols. It works in such a way: when crypto market participants have free funds and want to earn interest on them, they can deposit their crypto assets to the smart contract and get paid for it.
It first started in 2020, when Synthetix – one of the pioneer DeFi protocols, established an incentive mechanism that became one of the key catalysts for the DeFi Summer.
Later, we had Compound, which is a protocol that started to distribute COMP tokens to liquidity providers. This formula of paying users to transfer their stablecoins to Compound began a new era of DeFi when protocols competed with each other to offer the highest APY (annual percentage yield), thus achieving liquidity from DeFi farmers.
However, this mechanism is not bullet-proof:
5. The Main Drawback of Yield Farming & Liquidity Mining
The truth is, as long as you give the tokens as rewards, you will have liquidity providers with you. When the financial incentive (in the form of tokens) is gone, the liquidity providers are also gone.
Such a phenomenon is called mercenary capital and stands for the money in the crypto space from investors focused on short-term profits.
Why is that important?
As you read before, liquidity is king. If the depth of the protocol’s liquidity is not stable (and even worse, dependent only on the financial incentive), we enter the dangerous ground.
Because financial incentives cannot last constantly – they have to decrease in time (most often the incentives are planned only for the first months of operations to increase the interest in the protocol).
Without changing the incentive program (and most often, lowering the liquidity mining APRs), the price of the token will quickly decrease because of the selling pressure from DeFi farmers – if the only incentive is to earn money, providing liquidity is a pure business and the farmers will dump the tokens.
That’s why addressing the point of deep & low liquidity is that crucial. In the beginning, each project needs to define what will be its idea to attract liquidity – if it’s based only on financial incentives, the token price will dramatically decrease over a longer period of time.
6. Liquidity Pools vs Crypto Security: What Are MEV Sandwich Attacks?
And last but not least, the MEV Sandwich attacks (an on-chain example can be find here)
What are these?
Attacks from the hackers that “sandwich” the whole process between 3 transactions (hacker’s txn – victim’s txn – hacker’s txn).
You can see that during 3 consecutive transactions on the same token.
What does the process of MEV attacks look like?
First, the hacker seeks a victim and then makes a transaction. His (or her) goal is to increase the exchange rate on a given token trading pair (i.e.XYZ / ETH).
To do it, the bot buys the token before the real user (onchain example).
Then, the victim pays more for the digital asset (XYZ) than it usually would.
The outcome: the victim gets less ETH (onchain example).
Then, the hacker has to reverse the transaction and sell XYZ for the higher price.
How is that possible?
First, the attacker buys the token before the victim and pumps up the price. Then, the victim buys the token and pumps the price even more. In the end, the attacker sells the token at a higher exchange rate.
It can happen during the DEX swap or a lending operation.
To make such an operation, hackers code the bots and most often use protocols like Aave to maximize capital efficiency and use stablecoins to increase the price of a particular asset.
Why are we talking about MEV attacks?
They can appear during all kinds of DeFi operations.
To protect your community (and yourself) from the sandwich attacks:
- use CowSwap – an MEV-proof automated-market-maker DEX
- set the low slippage on DEXs (you can custom it)
It’s also good to increase awareness of the MEV attacks because 99% of crypto investors still do not know what they are and how not to suffer from them.
Thanks for your time! If you found this interesting, share the article on Twitter and show your friends that web3 is a great space.
See you in the next article!
Check here for details on how we build organic liquidity for crypto projects