diff --git a/go.mod b/go.mod index 6f2be37e035..f23d7a7aaa1 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/ory/dockertest/v3 v3.9.1 github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230328024000-175ec88e4304 - github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230328175100-184629d4f758 + github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230330162120-3f56e1ab713b github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230328024000-175ec88e4304 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 953712f9813..0bce873c74e 100644 --- a/go.sum +++ b/go.sum @@ -936,6 +936,8 @@ github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230328024000-175ec88e430 github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230328024000-175ec88e4304/go.mod h1:/h3CZIo25kMrM4Ojm7qBgMxKofTVwOycVWSa4rhEsaM= github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230328175100-184629d4f758 h1:rBHpiUpFdNbqFGKijltJ+1TMvowKTDgoY/vSc+ukQYU= github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230328175100-184629d4f758/go.mod h1:YFYyDzcapRxYoOGVSyBKk8xPiz6D5bw1p1g3Q1IUofc= +github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230330162120-3f56e1ab713b h1:b+KE2kSEFgnv+4UmTeMPJ3yT978JW8QJ7T60fI3L21Y= +github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230330162120-3f56e1ab713b/go.mod h1:psyK1Qz149N3KGG3EamOlVSZipmgg8g8OvTDmwhh5cI= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304/go.mod h1:yPWoJTj5RKrXKUChAicp+G/4Ni/uVEpp27mi/FF/L9c= github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230328024000-175ec88e4304 h1:Sa4RJpuP4tEzUoxpzOm1GZ798PXOhHK0WgV11/sHh0o= diff --git a/osmoutils/address.go b/osmoutils/address.go new file mode 100644 index 00000000000..fb47d79dad4 --- /dev/null +++ b/osmoutils/address.go @@ -0,0 +1,12 @@ +package osmoutils + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" +) + +// NewModuleAddressWithPrefix returns a new module address with the given prefix and identifier. +func NewModuleAddressWithPrefix(moduleName, prefix string, identifier []byte) sdk.AccAddress { + key := append([]byte(prefix), identifier...) + return address.Module(moduleName, key) +} diff --git a/proto/osmosis/concentrated-liquidity/pool.proto b/proto/osmosis/concentrated-liquidity/pool.proto index 35e9b2fb038..81eea146973 100644 --- a/proto/osmosis/concentrated-liquidity/pool.proto +++ b/proto/osmosis/concentrated-liquidity/pool.proto @@ -16,40 +16,46 @@ message Pool { option (gogoproto.goproto_stringer) = false; option (cosmos_proto.implements_interface) = "PoolI"; + // pool's address holding all liquidity tokens. string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; - uint64 id = 2; + + // address holding the incentives liquidity. + string incentives_address = 2 + [ (gogoproto.moretags) = "yaml:\"incentives_address\"" ]; + + uint64 id = 3; // Amount of total liquidity - string current_tick_liquidity = 3 [ + string current_tick_liquidity = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"current_tick_liquidity\"", (gogoproto.nullable) = false ]; - string token0 = 4; - string token1 = 5; + string token0 = 5; + string token1 = 6; - string current_sqrt_price = 6 [ + string current_sqrt_price = 7 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"spot_price\"", (gogoproto.nullable) = false ]; - string current_tick = 7 [ + string current_tick = 8 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"current_tick\"", (gogoproto.nullable) = false ]; // tick_spacing must be one of the authorized_tick_spacing values set in the // concentrated-liquidity parameters - uint64 tick_spacing = 8 [ (gogoproto.moretags) = "yaml:\"tick_spacing\"" ]; - string exponent_at_price_one = 9 [ + uint64 tick_spacing = 9 [ (gogoproto.moretags) = "yaml:\"tick_spacing\"" ]; + string exponent_at_price_one = 10 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"exponent_at_price_one\"", (gogoproto.nullable) = false ]; // swap_fee is the ratio that is charged on the amount of token in. - string swap_fee = 10 [ + string swap_fee = 11 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"swap_fee\"", (gogoproto.nullable) = false @@ -57,7 +63,7 @@ message Pool { // last_liquidity_update is the last time either the pool liquidity or the // active tick changed - google.protobuf.Timestamp last_liquidity_update = 11 [ + google.protobuf.Timestamp last_liquidity_update = 12 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"last_liquidity_update\"" diff --git a/x/concentrated-liquidity/incentives.go b/x/concentrated-liquidity/incentives.go index d72db6f78c8..a85df26dac1 100644 --- a/x/concentrated-liquidity/incentives.go +++ b/x/concentrated-liquidity/incentives.go @@ -603,7 +603,7 @@ func (k Keeper) collectIncentives(ctx sdk.Context, owner sdk.AccAddress, positio } // Send the collected incentives to the position's owner from the pool's address. - if err := k.bankKeeper.SendCoins(ctx, pool.GetAddress(), owner, collectedIncentivesForPosition); err != nil { + if err := k.bankKeeper.SendCoins(ctx, pool.GetIncentivesAddress(), owner, collectedIncentivesForPosition); err != nil { return sdk.Coins{}, err } @@ -695,8 +695,8 @@ func (k Keeper) createIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAd return types.IncentiveRecord{}, err } - // Transfer tokens from sender to pool balance - if err := k.bankKeeper.SendCoins(ctx, sender, pool.GetAddress(), sdk.NewCoins(incentiveCoin)); err != nil { + // Transfer tokens from sender to the pool's incentive address + if err := k.bankKeeper.SendCoins(ctx, sender, pool.GetIncentivesAddress(), sdk.NewCoins(incentiveCoin)); err != nil { return types.IncentiveRecord{}, err } diff --git a/x/concentrated-liquidity/incentives_test.go b/x/concentrated-liquidity/incentives_test.go index 59cddb9eeb9..f33df038b30 100644 --- a/x/concentrated-liquidity/incentives_test.go +++ b/x/concentrated-liquidity/incentives_test.go @@ -2627,7 +2627,7 @@ func (s *KeeperTestSuite) TestCollectIncentives() { validPool := s.PrepareConcentratedPool() validPoolId := validPool.GetId() - s.FundAcc(validPool.GetAddress(), tc.expectedIncentivesClaimed) + s.FundAcc(validPool.GetIncentivesAddress(), tc.expectedIncentivesClaimed) clKeeper := s.App.ConcentratedLiquidityKeeper ctx := s.Ctx @@ -2664,6 +2664,7 @@ func (s *KeeperTestSuite) TestCollectIncentives() { // Checkpoint starting balance to compare against later poolBalanceBeforeCollect := s.App.BankKeeper.GetAllBalances(ctx, validPool.GetAddress()) + incentivesBalanceBeforeCollect := s.App.BankKeeper.GetAllBalances(ctx, validPool.GetIncentivesAddress()) ownerBalancerBeforeCollect := s.App.BankKeeper.GetAllBalances(ctx, ownerWithValidPosition) // Set up invalid pool ID for error-catching case(s) @@ -2678,15 +2679,19 @@ func (s *KeeperTestSuite) TestCollectIncentives() { // Assertions poolBalanceAfterCollect := s.App.BankKeeper.GetAllBalances(ctx, validPool.GetAddress()) + incentivesBalanceAfterCollect := s.App.BankKeeper.GetAllBalances(ctx, validPool.GetIncentivesAddress()) ownerBalancerAfterCollect := s.App.BankKeeper.GetAllBalances(ctx, ownerWithValidPosition) + // Ensure pool balances are unchanged independent of error. + s.Require().Equal(poolBalanceBeforeCollect, poolBalanceAfterCollect) + if tc.expectedError != nil { s.Require().Error(err) s.Require().ErrorContains(err, tc.expectedError.Error()) s.Require().Equal(tc.expectedIncentivesClaimed, actualIncentivesClaimed) // Ensure balances are unchanged - s.Require().Equal(poolBalanceBeforeCollect, poolBalanceAfterCollect) + s.Require().Equal(incentivesBalanceBeforeCollect, incentivesBalanceAfterCollect) s.Require().Equal(ownerBalancerAfterCollect, ownerBalancerBeforeCollect) return } @@ -2696,7 +2701,7 @@ func (s *KeeperTestSuite) TestCollectIncentives() { s.Require().Equal(tc.expectedIncentivesClaimed.String(), actualIncentivesClaimed.String()) // Ensure balances are updated by the correct amounts - s.Require().Equal(tc.expectedIncentivesClaimed.String(), (poolBalanceBeforeCollect.Sub(poolBalanceAfterCollect)).String()) + s.Require().Equal(tc.expectedIncentivesClaimed.String(), (incentivesBalanceBeforeCollect.Sub(incentivesBalanceAfterCollect)).String()) s.Require().Equal(tc.expectedIncentivesClaimed.String(), (ownerBalancerAfterCollect.Sub(ownerBalancerBeforeCollect)).String()) }) } diff --git a/x/concentrated-liquidity/lp_test.go b/x/concentrated-liquidity/lp_test.go index d5c2ef75a38..7a827de5b46 100644 --- a/x/concentrated-liquidity/lp_test.go +++ b/x/concentrated-liquidity/lp_test.go @@ -432,13 +432,14 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { // Set expected incentives and fund pool with appropriate amount expectedIncentivesClaimed = expectedIncentivesFromUptimeGrowth(defaultUptimeGrowth, liquidityCreated, tc.timeElapsed, sdk.OneInt()) - s.FundAcc(pool.GetAddress(), expectedIncentivesClaimed) + s.FundAcc(pool.GetIncentivesAddress(), expectedIncentivesClaimed) // Note the pool and owner balances before collecting fees. poolBalanceBeforeCollect := s.App.BankKeeper.GetAllBalances(ctx, pool.GetAddress()) + incentivesBalanceBeforeCollect := s.App.BankKeeper.GetAllBalances(ctx, pool.GetIncentivesAddress()) ownerBalancerBeforeCollect := s.App.BankKeeper.GetAllBalances(ctx, owner) - expectedBalanceDelta := expectedFeesClaimed.Add(expectedIncentivesClaimed...).Add(sdk.NewCoin(ETH, config.amount0Expected.Abs())).Add(sdk.NewCoin(USDC, config.amount1Expected.Abs())) + expectedPoolBalanceDelta := expectedFeesClaimed.Add(sdk.NewCoin(ETH, config.amount0Expected.Abs())).Add(sdk.NewCoin(USDC, config.amount1Expected.Abs())) // System under test. amtDenom0, amtDenom1, err := concentratedLiquidityKeeper.WithdrawPosition(ctx, owner, config.positionId, config.liquidityAmount) @@ -457,10 +458,12 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { // If the remaining liquidity is zero, all fees and incentives should be collected and the position should be deleted. // Check if all fees and incentives were collected. poolBalanceAfterCollect := s.App.BankKeeper.GetAllBalances(ctx, pool.GetAddress()) + incentivesBalanceAfterCollect := s.App.BankKeeper.GetAllBalances(ctx, pool.GetIncentivesAddress()) ownerBalancerAfterCollect := s.App.BankKeeper.GetAllBalances(ctx, owner) - s.Require().Equal(expectedBalanceDelta.String(), poolBalanceBeforeCollect.Sub(poolBalanceAfterCollect).String()) - s.Require().Equal(expectedBalanceDelta.String(), ownerBalancerAfterCollect.Sub(ownerBalancerBeforeCollect).String()) + s.Require().Equal(expectedPoolBalanceDelta.String(), poolBalanceBeforeCollect.Sub(poolBalanceAfterCollect).String()) + s.Require().Equal(expectedPoolBalanceDelta.Add(expectedIncentivesClaimed...).String(), ownerBalancerAfterCollect.Sub(ownerBalancerBeforeCollect).String()) + s.Require().Equal(expectedIncentivesClaimed.String(), incentivesBalanceBeforeCollect.Sub(incentivesBalanceAfterCollect).String()) if expectedRemainingLiquidity.IsZero() { // Check that the positionLiquidity was deleted. diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index de5dd61ed52..47a378b96fe 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -7,12 +7,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/internal/math" "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types" - gammtypes "github.com/osmosis-labs/osmosis/v15/x/gamm/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v15/x/poolmanager/types" ) +const ( + incentivesAddressPrefix = "incentives" +) + var ( _ types.ConcentratedPoolExtension = &Pool{} one = sdk.OneDec() @@ -38,8 +42,8 @@ func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpac // Create a new pool struct with the specified parameters pool := Pool{ - // TODO: move gammtypes.NewPoolAddress(poolId) to poolmanagertypes - Address: gammtypes.NewPoolAddress(poolId).String(), + Address: poolmanagertypes.NewPoolAddress(poolId).String(), + IncentivesAddress: osmoutils.NewModuleAddressWithPrefix(types.ModuleName, incentivesAddressPrefix, sdk.Uint64ToBigEndian(poolId)).String(), Id: poolId, CurrentSqrtPrice: sdk.ZeroDec(), CurrentTick: sdk.ZeroInt(), @@ -63,6 +67,15 @@ func (p Pool) GetAddress() sdk.AccAddress { return addr } +// GetIncentivesAddress returns the address storing incentives of the concentrated liquidity pool. +func (p Pool) GetIncentivesAddress() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(p.IncentivesAddress) + if err != nil { + panic(fmt.Sprintf("could not bech32 decode address of pool with id: %d", p.GetId())) + } + return addr +} + // GetId returns the id of the concentrated liquidity pool func (p Pool) GetId() uint64 { return p.Id diff --git a/x/concentrated-liquidity/model/pool.pb.go b/x/concentrated-liquidity/model/pool.pb.go index 8c85f19f668..99375479d94 100644 --- a/x/concentrated-liquidity/model/pool.pb.go +++ b/x/concentrated-liquidity/model/pool.pb.go @@ -35,23 +35,26 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Pool struct { + // pool's address holding all liquidity tokens. Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` - Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + // address holding the incentives liquidity. + IncentivesAddress string `protobuf:"bytes,2,opt,name=incentives_address,json=incentivesAddress,proto3" json:"incentives_address,omitempty" yaml:"incentives_address"` + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` // Amount of total liquidity - CurrentTickLiquidity github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=current_tick_liquidity,json=currentTickLiquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_tick_liquidity" yaml:"current_tick_liquidity"` - Token0 string `protobuf:"bytes,4,opt,name=token0,proto3" json:"token0,omitempty"` - Token1 string `protobuf:"bytes,5,opt,name=token1,proto3" json:"token1,omitempty"` - CurrentSqrtPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=current_sqrt_price,json=currentSqrtPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_sqrt_price" yaml:"spot_price"` - CurrentTick github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=current_tick,json=currentTick,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"current_tick" yaml:"current_tick"` + CurrentTickLiquidity github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=current_tick_liquidity,json=currentTickLiquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_tick_liquidity" yaml:"current_tick_liquidity"` + Token0 string `protobuf:"bytes,5,opt,name=token0,proto3" json:"token0,omitempty"` + Token1 string `protobuf:"bytes,6,opt,name=token1,proto3" json:"token1,omitempty"` + CurrentSqrtPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=current_sqrt_price,json=currentSqrtPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_sqrt_price" yaml:"spot_price"` + CurrentTick github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=current_tick,json=currentTick,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"current_tick" yaml:"current_tick"` // tick_spacing must be one of the authorized_tick_spacing values set in the // concentrated-liquidity parameters - TickSpacing uint64 `protobuf:"varint,8,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` - ExponentAtPriceOne github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"exponent_at_price_one" yaml:"exponent_at_price_one"` + TickSpacing uint64 `protobuf:"varint,9,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` + ExponentAtPriceOne github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"exponent_at_price_one" yaml:"exponent_at_price_one"` // swap_fee is the ratio that is charged on the amount of token in. - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee" yaml:"swap_fee"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee" yaml:"swap_fee"` // last_liquidity_update is the last time either the pool liquidity or the // active tick changed - LastLiquidityUpdate time.Time `protobuf:"bytes,11,opt,name=last_liquidity_update,json=lastLiquidityUpdate,proto3,stdtime" json:"last_liquidity_update" yaml:"last_liquidity_update"` + LastLiquidityUpdate time.Time `protobuf:"bytes,12,opt,name=last_liquidity_update,json=lastLiquidityUpdate,proto3,stdtime" json:"last_liquidity_update" yaml:"last_liquidity_update"` } func (m *Pool) Reset() { *m = Pool{} } @@ -95,45 +98,47 @@ func init() { } var fileDescriptor_3526ea5373d96c9a = []byte{ - // 596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xb6, 0x4b, 0xdb, 0xb4, 0x9b, 0xaa, 0xd0, 0xed, 0x0f, 0x26, 0x02, 0x3b, 0xb2, 0x04, 0x0a, - 0x12, 0xb1, 0x09, 0x88, 0x4b, 0x6e, 0x0d, 0x3f, 0x52, 0x25, 0x44, 0x2b, 0xb7, 0x5c, 0x50, 0x25, - 0xcb, 0xb1, 0xb7, 0xee, 0x2a, 0xb6, 0xd7, 0xf1, 0x6e, 0x4a, 0x72, 0x44, 0x02, 0x89, 0x63, 0x8f, - 0x1c, 0xfb, 0x10, 0x3c, 0x44, 0xc5, 0xa9, 0x47, 0xc4, 0x21, 0xa0, 0xe4, 0x0d, 0xf2, 0x04, 0xc8, - 0xeb, 0x75, 0x62, 0x89, 0x70, 0xc8, 0xc9, 0x9e, 0x6f, 0xc6, 0xdf, 0xf7, 0xcd, 0xac, 0x67, 0xc1, - 0x63, 0x42, 0x43, 0x42, 0x31, 0x35, 0x5d, 0x12, 0xb9, 0x28, 0x62, 0x89, 0xc3, 0x90, 0x57, 0x0f, - 0x70, 0xb7, 0x87, 0x3d, 0xcc, 0x06, 0x66, 0x4c, 0x48, 0x60, 0xc4, 0x09, 0x61, 0x04, 0x3e, 0x14, - 0xa5, 0x46, 0xb1, 0x74, 0x5a, 0x69, 0x5c, 0x34, 0xda, 0x88, 0x39, 0x8d, 0xca, 0x3d, 0x97, 0xd7, - 0xd9, 0xfc, 0x23, 0x33, 0x0b, 0x32, 0x86, 0xca, 0x8e, 0x4f, 0x7c, 0x92, 0xe1, 0xe9, 0x9b, 0x40, - 0x35, 0x9f, 0x10, 0x3f, 0x40, 0x26, 0x8f, 0xda, 0xbd, 0x33, 0x93, 0xe1, 0x10, 0x51, 0xe6, 0x84, - 0x71, 0x56, 0xa0, 0x7f, 0x2e, 0x81, 0xe5, 0x23, 0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0xcd, 0x58, 0x95, 0x7e, 0x8e, 0x55, 0xe9, 0x43, 0xab, 0xd0, 0xaa, 0xb8, 0x24, - 0xea, 0x81, 0xd3, 0xa6, 0x79, 0x60, 0x5e, 0x34, 0x5e, 0x98, 0xfd, 0xff, 0x5d, 0x31, 0x21, 0xf1, - 0x50, 0xd0, 0x5e, 0xe5, 0x3d, 0x3c, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x88, 0x54, 0x6e, - 0x91, 0x04, 0x00, 0x00, + // 626 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x4e, 0xdb, 0x40, + 0x10, 0xb6, 0x29, 0x10, 0xd8, 0x20, 0x5a, 0x96, 0x9f, 0x1a, 0x54, 0x6c, 0x64, 0xa9, 0x55, 0x2a, + 0x35, 0x76, 0xd3, 0xaa, 0x17, 0x6e, 0xa4, 0x3f, 0x12, 0x12, 0x2a, 0xc8, 0xd0, 0x4b, 0x85, 0x64, + 0x39, 0xf6, 0x62, 0x56, 0xb1, 0xbd, 0x8e, 0x77, 0x43, 0xc9, 0xb1, 0x87, 0x4a, 0x3d, 0x72, 0xec, + 0x91, 0x87, 0xe8, 0x43, 0xa0, 0x9e, 0x50, 0x4f, 0x55, 0x0f, 0x6e, 0x95, 0xbc, 0x41, 0x9e, 0xa0, + 0xf2, 0x7a, 0x9d, 0x58, 0x22, 0x3d, 0xe4, 0x64, 0xcf, 0x37, 0x33, 0xdf, 0x7c, 0x33, 0xbb, 0xb3, + 0xe0, 0x29, 0xa1, 0x21, 0xa1, 0x98, 0x9a, 0x2e, 0x89, 0x5c, 0x14, 0xb1, 0xc4, 0x61, 0xc8, 0xab, + 0x07, 0xb8, 0xd3, 0xc5, 0x1e, 0x66, 0x3d, 0x33, 0x26, 0x24, 0x30, 0xe2, 0x84, 0x30, 0x02, 0x1f, + 0x8b, 0x50, 0xa3, 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, 0x1b, 0xdf, 0x29, 0xbb, 0x1b, 0x7b, 0x0e, 0x43, 0xca, 0xd2, 0x8e, 0x5c, 0xab, 0xbe, + 0xd8, 0x32, 0xf2, 0x45, 0x34, 0x8a, 0x45, 0x34, 0x4e, 0x8a, 0x45, 0x6c, 0xd6, 0x32, 0x19, 0xe3, + 0x96, 0x26, 0xd2, 0xe8, 0x57, 0x7f, 0x34, 0xd9, 0x5a, 0xcd, 0x7c, 0xa3, 0xeb, 0xf9, 0x81, 0x7b, + 0x76, 0x57, 0xbe, 0x5e, 0x6b, 0xd2, 0xb7, 0x6b, 0x4d, 0xfa, 0xf1, 0xbd, 0x3e, 0x97, 0xad, 0xf2, + 0x7e, 0xf3, 0xf4, 0xa6, 0xaf, 0xca, 0xb7, 0x7d, 0x55, 0xfe, 0xdb, 0x57, 0xe5, 0xab, 0x81, 0x2a, + 0xdd, 0x0e, 0x54, 0xe9, 0xd7, 0x40, 0x95, 0x3e, 0x36, 0x4b, 0xad, 0x8a, 0x27, 0xa7, 0x1e, 0x38, + 0x2d, 0x5a, 0x18, 0xe6, 0x45, 0xe3, 0x95, 0x79, 0xf9, 0xbf, 0x07, 0x2b, 0x24, 0x1e, 0x0a, 0x5a, + 0xf3, 0xbc, 0x87, 0x97, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xdf, 0xcb, 0xdc, 0x32, 0xdf, 0x04, + 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -163,7 +168,7 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintPool(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x62 { size := m.SwapFee.Size() i -= size @@ -173,7 +178,7 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a { size := m.ExponentAtPriceOne.Size() i -= size @@ -183,11 +188,11 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 if m.TickSpacing != 0 { i = encodeVarintPool(dAtA, i, uint64(m.TickSpacing)) i-- - dAtA[i] = 0x40 + dAtA[i] = 0x48 } { size := m.CurrentTick.Size() @@ -198,7 +203,7 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 { size := m.CurrentSqrtPrice.Size() i -= size @@ -208,20 +213,20 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a if len(m.Token1) > 0 { i -= len(m.Token1) copy(dAtA[i:], m.Token1) i = encodeVarintPool(dAtA, i, uint64(len(m.Token1))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if len(m.Token0) > 0 { i -= len(m.Token0) copy(dAtA[i:], m.Token0) i = encodeVarintPool(dAtA, i, uint64(len(m.Token0))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } { size := m.CurrentTickLiquidity.Size() @@ -232,11 +237,18 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 if m.Id != 0 { i = encodeVarintPool(dAtA, i, uint64(m.Id)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 + } + if len(m.IncentivesAddress) > 0 { + i -= len(m.IncentivesAddress) + copy(dAtA[i:], m.IncentivesAddress) + i = encodeVarintPool(dAtA, i, uint64(len(m.IncentivesAddress))) + i-- + dAtA[i] = 0x12 } if len(m.Address) > 0 { i -= len(m.Address) @@ -269,6 +281,10 @@ func (m *Pool) Size() (n int) { if l > 0 { n += 1 + l + sovPool(uint64(l)) } + l = len(m.IncentivesAddress) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } if m.Id != 0 { n += 1 + sovPool(uint64(m.Id)) } @@ -366,6 +382,38 @@ func (m *Pool) Unmarshal(dAtA []byte) error { m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentivesAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentivesAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } @@ -384,7 +432,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CurrentTickLiquidity", wireType) } @@ -418,7 +466,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Token0", wireType) } @@ -450,7 +498,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } m.Token0 = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Token1", wireType) } @@ -482,7 +530,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } m.Token1 = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CurrentSqrtPrice", wireType) } @@ -516,7 +564,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CurrentTick", wireType) } @@ -550,7 +598,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TickSpacing", wireType) } @@ -569,7 +617,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { break } } - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExponentAtPriceOne", wireType) } @@ -603,7 +651,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) } @@ -637,7 +685,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastLiquidityUpdate", wireType) } diff --git a/x/concentrated-liquidity/msg_server_test.go b/x/concentrated-liquidity/msg_server_test.go index e2ce99eaa66..a7f8e643c73 100644 --- a/x/concentrated-liquidity/msg_server_test.go +++ b/x/concentrated-liquidity/msg_server_test.go @@ -296,7 +296,7 @@ func (suite *KeeperTestSuite) TestCollectIncentives_Events() { // Set up accrued incentives err = addToUptimeAccums(ctx, pool.GetId(), suite.App.ConcentratedLiquidityKeeper, uptimeHelper.hundredTokensMultiDenom) suite.Require().NoError(err) - suite.FundAcc(pool.GetAddress(), expectedIncentivesFromUptimeGrowth(uptimeHelper.hundredTokensMultiDenom, DefaultLiquidityAmt, positionAge, sdk.NewInt(int64(len(tc.positionIds))))) + suite.FundAcc(pool.GetIncentivesAddress(), expectedIncentivesFromUptimeGrowth(uptimeHelper.hundredTokensMultiDenom, DefaultLiquidityAmt, positionAge, sdk.NewInt(int64(len(tc.positionIds))))) msgServer := cl.NewMsgServerImpl(suite.App.ConcentratedLiquidityKeeper) diff --git a/x/concentrated-liquidity/types/pool.go b/x/concentrated-liquidity/types/pool.go index c0ca5bf5bc8..ee30f03d60c 100644 --- a/x/concentrated-liquidity/types/pool.go +++ b/x/concentrated-liquidity/types/pool.go @@ -11,7 +11,7 @@ import ( type ConcentratedPoolExtension interface { poolmanagertypes.PoolI - // TODO: move these to separate interfaces + GetIncentivesAddress() sdk.AccAddress GetToken0() string GetToken1() string GetCurrentSqrtPrice() sdk.Dec diff --git a/x/gamm/keeper/grpc_query_test.go b/x/gamm/keeper/grpc_query_test.go index 401304f4040..c62a66b1054 100644 --- a/x/gamm/keeper/grpc_query_test.go +++ b/x/gamm/keeper/grpc_query_test.go @@ -12,6 +12,7 @@ import ( balancertypes "github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/stableswap" "github.com/osmosis-labs/osmosis/v15/x/gamm/types" + poolmanagertypes "github.com/osmosis-labs/osmosis/v15/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v15/x/gamm/v2types" ) @@ -455,7 +456,7 @@ func (suite *KeeperTestSuite) TestQueryPool() { err = suite.App.InterfaceRegistry().UnpackAny(poolRes.Pool, &pool) suite.Require().NoError(err) suite.Require().Equal(poolId, pool.GetId()) - suite.Require().Equal(types.NewPoolAddress(poolId).String(), pool.GetAddress().String()) + suite.Require().Equal(poolmanagertypes.NewPoolAddress(poolId).String(), pool.GetAddress().String()) } } @@ -472,7 +473,7 @@ func (suite *KeeperTestSuite) TestQueryPools() { err = suite.App.InterfaceRegistry().UnpackAny(poolRes.Pool, &pool) suite.Require().NoError(err) suite.Require().Equal(poolId, pool.GetId()) - suite.Require().Equal(types.NewPoolAddress(poolId).String(), pool.GetAddress().String()) + suite.Require().Equal(poolmanagertypes.NewPoolAddress(poolId).String(), pool.GetAddress().String()) } res, err := queryClient.Pools(gocontext.Background(), &types.QueryPoolsRequest{ @@ -488,7 +489,7 @@ func (suite *KeeperTestSuite) TestQueryPools() { var pool types.CFMMPoolI err = suite.App.InterfaceRegistry().UnpackAny(r, &pool) suite.Require().NoError(err) - suite.Require().Equal(types.NewPoolAddress(uint64(1)).String(), pool.GetAddress().String()) + suite.Require().Equal(poolmanagertypes.NewPoolAddress(uint64(1)).String(), pool.GetAddress().String()) suite.Require().Equal(uint64(1), pool.GetId()) } @@ -505,7 +506,7 @@ func (suite *KeeperTestSuite) TestQueryPools() { var pool types.CFMMPoolI err = suite.App.InterfaceRegistry().UnpackAny(r, &pool) suite.Require().NoError(err) - suite.Require().Equal(types.NewPoolAddress(uint64(i+1)).String(), pool.GetAddress().String()) + suite.Require().Equal(poolmanagertypes.NewPoolAddress(uint64(i+1)).String(), pool.GetAddress().String()) suite.Require().Equal(uint64(i+1), pool.GetId()) } } diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index 91a82e27a20..66bf101345a 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -41,7 +41,7 @@ var ( // * FutureGovernor is valid // * poolID doesn't already exist func NewBalancerPool(poolId uint64, balancerPoolParams PoolParams, assets []PoolAsset, futureGovernor string, blockTime time.Time) (Pool, error) { - poolAddr := types.NewPoolAddress(poolId) + poolAddr := poolmanagertypes.NewPoolAddress(poolId) // pool thats created up to ensuring the assets and params are valid. // We assume that FuturePoolGovernor is valid. diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index aadd6712a84..61bd0689cd1 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -14,6 +14,7 @@ import ( "github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/internal/test_helpers" "github.com/osmosis-labs/osmosis/v15/x/gamm/types" + poolmanagertypes "github.com/osmosis-labs/osmosis/v15/x/poolmanager/types" ) var ( @@ -1337,7 +1338,7 @@ func TestCalcJoinPoolNoSwapShares(t *testing.T) { t.Run(name, func(t *testing.T) { ctx := sdk.Context{} balancerPool := balancer.Pool{ - Address: types.NewPoolAddress(defaultPoolId).String(), + Address: poolmanagertypes.NewPoolAddress(defaultPoolId).String(), Id: defaultPoolId, PoolParams: balancer.PoolParams{SwapFee: defaultSwapFee, ExitFee: defaultExitFee}, PoolAssets: test.poolAssets, diff --git a/x/gamm/pool-models/stableswap/pool.go b/x/gamm/pool-models/stableswap/pool.go index 40cf09dccd0..3ce93b96a7a 100644 --- a/x/gamm/pool-models/stableswap/pool.go +++ b/x/gamm/pool-models/stableswap/pool.go @@ -52,7 +52,7 @@ func NewStableswapPool(poolId uint64, } pool := Pool{ - Address: types.NewPoolAddress(poolId).String(), + Address: poolmanagertypes.NewPoolAddress(poolId).String(), Id: poolId, PoolParams: stableswapPoolParams, TotalShares: sdk.NewCoin(types.GetPoolShareDenom(poolId), types.InitPoolSharesSupply), diff --git a/x/gamm/pool-models/stableswap/pool_test.go b/x/gamm/pool-models/stableswap/pool_test.go index 1297d677bc1..5cab54fa3f5 100644 --- a/x/gamm/pool-models/stableswap/pool_test.go +++ b/x/gamm/pool-models/stableswap/pool_test.go @@ -13,6 +13,7 @@ import ( "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" "github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/internal/cfmm_common" "github.com/osmosis-labs/osmosis/v15/x/gamm/types" + poolmanagertypes "github.com/osmosis-labs/osmosis/v15/x/poolmanager/types" ) var ( @@ -67,7 +68,7 @@ func poolStructFromAssets(assets sdk.Coins, scalingFactors []uint64) Pool { scalingFactors, _ = applyScalingFactorMultiplier(scalingFactors) p := Pool{ - Address: types.NewPoolAddress(defaultPoolId).String(), + Address: poolmanagertypes.NewPoolAddress(defaultPoolId).String(), Id: defaultPoolId, PoolParams: defaultStableswapPoolParams, TotalShares: sdk.NewCoin(types.GetPoolShareDenom(defaultPoolId), types.InitPoolSharesSupply), diff --git a/x/gamm/types/pool.go b/x/gamm/types/pool.go index 38cc6fe3c8a..6bac8ca41a2 100644 --- a/x/gamm/types/pool.go +++ b/x/gamm/types/pool.go @@ -3,8 +3,6 @@ package types import ( "time" - "github.com/cosmos/cosmos-sdk/types/address" - sdk "github.com/cosmos/cosmos-sdk/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v15/x/poolmanager/types" @@ -107,9 +105,3 @@ type WeightedPoolExtension interface { // GetTokenWeight returns the weight of the specified token in the pool. GetTokenWeight(denom string) (sdk.Int, error) } - -// TODO: move to poolmanager -func NewPoolAddress(poolId uint64) sdk.AccAddress { - key := append([]byte("pool"), sdk.Uint64ToBigEndian(poolId)...) - return address.Module(ModuleName, key) -} diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index ee9cd4aee8c..87a812db6a4 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -22,7 +22,7 @@ func (k Keeper) validateCreatedPool( return sdkerrors.Wrapf(types.ErrInvalidPool, "Pool was attempted to be created with incorrect pool ID.") } - if !pool.GetAddress().Equals(gammtypes.NewPoolAddress(poolId)) { + if !pool.GetAddress().Equals(types.NewPoolAddress(poolId)) { return sdkerrors.Wrapf(types.ErrInvalidPool, "Pool was attempted to be created with incorrect pool address.") } diff --git a/x/poolmanager/types/pool.go b/x/poolmanager/types/pool.go index 00c04038740..dd8e3473294 100644 --- a/x/poolmanager/types/pool.go +++ b/x/poolmanager/types/pool.go @@ -3,6 +3,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" proto "github.com/gogo/protobuf/proto" + + "github.com/osmosis-labs/osmosis/osmoutils" ) // PoolI defines an interface for pools that hold tokens. @@ -34,3 +36,8 @@ type PoolI interface { // GetType returns the type of the pool (Balancer, Stableswap, Concentrated, etc.) GetType() PoolType } + +// NewPoolAddress returns an address for a pool from a given id. +func NewPoolAddress(poolId uint64) sdk.AccAddress { + return osmoutils.NewModuleAddressWithPrefix(ModuleName, "pool", sdk.Uint64ToBigEndian(poolId)) +}