-
Notifications
You must be signed in to change notification settings - Fork 609
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
Conversation
Lgtm on first pass! Will review test changes in more detail later. |
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.
This looks good, nice work. Will wait for second approval since this touches core logic.
We may have to fix the osmoutils version if E2E fails |
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.
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 |
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.
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 |
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.
Great synthesis!
Progress towards #5854
What is the purpose of the change
This PR fixes a negative interval accumulation edge case bug by simply replacing
Sub
withSafeSub
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
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)