Bitcoin Forum
May 03, 2024, 01:23:49 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to Approximate a Decentralized Exchange  (Read 1322 times)
Trent Russell (OP)
Full Member
***
Offline Offline

Activity: 132
Merit: 100


willmathforcrypto.com


View Profile WWW
June 02, 2015, 03:24:40 PM
Last edit: June 05, 2015, 02:18:15 PM by Trent Russell
 #1

When problems pop up with centralized exchanges, as they repeatedly do, people start posting about the need for decentralized exchanges. An obvious question is how to interface with fiat, but this question misses the point that there are two distinct uses for exchanges. (1) To exchange one currency for another vs. (2) To hedge against volatility or speculate on prices. For purpose (2) there does not need to be an actual interface with fiat. A "decentralized exchange" designed to only support (2) can be built on top of Bitcoin using colored coins or Counterparty or Omni/Mastercoin. Similarly one could do this with assets in NxT or BitShares. I think in most of these cases there's a dependence on the ability to redeem the "digital asset" (e.g., the colored coin) for the asset it represents. BitShares uses a different mechanism, and seems to be a bit closer to what I'm about to describe. However, what I will describe doesn't need an altcoin or alternative network.

I've been thinking about a different way to simply use bitcoin with multisig to "exchange" in the sense of (2). Something like it must have been discussed before, so someone who's been around longer can hopefully point me to earlier threads. Here's a simple high level example.

Simple Example

Suppose Alice and Bob both have 1 bitcoin. Alice wants to try to make sure to keep at least $220 worth of bitcoin and is worried the price will fall. Bob thinks the price is about to rise and wants to profit from this. Alice and Bob could make a transaction T with their 2 bitcoins as inputs and with 2 outputs. The first output would be an OP_RETURN with a message (the "contract") and the second output would be a 2-of-2 multisig with both their addresses. The contract would say: "After 1 week, Alice gets paid X bitcoins and Bob gets paid 2-X bitcoins where X*P = 220 and P is the price of a bitcoin in USD." (To be more precise, if P < 110, then X must be 2.) While I've written this "contract" in English, it would be abbreviated to give the essential information in an OP_RETURN. Then after 1 week, Alice and Bob can look up the price P, build the transaction spending T's multisig output and both sign it. If the price is $200, then Alice gets 1.1 bitcoin and Bob gets 0.9 bitcoins. If the price is $250, then Alice gets 0.88 bitcoins and Bob gets 1.12 bitcoins.

Here is where there's a potential problem: they may not agree on P. Alice may say the price is $200 and Bob may say the price is $250. As long as they can't agree, the 2 bitcoins are locked up and neither benefits. It seems from a game theory perspective, they are incentivized to come to an agreement. Furthermore, since this is all on the blockchain, people can inspect the transaction and see that there has not been an agreement. Alice could publicly publish a partially signed transaction spending it assuming P = $200 and Bob could do the same with another partially signed transaction spending it assuming P = $250. Everyone could see these cryptographic commitments, look at the price on the day in question, and use it to determine whether or not to trust Alice or Bob (or neither) in the future. Suppose the price is $200 but Alice gives in, signing Bob's version (agreeing the price is $250). People can see that Bob said the price was higher than it really was (to his benefit) and distrust him in the future.

Another problem is that Alice or Bob might die or lose the private key, in which case both lose their money.

Example with Escrow

To some degree the problems could be mitigated by having a "decentralized exchange" as an escrow. This would simply be a bitcoin address I'll call Dentex. Instead of Alice and Bob sending their 2 bitcoins to a 2-of-2 multisig, they would send it to a 2-of-3 with addresses for Alice, Bob and Dentex, along with some "escrow fee" to Dentex. Just as before, Alice and Bob can agree on the price after the contract expires and sign the appropriate spend. If, however, they cannot agree, then Dentex can look up the price and sign a transaction spending the appropriate amounts to Alice and Bob. At that point, it's only up to Alice or Bob to sign and complete the contract. Dentex's reputation would be formed over time by people noting that Dentex correctly signed multisig txouts with a correct price at the correct times. Dentex could not simply run off with the money. There is still a problem (Sybil): Dentex might actually be Alice (or Bob). In this case Dentex could agree with Alice that the price is $200 even if the price is "really" $250. However, this would destroy Dentex's reputation immediately, so at least the attack could not continue. Also, in case Dentex were incapacitated (killed, shut down, imprisoned, gag ordered), all the "customers" revert to the 2-of-2 case in which they must agree on the price in order to free their money.

Dentex could be completely pseudonymous, with no one needing to know who or where they are. (This might be necessary if the "decentralized exchange" wants to avoid KYC/AML compliance.) Or Dentex could be completely open about who they are as a way of trying to get customers to trust them more.

Of course, this could be made more sophisticated in various ways, but hopefully I've gotten the idea across. Is anyone already doing this? Are there problems or attacks I'm not seeing? Thoughts?

1714699429
Hero Member
*
Offline Offline

Posts: 1714699429

View Profile Personal Message (Offline)

Ignore
1714699429
Reply with quote  #2

1714699429
Report to moderator
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714699429
Hero Member
*
Offline Offline

Posts: 1714699429

View Profile Personal Message (Offline)

Ignore
1714699429
Reply with quote  #2

1714699429
Report to moderator
ammy009
Sr. Member
****
Offline Offline

Activity: 303
Merit: 250



View Profile WWW
June 12, 2015, 05:17:53 PM
 #2

Very Good Idea. We really need decentralized exchange ......... because all centralized exchanges have security problem & your btc will be stolen any time............

Hollingsworth
Full Member
***
Offline Offline

Activity: 168
Merit: 100


View Profile
June 12, 2015, 08:36:07 PM
Last edit: June 12, 2015, 09:54:58 PM by Hollingsworth
 #3

Some years back on btc-e, I saw a gentleman post an idea for a decentralized exchange. It was built into a crypto wallet client and it envisioned a pure peer-to-peer alt coin exchange. There were tabs for the various alt currencies that would be traded. There was an interface for buy/sell orders for all the various alt currencies. No fees with instant coin transfers to the p2p wallet.

So the front end was created this way as a working concept, but the backend was never developed. Some blockchain magic would secure and the drive the exchange data between the p2p wallets.  The main caveat was that this exchange did not trade fiat as that would entail some sort of centralized control, btc being the main exchange currency.

It's a brilliant approach, theoretically, to having a decentralized exchange.

H.
lemipawa
Legendary
*
Offline Offline

Activity: 1708
Merit: 1003


View Profile
June 12, 2015, 08:48:18 PM
 #4

Perhaps something like this project is what you are looking for: https://bitcointalk.org/index.php?topic=946174.0. It is a trustless, decentralized exchange where all of the transactions occur on the blockchain(s).
Hollingsworth
Full Member
***
Offline Offline

Activity: 168
Merit: 100


View Profile
June 12, 2015, 09:50:55 PM
 #5

Perhaps something like this project is what you are looking for: https://bitcointalk.org/index.php?topic=946174.0. It is a trustless, decentralized exchange where all of the transactions occur on the blockchain(s).

Thanks for the heads up, that is the spirit of the idea I once saw.
Amph
Legendary
*
Offline Offline

Activity: 3206
Merit: 1069



View Profile
June 13, 2015, 07:48:25 AM
 #6

what you're saying about bitsquare and bitshares? https://bitshares.org/

are they really a decentralized exchange, i thought they are still a myth, and why no one is using it instead of using the traditional exchange?
Trent Russell (OP)
Full Member
***
Offline Offline

Activity: 132
Merit: 100


willmathforcrypto.com


View Profile WWW
June 14, 2015, 09:47:23 AM
 #7

Thanks for the pointers everyone. I'll do some reading about these options.

Mercury looks interesting, but it's only for cross chain trading. This seems like the easiest case to decentralize in a trustless way, but obviously people are still using centralized exchanges for some reason. I need to look further into Mercury.

what you're saying about bitsquare and bitshares? https://bitshares.org/

are they really a decentralized exchange, i thought they are still a myth, and why no one is using it instead of using the traditional exchange?

Bitshares is closest to what I'm describing. To be honest, the main reason I'm not using bitshares is because I couldn't successfully compile and run their source code under linux. Maybe I should join their forum and get someone to help me with troubleshooting.

jantenner81
Full Member
***
Offline Offline

Activity: 228
Merit: 100


CIYAM - UI/UX design


View Profile WWW
June 14, 2015, 10:22:54 AM
 #8

Did you notice CIYAM AT & ACCT ?

Automated Transactions (AT) is a technology created by CIYAM Developers which provides "Turing complete smart contracts" for any blockchain that implements it.
http://ciyam.org/at/

Atomic Cross Chain Trading
http://ciyam.org/at/at_atomic.html

Burst & Qora just integrated CIYAM AT / ACCT ino their existing chains! More to come soon! IF more communites would integrate AT/ACCT into their chains, then truly decentralized exchanges could get executed.

If you have questions concerning about, don't hesitate to contact me anytime!

