Automated Market Makers Explained

A market maker is someone who adjusts the price of one asset to meet the supply and demand of the other and vice versa. Automated market makers are smart contracts (self-executing contracts) that do just that, but as the name suggests, automatically, with the help of algorithms and equations. 

But what are these equations? How does this apply to cryptocurrency? Why are automated market makers exclusive to decentralized exchanges? 

We’ll answer all these questions (and more) in this article. 

What are Automated Market Makers?

Generally, centralized crypto exchanges act as middlemen who find suitable matches to facilitate trades between two traders, one wanting to buy Bitcoin (or any other cryptocurrency) at a certain price and another wanting to sell it at that price, and vice versa. 

These exchanges must provide liquidity (a lot of it), so everyone can find a suitable match to complete their trade. Hence, a lack of suitable matches is an indicator of low liquidity. 

This is where automated market makers come into the picture. AMMs eliminate the middlemen, enabling decentralized crypto trading directly between two traders with the help of smart contracts. 

You can trade crypto directly from your non-custodial wallet instead of adding funds to your exchange wallet first, which is the norm in centralized exchanges. 

AMMs are the backbone of decentralized exchanges

Read everything you need to know about centralized Vs decentralized exchanges

Now that we know what AMMs are and what they do. Let’s find out how they work. 

How Do Automated Market Makers Work?

Firstly, automated market makers don’t allow you to trade crypto directly for fiat currency. Instead, AMMs only support trading in trading pairs, meaning you can only trade one crypto for another. 

Some platforms are different. Hence, there are exceptions, but we’ll discuss that later. For now, trading pairs is the standard assumption we’re going forward with. 

The following is an example of a trading pair that we’ll consistently use throughout this article to understand different concepts – 

ETH/USDT, where there are 200 ETH and 20,000 USDT. 

So, the value of 1 ETH = 100 USDT (20,000 / 200)

Constant Product Formula

The constant product formula is what most DEX platforms use to price the assets in a trading pair. Here’s the formula – 

Constant Product Formula - Automated Market Makers

In this formula, 𝑥 and y denote the total units in each asset, while k denotes their product. And k is always constant. 

Using the example, it will look something like this – 

200 x 20,000 = 4,000,000

The idea is that the product of the total units in each asset should always be the same regardless of their individual value. In other words, both assets should share a 50:50 ratio in total value.  

So, if someone wants to buy 2 ETH, they must add roughly 202.02 USDT to the liquidity pool to maintain the value of k. 

Why?

4,000,000 / 198 = 20,202.02 

1 ETH = 102.03 (20,202/198)

As you can see, taking out ETH from the pool decreases its supply causing its value to go up, while adding more USDT increases its supply, further reducing its value to maintain the value of k. 

We know that’s a lot of math to take in at once. We suggest reading this section a few more times to understand what’s really happening here. 

Liquidity Pools & Liquidity Providers

Remember how we talked about centralized exchanges adding massive amounts of liquidity to facilitate trades and find suitable matches? As you know, in a CEX, only high-net-worth individuals can add liquidity. 

But that’s not the case in decentralized exchanges. With the help of Automated market makers and liquidity pools, anyone can become a liquidity provider (LP). 

In fact, they are incentivized to do so by the opportunity to earn a share of trading fees that traders pay. Even though these rewards are pretty low, with enough trading volume and time, the amount adds up fast. 

Liquidity pools consist of different trading pairs that people can choose from. It could be ETH/USDT, BTC/ETH  or anything. Some platforms like Uniswap allow you to create your own trading pool (pair). 

But as a liquidity provider, you must add liquidity in equal ratios of both assets of a trading pair. So, continuing with the example, if you’re adding 5 ETH, you must also add around 500 USDT. 

When you add liquidity in a pool, you’ll receive tokens in exchange. These tokens represent your contributions. Think of them as the equivalent of an invoice or receipt. 

Although you’ll still hold and own the original cryptocurrency, sometimes it can raise tax complications. The IRS views these transactions as disposal events, meaning you may be subject to capital gain taxes. To know more about the tax implications of DeFi activities, read this

Yield Farming Opportunities

You can use the token you receive in exchange for providing liquidity to earn more rewards by putting them in yield farming protocols. This is a part of leveraged yield farming strategies. 

Needless to say, this will introduce further complexity, especially in taxes. Read our in-depth guide on yield farming and leveraged yield farming to learn more. 

Impermanent Loss

Since 𝑥 x y = k, no matter what the market price of a cryptocurrency is out there, its price inside the liquidity pool will be solely determined by its ratio to the other asset because that’s how automated market makers work. 

So, continuing with the same example, if more and more people start selling ETH, its supply will increase, causing its price to go down more than its market price out there. This is when you realize an impermanent loss. The further the prices drift away from market price, the greater the loss you suffer.

As a liquidity provider, if you decided to keep your crypto funds in your wallet instead of a pool, you wouldn’t have realized this loss. However, It’s called an impermanent loss because the price may return to its initial position, or you might make more rewards than what you lost, making up for the loss. 

Nonetheless, here are some steps to take after realizing an impermanent loss

Examples and Variations of Automated Market Makers

Even though the constant product formula is the most popular and commonly used in Automated market makers, there are other, more complex ones, like the one Balancer uses. 

Balancers allow you to put up to 8 different tokens or coins in a single liquidity pool. Not only that, but it also lets you decide the ratio of each token and the transaction fee. It does this using a highly complex and multidimensional mathematical formula. 

Other than Balancer, here are some more liquidity pools example – 

For more options, check out our list of the best liquidity pools