What is an AMM (Automated Market Maker)?

What is an AMM (Automated Market Maker)?
TabTrader Team
TabTrader Team
Reading time is 5 min
Publication date is

Automated Market Maker (AMM): What Is it and How Does it Work?

An Automated Market Maker (AMM) is an algorithmic trade matching system which forms a key component of decentralized exchanges (DEXes).

AMMs use mathematical formulas to allow DEX users to trade with one another without the need for a third party. Everything, from asset prices to liquidity, is controlled and executed automatically.

What Is an Automated Market Maker (AMM)?

An Automated Market Maker (AMM) is basically the decentralized equivalent of a traditional cryptocurrency exchange’s centralized order book.

On ‘legacy’ crypto trading platforms, the order book presents an overview of asset liquidity — how much of each asset is available and at what price — to traders. Trades execute based on liquidity conditions, subject to both parties obeying the terms of use of the exchange in question, or being ‘allowed’ to complete their desired trade.

Decentralized exchanges do not possess this centralized infrastructure, and are open access — anyone can use them, no matter what their reason or goal might be. Decentralized trading ecosystems require infrastructure that is free of arbitrary decision-making, and that is where AMMs come in.

The AMM takes over human-controlled operations as part of exchange functionality; the algorithm matches trades, monitors liquidity and ultimately deems — in a logical manner — whether or not a given trade is possible under current liquidity conditions.

AMMs themselves come in various types, with some considerably more popular than others, likewise for practical reasons. To learn more about decentralized exchanges (DEXes) and their other important features, as well as how to trade on them, check out the TabTrader Academy article on them here.

How Does an Automated Market Maker (AMM) Work?

An AMM does what its name suggests — it facilitates automatic trade matching on a crypto exchange according to fixed mathematical rules written in smart contracts. 

These will execute provided that those mathematical conditions are met by both parties, as smart contracts cannot be tampered with.

In place of an order book, where traders themselves provide liquidity at respective price levels, the algorithm does so instead. Traders provide liquidity, and are thus known as liquidity providers, while the AMM handles asset pricing according to how much of each token is available.

How a DEX handles the flow of trades and maintains stability depends on the algorithm employed by the AMM itself. These come in several forms, but by far the most common in the so-called constant product automated market maker (CPMM).

Regardless of which equation lies at the heart of a DEX’s AMM, however, it will obey the set mathematical formula required for stability. In the case of a CPMM, for example, that formula is designed to ensure that the total number of asset A tokens  multiplied by the total number of asset B tokens remains constant at all times.

This mechanism thus determines asset pricing, according to the basic principle of supply and demand.

The Role of Liquidity Pools and Liquidity Providers in AMMs

When a trader uses a DEX, the exact mechanism of swapping one token for another is understandably different to that of traditional centralized exchanges.

The AMM is responsible for matching trades, and as such, when a trader interacts with the DEX smart contract, they are altering the available liquidity that the AMM monitors. This is why a trader during execution is known as a liquidity provider.

Liquidity providers contribute to the overall availability of tokens on the DEX, and their combined contributions form the liquidity pool. The higher the liquidity, the better for any exchange, and liquidity providers are incentivized to interact with rewards as part of activities such as yield farming.

Liquidity providers are essential for smooth DEX operation, and low liquidity creates a risk of a trader encountering slippage — a noticeable difference between the expected price of a trade and its final settlement price.

It also creates opportunities for arbitrage traders who could notice that the price of a token on a given DEX is considerably different to the wider market. In practice, however, popular DEXes offer accurate pricing for major tokens, as seasoned traders monitor them for any coincidental price discrepancies and trade them for arbitrage profits, which returns the price to normal.

Malicious actors can take advantage of liquidity scenarios to manipulate how profitable a victim’s DEX trade ultimately is. For more information, read the TabTrader Academy article here.

Yield Farming Opportunities on AMMs

There is more to DEX use than simply trading. Users can lend out liquidity to platforms and earn rewards, known as a yield.

In practice, many investors seek to maximize the potential yield by providing liquidity in all number of places to various projects, and these entities are called yield farmers.

Yield farming is popular throughout decentralized finance (DeFi). As an example, staking liquidity on a DEX could reward the liquidity provider with a token representing ownership of the small part of the liquidity pool they helped to create. This is profitable over time, as DEX fees deducted from trades — possible thanks to AMMs — grow the liquidity pool and offer tangible gains for liquidity providers.

Different liquidity pools, however, can offer different returns on investment, so yield farmers move liquidity around between different assets to increase their returns via the above mechanism.

The subsequent evolution of yield farming came when liquidity providers began to earn tokens and interest at the same time. The value of these tokens increased as more liquidity was provided, stimulating more reliable DEX liquidity.

This is called yield mining, the name stemming from the fact that more tokens appear with increased liquidity pledges.

What Are the Different Automated Market Maker (AMM) Models?

