ethereum_block_scanner.go
In the convertAmount function within the ETHScanner class, there is a significant risk of miscalculation when handling tokens that do not adhere to the standard 18 decimals, which is common for many ERC-20 tokens on the Ethereum network. The function attempts to normalize all token amounts to 18 decimals, but the logic incorrectly scales up the amount by (10^{18}) for all tokens, irrespective of their actual decimal configuration. This could result in a drastic misrepresentation of token amounts, potentially causing substantial financial discrepancies and loss when interacting with contracts expecting correctly scaled values.
Code snippet:
Expected Behavior: The function should correctly scale token amounts based on the difference between the tokens decimals and the standard 18 decimals, adjusting either up or down accordingly. This ensures that all token amounts are represented accurately within the system, preventing any unintended financial outcomes due to decimal errors.
Expected Behavior code snippet:
Logic:
Actual Behavior: The function inaccurately scales all non-18 decimal tokens up by (10^{18}), then divides by the tokens original decimal factor, leading to incorrect calculations, especially evident with tokens having decimals significantly less than 18.
Actual Behavior code snippet:
Logic:
