How to swap tokens?
A decentralized exchange (DEX) lets people exchange any two tokens. In this web3 guide, we’ll cover how DEXs work and how to swap tokens.
A decentralized exchange (DEX) lets people exchange any two tokens. In this web3 guide, we’ll cover how DEXs work and how to swap tokens.
A decentralized exchange (DEX) lets people exchange any two tokens.
In this guide, we’ll cover:
What follows is not investment advice.
Suppose you have some apples that you want to trade for oranges. You visit the grocery store:
One day, you realize that the oranges you’ve been buying are actually from your neighbor. You both decide to cut out the middleman (store) as follows:
Keep this analogy in mind as we discuss how decentralized exchanges work.
Centralized exchanges (CEX), like the store, use the order book method:
Decentralized exchanges (DEX), like the basket, are automated market makers (AMM) that use liquidity pools. Let’s define a few terms:
DEXs want a large liquidity pool to reduce price volatility. Consider these two examples:
So to recap, people can use DEXs to:
We’ll cover providing liquidity later. Let’s walk through how to swap tokens first.
In the example below, we’ll swap ETH and DAI tokens using Uniswap (a popular DEX) on Polygon. Polygon is an Ethereum L2 scaling solution that offers faster and cheaper transactions. To try this example yourself, you need to have:
1. Visit Uniswap and connect your wallet and network of choice
Visit Uniswap and click “Connect Wallet” in the top-right corner. Switch to the “Polygon” network.
2. Choose the tokens that you want to swap
Select the “Swap” tab and choose to swap an amount of WETH for DAI.
3. Check the exchange rate
Check the exchange rate to prevent ugly surprises. Cryptocurrency prices are volatile and market prices can differ from the quoted swap price in the pool.
Slippage is the difference between your expected exchange rate and the actual rate. Volatile tokens are more likely to experience slippage than ETH and DAI. You can also set the slippage tolerance in Uniswap:
4. Click ‘Swap’
Click the ‘Swap’ button to initiate a swap and confirm the transaction using your wallet. Note that you’ll need to pay a transaction fee (e.g., a small amount of MATIC).
After a few minutes, you should see some DAI in your wallet.
Now that you know how to swap tokens, let’s cover lending and borrowing crypto.
Up next: How to lend and borrow assets?