Ultimate Guide to Automated Market Makers

Automated Market Makers have made defi more lean and cost optimized while outrunning the traditional market making.

The existence of DeFi is based on its ability to execute trading in a more efficient manner which helps it keep its cost down. AMMs play a crucial role in this aspect of DeFi by providing liquidity, through pools, to crypto pairs that were illiquid. Furthermore, this is done in a more efficient way than traditional market makers to keep overall costs down.

Automated Market Makers have revolutionized trading by enabling decentralized and automated liquidity provision, making it accessible to a wider range of participants. In this article, we will delve into the role of AMMs in DeFi, explore their detailed working mechanism, and provide examples to illustrate their functionality.

The Role of Automated Market Makers in DeFi

Automated Market Makers are a set of algorithms that make it easy for certain cryptocurrency pairs to be liquid and tradeable which were hitherto illiquid. They assume the role of traditional market makers who buy and sell assets from their accounts so that there is ample liquidity for a given asset.

However, traditional financial markets rely on order books and centralized exchanges to facilitate trading. However, DeFi aims to eliminate intermediaries and provide users with direct control over their funds. This is where AMMs come into play. AMMs are smart contracts that automate the process of market-making by algorithmically determining asset prices based on the available liquidity in a particular trading pair.

Automated Market Makers typically have the following role in a Decentralized Exchange.

  1. Liquidity Provision: AMMs enable users to provide liquidity to decentralized exchanges, creating pools of assets that can be freely traded. Liquidity providers (LPs) contribute to these pools by depositing an equal value of two different tokens, establishing a price relationship between them.
  2. Price Determination: Unlike traditional order books, AMMs use mathematical formulas, such as the Constant Product Market Maker (CPMM) model, to calculate asset prices based on the supply and demand of the pooled assets. This allows users to trade tokens at any time without relying on order matching.
  3. Automated Trading: AMMs eliminate the need for buyers and sellers to find counterparties for their trades. Instead, trades are executed against the liquidity pool, which automatically adjusts asset prices based on the trade volume and pool balances.

Different Automated Market Maker Models

There are several Automated Market Maker models such as Constant Product, Constant Sum, Constant Mean, and several others. However, these three are the most common ones. The goal of all market maker models is to provide stability by adjusting the quantity of one asset when the quantity of the other changes.

Constant Product Market Maker Model

In this model, the product of two variables is kept constant. Suppose “a” and “b” are two assets, “A” and “B” are their respective quantities and their product is “k”.

The pair is defined by the relationship:

A*B=k

If the value of “A” decreases, the value of “B” has to be increased to keep “k” constant.

The associated graph is:

Constant Product Market Maker Model used in Automated Market Maker Source: Dmitiry Berenzon
Constant Product Market Maker Model, Source: Dmitiry Berenzon

The Constant Product Market Maker Model was first implemented by Uniswap.

In the real world this equation becomes:

where R_α and R_β are reserves of assets “a” and “b” and γ is the transaction fees.

Constant Sum Market Maker Model

In the constant sum market maker model, the quantities of asset “a” and asset “b” are stabilized by the question.

A+B=k

where A, is the quantity of asset “a” and “B” is the quantity of asset “b”. The graph of this equation seems like:

Constant Sum Market Maker Model used in Automated Market Maker Source: Dmitiry Berenzon
Constant Product Market Maker Model used in Automated Market Maker, Source: Dmitiry Berenzon

There is another variety of Constant Sum Market Maker mode, that it, the Constant Mean Market Maker Model. Its equation is as follows

(A+B)/2=k

where, A is the quantity of asset “a”, B is the quantity of asset “b” and “k” is their mean.

A more complex version of this model is

A drawback associated with this design is that if one asset loses 1:1 parity with the other, it would allow arbitrageurs to buy the depreciated asset for cheap and therefore drain that depreciated asset which would make the pair illiquid. Therefore this model is not used much in Automated Market Makers.

