🎓
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.