Tokens transfers amount rounded or not accurate (floating point)

Hello,

I have a serious problem with the data returned with ETH and BSC transfers, the amount number (tokens transfered) is rounded and sometimes not even accurate with big decimals (float) when it should never be rounded for accuracy reasons.

Here is an example with BSC:

Expected transfer value :
5049.28034264
Returned by Bitquery :
5049.2803426400005

Which is innacurate and probably a floating point problem caused by the programming language ( see website: floating-point-gui [dot] de/basic/ ).

Another example with ETH:

Many transfers amounts are not returned correctly with this one.

Expected:
19.110343473122736641 swETH
Returned by bitquery :
19.11034347312274 swETH

As you can see, it’s rounded.

Here is the graphql query used:

query ($network: EthereumNetwork!, $hash: String!, $limit: Int!, $offset: Int!) {
  ethereum(network: $network) {
    transfers(
      options: {limit: $limit, offset: $offset}
      amount: {gteq: 0}
      txHash: {is: $hash}
    ) {
      sender {
        address
      }
      receiver {
        address
      }
      amount
      currency {
        symbol
        address
        tokenType
        name
      }
      gasValue
      }
    }
  }
}

the params:

{
  "limit": 25,
  "offset": 0,
  "network": "ethereum",
  "hash": "0x02cbdf74994c7912aa39cfe1629f22df322e736ca2f0382aca5202f40f444168"
}

This is a huge issue and I would appreciate if it can be fixed.

Thanks for your help.
Regards

Thanks for raising this issue. I have created a ticket to bring it to the notice of the dev team. Will get back to you with the fix/response.

1 Like

@lyes For correct floating point values use the new dataset https://ide.bitquery.io/streaming_transaction-floating-point

This is recorded as a known issue in the dataset that you are using.

1 Like

Thank’s for your response.

The new dataset works fine and the data returned is much more accurate.

However I’m facing a new issue:

I can’t find a way to return the transfer amount in USD with this new dataset like I used to do before:

{
  ethereum(network: ethereum) {
    transfers(
      options: {limit: 10}
    ) {
      amount 
      amountInUSD: amount(in: USD)
    }
  }
}

Can you help me? is there any documentation online regarding this new dataset that can help?

Thank’s again!

You can find the documentation here https://docs.bitquery.io/

I will check if we can get transfers in USD in the new dataset.

1 Like

Thanks for the docs, I can’t find anything related to what I’m searching for inside.

I would really appreciate if you can get back to me for a solution to get transfers in USD in the new dataset.