The popularity of cryptocurrencies has naturally caused the development of Decentralized Exchanges. These DEXs are needed to swap and trade crypto assets efficiently. While some of these exchanges work on traditional order book models, others use a fascinating new technology known as automated market makers (AMMs). In essence, AMMs are autonomous trading mechanisms that allow for decentralized trading without the need for traditional market-making techniques or centralized exchanges.
But how do AMMs work, and what makes them so popular among crypto enthusiasts? In this article, we will delve into the world of AMMs, exploring the technology behind them and their benefits.
To fully understand how automated market makers (AMMs) work, it’s essential first to grasp the concept of traditional market makers. In a centralized financial market, like the stock market, market makers facilitate liquidity by matching buyers and sellers. These market makers can be individual traders, banks, or other institutions that create bid-ask orders, ensuring that counterparties are available for any trade.
However, in cases where there isn’t enough liquidity in the market to match buy and sell orders instantly, slippage can occur, causing asset prices to shift before a trade is completed. This is where market makers step in to provide additional liquidity and maintain market efficiency.
Decentralized exchanges introduced a new concept in the form of AMMs, eliminating intermediaries and automating providing liquidity. An AMM is a computer program that runs on smart contracts, which are self-executing computer codes that define the price of crypto tokens and provide liquidity. In contrast to traditional market makers, where you need to trade with a counterparty, AMMs enable you to trade with a smart contract directly. In other words, trades are peer-to-contract instead of peer-to-peer.
To trade on an AMM, you need to find a liquidity pool that holds the assets you wish to trade, like Ether and Tether, in the ETH/USDT liquidity pool. A mathematical formula determines the price of assets in an AMM liquidity pool, and anyone can become a liquidity provider by depositing a predetermined amount of tokens into the pool. As a reward for their service, liquidity providers earn fees from trades in the pool.
One of the critical advantages of AMM over traditional market makers is their ability to provide liquidity 24/7, as they don’t rely on a central authority or a limited number of market makers. Additionally, AMMs offer lower barriers to entry for liquidity providers, allowing anyone with tokens to participate and earn fees.
As we already covered, Automated market makers are a type of decentralized exchange that uses liquidity pools to automate the process of providing liquidity. These pools comprise specific trading pairs; anyone can become a liquidity provider by depositing a predetermined ratio of the two assets.
The ratio of assets in the liquidity pool is maintained through preset mathematical equations, such as Uniswap’s x*y=k equation. This ensures that the pricing of the pooled assets remains balanced and eliminates discrepancies.
In the equation, x represents the value of Asset A, y denotes the value of Asset B, and k is a constant. As a result, the multiplication of the price of Asset A and the price of B always equals the same number.
When a trader wants to swap one asset for another, they interact with the smart contract of the liquidity pool, which calculates the ratio of the two assets and executes the trade. Liquidity providers earn a portion of the trading fees generated from the pool, incentivizing them to provide liquidity to the protocol. The decentralized nature of AMMs allows for permissionless trading without intermediaries, enabling greater accessibility and efficiency in the trading of crypto assets.
First-generation AMMs like Bancor, Curve, and Uniswap popularized the use of constant function market makers, such as constant product market makers, constant sum market makers, and constant mean market makers.
The underlying principle of these AMM trades is a continuous function in which the total assets held by trading partners must remain constant. For token swap liquidity, non-custodial AMMs pool user deposits for trading pairs in a smart contract accessible to all traders. Unlike book exchanges, where users trade with a specific counterparty, users trade against the smart contract.
The first AMM-based DEX, Bancor, popularized the concept of a CFMM called a continuous product market maker (CPMM). The range of prices for two tokens in a CPMM is established by the function x*y=k, which is based on the quantity (liquidity) of each token.
To keep product K constant, if the supply of token X goes up, the supply of token Y must go down, and vice versa. The resulting graph is a hyperbola, with infinite availability of liquidity at ever-increasing prices that tend to infinity at both ends.
A constant sum market maker (CSMM) is preferable for trades with no effect on the price, although this sort of market maker does not offer unlimited supply. A straight line results when a CSMM is plotted since its formula is x+y=k.
If the off-chain reference price between the tokens is not 1:1, arbitrageurs can use this design flaw to drain one of the reserves. In this case, all the liquidity would be concentrated in one of the assets, leaving traders with no choice except to close their positions. This is why CSMM is a niche model among AMMs.
An alternative market mechanism with more than two tokens and a non-standard weighting scheme that is 50/50 can be created with the help of a constant mean market maker (CMMM). The model maintains a constant geometric mean weighted across all reserves.
If you have three assets in your liquidity pool, you may write the equation as (x*y*z)(13)=k. Swaps can be made between any assets in the pool, and there can be varying degrees of exposure to various assets within the pool.
We’ve already mentioned liquidity a couple of times, but what is it exactly, and why is it so crucial for AMMs to operate?
When discussing the market value of an item, liquidity refers to how quickly and easily it may be exchanged for another asset, typically a fiat currency. Ethereum’s decentralized exchanges had a liquidity problem until AMMs were introduced.
Finding enough people eager to trade consistently was challenging because the technology was new and the interface was complex. By forming liquidity pools and providing providers with an incentive to contribute assets, AMMs can address the issue of insufficient liquidity. Trading on decentralized exchanges becomes simpler as asset pools grow larger and their liquidity improves.
In AMM platforms, consumers trade against a liquidity pool of tokens rather than directly with other users. A liquidity pool is essentially a shared supply of tokens. Tokens are contributed to liquidity pools by users, and the pool’s price is set according to a mathematical formula. Liquidity pools can be optimized for various uses by modifying the formula.
By contributing tokens to an AMM’s liquidity pool, anyone with access to the internet and an ERC-20 token can act as a liquidity provider. Liquid providers typically receive compensation in exchange for contributing tokens to the pool, and the traders who use the liquidity pool pay this cost.
Ultimately, because of how AMMs function, the risk of slippage for large orders decreases as pool liquidity improves. That may entice even greater traffic to the site, and so on.
Different AMM designs will have varying slippage problems, which is still an important consideration. Keep in mind that an algorithm determines the prices. In a nutshell, it is based on the percentage change in the ratio of tokens in the liquidity pool following a trade, meaning there will be a great deal of slippage if the ratio shifts by a big amount.
In a centralized exchange, only well-established businesses and financial institutions (or extremely wealthy individuals) are eligible to become market makers. Regarding AMMs, however, anyone who meets the primary conditions can act as a liquidity provider.
Liquidity pools have varying criteria, but you’ll generally need a sizable cash reserve. Tokens such as Ether, Bitcoin, or Binance Coin are typically required to enter most smart contracts.
Liquidity providers can profit from all trades conducted within their liquidity pool by receiving network fees from the AMM protocol. It’s a method by which cryptocurrency holders can generate a passive income.
When liquidity providers withdraw their funds from the pool, they only collect their proportionate share of the transaction costs, which is added to their current deposit until then.
Although many unique decentralized exchanges have spawned over time, the most notable projects all employ pretty similar AMMs. Let’s look at a few examples.
Uniswap is an open-source, distributed protocol created in 2018. Uniswap developed on Ethereum, is still among the most well-liked DEXs available today and boasts the highest trading volume. Due to its open-source nature, other people have attempted to replicate or improve Uniswap.
SushiSwap is a DeFi protocol that forked off Uniswap and became rather popular. Despite their nearly identical functionality, the key distinction between the two is based on tokenomics. As an extra incentive program for liquidity providers, SushiSwap has unveiled the SUSHI token.
PancakeSwap is yet another version derived from UniSwap. However, UniSwap was designed to support altcoins based on Ethereum, while PancakeSwap was developed for Binance Smart Chain-based altcoins (BSC).
While the number of coins based on Binance’s Smart chain is far less compared to Ethereum’s, the ones that do tend to have lower gas fees and fewer transaction delays than Ethereum’s current network.
An Automated Market Maker is a decentralized exchange protocol that uses mathematical algorithms to set the prices of trading pairs.
An AMM maintains a liquidity pool that traders can use to buy or sell assets. When a trade is executed, the AMM calculates the new price of the assets based on the ratio of the assets in the liquidity pool.
Buyers and sellers place orders matched by a central matching engine in an order book exchange. In contrast, an AMM uses a predetermined mathematical formula to determine prices and execute trades.
AMMs provide several benefits, including lower fees, greater accessibility, and liquidity. Additionally, AMMs eliminate the need for intermediaries and central exchanges, making them more decentralized and secure.
AMMs are generally better suited for small-to-medium-sized trades due to the way they set prices. The price impact can be more significant for larger transactions, causing slippage and affecting the overall trade execution.
Impermanent loss occurs when the price of an asset in a liquidity pool diverges from the market price. Liquidity providers may experience impermanent loss when withdrawing their funds from the pool.
Impermanent loss can be minimized by selecting low-volatility trading pairs and ensuring that the ratio of the assets in the pool is maintained.
A constant product AMM, such as Uniswap, maintains a fixed product of the assets in the liquidity pool. In contrast, a constant sum AMM, such as Balancer, maintains a fixed sum of the assets in the pool.
Yes, anyone can provide liquidity to an AMM by depositing equal values of both assets in the liquidity pool. Liquidity providers receive a share of the trading fees generated by the AMM.
As DeFi continues to grow, the demand for AMMs is expected to increase. New AMM models and protocols will likely emerge, providing users with even more options for decentralized trading.
Decentralized exchanges, which allow users to trade cryptocurrencies without requiring the user’s trust or the exchange’s permission, have been revolutionized by automated market makers. AMMs have enabled users to reclaim ownership of their assets and participate in decentralized finance (DeFi) on a global scale through pooling assets and trading without a central authority.
It is expected that AMMs will play a significant role in promoting the expansion and widespread use of the DeFi ecosystem as time goes on. Ultimately, AMMs play a crucial role in the DeFi industry, opening up new opportunities and making trading more accessible globally.