Best
jan
CIYAM Developers

AT - Automated Transactions
CIYAM | Developer
Agestorzrxx
Sr. Member
****
Offline Offline

Activity: 462
Merit: 250


View Profile
June 14, 2015, 10:44:33 AM
 #9

We talk about decentralized exchange long time ago. But it still didn't work right now.
I don't think decentralized exchange can replace the centralized exchange. Yes centralized exchange got a lot of problem, but it is still more convenience than decentralized exchange.
okae
Legendary
*
Offline Offline

Activity: 1401
Merit: 1008


northern exposure


View Profile WWW
June 14, 2015, 11:22:38 AM
 #10

Did you notice CIYAM AT & ACCT ?

Automated Transactions (AT) is a technology created by CIYAM Developers which provides "Turing complete smart contracts" for any blockchain that implements it.
http://ciyam.org/at/

Atomic Cross Chain Trading
http://ciyam.org/at/at_atomic.html

Burst & Qora just integrated CIYAM AT / ACCT ino their existing chains! More to come soon! IF more communites would integrate AT/ACCT into their chains, then truly decentralized exchanges could get executed.

If you have questions concerning about, don't hesitate to contact me anytime!

Best
jan
CIYAM Developers

i still cant understand why this community didnt notice it yet, is aBIG STEP what the ciyam guys already did between burst&quora and ppl seems like nothing happend or maybe they didnt notice it yet dunno, but for me this a very good news.

They have laid the foundation stone, cmon devs lets continue it is a great beginning but you guys should continue it.

IMHO #1.b of suspects, Hal Finney is/was S.N.
AtheistAKASaneBrain
Hero Member
*****
Offline Offline

Activity: 770
Merit: 509


View Profile
June 14, 2015, 12:57:30 PM
 #11

Did you notice CIYAM AT & ACCT ?

Automated Transactions (AT) is a technology created by CIYAM Developers which provides "Turing complete smart contracts" for any blockchain that implements it.
http://ciyam.org/at/

Atomic Cross Chain Trading
http://ciyam.org/at/at_atomic.html

Burst & Qora just integrated CIYAM AT / ACCT ino their existing chains! More to come soon! IF more communites would integrate AT/ACCT into their chains, then truly decentralized exchanges could get executed.

If you have questions concerning about, don't hesitate to contact me anytime!

Best
jan
CIYAM Developers

i still cant understand why this community didnt notice it yet, is aBIG STEP what the ciyam guys already did between burst&quora and ppl seems like nothing happend or maybe they didnt notice it yet dunno, but for me this a very good news.

They have laid the foundation stone, cmon devs lets continue it is a great beginning but you guys should continue it.

Because at the end of the day this is a Bitcoin forum, and altcoins are mostly ignored.
Can this technology be applied to Bitcoin? maybe it could be proposed in a BIP. I don't think people is going to be using Qora or whatever only because of that. We need all the good stuff to be integrated into Bitcoin.
wizzardTim
Legendary
*
Offline Offline

Activity: 1708
Merit: 1000


Reality is stranger than fiction


View Profile
June 14, 2015, 02:43:46 PM
 #12

Did you notice CIYAM AT & ACCT ?

Automated Transactions (AT) is a technology created by CIYAM Developers which provides "Turing complete smart contracts" for any blockchain that implements it.
http://ciyam.org/at/

Atomic Cross Chain Trading
http://ciyam.org/at/at_atomic.html

Burst & Qora just integrated CIYAM AT / ACCT ino their existing chains! More to come soon! IF more communites would integrate AT/ACCT into their chains, then truly decentralized exchanges could get executed.

If you have questions concerning about, don't hesitate to contact me anytime!

Best
jan
CIYAM Developers

i still cant understand why this community didnt notice it yet, is aBIG STEP what the ciyam guys already did between burst&quora and ppl seems like nothing happend or maybe they didnt notice it yet dunno, but for me this a very good news.

They have laid the foundation stone, cmon devs lets continue it is a great beginning but you guys should continue it.

Because at the end of the day this is a Bitcoin forum, and altcoins are mostly ignored.
Can this technology be applied to Bitcoin? maybe it could be proposed in a BIP. I don't think people is going to be using Qora or whatever only because of that. We need all the good stuff to be integrated into Bitcoin.

AT is indeed huge and deserves the necessary attention. BTC can implement this technology if decided so. Please correct me if I'm wrong.

When it comes to the usability of altcoins, many people use them and others see opportunities with them. E.g. Qora has so many features that people can use in various ways.

Behold the Tangle Mysteries! Dare to know It's truth.

