Decentralized Finance (DeFi) created an explosion of activity within the chain. DEX volumes can compete with the volume of centralized exchanges. At this time of writing there are nearly $239 billion so far in 2022 in value locked up in DeFi protocols. And the ecosystem is rapidly expanding with new product types.
But what is making all this rise in the space possible? One of the key technologies behind all these products is the liquidity pool.
What is a liquidity pool?
A liquidity pool is a collection of funds locked into a smart contract. Liquidity pools are used to facilitate decentralized trading, lending and many other functions that we will explore later.
Liquidity Pools are the backbone of many decentralized exchanges (DEX), such as Uniswap. Users called Liquidity Providers (LPs) add an equal value of two tokens to a pool to create a market.
In exchange for providing their funds, liquidity providers earn trading fees (commission) from trades that occur in their pool, proportional to their share of total liquidity (i.e. total liquidity).
As anyone can be a liquidity provider, AMMs (Automated Market Makers) have made market making more accessible.
Automated market makers are a part of decentralized exchanges (DEXs) that were introduced to remove any intermediaries in the trading of crypto assets. You can think of AMM as a computer programme that automates the process of providing liquidity.
One of the first protocols to use liquidity pools was Bancor, but this idea gained more popularity and attention with the rise in popularity of Uniswap. Some other popular exchanges that use liquidity pools on Ethereum are SushiSwap, Curve and Balancer. The liquidity pools in these protocols contain ERC-20 tokens.
Liquidity pools vs. order books
To understand how liquidity pools differ, let’s look at the fundamental building block of electronic trades – the order book. Simply put, the order book is a collection of current open orders for a given market.
The system that matches the orders with each other is called a matching engine. Along with this, the order book is the core of any centralized exchange (CEX). This model is excellent for facilitating an efficient exchange and has enabled the creation of complex financial markets.
However, DeFi trading involves executing trades in a chain, with no central party holding the funds. This is a problem when it comes to order books. Every interaction with the order book requires some fees, which makes trading and trade execution much more expensive.
It also makes it very costly for market makers and traders to provide liquidity for pairs of trades as we explained earlier. Above all, however, most blockchains cannot handle the performance required for billions of dollars of transactions every day.
This means that on a blockchain like Ethereum, an in-chain order book is practically impossible. You could use sidechains or layer 2 solutions, and these are on the way. However, the network is not able to handle demand in its current form.
Scaling on the Blockchain using Layer 1 & Layer 2 solutions
Before we go any further, it should be noted that there are DEXs that work just fine with order books within the chain. Binance DEX is based on the Binance Chain and is specifically designed for fast and cheap transactions. Another example is Project Serum which is built on the Solana blockchain.
Even so, since many of the assets in the cryptocurrency space are on Ethereum, you can’t exchange them on other networks unless you use some kind of bridge between the chains.
How do they work?
Automated Market Makers (AMMs) have changed this game. It’s a major innovation that allows on-chain trading without requiring an order book. Since no direct counterparty is required to execute trades, traders can enter and exit positions in cryptocurrency pairs that would likely have little liquidity in the exchanges’ order books.
You could think of an order book on an exchange as a peer-to-peer method where buyers and sellers are connected to the order book. For example, trading on Binance DEX is peer-to-peer, as transactions are made directly between users’ wallets.
Trading using AMM is different. You could think of trading on AMM as a peer-to-contract system.
As we mentioned, a liquidity pool is a bundle of funds deposited into a smart contract by Liquidity Providers (LPs). When you execute a trade in an AMM, you do not have a counterparty in the traditional sense. Instead, you execute the trade against the liquidity in the liquidity pool. In order for the buyer to buy, there does not need to be a seller at the time, only sufficient liquidity in the liquidity pool.
When you buy for example a currency that has just entered Uniswap, there is no seller on the other side in the traditional sense. Instead, your activity is managed by the algorithm that governs what happens in the pool. In addition, the price is also determined by this algorithm based on the trades that happen in that pool.
Of course, liquidity has to come from somewhere and anyone can be a liquidity provider (LP), so it could be seen as your counterparty in some sense. But, it is not the same as in the case of the order book model, as you are interacting with the contract that governs the pool.
What are Liquidity Pools for?
So far, we have mostly discussed AMMs, which have been the most popular use of liquidity pools. However, as we said, providing liquidity is a deep but simple concept that can be used in a number of ways.
One of them is yield farming or liquidity mining. Liquidity pools form the basis of automated yield generation platforms such as yearn, where users add their funds to pools that are then used to generate yields and earn profit.
Getting new tokens into the hands of the right people is a very difficult problem for crypto projects. Liquidity mining is one of the most successful approaches. Basically, tokens are distributed algorithmically to users who place their tokens in a liquidity pool. Then, newly received tokens are distributed in proportion to each user’s share in the pool.
Note that these may even be tokens from other liquidity pools called pool tokens. For example, if you provide liquidity to Uniswap or lend funds to Compound, you will receive tokens representing your share of the pool. You may be able to deposit these tokens into another pool and get a return on them. These chains can get quite complicated as protocols incorporate other protocols’ tokens into their products and so on.
Another emerging area in DeFi is insurance against the risk of smart contracts. Many of the applications in this area are also supported by liquidity pools.
Another, even more novel use of liquidity pools is for tranching. It is a concept borrowed from traditional economics that involves dividing financial products based on their risks and returns.
According to Investopedia, Tranches are a collection of securities that are separated and grouped based on various characteristics and sold to investors. Tranches can have different maturities, credit ratings, and yields–or interest rates.
As you might expect, these products allow Liquidity Providers to choose customized risk and return profiles.
The minting (“creation”) of synthetic assets on the blockchain is also based on liquidity pools.
Add some collateral to a liquidity, plug it into a trusted oracle and you have a synthetic token attached to any asset you want. Okay, actually, it’s a more complicated problem than we’ve described, but the basic idea is as simple as that.
What else can we come up with? There are probably many more uses for liquidity pools that have yet to be revealed, and it all depends on the ingenuity of DeFi’s developers.
Impermanent Loss Risk
If you are a Liquidity Provider in an AMM, you should be familiar with a concept called impermanent loss (IL).
In short, it is a loss in dollar value compared to HODLing when you are providing liquidity to an AMM (the same of course should be mentioned that applies on the other side as impermanent gain – IL where the two currencies for which you are providing liquidity go up in dollar value as long as you have deposited them, and accordingly your return is received).
If you provide liquidity to an AMM, you are likely exposed to a permanent loss . Sometimes it can be tiny; sometimes it can be huge. You can read about it here.
Another thing to remember is the risks of smart contracts. When you deposit funds into a liquidity pool, they are in the pool. So while technically there are no intermediaries holding your money, the contract itself can be seen as a custodian of those.