What Is an Automated Market Maker (AMM)?
0
0
The Main
Automated Market Maker (AMM) is a software algorithm for controlling the liquidity and pricing of cryptoassets on decentralized exchanges.
AMM systems are widely used in the DeFi industry, particularly on decentralized exchanges (DEX) such as Uniswap, Balancer, Bancor, and Curve.
AMM uses liquidity in cryptocurrency public pools of multiple tokens locked in special smart contracts to create decentralized markets.
How did the automated market maker (AMM) come to be?
An automated market maker (AMM) is an autonomous trading mechanism on which most trading DeFi protocols operate. It enables the movement of capital and execution of user exchanges in the available cryptoasset markets.
The first known developer to talk about implementing AMM was Alan Liu, a member of the Gnosis project team. His ideas were outlined by Ethereum founder Vitalik Buterin on Reddit in 2016 and in a personal blog in July 2017.
This concept formed the basis of the Uniswap platform protocol, which received its first $100,000 grant from the Ethereum Foundation. In addition, Vitalik Buterin advised the Uniswap developers.
Subsequently, AMM became widely known 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 an ICO in June 2017.
How are liquidity pools related to AMM?
The key element necessary for MMA to work is a liquidity pool - a kind of storage of crypto-assets in the form of a smart contract. The liquidity pool usually consists of two cryptoassets and forms a market - analogous to a trading pair on a centralized exchange.
Some pool participants block their funds to generate income through exchange commissions. Such users are called liquidity providers.
Another category is direct users of a decentralized exchange who exchange cryptocurrencies in the protocol (such transactions are called ”swaps”) using one of the pools.
To better understand liquidity pools, let's look at what led to their creation.
The first DEX exchanges operated on Ethereum and used the standard order book 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 transactions on a decentralized exchange are confirmed via blockchain, the actual speed and capabilities of such DEXs were extremely limited. AMM provided a solution to this problem.
Thus, AMM is a fundamentally different way of creating an asset market, being the formula or rules by which the protocol deals with buy or sell orders and users' reserves.
How do liquidity pools work?
Pools can use two or more assets. 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 asset-based pools with similar value, such as ETH and wrapped token WETH or USDC and DAI. The operation of these pools is governed by AMMs.
Each such AMM-DEX may use its own formulas and rules to interact with liquidity pools. For example, the Uniswap protocol uses the following formula: x * y = k.
In the equation, x and y represent the number of tokens available in the liquidity pool; k is a constant value called the invariant. In the case of Curve, the formulas x * y = k and x + y = k are used.
The formula x * y = k is also used for the SushiSwap and PancakeSwap projects, which are the most common type of AMM-DEX.
How is an asset in a liquidity pool priced?
When liquidity is blocked in a pool, its provider receives special LP-tokens confirming their share in the pool. They can be presented as a promissory note, the possession of which gives the right to receive commissions from exchange transactions on the exchange and return their share from the pool;
LP-tokens are a transferable crypto-asset that can be sold or exchanged on the open market and invested in third-party DeFi applications.
The process of exchanging one asset for another through a liquidity pool is called a swap. The essence of the process is to add only one asset to the pool instead of two, as in the case of LPs. The pool charges a small commission for the swap, comparable to the commission for a transaction on a centralized exchange, i.e. 0.1-0.3%. The fees are distributed among liquidity providers in proportion to their share in the pool.
Example
Let's create a conditional liquidity pool for ETH/USDC pair. At the price of 1 ETH equal to 2000 USDC, we will need to simultaneously block any amount of these two coins in the smart contract in the ratio of 1:2000. At this price, there could be 100 ETH and 200,000 USDC in the pool.
The balance of assets in the pool is determined by their price. When a user decides to exchange 10 ETH using the pool described above, he will deposit his coins into a smart contract in a normal transaction. In exchange for his 10 ETH, he will receive 20,000 USDC (excluding the exchange fee).
After this exchange, the balance of the pool will be 110 ETH and 180,000 USDC. Consequently, the price of ETH specifically in this pool will be around 1636 USDC instead of 2000 USDC in other markets. This situation attracts arbitrage traders who capitalize on the imbalance by adding USDC to the pool until the price reaches a market price of 2,000 USDC per 1 ETH.
What are the drawbacks of the MMA?
Although AMM has been a breakthrough for trading and DeFi, it has a number of distinct disadvantages. First, there is a high risk of price slippage when making swaps using the MMA. In turn, this leads to risks of incurred losses for LPs and miner-extracted value (MEV) for ordinary users.
To protect against such risks, other types of AMMs are being created, such as the CowSwap project, which combines the developments of AMM-Balancer and the Gnosis protocol.
Second, unlike centralized exchanges, only one type of orders can be placed when trading through AMM. It is impossible to trade with limit orders or other types, for example Stop Loss.
What is Impermanent Loss?
Impermanent Loss (IL) is a temporary or unrealized loss when holding assets in a liquidity pool using AMM-DEX. ILs are attributed to liquidity providers (LPs), meaning the difference in price at the time tokens are locked in the pool and the actual price at the time of holding. Losses are called unrealized because they are not locked in until liquidity is withdrawn from the pool.
As an example, let us take a liquidity pool on the Uniswap exchange, which works according to the classical formula x * y = k:
- A liquidity provider blocked 1 ETH and 2000 DAI. Its share in the pool amounted to 10%;
- The pool holds a total of 10 ETH and 20,000 DAI - the equivalent of 40,000 DAI.
- The balance of the pool did not change because there were no new liquidity providers.
- Let's assume that the market price of ETH changed to 4000 DAI.
- Then arbitrage traders took advantage of the situation and changed the ratio in the pool to 5 ETH on one side and 20,000 DAI on the other. At the same time, the total size of the pool remained the original 40,000 DAI.
- At this point, the liquidity provider decided to withdraw his share from the pool - it is 10%.
- Given the current pool balance, he withdraws 0.5 ETH and 2000 DAI, although initially he added 1 ETH and 2000 DAI.
- The initial value of his share was 4000 DAI (1 ETH plus 2000 DAI) in terms of stablecoins. The asset value at the time of withdrawal was the same 4000 DAI (0.5 ETH plus 2000 DAI)
- However, if the user had simply held their 1 ETH and 2000 DAI, their asset value would have been 6000 DAI. This is the unrealized loss or gain when using AMM-DEX.
- The user will also receive 10% (proportional to his share in the pool) of all pool commissions as a reward for providing liquidity. The reward may be reduced, for example, due to taxes allocated to the developers or to the project treasury for future development.
This is a conditional example of a sharp increase in the price of one asset by 50%, without taking into account the many transactions of arbitrage traders and the time needed to align the priceof an asset within the pool with the price on centralized exchanges, where changes occur instantly.
When the market is ”calm”, variable movements are added to the Impermanent Loss calculation, as described in his blog by StarkNet developer Peteris Erins. As a result of these predictive calculations, the Impermanent Loss value on a two-fold movement in the price of an asset would be about 5.7%. But this is only a forecast value - potential ”losses” are very difficult to predict.
How to reduce risks when trading with AMM?
Before using a liquidity pool, you should calculate all possible commissions that you will have to pay at the time of deposit and planned withdrawal of assets.
The possibility of asset price movements in either direction must be taken into account. Some potential problems, such as the risk of intermittent loss (IL), can be calculated in advance.
To calculate IL, you need to understand the nature of its origin. You can also use one of the variable loss calculators available online.
0
0
Securely connect the portfolio you’re using to start.