submarine swaps

2021-12-12 · 3 min read

Problem #

Crucial for UX that there is no distinction b/w on-chain BTC and off-chain LN capacity. Transfers b/w on-chain BTC and off-chain LN wallets should also happen in one step and with minimal fees. Without submarine swaps you need an intermediate step where you first transfer LN funds to an on-chain BTC wallet, then pay the BTC. Another way to look at BTC -> LN is for topping up an existing LN channel (note you can't increase the total channel capacity, just fill your inbound/outbound side sending/receiving on-chain BTC)

Submarine Swaps claim to solve this problem.

Define #

Submarine swaps transfer funds between the base-layer chain and the second-layer Lightning Network through (paid) intermediaries — importantly — without trust. In effect, Submarine Swaps can bridge users’ on-chain and off-chain balances. Source

Submarine swaps are atomic on-chain to off-chain swaps (and vice-versa) of cryptocurrencies. Source

Submarine swaps rely on a trustless intermediary or "swap provider".

Protocol #

on-chain BTC -> off-chain LN channel

  1. User sends on-chain BTC contract + LN invoice to the swap provider.

    This swap contract is an HTLC; if the swap provider fails to execute in time, the user can reclaim their funds.

  2. 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.

  3. If successful, the off-chain LN channel will be filled with the corresponding amount and the swap provider can claim the funds in the HTLC.

Misc #

Actually execute a swap (0.20% fee as of 2021/12/12): https://submarineswaps.org/

See src for swaps service: https://github.com/submarineswaps/swaps-service

Breez uses Submarine Swaps to move on-chain bitcoin directly to the user’s Lightning node without the need to send the funds to a local bitcoin wallet first. As a result, users only see and manage their Lightning balance without a need to manage a separate on-chain balance.

Can execute Submarine Swaps across chains : 0 (i.e., spend on-chain ETH to fill off-chain LN channel)

Added privacy benefit: with a submarine swap, you effectively wash the BTC and receive uncorrelated Lightning.