Cross-Chain Swaps, Bridges, and DEXs Explained

Individual blockchains operate as isolated digital ecosystems where all applications are interconnected by a single network. For example, all tokens on the Ethereum blockchain are connected, making it easy to swap them on decentralized without much hassle. However, with the rapid increase in blockchain networks, the lack of connectivity between them has created a need for cross-chain infrastructure that enables interoperability across multiple blockchains.

Without cross-chain infrastructure, blockchains remain as disconnected as standalone apps in today's Web2 environment. Therefore, cross-chain swaps, allow for the seamless exchange of digital assets between different blockchains. Like decentralized exchanges for single blockchain networks, cross-chain swaps are becoming crucial for an interconnected blockchain world.

About cross-chain swaps

Cross-chain swaps on centralized exchanges (CEX) enable users to trade cryptocurrencies from different blockchains within a single platform. Users deposit their cryptocurrencies into the CEX, which then takes custody of these funds and manages the cross-chain transaction process. 

However, cross-chain swaps in CEXs come with significant risks. Users must trust the exchange to safeguard their funds, creating custodial risk. Users could lose their assets if the exchange is hacked, insolvent, or fraudulent. Additionally, CEXs are subject to regulatory oversight, which can vary by jurisdiction and affect the exchange's operations and users' access to their funds. Technical issues, such as system outages or delays, can disrupt trading and access to funds, especially during high-demand periods. 

Furthermore, CEXs typically require users to complete KYC verification, compromising user privacy as personal information is stored by the exchange and could be exposed in a data breach. Users must weigh these risks against the convenience and liquidity provided by CEXs when deciding how to conduct cross-chain swaps. 

Cross-chain decentralized exchanges (DEXs) such as OKX DEX are emerging as a panacea against the risks associated with centralized exchanges. But what exactly are cross-chain DEXs, and how do they function?

Decentralized Exchanges (DEXs)

Decentralized exchanges (DEXs) are peer-to-peer marketplaces where crypto users can transact directly without giving up control of their funds to a third party. These transactions are facilitated by smart contracts, which are self-executing agreements encoded in software.

Learn more about DEXs here:

Clickable Block

What is а Decentralized Exchange (DEX)?

Thanks to their permissionless access, DEXs play a fundamental role in decentralized finance (DeFi) and function as a vital building block ...

Tangem blog
cross-chain bridges

Cross-chain DEXs

A cross-chain DEX allows the exchange of digital assets across multiple blockchain networks. This type of exchange relies on cross-chain bridges and interoperability protocols to move assets between different blockchains. 

Cross-chain bridges are protocols that allow tokens and data to move between different blockchain networks. They work by locking assets on one blockchain and minting equivalent tokens on another blockchain, or by burning tokens on the source blockchain and minting new ones on the destination blockchain.

These bridges serve as the foundational infrastructure for cross-chain swaps, enabling assets to be moved across blockchain boundaries without the need for centralized intermediaries. For example, a cross-chain bridge can lock Ethereum (ETH) on the Ethereum blockchain and mint Wrapped Ethereum (WETH) on the Binance Smart Chain (BSC), allowing the asset to be utilized within the BSC ecosystem.

Cross-chain DEXs overcome traditional DEXs' limitations by providing a platform for users to trade assets from various blockchain ecosystems seamlessly. They build on the functionality provided by cross-chain bridges to offer a platform where users can trade assets from different blockchains directly. 

The issue with cross-chain bridges

Cross-chain communication involves trade-offs in trust or flexibility that are not necessary for interactions within a single blockchain. This means that achieving composability between smart contracts on different blockchains requires compromises in these areas, unlike composability within a single blockchain, which does not face these challenges.

A key consideration in cross-chain bridging is the use of wrapped versus native assets. Wrapped assets represent tokens from another blockchain and introduce additional security and trust issues, as they rely on one or more entities to hold the underlying tokens securely.

Another important aspect of cross-chain bridges is finality—the assurance that funds on the destination chain are accessible once they are confirmed on the source chain. Without guaranteed finality, a reversal of the transaction on the source chain (like a block reorganization) could have negative effects on the destination chain, potentially leading to issues such as the issuance of unsupported bridged tokens. 

