-
Notifications
You must be signed in to change notification settings - Fork 624
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
Conversation
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.
Good work, left one comment about a logic-related issue
x/concentrated-liquidity/position.go
Outdated
@@ -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) |
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.
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?
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.
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?
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.
Will finish review soon, just wanted to get these nits out there while I finished a few other tasks
x/concentrated-liquidity/lp_test.go
Outdated
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) |
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.
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
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.
added!
dd72895
to
d692411
Compare
x/concentrated-liquidity/lp.go
Outdated
@@ -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) { |
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.
@p0mvn not sure why we have to check if the position is frozen or not as you suggested?
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.
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
742ead5
to
9de86de
Compare
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. Left a few minor comments
go.work.sum
Outdated
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.
We shouldn't be pushing go.work.sum changes (odd that this made it in since it's in .gitignore)
x/concentrated-liquidity/lp.go
Outdated
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 | ||
} | ||
} |
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.
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
?
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.
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
Thank you @AlpinYukseloglu and @roman for comments. Resolved all your feedbacks! |
55214cd
to
6af866c
Compare
x/concentrated-liquidity/lp.go
Outdated
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} |
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.
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
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.
yup changed to PositionAlreadyExist Error and is covered here (inside incentives_test)
: https://github.com/osmosis-labs/osmosis/pull/4508/files#diff-91569dd5b56ddbfc9450f57de47bc13061e1daceaba154cab15b635d98912d19R1716-R1773
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.
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
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.
converted commented out test to cover this
https://github.com/osmosis-labs/osmosis/pull/4508/files#diff-8a43021241fc488af68dd6cdd7c762a85476f3aa8e44248784e9265c9ef0bbdfR799
efb0ba7
to
f60e6b5
Compare
caa2d36
to
40dc177
Compare
b0d4419
to
2488f07
Compare
@@ -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) |
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.
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.
Merging this understanding that it will cause some minor conflicts in #4724 to not block this small change on that large PR |
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
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)