Skip to content

Commit

Permalink
address Roman's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jan 11, 2023
1 parent b021858 commit e826b66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 8 additions & 4 deletions x/concentrated-liquidity/internal/math/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
"github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/types"
)

var sdkNineDec = sdk.NewDec(9)
var sdkTenDec = sdk.NewDec(10)
var (
sdkNineDec = sdk.NewDec(9)
sdkTenDec = sdk.NewDec(10)
sdkEighteenDec = sdk.NewDec(18)
sdkThirtyEightDec = sdk.NewDec(38)
)

// TicksToPrice returns the price for the lower and upper ticks.
// Returns error if fails to calculate price.
Expand Down Expand Up @@ -167,7 +171,7 @@ func powTenBigDec(exponent sdk.Int) osmomath.BigDec {
// This allows for a min spot price of 0.000000000000000001 and a max spot price of 100000000000000000000000000000000000000 for every exponentAtPriceOne value
func GetMinAndMaxTicksFromExponentAtPriceOne(exponentAtPriceOne sdk.Int) (minTick, maxTick int64) {
geometricExponentIncrementDistanceInTicks := sdkNineDec.Mul(powTen(exponentAtPriceOne.Neg()))
minTick = sdk.NewDec(18).Mul(geometricExponentIncrementDistanceInTicks).Neg().RoundInt().Int64()
maxTick = sdk.NewDec(38).Mul(geometricExponentIncrementDistanceInTicks).RoundInt().Int64()
minTick = sdkEighteenDec.Mul(geometricExponentIncrementDistanceInTicks).Neg().RoundInt64()
maxTick = sdkThirtyEightDec.Mul(geometricExponentIncrementDistanceInTicks).TruncateInt64()
return minTick, maxTick
}
1 change: 0 additions & 1 deletion x/concentrated-liquidity/swaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ func (s *KeeperTestSuite) TestCalcAndSwapOutAmtGivenIn() {
newUpperTick, err := math.PriceToTick(test.newUpperPrice, pool.GetPrecisionFactorAtPriceOne())
s.Require().NoError(err)

// TODO: Dont hardcode
lowerPrice, err := math.TickToPrice(newLowerTick, pool.GetPrecisionFactorAtPriceOne())
s.Require().NoError(err)
lowerSqrtPrice, err := lowerPrice.ApproxSqrt()
Expand Down

0 comments on commit e826b66

Please sign in to comment.