Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Double inversion of Price in code Logic #722

Open
@override-coder

Description

@override-coder

Description of the Issue:
The current implementation performs price inversion twice within the cfg.Invert block, both of which happen after the ERC20 price scaling. The first inversion happens here:

if cfg.Invert {
scaledERC20AdjustedPrice := new(big.Float).Quo(price, erc20ScalingFactor)
return new(big.Float).Quo(big.NewFloat(1), scaledERC20AdjustedPrice)
}

The second reversal occurs get provider price:

if cfg.Invert {
return new(big.Float).Quo(big.NewFloat(1), price), nil
}

This results in a double inversion of the price when cfg.Invert is set to true, which could lead to incorrect calculations.

Suggested Fix:
Remove the first inversion and only perform the scaling operation on the ERC20 price.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions