What are Automated Market Makers (AMMs)? A Comprehensive Guide on Market Making
An AMM pools liquidity into a smart contract that users trade against, meaning there's no need for counterparties or traditional market makers.
Decentralized finance continues to defy all odds as its explosive growth shows no slowing down. In 2021, DeFi market capitalization surpassed $150 billion, more than a 100% increase from the previous year. Innovations are entering the space daily, attracting billions of dollars for many DeFi platforms.
However, one of the most important underlying protocols powering DeFi platforms is often not talked about.
A smart contract protocol first introduced in the decentralized exchange, Uniswap, stays behind the scene propelling DeFi applications to greater heights - Automated Market Makers (AMMs).
But before we take on AMMs heads on, we have to firstly understand how the concept of market making works.
Conventional Market Makers
In traditional exchanges, market makers ensure that the trading process is seamless for traders by providing liquidity.
Normally, if Trader A intends to sell 1ETH for $3,000, the exchange will have to find another trader who wants to purchase 1ETH for the price Trader A is willing to sell - $3,000 in this case.
The exchange acts as an intermediary to ensure both parties have a seamless trading experience. However, the whole process crumbles if there's no trader at the other end to buy at Trader A or B asking/bidding price. This means the asset in question has low liquidity, meaning users can not easily trade it.
NB: Liquidity refers to the ease at which an asset can easily be converted to cash or other assets without a drastic shift in its market price.
The process of market-making comes in to enable exchanges to conduct a smooth trading service.
Financial institutions often referred to as market makers provide liquidity for the assets in an exchange by readily opening numerous buy and sell orders.
Hence, enabling the orders of retail traders to be fulfilled without necessarily having another trader on the other end. This process is also referred to as the order book model.
Market makers charge a fee for taking on the risks involved with providing this service. However, onboarding the order book market-making method to DeFi applications that run via smart contracts will consume too much money and time.
Early decentralized exchanges utilized a P2P model which was highly unattractive as it faced similar issues as exchanges without market makers.
Many early DeFi applications suffered because of this complication until Uniswap implemented the first Automated Market Making protocol.
What are Automated Market Makers (AMMs)?
The main aim of decentralized exchanges is to remove intermediaries like centralized exchanges or traditional market makers that control transaction processes.
Unlike traditional exchanges where transactions are completed via the order book model and custodial wallets, users carry out trades directly from non-custodial wallets (wallets where users have control over their private keys).
The order book is replaced with an automated market-making protocol.
Automated market-making protocols provide liquidity for trading assets via a smart contract - contracts that self execute based on predetermined conditions - and a mathematical formula for pricing assets.
An AMM pools liquidity into a smart contract that users trade against, meaning there's no need for counterparties or traditional market makers. Think of it as peer-to-contract (P2C).
These smart contracts are referred to as liquidity pools and anyone can provide liquidity for these pools unlike centralized exchanges where liquidity provision is restricted to only large financial institutions and very rich individuals.
If market makers are at the core of centralized exchanges, then AMM is the heart of decentralized exchanges.
How does an AMM work?
In AMM protocols, trading pairs are treated as individual liquidity pools. If you want to trade ETH for DAI, for example, you'll need to use an ETH/DAI liquidity pool.
Anyone can provide liquidity for these pools by depositing an equal ratio of the pair of assets in the pool. The ratio of assets in a pool must stay highly balanced to prevent heavy price fluctuations.
Hence, AMMs use a mathematical formula to ensure the price in liquidity pools correlates with that of the general market.
Most decentralized exchanges use a simple formula - x × y = k - for their pricing algorithm. Where x and y are the prices of both tokens in the pool and k is a constant.
The multiplication of both x and y should always result in a fixed number, meaning the pool's liquidity must remain constant and not change.
For example, in an ETH/USDC pool, when ETH is bought by USDC, the quantity of ETH in the pool reduces, in turn causing its price to rise.
The price of USDC, on the other hand, reduces as its quantity has increased. The reverse occurs when ETH is traded for USDC, meaning the price of USDC increases and that of ETH falls.
In a scenario where very large orders are placed in the pool, the ratio between tokens in the pool changes, causing slippage.
And hence, notable price differences between the market price of assets in the pool and their market price - ETH may be trading for $3,000 in a pool while its market price is $3100.
Arbitrage traders often capitalize on such price differences by buying low from the liquidity pool and selling at a higher rate on other exchanges.
However, with every trade, you'll have to pay exponentially high premiums until the price of ETH in the pool recovers to the market price.
This also implies that you can't purchase all of the quantity of a particular asset from a pool because the formula x × y = k would no longer make sense if either x or y - ETH or USDC - is zero.
Other AMMs utilise other types of formulas for algorithmically pricing assets. Balancer, for example, uses a formula that allows for the combination of up to eight assets in a liquidity pool.
Liquidity Pools and Liquidity Providers
From all we've discussed so far, liquidity is the focal point of automated market-making as traders basically trade against liquidity in smart contracts. So where does the liquidity come from?
This is where liquidity pools and liquidity providers come in.
AMM protocols are designed to encourage users to provide liquidity by rewarding them with the transaction fees charged on trades.
Protocols with low liquidity are susceptible to large slippages, hence, most AMMs promise high rewards to attract liquidity providers. The less slippage occurs in a pool, the more volume it will attract.
In an AMM with the x × y = k formula, liquidity providers (LPs) are required to deposit two tokens of equal value in the liquidity pool.
For example, 3ETH and 9,000USDC in an ETH/USDC pool at a rate of 3,000USDC per ether. And in turn, they receive a token representing the share of the pool they contributed. These tokens are known as liquidity providers tokens (LPT).
The LPT is used to determine the percentage of accrued transaction fees an LP receives - If your deposit represents 2% of the liquidity in the pool, then you will receive 2% of the transaction fees of that pool.
The LPT is later redeemed for funds when a liquidity provider wishes to exit the pool.
The interoperability of DeFi protocols also enables liquidity providers to maximize profits. Apart from the rewards mentioned above, you can stake your LPT on other lending platforms to earn extra yields.
What is Impermanent loss?
A discussion about AMMs without explaining the risk of impermanent loss is incomplete. Liquidity providers often face the risk of impermanent loss by providing liquidity for AMMs.
Impermanent loss occurs when the price ratio of assets in a pool changes from the price at which they were deposited.
A relatively small shift in price will incur small losses, however, when the price shift is high, LPs are better off holding onto their tokes than using it to provide liquidity.
Impermanent loss commonly affects crypto assets with high volatility. For this reason, AMMs work better with digital assets that show less volatility.
The name impermanent loss implies that the loss is only temporary as the price can revert to the ratio they were deposited.
Although the loss becomes permanent if the LP withdraws the funds before the price reverts. Earnings from accrued transaction fees and staking rewards can cover up for this loss.
Pros and Cons of AMMs
While AMMs open the market for new streams of income in a decentralized manner. The grass isn't entirely green on this side. In this section, we explored the good and the bad sides of AMMs.
Pros
AMMs allow anyone to be a liquidity provider as opposed to centralized exchanges where market making is restricted to the rich and large financial institutions.
AMMs provides several earning opportunities for users through transaction fees and yield farming.
AMMs are not susceptible to market manipulation like the order book model.
Cons
Most top AMM protocols run on the Ethereum blockchain where gas fees are highly expensive.
The order book model comes with different order types that are not available in AMM protocols.
AMM protocols are not as fast as the order book model.
Liquidity providers may incur impermanent losses.
Examples of DeFi platforms using AMMs
Below are some of the most popular decentralized exchanges in the market where you can access quality trading services:
Uniswap - This is probably the most popular decentralized exchange in the crypto market, seeing how it was the first protocol to utilize an AMM protocol. You can trade different cryptocurrencies via Uniswap v1, v2, and v3.
Pancakeswap - is a next-gen decentralized exchange on the Binance Smart Chain that allows for the exchange of tokens for a cheaper and high network speed.
dYdX - is a decentralized exchange that allows for margin trading like perpetual contracts. Users can speculate on both rising and falling prices of cryptocurrencies in a decentralized environment.
SushiSwap - The decentralized exchange is a fork of the popular Uniswap protocol. In addition to providing trading activities for top tokens, SushiSwap has a governance token SUSHI which enables LPs to maximize earnings.
Curve Finance - One of the top decentralized exchanges with a very high TVL (total value locked). Curve Finance focuses on stable coin trading, reducing the occurrence of slippage and transaction fees for users.
Conclusion
AMMs have made decentralized exchanges a profitable platform for both traders and liquidity providers. We make the market and trade all by ourselves without depending on any 'powerful' authority.
Before trading or becoming a liquidity provider on AMM platforms, ensure you consider the factors discussed in this guide and do your own diligent research.
Till I come your way next time, remember this is Web 3 and it belongs to you and I.
Before you go… send in your questions and thoughts. Let's take this discussion further.
Subscribe✉️ to receive this exciting newsletter directly in your inbox next time.