Put your crypto investments on autopilot with Shrimpy Advisory. Sign up, get $20!
Learn More

×

What Is An AMM (Automated Market Maker)

May 8, 2023

5m

Read Time

As a sub-lesson of decentralized exchanges, (objectively the most important DeFi use case) we will resume covering DEXs by further exploring automated market makers (AMM).

Automated market makers (AMM) enable unstoppable, automated, and decentralized trading using algorithms to price assets in liquidity pools. Traditional exchanges require buyers, sellers, and a central reserve of assets. In contrast, AMM exchanges crowdsource liquidity and use smart contracts to execute trades.

In 2021, AMM-based exchanges are processing billions of dollars worth of on-chain transactions every day. Uniswap, Sushi, Balancer, and Curve Finance are a few top crypto decentralized exchanges using the AMM model to deliver DeFi to the masses.

Each AMM takes a slightly different approach, but the general idea is the same.

  • Crowdsourced liquidity pools replace order books + buyers/sellers
  • An algorithm offers everyone the same price when buying crypto

What is an AMM Exchange?

Automated market makers (AMM) are decentralized exchanges that pool liquidity from users and price the assets within the pool using algorithms. The exact mechanics vary from exchange to exchange, but generally, AMMs offer deep liquidity, low transaction fees, and 100% uptime for as many users as possible.

An easy way to understand AMM-based exchanges is to consider how they differ from traditional exchanges.

Traditional exchanges require buyers and sellers to meet at an overlapping price point on a centralized order book. In contrast, AMMs do quite a few things differently.

  • Incentivize users in a process called yield farming to deposit crypto assets in liquidity pools
  • Use an algorithm, usually x * y = k, to provide everyone trading with the pool a constant price
  • Automatically swap assets between traders and liquidity pools using smart contracts

How AMM Decentralized Exchanges Work

Uniswap is a prime example of how automated market makers work.

Uniswap is an AMM protocol that acts like a robot waiter serving up trades between you and a liquidity pool bootstrapped by liquidity providers (LPs). Under the AMM model, you can play several roles: trader, liquidity provider, and protocol governor. The protocol itself achieves two things:

  1. Prices assets
  2. Executes trades via smart contracts

For instance, let us imagine trading ETH tokens for UNI tokens on Uniswap. After clicking the swap button, the algorithm calculates how much the trade impacts the liquidity pool's reserves - after which a price quote is given.

After approving the transaction, the AMM deposits UNI tokens into the ETH-UNI pool. Finally, it sends the quoted amount of ETH from the pool to the customer’s wallet.

AMMs use a constant product formula to price assets, which states:

x * y = k

X and y are equal amounts of a liquidity pool’s assets while k is the total or constant amount of pool liquidity. Now, let us view the ETH-UNI trade from the perspective of our new formula.

To buy ETH (x) on Uniswap, users need to add UNI (y) tokens to the pool. Note that k demands that the amount of liquidity remains constant. Therefore, by adding UNI tokens users increase one side of the pool and decrease the other (removing ETH).

The algorithm divides the pool's total liquidity by the new amount of UNI in the pool, then divides that by the new amount of ETH in the pool so that (k / y) / x = price. This is how the protocol determines the price paid for ETH (and other tokens), which will increase the more ETH is bought from the pool.

The way AMMs handle liquidity is similar to smart order routing systems. Both track the best paths for gathering liquidity at the best price possible. You can try out smart order routing by registering an account on Shrimpy and swapping tokens.

Advantages

AMMs offer advantages that help introduce many DeFi features that traditional exchanges cannot replicate. Here are a few advantages that they hold.

  • Decentralization. Smart contracts are predefined agreements that operate by autonomously executing commands. Combined with governance models, DEXs effectively transfer ownership of both the platform and assets to its users. Obviously enough, there is no centralized entity.
  • Non-custodial. Traders and liquidity providers interact with DEXs directly from their crypto wallets, retaining full custodianship of their assets. All transactions are subsequently defined and processed via smart contracts.
  • No manipulation. CEXs are infamous for manipulating markets and conducting insider trading. With no one there to benefit from such actions, DEXs clearly have no way of directing prices in their favor.
  • Security. Hosting DEXs is often done in a distributed manner to prevent attacks. Moreover, hackers can only interact with liquidity pools on a trading platform and not with the users that interact with the exchange.
  • Token accessibility. Thanks to their decentralized nature, everyone can list an asset on DEXs without having to rely on a vouching or verification system operated by the platform’s owners.

Downsides

There are downsides to all innovations. The disadvantages of AMM models boil down to the following:

  • Liquidity limitations. Centralized exchanges also depend on liquidity provided by their users, but not to the degree of reliance that decentralized exchanges have. DEXs traditionally have no liquidity pools on their own, so they must be filled by yield farmers who contribute their assets for other traders to use. Without them, the exchange cannot offer trading services.
  • Speed. Less efficient order execution compared to their counterpart, which is mainly brought on by the traditional lack of advanced trading tools.
  • Volume and slippage. DEXs have picked up on volume, but without an order book and market maker, users suffer extreme slippage rates - especially with large orders.
  • Fees. No order book also means no low fees. All users pay a fixed trading fee, along with gas fees charged by the Ethereum network. When congested, the network charges hundreds of dollars for a single transaction.

Conclusion

Automated market makers were initially introduced by Vitalik Buterin in 2017. Four years later, the first AMM models were launched. Not only have they severely improved the capabilities of existing decentralized exchanges, but AMMs have also made it possible for DeFi to exist in the first place. Attractive yields for providing liquidity were one of the main reasons why market participants switched to DeFi at all.

Appropriately, the next lesson deals with liquidity mining and yield farming: two important methods of earning passive income in DeFi. Both function similarly but there are nevertheless important distinctions that are reason enough for each to have a lesson dedicated to them.

About The Author:  
Marko is a crypto enthusiast who has been involved in the blockchain industry since 2018. When not charting, tweeting on CT, or researching Solana NFTs, he likes to read about psychology, InfoSec, and geopolitics.

More Lessons in

A Beginner’s Guide to Decentralized Finance (DeFi)