-
Notifications
You must be signed in to change notification settings - Fork 607
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
feat: make PoolModuleI CalculateSpotPrice API return BigDec #6487
Conversation
// TODO: remove Dec truncation before https://github.com/osmosis-labs/osmosis/issues/5726 is complete | ||
// Currently exists for state-compatibility with v19.x | ||
s.Require().Equal(spotPriceBaseETH.Dec(), DefaultCurrSqrtPrice.PowerInteger(2).Dec()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: tracked #6064
// TODO: remove Dec truncation before https://github.com/osmosis-labs/osmosis/issues/5726 is complete | ||
// Currently exists for state-compatibility with v19.x | ||
s.Require().Equal(spotPriceBaseUSDC.Dec(), osmomath.OneBigDec().Quo(DefaultCurrSqrtPrice.PowerInteger(2)).Dec()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: tracked #6064
// TODO: this is done to maintain state-compatibility with v19.x | ||
// Remove after https://github.com/osmosis-labs/osmosis/issues/6064 is complete. | ||
spotPrice.ChopPrecisionMut(osmomath.PrecisionDec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note tracked: #6064
// TODO: remove truncation before https://github.com/osmosis-labs/osmosis/issues/6064 is fully complete. | ||
return &types.QueryDenomSpotPriceResponse{PoolID: feeToken.PoolID, SpotPrice: spotPrice.Dec()}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: tracked #6064
// Note: spotPrice truncation is done here for maintaining state-compatibility with v19.x | ||
// It should be changed to support full spot price precision before | ||
// https://github.com/osmosis-labs/osmosis/issues/6064 is complete | ||
return sdk.NewCoin(baseDenom, spotPrice.Dec().MulInt(inputFee.Amount).RoundInt()), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: tracked #6064
Merging with one approval since this is a low-risk change that will be backported to v19.x and tested for state-compat |
* feat: make PoolModuleI CalculateSpotPrice API return BigDec * updates * clean up * updates * updates (cherry picked from commit a171707) # Conflicts: # CHANGELOG.md # app/upgrades/v16/upgrades_test.go # app/upgrades/v17/upgrades_test.go # x/poolmanager/router.go
…6487) (#6495) Co-authored-by: roman <[email protected]>
Progress towards: #6064
What is the purpose of the change
This PR aims to continue the progress toward introducing a BigDec spot price query.
It should be state-compatible. The current clients are not expected to be broken because we truncate the spot price to 18 decimals before returning.
In the subsequent PR, a new spot price query is to be introduced that returns a 36-decimal spot price.
Testing and Verifying
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)