Automated Market Makers (AMMs): The What, The How, and The Why
Discover the essentials of Automated Market Makers (AMMs) ➡️ What they are, how they work, and why they matter in crypto trading. Beginner-friendly and clear!
Subscribe to our newsletter to be in-loop with all news from the crypto world
Introduction
If you swapped a token on Uniswap or Curve Finance today, an AMM (Automated Market Maker) facilitated the trade for you. AMMs decentralize token issuance, listing, and trading on DEXs, removing intermediaries.
Let’s explore what AMMs are, how they work, and why they’re essential.
What Are Automated Market Makers
What Is an AMM?
Automated market makers in crypto are smart contract algorithms that allow traders to trade digital assets directly without needing a counterparty or an order book. Multi.io Research explains that AMMs rely on liquidity pools where tokens are automatically traded based on an algorithm.
DEX users can trade digital assets using liquidity pools. These pools are governed by AMMs which provide continuous liquidity.
AMMs are also responsible for determining the prices of tokens against their supply in the pool. AMMs have made token swaps the most common type of transaction types in crypto.
AMMs and CEXs differ in how they facilitate trades. Here’s a quick comparison:
History and Evolution of AMMs
The concept of AMMs originated in prediction markets like Augur and Gnosis. Vitalik Buterin proposed integrating AMMs with DEXs in 2016, and Bancor launched the first on-chain AMM in 2017. UniSwap revolutionized AMMs in 2018 with CPMM-based DEXs, followed by Curve Finance’s stablecoin pools in 2019 and Balancer’s custom-weight pools in 2020.
In the same year, Bancor launched its V2 version. The V2 version allowed users to benefit from dynamic weight in pools to mitigate impermanent loss risks. Users were no longer required to contribute liquidity in token pairs. Bancor allowed users to contribute one-side liquidity within the pool.
Blackholeswap introduced its cross-protocol AMM in 2020. It could process transactions beyond its liquidity by tapping into the excess supply of other lending protocols. Today, lending platforms like AAVE utilise the idle liquidity present in these AMM pools to lend to their users.
This article by Beincrypto throws light on how far AMMs have come since 2017.
How Automated Market Makers Work
Centralised crypto exchanges (CEXs) use order books that match buy and sell orders. Order books aren’t decentralised and automated. Also, order books can’t be used to facilitate trades in markets with scarce liquidity.
That’s where AMMs come in.
Automated market makers allow traders to make trades using an algorithm that dictates the price of tokens based on their supply in the liquidity pool.
The Role of Liquidity Pools
Crypto liquidity pools are smart contracts holding token/s that provide liquidity to decentralised exchanges (DEXs).
These pools are governed by AMMs, which set the prices and automate trades.
Together, they create a dynamic and transparent setting for decentralised protocols to function seamlessly.
A liquidity pool usually has a token pair, from which traders can swap one token for the other. For instance, this ETH/USDT pool on UniSwap V3 is a popular LP.
As a trader buys more of one token, there’s less of it than there was earlier in the pool. Consequently, it becomes more expensive. Reciprocally, since the trader swaps the first token for the second token, the second token’s supply increases within the pool. More supply means discounted prices.
AMMs simply put in code the law of demand and supply using algorithms for continuous liquidity and efficient price discovery in DeFi protocols.
Today, DeFi protocols and DEXs use sophisticated algorithms and weighted liquidity pools for better efficiency, automated trades, and greater fund protection against slippage.
The Math Behind AMMs: Pricing Formulas
Different AMMs use different mathematical formulas to determine the price of tokens in the liquidity pool. However, the most common and simplest formula is the Constant Product Formula, represented as x*y=k
Where,
x is the amount of the first token in the liquidity pool
y is the amount of second token in the liquidity pool
k is the constant value that the liquidity pool needs to maintain all the time.
The AMMs use this formula to ensure the combined value of tokens in the liquidity pool remains the same before and after every trade.
But how?
Whenever a user swaps tokens from the liquidity pool, the supply of the tokens (x or y) either increases or decreases. The AMM uses this formula and adjusts the prices of the tokens so that the product k always remains the same.
Let’s understand this with the help of an example,
Suppose a 50:50 liquidity pool contains two tokens - Alpha and Beta. The pool has 100 tokens of Alpha priced at $10 and 1,000 tokens of Beta, each priced at $1.
As per the constant product formula:
k = x*y
(10*100)*(1,000*1)
1,000*1,000 = 1,000,000
The total value of Alpha and Beta in the pool should remain $1,000,000 at all times.
There can be two case scenarios here.
Adding Alpha to receive a corresponding quantity of Beta from the liquidity pool
Adding Beta to receive a corresponding quantity of Alpha.
For instance, swapping Beta for Alpha in a liquidity pool decreases Alpha’s supply, raising its price, while increasing Beta’s supply lowers its price. AMMs ensure equilibrium using the constant product formula x⋅y=kx \cdot y = kx⋅y=k. This mechanism underpins efficient pricing in decentralized markets.
That’s how AMMs work as a liquidity provider and a pricing mechanism for DEXs and other liquidity protocols.
This video by WhiteBoard Crypto explains how AMMs work in the simplest and most succinct way possible.
Types of Automated Market Makers
Constant Product Market Maker (CPMM)
In the previous section, we discussed how Constant Product Market Makers work.
CPMM algorithms are a type of Constant Function Market Makers (CFMM). CPMM uses the constant product formula x*y=k to adjust the supply of tokens in the pool to keep the total value of the pool constant.
Bancor introduced CPMMs but they were made popular by UniSwap in 2018. Vitalik Buterin was among the first to ideate CPMMs for DEXs.
CPMM suffers from price slippage and impermanent loss risks. SushiSwap, QuickSwap, Pangolin DEX, PancakeSwap, and Raydium Protocol, and several other protocols use CPMM today.
Constant Sum Market Makers (CSMM)
CSMM uses the sum of two tokens in the pool as the constant, unlike CPMM.
For CSMM,
k = x+y
As the supply of token x increases, the supply of token y decreases proportionally so that the total sum, i.e., k, in the pool, remains constant.
The CSMM model has comparatively lower slippage risk than the CPMM model. This is because in CSMM, the size of the trade does not impact the exchange price of the tokens in the LP.
The image above shows the red curved line depicting price movements with fluctuating supply in the CSMM model. The blue straight line depicts the stable prices and zero slippage the CPMM model guarantees.
Still, the CSMM model isn’t a popular choice for DEXs as the model may become incapable of providing enough liquidity when handling large trades.
CSMM is often used in confluence with other models.
Hybrid AMMs
Hybrid AMM models find the middle ground between CPMM and CSMM models for liquidity provision.
A hybrid model can incorporate elements from different AMM models and be customised to serve specific purposes.
Curve Finance is a good example of a Hybrid AMM. It brings together the good elements of CPMM and CSMM models for a robust and capital-efficient AMM model. This model can handle large trades without compromising on liquidity (CPMM) and can lower the price slippage risk that comes with large trades (CSMM).
Balancer’s hybrid AMM model allows for up to 8 tokens in a pool with customizable weights, enhancing efficiency and liquidity compared to traditional CPMMs.
No intermediaries: Automated Market Makers (AMMs) serve a dual purpose in DeFi. They provide instant liquidity to traders by disintermediating transactions, and they also allow liquidity providers to engage in yield farming to earn transaction fees. AMMs also eliminate the need for order books or centralised control. Instead, AMMs use code-governed automated trading.
Global accessibility: AMMs allow for the trading and swapping of cryptocurrencies without the need for traditional intermediaries. AMMs can provide liquidity for token pairs even with scarce liquidity, allowing greater accessibility. AMMs also generate income through yield farming activities such as staking and liquidity mining. Read this article by NFT.E to learn more about DeFi and its offerings.
Reduced slippage: AMMs allow efficient trading by using algorithms to determine prices and facilitate trades. These AMM protocols have advanced mechanisms that ensure minimum slippage even when the trade size is large. AMMs route your trade through multiple liquidity sources for the best AMM price discovery.
Risks and Challenges
Impermanent loss: Impermanent loss happens when AMMs constantly determine new token prices based on their supply within the liquidity pool. When the prices of tokens fluctuate owing to AMM algorithms, the difference in price resulting from the change in the value of assets is called an impermanent loss.
Impermanent loss is the opportunity cost of contributing liquidity to an AMM pool over keeping the assets in your wallet. Read about impermanent loss in detail in this NFT.EU article.
Other risks: AMMs can also be prone to hacks and other smart contract vulnerabilities. Due to heavy congestion, gas and trading fees may get high for traders, leading to low liquidity. Market volatility can also play a part in impacting pool values.
Though there are numerous applications of AMMs in the DeFi space, let’s consider some top AMM protocols as real-world examples:
UniSwap
UniSwap is an AMM-based DEX on the Ethereum blockchain with over $4.1 billion TVL and controls 59% of the total DEX volume. UniSwap’s first version came in 2018 and was based on CPMM. Its V2 version enabled traders to create liquidity pools for ERC-20 token pairs at low gas fees.
In 2020, UniSwap introduced its token, $UNI, to incentivise Liquidity providers (LPs) and add decentralised governance and voting to its ecosystem. In 2021, Uniswap V3 made decentralised trading more capital-efficient by accumulating individual positions as a combined curve.
Check out real-time statistics of UniSwap on Defillama
Curve Finance
Curve Finance is a unique AMM-based DEX that provides only stablecoin pools. This results in relatively low slippage in prices as stablecoins are less volatile than other cryptocurrencies. Curve is a trusted DEX for executing large trades at very low gas fees.
The curve also provides some unique opportunities for passive income in DeFi. These include metapools, factory pools, and lending pools where LPs can earn varying percentages of yields and CRV tokens that carry voting rights.
Real-time statistics of Curve Finance on Defillama
Balancer
Another popular DEX since its launch in 2020, Balancer, uses a hybrid AMM model to offset liquidity pool risk and other associated ills. It offers multi-asset pools of up to 8 tokens.
The liquidity pools are weighted and can have customisable proportions from 2 to 98% for different tokens. This makes Balancer a lot more efficient and possesses deeper liquidity than other pools, but it’s a lot less beginner-friendly than UniSwap and Curve.
Check out the real-time statistics for Balancer on Defillama.
Please note: All these DEXs are first-generation AMMs and carry multiple risks, as discussed in the previous section. When you start engaging in yield farming on any of the DeFi platforms, remember to monitor your pool and check whether the market conditions are in favour. There is a chance that the trading fees you earn will be eaten up by impermanent loss.
Future of Automated Market Makers
The current AMMs are still evolving, and still need a lot of user-centric improvements to make AMMs more user-friendly and reliable. We need to introduce educational resources and guides to help users understand the associated risks and opportunities. The user interface needs to be made more mobile-friendly and accessible for non-technical users.
AMMs are evolving with Layer-2 scaling solutions to reduce costs and enhance speed. Cross-chain integrations, like THORChain, enable seamless token swaps across blockchains, while AI-driven tools help optimize fees and manage risks.
AMMs can present great passive income generation opportunities via liquidity incentives and arbitrage trading. All you need is a wallet to get started. Don’t forget to DYOR.
For more insightful pieces on DeFi and blockchain, check out NFT.EU.
Discover. Learn. Profit
Subscribe to our newsletter to be in-loop with all news from the crypto world
FAQs
Why did the concept of automated market makers (AMMs) emerge in the world of Web3?
In centralised trading, market makers are used to provide liquidity for trading pairs of tokens. The centralised exchange acts as an intermediary between the buyer and the seller. When the CEX cannot find suitable order matches, the liquidity of the token in question becomes low. CEXs only list tokens with high liquidity and repute.
DEXs bring accessibility via AMMs. AMMs replace order books and market makers with liquidity pools governed by algorithms. AMM-based tokens can provide liquidity for all markets while decentralising trades. AMMs form the core of Web3’s vision of a decentralised future.
What are the differences between automated market makers and centralised exchanges (CEXs)?
AMMs are smart contract algorithms that help automate trade and pricing of tokens without the need for order books. CEXs have order books to match buyers and sellers, but AMM-led DEXs have liquidity pools providing continuous liquidity. AMMs make DeFi trading more accessible, quick, and rewarding.
Can I earn passive income with AMMs?
Yes, you can earn passive income with AMMs through yield farming as a liquidity provider and through arbitrage trading as a DeFi trader. As an LP, you earn trading fees, annual yields, and platform tokens for providing liquidity. As a trader, you make profits from price differentials.