This repository was archived by the owner on Mar 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Double inversion of Price in code Logic #722
Copy link
Copy link
Open
Description
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:
connect/providers/apis/defi/uniswapv3/math.go
Lines 44 to 47 in e197035
| 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:
connect/pkg/math/oracle/utils.go
Lines 32 to 34 in e197035
| 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels