Stakenet’s vision: Part IV — Atomic vs Lightning swaps

Hydranet Team
Stakenet
Published in
4 min readApr 27, 2021

In the previous article, we discussed the Lightning Network and explained why we believe it to be the best scaling solution for Bitcoin and other coins. In this article we will go into more detail on how the Lightning Network allows decentralised exchanges, which have seen a surge in interest and adoption throughout 2020 and 2021, in providing high-frequency cross-chain trading on a massive scale. To elaborate, we must first explain the difference between Lightning atomic swaps and traditional atomic swaps, which is the technology behind current DEXs.

What are Atomic Swaps (on-chain swaps)?

In simple terms, an atomic swap is a way to exchange different cryptocurrencies trustlessly. Atomic swaps provide a proper decentralised means of exchanging different assets through the use of Hashed Timelock Contracts (HTLCs for short) and multisig addresses. This differs from your traditional CEX, where one centralised intermediary (the exchange) holds all coins in their custody and executes the trades themselves on their private servers. With an atomic swap DEX, they utilize smart contract technology between two blockchains to effectively achieve the same result but without requiring a user to give up ownership of their funds.

Atomic swaps are secure. The coins held by either party in a trade, only “swap” when the conditions of the original trade are met (e.g. Bob agrees to exchange 1 BTC to Alice for 32 ETH). If either Bob or Alice fail to honor their end of the trade, the transaction will not complete. This, in essence, is what makes atomic swaps trustless and what makes a decentralised exchange truly decentralised.

This is not completely without its own downsides. Traditional atomic swaps require hashed timelock contracts for every trade, and these HTLCs must record every transaction on two blockchains simultaneously. Since they are strictly on-chain, this leads to potentially long confirmation time waits (several minutes to even days) before trades are successfully executed. On-chain confirmation wait times are accompanied by on-chain fees that are wildly volatile and potentially very expensive. Read more about fees here.

DEXs that use traditional atomic swaps reflect the same scaling troubles that Bitcoin and Ethereum have seen in more recent years. Arguably, increased use and reliance on traditional atomic swaps will only enhance scaling troubles that major cryptocurrencies presently face, as it spams and congests blockchains that weren’t designed with high-frequency HTLCs in mind.

This is exhibited quite clearly by the volatility of gas fees and swap times on ERC-based DEXs like Uniswap v2, which grew in popularity and adoption until the flood of trades on the DEX congested Ethereum’s blockchain and pushed its network to its upper limits.

And what are Lightning Swaps (off-chain swaps)?

Atomic swap technology was first combined with the Lightning Network in August 2018, enabling the execution of “Lightning Swaps”, an instant and almost feeless cross-chain trade. To operate, they utilize Lightning nodes to check transactions between two separate chains and ensure a foundation of validity for transactions.

To achieve this, a Lightning “payment channel” is created with a one time on-chain transaction, with traditional fees and confirmation wait times. Once this payment channel is opened, one is capable of executing a theoretically infinite number of off-chain trades from it.

Off-chain Lightning channels make Bitcoin transfers instant and fees consistently low no matter what price Bitcoin is or how congested its blockchain is, and they will allow decentralised exchanges to scale in much the same way.

Off-chain trades cannot be tracked in any block explorer — increasing the user’s privacy enormously. The lightning swap, similar to a regular atomic swap, is then executed via a type of smart contract. These transactions are the most efficient solution to Bitcoin and Ethereum’s scaling problem, and opens the way for mass adoption without being limited by the on-chain throughput or compromising security.

Layer 3 DEXs are capable of bridging multiple off-chain scaling solutions together, allowing Bitcoin in a Lightning Network (so-called Lightning Swaps) channel to be swapped into Ethereum, Tether, Chainlink, or Binance Smart Chain from a Connext Network channel with ease and in seconds.

By way of instantaneous swaps, very low fees, and code-agnostic smart contracts, the degree of interoperability between the biggest cryptocurrencies is greatly expanded upon. This allows users to conduct direct P2P transactions within their wallet and achieve a CEX-like experience, all the while never losing custody of their funds or control of their private keys.

As we are connecting different Layer 2 solutions like Lightning Network and Connext Network (in addition to rollup solutions for cheaper Connext onboarding), we are viewed as a Layer 3 DEX solution.

In the next part of this info series, we will talk about how the Stakenet DEX is using all the benefits of the recently discussed scaling solutions and how the user can benefit of it.

Join us on Discord and follow us on Twitter to stay up-to-date with our latest news and developments. Special thanks to the eager Stakenet community members.

--

--