Throughout the 2020-2021 crypto bull run, the decentralized finance (DeFi) ecosystem emerged as the most innovative and thriving part of the crypto space. Most DeFi protocols rely on smart contracts handling pools of crypto assets deposited by DeFi users. Those pools are the backbone of the DeFi ecosystem and are crucial to the complete decentralization of the sector. But what are those liquidity pools, and how do they work?
What are liquidity pools and why are they important?
In essence, liquidity pools are reserves of tokens locked in a smart contract. In the DeFi ecosystem, liquidity pools facilitate swapping from an asset to another on decentralized exchanges (DEX). Instead of relying on buyers and sellers, those platforms use automated market makers (AMM), allowing traders to swap between cryptocurrencies without human intervention.
Liquidity Pools, the backbone of the DeFi ecosystem
On a traditional market like the New York Stock Exchange or centralized crypto exchanges like Binance, you have a single order book for each pair. Buyers and sellers will place their orders in the order book, which tracks all existing orders. Buyers will want to buy at the lowest price while sellers try to sell as high as possible. When a transaction occurs, it means the supply (sellers) met the demand (buyers) at a given price.
But what if all the sellers want to sell at 2$ while all the buyers want to buy at $1? This is where market makers come to play.
Fundamentally, market makers are individuals or entities always willing to buy or sell an asset. A market maker provides liquidity for a specific pair like BTC/USDT to reduce the interval between transactions.
Let’s take a quick example to illustrate the role of a market maker:
You’re on Binance and the price of 1 bitcoin is $56,250. All the buyers on Binance are buying BTC at $56,200. While sellers refuse to sell BTC below the $56,300 price level.
Here, the market maker will deploy his funds in the order book to facilitate the trading so that market participants don’t have to wait for a counterparty. In this situation, a market with no market maker would not receive any trade, making it useless for regular users.
Nevertheless, this mechanism is highly complex to set up in a decentralized way. Indeed, the activity of a market maker requires continuously placing and withdrawing sell or buy orders. This would be highly inefficient because of the transaction time of most blockchains and the fact that placing or withdrawing an order cost gas fees, which would quickly bankrupt the market maker placing and withdrawing thousands of orders per day.
This is why there was a need to invent something new that would work well in a decentralized ecosystem, and this is where liquidity pools come in.
The genesis of liquidity pools
The Bancor protocol created the first-ever AMM relying on liquidity pools to maintain liquidity on its exchange. This innovation released in 2017 is based on a simple but innovative mathematical equation where prices are set according to the quantities of tokens in the pools. Yet, liquidity pools only took over the DeFi ecosystem with the rise of Uniswap, which democratized the use of this innovation.
In November 2018, Uniswap released the first version of its decentralized exchange on the Ethereum network. Three years later, Uniswap records an average daily transaction volume of $1.5 billion.
How does a liquidity pool work?
In general, a liquidity pool holds 2 crypto assets; each pool represents a market for a given pair of tokens. Currently, the most popular pool on Uniswap is the USDC/ETH liquidity pool, which we will use as an example. When the pool was created, the first liquidity provider (LP) defined the initial price for the assets in the pool. On Uniswap and numerous other DEXs, each pool has to maintain a 50/50 ratio between the value of each asset. If you created the USDC/ETH and wanted to deposit 2 ETH worth $4,000 each, the Uniswap protocol would have asked you to provide $8,000 worth of USDC to match the value of your 2 ETH.
After an LP supplies liquidity to a pool, he receives LP tokens representing his share of the liquidity pool. On Uniswap, each swap has a 0.3% transaction fee. When a trade happens in a pool, the fees are distributed to LP token holders according to the liquidity they provide. If you provide 50% of the liquidity, you will be awarded 0.15% (50% of the 0.3% transaction fees) of the volume swapped in the pool. To retrieve your assets and receive the fees, you have to redeem your LP tokens by closing your position in the pool. The protocol will burn your LP tokens and send back your funds with the earned fees.
Last but not least, the AMM adjusts the token price after each swap. When someone buys ETHG in the USDC/ETH pool, it reduces the quantity of ETH in the pool and adds to the supply USDC. Here, the AMM will increase the price of ETH and reduce the price of USDC.
What are the benefits and the risks associated with liquidity pools?
Liquidity pools offer continuous liquidity for DeFi protocols and DeFi users; they have become a vital part of the DeFi ecosystem. Additionally, liquidity pools are yet another way for crypto investors to put their funds to work by providing liquidity and earning transaction fees. In turn, liquidity providers can use their LP tokens on other protocols as part of their yield farming strategy, which you will discover in a dedicated article. Still, liquidity pools involve some risks. The smart contract governing the pool can be flawed, leading to bugs or exploit by attackers.