An atomic swap, is a type of cryptocurrency exchange that occurs in a decentralized way and without the need for intermediaries in the process.
Los atomic swaps or atomic exchanges, refer to a type of exchange between cryptocurrencies, where there is no need to trust a third party. Throughout the process, users maintain full control of their funds and private keys. With this new technology, the aim is to make it easier for users to exchange without intermediaries
of different cryptocurrencies.
An example of the use of this technology would be the following:
Example: How does an Atomic Swap work?
Miguel has 5 ETH in his possession, but he wants to exchange them for BTC. However, Miguel does not want to use a traditional exchange service, in which he must relinquish control of his cryptocurrencies, since he will have to make a prior deposit to make the currency exchange. To deal with this, you decide to use a Atomic Swap. With this service, Miguel announces that he wants to exchange his ethers for the equivalent in bitcoins. That's where Miguel's order is published and another user, for example Daniela, sees it. Daniela has BTC and wants ETH, that's why she accepts the order that Miguel has published and the exchange process begins jointly and simultaneously, that is, the coins they move from one direction to another at a time.
To facilitate this process, the so-called Limited Time Hash Contract (HTTC). This ensures that each party receives their funds seamlessly.
Next, Miguel sends his ETH to an address indicated by the platform, while Daniela does the same with her BTC. Once both transactions are made and verified on their respective blockchain, Miguel and Daniela generate a cryptographic proof (hash). This test confirms the completion of such transactions. With this, the platform ensures that both parties have complied with the shipment of their cryptocurrencies, in the stipulated time and amount.
Once all the verifications have been completed, the process is finished and by then, Miguel will have his BTC and Daniela his ETH.
HTLC, the core of the functioning of the Atomic Swaps
HTLCs are the basic technology for the operation of atomic swaps and the guarantee of their operation. A HTLC or Limited Time Hash Contract it's just a Smart contract that manages a payment channel. These channels make use of blockchain properties hashlocks y timelocks. Through them, the recipient of a payment is asked to acknowledge having received it before a deadline. To do this, you must generate a cryptographic proof of payment or, otherwise, you will lose the ability to claim it, with which the amount will be returned to the payer.
The receiver generated cryptographic proof of payment can be used to trigger different actions on other payments. This makes HTLC a powerful technique for producing conditional payments in Bitcoin or others cryptocurrencies, with such capacity.
In addition to this, HTLCs have the ability to produce interactions on-chain (within the blockchain) u off-chain (outside the blockchain). This allows the Transactions performed by the parties participating in an HTLC are much faster and less expensive.
Types of Atomic Swaps
On-chain
This type of exchange is what occur directly in de la blockchain of each of the cryptocurrencies that intervene in it. That is, they are transactions that are carried out and verified by the cryptocurrency blockchain. Due to this, the process of these transactions is usually more slow, since network verification is required to be able to validate them within the atomic swaps platform. However, this process makes them safer and more suitable for high value exchanges.
Example: Atomic Swaps on-chain
Sofia wants to make a 100 BTC exchange for Litecoin. To do this, go to the website of the atomic swap platform of your choice and announce your exchange. Luis accepts the exchange and together they begin the process. The atomic swap platform raises the HTLC on-chain and records each transaction. However, to validate it, you must wait for the transactions made by Sofía and Luis to be validated on their respective blockchain. This means that Luis will see a quick confirmation from him, but Sofia will have to wait much longer. Only once both sides are confirmed will the exchange be complete.
Off-chain
These exchanges are what occur in channels fuera de la chain or blockchain of each cryptocurrency. They are generally performed on platforms Layer 2 (Layer 2) as Lightning Network o Liquidity Network. The purpose making changes under these systems is accelerate el process de exchange. This, then, allows these to be practically snapshots. All this without any of the parties losing total control over it.
Example: Atomic Swaps off-chain
Matías wants to exchange 0,5 BTC for Litecoin. David accepts the swap, but in this case they will use the atomic swap off-chain option. To make payments, they will use Lightning Network. With this, both parties guarantee the corresponding payment in cryptocurrencies to the other party immediately. The process of using HTLC is the same, all in order to ensure the process and that both parties receive what is fair. Once both parties have completed the transactions, the exchange is terminated.
Advantages and disadvantages
Advantages
- Atomic swaps allow one way traditional transparent y commitment de exchanges. All this thanks to the fact that the intervention of third parties in the process is not necessary.
- Allow mayores niveles de fullfilment of security requirements in exchanges and in the handling of users' cryptocurrencies or tokens. Firstly, the theft of cryptocurrencies or tokens due to a malicious attack on the service is ineffective. This is because the user's funds are not in the atomic swap service, but in his personal wallet. In this way, it is guaranteed that a malicious attack will not mean the theft of funds, a fairly common situation. Examples of these are the robberies that happened in Binance, Cryptopia or Mt. Gox.
- They allow the interoperability between different cryptocurrencies, . This by allowing users to interact with each other much more easily and directly.
Disadvantages
- The use of atomic swaps is limited a cryptocurrencies, able to use HTML. If one of the exchange cryptocurrencies lacks this functionality, it cannot be performed. This is because HTLC is the one that guarantees compliance with obligations and if the networks of the currencies involved do not allow HTLC to be implemented, the Atomic Swap platform cannot carry out that specific exchange.
- All the platforms Aun are en development and your options are limited in scope. In addition to this, its community is still small, which limits the capacity and supply of exchange.