What Are Automated Market Makers (AMMs)?
Explore Automated Market Makers (AMMs) and their role in decentralized finance, facilitating crypto trading via smart contracts and liquidity pools.
Explore Automated Market Makers (AMMs) and their role in decentralized finance, facilitating crypto trading via smart contracts and liquidity pools.
Automated Market Makers (AMMs) are a core component of decentralized finance (DeFi), transforming how digital assets are traded. These systems enable the automatic and permissionless exchange of cryptocurrencies through liquidity pools, rather than traditional order books. AMMs provide continuous liquidity to the DeFi ecosystem by employing mathematical algorithms to determine prices and manage asset flow.
AMMs operate differently from traditional order book exchanges that match individual buyers and sellers. Instead, AMMs utilize liquidity pools and mathematical formulas to facilitate trades and determine asset prices. A liquidity pool is a shared collection of two or more cryptocurrencies held within a smart contract. These pools serve as the primary source of liquidity, allowing users to swap tokens directly against the pool.
Liquidity pools are funded by individuals known as “liquidity providers” (LPs). These providers contribute crypto assets, typically in equal value of two different tokens, into the smart contract. By supplying these assets, LPs enable continuous trading. The market maker function, traditionally performed by financial institutions, is automated by a smart contract, removing the need for intermediaries and allowing for permissionless trading directly with the smart contract.
Trading on an AMM occurs by interacting directly with smart contracts that govern liquidity pools. The most common mathematical model for determining asset prices is the constant product formula, expressed as x y = k. In this formula, ‘x’ and ‘y’ represent the quantities of the two tokens in the liquidity pool, while ‘k’ is a constant value that must be maintained. This formula ensures the product of the reserves of the two assets remains constant, even as trades occur.
When a user swaps tokens, they deposit one asset into the pool and withdraw a corresponding amount of the other. For instance, if a user buys Token B with Token A, the amount of Token A in the pool increases, and the amount of Token B decreases. The constant product formula then recalculates the new ratio of assets to ensure ‘k’ remains unchanged, thereby adjusting the price of the tokens. This mechanism means that as one asset is bought, its quantity decreases, causing an automatic adjustment in the price ratio between the two assets.
Liquidity providers contribute their assets to these pools. In return for providing liquidity, they earn a portion of the trading fees generated from transactions within that pool. These fees are a small percentage of each trade, often ranging from 0.01% to 1%. The collected fees are then distributed among the liquidity providers proportionally to their share of the total liquidity in the pool. The pool automatically adjusts prices based on the constant product formula.
AMMs involve several specific concepts. Impermanent loss refers to a temporary divergence in the value of deposited assets compared to simply holding them. This occurs because the price ratio between the assets in the liquidity pool changes due to market volatility. The loss is considered “impermanent” because it is unrealized until the assets are withdrawn from the pool.
Impermanent loss arises when the price of a token within a liquidity pool significantly deviates from its price in external markets. The AMM’s algorithm attempts to maintain a balanced ratio within the pool, which can lead to a lower value for a liquidity provider’s assets than if they had not deposited them. If the price ratio eventually reverts to its initial state, the impermanent loss can diminish or disappear. However, if assets are removed during a period of price divergence, the loss becomes realized.
Slippage is the difference between the expected price of a trade and the actual price at which the trade is executed. This is a natural consequence of the constant product formula and the depth of the liquidity pool. Slippage becomes more pronounced with larger trades or in pools with lower liquidity, as a large order can significantly alter the asset ratio and price within the pool.
Trading fees are an integral part of AMM functionality. These fees are a small percentage charged on each transaction within a liquidity pool. These fees serve as an incentive for liquidity providers, as they are distributed among them based on their contribution to the pool’s liquidity.