Skip to main content

Automated Market Maker (AMM)

First of all, What is a Market Maker?​

market maker

The term market maker refers to a firm (often centralized) or individual who actively quotes two-sided markets in a particular asset, providing bids and asks along with the market size of each. Market makers provide liquidity and depth to markets and profit from the difference in the bid-ask spread.

evolution

Source: AAX

If you have experience in trading securities, you would have encountered the bids and asks as shown by your brokerage firms, which are often the market makers as well. Once the market maker receives an order from a buyer, they immediately sell off their position of shares from their own inventory, completing the order.

Market making facilitates a smoother flow of financial markets by making it easier for investors and traders to buy and sell. These market makers are an essential part of the stock market as they keep the financial markets liquid.

For further details on market makers, head over to Investopedia.

So what is an Automated Market Maker (AMM)?​

I am sure many of us are wondering, how is the price of a cryptocurrency on a Decentralized Finance (DeFi) determined, without the help of a centralized exchange that serves as its market maker?

The answer to this question is the adoption of Automated Market Makers.

automated market maker

An automated market maker (AMM) is a type of decentralized exchange (DEX) protocol that relies on a mathematical formula to price assets. Instead of using an order book like a traditional exchange, assets are priced according to a pricing algorithm.

How does Automated Market Maker work?​

An AMM work similarly to an order book exchange in that there are trading pairs. However, the difference is that there is no need for a counterparty on the other side to complete a trade. Instead, traders interact with the AMM which is a smart contract that acts as the market maker. Binance Academy refers to this as peer-to-contract (P2C).

Liquidity Pool and Liquidity Provider (LP)​

What is a liquidity pool?​

Liquidity pools represent different trading pairs, for example, ETH/BNB. AMM uses these liquidity pools to facilitate trading. As mentioned previously, trading on the Decentralized Exchange (DEX) is basically making a trade with the smart contract which holds these liquidity pools.

Who are the liquidity providers (LP)?​

Liquidity providers (LP) provide funds to liquidity pools, in exchange for fees from the trades that happen in the pools. This serves as an incentive for more liquidity providers, which will in turn reduce the price impact and slippage, a key criteria for the AMM.

Pricing algorithm in AMM​

I will be using the most popular DEX protocol as of date, Uniswap as an example. See also: UniswapV2 Pricing.

pricing-algo

Source:

OpenSwap

The AMM allows anyone to deposit or withdraw tokens from them, but only according to very specific rules set in the smart contract. One such rule is the constant product formula: x * y = const, where x and y are the reserves of two tokens in the liquidity pool.

trade

In order to withdraw some amount of token X, one must deposit (buy with) a proportional amount of token Y to maintain the constant k. The price is determined by the ratio between these two tokens.

Slippage​

As mentioned earlier, pricing is determined by an algorithm, which also means that it is determined by how much the ratio between the tokens in the liquidity pool changes after a trade. If the ratio changes by a large amount, there is going to be a large amount of slippage.

Tokens in liquidity pool with low liquidity is likely to suffer from high slippage, as the ratio is easily affected by the trades. On the other hand, tokens in liquidity pool with high liquidity is likely to have low slippage, which is desirable for traders and investors as they can more accurately determine their trade price.

Impermanent Loss​

pitfall of liquidity provider (LP)

Impermanent loss is a misleading term which can be very costly for liquidity providers (LPs) and LPs will need to keep this concept dear to them. It is called impermanent loss as the losses only became realized once you withdraw your tokens from the liquidity pools, much like unrealized loss.

Impermanent loss happens when you provide liquidity to a liquidity pool, and the price of your deposited tokens changes compared to when you deposited them. The bigger the change, the bigger the impermanent loss.

For example, if you provided 10% liquidity to a liquidity pool and the ratio of token X and Y is 1:10, when the ratio of token X and Y changes to let's say 1:5, you will receive the same 10% liquidity of the liquidity pool at the ratio 1:5 when you withdraw your liquidity.

This can lead to scenarios where it is better off to HODL the tokens instead of staking them in the liquidity pools.

tip

Binance Academy has a wonderful illustration of this impermanent loss.