listen icon indicating copy to clipboard operation
listen copied to clipboard

Computational logic issues about parse_notional function in tx_parser.rs

Open wuaikaiyuan opened this issue 10 months ago • 1 comments

Description

@piotrostr This function is taking the larger value,I think use Unsigned Absolute Differences: .map(|(a, b)| a.abs_diff(*b)), right?

#[timed(duration(printer = "info!"))]
pub fn parse_notional(
    tx: &EncodedConfirmedTransactionWithStatusMeta,
) -> Result<u64, Box<dyn std::error::Error>> {
...
            // This calculation is not clear, if a - b is negative, and then forced to convert to u64 will overflow into a very large positive number, may be wrongly considered a large transaction

            .map(|(a, b)| (***a as f64 - *b as f64) as u64**)
...
}

Steps to Reproduce

No

Additional Notes

No response

wuaikaiyuan avatar Feb 13 '25 12:02 wuaikaiyuan

could be, listen-legacy will be sunsetted at some point

for more up-to-date transaction notional parsing, have a look at listen-data-service, the parse_swap.rs

piotrostr avatar Feb 13 '25 15:02 piotrostr