The Future of Decentralized Trading and Exchanges (Atomic Swaps)

in bitcoin •  7 years ago 

Cryptocurrencies were first created to solve a problem regarding governance and centralization; they were made to ensure that the money system wasn't controlled or inflated by a single entity. Cryptocurrencies returned financial power democratically back to the users.

However, many parts of the system are still centralized, mainly surrounding exchanges and trading. Though a few decentralized exchanges (DEXs) exist, they either only work selectively on some coins, or rely on derivatives such as OPEN.btc that track the value of a coin.

Most of them don't actually swap blockchain coin ownership during trades, and this is quite an important problem to solve. Thankfully, a system exists to solve this conundrum, and is key to the rise of decentralized exchanges. This article will cover cross-chain atomic swaps, and why this technology will allow DEXs to take over.

6361209775984223581480794734_space111 copy.jpg

The Decentralized Exchange (DEX) vs Centralized Exchange (CX)

Decentralized exchanges (often referred to as "DEXs") are exchanges that aren't governed by a single company, person, or entity. This is very similar to how decentralized cryptocurrencies like Bitcoin aren't governed by a single entity. Rather, both of these decentralized systems are governed freely; by the people and the users who use the system.


Centralized exchanges (CXs) are exchanges that we normally use today, from Coinbase to Bittrex to Poloniex. CXs are governed by a single company, and this is why it's risky to trust them with funds.

Some of them get shut down or hacked, such as the infamous Mt. Gox exchange. Others have large downtimes due to being targeted by hackers. All of these exchanges have trading fees and some even have withdrawal fees, taking cuts of your money and your profits.

These are all problems that DEXs do not cope with. DEXs, to reiterate, aren't owned or operated by single entities, servers, companies, or people. This means, with a DEX, you (theoretically) get:

  • 100% uptime (0% downtime)
  • no need for trust
  • no possibility of shutdown or fund loss
  • no exchange/trading fees
  • no withdrawal fees (except for network transaction fees)
  • complete control over trading/exchange terms

and many other features. DEXs already exist today, with one of the most popular being the OpenLedger or BitShares DEX. However, the problem is that these DEXs can only perform decentralized trades of specific coins. OpenLedger is incompatible with trading Bitcoin directly, so it trades a cryptocurrency called OPEN.btc, which is different from Bitcoin but is worth 1 BTC.

This is a problem if we want to perform fully-trustless secure decentralized trades directly on the blockchain. Trading with derivatives or "mock cryptocurrencies" like OPEN.btc introduces new variables and more complicated steps to the system.

Cross-Chain Atomic Swap

The solution to this is called an "atomic swap." Atomic is a word used in cryptography and science to imply that two events occurred simultaneously, such that they can be referred to as just one event.

A handshake is atomic, because "A shaking B's hand" occurred simultaneously with "B shaking A's hand"; it's not possible for them not to occur simultaneously.

Let's say Alice and Bob want to perform a cryptocurrency trade; namely, Alice wants to sell 1 BTC for 20 ETH, and Bob wants to sell 20 ETH for 1 BTC. They find each others' requests, and pair with each other.

How do they perform the trade without relying on an escrow or third party? A terrible solution would be:

  1. Alice sends 1 BTC to Bob
  2. Bob sends 20 ETH to Alice

The above "solution" requires an insane amount of trust from Alice, because after Step 1, Bob could easily just keep the Bitcoins and the Ethereum. Therefore, the above solution doesn't work.

Solution: Hashed Time-Locked Contracts (HTLC)

However, in recent years cryptocurrency enthusiasts and developers have found solutions using something called a "Hashed Time-Locked Contract", or HTLC.

An HTLC basically allows the recipient of a pending payment to acknowledge or verify that the payment occurred, before a set deadline. The recipient would acknowledge the payment using a cryptographic proof.

The secondary component is what happens if the recipient does not acknowledge the payment. If they fail to acknowledge the transfer before the set deadline, they forfeit their ability to claim the pending payment.

This HTLC technology can be used in tandem with Bitcoin transactions to perform cross-chain atomic swaps. This has actually already been done on testnets multiple times; most recently, Altcoin.io performed a BTC/ETH testnet atomic swap, and the creators of Litecoin and Decred performed a LTC/Decred atomic swap.

HTLC Drawbacks

There are drawbacks to using an HTLC. In exchange for solid and complete security/accountabilty, the user forfeits some convenience. If the recipient were to stop the process in the middle, everyone would still have access to their respective cryptocurrencies.

However, they would only be able to transact with them after a certain amount of time (generally a day or two in tests). This deadline is decided by the set deadline the two parties use for their HTLC contracts.

Technical Atomic Swap Details

In the last section, we covered HTLCs and how they help support atomic swaps. But what is the technical "system" or method that allows this to occur? Below, we'll take a look at the Tier Nolan model or example for atomic swaps. Specifically, Alice is selling 1 BTC to Bob, for 20 ETH.

  1. Alice chooses a random number, say x. She hashes the number and gives H(x) to Bob.
  2. Alice creates a transaction that sends her BTC to a multi-sig address (2-of-2). This address is such that B can only redeem the coins if he reveals the value of the number x. Let's call this transaction Tx-1.
  3. Bob creates a transaction that sends his ETH to a multi-sig address with the same configuration as A's transaction. Let's call this Tx-3.
  4. Alice and Bob do not broadcast Tx-1 and Tx-3 yet. Instead, they each create time-locked refund transactions that allows each of them to take back their original coins if the trade was unsuccessful. A's locktime is P and B's is Q. It's recommended that P is much larger than Q.
  5. Alice reveals the value of the number x, and redeems her 20 ETH from Bob.
  6. Bob receives the value of x from Alice's reveal. He reveals it as well, and redeems his 1 BTC from Alice.

