Skip to content

Commit

Permalink
resolved feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
stackman27 committed May 17, 2023
1 parent 81c8a0f commit 9f88164
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
6 changes: 2 additions & 4 deletions x/concentrated-liquidity/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,6 @@ func (k Keeper) calcInAmtGivenOut(
return writeCtx, sdk.Coin{}, sdk.Coin{}, sdk.Int{}, sdk.Dec{}, sdk.Dec{}, err
}

fmt.Println("Desired: ", desiredTokenOut.Denom, tokenInDenom, asset0, asset1)

// check that the specified tokenOut matches one of the assets in the specified pool
if desiredTokenOut.Denom != asset0 && desiredTokenOut.Denom != asset1 {
return writeCtx, sdk.Coin{}, sdk.Coin{}, sdk.Int{}, sdk.Dec{}, sdk.Dec{}, types.TokenOutDenomNotInPoolError{TokenOutDenom: desiredTokenOut.Denom}
Expand Down Expand Up @@ -505,13 +503,13 @@ func (k Keeper) calcInAmtGivenOut(
// if no ticks are initialized (no users have created liquidity positions) then we return an error
nextTick, ok := swapStrategy.NextInitializedTick(ctx, poolId, swapState.tick.Int64())
if !ok {
return writeCtx, sdk.Coin{}, sdk.Coin{}, sdk.Int{}, sdk.Dec{}, sdk.Dec{}, types.UninitilizedTickError{NextTick: nextTick}
return writeCtx, sdk.Coin{}, sdk.Coin{}, sdk.Int{}, sdk.Dec{}, sdk.Dec{}, types.InvalidTickError{}
}

// utilizing the next initialized tick, we find the corresponding nextPrice (the target price)
sqrtPriceNextTick, err := math.TickToSqrtPrice(nextTick)
if err != nil {
return writeCtx, sdk.Coin{}, sdk.Coin{}, sdk.Int{}, sdk.Dec{}, sdk.Dec{}, types.TickToSqrtPriceConversionError{SqrtPriceNextTick: sqrtPriceNextTick}
return writeCtx, sdk.Coin{}, sdk.Coin{}, sdk.Int{}, sdk.Dec{}, sdk.Dec{}, types.TickToSqrtPriceConversionError{NextTick: nextTick}
}

sqrtPriceTarget := swapStrategy.GetSqrtTargetPrice(sqrtPriceNextTick)
Expand Down
12 changes: 2 additions & 10 deletions x/concentrated-liquidity/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,18 +816,10 @@ func (e SqrtRootCalculationError) Error() string {
return fmt.Sprintf("issue calculating square root of price limit %s", e.SqrtPriceLimit)
}

type UninitilizedTickError struct {
NextTick sdk.Int
}

func (e UninitilizedTickError) Error() string {
return fmt.Sprintf("there are no more ticks initialized to fill the swap %s", e.NextTick)
}

type TickToSqrtPriceConversionError struct {
SqrtPriceNextTick sdk.Dec
NextTick sdk.Int
}

func (e TickToSqrtPriceConversionError) Error() string {
return fmt.Sprintf("could not convert next tick (%v) to nextSqrtPrice", e.SqrtPriceNextTick)
return fmt.Sprintf("could not convert next tick to nextSqrtPrice (%v)", e.NextTick)
}

0 comments on commit 9f88164

Please sign in to comment.