Subscribe to over_akk
Subscribe to over_akk

Web3 Full-Stack Development Field Guide: ERC-721 NFT Issuance System
Building a full-stack DApp from scratch: Contracts, Frontend Interface, and Backend Event Listening.

From Java Architect to Web3 Novice: Hardhat Development Bootcamp
A transition guide designed for Java architects, mapping Backend concepts to Web3 reality using Hardhat.

Web3 Full-Stack Development Field Guide: ERC-721 NFT Issuance System
Building a full-stack DApp from scratch: Contracts, Frontend Interface, and Backend Event Listening.

From Java Architect to Web3 Novice: Hardhat Development Bootcamp
A transition guide designed for Java architects, mapping Backend concepts to Web3 reality using Hardhat.
<100 subscribers
<100 subscribers


Goals:
To journey from "Centralized Order Book Exchanges" all the way to "AMM + Curve Stablecoin Pools," and understand:
👉 Why do we need AMMs?
👉 Who are LPs?
👉 Where does Slippage come from?
👉 Why does Impermanent Loss exist?
👉 Why does Curve have low slippage and low impermanent loss?
👉 Why don't all AMMs use a "low slippage curve"?

Examples: Nasdaq, Binance, Coinbase
Uses an Order Book:
Users post "Buy Orders / Sell Orders."
A matching engine pairs them on a centralized server.
Funds are Custodial: Held by the exchange.
Pros:
Extremely fast matching speed.
No gas fees for cancelling orders.
High liquidity.
Cons:

Not Censorship-Resistant: Requires KYC; accounts can be frozen.
Single Point of Failure & Custodial Risk: Hacks, downtime, or the exchange running away with funds ("rug pulls").
Opaque Information & Potential Front-running.
Matching and settlement are moved on-chain (Smart Contracts).
Users must pay Gas to place, cancel, or take orders.
Pros:
Censorship-resistant.
Non-custodial.
Cons:
Slow: Limited by blockchain block times.
Expensive: Every operation requires Gas.
Poor Liquidity: Lack of sufficient market makers.
Vulnerable to On-chain Front-running.
Conclusion:
Moving the Order Book model directly on-chain results in a poor user experience. We need a liquidity model that does not rely on pending orders → AMM.

AMM (Automated Market Maker) =
An automated market-making system that uses mathematical formulas rather than an order book to quote prices and provide liquidity.
The Classic Model:

x = Quantity of Token X in the pool
y = Quantity of Token Y in the pool
x = Constant (Invariant)
For every transaction:
x and y change.
Such that x*y remains equal to k.
Price is determined by the internal state of the pool:


LP = Liquidity Provider
They deposit two assets into the pool according to a specific ratio (usually 50:50 value).
Example: 1 ETH + 2000 USDC.
In return:
They receive LP Tokens (representing their share/equity in the pool).
They earn trading fee revenue based on the pool's volume.
Without LPs, there is no pool; without a pool, you cannot trade using an AMM.


Slippage = The deviation between the actual average execution price and the price you saw before placing the order.
Reason:
When you place an order, the AMM doesn't just quote a price once; the price updates continuously throughout the execution of your trade.
The more you buy, the more you push the price up yourself during the process → The average execution price ends up higher than the starting point.
Pool State:

You use 10 Y to buy X:

You originally saw a "price of roughly 1:1," but the actual execution:
10 Y swapped for 9.091 X
Effective Price:

More expensive than the starting 1:1 → Slippage occurred.

Slippage is not the same as the Trading Fee.
It comes from the AMM formula:
By moving the price curve, you are essentially "consuming liquidity."
Larger trade size → Curve moves more → Higher slippage.
Shallower pool (low liquidity) → Higher slippage for the same trade size.

For the Trader:
High slippage → High cost → Yes, it's a disadvantage.
But for the Mechanism:
Slippage = A safety valve protecting the pool from being drained instantly.
If the curve were completely flat (ultra-low slippage):
Arbitrarily large trades would barely change the price.
The pool could easily be drained of "cheap assets" by arbitrageurs.
LPs would be wiped out quickly.
The higher the volatility of the asset, the steeper the curve must be, and the higher the slippage must be.
Therefore:
Stable Assets (Stablecoins): Curve can be flatter.
Volatile Assets (ETH / MEME): Curve must be steeper to protect LPs.

Taking Uniswap V2 as an example:
Every Swap is charged a 0.3% Fee.
This 0.3%:
Is added to the pool, increasing the total reserves.
Is distributed based on LP share holdings (Pool gets larger → Each LP token represents more assets).
LP revenue isn't paid out like "daily interest"; rather:
As trading volume increases, the pool as a whole gets "fatter."

Slippage: Caused by the mathematical curve.
Fee: A fixed percentage charged by the protocol.
Your Actual Cost = Slippage Loss + Trading Fee
Incentivize LPs to provide liquidity.
Offset Impermanent Loss for LPs.
Raise the cost of arbitrage, preventing excessive exploitation of the pool.

Impermanent Loss = The difference in asset value between "being an LP" and "simply holding the two assets in a wallet."
It is not an "absolute loss," but rather:
"You could have made more profit, but because you were an LP, your gains were dampened."

Initial State:
ETH Price = 1000
You provide LP:
1 ETH + 1000 USDC → Total Value 2000
Scenario: ETH rises to 2000.
If you HODL (don't LP):
Assets = 1 ETH (=2000) + 1000 USDC = 3000
If you LP (Pool rebalances):
The pool constantly "Sells ETH / Buys USDC" as price rises.
You might withdraw:
0.707 ETH + 1414 USDC 2828
Difference:
3000 - 2828 = 172 → Impermanent Loss.
If the price returns from 2000 back to 1000:
The pool ratio returns to the initial state.
You withdraw exactly what you put in.
The loss "disappears."
However:
If you withdraw your liquidity while the price is diverged → The loss becomes Permanent (Realized).
High Volatility Assets (ETH, MEME): High IL.
Stablecoin Swaps (USDC/USDT/DAI): Very low IL. → This leads us to: Curve's Stablecoin AMM.

Stablecoins are expected to be 1:1.
User psychological expectation is high:
Swapping 10,000 USDT for 9,900 USDC is painful.
Uniswap's curve is too convex ("curved"), causing:
Significant slippage even on moderately sized orders.
Price is anchored near $1.
Low volatility.
Users don't care about "speculation," only "efficient exchange."
This means:
We don't need a curve as steep as the one used for ETH.

Curve does not use:
Pure Constant Product ( )
Pure Constant Sum ()
Instead, it uses:
A Hybrid Curve between the two.
It becomes very flat near 1:1 (low slippage) and acts like a standard product curve (protective) in extreme cases.
Graphical Intuition:

Constant Sum AMM
(x + y = constant)
Stablecoin Trading
Low Slippage
Constant Product AMM
(x * y = k)
Standard Token Trading
Higher Slippage
Suitable for Stable Pairs
e.g., USDC/USDT, DAI/USDC
Suitable for Volatile Assets
e.g., ETH/USDC
In the stable range:
Curve is nearly flat → Minimal slippage for large trades.
When assets deviate significantly:
Curve becomes steep → Prevents the pool from being drained by arbitrage.
Because:
Asset volatility is naturally low (USDT / USDC / DAI).
Curve's design is very flat near 1:1, so large swaps don't cause massive price deviation.
The price change endured by LPs is limited → IL is negligible.
Therefore, risk-averse LPs love:
Stablecoin Pools (e.g., 3pool).
Soft-pegged Asset Pools (e.g., stETH/ETH).

Your question is spot on. The core logic is:
Low slippage is not a free lunch; it is "bought" with capital efficiency and model risk.
The flatter the curve:
The weaker the AMM's ability to resist price deviation.
The easier it is for arbitrageurs to drain one side of the assets with large capital.
For high-volatility assets, if the curve is too flat:
LPs will be exploited faster and more heavily.
The pool becomes unsafe.
Therefore:
High Volatility Assets (ETH/USDC): Need a steeper curve (Uniswap).
Low Volatility Assets (Stablecoins/Pegged): Can use a flatter curve (Curve).
Different asset types → Require different AMM curves → This is the "AMM Design Space."
Goals:
To journey from "Centralized Order Book Exchanges" all the way to "AMM + Curve Stablecoin Pools," and understand:
👉 Why do we need AMMs?
👉 Who are LPs?
👉 Where does Slippage come from?
👉 Why does Impermanent Loss exist?
👉 Why does Curve have low slippage and low impermanent loss?
👉 Why don't all AMMs use a "low slippage curve"?

Examples: Nasdaq, Binance, Coinbase
Uses an Order Book:
Users post "Buy Orders / Sell Orders."
A matching engine pairs them on a centralized server.
Funds are Custodial: Held by the exchange.
Pros:
Extremely fast matching speed.
No gas fees for cancelling orders.
High liquidity.
Cons:

Not Censorship-Resistant: Requires KYC; accounts can be frozen.
Single Point of Failure & Custodial Risk: Hacks, downtime, or the exchange running away with funds ("rug pulls").
Opaque Information & Potential Front-running.
Matching and settlement are moved on-chain (Smart Contracts).
Users must pay Gas to place, cancel, or take orders.
Pros:
Censorship-resistant.
Non-custodial.
Cons:
Slow: Limited by blockchain block times.
Expensive: Every operation requires Gas.
Poor Liquidity: Lack of sufficient market makers.
Vulnerable to On-chain Front-running.
Conclusion:
Moving the Order Book model directly on-chain results in a poor user experience. We need a liquidity model that does not rely on pending orders → AMM.

AMM (Automated Market Maker) =
An automated market-making system that uses mathematical formulas rather than an order book to quote prices and provide liquidity.
The Classic Model:

x = Quantity of Token X in the pool
y = Quantity of Token Y in the pool
x = Constant (Invariant)
For every transaction:
x and y change.
Such that x*y remains equal to k.
Price is determined by the internal state of the pool:


LP = Liquidity Provider
They deposit two assets into the pool according to a specific ratio (usually 50:50 value).
Example: 1 ETH + 2000 USDC.
In return:
They receive LP Tokens (representing their share/equity in the pool).
They earn trading fee revenue based on the pool's volume.
Without LPs, there is no pool; without a pool, you cannot trade using an AMM.


Slippage = The deviation between the actual average execution price and the price you saw before placing the order.
Reason:
When you place an order, the AMM doesn't just quote a price once; the price updates continuously throughout the execution of your trade.
The more you buy, the more you push the price up yourself during the process → The average execution price ends up higher than the starting point.
Pool State:

You use 10 Y to buy X:

You originally saw a "price of roughly 1:1," but the actual execution:
10 Y swapped for 9.091 X
Effective Price:

More expensive than the starting 1:1 → Slippage occurred.

Slippage is not the same as the Trading Fee.
It comes from the AMM formula:
By moving the price curve, you are essentially "consuming liquidity."
Larger trade size → Curve moves more → Higher slippage.
Shallower pool (low liquidity) → Higher slippage for the same trade size.

For the Trader:
High slippage → High cost → Yes, it's a disadvantage.
But for the Mechanism:
Slippage = A safety valve protecting the pool from being drained instantly.
If the curve were completely flat (ultra-low slippage):
Arbitrarily large trades would barely change the price.
The pool could easily be drained of "cheap assets" by arbitrageurs.
LPs would be wiped out quickly.
The higher the volatility of the asset, the steeper the curve must be, and the higher the slippage must be.
Therefore:
Stable Assets (Stablecoins): Curve can be flatter.
Volatile Assets (ETH / MEME): Curve must be steeper to protect LPs.

Taking Uniswap V2 as an example:
Every Swap is charged a 0.3% Fee.
This 0.3%:
Is added to the pool, increasing the total reserves.
Is distributed based on LP share holdings (Pool gets larger → Each LP token represents more assets).
LP revenue isn't paid out like "daily interest"; rather:
As trading volume increases, the pool as a whole gets "fatter."

Slippage: Caused by the mathematical curve.
Fee: A fixed percentage charged by the protocol.
Your Actual Cost = Slippage Loss + Trading Fee
Incentivize LPs to provide liquidity.
Offset Impermanent Loss for LPs.
Raise the cost of arbitrage, preventing excessive exploitation of the pool.

Impermanent Loss = The difference in asset value between "being an LP" and "simply holding the two assets in a wallet."
It is not an "absolute loss," but rather:
"You could have made more profit, but because you were an LP, your gains were dampened."

Initial State:
ETH Price = 1000
You provide LP:
1 ETH + 1000 USDC → Total Value 2000
Scenario: ETH rises to 2000.
If you HODL (don't LP):
Assets = 1 ETH (=2000) + 1000 USDC = 3000
If you LP (Pool rebalances):
The pool constantly "Sells ETH / Buys USDC" as price rises.
You might withdraw:
0.707 ETH + 1414 USDC 2828
Difference:
3000 - 2828 = 172 → Impermanent Loss.
If the price returns from 2000 back to 1000:
The pool ratio returns to the initial state.
You withdraw exactly what you put in.
The loss "disappears."
However:
If you withdraw your liquidity while the price is diverged → The loss becomes Permanent (Realized).
High Volatility Assets (ETH, MEME): High IL.
Stablecoin Swaps (USDC/USDT/DAI): Very low IL. → This leads us to: Curve's Stablecoin AMM.

Stablecoins are expected to be 1:1.
User psychological expectation is high:
Swapping 10,000 USDT for 9,900 USDC is painful.
Uniswap's curve is too convex ("curved"), causing:
Significant slippage even on moderately sized orders.
Price is anchored near $1.
Low volatility.
Users don't care about "speculation," only "efficient exchange."
This means:
We don't need a curve as steep as the one used for ETH.

Curve does not use:
Pure Constant Product ( )
Pure Constant Sum ()
Instead, it uses:
A Hybrid Curve between the two.
It becomes very flat near 1:1 (low slippage) and acts like a standard product curve (protective) in extreme cases.
Graphical Intuition:

Constant Sum AMM
(x + y = constant)
Stablecoin Trading
Low Slippage
Constant Product AMM
(x * y = k)
Standard Token Trading
Higher Slippage
Suitable for Stable Pairs
e.g., USDC/USDT, DAI/USDC
Suitable for Volatile Assets
e.g., ETH/USDC
In the stable range:
Curve is nearly flat → Minimal slippage for large trades.
When assets deviate significantly:
Curve becomes steep → Prevents the pool from being drained by arbitrage.
Because:
Asset volatility is naturally low (USDT / USDC / DAI).
Curve's design is very flat near 1:1, so large swaps don't cause massive price deviation.
The price change endured by LPs is limited → IL is negligible.
Therefore, risk-averse LPs love:
Stablecoin Pools (e.g., 3pool).
Soft-pegged Asset Pools (e.g., stETH/ETH).

Your question is spot on. The core logic is:
Low slippage is not a free lunch; it is "bought" with capital efficiency and model risk.
The flatter the curve:
The weaker the AMM's ability to resist price deviation.
The easier it is for arbitrageurs to drain one side of the assets with large capital.
For high-volatility assets, if the curve is too flat:
LPs will be exploited faster and more heavily.
The pool becomes unsafe.
Therefore:
High Volatility Assets (ETH/USDC): Need a steeper curve (Uniswap).
Low Volatility Assets (Stablecoins/Pegged): Can use a flatter curve (Curve).
Different asset types → Require different AMM curves → This is the "AMM Design Space."
Share Dialog
Share Dialog
No activity yet