AMM-in-DEX

AMM DEX Automated Market Maker

Published June 16, 2022

DEX (Decentralized Exchange) allows users buy, sell and exchange crypto-assets without managers or intermediaries. As everyone can join DeX at a low price, process speed is significant without identity verification, the usability of DeX is highly evaluated, and its presence among all the DeFi services is now becoming more and more noticeable.

The liquidity of DeX is supported by AMM (Automated Market Maker). Since AMM autonomously provides liquidity in the market, users can freely trade crypto-assets whenever they want. Conversely, programming a high-quality AMM is essential for developing a reliable DEX.

In this blog, we will find out more about the important role of AMM, and the reasons why it has been used widely in DEX development.

Liquidity is key in DEX Operation

Knowledge about DEX liquidity increase mechanism is essential for a deep understanding about AMM. How to increase liquidity turns out to be the key point in developing a high quality DEX. The first things to mention are Liquidity Pool and Liquidity Mining, which are the core principles of DEX Liquidity.

Liquidity Pool

DEX is an crypto-asset exchange, which allows users buy and sell directly from their wallet without centralized managers. In order for DEX to operate smoothly and continuously as a trading market, it is essential to guarantee the liquidity.

Liquidity refers to the ease of selling crypto-assets. Liquidity is high if users can sell cryptocurrencies they own easily and fast in the market. Otherwise, liquidity is low if there are no buyers and transitions are hard to form. Of course, with high liquidity, the market will reach its complete growth and attract a great deal of attention from investors. Therefore, all DEX developers are seeking the way in which they can increase liquidity. The level of liquidity depends largely on the popularity of crypto assets, but “Liquidity pool” in DEX has a average effects on liquidity. When launching DEX, the investors, called Liquidity Provider (now LP), form the market by offering token in form of equal sets. This token is provided to a “Liquidity pool”, a type of smart contract that is programmed to automatically form a transactions without an intermediary or administrator.

As later introduction, in order for DEX to operate, it is important that tokens provided by LP in pair or a set of multiple tokens are accumulated in the liquidity pool with a certain volume. In the transactions on DEX, users put the token they want to sell into the pool and then withdraw another token they want to buy. All of these transactions are done automatically by smart contracts, which is called AMM (Automated Market Maker). If there are many tokens in the liquidity pool provided by LP, it will be easier to form the transactions, but if it is too few, the trade can not be formed.

In other words, the more plentiful the tokens provided by LP are, the higher liquidity will be.

Liquidity Mining

The price of the tokens that LP provides to the liquidity pool do not always keep the upward trend, so LP carries a considerable risk of losing assets. LP provides token under the awareness of these risks, because the only thing they can do is hoping for a reasonable return. Each DEX project provides attractive incentives to make sure of the stableness of liquidity and encourages many investors to become LPs. The main axis is “liquidity mining”.

Liquidity mining specifically includes free distribution of LP tokens, distribution of transaction fees within the service, and even thousand percentage of extraordinary interest. LP tokens are evidences that the tokens have been put into the pool and are used for exchange when provided tokens are withdrew from the liquidity pool. If you deposit LP tokens on an exchange farm, you will earn farming income. Transaction fees are structured so that they can be received in suitable proportion to their share to the whole liquidity.

In other words, if the liquidity of DEX is sufficiently secured and many users trade frequently, the value of LP tokens will increase and the commission income to be distributed will also increase. If you raise the time when the price of the provided tokens increase, you can gain income, and if you sell them, you can get capital gains. This is the real pleasure of liquidity mining, and the results will decide the true value of the DEX project.

Also see: https://relipasoft.com/blog/dex-amm/

AMM is overwhelmingly effective in DEX

About AMM

In CEX (Centralized Exchange), order book model is used to match traders who want to sell tokens with those who want to buy them. The order book model is the same as stocks and government bonds, in which the intermediaries search for a buyer who meets the condition presented by the seller of “How much you want to sell for ~ JPY” . In other words, the price at the time of trading is fixed.

On the other hand, AMM, which is often used in DEX, uses a pre-built formula to automatically calculate the price according to the amount of token that the user puts in and withdraws from the pool. In other words, at AMM, smart contracts are autonomously determined, rather than traders setting prices and selling. In addition, there is an advantage that transaction fees can be reduced and speedy transactions are possible because no intermediaries are involved. The order book method requires the intervention of an intermediary for each transaction, which is time-consuming and tends to slow down the transaction speed. For Ethereum, the scalability problems of increasing fees and delays in transactions are serious, and in order to solve these problems, there is an increasing demand for the AMM method, which enables cheap and speedy trading.

Mechanism of AMM

As a basic pattern of DEX, it is common that two types of tokens are stocked in the liquidity pool. When a trader adds one and buys the other, AMM’s algorithm is programmed to lower the price of the token of which the quantity increased and increase the price of the other token.

To make the case easier to understand, let’s assume a simplified fictional DEX and explain it in detailed.

Supposing that LP provides two types of token to the liquidity pool, A and B.

The price is “1A = 200 yen” and “1B = 500 yen”.

The quantity of A is represented by “a”, the quantity of B is represented by “b”, and the program is set so that “a x b = 4,000”. This means that the trader is required to maintain a constant of “4,000” for the quantities of both tokens at all times, no matter what the transaction is. By the way, the formula defines constant quantities of these two types of tokens was introduced in Uniswap V2 of DEX.

In DEX, when LP provides tokens, it is a rule to provide two tokens in the same amount. Therefore, supposing that the total value of tokens A and B is the same amount of “20,000 JPY”. Then you can see that the amount of asset is “a = 100A (20,000 JPY÷ 200 JPY= 100)” and “b = 40B (20,000 JPY÷ 500 JPY= 40)”. DEX will probably start from this state.

If the trader adds 100A to the pool, the token amount a will be 200A because 100A is added to the original 100A. Here, in order to maintain the constant “4,000”, the token amount b of B is reduced to 20B (4,000 ÷ 200 = 20). And the price of 1A will drop to 100 yen as a increases (20,000 JPY÷ 200 = 100 JPY), and the price of 1B will increase to 1,000 yen as b decreases (20,000 JPY÷ 20 = 1,000 JPY).

So all transactions are maintained by the autonomous work of smart contracts built into AMM.

Actually, DEX is not as simple as this. The higher the liquidity, the more complicated the movement, because there are more tokens in the pool and the number of trades will increase.

There are examples of the order book method being implemented in DEX, but the current situation is that the AMM method is overwhelmingly more common. The main reason is that the Ethereum blockchain, as mentioned above, emphasizes low fees and speedy trading, so it is inevitably impractical for the order book method, which may take time and effort.

Variation loss is possible in AMM Method

When adopting the AMM method in DEX development, a risk to consider is “variation loss”. With AMM, tokens in the liquidity pool are constantly changing in price. Then, in some aspects, the value of the token may drop excessively, and for LP, the phenomenon that the price was higher before being provided may occur temporarily. This is “fluctuation loss”.

For example, if the price of Token A was 1,000 JPY per unit, but if there are unexpectedly many users who sell Token A, the price will drop to 800 JPY, 500 JPY, and so on. This is the mechanism of AMM, so intervening is impossible. However, in this case, if the LP withdraws this token from the liquidity pool by cutting the numbness when the price drops to 500 JPY, a variation loss of 500 JPY per unit will occur . However, if you keep following, it is quite possible that another token will be sold and the value of token A will be pulled back to nearly 1,000 JPY. On the contrary, the loss may exceed 1,000 JPY depending on the situation.

This is considered to be an unavoidable bargain to be a LP. At the same time, as a DEX developer, it’s important to keep in mind that it’s important to have an attractive incentive that can be remain to compensate for the loss of LPs.

In conclusion,

The key points of DEX development are “Presentation of a project that stimulates investment motivation”, “Development of a liquidity pool equipped with excellent AMM”, “Selection of crypto assets with future potential”, and “Preparation of incentives to attract LP”. Developing DEX that meets these requirements is not easy, but if it is successful, a very attractive market will be created.

If you are thinking of enhancing DeFi services such as DEX, feel free to contact us, we will help you to gain success. Our experienced engineers are looking forward to hearing from you.

Related articles

5 Types of AI Agents Explained: Features, Functions, and Use Cases
[ VIEW ]

October 31, 2025

5 Types of AI Agents Explained: Features, Functions, and Use Cases

Every time you ask ChatGPT to write an email, let your car park itself, or get a movie recommendation that feels uncannily right, you’re interacting...

Read post

AI Agents Explained: The Complete Guide For Businesses
[ VIEW ]

October 29, 2025

AI Agents Explained: The Complete Guide For Businesses

A few years ago, AI amazed us with its ability to write poems, answer questions, and generate lifelike images. It felt like having a brilliant...

Read post

Rust Web Frameworks: A Thorough Comparison Of Recommendations From Frontend To Backend
[ VIEW ]

October 24, 2025

Rust Web Frameworks: A Thorough Comparison Of Recommendations From Frontend To Backend

The programming language Rust has recently drawn considerable attention for its robust safety model, high performance, and memory efficiency, leading to its increasing adoption in...

Read post