Submarine swaps are a specific kind of atomic swap that allow moving sats between layers without counterparty risk.
An atomic swap is a pair of transactions on different systems where one of them cannot happen if the other does not take place as well.
There are two types of swaps:
- Normal swaps, also known as swap in, which is the exchange of coins from on-chain to lightning (π -> β‘οΈ).
- Reverse swaps or swap out, which is the exchange of coins from lightning to on-chain (β‘οΈ -> π).
These operations are typically performed to rebalance channels, move funds to cold storage and to break the link of KYCed sats.
Swapping in practice
Let's see a simplified example of how this works.
Alice and Bob would like to perform a submarine swap. Alice will send funds on-chain (swapping in) and Bob will send funds on lightning (swapping out).
They start by exchanging their public keys with each other. Then, Alice builds a contract to lock the funds with a preimage that she holds and two unlocking conditions:
- The funds can be redeemed by using Bob's signature and the preimage.
- After x blocks, the funds can be redeemed by using Alice's signature.
A preimage is a 32-byte random secret used to settle lightning payments.
Both parties are able to generate and verify this contract.
Alice now creates the on-chain transaction and broadcasts it to lock the coins with the contract, knowing that she will either receive sats via lightning or, if the trade fails, be able to unlock the coins after x blocks.
After the transaction has confirmed, Alice uses the same preimage to create a Lightning Network invoice and shares it with Bob.
Bob can verify the contract and safely pay the invoice because in order for Alice to claim the payment, she has to publicize the preimage, effectively giving Bob the possibility to unlock the on-chain funds from the contract by using the preimage and his signature.
It's important that Bob redeems the funds before the contract allows Alice to redeem the on-chain funds.
Once Alice claims the lightning payment and shares the preimage, Bob takes out the funds from the contract and the trade is complete, none of them had to trust the other at any point in time.
Services comparison
Now, if we want to do this ourselves, there are many services that let you perform this trade with them. Below is a list of the most popular ones and the fees they charge.
Miner/routing fees are not included.
Name | π -> β‘οΈ | β‘οΈ -> π | Open source | Tor support |
---|---|---|---|---|
Blink | 0.3 | 0.7 | πΈ | β |
Boltz | 0.2 | 0.4 | πΈ | πΈ |
Breeze | 0.75 (2,000 sats min fee) | 0.5 | πΈ | πΈ |
coinos | 0.1 | 0.1 | πΈ | πΈ |
Deezy | - | 0.15 | πΈ | β |
Diamond hands | -0.15 | 0.2 | πΈ | β |
Electrum | β | 0.5 | πΈ | πΈ |
FixedFloat | 0.5/1 | 0.5/1 | β | β |
HodlHodl (trade) | 0.3 + premium | 0.3 + premium | πΈ | β |
Loop | Variable (0.1 to 1) | Variable (0.1 to 1) | πΈ | πΈ |
Muun | Variable | 0.25 | πΈ | β |
myloopoutbot | - | 0.125 | β | πΈ (telegram over tor) |
Phoenix | 1 (3,000 sats min fee) | 0 | πΈ | πΈ |
Robosats (trade) | 0.025/0.175 + premium | 0.025/0.175 + premium | πΈ | πΈ |
Robosats (swap) | - | Variable (from 1 to 10) | πΈ | πΈ |
WoS | 0.5 | 0.5 + 26,000 sats | β | β |
ZigZag | - | 3 | πΈ | β |
Important notes
-
In Robosats, the order maker pays a fee of 0.025% and the taker 0.175%. The built-in swap fee can be checked at the coordinator summary. The flow of the trade is not exactly as explained above, but similar in practice.
-
Opening channels in Phoenix is expensive (1% fee) so I would suggest that you set up a big enough one and delay the rebalancing as much as possible. Also, don't forget to disable on-the-fly channel creation since it may open unnecessary channels and charge you 1% for each one opened when the sender can't find a route or he uses MPP.
-
Loop requires to run both a Bitcoin and a Lightning node. The Loop client is open source but the server you do the swap with is proprietary, you have to perform it with Lightning Labs, which charges a fee for it. This fee depends on current on-chain fees and it's represented in satoshis, meaning that the higher the amount you swap, the lower percentage you will pay.There's also a prepayment of 30,000 sats that you have to do before starting the loop out, it's counted towards your swap but will be forfeited if you do not send the rest of the funds. It prevents denial of service attacks and covers the cost of failed swaps. Learn more here.
-
Funds sent to a Muun wallet are forced to be routed through a node with a 2500ppm (0.25%) fee. This attack is called fee siphoning.On the other hand, swapping in is the equivalent of doing two on-chain transactions, since when you deposit funds they are not really in the Lightning Network, you have to send the funds out of the Muun wallet to complete the swap. So in this case the fee is for the miners, and will depend on the network congestion and the amount that you send (higher amount, lower % fee).
-
Deezy requires an access token to swap, must be requested through email or telegram. Swapping in is supported in the API documentation but it's not an option in the UI (only buying channels). The swap out fee can be checked here, no information on how to check the swap in fee.
-
Electrum and Breeze swaps are powered by Boltz. However, they charge 0.1% more than Boltz itself.
-
Diamond hands is a Boltz's fork.
-
Blink is the new name of the Bitcoin Beach Wallet. The first swap out costs 2,000 sats, the rest 0.7%.
Which one is the best?
The answer will depend on your use case and preferences. But in my case, after having tried most of the services, I would lean towards private, non-custodial, fully open-source and inexpensive ones like:
-
Robosats (trade): cheapest way of swapping if the premium is chosen wisely. I have seen orders with premiums above 0.5% (benefiting the maker) which make absolutely no sense and are a waste of their time. A better number would be near 0, allowing both parties to benefit from the trade.Probably in the range of -0.08 to 0 for swap out orders (remember, the on-chain fee is paid by the counterparty) and -0.05 to 0.05 for swap in orders.
-
Loop: swap monitoring, miner and routing fees adjustments. Really affordable when swapping large amounts.
-
Boltz: good reputation, beginner-friendly and simplest solution. Doesn't support Taproot.
There are also other worth mentioning options that do not offer as much privacy as the ones mentioned above, but that are still pretty good:
- coinos: one of the lowest fees, Tor support and extremely simple to create a new account. Custodial, but if you are using it just to swap it doesn't really matter.
- Phoenix: inital setup is expensive but then you enjoy swap outs without fees (apart from miner ones). A really convenient alternative if you are looking to be swapping out multiple times and for an extended period of time.
If you are swapping non-KYC sats, these two are fair pick. However, please take into account that using wallets lowers your privacy and is not recommended for breaking the link of KYCed sats.
This is because all your transactions are performed under the same identity, they store the xpub and all your movements in their databases. Even if the provider doesn't know who is the account owner, it has got information about where the funds came from and where they were sent.
With coinos, you could evade this by creating a new account for every swap.