- Excerpt from the IOTA Sacred Texts Vol. I
hua_hui
Legendary
*
Offline Offline

Activity: 1386
Merit: 1016



View Profile
June 14, 2015, 03:19:20 PM
 #13

We talk about decentralized exchange long time ago. But it still didn't work right now.
I don't think decentralized exchange can replace the centralized exchange. Yes centralized exchange got a lot of problem, but it is still more convenience than decentralized exchange.
Probably you haven't noticed the advantages decentralized exchanges will bring to us! Many ppl are getting fed up with the security issues, hacks, law compliance, high fee etc! Decentralized exchanges may resolve all of these issues! This technology is under development! We still need to wait for it!
Trent Russell (OP)
Full Member
***
Offline Offline

Activity: 132
Merit: 100


willmathforcrypto.com


View Profile WWW
June 15, 2015, 09:24:17 AM
 #14

I definitely find advances in trustless cross chain trading interesting and potentially useful. Probably my original post wasn't clear though. I was trying to describe a way to simulate a Crypto <-> Fiat exchange using multisig (using only bitcoin). It would be similar to what Coinapult used to do with "locks," but without relying on a central point of failure like Coinapult.

okae
Legendary
*
Offline Offline

Activity: 1401
Merit: 1008


northern exposure


View Profile WWW
June 15, 2015, 11:07:10 AM
 #15

Because at the end of the day this is a Bitcoin forum, and altcoins are mostly ignored.
Can this technology be applied to Bitcoin? maybe it could be proposed in a BIP. I don't think people is going to be using Qora or whatever only because of that. We need all the good stuff to be integrated into Bitcoin.

ofc man i agree with you, this is a bitcoin forum but you cant ignore whats is happening on those subforums, as you can see there are some good devs who are doing awesome things with alt coins, we should be the first who should not ignore it.

im not a dev, but im 100% sure that good ideas are always welcome Wink


AT is indeed huge and deserves the necessary attention. BTC can implement this technology if decided so. Please correct me if I'm wrong.

When it comes to the usability of altcoins, many people use them and others see opportunities with them. E.g. Qora has so many features that people can use in various ways.

exactly, Wink btw as i sayd what those devs guys do with qora&burst are just awesome.

IMHO #1.b of suspects, Hal Finney is/was S.N.
S4VV4S
Hero Member
*****
Offline Offline

Activity: 1582
Merit: 502


View Profile
June 15, 2015, 11:11:04 AM
 #16

Did you notice CIYAM AT & ACCT ?

Automated Transactions (AT) is a technology created by CIYAM Developers which provides "Turing complete smart contracts" for any blockchain that implements it.
http://ciyam.org/at/

Atomic Cross Chain Trading
http://ciyam.org/at/at_atomic.html

Burst & Qora just integrated CIYAM AT / ACCT ino their existing chains! More to come soon! IF more communites would integrate AT/ACCT into their chains, then truly decentralized exchanges could get executed.

If you have questions concerning about, don't hesitate to contact me anytime!

Best
jan
CIYAM Developers

i still cant understand why this community didnt notice it yet, is aBIG STEP what the ciyam guys already did between burst&quora and ppl seems like nothing happend or maybe they didnt notice it yet dunno, but for me this a very good news.

They have laid the foundation stone, cmon devs lets continue it is a great beginning but you guys should continue it.

Because at the end of the day this is a Bitcoin forum, and altcoins are mostly ignored.
Can this technology be applied to Bitcoin? maybe it could be proposed in a BIP. I don't think people is going to be using Qora or whatever only because of that. We need all the good stuff to be integrated into Bitcoin.

That is true.
However, we see a lot more innovations from altcoins rather than Bitcoin development.
The fact is however that Bitcoin was designed to be used as a currency (with some level of anonimity) and is considered and used by most as just that - a currency.
So I wouldn't expect any cool features added to Bitcoin anytime soon.
 
Trent Russell (OP)
Full Member
***
Offline Offline

Activity: 132
Merit: 100


willmathforcrypto.com


View Profile WWW
June 27, 2015, 08:39:21 PM
 #17

I fleshed out this idea and wrote a paper "Multisig Derivatives." Here's the pdf:

http://willmathforcrypto.com/multisigderivs.pdf

Here's a post about it:

https://bitcointalk.org/index.php?topic=1102062

Daedelus
Hero Member
*****
Offline Offline

Activity: 574
Merit: 500



View Profile
July 02, 2015, 01:56:52 PM
 #18

multigateway.org has been up and running for a year or so and is a good approximate to a decentralized exchange.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!