What Is an AMM? – The Engine That Powers DeFi Swaps

What Is an AMM? – The Engine That Powers DeFi Swaps

Have you ever traded your Pokémon cards with a friend? You might say, "I'll give you 1 Pikachu for 3 Charmanders." Now imagine if a robot helped you do that — not just with cards, but with cryptocurrencies like ETH and USDT — and it could do it 24/7 with anyone in the world.

That robot is called an AMM, or Automated Market Maker — one of the most powerful engines that makes DeFi (Decentralized Finance) work without banks or brokers.

Let’s break it down super simply



The Magic Jar: Liquidity Pool

Imagine a big jar filled with two types of coins: ETH and USDT. This jar is open to everyone. If you want to swap ETH for USDT (or the other way around), you just take out what you want and drop in what you’re trading.

This jar is called a Liquidity Pool. People (called Liquidity Providers, or LPs) pour their coins into the jar. In return, they get a small reward — like a tip — every time someone uses the jar to trade.

Example:

  • If Alice adds 10 ETH and 30,000 USDT into a jar, she becomes a Liquidity Provider.

  • Bob comes along and wants 1 ETH. The jar gives him 1 ETH, and in return, Bob puts in around 3,030 USDT.

  • Why 3,030 and not 3,000? We'll explain in a moment 


The Robot’s Rule: x * y = k

This is the rule the AMM robot always follows.

  • x = how much ETH is in the jar

  • y = how much USDT is in the jar

  • k = always stays the same (it’s like a magic number)

So, if someone takes ETH out, the robot makes sure the balance is kept by adjusting the amount of USDT. This is why the price changes automatically — like supply and demand, but instant and math-powered.

Formula in Action:
If the jar starts with:

  • 100 ETH and 300,000 USDT
    Then:
    x * y = 100 * 300,000 = 30,000,000

Now if someone buys 1 ETH, there are only 99 ETH left. To keep k = 30 million, the robot calculates the new y:


99 * y = 30,000,000 → y = 303,030

So, the buyer must put 3,030 USDT into the jar.

The more you buy, the more expensive it gets. That’s why this system avoids running out too quickly!


Slippage: The Price Shock

Let’s say you’re buying a lot at once — like 10 ETH. The jar must give out a lot of ETH and ask for even more USDT. That pushes the price up a lot.

This price jump is called slippage — and it can make large trades more expensive than expected.


Risks for Jar Owners: Impermanent Loss

Liquidity Providers (LPs) take on a special kind of risk.

Imagine the price of ETH rises fast outside the jar. Traders rush in to take ETH from the jar and add more USDT. When LPs withdraw their money, they may end up with more USDT and less ETH, missing out on the ETH price rally. That’s called Impermanent Loss.

If prices go back to normal, the loss disappears. But if not, it becomes permanent.


Arbitrage: The Clean-Up Crew

Sometimes, the jar’s price is different from other exchanges. Smart traders (called arbitrageurs) step in to buy low in one place and sell high in another. This helps bring prices back in line.

They make a little profit, and the whole system stays fair!


Different Flavors of AMMs

Not all jars are built the same. Some AMMs are designed for special types of tokens:

  • x + y = k: Used for stablecoins like USDC and USDT (e.g. Curve Finance). Very small slippage!

  • Balancer: Handles 3 or more tokens with different weights.

  • Uniswap v3: Lets LPs choose a price range to provide liquidity, so their money is used more efficiently.


Why AMMs Are a Big Deal

No middlemen – You don’t need banks or brokers.
24/7 open – No closing hours.
Everyone can participate – Anyone can trade or provide liquidity.
Core of DeFi – Yield farming, staking, swapping — all powered by AMMs.


Final Thought

AMMs are like self-driving vending machines for crypto. They don’t sleep. They don’t lie. They just follow the math. Thanks to AMMs, people all over the world can trade safely and fairly without needing to trust anyone.

And that’s what makes DeFi magical.