What is an Automated Market Maker? (Liquidity Pool Algorithm)

whiteboard crypto logo
Published by:
Whiteboard Crypto

An Automated Market Maker allows traders to buy and sell certain coins using an algorithm that dictates how expensive something should be based on how much of it there is.

As someone buys one asset, it gets more and more expensive because there is less of it. As they give it another asset, it gets cheaper because there is more of it. Basically supply and demand, but using an algorithm instead of the traditional method which uses a person. 

Welcome to WhiteboardCrypto, where we explain cryptocurrency topics using analogies, stories, and examples so you can actually understand them. In this video we are going to cover what an Automated Market Maker is and exactly how it works. Let’s dig in. 

What is an Automated Market Maker?

Automated Market Maker

Let’s say that you are a potato farmer. You’re sick and tired of going to work and seeing potatoes everywhere, then coming home only to eat more potatoes, even though you can cook potatoes in some very interesting ways. You don’t want any more potatoes. 

Here’s the real kicker though, you live in a whole village of potato growers, so you can’t really trade your potatoes for anything else. “It would be nice to trade my potatoes for something else, like apples,” you think. 

Well, along comes a trader who has access to a boat and he says, “I’ve found a village over east that grows apples and they are sick of them—I am here to see if you would like to invest in a trade.”

Well, now that your wish has come true, you have your chance to disappear, so you tell the trader yes. 

He says, “The apple farmers have put up 50,000 apples to add to my apple-potato exchange business, if you can give me 50,000 potatoes, we can get started.”

So your village has a meeting and they decide to join the trader in exchanging apples and potatoes. 

The trader goes, “Here’s the thing though, I have a magical genie with me that will store all 50,000 apples and all 50,000 potatoes in his lamp to keep safe, so they don’t go bad, but he wants to keep a perfect ratio of the value of both.”

He goes on, “Since together we put in 50,000 apples and 50,000 potatoes, he wants both numbers to always multiply to equal 2.5 billion, which is equal to 50,000 times 50,000. This way, if one year there are less apples, the apples will cost more potatoes to buy.” 

If you’re currently confused at what the magical genie has mentioned, it is actually the formula for a type of Automated Market Maker called a Constant Product Automated Market Maker. 

x * y = k

x and y are the quantities, or amounts, of the things you have. And k is a constant that always stays the same and does not change. In this example, k is 2.5 billion. Let’s keep going so you can understand it a bit better. 

The trader says, “Right now, there is a perfect 50:50 ratio of potatoes to apples, but that is because I have priced them each at a dollar. When you guys start trading, one of these may become more valuable, and thus it should be priced more than a dollar. Let me go through an example so you guys know how it works.”

So right now there are 50,000 apples and 50,000 potatoes, and the number of both must equal 2,500,000,000 when multiplied.

Let’s say a potato farmer comes along with 7,000 potatoes to trade, because they really want some apples. So he gives them to the Genie and waits while the Genie figures out how much to give him. 

Now we have 57,000 potatoes in the genie’s lamp, but we need to know how many apples to give the potato farmer. So we take 2.5 billion and divide it by 57,000. Why? You’ll see in a second.

The answer we get is 43,859. So this is the number of apples that SHOULD be left over in the magical genie’s lamp, but right now there are 50,000, so we just need to figure out the difference. The difference is 6140. We give the potato trader 6140 apples. 

So, as more and more apples were bought up, they became more expensive. This is why the farmer didn’t get exactly 7000 apples. 

Now there are 57,000 potatoes and 43,859 apples in the Genie’s lamp. Let’s make sure we didn’t upset the genie. 57,000 * 43,859 does equal 2.5 billion, so he is still happy!

I hope this is starting to make sense, and if you’ve gotten this far into my explanation of how automated market makers happen without even using any technical words, I think we deserve a big thumbs up. 

Before we continue with another example, let’s run over a quick example of finding out how much each asset costs in dollars.  

So assume that there was $50,000 worth of apples in the beginning since they were $1 and $50,000 worth of potatoes at the beginning of the trade—when the farmers brought up their potatoes and apples to the trader. 

