What is an automatic market maker?

Automatic Market Market Maker (AMM)-a software algorithm for liquidity control and pricing of crypto activists on decentralized exchanges.

AMM systems are widely used in Defi, in particular on decentralized exchanges (DEX), such as including Uniswap, Balancer, Bancor and Curve.

To create decentralized markets, AMM uses liquidity in cryptocurrency publicly available pools of several tokens blocked in special smart contracts.

How an automatic market maker appeared (AMM)?

Automatic market maker (AMM) is an autonomous trading mechanism on which most trading Defi protocols work. It provides the movement of capital and the implementation of user metabolic operations in available crypto acting markets.

The first well -known developer who spoke about the implementation of AMM was a member of the GNOSS project Alan Liu. His ideas were set forth by Ethereum by Vitalik Buterin on Reddit in 2016 and on a personal blog in July 2017.

This concept formed the basis of the Uniswap platform, which received the first grant of $ 100,000 from Ethereum Foundation. In addition, Vitalik Buterin advised Uniswap developers.

Subsequently, AMM became widely known precisely thanks to Uniswap. At the same time, one of the first successful AMM implementations can be called the Bancor Network platform, which raised $ 140 million through the ICO in June 2017.

How liquidity pools are associated with AMM?

The key element necessary for the work of AMM is a liquidity pool-a kind of storage of crypto actes in the form of a smart contract. The liquidity pool usually consists of two crypto assets and forms a market – an analogue of a trading pair on a centralized exchange.

Some participants in the pool block their funds to receive income from the commissions for exchange. Such users are called liquidity suppliers.

Another category is direct users of a decentralized exchange that exchange cryptocurrencies in the protocol (such operations are called “swaps”), using some of the pools.

To better understand the liquidity pools, consider what led to their creation.

The first DEX-exchanges worked on Ethereum and used the standard book of orders used on centralized exchanges for trading. For such a trading mechanism to be effective, it must have an extremely high transaction processing speed. Given that operations on a decentralized exchange are confirmed through the blockchain, the real speed and capabilities of such DEX were extremely limited. AMM allowed to find a solution to this problem.

Thus, AMM is a fundamentally different way to create an asset market, being a formula or rules for which the protocol works with applications for the purchase or sale, as well as with user reserves.

How liquidity pools work?

Two or more assets can be used in the pools. For example, on the Uniswap exchange, you can create pools for paired tokens. The Balancer platform allows you to create pools for three or more tokens. And the Curve protocol is designed for pools based on assets with a similar value, such as ETH and wrapped Weth or USDC and DAI token token. The work of these pools is regulated by AMM.

Each of these AMM-dex can use its own formulas and rules for interacting with liquidity bullets. For example, the Uniswap protocol uses the following formula: x * y = k.

In equation X and Y, the number of tokens available in the liquidity bullet; k is a constant value called the invariant. In the case of Curve, formulas x * y = k and x + y = k are used.

According to the X * y = k formula, Sushiswap and Pancakeswap projects also work-this is the most common type of AMM-dex.

How is the pricing of the asset in the liquidity bullet?

When blocking liquidity in the pool, its supplier receives special LP tokens confirming their share in the bullet. They can be presented as a debt receipt, the possession of which gives the right to receive commissions from exchange operations on the exchange and return their share from the pool.

LP tokens is a transmitted cryptoactive that can be sold or exchanged in the open market, as well as invest in third-party Defi applications.

The process of exchange of one asset for another by means of a liquidity pool is called swap (SWAP). The essence of the process is to add only one asset to the pool, instead of two, as in the case of LP. For holding a swap, the pool charges a small commission comparable to the commission for the transaction on the centralized exchange, that is, 0.1-0.3%. Commissions are distributed between liquidity suppliers in proportion to their share in the pool.


Create a conditional liquidity pool for the ETH/USDC pair. At a price of 1 ETH equal to 2000 USDC, it will be necessary to simultaneously block in a smart contract any number of these two coins in a ratio of 1: 2000. At this price in the bullet, there can be 100 ETH and 200,000 USDC.

