Skip to content

Commit

Permalink
use new truncators in CalculatePriceToTick
Browse files Browse the repository at this point in the history
  • Loading branch information
pysel committed Sep 6, 2023
1 parent b89119f commit 8e267f2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions x/concentrated-liquidity/math/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"errors"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types"
)
Expand Down Expand Up @@ -166,10 +168,9 @@ func CalculatePriceToTick(price osmomath.BigDec) (tickIndex int64, err error) {
// N.B. this exists to maintain backwards compatibility with
// the old version of the function that operated on decimal with precision of 18.
if price.GTE(types.MinSpotPriceBigDec) {
// TODO: implement efficient big decimal truncation.
// It is acceptable to truncate price as the minimum we support is
// 10**-12 which is above the smallest value of sdk.Dec.
price = osmomath.BigDecFromDec(price.Dec())
price.ChopPrecisionMut(sdk.Precision)
}

// The approach here is to try determine which "geometric spacing" are we in.
Expand Down

0 comments on commit 8e267f2

Please sign in to comment.