Long Text Interpretation: The Evolution History of AMM

BennyAttar
2022-08-31 10:02:51
Collection
The biggest obstacle we face is how decentralized finance can gain application in mainstream scenarios.

Author: Benny Attar

Compiler: wesely, The Way of DeFi

Since the emergence of financial concepts, there has been a corresponding financial "market." This concept can be traced back to the spice trade in the 17th century, where intermediaries provided higher liquidity to investors by buying and selling shares of spices. However, today's market makers have undergone significant changes. Today, market makers can provide liquidity for stocks, foreign exchange, and even physical assets, purchasing any asset through public quotes. Over time, financial markets have also rapidly evolved. In recent years, we have witnessed the rapid growth of decentralized finance (DeFi) and the rise of automated market making. In this article, I will primarily analyze the development history of automated market making and its impact on the cryptocurrency market.

First, I will briefly introduce the history of automated market making and how it has evolved; then I will discuss three generations of AMMs and their segmented applications in the cryptocurrency market. As time goes on, the complexity of mathematics, application platforms, and smart contracts has also increased. I hope this article will help both blockchain newcomers and seasoned users understand the evolution of automated market makers and better grasp their development trajectory.

To fully understand the content of this article, you first need to be familiar with the following definitions:

  • Blockchain: A decentralized distributed database that continuously verifies transactions in an immutable manner by various nodes. Blockchain is also the underlying technology for all crypto assets, decentralized applications, and smart contracts.

  • Decentralized Finance (DeFi): Financial products that operate based on smart contracts and blockchain technology, DeFi has initiated a revolution in the democratization of digital finance.

  • Automated Market Maker (AMM): A decentralized asset trading pool that allows users to seamlessly trade cryptocurrencies through its liquidity.

  • Decentralized Exchange (DEX): A peer-to-peer platform that allows users to trade crypto assets without intermediaries, often using AMMs as their trading pools.

  • Liquidity Pool: A digital asset "pool" of cryptocurrencies stored in smart contracts, on which AMMs operate.

  • Liquidity Provider (LP): Equivalent to market makers in AMMs, referring to individuals who deposit their crypto assets into liquidity pools to increase liquidity, in return for which they receive transaction fee rewards generated by the relevant trading pool.

Contrary to popular belief, automated market makers were not invented purely for the cryptocurrency market. In fact, academia has conducted quite in-depth research on AMMs for decades. As early as 2002, Robin Hanson first mentioned AMMs in his study of logarithmic market scoring rules. Later, research on AMMs primarily revolved around information aggregation (2004), prediction markets (2006), Bayesian models (2012), and gambling markets (2012) in non-crypto fields.

The first reference to AMMs in the crypto space was made by Vitalik Buterin in a Reddit post in 2016, where he discussed the idea of building decentralized exchanges in the same way as running prediction markets. Subsequently, Vitalik's idea began to circulate within the community and was quickly followed up by a community. Two years later, Vitalik published a follow-up article on AMMs, detailing his views on the role of decentralized exchanges. A few months later, Hayden Adams announced the launch of the Uniswap protocol, marking the beginning of the history of the first generation of cryptocurrency AMMs.

image

First Generation AMM: Building the Foundation

Uniswap introduced automated market makers to the crypto space in a very practical way, fundamentally changing the concept of automated market making. They proposed a market maker model called Constant Product Market Maker (CPMM), which is a formula that ensures DEX maintains continuous liquidity.

Constant Product Market Maker (CPMM) and the Rise of Uniswap

Uniswap introduced the constant product market maker formula to ensure constant liquidity in Ethereum token trading, as follows:

image

Where Rx and Ry refer to the reserves of each token, f is the transaction fee, and k is a constant, simplified as follows:

image

Where x is Token 1, y is Token 2, and k is a constant.

Essentially, Uniswap combines two assets being traded into a liquidity pool. The goal of Uniswap is to ensure that regardless of the size of the trade, the asset scale in the liquidity pool remains unchanged. For example, suppose asset x is ETH and asset y is DAI; to keep k constant, x (ETH) and y (DAI) can only increase or decrease in relation to each other. When you buy ETH, the amount of y (DAI) in the pool increases while x (ETH) decreases, causing the trading pool to become unbalanced and tilt towards the asset flowing into the pool. At this point, arbitrageurs will step in to profit (Note: when the trading pool becomes unbalanced, it indicates a price deviation, thus creating an arbitrage opportunity), ultimately returning to balance. image

