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

refactor(poolmanager): GetPoolDenoms method on PoolI for SQS #6863

Merged
merged 8 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#6805](https://github.com/osmosis-labs/osmosis/pull/6805) return bucket index of the current tick from LiquidityPerTickRange query
* [#6530](https://github.com/osmosis-labs/osmosis/pull/6530) Improve error message when CL LP fails due to slippage bound hit.
* [#6863](https://github.com/osmosis-labs/osmosis/pull/6863) GetPoolDenoms method on PoolI interface in poolmanager

### Bug Fixes

Expand Down
42 changes: 42 additions & 0 deletions tests/mocks/cfmm_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/mocks/cl_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/mocks/pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions x/concentrated-liquidity/model/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,11 @@ func (p *Pool) ApplySwap(newLiquidity osmomath.Dec, newCurrentTick int64, newCur
func (p *Pool) AsSerializablePool() poolmanagertypes.PoolI {
return p
}

// GetPoolDenoms implements types.ConcentratedPoolExtension.
func (p *Pool) GetPoolDenoms(ctx sdk.Context) []string {
return []string{
p.GetToken0(),
p.GetToken1(),
}
}
7 changes: 7 additions & 0 deletions x/cosmwasmpool/model/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v20/x/cosmwasmpool/cosmwasm/msg"
"github.com/osmosis-labs/osmosis/v20/x/cosmwasmpool/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types"
Expand Down Expand Up @@ -137,6 +138,12 @@ func (p *Pool) SetWasmKeeper(wasmKeeper types.WasmKeeper) {
p.WasmKeeper = wasmKeeper
}

// GetPoolDenoms implements types.PoolI.
func (p *Pool) GetPoolDenoms(ctx sdk.Context) []string {
poolLiquidity := p.GetTotalPoolLiquidity(ctx)
return osmoutils.CoinsDenoms(poolLiquidity)
}

func (p Pool) AsSerializablePool() poolmanagertypes.PoolI {
return &CosmWasmPool{
ContractAddress: p.ContractAddress,
Expand Down
5 changes: 5 additions & 0 deletions x/cosmwasmpool/model/store_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ func (p CosmWasmPool) GetStoreModel() poolmanagertypes.PoolI {
func (p CosmWasmPool) SetWasmKeeper(wasmKeeper types.WasmKeeper) {
panic("CosmWasmPool.SetWasmKeeeper not implemented")
}

// GetPoolDenoms implements types.PoolI.
func (p *CosmWasmPool) GetPoolDenoms(ctx sdk.Context) []string {
panic("CosmWasmPool.GetPoolDenoms not implemented")
p0mvn marked this conversation as resolved.
Show resolved Hide resolved
}
7 changes: 7 additions & 0 deletions x/gamm/pool-models/balancer/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v20/x/gamm/pool-models/internal/cfmm_common"
"github.com/osmosis-labs/osmosis/v20/x/gamm/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types"
Expand Down Expand Up @@ -982,3 +983,9 @@ func (p *Pool) ExitSwapExactAmountOut(
func (p *Pool) AsSerializablePool() poolmanagertypes.PoolI {
return p
}

// GetPoolDenoms implements types.CFMMPoolI.
func (p *Pool) GetPoolDenoms(ctx sdk.Context) []string {
liquidity := p.GetTotalPoolLiquidity(ctx)
return osmoutils.CoinsDenoms(liquidity)
}
7 changes: 7 additions & 0 deletions x/gamm/pool-models/stableswap/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
errorsmod "cosmossdk.io/errors"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v20/x/gamm/pool-models/internal/cfmm_common"
"github.com/osmosis-labs/osmosis/v20/x/gamm/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types"
Expand Down Expand Up @@ -492,3 +493,9 @@ func applyScalingFactorMultiplier(scalingFactors []uint64) ([]uint64, error) {
func (p *Pool) AsSerializablePool() poolmanagertypes.PoolI {
return p
}

// GetPoolDenoms implements types.CFMMPoolI.
func (p *Pool) GetPoolDenoms(ctx sdk.Context) []string {
liquidity := p.GetTotalPoolLiquidity(ctx)
return osmoutils.CoinsDenoms(liquidity)
}
5 changes: 4 additions & 1 deletion x/poolmanager/types/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
proto "github.com/cosmos/gogoproto/proto"
proto "github.com/gogo/protobuf/proto"
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, what's the reason we're changing this from cosmos' gogo proto to the original one?

Copy link
Member

Choose a reason for hiding this comment

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

Correct, we need to switch this back, good catch (was likely merge conflict)

Copy link
Member Author

Choose a reason for hiding this comment

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

done


"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils"
Expand All @@ -23,6 +23,9 @@ type PoolI interface {
// Returns whether the pool has swaps enabled at the moment
IsActive(ctx sdk.Context) bool

// GetPoolDenoms returns the pool's denoms.
GetPoolDenoms(sdk.Context) []string
p0mvn marked this conversation as resolved.
Show resolved Hide resolved

// Returns the spot price of the 'base asset' in terms of the 'quote asset' in the pool,
// errors if either baseAssetDenom, or quoteAssetDenom does not exist.
// For example, if this was a UniV2 50-50 pool, with 2 ETH, and 8000 UST
Expand Down