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 test): Add tests for inverse relationship testing between TickToSqrtPrice and PriceToTick #4060

Merged
merged 3 commits into from
Jan 18, 2023
Merged

(CL test): Add tests for inverse relationship testing between TickToSqrtPrice and PriceToTick #4060

merged 3 commits into from
Jan 18, 2023

Conversation

ThanhNhann
Copy link
Contributor

Closes: #3993

What is the purpose of the change

Add tests for inverse relationship testing between TickToSqrtPrice and PriceToTick

Brief Changelog

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no)
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no)
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented)

Comment on lines +260 to +277
"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),
Copy link
Member

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?

Copy link
Contributor Author

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

"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",
},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, LGTM

@ThanhNhann ThanhNhann changed the title Nhan/test inverse relationship tickprice (CL test): Add tests for inverse relationship testing between TickToSqrtPrice and PriceToTick Jan 18, 2023
Copy link
Member

@mattverse mattverse left a 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 🌮

Comment on lines +260 to +277
"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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, LGTM

@mattverse mattverse added the V:state/compatible/no_backport State machine compatible PR, depends on prior breaks label Jan 18, 2023
@mattverse mattverse merged commit 0b9e24f into osmosis-labs:main Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/concentrated-liquidity V:state/compatible/no_backport State machine compatible PR, depends on prior breaks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(CL Test): Add tests for inverse relationship testing between TickToPrice and PriceToTick
2 participants