What Automated Market Makers are and How They Work

Automated Market Makers are what allow traders to purchase and sell certain coins using an algorithm that dictates how costly something ought to be, based on how much of it there is. As someone buys one asset, it gets increasingly costly and expensive because there is less of it. As they give it another asset, it gets cheaper and cheaper because there is more of it. Basically, it is supply and demand but it’s using an algorithm instead of the conventional and traditional method which uses a person.

You’re a banana farmer living in a village full of banana farmers. You are sick and tired of only ever having, seeing, eating, and working on bananas. You can not trade off your banana for anything else to someone in your village though because all they have are bananas as well. This time, you want to eat some fish. Along came a trader who says he’s been to a nearby village where people are also sick and tired of all the fish they have. He offers you a trade and you agree to invest. The fishing village has put up 10,000 fish for the “fish – banana exchange business”. The trader needs you to put up 10,000 bananas so you and he can get started. Your village convenes and agrees to join the trader in exchanging fish and bananas. Before you get started though, he says he has a “magic box” that stores the 10,000 fish and 10,000 bananas to keep them safe and help preserve them from going bad. He has a condition that there must always be a perfect ratio of the value of both. He says that since together you put in 10,000 fish and 10,000 bananas, these numbers must always multiply to approximately equal to 100 million (10,000 x 10,000). This way, if there is a time when one is fewer in number than the other, it will cost more to buy.

The conditions given by the trader are actually the formula for an automated market maker called a Constant Product Automated Market Maker. The algorithm uses this formula (x*y=k), where x and y are quantities or amounts of the things you have (the fish and bananas), and k is a constant (the 100 million). Right now, there is a perfect 50 to 50 ratio of fish to bananas and they are each priced at 1 USD. When trading starts, one of the two may become more valuable and will be priced at more than a dollar. Let’s say, a banana farmer comes with 1,000 bananas to trade for some fish. He puts it in the “magic box” and waits to receive how much fish he can get in return. There are now 11,000 bananas and we must know how much fish to give the farmer. 11,000*f ≈ 100,000,000, where f is the amount of fish. f=100,000,000/ 11,000 ≈ 9,090. Right now, there are 10,000 fish but there must only be 9,090. Calculate the difference and give it to the farmer. 10,000-9,090= 910. The banana farmer put up 1,000 bananas and got 910 fish in return. As more fish were brought up, they became more expensive. That is why the banana farmer didn’t get exactly 1,000 fish back. So now, there are 11,000 bananas and 9,090 fish in the “magic box”. Check that the condition is still met, 11,000*9090 ≈ 100,000,000.

Calculating how much each asset costs in USD, we first assume that there is 10,000 USD worth of fish and 10,000 USD worth of bananas since they were both priced at 1 USD and there were 10,000 each. We just need to keep 10,000 as constant. So bananas would be 10,000 USD/ 11,000 bananas because that is how many bananas we have which brings their value to roughly 90.9 cents for each banana. They dropped from a dollar because someone brought a lot more of them to the “magic box”. Remember supply and demand? If you could plant and harvest gold at home, gold would suddenly become cheaper because you can make a lot more of it. The more there is of something in the “magic box”, the less its cost will be. Let’s now calculate the price of the fish. 10,000 USD/ 9,090 fish ≈ 1.10 USD. They rose in price because there is less in the “magic box”. There were more bananas than before, so its price dropped and there were fewer fish than before, so its price rose.

This is essentially how an Automated Market Maker works, as someone buys increasingly more of something, its price goes up. The fish are costing more because there are fewer of them. To determine pricing, the algorithm wants the value of what it is holding to be 50:50. Therefore, if you multiply the price of each asset by how many assets were in total, the total would still be a constant, 10,000 USD worth of bananas and 10,000 USD worth of fish. The “magic box” that we kept on mentioning is actually what’s called a Liquidity Pool.

Share on facebook
Share on twitter
Share on linkedin

Related Blogs »

Stic Blogs

Liquidity Pools

Liquidity pools, not to be confused with pools filled with water but rather pools filled with money. They are smart contracts that allow traders to

Read More »