DeFi & AMM

Swap (DEX)

The act of exchanging one token for another on a decentralized exchange, executed through a smart contract.

Swap (DEX) — A swap is the exchange of one cryptocurrency token for another on a decentralized exchange. Unlike centralized exchange trading, a DEX swap executes directly against a liquidity pool's smart contract, with the price determined algorithmically by the pool's reserve ratio.

What Is a Swap?

A swap is the fundamental trading action on a DEX. When a user swaps ETH for USDC on Uniswap, they send ETH to the liquidity pool contract and receive USDC in return. The exchange rate is calculated by the AMM's pricing formula based on the current ratio of tokens in the pool.

Swaps are permissionless and non-custodial — no account, identity verification, or intermediary is required. Any wallet can execute a swap by interacting with the DEX smart contract.

How Swaps Work

The user specifies an input token, output token, and amount. The DEX router finds the best pool or route, calculates the expected output after fees and price impact, and presents a quote. If the user approves, the transaction is submitted to the blockchain.

The swap contract transfers the input token from the user's wallet, updates the pool reserves, and sends the output token to the user — all in a single atomic transaction. A swap fee (typically 0.3%) is deducted and distributed to liquidity providers.

Why Swaps Matter

Swaps are the core utility of decentralized exchanges and the primary driver of on-chain trading volume. Every swap generates fees for LPs, contributes to a token's volume metrics on analytics platforms, and updates the pool's price — making swaps the fundamental building block of the DeFi ecosystem.

Common questions about Swap (DEX) in cryptocurrency and DeFi.

A swap incurs the pool's trading fee (commonly 0.3%), plus blockchain gas fees for the transaction. On high-traffic chains like Ethereum, gas can exceed the swap fee for small trades.

Yes. A swap fails if the price moves beyond the slippage tolerance before the transaction is confirmed, if the user has insufficient gas, or if the token contract has restrictions that block the transfer.

There is no protocol-enforced minimum, but the swap must be large enough that the output value exceeds the gas cost. On Ethereum, this practically means swaps under $50 may not be economical during high-gas periods.

Ready to put your knowledge into practice?

Start Boosting