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: implement pool liquidity query in pool manager, deprecate the one in gamm #4951

Merged
merged 11 commits into from
Apr 25, 2023

Conversation

stackman27
Copy link
Contributor

@stackman27 stackman27 commented Apr 18, 2023

Closes: #4802

What is the purpose of the change

Implement total pool liquidity for frontends in pool manager. Deprecate the one in gamm and make it route through pool manager.

Brief Changelog

  • #4951 Implement pool liquidity query in pool manager, deprecate the one in gamm

Testing and Verifying

tested using localosmosis with state
output;

❯ 
❯ osmosisd q poolmanager total-pool-liquidity 1
liquidity:
- amount: "100000000000"
  denom: stake
- amount: "100000000000"
  denom: uosmo
❯ 
❯ 
❯ osmosisd q poolmanager total-pool-liquidity 2
liquidity:
- amount: "100000000000"
  denom: uion
- amount: "100000000000"
  denom: uosmo
❯ 
❯ 
❯ osmosisd q poolmanager total-pool-liquidity 3
liquidity:
- amount: "100000000000"
  denom: stake
- amount: "10000000000"
  denom: uion
- amount: "200000000000"
  denom: uosmo
❯ 
❯ 
❯ osmosisd q poolmanager total-pool-liquidity 4
liquidity:
- amount: "999999"
  denom: uion
- amount: "19999999999"
  denom: uosmo

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)

@github-actions github-actions bot added C:CLI C:x/gamm Changes, features and bugs related to the gamm module. C:x/poolmanager labels Apr 18, 2023
@stackman27 stackman27 marked this pull request as ready for review April 18, 2023 23:25
@stackman27 stackman27 added the V:state/breaking State machine breaking PR label Apr 18, 2023
@github-actions github-actions bot added the C:x/twap Changes to the twap module label Apr 18, 2023
Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

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

LGTM once test cases are ported over

x/poolmanager/router.go Show resolved Hide resolved
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.

Please restore x/gamm CLI and Matt's comment about tests

x/gamm/client/cli/query.go Outdated Show resolved Hide resolved
@stackman27
Copy link
Contributor Author

@p0mvn @mattverse imported tests and readded cli!

x/concentrated-liquidity/pool_test.go Show resolved Hide resolved
Comment on lines 2049 to 2050
// Create default CL pool
pool := s.PrepareConcentratedPool()
Copy link
Member

Choose a reason for hiding this comment

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

Please also add a test with non-cl pool e.g. balancer

Copy link
Contributor Author

@stackman27 stackman27 Apr 24, 2023

Choose a reason for hiding this comment

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

added default balancer asset check. let me know if that suffice

Comment on lines 2011 to 2036
name: "valid with 2 coins",
poolId: 1,
poolLiquidity: defaultCoins,
expectedResult: defaultCoins,
},
{
name: "valid with 1 coin",
poolId: 1,
poolLiquidity: sdk.NewCoins(defaultPoolCoinTwo),
expectedResult: sdk.NewCoins(defaultPoolCoinTwo),
},
{
// can only happen if someone sends extra tokens to pool
// address. Should not occur in practice.
name: "valid with 3 coins",
poolId: 1,
poolLiquidity: sdk.NewCoins(defaultPoolCoinTwo, defaultPoolCoinOne, nonPoolCool),
expectedResult: defaultCoins,
},
{
// this can happen if someone sends random dust to pool address.
name: "only non-pool coin - does not show up in result",
poolId: 1,
poolLiquidity: sdk.NewCoins(nonPoolCool),
expectedResult: sdk.Coins(nil),
},
Copy link
Member

Choose a reason for hiding this comment

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

Some of these tests are only relevant in the context of concentrated liquidity (looks like this is where they were copied from).

What makes sense to be tested here:

  • can route to CL module and get liquidity
  • can route to gamm module and get liquidity
  • some error cases specific to poolmanager

Please refactor the tests to be relevant for this level of abstraction

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

@p0mvn
Copy link
Member

p0mvn commented Apr 25, 2023

Merging since all earlier comments have been addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:x/concentrated-liquidity C:x/gamm Changes, features and bugs related to the gamm module. C:x/poolmanager C:x/twap Changes to the twap module V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants