How Decentralized Exchanges Work

A mechanism-level explanation of how DEXs replace order books with liquidity pools, the x*y=k formula that prices every trade, and where the hard constraints — finality, gas costs, oracle dependency — actually live.
Lewis Jackson
CEO and Founder

The Load-Bearing Element of Centralized Exchanges

On a centralized exchange, you deposit funds with a company. That company maintains an order book, matches buyers with sellers, and holds custody of your assets throughout. Trust in the institution is the load-bearing element. FTX was the sharpest demonstration of what happens when that trust is misplaced — not a hack, but a custodian who used customer funds for something else.

A decentralized exchange (DEX) removes the custodian entirely. Trades execute directly from your wallet through a smart contract. No company holds your funds, no order book sits on a private server, and no central party can freeze withdrawals. What makes this possible isn't just a political choice about decentralization — it's a different market structure. Most DEXs replace the order book with something called an Automated Market Maker. Understanding that mechanism is what separates understanding DEXs from just knowing what they're called.

The Automated Market Maker: How Prices Get Set Without an Order Book

Most DEXs — Uniswap, SushiSwap, Curve, and many others — use an Automated Market Maker (AMM) instead of an order book. The core idea: rather than matching a buyer at $1,800 with a seller at $1,800, prices are set algorithmically based on the ratio of two tokens in a pool.

The formula at the heart of Uniswap v2 is: x * y = k

Where x is the quantity of token A in the pool, y is the quantity of token B, and k is a constant that must hold before and after every trade. When you buy token A with token B, you add B to the pool and remove A. This shifts the ratio, which changes the price. The more you buy relative to the pool's size, the more the ratio shifts — and the worse your effective price gets. That's slippage, and it's a direct consequence of the formula.

The full execution flow works like this:

  1. A liquidity provider (LP) deposits equal dollar value of two tokens — say ETH and USDC — into a pool smart contract
  2. The contract mints LP tokens representing their proportional share of the pool
  3. A trader sends USDC to the contract and receives ETH back, at a price determined by the x*y=k formula applied to the current pool balances
  4. The trader pays a fee — typically 0.3% — which stays in the pool, accruing to LPs
  5. The LP can withdraw their share at any time: original tokens plus accumulated fees, minus any impermanent loss

That last term matters. Impermanent loss is the difference between holding tokens outright versus holding them in an AMM pool. If ETH doubles while an LP is providing ETH/USDC liquidity, they end up with more USDC and less ETH than they'd have had holding directly — because arbitrageurs continuously rebalance the pool to track market prices. The loss is "impermanent" only if prices return to the original ratio; if they don't, it's realized at withdrawal.

Nothing in this flow requires a custodian. The smart contract holds the pooled assets and executes trades atomically — either the complete trade executes or none of it does. Your wallet interacts directly with the contract; at no point does a company take control of your funds.

Where the Hard Constraints Live

Three constraints shape what DEXs can and can't do:

Smart contract finality. Once a trade executes on-chain, it cannot be reversed. There's no dispute resolution, no support ticket, no chargeback mechanism. If you approve a malicious contract or send to the wrong pool, the loss is permanent. The code is the counterparty.

On-chain settlement cost. Every trade is a blockchain transaction. On Ethereum mainnet, gas costs during congestion can exceed $20-40 for a single swap — making small trades economically irrational. This is why the majority of DEX volume has migrated to Layer 2 networks (Arbitrum, Optimism, Base) and alternative L1s where fees are fractions of a cent.

Price feed dependency. More sophisticated DEX designs rely on price oracles to set liquidity ranges or trigger liquidations. Oracle manipulation is a documented attack vector. Multiple DeFi protocols have lost hundreds of millions this way — an attacker manipulates a pool price within a single transaction to exploit a downstream protocol relying on that price.

What's Changing at the Mechanism Level

Three developments are worth tracking:

Concentrated liquidity (Uniswap v3) lets LPs deploy capital within a specified price range rather than across the entire curve. Capital efficiency improves dramatically — potentially 4,000x for stable pairs in a tight range — but so does management complexity. LPs out of range earn zero fees while still bearing impermanent loss. It converts passive provision into something closer to active market-making.

Intent-based trading adds an execution layer above AMMs. Rather than trading directly against a pool, a user signs an "intent" specifying what they want, and off-chain solvers compete to fill it at the best price across multiple venues. CoW Protocol and UniswapX implement variations of this model. Execution complexity shifts from the user's wallet to a competitive solver market.

Cross-chain liquidity is being addressed through bridge-integrated protocols. Thorchain enables native swaps between Bitcoin, Ethereum, and other assets without wrapped tokens. The trust model is different from single-chain DEXs — cross-chain execution reintroduces validator sets or threshold signature schemes at the bridging layer, which is where many of the largest DeFi exploits have occurred.

What Would Confirm This Direction

Continued growth in DEX volume as a share of total spot crypto volume. Expanding LP fee revenue on L2 networks demonstrating that low-cost settlement makes AMM participation economically viable at scale. Intent-based protocols capturing a meaningful share of high-value trades rather than just arbitrage and long-tail tokens. These signals would indicate the AMM model gaining structural ground, not just capturing niche volume.

What Would Break It

A critical exploit in a top-tier AMM contract — the core pool logic, not a bridge or peripheral integration — would mark a structural failure. Regulatory treatment of LP provision as unlicensed market-making activity would reshape who can participate and under what conditions. Either represents a categorical setback, not a temporary volume shift.

Timing Perspective

Now: DEXs handle roughly 15-20% of spot crypto volume and dominate long-tail token trading. L2 migration has made gas costs manageable for regular traders.

Next (2025-2027): Intent-based architectures and concentrated liquidity tooling are gaining traction. The next major design iteration is likely at the execution layer, not the AMM formula itself.

Later: Institutional DEX participation depends on regulatory clarity around LP status and on-chain compliance infrastructure that doesn't yet exist at scale.

What This Doesn't Mean

This is a mechanism explanation, not a recommendation. Whether any specific DEX, pool, or LP strategy is worth using depends on factors this post doesn't address — protocol risk, current fee economics, tax treatment of LP income, and smart contract risk tolerance.

What it does establish: DEXs aren't a slightly different interface to the same market structure as a centralized exchange. The AMM model is a fundamentally different approach to price discovery — built on pooled liquidity and a mathematical constant product formula rather than order-matching. The x*y=k relationship, impermanent loss mechanics, and on-chain settlement constraints are prerequisite knowledge for understanding the rest of DeFi, which layers lending, borrowing, derivatives, and governance on top of this foundation.

Related Posts

See All
Crypto Research
New XRP-Focused Research Defining the “Velocity Threshold” for Global Settlement and Liquidity
A lot of people looking at my recent research have asked the same question: “Surely Ripple already understands all of this. So what does that mean for XRP?” That question is completely valid — and it turns out it’s the right question to ask. This research breaks down why XRP is unlikely to be the internal settlement asset of CBDC shared ledgers or unified bank platforms, and why that doesn’t mean XRP is irrelevant. Instead, it explains where XRP realistically fits in the system banks are actually building: at the seams, where different rulebooks, platforms, and networks still need to connect. Using liquidity math, system design, and real-world settlement mechanics, this piece explains: why most value settles inside venues, not through bridges why XRP’s role is narrower but more precise than most narratives suggest how velocity (refresh interval) determines whether XRP creates scarcity or just throughput and why Ripple’s strategy makes more sense once you stop assuming XRP must be “the core of everything” This isn’t a bullish or bearish take — it’s a structural one. If you want to understand XRP beyond hype and price targets, this is the question you need to grapple with.
Read Now
Crypto Research
The Jackson Liquidity Framework - Announcement
Lewis Jackson Ventures announces the release of the Jackson Liquidity Framework — the first quantitative, regulator-aligned model for liquidity sizing in AMM-based settlement systems, CBDC corridors, and tokenised financial infrastructures. Developed using advanced stochastic simulations and grounded in Basel III and PFMI principles, the framework provides a missing methodology for determining how much liquidity prefunded AMM pools actually require under real-world flow conditions.
Read Now
Crypto Research
Banks, Stablecoins, and Tokenized Assets
In Episode 011 of The Macro, crypto analyst Lewis Jackson unpacks a pivotal week in global finance — one marked by record growth in tokenized assets, expanding stablecoin adoption across emerging markets, and major institutions deepening their blockchain commitments. This research brief summarises Jackson’s key findings, from tokenized deposits to institutional RWA chains and AI-driven compliance, and explains how these developments signal a maturing, multi-rail settlement architecture spanning Ethereum, XRPL, stablecoin networks, and new interoperability layers.Taken together, this episode marks a structural shift toward programmable finance, instant settlement, and tokenized real-world assets at global scale.
Read Now

Related Posts

See All
No items found.
Lewsletter

Weekly notes on what I’m seeing

A personal letter I send straight to your inbox —reflections on crypto, wealth, time and life.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.