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

[CL]: Fix incorrect bound check/chain halt vector #5557

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/math/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func GetLiquidityFromAmounts(sqrtPrice, sqrtPriceA, sqrtPriceB sdk.Dec, amount0,
if sqrtPrice.LTE(sqrtPriceA) {
// If the current price is less than or equal to the lower tick, then we use the liquidity0 formula.
liquidity = Liquidity0(amount0, sqrtPriceA, sqrtPriceB)
} else if sqrtPrice.LTE(sqrtPriceB) {
} else if sqrtPrice.LT(sqrtPriceB) {
// If the current price is between the lower and upper ticks (non-inclusive of the lower tick but inclusive of the upper tick),
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
// then we use the minimum of the liquidity0 and liquidity1 formulas.
liquidity0 := Liquidity0(amount0, sqrtPrice, sqrtPriceB)
Expand Down
10 changes: 10 additions & 0 deletions x/concentrated-liquidity/math/math_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,16 @@ func (suite *ConcentratedMathTestSuite) TestGetLiquidityFromAmounts() {
expectedLiquidity0: sdk.MustNewDecFromStr("7.706742302257039729"),
expectedLiquidity1: sdk.MustNewDecFromStr("4.828427124746190095"),
},
"current sqrt price on upper bound": {
currentSqrtP: sqrt5500,
sqrtPHigh: sqrt5500,
sqrtPLow: sqrt4545,
amount0Desired: sdk.ZeroInt(),
amount1Desired: sdk.NewInt(1000000),
// Liquidity1 = amount1 / (sqrtPriceB - sqrtPriceA)
// https://www.wolframalpha.com/input?i=1000000%2F%2874.161984870956629487-67.416615162732695594%29
expectedLiquidity: "148249.842967213952971325",
},
}

for name, tc := range testCases {
Expand Down