Skip to content

Commit

Permalink
adams suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
stackman27 committed Aug 3, 2023
1 parent 91a0d97 commit e3b8139
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/upgrades/v17/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,16 @@ func CreateUpgradeHandler(
CosmwasmWeight: 300,
})

// get all the existing CL pools
pools, err := keepers.ConcentratedLiquidityKeeper.GetPools(ctx)
// get all the existing CL pool Ids
poolIds, err := keepers.ConcentratedLiquidityKeeper.GetPoolIds(ctx)
if err != nil {
return nil, err
}

for _, pool := range pools {
// migrate twap records for CL Pools
err = FlipTwapSpotPriceRecords(ctx, []uint64{pool.GetId()}, keepers)
if err != nil {
return nil, err
}
// migrate twap records for CL Pools
err = FlipTwapSpotPriceRecords(ctx, poolIds, keepers)
if err != nil {
return nil, err
}

return migrations, nil
Expand Down
16 changes: 16 additions & 0 deletions x/concentrated-liquidity/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ func (k Keeper) GetPools(ctx sdk.Context) ([]poolmanagertypes.PoolI, error) {
)
}

// GetPoolIds returns all the poolIds for CL Pools
func (k Keeper) GetPoolIds(ctx sdk.Context) ([]uint64, error) {
poolIds := []uint64{}
// get all the existing CL pools
pools, err := k.GetPools(ctx)
if err != nil {
return nil, err
}

for _, pool := range pools {
poolIds = append(poolIds, pool.GetId())
}

return poolIds, nil
}

// setPool stores a ConcentratedPoolExtension in the Keeper's KVStore.
// It returns an error if the provided pool is not of type *model.Pool.
func (k Keeper) setPool(ctx sdk.Context, pool types.ConcentratedPoolExtension) error {
Expand Down

0 comments on commit e3b8139

Please sign in to comment.