-
Notifications
You must be signed in to change notification settings - Fork 608
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 test): Add tests for inverse relationship testing between TickToSqrtPrice and PriceToTick #4060
(CL test): Add tests for inverse relationship testing between TickToSqrtPrice and PriceToTick #4060
Conversation
"50000 to tick with -4 k at price one": { | ||
price: sdk.NewDec(50000), | ||
exponentAtPriceOne: sdk.NewInt(-4), | ||
tickExpected: "400000", | ||
}, | ||
"5.01 to tick with -2 k at price one": { | ||
price: sdk.MustNewDecFromStr("5.01"), | ||
exponentAtPriceOne: sdk.NewInt(-2), | ||
tickExpected: "401", | ||
}, | ||
"50000.01 to tick with -6 k at price one": { | ||
price: sdk.MustNewDecFromStr("50000.01"), | ||
exponentAtPriceOne: sdk.NewInt(-6), | ||
tickExpected: "40000001", | ||
}, | ||
"0.090000889 to tick with -8 k at price one": { | ||
price: sdk.MustNewDecFromStr("0.090000889"), | ||
exponentAtPriceOne: sdk.NewInt(-8), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, are these chose arbitrarily?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's from test cases of TestPriceToTick
function, I originally thought about creating my own test cases, but I think it's better to reuse it with the code have verified
osmosis/x/concentrated-liquidity/internal/math/tick_test.go
Lines 170 to 189 in 07de0b4
"50000 to tick with -4 k at price one": { | |
price: sdk.NewDec(50000), | |
exponentAtPriceOne: sdk.NewInt(-4), | |
tickExpected: "400000", | |
}, | |
"5.01 to tick with -2 k at price one": { | |
price: sdk.MustNewDecFromStr("5.01"), | |
exponentAtPriceOne: sdk.NewInt(-2), | |
tickExpected: "401", | |
}, | |
"50000.01 to tick with -6 k at price one": { | |
price: sdk.MustNewDecFromStr("50000.01"), | |
exponentAtPriceOne: sdk.NewInt(-6), | |
tickExpected: "40000001", | |
}, | |
"0.090000889 to tick with -8 k at price one": { | |
price: sdk.MustNewDecFromStr("0.090000889"), | |
exponentAtPriceOne: sdk.NewInt(-8), | |
tickExpected: "-999991110", | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @ThanhNhann LGTM 🌮
"50000 to tick with -4 k at price one": { | ||
price: sdk.NewDec(50000), | ||
exponentAtPriceOne: sdk.NewInt(-4), | ||
tickExpected: "400000", | ||
}, | ||
"5.01 to tick with -2 k at price one": { | ||
price: sdk.MustNewDecFromStr("5.01"), | ||
exponentAtPriceOne: sdk.NewInt(-2), | ||
tickExpected: "401", | ||
}, | ||
"50000.01 to tick with -6 k at price one": { | ||
price: sdk.MustNewDecFromStr("50000.01"), | ||
exponentAtPriceOne: sdk.NewInt(-6), | ||
tickExpected: "40000001", | ||
}, | ||
"0.090000889 to tick with -8 k at price one": { | ||
price: sdk.MustNewDecFromStr("0.090000889"), | ||
exponentAtPriceOne: sdk.NewInt(-8), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, LGTM
Closes: #3993
What is the purpose of the change
Add tests for inverse relationship testing between
TickToSqrtPrice
andPriceToTick
Brief Changelog
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)