The Working Mechanism of Automated Market Makers

To understand the working mechanism of Automated Market Makers, let’s take a closer look at the widely used CPMM model, as exemplified by the popular decentralized exchange protocol Uniswap:

  1. Pool Initialization: To create a trading pair on an AMM-based platform, an LP deposits an equal value of two different tokens into a liquidity pool. For instance, depositing 1 ETH and 200 USDT would create an ETH/USDT trading pair.
  2. Asset Price Calculation: The CPMM formula in Uniswap is represented as x * y = k, where x and y are the quantities of the two tokens in the pool, and k is a constant. This formula ensures that the product of the token quantities remains constant throughout trading. As a result, if one token’s supply increases, the other token’s price adjusts accordingly.
  3. Trade Execution: When a user wants to trade ETH for USDT, they send the desired amount of ETH to the liquidity pool. The AMM calculates the new pool balances and determines the amount of USDT the user will receive based on the new price. The user’s trade is executed directly against the pool, and the asset prices are updated accordingly.
  4. Liquidity Provider Rewards: LPs earn transaction fees for providing liquidity to the pool. These fees are distributed proportionally to the LPs based on their share of the liquidity pool. The fees incentivize users to provide liquidity and maintain balanced pools.

Definition: LP Tokens are those cryptocurrencies that a liquidity provider gets in exchange for their deposited liquidity. They are cryptocurrencies but are more like receipts and proof of payment to a liquidity pools and not tradeable tokens, at least not till now.

CREAM Finance has provided a way for the collateralization of LP tokens obtained from their platform where LP tokens can be provided for further liquidity or could be collaterized to take loans.

Example: Uniswap’s Automated Market Makers Functionality

Uniswap, one of the pioneering decentralized exchanges, utilizes AMMs to facilitate trading. Let’s consider a scenario where Alice wants to swap 0.5 ETH for USDT using Uniswap:

  1. Alice’s Trade: Alice initiates a transaction on Uniswap, specifying the desired input token (ETH) and output token (USDT) and the amount she wants to trade.
  2. Price Calculation: Uniswap’s AMM calculates the trade based on the current liquidity pool balances. If, for instance, the ETH/USDT pool has 100 ETH and 20,000 USDT, the AMM determines the price at which Alice’s trade will be executed.
  3. Trade Execution: Once the price is calculated, the AMM deducts the appropriate amount of ETH from the pool and transfers the corresponding USDT to Alice’s wallet.
  4. Pool Balances Update: The pool balances are adjusted after the trade, ensuring the constant product (k) formula is maintained. This adjustment reflects the impact of Alice’s trade on the pool’s asset prices.

Benefits and Risks of Automated Market Makers

Benefits:

  1. Increased Liquidity: Automated Market Makers enable decentralized exchanges to have constant liquidity pools available for trading, ensuring that users can trade assets at any time without relying on external participants.
  2. Accessibility and Efficiency: AMMs provide a user-friendly and efficient trading experience by automating the price determination process and eliminating the need for order matching.
  3. Incentives for Liquidity Providers: LPs earn transaction fees and sometimes additional token rewards for providing liquidity, incentivizing their participation, and fostering liquidity in the DeFi ecosystem.

Risks:

  1. Impermanent Loss: LPs face the risk of impermanent loss when the relative prices of the pooled tokens change. This can result in lower returns compared to simply holding the tokens.
  2. Price Impact: Due to the nature of Automated Market Makers, large trades can cause significant price slippage, especially when trading illiquid tokens. This may impact the execution price for traders.
Dhirendra Chandra Das
Dhirendra Chandra Das

Dhirendra is a professional with dual degree MBA specializations in Finance and Marketing. He has a keen interest in finance and crypto. Starting his investment journey in Finance since 2015, Dhirendra has more than 8 years experience in Traditional Finance and 3 years experience in Decentralized Finance.

Articles: 101