diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 726834e0428..a602a98e888 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -410,7 +410,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.DistrKeeper, appKeepers.PoolManagerKeeper, appKeepers.EpochsKeeper, - appKeepers.SuperfluidKeeper, + appKeepers.GAMMKeeper, ) appKeepers.PoolIncentivesKeeper = &poolIncentivesKeeper appKeepers.PoolManagerKeeper.SetPoolIncentivesKeeper(appKeepers.PoolIncentivesKeeper) diff --git a/app/upgrades/v16/concentrated_pool.go b/app/upgrades/v16/concentrated_pool.go index 8e4042bc46b..a9eb3dd214d 100644 --- a/app/upgrades/v16/concentrated_pool.go +++ b/app/upgrades/v16/concentrated_pool.go @@ -7,7 +7,7 @@ import ( "github.com/osmosis-labs/osmosis/v16/app/keepers" clmodel "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/model" gammkeeper "github.com/osmosis-labs/osmosis/v16/x/gamm/keeper" - gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" "github.com/osmosis-labs/osmosis/v16/x/poolmanager" poolmanagertypes "github.com/osmosis-labs/osmosis/v16/x/poolmanager/types" ) @@ -70,8 +70,8 @@ func createCanonicalConcentratedLiquidityPoolAndMigrationLink(ctx sdk.Context, c // Set the migration link in x/gamm. // This will also migrate the CFMM distribution records to point to the new CL pool. - err = keepers.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, gammtypes.MigrationRecords{ - BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + err = keepers.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, gammmigration.MigrationRecords{ + BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: cfmmPoolId, ClPoolId: concentratedPool.GetId(), diff --git a/app/upgrades/v16/concentrated_pool_test.go b/app/upgrades/v16/concentrated_pool_test.go index bc3687fd03b..0346c6767fd 100644 --- a/app/upgrades/v16/concentrated_pool_test.go +++ b/app/upgrades/v16/concentrated_pool_test.go @@ -9,7 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v16/app/apptesting" v16 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v16" - gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" poolincentivestypes "github.com/osmosis-labs/osmosis/v16/x/pool-incentives/types" ) @@ -244,8 +244,8 @@ func (suite *ConcentratedUpgradeTestSuite) TestCreateCanonicalConcentratedLiquid // Validate migration record. migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx) suite.Require().NoError(err) - suite.Require().Equal(migrationInfo, gammtypes.MigrationRecords{ - BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + suite.Require().Equal(migrationInfo, gammmigration.MigrationRecords{ + BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: balancerId, ClPoolId: clPoolInState.GetId(), diff --git a/proto/osmosis/gamm/v1beta1/shared.proto b/proto/osmosis/gamm/v1beta1/shared.proto index 994f392b17a..e05944b7730 100644 --- a/proto/osmosis/gamm/v1beta1/shared.proto +++ b/proto/osmosis/gamm/v1beta1/shared.proto @@ -6,7 +6,7 @@ import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v16/x/gamm/types"; +option go_package = "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"; // MigrationRecords contains all the links between balancer and concentrated // pools diff --git a/x/concentrated-liquidity/bench_test.go b/x/concentrated-liquidity/bench_test.go index 500b039dd62..e78c8218e21 100644 --- a/x/concentrated-liquidity/bench_test.go +++ b/x/concentrated-liquidity/bench_test.go @@ -16,7 +16,7 @@ import ( clmodel "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer" - gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" ) type BenchTestSuite struct { @@ -102,8 +102,8 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p gammKeeper := s.App.GAMMKeeper // Create a link between the balancer and cl pool. - record := gammtypes.BalancerToConcentratedPoolLink{BalancerPoolId: gammPoolId, ClPoolId: clPoolId} - err = gammKeeper.ReplaceMigrationRecords(s.Ctx, []gammtypes.BalancerToConcentratedPoolLink{record}) + record := gammmigration.BalancerToConcentratedPoolLink{BalancerPoolId: gammPoolId, ClPoolId: clPoolId} + err = gammKeeper.ReplaceMigrationRecords(s.Ctx, []gammmigration.BalancerToConcentratedPoolLink{record}) s.Require().NoError(err) _, err = gammKeeper.GetLinkedConcentratedPoolID(s.Ctx, gammPoolId) diff --git a/x/concentrated-liquidity/incentives_test.go b/x/concentrated-liquidity/incentives_test.go index 212ff891ed8..ef8c178ab0b 100644 --- a/x/concentrated-liquidity/incentives_test.go +++ b/x/concentrated-liquidity/incentives_test.go @@ -18,6 +18,7 @@ import ( "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" poolincentivestypes "github.com/osmosis-labs/osmosis/v16/x/pool-incentives/types" ) @@ -1019,8 +1020,8 @@ func (s *KeeperTestSuite) TestUpdateUptimeAccumulatorsToNow() { // Create balancer pool and bond its shares balancerPoolId = s.setupBalancerPoolWithFractionLocked(tc.canonicalBalancerPoolAssets, sdk.OneDec()) s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx, - gammtypes.MigrationRecords{ - BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + gammmigration.MigrationRecords{ + BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()}, }, }, @@ -3589,8 +3590,8 @@ func (s *KeeperTestSuite) TestPrepareBalancerPoolAsFullRange() { balancerPoolId = 0 } else { s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx, - gammtypes.MigrationRecords{ - BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + gammmigration.MigrationRecords{ + BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()}, }, }, @@ -3723,8 +3724,8 @@ func (s *KeeperTestSuite) TestPrepareBalancerPoolAsFullRangeWithNonExistentPools } s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx, - gammtypes.MigrationRecords{ - BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + gammmigration.MigrationRecords{ + BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()}, }, }, @@ -3891,8 +3892,8 @@ func (s *KeeperTestSuite) TestClaimAndResetFullRangeBalancerPool() { // Link the balancer and CL pools s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx, - gammtypes.MigrationRecords{ - BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + gammmigration.MigrationRecords{ + BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: balancerPoolId, ClPoolId: clPoolId}, }, }) diff --git a/x/gamm/client/cli/tx.go b/x/gamm/client/cli/tx.go index 9bff956d001..e5d08bbc63c 100644 --- a/x/gamm/client/cli/tx.go +++ b/x/gamm/client/cli/tx.go @@ -14,6 +14,7 @@ import ( "github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/stableswap" "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" poolmanagertypes "github.com/osmosis-labs/osmosis/v16/x/poolmanager/types" "github.com/cosmos/cosmos-sdk/client" @@ -630,7 +631,7 @@ func ParseCoinsNoSort(coinsStr string) (sdk.Coins, error) { return sdk.NormalizeCoins(decCoins), nil } -func parseMigrationRecords(cmd *cobra.Command) ([]types.BalancerToConcentratedPoolLink, error) { +func parseMigrationRecords(cmd *cobra.Command) ([]gammmigration.BalancerToConcentratedPoolLink, error) { assetsStr, err := cmd.Flags().GetString(FlagMigrationRecords) if err != nil { return nil, err @@ -642,7 +643,7 @@ func parseMigrationRecords(cmd *cobra.Command) ([]types.BalancerToConcentratedPo return nil, errors.New("migration records should be a list of balancer pool id and concentrated pool id pairs") } - replaceMigrations := []types.BalancerToConcentratedPoolLink{} + replaceMigrations := []gammmigration.BalancerToConcentratedPoolLink{} i := 0 for i < len(assets) { balancerPoolId, err := strconv.Atoi(assets[i]) @@ -654,7 +655,7 @@ func parseMigrationRecords(cmd *cobra.Command) ([]types.BalancerToConcentratedPo return nil, err } - replaceMigrations = append(replaceMigrations, types.BalancerToConcentratedPoolLink{ + replaceMigrations = append(replaceMigrations, gammmigration.BalancerToConcentratedPoolLink{ BalancerPoolId: uint64(balancerPoolId), ClPoolId: uint64(clPoolId), }) diff --git a/x/gamm/keeper/genesis.go b/x/gamm/keeper/genesis.go index b9499cba619..73d9b16fbda 100644 --- a/x/gamm/keeper/genesis.go +++ b/x/gamm/keeper/genesis.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" ) // InitGenesis initializes the x/gamm module's state from a provided genesis @@ -36,7 +37,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState, unpack k.setTotalLiquidity(ctx, liquidity) if genState.MigrationRecords == nil { - k.SetMigrationRecords(ctx, types.MigrationRecords{}) + k.SetMigrationRecords(ctx, gammmigration.MigrationRecords{}) } else { k.SetMigrationRecords(ctx, *genState.MigrationRecords) } diff --git a/x/gamm/keeper/genesis_test.go b/x/gamm/keeper/genesis_test.go index 8e69be4eddc..32925378a05 100644 --- a/x/gamm/keeper/genesis_test.go +++ b/x/gamm/keeper/genesis_test.go @@ -7,9 +7,10 @@ import ( "github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" ) -var DefaultMigrationRecords = types.MigrationRecords{BalancerToConcentratedPoolLinks: []types.BalancerToConcentratedPoolLink{ +var DefaultMigrationRecords = gammmigration.MigrationRecords{BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: 1, ClPoolId: 4}, {BalancerPoolId: 2, ClPoolId: 5}, {BalancerPoolId: 3, ClPoolId: 6}, diff --git a/x/gamm/keeper/migrate.go b/x/gamm/keeper/migrate.go index d5dc3d2824a..48547c139f3 100644 --- a/x/gamm/keeper/migrate.go +++ b/x/gamm/keeper/migrate.go @@ -7,6 +7,7 @@ import ( "github.com/osmosis-labs/osmosis/osmoutils" cltypes "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" poolmanagertypes "github.com/osmosis-labs/osmosis/v16/x/poolmanager/types" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -57,17 +58,17 @@ func (k Keeper) MigrateUnlockedPositionFromBalancerToConcentrated(ctx sdk.Contex // GetAllMigrationInfo gets all existing links between Balancer Pool and Concentrated Pool, // wraps and returns them in `MigrationRecords`. -func (k Keeper) GetAllMigrationInfo(ctx sdk.Context) (types.MigrationRecords, error) { +func (k Keeper) GetAllMigrationInfo(ctx sdk.Context) (gammmigration.MigrationRecords, error) { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, types.KeyPrefixMigrationInfoBalancerPool) iter := prefixStore.Iterator(nil, nil) defer iter.Close() - balancerToClPoolLinks := []types.BalancerToConcentratedPoolLink{} + balancerToClPoolLinks := []gammmigration.BalancerToConcentratedPoolLink{} for ; iter.Valid(); iter.Next() { // balancer Pool Id - balancerToClPoolLink := types.BalancerToConcentratedPoolLink{} + balancerToClPoolLink := gammmigration.BalancerToConcentratedPoolLink{} balancerToClPoolLink.BalancerPoolId = sdk.BigEndianToUint64(iter.Key()) // concentrated Pool Id @@ -76,7 +77,7 @@ func (k Keeper) GetAllMigrationInfo(ctx sdk.Context) (types.MigrationRecords, er balancerToClPoolLinks = append(balancerToClPoolLinks, balancerToClPoolLink) } - migrationRecords := types.MigrationRecords{} + migrationRecords := gammmigration.MigrationRecords{} migrationRecords.BalancerToConcentratedPoolLinks = balancerToClPoolLinks return migrationRecords, nil } @@ -112,7 +113,7 @@ func (k Keeper) GetLinkedBalancerPoolID(ctx sdk.Context, concentratedPoolId uint // OverwriteMigrationRecordsAndRedirectDistrRecords sets the balancer to gamm pool migration info to the store and deletes all existing records // migrationInfo in state is completely overwitten by the given migrationInfo. // Additionally, the distribution record for the balancer pool is modified to redirect incentives to the new concentrated pool. -func (k Keeper) OverwriteMigrationRecordsAndRedirectDistrRecords(ctx sdk.Context, migrationInfo types.MigrationRecords) error { +func (k Keeper) OverwriteMigrationRecordsAndRedirectDistrRecords(ctx sdk.Context, migrationInfo gammmigration.MigrationRecords) error { store := ctx.KVStore(k.storeKey) // delete all existing migration records @@ -137,7 +138,7 @@ func (k Keeper) OverwriteMigrationRecordsAndRedirectDistrRecords(ctx sdk.Context } // SetMigrationRecords is used in initGenesis, setting the balancer to gamm pool migration info in store. -func (k Keeper) SetMigrationRecords(ctx sdk.Context, migrationInfo types.MigrationRecords) { +func (k Keeper) SetMigrationRecords(ctx sdk.Context, migrationInfo gammmigration.MigrationRecords) { store := ctx.KVStore(k.storeKey) for _, balancerToCLPoolLink := range migrationInfo.BalancerToConcentratedPoolLinks { @@ -198,7 +199,7 @@ func (k Keeper) redirectDistributionRecord(ctx sdk.Context, cfmmPoolId, clPoolId // 3) the balancer pool has exactly two tokens // 4) the denoms of the tokens in the balancer pool match the denoms of the tokens in the gamm pool // It also reorders records from lowest to highest balancer pool ID if they are not provided in order already. -func (k Keeper) validateRecords(ctx sdk.Context, records []types.BalancerToConcentratedPoolLink) error { +func (k Keeper) validateRecords(ctx sdk.Context, records []gammmigration.BalancerToConcentratedPoolLink) error { lastBalancerPoolID := uint64(0) balancerIdFlags := make(map[uint64]bool, len(records)) clIdFlags := make(map[uint64]bool, len(records)) @@ -284,7 +285,7 @@ func (k Keeper) validateRecords(ctx sdk.Context, records []types.BalancerToConce // ReplaceMigrationRecords gets the current migration records and replaces it in its entirety with the provided records. // It is checked for no err when a proposal is made, and executed when a proposal passes. -func (k Keeper) ReplaceMigrationRecords(ctx sdk.Context, records []types.BalancerToConcentratedPoolLink) error { +func (k Keeper) ReplaceMigrationRecords(ctx sdk.Context, records []gammmigration.BalancerToConcentratedPoolLink) error { err := k.validateRecords(ctx, records) if err != nil { return err @@ -307,13 +308,13 @@ func (k Keeper) ReplaceMigrationRecords(ctx sdk.Context, records []types.Balance // UpdateMigrationRecords gets the current migration records and only updates the records that are provided. // It is checked for no err when a proposal is made, and executed when a proposal passes. -func (k Keeper) UpdateMigrationRecords(ctx sdk.Context, records []types.BalancerToConcentratedPoolLink) error { +func (k Keeper) UpdateMigrationRecords(ctx sdk.Context, records []gammmigration.BalancerToConcentratedPoolLink) error { err := k.validateRecords(ctx, records) if err != nil { return err } - recordsMap := make(map[uint64]types.BalancerToConcentratedPoolLink, len(records)) + recordsMap := make(map[uint64]gammmigration.BalancerToConcentratedPoolLink, len(records)) // Set up a map of the existing records migrationInfos, err := k.GetAllMigrationInfo(ctx) @@ -329,7 +330,7 @@ func (k Keeper) UpdateMigrationRecords(ctx sdk.Context, records []types.Balancer recordsMap[record.BalancerPoolId] = record } - newRecords := []types.BalancerToConcentratedPoolLink{} + newRecords := []gammmigration.BalancerToConcentratedPoolLink{} // Iterate through the map and add all the records to a new list // if the clPoolId is 0, we remove the entire record @@ -346,7 +347,7 @@ func (k Keeper) UpdateMigrationRecords(ctx sdk.Context, records []types.Balancer // We now have a list of all previous records, as well as records that have been updated. // We can now remove all previous records and replace them with the new ones. - err = k.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, types.MigrationRecords{ + err = k.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, gammmigration.MigrationRecords{ BalancerToConcentratedPoolLinks: newRecords, }) if err != nil { diff --git a/x/gamm/keeper/migrate_test.go b/x/gamm/keeper/migrate_test.go index 9b11d491dbb..4fd490e3102 100644 --- a/x/gamm/keeper/migrate_test.go +++ b/x/gamm/keeper/migrate_test.go @@ -9,6 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" poolincentivestypes "github.com/osmosis-labs/osmosis/v16/x/pool-incentives/types" ) @@ -181,8 +182,8 @@ func (s *KeeperTestSuite) TestMigrate() { // Set up canonical link between balancer and cl pool if test.setupPoolMigrationLink { - record := types.BalancerToConcentratedPoolLink{BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()} - err = keeper.ReplaceMigrationRecords(s.Ctx, []types.BalancerToConcentratedPoolLink{record}) + record := gammmigration.BalancerToConcentratedPoolLink{BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()} + err = keeper.ReplaceMigrationRecords(s.Ctx, []gammmigration.BalancerToConcentratedPoolLink{record}) s.Require().NoError(err) } @@ -283,7 +284,7 @@ func (s *KeeperTestSuite) TestMigrate() { func (s *KeeperTestSuite) TestReplaceMigrationRecords() { tests := []struct { name string - testingMigrationRecords []types.BalancerToConcentratedPoolLink + testingMigrationRecords []gammmigration.BalancerToConcentratedPoolLink overwriteBalancerDenom0 string overwriteBalancerDenom1 string createFourAssetBalancerPool bool @@ -291,7 +292,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }{ { name: "Non existent balancer pool", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{{ BalancerPoolId: 5, ClPoolId: 3, }}, @@ -299,7 +300,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Non existent concentrated pool", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{{ BalancerPoolId: 1, ClPoolId: 5, }}, @@ -307,7 +308,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Adding two of the same balancer pool id at once should error", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 3, @@ -321,7 +322,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Adding two of the same cl pool id at once should error", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 3, @@ -335,7 +336,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Normal case with two records", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 3, @@ -349,7 +350,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Try to set one of the BalancerPoolIds to a cl pool Id", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 2, ClPoolId: 4, @@ -363,7 +364,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Try to set one of the ClPoolIds to a balancer pool Id", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 2, ClPoolId: 1, @@ -373,7 +374,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Mismatch denom0 between the two pools", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 3, @@ -384,7 +385,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Mismatch denom1 between the two pools", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 3, @@ -395,7 +396,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { }, { name: "Balancer pool has more than two tokens", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 5, ClPoolId: 3, @@ -458,8 +459,8 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { func (s *KeeperTestSuite) TestUpdateMigrationRecords() { tests := []struct { name string - testingMigrationRecords []types.BalancerToConcentratedPoolLink - expectedResultingRecords []types.BalancerToConcentratedPoolLink + testingMigrationRecords []gammmigration.BalancerToConcentratedPoolLink + expectedResultingRecords []gammmigration.BalancerToConcentratedPoolLink isPoolPrepared bool isPreexistingRecordsSet bool overwriteBalancerDenom0 string @@ -469,7 +470,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }{ { name: "Non existent balancer pool.", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{{ BalancerPoolId: 9, ClPoolId: 6, }}, @@ -478,7 +479,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Non existent concentrated pool.", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{{ BalancerPoolId: 1, ClPoolId: 9, }}, @@ -487,7 +488,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Adding two of the same balancer pool ids at once should error", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -502,7 +503,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Adding two of the same cl pool ids at once should error", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -517,7 +518,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Normal case with two records", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -527,7 +528,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { ClPoolId: 8, }, }, - expectedResultingRecords: []types.BalancerToConcentratedPoolLink{ + expectedResultingRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -546,7 +547,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Normal case with two records no preexisting records", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -556,7 +557,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { ClPoolId: 8, }, }, - expectedResultingRecords: []types.BalancerToConcentratedPoolLink{ + expectedResultingRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -571,7 +572,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Modify existing record, delete existing record, leave a record alone, add new record", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -585,7 +586,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { ClPoolId: 8, }, }, - expectedResultingRecords: []types.BalancerToConcentratedPoolLink{ + expectedResultingRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -604,7 +605,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Try to set one of the BalancerPoolIds to a cl pool Id", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 2, ClPoolId: 4, @@ -619,7 +620,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Try to set one of the ClPoolIds to a balancer pool Id", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 2, ClPoolId: 1, @@ -630,7 +631,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Mismatch denom0 between the two pools", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -642,7 +643,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Mismatch denom1 between the two pools", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 6, @@ -654,7 +655,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { }, { name: "Balancer pool has more than two tokens", - testingMigrationRecords: []types.BalancerToConcentratedPoolLink{ + testingMigrationRecords: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 9, ClPoolId: 6, @@ -698,7 +699,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { if test.isPreexistingRecordsSet { // Set up existing records so we can update them - existingRecords := []types.BalancerToConcentratedPoolLink{ + existingRecords := []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 5, diff --git a/x/gamm/types/genesis.go b/x/gamm/types/genesis.go index 98d644ac3eb..0ae4e7c84e0 100644 --- a/x/gamm/types/genesis.go +++ b/x/gamm/types/genesis.go @@ -2,6 +2,7 @@ package types import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" ) // DefaultGenesis creates a default GenesisState object. @@ -10,7 +11,7 @@ func DefaultGenesis() *GenesisState { Pools: []*codectypes.Any{}, NextPoolNumber: 1, Params: DefaultParams(), - MigrationRecords: &MigrationRecords{}, + MigrationRecords: &gammmigration.MigrationRecords{}, } } diff --git a/x/gamm/types/genesis.pb.go b/x/gamm/types/genesis.pb.go index de9b260c84c..259b0cac677 100644 --- a/x/gamm/types/genesis.pb.go +++ b/x/gamm/types/genesis.pb.go @@ -11,6 +11,7 @@ import ( types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + migration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" io "io" math "math" math_bits "math/bits" @@ -76,9 +77,9 @@ func (m *Params) GetPoolCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { type GenesisState struct { Pools []*types1.Any `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools,omitempty"` // will be renamed to next_pool_id in an upcoming version - NextPoolNumber uint64 `protobuf:"varint,2,opt,name=next_pool_number,json=nextPoolNumber,proto3" json:"next_pool_number,omitempty"` - Params Params `protobuf:"bytes,3,opt,name=params,proto3" json:"params"` - MigrationRecords *MigrationRecords `protobuf:"bytes,4,opt,name=migration_records,json=migrationRecords,proto3" json:"migration_records,omitempty"` + NextPoolNumber uint64 `protobuf:"varint,2,opt,name=next_pool_number,json=nextPoolNumber,proto3" json:"next_pool_number,omitempty"` + Params Params `protobuf:"bytes,3,opt,name=params,proto3" json:"params"` + MigrationRecords *migration.MigrationRecords `protobuf:"bytes,4,opt,name=migration_records,json=migrationRecords,proto3" json:"migration_records,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -135,7 +136,7 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetMigrationRecords() *MigrationRecords { +func (m *GenesisState) GetMigrationRecords() *migration.MigrationRecords { if m != nil { return m.MigrationRecords } @@ -569,7 +570,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.MigrationRecords == nil { - m.MigrationRecords = &MigrationRecords{} + m.MigrationRecords = &migration.MigrationRecords{} } if err := m.MigrationRecords.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/gamm/types/gov.go b/x/gamm/types/gov.go index e0b654ae459..c33204bf593 100644 --- a/x/gamm/types/gov.go +++ b/x/gamm/types/gov.go @@ -5,6 +5,7 @@ import ( "strings" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" ) const ( @@ -26,7 +27,7 @@ var ( ) // NewReplacePoolIncentivesProposal returns a new instance of a replace migration record's proposal struct. -func NewReplaceMigrationRecordsProposal(title, description string, records []BalancerToConcentratedPoolLink) govtypes.Content { +func NewReplaceMigrationRecordsProposal(title, description string, records []gammmigration.BalancerToConcentratedPoolLink) govtypes.Content { return &ReplaceMigrationRecordsProposal{ Title: title, Description: description, @@ -78,7 +79,7 @@ func (p ReplaceMigrationRecordsProposal) String() string { } // NewReplacePoolIncentivesProposal returns a new instance of a replace migration record's proposal struct. -func NewUpdatePoolIncentivesProposal(title, description string, records []BalancerToConcentratedPoolLink) govtypes.Content { +func NewUpdatePoolIncentivesProposal(title, description string, records []gammmigration.BalancerToConcentratedPoolLink) govtypes.Content { return &UpdateMigrationRecordsProposal{ Title: title, Description: description, diff --git a/x/gamm/types/gov.pb.go b/x/gamm/types/gov.pb.go index f880aff4a28..c62efb26c7a 100644 --- a/x/gamm/types/gov.pb.go +++ b/x/gamm/types/gov.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + migration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" io "io" math "math" math_bits "math/bits" @@ -31,9 +32,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Each record specifies a single connection between a single balancer pool and // a single concentrated pool. type ReplaceMigrationRecordsProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Records []BalancerToConcentratedPoolLink `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Records []migration.BalancerToConcentratedPoolLink `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` } func (m *ReplaceMigrationRecordsProposal) Reset() { *m = ReplaceMigrationRecordsProposal{} } @@ -77,9 +78,9 @@ var xxx_messageInfo_ReplaceMigrationRecordsProposal proto.InternalMessageInfo // The result MigrationRecords in state would be: // [(Balancer 1, CL 5), (Balancer 3, CL 4), (Balancer 4, CL 10)] type UpdateMigrationRecordsProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Records []BalancerToConcentratedPoolLink `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Records []migration.BalancerToConcentratedPoolLink `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` } func (m *UpdateMigrationRecordsProposal) Reset() { *m = UpdateMigrationRecordsProposal{} } @@ -507,7 +508,7 @@ func (m *ReplaceMigrationRecordsProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Records = append(m.Records, BalancerToConcentratedPoolLink{}) + m.Records = append(m.Records, migration.BalancerToConcentratedPoolLink{}) if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -655,7 +656,7 @@ func (m *UpdateMigrationRecordsProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Records = append(m.Records, BalancerToConcentratedPoolLink{}) + m.Records = append(m.Records, migration.BalancerToConcentratedPoolLink{}) if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/gamm/types/gov_test.go b/x/gamm/types/gov_test.go index f0ccfd369d1..ce2b75b4597 100644 --- a/x/gamm/types/gov_test.go +++ b/x/gamm/types/gov_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" ) func TestUpdateMigrationRecordsProposalMarshalUnmarshal(t *testing.T) { @@ -17,28 +18,28 @@ func TestUpdateMigrationRecordsProposalMarshalUnmarshal(t *testing.T) { proposal: &types.UpdateMigrationRecordsProposal{ Title: "", Description: "proposal to update migration records", - Records: []types.BalancerToConcentratedPoolLink(nil), + Records: []gammmigration.BalancerToConcentratedPoolLink(nil), }, }, { // empty description proposal: &types.UpdateMigrationRecordsProposal{ Title: "title", Description: "", - Records: []types.BalancerToConcentratedPoolLink(nil), + Records: []gammmigration.BalancerToConcentratedPoolLink(nil), }, }, { // empty records proposal: &types.UpdateMigrationRecordsProposal{ Title: "title", Description: "proposal to update migration records", - Records: []types.BalancerToConcentratedPoolLink(nil), + Records: []gammmigration.BalancerToConcentratedPoolLink(nil), }, }, { // one record proposal: &types.UpdateMigrationRecordsProposal{ Title: "title", Description: "proposal to update migration records", - Records: []types.BalancerToConcentratedPoolLink{ + Records: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 5, @@ -50,7 +51,7 @@ func TestUpdateMigrationRecordsProposalMarshalUnmarshal(t *testing.T) { proposal: &types.UpdateMigrationRecordsProposal{ Title: "title", Description: "proposal to update migration records", - Records: []types.BalancerToConcentratedPoolLink{ + Records: []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 1, ClPoolId: 5, diff --git a/x/gamm/types/shared.pb.go b/x/gamm/types/migration/shared.pb.go similarity index 86% rename from x/gamm/types/shared.pb.go rename to x/gamm/types/migration/shared.pb.go index 275ba9cd76e..0bb0b907cf2 100644 --- a/x/gamm/types/shared.pb.go +++ b/x/gamm/types/migration/shared.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: osmosis/gamm/v1beta1/shared.proto -package types +package migration import ( fmt "fmt" @@ -138,29 +138,29 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/shared.proto", fileDescriptor_ecfa270aa4b2c075) } var fileDescriptor_ecfa270aa4b2c075 = []byte{ - // 342 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x4a, 0x2b, 0x31, - 0x18, 0x85, 0x27, 0xf7, 0x96, 0xcb, 0x65, 0x04, 0x29, 0x43, 0x17, 0xb5, 0x48, 0x5a, 0xeb, 0xa6, - 0x1b, 0x27, 0x56, 0xc5, 0x85, 0xcb, 0xba, 0x52, 0x14, 0xa4, 0xb8, 0x72, 0x33, 0x24, 0x99, 0x98, - 0x86, 0x66, 0xf2, 0x97, 0x49, 0x5a, 0xec, 0x1b, 0xb8, 0xf4, 0x05, 0x04, 0x1f, 0xa7, 0xcb, 0x2e, - 0x5d, 0x89, 0xb4, 0x1b, 0x1f, 0x43, 0x3a, 0x99, 0x16, 0x17, 0xd2, 0x5d, 0x4e, 0xce, 0xf7, 0x1f, - 0xce, 0x9f, 0x84, 0x07, 0x60, 0x33, 0xb0, 0xca, 0x12, 0x49, 0xb3, 0x8c, 0x4c, 0xba, 0x4c, 0x38, - 0xda, 0x25, 0x76, 0x40, 0x73, 0x91, 0xc6, 0xa3, 0x1c, 0x1c, 0x44, 0xb5, 0x12, 0x89, 0x57, 0x48, - 0x5c, 0x22, 0x8d, 0x9a, 0x04, 0x09, 0x05, 0x40, 0x56, 0x27, 0xcf, 0x36, 0xf6, 0x24, 0x80, 0xd4, - 0x82, 0x14, 0x8a, 0x8d, 0x1f, 0x09, 0x35, 0xd3, 0xb5, 0xc5, 0x8b, 0x9c, 0xc4, 0xcf, 0x78, 0x51, - 0x5a, 0xd8, 0x2b, 0xc2, 0xa8, 0x15, 0x9b, 0x0e, 0x1c, 0x94, 0xf1, 0x7e, 0xfb, 0x15, 0x85, 0xd5, - 0x5b, 0x25, 0x73, 0xea, 0x14, 0x98, 0xbe, 0xe0, 0x90, 0xa7, 0x36, 0x7a, 0x46, 0xe1, 0x21, 0xa3, - 0x9a, 0x1a, 0x2e, 0xf2, 0xc4, 0x41, 0xc2, 0xc1, 0x70, 0x61, 0x5c, 0x4e, 0x9d, 0x48, 0x93, 0x11, - 0x80, 0x4e, 0xb4, 0x32, 0x43, 0x5b, 0x47, 0xad, 0xbf, 0x9d, 0x9d, 0x93, 0xb3, 0xf8, 0xb7, 0x2d, - 0xe2, 0x5e, 0x19, 0x70, 0x0f, 0x97, 0x3f, 0xc6, 0xef, 0x00, 0xf4, 0x8d, 0x32, 0xc3, 0x5e, 0x65, - 0xf6, 0xd1, 0x0c, 0xfa, 0x4d, 0xb6, 0x95, 0xb2, 0x6d, 0x13, 0xe2, 0xed, 0x41, 0x51, 0x27, 0xac, - 0x6e, 0xba, 0x16, 0xdd, 0x54, 0x5a, 0x47, 0x2d, 0xd4, 0xa9, 0xf4, 0x77, 0xd7, 0xf7, 0x2b, 0xf6, - 0x2a, 0x8d, 0xf6, 0xc3, 0x90, 0xeb, 0x0d, 0xf3, 0xa7, 0x60, 0xfe, 0x73, 0xed, 0xdd, 0x8b, 0xca, - 0xd7, 0x5b, 0x13, 0xf5, 0xae, 0x67, 0x0b, 0x8c, 0xe6, 0x0b, 0x8c, 0x3e, 0x17, 0x18, 0xbd, 0x2c, - 0x71, 0x30, 0x5f, 0xe2, 0xe0, 0x7d, 0x89, 0x83, 0x87, 0x63, 0xa9, 0xdc, 0x60, 0xcc, 0x62, 0x0e, - 0x19, 0x29, 0x17, 0x3e, 0xd2, 0x94, 0xd9, 0xb5, 0x20, 0x93, 0xee, 0x39, 0x79, 0xf2, 0x9f, 0xed, - 0xa6, 0x23, 0x61, 0xd9, 0xbf, 0xe2, 0x89, 0x4f, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x97, - 0x50, 0x5c, 0x09, 0x02, 0x00, 0x00, + // 344 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x31, 0x4b, 0xc3, 0x40, + 0x18, 0x86, 0x73, 0x5a, 0x44, 0x22, 0x48, 0x09, 0x1d, 0x6a, 0x91, 0x6b, 0xad, 0x4b, 0x17, 0x73, + 0x54, 0xc5, 0xa1, 0x63, 0x9d, 0x04, 0x05, 0x29, 0x9d, 0x5c, 0xc2, 0xdd, 0xe5, 0x4c, 0x8f, 0x5e, + 0xee, 0x2b, 0xb9, 0x6b, 0xb1, 0xff, 0xc0, 0xd1, 0x3f, 0x20, 0xf8, 0x73, 0x3a, 0x76, 0x74, 0x12, + 0x69, 0x17, 0x7f, 0x86, 0x34, 0x97, 0x14, 0x07, 0xe9, 0x96, 0x37, 0xef, 0xf3, 0xbd, 0xbc, 0xdf, + 0x77, 0xfe, 0x19, 0x98, 0x14, 0x8c, 0x34, 0x24, 0xa1, 0x69, 0x4a, 0x66, 0x5d, 0x26, 0x2c, 0xed, + 0x12, 0x33, 0xa2, 0x99, 0x88, 0xc3, 0x49, 0x06, 0x16, 0x82, 0x5a, 0x81, 0x84, 0x1b, 0x24, 0x2c, + 0x90, 0x46, 0x2d, 0x81, 0x04, 0x72, 0x80, 0x6c, 0xbe, 0x1c, 0xdb, 0x38, 0x49, 0x00, 0x12, 0x25, + 0x48, 0xae, 0xd8, 0xf4, 0x99, 0x50, 0x3d, 0x2f, 0x2d, 0x9e, 0xe7, 0x44, 0x6e, 0xc6, 0x89, 0xc2, + 0xc2, 0x4e, 0x11, 0x46, 0x8d, 0xd8, 0x76, 0xe0, 0x20, 0xb5, 0xf3, 0xdb, 0xef, 0xc8, 0xaf, 0x3e, + 0xc8, 0x24, 0xa3, 0x56, 0x82, 0x1e, 0x08, 0x0e, 0x59, 0x6c, 0x82, 0x57, 0xe4, 0x9f, 0x33, 0xaa, + 0xa8, 0xe6, 0x22, 0x8b, 0x2c, 0x44, 0x1c, 0x34, 0x17, 0xda, 0x66, 0xd4, 0x8a, 0x38, 0x9a, 0x00, + 0xa8, 0x48, 0x49, 0x3d, 0x36, 0x75, 0xd4, 0xda, 0xef, 0x1c, 0x5d, 0x5e, 0x87, 0xff, 0x6d, 0x11, + 0xf6, 0x8b, 0x80, 0x21, 0xdc, 0xfe, 0x19, 0x7f, 0x04, 0x50, 0xf7, 0x52, 0x8f, 0xfb, 0x95, 0xc5, + 0x57, 0xd3, 0x1b, 0x34, 0xd9, 0x4e, 0xca, 0xb4, 0xb5, 0x8f, 0x77, 0x07, 0x05, 0x1d, 0xbf, 0xba, + 0xed, 0x9a, 0x77, 0x93, 0x71, 0x1d, 0xb5, 0x50, 0xa7, 0x32, 0x38, 0x2e, 0xff, 0x6f, 0xd8, 0xbb, + 0x38, 0x38, 0xf5, 0x7d, 0xae, 0xb6, 0xcc, 0x5e, 0xce, 0x1c, 0x72, 0xe5, 0xdc, 0x5e, 0xe5, 0xe7, + 0xa3, 0x89, 0xfa, 0xc3, 0xc5, 0x0a, 0xa3, 0xe5, 0x0a, 0xa3, 0xef, 0x15, 0x46, 0x6f, 0x6b, 0xec, + 0x2d, 0xd7, 0xd8, 0xfb, 0x5c, 0x63, 0xef, 0xa9, 0x97, 0x48, 0x3b, 0x9a, 0xb2, 0x90, 0x43, 0x4a, + 0x8a, 0x85, 0x2f, 0x14, 0x65, 0xa6, 0x14, 0x64, 0xd6, 0xbd, 0x21, 0x2f, 0xee, 0xb1, 0xed, 0x7c, + 0x22, 0x0c, 0x49, 0xcb, 0xbb, 0xb2, 0x83, 0xfc, 0xd8, 0x57, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xb9, 0x95, 0x1b, 0x2d, 0x13, 0x02, 0x00, 0x00, } func (this *BalancerToConcentratedPoolLink) Equal(that interface{}) bool { diff --git a/x/pool-incentives/keeper/grpc_query.go b/x/pool-incentives/keeper/grpc_query.go index 4fac3ff7aa1..7b1d9256a26 100644 --- a/x/pool-incentives/keeper/grpc_query.go +++ b/x/pool-incentives/keeper/grpc_query.go @@ -166,7 +166,7 @@ func (q Querier) IncentivizedPools(ctx context.Context, _ *types.QueryIncentiviz // Retrieve the migration records between balancer pools and concentrated liquidity pools. // This comes from the superfluid keeper, since superfluid is the only pool incentives connected // module that has access to the gamm modules store. - migrationRecords, err := q.superfluidKeeper.GetAllMigrationInfo(sdkCtx) + migrationRecords, err := q.gammKeeper.GetAllMigrationInfo(sdkCtx) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/pool-incentives/keeper/grpc_query_test.go b/x/pool-incentives/keeper/grpc_query_test.go index 78ab6d32508..20cadd46e88 100644 --- a/x/pool-incentives/keeper/grpc_query_test.go +++ b/x/pool-incentives/keeper/grpc_query_test.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" cltypes "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" - gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types" "github.com/osmosis-labs/osmosis/v16/x/pool-incentives/types" ) @@ -279,8 +279,8 @@ func (s *KeeperTestSuite) TestIncentivizedPools() { // Create a link between the balancer pool and the cl pool if required. if tc.setupPoolMigrationLink { - record := gammtypes.BalancerToConcentratedPoolLink{BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()} - err := s.App.GAMMKeeper.ReplaceMigrationRecords(s.Ctx, []gammtypes.BalancerToConcentratedPoolLink{record}) + record := gammmigration.BalancerToConcentratedPoolLink{BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()} + err := s.App.GAMMKeeper.ReplaceMigrationRecords(s.Ctx, []gammmigration.BalancerToConcentratedPoolLink{record}) s.Require().NoError(err) } } diff --git a/x/pool-incentives/keeper/keeper.go b/x/pool-incentives/keeper/keeper.go index c1366581990..4eb9990ef37 100644 --- a/x/pool-incentives/keeper/keeper.go +++ b/x/pool-incentives/keeper/keeper.go @@ -29,10 +29,10 @@ type Keeper struct { bankKeeper types.BankKeeper distrKeeper types.DistrKeeper poolmanagerKeeper types.PoolManagerKeeper - superfluidKeeper types.SuperfluidKeeper + gammKeeper types.GAMMKeeper } -func NewKeeper(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, incentivesKeeper types.IncentivesKeeper, distrKeeper types.DistrKeeper, poolmanagerKeeper types.PoolManagerKeeper, epochKeeper types.EpochKeeper, superfluidKeeper types.SuperfluidKeeper) Keeper { +func NewKeeper(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, incentivesKeeper types.IncentivesKeeper, distrKeeper types.DistrKeeper, poolmanagerKeeper types.PoolManagerKeeper, epochKeeper types.EpochKeeper, gammKeeper types.GAMMKeeper) Keeper { // ensure pool-incentives module account is set if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) @@ -54,7 +54,7 @@ func NewKeeper(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, accountKee distrKeeper: distrKeeper, poolmanagerKeeper: poolmanagerKeeper, epochKeeper: epochKeeper, - superfluidKeeper: superfluidKeeper, + gammKeeper: gammKeeper, } } diff --git a/x/pool-incentives/types/expected_keepers.go b/x/pool-incentives/types/expected_keepers.go index a7c1540f1c9..4806f0faa9a 100644 --- a/x/pool-incentives/types/expected_keepers.go +++ b/x/pool-incentives/types/expected_keepers.go @@ -7,6 +7,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" incentivestypes "github.com/osmosis-labs/osmosis/v16/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v16/x/poolmanager/types" @@ -30,6 +31,10 @@ type PoolManagerKeeper interface { GetPool(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolI, error) } +type GAMMKeeper interface { + GetAllMigrationInfo(ctx sdk.Context) (gammmigration.MigrationRecords, error) +} + // IncentivesKeeper creates and gets gauges, and also allows additions to gauge rewards. type IncentivesKeeper interface { CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddress, coins sdk.Coins, distrTo lockuptypes.QueryCondition, startTime time.Time, numEpochsPaidOver uint64, poolId uint64) (uint64, error) diff --git a/x/superfluid/keeper/migrate.go b/x/superfluid/keeper/migrate.go index b37fada5dea..f7c58721403 100644 --- a/x/superfluid/keeper/migrate.go +++ b/x/superfluid/keeper/migrate.go @@ -10,7 +10,6 @@ import ( cltypes "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types" - poolincentivestypes "github.com/osmosis-labs/osmosis/v16/x/pool-incentives/types" "github.com/osmosis-labs/osmosis/v16/x/superfluid/types" ) @@ -334,34 +333,3 @@ func (k Keeper) validateSharesToMigrateUnlockAndExitBalancerPool(ctx sdk.Context return exitCoins, nil } - -// GetAllMigrationInfo helps to give pool-incentives access to the migration info located in the gamm store. -// This is required to circumnavigate import cycle errors without having to do a complete refactor. -func (k Keeper) GetAllMigrationInfo(ctx sdk.Context) (poolincentivestypes.MigrationRecords, error) { - gammMigrationRecords, err := k.gk.GetAllMigrationInfo(ctx) - if err != nil { - return poolincentivestypes.MigrationRecords{}, err - } - - // Perform conversion from gamm types.MigrationRecords to pool-incentives types.MigrationRecords - poolIncentivesMigrationRecords := convertMigrationRecords(gammMigrationRecords) - - return poolIncentivesMigrationRecords, nil -} - -// convertMigrationRecords performs the conversion from gamm types.MigrationRecords to pool-incentives types.MigrationRecords -func convertMigrationRecords(gammMigrationRecords gammtypes.MigrationRecords) poolincentivestypes.MigrationRecords { - poolIncentivesMigrationRecords := poolincentivestypes.MigrationRecords{} - - poolIncentivesMigrationRecords.BalancerToConcentratedPoolLinks = make([]poolincentivestypes.BalancerToConcentratedPoolLink, len(gammMigrationRecords.BalancerToConcentratedPoolLinks)) - for i := range gammMigrationRecords.BalancerToConcentratedPoolLinks { - // Perform the mapping for each BalancerToConcentratedPoolLink - poolIncentivesLink := poolincentivestypes.BalancerToConcentratedPoolLink{ - BalancerPoolId: gammMigrationRecords.BalancerToConcentratedPoolLinks[i].BalancerPoolId, - ClPoolId: gammMigrationRecords.BalancerToConcentratedPoolLinks[i].ClPoolId, - } - poolIncentivesMigrationRecords.BalancerToConcentratedPoolLinks[i] = poolIncentivesLink - } - - return poolIncentivesMigrationRecords -} diff --git a/x/superfluid/keeper/migrate_test.go b/x/superfluid/keeper/migrate_test.go index d26970865bc..8b882b2eefb 100644 --- a/x/superfluid/keeper/migrate_test.go +++ b/x/superfluid/keeper/migrate_test.go @@ -17,6 +17,7 @@ import ( cltypes "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types" "github.com/osmosis-labs/osmosis/v16/x/superfluid/keeper" "github.com/osmosis-labs/osmosis/v16/x/superfluid/types" @@ -1068,7 +1069,7 @@ func (s *KeeperTestSuite) SetupMigrationTest(ctx sdk.Context, superfluidDelegate clPoolId = clPool.GetId() // Add a gov sanctioned link between the balancer and concentrated liquidity pool. - migrationRecord := gammtypes.MigrationRecords{BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + migrationRecord := gammmigration.MigrationRecords{BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: balancerPooId, ClPoolId: clPoolId}, }} gammKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, migrationRecord) @@ -1366,7 +1367,7 @@ func (s *KeeperTestSuite) TestFunctional_VaryingPositions_Migrations() { s.CreateFullRangePosition(clPool, sdk.NewCoins(sdk.NewCoin(DefaultCoin0.Denom, sdk.NewInt(100000000)), sdk.NewCoin(DefaultCoin1.Denom, sdk.NewDec(100000000).Mul(balancerSpotPrice).TruncateInt()))) // Add a gov sanctioned link between the balancer and concentrated liquidity pool. - migrationRecord := gammtypes.MigrationRecords{BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + migrationRecord := gammmigration.MigrationRecords{BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: balancerPoolId, ClPoolId: clPoolId}, }} s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx, migrationRecord) diff --git a/x/superfluid/keeper/msg_server_test.go b/x/superfluid/keeper/msg_server_test.go index 735ea607d29..81ab89e7ff2 100644 --- a/x/superfluid/keeper/msg_server_test.go +++ b/x/superfluid/keeper/msg_server_test.go @@ -10,6 +10,7 @@ import ( cltypes "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" lockupkeeper "github.com/osmosis-labs/osmosis/v16/x/lockup/keeper" lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types" "github.com/osmosis-labs/osmosis/v16/x/superfluid/keeper" @@ -500,7 +501,7 @@ func (s *KeeperTestSuite) TestUnlockAndMigrateSharesToFullRangeConcentratedPosit clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, sdk.ZeroDec()) // Set migration link between the balancer and concentrated pool - migrationRecord := gammtypes.MigrationRecords{BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{ + migrationRecord := gammmigration.MigrationRecords{BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ {BalancerPoolId: balancerPool.GetId(), ClPoolId: clPool.GetId()}, }} s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx, migrationRecord) diff --git a/x/superfluid/types/expected_keepers.go b/x/superfluid/types/expected_keepers.go index 668318c5319..b2e367de537 100644 --- a/x/superfluid/types/expected_keepers.go +++ b/x/superfluid/types/expected_keepers.go @@ -10,6 +10,7 @@ import ( "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/model" cltypes "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types" gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" + gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration" incentivestypes "github.com/osmosis-labs/osmosis/v16/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types" epochstypes "github.com/osmosis-labs/osmosis/x/epochs/types" @@ -53,7 +54,7 @@ type GammKeeper interface { GetPoolAndPoke(ctx sdk.Context, poolId uint64) (gammtypes.CFMMPoolI, error) GetPoolsAndPoke(ctx sdk.Context) (res []gammtypes.CFMMPoolI, err error) ExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, tokenOutMins sdk.Coins) (exitCoins sdk.Coins, err error) - GetAllMigrationInfo(ctx sdk.Context) (gammtypes.MigrationRecords, error) + GetAllMigrationInfo(ctx sdk.Context) (gammmigration.MigrationRecords, error) GetLinkedConcentratedPoolID(ctx sdk.Context, poolIdLeaving uint64) (poolIdEntering uint64, err error) MigrateUnlockedPositionFromBalancerToConcentrated(ctx sdk.Context, sender sdk.AccAddress, sharesToMigrate sdk.Coin, tokenOutMins sdk.Coins) (positionId uint64, amount0, amount1 sdk.Int, liquidity sdk.Dec, poolIdLeaving, poolIdEntering uint64, err error) }