ELI5: Automated Market Makers or AMMs

Matthew Taylor
7 min readAug 31, 2023

Welcome to a series of posts where I attempt to ELI5 (Explain Like I’m 5) some of the concepts that are central to Decentralized Finance (DeFi) and some that are specific to Maverick Protocol. I hope that these explanations will be of some help to users who are new to DeFi.

These posts are provided solely for educational purposes and should not be understood to constitute financial advice.

I once watched a great software tutorial on YouTube,* in which the presenter began with one central idea:

“Computers are dumb.”

This is a really useful idea to keep in mind as we proceed with this series. His point was that while computers are, in many ways, very clever–that is, they are capable of doing all sorts of things very quickly that would be taxing to a human brain–they are fundamentally dumb, because they can only do what they are told to do.

Computers depend on instructions from humans–that is, code and input–to tell them what to do, when to do it, how to do it, and so forth. They are not (currently) capable of taking initiative. They can’t foresee problems. They aren’t even good at knowing when they’ve made a mistake. They just do what they’re told, when they’re told to do it.

So yes, computers are dumb.

In this post, I’m going to talk about Automated Market Makers. This is a bit of a mouthful, so everyone in DeFi agrees to abbreviate them to AMM or AMMs (when we’re talking about more than one).

AMMs are essentially software that runs on computers (or, more precisely, on the blockchain) and so–although they can do very clever things–AMMs are also dumb.

Remember this: AMMs are dumb.

So AMMs are dumb, and they’re a kind of software. What does this software do? Well, like a lot of things in DeFi, they replace something from the world of traditional finance (if you want to sound cool in crypto, you should refer to this as “TradFi”).

In TradFi (see? I sound cool, right?), there are people or institutions who play the role of “market maker.” What this means is that they provide a bunch of stocks at a range of price points, in order to make it possible for people to buy those stocks. They also agree to buy a bunch of stocks at a range of price points, in order to make it possible for people to sell those stocks.

In other words, they make markets.

Of course, market makers have a lot of institutional power. They exert control in markets by establishing prices for buying and selling, and make money by selling high and buying low (this is what TradFi folks call “the spread”).

Traditional market-making is very centralized and often not very transparent. These are things we don’t like in DeFi.

Using AMMs, DeFi replaces these people or institutions with a smart contract–that is, a piece of software that runs on the blockchain. Unlike people or institutions, an AMM doesn’t have any bias or financial interest in how it sets prices. It just follows the rules it has been given. Because it’s dumb.

Kyle Reese would have been great at DeFi.

AMMs are the backbone of DeFi. By replacing people and institutions with computer code, AMMs let us make markets that are decentralized, transparent, and permissionless. Everyone can see the rules the AMM is using to set the prices in its market, and the AMM is incapable of changing those rules to make itself a profit.

The AMM doesn’t care who you are. You don’t need an institutional account or a credit history to interact with an AMM. All you need is a cryptocurrency wallet, gas tokens, and the funds necessary to fulfill the trade you want to make with it.

All the AMM cares about is the rules it was given when it was coded and deployed to the blockchain.

We’ll go into more detail on the rules AMMs use to make their markets in future posts, but for now we can start with a very simple example.

Generally, AMMs facilitate swaps between pairs of cryptocurrency tokens. The AMM contracts holds reserves of these tokens and users come to make swaps, giving the AMM one token in exchange for the other. Most commonly, the AMM organizes the tokens into pairs in what we call “pools.” So, for example, an AMM might have a pool of ETH tokens and USDC tokens, which it uses to facilitate swaps between those two tokens.

Theoretically, an AMM can have an unlimited number of pools for every token pair (and even multiple pools per pair), but for this example let’s imagine an AMM which has a single pool for one token pair. We’ll call those tokens ABC and XYZ.

Perhaps the simplest rule we could give this AMM would be to allow users to make swaps at a 1:1 value. That is, to always exchange 1 ABC for 1 XYZ and vice versa.** That means:

  • If a user gives the AMM 1 ABC, the AMM should send back 1 XYZ
  • If a user gives the AMM 1 XYZ, the AMM should send back 1 ABC
  • If a user gives the AMM 2 ABC, the AMM should send back 2 XYZ
  • And so forth

With this one basic rule, the AMM has everything it needs to know how to handle swaps for this token pair.

A simple AMM, ready to make swaps happen between ABC and XYZ tokens. It is dumb.

Now, this makes perfect sense so long as 1 ABC = 1 XYZ. But if the price of these tokens in the larger world is different, or if it changes, this means that the AMM is buying/selling at a bad price. And it won’t know this. Because it’s dumb.

Say, for example, that the broader market decides 1 ABC is actually worth 2 XYZ. That means that anywhere else I go, I will be able to swap 1 ABC for 2 XYZ. But our dumb AMM is still selling 1 ABC for 1 XYZ. That means Alice can come to the AMM, swap 10 XYZ for 10 ABC, then go to another market and sell those 10 ABC for 20 XYZ, capturing a tidy profit.

This is why AMMs need more complicated rules, which we’ll get to in another post. But the core ideas you should take away from this post are:

  • AMMs are computer programs that run on the blockchain
  • AMMs facilitate token swaps using a predefined set of rules
  • These rules let AMMs make markets that are decentralized, transparent, and permissionless
  • These rules also mean that AMMs are dumb

If you’ve understood all this, then you’re already leaped over what I think of as the first basic misunderstanding in DeFi.

This is you. You’re doing great!

A basic question I see a lot of first time Defi users ask is:

Why is the AMM giving me the wrong price?

I assume a lot of these users are coming from centralized exchanges (again, to be cool we abbreviate that as “CEX” — but don’t say that out loud), where token prices are centrally controlled in order to follow the market (usually while maintaining a spread for the CEX).

This means if they see 1 ETH is trading for $1.7k, they can usually expect to be able to buy or sell 1 ETH for $1.7k. Therefore, they’re puzzled when they come to an AMM and the price isn’t $1.7k.

They don’t understand AMMs. More specifically, they expect AMMs to be smarter than they are (but you don’t, because you know that AMMs are dumb).

Generally, AMMs do not pay attention to the market price. AMMs don’t know, let alone care, if their price is “wrong.” They just offer token swaps based on whatever rules they were programmed with.

I think that’s enough for this post, but I’ll close by saying that the relative dumbness of AMMs is what a lot of people like and where a lot of trading action in DeFi comes from. Since AMMs are dumb, their prices are often left behind when the market moves, giving traders an opportunity to take advantage of the AMMs and make a little profit. The fancy word for this is “arbitrage,” but that’s a subject for another day!

* — I can’t find the original video, but it was a tutorial for GameSalad.

** — There’s actually a name for this kind of AMM, which is “constant sum.” IGNORE WHAT FOLLOWS IF YOU HATE MATH. The AMM is given a mathematical rule to follow: x + y = k. In this formula, x is the amount of ABC and y is the amount of XYZ in the AMM. These amounts sum to a number (k). The rule the AMM has to follow is to keep k constant. The only way to do this is by ensuring that x + y always sums to the same amount (k). That’s enough to instruct the AMM to balance all token inputs and outputs 1:1. If a user adds 1 ABC then x + y will sum to k +1, and the only way to equalize this is to send 1 XYZ back to the user (thus returning to a state where x + y = k).

--

--