x*y=k market maker, Vitalik Buterin

The Uniswap CPMM model represents a paradigm shift for AMMs for several reasons. First, it was the first decentralized exchange to completely remove intermediaries. Second, it achieved a combination of liquidity, fast trading, and on-chain mechanisms, allowing for pricing at correct values, which is revolutionary. Most impressively, this was accomplished with only about 300 lines of code. Since its launch, Uniswap has been the most widely used DEX to date.

image

Data Source: Dune Analytics, @hagaetc

Drawbacks of CPMM

Although Uniswap and the initial CPMM made significant progress for AMMs, there are still some drawbacks, such as slippage, impermanent loss, and security risks.

Slippage refers to the difference between the expected price of an order and the actual price at which the order is executed. Given the volatility of cryptocurrencies, the price of each token can fluctuate due to trading volume and activity. Most commonly, liquidity pools with low liquidity or those suddenly facing large trading volumes are more susceptible to slippage. The slippage percentage indicates how much the price of a specific asset has deviated throughout the trade, and it also represents the user's tolerance for slippage.

Impermanent loss is the change in the price of the assets you deposited into the liquidity pool. Due to price fluctuations occurring outside the liquidity pool, users (depositors) who have deposited into the liquidity pool may face potential losses in earnings. The greater the price change of the assets, the larger the impermanent loss faced by depositors. Therefore, in terms of impermanent loss, stablecoins carry much lower risk. The term "impermanent loss" is used because the losses indeed occur impermanently, but I prefer to call it divergence loss.

Other risks affecting CPMM mainly come from the inherent security risks of smart contracts, platforms, and their memory pools. As the ecosystem matures, security and MEV prevention have also improved. Generally speaking, anyone entering decentralized finance should be prepared to suffer financial losses, as this industry is still in a very early stage.

Constant Sum Market Maker (CSMM)

Another model similar to CPMM is the Constant Sum Market Maker. In this AMM, it is very suitable for scenarios where price changes during trading are close to zero, but it cannot provide unlimited liquidity. They follow the following formula:

image

Where Rx and Ry are the reserves of each token, f is the transaction fee, and k is a constant. A simpler formula can be expressed as:

image

Where x is Token 1, y is Token 2, and k is a constant. According to this formula, a straight line can be plotted as follows.

image

Visualization of CSMM (Dmitriy Berenzon)

However, when there is a mismatch between off-chain prices and the tokens in the pool, this design allows traders and arbitrageurs to deplete the pool's reserves, disrupting the stability of the liquidity pool and concentrating the assets in the pool into a single asset, thereby preventing the liquidity pool from functioning properly. This is also why CSMM has become a rarely used model for AMMs.

image

Homogeneity of Automated Market Makers ( Jensen, Nielsen, Pourpouneh, Ross)

Constant Mean Market Maker (CMMM)

This type of AMM model is primarily promoted by Balancer's Constant Mean Market Maker (CMMM). In this AMM, each liquidity pool can have more asset types than the traditional two assets, and unlike the classic 50:50 weighting system, this model allows for different weights for different assets while ensuring that the weighted geometric mean of each asset's reserves remains unchanged. CMMM satisfies the following equation: image

Where R is the reserve of each asset, w is the weight of each asset, and k is a constant. If it is a liquidity pool with three assets of equal liquidity, the equation can be simplified as follows: image

Where x is Token 1, y is Token 2, z is Token 3, and k is a constant. There is a very detailed introduction in Balancer's documentation. image

Source: Balancer Whitepaper

Although CMMM can simultaneously apply up to eight different assets, it does not solve the problems of the first generation AMM (such as impermanent loss and low capital efficiency). Nevertheless, the first generation AMM remains the cornerstone for building modern AMMs.

Second Generation AMM: Improving Deficiencies

In the first generation of AMMs, issues such as price volatility, impermanent loss, capital efficiency, security, and usability had a significant impact on AMMs. Fortunately, society craved innovation, and shortly after the emergence of the first generation of AMMs, a new generation of AMMs was born. It is difficult to pinpoint the exact time of its emergence, but the summer of DeFi in 2020 was undoubtedly an important catalyst. The most famous of the new generation AMMs is Curve's Stableswap.

Hybrid CPMM and Curve.Fi

Curve Finance combines traditional CPMM and CSMM to create a hybrid CPMM, also known as Stableswap (Note: Stableswap combines the low slippage of constant sum with the infinite liquidity characteristics of constant product). In this, Curve proposed an advanced formula that can create exponentially dense liquidity, most of which belongs to linear exchange rates. The specific formula is as follows: image

Where x is the reserve of each asset, n is the number of assets, D is the invariant (the total value in reserves), and A is the amplification coefficient (similar to "leverage," representing the curvature of the curve).

image

Curve's Stableswap is a special type of CSMM; when the liquidity pool is balanced, it is CSMM, and once the pool becomes unbalanced, it switches to CPMM. It significantly reduces slippage when trading related assets by finding its market fit.

image

Curve Whitepaper

Curve's Stableswap is very suitable for stablecoins because the impact on trading prices is minimal in this model. Later, we will also see the second version of AMM launched by Curve, designed specifically for unrelated assets.

Curve is undoubtedly one of the winners of the second generation AMMs. Even in the face of the current bear market, Curve's locked TVL still occupies a significant share.

image

Data Source: Dune Analytics, @naings

In addition to Curve, the second generation AMMs have also achieved many other significant accomplishments, some of which have addressed various issues we encountered in the first generation AMMs.

Other Second Generation AMMs

Virtual Automated Market Maker (vAMM), Derivatives, and Perpetual Protocols

Perpetual protocols have opened up perpetual contract trading through a 100% on-chain model, bringing AMMs into a new application field. In short, perpetual contracts are derivatives similar to futures contracts but without an expiration date. Perpetual protocols use the same AMM formula as Uniswap (x * y = k) but do not have a liquidity pool (k) storing assets. Instead, all assets are stored in smart contracts, which contain all assets supporting vAMM. As the "virtual" part of vAMM suggests, vAMM does not exchange real tokens but is used to exchange virtual synthetic assets, such as derivatives.

Since the launch of Perpetual Protocol, many innovations and hype have emerged around on-chain derivatives trading, along with many other platforms like Synthetix, GMX, FutureSwap, etc.

Proactive Market Maker (PMM) and DODO

To increase liquidity for the protocol and maximize capital utilization, DODO introduced the Proactive Market Maker (PMM). In short, PMM uses on-chain oracles to gather accurate price data and aggregate liquidity near the current market price. To achieve this, DODO needs to timely adjust the curve of the asset pool to ensure sufficient liquidity is available and create a flatter curve across the market price. As the curve becomes flatter, liquidity becomes more widespread, allowing users to benefit from lower slippage. DODO also implements unilateral liquidity, where a single trade corresponds to two independent pools (a buy pool and a sell pool), making PMM closer to traditional market maker models from certain perspectives.

Bancor

Bancor is one of the earliest DeFi native projects, and its development has also been dramatic. Bancor was the first and largest AMM launched via TGE in blockchain history. However, centralized and security issues in the initial months hindered Bancor's development, ultimately leading to Uniswap gaining market dominance later.

However, Bancor itself also has some noteworthy innovations. The original Bancor protocol invented what we now call liquidity pools, referring to them as "relays" and "smart tokens." Bancor V2 and V2.1 introduced impermanent loss protection (after 100 days of asset collateral) and unilateral liquidity. Bancor 3 launched instant impermanent loss protection, automatic compounding, dual rewards, and various other interesting features. However, in recent months, the protocol has faced some design issues that hindered its entry into the top DEX ranks.

SushiSwap and Liquidity Mining

