Liquidity pools are one of the key components of decentralised finance. Liquidity pools are pools of tokens locked into a smart contract. Decentralized exchanges (DEX) use liquidity pools to facilitate trading on public blockchains. By participating in liquidity pools users provide cryptocurrency exchanges with the working capital to buy and sell assets in exchange for interest and rewards.
Why Do We Need Liquidity Pools?
Cryptocurrency exchanges like Coinbase and Binance trading are based on the orderbook model. In the orderbook model, buyers and sellers come together and place orders for tokens they would like to buy or sell at a given price. Buyers try to buy the asset at the lowest price possible and sellers try to sell the asset at the highest price possible. For a transaction to occur, buyers and sellers must agree on the price. This can happen when a buyer raises their bid, or a seller lowers their ask.
The orderbook model begs the question; what happens if sellers and buyers cannot agree on a price? What if there are not enough coins to buy? This is where market makers come into play. Market makers facilitate trading by always buying or selling a particular asset. By doing this, they provide liquidity and allow users to trade without waiting for another user to agree to their price.
The orderbook model is not suited for decentralised finance.
To replicate the orderbook model in Defi would result in a slow, expensive user experience. The order book model relies heavily on a market maker or multiple market makers always willing to make the market in a specific asset. Without market makers, an exchange becomes illiquid. On top of this, market makers usually track an asset’s current price by constantly changing their prices, resulting in a large number of orders and order cancellations being sent to an exchange.
The Ethereum platform can only achieve 12-15 transactions per second with 10-19 second block times. Each of these interactions with a smart contract has a gas fee. Given that market makers are constantly updating their orders, current Ethereum gas fees would bankrupt most market makers.
Though second layer scaling solutions hoep to reduce transaction costs on Ethereum they are not a viable solution for the order book model. The order book model’s dependency on market makers will continue to create a liquidity issue. In addition, trading would require users to move assets in and out of a second layer resulting in a poor user experience.
Defi needs liquidity pools to solve this problem.
How Do Liquidity Pools Work?
A given liquidity pool holds two tokens. Each pool creates a new market for the pair of tokens. For example, Dai/Eth is a liquidity pool on Uniswap that holds both Dai and Eth for trading. When a new pool is constructed, the first user to provide liquidity sets the initial price of assets inside the pool. The liquidity provider is incentivized to supply an equal value of both tokens in the pool. Suppose the initial price of the tokens inside the pool diverges from the current global market price. This creates an opportunity for arbitrage and results in an impermanent loss for the liquidity provider. The potential for loss when a pool has an imbalance of assets promotes all users who participate in the pool to supply tokens in the correct ratio.
When liquidity is supplied to a pool, the liquidity provider may receive special tokens called LP tokens which represent rights to interest earned by the pool. These tokens are given in proportion to how much liquidity is provided to the pool. When a trade is facilitated by the pool, a 0.3% fee is proportionally distributed amongst all the LP token holders. If the liquidity provider wants their underlying liquidity back, plus accrued fees, they must burn their LP tokens.
Automated market makers keep token quantities and prices in balance.
Token swaps facilitated by the liquidity pool result in a price adjustment from a deterministic pricing algorithm. This mechanism acts as an automated market maker (AMM). Liquidity pools across different protocols may use a slightly different algorithm. Basic liquidity pools on Uniswap use what they call a “constant product market maker algorithm” to ensure the quantities of each supplied tokens always remain the in balance. On top of this, the algorithm asymptotically increases the price of tokens as demand increases. This allows the pool to provide liquidity no matter how large a trade is.
The ratio in a liquidity pool will dictate the price of each token. Let’s say someone buys Eth from a Dai/Eth pool. This Transaction will reduce the supply of Eth while increasing the supply of Dai. As a result of the change in balance, the price of Eth will increase and the price in Dai will decrease. How much the price moves is dependant on the size of the trade in proportion to the pool’s size. A larger pool will experience a smaller price impact (slippage) for each trade. Larger pools can accommodate larger trades.
What is Liquidity Mining?
Because larger liquidity pools experience less slippage and create a better trading experience, some protocols like “Balancer” incentivize liquidity providers to contribute to specific liquidity pools. In exchange for contributing to a specified liquidity pool, users are rewarded with extra tokens. Liquidity mining is where a user moves their capital from one pool to another to maximize their rewards. Motivated users may change liquidity pools or even currencies daily so that they are always generating the maximum rewards. To read about liquidity mining in action checkout our post on Yearn Finance.
Liquidity pools are a simple and powerful tool. The liquidity pool model eliminates facilitates exchanges without requiring a centralized order book and without depending on external market makers to provide liquidity. In this article, we discussed liquidity pools in their most basic form. Protocols outside of Uniswap have built more advanced iterations of this concept. In future posts, we will introduce and discuss these many different iterations of liquidity pools.
We would like to give credit to finematics. His youtube channel explains Basic Defi concepts and has inspired much our Defi series as well as guided our own research.