← Back to Academy

🤖Dive in the Pool #2 : What is an AMM (Automated Market Maker)?

Published on 
January 11, 2024

Welcome back for episode #2 of Dive in the pool!

Based on our poll from last article, you want to know more about AMMs. Here at Lobster, we listen to our community! So get ready to know everything you need to understand about this essential component of decentralized finance (DeFi).

Let’s dive in !

Curious about DeFi and its various components? Each week, our team at Lobster takes a closer look at one aspect of DeFi, turning you into an expert on this fast-moving financial sector.

In our previous article on liquidity pools (if you haven’t read it yet, click here), we briefly introduced the concept of AMM (Automated Market Maker). Now it’s time to dive deeper into this innovation.

🤖What’s an AMM ?

An AMM is a key element of DeFi. It is an algorithm that automates the process of executing trades on decentralized exchanges (DEX), making it possible for users to freely swaps their assets for another, 24/7, without an intermediary matching buyers and sellers.

AMMs operate through liquidity pools, where liquidity providers make cryptocurrency pairs available. These pools enable decentralized exchanges to operate. AMMs determine the price of an asset based on its quantity in the pool, according to a precise mathematical formula.

If a user adds (sells) a cryptocurrency to a pool, its price falls due to the increase in supply. Conversely, if a user withdraws (buys) a cryptocurrency, its price rises.

Now you got the big picture, but to make you a true expert, you need to know in detail how it works.

💼How does an AMM work ?There are several models of AMMs, but we won’t explain all of them right now. Let’s focus to the most widespread, the “Constant product market maker” formula: X*Y=K.

Here, X represents the total quantity of one token in the pool, Y that of the other token, and K is a constant.

Let’s break it down and even if you’re not a math guy(or girl), don’t worry, it’s pretty straightforward.

📐Let’s do some quick maths

Let’s take an example:

We have a liquidity pool made up of ether (ETH) and USDC. Initially, the pool contains 500 ETH worth $500,000 and 500,000 USDC also worth 500,000. The value of 1 ETH is 1000 USDC. The constant K for this pool is calculated as follows:

K = Quantity of ETH * Quantity of USDC = 500 * 500,000 = 250,000,000.

Now consider a trader who wishes to exchange 10,000 USDC for ETH. After this exchange, the total quantity of USDC in the pool will increase by 10,000 to 510,000 USDC.

To maintain constant K at 250,000,000, we need to recalculate the new quantity of ETH in the pool. Let’s use the formula X * Y = K, where Y is now 510,000 USDC :

500 ETH * 500,000 USDC = 250,000,000 (initial K) X ETH * 510,000 USDC = 250,000,000 (K must remain constant)

To find the new quantity of ETH (X), we rearrange the formula to calculate X :

X = 250,000,000 / 510,000 ≈ 490.196 ETH

This means that the new quantity of ETH in the pool after the exchange is approximately 490,196 ETH. If the pool originally had 500 ETH, this means that the user receives the difference, that is around 500–490.196 = 9,804 ETH for his 10,000 USDC. This phenomenon is called “slippage” and happens when a large order is placed on a liquidity pool that is too illiquid to handle the size of the order.

The new ETH price in USDC can be calculated by dividing the total quantity of USDC by the total quantity of ETH in the pool:

New ETH price = Total quantity of USDC / Total quantity of ETH = 510,000 USDC / 490.196 ETH ≈ 1,040.4 USDC per ETH

So, after the transaction, the new price of one ETH in this liquidity pool is approximately 1,040.4 USDC.

In this example, the price change is quite marked, as the total value of the liquidity pool is not extremely high. However, in a pool worth millions of dollars, the impact on price would be much less significant.

Next, let’s explore the various advantages that AMMs offer to users and liquidity providers in the DeFi ecosystem.

👍Advantages of AMMs

AMMs offer unique advantages such as :

Enhanced Liquidity on decentralized exchanges: AMMs significantly boost the liquidity of decentralized exchanges. This high liquidity is crucial for the efficient operation of these platforms.

Passive Income for Liquidity Providers: Those who contribute assets to liquidity pools (liquidity providers) can earn passive income through transaction fees generated within these pools. This is a key incentive for participation in the DeFi ecosystem.

While these advantages are significant, it’s also important to consider the challenges faced by liquidity providers in these AMMs, particularly the concept of “impermanent loss.”

💪Challenges for liquidity providers

Providing liquidity may seem risk-free at first glance. However, you need to be aware of the phenomenon known as “impermanent loss”.

This loss occurs when the price of an asset in the pool diverges significantly from the price in the wider market. The liquidity provider could have earned more by simply keeping his cryptos in his portfolio.

This loss is said to be impermanent, because if the price returns to its initial level, there is no real loss. The loss is only effective if the liquidity provider withdraws his cryptos from the pool when the price is different from the one of his initial deposit. If this concept seems complex, don’t worry, we’ll come back to it in our next article.

🦞Lobster — DeFi made easy

At Lobster, we’ve created an algorithm in order to benefit from the best yield from liquidity providing, without having to worry about impermanent loss, or anything else.

Thanks to constant market and on-chain observation, Lobster’s algorithm automatically triggers position exits when the risk of negative impact on your returns becomes too high.

Want to dive deeper into the fascinating world of DeFi with Lobster by your side?

Take a look around our website →