Open extra topbar

Available balance calculations out of whack

If you are new here, please see some information on how to ask for support. Thank you!

Available balance calculations out of whack

dashed-slug.net Forums Exchange extension support Available balance calculations out of whack

This topic contains 8 replies, has 2 voices, and was last updated by  megeanwasson 2 months, 3 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #5697

    megeanwasson
    Participant

    Hi Alex,
    I think there is something not quite right with the available balance calculations and how it works and affects the exchange.
    I have started off with blank exchange with no trades on and then proceeded to add some trades.

    BTC Balance shows correctly then I add a buy order, all good so far.
    negative-1

    Now I place that order and this is the result, all good so far.
    negative-2

    Now I place another order on the same pair, all still ok here.
    negative-3

    Now I go to another coin to place a new order.
    negative-4

    On submitting this order everything starts to go wrong from here, the btc amount deducted from available balance is off by a zero, it is deducting 0.0002003 instead of 0.002003 and shows no errors.
    negative-5

    Now I go to another coin to place another buy order.
    negative-6

    After completing this last order I end up with B-1.86108917 ($-6416.77)

    negative-7

    Please let me know if you need more info to help find the problem?

    Kind Regards
    Megan

    #5708

    alexg
    Keymaster

    Hello Megan,

    Thank you for reporting this. And I appreciate the detailed screenshots.

    I will investigate immediately, as I believe that this is one of the last significant errors with the exchange.

    Hopefully I will have a better reply soon.

    In the meantime, could you please confirm that you are using 4.0.x of wallets and 0.6.0-beta of the Exchange?

    thanks

    #5709

    megeanwasson
    Participant

    Hi Alex,
    All latest plugins.
    I also thought maybe it was becuase i was cross trading coins with each other, but then changed to only have the coins against BTC but resulted same errors.

    Alt Coins Adapter: by Alex Georgiou – 0.1.0
    Bitcoin and Altcoin Wallets: Exchange extension by dashed-slug – 0.6.0-beta
    Bitcoin and Altcoin Wallets: Full Node Multi Coin Adapter extension by dashed-slug – 1.0.5
    Bitcoin and Altcoin Wallets: WooCommerce Cryptocurrency Payment Gateway by dashed-slug – 2.0.0
    Bitcoin and Altcoin Wallets: by dashed-slug – 4.0.0 

    Let me know if you need anything else.
    Just a note I also tried with all plugins disabled and on default wp template and still got the same issue.

    Regards
    Megan

    #5722

    alexg
    Keymaster

    Hello Megan,

    (I would have liked to reply to you sooner but I spent all day assisting people who faced memory issues with the latest update, causing the cron jobs to not run in some cases. Version 4.0.1 solves most of these issues but in certain server configurations with multiple external wallets there can be problems. Fortunately there is now a way to debug these issues. I noticed that you have enabled a few coins yourslef, so if you detect any such problems, let me know.)

    As for your issue with the exchange, the error is mine. I have made a mistake that I will correct in the next patch. I am a bit surprised that I never saw any error message, but somehow this went undetected.

    Perhaps you could apply the fix to your code directly, and tell me if this is enough to solve the problem you encountered:

    In file includes/php-api.php, line 1357, it now reads:

    SUM( amount - filled ) * rate AS a

    This is obviously a mistake that can cause a MySQL error 1140, and can therefore cause the available balance calculation to be wrong.

    The correct expression would be:

    SUM( ( amount - filled ) * rate ) AS a

    If you can, please edit your code and see if the problem is resolved.

    As always I appreciate very much your help in spotting this.

    with regards

    #5723

    megeanwasson
    Participant

    Hi Alex,
    I will apply patch and see it it resolves the issue 🙂
    I will feedback as soon as tested.
    Regards
    Megan

    #5724

    megeanwasson
    Participant

    Ok, I have tested all coins against BTC and available BTC balances calculated correctly 🙂
    I will now go setup everything again and try trades across the coins to see if they also work and balance correclty.
    Will let you know as soon as tested.

    #5725

    megeanwasson
    Participant

    Hi Alex,
    Your patch seems to have worked.
    I have now tested across all coin pairs and all the balances look to be calculating correctly now 🙂
    If I do find any further issues with the balances I will revert back 🙂

    Regards
    Megan

    #5729

    alexg
    Keymaster

    Helo Megan, that’s great news! I will release a patch for the exchange extension with only this fix for now.

    with regards

    #5731

    megeanwasson
    Participant

    Awesome 🙂
    I have maybe found another small glitch with prices of one coin on the exchange rates shortcodes, not sure if it’s related, will open new thread shortly.
    Regards
    Megan

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.