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

fix/test/docs: negative interval accumulation with spread rewards #5869

Merged
merged 8 commits into from
Jul 31, 2023

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Jul 18, 2023

Progress towards #5854

What is the purpose of the change

This PR fixes a negative interval accumulation edge case bug by simply replacing Sub with SafeSub where applicable.

The tests are extended to cover claiming rewards below, inside, and above the position after it is initialized.

Note, that incentive rewards still need to be tested and potentially fixed. This PR only covers spread rewards.

Testing and Verifying

The global invariants are asserted, and the tests ensure that the appropriate amount is claimed from all positions in all cases.

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 the V:state/breaking State machine breaking PR label Jul 18, 2023
@github-actions github-actions bot added C:docs Improvements or additions to documentation C:app-wiring Changes to the app folder C:x/concentrated-liquidity labels Jul 18, 2023
@p0mvn p0mvn marked this pull request as ready for review July 18, 2023 15:51
@p0mvn p0mvn requested a review from czarcas7ic as a code owner July 18, 2023 15:51
@ValarDragon
Copy link
Member

Lgtm on first pass! Will review test changes in more detail later.

Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

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

This looks good, nice work. Will wait for second approval since this touches core logic.

@ValarDragon
Copy link
Member

We may have to fix the osmoutils version if E2E fails

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, good work!

if the current tick >= tick. As a result, when subtracting the lower tick snapshot from the upper,
the lower one is greater than or equal to the upper.

This is not an issue because it gets canceled out by the "interval accumulation outside at time t'" that is added to
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps the more important point here is that the accumulator value is still always strictly increasing, meaning that the diff between the values at t' and t are always positive.

This alone should be sufficient to make the feature sound, regardless of whether the initial negative value is ever "canceled out"

@@ -1244,6 +1244,76 @@ func (k Keeper) collectSpreadRewards(

This returns the amount of spread rewards collected by the user.

## Interval Accumulation
Copy link
Contributor

Choose a reason for hiding this comment

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

Great synthesis!

@AlpinYukseloglu AlpinYukseloglu merged commit 4637629 into main Jul 31, 2023
@AlpinYukseloglu AlpinYukseloglu deleted the roman/fix-neg-range-repro branch July 31, 2023 17:17
@github-actions github-actions bot mentioned this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:docs Improvements or additions to documentation C:x/concentrated-liquidity V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants