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

feat: return bucket index of the current tick from LiquidityPerTickRange query #6805

Merged
merged 4 commits into from
Nov 1, 2023

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Nov 1, 2023

Closes: https://app.clickup.com/t/86a19jj0x

What is the purpose of the change

This PR is an update to the full range liquidity query. It adds a new return parameter that is the bucket index corresponding to the current tick.

This functionality is necessary for the SQS router in: #6785

By having this index, we don't have to iterate all ticks in search of the current tick. Instead, we can index into the desired bucket in constant time.

Testing and Verifying

Added unit test and also tested on localosmosis

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

@p0mvn p0mvn added A:automerge V:state/compatible/backport State machine compatible PR, should be backported A:backport/v20.x backport patches to v20.x branch labels Nov 1, 2023
@p0mvn p0mvn marked this pull request as ready for review November 1, 2023 22:29
Copy link
Contributor

@AlpinYukseloglu AlpinYukseloglu left a comment

Choose a reason for hiding this comment

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

LGTM assuming you've already tested the changes on localosmosis (I just reviewed code).

Had one comment around more clearly defining "bucket" for external users of this query but non-blocking so approving

// Returns index of the bucket that corresponds to the current tick.
// For cases where there is no liqudity in the bucket but there may be liquidity to the right, the value will be -1.
// For cases where there is no liquidity in the bucket but there may be liquidity to the left, the value will be len(liquidityDepthsForRange).
// Otherwise, the index points to the bucket that corresponds to the current tick.
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be useful to more concretely define "bucket" vs. "tick" either here or in docs

Copy link
Member

Choose a reason for hiding this comment

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

The docs defines terminologies for these AFAIR!

Copy link
Member Author

Choose a reason for hiding this comment

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

- `Tick` - a unit that has a 1:1 mapping with price
- `Bucket` - an area between two initialized ticks.

@mergify mergify bot merged commit 9755013 into main Nov 1, 2023
3 checks passed
@mergify mergify bot deleted the roman/cl-full-range-query branch November 1, 2023 22:48
mergify bot pushed a commit that referenced this pull request Nov 1, 2023
…nge query (#6805)

Closes: https://app.clickup.com/t/86a19jj0x

## What is the purpose of the change

This PR is an update to the full range liquidity query. It adds a new return parameter that is the bucket index corresponding to the current tick.

This functionality is necessary for the SQS router in: #6785

By having this index, we don't have to iterate all ticks in search of the current tick. Instead, we can index into the desired bucket in constant time.

## Testing and Verifying

Added unit test and also tested on localosmosis

## Documentation and Release Note

  - [x] Does this pull request introduce a new feature or user-facing behavior changes?
  - [x] Changelog entry added to `Unreleased` section of `CHANGELOG.md`?

Where is the change documented?
  - [ ] Specification (`x/{module}/README.md`)
  - [ ] Osmosis documentation site
  - [ ] Code comments?
  - [ ] N/A

(cherry picked from commit 9755013)
p0mvn added a commit that referenced this pull request Nov 2, 2023
…nge query (#6805) (#6806)

Closes: https://app.clickup.com/t/86a19jj0x

## What is the purpose of the change

This PR is an update to the full range liquidity query. It adds a new return parameter that is the bucket index corresponding to the current tick.

This functionality is necessary for the SQS router in: #6785

By having this index, we don't have to iterate all ticks in search of the current tick. Instead, we can index into the desired bucket in constant time.

## Testing and Verifying

Added unit test and also tested on localosmosis

## Documentation and Release Note

  - [x] Does this pull request introduce a new feature or user-facing behavior changes?
  - [x] Changelog entry added to `Unreleased` section of `CHANGELOG.md`?

Where is the change documented?
  - [ ] Specification (`x/{module}/README.md`)
  - [ ] Osmosis documentation site
  - [ ] Code comments?
  - [ ] N/A

(cherry picked from commit 9755013)

Co-authored-by: Roman <[email protected]>
@github-actions github-actions bot mentioned this pull request Apr 1, 2024
@github-actions github-actions bot mentioned this pull request Apr 15, 2024
@github-actions github-actions bot mentioned this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge A:backport/v20.x backport patches to v20.x branch C:CLI C:x/concentrated-liquidity V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants