KomodoPlatform / komodo-defi-framework

This is the official Komodo DeFi Framework repository
https://komodoplatform.com/en/docs/komodo-defi-framework/
104 stars 95 forks source link

Some orders receiving with corrupted price #555

Closed tonymorony closed 5 years ago

tonymorony commented 5 years ago

At first faced on mobiles (for BCH and LTC vs KMD), then reproduced in CLI with AtomicDEX MarketMaker 2.0.1381_mm2_9687d15e7_Linux

Example of the "bad" (to many digits in non rational one) price in orderbook: https://paste.ubuntu.com/p/XWmTx43q9D/

"bids": [
    {
      "coin": "BCH",
      "address": "RT9MpMyucqXiX8bZLimXBnrrn2ofmdGNKd",
      "price": "0.002634824632517240703595939415268187559182047612670189132802603277561013155878582900801136451717353454",
      "price_rat": [
        [
          1,
          [
            2500000
          ]
        ]
artemii235 commented 5 years ago

@tonymorony Hi, thanks for the report! Price is not corrupted here, it's decimal representation of corresponding rational number with maximum available precision, e.g. from the linked issue: "price_rat":[[1,[2431504384,46]],[1,[3600861933,17618]]] - it's actually 200000000000/75672334682861, that is ~ 0.002642973827068902744216955210886791832516153690411964494336800995627777720251367932848888234461954501. So the number has infinite decimal representation, but as BigDecimal has limited precision it can store about 100 digits and everything else is truncated.

tonymorony commented 5 years ago

Got it. Thank you for the clarification @artemii235 !

artemii235 commented 5 years ago

@tonymorony You're welcome!