Biscoint / biscoint-api-node

NodeJS library for interacting with biscoint.io's API.
MIT License
15 stars 7 forks source link

Bug: divergence on ETH amount #21

Closed lzkill closed 2 years ago

lzkill commented 3 years ago

I'm constantly getting divergence on the ETH amount after buy operations. The amount returned by confirmOffer doesn't match the value shown by the app. This behaviour has not been seen on BTC operations yet, suggesting that the new ETH features might be flawed.

positions

resized-image-Promo

bolaum commented 3 years ago

Hi @lzkill. Could you walk me through how to reproduce this? Is this related to the API in any way? Values between API requests and what the app returns may vary.

If you access biscoint.io/dashboard/transactions you can export a detailed report on your operations and get the exact amount for each op.

lzkill commented 3 years ago

Hi @bolaum.

I haven't found a way to simulate this issue. All my buy operations on Biscoint are done by the API. When the bots are doing their stuff I can see the balance on the app moving up and down, but right now there are no operations being done. Shouldn't the balance match?

Unfortunately, the csv report rounds the ETH amount, so I can't check the divergent decimal places.

h

My question is: if the api method returned 0.003083157696, why my balance shows only 0.003083155528 ETH?

bolaum commented 3 years ago

@lzkill could you open a ticket in the support (email suporte@biscoint.io)? It is better to discuss details on your account through a private channel. Reply here when you do. Thanks.

lzkill commented 3 years ago

As discussed with @bolaum the backend is returning '0000' in the baseAmount for ETH sell operations.

Buy offer base amount: 0.002987794858 Buy confirm base amount: 0.002987794858 Sell offer base amount: 0.002987790000 Sell confirm base amount: 0.002987790000

See this for a reproducible script.

bolaum commented 3 years ago

@itxtoledo could you check if this is a lib or backend issue?

lzkill commented 3 years ago

The temporary hack is truncating the amount on ETH sell offers. The side effect is some ETH residue leftover in the account.

  async offer(args: IOfferParams): Promise<IOfferResult> {
    this.truncateEthAmount(args);
    return this.biscoint.offer(args);
  }

  truncateEthAmount(args: IOfferParams) {
    if (!args.isQuote && args.base === 'ETH') {
      args.amount = truncateString(args.amount, 10);
    }

    return args;
  }

truncateString(str, num) {
  if (str.length <= num) {
    return str;
  }
  return str.slice(0, num);
}
mejnour commented 2 years ago

We submitted a new PR that improves consistency. One can now pass 12 decimal places to our API and receive the same.

https://github.com/Biscoint/biscoint-api-node/commit/b1142a8302ac1a1a40ec0f47cb42d3b1e0a54718

mejnour commented 2 years ago

Closing this issue as it seems to be resolved. Please feel free to open another one in case you find something new. Thanks for contributing!

lzkill commented 2 years ago

I confirm it!

You guys are awesome! Thanks!