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

feat: transfer cl position to new owner #6623

Merged
merged 36 commits into from
Oct 11, 2023
Merged

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Oct 3, 2023

Closes: #6541

What is the purpose of the change

Allows a user to provide a list of position IDs that they own, collect all rewards, and transfer the ownership of that position to a new address.

This is achieved slightly different than how the issue described. Instead of withdrawing and creating a new position, we change the necessary state entries. The method described in the issue was discarded when I realized the amount of the liquidity the position has before and after withdrawing would never be 1:1, while the method done here achieves an exact duplicate of the position, with the only change being the owner.

Some drive by changes:

  1. No longer call the SendCoins or FundCommunityPool on empty coins for incentive retrieval
  2. No longer call SendCoins on empty coins for spread rewards retrieval
  3. Adds a underlyingPositionsValue method to determine the coins value for a list of positionIds

Testing and Verifying

Rigorous testing done on the method itself as well as the events that are emitted, and any method that was created in this PR.

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

@czarcas7ic czarcas7ic added the V:state/breaking State machine breaking PR label Oct 3, 2023
@czarcas7ic
Copy link
Member Author

@devbot-wizard help

@devbot-wizard
Copy link
Collaborator

Hi! I'm DevBot, a bot that helps with common tasks in the development process. Commands:

  • devbot fix: Fix basic errors in the PR. (e.g. imports, changelog conflicts, go mod conflicts)
  • devbot merge base: Merge the base branch into the PR branch.
  • devbot add changelog [misc/feat/bug/api/sec] [message]: Add a changelog entry to the PR. (e.g. devbot add changelog feat Added a new feature)
    • If message is blank, defaults to PR title.
  • devbot re-pr: Re-PR the PR, useful for external contributors where we have no edit perms.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2023

Important Notice

This PR modifies an in-repo Go module. It is one of:

  • osmomath
  • osmoutils
  • x/ibc-hooks
  • x/epochs

The dependent Go modules, especially the root one, will have to be
updated to reflect the changes. Failing to do so might cause e2e to fail.

Please follow the instructions below:

  1. Open https://github.com/osmosis-labs/osmosis/actions/workflows/go-mod-auto-bump.yml
  2. Provide the current branch name
  3. On success, confirm if an automated commit corretly updated the go.mod and go.sum files

Please let us know if you need any help.

@czarcas7ic
Copy link
Member Author

devbot add changelog feat

github-actions and others added 2 commits October 3, 2023 04:06
Comment on lines +177 to +181
// Early return, emit no events if there is no spread rewards to claim.
if spreadRewardsClaimed.IsZero() {
return sdk.Coins{}, nil
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Slightly unrelated to this PR, but I think the change makes sense. I realized we would emit a bank send event coming from collecting spread rewards on every call, even when there are no spread rewards to claim. This logic added is similar to the incentives claiming logic that ends early if there are no incentives to claim.

Comment on lines +763 to +774
if !collectedIncentivesForPosition.IsZero() {
if err := k.bankKeeper.SendCoins(ctx, pool.GetIncentivesAddress(), sender, collectedIncentivesForPosition); err != nil {
return sdk.Coins{}, sdk.Coins{}, err
}
}

// Send the forfeited incentives to the community pool from the pool's address.
err = k.communityPoolKeeper.FundCommunityPool(ctx, forfeitedIncentivesForPosition, pool.GetIncentivesAddress())
if err != nil {
return sdk.Coins{}, sdk.Coins{}, err
if !forfeitedIncentivesForPosition.IsZero() {
err = k.communityPoolKeeper.FundCommunityPool(ctx, forfeitedIncentivesForPosition, pool.GetIncentivesAddress())
if err != nil {
return sdk.Coins{}, sdk.Coins{}, err
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Similar to the comment above, there is no need to run this logic and emit events if the value is zero.

@czarcas7ic czarcas7ic closed this Oct 3, 2023
@czarcas7ic czarcas7ic reopened this Oct 3, 2023
@czarcas7ic czarcas7ic added V:state/breaking State machine breaking PR and removed V:state/breaking State machine breaking PR labels Oct 3, 2023
@czarcas7ic czarcas7ic closed this Oct 8, 2023
@czarcas7ic czarcas7ic reopened this Oct 8, 2023
@@ -159,7 +160,7 @@ func (s *KeeperTestSuite) TestAddToPosition_Events() {
}{
"happy path": {
expectedAddedToPositionEvent: 1,
expectedMessageEvents: 5,
expectedMessageEvents: 4,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know what caused the drop here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that we do an early return on spread rewards claim when there are no spread rewards, we emit one less event.

return types.PositionOwnerMismatchError{PositionOwner: position.Address, Sender: sender.String()}
}

// If the position has an active underlying lock, we cannot transfer it.
Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify, the implication is that superfluid positions can't be transferred right?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is correct, it is beyond the scope of requirements for this feature

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM.

I'm wondering if we could integrate this into the fuzz test suite to ensure the system continues being operational after position transfers.

Additionally, we should make sure that we test this on edgenet where bug bash would be happening

position, err := s.App.ConcentratedLiquidityKeeper.GetPosition(ctx, positionId)
s.Require().NoError(err)

// We fund the account with roundedInt because, there occurs
Copy link
Member

Choose a reason for hiding this comment

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

incomplete sentence

Copy link
Member Author

@czarcas7ic czarcas7ic Oct 11, 2023

Choose a reason for hiding this comment

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

comment was outdated, I meant to remove the entire thing when I no longer funded with roundedInt but only removed it partially. Fixed here 04a3a68

@czarcas7ic czarcas7ic closed this Oct 11, 2023
@czarcas7ic czarcas7ic reopened this Oct 11, 2023
@czarcas7ic
Copy link
Member Author

Added transfer position to fuzz test 0b8367a

@czarcas7ic czarcas7ic merged commit eff0deb into main Oct 11, 2023
@czarcas7ic czarcas7ic deleted the adam/transfer-position-cl branch October 11, 2023 20:27
pysel pushed a commit that referenced this pull request Oct 17, 2023
* transer cl position

* Auto: update go.mod after push to adam/transfer-position-cl that modified dependencies locally

* changelog

* remove commented out logic

* Update CHANGELOG.md

* add godoc and test for ParseUint64SliceToString

* add godoc

* add incentives and spread rewards to message server test

* expand message server test

* further expand test

* godoc

* Auto: update go.mod after push to adam/transfer-position-cl that modified dependencies locally

* use helper methods

* modify array diff method

* Auto: update go.mod after push to adam/transfer-position-cl that modified dependencies locally

* address test

* last test fix

* Update x/concentrated-liquidity/client/cli/tx.go

Co-authored-by: Matt, Park <[email protected]>

* Update osmoutils/compare.go

Co-authored-by: Roman <[email protected]>

* rename all uses

* sort the result, add tests for both sorted and unsorted

* extend tests

* unrelated lint

* add testing invariants comment to TestTransferPositions

* add why actual amount should be less than expected

* Auto: update go.mod after push to adam/transfer-position-cl that modified dependencies locally

* regen docs

* comment explaining trasferPosition in proto

* add fixed gas consumption

* fix scaling gas charge and add parser test case

* Auto: update go.mod after push to adam/transfer-position-cl that modified dependencies locally

* remove incorrect comment

* tidy osmomath

* transfer random position

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: Roman <[email protected]>
Co-authored-by: alpo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add message for transferring CL position ownership
5 participants