From 1986552f19871f4a83d044f5ab9b9bd4bb7bc8a6 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Wed, 23 Aug 2023 17:19:23 -0700 Subject: [PATCH 01/16] basic proto fix --- proto/duality/dex/pool.proto | 7 +- x/dex/keeper/core.go | 11 +- x/dex/keeper/core_helper_test.go | 3 +- x/dex/keeper/deposit_record.go | 17 +- x/dex/keeper/msg_server_test.go | 16 +- x/dex/keeper/pool.go | 123 ++++++- x/dex/keeper/pool_test.go | 26 ++ x/dex/types/deposit_denom.go | 75 ----- x/dex/types/keys.go | 30 +- x/dex/types/pool.go | 18 +- x/dex/types/pool.pb.go | 82 ++++- x/dex/types/pool_denom.go | 22 ++ x/dex/types/pool_params.go | 38 +++ x/incentives/client/cli/query_test.go | 10 +- x/incentives/keeper/distribute.go | 12 +- x/incentives/keeper/distribute_test.go | 24 +- x/incentives/keeper/distributor.go | 3 +- x/incentives/keeper/distributor_test.go | 12 +- x/incentives/keeper/export_test.go | 4 +- x/incentives/keeper/gauge.go | 2 +- x/incentives/keeper/keeper_test.go | 10 +- x/incentives/keeper/query_server.go | 10 +- x/incentives/keeper/stake.go | 20 ++ x/incentives/keeper/stake_refs.go | 12 +- x/incentives/keeper/suite_test.go | 10 - x/incentives/keeper/utils_test.go | 103 +++--- x/incentives/types/expected_keepers.go | 1 + x/incentives/types/query_condition.go | 18 +- x/incentives/types/query_condition_test.go | 16 +- x/incentives/types/stake.go | 62 +--- x/incentives/types/stakes.go | 21 +- x/incentives/types/stakes_test.go | 373 +++++++++++---------- 32 files changed, 666 insertions(+), 525 deletions(-) create mode 100644 x/dex/keeper/pool_test.go delete mode 100644 x/dex/types/deposit_denom.go create mode 100644 x/dex/types/pool_denom.go create mode 100644 x/dex/types/pool_params.go diff --git a/proto/duality/dex/pool.proto b/proto/duality/dex/pool.proto index 932687b79..3498ca0a9 100644 --- a/proto/duality/dex/pool.proto +++ b/proto/duality/dex/pool.proto @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto"; import "duality/dex/pool_reserves.proto"; message Pool { - PoolReserves lower_tick0 = 1; - PoolReserves upper_tick1 = 2; -} \ No newline at end of file + string ID = 1; + PoolReserves lower_tick0 = 2; + PoolReserves upper_tick1 = 3; +} diff --git a/x/dex/keeper/core.go b/x/dex/keeper/core.go index c15911a12..12ea961fd 100644 --- a/x/dex/keeper/core.go +++ b/x/dex/keeper/core.go @@ -56,7 +56,7 @@ func (k Keeper) DepositCore( return nil, nil, nil, err } - existingShares := k.bankKeeper.GetSupply(ctx, pool.GetDepositDenom()).Amount + existingShares := k.bankKeeper.GetSupply(ctx, pool.GetPoolDenom()).Amount inAmount0, inAmount1, outShares := pool.Deposit(amount0, amount1, existingShares, autoswap) @@ -136,9 +136,8 @@ func (k Keeper) WithdrawCore( return err } - sharesID := types.NewDepositDenom(&types.PairID{Token0: pairID.Token0, Token1: pairID.Token1}, tickIndex, fee). - String() - totalShares := k.bankKeeper.GetSupply(ctx, sharesID).Amount + poolSharesDenom := pool.GetPoolDenom() + totalShares := k.bankKeeper.GetSupply(ctx, poolSharesDenom).Amount if totalShares.LT(sharesToRemove) { return sdkerrors.Wrapf( @@ -146,7 +145,7 @@ func (k Keeper) WithdrawCore( "%s does not have %s shares of type %s", callerAddr, sharesToRemove, - sharesID, + poolSharesDenom, ) } @@ -154,7 +153,7 @@ func (k Keeper) WithdrawCore( k.SetPool(ctx, pool) if sharesToRemove.IsPositive() { - if err := k.BurnShares(ctx, callerAddr, sharesToRemove, sharesID); err != nil { + if err := k.BurnShares(ctx, callerAddr, sharesToRemove, poolSharesDenom); err != nil { return err } } diff --git a/x/dex/keeper/core_helper_test.go b/x/dex/keeper/core_helper_test.go index 5ac71dfff..95b9dbe5a 100644 --- a/x/dex/keeper/core_helper_test.go +++ b/x/dex/keeper/core_helper_test.go @@ -63,7 +63,6 @@ func (s *CoreHelpersTestSuite) SetupTest() { func (s *CoreHelpersTestSuite) setLPAtFee1Pool(tickIndex int64, amountA int, amountB int) { pairID := &types.PairID{Token0: "TokenA", Token1: "TokenB"} - sharesID := types.NewDepositDenom(pairID, tickIndex, 0).String() pool, err := s.app.DexKeeper.GetOrInitPool(s.ctx, pairID, tickIndex, 1) if err != nil { panic(err) @@ -72,7 +71,7 @@ func (s *CoreHelpersTestSuite) setLPAtFee1Pool(tickIndex int64, amountA int, amo amountAInt := sdk.NewInt(int64(amountA)) amountBInt := sdk.NewInt(int64(amountB)) - existingShares := s.app.BankKeeper.GetSupply(s.ctx, sharesID).Amount + existingShares := s.app.BankKeeper.GetSupply(s.ctx, pool.GetPoolDenom()).Amount totalShares := pool.CalcSharesMinted(amountAInt, amountBInt, existingShares) diff --git a/x/dex/keeper/deposit_record.go b/x/dex/keeper/deposit_record.go index 1e92e9d0a..c2791dbd4 100644 --- a/x/dex/keeper/deposit_record.go +++ b/x/dex/keeper/deposit_record.go @@ -10,18 +10,23 @@ func (k Keeper) GetAllDepositsForAddress(ctx sdk.Context, addr sdk.AccAddress) [ var depositArr []*types.DepositRecord k.bankKeeper.IterateAccountBalances(ctx, addr, func(sharesMaybe sdk.Coin) bool { - depositDenom, err := types.NewDepositDenomFromString(sharesMaybe.Denom) + err := types.ValidatePoolDenom(sharesMaybe.Denom) if err != nil { return false } + poolParams, err := k.GetPoolParamsByID(ctx, sharesMaybe.Denom) + if err != nil { + panic("Can't get info for PoolDenom") + } + fee := utils.MustSafeUint64(poolParams.Fee) depositRecord := &types.DepositRecord{ - PairID: depositDenom.PairID, + PairID: poolParams.PairID, SharesOwned: sharesMaybe.Amount, - CenterTickIndex: depositDenom.Tick, - LowerTickIndex: depositDenom.Tick - utils.MustSafeUint64(depositDenom.Fee), - UpperTickIndex: depositDenom.Tick + utils.MustSafeUint64(depositDenom.Fee), - Fee: depositDenom.Fee, + CenterTickIndex: poolParams.Tick, + LowerTickIndex: poolParams.Tick - fee, + UpperTickIndex: poolParams.Tick + fee, + Fee: poolParams.Fee, } depositArr = append(depositArr, depositRecord) diff --git a/x/dex/keeper/msg_server_test.go b/x/dex/keeper/msg_server_test.go index 6735fc08e..7fc1798f6 100644 --- a/x/dex/keeper/msg_server_test.go +++ b/x/dex/keeper/msg_server_test.go @@ -1064,9 +1064,11 @@ func (s *MsgServerTestSuite) getPoolShares( tick int64, fee uint64, ) (shares sdk.Int) { - sharesID := types.NewDepositDenom(&types.PairID{Token0: token0, Token1: token1}, tick, fee). - String() - return s.app.BankKeeper.GetSupply(s.ctx, sharesID).Amount + poolID, found := s.app.DexKeeper.GetPoolIDByParams(s.ctx, &types.PairID{Token0: token0, Token1: token1}, tick, fee) + if !found { + return sdk.ZeroInt() + } + return s.app.BankKeeper.GetSupply(s.ctx, poolID).Amount } func (s *MsgServerTestSuite) assertPoolShares( @@ -1086,9 +1088,11 @@ func (s *MsgServerTestSuite) getAccountShares( tick int64, fee uint64, ) (shares sdk.Int) { - sharesID := types.NewDepositDenom(&types.PairID{Token0: token0, Token1: token1}, tick, fee). - String() - return s.app.BankKeeper.GetBalance(s.ctx, account, sharesID).Amount + id, found := s.app.DexKeeper.GetPoolIDByParams(s.ctx, types.MustNewPairID(token0, token1), tick, fee) + if !found { + return sdk.ZeroInt() + } + return s.app.BankKeeper.GetBalance(s.ctx, account, id).Amount } func (s *MsgServerTestSuite) assertAccountShares( diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index fc9403bf5..23cc2db66 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -1,6 +1,10 @@ package keeper import ( + "encoding/binary" + "fmt" + + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/duality-labs/duality/x/dex/types" "github.com/duality-labs/duality/x/dex/utils" @@ -17,7 +21,46 @@ func (k Keeper) GetOrInitPool( return pool, nil } - return types.NewPool(pairID, centerTickIndexNormalized, fee) + return k.InitPool(ctx, pairID, centerTickIndexNormalized, fee) +} + +func (k Keeper) InitPool( + ctx sdk.Context, + pairID *types.PairID, + centerTickIndexNormalized int64, + fee uint64, +) (*types.Pool, error) { + poolID := k.InitPoolKeys(ctx, pairID, centerTickIndexNormalized, fee) + return types.NewPool(pairID, centerTickIndexNormalized, fee, poolID) +} + +func (k Keeper) InitPoolKeys(ctx sdk.Context, + pairID *types.PairID, + centerTickIndexNormalized int64, + fee uint64, +) string { + poolKeyBz := types.PoolKey(*pairID, centerTickIndexNormalized, fee) + + poolID := k.GetNextPoolID(ctx) + poolIDBz := []byte(poolID) + + store := ctx.KVStore(k.storeKey) + + poolIDStore := prefix.NewStore(store, types.KeyPrefix(types.PoolIDKeyPrefix)) + poolIDStore.Set(poolKeyBz, poolIDBz) + + poolRefStore := prefix.NewStore(store, types.KeyPrefix(types.PoolRefKeyPrefix)) + poolRefStore.Set(poolIDBz, poolKeyBz) + + return poolID +} + +// GetNextPoolId get ID for the next pool to be created +func (k Keeper) GetNextPoolID(ctx sdk.Context) string { + poolCount := k.GetPoolCount(ctx) + // JCP TODO: this should happen in init keys once we switch poolID to uint64 + k.SetPoolCount(ctx, poolCount+1) + return types.NewPoolDenom(poolCount) } func (k Keeper) GetPool( @@ -34,6 +77,11 @@ func (k Keeper) GetPool( Fee: fee, } + poolID, found := k.GetPoolIDByParams(ctx, pairID, centerTickIndexNormalized, fee) + if !found { + return nil, false + } + upperTick, upperTickFound := k.GetPoolReserves(ctx, id0To1) lowerTick, lowerTickFound := k.GetPoolReserves(ctx, id0To1.Counterpart()) @@ -46,11 +94,84 @@ func (k Keeper) GetPool( } return &types.Pool{ + ID: poolID, LowerTick0: lowerTick, UpperTick1: upperTick, }, true } +// GetPoolCount get the total number of pool +func (k Keeper) GetPoolCount(ctx sdk.Context) uint64 { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.KeyPrefix(types.PoolCountKeyPrefix) + bz := store.Get(byteKey) + + // Count doesn't exist: no element + if bz == nil { + return 0 + } + + // Parse bytes + return binary.BigEndian.Uint64(bz) +} + +func (k Keeper) GetPoolIDByParams( + ctx sdk.Context, + pairID *types.PairID, + centerTickIndexNormalized int64, + fee uint64, +) (id string, found bool) { + poolRefKey := types.PoolKey(*pairID, centerTickIndexNormalized, fee) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolIDKeyPrefix)) + b := store.Get(poolRefKey) + if b == nil { + return "", false + } + + return string(b), true +} + +func (k Keeper) GetPoolParamsByID( + ctx sdk.Context, + id string, +) (types.PoolParams, error) { + // JCP TODO: should this be found vs error? + ref, found := k.GetPoolRefByID(ctx, id) + if !found { + return types.PoolParams{}, types.ErrInvalidDepositDenom + } + fmt.Printf("REf: %v (%v)\n", ref, string(ref)) + + poolParams, err := types.ParsePoolRefToParams(ref) + if err != nil { + panic("Cannot parse pool ref") + } + + return poolParams, nil +} + +func (k Keeper) GetPoolRefByID( + ctx sdk.Context, + id string, +) (ref []byte, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRefKeyPrefix)) + b := store.Get([]byte(id)) + if b == nil { + return []byte{}, false + } + + return b, true +} + +// SetPoolCount set the total number of pool +func (k Keeper) SetPoolCount(ctx sdk.Context, count uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.KeyPrefix(types.PoolCountKeyPrefix) + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, count) + store.Set(byteKey, bz) +} + func (k Keeper) SetPool(ctx sdk.Context, pool *types.Pool) { if pool.LowerTick0.HasToken() { k.SetPoolReserves(ctx, pool.LowerTick0) diff --git a/x/dex/keeper/pool_test.go b/x/dex/keeper/pool_test.go new file mode 100644 index 000000000..a6d5f0c48 --- /dev/null +++ b/x/dex/keeper/pool_test.go @@ -0,0 +1,26 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/duality-labs/duality/testutil/keeper" + "github.com/stretchr/testify/require" +) + +func TestPoolInit(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + + pool, err := keeper.InitPool(ctx, defaultPairID, 0, 1) + require.NoError(t, err) + pool.Deposit(sdk.NewInt(100), sdk.NewInt(100), sdk.NewInt(0), true) + keeper.SetPool(ctx, pool) + + dbPool, found := keeper.GetPool(ctx, defaultPairID, 0, 1) + + require.True(t, found) + + require.Equal(t, pool.ID, dbPool.ID) + require.Equal(t, pool.LowerTick0, dbPool.LowerTick0) + require.Equal(t, pool.UpperTick1, dbPool.UpperTick1) +} diff --git a/x/dex/types/deposit_denom.go b/x/dex/types/deposit_denom.go deleted file mode 100644 index e888e6615..000000000 --- a/x/dex/types/deposit_denom.go +++ /dev/null @@ -1,75 +0,0 @@ -package types - -import ( - fmt "fmt" - "regexp" - "strconv" - "strings" -) - -const LPsharesRegexpStr = "^" + DepositSharesPrefix + "-" + - // Token0 (regexp from cosmos-sdk.types.coin.reDnmString) - "([a-zA-Z][a-zA-Z0-9/-]{2,127})" + "-" + - // Token1 - "([a-zA-Z][a-zA-Z0-9/-]{2,127})" + "-" + - // Tickindex - `t(-?\d+)` + "-" + - // fee - `f(\d+)` - -var LPSharesRegexp = regexp.MustCompile(LPsharesRegexpStr) - -type DepositDenom struct { - PairID *PairID - Tick int64 - Fee uint64 -} - -func NewDepositDenom(pairID *PairID, tick int64, fee uint64) *DepositDenom { - return &DepositDenom{ - PairID: pairID, - Tick: tick, - Fee: fee, - } -} - -func NewDepositDenomFromString(denom string) (depositDenom *DepositDenom, err error) { - // NOTE: Since dashes are removed as part of CreateSharesId, if either side of the LP position are denoms that contain dashes - // they will not be parsed correctly and the correct dneom will not be returned - matchArr := LPSharesRegexp.FindAllStringSubmatch(denom, -1) - if matchArr == nil { - return nil, ErrInvalidDepositDenom - } - - matches := matchArr[0][1:5] - tick, err := strconv.ParseInt(matches[2], 10, 0) - if err != nil { - return nil, ErrInvalidDepositDenom - } - - fee, err := strconv.ParseUint(matches[3], 10, 0) - if err != nil || fee < 0 { - return nil, ErrInvalidDepositDenom - } - - return &DepositDenom{ - PairID: &PairID{ - Token0: matches[0], - Token1: matches[1], - }, - Tick: tick, - Fee: fee, - }, nil -} - -func (d DepositDenom) String() string { - // TODO: Revist security of this. - prefix := DepositDenomPairIDPrefix(d.PairID.Token0, d.PairID.Token1) - return fmt.Sprintf("%s-t%d-f%d", prefix, d.Tick, d.Fee) -} - -func DepositDenomPairIDPrefix(token0, token1 string) string { - t0 := strings.ReplaceAll(token0, "-", "") - t1 := strings.ReplaceAll(token1, "-", "") - return fmt.Sprintf("%s-%s-%s", DepositSharesPrefix, t0, t1) -} diff --git a/x/dex/types/keys.go b/x/dex/types/keys.go index 34da901fb..4a443b8bd 100644 --- a/x/dex/types/keys.go +++ b/x/dex/types/keys.go @@ -29,7 +29,7 @@ const ( ) const ( - DepositSharesPrefix = "DualityPoolShares" + PoolNamePrefix = "duality/pool/" ) const ( @@ -47,6 +47,15 @@ const ( // LimitOrderExpirationKeyPrefix is the prefix to retrieve all LimitOrderExpiration LimitOrderExpirationKeyPrefix = "LimitOrderExpiration/value/" + + // PoolIDKeyPrefix is the prefix to retrieve all PoolIds or retrieve a specific pool by pair+tick+fee + PoolIDKeyPrefix = "Pool/id/" + + // PoolRefKeyPrefix is the prefix to retrieve all pool refs (pair+tick+fee) + PoolRefKeyPrefix = "Pool/ref/" + + // PoolCountKeyPrefix is the prefix to retrieve the Pool count + PoolCountKeyPrefix = "Pool/count/" ) func KeyPrefix(p string) []byte { @@ -201,6 +210,25 @@ func LimitOrderExpirationKey( return key } +func PoolKey( + pairID PairID, + tickIndex int64, + fee uint64, +) []byte { + key := []byte(pairID.CanonicalString()) + key = append(key, []byte("/")...) + + tickIndexBytes := TickIndexToBytes(tickIndex) + key = append(key, tickIndexBytes...) + key = append(key, []byte("/")...) + + feeBytes := sdk.Uint64ToBigEndian(fee) + key = append(key, feeBytes...) + key = append(key, []byte("/")...) + + return key +} + // Deposit Event Attributes const ( DepositEventKey = "Deposit" diff --git a/x/dex/types/pool.go b/x/dex/types/pool.go index 3c9dee150..0e41ff0c4 100644 --- a/x/dex/types/pool.go +++ b/x/dex/types/pool.go @@ -9,6 +9,7 @@ func NewPool( pairID *PairID, centerTickIndexNormalized int64, fee uint64, + id string, ) (*Pool, error) { feeInt64 := utils.MustSafeUint64(fee) @@ -28,6 +29,7 @@ func NewPool( return &Pool{ LowerTick0: lowerTick, UpperTick1: upperTick, + ID: id, }, nil } @@ -108,7 +110,7 @@ func (p *Pool) Deposit( ) if inAmount0.Equal(sdk.ZeroInt()) && inAmount1.Equal(sdk.ZeroInt()) { - return sdk.ZeroInt(), sdk.ZeroInt(), sdk.Coin{Denom: p.GetDepositDenom()} + return sdk.ZeroInt(), sdk.ZeroInt(), sdk.Coin{Denom: p.GetPoolDenom()} } outShares = p.CalcSharesMinted(inAmount0, inAmount1, existingShares) @@ -135,12 +137,8 @@ func (p *Pool) Deposit( return inAmount0, inAmount1, outShares } -func (p *Pool) GetDepositDenom() string { - return NewDepositDenom( - p.UpperTick1.Key.TradePairID.MustPairID(), - p.CenterTickIndex(), - p.Fee(), - ).String() +func (p *Pool) GetPoolDenom() string { + return p.ID } func (p *Pool) Price(tradePairID *TradePairID) sdk.Dec { @@ -179,7 +177,7 @@ func (p *Pool) CalcSharesMinted( sharesMintedAmount = valueMintedToken0.TruncateInt() } - return sdk.Coin{Denom: p.GetDepositDenom(), Amount: sharesMintedAmount} + return sdk.Coin{Denom: p.GetPoolDenom(), Amount: sharesMintedAmount} } func (p *Pool) CalcResidualSharesMinted( @@ -194,10 +192,10 @@ func (p *Pool) CalcResidualSharesMinted( fee, ) if err != nil { - return sdk.Coin{Denom: p.GetDepositDenom()}, err + return sdk.Coin{Denom: p.GetPoolDenom()}, err } - return sdk.Coin{Denom: p.GetDepositDenom(), Amount: valueMintedToken0.TruncateInt()}, nil + return sdk.Coin{Denom: p.GetPoolDenom(), Amount: valueMintedToken0.TruncateInt()}, nil } func (p *Pool) RedeemValue(sharesToRemove, totalShares sdk.Int) (outAmount0, outAmount1 sdk.Int) { diff --git a/x/dex/types/pool.pb.go b/x/dex/types/pool.pb.go index 9bc8cc654..982d139e3 100644 --- a/x/dex/types/pool.pb.go +++ b/x/dex/types/pool.pb.go @@ -24,8 +24,9 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Pool struct { - LowerTick0 *PoolReserves `protobuf:"bytes,1,opt,name=lower_tick0,json=lowerTick0,proto3" json:"lower_tick0,omitempty"` - UpperTick1 *PoolReserves `protobuf:"bytes,2,opt,name=upper_tick1,json=upperTick1,proto3" json:"upper_tick1,omitempty"` + ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` + LowerTick0 *PoolReserves `protobuf:"bytes,2,opt,name=lower_tick0,json=lowerTick0,proto3" json:"lower_tick0,omitempty"` + UpperTick1 *PoolReserves `protobuf:"bytes,3,opt,name=upper_tick1,json=upperTick1,proto3" json:"upper_tick1,omitempty"` } func (m *Pool) Reset() { *m = Pool{} } @@ -61,6 +62,13 @@ func (m *Pool) XXX_DiscardUnknown() { var xxx_messageInfo_Pool proto.InternalMessageInfo +func (m *Pool) GetID() string { + if m != nil { + return m.ID + } + return "" +} + func (m *Pool) GetLowerTick0() *PoolReserves { if m != nil { return m.LowerTick0 @@ -82,21 +90,22 @@ func init() { func init() { proto.RegisterFile("duality/dex/pool.proto", fileDescriptor_458bee7d4cc3fc09) } var fileDescriptor_458bee7d4cc3fc09 = []byte{ - // 212 bytes of a gzipped FileDescriptorProto + // 229 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0x29, 0x4d, 0xcc, 0xc9, 0x2c, 0xa9, 0xd4, 0x4f, 0x49, 0xad, 0xd0, 0x2f, 0xc8, 0xcf, 0xcf, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0x8a, 0xeb, 0xa5, 0xa4, 0x56, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf5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 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x4c, 0x9e, 0x2e, 0x42, + 0x56, 0x5c, 0xdc, 0x39, 0xf9, 0xe5, 0xa9, 0x45, 0xf1, 0x25, 0x99, 0xc9, 0xd9, 0x06, 0x12, 0x4c, + 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x92, 0x7a, 0x48, 0x56, 0xea, 0x81, 0xf4, 0x05, 0x41, 0x8d, 0x0b, + 0xe2, 0x02, 0xab, 0x0e, 0x01, 0x29, 0x06, 0xe9, 0x2d, 0x2d, 0x28, 0x80, 0xea, 0x35, 0x94, 0x60, + 0x26, 0xa8, 0x17, 0xac, 0x1a, 0xa4, 0xd7, 0xd0, 0xc9, 0xf5, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, + 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, + 0x8f, 0xe5, 0x18, 0xa2, 0xb4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, + 0xa1, 0x46, 0xe9, 0xe6, 0x24, 0x26, 0x15, 0xc3, 0x38, 0xfa, 0x15, 0x60, 0x5f, 0x96, 0x54, 0x16, + 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xbd, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x2a, 0x36, + 0x90, 0x3c, 0x01, 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -129,7 +138,7 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if m.LowerTick0 != nil { { @@ -141,6 +150,13 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x12 + } + if len(m.ID) > 0 { + i -= len(m.ID) + copy(dAtA[i:], m.ID) + i = encodeVarintPool(dAtA, i, uint64(len(m.ID))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -163,6 +179,10 @@ func (m *Pool) Size() (n int) { } var l int _ = l + l = len(m.ID) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } if m.LowerTick0 != nil { l = m.LowerTick0.Size() n += 1 + l + sovPool(uint64(l)) @@ -210,6 +230,38 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", 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.ID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LowerTick0", wireType) } @@ -245,7 +297,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UpperTick1", wireType) } diff --git a/x/dex/types/pool_denom.go b/x/dex/types/pool_denom.go new file mode 100644 index 000000000..c89727e73 --- /dev/null +++ b/x/dex/types/pool_denom.go @@ -0,0 +1,22 @@ +package types + +import ( + "fmt" + "regexp" +) + +const PoolDenomRegexpStr = PoolNamePrefix + `\d+` + +var PoolDenomRegexp = regexp.MustCompile(PoolDenomRegexpStr) + +func NewPoolDenom(poolIdx uint64) string { + return fmt.Sprintf("%s%d", PoolNamePrefix, poolIdx) +} + +func ValidatePoolDenom(denom string) error { + if !PoolDenomRegexp.MatchString(denom) { + return ErrInvalidDepositDenom + } + + return nil +} diff --git a/x/dex/types/pool_params.go b/x/dex/types/pool_params.go new file mode 100644 index 000000000..c3be0c11e --- /dev/null +++ b/x/dex/types/pool_params.go @@ -0,0 +1,38 @@ +package types + +import ( + "bytes" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type PoolParams struct { + PairID *PairID + Tick int64 + Fee uint64 +} + +func ParsePoolRefToParams(poolRef []byte) (PoolParams, error) { + parts := bytes.Split(poolRef, []byte("/")) + if len(parts) != 4 { + return PoolParams{}, ErrInvalidDepositDenom + } + + pairID, err := NewPairIDFromCanonicalString(string(parts[0])) + if err != nil { + return PoolParams{}, err + } + + tick, err := BytesToTickIndex(parts[1]) + if err != nil { + return PoolParams{}, err + } + + fee := sdk.BigEndianToUint64(parts[2]) + + return PoolParams{PairID: pairID, Tick: tick, Fee: fee}, nil +} + +func NewPoolParams(pairID *PairID, tick int64, fee uint64) PoolParams { + return PoolParams{PairID: pairID, Tick: tick, Fee: fee} +} diff --git a/x/incentives/client/cli/query_test.go b/x/incentives/client/cli/query_test.go index 58e1dc6b0..9c9e113a6 100644 --- a/x/incentives/client/cli/query_test.go +++ b/x/incentives/client/cli/query_test.go @@ -41,14 +41,8 @@ func (s *QueryTestSuite) SetupSuite() { s.Setup() s.queryClient = types.NewQueryClient(s.QueryHelper) - denom := dextypes.NewDepositDenom( - &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - 0, - 1, - ).String() + pool, _ := s.App.DexKeeper.InitPool(s.Ctx, dextypes.MustNewPairID("tokenA", "tokenB"), 0, 1) + denom := pool.GetPoolDenom() // set up stake with id = 1 addr := apptesting.SetupAddr(0) diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index 6991ab287..e836b6ac3 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -14,16 +14,16 @@ var _ DistributorKeeper = Keeper{} func (k Keeper) ValueForShares(ctx sdk.Context, coin sdk.Coin, tick int64) (sdk.Int, error) { totalShares := k.bk.GetSupply(ctx, coin.Denom).Amount - depositDenom, err := dextypes.NewDepositDenomFromString(coin.Denom) + poolParams, err := k.dk.GetPoolParamsByID(ctx, coin.Denom) if err != nil { return sdk.ZeroInt(), err } pool, err := k.dk.GetOrInitPool( ctx, - depositDenom.PairID, - depositDenom.Tick, - depositDenom.Fee, + poolParams.PairID, + poolParams.Tick, + poolParams.Fee, ) if err != nil { return sdk.ZeroInt(), err @@ -127,11 +127,11 @@ func (k Keeper) GetRewardsEstimate( pairSet := map[dextypes.PairID]bool{} for _, l := range filterStakes { for _, c := range l.Coins { - depositDenom, err := dextypes.NewDepositDenomFromString(c.Denom) + poolParams, err := k.dk.GetPoolParamsByID(ctx, c.Denom) if err != nil { panic("all stakes should be valid deposit denoms") } - pairSet[*depositDenom.PairID] = true + pairSet[*poolParams.PairID] = true } } diff --git a/x/incentives/keeper/distribute_test.go b/x/incentives/keeper/distribute_test.go index e9bdbb746..2f0ca3ae2 100644 --- a/x/incentives/keeper/distribute_test.go +++ b/x/incentives/keeper/distribute_test.go @@ -44,11 +44,7 @@ func (suite *KeeperTestSuite) TestValueForShares() { fee: 1, }, }, - coin: sdk.NewInt64Coin( - dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). - String(), - 20, - ), + coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), tick: 1000, expectation: sdk.NewInt(21), }, @@ -63,11 +59,7 @@ func (suite *KeeperTestSuite) TestValueForShares() { fee: 1, }, }, - coin: sdk.NewInt64Coin( - dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). - String(), - 20, - ), + coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), tick: 0, expectation: sdk.NewInt(20), }, @@ -89,11 +81,7 @@ func (suite *KeeperTestSuite) TestValueForShares() { fee: 2, }, }, - coin: sdk.NewInt64Coin( - dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). - String(), - 20, - ), + coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), tick: 1000, expectation: sdk.NewInt(21), }, @@ -115,11 +103,7 @@ func (suite *KeeperTestSuite) TestValueForShares() { fee: 1, }, }, - coin: sdk.NewInt64Coin( - dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). - String(), - 20, - ), + coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), tick: 1000, expectation: sdk.NewInt(21), }, diff --git a/x/incentives/keeper/distributor.go b/x/incentives/keeper/distributor.go index 25cc09686..5dd5c5700 100644 --- a/x/incentives/keeper/distributor.go +++ b/x/incentives/keeper/distributor.go @@ -8,6 +8,7 @@ import ( type DistributorKeeper interface { ValueForShares(ctx sdk.Context, coin sdk.Coin, tick int64) (sdk.Int, error) GetStakesByQueryCondition(ctx sdk.Context, distrTo *types.QueryCondition) types.Stakes + StakeCoinsPassingQueryCondition(ctx sdk.Context, stake *types.Stake, distrTo types.QueryCondition) sdk.Coins } type Distributor struct { @@ -42,7 +43,7 @@ func (d Distributor) Distribute( stakeSumCache := make(map[uint64]sdk.Int, len(gaugeStakes)) for _, stake := range gaugeStakes { - stakeCoins := stake.CoinsPassingQueryCondition(gauge.DistributeTo) + stakeCoins := d.keeper.StakeCoinsPassingQueryCondition(ctx, stake, gauge.DistributeTo) stakeTotal := sdk.ZeroInt() for _, stakeCoin := range stakeCoins { adjustedPositionValue, err := d.keeper.ValueForShares(ctx, stakeCoin, gauge.PricingTick) diff --git a/x/incentives/keeper/distributor_test.go b/x/incentives/keeper/distributor_test.go index 54ee62ebc..3dea7a3ee 100644 --- a/x/incentives/keeper/distributor_test.go +++ b/x/incentives/keeper/distributor_test.go @@ -37,6 +37,10 @@ func (k MockKeeper) GetStakesByQueryCondition( return k.stakes } +func (k MockKeeper) StakeCoinsPassingQueryCondition(ctx sdk.Context, stake *types.Stake, distrTo types.QueryCondition) sdk.Coins { + panic("StakeCoinsPassingQueryCondition has not been implemented for the MockKeeper") +} + func TestDistributor(t *testing.T) { app := app.Setup(t, false) ctx := app.BaseApp.NewContext( @@ -62,10 +66,10 @@ func TestDistributor(t *testing.T) { sdk.Coins{}, 0, ) - rewardedDenom := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 5, 1). - String() - nonRewardedDenom := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 12, 1). - String() + rewardPool, _ := app.DexKeeper.GetOrInitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 5, 1) + rewardedDenom := rewardPool.GetPoolDenom() + nonRewardPool, _ := app.DexKeeper.GetOrInitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 12, 1) + nonRewardedDenom := nonRewardPool.GetPoolDenom() allStakes := types.Stakes{ {1, "addr1", ctx.BlockTime(), sdk.Coins{sdk.NewCoin(rewardedDenom, sdk.NewInt(50))}, 0}, {2, "addr2", ctx.BlockTime(), sdk.Coins{sdk.NewCoin(rewardedDenom, sdk.NewInt(25))}, 0}, diff --git a/x/incentives/keeper/export_test.go b/x/incentives/keeper/export_test.go index 824a5df24..554a50be4 100644 --- a/x/incentives/keeper/export_test.go +++ b/x/incentives/keeper/export_test.go @@ -31,8 +31,8 @@ func (k Keeper) MoveActiveGaugeToFinishedGauge(ctx sdk.Context, gauge *types.Gau return k.moveActiveGaugeToFinishedGauge(ctx, gauge) } -func GetStakeRefKeys(stake *types.Stake) ([][]byte, error) { - return getStakeRefKeys(stake) +func (k Keeper) GetStakeRefKeys(ctx sdk.Context, stake *types.Stake) ([][]byte, error) { + return k.getStakeRefKeys(ctx, stake) } func RemoveValue(ids []uint64, id uint64) ([]uint64, int) { diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index fb6734874..41d2ae9a3 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -216,7 +216,7 @@ func (k Keeper) GetGaugeQualifyingValue(ctx sdk.Context, gaugeID uint64) (uint64 var value uint64 = 0 stakes := k.GetStakesByQueryCondition(ctx, &gauge.DistributeTo) for _, stake := range stakes { - stakeCoins := stake.CoinsPassingQueryCondition(gauge.DistributeTo) + stakeCoins := k.StakeCoinsPassingQueryCondition(ctx, stake, gauge.DistributeTo) for _, stakeCoin := range stakeCoins { adjustedPositionValue, err := k.ValueForShares(ctx, stakeCoin, gauge.PricingTick) if err != nil { diff --git a/x/incentives/keeper/keeper_test.go b/x/incentives/keeper/keeper_test.go index 64b60ef03..05284a2fd 100644 --- a/x/incentives/keeper/keeper_test.go +++ b/x/incentives/keeper/keeper_test.go @@ -25,22 +25,24 @@ func (suite *KeeperTestSuite) SetupTest() { suite.Setup() suite.QueryServer = keeper.NewQueryServer(suite.App.IncentivesKeeper) suite.MsgServer = keeper.NewMsgServerImpl(suite.App.IncentivesKeeper) - suite.LPDenom0 = dextypes.NewDepositDenom( + pool0, _ := suite.App.DexKeeper.GetOrInitPool(suite.Ctx, &dextypes.PairID{ Token0: "TokenA", Token1: "TokenB", }, 0, 1, - ).String() - suite.LPDenom1 = dextypes.NewDepositDenom( + ) + suite.LPDenom0 = pool0.GetPoolDenom() + pool1, _ := suite.App.DexKeeper.GetOrInitPool(suite.Ctx, &dextypes.PairID{ Token0: "TokenA", Token1: "TokenB", }, 1, 1, - ).String() + ) + suite.LPDenom1 = pool1.GetPoolDenom() suite.SetEpochStartTime() } diff --git a/x/incentives/keeper/query_server.go b/x/incentives/keeper/query_server.go index 1e20f8bb0..70a3ee0b6 100644 --- a/x/incentives/keeper/query_server.go +++ b/x/incentives/keeper/query_server.go @@ -92,14 +92,14 @@ func (q QueryServer) GetGauges( } var lowerTick, upperTick int64 - var depositDenom *dextypes.DepositDenom + var poolParams *dextypes.PoolParams if req.Denom != "" { - depositDenom, err := dextypes.NewDepositDenomFromString(req.Denom) + poolParams, err := q.dk.GetPoolParamsByID(ctx, req.Denom) if err != nil { return nil, err } - lowerTick = depositDenom.Tick - int64(depositDenom.Fee) - upperTick = depositDenom.Tick + int64(depositDenom.Fee) + lowerTick = poolParams.Tick - int64(poolParams.Fee) + upperTick = poolParams.Tick + int64(poolParams.Fee) } gauges := types.Gauges{} @@ -116,7 +116,7 @@ func (q QueryServer) GetGauges( } if req.Denom != "" { for _, gauge := range newGauges { - if *gauge.DistributeTo.PairID != *depositDenom.PairID { + if *gauge.DistributeTo.PairID != *poolParams.PairID { continue } lowerTickInRange := gauge.DistributeTo.StartTick <= lowerTick && diff --git a/x/incentives/keeper/stake.go b/x/incentives/keeper/stake.go index 856e14a8d..ca366a34f 100644 --- a/x/incentives/keeper/stake.go +++ b/x/incentives/keeper/stake.go @@ -227,3 +227,23 @@ func (k Keeper) CreateStake( return stake, nil } + +func (k Keeper) StakeCoinsPassingQueryCondition( + ctx sdk.Context, + stake *types.Stake, + distrTo types.QueryCondition, +) sdk.Coins { + coins := stake.Coins + result := sdk.NewCoins() + for _, c := range coins { + poolParams, err := k.dk.GetPoolParamsByID(ctx, c.Denom) + if err != nil { + continue + } + + if distrTo.Test(poolParams) { + result = result.Add(c) + } + } + return result +} diff --git a/x/incentives/keeper/stake_refs.go b/x/incentives/keeper/stake_refs.go index 3a1ce6635..d46d66ba0 100644 --- a/x/incentives/keeper/stake_refs.go +++ b/x/incentives/keeper/stake_refs.go @@ -9,7 +9,7 @@ import ( // addStakeRefs adds appropriate reference keys preceded by a prefix. // A prefix indicates whether the stake is unstaking or not. func (k Keeper) addStakeRefs(ctx sdk.Context, stake *types.Stake) error { - refKeys, err := getStakeRefKeys(stake) + refKeys, err := k.getStakeRefKeys(ctx, stake) if err != nil { return err } @@ -23,7 +23,7 @@ func (k Keeper) addStakeRefs(ctx sdk.Context, stake *types.Stake) error { // deleteStakeRefs deletes all the stake references of the stake with the given stake prefix. func (k Keeper) deleteStakeRefs(ctx sdk.Context, stake *types.Stake) error { - refKeys, err := getStakeRefKeys(stake) + refKeys, err := k.getStakeRefKeys(ctx, stake) if err != nil { return err } @@ -36,7 +36,7 @@ func (k Keeper) deleteStakeRefs(ctx sdk.Context, stake *types.Stake) error { return nil } -func getStakeRefKeys(stake *types.Stake) ([][]byte, error) { +func (k Keeper) getStakeRefKeys(ctx sdk.Context, stake *types.Stake) ([][]byte, error) { owner, err := sdk.AccAddressFromBech32(stake.Owner) if err != nil { return nil, err @@ -47,13 +47,13 @@ func getStakeRefKeys(stake *types.Stake) ([][]byte, error) { refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexAccount, owner))] = true for _, coin := range stake.Coins { - depositDenom, err := dextypes.NewDepositDenomFromString(coin.Denom) + poolParams, err := k.dk.GetPoolParamsByID(ctx, coin.Denom) if err != nil { panic("Only valid LP tokens should be staked") } denomBz := []byte(coin.Denom) - pairIDBz := []byte(depositDenom.PairID.CanonicalString()) - tickBz := dextypes.TickIndexToBytes(depositDenom.Tick) + pairIDBz := []byte(poolParams.PairID.CanonicalString()) + tickBz := dextypes.TickIndexToBytes(poolParams.Tick) refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexDenom, denomBz))] = true refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexPairTick, pairIDBz, tickBz))] = true refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexAccountDenom, owner, denomBz))] = true diff --git a/x/incentives/keeper/suite_test.go b/x/incentives/keeper/suite_test.go index cb5ffc532..a880762a7 100644 --- a/x/incentives/keeper/suite_test.go +++ b/x/incentives/keeper/suite_test.go @@ -91,16 +91,6 @@ func (suite *KeeperTestSuite) SetupStake( return stake } -func GetQualifyingDenom(qc types.QueryCondition) *dextypes.DepositDenom { - tick := qc.StartTick + (qc.EndTick-qc.StartTick)/2 - fee := (qc.EndTick - qc.StartTick) / 3 - return dextypes.NewDepositDenom( - qc.PairID, - tick, - uint64(fee), - ) -} - // setupNewGauge creates a gauge with the specified duration. func (suite *KeeperTestSuite) SetupGauge(s gaugeSpec) *types.Gauge { addr := sdk.AccAddress([]byte("Gauge_Creation_Addr_")) diff --git a/x/incentives/keeper/utils_test.go b/x/incentives/keeper/utils_test.go index 158fafc68..f25f6c137 100644 --- a/x/incentives/keeper/utils_test.go +++ b/x/incentives/keeper/utils_test.go @@ -2,15 +2,11 @@ package keeper_test import ( "testing" - "time" "github.com/stretchr/testify/require" - dextypes "github.com/duality-labs/duality/x/dex/types" . "github.com/duality-labs/duality/x/incentives/keeper" "github.com/duality-labs/duality/x/incentives/types" - - sdk "github.com/cosmos/cosmos-sdk/types" ) func TestCombineKeys(t *testing.T) { @@ -65,52 +61,53 @@ func TestRemoveValue(t *testing.T) { require.Equal(t, index4, -1) } -func TestStakeRefKeys(t *testing.T) { - addr1 := sdk.AccAddress([]byte("addr1---------------")) - denom1 := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). - String() - denom2 := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenC"}, 0, 1). - String() - // empty address and 1 coin - stake1 := types.NewStake( - 1, - sdk.AccAddress{}, - sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, - time.Now(), - 10, - ) - _, err := GetStakeRefKeys(stake1) - require.Error(t, err) - - // empty address and 2 coins - stake2 := types.NewStake( - 1, - sdk.AccAddress{}, - sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, - time.Now(), - 10, - ) - _, err = GetStakeRefKeys(stake2) - require.Error(t, err) - - // not empty address and 1 coin - stake3 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) - keys3, err := GetStakeRefKeys(stake3) - require.Len(t, keys3, 6) - - // not empty address and empty coin - stake4 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) - keys4, err := GetStakeRefKeys(stake4) - require.Len(t, keys4, 6) - - // not empty address and 2 coins - stake5 := types.NewStake( - 1, - addr1, - sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, - time.Now(), - 10, - ) - keys5, err := GetStakeRefKeys(stake5) - require.Len(t, keys5, 10) -} +// JCP TODO: fix me +// func TestStakeRefKeys(t *testing.T) { +// addr1 := sdk.AccAddress([]byte("addr1---------------")) +// denom1 := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). +// String() +// denom2 := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenC"}, 0, 1). +// String() +// // empty address and 1 coin +// stake1 := types.NewStake( +// 1, +// sdk.AccAddress{}, +// sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, +// time.Now(), +// 10, +// ) +// _, err := GetStakeRefKeys(stake1) +// require.Error(t, err) + +// // empty address and 2 coins +// stake2 := types.NewStake( +// 1, +// sdk.AccAddress{}, +// sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, +// time.Now(), +// 10, +// ) +// _, err = GetStakeRefKeys(stake2) +// require.Error(t, err) + +// // not empty address and 1 coin +// stake3 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) +// keys3, err := GetStakeRefKeys(stake3) +// require.Len(t, keys3, 6) + +// // not empty address and empty coin +// stake4 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) +// keys4, err := GetStakeRefKeys(stake4) +// require.Len(t, keys4, 6) + +// // not empty address and 2 coins +// stake5 := types.NewStake( +// 1, +// addr1, +// sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, +// time.Now(), +// 10, +// ) +// keys5, err := GetStakeRefKeys(stake5) +// require.Len(t, keys5, 10) +// } diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go index 59a03ab74..afbe8526d 100644 --- a/x/incentives/types/expected_keepers.go +++ b/x/incentives/types/expected_keepers.go @@ -34,4 +34,5 @@ type AccountKeeper interface { type DexKeeper interface { GetOrInitPool(ctx sdk.Context, pairID *types.PairID, centerTickIndex int64, fee uint64) (*dextypes.Pool, error) + GetPoolParamsByID(ctx sdk.Context, id string) (types.PoolParams, error) } diff --git a/x/incentives/types/query_condition.go b/x/incentives/types/query_condition.go index cb7bb0b36..f2e8a7af3 100644 --- a/x/incentives/types/query_condition.go +++ b/x/incentives/types/query_condition.go @@ -1,24 +1,12 @@ package types import ( - "strings" - dextypes "github.com/duality-labs/duality/x/dex/types" ) -func (qc QueryCondition) Test(denom string) bool { - denomPrefix := dextypes.DepositDenomPairIDPrefix(qc.PairID.Token0, qc.PairID.Token1) - if !strings.Contains(denom, denomPrefix) { - return false - } - - depositDenom, err := dextypes.NewDepositDenomFromString(denom) - if err != nil { - return false - } - - lowerTick := depositDenom.Tick - int64(depositDenom.Fee) - upperTick := depositDenom.Tick + int64(depositDenom.Fee) +func (qc QueryCondition) Test(poolParams dextypes.PoolParams) bool { + lowerTick := poolParams.Tick - int64(poolParams.Fee) + upperTick := poolParams.Tick + int64(poolParams.Fee) lowerTickQualifies := qc.StartTick <= lowerTick && lowerTick <= qc.EndTick upperTickQualifies := qc.StartTick <= upperTick && upperTick <= qc.EndTick return lowerTickQualifies && upperTickQualifies diff --git a/x/incentives/types/query_condition_test.go b/x/incentives/types/query_condition_test.go index 9a02f06b8..b5f1563c9 100644 --- a/x/incentives/types/query_condition_test.go +++ b/x/incentives/types/query_condition_test.go @@ -18,50 +18,50 @@ func TestQueryCondition(t *testing.T) { tests := []struct { name string queryCond QueryCondition - denom string + poolParams dextypes.PoolParams testResult bool }{ { name: "Matching denom and tick range", queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - denom: dextypes.NewDepositDenom(&dextypes.PairID{Token0: "coin1", Token1: "coin2"}, 15, 5).String(), + poolParams: dextypes.NewPoolParams(pairID, 15, 5), testResult: true, }, { name: "Non-matching denom", queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - denom: dextypes.NewDepositDenom(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 5).String(), + poolParams: dextypes.NewPoolParams(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 5), testResult: false, }, { name: "Non-matching tick range", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - denom: dextypes.NewDepositDenom(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 6).String(), + poolParams: dextypes.NewPoolParams(pairID, 15, 6), testResult: false, }, { name: "Non-matching tick fee range lower", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - denom: dextypes.NewDepositDenom(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 10, 5).String(), + poolParams: dextypes.NewPoolParams(pairID, 10, 5), testResult: false, }, { name: "Non-matching tick fee range upper", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - denom: dextypes.NewDepositDenom(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 20, 5).String(), + poolParams: dextypes.NewPoolParams(pairID, 20, 5), testResult: false, }, { name: "Invalid denom", queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - denom: "invalid-denom", + poolParams: dextypes.NewPoolParams(&dextypes.PairID{Token0: "coinz", Token1: "coinz"}, 15, 5), testResult: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - result := tt.queryCond.Test(tt.denom) + result := tt.queryCond.Test(tt.poolParams) assert.Equal(t, tt.testResult, result) }) } diff --git a/x/incentives/types/stake.go b/x/incentives/types/stake.go index 779dfdc50..e554c2297 100644 --- a/x/incentives/types/stake.go +++ b/x/incentives/types/stake.go @@ -44,70 +44,10 @@ func (p Stake) SingleCoin() (sdk.Coin, error) { func (p Stake) ValidateBasic() error { for _, coin := range p.Coins { - _, err := dextypes.NewDepositDenomFromString(coin.Denom) + err := dextypes.ValidatePoolDenom(coin.Denom) if err != nil { return err } } return nil } - -func (p Stake) CoinsPassingQueryCondition(distrTo QueryCondition) sdk.Coins { - coins := p.Coins - switch len(p.Coins) { - case 0: - return nil - - case 1: - coin := coins[0] - if !distrTo.Test(coin.Denom) { - return nil - } - return sdk.Coins{coin} - - default: - // Binary search the amount of coins remaining - result := sdk.NewCoins() - denomPrefix := dextypes.DepositDenomPairIDPrefix( - distrTo.PairID.Token0, - distrTo.PairID.Token1, - ) - low := 0 - high := len(coins) - for low < high { - mid := low + ((high - low) / 2) - coin := coins[mid] - switch { - case distrTo.Test(coin.Denom): - result = result.Add(coin) - - midLeft := mid - 1 - for 0 <= midLeft { - coin = coins[midLeft] - if !distrTo.Test(coin.Denom) { - break - } - result = result.Add(coin) - midLeft-- - } - - midRight := mid + 1 - for midRight < len(coins) { - coin = coins[midRight] - if !distrTo.Test(coin.Denom) { - break - } - result = result.Add(coin) - midRight++ - } - - return result - case denomPrefix < coin.Denom: - high = mid - default: - low = mid - } - } - return nil - } -} diff --git a/x/incentives/types/stakes.go b/x/incentives/types/stakes.go index f3b1add39..468770d49 100644 --- a/x/incentives/types/stakes.go +++ b/x/incentives/types/stakes.go @@ -4,16 +4,17 @@ import sdk "github.com/cosmos/cosmos-sdk/types" type Stakes []*Stake -func (stakes Stakes) CoinsByQueryCondition(distrTo QueryCondition) sdk.Coins { - coins := sdk.Coins{} - for _, stake := range stakes { - coinsToAdd := stake.CoinsPassingQueryCondition(distrTo) - if !coinsToAdd.Empty() { - coins = coins.Add(coinsToAdd...) - } - } - return coins -} +// JCP TODO: remove? +// func (stakes Stakes) CoinsByQueryCondition(distrTo QueryCondition) sdk.Coins { +// coins := sdk.Coins{} +// for _, stake := range stakes { +// coinsToAdd := stake.CoinsPassingQueryCondition(distrTo) +// if !coinsToAdd.Empty() { +// coins = coins.Add(coinsToAdd...) +// } +// } +// return coins +// } func (stakes Stakes) GetCoins() sdk.Coins { coins := sdk.Coins{} diff --git a/x/incentives/types/stakes_test.go b/x/incentives/types/stakes_test.go index 5dd7e85f4..a550845ed 100644 --- a/x/incentives/types/stakes_test.go +++ b/x/incentives/types/stakes_test.go @@ -1,188 +1,189 @@ package types_test -import ( - "testing" - time "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - dextypes "github.com/duality-labs/duality/x/dex/types" - . "github.com/duality-labs/duality/x/incentives/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestStakesCoinsByQueryCondition(t *testing.T) { - owner, err := sdk.AccAddressFromBech32("dual1lyaz7emmzreenas4fpz49a49958kye7wxuvsdr") - require.NoError(t, err) - - allCoins := sdk.Coins{ - sdk.NewInt64Coin( - dextypes.NewDepositDenom( - &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - }, - 25, - 10, - ).String(), - 100, - ), - sdk.NewInt64Coin( - dextypes.NewDepositDenom( - &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - }, - 75, - 10, - ).String(), - 200, - ), - sdk.NewInt64Coin( - dextypes.NewDepositDenom( - &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - }, - 75, - 50, - ).String(), - 200, - ), - } - - stakes := Stakes{ - NewStake(1, owner, sdk.Coins{allCoins[0]}, time.Time{}, 0), - NewStake(2, owner, sdk.Coins{allCoins[1]}, time.Time{}, 0), - NewStake(3, owner, sdk.Coins{allCoins[2]}, time.Time{}, 0), - } - - pairID := &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - } - - tests := []struct { - name string - queryCond QueryCondition - coinsByCond sdk.Coins - }{ - { - name: "All coins", - queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 100}, - coinsByCond: sdk.Coins{allCoins[0], allCoins[1]}, - }, - { - name: "Coin1 only", - queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 50}, - coinsByCond: sdk.Coins{allCoins[0]}, - }, - { - name: "Coin2 only", - queryCond: QueryCondition{PairID: pairID, StartTick: 50, EndTick: 100}, - coinsByCond: sdk.Coins{allCoins[1]}, - }, - { - name: "No coins", - queryCond: QueryCondition{PairID: pairID, StartTick: 100, EndTick: 200}, - coinsByCond: sdk.Coins{}, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - coins := stakes.CoinsByQueryCondition(tt.queryCond) - assert.Equal(t, tt.coinsByCond, coins) - }) - } -} - -func TestStakesCoinsByQueryConditionMultiple(t *testing.T) { - owner, err := sdk.AccAddressFromBech32("dual1lyaz7emmzreenas4fpz49a49958kye7wxuvsdr") - require.NoError(t, err) - - allCoins := sdk.Coins{} - - coins1 := sdk.NewInt64Coin( - dextypes.NewDepositDenom( - &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - }, - 25, - 10, - ).String(), - 100, - ) - allCoins = allCoins.Add(coins1) - - coins2 := sdk.NewInt64Coin( - dextypes.NewDepositDenom( - &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - }, - 75, - 10, - ).String(), - 200, - ) - allCoins = allCoins.Add(coins2) - - coins3 := sdk.NewInt64Coin( - dextypes.NewDepositDenom( - &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - }, - 75, - 50, - ).String(), - 200, - ) - allCoins = allCoins.Add(coins3) - assert.Equal(t, allCoins, allCoins.Sort()) - - stakes := Stakes{ - NewStake(1, owner, allCoins, time.Time{}, 0), - } - - pairID := &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - } - - tests := []struct { - name string - queryCond QueryCondition - expected sdk.Coins - }{ - { - name: "All coins", - queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 100}, - expected: sdk.Coins{coins1, coins2}, - }, - { - name: "Coin1 only", - queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 50}, - expected: sdk.Coins{coins1}, - }, - { - name: "Coin2 only", - queryCond: QueryCondition{PairID: pairID, StartTick: 50, EndTick: 100}, - expected: sdk.Coins{coins2}, - }, - { - name: "No coins", - queryCond: QueryCondition{PairID: pairID, StartTick: 100, EndTick: 200}, - expected: sdk.Coins{}, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - coins := stakes.CoinsByQueryCondition(tt.queryCond) - assert.Equal(t, tt.expected, coins) - }) - } -} +// JCP TODO: fix? delete? +// import ( +// "testing" +// time "time" + +// sdk "github.com/cosmos/cosmos-sdk/types" +// dextypes "github.com/duality-labs/duality/x/dex/types" +// . "github.com/duality-labs/duality/x/incentives/types" +// "github.com/stretchr/testify/assert" +// "github.com/stretchr/testify/require" +// ) + +// func TestStakesCoinsByQueryCondition(t *testing.T) { +// owner, err := sdk.AccAddressFromBech32("dual1lyaz7emmzreenas4fpz49a49958kye7wxuvsdr") +// require.NoError(t, err) + +// allCoins := sdk.Coins{ +// sdk.NewInt64Coin( +// dextypes.NewDepositDenom( +// &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// }, +// 25, +// 10, +// ).String(), +// 100, +// ), +// sdk.NewInt64Coin( +// dextypes.NewDepositDenom( +// &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// }, +// 75, +// 10, +// ).String(), +// 200, +// ), +// sdk.NewInt64Coin( +// dextypes.NewDepositDenom( +// &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// }, +// 75, +// 50, +// ).String(), +// 200, +// ), +// } + +// stakes := Stakes{ +// NewStake(1, owner, sdk.Coins{allCoins[0]}, time.Time{}, 0), +// NewStake(2, owner, sdk.Coins{allCoins[1]}, time.Time{}, 0), +// NewStake(3, owner, sdk.Coins{allCoins[2]}, time.Time{}, 0), +// } + +// pairID := &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// } + +// tests := []struct { +// name string +// queryCond QueryCondition +// coinsByCond sdk.Coins +// }{ +// { +// name: "All coins", +// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 100}, +// coinsByCond: sdk.Coins{allCoins[0], allCoins[1]}, +// }, +// { +// name: "Coin1 only", +// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 50}, +// coinsByCond: sdk.Coins{allCoins[0]}, +// }, +// { +// name: "Coin2 only", +// queryCond: QueryCondition{PairID: pairID, StartTick: 50, EndTick: 100}, +// coinsByCond: sdk.Coins{allCoins[1]}, +// }, +// { +// name: "No coins", +// queryCond: QueryCondition{PairID: pairID, StartTick: 100, EndTick: 200}, +// coinsByCond: sdk.Coins{}, +// }, +// } + +// for _, tt := range tests { +// t.Run(tt.name, func(t *testing.T) { +// coins := stakes.CoinsByQueryCondition(tt.queryCond) +// assert.Equal(t, tt.coinsByCond, coins) +// }) +// } +// } + +// func TestStakesCoinsByQueryConditionMultiple(t *testing.T) { +// owner, err := sdk.AccAddressFromBech32("dual1lyaz7emmzreenas4fpz49a49958kye7wxuvsdr") +// require.NoError(t, err) + +// allCoins := sdk.Coins{} + +// coins1 := sdk.NewInt64Coin( +// dextypes.NewDepositDenom( +// &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// }, +// 25, +// 10, +// ).String(), +// 100, +// ) +// allCoins = allCoins.Add(coins1) + +// coins2 := sdk.NewInt64Coin( +// dextypes.NewDepositDenom( +// &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// }, +// 75, +// 10, +// ).String(), +// 200, +// ) +// allCoins = allCoins.Add(coins2) + +// coins3 := sdk.NewInt64Coin( +// dextypes.NewDepositDenom( +// &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// }, +// 75, +// 50, +// ).String(), +// 200, +// ) +// allCoins = allCoins.Add(coins3) +// assert.Equal(t, allCoins, allCoins.Sort()) + +// stakes := Stakes{ +// NewStake(1, owner, allCoins, time.Time{}, 0), +// } + +// pairID := &dextypes.PairID{ +// Token0: "coin1", +// Token1: "coin2", +// } + +// tests := []struct { +// name string +// queryCond QueryCondition +// expected sdk.Coins +// }{ +// { +// name: "All coins", +// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 100}, +// expected: sdk.Coins{coins1, coins2}, +// }, +// { +// name: "Coin1 only", +// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 50}, +// expected: sdk.Coins{coins1}, +// }, +// { +// name: "Coin2 only", +// queryCond: QueryCondition{PairID: pairID, StartTick: 50, EndTick: 100}, +// expected: sdk.Coins{coins2}, +// }, +// { +// name: "No coins", +// queryCond: QueryCondition{PairID: pairID, StartTick: 100, EndTick: 200}, +// expected: sdk.Coins{}, +// }, +// } + +// for _, tt := range tests { +// t.Run(tt.name, func(t *testing.T) { +// coins := stakes.CoinsByQueryCondition(tt.queryCond) +// assert.Equal(t, tt.expected, coins) +// }) +// } +// } From 57baad8cbdd98f530b8c482e2c8429caa4ca24c1 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Fri, 25 Aug 2023 14:26:11 -0700 Subject: [PATCH 02/16] fix stake distr tests --- x/dex/keeper/pool.go | 2 -- x/incentives/keeper/distributor_test.go | 12 +++++++----- x/incentives/types/query_condition.go | 5 +++++ x/incentives/types/query_condition_test.go | 6 ------ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index 23cc2db66..32ce5d71c 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -2,7 +2,6 @@ package keeper import ( "encoding/binary" - "fmt" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -140,7 +139,6 @@ func (k Keeper) GetPoolParamsByID( if !found { return types.PoolParams{}, types.ErrInvalidDepositDenom } - fmt.Printf("REf: %v (%v)\n", ref, string(ref)) poolParams, err := types.ParsePoolRefToParams(ref) if err != nil { diff --git a/x/incentives/keeper/distributor_test.go b/x/incentives/keeper/distributor_test.go index 3dea7a3ee..e6d57adea 100644 --- a/x/incentives/keeper/distributor_test.go +++ b/x/incentives/keeper/distributor_test.go @@ -18,27 +18,29 @@ var _ DistributorKeeper = MockKeeper{} type MockKeeper struct { stakes types.Stakes + keeper DistributorKeeper } -func NewMockKeeper(stakes types.Stakes) MockKeeper { +func NewMockKeeper(keeper DistributorKeeper, stakes types.Stakes) MockKeeper { return MockKeeper{ stakes: stakes, + keeper: keeper, } } -func (k MockKeeper) ValueForShares(ctx sdk.Context, coin sdk.Coin, tick int64) (sdk.Int, error) { +func (k MockKeeper) ValueForShares(_ sdk.Context, coin sdk.Coin, tick int64) (sdk.Int, error) { return coin.Amount.Mul(sdk.NewInt(2)), nil } func (k MockKeeper) GetStakesByQueryCondition( - ctx sdk.Context, + _ sdk.Context, distrTo *types.QueryCondition, ) types.Stakes { return k.stakes } func (k MockKeeper) StakeCoinsPassingQueryCondition(ctx sdk.Context, stake *types.Stake, distrTo types.QueryCondition) sdk.Coins { - panic("StakeCoinsPassingQueryCondition has not been implemented for the MockKeeper") + return k.keeper.StakeCoinsPassingQueryCondition(ctx, stake, distrTo) } func TestDistributor(t *testing.T) { @@ -77,7 +79,7 @@ func TestDistributor(t *testing.T) { {4, "addr3", ctx.BlockTime(), sdk.Coins{sdk.NewCoin(nonRewardedDenom, sdk.NewInt(50))}, 0}, } - distributor := NewDistributor(NewMockKeeper(allStakes)) + distributor := NewDistributor(NewMockKeeper(app.IncentivesKeeper, allStakes)) testCases := []struct { name string diff --git a/x/incentives/types/query_condition.go b/x/incentives/types/query_condition.go index f2e8a7af3..fbd6c7a75 100644 --- a/x/incentives/types/query_condition.go +++ b/x/incentives/types/query_condition.go @@ -5,9 +5,14 @@ import ( ) func (qc QueryCondition) Test(poolParams dextypes.PoolParams) bool { + if *poolParams.PairID != *qc.PairID { + return false + } + lowerTick := poolParams.Tick - int64(poolParams.Fee) upperTick := poolParams.Tick + int64(poolParams.Fee) lowerTickQualifies := qc.StartTick <= lowerTick && lowerTick <= qc.EndTick upperTickQualifies := qc.StartTick <= upperTick && upperTick <= qc.EndTick + return lowerTickQualifies && upperTickQualifies } diff --git a/x/incentives/types/query_condition_test.go b/x/incentives/types/query_condition_test.go index b5f1563c9..2a3155b9c 100644 --- a/x/incentives/types/query_condition_test.go +++ b/x/incentives/types/query_condition_test.go @@ -51,12 +51,6 @@ func TestQueryCondition(t *testing.T) { poolParams: dextypes.NewPoolParams(pairID, 20, 5), testResult: false, }, - { - name: "Invalid denom", - queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - poolParams: dextypes.NewPoolParams(&dextypes.PairID{Token0: "coinz", Token1: "coinz"}, 15, 5), - testResult: false, - }, } for _, tt := range tests { From 0c57685c78c2fb26fc7e4c6e62ce2d13cfc6847f Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Fri, 25 Aug 2023 14:34:08 -0700 Subject: [PATCH 03/16] cleaner pool equality check --- x/dex/types/pair_id.go | 4 ++++ x/incentives/types/query_condition.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/x/dex/types/pair_id.go b/x/dex/types/pair_id.go index 505442724..4f18aadfe 100644 --- a/x/dex/types/pair_id.go +++ b/x/dex/types/pair_id.go @@ -89,3 +89,7 @@ func (p *PairID) MustTradePairIDFromTaker(taker string) *TradePairID { panic(fmt.Errorf("pair.TradePairIDFromMaker(maker string) called where maker does not equal either pair.Token0 or pair.Token1")) } } + +func (p *PairID) Equal(otherPairID *PairID) bool { + return *p == *otherPairID +} diff --git a/x/incentives/types/query_condition.go b/x/incentives/types/query_condition.go index fbd6c7a75..3bed6f25f 100644 --- a/x/incentives/types/query_condition.go +++ b/x/incentives/types/query_condition.go @@ -5,7 +5,7 @@ import ( ) func (qc QueryCondition) Test(poolParams dextypes.PoolParams) bool { - if *poolParams.PairID != *qc.PairID { + if !poolParams.PairID.Equal(qc.PairID) { return false } From 6191935a59bbfeb5bd0f826123c665321f6916c0 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Fri, 25 Aug 2023 15:21:24 -0700 Subject: [PATCH 04/16] Preserve pool ids even if no reserves exist --- x/dex/keeper/pool.go | 3 ++- x/dex/types/pool.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index 32ce5d71c..2511d5715 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -89,7 +89,8 @@ func (k Keeper) GetPool( } else if lowerTickFound && !upperTickFound { upperTick = types.NewPoolReservesFromCounterpart(lowerTick) } else if !lowerTickFound && !upperTickFound { - return nil, false + // Pool has already been initialized before so we can safely assume that pool creation doesn't throw an error + return types.MustNewPool(pairID, centerTickIndexNormalized, fee, poolID), true } return &types.Pool{ diff --git a/x/dex/types/pool.go b/x/dex/types/pool.go index 0e41ff0c4..ce5e7d162 100644 --- a/x/dex/types/pool.go +++ b/x/dex/types/pool.go @@ -33,6 +33,19 @@ func NewPool( }, nil } +func MustNewPool( + pairID *PairID, + centerTickIndexNormalized int64, + fee uint64, + id string, +) *Pool { + pool, err := NewPool(pairID, centerTickIndexNormalized, fee, id) + if err != nil { + panic("Error while creating new pool: " + err.Error()) + } + return pool +} + func (p *Pool) CenterTickIndex() int64 { feeInt64 := utils.MustSafeUint64(p.Fee()) return p.UpperTick1.Key.TickIndexTakerToMaker - feeInt64 From 7b62d714e0184d5f97d024c0538cfde67230a83d Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Fri, 25 Aug 2023 16:04:03 -0700 Subject: [PATCH 05/16] fix pool query --- x/dex/keeper/pool.go | 23 ----------------------- x/dex/keeper/pool_reserves_test.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index 2511d5715..043b00da3 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -188,26 +188,3 @@ func (k Keeper) SetPool(ctx sdk.Context, pool *types.Pool) { ctx.EventManager().EmitEvent(types.CreateTickUpdatePoolReserves(*pool.LowerTick0)) ctx.EventManager().EmitEvent(types.CreateTickUpdatePoolReserves(*pool.UpperTick1)) } - -// Useful for testing -func MustNewPool(pairID *types.PairID, normalizedCenterTickIndex int64, fee uint64) *types.Pool { - feeInt64 := utils.MustSafeUint64(fee) - - id0To1 := &types.PoolReservesKey{ - TradePairID: types.NewTradePairIDFromMaker(pairID, pairID.Token1), - TickIndexTakerToMaker: normalizedCenterTickIndex + feeInt64, - Fee: fee, - } - - upperTick, err := types.NewPoolReserves(id0To1) - if err != nil { - panic(err) - } - - lowerTick := types.NewPoolReservesFromCounterpart(upperTick) - - return &types.Pool{ - LowerTick0: lowerTick, - UpperTick1: upperTick, - } -} diff --git a/x/dex/keeper/pool_reserves_test.go b/x/dex/keeper/pool_reserves_test.go index dc6afccb4..02f0a6753 100644 --- a/x/dex/keeper/pool_reserves_test.go +++ b/x/dex/keeper/pool_reserves_test.go @@ -14,7 +14,10 @@ import ( func createNPoolReserves(k *keeper.Keeper, ctx sdk.Context, n int) []*types.PoolReserves { items := make([]*types.PoolReserves, n) for i := range items { - pool := keeper.MustNewPool(types.MustNewPairID("TokenA", "TokenB"), int64(i), uint64(i)) + pool, err := k.InitPool(ctx, types.MustNewPairID("TokenA", "TokenB"), int64(i), uint64(i)) + if err != nil { + panic("failed to create pool") + } pool.Deposit(sdk.NewInt(10), sdk.NewInt(0), sdk.ZeroInt(), true) k.SetPool(ctx, pool) items[i] = pool.LowerTick0 @@ -34,7 +37,10 @@ func createNPools(k *keeper.Keeper, ctx sdk.Context, n int) []struct { Fee uint64 }, n) for i := range items { - pool := keeper.MustNewPool(types.MustNewPairID("TokenA", "TokenB"), int64(i), uint64(i)) + pool, err := k.InitPool(ctx, types.MustNewPairID("TokenA", "TokenB"), int64(i), uint64(i)) + if err != nil { + panic("failed to create pool") + } pool.Deposit(sdk.NewInt(10), sdk.NewInt(0), sdk.ZeroInt(), true) k.SetPool(ctx, pool) items[i] = struct { From e25398c6d41e3b1d78c74676df28f289a921d0d8 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Fri, 25 Aug 2023 16:12:58 -0700 Subject: [PATCH 06/16] depositDenom => poolDenom --- x/dex/types/errors.go | 4 ++-- x/dex/types/pool_denom.go | 2 +- x/dex/types/pool_params.go | 2 +- x/incentives/keeper/utils_test.go | 4 ++-- x/incentives/types/stakes_test.go | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x/dex/types/errors.go b/x/dex/types/errors.go index add271fbd..5abc1ae9e 100644 --- a/x/dex/types/errors.go +++ b/x/dex/types/errors.go @@ -65,10 +65,10 @@ var ( 1117, "Supplying a tick outside the range of [-352437, 352437] is not allowed", ) - ErrInvalidDepositDenom = sdkerrors.Register( + ErrInvalidPoolDenom = sdkerrors.Register( ModuleName, 1118, - "Denom is not an instance of Duality DepositDenom", + "Denom is not an instance of Duality PoolDenom", ) ErrInvalidPairIDStr = sdkerrors.Register( ModuleName, diff --git a/x/dex/types/pool_denom.go b/x/dex/types/pool_denom.go index c89727e73..526f6f46e 100644 --- a/x/dex/types/pool_denom.go +++ b/x/dex/types/pool_denom.go @@ -15,7 +15,7 @@ func NewPoolDenom(poolIdx uint64) string { func ValidatePoolDenom(denom string) error { if !PoolDenomRegexp.MatchString(denom) { - return ErrInvalidDepositDenom + return ErrInvalidPoolDenom } return nil diff --git a/x/dex/types/pool_params.go b/x/dex/types/pool_params.go index c3be0c11e..d23a0e464 100644 --- a/x/dex/types/pool_params.go +++ b/x/dex/types/pool_params.go @@ -15,7 +15,7 @@ type PoolParams struct { func ParsePoolRefToParams(poolRef []byte) (PoolParams, error) { parts := bytes.Split(poolRef, []byte("/")) if len(parts) != 4 { - return PoolParams{}, ErrInvalidDepositDenom + return PoolParams{}, ErrInvalidPoolDenom } pairID, err := NewPairIDFromCanonicalString(string(parts[0])) diff --git a/x/incentives/keeper/utils_test.go b/x/incentives/keeper/utils_test.go index f25f6c137..e097d20df 100644 --- a/x/incentives/keeper/utils_test.go +++ b/x/incentives/keeper/utils_test.go @@ -64,9 +64,9 @@ func TestRemoveValue(t *testing.T) { // JCP TODO: fix me // func TestStakeRefKeys(t *testing.T) { // addr1 := sdk.AccAddress([]byte("addr1---------------")) -// denom1 := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). +// denom1 := dextypes.NewPoolDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). // String() -// denom2 := dextypes.NewDepositDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenC"}, 0, 1). +// denom2 := dextypes.NewPoolDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenC"}, 0, 1). // String() // // empty address and 1 coin // stake1 := types.NewStake( diff --git a/x/incentives/types/stakes_test.go b/x/incentives/types/stakes_test.go index a550845ed..1682624fb 100644 --- a/x/incentives/types/stakes_test.go +++ b/x/incentives/types/stakes_test.go @@ -18,7 +18,7 @@ package types_test // allCoins := sdk.Coins{ // sdk.NewInt64Coin( -// dextypes.NewDepositDenom( +// dextypes.NewPoolDenom( // &dextypes.PairID{ // Token0: "coin1", // Token1: "coin2", @@ -29,7 +29,7 @@ package types_test // 100, // ), // sdk.NewInt64Coin( -// dextypes.NewDepositDenom( +// dextypes.NewPoolDenom( // &dextypes.PairID{ // Token0: "coin1", // Token1: "coin2", @@ -40,7 +40,7 @@ package types_test // 200, // ), // sdk.NewInt64Coin( -// dextypes.NewDepositDenom( +// dextypes.NewPoolDenom( // &dextypes.PairID{ // Token0: "coin1", // Token1: "coin2", @@ -105,7 +105,7 @@ package types_test // allCoins := sdk.Coins{} // coins1 := sdk.NewInt64Coin( -// dextypes.NewDepositDenom( +// dextypes.NewPoolDenom( // &dextypes.PairID{ // Token0: "coin1", // Token1: "coin2", @@ -118,7 +118,7 @@ package types_test // allCoins = allCoins.Add(coins1) // coins2 := sdk.NewInt64Coin( -// dextypes.NewDepositDenom( +// dextypes.NewPoolDenom( // &dextypes.PairID{ // Token0: "coin1", // Token1: "coin2", @@ -131,7 +131,7 @@ package types_test // allCoins = allCoins.Add(coins2) // coins3 := sdk.NewInt64Coin( -// dextypes.NewDepositDenom( +// dextypes.NewPoolDenom( // &dextypes.PairID{ // Token0: "coin1", // Token1: "coin2", From 10a3e3f445de1f72d43b008e600592a059b09301 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Mon, 28 Aug 2023 14:21:10 -0700 Subject: [PATCH 07/16] switch to storing only pool ID --- proto/duality/dex/pool.proto | 2 +- x/dex/keeper/deposit_record.go | 2 +- x/dex/keeper/msg_server_test.go | 7 +++- x/dex/keeper/pool.go | 54 +++++++++++++++---------- x/dex/types/keys.go | 3 -- x/dex/types/pool.go | 6 +-- x/dex/types/pool.pb.go | 44 +++++++-------------- x/dex/types/pool_denom.go | 25 ++++++++++-- x/dex/types/pool_denom_test.go | 55 ++++++++++++++++++++++++++ x/dex/types/pool_params.go | 8 ++++ x/incentives/keeper/distribute.go | 4 +- x/incentives/keeper/query_server.go | 2 +- x/incentives/keeper/stake.go | 2 +- x/incentives/keeper/stake_refs.go | 2 +- x/incentives/types/expected_keepers.go | 2 +- 15 files changed, 148 insertions(+), 70 deletions(-) create mode 100644 x/dex/types/pool_denom_test.go diff --git a/proto/duality/dex/pool.proto b/proto/duality/dex/pool.proto index 3498ca0a9..c86db6fe6 100644 --- a/proto/duality/dex/pool.proto +++ b/proto/duality/dex/pool.proto @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto"; import "duality/dex/pool_reserves.proto"; message Pool { - string ID = 1; + uint64 ID = 1; PoolReserves lower_tick0 = 2; PoolReserves upper_tick1 = 3; } diff --git a/x/dex/keeper/deposit_record.go b/x/dex/keeper/deposit_record.go index c2791dbd4..c02703716 100644 --- a/x/dex/keeper/deposit_record.go +++ b/x/dex/keeper/deposit_record.go @@ -15,7 +15,7 @@ func (k Keeper) GetAllDepositsForAddress(ctx sdk.Context, addr sdk.AccAddress) [ return false } - poolParams, err := k.GetPoolParamsByID(ctx, sharesMaybe.Denom) + poolParams, err := k.GetPoolParamsByDenom(ctx, sharesMaybe.Denom) if err != nil { panic("Can't get info for PoolDenom") } diff --git a/x/dex/keeper/msg_server_test.go b/x/dex/keeper/msg_server_test.go index 7fc1798f6..fbd6b711f 100644 --- a/x/dex/keeper/msg_server_test.go +++ b/x/dex/keeper/msg_server_test.go @@ -1068,7 +1068,8 @@ func (s *MsgServerTestSuite) getPoolShares( if !found { return sdk.ZeroInt() } - return s.app.BankKeeper.GetSupply(s.ctx, poolID).Amount + poolDenom := types.NewPoolDenom(poolID) + return s.app.BankKeeper.GetSupply(s.ctx, poolDenom).Amount } func (s *MsgServerTestSuite) assertPoolShares( @@ -1092,7 +1093,9 @@ func (s *MsgServerTestSuite) getAccountShares( if !found { return sdk.ZeroInt() } - return s.app.BankKeeper.GetBalance(s.ctx, account, id).Amount + + poolDenom := types.NewPoolDenom(id) + return s.app.BankKeeper.GetBalance(s.ctx, account, poolDenom).Amount } func (s *MsgServerTestSuite) assertAccountShares( diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index 043b00da3..70d2bc7fc 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -37,11 +37,13 @@ func (k Keeper) InitPoolKeys(ctx sdk.Context, pairID *types.PairID, centerTickIndexNormalized int64, fee uint64, -) string { +) uint64 { poolKeyBz := types.PoolKey(*pairID, centerTickIndexNormalized, fee) poolID := k.GetNextPoolID(ctx) - poolIDBz := []byte(poolID) + poolIDBz := sdk.Uint64ToBigEndian(poolID) + + k.SetPoolCount(ctx, poolID+1) store := ctx.KVStore(k.storeKey) @@ -55,11 +57,8 @@ func (k Keeper) InitPoolKeys(ctx sdk.Context, } // GetNextPoolId get ID for the next pool to be created -func (k Keeper) GetNextPoolID(ctx sdk.Context) string { - poolCount := k.GetPoolCount(ctx) - // JCP TODO: this should happen in init keys once we switch poolID to uint64 - k.SetPoolCount(ctx, poolCount+1) - return types.NewPoolDenom(poolCount) +func (k Keeper) GetNextPoolID(ctx sdk.Context) uint64 { + return k.GetPoolCount(ctx) } func (k Keeper) GetPool( @@ -120,41 +119,54 @@ func (k Keeper) GetPoolIDByParams( pairID *types.PairID, centerTickIndexNormalized int64, fee uint64, -) (id string, found bool) { +) (id uint64, found bool) { poolRefKey := types.PoolKey(*pairID, centerTickIndexNormalized, fee) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolIDKeyPrefix)) b := store.Get(poolRefKey) if b == nil { - return "", false + return 0, false } - return string(b), true + poolID := sdk.BigEndianToUint64(b) + return poolID, true +} + +func (k Keeper) GetPoolParamsByDenom( + ctx sdk.Context, + denom string, +) (pp types.PoolParams, err error) { + poolID, err := types.ParsePoolIDFromDenom(denom) + if err != nil { + return pp, err + } + pp, found := k.GetPoolParamsByID(ctx, poolID) + if !found { + return pp, types.ErrInvalidPoolDenom + } + return pp, nil } func (k Keeper) GetPoolParamsByID( ctx sdk.Context, - id string, -) (types.PoolParams, error) { - // JCP TODO: should this be found vs error? + id uint64, +) (pp types.PoolParams, found bool) { ref, found := k.GetPoolRefByID(ctx, id) if !found { - return types.PoolParams{}, types.ErrInvalidDepositDenom + return pp, false } - poolParams, err := types.ParsePoolRefToParams(ref) - if err != nil { - panic("Cannot parse pool ref") - } + poolParams := types.MustParsePoolRefToParams(ref) - return poolParams, nil + return poolParams, true } func (k Keeper) GetPoolRefByID( ctx sdk.Context, - id string, + poolID uint64, ) (ref []byte, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRefKeyPrefix)) - b := store.Get([]byte(id)) + poolIDBz := sdk.Uint64ToBigEndian(poolID) + b := store.Get(poolIDBz) if b == nil { return []byte{}, false } diff --git a/x/dex/types/keys.go b/x/dex/types/keys.go index 4a443b8bd..378ed90c5 100644 --- a/x/dex/types/keys.go +++ b/x/dex/types/keys.go @@ -28,9 +28,6 @@ const ( Separator = "/" ) -const ( - PoolNamePrefix = "duality/pool/" -) const ( // TickLiquidityKeyPrefix is the prefix to retrieve all TickLiquidity diff --git a/x/dex/types/pool.go b/x/dex/types/pool.go index ce5e7d162..ebbf6fecb 100644 --- a/x/dex/types/pool.go +++ b/x/dex/types/pool.go @@ -9,7 +9,7 @@ func NewPool( pairID *PairID, centerTickIndexNormalized int64, fee uint64, - id string, + id uint64, ) (*Pool, error) { feeInt64 := utils.MustSafeUint64(fee) @@ -37,7 +37,7 @@ func MustNewPool( pairID *PairID, centerTickIndexNormalized int64, fee uint64, - id string, + id uint64, ) *Pool { pool, err := NewPool(pairID, centerTickIndexNormalized, fee, id) if err != nil { @@ -151,7 +151,7 @@ func (p *Pool) Deposit( } func (p *Pool) GetPoolDenom() string { - return p.ID + return NewPoolDenom(p.ID) } func (p *Pool) Price(tradePairID *TradePairID) sdk.Dec { diff --git a/x/dex/types/pool.pb.go b/x/dex/types/pool.pb.go index 982d139e3..bfacf593e 100644 --- a/x/dex/types/pool.pb.go +++ b/x/dex/types/pool.pb.go @@ -24,7 +24,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Pool struct { - ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` + ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` LowerTick0 *PoolReserves `protobuf:"bytes,2,opt,name=lower_tick0,json=lowerTick0,proto3" json:"lower_tick0,omitempty"` UpperTick1 *PoolReserves `protobuf:"bytes,3,opt,name=upper_tick1,json=upperTick1,proto3" json:"upper_tick1,omitempty"` } @@ -62,11 +62,11 @@ func (m *Pool) XXX_DiscardUnknown() { var xxx_messageInfo_Pool proto.InternalMessageInfo -func (m *Pool) GetID() string { +func (m *Pool) GetID() uint64 { if m != nil { return m.ID } - return "" + return 0 } func (m *Pool) GetLowerTick0() *PoolReserves { @@ -96,7 +96,7 @@ var fileDescriptor_458bee7d4cc3fc09 = []byte{ 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0x8a, 0xeb, 0xa5, 0xa4, 0x56, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf5, 0x41, 0x2c, 0x88, 0x12, 0x29, 0x79, 0x74, 0xad, 0xf1, 0x45, 0xa9, 0xc5, 0xa9, 0x45, 0x65, 0xa9, 0xc5, 0x10, 0x05, 0x4a, 0x7d, 0x8c, 0x5c, 0x2c, 0x01, 0xf9, 0xf9, 0x39, 0x42, - 0x7c, 0x5c, 0x4c, 0x9e, 0x2e, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x4c, 0x9e, 0x2e, 0x42, + 0x7c, 0x5c, 0x4c, 0x9e, 0x2e, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x4c, 0x9e, 0x2e, 0x42, 0x56, 0x5c, 0xdc, 0x39, 0xf9, 0xe5, 0xa9, 0x45, 0xf1, 0x25, 0x99, 0xc9, 0xd9, 0x06, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x92, 0x7a, 0x48, 0x56, 0xea, 0x81, 0xf4, 0x05, 0x41, 0x8d, 0x0b, 0xe2, 0x02, 0xab, 0x0e, 0x01, 0x29, 0x06, 0xe9, 0x2d, 0x2d, 0x28, 0x80, 0xea, 0x35, 0x94, 0x60, @@ -104,8 +104,8 @@ var fileDescriptor_458bee7d4cc3fc09 = []byte{ 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xb4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0x46, 0xe9, 0xe6, 0x24, 0x26, 0x15, 0xc3, 0x38, 0xfa, 0x15, 0x60, 0x5f, 0x96, 0x54, 0x16, - 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xbd, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x2a, 0x36, - 0x90, 0x3c, 0x01, 0x00, 0x00, + 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xbd, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x0b, 0xf6, + 0xad, 0x3c, 0x01, 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -152,12 +152,10 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.ID) > 0 { - i -= len(m.ID) - copy(dAtA[i:], m.ID) - i = encodeVarintPool(dAtA, i, uint64(len(m.ID))) + if m.ID != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.ID)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -179,9 +177,8 @@ func (m *Pool) Size() (n int) { } var l int _ = l - l = len(m.ID) - if l > 0 { - n += 1 + l + sovPool(uint64(l)) + if m.ID != 0 { + n += 1 + sovPool(uint64(m.ID)) } if m.LowerTick0 != nil { l = m.LowerTick0.Size() @@ -230,10 +227,10 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } - var stringLen uint64 + m.ID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -243,24 +240,11 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ID |= 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.ID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LowerTick0", wireType) diff --git a/x/dex/types/pool_denom.go b/x/dex/types/pool_denom.go index 526f6f46e..f27660d7d 100644 --- a/x/dex/types/pool_denom.go +++ b/x/dex/types/pool_denom.go @@ -3,14 +3,18 @@ package types import ( "fmt" "regexp" + "strconv" ) -const PoolDenomRegexpStr = PoolNamePrefix + `\d+` +const ( + PoolDenomPrefix = "duality/pool/" + PoolDenomRegexpStr = "^" + PoolDenomPrefix + `(\d+)` + "$" +) var PoolDenomRegexp = regexp.MustCompile(PoolDenomRegexpStr) -func NewPoolDenom(poolIdx uint64) string { - return fmt.Sprintf("%s%d", PoolNamePrefix, poolIdx) +func NewPoolDenom(poolID uint64) string { + return fmt.Sprintf("%s%d", PoolDenomPrefix, poolID) } func ValidatePoolDenom(denom string) error { @@ -20,3 +24,18 @@ func ValidatePoolDenom(denom string) error { return nil } + +func ParsePoolIDFromDenom(denom string) (uint64, error) { + res := PoolDenomRegexp.FindStringSubmatch(denom) + if len(res) != 2 { + return 0, ErrInvalidPoolDenom + } + idStr := res[1] + + idInt, err := strconv.ParseUint(idStr, 10, 0) + if err != nil { + return 0, ErrInvalidPoolDenom + } + + return idInt, nil +} diff --git a/x/dex/types/pool_denom_test.go b/x/dex/types/pool_denom_test.go new file mode 100644 index 000000000..ffdd8742c --- /dev/null +++ b/x/dex/types/pool_denom_test.go @@ -0,0 +1,55 @@ +package types_test + +import ( + "testing" + + . "github.com/duality-labs/duality/x/dex/types" + "github.com/stretchr/testify/require" +) + +func TestParsePoolIDFromDenom(t *testing.T) { + for _, tc := range []struct { + desc string + denom string + expected uint64 + valid bool + }{ + { + desc: "valid denom", + denom: "duality/pool/0", + expected: 0, + valid: true, + }, + { + desc: "valid denom long", + denom: "duality/pool/999999999", + expected: 999999999, + valid: true, + }, + { + desc: "invalid format 1", + denom: "/duality/pool/0", + valid: false, + }, + { + desc: "invalid format 2", + denom: "duality/pool/0/", + valid: false, + }, + { + desc: "invalid denom prefix", + denom: "INVALID/pool/0", + valid: false, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + id, err := ParsePoolIDFromDenom(tc.denom) + if tc.valid { + require.NoError(t, err) + require.Equal(t, tc.expected, id) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/dex/types/pool_params.go b/x/dex/types/pool_params.go index d23a0e464..6168422c4 100644 --- a/x/dex/types/pool_params.go +++ b/x/dex/types/pool_params.go @@ -33,6 +33,14 @@ func ParsePoolRefToParams(poolRef []byte) (PoolParams, error) { return PoolParams{PairID: pairID, Tick: tick, Fee: fee}, nil } +func MustParsePoolRefToParams(poolRef []byte) PoolParams { + poolParams, err := ParsePoolRefToParams(poolRef) + if err != nil { + panic("Invalid pool ref") + } + return poolParams +} + func NewPoolParams(pairID *PairID, tick int64, fee uint64) PoolParams { return PoolParams{PairID: pairID, Tick: tick, Fee: fee} } diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index e836b6ac3..07049a829 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -14,7 +14,7 @@ var _ DistributorKeeper = Keeper{} func (k Keeper) ValueForShares(ctx sdk.Context, coin sdk.Coin, tick int64) (sdk.Int, error) { totalShares := k.bk.GetSupply(ctx, coin.Denom).Amount - poolParams, err := k.dk.GetPoolParamsByID(ctx, coin.Denom) + poolParams, err := k.dk.GetPoolParamsByDenom(ctx, coin.Denom) if err != nil { return sdk.ZeroInt(), err } @@ -127,7 +127,7 @@ func (k Keeper) GetRewardsEstimate( pairSet := map[dextypes.PairID]bool{} for _, l := range filterStakes { for _, c := range l.Coins { - poolParams, err := k.dk.GetPoolParamsByID(ctx, c.Denom) + poolParams, err := k.dk.GetPoolParamsByDenom(ctx, c.Denom) if err != nil { panic("all stakes should be valid deposit denoms") } diff --git a/x/incentives/keeper/query_server.go b/x/incentives/keeper/query_server.go index 70a3ee0b6..26ae1647b 100644 --- a/x/incentives/keeper/query_server.go +++ b/x/incentives/keeper/query_server.go @@ -94,7 +94,7 @@ func (q QueryServer) GetGauges( var lowerTick, upperTick int64 var poolParams *dextypes.PoolParams if req.Denom != "" { - poolParams, err := q.dk.GetPoolParamsByID(ctx, req.Denom) + poolParams, err := q.dk.GetPoolParamsByDenom(ctx, req.Denom) if err != nil { return nil, err } diff --git a/x/incentives/keeper/stake.go b/x/incentives/keeper/stake.go index ca366a34f..bdc9eae1e 100644 --- a/x/incentives/keeper/stake.go +++ b/x/incentives/keeper/stake.go @@ -236,7 +236,7 @@ func (k Keeper) StakeCoinsPassingQueryCondition( coins := stake.Coins result := sdk.NewCoins() for _, c := range coins { - poolParams, err := k.dk.GetPoolParamsByID(ctx, c.Denom) + poolParams, err := k.dk.GetPoolParamsByDenom(ctx, c.Denom) if err != nil { continue } diff --git a/x/incentives/keeper/stake_refs.go b/x/incentives/keeper/stake_refs.go index d46d66ba0..953921a8f 100644 --- a/x/incentives/keeper/stake_refs.go +++ b/x/incentives/keeper/stake_refs.go @@ -47,7 +47,7 @@ func (k Keeper) getStakeRefKeys(ctx sdk.Context, stake *types.Stake) ([][]byte, refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexAccount, owner))] = true for _, coin := range stake.Coins { - poolParams, err := k.dk.GetPoolParamsByID(ctx, coin.Denom) + poolParams, err := k.dk.GetPoolParamsByDenom(ctx, coin.Denom) if err != nil { panic("Only valid LP tokens should be staked") } diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go index afbe8526d..f44eb7bbf 100644 --- a/x/incentives/types/expected_keepers.go +++ b/x/incentives/types/expected_keepers.go @@ -34,5 +34,5 @@ type AccountKeeper interface { type DexKeeper interface { GetOrInitPool(ctx sdk.Context, pairID *types.PairID, centerTickIndex int64, fee uint64) (*dextypes.Pool, error) - GetPoolParamsByID(ctx sdk.Context, id string) (types.PoolParams, error) + GetPoolParamsByDenom(ctx sdk.Context, id string) (types.PoolParams, error) } From d680f0548239704e649c5bb41976432fdcfc4081 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Mon, 28 Aug 2023 14:42:05 -0700 Subject: [PATCH 08/16] fix GetStakeRefKeys tests --- x/incentives/keeper/utils_test.go | 113 +++++++++++++++++------------- 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/x/incentives/keeper/utils_test.go b/x/incentives/keeper/utils_test.go index e097d20df..76f7c8d3e 100644 --- a/x/incentives/keeper/utils_test.go +++ b/x/incentives/keeper/utils_test.go @@ -2,9 +2,14 @@ package keeper_test import ( "testing" + "time" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/duality-labs/duality/app" + dextypes "github.com/duality-labs/duality/x/dex/types" . "github.com/duality-labs/duality/x/incentives/keeper" "github.com/duality-labs/duality/x/incentives/types" ) @@ -61,53 +66,61 @@ func TestRemoveValue(t *testing.T) { require.Equal(t, index4, -1) } -// JCP TODO: fix me -// func TestStakeRefKeys(t *testing.T) { -// addr1 := sdk.AccAddress([]byte("addr1---------------")) -// denom1 := dextypes.NewPoolDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1). -// String() -// denom2 := dextypes.NewPoolDenom(&dextypes.PairID{Token0: "TokenA", Token1: "TokenC"}, 0, 1). -// String() -// // empty address and 1 coin -// stake1 := types.NewStake( -// 1, -// sdk.AccAddress{}, -// sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, -// time.Now(), -// 10, -// ) -// _, err := GetStakeRefKeys(stake1) -// require.Error(t, err) - -// // empty address and 2 coins -// stake2 := types.NewStake( -// 1, -// sdk.AccAddress{}, -// sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, -// time.Now(), -// 10, -// ) -// _, err = GetStakeRefKeys(stake2) -// require.Error(t, err) - -// // not empty address and 1 coin -// stake3 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) -// keys3, err := GetStakeRefKeys(stake3) -// require.Len(t, keys3, 6) - -// // not empty address and empty coin -// stake4 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) -// keys4, err := GetStakeRefKeys(stake4) -// require.Len(t, keys4, 6) - -// // not empty address and 2 coins -// stake5 := types.NewStake( -// 1, -// addr1, -// sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, -// time.Now(), -// 10, -// ) -// keys5, err := GetStakeRefKeys(stake5) -// require.Len(t, keys5, 10) -// } +func TestStakeRefKeys(t *testing.T) { + addr1 := sdk.AccAddress([]byte("addr1---------------")) + app := app.Setup(t, false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + pool1, err := app.DexKeeper.InitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1) + require.NoError(t, err) + + denom1 := pool1.GetPoolDenom() + + pool2, err := app.DexKeeper.InitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenC"}, 0, 1) + require.NoError(t, err) + + denom2 := pool2.GetPoolDenom() + + // empty address and 1 coin + stake1 := types.NewStake( + 1, + sdk.AccAddress{}, + sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, + time.Now(), + 10, + ) + _, err = app.IncentivesKeeper.GetStakeRefKeys(ctx, stake1) + require.Error(t, err) + + // empty address and 2 coins + stake2 := types.NewStake( + 1, + sdk.AccAddress{}, + sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, + time.Now(), + 10, + ) + _, err = app.IncentivesKeeper.GetStakeRefKeys(ctx, stake2) + require.Error(t, err) + + // not empty address and 1 coin + stake3 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) + keys3, err := app.IncentivesKeeper.GetStakeRefKeys(ctx, stake3) + require.Len(t, keys3, 6) + + // not empty address and empty coin + stake4 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) + keys4, err := app.IncentivesKeeper.GetStakeRefKeys(ctx, stake4) + require.Len(t, keys4, 6) + + // not empty address and 2 coins + stake5 := types.NewStake( + 1, + addr1, + sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, + time.Now(), + 10, + ) + keys5, err := app.IncentivesKeeper.GetStakeRefKeys(ctx, stake5) + require.Len(t, keys5, 10) +} From e4fefc4ca77a54c3736a807da47c7da612d9e50e Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Mon, 28 Aug 2023 14:46:52 -0700 Subject: [PATCH 09/16] remove dead code --- x/incentives/types/stakes.go | 12 -- x/incentives/types/stakes_test.go | 189 ------------------------------ 2 files changed, 201 deletions(-) delete mode 100644 x/incentives/types/stakes_test.go diff --git a/x/incentives/types/stakes.go b/x/incentives/types/stakes.go index 468770d49..e2b0240b7 100644 --- a/x/incentives/types/stakes.go +++ b/x/incentives/types/stakes.go @@ -4,18 +4,6 @@ import sdk "github.com/cosmos/cosmos-sdk/types" type Stakes []*Stake -// JCP TODO: remove? -// func (stakes Stakes) CoinsByQueryCondition(distrTo QueryCondition) sdk.Coins { -// coins := sdk.Coins{} -// for _, stake := range stakes { -// coinsToAdd := stake.CoinsPassingQueryCondition(distrTo) -// if !coinsToAdd.Empty() { -// coins = coins.Add(coinsToAdd...) -// } -// } -// return coins -// } - func (stakes Stakes) GetCoins() sdk.Coins { coins := sdk.Coins{} for _, stake := range stakes { diff --git a/x/incentives/types/stakes_test.go b/x/incentives/types/stakes_test.go deleted file mode 100644 index 1682624fb..000000000 --- a/x/incentives/types/stakes_test.go +++ /dev/null @@ -1,189 +0,0 @@ -package types_test - -// JCP TODO: fix? delete? -// import ( -// "testing" -// time "time" - -// sdk "github.com/cosmos/cosmos-sdk/types" -// dextypes "github.com/duality-labs/duality/x/dex/types" -// . "github.com/duality-labs/duality/x/incentives/types" -// "github.com/stretchr/testify/assert" -// "github.com/stretchr/testify/require" -// ) - -// func TestStakesCoinsByQueryCondition(t *testing.T) { -// owner, err := sdk.AccAddressFromBech32("dual1lyaz7emmzreenas4fpz49a49958kye7wxuvsdr") -// require.NoError(t, err) - -// allCoins := sdk.Coins{ -// sdk.NewInt64Coin( -// dextypes.NewPoolDenom( -// &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// }, -// 25, -// 10, -// ).String(), -// 100, -// ), -// sdk.NewInt64Coin( -// dextypes.NewPoolDenom( -// &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// }, -// 75, -// 10, -// ).String(), -// 200, -// ), -// sdk.NewInt64Coin( -// dextypes.NewPoolDenom( -// &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// }, -// 75, -// 50, -// ).String(), -// 200, -// ), -// } - -// stakes := Stakes{ -// NewStake(1, owner, sdk.Coins{allCoins[0]}, time.Time{}, 0), -// NewStake(2, owner, sdk.Coins{allCoins[1]}, time.Time{}, 0), -// NewStake(3, owner, sdk.Coins{allCoins[2]}, time.Time{}, 0), -// } - -// pairID := &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// } - -// tests := []struct { -// name string -// queryCond QueryCondition -// coinsByCond sdk.Coins -// }{ -// { -// name: "All coins", -// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 100}, -// coinsByCond: sdk.Coins{allCoins[0], allCoins[1]}, -// }, -// { -// name: "Coin1 only", -// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 50}, -// coinsByCond: sdk.Coins{allCoins[0]}, -// }, -// { -// name: "Coin2 only", -// queryCond: QueryCondition{PairID: pairID, StartTick: 50, EndTick: 100}, -// coinsByCond: sdk.Coins{allCoins[1]}, -// }, -// { -// name: "No coins", -// queryCond: QueryCondition{PairID: pairID, StartTick: 100, EndTick: 200}, -// coinsByCond: sdk.Coins{}, -// }, -// } - -// for _, tt := range tests { -// t.Run(tt.name, func(t *testing.T) { -// coins := stakes.CoinsByQueryCondition(tt.queryCond) -// assert.Equal(t, tt.coinsByCond, coins) -// }) -// } -// } - -// func TestStakesCoinsByQueryConditionMultiple(t *testing.T) { -// owner, err := sdk.AccAddressFromBech32("dual1lyaz7emmzreenas4fpz49a49958kye7wxuvsdr") -// require.NoError(t, err) - -// allCoins := sdk.Coins{} - -// coins1 := sdk.NewInt64Coin( -// dextypes.NewPoolDenom( -// &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// }, -// 25, -// 10, -// ).String(), -// 100, -// ) -// allCoins = allCoins.Add(coins1) - -// coins2 := sdk.NewInt64Coin( -// dextypes.NewPoolDenom( -// &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// }, -// 75, -// 10, -// ).String(), -// 200, -// ) -// allCoins = allCoins.Add(coins2) - -// coins3 := sdk.NewInt64Coin( -// dextypes.NewPoolDenom( -// &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// }, -// 75, -// 50, -// ).String(), -// 200, -// ) -// allCoins = allCoins.Add(coins3) -// assert.Equal(t, allCoins, allCoins.Sort()) - -// stakes := Stakes{ -// NewStake(1, owner, allCoins, time.Time{}, 0), -// } - -// pairID := &dextypes.PairID{ -// Token0: "coin1", -// Token1: "coin2", -// } - -// tests := []struct { -// name string -// queryCond QueryCondition -// expected sdk.Coins -// }{ -// { -// name: "All coins", -// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 100}, -// expected: sdk.Coins{coins1, coins2}, -// }, -// { -// name: "Coin1 only", -// queryCond: QueryCondition{PairID: pairID, StartTick: 0, EndTick: 50}, -// expected: sdk.Coins{coins1}, -// }, -// { -// name: "Coin2 only", -// queryCond: QueryCondition{PairID: pairID, StartTick: 50, EndTick: 100}, -// expected: sdk.Coins{coins2}, -// }, -// { -// name: "No coins", -// queryCond: QueryCondition{PairID: pairID, StartTick: 100, EndTick: 200}, -// expected: sdk.Coins{}, -// }, -// } - -// for _, tt := range tests { -// t.Run(tt.name, func(t *testing.T) { -// coins := stakes.CoinsByQueryCondition(tt.queryCond) -// assert.Equal(t, tt.expected, coins) -// }) -// } -// } From 24fbabd398dfe28c686a8aaf8ccff03dc4ea8e27 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Mon, 28 Aug 2023 15:40:47 -0700 Subject: [PATCH 10/16] add PoolByID query --- proto/duality/dex/query.proto | 12 +- x/dex/client/cli/query.go | 1 + x/dex/client/cli/query_pool.go | 36 ++- x/dex/keeper/grpc_query_pool.go | 18 ++ x/dex/keeper/grpc_query_pool_test.go | 51 +++ x/dex/keeper/pool.go | 9 + x/dex/types/query.pb.go | 448 +++++++++++++++++++-------- x/dex/types/query.pb.gw.go | 101 ++++++ 8 files changed, 547 insertions(+), 129 deletions(-) diff --git a/proto/duality/dex/query.proto b/proto/duality/dex/query.proto index 26c160579..eb0269a9c 100644 --- a/proto/duality/dex/query.proto +++ b/proto/duality/dex/query.proto @@ -97,11 +97,16 @@ service Query { option (google.api.http).get = "/duality/dex/estimate_place_limit_order"; } - // Queries the pool for a pair, tick and fee + // Queries a pool by pair, tick and fee rpc Pool(QueryPoolRequest) returns (QueryPoolResponse) { option (google.api.http).get = "/duality/dex/pool/{pairID}/{tickIndex}/{fee}"; } + // Queries a pool by ID + rpc PoolByID(QueryPoolByIDRequest) returns (QueryPoolResponse) { + option (google.api.http).get = "/duality/dex/pool/{poolID}"; + } + // this line is used by starport scaffolding # 2 } @@ -323,6 +328,11 @@ message QueryPoolRequest { string pairID = 1; int64 tickIndex = 2; uint64 fee = 3; + +} + +message QueryPoolByIDRequest { + uint64 poolID = 1; } message QueryPoolResponse { diff --git a/x/dex/client/cli/query.go b/x/dex/client/cli/query.go index cce88d1a9..a8bb670c4 100644 --- a/x/dex/client/cli/query.go +++ b/x/dex/client/cli/query.go @@ -41,6 +41,7 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdListPoolReserves()) cmd.AddCommand(CmdShowPoolReserves()) cmd.AddCommand(CmdShowPool()) + cmd.AddCommand(CmdShowPoolByID()) // this line is used by starport scaffolding # 1 diff --git a/x/dex/client/cli/query_pool.go b/x/dex/client/cli/query_pool.go index 6f991a109..6712a6973 100644 --- a/x/dex/client/cli/query_pool.go +++ b/x/dex/client/cli/query_pool.go @@ -15,7 +15,7 @@ func CmdShowPool() *cobra.Command { cmd := &cobra.Command{ Use: "show-pool '[pair-id]' [tick-index] [fee]", Short: "shows a pool. Make sure to wrap your pair-id in quotes otherwise the shell will interpret <> as a separator token", - Example: "show-pool-reserves 'tokenA<>tokenB' [-5] 1", + Example: "show-pool 'tokenA<>tokenB' [-5] 1", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx := client.GetClientContextFromCmd(cmd) @@ -59,3 +59,37 @@ func CmdShowPool() *cobra.Command { return cmd } + +func CmdShowPoolByID() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-pool-by-id [poolID]", + Short: "shows a pool by poolID", + Example: "show-pool-by-id 5", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argPoolID, err := strconv.ParseUint(args[0], 10, 0) + if err != nil { + return err + } + + params := &types.QueryPoolByIDRequest{ + PoolID: argPoolID, + } + + res, err := queryClient.PoolByID(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dex/keeper/grpc_query_pool.go b/x/dex/keeper/grpc_query_pool.go index cd434e46e..75ac7c3b0 100644 --- a/x/dex/keeper/grpc_query_pool.go +++ b/x/dex/keeper/grpc_query_pool.go @@ -31,3 +31,21 @@ func (k Keeper) Pool( return &types.QueryPoolResponse{Pool: pool}, nil } + +func (k Keeper) PoolByID( + goCtx context.Context, + req *types.QueryPoolByIDRequest, +) (*types.QueryPoolResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + pool, found := k.GetPoolByID(ctx, req.PoolID) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryPoolResponse{Pool: pool}, nil +} diff --git a/x/dex/keeper/grpc_query_pool_test.go b/x/dex/keeper/grpc_query_pool_test.go index dbfaa55fe..207bb31b1 100644 --- a/x/dex/keeper/grpc_query_pool_test.go +++ b/x/dex/keeper/grpc_query_pool_test.go @@ -69,3 +69,54 @@ func TestPoolQuerySingle(t *testing.T) { }) } } + +func TestPoolQueryByID(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNPools(keeper, ctx, 2) + for _, tc := range []struct { + desc string + request *types.QueryPoolByIDRequest + response *types.QueryPoolResponse + err error + }{ + { + desc: "First", + request: &types.QueryPoolByIDRequest{ + PoolID: 0, + }, + response: &types.QueryPoolResponse{Pool: msgs[0].Pool}, + }, + { + desc: "Second", + request: &types.QueryPoolByIDRequest{ + PoolID: 1, + }, + response: &types.QueryPoolResponse{Pool: msgs[1].Pool}, + }, + { + desc: "KeyNotFound", + request: &types.QueryPoolByIDRequest{ + PoolID: 100, + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.PoolByID(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index 70d2bc7fc..297edd6e5 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -99,6 +99,15 @@ func (k Keeper) GetPool( }, true } +func (k Keeper) GetPoolByID(ctx sdk.Context, poolID uint64) (pool *types.Pool, found bool) { + poolParams, found := k.GetPoolParamsByID(ctx, poolID) + if !found { + return pool, false + } + + return k.GetPool(ctx, poolParams.PairID, poolParams.Tick, poolParams.Fee) +} + // GetPoolCount get the total number of pool func (k Keeper) GetPoolCount(ctx sdk.Context) uint64 { store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) diff --git a/x/dex/types/query.pb.go b/x/dex/types/query.pb.go index 6c38e0a5d..80ede9338 100644 --- a/x/dex/types/query.pb.go +++ b/x/dex/types/query.pb.go @@ -1664,6 +1664,50 @@ func (m *QueryPoolRequest) GetFee() uint64 { return 0 } +type QueryPoolByIDRequest struct { + PoolID uint64 `protobuf:"varint,1,opt,name=poolID,proto3" json:"poolID,omitempty"` +} + +func (m *QueryPoolByIDRequest) Reset() { *m = QueryPoolByIDRequest{} } +func (m *QueryPoolByIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolByIDRequest) ProtoMessage() {} +func (*QueryPoolByIDRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4664128fddcf2b7a, []int{31} +} +func (m *QueryPoolByIDRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolByIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolByIDRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryPoolByIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolByIDRequest.Merge(m, src) +} +func (m *QueryPoolByIDRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolByIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolByIDRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolByIDRequest proto.InternalMessageInfo + +func (m *QueryPoolByIDRequest) GetPoolID() uint64 { + if m != nil { + return m.PoolID + } + return 0 +} + type QueryPoolResponse struct { Pool *Pool `protobuf:"bytes,1,opt,name=pool,proto3" json:"pool,omitempty"` } @@ -1672,7 +1716,7 @@ func (m *QueryPoolResponse) Reset() { *m = QueryPoolResponse{} } func (m *QueryPoolResponse) String() string { return proto.CompactTextString(m) } func (*QueryPoolResponse) ProtoMessage() {} func (*QueryPoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4664128fddcf2b7a, []int{31} + return fileDescriptor_4664128fddcf2b7a, []int{32} } func (m *QueryPoolResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1740,137 +1784,140 @@ func init() { proto.RegisterType((*QueryEstimatePlaceLimitOrderRequest)(nil), "duality.dex.QueryEstimatePlaceLimitOrderRequest") proto.RegisterType((*QueryEstimatePlaceLimitOrderResponse)(nil), "duality.dex.QueryEstimatePlaceLimitOrderResponse") proto.RegisterType((*QueryPoolRequest)(nil), "duality.dex.QueryPoolRequest") + proto.RegisterType((*QueryPoolByIDRequest)(nil), "duality.dex.QueryPoolByIDRequest") proto.RegisterType((*QueryPoolResponse)(nil), "duality.dex.QueryPoolResponse") } func init() { proto.RegisterFile("duality/dex/query.proto", fileDescriptor_4664128fddcf2b7a) } var fileDescriptor_4664128fddcf2b7a = []byte{ - // 1969 bytes of a gzipped FileDescriptorProto + // 2013 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0xcf, 0x6f, 0x1b, 0xc7, - 0x15, 0xf6, 0x88, 0xb2, 0x2c, 0x8f, 0x9d, 0x58, 0x1e, 0xcb, 0x09, 0x4d, 0x3b, 0x5c, 0x75, 0xea, - 0x1f, 0x92, 0x6d, 0x71, 0x2d, 0xa5, 0x4e, 0x5b, 0x37, 0x68, 0x2b, 0xc5, 0x89, 0xc3, 0xd6, 0xa9, - 0xd5, 0x0d, 0x7d, 0x68, 0x5a, 0x94, 0x5d, 0x91, 0x63, 0x7a, 0xa1, 0xe5, 0xee, 0x7a, 0x77, 0x29, - 0x8b, 0x10, 0x8c, 0xa2, 0xbd, 0xf4, 0x54, 0x34, 0x6d, 0x03, 0x34, 0x28, 0xda, 0x43, 0xd0, 0xab, - 0x81, 0x06, 0x45, 0xcf, 0x45, 0x0f, 0x3d, 0x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1, 0xfc, 0xfb, 0xd8, 0xff, 0x0b, 0xc2, 0xf3, 0x03, 0x73, 0x72, 0xe6, 0x97, - 0xb3, 0xd1, 0x38, 0x24, 0x9a, 0x61, 0x65, 0x29, 0xfa, 0x0d, 0x11, 0xcd, 0x75, 0xf2, 0xfa, 0x0b, - 0x44, 0x43, 0x3e, 0x46, 0x78, 0xae, 0xbf, 0xf0, 0x43, 0x96, 0x94, 0x7c, 0xaa, 0xca, 0x4a, 0x85, - 0xcb, 0x59, 0x4c, 0x87, 0x4a, 0x43, 0x08, 0xba, 0xfb, 0x0f, 0x8a, 0x9e, 0xb4, 0xc9, 0x47, 0x08, - 0x9f, 0x90, 0xcb, 0x3d, 0x9c, 0xca, 0x45, 0x25, 0x37, 0x8a, 0x6a, 0x52, 0x61, 0x29, 0x83, 0x25, - 0xe0, 0xba, 0x2a, 0x70, 0x5d, 0x24, 0xe7, 0x07, 0x71, 0xc1, 0xff, 0x46, 0x64, 0x58, 0x9f, 0x20, - 0x4c, 0xfa, 0x6a, 0x3d, 0x1c, 0xd9, 0x95, 0xd4, 0xf9, 0x06, 0x0b, 0x4a, 0x85, 0xab, 0xd9, 0x8c, - 0x01, 0xdf, 0x35, 0x81, 0xef, 0x32, 0x59, 0x1c, 0xc4, 0x27, 0x65, 0xb9, 0x0f, 0xe3, 0x5c, 0xa2, - 0x92, 0xc2, 0x11, 0xaa, 0x19, 0x51, 0x95, 0x91, 0x54, 0x59, 0x4d, 0x2b, 0xeb, 0xd0, 0x37, 0x04, - 0xba, 0x6b, 0xa4, 0xa4, 0xa7, 0xff, 0xcb, 0x48, 0xa5, 0xbc, 0xff, 0x21, 0x7c, 0x26, 0xf5, 0x49, - 0x4f, 0xae, 0x2b, 0x75, 0x35, 0xaa, 0xee, 0x50, 0x78, 0x63, 0x5c, 0x37, 0x08, 0xe2, 0x87, 0x22, - 0x88, 0xbb, 0xe4, 0xfd, 0x44, 0x10, 0xf7, 0x2c, 0xdb, 0x66, 0xf5, 0xea, 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xb7, 0x50, 0x44, 0x16, 0xb5, 0x7c, 0xea, + 0xca, 0x50, 0x85, 0x8b, 0x59, 0x4c, 0x07, 0x4a, 0x43, 0x0a, 0xba, 0xf3, 0x0f, 0x8d, 0xae, 0xb4, + 0xc9, 0x47, 0x08, 0x1f, 0x53, 0xcb, 0x43, 0x82, 0xca, 0x05, 0x2d, 0x37, 0x9a, 0xea, 0x53, 0x61, + 0x31, 0x83, 0x25, 0xe0, 0xba, 0x2c, 0x71, 0x9d, 0x27, 0x67, 0xfb, 0x71, 0xc1, 0xff, 0x52, 0x54, + 0x58, 0x9f, 0x20, 0x4c, 0x7a, 0x6a, 0x43, 0x02, 0xd9, 0xa5, 0xd4, 0xf9, 0xfa, 0x0b, 0x50, 0x85, + 0xcb, 0xd9, 0x8c, 0x01, 0xdf, 0x15, 0x89, 0xef, 0x22, 0x59, 0xe8, 0xc7, 0xa7, 0x64, 0xb9, 0x07, + 0xe3, 0x4c, 0xa2, 0xf2, 0x22, 0x10, 0xea, 0x19, 0xd1, 0x95, 0x9d, 0x74, 0x59, 0x4d, 0x2b, 0x03, + 0xd1, 0x37, 0x24, 0xba, 0x2b, 0xa4, 0x6c, 0xa4, 0xff, 0x8b, 0x49, 0xa7, 0xbc, 0xff, 0x23, 0x7c, + 0x3a, 0xb5, 0x04, 0x40, 0xae, 0x6a, 0x75, 0x35, 0xac, 0x4e, 0x51, 0x78, 0x63, 0x54, 0x37, 0x08, + 0xe2, 0x47, 0x32, 0x88, 0x5b, 0xe4, 0xfd, 0x44, 0x10, 0xb7, 0x6d, 0xc7, 0x61, 0xf5, 0xea, 0x7e, + 0x37, 0x86, 0xbf, 0x23, 0x3c, 0x97, 0x0a, 0x41, 0x64, 0xe6, 0xaa, 0x96, 0xee, 0x17, 0x09, 0x36, + 0x4b, 0x59, 0x85, 0x1a, 0x32, 0xd8, 0x45, 0x72, 0x21, 0x63, 0xb0, 0xe4, 0x4f, 0x08, 0x1f, 0x53, + 0x1f, 0xb4, 0xe9,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 0x0f, 0x9f, 0x15, 0x0f, 0x3c, 0x79, 0x56, + 0x3c, 0xf0, 0xd9, 0xb3, 0xe2, 0x81, 0x0f, 0x2e, 0x29, 0x8f, 0x0d, 0xf0, 0x5f, 0x72, 0xac, 0xad, + 0xa0, 0x33, 0xd8, 0x6e, 0xb4, 0x49, 0x8b, 0x57, 0xc7, 0xd6, 0x94, 0x7c, 0xc8, 0xbe, 0xfe, 0x79, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x67, 0x34, 0x5f, 0x2c, 0x5a, 0x21, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1915,8 +1962,10 @@ type QueryClient interface { EstimateMultiHopSwap(ctx context.Context, in *QueryEstimateMultiHopSwapRequest, opts ...grpc.CallOption) (*QueryEstimateMultiHopSwapResponse, error) // Queries the simulated result of a multihop swap EstimatePlaceLimitOrder(ctx context.Context, in *QueryEstimatePlaceLimitOrderRequest, opts ...grpc.CallOption) (*QueryEstimatePlaceLimitOrderResponse, error) - // Queries the pool for a pair, tick and fee + // Queries a pool by pair, tick and fee Pool(ctx context.Context, in *QueryPoolRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) + // Queries a pool by ID + PoolByID(ctx context.Context, in *QueryPoolByIDRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) } type queryClient struct { @@ -2071,6 +2120,15 @@ func (c *queryClient) Pool(ctx context.Context, in *QueryPoolRequest, opts ...gr return out, nil } +func (c *queryClient) PoolByID(ctx context.Context, in *QueryPoolByIDRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) { + out := new(QueryPoolResponse) + err := c.cc.Invoke(ctx, "/duality.dex.Query/PoolByID", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -2103,8 +2161,10 @@ type QueryServer interface { EstimateMultiHopSwap(context.Context, *QueryEstimateMultiHopSwapRequest) (*QueryEstimateMultiHopSwapResponse, error) // Queries the simulated result of a multihop swap EstimatePlaceLimitOrder(context.Context, *QueryEstimatePlaceLimitOrderRequest) (*QueryEstimatePlaceLimitOrderResponse, error) - // Queries the pool for a pair, tick and fee + // Queries a pool by pair, tick and fee Pool(context.Context, *QueryPoolRequest) (*QueryPoolResponse, error) + // Queries a pool by ID + PoolByID(context.Context, *QueryPoolByIDRequest) (*QueryPoolResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2159,6 +2219,9 @@ func (*UnimplementedQueryServer) EstimatePlaceLimitOrder(ctx context.Context, re func (*UnimplementedQueryServer) Pool(ctx context.Context, req *QueryPoolRequest) (*QueryPoolResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Pool not implemented") } +func (*UnimplementedQueryServer) PoolByID(ctx context.Context, req *QueryPoolByIDRequest) (*QueryPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolByID not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2452,6 +2515,24 @@ func _Query_Pool_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } +func _Query_PoolByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolByIDRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolByID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/duality.dex.Query/PoolByID", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolByID(ctx, req.(*QueryPoolByIDRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "duality.dex.Query", HandlerType: (*QueryServer)(nil), @@ -2520,6 +2601,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Pool", Handler: _Query_Pool_Handler, }, + { + MethodName: "PoolByID", + Handler: _Query_PoolByID_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "duality/dex/query.proto", @@ -3866,6 +3951,34 @@ func (m *QueryPoolRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryPoolByIDRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryPoolByIDRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolByIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolID != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *QueryPoolResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -4456,6 +4569,18 @@ func (m *QueryPoolRequest) Size() (n int) { return n } +func (m *QueryPoolByIDRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolID != 0 { + n += 1 + sovQuery(uint64(m.PoolID)) + } + return n +} + func (m *QueryPoolResponse) Size() (n int) { if m == nil { return 0 @@ -8183,6 +8308,75 @@ func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPoolByIDRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPoolByIDRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolByIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + } + m.PoolID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/dex/types/query.pb.gw.go b/x/dex/types/query.pb.gw.go index e7d170d13..759cb9c40 100644 --- a/x/dex/types/query.pb.gw.go +++ b/x/dex/types/query.pb.gw.go @@ -1173,6 +1173,60 @@ func local_request_Query_Pool_0(ctx context.Context, marshaler runtime.Marshaler } +func request_Query_PoolByID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolByIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poolID"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poolID") + } + + protoReq.PoolID, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poolID", err) + } + + msg, err := client.PoolByID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolByID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolByIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poolID"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poolID") + } + + protoReq.PoolID, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poolID", err) + } + + msg, err := server.PoolByID(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1547,6 +1601,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PoolByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PoolByID_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1908,6 +1985,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PoolByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PoolByID_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1943,6 +2040,8 @@ var ( pattern_Query_EstimatePlaceLimitOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"duality", "dex", "estimate_place_limit_order"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_Pool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"duality", "dex", "pool", "pairID", "tickIndex", "fee"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PoolByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"duality", "dex", "pool", "poolID"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1977,4 +2076,6 @@ var ( forward_Query_EstimatePlaceLimitOrder_0 = runtime.ForwardResponseMessage forward_Query_Pool_0 = runtime.ForwardResponseMessage + + forward_Query_PoolByID_0 = runtime.ForwardResponseMessage ) From 8eff2ad74b37c1a10f5cf57fc8574b1528934760 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Tue, 29 Aug 2023 10:48:16 -0700 Subject: [PATCH 11/16] Clarify name for SafeUint64 --- x/dex/keeper/deposit_record.go | 2 +- x/dex/keeper/pool.go | 2 +- x/dex/types/pool.go | 4 ++-- x/dex/types/pool_reserves_key.go | 2 +- x/dex/utils/math.go | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x/dex/keeper/deposit_record.go b/x/dex/keeper/deposit_record.go index c02703716..a94fdddd9 100644 --- a/x/dex/keeper/deposit_record.go +++ b/x/dex/keeper/deposit_record.go @@ -19,7 +19,7 @@ func (k Keeper) GetAllDepositsForAddress(ctx sdk.Context, addr sdk.AccAddress) [ if err != nil { panic("Can't get info for PoolDenom") } - fee := utils.MustSafeUint64(poolParams.Fee) + fee := utils.MustSafeUint64ToInt64(poolParams.Fee) depositRecord := &types.DepositRecord{ PairID: poolParams.PairID, SharesOwned: sharesMaybe.Amount, diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index 297edd6e5..ecda68264 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -67,7 +67,7 @@ func (k Keeper) GetPool( centerTickIndexNormalized int64, fee uint64, ) (*types.Pool, bool) { - feeInt64 := utils.MustSafeUint64(fee) + feeInt64 := utils.MustSafeUint64ToInt64(fee) id0To1 := &types.PoolReservesKey{ TradePairID: types.NewTradePairIDFromMaker(pairID, pairID.Token1), diff --git a/x/dex/types/pool.go b/x/dex/types/pool.go index ebbf6fecb..663a424b7 100644 --- a/x/dex/types/pool.go +++ b/x/dex/types/pool.go @@ -11,7 +11,7 @@ func NewPool( fee uint64, id uint64, ) (*Pool, error) { - feeInt64 := utils.MustSafeUint64(fee) + feeInt64 := utils.MustSafeUint64ToInt64(fee) id0To1 := &PoolReservesKey{ TradePairID: NewTradePairIDFromMaker(pairID, pairID.Token1), @@ -47,7 +47,7 @@ func MustNewPool( } func (p *Pool) CenterTickIndex() int64 { - feeInt64 := utils.MustSafeUint64(p.Fee()) + feeInt64 := utils.MustSafeUint64ToInt64(p.Fee()) return p.UpperTick1.Key.TickIndexTakerToMaker - feeInt64 } diff --git a/x/dex/types/pool_reserves_key.go b/x/dex/types/pool_reserves_key.go index 423d6a93b..383dcb5af 100644 --- a/x/dex/types/pool_reserves_key.go +++ b/x/dex/types/pool_reserves_key.go @@ -65,7 +65,7 @@ func (p PoolReservesKey) KeyUnmarshal(bz []byte) error { } func (p PoolReservesKey) Counterpart() *PoolReservesKey { - feeInt64 := utils.MustSafeUint64(p.Fee) + feeInt64 := utils.MustSafeUint64ToInt64(p.Fee) return &PoolReservesKey{ TradePairID: p.TradePairID.Reversed(), TickIndexTakerToMaker: p.TickIndexTakerToMaker*-1 + 2*feeInt64, diff --git a/x/dex/utils/math.go b/x/dex/utils/math.go index 6d3533778..79e7b1c45 100644 --- a/x/dex/utils/math.go +++ b/x/dex/utils/math.go @@ -84,12 +84,12 @@ func Uint64ToSortableString(i uint64) string { return fmt.Sprintf("%s%s", lenChar, intStr) } -func SafeUint64(in uint64) (out int64, overflow bool) { +func SafeUint64ToInt64(in uint64) (out int64, overflow bool) { return int64(in), in > math.MaxInt64 } -func MustSafeUint64(in uint64) (out int64) { - safeInt64, overflow := SafeUint64(in) +func MustSafeUint64ToInt64(in uint64) (out int64) { + safeInt64, overflow := SafeUint64ToInt64(in) if overflow { panic("Overflow while casting uint64 to int64") } From cbcd2a3b7e01fa54be1cc2ed0e473bc51291bc73 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Wed, 30 Aug 2023 14:07:01 -0700 Subject: [PATCH 12/16] save --- x/dex/types/pool_params.go | 13 +++++++------ x/incentives/types/query_condition_test.go | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/x/dex/types/pool_params.go b/x/dex/types/pool_params.go index 6168422c4..b93ce6f81 100644 --- a/x/dex/types/pool_params.go +++ b/x/dex/types/pool_params.go @@ -10,9 +10,10 @@ type PoolParams struct { PairID *PairID Tick int64 Fee uint64 + PoolID uint64 } -func ParsePoolRefToParams(poolRef []byte) (PoolParams, error) { +func ParsePoolRefToParams(poolID uint64, poolRef []byte) (PoolParams, error) { parts := bytes.Split(poolRef, []byte("/")) if len(parts) != 4 { return PoolParams{}, ErrInvalidPoolDenom @@ -30,17 +31,17 @@ func ParsePoolRefToParams(poolRef []byte) (PoolParams, error) { fee := sdk.BigEndianToUint64(parts[2]) - return PoolParams{PairID: pairID, Tick: tick, Fee: fee}, nil + return PoolParams{PairID: pairID, Tick: tick, Fee: fee, PoolID: poolID}, nil } -func MustParsePoolRefToParams(poolRef []byte) PoolParams { - poolParams, err := ParsePoolRefToParams(poolRef) +func MustParsePoolRefToParams(poolID uint64, poolRef []byte) PoolParams { + poolParams, err := ParsePoolRefToParams(poolID, poolRef) if err != nil { panic("Invalid pool ref") } return poolParams } -func NewPoolParams(pairID *PairID, tick int64, fee uint64) PoolParams { - return PoolParams{PairID: pairID, Tick: tick, Fee: fee} +func NewPoolParams(pairID *PairID, tick int64, fee uint64, poolID uint64) PoolParams { + return PoolParams{PairID: pairID, Tick: tick, Fee: fee, PoolID: poolID} } diff --git a/x/incentives/types/query_condition_test.go b/x/incentives/types/query_condition_test.go index 2a3155b9c..b5e4a58d5 100644 --- a/x/incentives/types/query_condition_test.go +++ b/x/incentives/types/query_condition_test.go @@ -24,31 +24,31 @@ func TestQueryCondition(t *testing.T) { { name: "Matching denom and tick range", queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - poolParams: dextypes.NewPoolParams(pairID, 15, 5), + poolParams: dextypes.NewPoolParams(pairID, 15, 5, 0), testResult: true, }, { name: "Non-matching denom", queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - poolParams: dextypes.NewPoolParams(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 5), + poolParams: dextypes.NewPoolParams(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 5, 0), testResult: false, }, { name: "Non-matching tick range", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolParams: dextypes.NewPoolParams(pairID, 15, 6), + poolParams: dextypes.NewPoolParams(pairID, 15, 6, 0), testResult: false, }, { name: "Non-matching tick fee range lower", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolParams: dextypes.NewPoolParams(pairID, 10, 5), + poolParams: dextypes.NewPoolParams(pairID, 10, 5, 0), testResult: false, }, { name: "Non-matching tick fee range upper", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolParams: dextypes.NewPoolParams(pairID, 20, 5), + poolParams: dextypes.NewPoolParams(pairID, 20, 5, 0), testResult: false, }, } From 878e768e394b664848485ed8818abe2ca87e07fd Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Thu, 31 Aug 2023 19:41:42 -0700 Subject: [PATCH 13/16] Cleaner poolMetadata storage --- proto/duality/dex/genesis.proto | 15 +- proto/duality/dex/pool_metadata.proto | 13 + proto/duality/dex/query.proto | 402 +++--- x/dex/client/cli/query.go | 2 + x/dex/client/cli/query_pool_metadata.go | 82 ++ x/dex/genesis.go | 9 + x/dex/genesis_test.go | 11 + x/dex/keeper/core.go | 8 +- x/dex/keeper/deposit_record.go | 14 +- x/dex/keeper/grpc_query_pool_metadata.go | 54 + x/dex/keeper/grpc_query_pool_metadata_test.go | 118 ++ x/dex/keeper/grpc_query_pool_test.go | 16 +- x/dex/keeper/pool.go | 86 +- x/dex/keeper/pool_metadata.go | 76 ++ x/dex/keeper/pool_metadata_test.go | 54 + x/dex/keeper/pool_reserves_test.go | 31 - x/dex/keeper/pool_test.go | 66 + x/dex/types/genesis.go | 13 + x/dex/types/genesis.pb.go | 147 +- x/dex/types/genesis_test.go | 35 + x/dex/types/keys.go | 9 +- x/dex/types/pool_metadata.go | 5 + x/dex/types/pool_metadata.pb.go | 432 ++++++ x/dex/types/pool_params.go | 47 - x/dex/types/query.pb.go | 1184 ++++++++++++++--- x/dex/types/query.pb.gw.go | 184 +++ x/incentives/keeper/distribute.go | 12 +- x/incentives/keeper/query_server.go | 10 +- x/incentives/keeper/stake.go | 4 +- x/incentives/keeper/stake_refs.go | 6 +- x/incentives/types/expected_keepers.go | 2 +- x/incentives/types/query_condition.go | 8 +- x/incentives/types/query_condition_test.go | 14 +- 33 files changed, 2567 insertions(+), 602 deletions(-) create mode 100644 proto/duality/dex/pool_metadata.proto create mode 100644 x/dex/client/cli/query_pool_metadata.go create mode 100644 x/dex/keeper/grpc_query_pool_metadata.go create mode 100644 x/dex/keeper/grpc_query_pool_metadata_test.go create mode 100644 x/dex/keeper/pool_metadata.go create mode 100644 x/dex/keeper/pool_metadata_test.go create mode 100644 x/dex/types/pool_metadata.go create mode 100644 x/dex/types/pool_metadata.pb.go delete mode 100644 x/dex/types/pool_params.go diff --git a/proto/duality/dex/genesis.proto b/proto/duality/dex/genesis.proto index 314f6a20f..3301d5555 100644 --- a/proto/duality/dex/genesis.proto +++ b/proto/duality/dex/genesis.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package duality.dex; import "gogoproto/gogo.proto"; @@ -6,17 +7,21 @@ import "duality/dex/params.proto"; import "duality/dex/limit_order_tranche_user.proto"; import "duality/dex/limit_order_tranche.proto"; import "duality/dex/tick_liquidity.proto"; +import "duality/dex/pool_metadata.proto"; + // this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/duality-labs/duality/x/dex/types"; // GenesisState defines the dex module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; - repeated TickLiquidity tickLiquidityList = 2 [(gogoproto.nullable) = true]; - repeated LimitOrderTranche inactiveLimitOrderTrancheList = 6 [(gogoproto.nullable) = true]; - repeated LimitOrderTrancheUser limitOrderTrancheUserList = 7 [(gogoproto.nullable) = true]; - + Params params = 1 [(gogoproto.nullable) = false]; + repeated TickLiquidity tickLiquidityList = 2 [(gogoproto.nullable) = true ]; + repeated LimitOrderTranche inactiveLimitOrderTrancheList = 6 [(gogoproto.nullable) = true ]; + repeated LimitOrderTrancheUser limitOrderTrancheUserList = 7 [(gogoproto.nullable) = true ]; // this line is used by starport scaffolding # genesis/proto/state + repeated PoolMetadata poolMetadataList = 8 [(gogoproto.nullable) = false]; + uint64 poolCount = 9; } + diff --git a/proto/duality/dex/pool_metadata.proto b/proto/duality/dex/pool_metadata.proto new file mode 100644 index 000000000..80e91b371 --- /dev/null +++ b/proto/duality/dex/pool_metadata.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package duality.dex; + +option go_package = "github.com/duality-labs/duality/x/dex/types"; + +import "duality/dex/pair_id.proto"; + +message PoolMetadata { + uint64 ID = 1; + int64 tick = 2; + uint64 fee = 3; + PairID pairID = 4; +} diff --git a/proto/duality/dex/query.proto b/proto/duality/dex/query.proto index eb0269a9c..2606afb1a 100644 --- a/proto/duality/dex/query.proto +++ b/proto/duality/dex/query.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package duality.dex; import "gogoproto/gogo.proto"; @@ -15,6 +16,7 @@ import "duality/dex/tx.proto"; import "cosmos/base/v1beta1/coin.proto"; import "google/protobuf/timestamp.proto"; import "duality/dex/pool.proto"; +import "duality/dex/pool_metadata.proto"; // this line is used by starport scaffolding # 1 @@ -22,142 +24,169 @@ option go_package = "github.com/duality-labs/duality/x/dex/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/duality/dex/params"; - } - - // Queries a LimitOrderTrancheUser by index. - rpc LimitOrderTrancheUser(QueryGetLimitOrderTrancheUserRequest) returns (QueryGetLimitOrderTrancheUserResponse) { - option (google.api.http).get = "/duality/dex/limit_order_tranche_user/{address}/{trancheKey}"; - } - - // Queries a list of LimitOrderTrancheMap items. - rpc LimitOrderTrancheUserAll(QueryAllLimitOrderTrancheUserRequest) returns (QueryAllLimitOrderTrancheUserResponse) { - option (google.api.http).get = "/duality/dex/limit_order_tranche_user"; - } - - // Queries a LimitOrderTranche by index. - rpc LimitOrderTranche(QueryGetLimitOrderTrancheRequest) returns (QueryGetLimitOrderTrancheResponse) { - option (google.api.http).get = "/duality/dex/limit_order_tranche/{pairID}/{tokenIn}/{tickIndex}/{trancheKey}"; - } - - // Queries a list of LimitOrderTranche items for a given pairID / TokenIn combination. - rpc LimitOrderTrancheAll(QueryAllLimitOrderTrancheRequest) returns (QueryAllLimitOrderTrancheResponse) { - option (google.api.http).get = "/duality/dex/limit_order_tranche/{pairID}/{tokenIn}"; - } - - // Queries a list of GetUserPositions items. - rpc GetUserPositions(QueryGetUserPositionsRequest) returns (QueryGetUserPositionsResponse) { - option (google.api.http).get = "/duality/dex/user/positions/{address}"; - } - - // Queries a list of UserDeposits items. - rpc UserDepositsAll(QueryAllUserDepositsRequest) returns (QueryAllUserDepositsResponse) { - option (google.api.http).get = "/duality/dex/user/deposits/{address}"; - } - - // Queries a list of UserLimitOrders items. - rpc UserLimitOrdersAll(QueryAllUserLimitOrdersRequest) returns (QueryAllUserLimitOrdersResponse) { - option (google.api.http).get = "/duality/dex/user/limit_orders/{address}"; - } - - // Queries a list of TickLiquidity items. - rpc TickLiquidityAll(QueryAllTickLiquidityRequest) returns (QueryAllTickLiquidityResponse) { - option (google.api.http).get = "/duality/dex/tick_liquidity/{pairID}/{tokenIn}"; - } - - // Queries a InactiveLimitOrderTranche by index. - rpc InactiveLimitOrderTranche(QueryGetInactiveLimitOrderTrancheRequest) returns (QueryGetInactiveLimitOrderTrancheResponse) { - option (google.api.http).get = "/duality/dex/filled_limit_order_tranche/{pairID}/{tokenIn}/{tickIndex}/{trancheKey}"; - } - - // Queries a list of InactiveLimitOrderTranche items. - rpc InactiveLimitOrderTrancheAll(QueryAllInactiveLimitOrderTrancheRequest) returns (QueryAllInactiveLimitOrderTrancheResponse) { - option (google.api.http).get = "/duality/dex/filled_limit_order_tranche"; - } - - // Queries a list of PoolReserves items. - rpc PoolReservesAll(QueryAllPoolReservesRequest) returns (QueryAllPoolReservesResponse) { - option (google.api.http).get = "/duality/dex/pool_reserves/{pairID}/{tokenIn}"; - } - - // Queries a PoolReserve by index - rpc PoolReserves(QueryGetPoolReservesRequest) returns (QueryGetPoolReservesResponse) { - option (google.api.http).get = "/duality/dex/pool_reserves/{pairID}/{tokenIn}/{tickIndex}/{fee}"; - } - - // Queries the simulated result of a multihop swap - rpc EstimateMultiHopSwap(QueryEstimateMultiHopSwapRequest) returns (QueryEstimateMultiHopSwapResponse) { - option (google.api.http).get = "/duality/dex/estimate_multi_hop_swap"; - } - - // Queries the simulated result of a multihop swap - rpc EstimatePlaceLimitOrder(QueryEstimatePlaceLimitOrderRequest) returns (QueryEstimatePlaceLimitOrderResponse) { - option (google.api.http).get = "/duality/dex/estimate_place_limit_order"; - } - - // Queries a pool by pair, tick and fee - rpc Pool(QueryPoolRequest) returns (QueryPoolResponse) { - option (google.api.http).get = "/duality/dex/pool/{pairID}/{tickIndex}/{fee}"; - } - + + // Parameters queries the parameters of the module. + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/duality/dex/params"; + + } + + // Queries a LimitOrderTrancheUser by index. + rpc LimitOrderTrancheUser (QueryGetLimitOrderTrancheUserRequest) returns (QueryGetLimitOrderTrancheUserResponse) { + option (google.api.http).get = "/duality/dex/limit_order_tranche_user/{address}/{trancheKey}"; + + } + + // Queries a list of LimitOrderTrancheMap items. + rpc LimitOrderTrancheUserAll (QueryAllLimitOrderTrancheUserRequest) returns (QueryAllLimitOrderTrancheUserResponse) { + option (google.api.http).get = "/duality/dex/limit_order_tranche_user"; + + } + + // Queries a LimitOrderTranche by index. + rpc LimitOrderTranche (QueryGetLimitOrderTrancheRequest) returns (QueryGetLimitOrderTrancheResponse) { + option (google.api.http).get = "/duality/dex/limit_order_tranche/{pairID}/{tokenIn}/{tickIndex}/{trancheKey}"; + + } + + // Queries a list of LimitOrderTranche items for a given pairID / TokenIn combination. + rpc LimitOrderTrancheAll (QueryAllLimitOrderTrancheRequest) returns (QueryAllLimitOrderTrancheResponse) { + option (google.api.http).get = "/duality/dex/limit_order_tranche/{pairID}/{tokenIn}"; + + } + + // Queries a list of GetUserPositions items. + rpc GetUserPositions (QueryGetUserPositionsRequest) returns (QueryGetUserPositionsResponse) { + option (google.api.http).get = "/duality/dex/user/positions/{address}"; + + } + + // Queries a list of UserDeposits items. + rpc UserDepositsAll (QueryAllUserDepositsRequest) returns (QueryAllUserDepositsResponse) { + option (google.api.http).get = "/duality/dex/user/deposits/{address}"; + + } + + // Queries a list of UserLimitOrders items. + rpc UserLimitOrdersAll (QueryAllUserLimitOrdersRequest) returns (QueryAllUserLimitOrdersResponse) { + option (google.api.http).get = "/duality/dex/user/limit_orders/{address}"; + + } + + // Queries a list of TickLiquidity items. + rpc TickLiquidityAll (QueryAllTickLiquidityRequest) returns (QueryAllTickLiquidityResponse) { + option (google.api.http).get = "/duality/dex/tick_liquidity/{pairID}/{tokenIn}"; + + } + + // Queries a InactiveLimitOrderTranche by index. + rpc InactiveLimitOrderTranche (QueryGetInactiveLimitOrderTrancheRequest) returns (QueryGetInactiveLimitOrderTrancheResponse) { + option (google.api.http).get = "/duality/dex/filled_limit_order_tranche/{pairID}/{tokenIn}/{tickIndex}/{trancheKey}"; + + } + + // Queries a list of InactiveLimitOrderTranche items. + rpc InactiveLimitOrderTrancheAll (QueryAllInactiveLimitOrderTrancheRequest) returns (QueryAllInactiveLimitOrderTrancheResponse) { + option (google.api.http).get = "/duality/dex/filled_limit_order_tranche"; + + } + + // Queries a list of PoolReserves items. + rpc PoolReservesAll (QueryAllPoolReservesRequest) returns (QueryAllPoolReservesResponse) { + option (google.api.http).get = "/duality/dex/pool_reserves/{pairID}/{tokenIn}"; + + } + + // Queries a PoolReserve by index + rpc PoolReserves (QueryGetPoolReservesRequest) returns (QueryGetPoolReservesResponse) { + option (google.api.http).get = "/duality/dex/pool_reserves/{pairID}/{tokenIn}/{tickIndex}/{fee}"; + + } + + // Queries the simulated result of a multihop swap + rpc EstimateMultiHopSwap (QueryEstimateMultiHopSwapRequest) returns (QueryEstimateMultiHopSwapResponse) { + option (google.api.http).get = "/duality/dex/estimate_multi_hop_swap"; + + } + + // Queries the simulated result of a multihop swap + rpc EstimatePlaceLimitOrder (QueryEstimatePlaceLimitOrderRequest) returns (QueryEstimatePlaceLimitOrderResponse) { + option (google.api.http).get = "/duality/dex/estimate_place_limit_order"; + + } + + // Queries a pool by pair, tick and fee + rpc Pool (QueryPoolRequest) returns (QueryPoolResponse) { + option (google.api.http).get = "/duality/dex/pool/{pairID}/{tickIndex}/{fee}"; + + } + // Queries a pool by ID - rpc PoolByID(QueryPoolByIDRequest) returns (QueryPoolResponse) { - option (google.api.http).get = "/duality/dex/pool/{poolID}"; - } - -// this line is used by starport scaffolding # 2 + rpc PoolByID (QueryPoolByIDRequest) returns (QueryPoolResponse) { + option (google.api.http).get = "/duality/dex/pool/{poolID}"; + + } + + // this line is used by starport scaffolding # 2 + + // Queries a list of PoolMetadata items. + rpc PoolMetadata (QueryGetPoolMetadataRequest) returns (QueryGetPoolMetadataResponse) { + option (google.api.http).get = "/duality-labs/duality/dex/pool_metadata/{id}"; + + } + rpc PoolMetadataAll (QueryAllPoolMetadataRequest) returns (QueryAllPoolMetadataResponse) { + option (google.api.http).get = "/duality-labs/duality/dex/pool_metadata"; + + } } - // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { + // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = true]; } message QueryGetLimitOrderTrancheUserRequest { - string address = 1; + string address = 1; string trancheKey = 2; } message QueryGetLimitOrderTrancheUserResponse { - LimitOrderTrancheUser LimitOrderTrancheUser = 1 [(gogoproto.nullable) = true]; + LimitOrderTrancheUser LimitOrderTrancheUser = 1 [(gogoproto.nullable) = true]; } message QueryAllLimitOrderTrancheUserRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 1; } message QueryAllLimitOrderTrancheUserResponse { - repeated LimitOrderTrancheUser LimitOrderTrancheUser = 1 [(gogoproto.nullable) = true]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated LimitOrderTrancheUser LimitOrderTrancheUser = 1 [(gogoproto.nullable) = true]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryGetLimitOrderTrancheRequest { - string pairID = 1; - int64 tickIndex =2; - string tokenIn = 3; + string pairID = 1; + int64 tickIndex = 2; + string tokenIn = 3; string trancheKey = 4; - } message QueryGetLimitOrderTrancheResponse { - LimitOrderTranche LimitOrderTranche = 1 [(gogoproto.nullable) = true]; + LimitOrderTranche LimitOrderTranche = 1 [(gogoproto.nullable) = true]; } message QueryAllLimitOrderTrancheRequest { - string pairID = 1; - string tokenIn = 2; - cosmos.base.query.v1beta1.PageRequest pagination = 3; + string pairID = 1; + string tokenIn = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; } message QueryAllLimitOrderTrancheResponse { - repeated LimitOrderTranche LimitOrderTranche = 1 [(gogoproto.nullable) = true]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated LimitOrderTranche LimitOrderTranche = 1 [(gogoproto.nullable) = true]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryGetUserPositionsRequest { @@ -185,150 +214,107 @@ message QueryAllUserLimitOrdersResponse { } message QueryAllTickLiquidityRequest { - string pairID = 1; - string tokenIn = 2; - cosmos.base.query.v1beta1.PageRequest pagination = 3; + string pairID = 1; + string tokenIn = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; } message QueryAllTickLiquidityResponse { - repeated TickLiquidity tickLiquidity = 1 [(gogoproto.nullable) = true]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated TickLiquidity tickLiquidity = 1 [(gogoproto.nullable) = true]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryGetInactiveLimitOrderTrancheRequest { - string pairID = 1; - string tokenIn = 2; - int64 tickIndex = 3; + string pairID = 1; + string tokenIn = 2; + int64 tickIndex = 3; string trancheKey = 4; - } message QueryGetInactiveLimitOrderTrancheResponse { - LimitOrderTranche inactiveLimitOrderTranche = 1 [(gogoproto.nullable) = true]; + LimitOrderTranche inactiveLimitOrderTranche = 1 [(gogoproto.nullable) = true]; } message QueryAllInactiveLimitOrderTrancheRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 1; } message QueryAllInactiveLimitOrderTrancheResponse { - repeated LimitOrderTranche inactiveLimitOrderTranche = 1 [(gogoproto.nullable) = true]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated LimitOrderTranche inactiveLimitOrderTranche = 1 [(gogoproto.nullable) = true]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryAllPoolReservesRequest { - string pairID = 1; - string tokenIn = 2; -cosmos.base.query.v1beta1.PageRequest pagination = 3; + string pairID = 1; + string tokenIn = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; } message QueryAllPoolReservesResponse { - repeated PoolReserves poolReserves = 1 [(gogoproto.nullable) = true]; -cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated PoolReserves poolReserves = 1 [(gogoproto.nullable) = true]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryGetPoolReservesRequest { - string pairID = 1; - string tokenIn = 2; - int64 tickIndex =3; - uint64 fee = 4; - + string pairID = 1; + string tokenIn = 2; + int64 tickIndex = 3; + uint64 fee = 4; } message QueryGetPoolReservesResponse { - PoolReserves poolReserves = 1 [(gogoproto.nullable) = true]; + PoolReserves poolReserves = 1 [(gogoproto.nullable) = true]; } message QueryEstimateMultiHopSwapRequest { - string creator = 1; - string receiver = 2; - repeated MultiHopRoute routes = 3; - string amountIn = 4 [ - (gogoproto.moretags) = "yaml:\"amountIn\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "amountIn" - ]; - string exitLimitPrice = 5 [ - (gogoproto.moretags) = "yaml:\"exitLimitPrice\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "exitLimitPrice" - ]; + string creator = 1; + string receiver = 2; + repeated MultiHopRoute routes = 3; + string amountIn = 4 [(gogoproto.moretags) = "yaml:\"amountIn\"" , (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false, (gogoproto.jsontag) = "amountIn" ]; + string exitLimitPrice = 5 [(gogoproto.moretags) = "yaml:\"exitLimitPrice\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.jsontag) = "exitLimitPrice"]; + // If pickBestRoute == true then all routes are run and the route with the best price is chosen // otherwise, the first succesful route is used. bool pickBestRoute = 6; } message QueryEstimateMultiHopSwapResponse { - cosmos.base.v1beta1.Coin coinOut = 1 [ - (gogoproto.nullable) = false, - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.jsontag) = "coinOut" - ]; + cosmos.base.v1beta1.Coin coinOut = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.jsontag) = "coinOut"]; } message QueryEstimatePlaceLimitOrderRequest { - string creator = 1; - string receiver = 2; - string tokenIn = 3; - string tokenOut = 4; - int64 tickIndexInToOut = 5; - string amountIn = 6 [ - (gogoproto.moretags) = "yaml:\"amountIn\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "amountIn" - ]; - LimitOrderType orderType = 7; + string creator = 1; + string receiver = 2; + string tokenIn = 3; + string tokenOut = 4; + int64 tickIndexInToOut = 5; + string amountIn = 6 [(gogoproto.moretags) = "yaml:\"amountIn\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false, (gogoproto.jsontag) = "amountIn"]; + LimitOrderType orderType = 7; + // expirationTime is only valid iff orderType == GOOD_TIL_TIME. - google.protobuf.Timestamp expirationTime = 8 [ - (gogoproto.stdtime) = true, - (gogoproto.nullable) = true - ]; - string maxAmountOut = 9 [ - (gogoproto.moretags) = "yaml:\"maxAmountOut\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = true, - (gogoproto.jsontag) = "maxAmountOut" - ]; + google.protobuf.Timestamp expirationTime = 8 [(gogoproto.stdtime) = true , (gogoproto.nullable) = true ] ; + string maxAmountOut = 9 [(gogoproto.moretags) = "yaml:\"maxAmountOut\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = true, (gogoproto.jsontag) = "maxAmountOut"]; } message QueryEstimatePlaceLimitOrderResponse { - - // Total amount of coin used for the limit order - // You can derive makerLimitInCoin using the equation: totalInCoin = swapInCoin + makerLimitInCoin - cosmos.base.v1beta1.Coin totalInCoin = 1 [ - (gogoproto.moretags) = "yaml:\"totalInCoin\"", - (gogoproto.nullable) = false, - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.jsontag) = "totalInCoin" - ]; - - // Total amount of the token in that was immediately swapped for swapOutCoin - cosmos.base.v1beta1.Coin swapInCoin = 2 [ - (gogoproto.moretags) = "yaml:\"swapInCoin\"", - (gogoproto.nullable) = false, - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.jsontag) = "swapInCoin" - ]; - - // Total amount of coin received from the taker portion of the limit order - // This is the amount of coin immediately available in the users account after executing the - // limit order. It does not include any future proceeds from the maker portion which will have withdrawn in the future - cosmos.base.v1beta1.Coin swapOutCoin = 3 [ - (gogoproto.moretags) = "yaml:\"swapOutCoin\"", - (gogoproto.nullable) = false, - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.jsontag) = "swapOutCoin" - ]; + + // Total amount of coin used for the limit order + // You can derive makerLimitInCoin using the equation: totalInCoin = swapInCoin + makerLimitInCoin + cosmos.base.v1beta1.Coin totalInCoin = 1 [(gogoproto.moretags) = "yaml:\"totalInCoin\"", (gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.jsontag) = "totalInCoin"]; + + // Total amount of the token in that was immediately swapped for swapOutCoin + cosmos.base.v1beta1.Coin swapInCoin = 2 [(gogoproto.moretags) = "yaml:\"swapInCoin\"", (gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.jsontag) = "swapInCoin"]; + + // Total amount of coin received from the taker portion of the limit order + // This is the amount of coin immediately available in the users account after executing the + // limit order. It does not include any future proceeds from the maker portion which will have withdrawn in the future + cosmos.base.v1beta1.Coin swapOutCoin = 3 [(gogoproto.moretags) = "yaml:\"swapOutCoin\"", (gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.jsontag) = "swapOutCoin"]; } message QueryPoolRequest { - string pairID = 1; - int64 tickIndex = 2; - uint64 fee = 3; - + string pairID = 1; + int64 tickIndex = 2; + uint64 fee = 3; } message QueryPoolByIDRequest { @@ -336,7 +322,25 @@ message QueryPoolByIDRequest { } message QueryPoolResponse { - Pool pool = 1 [(gogoproto.nullable) = true]; + Pool pool = 1 [(gogoproto.nullable) = true]; } + // this line is used by starport scaffolding # 3 +message QueryGetPoolMetadataRequest { + uint64 id = 1; +} + +message QueryGetPoolMetadataResponse { + PoolMetadata PoolMetadata = 1 [(gogoproto.nullable) = false]; +} + +message QueryAllPoolMetadataRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllPoolMetadataResponse { + repeated PoolMetadata PoolMetadata = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + diff --git a/x/dex/client/cli/query.go b/x/dex/client/cli/query.go index a8bb670c4..69d2774da 100644 --- a/x/dex/client/cli/query.go +++ b/x/dex/client/cli/query.go @@ -43,6 +43,8 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdShowPool()) cmd.AddCommand(CmdShowPoolByID()) + cmd.AddCommand(CmdListPoolMetadata()) + cmd.AddCommand(CmdShowPoolMetadata()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/dex/client/cli/query_pool_metadata.go b/x/dex/client/cli/query_pool_metadata.go new file mode 100644 index 000000000..ff511132a --- /dev/null +++ b/x/dex/client/cli/query_pool_metadata.go @@ -0,0 +1,82 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/duality-labs/duality/x/dex/types" + "github.com/spf13/cobra" +) + +func CmdListPoolMetadata() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-pool-metadata", + Short: "list all PoolMetadata", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllPoolMetadataRequest{ + Pagination: pageReq, + } + + res, err := queryClient.PoolMetadataAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowPoolMetadata() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-pool-metadata [id]", + Short: "shows a PoolMetadata", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + id, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + params := &types.QueryGetPoolMetadataRequest{ + Id: id, + } + + res, err := queryClient.PoolMetadata(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dex/genesis.go b/x/dex/genesis.go index 7dbed7b62..0b33c4a80 100644 --- a/x/dex/genesis.go +++ b/x/dex/genesis.go @@ -28,6 +28,13 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.LimitOrderTrancheUserList { k.SetLimitOrderTrancheUser(ctx, elem) } + // Set all the poolMetadata + for _, elem := range genState.PoolMetadataList { + k.SetPoolMetadata(ctx, elem) + } + + // Set poolMetadata count + k.SetPoolCount(ctx, genState.PoolCount) // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, &genState.Params) } @@ -39,6 +46,8 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.LimitOrderTrancheUserList = k.GetAllLimitOrderTrancheUser(ctx) genesis.TickLiquidityList = k.GetAllTickLiquidity(ctx) genesis.InactiveLimitOrderTrancheList = k.GetAllInactiveLimitOrderTranche(ctx) + genesis.PoolMetadataList = k.GetAllPoolMetadata(ctx) + genesis.PoolCount = k.GetPoolCount(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/dex/genesis_test.go b/x/dex/genesis_test.go index 928e51c3b..3083e0129 100644 --- a/x/dex/genesis_test.go +++ b/x/dex/genesis_test.go @@ -92,6 +92,15 @@ func TestGenesis(t *testing.T) { }, }, }, + PoolMetadataList: []types.PoolMetadata{ + { + ID: 0, + }, + { + ID: 1, + }, + }, + PoolCount: 2, // this line is used by starport scaffolding # genesis/test/state } @@ -110,5 +119,7 @@ func TestGenesis(t *testing.T) { genesisState.InactiveLimitOrderTrancheList, got.InactiveLimitOrderTrancheList, ) + require.ElementsMatch(t, genesisState.PoolMetadataList, got.PoolMetadataList) + require.Equal(t, genesisState.PoolCount, got.PoolCount) // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/dex/keeper/core.go b/x/dex/keeper/core.go index 12ea961fd..dc8bee698 100644 --- a/x/dex/keeper/core.go +++ b/x/dex/keeper/core.go @@ -136,16 +136,16 @@ func (k Keeper) WithdrawCore( return err } - poolSharesDenom := pool.GetPoolDenom() - totalShares := k.bankKeeper.GetSupply(ctx, poolSharesDenom).Amount + poolDenom := pool.GetPoolDenom() + totalShares := k.bankKeeper.GetSupply(ctx, poolDenom).Amount if totalShares.LT(sharesToRemove) { return sdkerrors.Wrapf( types.ErrInsufficientShares, "%s does not have %s shares of type %s", callerAddr, sharesToRemove, - poolSharesDenom, + poolDenom, ) } @@ -153,7 +153,7 @@ func (k Keeper) WithdrawCore( k.SetPool(ctx, pool) if sharesToRemove.IsPositive() { - if err := k.BurnShares(ctx, callerAddr, sharesToRemove, poolSharesDenom); err != nil { + if err := k.BurnShares(ctx, callerAddr, sharesToRemove, poolDenom); err != nil { return err } } diff --git a/x/dex/keeper/deposit_record.go b/x/dex/keeper/deposit_record.go index a94fdddd9..8b7aeaf9c 100644 --- a/x/dex/keeper/deposit_record.go +++ b/x/dex/keeper/deposit_record.go @@ -15,18 +15,18 @@ func (k Keeper) GetAllDepositsForAddress(ctx sdk.Context, addr sdk.AccAddress) [ return false } - poolParams, err := k.GetPoolParamsByDenom(ctx, sharesMaybe.Denom) + poolMetadata, err := k.GetPoolMetadataByDenom(ctx, sharesMaybe.Denom) if err != nil { panic("Can't get info for PoolDenom") } - fee := utils.MustSafeUint64ToInt64(poolParams.Fee) + fee := utils.MustSafeUint64ToInt64(poolMetadata.Fee) depositRecord := &types.DepositRecord{ - PairID: poolParams.PairID, + PairID: poolMetadata.PairID, SharesOwned: sharesMaybe.Amount, - CenterTickIndex: poolParams.Tick, - LowerTickIndex: poolParams.Tick - fee, - UpperTickIndex: poolParams.Tick + fee, - Fee: poolParams.Fee, + CenterTickIndex: poolMetadata.Tick, + LowerTickIndex: poolMetadata.Tick - fee, + UpperTickIndex: poolMetadata.Tick + fee, + Fee: poolMetadata.Fee, } depositArr = append(depositArr, depositRecord) diff --git a/x/dex/keeper/grpc_query_pool_metadata.go b/x/dex/keeper/grpc_query_pool_metadata.go new file mode 100644 index 000000000..dc2a6c0ad --- /dev/null +++ b/x/dex/keeper/grpc_query_pool_metadata.go @@ -0,0 +1,54 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/duality-labs/duality/x/dex/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) PoolMetadataAll(goCtx context.Context, req *types.QueryAllPoolMetadataRequest) (*types.QueryAllPoolMetadataResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var poolMetadatas []types.PoolMetadata + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + poolMetadataStore := prefix.NewStore(store, types.KeyPrefix(types.PoolMetadataKeyPrefix)) + + pageRes, err := query.Paginate(poolMetadataStore, req.Pagination, func(key []byte, value []byte) error { + var poolMetadata types.PoolMetadata + if err := k.cdc.Unmarshal(value, &poolMetadata); err != nil { + return err + } + + poolMetadatas = append(poolMetadatas, poolMetadata) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllPoolMetadataResponse{PoolMetadata: poolMetadatas, Pagination: pageRes}, nil +} + +func (k Keeper) PoolMetadata(goCtx context.Context, req *types.QueryGetPoolMetadataRequest) (*types.QueryGetPoolMetadataResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + poolMetadata, found := k.GetPoolMetadata(ctx, req.Id) + if !found { + return nil, sdkerrors.ErrKeyNotFound + } + + return &types.QueryGetPoolMetadataResponse{PoolMetadata: poolMetadata}, nil +} diff --git a/x/dex/keeper/grpc_query_pool_metadata_test.go b/x/dex/keeper/grpc_query_pool_metadata_test.go new file mode 100644 index 000000000..fb50489e5 --- /dev/null +++ b/x/dex/keeper/grpc_query_pool_metadata_test.go @@ -0,0 +1,118 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/duality-labs/duality/testutil/keeper" + "github.com/duality-labs/duality/testutil/nullify" + "github.com/duality-labs/duality/x/dex/types" +) + +func TestPoolMetadataQuerySingle(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNPoolMetadata(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryGetPoolMetadataRequest + response *types.QueryGetPoolMetadataResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetPoolMetadataRequest{Id: msgs[0].ID}, + response: &types.QueryGetPoolMetadataResponse{PoolMetadata: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetPoolMetadataRequest{Id: msgs[1].ID}, + response: &types.QueryGetPoolMetadataResponse{PoolMetadata: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetPoolMetadataRequest{Id: uint64(len(msgs))}, + err: sdkerrors.ErrKeyNotFound, + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.PoolMetadata(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestPoolMetadataQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNPoolMetadata(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllPoolMetadataRequest { + return &types.QueryAllPoolMetadataRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.PoolMetadataAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.PoolMetadata), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.PoolMetadata), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.PoolMetadataAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.PoolMetadata), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.PoolMetadata), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.PoolMetadataAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.PoolMetadata), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.PoolMetadataAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/dex/keeper/grpc_query_pool_test.go b/x/dex/keeper/grpc_query_pool_test.go index 207bb31b1..dcbfcda8c 100644 --- a/x/dex/keeper/grpc_query_pool_test.go +++ b/x/dex/keeper/grpc_query_pool_test.go @@ -27,19 +27,19 @@ func TestPoolQuerySingle(t *testing.T) { desc: "First", request: &types.QueryPoolRequest{ PairID: "TokenA<>TokenB", - TickIndex: msgs[0].TickIndex, - Fee: msgs[0].Fee, + TickIndex: msgs[0].CenterTickIndex(), + Fee: msgs[0].Fee(), }, - response: &types.QueryPoolResponse{Pool: msgs[0].Pool}, + response: &types.QueryPoolResponse{Pool: msgs[0]}, }, { desc: "Second", request: &types.QueryPoolRequest{ PairID: "TokenA<>TokenB", - TickIndex: msgs[1].TickIndex, - Fee: msgs[1].Fee, + TickIndex: msgs[1].CenterTickIndex(), + Fee: msgs[1].Fee(), }, - response: &types.QueryPoolResponse{Pool: msgs[1].Pool}, + response: &types.QueryPoolResponse{Pool: msgs[1]}, }, { desc: "KeyNotFound", @@ -85,14 +85,14 @@ func TestPoolQueryByID(t *testing.T) { request: &types.QueryPoolByIDRequest{ PoolID: 0, }, - response: &types.QueryPoolResponse{Pool: msgs[0].Pool}, + response: &types.QueryPoolResponse{Pool: msgs[0]}, }, { desc: "Second", request: &types.QueryPoolByIDRequest{ PoolID: 1, }, - response: &types.QueryPoolResponse{Pool: msgs[1].Pool}, + response: &types.QueryPoolResponse{Pool: msgs[1]}, }, { desc: "KeyNotFound", diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index ecda68264..5e26294bd 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -28,32 +28,27 @@ func (k Keeper) InitPool( pairID *types.PairID, centerTickIndexNormalized int64, fee uint64, -) (*types.Pool, error) { - poolID := k.InitPoolKeys(ctx, pairID, centerTickIndexNormalized, fee) - return types.NewPool(pairID, centerTickIndexNormalized, fee, poolID) -} - -func (k Keeper) InitPoolKeys(ctx sdk.Context, - pairID *types.PairID, - centerTickIndexNormalized int64, - fee uint64, -) uint64 { - poolKeyBz := types.PoolKey(*pairID, centerTickIndexNormalized, fee) +) (pool *types.Pool, err error) { + poolMetadata := types.PoolMetadata{PairID: pairID, Tick: centerTickIndexNormalized, Fee: fee} - poolID := k.GetNextPoolID(ctx) - poolIDBz := sdk.Uint64ToBigEndian(poolID) + // Get current pool poolID + poolID := k.GetPoolCount(ctx) + poolMetadata.ID = poolID - k.SetPoolCount(ctx, poolID+1) + // Store poolMetadata + k.SetPoolMetadata(ctx, poolMetadata) - store := ctx.KVStore(k.storeKey) + // Create a reference so poolID can be looked up by poolMetadata + poolIDBz := sdk.Uint64ToBigEndian(poolID) + poolIDKey := types.PoolIDKey(pairID, centerTickIndexNormalized, fee) - poolIDStore := prefix.NewStore(store, types.KeyPrefix(types.PoolIDKeyPrefix)) - poolIDStore.Set(poolKeyBz, poolIDBz) + poolIDStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolIDKeyPrefix)) + poolIDStore.Set(poolIDKey, poolIDBz) - poolRefStore := prefix.NewStore(store, types.KeyPrefix(types.PoolRefKeyPrefix)) - poolRefStore.Set(poolIDBz, poolKeyBz) + // Update poolCount + k.SetPoolCount(ctx, poolID+1) - return poolID + return types.NewPool(pairID, centerTickIndexNormalized, fee, poolID) } // GetNextPoolId get ID for the next pool to be created @@ -100,12 +95,12 @@ func (k Keeper) GetPool( } func (k Keeper) GetPoolByID(ctx sdk.Context, poolID uint64) (pool *types.Pool, found bool) { - poolParams, found := k.GetPoolParamsByID(ctx, poolID) + poolMetadata, found := k.GetPoolMetadata(ctx, poolID) if !found { return pool, false } - return k.GetPool(ctx, poolParams.PairID, poolParams.Tick, poolParams.Fee) + return k.GetPool(ctx, poolMetadata.PairID, poolMetadata.Tick, poolMetadata.Fee) } // GetPoolCount get the total number of pool @@ -129,9 +124,9 @@ func (k Keeper) GetPoolIDByParams( centerTickIndexNormalized int64, fee uint64, ) (id uint64, found bool) { - poolRefKey := types.PoolKey(*pairID, centerTickIndexNormalized, fee) + poolIDKey := types.PoolIDKey(pairID, centerTickIndexNormalized, fee) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolIDKeyPrefix)) - b := store.Get(poolRefKey) + b := store.Get(poolIDKey) if b == nil { return 0, false } @@ -140,49 +135,6 @@ func (k Keeper) GetPoolIDByParams( return poolID, true } -func (k Keeper) GetPoolParamsByDenom( - ctx sdk.Context, - denom string, -) (pp types.PoolParams, err error) { - poolID, err := types.ParsePoolIDFromDenom(denom) - if err != nil { - return pp, err - } - pp, found := k.GetPoolParamsByID(ctx, poolID) - if !found { - return pp, types.ErrInvalidPoolDenom - } - return pp, nil -} - -func (k Keeper) GetPoolParamsByID( - ctx sdk.Context, - id uint64, -) (pp types.PoolParams, found bool) { - ref, found := k.GetPoolRefByID(ctx, id) - if !found { - return pp, false - } - - poolParams := types.MustParsePoolRefToParams(ref) - - return poolParams, true -} - -func (k Keeper) GetPoolRefByID( - ctx sdk.Context, - poolID uint64, -) (ref []byte, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRefKeyPrefix)) - poolIDBz := sdk.Uint64ToBigEndian(poolID) - b := store.Get(poolIDBz) - if b == nil { - return []byte{}, false - } - - return b, true -} - // SetPoolCount set the total number of pool func (k Keeper) SetPoolCount(ctx sdk.Context, count uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) diff --git a/x/dex/keeper/pool_metadata.go b/x/dex/keeper/pool_metadata.go new file mode 100644 index 000000000..bda2d6256 --- /dev/null +++ b/x/dex/keeper/pool_metadata.go @@ -0,0 +1,76 @@ +package keeper + +import ( + "encoding/binary" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/duality-labs/duality/x/dex/types" +) + +// SetPoolMetadata set a specific poolMetadata in the store +func (k Keeper) SetPoolMetadata(ctx sdk.Context, poolMetadata types.PoolMetadata) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolMetadataKeyPrefix)) + b := k.cdc.MustMarshal(&poolMetadata) + store.Set(GetPoolMetadataIDBytes(poolMetadata.ID), b) +} + +// GetPoolMetadata returns a poolMetadata from its id +func (k Keeper) GetPoolMetadata(ctx sdk.Context, id uint64) (val types.PoolMetadata, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolMetadataKeyPrefix)) + b := store.Get(GetPoolMetadataIDBytes(id)) + if b == nil { + return val, false + } + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +func (k Keeper) GetPoolMetadataByDenom( + ctx sdk.Context, + denom string, +) (pm types.PoolMetadata, err error) { + poolID, err := types.ParsePoolIDFromDenom(denom) + if err != nil { + return pm, err + } + pm, found := k.GetPoolMetadata(ctx, poolID) + if !found { + return pm, types.ErrInvalidPoolDenom + } + return pm, nil +} + +// RemovePoolMetadata removes a poolMetadata from the store +func (k Keeper) RemovePoolMetadata(ctx sdk.Context, id uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolMetadataKeyPrefix)) + store.Delete(GetPoolMetadataIDBytes(id)) +} + +// GetAllPoolMetadata returns all poolMetadata +func (k Keeper) GetAllPoolMetadata(ctx sdk.Context) (list []types.PoolMetadata) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolMetadataKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PoolMetadata + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// GetPoolMetadataIDBytes returns the byte representation of the ID +func GetPoolMetadataIDBytes(id uint64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, id) + return bz +} + +// GetPoolMetadataIDFromBytes returns ID in uint64 format from a byte array +func GetPoolMetadataIDFromBytes(bz []byte) uint64 { + return binary.BigEndian.Uint64(bz) +} diff --git a/x/dex/keeper/pool_metadata_test.go b/x/dex/keeper/pool_metadata_test.go new file mode 100644 index 000000000..61fa75f0a --- /dev/null +++ b/x/dex/keeper/pool_metadata_test.go @@ -0,0 +1,54 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/duality-labs/duality/testutil/keeper" + "github.com/duality-labs/duality/testutil/nullify" + "github.com/duality-labs/duality/x/dex/keeper" + "github.com/duality-labs/duality/x/dex/types" + "github.com/stretchr/testify/require" +) + +func createNPoolMetadata(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.PoolMetadata { + items := make([]types.PoolMetadata, n) + for i := range items { + items[i].ID = uint64(i) + keeper.SetPoolMetadata(ctx, items[i]) + } + + return items +} + +func TestPoolMetadataGet(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + items := createNPoolMetadata(keeper, ctx, 10) + for _, item := range items { + got, found := keeper.GetPoolMetadata(ctx, item.ID) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&got), + ) + } +} + +func TestPoolMetadataRemove(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + items := createNPoolMetadata(keeper, ctx, 10) + for _, item := range items { + keeper.RemovePoolMetadata(ctx, item.ID) + _, found := keeper.GetPoolMetadata(ctx, item.ID) + require.False(t, found) + } +} + +func TestPoolMetadataGetAll(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + items := createNPoolMetadata(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllPoolMetadata(ctx)), + ) +} diff --git a/x/dex/keeper/pool_reserves_test.go b/x/dex/keeper/pool_reserves_test.go index 02f0a6753..61ef9cd05 100644 --- a/x/dex/keeper/pool_reserves_test.go +++ b/x/dex/keeper/pool_reserves_test.go @@ -26,37 +26,6 @@ func createNPoolReserves(k *keeper.Keeper, ctx sdk.Context, n int) []*types.Pool return items } -func createNPools(k *keeper.Keeper, ctx sdk.Context, n int) []struct { - Pool *types.Pool - TickIndex int64 - Fee uint64 -} { - items := make([]struct { - Pool *types.Pool - TickIndex int64 - Fee uint64 - }, n) - for i := range items { - pool, err := k.InitPool(ctx, types.MustNewPairID("TokenA", "TokenB"), int64(i), uint64(i)) - if err != nil { - panic("failed to create pool") - } - pool.Deposit(sdk.NewInt(10), sdk.NewInt(0), sdk.ZeroInt(), true) - k.SetPool(ctx, pool) - items[i] = struct { - Pool *types.Pool - TickIndex int64 - Fee uint64 - }{ - Pool: pool, - TickIndex: int64(i), - Fee: uint64(i), - } - } - - return items -} - func TestGetPoolReserves(t *testing.T) { keeper, ctx := keepertest.DexKeeper(t) items := createNPoolReserves(keeper, ctx, 10) diff --git a/x/dex/keeper/pool_test.go b/x/dex/keeper/pool_test.go index a6d5f0c48..041cebfea 100644 --- a/x/dex/keeper/pool_test.go +++ b/x/dex/keeper/pool_test.go @@ -5,9 +5,26 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/duality-labs/duality/testutil/keeper" + "github.com/duality-labs/duality/x/dex/keeper" + "github.com/duality-labs/duality/x/dex/types" "github.com/stretchr/testify/require" ) +func createNPools(k *keeper.Keeper, ctx sdk.Context, n int) []*types.Pool { + items := make([]*types.Pool, n) + for i := range items { + pool, err := k.InitPool(ctx, types.MustNewPairID("TokenA", "TokenB"), int64(i), uint64(i)) + if err != nil { + panic("failed to create pool") + } + pool.Deposit(sdk.NewInt(10), sdk.NewInt(0), sdk.ZeroInt(), true) + k.SetPool(ctx, pool) + items[i] = pool + } + + return items +} + func TestPoolInit(t *testing.T) { keeper, ctx := keepertest.DexKeeper(t) @@ -24,3 +41,52 @@ func TestPoolInit(t *testing.T) { require.Equal(t, pool.LowerTick0, dbPool.LowerTick0) require.Equal(t, pool.UpperTick1, dbPool.UpperTick1) } + +func TestPoolCount(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + items := createNPools(keeper, ctx, 10) + count := uint64(len(items)) + require.Equal(t, count, keeper.GetPoolCount(ctx)) +} + +func TestGetPoolByID(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + items := createNPools(keeper, ctx, 2) + + pool0, found := keeper.GetPoolByID(ctx, items[0].ID) + require.True(t, found) + require.Equal(t, items[0], pool0) + + pool1, found := keeper.GetPoolByID(ctx, items[1].ID) + require.True(t, found) + require.Equal(t, items[1], pool1) + + _, found = keeper.GetPoolByID(ctx, 99) + require.False(t, found) +} + +func TestGetPoolIDByParams(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + items := createNPools(keeper, ctx, 2) + + id0, found := keeper.GetPoolIDByParams( + ctx, + items[0].LowerTick0.Key.TradePairID.MustPairID(), + items[0].CenterTickIndex(), + items[0].Fee(), + ) + require.True(t, found) + require.Equal(t, items[0].ID, id0) + + id1, found := keeper.GetPoolIDByParams( + ctx, + items[1].LowerTick0.Key.TradePairID.MustPairID(), + items[1].CenterTickIndex(), + items[1].Fee(), + ) + require.True(t, found) + require.Equal(t, items[1].ID, id1) + + _, found = keeper.GetPoolIDByParams(ctx, defaultPairID, 99, 2) + require.False(t, found) +} diff --git a/x/dex/types/genesis.go b/x/dex/types/genesis.go index 69d3f13fa..89dd2b10e 100644 --- a/x/dex/types/genesis.go +++ b/x/dex/types/genesis.go @@ -13,6 +13,7 @@ func DefaultGenesis() *GenesisState { LimitOrderTrancheUserList: []*LimitOrderTrancheUser{}, TickLiquidityList: []*TickLiquidity{}, InactiveLimitOrderTrancheList: []*LimitOrderTranche{}, + PoolMetadataList: []PoolMetadata{}, // this line is used by starport scaffolding # genesis/types/default Params: *DefaultParams(), } @@ -58,6 +59,18 @@ func (gs GenesisState) Validate() error { } inactiveLimitOrderTrancheKeyMap[index] = struct{}{} } + // Check for duplicated ID in poolMetadata + poolMetadataIdMap := make(map[uint64]bool) + poolMetadataCount := gs.GetPoolCount() + for _, elem := range gs.PoolMetadataList { + if _, ok := poolMetadataIdMap[elem.ID]; ok { + return fmt.Errorf("duplicated id for poolMetadata") + } + if elem.ID >= poolMetadataCount { + return fmt.Errorf("poolMetadata id should be lower or equal than the last id") + } + poolMetadataIdMap[elem.ID] = true + } // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() diff --git a/x/dex/types/genesis.pb.go b/x/dex/types/genesis.pb.go index 650f26a05..ab2dcae4d 100644 --- a/x/dex/types/genesis.pb.go +++ b/x/dex/types/genesis.pb.go @@ -29,6 +29,9 @@ type GenesisState struct { TickLiquidityList []*TickLiquidity `protobuf:"bytes,2,rep,name=tickLiquidityList,proto3" json:"tickLiquidityList,omitempty"` InactiveLimitOrderTrancheList []*LimitOrderTranche `protobuf:"bytes,6,rep,name=inactiveLimitOrderTrancheList,proto3" json:"inactiveLimitOrderTrancheList,omitempty"` LimitOrderTrancheUserList []*LimitOrderTrancheUser `protobuf:"bytes,7,rep,name=limitOrderTrancheUserList,proto3" json:"limitOrderTrancheUserList,omitempty"` + // this line is used by starport scaffolding # genesis/proto/state + PoolMetadataList []PoolMetadata `protobuf:"bytes,8,rep,name=poolMetadataList,proto3" json:"poolMetadataList"` + PoolCount uint64 `protobuf:"varint,9,opt,name=poolCount,proto3" json:"poolCount,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -92,6 +95,20 @@ func (m *GenesisState) GetLimitOrderTrancheUserList() []*LimitOrderTrancheUser { return nil } +func (m *GenesisState) GetPoolMetadataList() []PoolMetadata { + if m != nil { + return m.PoolMetadataList + } + return nil +} + +func (m *GenesisState) GetPoolCount() uint64 { + if m != nil { + return m.PoolCount + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "duality.dex.GenesisState") } @@ -99,29 +116,32 @@ func init() { func init() { proto.RegisterFile("duality/dex/genesis.proto", fileDescriptor_6ccf50bb6779a67a) } var fileDescriptor_6ccf50bb6779a67a = []byte{ - // 337 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4a, 0xfb, 0x30, - 0x1c, 0xc7, 0x9b, 0xfd, 0xff, 0x4c, 0xc8, 0xbc, 0x58, 0x3d, 0x6c, 0x05, 0xe3, 0x18, 0x08, 0x43, - 0xb1, 0xc5, 0xf9, 0x06, 0x03, 0xf1, 0x32, 0x54, 0xe6, 0xbc, 0x78, 0x29, 0x59, 0x1b, 0xbb, 0x68, - 0xb7, 0xd4, 0x24, 0x95, 0xee, 0x2d, 0x7c, 0xac, 0x1d, 0x77, 0xf4, 0x24, 0xd2, 0xe2, 0x7b, 0x48, - 0xd2, 0x0c, 0x3a, 0x87, 0xf3, 0xd6, 0x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x08, 0x5b, - 0xf1, 0xcf, 0xc1, 0xbd, 0x20, 0x5c, 0xe7, 0xec, 0xe8, 0x9c, 0xce, 0xf6, 0x1c, 0x45, 0x9b, 0xac, - 0xdf, 0x55, 0xfd, 0xcb, 0x45, 0x8e, 0xc0, 0x32, 0x47, 0xe0, 0x33, 0x47, 0xe0, 0xad, 0x40, 0xd6, - 0xb2, 0x40, 0xd6, 0x7b, 0x81, 0xac, 0x87, 0xd3, 0x88, 0xca, 0x49, 0x3a, 0x76, 0x03, 0x36, 0xf5, - 0x4c, 0xd0, 0x59, 0x8c, 0xc7, 0x62, 0xf5, 0xe3, 0x65, 0xe5, 0xeb, 0xcd, 0x13, 0x22, 0xc6, 0x75, - 0xfd, 0x6a, 0x17, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x06, 0x91, 0x31, 0x92, 0x84, 0x02, 0x00, - 0x00, + // 391 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x4e, 0xfa, 0x40, + 0x14, 0xc5, 0xdb, 0x3f, 0x84, 0xbf, 0x0c, 0x2e, 0xb4, 0xba, 0x28, 0x8d, 0x96, 0x86, 0xc4, 0x84, + 0x68, 0x6c, 0x23, 0xbe, 0x01, 0xc6, 0xb8, 0x10, 0x3f, 0x82, 0xb8, 0x71, 0xd3, 0x0c, 0xed, 0x58, + 0x46, 0xdb, 0x0e, 0xb6, 0x53, 0x03, 0x6f, 0xe1, 0x63, 0xb1, 0x64, 0xe9, 0xca, 0x18, 0x78, 0x11, + 0x33, 0x1f, 0xc4, 0x56, 0x22, 0xee, 0xda, 0x7b, 0x7f, 0xf7, 0x9c, 0x7b, 0x6e, 0x06, 0xd4, 0xfd, + 0x0c, 0x86, 0x98, 0x4e, 0x1c, 0x1f, 0x8d, 0x9d, 0x00, 0xc5, 0x28, 0xc5, 0xa9, 0x3d, 0x4a, 0x08, + 0x25, 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0xb9, 0xde, 0x87, 0xd1, 0xd2, 0xeb, 0x77, 0x29, + 0xed, 0x12, 0x6c, 0xb1, 0xf3, 0x5f, 0xc9, 0xeb, 0x73, 0xf9, 0x0d, 0x2e, 0x5f, 0x2f, 0x1e, 0x38, + 0x07, 0xc9, 0x33, 0xaf, 0x0c, 0x6a, 0x7b, 0xa0, 0xca, 0x6a, 0x67, 0x24, 0x8b, 0xa9, 0x5e, 0xb5, + 0xd4, 0x56, 0xb9, 0xf7, 0x5d, 0xe8, 0x9c, 0x4f, 0xe7, 0xa6, 0x3a, 0x9b, 0x9b, 0xea, 0xe7, 0xdc, + 0x54, 0xdf, 0x16, 0xa6, 0x32, 0x5b, 0x98, 0xca, 0xfb, 0xc2, 0x54, 0x1e, 0x8e, 0x02, 0x4c, 0x87, + 0xd9, 0xc0, 0xf6, 0x48, 0xe4, 0x48, 0xd3, 0xe3, 0x10, 0x0e, 0xd2, 0xe5, 0x8f, 0x33, 0x16, 0x2f, + 0x69, 0x32, 0x42, 0xe9, 0xa0, 0xc2, 0x1f, 0xc8, 0xe9, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, + 0x3a, 0x05, 0xa4, 0x10, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -144,6 +164,25 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.PoolCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.PoolCount)) + i-- + dAtA[i] = 0x48 + } + if len(m.PoolMetadataList) > 0 { + for iNdEx := len(m.PoolMetadataList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolMetadataList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } if len(m.LimitOrderTrancheUserList) > 0 { for iNdEx := len(m.LimitOrderTrancheUserList) - 1; iNdEx >= 0; iNdEx-- { { @@ -236,6 +275,15 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.PoolMetadataList) > 0 { + for _, e := range m.PoolMetadataList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.PoolCount != 0 { + n += 1 + sovGenesis(uint64(m.PoolCount)) + } return n } @@ -409,6 +457,59 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolMetadataList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PoolMetadataList = append(m.PoolMetadataList, PoolMetadata{}) + if err := m.PoolMetadataList[len(m.PoolMetadataList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolCount", wireType) + } + m.PoolCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/dex/types/genesis_test.go b/x/dex/types/genesis_test.go index 49fc65f41..6299cf3e3 100644 --- a/x/dex/types/genesis_test.go +++ b/x/dex/types/genesis_test.go @@ -73,6 +73,15 @@ func TestGenesisState_Validate(t *testing.T) { }, }, }, + PoolMetadataList: []types.PoolMetadata{ + { + ID: 0, + }, + { + ID: 1, + }, + }, + PoolCount: 2, // this line is used by starport scaffolding # types/genesis/validField }, valid: true, @@ -147,6 +156,32 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, + { + desc: "duplicated poolMetadata", + genState: &types.GenesisState{ + PoolMetadataList: []types.PoolMetadata{ + { + ID: 0, + }, + { + ID: 0, + }, + }, + }, + valid: false, + }, + { + desc: "invalid poolCount", + genState: &types.GenesisState{ + PoolMetadataList: []types.PoolMetadata{ + { + ID: 1, + }, + }, + PoolCount: 0, + }, + valid: false, + }, // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { diff --git a/x/dex/types/keys.go b/x/dex/types/keys.go index 378ed90c5..7a75f6b35 100644 --- a/x/dex/types/keys.go +++ b/x/dex/types/keys.go @@ -28,7 +28,6 @@ const ( Separator = "/" ) - const ( // TickLiquidityKeyPrefix is the prefix to retrieve all TickLiquidity TickLiquidityKeyPrefix = "TickLiquidity/value/" @@ -48,8 +47,8 @@ const ( // PoolIDKeyPrefix is the prefix to retrieve all PoolIds or retrieve a specific pool by pair+tick+fee PoolIDKeyPrefix = "Pool/id/" - // PoolRefKeyPrefix is the prefix to retrieve all pool refs (pair+tick+fee) - PoolRefKeyPrefix = "Pool/ref/" + // PoolMetadataKeyPrefix is the prefix to retrieve all PoolMetadata + PoolMetadataKeyPrefix = "PoolMetadata/value/" // PoolCountKeyPrefix is the prefix to retrieve the Pool count PoolCountKeyPrefix = "Pool/count/" @@ -207,8 +206,8 @@ func LimitOrderExpirationKey( return key } -func PoolKey( - pairID PairID, +func PoolIDKey( + pairID *PairID, tickIndex int64, fee uint64, ) []byte { diff --git a/x/dex/types/pool_metadata.go b/x/dex/types/pool_metadata.go new file mode 100644 index 000000000..eff09212b --- /dev/null +++ b/x/dex/types/pool_metadata.go @@ -0,0 +1,5 @@ +package types + +func NewPoolMetadata(pairID *PairID, tick int64, fee uint64, poolID uint64) PoolMetadata { + return PoolMetadata{PairID: pairID, Tick: tick, Fee: fee, ID: poolID} +} diff --git a/x/dex/types/pool_metadata.pb.go b/x/dex/types/pool_metadata.pb.go new file mode 100644 index 000000000..610f79cfc --- /dev/null +++ b/x/dex/types/pool_metadata.pb.go @@ -0,0 +1,432 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: duality/dex/pool_metadata.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type PoolMetadata struct { + ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` + Tick int64 `protobuf:"varint,2,opt,name=tick,proto3" json:"tick,omitempty"` + Fee uint64 `protobuf:"varint,3,opt,name=fee,proto3" json:"fee,omitempty"` + PairID *PairID `protobuf:"bytes,4,opt,name=pairID,proto3" json:"pairID,omitempty"` +} + +func (m *PoolMetadata) Reset() { *m = PoolMetadata{} } +func (m *PoolMetadata) String() string { return proto.CompactTextString(m) } +func (*PoolMetadata) ProtoMessage() {} +func (*PoolMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_20ad68f12715e384, []int{0} +} +func (m *PoolMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolMetadata.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PoolMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolMetadata.Merge(m, src) +} +func (m *PoolMetadata) XXX_Size() int { + return m.Size() +} +func (m *PoolMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_PoolMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolMetadata proto.InternalMessageInfo + +func (m *PoolMetadata) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *PoolMetadata) GetTick() int64 { + if m != nil { + return m.Tick + } + return 0 +} + +func (m *PoolMetadata) GetFee() uint64 { + if m != nil { + return m.Fee + } + return 0 +} + +func (m *PoolMetadata) GetPairID() *PairID { + if m != nil { + return m.PairID + } + return nil +} + +func init() { + proto.RegisterType((*PoolMetadata)(nil), "duality.dex.PoolMetadata") +} + +func init() { proto.RegisterFile("duality/dex/pool_metadata.proto", fileDescriptor_20ad68f12715e384) } + +var fileDescriptor_20ad68f12715e384 = []byte{ + // 224 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0x29, 0x4d, 0xcc, + 0xc9, 0x2c, 0xa9, 0xd4, 0x4f, 0x49, 0xad, 0xd0, 0x2f, 0xc8, 0xcf, 0xcf, 0x89, 0xcf, 0x4d, 0x2d, + 0x49, 0x4c, 0x49, 0x2c, 0x49, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0x2a, 0xd0, + 0x4b, 0x49, 0xad, 0x90, 0x92, 0x44, 0x51, 0x9d, 0x98, 0x59, 0x14, 0x9f, 0x99, 0x02, 0x51, 0xa7, + 0x54, 0xc8, 0xc5, 0x13, 0x90, 0x9f, 0x9f, 0xe3, 0x0b, 0xd5, 0x2d, 0xc4, 0xc7, 0xc5, 0xe4, 0xe9, + 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x12, 0xc4, 0xe4, 0xe9, 0x22, 0x24, 0xc4, 0xc5, 0x52, 0x92, + 0x99, 0x9c, 0x2d, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x1c, 0x04, 0x66, 0x0b, 0x09, 0x70, 0x31, 0xa7, + 0xa5, 0xa6, 0x4a, 0x30, 0x83, 0x15, 0x81, 0x98, 0x42, 0xda, 0x5c, 0x6c, 0x20, 0x63, 0x3d, 0x5d, + 0x24, 0x58, 0x14, 0x18, 0x35, 0xb8, 0x8d, 0x84, 0xf5, 0x90, 0xac, 0xd7, 0x0b, 0x00, 0x4b, 0x05, + 0x41, 0x95, 0x38, 0xb9, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, + 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x76, + 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x00, 0xdd, 0x9c, 0xc4, + 0xa4, 0x62, 0x18, 0x47, 0xbf, 0x02, 0xec, 0x83, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, + 0x07, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x45, 0x67, 0x83, 0xda, 0x0b, 0x01, 0x00, 0x00, +} + +func (m *PoolMetadata) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PoolMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PairID != nil { + { + size, err := m.PairID.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPoolMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.Fee != 0 { + i = encodeVarintPoolMetadata(dAtA, i, uint64(m.Fee)) + i-- + dAtA[i] = 0x18 + } + if m.Tick != 0 { + i = encodeVarintPoolMetadata(dAtA, i, uint64(m.Tick)) + i-- + dAtA[i] = 0x10 + } + if m.ID != 0 { + i = encodeVarintPoolMetadata(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintPoolMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovPoolMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PoolMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovPoolMetadata(uint64(m.ID)) + } + if m.Tick != 0 { + n += 1 + sovPoolMetadata(uint64(m.Tick)) + } + if m.Fee != 0 { + n += 1 + sovPoolMetadata(uint64(m.Fee)) + } + if m.PairID != nil { + l = m.PairID.Size() + n += 1 + l + sovPoolMetadata(uint64(l)) + } + return n +} + +func sovPoolMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPoolMetadata(x uint64) (n int) { + return sovPoolMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PoolMetadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PoolMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Tick", wireType) + } + m.Tick = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Tick |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + m.Fee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Fee |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PairID", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPoolMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPoolMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PairID == nil { + m.PairID = &PairID{} + } + if err := m.PairID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPoolMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoolMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPoolMetadata(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPoolMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPoolMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPoolMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPoolMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPoolMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPoolMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPoolMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dex/types/pool_params.go b/x/dex/types/pool_params.go deleted file mode 100644 index b93ce6f81..000000000 --- a/x/dex/types/pool_params.go +++ /dev/null @@ -1,47 +0,0 @@ -package types - -import ( - "bytes" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type PoolParams struct { - PairID *PairID - Tick int64 - Fee uint64 - PoolID uint64 -} - -func ParsePoolRefToParams(poolID uint64, poolRef []byte) (PoolParams, error) { - parts := bytes.Split(poolRef, []byte("/")) - if len(parts) != 4 { - return PoolParams{}, ErrInvalidPoolDenom - } - - pairID, err := NewPairIDFromCanonicalString(string(parts[0])) - if err != nil { - return PoolParams{}, err - } - - tick, err := BytesToTickIndex(parts[1]) - if err != nil { - return PoolParams{}, err - } - - fee := sdk.BigEndianToUint64(parts[2]) - - return PoolParams{PairID: pairID, Tick: tick, Fee: fee, PoolID: poolID}, nil -} - -func MustParsePoolRefToParams(poolID uint64, poolRef []byte) PoolParams { - poolParams, err := ParsePoolRefToParams(poolID, poolRef) - if err != nil { - panic("Invalid pool ref") - } - return poolParams -} - -func NewPoolParams(pairID *PairID, tick int64, fee uint64, poolID uint64) PoolParams { - return PoolParams{PairID: pairID, Tick: tick, Fee: fee, PoolID: poolID} -} diff --git a/x/dex/types/query.pb.go b/x/dex/types/query.pb.go index 80ede9338..0c565aa68 100644 --- a/x/dex/types/query.pb.go +++ b/x/dex/types/query.pb.go @@ -1752,6 +1752,191 @@ func (m *QueryPoolResponse) GetPool() *Pool { return nil } +// this line is used by starport scaffolding # 3 +type QueryGetPoolMetadataRequest struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *QueryGetPoolMetadataRequest) Reset() { *m = QueryGetPoolMetadataRequest{} } +func (m *QueryGetPoolMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetPoolMetadataRequest) ProtoMessage() {} +func (*QueryGetPoolMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4664128fddcf2b7a, []int{33} +} +func (m *QueryGetPoolMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetPoolMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetPoolMetadataRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetPoolMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetPoolMetadataRequest.Merge(m, src) +} +func (m *QueryGetPoolMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetPoolMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetPoolMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetPoolMetadataRequest proto.InternalMessageInfo + +func (m *QueryGetPoolMetadataRequest) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type QueryGetPoolMetadataResponse struct { + PoolMetadata PoolMetadata `protobuf:"bytes,1,opt,name=PoolMetadata,proto3" json:"PoolMetadata"` +} + +func (m *QueryGetPoolMetadataResponse) Reset() { *m = QueryGetPoolMetadataResponse{} } +func (m *QueryGetPoolMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetPoolMetadataResponse) ProtoMessage() {} +func (*QueryGetPoolMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4664128fddcf2b7a, []int{34} +} +func (m *QueryGetPoolMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetPoolMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetPoolMetadataResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetPoolMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetPoolMetadataResponse.Merge(m, src) +} +func (m *QueryGetPoolMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetPoolMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetPoolMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetPoolMetadataResponse proto.InternalMessageInfo + +func (m *QueryGetPoolMetadataResponse) GetPoolMetadata() PoolMetadata { + if m != nil { + return m.PoolMetadata + } + return PoolMetadata{} +} + +type QueryAllPoolMetadataRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllPoolMetadataRequest) Reset() { *m = QueryAllPoolMetadataRequest{} } +func (m *QueryAllPoolMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllPoolMetadataRequest) ProtoMessage() {} +func (*QueryAllPoolMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4664128fddcf2b7a, []int{35} +} +func (m *QueryAllPoolMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPoolMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPoolMetadataRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPoolMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPoolMetadataRequest.Merge(m, src) +} +func (m *QueryAllPoolMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPoolMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPoolMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPoolMetadataRequest proto.InternalMessageInfo + +func (m *QueryAllPoolMetadataRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllPoolMetadataResponse struct { + PoolMetadata []PoolMetadata `protobuf:"bytes,1,rep,name=PoolMetadata,proto3" json:"PoolMetadata"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllPoolMetadataResponse) Reset() { *m = QueryAllPoolMetadataResponse{} } +func (m *QueryAllPoolMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllPoolMetadataResponse) ProtoMessage() {} +func (*QueryAllPoolMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4664128fddcf2b7a, []int{36} +} +func (m *QueryAllPoolMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPoolMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPoolMetadataResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPoolMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPoolMetadataResponse.Merge(m, src) +} +func (m *QueryAllPoolMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPoolMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPoolMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPoolMetadataResponse proto.InternalMessageInfo + +func (m *QueryAllPoolMetadataResponse) GetPoolMetadata() []PoolMetadata { + if m != nil { + return m.PoolMetadata + } + return nil +} + +func (m *QueryAllPoolMetadataResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "duality.dex.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "duality.dex.QueryParamsResponse") @@ -1786,138 +1971,149 @@ func init() { proto.RegisterType((*QueryPoolRequest)(nil), "duality.dex.QueryPoolRequest") proto.RegisterType((*QueryPoolByIDRequest)(nil), "duality.dex.QueryPoolByIDRequest") proto.RegisterType((*QueryPoolResponse)(nil), "duality.dex.QueryPoolResponse") + proto.RegisterType((*QueryGetPoolMetadataRequest)(nil), "duality.dex.QueryGetPoolMetadataRequest") + proto.RegisterType((*QueryGetPoolMetadataResponse)(nil), "duality.dex.QueryGetPoolMetadataResponse") + proto.RegisterType((*QueryAllPoolMetadataRequest)(nil), "duality.dex.QueryAllPoolMetadataRequest") + proto.RegisterType((*QueryAllPoolMetadataResponse)(nil), "duality.dex.QueryAllPoolMetadataResponse") } func init() { proto.RegisterFile("duality/dex/query.proto", fileDescriptor_4664128fddcf2b7a) } var fileDescriptor_4664128fddcf2b7a = []byte{ - // 2013 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0xcf, 0x6f, 0x1b, 0xc7, - 0x15, 0xf6, 0x88, 0xb2, 0x2c, 0x8f, 0x9d, 0x58, 0x1e, 0xcb, 0x0e, 0x4d, 0x2b, 0xa4, 0x32, 0xf5, - 0x0f, 0xc9, 0xb6, 0xb8, 0x96, 0x52, 0xa7, 0xad, 0x1b, 0xb4, 0x95, 0xa2, 0xc4, 0x61, 0xeb, 0xd4, - 0xea, 0x46, 0x3e, 0x34, 0x2d, 0xca, 0xae, 0xc8, 0xb1, 0xbc, 0xd0, 0x72, 0x67, 0xbd, 0xbb, 0xb4, - 0x45, 0x18, 0x46, 0xd1, 0x5e, 0x7a, 0x2a, 0x9a, 0xb6, 0x01, 0x1a, 0x14, 0xed, 0x21, 0xe8, 0xa1, - 0x17, 0x03, 0x0d, 0xfa, 0x07, 0x14, 0x3d, 0xf4, 0xe0, 0xa3, 0x81, 0x5e, 0x82, 0x1e, 0xd8, 0xc2, - 0x2e, 0x50, 0xc0, 0x47, 0xf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24, 0xce, 0x9d, 0xaa, 0xcf, 0x02, 0xe6, - 0xdf, 0x63, 0xf1, 0x24, 0xb3, 0x89, 0x21, 0x76, 0xa1, 0xb5, 0xa8, 0xb2, 0x16, 0xf3, 0x55, 0xe3, - 0x76, 0xcc, 0x54, 0x09, 0x38, 0x97, 0x5f, 0x5b, 0xcd, 0xdb, 0x46, 0x68, 0x37, 0x58, 0x10, 0x5a, - 0x0d, 0x0f, 0x0c, 0x4e, 0xf5, 0xce, 0x1b, 0xb5, 0xd3, 0x59, 0x4c, 0x7e, 0x20, 0x92, 0xb0, 0x21, - 0xd9, 0x35, 0xd9, 0xdd, 0x26, 0x0b, 0x42, 0xfa, 0x2e, 0x3e, 0x91, 0x68, 0x0d, 0x3c, 0xee, 0x06, - 0x8c, 0x2c, 0xe3, 0xa9, 0x28, 0x0b, 0x79, 0x34, 0x8f, 0x16, 0x8e, 0xac, 0x9c, 0x28, 0x2b, 0x6a, - 0x28, 0x47, 0xc6, 0x6b, 0x93, 0x8f, 0xdb, 0x25, 0x64, 0x82, 0x21, 0xfd, 0x29, 0x3e, 0x2b, 0x47, - 0xba, 0xce, 0xc2, 0x1b, 0x82, 0xfa, 0x9b, 0x82, 0xf9, 0xcd, 0x88, 0xf8, 0x5b, 0x01, 0xf3, 0x61, - 0x46, 0x92, 0xc7, 0x87, 0xac, 0x7a, 0xdd, 0x67, 0x41, 0x34, 0xf6, 0x61, 0x33, 0xfe, 0x24, 0x45, - 0x8c, 0x21, 0x51, 0xdf, 0x63, 0xad, 0xfc, 0x84, 0xec, 0x54, 0x5a, 0xe8, 0x2f, 0x11, 0x3e, 0x37, - 0x64, 0x0a, 0x80, 0xff, 0x13, 0x7c, 0x52, 0x6b, 0x00, 0xd1, 0xd0, 0x44, 0x34, 0x5a, 0x4b, 0x08, - 0x4e, 0x3f, 0x0c, 0x75, 0x21, 0xd6, 0x55, 0xc7, 0x19, 0x18, 0xeb, 0x3b, 0x18, 0x77, 0xa5, 0x0e, - 0x93, 0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0xae, - 0x7b, 0x16, 0x96, 0xf1, 0x6c, 0x67, 0xec, 0xb5, 0x56, 0x65, 0x5d, 0x1d, 0x9f, 0x73, 0x07, 0xc6, - 0x9f, 0x34, 0xe1, 0x8b, 0x7e, 0x07, 0x1f, 0x57, 0xb0, 0x80, 0xb0, 0x2e, 0xe1, 0x49, 0xd1, 0x0d, - 0x82, 0x3a, 0xde, 0x77, 0x50, 0xc2, 0x01, 0x29, 0x8d, 0x56, 0xfe, 0x72, 0x0a, 0x1f, 0x94, 0x43, - 0x90, 0x3b, 0x78, 0x2a, 0xaa, 0xdc, 0x91, 0x52, 0xc2, 0xa5, 0xbf, 0x2c, 0x58, 0x98, 0x4f, 0x37, - 0x88, 0x30, 0xd0, 0x33, 0xbf, 0xf8, 0xd7, 0xff, 0x7e, 0x37, 0x71, 0x92, 0x9c, 0x30, 0xfa, 0x4b, - 0xb7, 0xe4, 0x9f, 0x28, 0xa5, 0x0c, 0x45, 0x96, 0xfb, 0x07, 0x1e, 0x52, 0x30, 0x2c, 0xac, 0x8c, - 0xe2, 0x02, 0xe8, 0xd6, 0x25, 0xba, 0x6f, 0x91, 0x37, 0x8d, 0x2c, 0xe5, 0x63, 0xe3, 0x01, 0xbc, - 0x57, 0x1f, 0x1a, 0x0f, 0xba, 0x4f, 0x8c, 0x87, 0xe4, 0x53, 0x84, 0xf3, 0xda, 0x79, 0x56, 0x1d, - 0x47, 0x17, 0xc9, 0x90, 0x72, 0xa0, 0x2e, 0x92, 0x61, 0x05, 0x3d, 0xba, 0x24, 0x23, 0xb9, 0x40, - 0xce, 0x65, 0x8a, 0x84, 0x3c, 0x46, 0x9a, 0x22, 0x0c, 0x59, 0xca, 0x46, 0x61, 0x8c, 0xb3, 0x9c, - 0xd5, 0x1c, 0x30, 0x6e, 0x4a, 0x8c, 0xdf, 0x27, 0x37, 0x86, 0x61, 0x34, 0x1e, 0x44, 0xcb, 0x46, - 0xf0, 0x1c, 0x1d, 0x82, 0xe2, 0x57, 0xbc, 0x5c, 0x7a, 0xd8, 0xff, 0x1b, 0xc2, 0xb3, 0x7d, 0x73, - 0x0a, 0xe6, 0x97, 0xb2, 0xd1, 0x38, 0x20, 0x9a, 0x41, 0x65, 0x2c, 0xfa, 0x4d, 0x19, 0xcd, 0x55, - 0xf2, 0xfa, 0x0b, 0x44, 0x43, 0x3e, 0x46, 0x78, 0xa6, 0xb7, 0x50, 0x44, 0x16, 0xb5, 0x7c, 0xea, - 0xca, 0x50, 0x85, 0x8b, 0x59, 0x4c, 0x07, 0x4a, 0x43, 0x0a, 0xba, 0xf3, 0x0f, 0x8d, 0xae, 0xb4, - 0xc9, 0x47, 0x08, 0x1f, 0x53, 0xcb, 0x43, 0x82, 0xca, 0x05, 0x2d, 0x37, 0x9a, 0xea, 0x53, 0x61, - 0x31, 0x83, 0x25, 0xe0, 0xba, 0x2c, 0x71, 0x9d, 0x27, 0x67, 0xfb, 0x71, 0xc1, 0xff, 0x52, 0x54, - 0x58, 0x9f, 0x20, 0x4c, 0x7a, 0x6a, 0x43, 0x02, 0xd9, 0xa5, 0xd4, 0xf9, 0xfa, 0x0b, 0x50, 0x85, - 0xcb, 0xd9, 0x8c, 0x01, 0xdf, 0x15, 0x89, 0xef, 0x22, 0x59, 0xe8, 0xc7, 0xa7, 0x64, 0xb9, 0x07, - 0xe3, 0x4c, 0xa2, 0xf2, 0x22, 0x10, 0xea, 0x19, 0xd1, 0x95, 0x9d, 0x74, 0x59, 0x4d, 0x2b, 0x03, - 0xd1, 0x37, 0x24, 0xba, 0x2b, 0xa4, 0x6c, 0xa4, 0xff, 0x8b, 0x49, 0xa7, 0xbc, 0xff, 0x23, 0x7c, - 0x3a, 0xb5, 0x04, 0x40, 0xae, 0x6a, 0x75, 0x35, 0xac, 0x4e, 0x51, 0x78, 0x63, 0x54, 0x37, 0x08, - 0xe2, 0x47, 0x32, 0x88, 0x5b, 0xe4, 0xfd, 0x44, 0x10, 0xb7, 0x6d, 0xc7, 0x61, 0xf5, 0xea, 0x7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b, 0x32, 0x79, 0x4d, 0x3f, 0x83, 0x72, 0x7f, 0x1e, 0x0a, - 0x82, 0x4a, 0x10, 0x73, 0xa4, 0xa0, 0x03, 0x21, 0xaf, 0xda, 0x0f, 0xd7, 0xde, 0x7e, 0xfc, 0xb4, - 0x88, 0x9e, 0x3c, 0x2d, 0xa2, 0xff, 0x3e, 0x2d, 0xa2, 0x0f, 0x9f, 0x15, 0x0f, 0x3c, 0x79, 0x56, - 0x3c, 0xf0, 0xd9, 0xb3, 0xe2, 0x81, 0x0f, 0x2e, 0x29, 0x8f, 0x0d, 0xf0, 0x5f, 0x72, 0xac, 0xad, - 0xa0, 0x33, 0xd8, 0x6e, 0xb4, 0x49, 0x8b, 0x57, 0xc7, 0xd6, 0x94, 0x7c, 0xc8, 0xbe, 0xfe, 0x79, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x67, 0x34, 0x5f, 0x2c, 0x5a, 0x21, 0x00, 0x00, + // 2125 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x5a, 0xcd, 0x6f, 0x1b, 0xc7, + 0x15, 0xd7, 0x88, 0xb2, 0x2c, 0x8f, 0x13, 0x5b, 0x1e, 0xcb, 0x09, 0x4d, 0x2b, 0xa4, 0x32, 0xf5, + 0x87, 0xfc, 0x21, 0xae, 0xa5, 0xd4, 0x69, 0xeb, 0x06, 0x6d, 0xa5, 0x28, 0x71, 0xd4, 0xda, 0xb5, + 0xba, 0x91, 0x0f, 0x4d, 0x8b, 0xb2, 0x2b, 0x72, 0x2c, 0x2f, 0xb4, 0xe4, 0xae, 0x77, 0x97, 0xb6, + 0x08, 0x41, 0x28, 0xda, 0x4b, 0x4f, 0x45, 0xd3, 0x36, 0x40, 0xd2, 0xa2, 0x3d, 0x04, 0xbd, 0x1a, + 0x68, 0xd0, 0x3f, 0xa0, 0xe8, 0xa1, 0x07, 0x1f, 0x0d, 0xf4, 0x12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, 0x31, + 0x5e, 0x7f, 0xa9, 0xb0, 0x70, 0x29, 0x9b, 0x31, 0xe0, 0xbb, 0x2c, 0xf0, 0x5d, 0x20, 0xf3, 0xfd, + 0xf8, 0xa4, 0x59, 0xee, 0xc1, 0x38, 0xad, 0xd4, 0xc8, 0x38, 0x42, 0x3d, 0x23, 0xba, 0x02, 0xa1, + 0x6e, 0x56, 0x93, 0x0a, 0x76, 0xf4, 0x4d, 0x81, 0xee, 0x32, 0x29, 0x1b, 0xc9, 0xbf, 0x16, 0xea, + 0x94, 0xf7, 0x7f, 0x84, 0x4f, 0x26, 0x16, 0x6b, 0xc8, 0x15, 0xad, 0xae, 0xd2, 0x2a, 0x4a, 0x85, + 0x37, 0x87, 0x75, 0x83, 0x24, 0x7e, 0x24, 0x92, 0xb8, 0x45, 0xde, 0x57, 0x92, 0xb8, 0x6d, 0x3b, + 0x0e, 0xab, 0x55, 0x9e, 0x77, 0x63, 0xf8, 0x1b, 0xc2, 0xb3, 0x89, 0x10, 0xf8, 0xcc, 0x5c, 0xd1, + 0xd2, 0xfd, 0x2c, 0xc9, 0x66, 0x29, 0x80, 0x51, 0x43, 0x24, 0x7b, 0x9e, 0x9c, 0xcb, 0x98, 0x2c, + 0xf9, 0x13, 0xc2, 0x47, 0xe5, 0xd2, 0x43, 0xf2, 0x4a, 0xd4, 0x94, 0x56, 0x12, 0x56, 0xa2, 0xae, + 0x06, 0x42, 0xaf, 0x08, 0x64, 0x06, 0x59, 0x30, 0x12, 0x7f, 0x57, 0xd6, 0x49, 0xe9, 0x01, 0x8a, + 0x6e, 0x30, 0x9d, 0xaa, 0xd1, 0xbc, 0x56, 0x06, 0x19, 0xc1, 0x25, 0x14, 0x68, 0xe8, 0x35, 0x01, + 0x6e, 0x99, 0x7c, 0x7b, 0x28, 0x70, 0xaa, 0x2c, 0x6e, 0x33, 0xb6, 0x47, 0xfe, 0x8c, 0xf0, 0x8c, + 0xee, 0xed, 0xaf, 0x3b, 0x28, 0x06, 0xd4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07, 0x17, 0xa5, 0xc7, + 0xb4, 0x76, 0xb0, 0x9d, 0xe8, 0x68, 0xe3, 0xaf, 0xea, 0xcd, 0x49, 0x51, 0xa8, 0x79, 0xe3, 0x8b, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x33, 0xa8, 0x4d, 0x75, 0x5b, 0x24, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1966,6 +2162,9 @@ type QueryClient interface { Pool(ctx context.Context, in *QueryPoolRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) // Queries a pool by ID PoolByID(ctx context.Context, in *QueryPoolByIDRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) + // Queries a list of PoolMetadata items. + PoolMetadata(ctx context.Context, in *QueryGetPoolMetadataRequest, opts ...grpc.CallOption) (*QueryGetPoolMetadataResponse, error) + PoolMetadataAll(ctx context.Context, in *QueryAllPoolMetadataRequest, opts ...grpc.CallOption) (*QueryAllPoolMetadataResponse, error) } type queryClient struct { @@ -2129,6 +2328,24 @@ func (c *queryClient) PoolByID(ctx context.Context, in *QueryPoolByIDRequest, op return out, nil } +func (c *queryClient) PoolMetadata(ctx context.Context, in *QueryGetPoolMetadataRequest, opts ...grpc.CallOption) (*QueryGetPoolMetadataResponse, error) { + out := new(QueryGetPoolMetadataResponse) + err := c.cc.Invoke(ctx, "/duality.dex.Query/PoolMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PoolMetadataAll(ctx context.Context, in *QueryAllPoolMetadataRequest, opts ...grpc.CallOption) (*QueryAllPoolMetadataResponse, error) { + out := new(QueryAllPoolMetadataResponse) + err := c.cc.Invoke(ctx, "/duality.dex.Query/PoolMetadataAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -2165,6 +2382,9 @@ type QueryServer interface { Pool(context.Context, *QueryPoolRequest) (*QueryPoolResponse, error) // Queries a pool by ID PoolByID(context.Context, *QueryPoolByIDRequest) (*QueryPoolResponse, error) + // Queries a list of PoolMetadata items. + PoolMetadata(context.Context, *QueryGetPoolMetadataRequest) (*QueryGetPoolMetadataResponse, error) + PoolMetadataAll(context.Context, *QueryAllPoolMetadataRequest) (*QueryAllPoolMetadataResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2222,6 +2442,12 @@ func (*UnimplementedQueryServer) Pool(ctx context.Context, req *QueryPoolRequest func (*UnimplementedQueryServer) PoolByID(ctx context.Context, req *QueryPoolByIDRequest) (*QueryPoolResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PoolByID not implemented") } +func (*UnimplementedQueryServer) PoolMetadata(ctx context.Context, req *QueryGetPoolMetadataRequest) (*QueryGetPoolMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolMetadata not implemented") +} +func (*UnimplementedQueryServer) PoolMetadataAll(ctx context.Context, req *QueryAllPoolMetadataRequest) (*QueryAllPoolMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolMetadataAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2533,6 +2759,42 @@ func _Query_PoolByID_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Query_PoolMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetPoolMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/duality.dex.Query/PoolMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolMetadata(ctx, req.(*QueryGetPoolMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PoolMetadataAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllPoolMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolMetadataAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/duality.dex.Query/PoolMetadataAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolMetadataAll(ctx, req.(*QueryAllPoolMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "duality.dex.Query", HandlerType: (*QueryServer)(nil), @@ -2605,6 +2867,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PoolByID", Handler: _Query_PoolByID_Handler, }, + { + MethodName: "PoolMetadata", + Handler: _Query_PoolMetadata_Handler, + }, + { + MethodName: "PoolMetadataAll", + Handler: _Query_PoolMetadataAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "duality/dex/query.proto", @@ -4014,78 +4284,223 @@ func (m *QueryPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryGetPoolMetadataRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n + +func (m *QueryGetPoolMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetPoolMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.Params != nil { - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Id != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryGetLimitOrderTrancheUserRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.TrancheKey) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryGetPoolMetadataResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return n + return dAtA[:n], nil } -func (m *QueryGetLimitOrderTrancheUserResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetPoolMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetPoolMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.LimitOrderTrancheUser != nil { - l = m.LimitOrderTrancheUser.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.PoolMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - return n + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (m *QueryAllLimitOrderTrancheUserRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryAllPoolMetadataRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *QueryAllPoolMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPoolMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllPoolMetadataResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllPoolMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPoolMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.PoolMetadata) > 0 { + for iNdEx := len(m.PoolMetadata) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolMetadata[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetLimitOrderTrancheUserRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.TrancheKey) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetLimitOrderTrancheUserResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LimitOrderTrancheUser != nil { + l = m.LimitOrderTrancheUser.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllLimitOrderTrancheUserRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -4594,6 +5009,61 @@ func (m *QueryPoolResponse) Size() (n int) { return n } +func (m *QueryGetPoolMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + return n +} + +func (m *QueryGetPoolMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PoolMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllPoolMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllPoolMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PoolMetadata) > 0 { + for _, e := range m.PoolMetadata { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -8463,6 +8933,364 @@ func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetPoolMetadataRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetPoolMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetPoolMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetPoolMetadataResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetPoolMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetPoolMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PoolMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllPoolMetadataRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllPoolMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllPoolMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllPoolMetadataResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllPoolMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllPoolMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PoolMetadata = append(m.PoolMetadata, PoolMetadata{}) + if err := m.PoolMetadata[len(m.PoolMetadata)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/dex/types/query.pb.gw.go b/x/dex/types/query.pb.gw.go index 759cb9c40..46c3ccc74 100644 --- a/x/dex/types/query.pb.gw.go +++ b/x/dex/types/query.pb.gw.go @@ -1227,6 +1227,96 @@ func local_request_Query_PoolByID_0(ctx context.Context, marshaler runtime.Marsh } +func request_Query_PoolMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetPoolMetadataRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.PoolMetadata(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolMetadata_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetPoolMetadataRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.PoolMetadata(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_PoolMetadataAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PoolMetadataAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPoolMetadataRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PoolMetadataAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PoolMetadataAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolMetadataAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPoolMetadataRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PoolMetadataAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PoolMetadataAll(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1624,6 +1714,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PoolMetadata_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PoolMetadata_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolMetadataAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PoolMetadataAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolMetadataAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2005,6 +2141,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PoolMetadata_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PoolMetadata_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolMetadataAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PoolMetadataAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PoolMetadataAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2042,6 +2218,10 @@ var ( pattern_Query_Pool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"duality", "dex", "pool", "pairID", "tickIndex", "fee"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_PoolByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"duality", "dex", "pool", "poolID"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PoolMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"duality-labs", "duality", "dex", "pool_metadata", "id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PoolMetadataAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"duality-labs", "duality", "dex", "pool_metadata"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -2078,4 +2258,8 @@ var ( forward_Query_Pool_0 = runtime.ForwardResponseMessage forward_Query_PoolByID_0 = runtime.ForwardResponseMessage + + forward_Query_PoolMetadata_0 = runtime.ForwardResponseMessage + + forward_Query_PoolMetadataAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index 07049a829..820b9453d 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -14,16 +14,16 @@ var _ DistributorKeeper = Keeper{} func (k Keeper) ValueForShares(ctx sdk.Context, coin sdk.Coin, tick int64) (sdk.Int, error) { totalShares := k.bk.GetSupply(ctx, coin.Denom).Amount - poolParams, err := k.dk.GetPoolParamsByDenom(ctx, coin.Denom) + poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, coin.Denom) if err != nil { return sdk.ZeroInt(), err } pool, err := k.dk.GetOrInitPool( ctx, - poolParams.PairID, - poolParams.Tick, - poolParams.Fee, + poolMetadata.PairID, + poolMetadata.Tick, + poolMetadata.Fee, ) if err != nil { return sdk.ZeroInt(), err @@ -127,11 +127,11 @@ func (k Keeper) GetRewardsEstimate( pairSet := map[dextypes.PairID]bool{} for _, l := range filterStakes { for _, c := range l.Coins { - poolParams, err := k.dk.GetPoolParamsByDenom(ctx, c.Denom) + poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, c.Denom) if err != nil { panic("all stakes should be valid deposit denoms") } - pairSet[*poolParams.PairID] = true + pairSet[*poolMetadata.PairID] = true } } diff --git a/x/incentives/keeper/query_server.go b/x/incentives/keeper/query_server.go index 26ae1647b..5d5a73fe7 100644 --- a/x/incentives/keeper/query_server.go +++ b/x/incentives/keeper/query_server.go @@ -92,14 +92,14 @@ func (q QueryServer) GetGauges( } var lowerTick, upperTick int64 - var poolParams *dextypes.PoolParams + var poolMetadata *dextypes.PoolMetadata if req.Denom != "" { - poolParams, err := q.dk.GetPoolParamsByDenom(ctx, req.Denom) + poolMetadata, err := q.dk.GetPoolMetadataByDenom(ctx, req.Denom) if err != nil { return nil, err } - lowerTick = poolParams.Tick - int64(poolParams.Fee) - upperTick = poolParams.Tick + int64(poolParams.Fee) + lowerTick = poolMetadata.Tick - int64(poolMetadata.Fee) + upperTick = poolMetadata.Tick + int64(poolMetadata.Fee) } gauges := types.Gauges{} @@ -116,7 +116,7 @@ func (q QueryServer) GetGauges( } if req.Denom != "" { for _, gauge := range newGauges { - if *gauge.DistributeTo.PairID != *poolParams.PairID { + if *gauge.DistributeTo.PairID != *poolMetadata.PairID { continue } lowerTickInRange := gauge.DistributeTo.StartTick <= lowerTick && diff --git a/x/incentives/keeper/stake.go b/x/incentives/keeper/stake.go index bdc9eae1e..8529e016d 100644 --- a/x/incentives/keeper/stake.go +++ b/x/incentives/keeper/stake.go @@ -236,12 +236,12 @@ func (k Keeper) StakeCoinsPassingQueryCondition( coins := stake.Coins result := sdk.NewCoins() for _, c := range coins { - poolParams, err := k.dk.GetPoolParamsByDenom(ctx, c.Denom) + poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, c.Denom) if err != nil { continue } - if distrTo.Test(poolParams) { + if distrTo.Test(poolMetadata) { result = result.Add(c) } } diff --git a/x/incentives/keeper/stake_refs.go b/x/incentives/keeper/stake_refs.go index 953921a8f..fc5d45a56 100644 --- a/x/incentives/keeper/stake_refs.go +++ b/x/incentives/keeper/stake_refs.go @@ -47,13 +47,13 @@ func (k Keeper) getStakeRefKeys(ctx sdk.Context, stake *types.Stake) ([][]byte, refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexAccount, owner))] = true for _, coin := range stake.Coins { - poolParams, err := k.dk.GetPoolParamsByDenom(ctx, coin.Denom) + poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, coin.Denom) if err != nil { panic("Only valid LP tokens should be staked") } denomBz := []byte(coin.Denom) - pairIDBz := []byte(poolParams.PairID.CanonicalString()) - tickBz := dextypes.TickIndexToBytes(poolParams.Tick) + pairIDBz := []byte(poolMetadata.PairID.CanonicalString()) + tickBz := dextypes.TickIndexToBytes(poolMetadata.Tick) refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexDenom, denomBz))] = true refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexPairTick, pairIDBz, tickBz))] = true refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexAccountDenom, owner, denomBz))] = true diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go index f44eb7bbf..6c2c45461 100644 --- a/x/incentives/types/expected_keepers.go +++ b/x/incentives/types/expected_keepers.go @@ -34,5 +34,5 @@ type AccountKeeper interface { type DexKeeper interface { GetOrInitPool(ctx sdk.Context, pairID *types.PairID, centerTickIndex int64, fee uint64) (*dextypes.Pool, error) - GetPoolParamsByDenom(ctx sdk.Context, id string) (types.PoolParams, error) + GetPoolMetadataByDenom(ctx sdk.Context, id string) (types.PoolMetadata, error) } diff --git a/x/incentives/types/query_condition.go b/x/incentives/types/query_condition.go index 3bed6f25f..a43d847e7 100644 --- a/x/incentives/types/query_condition.go +++ b/x/incentives/types/query_condition.go @@ -4,13 +4,13 @@ import ( dextypes "github.com/duality-labs/duality/x/dex/types" ) -func (qc QueryCondition) Test(poolParams dextypes.PoolParams) bool { - if !poolParams.PairID.Equal(qc.PairID) { +func (qc QueryCondition) Test(poolMetadata dextypes.PoolMetadata) bool { + if !poolMetadata.PairID.Equal(qc.PairID) { return false } - lowerTick := poolParams.Tick - int64(poolParams.Fee) - upperTick := poolParams.Tick + int64(poolParams.Fee) + lowerTick := poolMetadata.Tick - int64(poolMetadata.Fee) + upperTick := poolMetadata.Tick + int64(poolMetadata.Fee) lowerTickQualifies := qc.StartTick <= lowerTick && lowerTick <= qc.EndTick upperTickQualifies := qc.StartTick <= upperTick && upperTick <= qc.EndTick diff --git a/x/incentives/types/query_condition_test.go b/x/incentives/types/query_condition_test.go index b5e4a58d5..0880da5e7 100644 --- a/x/incentives/types/query_condition_test.go +++ b/x/incentives/types/query_condition_test.go @@ -18,44 +18,44 @@ func TestQueryCondition(t *testing.T) { tests := []struct { name string queryCond QueryCondition - poolParams dextypes.PoolParams + poolMetadata dextypes.PoolMetadata testResult bool }{ { name: "Matching denom and tick range", queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - poolParams: dextypes.NewPoolParams(pairID, 15, 5, 0), + poolMetadata: dextypes.NewPoolMetadata(pairID, 15, 5, 0), testResult: true, }, { name: "Non-matching denom", queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - poolParams: dextypes.NewPoolParams(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 5, 0), + poolMetadata: dextypes.NewPoolMetadata(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 5, 0), testResult: false, }, { name: "Non-matching tick range", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolParams: dextypes.NewPoolParams(pairID, 15, 6, 0), + poolMetadata: dextypes.NewPoolMetadata(pairID, 15, 6, 0), testResult: false, }, { name: "Non-matching tick fee range lower", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolParams: dextypes.NewPoolParams(pairID, 10, 5, 0), + poolMetadata: dextypes.NewPoolMetadata(pairID, 10, 5, 0), testResult: false, }, { name: "Non-matching tick fee range upper", queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolParams: dextypes.NewPoolParams(pairID, 20, 5, 0), + poolMetadata: dextypes.NewPoolMetadata(pairID, 20, 5, 0), testResult: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - result := tt.queryCond.Test(tt.poolParams) + result := tt.queryCond.Test(tt.poolMetadata) assert.Equal(t, tt.testResult, result) }) } From e2b39d3f867eebc91f7d536908280bd36a82db68 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Thu, 31 Aug 2023 20:31:00 -0700 Subject: [PATCH 14/16] random fixes --- proto/duality/dex/genesis.proto | 9 +- proto/duality/dex/query.proto | 17 +- x/dex/keeper/pool.go | 50 +++--- x/dex/keeper/pool_reserves_test.go | 10 +- x/dex/types/genesis.go | 6 +- x/dex/types/genesis.pb.go | 77 ++++---- x/dex/types/query.pb.go | 270 ++++++++++++++--------------- x/dex/types/query.pb.gw.go | 4 +- 8 files changed, 219 insertions(+), 224 deletions(-) diff --git a/proto/duality/dex/genesis.proto b/proto/duality/dex/genesis.proto index 3301d5555..a21279d40 100644 --- a/proto/duality/dex/genesis.proto +++ b/proto/duality/dex/genesis.proto @@ -17,11 +17,10 @@ option go_package = "github.com/duality-labs/duality/x/dex/types"; message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; repeated TickLiquidity tickLiquidityList = 2 [(gogoproto.nullable) = true ]; - repeated LimitOrderTranche inactiveLimitOrderTrancheList = 6 [(gogoproto.nullable) = true ]; - repeated LimitOrderTrancheUser limitOrderTrancheUserList = 7 [(gogoproto.nullable) = true ]; - + repeated LimitOrderTranche inactiveLimitOrderTrancheList = 3 [(gogoproto.nullable) = true ]; + repeated LimitOrderTrancheUser limitOrderTrancheUserList = 4 [(gogoproto.nullable) = true ]; + repeated PoolMetadata poolMetadataList = 5 [(gogoproto.nullable) = false]; + uint64 poolCount = 6; // this line is used by starport scaffolding # genesis/proto/state - repeated PoolMetadata poolMetadataList = 8 [(gogoproto.nullable) = false]; - uint64 poolCount = 9; } diff --git a/proto/duality/dex/query.proto b/proto/duality/dex/query.proto index 2606afb1a..f34784fd6 100644 --- a/proto/duality/dex/query.proto +++ b/proto/duality/dex/query.proto @@ -24,7 +24,6 @@ option go_package = "github.com/duality-labs/duality/x/dex/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/duality/dex/params"; @@ -127,17 +126,20 @@ service Query { } - // this line is used by starport scaffolding # 2 - - // Queries a list of PoolMetadata items. + // Queries a PoolMetadata by ID rpc PoolMetadata (QueryGetPoolMetadataRequest) returns (QueryGetPoolMetadataResponse) { - option (google.api.http).get = "/duality-labs/duality/dex/pool_metadata/{id}"; + option (google.api.http).get = "/duality/dex/pool_metadata/{id}"; } + + // Queries a list of PoolMetadata items. rpc PoolMetadataAll (QueryAllPoolMetadataRequest) returns (QueryAllPoolMetadataResponse) { - option (google.api.http).get = "/duality-labs/duality/dex/pool_metadata"; + option (google.api.http).get = "/duality/dex/pool_metadata"; } + +// this line is used by starport scaffolding # 2 + } // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} @@ -326,7 +328,6 @@ message QueryPoolResponse { } -// this line is used by starport scaffolding # 3 message QueryGetPoolMetadataRequest { uint64 id = 1; } @@ -344,3 +345,5 @@ message QueryAllPoolMetadataResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +// this line is used by starport scaffolding # 3 + diff --git a/x/dex/keeper/pool.go b/x/dex/keeper/pool.go index 5e26294bd..4eec19432 100644 --- a/x/dex/keeper/pool.go +++ b/x/dex/keeper/pool.go @@ -31,7 +31,7 @@ func (k Keeper) InitPool( ) (pool *types.Pool, err error) { poolMetadata := types.PoolMetadata{PairID: pairID, Tick: centerTickIndexNormalized, Fee: fee} - // Get current pool poolID + // Get current poolID poolID := k.GetPoolCount(ctx) poolMetadata.ID = poolID @@ -103,21 +103,6 @@ func (k Keeper) GetPoolByID(ctx sdk.Context, poolID uint64) (pool *types.Pool, f return k.GetPool(ctx, poolMetadata.PairID, poolMetadata.Tick, poolMetadata.Fee) } -// GetPoolCount get the total number of pool -func (k Keeper) GetPoolCount(ctx sdk.Context) uint64 { - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) - byteKey := types.KeyPrefix(types.PoolCountKeyPrefix) - bz := store.Get(byteKey) - - // Count doesn't exist: no element - if bz == nil { - return 0 - } - - // Parse bytes - return binary.BigEndian.Uint64(bz) -} - func (k Keeper) GetPoolIDByParams( ctx sdk.Context, pairID *types.PairID, @@ -135,15 +120,6 @@ func (k Keeper) GetPoolIDByParams( return poolID, true } -// SetPoolCount set the total number of pool -func (k Keeper) SetPoolCount(ctx sdk.Context, count uint64) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) - byteKey := types.KeyPrefix(types.PoolCountKeyPrefix) - bz := make([]byte, 8) - binary.BigEndian.PutUint64(bz, count) - store.Set(byteKey, bz) -} - func (k Keeper) SetPool(ctx sdk.Context, pool *types.Pool) { if pool.LowerTick0.HasToken() { k.SetPoolReserves(ctx, pool.LowerTick0) @@ -161,3 +137,27 @@ func (k Keeper) SetPool(ctx sdk.Context, pool *types.Pool) { ctx.EventManager().EmitEvent(types.CreateTickUpdatePoolReserves(*pool.LowerTick0)) ctx.EventManager().EmitEvent(types.CreateTickUpdatePoolReserves(*pool.UpperTick1)) } + +// GetPoolCount get the total number of pools +func (k Keeper) GetPoolCount(ctx sdk.Context) uint64 { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.KeyPrefix(types.PoolCountKeyPrefix) + bz := store.Get(byteKey) + + // Count doesn't exist: no element + if bz == nil { + return 0 + } + + // Parse bytes + return binary.BigEndian.Uint64(bz) +} + +// SetPoolCount set the total number of pools +func (k Keeper) SetPoolCount(ctx sdk.Context, count uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.KeyPrefix(types.PoolCountKeyPrefix) + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, count) + store.Set(byteKey, bz) +} diff --git a/x/dex/keeper/pool_reserves_test.go b/x/dex/keeper/pool_reserves_test.go index 61ef9cd05..50f5f35ff 100644 --- a/x/dex/keeper/pool_reserves_test.go +++ b/x/dex/keeper/pool_reserves_test.go @@ -13,16 +13,10 @@ import ( func createNPoolReserves(k *keeper.Keeper, ctx sdk.Context, n int) []*types.PoolReserves { items := make([]*types.PoolReserves, n) - for i := range items { - pool, err := k.InitPool(ctx, types.MustNewPairID("TokenA", "TokenB"), int64(i), uint64(i)) - if err != nil { - panic("failed to create pool") - } - pool.Deposit(sdk.NewInt(10), sdk.NewInt(0), sdk.ZeroInt(), true) - k.SetPool(ctx, pool) + pools := createNPools(k, ctx, n) + for i, pool := range pools { items[i] = pool.LowerTick0 } - return items } diff --git a/x/dex/types/genesis.go b/x/dex/types/genesis.go index 89dd2b10e..c1ebd607b 100644 --- a/x/dex/types/genesis.go +++ b/x/dex/types/genesis.go @@ -60,16 +60,16 @@ func (gs GenesisState) Validate() error { inactiveLimitOrderTrancheKeyMap[index] = struct{}{} } // Check for duplicated ID in poolMetadata - poolMetadataIdMap := make(map[uint64]bool) + poolMetadataIDMap := make(map[uint64]bool) poolMetadataCount := gs.GetPoolCount() for _, elem := range gs.PoolMetadataList { - if _, ok := poolMetadataIdMap[elem.ID]; ok { + if _, ok := poolMetadataIDMap[elem.ID]; ok { return fmt.Errorf("duplicated id for poolMetadata") } if elem.ID >= poolMetadataCount { return fmt.Errorf("poolMetadata id should be lower or equal than the last id") } - poolMetadataIdMap[elem.ID] = true + poolMetadataIDMap[elem.ID] = true } // this line is used by starport scaffolding # genesis/types/validate diff --git a/x/dex/types/genesis.pb.go b/x/dex/types/genesis.pb.go index ab2dcae4d..d1469d8d6 100644 --- a/x/dex/types/genesis.pb.go +++ b/x/dex/types/genesis.pb.go @@ -27,11 +27,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` TickLiquidityList []*TickLiquidity `protobuf:"bytes,2,rep,name=tickLiquidityList,proto3" json:"tickLiquidityList,omitempty"` - InactiveLimitOrderTrancheList []*LimitOrderTranche `protobuf:"bytes,6,rep,name=inactiveLimitOrderTrancheList,proto3" json:"inactiveLimitOrderTrancheList,omitempty"` - LimitOrderTrancheUserList []*LimitOrderTrancheUser `protobuf:"bytes,7,rep,name=limitOrderTrancheUserList,proto3" json:"limitOrderTrancheUserList,omitempty"` - // this line is used by starport scaffolding # genesis/proto/state - PoolMetadataList []PoolMetadata `protobuf:"bytes,8,rep,name=poolMetadataList,proto3" json:"poolMetadataList"` - PoolCount uint64 `protobuf:"varint,9,opt,name=poolCount,proto3" json:"poolCount,omitempty"` + InactiveLimitOrderTrancheList []*LimitOrderTranche `protobuf:"bytes,3,rep,name=inactiveLimitOrderTrancheList,proto3" json:"inactiveLimitOrderTrancheList,omitempty"` + LimitOrderTrancheUserList []*LimitOrderTrancheUser `protobuf:"bytes,4,rep,name=limitOrderTrancheUserList,proto3" json:"limitOrderTrancheUserList,omitempty"` + PoolMetadataList []PoolMetadata `protobuf:"bytes,5,rep,name=poolMetadataList,proto3" json:"poolMetadataList"` + PoolCount uint64 `protobuf:"varint,6,opt,name=poolCount,proto3" json:"poolCount,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -116,32 +115,32 @@ func init() { func init() { proto.RegisterFile("duality/dex/genesis.proto", fileDescriptor_6ccf50bb6779a67a) } var fileDescriptor_6ccf50bb6779a67a = []byte{ - // 391 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x4e, 0xfa, 0x40, - 0x14, 0xc5, 0xdb, 0x3f, 0x84, 0xbf, 0x0c, 0x2e, 0xb4, 0xba, 0x28, 0x8d, 0x96, 0x86, 0xc4, 0x84, - 0x68, 0x6c, 0x23, 0xbe, 0x01, 0xc6, 0xb8, 0x10, 0x3f, 0x82, 0xb8, 0x71, 0xd3, 0x0c, 0xed, 0x58, - 0x46, 0xdb, 0x0e, 0xb6, 0x53, 0x03, 0x6f, 0xe1, 0x63, 0xb1, 0x64, 0xe9, 0xca, 0x18, 0x78, 0x11, - 0x33, 0x1f, 0xc4, 0x56, 0x22, 0xee, 0xda, 0x7b, 0x7f, 0xf7, 0x9c, 0x7b, 0x6e, 0x06, 0xd4, 0xfd, - 0x0c, 0x86, 0x98, 0x4e, 0x1c, 0x1f, 0x8d, 0x9d, 0x00, 0xc5, 0x28, 0xc5, 0xa9, 0x3d, 0x4a, 0x08, - 0x25, 0x5a, 0x4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, 0x87, 0xd1, 0xd2, 0xeb, 0x77, 0x29, - 0xed, 0x12, 0x6c, 0xb1, 0xf3, 0x5f, 0xc9, 0xeb, 0x73, 0xf9, 0x0d, 0x2e, 0x5f, 0x2f, 0x1e, 0x38, - 0x07, 0xc9, 0x33, 0xaf, 0x0c, 0x6a, 0x7b, 0xa0, 0xca, 0x6a, 0x67, 0x24, 0x8b, 0xa9, 0x5e, 0xb5, - 0xd4, 0x56, 0xb9, 0xf7, 0x5d, 0xe8, 0x9c, 0x4f, 0xe7, 0xa6, 0x3a, 0x9b, 0x9b, 0xea, 0xe7, 0xdc, - 0x54, 0xdf, 0x16, 0xa6, 0x32, 0x5b, 0x98, 0xca, 0xfb, 0xc2, 0x54, 0x1e, 0x8e, 0x02, 0x4c, 0x87, - 0xd9, 0xc0, 0xf6, 0x48, 0xe4, 0x48, 0xd3, 0xe3, 0x10, 0x0e, 0xd2, 0xe5, 0x8f, 0x33, 0x16, 0x2f, - 0x69, 0x32, 0x42, 0xe9, 0xa0, 0xc2, 0x1f, 0xc8, 0xe9, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, - 0x3a, 0x05, 0xa4, 0x10, 0x03, 0x00, 0x00, + // 392 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcf, 0x4e, 0xea, 0x40, + 0x14, 0xc6, 0xdb, 0x0b, 0x97, 0xe4, 0x0e, 0x77, 0x71, 0x6f, 0x75, 0x51, 0x1a, 0x2d, 0x0d, 0x89, + 0x09, 0xd1, 0xd8, 0x46, 0x7c, 0x03, 0x8c, 0x71, 0x21, 0xfe, 0x09, 0xe2, 0xc6, 0x4d, 0x33, 0xb4, + 0x63, 0x19, 0x6d, 0x3b, 0xd8, 0x99, 0x1a, 0x78, 0x0b, 0x1f, 0x8b, 0x25, 0x4b, 0x57, 0xc6, 0xc0, + 0x8b, 0x98, 0xf9, 0x43, 0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, 0xf4, 0x81, 0x4c, 0x2e, + 0xb4, 0x2b, 0x42, 0xdb, 0x2e, 0x69, 0xaf, 0x91, 0x4a, 0x7f, 0xb3, 0x94, 0x71, 0x0f, 0x1a, 0xf1, + 0xd7, 0xc6, 0x2d, 0x45, 0x99, 0xf0, 0xa9, 0x0a, 0x9f, 0xd6, 0x66, 0x1f, 0x4e, 0x2b, 0xaf, 0xef, + 0xa5, 0x8c, 0x73, 0xf0, 0x8f, 0x9f, 0xff, 0x42, 0x5d, 0x5f, 0xc8, 0xff, 0x16, 0xf2, 0x8d, 0xf2, + 0x81, 0x0b, 0x90, 0x3a, 0xf3, 0xda, 0xa0, 0xb1, 0x03, 0xfe, 0xf0, 0xda, 0x09, 0xc9, 0x53, 0x66, + 0xd6, 0x1c, 0xbd, 0x5d, 0xed, 0x7f, 0x16, 0xba, 0xa7, 0xb3, 0x85, 0xad, 0xcf, 0x17, 0xb6, 0xfe, + 0xbe, 0xb0, 0xf5, 0x97, 0xa5, 0xad, 0xcd, 0x97, 0xb6, 0xf6, 0xba, 0xb4, 0xb5, 0xbb, 0x83, 0x08, + 0xb3, 0x51, 0x3e, 0x74, 0x03, 0x92, 0x78, 0xca, 0xf4, 0x30, 0x86, 0x43, 0xba, 0xfa, 0xf1, 0x26, + 0xf2, 0x25, 0x4d, 0xc7, 0x88, 0x0e, 0x6b, 0xe2, 0x81, 0x1c, 0x7f, 0x04, 0x00, 0x00, 0xff, 0xff, + 0xb6, 0x99, 0x5f, 0x53, 0x10, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -167,7 +166,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.PoolCount != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.PoolCount)) i-- - dAtA[i] = 0x48 + dAtA[i] = 0x30 } if len(m.PoolMetadataList) > 0 { for iNdEx := len(m.PoolMetadataList) - 1; iNdEx >= 0; iNdEx-- { @@ -180,7 +179,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x2a } } if len(m.LimitOrderTrancheUserList) > 0 { @@ -194,7 +193,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x22 } } if len(m.InactiveLimitOrderTrancheList) > 0 { @@ -208,7 +207,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x1a } } if len(m.TickLiquidityList) > 0 { @@ -389,7 +388,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InactiveLimitOrderTrancheList", wireType) } @@ -423,7 +422,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LimitOrderTrancheUserList", wireType) } @@ -457,7 +456,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PoolMetadataList", wireType) } @@ -491,7 +490,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PoolCount", wireType) } diff --git a/x/dex/types/query.pb.go b/x/dex/types/query.pb.go index 0c565aa68..22c33c8e3 100644 --- a/x/dex/types/query.pb.go +++ b/x/dex/types/query.pb.go @@ -1752,7 +1752,6 @@ func (m *QueryPoolResponse) GetPool() *Pool { return nil } -// this line is used by starport scaffolding # 3 type QueryGetPoolMetadataRequest struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } @@ -1980,140 +1979,141 @@ func init() { func init() { proto.RegisterFile("duality/dex/query.proto", fileDescriptor_4664128fddcf2b7a) } var fileDescriptor_4664128fddcf2b7a = []byte{ - // 2125 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x5a, 0xcd, 0x6f, 0x1b, 0xc7, - 0x15, 0xd7, 0x88, 0xb2, 0x2c, 0x8f, 0x13, 0x5b, 0x1e, 0xcb, 0x09, 0x4d, 0x2b, 0xa4, 0x32, 0xf5, - 0x87, 0xfc, 0x21, 0xae, 0xa5, 0xd4, 0x69, 0xeb, 0x06, 0x6d, 0xa5, 0x28, 0x71, 0xd4, 0xda, 0xb5, - 0xba, 0x91, 0x0f, 0x4d, 0x8b, 0xb2, 0x2b, 0x72, 0x2c, 0x2f, 0xb4, 0xe4, 0xae, 0x77, 0x97, 0xb6, - 0x08, 0x41, 0x28, 0xda, 0x4b, 0x4f, 0x45, 0xd3, 0x36, 0x40, 0xd2, 0xa2, 0x3d, 0x04, 0xbd, 0x1a, - 0x68, 0xd0, 0x3f, 0xa0, 0xe8, 0xa1, 0x07, 0x1f, 0x0d, 0xf4, 0x12, 0x14, 0x28, 0x5b, 0xd8, 0x05, - 0x0a, 0xf8, 0xa8, 0xbf, 0x20, 0x98, 0xd9, 0xb7, 0xe4, 0x0c, 0x39, 0xcb, 0x5d, 0xda, 0x0c, 0x7c, - 0xb2, 0x76, 0xe6, 0xbd, 0x79, 0xbf, 0xf7, 0x9b, 0xdf, 0x7c, 0x3d, 0x1a, 0xbf, 0x5a, 0x6b, 0x5a, - 0x8e, 0x1d, 0xb6, 0x8c, 0x1a, 0xdb, 0x31, 0xee, 0x36, 0x99, 0xdf, 0x2a, 0x7b, 0xbe, 0x1b, 0xba, - 0xe4, 0x30, 0x74, 0x94, 0x6b, 0x6c, 0x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xbc, 0x11, 0x97, 0x3c, 0x56, 0xa6, 0xf8, 0x42, 0xff, 0xf0, - 0x3f, 0x25, 0x64, 0xf6, 0xf8, 0x92, 0x16, 0x7e, 0xa9, 0x6e, 0xed, 0x2c, 0x0b, 0x5c, 0x9c, 0x9b, - 0x43, 0x22, 0xef, 0x5b, 0xdc, 0x7e, 0xa8, 0xbc, 0x95, 0x51, 0xf6, 0xdb, 0xa5, 0xe3, 0x51, 0xee, - 0x72, 0x2b, 0x35, 0x15, 0x23, 0xda, 0xce, 0xc1, 0xeb, 0x3f, 0x51, 0x2e, 0x20, 0xe4, 0xdf, 0x20, - 0x7c, 0x38, 0x74, 0x43, 0xcb, 0x59, 0x6b, 0x70, 0xed, 0xa5, 0xab, 0x79, 0x63, 0x78, 0x35, 0xcb, - 0x01, 0xf6, 0xdb, 0x25, 0x12, 0xc1, 0x97, 0x1a, 0xa9, 0x29, 0x9b, 0x90, 0x5f, 0x21, 0x8c, 0x83, - 0xfb, 0x96, 0x07, 0x90, 0xc6, 0xd3, 0x20, 0x99, 0xc3, 0x43, 0x92, 0xc6, 0xdf, 0x6f, 0x97, 0x8e, - 0x45, 0x88, 0xba, 0x6d, 0xd4, 0x94, 0x0c, 0x04, 0x47, 0xfc, 0xf3, 0x66, 0x33, 0x14, 0x80, 0x72, - 0x5f, 0x06, 0x47, 0x52, 0x80, 0x2e, 0x47, 0x52, 0x23, 0x35, 0x65, 0x13, 0xfa, 0x01, 0x9e, 0x8e, - 0x6a, 0x62, 0xe2, 0x7c, 0x79, 0x9e, 0x4a, 0x04, 0x9c, 0x85, 0xb9, 0xee, 0x59, 0x58, 0xc6, 0x33, - 0x9d, 0xb1, 0x57, 0x5a, 0x6b, 0xab, 0xf2, 0xf8, 0xae, 0xeb, 0xc0, 0xf8, 0x13, 0x26, 0x7c, 0xd1, - 0xef, 0xe0, 0x63, 0x12, 0x16, 0x10, 0xd6, 0x45, 0x3c, 0xc1, 0xbb, 0x41, 0x50, 0xc7, 0xfa, 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2, 0x2a, 0x4a, 0x85, - 0x37, 0x87, 0x75, 0x83, 0x24, 0x7e, 0x24, 0x92, 0xb8, 0x45, 0xde, 0x57, 0x92, 0xb8, 0x6d, 0x3b, - 0x0e, 0xab, 0x55, 0x9e, 0x77, 0x63, 0xf8, 0x1b, 0xc2, 0xb3, 0x89, 0x10, 0xf8, 0xcc, 0x5c, 0xd1, - 0xd2, 0xfd, 0x2c, 0xc9, 0x66, 0x29, 0x80, 0x51, 0x43, 0x24, 0x7b, 0x9e, 0x9c, 0xcb, 0x98, 0x2c, - 0xf9, 0x13, 0xc2, 0x47, 0xe5, 0xd2, 0x43, 0xf2, 0x4a, 0xd4, 0x94, 0x56, 0x12, 0x56, 0xa2, 0xae, - 0x06, 0x42, 0xaf, 0x08, 0x64, 0x06, 0x59, 0x30, 0x12, 0x7f, 0x57, 0xd6, 0x49, 0xe9, 0x01, 0x8a, - 0x6e, 0x30, 0x9d, 0xaa, 0xd1, 0xbc, 0x56, 0x06, 0x19, 0xc1, 0x25, 0x14, 0x68, 0xe8, 0x35, 0x01, - 0x6e, 0x99, 0x7c, 0x7b, 0x28, 0x70, 0xaa, 0x2c, 0x6e, 0x33, 0xb6, 0x47, 0xfe, 0x8c, 0xf0, 0x8c, - 0xee, 0xed, 0xaf, 0x3b, 0x28, 0x06, 0xd4, 0x71, 0x74, 0x07, 0xc5, 0xa0, 0x92, 0x42, 0xc2, 0x3e, - 0xc7, 0xc0, 0xa5, 0x52, 0xe7, 0x3e, 0x95, 0x3b, 0xae, 0x57, 0xe1, 0xcf, 0x00, 0xf2, 0x17, 0x84, - 0x5f, 0x4d, 0x78, 0xdb, 0x91, 0xcb, 0xc9, 0x91, 0xf5, 0x55, 0x83, 0xc2, 0xe2, 0x10, 0x1e, 0x03, - 0x65, 0xda, 0x81, 0xeb, 0x71, 0x37, 0x59, 0xae, 0x64, 0x17, 0x4f, 0xf0, 0x89, 0x23, 0xaf, 0x69, - 0x2e, 0x83, 0xdd, 0x47, 0x4c, 0xa1, 0x98, 0xd4, 0x0d, 0x71, 0xbf, 0x2a, 0xe2, 0x96, 0xc9, 0xa5, - 0xbe, 0x79, 0x96, 0xa7, 0xb7, 0x77, 0x52, 0xef, 0xe2, 0xa9, 0xf8, 0x35, 0x43, 0x5e, 0xd7, 0x47, - 0x90, 0x5e, 0x3a, 0xa9, 0x20, 0xa8, 0x00, 0x31, 0x4b, 0x0a, 0x3a, 0x10, 0xe2, 0x51, 0xb4, 0x47, - 0x7e, 0x8f, 0xd4, 0x8b, 0xfb, 0x00, 0xd9, 0xf7, 0xbc, 0x2d, 0x06, 0xc8, 0xbe, 0xf7, 0x75, 0xd0, - 0x4f, 0xc7, 0x82, 0x63, 0x6d, 0x06, 0x46, 0xe2, 0x7f, 0xb4, 0x30, 0x76, 0xed, 0xda, 0x1e, 0xf9, - 0x18, 0xb6, 0x8c, 0x78, 0xb8, 0xc1, 0x5b, 0x46, 0x06, 0x78, 0x09, 0x8f, 0x97, 0x7e, 0x95, 0xa4, - 0xc0, 0x5b, 0x79, 0xe7, 0xe1, 0xe3, 0x22, 0x7a, 0xf4, 0xb8, 0x88, 0xfe, 0xfb, 0xb8, 0x88, 0x3e, - 0x7c, 0x52, 0x1c, 0x7b, 0xf4, 0xa4, 0x38, 0xf6, 0xf9, 0x93, 0xe2, 0xd8, 0x07, 0x17, 0xa5, 0xc7, - 0xb4, 0x76, 0xb0, 0x9d, 0xe8, 0x68, 0xe3, 0xaf, 0xea, 0xcd, 0x49, 0x51, 0xa8, 0x79, 0xe3, 0x8b, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x33, 0xa8, 0x4d, 0x75, 0x5b, 0x24, 0x00, 0x00, + // 2131 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x5a, 0xcf, 0x6f, 0x1b, 0xc7, + 0x15, 0xd6, 0x88, 0xb2, 0x2c, 0x8f, 0x13, 0x5b, 0x1e, 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f, 0x0d, 0xdd, 0xd0, 0x72, 0x4a, 0x75, 0xae, 0xbd, 0xc1, 0x6a, 0xde, 0x18, 0x5e, 0xcd, + 0x72, 0x80, 0xfd, 0x56, 0x81, 0x44, 0xf0, 0xa5, 0x46, 0x6a, 0xca, 0x26, 0xe4, 0x57, 0x08, 0xe3, + 0xe0, 0xa1, 0xe5, 0x01, 0xa4, 0xf1, 0x41, 0x90, 0xcc, 0xe1, 0x21, 0x49, 0xe3, 0xef, 0xb7, 0x0a, + 0x27, 0x22, 0x44, 0x9d, 0x36, 0x6a, 0x4a, 0x06, 0x82, 0x23, 0xfe, 0x79, 0xbb, 0x11, 0x0a, 0x40, + 0x99, 0xcf, 0x83, 0x23, 0x29, 0x40, 0x87, 0x23, 0xa9, 0x91, 0x9a, 0xb2, 0x09, 0x7d, 0x1f, 0x4f, + 0x47, 0x35, 0x31, 0x71, 0xbe, 0x1c, 0xa4, 0x12, 0x01, 0x67, 0x61, 0xa6, 0x73, 0x16, 0x16, 0xf1, + 0x4c, 0x7b, 0xec, 0xd5, 0x66, 0x69, 0x4d, 0x1e, 0xdf, 0x75, 0x1d, 0x18, 0x7f, 0xc2, 0x84, 0x2f, + 0xfa, 0x2d, 0x7c, 0x42, 0xc2, 0x02, 0xc2, 0xba, 0x8c, 0x27, 0x78, 0x37, 0x08, 0xea, 0x44, 0xcf, + 0x41, 0x09, 0x07, 0xa4, 0x30, 0xa2, 0x8b, 0xea, 0xf1, 0x7f, 0x0b, 0xaa, 0x82, 0x71, 0xe0, 0x63, + 0x78, 0xdc, 0xae, 0x42, 0xd0, 0x71, 0xbb, 0xda, 0x7d, 0x58, 0x77, 0xcc, 0x3b, 0x87, 0xb5, 0xdc, + 0x9e, 0x78, 0x58, 0xc7, 0x06, 0x02, 0xcb, 0x98, 0xa9, 0x38, 0x51, 0xa6, 0x5e, 0xed, 0xba, 0x31, + 0x8d, 0xea, 0x76, 0xdc, 0x7d, 0x51, 0x4b, 0x91, 0x4c, 0x66, 0xe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a0, 0xf3, 0x02, 0xc9, 0x59, 0x52, 0x30, 0x12, 0xff, 0x6f, 0x85, 0xb1, 0x6b, 0x57, 0xf7, 0xc8, + 0x2f, 0x60, 0x97, 0x88, 0x47, 0xe8, 0xbf, 0x4b, 0xa4, 0x40, 0x94, 0xf0, 0x5e, 0xe9, 0xc3, 0x4d, + 0x1b, 0xd1, 0xea, 0xdb, 0x8f, 0x9f, 0xe6, 0xd1, 0x93, 0xa7, 0x79, 0xf4, 0xdf, 0xa7, 0x79, 0xf4, + 0xc1, 0xb3, 0xfc, 0xd8, 0x93, 0x67, 0xf9, 0xb1, 0x4f, 0x9f, 0xe5, 0xc7, 0xde, 0xbf, 0x2c, 0x3d, + 0x99, 0xc1, 0x7f, 0xd1, 0xb1, 0x36, 0x83, 0xf6, 0x60, 0x3b, 0xd1, 0x01, 0xc6, 0xdf, 0xce, 0x9b, + 0x93, 0xa2, 0x1c, 0xf3, 0xfa, 0x67, 0x01, 0x00, 0x00, 0xff, 0xff, 0x22, 0xde, 0x09, 0xcd, 0x41, + 0x24, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/dex/types/query.pb.gw.go b/x/dex/types/query.pb.gw.go index 46c3ccc74..de1eaba49 100644 --- a/x/dex/types/query.pb.gw.go +++ b/x/dex/types/query.pb.gw.go @@ -2219,9 +2219,9 @@ var ( pattern_Query_PoolByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"duality", "dex", "pool", "poolID"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PoolMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"duality-labs", "duality", "dex", "pool_metadata", "id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PoolMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"duality", "dex", "pool_metadata", "id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PoolMetadataAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"duality-labs", "duality", "dex", "pool_metadata"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PoolMetadataAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"duality", "dex", "pool_metadata"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( From 9b6a9419b63c414064d2788445dcbe773cc18ecf Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Fri, 1 Sep 2023 14:14:38 -0700 Subject: [PATCH 15/16] update protos --- x/dex/types/query.pb.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x/dex/types/query.pb.go b/x/dex/types/query.pb.go index 22c33c8e3..01bcc1ae5 100644 --- a/x/dex/types/query.pb.go +++ b/x/dex/types/query.pb.go @@ -2162,8 +2162,9 @@ type QueryClient interface { Pool(ctx context.Context, in *QueryPoolRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) // Queries a pool by ID PoolByID(ctx context.Context, in *QueryPoolByIDRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) - // Queries a list of PoolMetadata items. + // Queries a PoolMetadata by ID PoolMetadata(ctx context.Context, in *QueryGetPoolMetadataRequest, opts ...grpc.CallOption) (*QueryGetPoolMetadataResponse, error) + // Queries a list of PoolMetadata items. PoolMetadataAll(ctx context.Context, in *QueryAllPoolMetadataRequest, opts ...grpc.CallOption) (*QueryAllPoolMetadataResponse, error) } @@ -2382,8 +2383,9 @@ type QueryServer interface { Pool(context.Context, *QueryPoolRequest) (*QueryPoolResponse, error) // Queries a pool by ID PoolByID(context.Context, *QueryPoolByIDRequest) (*QueryPoolResponse, error) - // Queries a list of PoolMetadata items. + // Queries a PoolMetadata by ID PoolMetadata(context.Context, *QueryGetPoolMetadataRequest) (*QueryGetPoolMetadataResponse, error) + // Queries a list of PoolMetadata items. PoolMetadataAll(context.Context, *QueryAllPoolMetadataRequest) (*QueryAllPoolMetadataResponse, error) } From 43cc1413664fa360f096a8b167a50d434243b4a1 Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Wed, 13 Sep 2023 17:09:40 -0700 Subject: [PATCH 16/16] Small cleanup + comments --- proto/duality/dex/pool.proto | 2 ++ x/dex/keeper/pool_metadata.go | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/proto/duality/dex/pool.proto b/proto/duality/dex/pool.proto index c86db6fe6..228eb6d8e 100644 --- a/proto/duality/dex/pool.proto +++ b/proto/duality/dex/pool.proto @@ -5,6 +5,8 @@ option go_package = "github.com/duality-labs/duality/x/dex/types"; import "gogoproto/gogo.proto"; import "duality/dex/pool_reserves.proto"; +// NOTE: This struct is never actually stored in the KV store. It is merely a convenience wrapper for holding both sides of a pool. + message Pool { uint64 ID = 1; PoolReserves lower_tick0 = 2; diff --git a/x/dex/keeper/pool_metadata.go b/x/dex/keeper/pool_metadata.go index bda2d6256..272eae37f 100644 --- a/x/dex/keeper/pool_metadata.go +++ b/x/dex/keeper/pool_metadata.go @@ -69,8 +69,3 @@ func GetPoolMetadataIDBytes(id uint64) []byte { binary.BigEndian.PutUint64(bz, id) return bz } - -// GetPoolMetadataIDFromBytes returns ID in uint64 format from a byte array -func GetPoolMetadataIDFromBytes(bz []byte) uint64 { - return binary.BigEndian.Uint64(bz) -}