Submarine Swaps are atomic on-chain to off-chain swaps (and vice versa) of cryptocurrencies.
This was made possible (and put into production) by Alex Bosworth. Olaoluwa Osuntokun originally coined the term Submarine Swap—one half is above water (on-chain), one half is below water (off-chain).
Lightning Labs has released Loop, a submarine swap service that plugs into LND. The client is open source but the server is proprietary—to perform a swap, you have to perform it with Lightning Labs.
Alex Bosworth released an early demo of submarine swaps using fully open-source code:
Boltz Exchange has also open-sourced an implementation that is also compatible with Litecoin LN:
Transactions between on-chain blockchain addresses and off-chain Lightning addresses are not directly compatible. This creates a transaction barrier between the underlying blockchain and the off-chain Lightning Network, regardless of implementation.
Submarine swaps solve this issue by enabling Lightning channels to be refilled via an on-chain transfer from the underlying blockchain to the off-chain LN channel.
A submarine swap essentially looks like this:
Alice produces or retrieves a Lightning Network payment invoice. It doesn't matter whether the Lightning payment is to Alice or to someone else that Alice is trying to pay.
Alice presents the Lightning invoice to Bob, a "submarine swap provider".
Bob quotes what he must be paid on chain in order to pay the Lightning invoice off-chain.
If Alice accepts the exchange rate, Bob and Alice work together and construct an HTLC that creates a conditional on-chain payment to Bob.
Alice makes the conditional payment to Bob.
The conditional payment to Bob is hashlocked with the same secret that will be revealed if the Lightning invoice is paid. Bob can only redeem the conditional payment from Alice by making the Lightning payment.
Bob pays the Lightning invoice, forcing the Lightning payment recipient to reveal the secret S.
Bob uses the secret S to redeem the conditional payment from Alice.
If Bob does not pay the Lightning invoice before it expires, Bob is not able to redeem the conditional payment from Alice. In this case, Alice can wait for the HTLC to expire, then redeem the conditional payment's funds back to herself.
What do submarine swaps allow you to do?
trustlessly pay someone on-chain to perform an off-chain payment for you
trustlessly pay someone on-chain to buy coins on the Lightning Network from them
This means that a user can make Lightning Network payments without being on the Lightning Network, rebalance their Lightning Network channels with a fast and low-cost payment on another chain, and perform fast trustless swaps where the usual slow step is made instant.
Submarine conditional swaps have been demonstrated on the Bitcoin and Litecoin Lightning Networks, using on-chain payments on Bitcoin, Litecoin, and BCH. They should also be possible (albeit with more steps) using on-chain payments on other Bitcoin derivatives, Ethereum, Stellar, Ripple, and more.