There are other specific reasons why swaps via cross-chain bridges fail.

Common reasons for cross-chain swap failures

There are three types of failed cross-chain swaps

  • Failed source-chain swaps.
  • Failed destination-chain swaps.
  • Failed cross-bridge transactions.

Here's why the source-chain swaps and the destination-chain swaps may be unsuccessful:

  • Broadcast failure: occurs when a transaction is not successfully communicated to the blockchain network. This can happen if the transaction details are not properly sent from the source chain to the bridge, resulting in the swap not being executed or recognized by the destination chain.
     
  • Insufficient gas: Insufficient gas means there wasn’t enough cryptocurrency allocated to cover the transaction fees required for processing on the blockchain.
     
  • Insufficient approved crypto amount: This issue arises when the amount of cryptocurrency approved for use in the swap is less than required. The swap cannot be completed if the user has not approved or provided enough tokens for the transaction.
     
  • Third-party DEX contract execution error: This happens when there is a problem with the smart contract of the decentralized exchange handling the swap. This could be due to coding errors, bugs, or unexpected issues in the contract's logic.
     
  • The transaction was sped up or canceled: Speeding up a transaction might involve increasing the gas fee to prioritize it while canceling stops the transaction from being executed. These actions can disrupt the swap process, potentially leading to failure.
     
  • Tokens traded were safemoon or honeypot tokens: SafeMoon or honeypot tokens are types of cryptocurrencies that may have specific features or risks. SafeMoon tokens might have high transaction fees or liquidity issues, while honeypot tokens are designed to trap funds and prevent users from withdrawing them.
     
  • Triggered the third-party bridge’s blocklist: A blocklist is a set of addresses or criteria that a bridge or DEX uses to prevent transactions involving certain tokens or entities. If a cross-chain bridge swap involves tokens or addresses that are on the bridge’s blocklist, the transaction will be blocked.
     
  • Exceeded minimum/maximum cross-chain amount: Bridges often have minimum and maximum limits for the amounts that can be swapped across chains. The transaction will fail if the amount of tokens being swapped does not fall within these specified limits.
     
  • Insufficient liquidity on the bridge: Liquidity refers to the availability of assets in the bridge’s liquidity pools needed to complete the swap. If the bridge does not have enough liquidity to cover the amount of tokens being swapped, the transaction cannot proceed. This can happen if the liquidity pool is depleted or if there is an imbalance between the source and destination assets in the bridge.
     
  • The cross-bridge transaction timed out: A timeout occurs when a transaction takes too long to process, leading to its failure. This can happen if there are delays in the bridge’s mechanism for moving assets between chains or if there are network congestion issues.

Cross-chain refunds

When swapping with OKX DEX in Tangem Express and the transaction fails, you can get a refund. Refunds occur when a transaction initiated fails at any point, and the user needs to get their assets back. These refunds can be triggered for any of the reasons mentioned above.

If the problem occurs with a source-chain swap or the cross-bridge transaction, the user will receive their source token back, and it's likely that the transaction fee will not even be deducted. 

However, if the destination-chain swap fails, the user will receive their funds in the intermediate token that was used for the bridge. These tokens usually include popular options such as USDT, USDC, DAI, WETH, and ETH.

FAQ

What is the difference between an on-chain swap and a cross-chain swap?
An on-chain swap involves converting cryptocurrencies within the same blockchain network, where both the sending and receiving tokens are on this network. In contrast, a cross-chain swap involves converting assets across different blockchain networks, where the token you send is on one network, and the token you receive is on another.

Why do swaps fail?
During network congestion, gas fees may increase significantly. Miners prioritize transactions with higher gas fees, so a transaction can fail if it isn't picked up promptly. Using the platform's recommended default gas fees when initiating a transaction is advisable.

Liquidity depths can fluctuate in volatile markets. If the trading amount falls below the required minimum, the contract may halt the transaction, leading to failure due to excessive slippage.
Also, if a user initiates multiple identical transactions simultaneously but only has enough balance for the first transaction, subsequent transactions will fail.

Do I still need to pay network fees after a transaction fails?
Yes, network fees are required even if a transaction fails. Network fees compensate miners or validators for processing the transaction, as they consume network resources regardless of the transaction's success.