Not all AMMs are created equal, but preferred models quickly emerged as DEXes gained traction.

There are three basic types of AMM, each with a different formula responsible for maintaining the integrity of their liquidity pool. These are constant product (CPMM), constant sum (CSMM) and constant mean (CMMM). Some projects, such as Balancer, use a mixture of these and thus are known as hybrid AMMs.

Continue reading to discover how each type of AMM stands out.

Constant Product Automated Market Maker (CPMM)

By far the most popular choice for DEX order handling between two assets is the Constant Product Market Maker (CPMM).

A CPMM allows trading between two assets to be conducted automatically, with prices decided as a function of classic supply and demand.

It does this using a mathematical formula: X*Y=K. Here, the product of asset A and asset B must remain constant, hence its name — there must always be a fixed total asset inventory. 

X*Y=K allows for the price per unit of either asset to fluctuate according to how much of that given asset is available, or how much liquidity there is. If a trader brings asset A to swap for asset B, asset A will start to cost less than before and asset B more.

This mechanism has an additional benefit of ensuring that liquidity stays available — it is only the price required to gain access to it that changes.

Constant Sum Automated Market Maker (CSMM)

A rarely-used AMM algorithm is constant sum, which handles liquidity using a subtly different formula: X+Y=K.

Here, the constant is simply the sum total of asset A plus asset B. Problems arise due to the impact that this can have on liquidity itself — there is no defense against one asset’s liquidity disappearing at the hands of arbitrage traders if the two assets are not identical in value.

Constant Mean Automated Market Maker (CMMM)

Constant Mean Automated Market Maker (CMMM) is a type of AMM used to handle trading between more than two assets.

Here, the geometric mean of all assets in the liquidity pool forms the constant K, allowing each to be priced according to liquidity conditions as with a CPMM.

As an example, if there are three assets in the liquidity pool, the mathematical equation for the CMMM will be (X*Y*Z)^(⅓)=K.

CMMM functionality is useful but still leaves traders at risk of slippage — price discrepancies while using a DEX — and subsequent incarnations of AMMs have sought to address this. The solution has been to incorporate elements of some or all of the AMMs types to produce a so-called hybrid AMM.

An example of a hybrid AMM is Curve, which uses a combination of CPMM and CSMM to manage its stablecoin trades — assets where the relative value is 1:1. 

The Bottom Line

Automated market makers lie at the heart of the decentralized exchange, and constitute essential infrastructure for DeFi token swaps.

AMMs have the unique ability to create and handle entire markets using mathematical equations which cannot be altered. This forms the backbone of DEX trading, where no individual use is required to prove eligibility to trade.

An AMM can work in different ways, with different equations, and some DEXes employ hybrid models for handling token swaps.

Whether or not a particular AMM is ‘better’ than another, beyond simple math, largely depends on the nature of the platform on which it is deployed. Certain DEX platforms cater to specific use cases, while some are designed for mass appeal.

Regardless, AMMs solve a key headache for crypto traders wishing to exchange as and when they desire, without arbitrary boundaries or ‘terms and conditions’ laid down by third parties.

Like everything in DeFi, the space is evolving constantly, with today’s industry already vastly different to the early days of the DEX and the first AMM deployments. AMMs may not be perfect, however, and some, such as constant sum AMMs, are rarely used as a standalone solution due to being liable to losing control of liquidity.

TabTrader offers access to the world’s biggest crypto exchanges from one convenient interface, and the list is constantly growing as the industry expands. If you haven’t done so, give the TabTrader app a go, now available for iOS, Android and Web.

New to crypto trading and want to learn more before hooking up your wallet via the TabTrader API? The TabTrader Academy has dozens of articles that will answer all your most burning questions. 

FAQ

What is an AMM in DeFi?

An AMM, which stands for automated market maker, is a protocol which uses mathematical equations to automate trades and maintain liquidity within a decentralized exchange (DEX). DEX trading is a major aspect of DeFi, and AMMs allow DEXes to offer permissionless trading without the need for a third party or centralized order book.

What is an example of an automated market maker?

Automated market makers (AMMs) are found in popular DeFi projects such as Uniswap, Curve Finance and Balancer. These decentralized exchanges, or DEXes, use an AMM to automate trade settlement and make it permissionless without the need for a third party.

How is an automated market maker different from a traditional market maker?

Automated market makers (AMMs) use math to ensure adequate liquidity within a decentralized exchange. This is very different from ‘traditional’ exchanges, including crypto trading platforms, where human market makers and exchange reserves are relied upon to provide the liquidity required.

What are the benefits of AMMs?

An AMM, or automated market maker, removes the pitfalls that accompany regular crypto exchange trading. Centralized infrastructure and permissioned usage are replaced by algorithms and smart contracts, meaning that anyone with a suitable crypto wallet can transact in an anonymous manner. 

Looking to get started in crypto trading?

Try TabTrader on mobile or web!

google-playapp-storeweb-app