So we keep $50,000 as a constant when calculating their value—that is how much each asset should total. 

So potatoes would be $50,000 / $57,000, which brings their price to 87.7 pennies for each potato. “Why did they drop from a dollar?” you ask? Because someone brought a lot more of them to the genie! It’s supply and demand, if you could grow gold on the trees in the backyard, gold would suddenly be a lot cheaper. 

The more there is in the Genie’s lamp, the less they will cost. From now on, instead of saying “Genie’s lamp” I’m going to call it what it really is—a liquidity pool. 

Now, let’s calculate the price of the apples. This calculation would be $50,000 / $43,859. Wow, that means apples are worth $1.14. They rose in price because there are less of them in the liquidity pool. 

So since this potato trader gave a bunch of potatoes to the liquidity pool and took a bunch of apples, the price of apples went up and the price of potatoes went down due to supply and demand, which is shown in the formula x * y = k. 

I personally learn from examples, and this concept took me a week of studying to fully understand, so let’s go over another example. 

Example 2

Automated Market Maker Genie

Let’s say a potato farmer brings another 10,000 potatoes. 

Now there are 67,000 potatoes in the pool. 

We need to know how many apples to give that potato farmer. 

So we use our constant of 2.5 billion divided by 67,000 and we get: 37,313. 

This means there should be 37,313 apples in the pool, but right now we have 43,859. So we give the difference to the potato farmer—which is 6546. This time the potato farmer paid even more for his apples. Since they keep buying them up, the liquidity pool charges more for them so it won’t ever run out of stock. 

Now there are 67,000 potatoes and 37,313 apples in our liquidity pool. Both of these numbers multiply to 2.5 billion, so the Genie (which is actually the algorithm) is happy. Let’s calculate the price. 

50,000 / 67,000 means the potatoes are worth 74.6 cents.

50,000/ 37,313 means the apples are worth $1.34 cents. 

Again, we saw that there were more potatoes than before, so the price dropped, and that there were less apples than before so the price rose. 

Now hopefully you are understanding how an automated marker maker works. As someone buys more and more of something, the price goes up—the apples are costing more because there are less of them—and the algorithm always wants the value of what it is holding to be 50:50.

If you multiplied the price of each asset by how many assets were in the liquidity pool, the total would still be $50,000 of apples and $50,000 of potatoes. 

Let’s do one more example really quick just to drive it home. 

Example 3

This time, an apple farmer comes along with 2000 apples. 

So he adds them to the liquidity pool and now there are 39313 apples, but we need to figure out how many potatoes to give him. 

2.5 billion / 39,313 = 63,592, which is how many potatoes there should be. 

There are currently 67,000 potatoes, and the pool only wants 63,592, so we take the difference and give it to the apple farmer, which is 3408 potatoes. The farmer gave 2000 apples and got 3408 potatoes because at the time his apples were more valuable. 

A real liquidity pool can sometimes have up to millions of dollars worth of assets in it, and you should know that the more money is in a liquidity pool, the more stable the price.

If there were 500,000 apples and 500,000 potatoes and you still wanted to trade only 2000 apples, the price difference wouldn’t change as much as we saw in our example. 


You should know that liquidity pools reward investors, those who put up money into the pool, with a fraction of each trade that happens on their platform. Even if it is less than one percent each trade, if someone is trading multiple times a day, that number really adds up and can be profitable for the trader. 

Liquidity pools also get more complicated because what if another trader came along and wanted to add another 50,000 apples and 50,000 potatoes from villages he found? How do we make sure they can take out their original investment as the price changes? What about if we find a pineapple farmer and want to add him to the trading pool? 

Well, there are answers to these questions, but they are for a different article, as we try to keep these article short and very easy to understand.

Thanks so much for reading, we hope you learned something, and we really hope you enjoyed it.

whiteboard crypto logo

WhiteboardCrypto is the #1 online resource for crypto education that explains topics of the cryptocurrency world using analogies, stories, and examples so that anyone can easily understand them. Growing to over 870,000 Youtube subscribers, the content has been shared around the world, played in public conferences and universities, and even in Congress.