Lesson 4
What is an Automated Market Maker? (AMM)
AMM’s speed up transactions through their usage of the constant function formula and readily-available currency within liquidity pools.
What do Automated Market Makers (AMMs) do?
Automated market makers (AMMs for short) are systems that let you exchange assets without needing middle men. Each AMM holds a pool of two assets and enables users to swap between them at an exchange rate set by a formula. They’re the most common way to implement a decentralized exchange to allow everyday traders to exchange assets of various sorts for fair rates. The main alternative to AMMs are Central Limit Order Books (CLOBs) which we’ll talk about more in the next section. (Fun fact, the XRPL currently uses a CLOB, and has recently approved adding AMM!)
How do AMMs work?
At its heart, an AMM works by pooling two tokens together in a pair of liquidity pools. Once enough currency is pooled together, the AMM automatically picks a fair exchange rate between the different currencies. AMM’s figure out the fair exchange rate with a powerful formula called a “constant function formula” which tries to model the price that a traditional market would discover on its own. Liquidity pools are handy for two reasons. First, because the prices are chosen automatically, everyday token holders can contribute without having to know what a “fair” exchange rate is. They’re also useful because they can provide constant liquidity as the pool is always willing to trade. Think of it like the exchange rate that is always available at your bank.
Automated Pricing and Continuous Trading
As people trade within the pool, the AMM’s algorithm adjusts the prices of the assets to keep everything in balance. If one asset is in high demand, its price goes up, and the other asset’s price drops. This algorithm uses the constant function formula to keep things in balance.
- Sets a price that follows supply and demand for the various tokens. If there’s a large supply of a token, exchanging for it will be easier. Conversely, with small amounts of a token in the liquidity pool, it will cost a lot to trade for the remaining tokens.
- On the demand side, trading more of a token at once is more expensive. You can think of the price updating automatically as you buy more and more of the token, reducing the supply as you go.
How does the XRPL order book differ from a typical AMM?
A traditional order book system functions differently than an AMM, which relies on math formulas to leverage the liquidity pools in completing a trade. In the Order Book, trades occur when buy and sell orders match, allowing for more specific pricing, but can struggle to discover a fair market price if there are few traders. Trades on the Order Book happen when a buyer’s bid matches a seller’s ask while an AMM executes trades instantly based on the current formula-based prices.
In the next lesson, we’ll dig into the order book on the XRPL and explain how it works.