The Beginner’s Guide to Automated Market Makers
Decentralized Finance (DeFi) is all the rage in the crypto world these days. With more and more innovative products being launched on a daily basis, it is totally worth the hype and the attention it is getting. After all, it is changing how people view finance by making it safer and more accessible.
Automated Market Makers are a huge part of the DeFi space. But before we talk further about them, here’s a list of everything that you’ll find in the article. Feel free to jump to any section you like.
- What is Market Making?
- What is an Automated Market Maker (AMM)?
- How does an Automated Market Maker (AMM) work?
- Why do we need Automated Market Making?
- What are the disadvantages of Automated Market Makers (AMM)?
- What are the best Automated Market Makers (AMM)?
- FAQs
- What is a liquidity pool?
- What is impermanent loss?
And with that out of the way, let’s jump right into it!
What is Market Making?
Before we get into details about what automated market makers (AMM) are, let us first take a look at what market making is all about.
To put it simply, market making is the act of providing liquidity to the given market. In case you're wondering what liquidity is, it refers to how easily an asset can be turned into cash without affecting the market price of the said asset.
Let us talk about the process with the help of an example.
Imagine that a seller wants to sell their asset. Ideally, the seller would go to the market and quote a price for their asset. And then an interested buyer willing to pay the quoted price for the said asset would buy the asset.
But what if the buyer decides that the price quoted for the asset is not justified? What if the buyer is of the impression that the real value of the asset is much lower than what was quoted? And what if this feeling resonates with all of the potential buyers? There would be no trade until the buyers and the seller agree to a price for the asset that suits both.
Traditional markets use order books and systems to match orders for the right buyer to find the right seller. The order book isn't actually a book—at least these days it isn't. On the contrary, it is an electronic record that not only maintains all orders but also displays them.
In order book markets, the sellers have to place a sell order in the order book. The order book then shows it to all the traders in the market along with the quoted price.
Likewise, the buyers have to place a buy order in the order book along with the price at which they're willing to buy an asset. The order matching system then pairs the buyers and the sellers and settles the orders.
Enough of how the system works. Let's get back to the problem at hand and see how it pans out in the case of order book markets. If the seller quotes a price that none of the buyers quote, it will be impossible for the order matching system to pair the seller with a buyer. And when that happens, it is said that the market for that asset is illiquid.
It is not rare for such an occurrence to happen. After all, every seller would try to set the highest price for their asset. Likewise, every buyer would try to get the asset for as low a price as possible. It's human nature to want to maximize profits. And if neither the seller nor the buyer is willing to budge, you would definitely get a stalemate.
To overcome this issue, what traditional markets do is introduce traders who are ready to buy or sell certain assets at any given price.
So a seller seeking high prices for their asset can always rely on these traders to buy their asset. Likewise, buyers looking forward to paying the lowest possible price to buy an asset can do so by purchasing it from these traders.
These traders allow trade to happen in markets where it looks almost impossible for any trade to happen. And for this very reason, these traders are called market makers. Aptly enough, the process of creating a market for an asset is called market making.
The market makers help increase the efficiency of financial markets and reduce the price volatility of the assets by providing liquidity for the assets at all times.
What is an Automated Market Maker (AMM)?
Automated market makers (AMM) are essentially algorithms used by decentralized exchanges (DEXes) to set the price of an asset. These algorithms rely on mathematical formulas instead of order books to decide what the price of the given asset should be.
The formula used by the algorithm varies from protocol to protocol. Uniswap, for example, uses the formula: x*y = k. Here, x is the amount of tokens belonging to a certain cryptocurrency present in the liquidity pool. The y in the formula is the amount of tokens belonging to another cryptocurrency present in the liquidity pool.
Finally, the k in the formula is a fixed constant. So, you see, the algorithm has to ensure that the total liquidity of the liquidity pool remains constant all the time. This makes Uniswap a Constant Function Automated Market Maker.
I'm sure you would agree that this is a great way to make markets and that the decentralized finance (DeFi) industry did a great job at coming up with it. But one of the first institutions to make use of automated market making was actually Shearson Lehman and Brothers. Isn't it surprising how far back the idea goes?
Shearson Lehman and Brothers used the technology available at that time to bring liquidity to the traditional market. And in doing so, they reduced the probability of human manipulation by many folds.
DeFi is using the technology available right now to do a lot more than just that. After all, blockchain technology has more complex solutions to offer than just a few simple algorithms.
Let us now take a look at how automated market makers work!
How does an Automated Market Maker (AMM) work?
Not very unlike how order book exchanges worked, automated market makers need trading pairs to function. In traditional markets, this could be USD/Gold or any asset paired with any other asset. This way, you could come to the market with one asset and go back home with the other.
The difference between automated market makers and traditional markets comes in when we talk about the counterparty. You see, you don't need another trader on the other side of the trade for a trade to happen. Instead, when it comes to automated market makers, you simply interact with smart contracts. These smart contracts then make the market.
On decentralized exchanges (DEXes), the trades directly happen between the wallets of the users.
So, if you trade your Kyber Network Crystal (KNC) tokens for Synthetic Network (SNX) tokens, you can be sure that there's another user trading their Synthetic Network (SNX) tokens for Kyber Network Crystal (KNC) tokens on the platform. And what you would have witnessed is something that is called a peer to peer (P2P) transaction.
But when you trade on automated market makers, your transactions are peer to contract (P2C) transactions. So you don't trade with another trader but instead, trade with the platform itself. And the price you get for the assets you intend to buy or sell is something that the formula decides for you.
Now, you might be wondering how the platform gets the liquidity for trading with you. Well, that is done by users of the platform who provide liquidity to the various liquidity pools the platform has for different token pairs. And for doing so, these users are called liquidity providers.
Don't worry if you don't understand the concept properly just yet. We are going to discuss what liquidity pools are later in this article.
Why do we Need Automated Market Making?
To answer the question of why there's a need for automated market making in the world of finance, we need to look back at the time when it was first used.
Back when Shearson Lehman and Brothers implemented the concept of automated market making for the first time, it was a different era. Technology was seeing rapid advancements back then and trading was at a rise on NASDAQ and other stock market indices all around the world.
The only problem was that the entries in the order books still required to be done by humans. Imagine rooms full of people making entries in the order books by hand. That's how the markets looked like back then.
It isn't surprising, therefore, that there was a lot of room for human manipulation in these markets. In fact, that was quite a problem back then. People with a lot of capital and influence could pay the market makers to shift the prices of the assets in their favor. And they did it quite a lot.
To make the markets fairer and to bring more liquidity to the market, certain rules were formed. These rules regulated the prices of the assets by performing certain actions. So, if the price of an asset sees an increase, a certain action would be performed. Likewise, if the price of an asset decreases, some other action would be performed.
But technology was still evolving and people were trading only during certain hours of the day.
Coming back to the present, blockchain technology has enabled markets to be open at any given point in time. It doesn't matter what time of the day it is, or even the day, week, or month (or year, for that matter). The markets on the blockchain are always open and they are not only safer but more efficient now.
We're in the 21st century and it is only fair to expect our financial markets to reflect the same.
What are the disadvantages of Automated Market Makers (AMM)?
Automated market makers have a lot of great things to offer. However, they come with their own set of problems.
To start with, since we're relying only on smart contracts for everything that happens on the platform, any bug in the smart contract could wreak havoc on the entire system. AMMs like Uniswap and Balancer have seen this happen when some liquidity providers lost their money because of complex smart contract interactions.
Moreover, AMMs have to largely rely on traditional order book exchanges for arbitrage. Despite the elegance of the mathematical formulas these platforms use, they just can't come up with a true representation of the market sentiment.
But by relying on arbitrage traders for pricing the assets what they should be, the problem of impermanent loss comes up. And that is something all of the AMMs have to face.
These platforms allow arbitrage traders to make huge profits by balancing out the prices of the assets listed on the AMMs. However, it is the liquidity providers who have to pay for this.
And if the price moves a bit too far in one direction, liquidity providers stand a chance to lose their money (or at least some of it) despite the fact that they receive trading fees. While it is true that such a loss is impermanent since the price of the asset can always bounce back, it doesn't always bounce back.
Moreover, scalability is still an issue in the case of AMMs. Given the gas congestion that we're seeing in AMMs right now, it looks like they're about to hit the ceiling now in terms of usability.
While more and more improvements are being made in the world of AMMs, the trade volume and liquidity that they enjoy are nothing compared to some of the biggest centralized exchanges.
But then, the centralized exchanges have been around for much longer than AMMs. So we should give AMMs some time to work their way up and stand neck to neck with centralized exchanges.
What are the best Automated Market Makers (AMM)?
There are many AMMs in the DeFi space now. If we talk about all of them, that'll take an entire blog on its own. So let's focus on three of the best AMMs out there.
1. Uniswap
Uniswap is an Ethereum-based protocol that was launched back in November 2018. Created by Hayden Adams, the protocol is one of the first to provide automated liquidity. As of now, Uniswap is one of the most popular AMMs in the DeFi space.
The platform uses smart contracts to set the prices of all the tokens on the platform automatically. And by doing so, ensures a fair market while adding to the security as well as the decentralized and censorship-resistant nature of the platform.
2. Curve
Curve is an AMM that aggregates stablecoin tokens into liquidity pools. Doing so allows the users of the platform to swap tokens without worrying about a high slippage.
With the lending protocols of the platform, it ensures that liquidity providers are able to earn stable interests and trading fees.
Much like Uniswap, you get pool tokens as a reward for adding liquidity to liquidity pools on the platform. But when you wish to withdraw from the pool, you get to choose the stablecoin you get. This makes it very different from the other AMMs.
3. Balancer
Balancer is, without doubt, one of the most innovative AMMs in the DeFi space. It has features like multi-token pools, dynamic pool fees, and custom pool ratios to offer its users.
The platform allows the creation of liquidity pools of 8 tokens at max. This makes it an automated portfolio manager in the suit of an index.
To the delight of all users of the platform, Balancer adjusts the pool fee based on the condition of the market and the volatility of the assets.
FAQs
What is a liquidity pool?
Liquidity pools can be thought of as huge stacks of assets that you, as a user, can trade against. They enable the AMMs to allow people to trade, borrow, and lend on the platform.
There are some users who add their assets to these stacks. In fact, it is because of these users that these stacks of assets are huge in the first place. What these users are actually doing by adding their assets to the stacks is providing liquidity. And for that reason, these users are called Liquidity Providers (LPs).
Another way of looking at these users is as market makers because at the end of the day, by adding certain assets to the liquidity pools, they provide liquidity to those assets and sometimes create, sometimes support the market for those assets.
Now the question is, what's in it for the liquidity providers? Well, the platforms charge a certain fee for the trades happening on the platform. Liquidity providers get a percentage of the fee charged from the traders in the liquidity pool that they provided liquidity to.
Liquidity pools are really important for the AMMs to work efficiently. The slippage incurred by large orders reduces when the liquidity in the pool increases. And that, in itself, is a major factor that attracts more people to the platform thus increasing its trade volume.
A thing to remember, however, is that the slippage varies from AMM to AMM depending on the platform's design. Since the pricing is defined by an algorithm, the slippage changes with the algorithm.
In most cases, it is decided by taking into account the change in the ratio between the tokens in a liquidity pool after a trade happens. But what if the change in the ratio is huge? The wide margin would definitely lead to quite some slippage.
What is impermanent loss?
Let's say that you're a liquidity provider for a liquidity pool on an AMM.
For this specific example, let's say the AMM is Uniswap and the liquidity pool we're talking about is of the ETH/DAI token pair. Since Uniswap is a Constant Function Automated Market Maker, you would need to provide an equal amount of ETH and DAI tokens to add liquidity to the pool.
Now imagine that the prices of ETH rises sharply. When that happens, users on the platform would try arbitraging until the price of ETH in the liquidity pool becomes the same as the market price for ETH.
But you already have your ETH locked in. If you had your ETH tokens with you when the price of ETH rose, you could've sold your tokens at a profit. But since your ETH was in the liquidity pool, you incurred a temporary loss until the arbitrageurs came in and ensured that the price of ETH in the liquidity pool is the same as its market price.
This temporary loss is what we call an impermanent loss. And it is called so because it is not until you pull your tokens out that the loss becomes permanent.
To understand that better, let's hop back into the example above. You had your ETH locked in while the price of ETH shot up. If you pull your ETH tokens out while the price of ETH is lower in the liquidity pool compared to that in the market, you make your loss permanent. But if you hold on, the arbitrageurs would calibrate the price of ETH on the two platforms. And when that happens, your temporary loss is reversed.
Before you go…
As more and more AMMs are hitting the market, the competition is on a rise. And the thing about competition is that it leads to improvement.
The platform would have to keep hustling and innovating to stay relevant. And that gives us hope that AMMs would improve substantially in the future.
That said, time will tell how much the AMMs manage to improve in the times ahead.