orionprotocol / orion-holochain

Orion Holochain Application written in Rust
24 stars 2 forks source link

Questions #3

Open GildedHonour opened 5 years ago

GildedHonour commented 5 years ago

1) Can Order have many Trades -- 1:many? Or does Order always have to have a single Trade -- 1:1?

2) Is Order created by User or Broker?

GildedHonour commented 5 years ago

Order(offer) will look like this, right?

  Order/Offer {
    currency1 = usd 
    currency2 = btc
    quantity1 = 1000
    quantity2 = 0.25
  }

===> someone wants to buy 0.25 BTC for $1k USD

"currency1" and "currency2" can be stored in a single field as a pair.

In the initial task we have "price" and "quantity", what are they for?

koloale commented 5 years ago

Order(offer) will look like this, right?

  Order/Offer {
    currency1 = usd 
    currency2 = btc
    quantity1 = 1000
    quantity2 = 0.25
  }

===> someone wants to buy 0.25 BTC for $1k USD

"currency1" and "currency2" can be stored in a single field as a pair.

In the initial task we have "price" and "quantity", what are they for?

I would suggest the following structure:

Order {
    ord_id = HashString // Unique identifier
    baseAsset = 'BTC'
    quoteAsset = 'USD'
    side = buy or sell // Enum
    price = 5312.19 // Decimal
    qty = 0.64 //Decimal
    timestamp // when order was created in milliseconds since epoch

This order means someone wants to buy 0.64 BTC (bitcoin) for price 5312.19 for 1 BTC, thus paying 0.64*5312.19 = 3400.44 USD for this.

koloale commented 5 years ago
  1. Can Order have many Trades -- 1:many? Or does Order always have to have a single Trade -- 1:1?
  2. Is Order created by User or Broker?
  1. 1 Order can have many Trades.
  2. In Broker zoom orders are created and signed by Orion only - dedicated single Agent, which address is stored in genesis in code.
GildedHonour commented 5 years ago

1) Linking, validation

some chapters in the documentation aren't ready yet, for instance:

https://developer.holochain.org/guide/latest/zome/linking.html https://developer.holochain.org/guide/latest/zome/entry_validation.html

I've implemented linking based on the examples. It's probably incomplete yet

2) Agents

I understand that an Agent is an object that manages the keys, and other entities somehow, it's on the top of hierarchy....

How does it do this implementation-wise? How does it sign data and is it supposed to sign it?

How does interact with entities and they with it? And with DNA? And other stuff....

In the example applications on github Agents aren't implemented

https://developer.holochain.org/guide/latest/conductor_agents.html --> there's some info, but not enough

GildedHonour commented 5 years ago
  1. "ID" field for Entities -- they're probably not needed, in the example applications none of the Entities has ID field. Therefore I've removed them. I'll need to confirm this with the developers in the chat nonetheless.
GildedHonour commented 5 years ago
  1. What's the role of Conductor?
GildedHonour commented 5 years ago

@koloale

Let's say,

1st person comes and creates an order "I want to sell 1 bitcoin for $5k" 2nd person - "I want to sell 1 bitcoin for $5.5k" 3nd person - "I want to sell 1 bitcoin for $6k"

3 orders.

A 4th person comes and wants to buy:

1) 1 bitcoin for $5.3k 2) or 0.3 bitcoin for $1.5k and 0.7 for $2.9k 3) or [......]

There can be many such variations.

1) What's the algorithm for deciding which order is used to fulfill another order? In a nutshell.

2) The orders will be fulfilled automatically, by timer? Namely, there'll be a timer "check all the orders and see which can be fulfilled" every N minutes.

koloale commented 5 years ago

Our Orion-Broker application doesn’t cover matching logic, it’s implemented in a separate module. So if a broker receive an order, it accept it, and should submit for execution on a particular exchange. After that the broker simply creates trades until that order filled fully.