Automated market makers (AMM) are one of the major changes that has come with DeFi in 2019 and 2020. An AMM allows a much more fair and transparent trading of cryptocurrency, but it can be a very difficult concept for beginners to grasp.
This article will explain how AMM works. We will also explain the differences between centralized and decentralized exchanges and even cover some of the downsides of AMM.
The Differences Between Centralized and Decentralized Exchanges
To understand automated market makers (AMM), you first must understand the difference between a centralized and decentralized exchange and how the price of cryptocurrency on each type of exchange is determined.
Fortunately, the differences are clear and easy to understand.
First, centralized exchanges are controlled by one central authority – the cryptocurrency exchange. Cryptocurrency is also stored in the exchange’s wallet. There’s a saying in cryptocurrency:
“If you don’t have the private keys, then it’s not your cryptocurrency.”
It’s true. The cryptocurrency exchange holds the private keys, which makes them the owner of the cryptocurrency. This means you must rely on the security of the exchange to protect your cryptocurrency.
The other problem with a centralized exchange is that it uses an order book. Order books are the standard for financial exchanges, but they are much slower and require more work to operate.
Both those factors result in much higher fees than those offered by a decentralized exchange.
Decentralized exchanges are a little different. First, there is no central authority on a decentralized exchange.
All orders are done on the blockchain through a smart contract. A buyer places cryptocurrency into a smart contract pool and the cryptocurrency they purchase is deposited in their wallet.
This is safer than a centralized exchange. It also requires less work, which means lower fees.
The interesting part of a decentralized exchange is that it should not have an order book, which raises an interesting question.
If there is no order book to match buyers and sellers, then how is the price of a cryptocurrency determined?
The answer is, of course, automated market makers (AMM).
What is an automated market maker (AMM)?
Basically, an automated market maker (AMM) is an algorithm in a smart contract that automatically determines the exchange rate of cryptocurrency based on the amount of cryptocurrency in the pool.
This does not really explain how an automated marker maker (AMM) works, though. The next section will go into detail on how a traditional automated market maker (AMM) works.
How an Automated Market Maker (AMM) Works
Automated market makers rely on a fairly basic formula to operate. This formula is the following:
X and Y represent cryptocurrencies in a pool. C represents a constant value. Now, the value of x and y is based on the value of the cryptocurrency and not the total number of tokens in the pool.
For instance, if ETH is worth $1000 and DAI is worth $1, then a theoretical pool would look like the following:
100 ETH * 10,000 DAI = 100,000
The price will remain stable until a change comes along. For instance, if someone wishes to withdrawal 1 ETH from the pool, the following equation will apply:
(100 ETH – 1 ETH) * (1000 DAI + (1ETH * [price in DAI] + fee) = C
As you may notice, C will change slightly from this due to the fee. This is perfectly fine because the fee is small. Plus, C is based on X and Y and not the fee.
Anyway, the benefit of this model for determining the price is that the pool and price are always equaled out. If not enough ETH is in the pool, then the price of ETH will gradually increase until the price multiplied by DAI equals C.
It’s a really simple system that assures a balanced price.
That said, it does have some downsides. These downsides are covered in the below section.
The Downsides of AMM
There are some downsides to automated market makers. The two biggest problems surround the publicly available order book and the relatively small liquidity of decentralized exchanges.
Pumping is Easy
The first problem with an AMM is that pumping the price of a cryptocurrency. This is mostly commonly done by placing a large buy order that will cause the price to spike. Remember, it’s a simple formula to determine the price combined with a small amount of liquidity.
This is just begging for a whale to completely manipulate the price. Fortunately, this type of manipulation is not too common by a single actor.
The more common type of manipulation is something called front running. This is actually illegal if the order book is private. However, the order book on a decentralized exchange is publicly available.
This allows a front runner to jump the order queue by initiating a trade by using more gas, lowering the price, and then purchasing the cryptocurrency at the lower price from the existing order.
This is a relatively simple problem to solve – make orders secret until after the block has been mined. Of course, different issues arise with that solution, but it does eliminate the front-running that currently plagues decentralized exchanges.
How does liquidity work with AMM?
Liquidity with automated market makers works a little differently than standard liquidity. Remember, a decentralized exchange relies on cryptocurrency pools.
With that in mind, liquidity is provided by users “locking in” cryptocurrency into the pool. The fees collected are then distributed to liquidity providers in exchange for providing liquidity. The fees are split evenly amongst those that provide liquidity. For example, if you place 1 ETH into a 100 ETH pool, then you receive 1% of the trading fees for the time you have the ETH locked into the pool.
Is there an arbitrage opportunity with AMM?
Yes, arbitrage is a great opportunity with AMM and decentralized exchanges. For example, if the price of ETH on a decentralized exchange rises to $115 (while staying at $100 on Coinbase) due to a large purchase of ETH, then an arbitrageur will purchase the ETH for $100 on Coinbase and sell it for $115 on the decentralized exchange.
The arbitrageur will continue to do this until there is no arbitrage opportunity available. Arbitrageurs serve an important function on decentralized exchanges as they keep the price of a cryptocurrency comparable to those on centralized exchanges.
Overall, automated market makers (AMM) are not a difficult concept to understand. It’s simply a pool that rebalances its price after every transaction. Of course, things can get much more complicated than this with much more complicated formulas or cryptocurrency pools that contain more than two cryptocurrencies, but that goes beyond the scope of this article.
The point we want to emphasize is that decentralized exchanges rely on some form AMM to price cryptocurrency, and that is a much more efficient model than the order book model offered by centralized cryptocurrency exchanges.