Submarine swaps are atomic on-chain to off-chain swaps (and vice-versa) of cryptocurrencies. Conceptualized by Lightning Labs CTO Olaoluwa Osuntokun and Lightning Labs Infrastructure Lead Alex Bosworth, they are designed to facilitate the transfer from on-chain BTC to an off-chain Lightning Network (LN) channel. Currently, this is not directly possible without submarine swaps and requires an additional step where a user has to transfer LN funds to their on-chain Bitcoin wallet.
Described as “on-chain ramps to the LN,” submarine swaps have several profound use cases and potential implications. Unlike atomic swaps — where LN needs to be enabled on both cryptocurrencies participating in an exchange — submarine swaps only need one side to be lightning enabled. As such, the future application of submarine swaps could see them becoming a vital infrastructure for decentralized exchange across various blockchains.
How Do They Work?
The primary problem that submarine swaps address is that transactions between on-chain Bitcoin addresses and off-chain LN addresses are not directly compatible. This creates a transaction barrier between the Bitcoin blockchain and the off-chain LN.
An additional limitation of the current LN implementation is that setting up an LN channel requires an on-chain transaction (and subsequent fee) as well as a prefilled amount of BTC sent to the channel. Once that supply of BTC in the channel runs out, there is no method to refill the channel, and another channel needs to be opened. This costs more on-chain transaction fees, and although essentially unlimited transactions can be sent within an LN channel as long as there is enough BTC, it is inconvenient and inefficient to repeatedly open multiple channels.
Read: Lightning Network: the 2nd Layer, Off-Chain Scaling for Bitcoin
Submarine swaps provide a solution to this problem by allowing LN channels to be refilled through an on-chain transfer from the Bitcoin blockchain to the off-chain LN channel. Submarine swaps are derived from atomic swaps so they work with similar functionality.
Submarine and atomic swaps utilize a trustless intermediary for transferring tokens between blockchains or intra-chain (i.e., Bitcoin on-chain to off-chain LN). This is accomplished by leveraging hash-time locked contracts where the receiver of a transaction needs to acknowledge receiving the payment before a specific deadline by providing a cryptographic proof of payment. If not, the receiver forfeits the ability to claim the tokens, and they are returned to the payer.
Read: What Are Atomic Swaps?
The best example of how this works in a submarine swap is from a transfer from the Bitcoin blockchain to an off-chain LN channel, which is currently the one-way functionality of submarine swaps that is live. Submarine swaps employ a “swap provider” as the trustless intermediary.
A user sends their on-chain BTC to the submarine swap service contract with an LN invoice, where the swap provider pays the off-chain LN invoice. If the invoice is not paid within the specific hash time-locked contract, then the payer (on-chain address) can reclaim the initial on-chain BTC sent. The preimage in the swap contract is used by the swap provider as proof of payment to claim the on-chain BTC at the swap address. The swap provider will not know the preimage unless the LN invoice is paid. The result is that the funds are reimbursed to the payer if the invoice is not completed. If it is successful, then the LN channel is funded with the amount corresponding to the on-chain BTC sent.
The process works the same way for an inverse transaction from an off-chain LN channel to an on-chain Bitcoin address. However, this functionality is still in development and is not an available option on the submarine swaps contract yet.
Insufficient liquidity may be a potential problem for submarine swaps, particularly in its early stages. However, the swap rate provides an incentive for on-chain users to front their BTC for swap transactions, earning a fee for doing so rather than letting it sit in their wallet. Swap providers can technically even be the payer in a transaction, making the swap process very flexible.
Application, Further Development, and Future Implications
Submarine swaps provide an effective tool for the previously mentioned problem of refilling LN channels without having to open new channels continually. At first glance, this is the most practical use case in its current iteration. However, due to the nature of submarine swaps only needing one side of the transfer to be LN enabled, submarine swaps are capable of facilitating cross-chain transfers with chains that aren’t LN enabled, as long as the opposing side is LN enabled.
Submarine swaps between different blockchains have already been successfully attempted. Developer Jason Wong successfully forked the submarine swap project and built-out the functionality to achieve an on-chain Litecoin swap to off-chain Bitcoin LN. The swap from…