What is an Automated Market Maker (AMM)?
Have you ever wondered how swap works? How does the underlying system organize and execute buy and sell orders? We decided to take a look at the brains behind decentralized trading and it’s called the Automated Market Maker.
Central limit order book vs. Automated Market Maker
Most traditional exchanges process all trading orders through a trade execution model called the Central limit order book (CLOB). The CLOB model is transparent, low-cost, anonymous and can match orders in real-time, but it’s slow and involves a middleman that needs to execute individual orders.
Here’s how it works: buyers post publicly the highest price they are willing to accept. Sellers post publicly the lowest price they are willing to accept. When these prices overlap, a transaction is executed. If not, the order remains unexecuted.
It’s quite straightforward, right? This model is used by traditional equity and derivative exchanges, and by some centralized crypto exchanges.
On the other hand, decentralized exchanges developed their own solution to achieve better capital efficiency, speed and ease of use. The protocol is called Automated Market Maker (AMM) and it helps traders exchange cryptocurrencies without an intermediary.
While AMMs are commonly used in decentralized exchanges, there are a few centralized exchanges implementing AMM protocols as well. The best example would probably be Binance Liquid Swap — a liquidity pool with an AMM algorithm.
The AMM runs on smart contracts and is therefore completely automated. It facilitates traders to trade a specific coin or token pair but doesn’t require a counteroffer to make a trading order go through. This is possible because the AMM model uses resources from liquidity pools.
What is a liquidity pool?
A liquidity pool is a virtual pool of money that contains a pair of crypto assets, for example, ETH/BTC, and runs on a specific algorithm. Its foundation is a smart contract that maintains the crypto pair value in a constant 50:50 ratio. Investors who decide to contribute their assets to the liquidity pool are known as liquidity providers. Once they provide liquidity, they are entitled to a certain percentage of fees that occur with every trade in the specified pool.
How does AMM work?
An automated market maker helps users exchange cryptocurrencies by connecting users directly, without an intermediary. It needs to make sure the ratio of assets in liquidity pools remains balanced and calculates the price of a crypto asset depending on its paired token. AMMs are running on algorithms, the most common being the Constant Product Market Maker. For the purposes of this article, we will use the CPMM algorithm as an example.
The basic goal that an AMM strives to achieve is the perfect ratio of a crypto asset pair.
Once a liquidity pool is set up, it must be filled up with a pair of crypto tokens in a 50:50 ratio.
Then the AMM makes its calculation based on one simple formula:
x * y = k
x = quantity of asset A
y = quantity of asset B
k = constant.
AMM first calculates the constant which needs to remain unchanged at all times. The formula above is used to calculate the price of both assets. When buyers start buying asset A in exchange for asset B, asset A becomes more expensive and the price of asset B starts falling. Basic supply and demand approach.
Here’s where liquidity plays a big role. High liquidity suggests the market is active and that buyers and sellers can easily trade a specific pair. On the other hand, low liquidity shows there is less activity and it is harder to buy and sell an asset.
The more assets there are in a liquidity pool the more stable it is, because the price of the assets doesn’t change as drastically with each trade made.
Slippage and Impermanent loss
Slippage is also closely tied to liquidity. When liquidity is low, slippage can occur. This means that the price of an asset can drastically change during the trade execution and it can significantly affect the outcome of the trade. To avoid slippages, transactions must be executed as instantaneously as possible.
Types of algorithm
DEXs use different AMM algorithms, sometimes even a combination of two. While the most common one is the already mentioned CPMM, others exist as well. Here are some of the best know AMM algorithms:
- Constant Product Market Maker (CPMM)
- Constant Sum Market Maker (CSMM)
- Constant Mean Market Maker (CMMM)
- Advanced Hybrid Constant Function Market Maker (CFMM)
- Dynamic Automated Market Maker (DAMM)
If you want to dig deeper into individual algorithms, a detailed explanation can be found in the A Mathematical View of Automated Market Maker (AMM) Algorithms and Its Future blog.
Best known AMMs
The DeFi space is constantly adding new projects and platforms so the list of AMMs consequently grows longer and longer every day.
According to Coingecko, here are the current top seven Automated Market Makers:
- Uniswap — AMM protocol that relies on a series of smart contracts on top of Ethereum. Tokens need to be ERC20 compliant or ETH.
- Pancakeswap — the most popular AMM protocol on top of the Binance Smart Chain. It uses a hybrid CFMM algorithm.
- Osmosis — AMM is built with the Cosmos SDK; it specializes in the InterchainDeFi movement (Tendermint-based blockchains) in the Cosmos ecosystem.
- Curve DAO — the protocol is designed to make it easy to swap between similar ERC-20 tokens, primarily stablecoins (like USDC and DAI) and Ethereum-based Bitcoin tokens (like WBTC and renBTC). It uses a combination of CSMM and CPMM algorithms.
- Sushi — an AMM decentralized exchange (DEX) currently on the Ethereum blockchain. It utilizes the constant product market model.
- Balancer — its AMM allows users to create liquidity pools with up to eight different tokens in any ratio. It uses the CMMM algorithm.
- Bancor Network — one of the market’s very first automated market makers (2017). Its AMM utilizes the concept of a bonding curve.
The basic concept behind cryptocurrency is its decentralized approach. No middlemen overseeing our actions. Automated market makers are realizing this very idea as they successfully eliminate the need for intermediaries in the trading processes and make the entire service faster and more user-friendly. AMMs enable digital assets trading without permission and automatically by using liquidity pools as opposed to traditional market order books.
Faster, automated, permissionless … perfect!
Join the GoCrypto community on Telegram!