Introducing Interchain Atomic Swap
This post presents Interchain Atomic Swap (IAS), a trustless and decentralized protocol for inter-chain asset swaps using the Inter-Blockchain Communication (IBC) Protocol standard (ICS-100). IAS is an application layer protocol developed by Side Labs and has now officially been merged into IBC.
What is an Atomic Swap?
Atomic swaps are rapidly gaining popularity as they provide a decentralized, secure, and private way of exchanging digital assets across different blockchain networks, without both the need for an intermediary token or pool and the need for a trusted third party.
One of the key advantages of atomic swaps is their atomicity property, which ensures that the entire trade is either executed completely or not at all. This property prevents fraud and cheating, as neither party can partially fulfill their side of the trade. If any part of the trade fails to execute, the entire trade is canceled, and the assets remain in their respective blockchain addresses.
Atomic swaps can only be performed between two compatible blockchain networks that support the same Hash Time-Locked Contracts (HTLC) or similar smart contract functionality. This requires the two blockchain networks to support the same cryptographic hash function and transaction scripting language. However, in cases where blockchain networks do not share compatible smart contract functionality, alternative cross-chain bridge or interoperability protocols may be needed to facilitate the exchange of digital assets between them.
Recent advancements in interoperability protocols, such as the Inter-Blockchain Communication (IBC) protocol within the Cosmos network, have made it possible to perform atomic swaps across multiple blockchain networks.
What is IBC?
According to the IBC-Go documentation:
“The Inter-Blockchain Communication protocol (IBC) is an end-to-end, connection-oriented, stateful protocol for reliable, ordered, and authenticated communication between heterogeneous blockchains arranged in an unknown and dynamic topology”.
The IBC protocol has been designed to be modular, allowing IBC application developers to concentrate on high-level functionality without having to concern themselves with low-level details such as clients, connections, and proof verification. This allows them to develop applications in a more efficient and streamlined manner, ultimately reducing development time and costs. By decoupling the application layer from the lower-level transport layer, IBC architecture operates similarly to the TCP/IP protocol utilized in the internet. The modular design of the IBC protocol constitutes a distinctive feature that distinguishes it from other cross-chain messaging protocols. This attribute endows IBC with greater versatility than just a bridge protocol for transferring assets across networks. Indeed, the modular structure enables developers to create an array of inter-chain applications tailored to specific use cases. For instance, ICS-20 facilitates inter-chain fungible token transfers, ICS-27 allows for inter-chain account management, and ICS-28 is used for inter-chain security sharing. Leveraging the modular architecture of IBC, developers can generate potent inter-chain applications that can seamlessly integrate with diverse blockchain networks, thereby expanding the horizons of innovation and collaboration within the decentralized ecosystem.
How does Interchain Atomic Swap Work?
Developed by Side Labs and backed by the IBC Protocol core team, Interchain Atomic Swap (IAS) is a new IBC application (ICS-100) focused on inter-chain asset swaps.
To exchange token X for token Y, a maker creates an order specifying the quantity and price of the exchange, and sends the offered token X to the maker chain’s escrow account. A taker on a different chain that holds token Y can then accept the offer by taking the order and sending the desired amount of token Y to the taker chain’s escrow account. The corresponding token amounts are then transferred to each user’s receiving address by the respective escrow accounts, without requiring the usual IBC transfer.
An order without any takers can be canceled, allowing users to correct any mistakes, such as an incorrect price or taker address. If canceled, the escrowed tokens are refunded.
When making or taking an order, a timeout window is specified in the relayed data packet. If the exchange is not completed within the specified time frame, the escrowed tokens are refunded. This timeout window can be customized to suit the needs of users.
Why do we need Interchain Atomic Swap?
Interchain Atomic Swap (IAS) is designed to be bridgeless, scalable and composable, which are essential attributes in the context of cross-chain interoperability.
ICS-20 (Fungible Token Transfer) is widely recognized as the most secure bridging technology for transferring assets across different networks. It operates on a lock-mint mechanism, which allows for the safe transfer of value from native tokens to voucher tokens. IAS provides an alternative solution that is bridgeless, meaning that it does not require the use of a centralized intermediary or bridge to execute cross-chain transactions. Furthermore, the IAS process enhances user experience by eliminating the need for lock-mint mechanisms when exchanging assets between blockchains. Additionally, it provides a fault isolation solution that mitigates the impact of malicious attacks on synthetic assets, also known as voucher assets, by limiting their scope of damage.
Scalability is achieved through the use of a modular architecture, which allows for the implementation of IAS functionality in a variety of blockchain environments. This design approach facilitates easy integration of the protocol into existing blockchains with minimal modifications to their underlying architecture. At present, IBC connects to 53 chains, and it is projected that in the next few years, hundreds and thousands of individual chains will be connected via IBC. This expanding network provides opportunities for integration of IAS with all chains, enhancing the interoperability of the blockchain ecosystem.
Composability is another important feature of IAS. Composability refers to the ability of IAS to be used in combination with other protocols and smart contracts to achieve more complex inter-chain functionality. For example, IAS can be combined with the Interchain Accounts (ICA) protocol to enable seamless and efficient inter-chain liquid staking architecture without transferring tokens across chains. Similarly, IAS can be combined with other protocols, such as those related to decentralized finance (DeFi), to enable more advanced decentralized applications.
IAS’s features make it an invaluable protocol for fostering inter-chain interoperability and supporting the growth of the interconnected blockchain ecosystem.
What are potential Use Cases?
IAS offers numerous benefits for decentralized exchanges (DEXes). By leveraging IAS, developers can create a variety of DEX types, including but not limited to inter-chain orderbooks, inter-chain peer-to-peer OTC marketplaces, inter-chain shield swaps with high-level on-chain privacy, inter-chain stablecoin swaps, and more.
The exchange of inter-chain assets is the primary use case of IAS, as described above. However, the potential of this protocol extends beyond just inter-chain asset exchange. There are two other promising use cases of IAS, namely inter-chain liquid staking and payment channels, that warrant further research and exploration.
Inter-chain Liquid Staking: Inter-chain liquid staking involves staking assets from one blockchain on another blockchain, allowing users to participate in staking activities across multiple networks without the need for a direct connection to each network. Currently, most liquid staking mechanisms rely on a combination of ICA (ICS-27) and Transfer (ICS-20) to facilitate the staking of assets across different blockchains. For instance, when liquid staking ATOM with Chain A, users are required to transfer their ATOM tokens from Cosmos Hub to Chain A, which then sends ibc/ATOM back to its ICA on Cosmos Hub. While this process has been functional, it can be further improved to provide a more secure and seamless user experience by incorporating IAS into the architecture. By replacing IBC Transfer (ICS-20) with IAS, the liquid staking process can be significantly enhanced in terms of security and user experience. With IAS, users can stake their assets directly without having to move them between different chains, reducing the risk of losing assets in transit. Additionally, the use of IAS enables faster settlement times, thereby increasing the efficiency of the liquid staking process.
Payment Channel: Payment Channels offer a fast and cost-effective way to enable microtransactions between two parties. This can be achieved by opening a cross-chain payment channel using an initial atomic swap transaction, followed by using subsequent atomic swaps to update the balance of the channel without requiring any on-chain transactions. To close the payment channel, the two parties can simply use a final atomic swap to update the balance of the payment channel and distribute the funds to their respective blockchain addresses. Payment channels have significant potential use cases, including high-throughput inter-chain DEXes based on limited order books (LOBs). With the ability to enable fast and cheap microtransactions, payment channels can facilitate a high volume of trades between different blockchains. This can lead to increased throughput and efficiency in inter-chain DEXes, allowing for seamless trading of assets between different blockchain networks. Additionally, payment channels can also enable other use cases, such as inter-chain micropayments for online content, gaming, and digital services. By eliminating the need for on-chain transactions for every payment, payment channels can significantly reduce transaction fees and confirmation times, making microtransactions feasible and cost-effective.
The possibilities enabled by IAS are vast and extend far beyond what has been explored so far. IAS presents an innovative solution with far-reaching implications for a wide array of interchain applications. As this protocol continues to evolve and mature, we eagerly anticipate witnessing the pioneering ways in which the community will harness IAS to create new applications and services.
What’s next?
Interchain Atomic Swap (IAS) is an open source standard. At Side Labs, our team is committed to implementing this open source standard in various ways to cater to diverse user needs, including a native x/IAS module written in Go and IBC-enabled CosmWasm-based smart contracts written in Rust. Moreover, we are continuously working to extend support for EVM-based chains.
We are excited to be part of this evolution and to witness the boundless potential that IAS can unlock. We look forward to exploring the endless possibilities that this technology offers, and to continue contributing to its development and expansion in the years to come. We encourage you to share your ideas and projects with us in our Discord channel, where our developer community can provide support and collaboration.
To delve deeper into the specifics of Interchain Atomic Swap, we recommend visiting IBC Github repository. And if you’re curious about how IAS will be implemented on the Side blockchain, keep an eye out for upcoming updates on our Twitter!
About Side Labs
Side Labs is the core contributor behind the ongoing development of Side Protocol, the open-source interchain explorer Ping Pub, and IBC-based applications, notably ICS-100 and ICS-101. Team at Side Labs comprises a select group of seasoned and highly skilled web3 builders, engineers, and researchers.
References:
https://ibc.cosmos.network/main/ibc/overview.html
https://github.com/cosmos/ibc/tree/main/spec/app/ics-100-atomic-swap