So, what are liquidity pools, how do they work?

You can watch the video on the YouTube channel

Subscribe to the youtube channel of the Bitcoin School

So, what are liquidity pools, how do they work? And why do we need them in decentralized finance? Also, what are the differences between liquidity pools across different protocols? Such as: Uniswap, Balancer or Curve. We will be going through all of this in this video.

Before we start, if you are new to DeFi, you may want to watch my introduction to Decentralized Finance video first. Also, you may want to subscribe to this channel for more DeFi related content.

Alright, so lets talk about liquidity pools. Liquidity pools in essence are pools of tokens that are locked in a smart contract. They are used to facilitate trading by providing liquidity and are extensively used by some of the decentralized exchanges, aka DEXes.

One of the first projects that introduced liquidity pools was Bancor. But they became widely popularized by Uniswap.

Before we explain, how liquidity pools work under the hood, and what automated market making is, lets try to understand, why we even need them in the first place.

If you are familiar with any standard crypto exchanges like Conbase or Binance, you may have seen, that their trading is based on the order book model. This is also the way traditional stock exchanges such as NYSE or Nasdaq work.

In this order book model buyers and sellers come together and place their orders. Buyers, aka Bidders, try to buy a certain asset for the lowest price possible. Whereas sellers try to sell the same asset for as high as possible. For trades 2 happen, both buyers and sellers have to converge on the price. This can happen by either a buyer bidding higher, or a seller lowering their price.

But what if there is no one willing to place their orders at the fair price level?

What if there are not enough coins that you want to buy? This is where market makers come to play. In essence, market makers are entities, that facilitate trading by always willing to buy or sell a particular asset. By doing that, they provide liquidity. So the users can always trade, and they dont have to wait for another counterparty to show up.

Okay, so why we cant just reproduce something like this in decentralized finance?

The answer is — we can. It will be just really slow, expensive, and pretty much always result in poor user experience. The main reason for this is the fact that order book model relies heavily on having a market maker or multiple market makers willing to always make the market, in a certain asset.

Without marker makers, an exchange becomes instantly illiquid, and it is pretty much unusable for normal users. On top of that, market makers usually track the current price of an asset by constantly changing their prices.

Which results in a huge number of orders and order cancellations that are being sent to the exchange.

Ethereum with a current throughput of around ten to fifteen transactions per second, and a block time between ten and nineteen seconds, is not really a viable option for an order book exchange.

On top of that, every interaction with a smart contract cost a gas fee. So market makers would go bankrupt by just updating their orders.

How about the second layer scaling then?

Some of the second layer scaling projects like Loopring look promising. But even they are still dependent on market makers and they can face liquidity issues.

On top of that, if a user wants to make only a single trade, they would have to move their funds in and out of the second layer.

Which adds two extra steps to the process.

This is exactly why there was a need to invent something new, that can work well in the decentralized world. And this is where liquidity pools come to play.

Okay, so now that we understand why we need liquidity pools in decentralized finance, lets see how they actually work?

It its basic form a single liquidity pool holds two tokens and each pool creates a new market for that particular pair of tokens. DAI/ETH can be a good example of a popular liquidity pool on Uniswap.

When a new pool is created, the first liquidity provider is the one that sets the initial price of the assets in the pool.

The liquidity provider is incentivized to supply an equal value of both tokens in the pool.

If the initial price of the tokens in the pool diverges from the current global market price, it creates an instant arbitrage opportunity, that can result in lost capital for the liquidity provider.

This concept of supplying tokens in a correct ratio remains the same for all the other liquidity providers that are willing to add more funds to the pool later.

When liquidity is supplied to the pool, the liquidity provider (LP) receives special tokens called LP Tokens in proportion to how much liquidity they supplied to the pool.

When a trade is facilitated by the pool, a zero point three percent fee is proportionally distributed amongst all the LP token holders.

If the liquidity provider wants to get their underlying liquidity back, plus any accrued fees, they must burn their LP Tokens. Each token swap that liquidity pool facilitates results in a price adjustment according to a deterministic pricing algorithm.

This mechanism is also called an Automated Market Maker (AMM).

And liquidity pools across different protocols may use a slightly different algorithm.

Basic liquidity pools such as those used by Uniswap use the constant product market maker algorithm. That makes sure, that the product of the quantities of the two supplied tokens always remains the same.

On top of that, because of the algorithm, the pool can always provide liquidity, no matter how large a trade is. The main reason for this, is that the algorithm asymptotically increases price of the token as the desired quantity increases.

The math behind the constant product market makers is pretty interesting, but to make sure that this video is not too long, Ill save it for another time.

The main takeaway here is that the ratio of the tokens in the pool dictates the price.

So if someone, lets say, buys ETH from the DAI/ETH pool, they reduce the supply of ETH, and add the supply of DAI.

Which results in an increase in the price of ETH. And a decrease in the price of DAI.

How much the price moves depends on the size of the trade. In proportion to the size of the pool.

The bigger the pool is in comparison to a trade, the lesser the price impact aka slippage occurs.

So large pools can accommodate bigger trades without moving the price too much. Because larger liquidity pools create less slippage and are resulting in a better trading experience, some protocols like Balancer started incentivizing liquidity providers with extra tokens for supplying liquidity to certain pools.

This process is called liquidity mining, and we talked about it in our yield farming video.

The concepts behind the liquidity pools and automated market making are quite simple, yet extremely powerful. As we dont have to have a centralized order book anymore, and we dont have to rely on external market makers to constantly keep providing liquidity to an exchange.

The liquidity pools that we just described are used by Uniswap. And they are the most basic forms of liquidity pools.

Other projects iterated on this concept, and came up with these few interesting ideas. Curve, for example, realized that the automated market making mechanism behind Uniswap doesnt work very well for assets, that should have the very similar price. Such as stablecoins, or different flavours of the same coin.

Like WETH, or SETH. Curve pools, by implementing a slightly different algorithm are able to offer lower fees and lower slippage in exchanging these tokens.

The other idea for different liquidity pools came from Balancer. That realized, that we dont have to limit ourselves to having only two assets in a pool.

And in fact, Balancer allows for as many as eight tokens in a singe liquidity pool. And of course, like with everything in DeFi, we have to remember the potential risks.

Besides our standard DeFi risks, like – Smart Contract bugs, admin keys and systemic risks, we have to add two new ones.

Impermanent loss and the liquidity pool hacks.

So, what are liquidity pools, how do they work? обновлено: November 17, 2021 автором: SchBit