This article aims to provide an overview of Automated Market Makers (AMMs). It references blockchain technology and impermanent loss. If you are unfamiliar with DeFi, read our introductory articles on DeFi, blockchain, and impermanent loss before reading this article.
The Mechanism Behind AMMs
Short for Automated Market Makers, AMMs are platforms that facilitate the trade of digital tokens using liquidity pools. Compared to a traditional exchange where buyers and sellers indicate prices at which they would like to trade an asset, AMMs facilitate trades automatically and instantly between users and liquidity pools.
In 2017, Bancor launched as one of the pioneering decentralized exchanges (DEXs) in cryptocurrency (crypto), built initially on the Ethereum network. It was the first to introduce AMMs with algorithmically priced assets in liquidity pools. Uniswap popularized the use of AMMs in 2018. Other examples of top crypto decentralized exchanges using AMMs include SushiSwap, PancakeSwap, and Curve Finance.
What Is a Liquidity Pool?
A liquidity pool is a pool comprising two types of crypto tokens. Users can deposit equal values of both tokens to participate in the liquidity pool, where they can earn trading fees when other users trade that pair of tokens.
For instance, if a user exchanges ETH for DAI in an ETH-DAI liquidity pool, the transaction fees paid will be distributed to every liquidity provider (LP) of the ETH-DAI pair according to the percentage of the pool they own. In some cases, LPs can earn extra rewards in the project’s native token, adding an extra layer of incentives. Learn more about DeFi farming here!
Constant Product Formula
An AMM can hold many different liquidity pools, each with an interest rate determined by its popularity. To maintain equilibrium, many AMMs use a constant product formula. The constant is represented by “k” in the following formula popularized by Uniswap:
x × y = k
This formula adjusts the prices of each token in the pool according to the number of tokens, as denoted by “x” and “y”. To aid understanding, we will use an ETH/BTC trading pair as an example. When traders purchase ETH, the price of ETH rises as there is a lower supply in the pool. On the contrary, BTC price falls as there is a greater quantity of the asset in the pool. Ultimately, the pool will stay in constant balance by adjusting the price of the assets to keep the total value of ETH and BTC equal.
Generally, token prices in these pools do not deviate significantly from real market prices. The balance of the liquidity pool is maintained by arbitrage traders capitalizing on price differentials of assets on multiple exchanges to make profits. For example, if the price of ETH falls below the market rate on a particular exchange, arbitrage traders can take advantage of this price imbalance by buying the cheaper ETH and selling it for profit on other exchanges. Consequently, the price of ETH will continuously adjust until it reaches the market rate.
Variations in Mechanisms
With the DeFi ecosystem constantly changing and growing, alternative mechanisms have emerged beyond the constant product formula. Here are a few examples:
Balancer pools use a constant mean formula, allowing up to 8 tokens at variable ratios, compared to the more common two tokens at a 1:1 ratio.
Curve creates liquidity pools of similar assets such as stablecoins. This results in reduced impermanent loss and transaction fees since fluctuations in prices of stablecoins are usually much smaller.
3. Uniswap v3
Uniswap v3 features many improvements, including concentrated liquidity and active liquidity. Although it continues using the constant product formula, users can now choose the price range they would like to allocate their assets to and thus earn fees. Once out of that range, liquidity will be rendered inactive. Previously, liquidity would be distributed across the entire curve evenly from prices 0 to infinity, exposing LPs to more impermanent loss.
Benefits of AMMs
Better Rates for Large Trades
Popular Ethereum trading pairs on CEXs do not accommodate large trading orders in a preferable price range. According to research, a trader who executes a $5 million trade can save around $24,000 on Uniswap v3 than on Coinbase.
Decentralization and Transparency
CEXs are also infamous for exploiting markets to conduct insider trading. AMMs are decentralized and non-custodial. Greater transparency with on-chain order books and the lack of a centralized entity makes DEXs more secure than their centralized counterparts. The smart contract code is also accessible to the public, allowing crypto natives to verify the code rather than rely on a centralized business to remain solvent.
Risks of Providing Liquidity
Impermanent loss is the difference in token value if users hold tokens in a wallet instead of putting them in a liquidity pool. Due to the constant product formula, the AMM constantly tries to maintain the ratio of tokens provided in a liquidity pool. This means that the price of the assets will fluctuate during rebalancing. Since crypto assets are volatile, there is a possibility that users can profit more simply by holding on to their crypto rather than putting it in a pool.
A comprehensive analytics platform such as Harvest by Treehouse can show you any impermanent loss incurred across your portfolio. Harvest also offers you a detailed breakdown of your P&L and a historical view of your portfolio.
Pools must reimburse LPs for the potential loss of value in the form of fees. Users who trade with the liquidity pool provide these fees. While liquidity providers benefit by receiving a proportional percentage of these payments, traders bear a relatively high cost with every transaction.
Slippage refers to the event where the actual price changes from its original value during a trade. Slippage is worsened by the price volatility of the assets in the pool since traders affect the prices with every transaction made. However, slippage issues can be resolved by attracting more liquidity into the pool. With a larger liquidity pool, changes in the ratio of tokens will be less significant with every trade made. Thus, changes in asset price can be minimized.
Aside from this, there is the ever-present threat of hackers exploiting smart contract vulnerabilities, such as loopholes in the protocol’s code. The only way to minimize this risk is to do your own research or DYOR, and only deposit your funds in more reputable projects that have been audited by proficient smart contract auditors.
The Future With AMMs
Despite the risk of impermanent loss, AMMs provide many opportunities to those looking to expand their financial portfolio. Aside from the ease of trading tokens, AMMs open up arbitrage opportunities and allow users to earn rewards. They can even build entire communities through liquidity mining and allow blockchain projects to launch new cryptocurrencies with greater ease. As the backbone of DEXs, AMMs have brought invaluable innovation to the DeFi landscape and will probably remain a staple in the space.
New to DeFi? If you found this useful, check out our other Learn DeFi articles to dive deeper into the wonderful world of DeFi! Alternatively, browse our Insights section to read more in-depth analyses on the DeFi space. You can also try out our flagship product, Harvest, to get a comprehensive analysis of your DeFi assets. Lastly, subscribe to newsletter updates in the box below!