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: using coins.Denoms() from sdk instead of osmoutils #7126

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions ingest/sqs/router/usecase/pools/routable_transmuter_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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/v21/ingest/sqs/domain"
cwpoolmodel "github.com/osmosis-labs/osmosis/v21/x/cosmwasmpool/model"
poolmanagertypes "github.com/osmosis-labs/osmosis/v21/x/poolmanager/types"
Expand All @@ -30,7 +29,7 @@ func (r *routableTransmuterPoolImpl) GetId() uint64 {

// GetPoolDenoms implements domain.RoutablePool.
func (r *routableTransmuterPoolImpl) GetPoolDenoms() []string {
return osmoutils.CoinsDenoms(r.Balances)
return r.Balances.Denoms()
}

// GetType implements domain.RoutablePool.
Expand Down
9 changes: 0 additions & 9 deletions osmoutils/coin_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// TODO: Get this into the SDK https://github.com/cosmos/cosmos-sdk/issues/12538
func CoinsDenoms(coins sdk.Coins) []string {
denoms := make([]string, len(coins))
for i, coin := range coins {
denoms[i] = coin.Denom
}
return denoms
}

// MinCoins returns the minimum of each denom between both coins.
// For now it assumes they have the same denoms.
// TODO: Replace with method in SDK once we update our version
Expand Down
3 changes: 1 addition & 2 deletions x/cosmwasmpool/model/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

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

"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v21/x/cosmwasmpool/cosmwasm/msg"
"github.com/osmosis-labs/osmosis/v21/x/cosmwasmpool/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v21/x/poolmanager/types"
Expand Down Expand Up @@ -141,7 +140,7 @@ func (p *Pool) SetWasmKeeper(wasmKeeper types.WasmKeeper) {
// GetPoolDenoms implements types.PoolI.
func (p *Pool) GetPoolDenoms(ctx sdk.Context) []string {
poolLiquidity := p.GetTotalPoolLiquidity(ctx)
return osmoutils.CoinsDenoms(poolLiquidity)
return poolLiquidity.Denoms()
}

func (p Pool) AsSerializablePool() poolmanagertypes.PoolI {
Expand Down
3 changes: 1 addition & 2 deletions x/gamm/keeper/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ func (k Keeper) GetPoolDenoms(ctx sdk.Context, poolId uint64) ([]string, error)
return nil, err
}

denoms := osmoutils.CoinsDenoms(pool.GetTotalPoolLiquidity(ctx))
return denoms, err
return pool.GetTotalPoolLiquidity(ctx).Denoms(), err
}

// setNextPoolId sets next pool Id.
Expand Down
3 changes: 1 addition & 2 deletions x/gamm/pool-models/balancer/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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/v21/x/gamm/pool-models/internal/cfmm_common"
"github.com/osmosis-labs/osmosis/v21/x/gamm/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v21/x/poolmanager/types"
Expand Down Expand Up @@ -987,5 +986,5 @@ func (p *Pool) AsSerializablePool() poolmanagertypes.PoolI {
// GetPoolDenoms implements types.CFMMPoolI.
func (p *Pool) GetPoolDenoms(ctx sdk.Context) []string {
liquidity := p.GetTotalPoolLiquidity(ctx)
return osmoutils.CoinsDenoms(liquidity)
return liquidity.Denoms()
}
3 changes: 1 addition & 2 deletions x/gamm/pool-models/stableswap/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
errorsmod "cosmossdk.io/errors"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v21/x/gamm/pool-models/internal/cfmm_common"
"github.com/osmosis-labs/osmosis/v21/x/gamm/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v21/x/poolmanager/types"
Expand Down Expand Up @@ -497,5 +496,5 @@ func (p *Pool) AsSerializablePool() poolmanagertypes.PoolI {
// GetPoolDenoms implements types.CFMMPoolI.
func (p *Pool) GetPoolDenoms(ctx sdk.Context) []string {
liquidity := p.GetTotalPoolLiquidity(ctx)
return osmoutils.CoinsDenoms(liquidity)
return liquidity.Denoms()
}
2 changes: 1 addition & 1 deletion x/gamm/simulation/sim_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func RandomJoinPoolMsg(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Context) (
if err != nil {
return nil, err
}
poolDenoms := osmoutils.CoinsDenoms(pool.GetTotalPoolLiquidity(ctx))
poolDenoms := pool.GetTotalPoolLiquidity(ctx).Denoms()

// get address that has all denoms from the randomly selected pool
sender, tokenIn, senderExists := sim.SelAddrWithDenoms(ctx, poolDenoms)
Expand Down
3 changes: 1 addition & 2 deletions x/twap/listeners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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/v21/x/twap"
"github.com/osmosis-labs/osmosis/v21/x/twap/types"

Expand Down Expand Up @@ -58,7 +57,7 @@ func (s *TestSuite) TestAfterPoolCreatedHook() {
s.RunBasicSwap(poolId)
}

denoms := osmoutils.CoinsDenoms(tc.poolCoins)
denoms := tc.poolCoins.Denoms()
denomPairs := types.GetAllUniqueDenomPairs(denoms)
expectedRecords := []types.TwapRecord{}
for _, denomPair := range denomPairs {
Expand Down
3 changes: 1 addition & 2 deletions x/twap/logic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/osmoutils/osmoassert"
gammtypes "github.com/osmosis-labs/osmosis/v21/x/gamm/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v21/x/poolmanager/types"
Expand Down Expand Up @@ -1323,7 +1322,7 @@ func (s *TestSuite) TestAfterCreatePool() {
s.Require().Equal(tc.poolId, poolId)
s.Require().NoError(err)

denoms := osmoutils.CoinsDenoms(tc.poolCoins)
denoms := tc.poolCoins.Denoms()
denomPairs := types.GetAllUniqueDenomPairs(denoms)
expectedRecords := []types.TwapRecord{}
for _, denomPair := range denomPairs {
Expand Down