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

Fix CreateCanonicalConcentratedLiquidityPoolAndMigrationLink overriding migration records #6282

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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### State Breaking

* [#6344](https://github.com/osmosis-labs/osmosis/pull/6344) fix: set name, display and symbol of denom metadata in tokenfactory's CreateDenom
* [#6279](https://github.com/osmosis-labs/osmosis/pull/6279) fix prop-597 introduced issue
* [#6282](https://github.com/osmosis-labs/osmosis/pull/6282) Fix CreateCanonicalConcentratedLiquidityPoolAndMigrationLink overriding migration records

### Bug Fixes

* [#6334](https://github.com/osmosis-labs/osmosis/pull/6334) fix: enable taker fee cli
* [#6352](https://github.com/osmosis-labs/osmosis/pull/6352) Reduce error blow-up in CalcAmount0Delta by changing the order of math operations.
* [#6368](https://github.com/osmosis-labs/osmosis/pull/6368) Stricter rounding behavior in CL math's CalcAmount0Delta and GetNextSqrtPriceFromAmount0InRoundingUp


### API Breaks

* [#6256](https://github.com/osmosis-labs/osmosis/pull/6256) Refactor CalcPriceToTick to operate on BigDec price to support new price range.
Expand Down
14 changes: 5 additions & 9 deletions x/gamm/keeper/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,13 @@ func (k Keeper) CreateCanonicalConcentratedLiquidityPoolAndMigrationLink(ctx sdk
if err != nil {
return nil, err
}

// Set the migration link in x/gamm.
// This will also migrate the CFMM distribution records to point to the new CL pool.
err = k.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, gammmigration.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{
BalancerPoolId: cfmmPoolId,
ClPoolId: concentratedPool.GetId(),
},
},
})
err = k.UpdateMigrationRecords(ctx, []gammmigration.BalancerToConcentratedPoolLink{
{
BalancerPoolId: cfmmPoolId,
ClPoolId: concentratedPool.GetId(),
}})
if err != nil {
return nil, err
}
Expand Down
15 changes: 12 additions & 3 deletions x/gamm/keeper/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1154,9 +1154,14 @@ func (s *KeeperTestSuite) TestCreateCanonicalConcentratedLiquidityPoolAndMigrati

balancerId := s.PrepareBalancerPoolWithCoins(tc.poolLiquidity...)

// Another pool for testing that its gauge links are unchanged
// Another pool for testing that its gauge and migration links are unchanged.
balancerId2 := s.PrepareBalancerPoolWithCoins(tc.poolLiquidity...)

// Another pool for testing that previously existing migration links don't get overwritten.
balancerId3 := s.PrepareBalancerPoolWithCoins(tc.poolLiquidity...)

clPoolOld, err := s.App.GAMMKeeper.CreateCanonicalConcentratedLiquidityPoolAndMigrationLink(s.Ctx, balancerId3, tc.desiredDenom0, osmomath.ZeroDec(), defaultTickSpacing)

balancerPool, err := s.App.PoolManagerKeeper.GetPool(s.Ctx, balancerId)
s.Require().NoError(err)

Expand Down Expand Up @@ -1189,8 +1194,8 @@ func (s *KeeperTestSuite) TestCreateCanonicalConcentratedLiquidityPoolAndMigrati
s.Require().NoError(err)

// Get the new concentrated pool.
// Note, + 2 becuse we create 2 balancer pools during test setup, and 1 concentrated pool during migration.
clPoolInState, err := s.App.PoolManagerKeeper.GetPool(s.Ctx, validPoolId+2)
// Note, +4 because we create 3 balancer pools and 1 cl pool during test setup, and 1 concentrated pool during migration.
clPoolInState, err := s.App.PoolManagerKeeper.GetPool(s.Ctx, validPoolId+4)
s.Require().NoError(err)
s.Require().Equal(clPool, clPoolInState)

Expand Down Expand Up @@ -1229,6 +1234,10 @@ func (s *KeeperTestSuite) TestCreateCanonicalConcentratedLiquidityPoolAndMigrati
BalancerPoolId: balancerId,
ClPoolId: clPoolInState.GetId(),
},
{
BalancerPoolId: balancerId3,
ClPoolId: clPoolOld.GetId(),
},
},
})

Expand Down