mastercoin-MSC / mastercore

mastercore info
mastercoin.org
MIT License
24 stars 11 forks source link

Edgy trading engine #198

Closed dexX7 closed 9 years ago

dexX7 commented 9 years ago

Very first: is it just me or does a trade only work, if one of the pairs is TMSC? This was intended as interface restriction, but the trading engine should accept it.

Here two cases with matches that do not match:


A1 offers 10.00000000 TMSC for  2.00000000 TDiv1
A2 offers  3.75000000 TDiv1 for 15.00000000 TMSC

10.0 TMSC trade for 2.0 BTC TDiv1. The update:

A2 offers 1.25000000 TDiv1 for 5.00000000 TMSC
A1 approaches with 5.00000000 TMSC for 1.25000000 TDiv1

Result: no match, yet straight from the getorderbook_MP(2) + getorderbook_MP(2147483653):

[{
  'property_owned': 2,
  'property_desired': 2147483653,
  'amount_original': '5.00000000',
  'amount_desired': '1.25000000'
}]
[{
  'property_owned': 2147483653,
  'property_desired': 2,
  'amount_original': '1.25000000',
  'amount_desired': '5.00000000'
}]

One Satoshi more is sufficient (A1 offers 5.00000001 TMSC for 1.25000000 TDiv1). Not the first time.

This example is actually from https://github.com/mastercoin-MSC/spec/issues/173#issue-34200081 route C.


A1 offers 100 TIndiv1 for 200.00000000 TMSC
A2 offers 600.00000000 TMSC for 300 TIndiv1

No match. Selling 400.0 TMSC for 200 TIndiv1, or 800.0 ... or ... works well. Only 600.0 for 300 is edgy.


Then there is:

A1 offers 20 Indiv1 for 10 Indiv2
A2 offers 12 Indiv2 for 17 Indiv1

Outcome with divisible units seems to be around 8.5 trade for 17.0.

When using indeed indivisible units, then: 17 trade for 8 (you probably should round up, see: https://github.com/mastercoin-MSC/spec/issues/170#issuecomment-44072344) with a leftover reserve.

However it seems the desired result is actually: A1 is served and 20 Indiv1 trade for 10 Indiv2. A2 has a leftover and still desired 2 Indiv2 more. Not sure what happens with that, but see here: https://github.com/mastercoin-MSC/spec/pull/289#issuecomment-62238156

dexX7 commented 9 years ago

I'm going to reevaluate this and the trades mentioned here, once the trading engine is working again, so to speak.

m21 commented 9 years ago

Metadex Item

dexX7 commented 9 years ago

@m21: maybe start to use labels here to tag issues/PRs?

m21 commented 9 years ago

Good idea thanks Dexx :)

dexX7 commented 9 years ago

This should be converted into a spock test, and any follow up discussed in https://github.com/OmniLayer/omnicore/issues/9.