Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double inversion of Price in code Logic #722

Open
override-coder opened this issue Sep 4, 2024 · 0 comments
Open

Double inversion of Price in code Logic #722

override-coder opened this issue Sep 4, 2024 · 0 comments

Comments

@override-coder
Copy link

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.

@override-coder override-coder changed the title uniswap double inversion of Price in code Logic double inversion of Price in code Logic Sep 4, 2024
@override-coder override-coder changed the title double inversion of Price in code Logic (fix):Double inversion of Price in code Logic Sep 4, 2024
@override-coder override-coder changed the title (fix):Double inversion of Price in code Logic (fix) Double inversion of Price in code Logic Sep 4, 2024
@override-coder override-coder changed the title (fix) Double inversion of Price in code Logic Double inversion of Price in code Logic Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant