Ever since the dawn of financial history, markets had to be made. Tracing back to 17th century spice trading where intermediaries bought and sold shares to offer investors higher liquidity, market making has evolved tremendously. Through equities, foreign exchange rates, and even physical assets, market makers today provide liquidity and are ready to buy any asset at publicly quoted prices. However, as time passes, financial markets evolve alongside it. The past several years, we’ve seen an incredible increase in decentralized finance (DeFi), coupled with the rise in automated market making. In this article, we analyze the brief, yet complex, history of automated market making and its effects on the crypto markets.
First, we will give a short background on the history of automated market making and how it evolved into the crypto sphere. Then, we discuss the three generations of AMMs and their subdivisions in the crypto market. As you will see in this article, as time passes, the mathematics, platforms, and smart contracts subsequently increase in complexity. My hope in this article is that novice and advanced users of blockchain technology alike will understand the evolution of automated market makers and will get a better degree of the route it's going.
To begin, several definitions need to be understood to get a full grasp of this article:
Blockchain - A decentralized distributed database with an ongoing immutable validation of transactions by nodes. The underlying technology for crypto-assets, decentralized applications, and smart contracts.
Decentralized Finance (DeFi) - Financial products operating on smart contracts and blockchain technology. The digital revolution to democratize finance.
Automated Market Makers (AMM) - A decentralized asset trading pool allowing users to buy and sell cryptocurrencies by seamlessly trading against its liquidity.
Decentralized Exchanges (DEX) - Peer-to-peer platform allowing users to transfer crypto-assets without an intermediary, often using an AMM as its trading pool.
Liquidity Pool - Digital “pools” of crypto-assets stored in a smart contract. AMMs run on top of liquidity pools.
Liquidity Providers (LPs) - The equivalent to a market maker in an AMM, someone who deposits their crypto-assets in a liquidity pool in order to increase liquidity. In return, they receive rewards from fees generated from the trades on that platform or pool.
Contrary to popular opinion, automated market makers were not invented purely for the cryptocurrency markets. In fact, AMMs have been studied quite significantly amongst academic circles for decades. The first mentions of AMMs were discussed in Robin Hanson’s studies for Logarithmic Market Scoring Rules as early as 2002. Later studies of AMMs in non-crypto settings revolved around information aggregation (2004), prediction markets (2006), Bayesian models (2012), and betting markets (2012).
However, the first time AMMs were referenced for a cryptocurrency application was in a historic 2016 Reddit post by the creator of Ethereum, Vitalik Buterin, who discussed the idea of running decentralized exchanges the same way prediction markets are run.
Vitalik’s ideas picked up steam and a community followed quickly. Two years later, he released a follow up article with some more specifications on how he sees decentralized exchanges actually playing out. Several months later, Hayden Adams announced the launch of Uniswap protocol, thus starting the first generation of cryptocurrency AMMs.
The First Generation of Crypto AMMs: The Foundations
Uniswap revolutionized automated market makers by introducing them in a functional way to the crypto sphere. They presented the Constant Product Market Maker (CPMM), a formula ensuring constant liquidity on decentralized exchanges.
Constant Product Market Makers and the Rise of Uniswap
Uniswap introduced the constant product market maker formula to ensure there is constant liquidity in the exchange of tokens on Ethereum. The formula is as follows:
Where Rx and Ry is the reserves of each token, f is the transaction fee, and k is a constant. Or more simply written,
where x is token 1, y is token 2, and k is a constant.
In essence, Uniswap combines the two assets being traded into one liquidity pool. Uniswap’s goal is to ensure that no matter the size of the trade, the size of the liquidity pool will remain constant. Let’s say asset x is ETH, and asset y is DAI. In order to keep k constant, x (ETH) and y (DAI) can only move inverse of each other. When you make a purchase of ETH, you increase y (as you add DAI to the liquidity pool) and decreasing x (as you remove ETH from the liquidity pool). Ultimately, the pool becomes imbalanced, tipping towards the asset that you exchanged into the pool. Arbitrageurs come in and quickly rebalance it, in return for the difference in profits.
For a simple explanation of how constant function market makers work, I recommend reading this article. To understand Uniswap more thoroughly, this article has an excellent explanation.
The Uniswap CPMM model was paradigm shifting for several reasons. First, it was the first decentralized exchange that completely removed the middleman from any transaction. The combination of easy liquidity and fast exchanges with an on-chain mechanism for quoting remarkably close to the correct price was revolutionary. What’s most impressive, however, is that this was done in less than 300 lines of code.
After lots of preparation, formalization, and hype, Uniswap launched quite successfully. Since their launch, they have been by far the most actively used DEX by volume.
The Drawbacks of CPMMs
Despite all of these remarkable advances, Uniswap and initial CPMMs still have their drawbacks. Namely, slippage, impermanent loss, and security risks.
Slippage is the difference between the expected price of an order and the price when the order actually executes. Given cryptocurrency’s unpredictable volatility, the price of each token can fluctuate often depending on trade volume and activity. Most commonly, pools with little liquidity or larger trades are most affected by slippage. The slippage percentage shows how much the price for a specific asset moved throughout the trade, or how much your slippage tolerance is.
Impermanent loss is the change in price of your assets deposited into a liquidity pool. Given the price fluctuations that happen outside of the liquidity pool, the depositor is missing out on potential gains. The bigger the price change, the more a depositor is exposed to impermanent loss. For that reason, stablecoins are significantly less risky in terms of impermanent loss. Impermanent loss gets its name because the losses are indeed impermanent, until realized. For that reason, I prefer saying divergence loss.
Other risks that affect CPMMs are inherent security risks in the smart contracts, platform, and their mempools. However, as the ecosystem matures, security and MEV prevention improves along with it. In general, anyone experimenting with decentralized finance should be prepared to incur financial loss, as the sector is extremely young and juvenile.
Constant Sum Market Makers (CSMM)
A second implementation of the CPMM is the constant sum market maker (CSMM). In this AMM, it is ideal for close-to-zero price impacts during trades, but it does not provide infinite liquidity. They follow the formula:
Where Rx and Ry is the reserves of each token, f is the transaction fee, and k is a constant. Looks familiar. Written more simply, the formula is expressed as:
where x is token 1, y is token 2, and k is a constant. Following this formula, it plots a straight line when graphed.
Unfortunately, this design gives traders and arbitrageurs the opportunity to drain one of the reserves if the off-chain price doesn’t match with the tokens in the pool. Such a situation would destroy one side of the liquidity pool, leaving all of the liquidity residing in just one of the assets and therefore making the liquidity pool unfit for use. Because of this, CSMM is a model rarely used by AMMs.
Constant Mean Market Makers (CMMM)
The third type of first-generation AMM is the constant mean market maker (CMMM) popularized by Balancer. In this AMM, each liquidity pool can have more than the traditional two assets and can be weighed differently than the classic 50:50 weighing system. Ultimately, the weighted geometric mean of each reserve remains constant. CMMMs satisfy the following equation:
Where R is the reserves of each asset, w is the weights of each asset, and k is the constant. More simply, in an equal liquidity pool with three assets, the equation would be the following:
Where x is token 1, y is token 2, and z is token 3, and k is constant. Balancer’s documentation is excellent for understanding their weighted math!
Despite being able to weigh up to eight assets together, first-generation AMM issues like impermanent loss and minimal capital efficiency are still applicable in CMMMs. Ultimately, the first generation of AMMs is the time period that built the building blocks for modern day AMMs.
The Second Generation of Crypto AMMs: Improving Limitations
We identified the key limitations preventing first generation AMMs from becoming financial behemoths. Issues of price fluctuations, impermanent loss, capital efficiency, security, and usability affect the initial AMMs most. Luckily, society is eager to innovate, and a new generation of AMMs were born shortly after. It is difficult to point out exactly when it happened timeline-wise, but the DeFi Summer of 2020 was certainly a major catalyst. What is most famous from the new generation of AMMs, however, was Curve’s Stableswap.
Hybrid CPMMs and Curve.Fi
Curve Finance had an insight of combining the traditional CPMM and CSMM and creating a Hybrid-CPMM. Known as the Stableswap invariant, Curve brought forth an advanced formula that creates exponentially denser pockets of liquidity towards the outer bounds, and a linear exchange rate for the majority of the curve. The formula is the following:
Where x is the reserves of each asset, n is the number of assets, D is the invariant (total value in the reserve), and A is the amplification coefficient (similar to “leverage”, basically how curved the line is). Here’s a great explanation of Curve’s Stableswap formula.
Curves Stableswap is a CSMM as the liquidity pool is balanced, and shifts towards a CPMM as the pool becomes imbalanced. It founds its market fit by significantly decreasing slippage for trades on assets closely correlated to each other.
Curve’s Stableswap is especially dominant for stablecoins (hence the name), given their low price impact trades. Later on, as we’ll see, Curve introduced a second version of their pools designed for uncorrelated assets.
Ultimately, Curve was the clear winner of second generation AMMs. Up until market carnage several months ago, Curve had a significant percentage of Total Value Locked (also known as TVL, a measurement of how much value in assets is deposited into the platform).
In addition to Curve, there were many other major accomplishments in second generation AMMs as we’ll note. Many of these continued expanding and solving the issues we identified with first generation AMMs.
Other 2nd Generation AMMs
Virtual Automated Market Makers (vAMMs), Derivatives, and Perpetual Protocol
Perpetual Protocol introduced a new application for AMMs by enabling trading of perpetual contracts completely on-chain. In short, perpetual contracts are derivatives similar to future contracts, but without an expiry date. Perpetual protocol uses the same AMM formula as Uniswap (x * y = k), but there is no liquidity pool in which the assets are stored (k). Rather, all the assets are stored in a smart contract that holds all the assets backing the vAMM. As the “virtual” part of vAMM implies, rather than swapping real tokens, vAMMs are used to swap virtual synthetic assets, like derivatives. Here’s a good run-down of how vAMMs work on Perpetual Protocol.
Since Perpetual Protocol launch, there has been lots of innovation and hype around trading derivatives on-chain. Some other example platforms include Synthetix, GMX, and FutureSwap.
Proactive Market Maker (PMM) and DODO
Aiming to increase liquidity on its protocol and to minimize low fund utilization rates, DODO introduced the Proactive Market Maker (PMM). In short, PMMs utilize on-chain oracles to gather accurate price data and aggregate liquidity near the current market price. To do so, DODO actively shifts the curve of the asset pool to ensure sufficient liquidity is available and creates a flatter curve across the market price. As the curve gets flatter, liquidity becomes more widely available and users benefit from lower slippage. DODO also implemented single-sided liquidity, where there are two separate pools for a single trading pair (a bid pool and an ask pool). In some ways, PMMs would be the closest equivalent to a traditional market maker.
Bancor
Widely considered as one of the founding fathers of DeFi, the case for Bancor is interesting. Bancor was the first AMM to launch with one of the largest token generation events in blockchain history. However, centralization and security concerns in its first few months prevented it from fully picking up steam, ultimately leading to Uniswap gaining market dominance.
However, Bancor had some remarkable innovations in itself that are worth mentioning. The original Bancor protocol invented modern-day liquidity pools, calling them “relays” and “smart tokens” at the time. Bancor V2 & V2.1 brought forth impermanent loss protection (after staking your assets for 100 days) and single-sided liquidity. Bancor 3 introduced instant impermanent loss protection, auto-compounding and dual-sided rewards, and a variety of other interesting features. However, there have been several design concerns with the protocol in recent months that have halted its growth as a leading DEX.
SushiSwap and Liquidity Mining
In August 2020, an anonymous developer forked the source-code of Uniswap and created a rival clone with a higher focus on the community aspect of DeFi through a governance token and staking rewards. Through a vampire attack on Uniswap's liquidity, Sushiswap quickly gained prominence and an influx of users. For the first time in DeFi history, the first on-chain hostile takeover took place. After the attack, Sushiswap captured nearly 9% of all DEX volumes and lots of community attention. Several days later, however, the pseudonymous founder Chef Nomi sold the entire development fund for 38,000 ETH (~$14 million). Sparking outrage from the community, Chef Nomi returned all the funds back to the protocol and issued an apology message. Since its controversial founding, Sushiswap has developed a well-regarded DeFi ecosystem with a suite of DeFi tools, including a multi-chain DEX, a lending market, a token launchpad, a liquidity provision reward system, and a recent AMM development framework. Despite it’s rough start, Sushiswap has created a formidable reputation for itself.
Aggregators
Although not specifically part of the evolution of AMMs, another innovation that came in the second generation AMM period worth mentioning was DEX aggregators. In short, DEX aggregators source liquidity across different DEX’s and suggest the best token swap rates to the user. The most well known DEX aggregator is 1inch, however other well known ones are Paraswap and OpenOcean. Most recently, CowSwap has had some fascinating innovations in the aggregator space.
Recapping Second Generation AMMs
In the second generation of AMMs, we saw the issues that arose in the first generation being solved with complex mathematical equations, unique liquidity pool blends, and the creation of a variety of other financial use-cases for AMMs.
The Third Generation of Crypto AMMs: Modern Day Behemoths
After dissecting the innovations of second generation AMMs, one would think third generation AMMs would take these remodelings to a further level with even further complex research and solutions. However, this hypothesis is surprisingly proven wrong, as third generation AMMs (and modern day AMMs for that matter) are primarily dominated by the two behemoths that reinvented and updated themselves from the second generation: Uniswap V3 and Curve V2.
In this section, we’ll analyze their groundbreaking innovations, their rise to dominance, and how they have somewhat monopolized the market. We’ll conclude the chapter with several other AMMs that have brought forth notable innovations in recent months. Timeline wise, think of the third generation of AMMs as mid-2021 to the start of the crypto bear market in the recent months.
Uniswap V3 and Concentrated Liquidity
Earlier, we discussed the launch of Uniswap and their rise to dominance in the market. In May 2020, Uniswap launched their second version, Uniswap V2, which introduced ERC20 pairs, price oracles, flash swaps, and a variety of other technical improvements. Although not significantly drastic changes to the platform, it was certainly a step forward in innovation. Uniswap V3, however, created a new paradigm in automated market makers.
In March 2021, Uniswap announced their third iteration of their platform, Uniswap V3. In it, they introduced two major new features: concentrated liquidity and multiple fee tiers. Concentrated liquidity gave LP’s granular control over what price ranges their capital is allocated to, thus providing significantly higher capital efficiency and significantly lower slippage, while also protecting against any asset freefall scenario. The flexible fees offered LP’s the opportunity to tailor their margins based on the expected volatility of the pairs they deposit.
Since Uniswap V3’s launch, they’ve had ~$700 billion in trade volume, ~90% dominance over all Uniswap trades, over $5.5 billion in TVL (with a peak of $10 billion in Nov 2021), and a significant majority in DEX market share.
Curve V2 and Automation (But With Trade-Offs!)
We discussed earlier Curve’s creation of Hybrid CPMMs, Stableswap, and their rise to prominence in the decentralized exchange of directly pegged assets. Several months after Uniswap V3s launch, Curve announced their creation of a direct competitor: Curve V2.
In Curve V2, Curve expanded on their Stableswap innovation and enabled the efficient pool to be utilized for all assets, not just stablecoins. Additionally, similar to Uniswap V3, Curve introduced concentrated liquidity - but with one caveat: LPs don’t choose their liquidity range. Rather, Curve’s in-house market making algorithm and price oracles create the liquidity range, thus creating a passive environment for LPs. Curve attempted to capitalize on the complaints that concentrated liquidity on Uniswap required too much active management for novice DeFi users. In addition to automated concentrated liquidity, Curve also introduced customized pools to accommodate any LPs' ideas (although it is rather complicated to create a pool).
Despite being a groundbreaking invention in the sense that the concentrated liquidity is automated, it came with a trade-off that more experienced DeFi users wouldn’t be able to actively manage their funds. Coupled with Curve’s rustic and intimidating UX, the juxtaposition is evident as to why most altcoin liquidity is still on Uniswap. Regardless, Curve likely has superior trade execution to Uniswap in terms of efficiency and price slippage. For a great side-by-side comparison of Curve V2 and Uniswap V3, take a look at this report by Delphi Digital.
At the time of writing, Curve does have a higher TVL than Uniswap by about $500 million, although its peak TVL is more than double the former ($24 billion). However, Curve consistently ranks 2nd to Uniswap in a variety of other metrics such as total volume, revenue, and market cap.
In short, Curve likely attracts the more advanced DeFi users, although their claim-to-fame of automated concentrated liquidity puzzles me, given their clientele is adequate enough to configure their liquidity themselves. Trends show Curve’s dominance is growing, and given their technology is comparable or even stronger than Uniswap, purely psychological and adoption barriers are holding them back.
Ultimately, Uniswap V3 and Curve V2 are the two clear winners of the third generation of AMMs. However, it is certainly interesting and worthwhile to mention other notable AMM innovations from the third generation. Although none of these gained close to as much traction as Uniswap and Curve, their technologies are certainly impressive.
Other Gen3 AMMs
Solidly
Solidly is an AMM built on Fantom that allows low-cost near-zero slippage trades both for correlated and uncorrelated assets. Although it did not have any remarkable AMM design innovations, its complex tokenomics mechanism design is focused primarily on generating volume and transactions, as opposed to merely incentivizing TVL and liquidity provision in traditional crypto AMMs. It rose to fame because of its founder, Andre Cronje, a DeFi mastermind who ultimately left the ecosystem, subsequently causing Fantom TVL to plummet and drama to rise. Ultimately, Solidly brought lots of fame to Fantom, although since its decline it has become near-obsolete.
Lifinity
Lifinity, built on the Solana blockchain, expanded and combined the ideas introduced by Uniswap and DODO. Namely, the intersection of proactive market making and concentrated liquidity. Although concentrated liquidity improves capital efficiency, issues of impermanent loss are still prevalent. Thus, Lifinity added a proactive market making mechanism with Pyth oracles on top of the concentrated liquidity. Since Lifinity’s liquidity pools are not reliant on arbitrageurs to keep prices accurate, risks of impermanent loss are greatly reduced. Lifinity also added an automatic rebalancing mechanism to ensure the value of the two assets in the pool always remained constant.
The Future of Crypto AMMs: Solving the Biggest Problem of All
In this article, we discussed how the concept behind cryptocurrency AMMs evolved from a simple algebraic equation into an ecosystem of innovation and research. The amount of developer interest in DeFi is growing day by day, and the critical usability is growing as well.
However, the greatest hill to overcome is now upon the ecosystem. Active users in decentralized finance are still a fraction of cryptocurrency users as a whole, and are a fraction of a fraction of the global financial system. To create a new financial paradigm, users must follow. Although solving issues like impermanent loss, capital efficiency, and slippage are certainly necessary to foster worldwide adoption, these innovations tend to only make DeFi more complicated. Movements like “DeFi in the back, FinTech in the front” (referring to underlying backends on applications being decentralized finance, while the user experience is as seamless as modern FinTech) are necessary to lead this trend.
To put this into numbers, Uniswap, the largest DEX as discussed earlier, in its history has had 600k unique users. Coinbase, the largest centralized crypto exchange, has over 100 million verified users. Meaning, over 100 million people are already interested in cryptocurrencies, yet haven’t made the leap into DeFi where they can actively control their finances. Certainly, the platform which facilitates the transition from a novice crypto user to decentralized finance will win the so-called “DEX wars”.
We already see this trend playing out in many DeFi platforms already. Protocols are prioritizing well-written documentation, simple layouts (other than Curve, the second most used DEX, ironically), and gamification of their platforms (a questionable idea in my eyes - finances should not be gamed), allow beginner users an easier entryway into the decentralized finance world.
Just last week, Trader Joe, the biggest DEX on the Avalanche blockchain, announced their new AMM, Liquidity Book. In short, it allows liquidity to be priced into fixed bins, taking the concentrated liquidity idea a step further. Coupled with their simple-to-use all-in-one financial ecosystem platform, perhaps that's a trend unfolding before our eyes. Other new innovations in the recent months are blended AMMs, MEV capturing AMMs, and increase in use cases for Bitcoin in a DeFi setting. Anticipation for the much-awaited ETH merge next month also will greatly affect decentralized finance as energy use will be reduced by ~99%, thus allowing for greater bandwidth for transactions.
All in all, mainstream adoption of decentralized finance remains to be the biggest obstacle ahead of us. Through the innovations highlighted in this article, I can assure we’re taking steps closer everyday. I’m glad to be doing my part in educating and developing the next generation of finance. Now that you’ve read this article, what are you doing?
Thats an awesome and comprehensive overview.
Have you also been looking into NFT AMMs? Would be very curious on your thoughts on such types of AMMs.
Awesome overview. Thanks for writing this.
If am not asking too much, such detailed overviews for other main Crypto Primitives would be awesome .