🎓

# What is a liquidity pool?

Imagine you have an apple, and you want to swap it for a lemon.

You could sell your apple and use the money to buy a lemon. But then you'd have to find a buyer for your apple, and then find a place that sells lemons...wouldn't it be easier if you could just swap your apple for a lemon directly instead?

Yes it would! But to do that there must be lemons lying around, ready to be swapped.

So how do we do that? Well, we convince other people to take the apples and lemons they already own and put them in a bucket. Now you can go to that bucket, put an apple in, and take a lemon out. Congrats, you have directly swapped your apple for a lemon!

🍎 -› 🍋 = 🎉

But how do we convince people to put their apples and lemons into the bucket? We do that by charging a small fee when anyone wants to use the bucket to swap betwen the two fruits.

You put an apple in the bucket, pay a small fee, and then take out a lemon.

🍎+💰 -› 🪣 -› 🍋 = 🎉

We then take the fee you just paid and split it amongst everyone who has put apples and lemons in the bucket - they get your fee as a reward for keeping the bucket filled with apples and lemons.

The bucket in this analogy is called a

**liquidity pool**.Now, the problem with the bucket is that apples and lemons aren't worth exactly the same. You can't swap one apple for one lemon. And if it's not apples and lemons in the bucket, but rather coins like Bitcoin and Ethereum, their prices fluctuate up and down every second.

In the bucket analogy above you swapped apples for lemons. But this presents a problem: there are now more apples than lemons in the bucket. If this continues, eventually there won't be any lemons left in the bucket to swap for.

🍎🍎🍎🍎🍎🍎🍎🍎🍎🍎🍋🍋🍋 = ❌

To make sure this doesn't happen, the bucket will always attempt to re-balance itself so that there is always an

*equal value*of apples and lemons in the bucket. Not an equal*amount*- an equal*value*.So let's go back to Bitcoin and Ethereum, and say there is a pool with $500 worth of Bitcoin and $500 worth of Ethereum.

You put $100 worth of Bitcoin in the pool, and take out $100 worth of Ethereum. All good so far.

But if you look in the pool, there is now $600 worth of Bitcoin, and $400 worth of Ethereum. As per the rules of the pool, this is not allowed. There must always be an equal

*value*of Bitcoin and Ethereum in the pool, so in this case there needs to be $500 of each.Before we continue it's important to understand that liquidity pools are like small isolated markets. The price of each coin or token in the pool is not determined by the market in general, it's determined by the trading that happens inside of the pool specifically.

Our pool is now out of balance. There is $600 worth of Bitcoin but only $400 worth of Ethereum.

But two things happened in the pool when you swapped $100 worth of Bitcoin for $100 worth of Ethereum.

The first thing that happened is that the pool predicted balancing issues and therefore quoted you a slightly higher price of Ethereum before you made your trade.

This is called

**slippage**- it's the premium you pay on top of the price of Ethereum for causing a balancing issue in the pool.The lesser the impact your swap has on the overall balance of the pool, the lower the slippage.

The second thing that happened is that you performed a trade! Standard market mechanics dictates the price of Ethereum going up, and the price of Bitcoin going down.

One of your friends now sees that the price of Ethereum in the pool is higher than it is elsewhere on the market.

So they hatch a plan...if they buy Ethereum on the market and use the pool to swap Ethereum for Bitcoin, they will get more Bitcoin than they would have from trading in the market, and can sell that Bitcoin for an instant profit.

Easy money! 🤑

So when you swapped Bitcoin for Ethereum, you actually increased the price of Ethereum in the pool. This incentivised your friend to swap the other way around, causing the pool to balance out again.

This opportunity is called an

**arbitrage**, and your friend is called an arbitrageur.Your friend the arbitrageur is most likely a bot. 🤖

In the above examples we talked about what a liquidity pool is (the bucket), how it works (pool balancing) and how it maintains its balance (via arbitrage).

There is one more huge factor in crypto though: price movements. Tokens fluctuate in value every second, sometimes drastically so.

Let's come back to our analogy of apples and lemons. Let's say apples and lemons are priced at $1 each, and we have 100 apples and 100 lemons in the bucket. All is balanced, and the total value of fruit in the bucket is $200.

But suddenly someone in the town market starts selling apples at $2 each.

Uh-oh, that now means we actually have $200 worth of apples in the bucket, but they're still priced at $1 each - the bucket has no clue what is happening in the town market.

Arbitrage bots now realise they can buy a lemon in the market for $1 and swap it for one apple in your bucket (also currently priced at $1). They can then take that apple back to the market and sell it for $2 to someone, making a $1 profit

Every time the arbitrage bot comes back with a lemon to swap for an apple, the bucket increases the price of apples (because of increased demand) until the price of an apple in the bucket is $2 - on par with the seller in the town market.

When that happens there is no more profit to be made by the arbitrage bot, so it stops swapping lemons for apples.

Remember: the bucket always has to have an equal value of apples and lemons. You might think that since we started with $200 worth of fruit in the bucket, and then apples doubled in value, there should now be $300 worth of fruit in the bucket.

But there isn't!

And that's because the arbitrage bots didn't have to swap two lemons for one apple whilst the bucket adjusted its price of apples to $2 each. In the beginning it could swap one lemon for one apple, then 1.01 lemon for one apple, etc.

The math to calculate how many lemons the bots actually swapped for apples is unnecessary to explain in detail here, but in this specific case the impact on the bucket's total value of apples and lemons would be 5.72%.

What does impact mean?

Well, because of the uneven swapping, the bucket now has a total of 70.71 apples and 141.42 lemons. This means the bucket's total value is $282.84, instead of the $300 it would have been worth if the bucket had set its price of apples to $2 at the same time as the seller in the town market did.

$282.84 is 5.72% less than $300, and this is a result of the arbitrage bots taking advantage of the discount on apples from the bucket.

But wait! What if the bucket was filled by 100 people providing 1 apple and 1 lemon each, and they now look inside the bucket? The ratio between apples and lemons in the bucket has changed from 100/100 to 70.71/141.42...there aren't enough apples anymore to make everyone whole.

In other words; withdrawing their share of the bucket would result in them getting 0.7 apples and 1.4 lemons.

The 0.7 apples and 1.4 lemons they have in the bucket are now worth $2.82 combined (since the price of apples went up). They initially put $2 worth of fruit in the bucket, so they are actually up 41% in this case.

However, if they had just held on to their 1 apple and 1 lemon, they would have $3 worth of fruit right now instead of $2.82.

This difference is what is referred to as

**impermanent loss**.It's important to point out that until you withdraw from the pool, the loss has not been realised yet - it has not been made permanent. That is why it's called an

*impermanent*loss: you haven't lost anything until you realise it (withdrawing your apples and lemons from the bucket).It's also important to point out that if you don't withdraw your apples and lemons from the bucket, and then apples go down to $1 again, you have suffered no impermanent loss at all. Withdrawing at that stage would result in getting the same 1 apple and 1 lemon you provided at the start.

There is a common misconception that impermanent loss should be avoided at all costs, but this is not true. Impermanent loss in itself is nothing to fear. All it really means is that

*in most scenarios*you would*earn slightly less or lose slightly more*than you would have if you held the tokens individually instead of entering them into a liquidity pool.**So if it's always more lucrative to hold on to the coins/tokens individually, why should you enter a liquidity pool?**

Because remember: everyone who provides liquidity to the pool are rewarded by sharing the swap fees. In most cases these swap fees give you more money in return than you lose through impermanent loss.

Last modified 3mo ago