Decentralized finance (DeFi) offers intermediary-free, blockchain-based financial services and is one of the hottest growth segments in the crypto economy. During 2017–2023, the average yearly user account number in DeFi grew from a meager 189 to more than 6.6 million, and annual DeFi trading activity hit the $1 trillion mark in 2021.
Some reports suggest decentralized exchanges (DEXs) like Uniswap often surpass the trading volume on established centralized crypto exchanges (CEXs) like Coinbase. Although there are many reasons behind the surge in DEX usage, an algorithmic framework called the automated market maker (AMM) model played a key role in DeFi's recent development. To this day, many of the most widely used DEXs rely on AMMs to offer users convenient peer-to-peer (P2P) trading.
Since AMM DEXs have become a dominant part of DeFi, it's important to understand how they work before swapping cryptocurrencies on DEXs that leverage this technology. Learning the basics of AMM protocols helps you better assess the benefits and potential risks of relying on this model.
What is Market Making in Crypto?
Because AMMs are a new version of a traditional practice called "market making," reviewing how market making works on CEXs and contrasting it with DeFi helps to clarify the function of AMMs.
CEXs like Coinbase rely on centralized "orderbooks" to record every transaction on their platforms and match buyers and sellers whenever people want to exchange cryptocurrency. To ensure there's always a willing counterparty on a CEX to take a trade’s other side, these companies typically work with high-volume traders or professional firms called "market makers" to provide their exchanges with higher volumes of crypto asset. Market makers offer "liquidity" to a CEX's platform, making it easy for traders to quickly exchange digital assets with minimal price inefficiencies (aka slippage). These crypto market makers collect a small percentage of every transaction on a CEX called a "bid-ask spread," where "bids" are the highest price traders are willing to buy digital assets, and the "ask" price is the lowest sellers are willing to sell their cryptocurrencies. The "spread" is the slight difference between the "bid" and "ask" price on a CEX, which serves as compensation for market makers. For instance, if Bitcoin (BTC) had a bid price of $24,997 and an ask price of $25,000, the spread would be $3 per coin.
What are Automated Market Makers?
AMMs are algorithmic protocols that remove intermediaries from the market-making process. DEXs use AMM algorithms to confirm crypto transfers between traders without using orderbooks or centralized market makers. Instead, AMM DEXs use smart contracts to verify P2P crypto transfers between traders. For example, if developers create a smart contract to transfer five Ethereum (ETH) coins to a specific crypto wallet when a trader deposits 10,000 USDC into an account, it automatically recognizes the 10,000 USDC deposit and sends the five ETH to the user's crypto wallet. All the transfers on AMM DEXs take place on blockchains with smart contract functionality, including Ethereum, Cardano, and Solana.
What is an AMM Liquidity Provider?
Smart contracts "automate" trading on AMM DEXs, but these programs don't magically create money for users to trade. AMM DEXs need to incentivize people to add liquidity to their protocols for users to exchange. However, instead of working exclusively with centralized trading firms or traders, DEXs let any crypto trader become a liquidity provider (LP) by contributing digital assets to the protocol. LPs fill the role of market makers on AMM DEXs by depositing cryptocurrency into virtual vaults known as "liquidity pools." In return for providing liquidity to exchanges, LPs often receive a percentage of the DEX's trading fees or token compensation.
How Does an AMM Work?
Every AMM DEX uses a different algorithm to constantly adjust the supply in liquidity pools, but one of the most common models is the Constant Product Market Maker. First introduced on Uniswap, Constant Product AMMs use the equation "x*y=k" to ensure an equal supply of two cryptocurrencies in a liquidity pool. In this equation, "x" represents the total amount of the first cryptocurrency, "y" is the total of the second digital asset, and "k" is a constant variable. Here, LPs must supply a 50/50 ratio of the two crypto assets in their trading pair to maintain balance in the liquidity pool.
For example, suppose Ethereum trades for $2,000 per coin, and someone wants to contribute to an ETH/USDC liquidity pool on Uniswap. Since USDC is a USD stablecoin, it always has a 1:1 value with the U.S. dollar, meaning 2,000 USDC equals one ETH. Therefore, an LP might supply two ETH and 4,000 USDC ($8,000) to the ETH/USDC pair.
In the same scenario where ETH equals $2,000, imagine the ETH/USDC pair has 50 ETH and 100,000 USDC. In this case, the "k" constant is 5 million (50 x 100,000 = 5 million), so the sum of the two assets in this pool must always equal this value. If a trader bought one ETH from this pool with 2,000 USDC, the Constant Product algorithm works out the following algebra to calculate the new value for ETH:
(50 - 1) (100,000 + x) = 5 million
49 (100,000 + x) = 5 million
100,000 + x = 5 million/49
100,000 + x = 102,040.816
x = 102,040.816 - 100,000
x = $2,040.816
The above equation shows that by removing one ETH from the liquidity pool, the trader made ETH more valuable and increased its market price from $2,000 to $2,040.816 per coin. It also reveals the value of USDC changed to 102,040.816 when one ETH left the pool. To verify this, multiply 102,040.816 by 49 to equal the constant "k" value of 5 million. The AMM continuously adjusts the liquidity pool's price dynamics and asset proportions using the above formula depending on whether people buy or sell these digital assets.
Benefits of the AMM Model
AMM is a powerful tool in DeFi for traders who value self-custody of their digital assets. This model also makes it easier for crypto holders to earn rewards by joining a liquidity pool.
Offers full ownership of digital assets: An AMM DEX's algorithm and smart contracts enable crypto trading without relying on a third-party intermediary. Traders send and receive virtual currency on an AMM DEX directly in their self-custodial crypto wallets, so there's no need to worry about potential counterparty risk.
Makes it easy for new blockchain projects to launch: Small, independent crypto projects don't need to depend on CEX listings or venture capitalists to raise funds. Developers who know the basics of coding cryptocurrencies can publicize, organize, and launch their tokens on an AMM DEX. Since DEXs don't have intermediaries checking every token listing, emerging and experimental projects often find it simple to sell tokens on DEXs.
Gives you a chance to become a market maker: AMM DEXs let anyone with a crypto wallet become a market maker by depositing digital assets in liquidity pools. As long as LPs feel comfortable with the risks inherent in DeFi, including zero insurance protections and the potential for hacks, they can earn passive income from DEX fees.
Risks With First-Generation AMMs
Although AMM DEXs like Uniswap, Curve Finance, and PancakeSwap dominate today's DeFi ecosystem, there are a few potential concerns about over-reliance on AMM algorithms. Critics often point out inherent inefficiencies in using the AMM model.
Heavily depends on arbitrage: Arbitrage is a trading practice where people simultaneously buy and sell the same digital asset to profit off market inefficiencies. For example, if a trader notices ETH trades for $2,000 on Uniswap and $2,050 on Coinbase, they'd buy ETH on Uniswap and sell it on Coinbase for a $50 profit per coin. DEXs rely heavily on arbitrageurs to balance liquidity pools when cryptocurrencies’ value deviates too far from the average market rate. Since AMM DEXs don't maintain orderbooks, they must seek outside traders to spot and correct inefficiencies constantly.
Impractical for large orders without high liquidity: Another disadvantage of not using an orderbook is that AMM DEXs have greater difficulty processing trades at specific prices for buyers and sellers (aka limit orders). Traders also need to be wary of their trade's impact on the liquidity pool's balance of assets and their final price. High-volume transactions have greater odds of significantly disrupting the price dynamics in a liquidity pool, often resulting in slippage.
Potential impermanent loss: Because the ratio of crypto assets constantly changes based on market dynamics, each LP’s 50/50 split may not be the same when they want to withdraw. For instance, if Ethereum's price goes on a significant bull run, LPs in an ETH/USDC pool have less ETH and more USDC than the 50/50 proportion they initially deposited. In this case, an LP "lost" the price appreciation of holding the original ETH amount in a crypto wallet rather than giving it to a liquidity pool (aka impermanent loss). The fees an LP collects from their pool must offset the impermanent loss from a cryptocurrency's price increase to counteract this phenomenon.
Prone to scams: Although it's easier for legitimate crypto start-ups to launch tokens on DEXs, it's also simpler for scammers to create a sham token and lure unsuspecting traders. Estimates suggest scam tokens on DeFi sites like AMM DEXs account for billions of dollars in lost funds.
Does dYdX Use an AMM Model?
Although AMM is popular in DeFi, it's not the only algorithm used on DEXs. For instance, dYdX uses an off-chain orderbook model to offer eligible users a fast and efficient crypto trading experience. Using a combination of an off-chain orderbook and matching engine plus an on-chain settlement layer, dYdX offers eligible traders fast, low-slippage trading between dozens of crypto perpetual contracts without sacrificing the benefits of decentralization and self-custody of assets. dYdX also offers eligible traders seamless API integrations attracting deep liquidity from the DeFi sector, further reducing the risk of slippage when trading crypto assets. dYdX believes that the hybrid matching infrastructure provides the fastest, cheapest, and most convenient way for eligible traders to take advantage of decentralized derivatives trading. However, with the upcoming release of open source software that can enable the dYdX Chain, dYdX will further improve on this model with increased transparency and open-source code.
Head to the dYdX blog to learn more about our product and platform.
Access Deep Crypto Liquidity on dYdX
Unlike AMM DEXs, eligible traders on dYdX can access deep liquidity from the DeFi ecosystem and institutional market makers using our advanced off-chain orderbook model. With this intricate system, eligible traders can enjoy both maximum capital efficiency for low slippage confirmations and the privacy of P2P decentralized trading.
For more details on how DeFi and crypto perpetuals trading works, check out the educational guides on dYdX Academy.
Eligible traders can start trading on dYdX today!
Disclaimer
The content of this article (the “Article”) is provided for general informational purposes only. Reference to any specific strategy, technique, product, service, or entity does not constitute an endorsement or recommendation by dYdX Trading Inc., or any affiliate, agent, or representative thereof (“dYdX”). Use of strategies, techniques, products or services referenced in this Article may involve material risks, including the risk of financial losses arising from the volatility, operational loss, or nonconsensual liquidation of digital assets. The content of this Article does not constitute, and should not be considered, construed, or relied upon as, financial advice, legal advice, tax advice, investment advice, or advice of any other nature; and the content of this Article is not an offer, solicitation or call to action to make any investment, or purchase any crypto asset, of any kind. dYdX makes no representation, assurance or guarantee as to the accuracy, completeness, timeliness, suitability, or validity of any information in this Article or any third-party website that may be linked to it. You are solely responsible for conducting independent research, performing due diligence, and/or seeking advice from a professional advisor prior to taking any financial, tax, legal, or investment action.
You may only use the dYdX Services in compliance with the dYdX Terms of Use available here, including the geographic restrictions therein.
Any applicable sponsorship in connection with this Article will be disclosed, and any reference to a sponsor in this Article is for disclosure purposes, or informational in nature, and in any event is not a call to action to make an investment, acquire a service or product, or purchase crypto assets. This Article does not offer the purchase or sale of any financial instruments or related services.
By accessing this Article and taking any action in connection with the information contained in this Article, you agree that dYdX is not responsible, directly or indirectly, for any errors, omissions, or delays related to this Article, or any damage, injury, or loss incurred in connection with use of or reliance on the content of this Article, including any specific strategy, technique, product, service, or entity that may be referenced in the Article.