Above is the complete description of the model. Note that if at any point in these steps, Alice or Bob fails to complete their side of the deal, the other can easily use a refund transaction to cancel the trade.

Conclusions

If you've read this far, it's clear you're knowledgeable about cryptocurrencies; you now know what a cross-chain atomic swap is, and how this technology can greatly benefit the DEX (decentralized exchange).

As the Lightning Network for Bitcoin is developed and released, cross-chain atomic swaps on Bitcoin are expected to ramp up, beginning a possible reign for decentralized exchange, and ridding us of the problems with centralized ones.


Thanks for reading,
@mooncryption

image sources: 1, 2 -
modified, 3,4, 5, 6

references:

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Great breakdown. Resteemed. Here's to decentralized everything...

does bitshares trade open.btc like ledger?

Yes.

This post was resteemed by @resteembot!
Good Luck!


Curious? Check out:


The @resteembot users are a small but growing community.
Check out the other resteemed posts in resteembot's feed.
Some of them are truly great.

Calling @originalworks :)
img credz: pixabay.com
Nice, you got a 24.0% @trafalgar upgoat, thanks to @mooncryption
Want a boost? Minnowbooster's got your back!

The @OriginalWorks bot has determined this post by @mooncryption to be original material and upvoted it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!
For more information, Click Here!
Special thanks to @reggaemuffin for being a supporter! Vote him as a witness to help make Steemit a better place!

This piece is an important education for me, though I’m not a Newbie on the cryptocurrency, generally speaking, and have been studying the Bitcoin technology years. So not only am I following you from this point to check and see what my voting power is to try also help out in that domain.

I notice that there is not much literature recent literature or mention in the exchange listings of Bisq (formerly Bitsquare). Since this was a pioneer among the decentralized exchanges, do you have any opinion as to why it’s not getting more attention?

Secondly, in preparation for the demise of the exchanges which DEXs do you recommend that we spend a lot of time trying to get our ‘heads around’? I had actually planned to do some serious time investment on Bisq; but now I’m worried that that might be a waste of time.

Also I see in the recent literature from BANCOR that they’re working on software that will allow web-based trading of BNT with no need for exchanges and no need for the traders to know anything about the underlying cryptographic principles. That me know if you’d like to see the link and I’ll try to dig it up.

Bisq is a decentralized exchange, as you brought up, and the developers have done a great job at maintaining security, privacy, and decentralization in all facets of the application.

Bisq's "main purpose" as I see it is to ensure decentralized fiat <> crypto trades. They have systems of arbitrators to make sure that fiat trades go through, and they also have set fees for trades.

As for decentralized exchanges, there exist many from Bitshares to Bisq, but they haven't caught on as most of them are dodging the real problem. Rather than arbitrating with the blockchain, they use different methods; Bisq uses a decentralized team of arbitrators, while Bitshares uses derivatives (or mock cryptocurrencies) that replicate the real blockchain cryptocurrencies. Bisq is not at all a bad application though, and I do recommend you get the hang of it if you're interested in that.

I think the "true" Bitcoin DEX will come out soon once the Lightning Network has established itself. After the Lightning Network release, an HTLC-based Bitcoin DEX would likely work well, and I think development will begin on that very soon.

As for Bancor, BNTs are extremely tied with the Ethereum blockchain. I believe Bancor will only work primarily with Ethereum ERC-20 tokens, which gives them the "boost" of using built-in smart contracts. Bitcoin doesn't have native smart contracts, which is why a Bitcoin DEX has become a harder puzzle to solve.

I think the gist is that there have been decentralized exchanges for specific financial sectors. Developers have targeted places where it's easy to establish a DEX; but a blockchain-backed Bitcoin DEX is the next step in ensuring decentralized trading.

A big thanks to you, mooncryption, for an authoritative response to my questions and what I accept as great guidance about my up-coming time investment in preparing for the demise of the exchanges. I am already Following you, and will now try to do a decent up-vote. If my SP is too weak, I will do so in response to a future post by you.

I certainly recommend to the other crypto enthusiasts in Steemit to keep track of your work.

DEX are the future, in fact it's the next big thing with the increasing regulations and uncertainty around cryptos.

Thank you for the detailed explanation of Atomic Swaps.

It is an exciting mechanism to be implemented into the blockchain. I agree that we need DEX in a bad way.

One thing you omitted when posting about centralized exchanges: they are subject to the regulations where they are located and operate. Failure to comply can result in fines or even shut down. Hence, even thought the blockchain and currency isnt under government control, the exchanges can be.

DEX fixes this too.

You're right! These days, exchanges like Bittrex and Bitfinex are throwing lots of users out and are even shutting down service due to laws and regulations.

What a fantastic post ! So much informations for me regarding Atomic Swap thank you ! I banned Bittrex couple of days ago to focus on Bitshares and Cryptopia (CX smaller but still ok).