What are token swaps?
Learn all about token swaps, how you can execute them, and the benefits they bring to the DeFi ecosystem.
By Mrig P
Since the launch of Ethereum in 2015, DeFi has come a long way. And of all the services that have played a crucial role in building the DeFi ecosystem, token swapping reigns supreme.
Without the ability to conduct a token swap within a blockchain ecosystem or between two different blockchains, DeFi as we know it would come to a halt.
This beginner’s guide on token swaps explains what they are, how they work, and how you can start swapping your tokens.
What is a token swap?
A token swap refers to the exchange of one crypto token for another without the need to first convert it to fiat currency. For example, when you deposit Ethereum's native token ETH on a DEX and get USDT in return, you are conducting a token swap.
But there’s more.
Token swapping has three distinct meanings in the crypto space. Let’s explore each one of them separately.
Regular token swaps
Regular token swaps simply refer to the exchange of tokens through a centralized or decentralized exchange.
The concept of token swapping through both exchanges is the same — you sell a token you already own and buy an equivalent value of the other token. However, the amount of control you have over your assets differs in both exchanges.
Centralized exchanges are custodial, meaning they have ultimate control over your assets. Decentralized exchanges, on the other hand, offer users complete control over their assets, which they store using a non-custodial wallet.
Cross-chain token swaps
A cross-chain token swap is when you move your tokens from one blockchain network to another. This is usually done using bridges that lock tokens on one blockchain and mint a wrapped token on the other.
For example, you can use the Binance bridge to lock your ETH on the Ethereum network and receive wrapped Ethereum (wETH) on the Binance chain. And you can follow a similar process to unwrap your wETH and receive ETH in your Ethereum wallet.
A token migration occurs when a project migrates from one blockchain network to another to raise funds or improve its functionality. Here’s how this works:
The developers raise funds by distributing “placeholder” tokens on a blockchain like Ethereum.
Once the project is complete, the token holders are asked to exchange the placeholder tokens for the native tokens of the new blockchain, which is essentially a token swap since tokens are exchanged between blockchains.
Only the first two examples are a “token swap” in the sense that one token is swapped for another. Token migration isn’t technically a swap but rather the migration of the entire supply of a project’s token from one chain to the other.
For the purpose of this article, we’ll only focus on the first two types of token swaps.
How do token swaps work?
By now, it’s pretty clear that token swapping means one of two things: exchanging a crypto asset to get another desired token on the same chain or passing your token through a crypto bridge to use it on a different blockchain.
Depending on which type of token swap you’re conducting and on which platform, the process may differ.
Decentralized exchange swaps
Decentralized exchanges are crypto swapping exchanges that do not need you to deposit your assets into the exchange, meaning you have complete control over your assets.
On DEXs, a token swap involves mostly relying on liquidity pools — user-supplied funds locked in a smart contract — to create enough liquidity for users to swap tokens.
To contribute to liquidity pools, the user (also called a liquidity provider) must deposit their digital tokens in an equivalent ratio to keep the pool balanced. For example, if someone is depositing liquidity in an ETH/USDT pool, they must deposit an equal worth of both assets, say $500 worth of ETH paired with $500 worth of USDT.
Each set of paired tokens has a separate liquidity pool on the DEX, and to complete token swaps, you’d add a token to a respective liquidity pool and withdraw an equal worth of the other token from the pool after paying a small transaction fee to the blockchain.
If you’re swapping tokens that don’t exist as an exact swap pair, you’ll have to convert your digital assets into a stablecoin or some other popular digital assets before ending up with your final token.
For example, if you want to trade COMP (the native token for Compound) for BAT, you’ll have to convert your COMP into a popular token like ETH first because the COMP/BAT pair liquidity pool is fairly difficult to find.
Once you’ve converted your COMP to ETH, you can easily find an ETH/BAT pair and buy BAT tokens. This intermediate step means more gas fees and higher transaction costs.
DEXs like Uniswap offer an auto-router feature that directs your trade from COMP to ETH or USDT to BAT in a single transaction, significantly lowering the total cost you pay for the transaction.
Centralized exchange swaps
Centralized exchanges work similarly to traditional stock exchanges, employing the order-book model to make swaps.
Order books are electronic ledgers that contain a list of all the buy and sell orders, which includes order volume and the price at which users are willing to buy or sell their assets.
When you place a buy order, it’s sent to the order book where the matching engine tries to find a corresponding sell order. Once the two orders are matched, the token swap is done.
Cross-chain (atomic) swaps
Cross-chain swaps, also known as atomic swaps, enable two users to exchange one digital token directly without needing an exchange or other intermediaries like a token swapping service.
These swaps are carried out using a Hashed Time Lock Contract. This ensures that the swap doesn’t occur if either party doesn’t deposit their assets and submits cryptographic proof of their transaction within a specific time frame.
Benefits of token swaps
Here are some of the most notable benefits of token swaps:
Purchase any crypto token
Token swaps help you widen your exposure to crypto assets even if you own just one crypto token. For example, ETH holders can go to a CEX or DEX to exchange their tokens for wBTC, BNB, ENS, MATIC, USDT, and a long list of other tokens. This is especially useful if you’re investing in the crypto market as it helps reduce risk and volatility.
Access dApps across blockchains
Cross-chain bridges allow you to access decentralized applications (dApps) on different blockchains by moving assets across multiple chains. For example, if you’re a Bitcoin user, you can explore dapps on the Ethereum blockchain with wBTC.
Further, developers get the flexibility to build multi-chain protocols and tap into the audience on multiple chains. Developers can also leverage the large audience base on a popular blockchain like Ethereum to gain traction for their project and initiate a token migration after launching their blockchain.
Disadvantages of token swaps
Token swaps are not foolproof and bring some risks to the table.
If you’re trading fairly new tokens on a DEX, you’re bound to experience “slippage” due to low liquidity. Slippage is when there’s a price difference between the expected price and the price at which an order executes.
This tends to happen for large orders because the withdrawal changes the liquidity in the pools, which subsequently alters the assets’ price while your trade gets executed.
Cross-chain bridges allow you to take your tokens from one blockchain chain to another. Since they are a concentrated source of liquidity, however, hackers sometimes target them to steal users’ funds. Bridge hacks accounted for 69% of all the funds stolen in 2022.
How can I conduct a token swap?
There are three different ways to conduct a token swap. Let’s look at each of them in detail.
1. Token swap on a decentralized exchange
Here’s a step-by-step guide for token swapping ETH to USDT on Uniswap. You can follow similar steps to conduct a token swap on other exchanges as well.
Step 1. Open Uniswap.
Step 2. Click “Connect Wallet” and choose a wallet of your choice. For the purpose of this demonstration, we’re using the Metamask wallet.
Step 3. Select the tokens you want to swap and receive.
Step 4. Enter the number of tokens you want to swap and Uniswap will automatically calculate the approximate number of the other token you’ll receive.
Step 5. Confirm the details of the transaction.
Step 6. Approve Uniswap’s request to use your token by signing wallet transactions.
Step 7. Click the swap button and confirm the transaction from your wallet pop-up to complete the swap.
2. Token swap on a centralized exchange
For the purpose of this example, we’ll use the Binance exchange. You can follow a similar process for other exchanges.
Step 1. Go to Binance and create an account.
Step 2. Click “Verify Now” and enter your personal details to complete the verification process.
Step 3. Go to the exchange section.
Step 4. Select the token pair you want to trade.
Step 5. Enter the trade details.
Step 6. Confirm and execute trade.
3. Cross-chain token swap
There are a wide range of blockchain bridges that help you transfer your assets from one chain to the other. To give you an overview of how the process works, let’s use the Polygon bridge to bridge assets from Ethereum to Polygon.
Step 1. Go to the Polygon wallet suite and click “Polygon Bridge” to log into the Polygon wallet.
Step 2. Next, choose your Ethereum wallet and connect it to Polygon. We’re using the Metamask wallet for this example.
Step 3. Sign your transaction by clicking “Sign” to complete the wallet linking process.
Step 4. Next, go to the deposit tab and add the amount of tokens you want to bridge.
Step 5. Check the estimated gas fee.
Step 6. Confirm your transaction through your wallet and complete the bridge.
Once the transaction is confirmed on the blockchain, you will receive the tokens in your Polygon wallet.
Note: You might have to add the token manually to your Polygon wallet.
Begin your DeFi journey with MoonPay
Token swaps have become a central feature of the DeFi ecosystem. They not only enable interoperability and allow DeFi users and developers to get more exposure to different blockchains, they also provide investment opportunities to crypto traders.
Depending on whether you prefer non-custodial or custodial wallets, you can either swap your tokens on a decentralized or centralized exchange. However, you must educate yourself on the benefits and risks of using either of these approaches.
To get started, simply buy crypto via MoonPay using your credit card or any other preferred payment method.