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 Incentives] Remove ability to add to frozen positions #4508

Merged
merged 3 commits into from
Mar 26, 2023

Conversation

stackman27
Copy link
Contributor

Closes: #4482

What is the purpose of the change

Now that we key positions by joinTime and freezeDuration, it is no longer possible for people to add to an existing position.

Brief Changelog

-> users cannot update their existing position, instead we create new position

Testing and Verifying

remove unwanted tests

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)

@stackman27 stackman27 requested a review from czarcas7ic March 6, 2023 05:22
@stackman27 stackman27 added V:state/compatible/backport State machine compatible PR, should be backported V:state/breaking State machine breaking PR and removed V:state/compatible/backport State machine compatible PR, should be backported labels Mar 6, 2023
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.

Good work, left one comment about a logic-related issue

@@ -68,7 +68,7 @@ func (k Keeper) initOrUpdatePosition(

// TODO: consider deleting position if liquidity becomes zero

err = k.initOrUpdatePositionUptime(ctx, poolId, position, owner, lowerTick, upperTick, liquidityDelta, joinTime, freezeDuration)
err = k.initPositionUptime(ctx, poolId, position, owner, lowerTick, upperTick, liquidityDelta, joinTime, freezeDuration)
Copy link
Member

Choose a reason for hiding this comment

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

So we remove the ability to update the incentives accumulator but positions themselves still seem to be treated as if they are allowed to have liquidity increased for the same freeze duration. Shouldn't we disallow that as well?

Copy link
Contributor Author

@stackman27 stackman27 Mar 6, 2023

Choose a reason for hiding this comment

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

i dont understand how can "position be allowed to have liquidity increase for same freeze duration", if there is any change in liquidity we update JoinTime thus creating new position, is that not the case?

@stackman27 stackman27 marked this pull request as draft March 7, 2023 07:24
@stackman27 stackman27 marked this pull request as ready for review March 7, 2023 19:13
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.

Will finish review soon, just wanted to get these nits out there while I finished a few other tasks

s.Require().True(hasPosition)

// Check position state
s.validatePositionUpdate(s.Ctx, tc.poolId, s.TestAccs[0], tc.lowerTick, tc.upperTick, defaultJoinTime, tc.freezeDuration, tc.liquidityAmount)
s.validatePositionUpdate(s.Ctx, tc.poolId, s.TestAccs[0], tc.lowerTick, tc.upperTick, DefaultJoinTime, tc.freezeDuration, tc.liquidityAmount)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have assertions around uptime accumulators being updated the way we expect them to be - only on initialization. Please add tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added!

@stackman27 stackman27 force-pushed the sis/cl-inc-remove-update branch from dd72895 to d692411 Compare March 9, 2023 00:31
@@ -77,6 +77,13 @@ func (k Keeper) createPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddr
}
}

if !k.hasFullPosition(ctx, poolId, owner, lowerTick, upperTick, joinTime, freezeDuration) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@p0mvn not sure why we have to check if the position is frozen or not as you suggested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

talked to @AlpinYukseloglu about this and here's a quick tldr is

"currently we donot support 0sec uptime therefore positions are not frozen from 0sec-60sec (min supported uptime is 1min). I think in future we are planning on adding 0sec uptime so that all positions are frozen to begin with"

for the sake of this PR I added frozen check and made a note to remove it once we add 0sec supported uptime

@stackman27 stackman27 requested review from czarcas7ic and p0mvn March 9, 2023 00:50
@stackman27 stackman27 force-pushed the sis/cl-inc-remove-update branch 8 times, most recently from 742ead5 to 9de86de Compare March 16, 2023 07:21
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. Left a few minor comments

go.work.sum Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't be pushing go.work.sum changes (odd that this made it in since it's in .gitignore)

Comment on lines 82 to 83
if !hasFullPosition {
err = k.initPositionUptime(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, freezeDuration)
if err != nil {
return sdk.Int{}, sdk.Int{}, sdk.Dec{}, time.Time{}, err
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we not error in the else case of this if it should not be possible to have the position with the same key due to joinTime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i didn't error for the <1min uptime case where one could modify position from 0sec to 60sec, but since we added 1nano second uptime, i'll add error

@stackman27
Copy link
Contributor Author

stackman27 commented Mar 16, 2023

Thank you @AlpinYukseloglu and @roman for comments. Resolved all your feedbacks!

@stackman27 stackman27 force-pushed the sis/cl-inc-remove-update branch 3 times, most recently from 55214cd to 6af866c Compare March 17, 2023 21:50
@stackman27 stackman27 requested a review from p0mvn March 17, 2023 21:52
return sdk.Int{}, sdk.Int{}, sdk.Dec{}, time.Time{}, err
}
} else {
return sdk.Int{}, sdk.Int{}, sdk.Dec{}, time.Time{}, types.PositionNotFoundError{PoolId: poolId, LowerTick: lowerTick, UpperTick: upperTick, JoinTime: joinTime, FreezeDuration: freezeDuration}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a test covering this?

Also, this should not be a PositionNotFoundError. We should have a new one for attempting to add to an existing position

Copy link
Contributor Author

@stackman27 stackman27 Mar 18, 2023

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

The linked test seems to cover another function.

We should have a direct test for createPosition in lp_test.go for this. I think the commented-out test that was removed can be converted to cover this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stackman27 stackman27 force-pushed the sis/cl-inc-remove-update branch from efb0ba7 to f60e6b5 Compare March 18, 2023 00:03
@stackman27 stackman27 requested a review from p0mvn March 18, 2023 00:03
@stackman27 stackman27 force-pushed the sis/cl-inc-remove-update branch 3 times, most recently from caa2d36 to 40dc177 Compare March 24, 2023 22:26
@stackman27 stackman27 force-pushed the sis/cl-inc-remove-update branch from b0d4419 to 2488f07 Compare March 25, 2023 00:26
@@ -130,7 +140,7 @@ func (k Keeper) withdrawPosition(ctx sdk.Context, owner sdk.AccAddress, position
}

// If the position is still frozen, claim and forfeit any accrued incentives for the position.
isPositionFrozen := position.JoinTime.Add(position.FreezeDuration).After(ctx.BlockTime())
isPositionFrozen := k.IsPositionStillFrozen(ctx, position.JoinTime, position.FreezeDuration)
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we're removing freezeDuration, we should be able to remove this check and just call claimAllIncentivesForPosition. It might make sense to rebase this PR to the latest CL PR that has these changes.

@AlpinYukseloglu
Copy link
Contributor

Merging this understanding that it will cause some minor conflicts in #4724 to not block this small change on that large PR

@AlpinYukseloglu AlpinYukseloglu merged commit c20a2b1 into main Mar 26, 2023
@AlpinYukseloglu AlpinYukseloglu deleted the sis/cl-inc-remove-update branch March 26, 2023 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants