Token Swap

Exchanging one token for another, either on a venue's book or against a pool.

Basically

In plain words, a token swap is the exchange of one cryptocurrency for another, executed either on a centralized exchange or through a DeFi protocol.

Key Takeaways

  • A token swap exchanges one cryptocurrency for another, either through a centralized exchange's order book or via a decentralized exchange (DEX) that uses automated market makers or on-chain order books.
  • DEX-based swaps execute through smart contracts and liquidity pools, settling atomically on-chain: the trade either fully completes or fully reverts in a single transaction.
  • Swap aggregators like 1inch and Jupiter route trades across multiple DEXs to find the best price, while newer intent-based systems let solvers compete to fill orders off-chain before settling on-chain.

What Is a Token Swap?

A token swap is the exchange of one cryptocurrency token for another. At its simplest, a user sends token A into a trading venue and receives token B in return at the prevailing market rate. This is the most fundamental operation in crypto trading and the backbone of decentralized finance (DeFi).

Token swaps can happen in two contexts. On a centralized exchange (CEX) like Coinbase or Binance, the exchange matches buyers and sellers using internal order books and settles trades on its own ledger. On a DEX, the swap executes through a smart contract on a public blockchain, with no intermediary holding funds at any point. DEX swaps are trustless, permissionless, and transparent: anyone can verify the trade on-chain.

DEX trading volume has grown significantly, with monthly spot volume reaching $231 billion in January 2026 and DEX-to-CEX market share climbing above 14%. This growth reflects a broader shift toward self-custodial trading, where users retain control of their assets throughout the swap process.

How It Works

The mechanics of a token swap differ depending on whether the venue uses an automated market maker or an order book. Both models achieve the same result (exchanging one token for another) but price discovery works differently.

AMM-Based Swaps

Most DEX volume flows through automated market makers. Instead of matching individual buyers and sellers, AMMs use liquidity pools: smart contracts holding reserves of two (or more) tokens. Anyone can deposit tokens into a pool to become a liquidity provider (LP) and earn a share of trading fees.

The price of a swap is determined algorithmically by the constant product formula. For a pool containing reserves of token X and token Y:

When a trader buys token X from the pool, the reserve of X decreases and the reserve of Y increases (the trader deposits Y). The constant k must remain unchanged, so the price shifts with every trade. Larger trades move the price more, which is why slippage increases with trade size relative to pool depth.

Uniswap v2 pioneered this model with a flat 0.3% fee per swap distributed to LPs. Uniswap v3 introduced concentrated liquidity, letting LPs allocate capital within specific price ranges for up to 4,000x capital efficiency. Uniswap v4, launched on Ethereum mainnet in January 2026, introduced a singleton contract architecture (all pools in one contract) and a hooks system for attaching custom logic to pools.

Order Book DEX Swaps

Order book DEXs work more like traditional exchanges. Market makers post limit orders (bids and asks), and incoming swap orders match against resting orders at their posted prices. This model offers tighter spreads and lower slippage for large trades when the book is deep, but requires active market makers to provide liquidity.

The Swap Lifecycle

A typical DEX swap follows five steps from quote to settlement:

Swap Aggregators

A single DEX pool may not offer the best price for a given trade. Swap aggregators solve this by scanning every reachable liquidity source on a chain, splitting an order across the optimal combination of pools, and delivering the best net output after gas costs.

The aggregator's pathfinding algorithm considers direct routes (single pool), multi-hop routes (token A to token B to token C), and split routes (sending portions of the trade to different pools simultaneously). Gas costs are factored in: a slightly better price on a secondary DEX may not be worth the extra gas of a multi-hop route.

Major aggregators include:

Atomic Swaps

While standard token swaps happen within a single blockchain, atomic swaps enable trustless exchange across two separate blockchains using Hash Time-Locked Contracts (HTLCs). The term "atomic" means indivisible: the swap either completes for both parties or neither.

The asymmetric timelocks ensure safety: Alice's longer timeout prevents her from claiming Bob's ETH and also reclaiming her own BTC. If either party fails to act, funds are refunded automatically. Atomic swaps require multiple on-chain transactions and compatible hash functions on both chains, making them slower than single-chain DEX swaps but fully trustless across chains.

Use Cases

Why It Matters

Token swaps are the foundational primitive of decentralized finance. Every DeFi activity, from providing liquidity to entering a leveraged position, begins with a swap. The ability to exchange assets without an intermediary is what makes permissionless finance possible.

For Bitcoin users, the evolution of swap infrastructure is particularly relevant. Layer 2 protocols like Spark enable fast, low-cost transfers of Bitcoin and stablecoins, creating new opportunities for swap functionality on Bitcoin's security model. As intent-based trading matures and cross-chain aggregation improves, the user experience of token swaps continues to converge toward traditional exchange simplicity while preserving the trustless guarantees of decentralized settlement.

For a deeper look at how decentralized exchange infrastructure is evolving on Bitcoin, see the BtcFi landscape overview and the guide to Bitcoin on/off-ramps.

Risks and Considerations

Slippage and Price Impact

Slippage is the difference between the expected and actual execution price. It arises from two sources: the mathematical price impact of trading against a finite pool (inherent to the constant product formula), and market movement during the delay between transaction submission and block inclusion. Larger trades in shallower pools experience worse slippage. Setting slippage tolerance too high exposes the trader to unfavorable fills; setting it too low causes transactions to revert frequently.

Impermanent Loss

Liquidity providers face impermanent loss when the price ratio of pooled tokens diverges from the ratio at deposit time. For a standard 50/50 pool, a 2x price change results in approximately 5.7% loss compared to simply holding the tokens, and a 5x change results in roughly 25.5% loss. Trading fees earned may partially offset this, but the loss is often permanent if the price does not revert before withdrawal.

Front-Running and MEV

When a swap transaction sits in the public mempool awaiting block inclusion, it is visible to bots that extract maximal extractable value (MEV). Sandwich attacks are the most common form: a bot front-runs the victim's trade (buying before them to push the price up), then back-runs it (selling after at the inflated price). Studies estimate that roughly 1.2% of Ethereum DEX trades are sandwiched, with total MEV extraction exceeding $550 million annually on Ethereum. Private transaction submission and intent-based systems like UniswapX and CoW Swap help mitigate this by routing orders off the public mempool.

Smart Contract Risk

Every DEX swap interacts with smart contracts that may contain bugs, exploits, or malicious code. Token approval vulnerabilities are a specific concern: granting unlimited ERC-20 allowances to a DEX router means a compromised or malicious contract could drain all approved tokens. Using a smart contract audit as a baseline check and approving only exact amounts reduces this risk.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.

0

← All 1876 glossary terms