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

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you might be wondering what is an automated market maker well 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's less of it and as they give it another asset it gets cheaper and cheaper because there's more of it basically it's supply and demand but it's using an algorithm instead of the traditional method which uses a person welcome to whiteboard crypto where we explain cryptocurrency topics using analogies stories and examples so that you can actually understand them and in this video we're going to cover what an automated market maker is and exactly how it works let's dig in let's say that you're a potato farmer you're sick and tired of going to work and seeing potatoes everywhere then coming home to eat only more potatoes even though you can cook some potatoes in very interesting ways you do not want any more potatoes but here's the real kicker though you live in a village of potato farmers 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 found a village over east who 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 and you don't want the chance to disappear 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 magical lamp to keep safe that way they don't go bad but he wants to keep a perfect ratio of the value of both of these the trader goes on since together we put in 50 000 apples and 50 000 potatoes he wants both of these 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 to buy now 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 it uses the inverse formula x times y equals k well x and y are the quantities or the amounts of the things that you have where k is a constant that always stays the same and it does not change in this case k is 2.5 billion let's keep going on with an example so that maybe you can understand it just a bit better the trader says right now there is a perfect 50 to 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 at more than a dollar let me go through an example with you guys so you know how it works alright so right now there are fifty thousand apples and fifty thousand potatoes and the number of both of those must equal 2.5 billion when multiplied so 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 he waits while the genie figures out how many apples to give him so 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 let's start with some math so we take 2.5 billion and we divide it by 57 000. you might be wondering why well hopefully you'll see in a second the answer we get to this math question is 43 859 so this is the number of apples that should be left over in the magical genie's lamp however right now there's 50 000 so we just need to find out the difference and give the difference to the potato farmer well the difference is six thousand one hundred forty so we give the potato farmer six thousand one hundred and forty apples now you might be wondering how come we gave seven thousand potatoes but we got around six thousand apples well as more and more apples were bought up they became more expensive this is why the farmer didn't get exactly 7 000 apples back so now there are 57 000 potatoes and 43 859 apples in the genie's lamp let's make sure that we didn't upset the genie 57 000 times 43 859 does equal 2.5 billion so the magical genie is still happy i hope that this is starting to make sense and if you've gotten this far into my explanation of how an automated market maker happens without even using any technical words i think we deserve a big thumbs up but 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 fifty thousand dollars worth of apples in the beginning since the magical genie said he priced them at one dollar and there was 50 000 of them so we just need to keep 50 000 as a constant when we're calculating their value this is how much each asset should equal so potatoes would be 50 000 over 57 000 because that's how many potatoes we have which brings their price to 87.7 pennies for each potato you might be wondering why did they drop from a dollar well it's because someone brought a lot more of them to the genie it's basic supply and demand for example if you could grow gold on trees in your backyard gold would suddenly be a lot cheaper because there's a lot more of it the more there is in the genie's lamp the less they will cost so from now on instead of saying genie's lamp i'm going to call it what it really is a liquidity pool so now let's calculate the price of the apples this calculation would be fifty thousand dollars over forty three thousand eight hundred and fifty nine this means the apples are worth a dollar and fourteen cents they rose in price because there's less of them in the liquidity pool so since this potato trader gave a bunch of potatoes to the liquidity pool and took out a bunch of apples the price of apples went up and the price of potatoes went down basically due to supply and demand which is shown in the formula x times y equals k now i personally learned from examples and this concept took me a week of studying to fully understand so let's go over another example let's say a potato farmer brings up another 10 000 potatoes so 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 that there should be 37 313 apples in the pool but right now we have 43 859. so we just calculate the difference and give it to the potato farmer which is 6546 this time the potato farmer paid even more for his apples since he kept buying them up the liquidity pool charges more and more for them that way it never runs out of stock the price will exponentially keep going up as he buys more so now there are sixty seven thousand potatoes and thirty seven thousand three hundred thirteen apples in our liquidity pool both of these numbers multiply to two point five billion so the genie which is actually the algorithm is happy now let's calculate the price fifty thousand dollars divided by sixty seven thousand potatoes means the potatoes are worth seventy four point six pennies they dropped even lower next fifty thousand dollars divided by thirty seven thousand three hundred thirteen apples means the apples are now worth a dollar and 34 cents they rose in price so again we saw that there were more potatoes than before so the price dropped and there were less apples than before so the price rose now hopefully you are understanding how an automated market maker works as someone buys more and more of something the price goes up the apples are costing more because there's less of them and when it comes to pricing the algorithm always wants the value of what it is holding to be 50 50. so if you multiply the price of each asset by how many assets were total in the liquidity pool the total would still be fifty thousand dollars worth of apples and fifty thousand dollars worth of potatoes let's do one more example really quick just to drive it home this time an apple farmer comes along with two thousand apples so he adds them to the liquidity pool and now there are 39 313 apples but we need to figure out how many potatoes to give him if you want to you can pause this video and try to come up with a number on your own just for fun leave a comment of what you come up with in the comment section below so finishing the math 2.5 billion divided by 39 313 gives us 63 592 which is how many potatoes there should be in the pool well right now there's still 67 000 potatoes and the pool only wants sixty three thousand five hundred ninety two so we take the difference and we give it to the apple farmer which is three thousand four hundred eight potatoes so in essence the farmer gave two thousand apples and got three thousand four hundred eight potatoes because at the time his apples were very valuable now we went over those examples really quick and feel free to go back to the beginning of this video and watch it again and if you're still kind of confused i highly recommend watching our video on liquidity pools and how they work but one thing i want you to know is that a real liquidity pool can sometimes have up to millions of dollars worth of assets in it and you should know the more money that is in a liquidity pool the stabler the price is if there were half a million apples and half a million potatoes and you still only wanted to trade around 2000 apples the price difference wouldn't change as much as we saw in our example because the amount of apples you were trading in proportion to the amount of apples in the pool was a very small amount now also you should know that liquidity pools reward investors and the investors are the people who put up the money into the liquidity pool in the first place they give those investors a small fraction of each trade that happens on their platform now even if this is less than one percent of each trade if someone is trading multiple times a day those numbers really add up and it can be profitable for the investor another thing to know about liquidity pools is that they can get really complicated really fast because what if another trader came along and wanted to add another 50 000 apples and 50 000 potatoes from the villages that he found how do we make sure that the investors can take out their original investment as the price is changing what about if we find a pineapple farmer and we want to add him to the trading pool well there are answers to these questions but they're for a different video as this one has came to its end we try to keep these videos short and very simple to understand so if you want to learn more consider subscribing to watch our future videos or checking the playlist in the description for similar topics thank you guys so much for watching we hope that you learned something and we hope to see you in the next video
Info
Channel: Whiteboard Crypto
Views: 367,213
Rating: undefined out of 5
Keywords:
Id: 1PbZMudPP5E
Channel Id: undefined
Length: 10min 25sec (625 seconds)
Published: Sat May 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.