Since the launch of Ethereum in 2015, decentralized finance (DeFi) has come a long way. And out of all the services that have played a crucial role in building the DeFi ecosystem, token swaps reign supreme.
This beginner's guide on token swaps explains what they are, how they work, and how you can start swapping 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 decentralized exchange (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 digital 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, token holders are asked to exchange the placeholder tokens for the native tokens of the new blockchain. This is essentially a token swap since there is an exchange of tokens between blockchains.
Only the first two examples (regular token swaps and cross-chain token swaps) 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 — user-supplied funds locked in a smart contract — to create enough liquidity for users to swap tokens.
To contribute to liquidity pools, users (also called liquidity providers) 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 need to 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 (such as USDT or USDC) 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 COMP/BAT pair liquidity pools are 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.
Still confused? Don't worry, we'll cover the exact steps needed to swap tokens below.
DEXs like Uniswap offer an auto-router feature that directs your trade COMP for ETH or USDT to BAT in a single transaction, significantly lowering the total cost of trading fees you pay for the transaction. MoonPay allows you to make these types of direct swaps as well.
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.
While centralized exchanges use order books, decentralized exchanges use automated market makers (AMMs) like Uniswap, Bancor, and Curve to facilitate trades.
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 that ensures the token swap won't occur if either party doesn't deposit their assets and submit 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 crypto tokens
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 wrapped Bitcoin (wBTC).
Further, developers get the added flexibility to build multi-chain protocols and tap into the audience on multiple chains. Devs 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 when 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. In 2022, bridge hacks accounted for $2 billion in funds stolen.
How can I swap tokens?
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 transaction details.
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 to conduct a token swap. You can follow a similar process to swap tokens on 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 crypto 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 again for this example.
Step 3. Sign your transaction by clicking “Sign” to connect your wallet.
Step 4. Next, go to the deposit tab and add the amount of tokens you want to bridge.
Step 5. Check the estimated gas fees.
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.
Token swaps have become a central feature of the DeFi ecosystem, powering both centralized and decentralized exchange platforms. 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 tokens on a decentralized or centralized exchange. However, you must educate yourself on the benefits and risks of using either of these approaches.
How to swap tokens via MoonPay
Step 1: Select your cryptocurrency trading pair
Step 2: Enter the amount of crypto to swap
After choosing the swapping pair, next you'll need to decide how much crypto you'd like to swap. There is a minimum of $15 for all crypto exchange transactions.
Step 3: Connect your wallet
Using WalletConnect, MoonPay allows your to connect your preferred non-custodial crypto wallet to receive your new tokens.
Step 4: Review details and confirm the swap
Before completing the swap exchange, you'll be asked to review transaction details, including crypto swap amount, cryptocurrency wallet address, exchange rate, as well as transaction fees incurred.
Click "Confirm swap" to initiate the cryptocurrency exchange.
To cover any network fees, make sure that you have enough crypto in your wallet.
Step 5: Receive your crypto
After the transaction is confirmed on the blockchain, you'll receive your new cryptocurrency tokens in your selected wallet.
Note: if this is your first time completing a crypto swap transaction with MoonPay, you’ll need to pass identity verification and KYC before continuing with the exchange.
Start token swapping today
MoonPay is changing the token swap game with our new Swaps feature.
Still not sure where to start? View our beginner's guide on how to buy Bitcoin.
MoonPay also makes it easy to sell crypto when you decide it's time to cash out. Simply enter the amount of the token you'd like to sell and enter the details where you want to receive your funds.