Atomic Swaps

From CryptoWiki

Basics

  • An Atomic swap is a smart contract technology that enables exchange of one cryptocurrency for another without using centralized intermediaries, such as exchanges. ... They first came into prominence in September 2017, when an atomic swap between Bitcoin and Litecoin was conducted.
  • From this presentation by REN (11-5-2020):

"Great for exchanging two assets, as long as you already know who you are going to exchange the assets with, you already know what assets you are working with and you already know the price and you are okay with either party being able to cancel the swap at any point. Therefor it is a pretty limited use case, and it has had limited adoption. They do not work for general applications and also not for actually every single blockchain either."

Why are they important? And what is the downside?

"Why are atomic swaps important?

Today, most centralized exchanges force traders to transfer cryptocurrencies via a wallet that is being controlled and hosted by a centralized exchange. This is known as a “hot wallet.” What does this really mean?  Well, traders do not control their private key for hot wallets. So, this places their investment at the mercy of exchanges. This means atomic swap trades hold several advantages over centralized exchange trades, such as: 

  • Truly decentralized:

Atomic swaps are truly decentralized, allowing cryptocurrency traders to exchange digital assets without the need for third-party arbitration, with no counterparty risk.

  • Mitigate investor risk:

Atomic swaps also leave cryptocurrency holders in complete control of their cryptocurrency at all times, eliminating the hacking risk presented by centralized exchanges. 

  • Reduced trading fees:

The only fees associated with atomic swaps are standard blockchain transaction fees, making atomic swaps a fee-free trading method.

What is the downside to an atomic swap?

Atomic swap trades are limited by liquidity. This means that without an exchange platform it can be difficult for traders to communicate and exchange cryptocurrencies. However, recent developments with atomic swap technology have resulted in the prolific increase in decentralized exchanges. Decentralized exchanges are combatting this issue through matching orders between traders using atomic swaps."

How do atomic swaps work?

  • From this post on Forbes:

"Atomic swaps use a specific type of smart contract called a hash timelock contract (HTCL)
This can be thought of like a “virtual lockbox” requiring two special keys:

  1. A HashLock key:

That only distributes traded cryptocurrency to traders when all parties have signed off on their respective transactions.

  1. A TimeLock key:

A safety mechanism that returns traded cryptocurrency to traders if the trade is not completed within a specified time period. To open an atomic swap, the first party will create an HTCL address who will then deposit a cryptocurrency. After that, a secret passcode for this cryptocurrency is created. This is called a preimage. which is subsequently hashed (a process that “locks” the preimage).  This hashed preimage is then forwarded to a second party, who verifies that the capital for the cryptocurrency has been deposited. A second trader will then deposit their trade capital into a new address, which has been created with the same hash.  The first party unlocks the trade capital deposited by the second party with a secret passcode used to deposit the initial trade capital. The second party can then unlock the trade capital deposited by the first party. Meaning, that an atomic swap has been processed."