pull down to refresh

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:
  1. The funds can be redeemed by using Bob's signature and the preimage.
  2. 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 sourceTor support
Blink0.30.7πŸ—Έβ˜“
Boltz0.20.4πŸ—ΈπŸ—Έ
Breeze0.75 (2,000 sats min fee)0.5πŸ—ΈπŸ—Έ
coinos0.10.1πŸ—ΈπŸ—Έ
Deezy-0.15πŸ—Έβ˜“
Diamond hands-0.150.2πŸ—Έβ˜“
Electrumβ˜“0.5πŸ—ΈπŸ—Έ
FixedFloat0.5/10.5/1β˜“β˜“
HodlHodl (trade)0.3 + premium0.3 + premiumπŸ—Έβ˜“
LoopVariable (0.1 to 1)Variable (0.1 to 1)πŸ—ΈπŸ—Έ
MuunVariable0.25πŸ—Έβ˜“
myloopoutbot-0.125β˜“πŸ—Έ (telegram over tor)
Phoenix1 (3,000 sats min fee)0πŸ—ΈπŸ—Έ
Robosats (trade)0.025/0.175 + premium0.025/0.175 + premiumπŸ—ΈπŸ—Έ
Robosats (swap)-Variable (from 1 to 10)πŸ—ΈπŸ—Έ
WoS0.50.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.
reply
Thank you!
reply
Dang post image! Image not found!?
reply
wow, very informative. coinos looks very cool. it warms my heart to see so many tools being developed for establishing bitcoin as a mainstream payments system.
ive always had this idea that in the future the lightning network will work best if merchants and people who did a large number of daily transactions (i.e. the ones who get hurt most by fees, you know, the 2.5% that visa charges, run their own lightning nodes so they can save on tx fees first and foremost. can you imagine if wal mart started running their own nodes and channels with lightning even if they are settling in usd. they could legit not only save over 2% on this, they could potentially earn some sats by running large nodes and channels, and it would vastly improve the liquidity on LN . they could basically become their own payments provider and de facto settle payments for others in the meantime. that shit would blow peoples mind, then see what happens when you tell them that sats have NGU technology. FUUUUUUU
reply
Regarding COINOS support and issues:
I was trying to swap in large amounts (~Millions sats) and succeeded in swapping in (transferring to WoS LN destination wallet) for a few transactions, then coinos started failing those repeated large transfer attempts. A problem happened where coinos transfer attempt choked, but showed in the history tab that transfer was successful, but funds were never received on destination LN wallet AND balance in coinos was deducted.
HOWEVER - I emailed the support team support@coinos.io and within just a few hours got a response from Adam (founder) apologizing for the inconvenience and manually resetting my balance. No satoshis lost. Good integrity custodial platform.
Additional Coinos swapout bug - when doing swap outs, if you click the "Gear" icon to adjust mining fee, and scroll the fee bar all the way down and release, if you then try to scroll the fee bar back up to "just see" what the higher fees are, when you release mouse button the swap-out immediately confirms at that fee rate. It's a bug, haven't bothered to tell coinos yet. If you want cheapest mining fee set it low then don't fuck with it just send the tx.
TL;DR - coinos a little buggy but has excellent customer email support for any issues and has really high integrity. Thought I lost funds in an attempted transfer failed, but funds were restored by support same day. Coinos struggles with large repeated swapins. Swapouts are easy.
reply
Great to know that! Thanks for sharing!
reply
Awesome, thx
For which of these do I need an account or an app or some bullshit like this?
I know Boltz simply worked without it last time
reply
The ones that require an account are:
  • coinos
  • hodlhodl
  • blink: requires a phone number
  • breeze: not to use, but the only way to backup the channels is with a Google account
  • deezy: requires an access token which has to be requested by email or telegram so you do need an account
reply
Thanks for this, a couple of nits:
  1. It's Breez, not Breeze
  2. You're not differentiating between submarine swaps (trustless) and trusted swaps (there are trusted solutions on the list).
  3. Breez fee is the same as Boltz for reverse, 0.4%. For swap-in, it's actually channel opening fee, but it's not always required.
reply
Thanks for the feedback! I'm sorry for the typo and for not making the point clear with the fees (rn I'm not sure where I got that Breez charged 0.1 more, perhaps I counted the miner fee as well by mistake).
Regarding trusted and trustless swaps differentiation, you are right. I limited the post to cover the functionality of non-custodial swaps as those are the ones tools like Loop and Boltz use (robosats isn't even a swap service but a P2P exchange that uses HODL invoices for example).
I didn't have enough time to review all the implementations and some of them are closed source, but I included them in the list anyway so everyone has got a picture of how much the market is charging.
reply
Makes sense! Closed source should consider trusted or at least provide a way to validate that the swap is trustless imo.
reply
An excellent and very detailed guide, I saved it for myself.
reply
So all swap ins and swap outs are using submarine swaps? Aren’t there different kinds of swaps?
Also if all swaps require a counterparty, why are some swaps super fast while some take longer? Boltz usually takes longer why swapping into WoS is very fast.
reply
I haven't verified the source code of all these solutions, and some do not even have it open so I can't say they are all using the same logic, but given the properties of the contract it wouldn't make much sense to do it differently.
Regarding the speed of the swap, what some services do is to accept 0 confirmation transactions, that is, you send via lightning and they send you on-chain but the UI shows a successful message immediately and does not wait for the transaction they sent to confirm.
Boltz offers this option when swapping out, Muun offers turbo channels and WoS is likely to be using something similar.
And for swap ins, the user does not create the contract but the service does, and they set the miner fee as well so it's likely that they accept 0 confirmation transactions because they make sure the fee is high enough to be confirmed within the contract time (and they can bump it up if fees increase suddenly).
reply
Bookmarked, thx !
reply
That is just fantastic !
reply
I'm glad you liked it, thanks!
reply
@aftermath I'm having some issue swapping out some liquidity to onchain on a new node #589834 maybe you can help me dive into the various options I'm testing.
I have a channel with Bolts so this swap was pretty straight forward and the fee reflected what was advertised.
I'm now testing coinos and wondering if I should open a private channel with their node too? Considering I've only private channels and my node is running on Tor, I'm now finding it hard to swap funds from my node to the coinos wallet.
any suggestion?
reply
Hi @npub1q67p49masrcjf__d7qaq6mwh0q, sorry for the delayed response.
Indeed, the coinos node it's hard to reach because there aren't many routes to it and the ones that do have liquidity are charging high fees (it seems that there's way more demand for sending sats to it than from it), sometimes making the swap uneconomical.
I think opening a private channel to it is probably the best option, it will require receiving/balancing to that channel to send the funds and coinos will know that you are the one sending the funds, but other than that there's no drawbacks.
An alternative could be opening a public channel, helping others to reach the node and charging a fee for it. The caveat with this last option is that you depend on the coinos node to send funds through your channel to refill the liquidity. May be profitable if the fees are chosen correctly.
reply
I just use boltz and nothing else
reply
this is great but please put a "trusted/custodial" vs "trustless" column. very important in my opinion.
reply
Unfortunately I cannot modify the post anymore. Also, differentiating between trusted and trustless solutions would require to verify the source code of all of them (some are closed source so it's not possible), and that takes way more time than I currently have.
reply
Closed source = trusted. And that includes LL loop.
reply
That's right, I was referring to the swapping implementation itself (if the service has access to the funds at any point in time) but we could definitely consider all closed source services as trusted, regardless of what the code is actually doing.
reply
Also HodlHodl could be used to swap onchain BTC vs LN BTC. Here are my offers where you can swap onchain BTC to LN (my fee is 1%):
reply
deleted by author
reply
deleted by author
reply