Swap
A swap in decentralized finance refers to the instant exchange of one cryptocurrency for another directly through a smart contract. Unlike traditional exchanges that use order books, DeFi swaps utilize liquidity pools and automated market makers to match users with existing reserves. This process is trustless, permissionless, and executed entirely on-chain, allowing users to maintain full custody of their assets until the moment the exchange is completed.Definition
A swap in decentralized finance refers to the instant exchange of one cryptocurrency for another directly through a smart contract. Unlike traditional exchanges that use order books, DeFi swaps utilize liquidity pools and automated market makers to match users with existing reserves. This process is trustless, permissionless, and executed entirely on-chain, allowing users to maintain full custody of their assets until the moment the exchange is completed.Simple explanation
It is like a digital vending machine. You put one coin in, and the machine gives you a different coin based on the current exchange rate. No broker is needed, and you don’t have to wait for someone else to accept your trade.Why it matters
Swaps allow for instantaneous, global trading without the need for centralized intermediaries or lengthy account verification processes. They have enabled the rapid movement of capital across various tokens, fostering a dynamic and liquid DeFi ecosystem.How it works
A user sends a transaction to a decentralized exchange with the amount of tokens they want to trade. The smart contract checks the associated liquidity pool, calculates the exchange rate using the AMM algorithm, and performs the trade. The new tokens are then sent directly back to the user’s wallet in a single transaction.Real-world example
Using the Uniswap web interface to exchange ETH for USDC represents a classic DeFi swap.Advantages
- Instant trade execution
- Full user custody of funds
- No account registration required
Limitations
- Requires payment of network gas fees
- Risk of smart contract errors
- Subject to slippage
Common misconceptions
- Some believe swaps are slow. Because they are automated, they are usually completed within seconds or minutes.
- Many assume every swap is anonymous. While there is no signup, all transactions remain visible on the public blockchain ledger.
Related knowledge
- AMM — term
- DEX — term
- Liquidity Pool — term
- Smart Contract — term
- Token — term
Canonical knowledge ID:
glossary:swap