In August 2020, an anonymous developer forked Uniswap's source code and created a project that garnered more attention from the DeFi community through governance tokens and staking rewards. By conducting a vampire attack on Uniswap, SushiSwap quickly gained notoriety and attracted a large number of users. In DeFi history, this marked the first on-chain "hostile takeover." After the attack, SushiSwap captured nearly 9% of DEX trading volume and significant community attention. However, a few days later, the pseudonymous founder Chef Nomi sold the entire development fund for 38,000 ETH (approximately $14 million), causing outrage in the community. Chef Nomi returned the funds and issued an apology. Since its controversial inception, SushiSwap has developed a highly regarded DeFi ecosystem, including a suite of DeFi tools, multi-chain DEX, lending markets, token launch pads, liquidity net reward systems, and a recent AMM development framework. Despite a rocky start, SushiSwap has built an impressive reputation for itself.

Aggregators

While aggregators are not a core part of AMM development, another noteworthy innovation emerged during the second generation AMM period: DEX aggregators. In short, DEX aggregators can source liquidity from different DEXs and provide users with the best token exchange rates. The most famous DEX aggregator is 1inch, with others like Paraswap and OpenOcean. Recently, CowSwap has also made some notable innovations in the aggregator space.

Review of Second Generation AMMs

In the second generation AMMs, we see that the issues that arose in the first generation AMMs are being addressed through complex mathematical equations, unique liquidity pool designs, and the creation of various financial use cases for AMMs.


Third Generation AMM: Contemporary Giants

After analyzing the innovations of the second generation AMMs, one might think that the third generation AMMs would elevate these transformations to a higher level through more complex research and solutions. However, the third generation AMMs are primarily dominated by two giants that have self-transformed and updated from the second generation: Uniswap V3 and Curve V2.

In this section, we will analyze their groundbreaking innovations, their dominance, and how they have monopolized the market. We will conclude this chapter with several other AMMs that have brought significant innovations in recent months. Timeline-wise, the third generation AMMs began in mid-2021 and continued until the recent cryptocurrency bear market.

Uniswap V3 and Concentrated Liquidity

Earlier, we discussed the birth of Uniswap and its dominant position in the market. In May 2020, Uniswap launched their second version, Uniswap V2, which introduced ERC20 pairs, price oracles, flash swaps, and various other technical improvements. Although there were no significant changes to the platform's surface, this was undoubtedly a step forward in innovation. Uniswap V3 created a new paradigm for automated market makers.

image

Uniswap's version data source: Kyros Ventures.

In March 2021, Uniswap announced the third iteration, Uniswap V3. In the updates, they introduced two major new features: concentrated liquidity and multiple fee tiers. Concentrated liquidity allows LPs to finely control the price range of their capital allocation, significantly improving capital efficiency and reducing slippage while preventing any asset from experiencing a flash crash. Flexible fees allow LPs to adjust their margins based on the expected volatility of the currency pairs they deposit.

image

Since the launch of Uniswap V3, they have achieved approximately $700 billion in trading volume, accounting for 90% of all trading across different versions of Uniswap. Additionally, with over $5.5 billion in TVL (peaking at $10 billion in November 2021), they hold a significant share of the DEX market.

image

Data Source: Dune Analytics @Bibip

Curve V2 and Automation

We previously discussed the Hybrid CPMM and Stableswap created by Curve and their rise in decentralized trading of directly pegged assets. A few months after the release of Uniswap V3, Curve announced their Curve V2 to compete with Uniswap V3.

In Curve V2, Curve expanded their Stableswap innovation and made effective pools usable for all assets, not just stablecoins. Additionally, similar to Uniswap V3, Curve also introduced concentrated liquidity, but one point to note is that LPs cannot choose their liquidity ranges. Instead, Curve's internal market-making algorithm and price oracle create the liquidity ranges, creating a passive environment for LPs. Curve believes that the concentrated liquidity on Uniswap is too difficult for DeFi newcomers, making Curve V2 more user-friendly. Besides automated concentrated liquidity, Curve also introduced customizable pools to accommodate any LP's ideas (although creating pools is quite complex).

Although concentrated liquidity is a groundbreaking invention in automation, it also prevents experienced DeFi users from actively managing their funds. Coupled with Curve's intimidating user experience, many altcoins still prefer Uniswap. Nevertheless, Curve performs better than Uniswap in terms of efficiency and price slippage.

