omgnetwork / research

43 stars 2 forks source link

bitcoin clearing house #98

Open boolafish opened 5 years ago

boolafish commented 5 years ago

Note

cf whitepaper :scream We haven’t performed measurements for quality of liquidity (work in progress). However, it would be a reasonable assumption that most crypto volume involves BTC We need to understand if the Bitcoin clearinghouse construction as described in the whitepaper can be built. If it cannot be built, then we have to seek alternative ways to bring BTC to the OmiseGO Platform.

kevsul commented 5 years ago

Kelvin had the idea of using the Lightning network for this:

Bitcoin clearinghouse

I haven’t done a lot of research into this area. I’m currently reaching out to Joseph to get a better understanding of what he had in mind. For now, we can already support tokens like WBTC that wrap BTC into an ERC20 (though it isn’t really decentralized). However, I’ll attempt to give my current understanding of the construction so we at least have something written down.

The “clearinghouse” construction described in the OMG paper seems to be an extension of the basic OMG plasma chain. If my understanding is correct, then it’s actually quite simple. In order to trade BTC (or any BTC-like token that supports payment channels), we can theoretically make use of the lightning network.

The flow of an ETH-BTC trade would work as follows:

  1. Alice and Bob wish to trade X BTC for Y ETH.
  2. Alice and Bob are connected to each other on the lightning network through a third party (Carol), which Joseph calls a “clearinghouse” (a hub, basically).
  3. Carol locks up some funds in the OMG smart contract (used for bonding) and pre-initializes hashes to which only she has the preimage. Carol publishes and signs one hash for each of her users (in this case, Alice and Bob).
  4. Alice has X BTC in a channel with Carol, Carol has X BTC in a channel with Bob. Bob has Y ETH on the OMG plasma chain.
  5. Alice signs a trade saying she’ll sell X BTC for Y ETH, including a payment channel transaction conditional on the reveal of the Alice-Carol preimage. Bob signs a trade saying he’ll trade Y ETH for X BTC, including a payment channel transaction conditional on the reveal of the Bob-Carol preimage. The two trades match.
  6. The trade executes on the condition that the preimages for the Alice-Carol channel and for the Bob-Carol channel are revealed.
  7. If the preimages are revealed within some period of time P, the trade executes. Alice receives Y ETH on the OMG plasma chain and Bob receives X BTC on the Bob-Carol channel.
  8. If the preimages are not revealed within the period P, the trade fails. Carol is punished using the funds she locked in the OMG smart contract.
  9. If Carol reveals preimages without a corresponding trade, Carol is punished.

Some questions here:

  1. How much money does Carol need to lock up?
  2. How do we make sure that Carol doesn’t cheat by locking up less money than she should?
  3. Where should the challenges occur?
  4. How long should the timeout period be?
  5. What happens if the operator censors Carol when she’s revealing the preimages?
slavamirovsky commented 5 years ago

Interesting note guys. I know this is not directly related, but we gonna be working with Jamie, Jeremy and Alexei (Biz Dev) on how we can understand our quality of liquidity and the one on our competitors' side. Please find the link: https://docs.google.com/document/d/1nIRUhcoTwOOr5-Odh9fAZcMODnIboP-7-j5OtVAKcjI/edit?usp=sharing

madxor commented 5 years ago

Work in progress: clearinghouse doc

madxor commented 5 years ago

Short summary of what the clearinghouse is: "It's a fancy escrow" :)

slavamirovsky commented 5 years ago

@madxor please keep us updated on the progress here. We have got a call last week. Maybe there is sth new.

(obviously the priority for the next few days stays STARK, still if u gonna have capacity - feel free to drop some lines here)

madxor commented 5 years ago

@Nikodemek18 Requested analysis of the WBTC in the clearinghouse doc, summary below.

Wrapped BTC (WBTC) is simply an ERC20 token, hence it should be fairly easy to use it with our DEX infrastructure. The trading process would be simplified because we would not need to have Bitcoin parts of the infrastructure and could only use Ethereum and Plasma parts.

WBTC relies heavily on trusted parties: merchants and custodians, which are subject to regulations. BTC-WBTC exchanges are performed by atomic swaps or trusted exchanges. If atomic swaps are used, then the custody is transferred immediately. If trusted exchange is used, then the custody transfer depends on that particular exchange. Please note that the clearinghouse could also play a role of a trusted exchange.