Understanding AMMs: The Foundation You Need to Grasp Ekubo’s Edge
Everything you need to know about AMMs before diving into Ekubo’s design.
Introduction
Before diving into Ekubo, arguably the most optimized AMM live today, let’s take a step back. What even is an AMM? Why do LPs keep getting rekt? What’s impermanent loss? And how did we go from AMM v1 to v4?
This article is your high-level guide to how AMMs actually work, the missing context you need to truly understand what Ekubo improves, and why it matters.
If you’re serious about DeFi, understanding the mechanics isn’t optional. Let’s break it down:
What is an AMM?
Liquidity provision
Impermanent Loss
Slippage
V1-V2-V3-V4 style AMM
If you’re already comfortable with all this, feel free to skip ahead, the Ekubo deep dive is already here.
1. What is an AMM?
An Automated Market Maker (AMM) is a decentralized exchange (DEX) where users trade two tokens through liquidity pools instead of an order book. A smart contract quotes the price and settles the swap automatically, eliminating the need for an intermediary.
Most pools hold two assets, but some, like Curve Finance, support pools with more than two. That said, we’ll focus here on the most common setup: two-asset pools, as they represent the majority of AMM volume and usage.
AMMs use pricing curves that adjust with every swap, reflecting real-time shifts in liquidity and demand. The classic mechanism behind this adjustment (v2 style AMMs) is the constant product formula: x * y = k; where :
x = balance of asset A
y = balance of asset B
k = constant
When x rises, y must fall to keep k unchanged, creating a smooth price curve driven purely by pool balances.
Worked example
ETH–USDC pool at genesis
10 ETH (x)
1 000 USDC (y)
k = 10 000 (because 10 * 1 000 = 10 000)
A trader buys 1 ETH. New ETH balance = 9, so:
9 * y = 10 000
y = 10 000/9
y = 1 111.11 USDC
The trader pays 111.11 USDC, not 100 USDC, because k must stay 10 000 given the new balances. This means the swapper withdraws 1 ETH from the pool and deposits 111.11 USDC.
After the swap the pool holds
9 ETH
1 111.11 USDC
This is the math behind the curve, simple, predictable, and powerful.
As such, the more liquidity an AMM has, the more efficiently traders can execute their trades; because price impact per unit traded shrinks as pool depth increases.
This constant-product rule powers v1 and v2 AMMs. Later versions (v3 & v4) refine the curve by letting LPs choose price ranges or attach custom logic; you’ll meet those in the next section.
With an AMM, anyone can permissionlessly:
Trade
Provide liquidity to an existing market
Create a new market by launching and funding a new pool
However, since each pool operates in isolation, the same token pair can be priced differently across AMMs, or even across multiple pools within the same AMM.
This is where arbitrageurs and aggregators come into play. Arbitrageurs, whether manually or using bots, buy from the cheaper pool and sell into the pricier one, capturing the spread, rebalancing prices, and pocketing a profit in the process.
Aggregators, like 1inch, AVNU, or Kyberswap, automate this logic: they scan multiple pools in real time, split orders when necessary, and route trades through the most efficient paths.
That’s why most users don’t trade directly through a single AMM. Instead, they rely on aggregators, which abstract away the complexity, deliver the best execution, and help maintain price consistency across the ecosystem.
2. Liquidity provision
Where does the liquidity come from? Actually, any user can deposit assets and become a liquidity provider (LP).
In return, LPs earn the fees generated by those pools. For example, liquidity providers in the ETH–USDC pool receive all the fees from trades on that pair. In a UniV2-style AMM, that’s typically 0.3% of each swap.
LPs get paid because:
Pools cannot operate without their capital.
They shoulder smart-contract risk and impermanent-loss risk.
3. Impermanent Loss
When a LP adds funds to a pool, the liquidity is split between two assets. For example, if an LP provides liquidity to an ETH–USDC pool, they’ll deposit 50% in ETH and 50% in USDC.
Impermanent Loss (IL) is what happens when you'd have been better off just hodling: LPs earn fees, yes, but if prices move too far, the opportunity cost can outweigh the gains.
Example
Deposit 5 ETH + 10 000 USDC (ETH = 2 000 USDC) → position value = 20 000 USDC.
Pool totals 50 ETH + 100 000 USDC → LP share = 10%.
ETH doubles to 4 000 USDC. After arbitrage and following the constant product formula (x*y=k), pool ≈ 35.36 ETH + 141 440 USDC.
LP withdraws their 10% share → 3.54 ETH + 14 144 USDC ≈ 28 302 USDC.
Just HODLing the initial 5 ETH and 10 000 USDC would be 30 000 USDC → IL = 1 698 USDC.
That 1 698 USDC gap is the impermanent loss the LP incurred despite the pool’s fees.
Despite this risk, LPs still provide liquidity because they expect to earn more from fees than they lose to impermanent loss.
4. Slippage
Slippage refers to the difference between the expected price of a trade and the actual price at which it is executed. In an AMM, this occurs due to two main factors:
Structural factor: linked to the price curve mechanics, which automatically adjust the asset ratios in the pool based on the size of the order. In other words, the larger the trade vs the pool size, the worse the price. It’s math, and that’s why whales love deep pools and hate thin ones.
Timing factor: caused by the delay between when a user submits a trade and when it gets confirmed onchain. During this window, other transactions may affect the price. This can be worsened by MEV and front-running, where bots anticipate and exploit these price movements.
Note that there are two kinds of slippage:
Positive slippage → When the final price is better than expected. Rare, but possible.
Negative slippage → When the final price is worse than expected; the most common case.
How to reduce slippage?
Use DEX aggregators (like AVNU on Starknet or 1inch on Ethereum) to route your trade to the best available price.
Set a low slippage tolerance in the AMM interface.
Prefer deep pools or optimized AMMs (e.g. Ekuboooo).
Alright, at this point you've got all the basics down. Now let's quickly dive into the different AMM designs (v1 to v4) and see how each version improves upon the last.
5. V1-V2-V3-V4 style AMM
Uniswap launched the first constant-product AMM in 2018 and has iterated three times since, while Ekubo brought a v4-style design to Starknet a year ahead of Uniswap’s own release.
v1 (2018) introduced permissionless liquidity pools that always routed through ETH. Anyone could list a token by seeding an equal value of ETH and the token, and LPs earned a flat 0.30% fee. The downside? Trades always routed through ETH (A → ETH → B), adding extra gas and slippage.
v2 (2020) removed the ETH hop by allowing any ERC-20 to pair directly with any other. That single change slashed gas costs and price impact.
For passive LPs, the “set-and-forget” model of this version is still the simplest option to provide liquidity.
v3 (2021) introduced concentrated liquidity. Instead of providing funds across 0→∞ range, LPs choose a price range and earn far more fees when the market trades inside it, up to 4 000× better capital efficiency. For example, in a USDC/USDT pool, the price stays between $0.995 and $1.005 around 99% of the time. So there’s no point in providing liquidity across a price range from 0 to infinity.
Three fee tiers (0.05%, 0.30%, 1%) let LPs match volatility, and each position is an NFT. The trade-off is that LPs must watch their ranges; once out-of-range they earn nothing.
Note that choosing a price range with concentrated liquidity is similar to placing limit orders on the market.
Example: An LP provides $3,000 in ETH/USDC within the range of $2400 to $2,800, with ETH as the base token and USDC as the quote token (quote token means the numerator of the prices).
If ETH drops below $2,400, the position becomes 100% ETH.
If ETH rises above $2,800, the position becomes 100% USDC.
As long as the price remains within the defined range, the LP earns swap fees.
In short, v3 = More yield when you're in range. Zero when you’re not. That’s the tradeoff of active LPing.
v4 (2024-25) collapses every pool into one “singleton” contract and adds hooks, small plug-ins that run custom logic before or after a swap.
Singleton architecture cuts pool-creation gas by roughly 99% and swap gas by about half. How? All pools are grouped within a single smart contract, unlike previous versions where each pool had its own separate contract. Thanks to this Singleton architecture, the shared pool logic no longer needs to be redeployed every time a new pool is created. The result? Lower costs, greater efficiency, and better access to liquidity.
Hooks unlock dynamic fees, auto-compounding, lending idle liquidity, MEV-sharing, DCA orders, and much more, on top of AMM pools. In V3, only LP management and fee tiers were configurable. With V4, LPs and devs have much more flexibility to tailor pools to their specific needs.
Worth noting: Ekubo was the first protocol to deploy the v4 design. Its founder, Moody, wrote much of Uniswap v3 and later led the v4 spec, before launching Ekubo and continuing to improve on that very design.
Conclusion
AMMs can be seen as a liquidity layer, empowering anyone to permissionlessly create markets, provide liquidity, and trade. With the v4 design, this scope expands dramatically: AMMs become the foundational layer for any DeFi primitive built on top. And Ekubo is building the ultimate environment for that.
Now that you’ve got the key concepts, AMMs, slippage, impermanent loss, concentrated liquidity, and the evolution of designs, you’re ready to dive into the AMM endgame: Ekubo.
None of this content is financial advice. Stay SAFU and always do your own research.
If you liked this article and don’t want to miss the Ekubo article, feel free to register, it’s free!