At the time of writing, Curve's TVL is indeed about $500 million higher than Uniswap's, although its peak TVL was more than double that of Uniswap (approximately $24 billion). However, in various other metrics such as total volume, revenue, and market capitalization, Curve consistently ranks behind Uniswap.

image

Daily total revenue of Uniswap and Curve over the past 180 days (Source: Token Terminal) image

Daily circulating market capitalization of Uniswap, Curve, and Balancer over the past 365 days (Source: Token Terminal)

In summary, Curve may attract more advanced DeFi users, and trends indicate that Curve's dominance is growing. Given that their technology is comparable to or even stronger than Uniswap's, market perception and application expansion are the main reasons hindering its development. Ultimately, Uniswap V3 and Curve V2 are the two main winners of the third generation AMMs. It is worth mentioning that there are other notable AMM innovations in the third generation, although they have not received as much attention as Uniswap and Curve, their technology is also formidable.

Other Third Generation AMMs

Solidly

Solidly is an AMM built on the public chain Fantom, allowing for low-cost, near-zero slippage trading of related and unrelated assets. Although it does not have any significant AMM design innovations, Solidly features a complex tokenomics mechanism, where the related design incentivizes rapid growth in trading volume and asset quantity, rather than merely incentivizing liquidity providers as in traditional crypto AMMs. Solidly gained fame due to its founder Andre Cronje, known as the father of DeFi, who ultimately chose to leave the industry, leading to a significant drop in Fantom's TVL, but Solidly also brought a lot of fame to Fantom.

Lifinity

Lifinity is built on the Solana blockchain, extending and combining some AMM mechanisms from Uniswap and DODO: proactive market making and concentrated liquidity. Although concentrated liquidity improves capital efficiency, the issue of impermanent loss still persists. Therefore, Lifinity adds a proactive market-making mechanism, the Pyth oracle, on top of concentrated liquidity. Since Lifinity's liquidity pool does not rely on arbitrageurs to maintain price accuracy, it significantly reduces the risk of impermanent loss. Lifinity also incorporates an automatic rebalancing mechanism to ensure that the value of the two assets in the pool remains unchanged.

The Future of AMMs: Solving Core Issues

In this article, we discussed how cryptocurrency AMMs have evolved from simple algebraic equations to an innovative ecosystem. Currently, developers' interest in DeFi is growing, and the usability of products is improving.

However, the biggest obstacle to overcome now lies above the ecosystem. Active users in decentralized finance still represent only a small fraction of the entire cryptocurrency user base, and in the global financial system, they are negligible. To create a new financial paradigm, users are a prerequisite. Although addressing issues like impermanent loss, capital efficiency, and slippage positively impacts the global application of DeFi, these innovations often make DeFi more complex. A good product might be "DeFi in the back, FinTech in the front" (meaning the underlying backend of the application is decentralized finance, while the user experience can be as seamless as modern financial technology), which is also a necessary condition to lead this trend.

From the data, Uniswap is currently the largest DEX, with 600,000 unique users in its history. On the other hand, Coinbase, as the largest CEX, has over 100 million users. This means that even though more than 100 million people are already interested in cryptocurrencies, they have not entered the DeFi space, where they could control their asset investments. Platforms that facilitate the transition of new crypto users to DeFi will win the "DEX war."

In fact, we have already seen this trend on many DeFi platforms. These protocols often prioritize well-written documentation, simple layouts, and gamified platforms, making it easier for beginners to enter the world of decentralized finance.

Last week, Trader Joe, the largest DEX on Avalanche, announced their new AMM liquidity book, which allows liquidity to be priced as fixed positions, further advancing the idea of concentrated liquidity while also providing a simple and user-friendly integrated financial ecosystem. This may be the current development trend. Other recent innovations include hybrid AMMs, MEV capture AMMs, and the increasing use cases for Bitcoin in the DeFi environment. The long-awaited ETH merge next month will also greatly impact the development of decentralized finance, as Ethereum's energy consumption is reduced by 99%, providing greater bandwidth for transactions.

In conclusion, how decentralized finance gains mainstream application remains the biggest obstacle before us. However, through the introduction of this article, I can confirm that this industry is making progress every day.

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
banner
ChainCatcher Building the Web3 world with innovators