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

Remove extra code path in TickToPrice (backport #7598) #7602

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions x/concentrated-liquidity/math/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,8 @@ func TickToPrice(tickIndex int64) (osmomath.BigDec, error) {
numAdditiveTicks := tickIndex - (geometricExponentDelta * geometricExponentIncrementDistanceInTicks)
additiveSpacing := currentAdditiveIncrementInTicks.MulInt64(numAdditiveTicks)

var price osmomath.BigDec

// Finally, we can calculate the price
// Note that to maintain backwards state-compatibility, we utilize the
// original math based on 18 precision decimal on the range of [MinInitializedTick, tick(MaxSpotPrice)]
// For the newly extended range of [MinInitializedTickV2, MinInitializedTick), we use the new math
// based on 36 precision decimal.
// TODO: Delete this code difference, it yields the exact same number every time.
if tickIndex < types.MinInitializedTick {
price = additiveSpacing.AddMut(powTenBigDec(geometricExponentDelta))
} else {
price = osmomath.BigDecFromDecMut((additiveSpacing.Dec()).AddMut(PowTenInternal(geometricExponentDelta)))
}
price := additiveSpacing.AddMut(powTenBigDec(geometricExponentDelta))

// defense in depth, this logic would not be reached due to use having checked if given tick is in between
// min tick and max tick.
Expand Down