-
-
Notifications
You must be signed in to change notification settings - Fork 12
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: bug decrease liquidity #140
Conversation
@@ -226,8 +214,15 @@ func (k Keeper) DecreaseLiquidity(ctx sdk.Context, sender sdk.AccAddress, positi | |||
return math.Int{}, math.Int{}, errorsmod.Wrapf(types.ErrPoolNotFound, "pool id: %d", position.PoolId) | |||
} | |||
|
|||
liquiditDelta := liquidity.Neg() | |||
amountBase, amountQuote, lowerTickEmpty, upperTickEmpty, err := k.UpdatePosition(ctx, position.PoolId, sender, position.LowerTick, position.UpperTick, liquiditDelta, positionId) | |||
if liquidity.Equal(position.Liquidity) { |
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.
Question:
Is if liquidity.Equal(position.Liquidity) {
really needed?
I am thinking of a possibility that we should collect fees anytime
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.
Need to dig the relation with k.SetAccumulatorPositionFeeAccumulator
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 see a problem since this function is only called for DecreaseLiquidity and IncreaseLiquidity.
simple and good.
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've already merged #141, and to avoid confusion, it's better to change the spec from v0.3.x.
Overview
Fixed a problem in the DecreaseLiquidity and IncreaseLiquidity process that caused incorrect settlements.
Rewards are now correctly earned with IncreaseLiquidity and DecreaseLiquidity.
Details
L149-159
Remove unnecessary SetPosition. No need to update DB here.
R217-225
Changed so that rewards are claimed before positions are deleted. Fixed typo
liquiditDelta
L247-L264
The location of the rewards claim was changed before the position was changed (R217-225). Other logic has been integrated into the
UpdatePosition
function to avoid wasteful processing.R356-R374 & R382-R400
The deleted L247-L264 process has been integrated here. To avoid both deleting and updating positions.