Section II: Decentralized Exchange Architecture
Decentralized exchanges solve a fundamental problem: how can users trade assets without trusting a centralized intermediary to hold their funds? In doing so, they establish on-chain price discovery and liquidity that other protocols can build upon.
Uniswap: The AMM Revolution
Uniswap pioneered a radically different approach to trading that transformed how we think about market making. Instead of maintaining complex order books that require constant updates and millisecond matching, Uniswap uses an Automated Market Maker (AMM) that quotes prices from pool balances and settles trades atomically.
This innovation arose from Ethereum's specific constraints. As discussed in Chapter II, Ethereum has low throughput, variable fees, and roughly twelve-second blocks. A central limit order book requires constant posting and canceling of orders with millisecond matching, making it too transaction-intensive to be feasible and expensive to run fully on-chain. AMMs solve this by replacing the matching engine with a pricing curve that requires only one transaction to update balances and settle immediately.
The evolution of Uniswap's pricing reveals how DeFi protocols iterate toward better capital utilization. Uniswap v1 used pools pairing every token with ETH, following the constant product invariant where x × y = k (a fixed value). Any trade between tokens had to route through ETH, requiring two separate swaps and incurring two sets of fees.
Price Impact and Slippage: The Core Mechanics
Why does buying tokens move the price? This seemingly simple question reveals the core mechanics of AMMs. Consider a constant product pool with token reserves and a fixed invariant. When a trader buys token X with token Y, they add their input amount to the Y reserves and remove output tokens from the X reserves. The constraint that their product must remain constant means larger trades have proportionally larger price impact.
Two requirements drive this dynamic simultaneously. The pool can never run out of either token, and it must always be able to quote a price for any trade, no matter the size. These constraints working together explain why prices become exponentially steep as reserves shrink: a pool nearly depleted of token X still has to accept your trade, but must price it high enough to mathematically prevent the supply from ever hitting zero.
To understand this intuitively, imagine a special marketplace with two buckets of red marbles and blue marbles. There's a magical rule that mirrors the AMM's constant product formula: the number of red marbles multiplied by the number of blue marbles must always equal the same number (like 10,000).
When someone wants to buy red marbles, they have to add blue marbles to the blue bucket. But here's the catch: they can only take out enough red marbles so that the multiplication rule stays true.
If the buckets start with 100 red marbles and 100 blue marbles (100 × 100 = 10,000), and someone wants to buy 20 red marbles. They need add 25 blue marbles to the bucket (making it 125 blue and leaving 80 red). This works because 125 × 80 ≈ 10,000.
The more red marbles someone wants, the exponentially more blue marbles they need to add. The bucket becomes "stingier" with each marble taken, the first marble is cheap, but the 50th costs exponentially more.
If someone wants to buy 50 red marbles. They need add 100 blue marbles to the bucket (making it 200 blue and leaving 50 red). The math still works because 200 × 50 ≈ 10,000.
The deeper the buckets (more marbles), the less each individual trade affects the overall balance. Shallow buckets create large price swings; deep buckets maintain price stability.
In DeFi terms: these buckets are liquidity pools, the marbles are token reserves, and the stinginess is slippage (the price impact that grows with trade size). Unlike traditional markets where there may not be enough sellers, AMM pools always have liquidity available at a calculable price.
For small trades, slippage approximates the trading fee. But for larger trades, the curve's shape adds additional price impact that grows with trade size relative to pool depth. Small trades get better execution while large trades pay for their market impact, a natural market mechanism emerging from the mathematical curve.
This predictability is what makes AMMs powerful. Unlike order book markets where large trades can walk through multiple price levels unpredictably, AMM slippage follows mathematical curves. Traders can calculate their expected execution price before submitting transactions, and arbitrageurs can immediately correct any price deviations between pools.
Uniswap's Evolution: v2, v3, and v4
With the core mechanics of price impact understood, we can examine how Uniswap evolved to improve capital efficiency while maintaining these fundamental dynamics.
Uniswap v2 generalized this approach, allowing any ERC-20 pair without forced ETH routing. The router and SDK enable multi-hop routing across pools through off-chain pathfinding, while the contracts execute the supplied path. The protocol also added TWAP (Time-Weighted Average Price) oracles for price tracking and flash swaps for advanced use cases. The core pricing mechanism remained the constant product formula, but the removal of ETH routing significantly improved liquidity utilization.
Uniswap v3 introduced concentrated liquidity, fundamentally changing how AMMs work. Instead of spreading liquidity across all possible prices, liquidity providers can choose specific price ranges called "ticks." Within each active range, the pricing behaves similarly to v2's constant product formula but with higher effective liquidity since capital is concentrated. This reduces slippage for trades within active ranges while maintaining the AMM's simplicity. In practice, this design is especially powerful for highly correlated assets such as stablecoin pairs or liquid staking token pools like stETH/ETH, where most trading happens near a known fair value and LPs are comfortable concentrating around it. It also lets LPs shape how their orders execute over time: by placing liquidity only above or below the current price, they can effectively set up gradual buys or sells (range orders), accumulating or offloading a position while minimizing immediate price impact.
Uniswap v4, which launched in early 2025, represents the next evolution with a single "singleton" contract holding all pools for gas savings. The major innovation is "hooks" that allow programmable AMM behavior. These hooks can implement dynamic fees, time-weighted average market makers, MEV-aware flows, limit orders, and more. The default pools can still use constant product curves, but the architecture enables entirely new pricing behaviors.
Curve Finance: Math for Stable Trading
While Uniswap succeeded at enabling trades between volatile assets like ETH and various ERC-20 tokens, an inefficiency emerged when users traded stablecoins on the platform. Stablecoins like USDC and USDT should theoretically trade at nearly identical values, but Uniswap v2's constant product formula spread liquidity across price ranges that rarely occur in stablecoin trading, causing higher slippage for assets that barely fluctuate relative to each other.
The StableSwap Approach
Curve Finance developed StableSwap, a hybrid mathematical approach that blends two pricing curves to address this inefficiency. Near the peg around the 1:1 ratio, StableSwap behaves like a constant sum formula creating minimal slippage, while gradually transitioning toward constant product behavior as prices drift from the peg to prevent pool failure.
The key innovation was Curve's amplification factor (A), which controls how flat the pricing curve remains near the 1:1 peg. Higher amplification creates lower slippage for normal trades near $1.00 while maintaining steep protective walls for extreme scenarios. This allowed Curve to charge lower fees (0.01-0.04% versus Uniswap's 0.3%) while providing superior execution for stablecoin swaps.
The Three-Pool Foundation and Ecosystem
Curve's 3pool containing USDC, USDT, and DAI became a key piece of stablecoin infrastructure. Rather than fragmenting stablecoin liquidity across separate two-asset pools, the 3pool concentrated major stablecoin liquidity in a single venue. Traders could swap between any pair with a single transaction while benefiting from the combined depth of all three assets.
Building on this foundation, Curve created "meta-pools" that allowed new stablecoins to pair directly against 3pool LP tokens, gaining access to liquidity against all three major stablecoins simultaneously. New projects like FRAX, LUSD, and GUSD could tap into the 3pool's billion-dollar liquidity without fragmenting it across multiple venues, solving the bootstrap problem for new stablecoin launches.
The architecture extended beyond dollar stablecoins to liquid staking derivatives like stETH/ETH, where the specialized mathematics proved well-suited for assets that should maintain relatively stable ratios. Curve became a major venue for various pegged asset categories including wrapped Bitcoin variants and EUR stablecoins.
Market Evolution and Competition
Despite these technical innovations and network effects, competitive dynamics have shifted significantly. The March 2023 USDC depegging crisis provided a stress test of Curve's design. As USDC dropped to $0.88, the 3pool became heavily imbalanced toward USDC as traders fled the distressed asset. While the mathematics worked as designed and the pool rebalanced after USDC recovered, the crisis revealed both the resilience and limitations of AMM-based stablecoin trading under extreme market stress.
Curve's mathematical advantages and established liquidity couldn't prevent market share erosion from Uniswap v3's concentrated liquidity. Uniswap's 0.01% fee tiers matched Curve's pricing while concentrated liquidity allowed sophisticated providers to achieve similar capital efficiency. Combined with Uniswap's more accessible user experience and broader ecosystem integration, this competitive shift has reversed the landscape. Uniswap now processes over $220 million daily in USDC/USDT swaps compared to Curve's approximately $44 million across all its stablecoin pools.
Bonding-Curve Launchpads
While Uniswap and Curve focus on trading existing tokens, a related innovation applies similar mathematical curves to solve a different problem: how new tokens come into existence and find their initial price. Before bonding-curve launchpads emerged, launching a token typically meant proceeding directly to an AMM like Uniswap or Raydium. Development teams would create their token and seed an initial liquidity pool using their own capital, usually pairing it against ETH, SOL, or a stablecoin. They would often burn or lock the LP tokens to demonstrate they could not later "rug" the pool. This approach made token launches capital-intensive and established a particular set of trust assumptions: users needed to believe the team would neither withdraw liquidity, mint new tokens arbitrarily, nor otherwise abuse their privileged position around the pool.
Pump.fun fundamentally reframed this pipeline by introducing a distinct "pre-AMM" stage governed by a bonding curve. Built on Solana, it functions as a permissionless launchpad where anyone can create a token and watch it trade immediately on a curve-based contract. When someone launches a new token, a fixed supply (commonly one billion units) is minted. Roughly 800 million tokens are made available on the bonding curve, while the remaining 200 million or so are allocated to the creator and typically later recycled into the initial liquidity position once the token graduates.
The curve sells tokens against SOL, with prices rising non-linearly as more of those 800 million tokens are purchased and falling when they are sold back into the curve. In practice, the creator can also buy from the curve immediately at launch. This gives them a natural opportunity to build an early position at the lowest prices before wider attention arrives.
Once the bonding curve reaches a defined completion threshold (effectively, once a platform-specified number of tokens have been sold and a target amount of SOL has been accumulated), the token "graduates." At this pivotal moment, the system automatically seeds a liquidity pool on a downstream AMM and transfers the bonded SOL and tokens into it, often burning the resulting LP tokens. Historically, this meant creating a pool on Raydium. More recently, Pump.fun routes graduated tokens into its own AMM, PumpSwap, where they trade like any other Solana token.
For users, this design compresses issuance, initial price discovery, and AMM listing into a single automated pipeline. Pump.fun's contracts handle pool creation and LP-token burning behind the scenes instead of teams manually setting up a pool and then burning LP. Because PumpSwap is vertically integrated, the platform can also levy protocol fees on secondary trading and share a slice of those fees with token creators. This turns successful graduations into an ongoing fee stream rather than just a one-off bonding-curve event.
This architecture removes certain trust assumptions while introducing others. Developers no longer control LP tokens during the early phase. The bonding-curve contract enforces pricing and liquidity, while graduation logic automatically seeds the AMM pool. Yet participants now rely on the correctness and governance of a single platform's contracts and backend, along with its off-chain policies governing moderation, regional restrictions, and listing rules.
The creator still holds a meaningful portion of supply and can buy early on the curve. This means "soft rugs" via aggressive selling or outright abandonment remain common even when classic LP-withdrawal rugs become harder to execute. In practice, only a small fraction of the thousands of daily launches ever graduate off the curve. Lifetime averages sit in the low single digits (around 1-2% of tokens graduating overall), with daily graduation rates typically below 3% and only occasionally spiking above 4% during peak mania. Most tokens die in place as short-lived social experiments.
Despite these risks, or perhaps because of them, Pump.fun became one of the most influential retail-facing crypto applications of the 2024-2025 cycle. It reduced the cost and friction of token creation to nearly zero, transformed the "token" itself into a disposable social object, and helped catalyze a massive memecoin wave. Many assets began life on a bonding curve before ever touching a conventional AMM. The model proved contagious: bonding-curve launchpads and Pump.fun clones rapidly appeared across other L1s and L2s, cementing this "factory plus curve plus AMM graduation" pipeline as a standard pattern for speculative token issuance.
Conceptually, bonding-curve launchpads sit upstream of the exchange architectures described throughout the rest of this section. They are not general-purpose DEXs in the way Uniswap or Curve are, but they employ similar mathematical principles to automate primary issuance, early price discovery, and initial liquidity provisioning. AMMs still handle the long-tail trading once a token graduates. Bonding curves simply shifted who must provide seed capital and what users must trust in the earliest, most reflexive phase of a token's existence.
Alternative Exchange Architectures
The AMM revolution sparked further innovation in exchange design, each solving different aspects of the trading problem.
Intent-Based Systems
Intent-based platforms like CoW Swap and UniswapX represent a paradigm shift from traditional transaction specification. Instead of users constructing exact swap paths and parameters, they sign high-level "intents" that describe desired outcomes, such as "I want to receive at least 1,000 USDC for my 1 ETH within the next 2 minutes."
Off-chain solvers (also called "fillers") then compete to fulfill these intents, routing across multiple venues for best execution. CoW Swap uses batch auctions where solvers submit bids to fill multiple orders simultaneously, often finding Coincidence of Wants (CoW) where orders can be settled directly against each other without touching AMM liquidity. UniswapX employs Dutch auctions where the offered price gradually improves until a filler takes it.
Users often get better prices than direct AMM swaps since solvers can access multiple liquidity sources and internalize trades. UniswapX additionally enables gasless submission where fillers pay the gas fees, improving the user experience. Both systems provide MEV protection since the competitive solver auction makes it difficult for any single actor to extract value.
Request-for-Quote Systems
Request-for-Quote (RFQ) systems bring professional market making to DeFi by combining off-chain efficiency with on-chain settlement. Platforms like Hashflow and 0x RFQ allow users to request firm quotes from market makers, who provide guaranteed prices based on current conditions.
Market makers quote prices off-chain, considering their inventory, hedging costs, and desired margins. Once a user accepts a quote, settlement happens on-chain at the guaranteed price with no slippage risk. This approach proves effective for larger trades where AMM price impact would be significant, and for institutional users who value execution certainty over decentralization.
Decentralized Perpetual Exchanges
Beyond spot trading, decentralized perpetual exchanges have grown rapidly, bringing on-chain leverage and competitive performance. While Chapter VI covered the mechanics of perpetual futures on centralized exchanges, this section focuses on their decentralized counterparts. Platforms like GMX use synthetic pricing with LP pools backing trades, while dYdX originally built on StarkEx for better performance before launching its own application-specific blockchain. These developments demonstrate how DeFi continues expanding the scope of possible financial services.
Application-specific chains like Hyperliquid run their own blockchains optimized entirely for trading, prioritizing speed and order book efficiency over general-purpose computation. This architecture enables sub-second finality and complex order types that would be impractical on general L1s. Chapter X examines Hyperliquid's approach in depth.
Each model balances different priorities: AMMs prioritize decentralization and composability, RFQ systems optimize for execution quality, and application-specific chains maximize performance. The optimal choice depends on specific use cases, performance requirements, and risk tolerance.