Swap
Exchange tokens on Immutable Chain via QuickSwap.
When to use:
- Players need a specific token for in-game purchases
- Converting between game currencies
- Exchanging tokens before marketplace transactions
Overview
The swap widget, powered by QuickSwap, facilitates token exchanges on Immutable zkEVM. QuickSwap is a decentralized exchange (DEX) that provides liquidity for token swaps on Immutable Chain. Any allowlisted token with liquidity on QuickSwap is supported. The widget automatically routes swaps through the most efficient liquidity pools to minimize slippage and transaction costs.Prerequisites
Install the Immutable SDK:- npm
- yarn
Quick Start
Parameters
| Parameter | Type | Description |
|---|---|---|
flow | 'SWAP' | Required. Specifies the swap flow |
fromTokenAddress | string | Optional. Token to swap from |
toTokenAddress | string | Required. Token to swap to |
amount | string | Optional. Amount to swap |
Events
| Event | Description | Payload |
|---|---|---|
SUCCESS | Swap completed | { transactionHash, fromToken, toToken, fromAmount, toAmount } |
FAILURE | Swap failed | { error } |
CLOSE | User closed widget | — |
Common tokens
| Token | Mainnet Address | Testnet Address |
|---|---|---|
| IMX | NATIVE | NATIVE |
| USDC | 0x6de8aCC0D406837030CE4dd28e7c08C5a96a30d2 | 0x3B2d8A1931736Fc321C24864BceEe981B11c3c57 |
| wETH | 0x52a6c53869ce09a731cd772f245b97a4401d3348 | 0xe9E96d1aad82562b7588F03f49aD34186f996478 |