The balance of assets in the pool is determined by their price. When the user decides to exchange 10 ETH using the above pool, he will bring his coins to a smart contract with a conventional transaction. In exchange for his 10 ETH, he will receive 20,000 USDC (excluding the exchange commission).

After this exchange, the balance of the pool will be 110 ETH and 180,000 USDC. Therefore, the price of ETH specifically in this pool will be about 1636 USDC instead of 2000 USDC in other markets. This situation attracts arbitration traders that benefit from imbalance by adding USDC to the pool until the price reaches market 2,000 USDC for 1 ETH.

What are the shortcomings of AMM?

Although AMM has become a breakthrough for trading and Defi, it has a number of obvious disadvantages. Firstly, when performing swaps using AMM, there is a high risk of slipping price. In turn, this leads to risks of inconsistent losses for LP and a value extracted by a miner for ordinary users.

Other types of AMM are created to protect against such risks, such as the CoESWAP project, combining the developments of AMM-Balancer and the GNOSIS protocol.

Secondly, unlike centralized exchanges during trading through AMM, only one type of application can be placed. Trade in limit applications or other types, such as Stop Loss, cannot be.

What are inconsistent losses?

Impermanent Loss, IL)-these are temporary or unrealized losses when holding assets in the liquidity bullet using amm-dex. IL relate to liquidity suppliers (LP), means the difference in price at the time of blocking tokens in the pool and the actual price at the time of retention. Losses are called unrealized because they are not fixed until liquidity is removed from the pool.


As an example, take a liquidity pool on the Uniswap exchange operating in the classic formula X * y = k:

  1. Liquidity supplier has blocked 1 ETH and 2000 DAI. Its share in the pool was 10%.
  2. In total, the pool contains 10 ETH and 20,000 DAI – equivalent 40,000 DAI.
  3. The balance of the pool did not change, since there were no new liquidity suppliers.
  4. Suppose that the market price of ETH has changed to 4000 DAI.
  5. Then the arbitration traders took advantage of the situation and changed the ratio in the 5th pool on the one hand and 20,000 DAI on the other. At the same time, the total size of the pool remained initial – 40,000 DAI.
  6. At this moment, the liquidity supplier decided to remove his share from the pool – it is 10%.
  7. Taking into account the current balance of the pool, it displays 0.5 ETH and 2000 DAI, although it initially added 1 ETH and 2000 DAI.
  8. The initial cost of its share was 4000 DAI (1 ETH plus 2000 DAI) in terms of stablecoins. The value of assets at the time of withdrawal was the same 4000 DAI (0.5 ETH plus 2000 DAI)
  9. However, if the user simply held his 1 ETH and 2000 DAI, then the value of its assets would already be 6000 DAI. This is an unrealized loss or profit when using amm-dex.
  10. The user will also receive 10% (in proportion to his share in the pool) from all pool commissions as a reward for providing liquidity. The award may be reduced, for example, due to taxes expelled to developers or to the Treasury of the project for the future development.

This is a conditional example of a sharp increase in the price of one asset by 50%, without taking into account many transactions of arbitration traders and the time that are necessary to align the price
Asset inside the pool with a price on centralized exchanges, where changes occur instantly.

With a “calm” market, variables of movement are added to the calculation of unstable losses, as Peteris’s Starknet developer described in his blog. As a result of these forecast calculations, the value of the IMPERMANENT LOSS on a double asset price will be about 5.7%. But this is only a forecast value – potential “losses” is very difficult to predict.

How to reduce risks when trading using AMM?

Before using the liquidity pool, you should calculate all possible commissions that you will have to pay at the time of entry and planned output of assets.

It is necessary to take into account the possibility of moving the price of assets in both directions. Some potential problems, such as the risk of inconsistent losses (IL), can be calculated in advance.

To calculate the IL indicator, you need to understand the nature of its origin. You can also use one of the calculators of unstable losses available on the Internet.