Skip to content

Commit

Permalink
refactor: breaking CL tick to sqrt price math min spot price relaxati…
Browse files Browse the repository at this point in the history
…on (#6319)

* refactor: state-compatible big decimal tick to sqrt price conversions

* updates and clean ups

* lint

* refactor: breaking CL tick to sqrt price math min spot price relaxation

* add test skip
  • Loading branch information
p0mvn authored Sep 8, 2023
1 parent 8ac3efb commit 6b3273f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
10 changes: 10 additions & 0 deletions x/concentrated-liquidity/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ func (s *KeeperTestSuite) swapNearInitializedTickBoundary(r *rand.Rand, pool typ
}

func (s *KeeperTestSuite) swapNearTickBoundary(r *rand.Rand, pool types.ConcentratedPoolExtension, targetTick int64, zfo bool) (didSwap bool, fatalErr bool) {
// TODO: remove this limit upon completion of the refactor in:
// https://github.com/osmosis-labs/osmosis/issues/5726
// Due to an intermediary refactor step where we have
// full range positions created in the extended full range it
// sometimes tries to swap to the V2 MinInitializedTick that
// is not supported yet by the rest of the system.
if targetTick < types.MinInitializedTick {
return false, false
}

swapInDenom, swapOutDenom := zfoToDenoms(zfo, pool)
// TODO: Confirm accuracy of this method.
amountInRequired, curLiquidity, _ := s.computeSwapAmounts(pool.GetId(), pool.GetCurrentSqrtPrice(), targetTick, zfo, false)
Expand Down
12 changes: 0 additions & 12 deletions x/concentrated-liquidity/math/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,6 @@ func CalculateSqrtPriceToTick(sqrtPrice osmomath.BigDec) (tickIndex int64, err e
return 0, err
}

// TODO: remove this check. It is present to maintain backwards state-compatibility with
// v19.x and earlier major releases of Osmosis.
// Once https://github.com/osmosis-labs/osmosis/issues/5726 is fully complete,
// this should be removed.
//
// Backwards state-compatibility is maintained by having the swap and LP logic error
// here in case the price/tick falls below the origina minimum tick bounds that are
// consistent with v19.x and earlier release lines.
if tick < types.MinCurrentTick {
return 0, types.TickIndexMinimumError{MinTick: types.MinCurrentTick}
}

// We have a candidate bucket index `t`. We discern here if:
// * sqrtPrice in [TickToSqrtPrice(t - 1), TickToSqrtPrice(t))
// * sqrtPrice in [TickToSqrtPrice(t), TickToSqrtPrice(t + 1))
Expand Down
7 changes: 0 additions & 7 deletions x/concentrated-liquidity/math/tick_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,13 +833,6 @@ func TestCalculatePriceToTick(t *testing.T) {

// This test validates that conversions at the new initialized boundary are sound.
func TestSqrtPriceToTick_MinInitializedTickV2(t *testing.T) {

// TODO: remove this Skip(). It is present to maintain backwards state-compatibility with
// v19.x and earlier major releases of Osmosis.
// Once https://github.com/osmosis-labs/osmosis/issues/5726 is fully complete,
// this should be removed.
t.Skip()

minSqrtPrice, err := osmomath.MonotonicSqrtBigDec(types.MinSpotPriceV2)
require.NoError(t, err)

Expand Down

0 comments on commit 6b3273f

Please sign in to comment.