Atomic Swap

 

 

Atomic Swaps are decentralized and trustless trades between two users of different cryptocurrencies. That technology is relatively new and is aimed to make a revolution in the transactions.

Atomic Swaps Review

As the blockchains are not related and transactions cannot be reversed, this provides no protection against one of the party never honoring their end of the trade. One common solution to this problem is to introduce a mutually-trusted third party for the escrow, however this represents a scalability and privacy problem. It also does not offer any protection against collusion. Atomic swaps solve this problem without the need for a third party by using timed smart-contracts on both chains.

Atomic swaps involve each paying party into a contract transaction, one contract for each blockchain. The contracts contain an output that is spendable by either party, but the rules required for redemption are different for each party involved. One party (called counterparty 1 or the initiator) generates a secret key and sends the intended trade amount into a smart-contract. The second party (called counterparty2 or the participant) can only redeem the funds by knowing the secret key. If a pre-determined period of time (typically 48 hours) expires after the smart-contract transaction has been mined or staked and the funds have not been redeemed by the participant, the funds can be refunded back to the initiator’s wallet.

For simplicity, we assume the initiator wishes to trade Particl for Decred with the participant. The initiator can also trade Decred for Particl and the steps will be the same, but with each step performed on the other blockchain. At this point, the participant is unable to claim the funds from the initiator’s Particl smart-contract because the secret key is unknown by him. If the initiator revealed his secret key at this moment, the participant could claim the funds from the contract without ever honoring his end of the trade, leaving the initiator at a loss.

To avoid this, the participant creates a similar smart-contract but on the Decred blockchain and sends the intended Decred amount into it. However, for the initiator to redeem the output, their own secret key must be revealed to the participant. To create their smart contract for the participant, the initiator must reveal not the secret key (since the participant could stil claim funds and not honor their end of the deal), but a cryptographic hash of the secret key to the participant so that the smart-contract can be properly deployed. The participant’s contract can equally be refunded after a pre-determined period of time. The initiator then redeems the participant’s Decred funds by revealing the secret key to the participant’s smart-contract. The secret key is then extracted from the initiator’s redeeming Decred transaction providing the participant with the ability to redeem the initiator’s Particl contract.

This procedure is atomic (with timeout) as it gives each party at least 24 hours to redeem their coins on the other blockchain before a refund can be performed. This is the best option for people requiring privacy, and is also probably going to be the cheapest to use.

Decentralized exchanges

There are alternatives to centralized exchanges which are called DEXs or decentralized exchanges. The structure of such platforms allows users retain ownership of their atomic swap coins with their private keys. That method allows preventing the cryptocurrencies from being accumulated in one centralized place of attack.

There is a high demand for DEXs and it is constantly growing. The Radar Relay exchange, for example, exceeded $1 million in volume over a 24 hour period for the first time in the beginning of January. However, that type of exchanges is also no unlimited. They have liquidity and are front running. How do the DEXs work? Their work is built in the way when people set and take orders individually. The orders exist on separate order books, and these books are hosted independently of one another. Those orders which are placed on one book can not appear on another. Unfortunately, that causes the lack of liquidity for users. For that reason, users must look at several different books to place an order.

How to solve that problem? It can be solved via the “Liquidity Network”. That’s a process meaning that different order books use an API for sharing their orders with each other. This way orders flow between “relayers” and provide the necessary liquidity within the network. As it was stated above, decentralized exchanges are front running. Front running is the concept meaning people can outbid and order placed on a DEX. Lots of DEXs which run on Ethereum rely on smart contracts. However, that causes problem, while the network is a public blockchain and anyone can check the memory pool to see who wants to take an order.

A former Google Software Engineer Ivan Bogatyy suggested to the Bancorteam in his blog to implement a minimum return on trades effectively cancelling the order as soon as the user realizes someone is trying to cut in front of them. He suggested one more solution to set a maximum gas price for people to bid higher than the limit. These solutions are short-term. It will not prevent from front running but will cut a user’s losses. One more possible solution is a “Commit-Reveal Scheme” by Will Warren, the co-founder of the 0x project (an open protocol for the DEXs). What does it mean? A trader secretly commits his funds with a transaction but doesn’t reveal it. As soon as the transaction is mined, a second one is sent with all the details, executing the order on the decentralized exchange. This method is not perfect too, while accidental collisions can still arise when two of the same orders are placed at a time, for example.

Technology

Lightning Network announced the 1st bets release for Mainnet on both Bitcoin and Litecoin on the 15th of March, 2018. Atomic Swaps is the most anticipated app of the LN. Atomic Swaps is the “all or nothing” exchange of one cryptocurrency for another (BTC/LTC, for example). The LN isn’t necessary, but it would make atomic swaps private, instantaneous, and fee-less comparing to mining.

Taking into account the liquidity, the LN might face an issue of fund and channel availability. The network nature demands users to create channels of payments via multisigs, meaning that a user can get on the LN channel only when he has something to spend. The intermediaries can route payments only in case they have a certain amount of funds. The solution can be the same as with the DEXs. The transactions can be routed and shared between nodes which have enough funds and channels for performing the swap. It might not be the best solution as for now, while the LN is at its early development stage, but with its growth it will be a good solution.

Atomic swaps use the Hash Time Locked Contracts technique or HTLC. When both currencies are submitted into these contracts, HTLCs ensure the amount being exchanged can’t be outbid when they can be on DEXs, so there is no “accidental collision” danger.

Atomic Swap Coins

Let’s say you want to exchange your Litecoin for Bitcoin, you would need to find someone on the LN to exchange with. Respective coins are committed to the swap. They are routed via other nodes if you need other connection points and don’t wish to pay for fees to create two payment channels. So, the exchange is guaranteed.
For preventing bad actors from cheating or stealing other people funds, there are severe punishing contracts.

Coins

Atomic swaps allow the members of the crypto community to trade across various blockchains in a safe way, at high speed and with minimal fees. You can convert atomic swap Altcoins, including atomic swap Litecoin, atomic swap Bitcoin, and the full list of the coins possible to convert is as follows:

Atomic swaps and taxes

The commission for a transaction should be paid twice.

External links

See Also

Sources