The nature of Web3 is ephemeral: as with most new technologies, things move fast. A chain favored among memecoin enthusiasts might dry up overnight because of a security exploit. A new chain might emerge, supporting use cases not yet imagined. If you want to keep pace with these changes and experiment with dynamic, new blockchains, you’re probably going to need to make a cross-chain swap, here and there.
Sure, cross-chain swaps are pretty easy through a centralized exchange, but let’s say that something crazy just happened, like, say, the head of your preferred centralized exchange gave the treasury to his special friend, who proceeded to gamble it all away. I know, it’s a far-fetched premise, but stick with us here: instead of going through a centralized exchange, why not use a cross-chain swap on DeFi?
What is a cross-chain swap?
If you're already familiar with how a cross-chain bridge works, it's not a far leap to imagine a cross-chain swap. In brief, a bridge works like this: it takes a deposit of native tokens on Chain A, verifies that deposit, and mints a corresponding number of wrapped tokens on Chain B.
One of the uses of cross-chain bridging is a cross-chain swap: trading a token issued on Chain A for a token that is issued on Chain B – all via the decentralized web. A cross-chain swap works like this: you find a bridge that connects Chain A and Chain B, deposit your Chain A tokens and send a wrapped version of them to the destination chain where your desired token lives. Then, you swap the wrapped tokens via a DEX on the destination.
This is the flow for most cross-chain bridges, including Axelar’s Satellite bridge work. But as we’ve mentioned in our post about cross-chain bridges, they can be a useful method for moving assets to another network, but they come with a whole host of drawbacks that might give you pause. In addition, there’s the problem of cross-chain liquidity. As a developer, if you want to solve this problem for your user, you need a cross-chain liquidity router. Otherwise, user experience looks like this:
Cross-chain swap user experience
Let’s say Alice wants to swap an asset on Chain A for an asset on Chain B, and she doesn’t want to go through a centralized exchange. Without liquidity routing, this cross-chain swap requires at least three separate operations, and some of them can be frustratingly complex, depending what tokens and wallets Alice already has.
If, as in the example in the introduction, Chain B is a new chain that Alice is trying to explore, the process can be frustratingly complex.
First, Alice has to find a DEX on Chain B that has liquidity for the pair she wants to swap. This will be a pair between the bridged version of the Chain A asset and the native version of the Chain B asset. (Axelar provides a list of pools for this.) If this doesn’t exist, Alice is out of luck – or, she has to do an additional swap, to get into an asset that has a liquid pair with the desired asset on Chain B.
Before Alice can get to the final step, she'll need to make sure she has two things: a Chain B wallet and enough of the Chain B gas token to pay the transaction fee for the swap.
Once Alice finds liquidity and has wallets and gas tokens set up on both chains, she heads to a bridge that links the two chains, connects her Chain A wallet, and initiates the bridge to Chain B.
Alice initiates the swap on the Chain B DEX and breathes a sigh of relief.
Automating cross-chain swaps for the user
What if there was a more efficient way of doing things between blockchain networks, would that be something Alice might be interested in?
The key to cross-chain swaps lies in General Message Passing (GMP) technology. As we explained in this blog post, GMP is the engine driving a goal of a permissionless internet of blockchains: with GMP, not only wrapped assets, but logic can move securely cross-chain. This means users can execute cross-chain swaps end-to-end, with a single click, without having to leave the UI of a cross-chain DEX.
This development is at the heart of applications like Squid, a project that enables cross-chain swaps through cross-chain liquidity routing. Unlike most conventional bridges, which depend on liquidity pooled in the bridge itself (a massive target for bad actors, as explained in our post about bridges), Squid operates by leveraging the liquidity stores of USDC, routing all swaps through USDC. It's a natural choice given that the stablecoin has a presence on every blockchain network. This is a similar concept to what Polygon has planned to do with Supernets: an infrastructure development that allows developers to create interconnected layer-1 networks and applications through the underlying Polygon Network.
There is another key piece of infrastructure, here: cross-chain gas services. Without these, it would be necessary for users of a cross-chain swap to maintain wallets on both connected chains, holding each chain's native gas token for payment at both ends of the transaction. Cross-chain gas services handle the conversion of source-chain tokens into both AXL, for paying fees to Axelar validators, and the destination-chain token, for paying required gas there.
Who is building cross-chain swaps?
Indeed, the mission of one-click interconnectivity has spread throughout the entire crypto space. For example, Cosmos-based automated market maker (AMM) Osmosis is using this idea to bring their vision of an internet of blockchains to fruition. As they explain in a medium post, Osmosis’ didn't want its utility as a DEX for cross-chain swaps to be limited to the Cosmos ecosystem. With General Message Passing, Osmosis will be able to take its cross-chain swaps between the Cosmos and the greater internet of blockchains with a simple, one-click user experience, and decentralization that provides unparalleled security.
In another Medium post, Osmosis points out that, alongside their back-end, they bring something else to the equation: massive amounts of pre-funded liquidity. Moving forward, the plan is to move beyond mere cross-chain swaps and usher in a new era of Web3, including cross-chain lending, frictionless NFT marketplaces across networks, and eventually, a fully interoperable internet of blockchains.
But for now, with projects like Osmosis and Squid, cross-chain swaps are about to get so easy, it's probably going to lead to another, more immediate problem: how to calculate your cross-chain taxes.