-
-
Notifications
You must be signed in to change notification settings - Fork 250
Description
Using the method get_token_balance(address=my_address) to get the token balance for an address, the output does not take into account the number of decimals. For example:
fetching USDC (contract address 0xdac17f958d2ee523a2206206994597c13d831ec7) token balance returns a number that needs to be divided by 1e+6 (i.e. 6 decimal places):
Result: {"status":"1","message":"OK","result":"87000000000"} --> actual value = 87,000
But for many other tokens, it needs to be divided by 1e+18:
For example, for aWETH (contract address 0x030ba81f1c18d280636f32af80b9aad02cf0854e):
Result: {"status":"1","message":"OK","result":"200004568518412516545"} --> actual value = 200.004568518412516545
Question is how can we know the divisor / i.e. how many decimals is in the result?