From 4c879bc4fbb7b0cb760ec4530e50de556ce7d5cb Mon Sep 17 00:00:00 2001 From: Derrick Lee Date: Mon, 3 Oct 2022 16:37:29 -0700 Subject: [PATCH] Add Earn deposits `value_in_staked_tokens` query parameter (#1325) * Add earn deposits query param to return individual vaults value as ukava * Add value_in_staked_tokens param handler to specific vault query * Use separate ukava coins when querying deposits in ukava Avoid usd of sdk.Coins.Add() as those will aggregate ukava amounts --- client/docs/swagger-ui/swagger.yaml | 269 +++++++++++++++++++++++ docs/core/proto-docs.md | 1 + proto/kava/earn/v1beta1/query.proto | 5 +- proto/kava/kavadist/v1beta1/params.proto | 24 +- x/earn/client/cli/query.go | 11 +- x/earn/keeper/grpc_query.go | 38 ++++ x/earn/keeper/grpc_query_test.go | 130 +++++++++-- x/earn/testutil/suite.go | 72 ++++++ x/earn/types/query.go | 8 +- x/earn/types/query.pb.go | 151 ++++++++----- 10 files changed, 614 insertions(+), 95 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 4cd7b629..67ed8300 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -7077,6 +7077,12 @@ paths: in: query required: false type: string + - name: value_in_staked_tokens + description: respond with vault value in ukava for bkava vaults. + in: query + required: false + type: boolean + format: boolean - name: pagination.key description: |- key is a value returned in PageResponse.next_key to begin @@ -10785,6 +10791,66 @@ paths: representing the yearly APR of KAVA tokens that will be minted during that period + infrastructure_params: + type: object + properties: + infrastructure_periods: + type: array + items: + type: object + properties: + start: + type: string + format: date-time + title: example "2020-03-01T15:20:00Z" + end: + type: string + format: date-time + title: example "2020-06-01T15:20:00Z" + inflation: + type: string + format: byte + title: example "1.000000003022265980" - 10% inflation + title: >- + Period stores the specified start and end dates, and + the inflation, expressed as a decimal + + representing the yearly APR of KAVA tokens that will + be minted during that period + core_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + weight: + type: string + partner_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + rewards_per_second: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which + implements the custom method + + signatures required by gogoproto. title: Params governance parameters for kavadist module description: >- QueryParamsResponse defines the response type for querying @@ -55834,6 +55900,73 @@ definitions: time_period: type: string title: RateLimit parameters for rate-limiting the supply of an issued asset + kava.kavadist.v1beta1.CoreReward: + type: object + properties: + address: + type: string + format: byte + weight: + type: string + kava.kavadist.v1beta1.InfrastructureParams: + type: object + properties: + infrastructure_periods: + type: array + items: + type: object + properties: + start: + type: string + format: date-time + title: example "2020-03-01T15:20:00Z" + end: + type: string + format: date-time + title: example "2020-06-01T15:20:00Z" + inflation: + type: string + format: byte + title: example "1.000000003022265980" - 10% inflation + title: >- + Period stores the specified start and end dates, and the inflation, + expressed as a decimal + + representing the yearly APR of KAVA tokens that will be minted + during that period + core_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + weight: + type: string + partner_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + rewards_per_second: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. kava.kavadist.v1beta1.Params: type: object properties: @@ -55863,7 +55996,84 @@ definitions: representing the yearly APR of KAVA tokens that will be minted during that period + infrastructure_params: + type: object + properties: + infrastructure_periods: + type: array + items: + type: object + properties: + start: + type: string + format: date-time + title: example "2020-03-01T15:20:00Z" + end: + type: string + format: date-time + title: example "2020-06-01T15:20:00Z" + inflation: + type: string + format: byte + title: example "1.000000003022265980" - 10% inflation + title: >- + Period stores the specified start and end dates, and the + inflation, expressed as a decimal + + representing the yearly APR of KAVA tokens that will be minted + during that period + core_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + weight: + type: string + partner_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + rewards_per_second: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. title: Params governance parameters for kavadist module + kava.kavadist.v1beta1.PartnerReward: + type: object + properties: + address: + type: string + format: byte + rewards_per_second: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. kava.kavadist.v1beta1.Period: type: object properties: @@ -55937,6 +56147,65 @@ definitions: representing the yearly APR of KAVA tokens that will be minted during that period + infrastructure_params: + type: object + properties: + infrastructure_periods: + type: array + items: + type: object + properties: + start: + type: string + format: date-time + title: example "2020-03-01T15:20:00Z" + end: + type: string + format: date-time + title: example "2020-06-01T15:20:00Z" + inflation: + type: string + format: byte + title: example "1.000000003022265980" - 10% inflation + title: >- + Period stores the specified start and end dates, and the + inflation, expressed as a decimal + + representing the yearly APR of KAVA tokens that will be + minted during that period + core_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + weight: + type: string + partner_rewards: + type: array + items: + type: object + properties: + address: + type: string + format: byte + rewards_per_second: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. title: Params governance parameters for kavadist module description: >- QueryParamsResponse defines the response type for querying x/kavadist diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 24a1933e..37346f2c 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -3089,6 +3089,7 @@ QueryDepositsRequest is the request type for the Query/Deposits RPC method. | ----- | ---- | ----- | ----------- | | `depositor` | [string](#string) | | depositor optionally filters deposits by depositor | | `denom` | [string](#string) | | denom optionally filters deposits by vault denom | +| `value_in_staked_tokens` | [bool](#bool) | | respond with vault value in ukava for bkava vaults | | `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | diff --git a/proto/kava/earn/v1beta1/query.proto b/proto/kava/earn/v1beta1/query.proto index b2417933..cf025c6f 100644 --- a/proto/kava/earn/v1beta1/query.proto +++ b/proto/kava/earn/v1beta1/query.proto @@ -104,8 +104,11 @@ message QueryDepositsRequest { // denom optionally filters deposits by vault denom string denom = 2; + // respond with vault value in ukava for bkava vaults + bool value_in_staked_tokens = 3; + // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 3; + cosmos.base.query.v1beta1.PageRequest pagination = 4; } // QueryDepositsResponse is the response type for the Query/Deposits RPC method. diff --git a/proto/kava/kavadist/v1beta1/params.proto b/proto/kava/kavadist/v1beta1/params.proto index ddaa9af2..627d5ec8 100644 --- a/proto/kava/kavadist/v1beta1/params.proto +++ b/proto/kava/kavadist/v1beta1/params.proto @@ -13,20 +13,21 @@ option (gogoproto.goproto_getters_all) = false; // Params governance parameters for kavadist module message Params { - bool active = 1 [(gogoproto.moretags) = "yaml:\"active\""]; - repeated Period periods = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"periods\""]; + bool active = 1 [(gogoproto.moretags) = "yaml:\"active\""]; + repeated Period periods = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"periods\""]; InfrastructureParams infrastructure_params = 4 [(gogoproto.nullable) = false]; } message InfrastructureParams { - repeated Period infrastructure_periods = 1 [(gogoproto.castrepeated) = "Periods", (gogoproto.nullable) = false]; - repeated CoreReward core_rewards = 2 [(gogoproto.castrepeated) = "CoreRewards", (gogoproto.nullable) = false]; - repeated PartnerReward partner_rewards = 3 [(gogoproto.castrepeated) = "PartnerRewards", (gogoproto.nullable) = false]; - option (gogoproto.goproto_stringer) = true; + repeated Period infrastructure_periods = 1 [(gogoproto.castrepeated) = "Periods", (gogoproto.nullable) = false]; + repeated CoreReward core_rewards = 2 [(gogoproto.castrepeated) = "CoreRewards", (gogoproto.nullable) = false]; + repeated PartnerReward partner_rewards = 3 + [(gogoproto.castrepeated) = "PartnerRewards", (gogoproto.nullable) = false]; + option (gogoproto.goproto_stringer) = true; } message CoreReward { - bytes address = 1 [ + bytes address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressBytes", (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; @@ -35,16 +36,16 @@ message CoreReward { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - option (gogoproto.goproto_stringer) = true; + option (gogoproto.goproto_stringer) = true; } message PartnerReward { - bytes address = 1 [ + bytes address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressBytes", (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - cosmos.base.v1beta1.Coin rewards_per_second = 2[(gogoproto.nullable) = false]; - option (gogoproto.goproto_stringer) = true; + cosmos.base.v1beta1.Coin rewards_per_second = 2 [(gogoproto.nullable) = false]; + option (gogoproto.goproto_stringer) = true; } // Period stores the specified start and end dates, and the inflation, expressed as a decimal @@ -67,4 +68,3 @@ message Period { (gogoproto.moretags) = "yaml:\"inflation\"" ]; } - diff --git a/x/earn/client/cli/query.go b/x/earn/client/cli/query.go index 9bd3dcd8..4eaebaac 100644 --- a/x/earn/client/cli/query.go +++ b/x/earn/client/cli/query.go @@ -15,8 +15,9 @@ import ( // flags for cli queries const ( - flagDenom = "denom" - flagOwner = "owner" + flagDenom = "denom" + flagOwner = "owner" + flagValueInStakedTokens = "value_in_staked_tokens" ) // GetQueryCmd returns the cli query commands for the earn module @@ -145,6 +146,10 @@ func queryDepositsCmd() *cobra.Command { if err != nil { return err } + valueInStakedTokens, err := cmd.Flags().GetBool(flagValueInStakedTokens) + if err != nil { + return err + } pageReq, err := client.ReadPageRequest(cmd.Flags()) if err != nil { @@ -156,6 +161,7 @@ func queryDepositsCmd() *cobra.Command { req := types.NewQueryDepositsRequest( ownerBech, denom, + valueInStakedTokens, pageReq, ) res, err := queryClient.Deposits(context.Background(), req) @@ -171,6 +177,7 @@ func queryDepositsCmd() *cobra.Command { cmd.Flags().String(flagOwner, "", "(optional) filter for deposits by owner address") cmd.Flags().String(flagDenom, "", "(optional) filter for deposits by vault denom") + cmd.Flags().Bool(flagValueInStakedTokens, false, "(optional) get underlying staked tokens for staking derivative vaults") return cmd } diff --git a/x/earn/keeper/grpc_query.go b/x/earn/keeper/grpc_query.go index f0c245a1..72fd09be 100644 --- a/x/earn/keeper/grpc_query.go +++ b/x/earn/keeper/grpc_query.go @@ -296,6 +296,19 @@ func (s queryServer) getOneAccountOneVaultDeposit( return nil, status.Error(codes.NotFound, err.Error()) } + if req.ValueInStakedTokens { + // Get underlying ukava amount if denom is a derivative + if s.keeper.liquidKeeper.IsDerivativeDenom(ctx, req.Denom) { + ukavaValue, err := s.keeper.liquidKeeper.GetStakedTokensForDerivatives(ctx, sdk.NewCoins(value)) + if err != nil { + // This should "never" happen if IsDerivativeDenom is true + panic("Error getting ukava value for " + req.Denom) + } + + value = ukavaValue + } + } + return &types.QueryDepositsResponse{ Deposits: []types.DepositResponse{ { @@ -397,6 +410,31 @@ func (s queryServer) getOneAccountAllDeposits( return nil, status.Error(codes.InvalidArgument, err.Error()) } + if req.ValueInStakedTokens { + // Plain slice to not sum ukava amounts together. This is not a valid + // sdk.Coin due to multiple coins of the same denom, but we need them to + // be separate in the response to not be an aggregate amount. + var valueInStakedTokens []sdk.Coin + + for _, coin := range value { + // Non-bkava coins are kept as is + if !s.keeper.liquidKeeper.IsDerivativeDenom(ctx, coin.Denom) { + valueInStakedTokens = append(valueInStakedTokens, coin) + continue + } + + // Derivative coins are converted to underlying staked tokens + ukavaValue, err := s.keeper.liquidKeeper.GetStakedTokensForDerivatives(ctx, sdk.NewCoins(coin)) + if err != nil { + // This should "never" happen if IsDerivativeDenom is true + panic("Error getting ukava value for " + coin.Denom) + } + valueInStakedTokens = append(valueInStakedTokens, ukavaValue) + } + + value = valueInStakedTokens + } + deposits = append(deposits, types.DepositResponse{ Depositor: depositor.String(), Shares: accountShare.Shares, diff --git a/x/earn/keeper/grpc_query_test.go b/x/earn/keeper/grpc_query_test.go index 395a5e41..2ed96cf9 100644 --- a/x/earn/keeper/grpc_query_test.go +++ b/x/earn/keeper/grpc_query_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "context" + "fmt" "testing" "github.com/cosmos/cosmos-sdk/baseapp" @@ -14,6 +15,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/kava-labs/kava/app" "github.com/kava-labs/kava/x/earn/keeper" "github.com/kava-labs/kava/x/earn/testutil" "github.com/kava-labs/kava/x/earn/types" @@ -217,32 +219,61 @@ func (suite *grpcQueryTestSuite) TestVault_NotFound() { } func (suite *grpcQueryTestSuite) TestDeposits() { + // Validator setup for bkava + _, addrs := app.GeneratePrivKeyAddressPairs(5) + valAccAddr1, valAccAddr2, delegator := addrs[0], addrs[1], addrs[2] + valAddr1 := sdk.ValAddress(valAccAddr1) + valAddr2 := sdk.ValAddress(valAccAddr2) + vault1Denom := "usdx" vault2Denom := "busd" - vault3Denom := testutil.TestBkavaDenoms[0] + vault3Denom := fmt.Sprintf("bkava-%s", valAddr1.String()) + vault4Denom := fmt.Sprintf("bkava-%s", valAddr2.String()) + + initialUkavaBalance := sdk.NewInt(1e9) + startBalance := sdk.NewCoins( + sdk.NewCoin("ukava", initialUkavaBalance), + sdk.NewInt64Coin(vault1Denom, 1000), + sdk.NewInt64Coin(vault2Denom, 1000), + // Bkava isn't actually minted via x/liquid + sdk.NewInt64Coin(vault3Denom, 1000), + sdk.NewInt64Coin(vault4Denom, 1000), + ) + + delegateAmount := sdk.NewInt(100e6) + + suite.App.FundAccount(suite.Ctx, valAccAddr1, startBalance) + suite.App.FundAccount(suite.Ctx, valAccAddr2, startBalance) + suite.App.FundAccount(suite.Ctx, delegator, startBalance) + + suite.CreateNewUnbondedValidator(valAddr1, initialUkavaBalance) + suite.CreateNewUnbondedValidator(valAddr2, initialUkavaBalance) + suite.CreateDelegation(valAddr1, delegator, delegateAmount) + suite.CreateDelegation(valAddr2, delegator, delegateAmount) + + staking.EndBlocker(suite.Ctx, suite.App.GetStakingKeeper()) + + savingsParams := suite.SavingsKeeper.GetParams(suite.Ctx) + savingsParams.SupportedDenoms = append(savingsParams.SupportedDenoms, "bkava") + suite.SavingsKeeper.SetParams(suite.Ctx, savingsParams) // Add vaults suite.CreateVault(vault1Denom, types.StrategyTypes{types.STRATEGY_TYPE_HARD}, false, nil) suite.CreateVault(vault2Denom, types.StrategyTypes{types.STRATEGY_TYPE_HARD}, false, nil) suite.CreateVault("bkava", types.StrategyTypes{types.STRATEGY_TYPE_SAVINGS}, false, nil) - startBalance := sdk.NewCoins( - sdk.NewInt64Coin(vault1Denom, 1000), - sdk.NewInt64Coin(vault2Denom, 1000), - sdk.NewInt64Coin(vault3Denom, 1000), - ) - deposit1Amount := sdk.NewInt64Coin(vault1Denom, 100) deposit2Amount := sdk.NewInt64Coin(vault2Denom, 200) deposit3Amount := sdk.NewInt64Coin(vault3Denom, 200) + deposit4Amount := sdk.NewInt64Coin(vault4Denom, 300) // Accounts acc1 := suite.CreateAccount(startBalance, 0).GetAddress() - acc2 := suite.CreateAccount(startBalance, 1).GetAddress() + acc2 := delegator // Deposit into each vault from each account - 4 total deposits // Acc 1: usdx + busd - // Acc 2: usdx + bkava + // Acc 2: usdx + bkava-1 + bkava-2 err := suite.Keeper.Deposit(suite.Ctx, acc1, deposit1Amount, types.STRATEGY_TYPE_HARD) suite.Require().NoError(err) err = suite.Keeper.Deposit(suite.Ctx, acc1, deposit2Amount, types.STRATEGY_TYPE_HARD) @@ -252,12 +283,14 @@ func (suite *grpcQueryTestSuite) TestDeposits() { suite.Require().NoError(err) err = suite.Keeper.Deposit(suite.Ctx, acc2, deposit3Amount, types.STRATEGY_TYPE_SAVINGS) suite.Require().NoError(err) + err = suite.Keeper.Deposit(suite.Ctx, acc2, deposit4Amount, types.STRATEGY_TYPE_SAVINGS) + suite.Require().NoError(err) suite.Run("specific vault", func() { // Query all deposits for account 1 res, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(acc1.String(), vault1Denom, nil), + types.NewQueryDepositsRequest(acc1.String(), vault1Denom, false, nil), ) suite.Require().NoError(err) suite.Require().Len(res.Deposits, 1) @@ -282,7 +315,7 @@ func (suite *grpcQueryTestSuite) TestDeposits() { suite.Run("specific bkava vault", func() { res, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(acc2.String(), vault3Denom, nil), + types.NewQueryDepositsRequest(acc2.String(), vault3Denom, false, nil), ) suite.Require().NoError(err) suite.Require().Len(res.Deposits, 1) @@ -304,10 +337,33 @@ func (suite *grpcQueryTestSuite) TestDeposits() { ) }) + suite.Run("specific bkava vault in staked tokens", func() { + res, err := suite.queryClient.Deposits( + context.Background(), + types.NewQueryDepositsRequest(acc2.String(), vault3Denom, true, nil), + ) + suite.Require().NoError(err) + suite.Require().Len(res.Deposits, 1) + suite.Require().Equal( + types.DepositResponse{ + Depositor: acc2.String(), + // Only includes specified deposit shares + Shares: types.NewVaultShares( + types.NewVaultShare(deposit3Amount.Denom, deposit3Amount.Amount.ToDec()), + ), + // Only the specified vault denom value + Value: sdk.NewCoins( + sdk.NewCoin("ukava", deposit3Amount.Amount), + ), + }, + res.Deposits[0], + ) + }) + suite.Run("invalid vault", func() { _, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(acc1.String(), "notavaliddenom", nil), + types.NewQueryDepositsRequest(acc1.String(), "notavaliddenom", false, nil), ) suite.Require().Error(err) suite.Require().ErrorIs(err, status.Errorf(codes.NotFound, "vault for notavaliddenom not found")) @@ -317,7 +373,7 @@ func (suite *grpcQueryTestSuite) TestDeposits() { // Query all deposits for account 1 res, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(acc1.String(), "", nil), + types.NewQueryDepositsRequest(acc1.String(), "", false, nil), ) suite.Require().NoError(err) suite.Require().Len(res.Deposits, 1) @@ -335,6 +391,40 @@ func (suite *grpcQueryTestSuite) TestDeposits() { res.Deposits, ) }) + + suite.Run("all vaults value in staked tokens", func() { + // Query all deposits for account 1 with value in staked tokens + res, err := suite.queryClient.Deposits( + context.Background(), + types.NewQueryDepositsRequest(acc2.String(), "", true, nil), + ) + suite.Require().NoError(err) + suite.Require().Len(res.Deposits, 1) + suite.Require().Equal( + types.DepositResponse{ + Depositor: acc2.String(), + Shares: types.VaultShares{ + types.NewVaultShare(deposit4Amount.Denom, deposit4Amount.Amount.ToDec()), + types.NewVaultShare(deposit3Amount.Denom, deposit3Amount.Amount.ToDec()), + types.NewVaultShare(deposit1Amount.Denom, deposit1Amount.Amount.ToDec()), + }, + Value: sdk.Coins{ + sdk.NewCoin("ukava", deposit4Amount.Amount), + sdk.NewCoin("ukava", deposit3Amount.Amount), + // Deposit 1 is last as it's the same order as vault shares + deposit1Amount, + }, + }, + res.Deposits[0], + ) + for i := range res.Deposits[0].Shares { + suite.Equal( + res.Deposits[0].Shares[i].Amount, + res.Deposits[0].Value[i].Amount.ToDec(), + "order of deposit value should match shares", + ) + } + }) } func (suite *grpcQueryTestSuite) TestDeposits_NoDeposits() { @@ -353,7 +443,7 @@ func (suite *grpcQueryTestSuite) TestDeposits_NoDeposits() { // Query all deposits for account 1 res, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(acc1.String(), vault1Denom, nil), + types.NewQueryDepositsRequest(acc1.String(), vault1Denom, false, nil), ) suite.Require().NoError(err) suite.Require().Len(res.Deposits, 1) @@ -376,7 +466,7 @@ func (suite *grpcQueryTestSuite) TestDeposits_NoDeposits() { // Query all deposits for account 1 res, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(acc1.String(), "", nil), + types.NewQueryDepositsRequest(acc1.String(), "", false, nil), ) suite.Require().NoError(err) suite.Require().Empty(res.Deposits) @@ -386,7 +476,7 @@ func (suite *grpcQueryTestSuite) TestDeposits_NoDeposits() { func (suite *grpcQueryTestSuite) TestDeposits_NoDepositor() { _, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest("", "usdx", nil), + types.NewQueryDepositsRequest("", "usdx", false, nil), ) suite.Require().Error(err) suite.Require().ErrorIs(err, status.Error(codes.InvalidArgument, "depositor is required")) @@ -395,14 +485,14 @@ func (suite *grpcQueryTestSuite) TestDeposits_NoDepositor() { func (suite *grpcQueryTestSuite) TestDeposits_InvalidAddress() { _, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest("asdf", "usdx", nil), + types.NewQueryDepositsRequest("asdf", "usdx", false, nil), ) suite.Require().Error(err) suite.Require().ErrorIs(err, status.Error(codes.InvalidArgument, "Invalid address")) _, err = suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest("asdf", "", nil), + types.NewQueryDepositsRequest("asdf", "", false, nil), ) suite.Require().Error(err) suite.Require().ErrorIs(err, status.Error(codes.InvalidArgument, "Invalid address")) @@ -440,7 +530,7 @@ func (suite *grpcQueryTestSuite) TestDeposits_bKava() { // Query all deposits for account 1 res, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(address1.String(), "bkava", nil), + types.NewQueryDepositsRequest(address1.String(), "bkava", false, nil), ) suite.Require().NoError(err) suite.Require().Len(res.Deposits, 1) @@ -475,7 +565,7 @@ func (suite *grpcQueryTestSuite) TestDeposits_bKava() { // Query all deposits for account 1 res, err := suite.queryClient.Deposits( context.Background(), - types.NewQueryDepositsRequest(address1.String(), "bkava", nil), + types.NewQueryDepositsRequest(address1.String(), "bkava", false, nil), ) suite.Require().NoError(err) suite.Require().Len(res.Deposits, 1) diff --git a/x/earn/testutil/suite.go b/x/earn/testutil/suite.go index 04bbb8bc..59191ddf 100644 --- a/x/earn/testutil/suite.go +++ b/x/earn/testutil/suite.go @@ -5,6 +5,7 @@ import ( "reflect" "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/kava-labs/kava/app" "github.com/kava-labs/kava/x/earn/keeper" "github.com/kava-labs/kava/x/earn/types" @@ -22,6 +23,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -160,6 +163,13 @@ func (suite *Suite) SetupTest() { nil, ) + stakingParams := stakingtypes.DefaultParams() + stakingParams.BondDenom = "ukava" + + stakingGs := stakingtypes.GenesisState{ + Params: stakingParams, + } + tApp := app.NewTestApp() tApp.InitializeFromGenesisStates( @@ -167,6 +177,7 @@ func (suite *Suite) SetupTest() { pricefeedtypes.ModuleName: tApp.AppCodec().MustMarshalJSON(&pricefeedGS), hardtypes.ModuleName: tApp.AppCodec().MustMarshalJSON(&hardGS), savingstypes.ModuleName: tApp.AppCodec().MustMarshalJSON(&savingsGS), + stakingtypes.ModuleName: tApp.AppCodec().MustMarshalJSON(&stakingGs), }, ) @@ -357,6 +368,67 @@ func (suite *Suite) SavingsDepositAmountEqual(expected sdk.Coins) { ) } +// ---------------------------------------------------------------------------- +// Staking + +// CreateNewUnbondedValidator creates a new validator in the staking module. +// New validators are unbonded until the end blocker is run. +func (suite *Suite) CreateNewUnbondedValidator(addr sdk.ValAddress, selfDelegation sdk.Int) stakingtypes.Validator { + // Create a validator + err := suite.deliverMsgCreateValidator(suite.Ctx, addr, suite.NewBondCoin(selfDelegation)) + suite.Require().NoError(err) + + // New validators are created in an unbonded state. Note if the end blocker is run later this validator could become bonded. + + validator, found := suite.App.GetStakingKeeper().GetValidator(suite.Ctx, addr) + suite.Require().True(found) + return validator +} + +// NewBondCoin creates a Coin with the current staking denom. +func (suite *Suite) NewBondCoin(amount sdk.Int) sdk.Coin { + stakingDenom := suite.App.GetStakingKeeper().BondDenom(suite.Ctx) + return sdk.NewCoin(stakingDenom, amount) +} + +// CreateDelegation delegates tokens to a validator. +func (suite *Suite) CreateDelegation(valAddr sdk.ValAddress, delegator sdk.AccAddress, amount sdk.Int) sdk.Dec { + sk := suite.App.GetStakingKeeper() + + stakingDenom := sk.BondDenom(suite.Ctx) + msg := stakingtypes.NewMsgDelegate( + delegator, + valAddr, + sdk.NewCoin(stakingDenom, amount), + ) + + msgServer := stakingkeeper.NewMsgServerImpl(sk) + _, err := msgServer.Delegate(sdk.WrapSDKContext(suite.Ctx), msg) + suite.Require().NoError(err) + + del, found := sk.GetDelegation(suite.Ctx, delegator, valAddr) + suite.Require().True(found) + return del.Shares +} + +func (suite *Suite) deliverMsgCreateValidator(ctx sdk.Context, address sdk.ValAddress, selfDelegation sdk.Coin) error { + msg, err := stakingtypes.NewMsgCreateValidator( + address, + ed25519.GenPrivKey().PubKey(), + selfDelegation, + stakingtypes.Description{}, + stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + sdk.NewInt(1e6), + ) + if err != nil { + return err + } + + msgServer := stakingkeeper.NewMsgServerImpl(suite.App.GetStakingKeeper()) + _, err = msgServer.CreateValidator(sdk.WrapSDKContext(suite.Ctx), msg) + return err +} + // ---------------------------------------------------------------------------- // EventsContains asserts that the expected event is in the provided events diff --git a/x/earn/types/query.go b/x/earn/types/query.go index ed94ccc3..5bc93996 100644 --- a/x/earn/types/query.go +++ b/x/earn/types/query.go @@ -23,11 +23,13 @@ func NewQueryVaultRequest(denom string) *QueryVaultRequest { func NewQueryDepositsRequest( depositor string, denom string, + ValueInStakedTokens bool, pagination *query.PageRequest, ) *QueryDepositsRequest { return &QueryDepositsRequest{ - Depositor: depositor, - Denom: denom, - Pagination: pagination, + Depositor: depositor, + Denom: denom, + ValueInStakedTokens: ValueInStakedTokens, + Pagination: pagination, } } diff --git a/x/earn/types/query.pb.go b/x/earn/types/query.pb.go index 0035044c..26ccc6e7 100644 --- a/x/earn/types/query.pb.go +++ b/x/earn/types/query.pb.go @@ -323,8 +323,10 @@ type QueryDepositsRequest struct { Depositor string `protobuf:"bytes,1,opt,name=depositor,proto3" json:"depositor,omitempty"` // denom optionally filters deposits by vault denom Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // respond with vault value in ukava for bkava vaults + ValueInStakedTokens bool `protobuf:"varint,3,opt,name=value_in_staked_tokens,json=valueInStakedTokens,proto3" json:"value_in_staked_tokens,omitempty"` // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,4,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryDepositsRequest) Reset() { *m = QueryDepositsRequest{} } @@ -462,61 +464,63 @@ func init() { func init() { proto.RegisterFile("kava/earn/v1beta1/query.proto", fileDescriptor_63f8dee2f3192a6b) } var fileDescriptor_63f8dee2f3192a6b = []byte{ - // 855 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x4f, 0x1b, 0x47, - 0x14, 0xf7, 0xda, 0xd8, 0x82, 0x71, 0xa1, 0xf5, 0xe0, 0x4a, 0xb6, 0x29, 0x6b, 0xb3, 0x14, 0x58, - 0x2a, 0x79, 0xb7, 0xb8, 0x52, 0x7b, 0x41, 0x95, 0xea, 0xa2, 0x22, 0x7a, 0xa8, 0xe8, 0xd2, 0x72, - 0xa8, 0x54, 0x59, 0x63, 0x3c, 0x5a, 0x56, 0xd8, 0x3b, 0x66, 0x67, 0xec, 0x96, 0x56, 0x51, 0x24, - 0xa4, 0xdc, 0x23, 0xe5, 0x7f, 0xc8, 0x01, 0xe5, 0xc8, 0x1f, 0xc1, 0x11, 0x91, 0x4b, 0x94, 0x03, - 0x24, 0x90, 0x73, 0xce, 0x39, 0x46, 0xf3, 0xb1, 0xfe, 0x36, 0x46, 0x39, 0xc1, 0xbe, 0x8f, 0xdf,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0xf9, 0x53, 0xb1, 0x84, 0x56, 0xc5, 0xf2, 0x23, 0x48, - 0x08, 0x85, 0x9c, 0x25, 0x66, 0x26, 0x4b, 0x85, 0x11, 0x2c, 0x22, 0x25, 0xcc, 0x08, 0xc9, 0x64, - 0x96, 0xb1, 0x0e, 0x52, 0x5d, 0x58, 0xc5, 0x05, 0xd3, 0x20, 0x5e, 0xc3, 0x3e, 0x69, 0x08, 0xe5, - 0x33, 0x8e, 0xfc, 0x30, 0x9c, 0x5e, 0x5d, 0x1d, 0x01, 0x9b, 0x20, 0x2e, 0xa0, 0x54, 0x95, 0x0f, - 0xe5, 0x97, 0x49, 0xc6, 0xfb, 0x28, 0x98, 0xed, 0xc7, 0x1b, 0xc9, 0x0d, 0x1d, 0x00, 0xd4, 0x53, - 0x79, 0x98, 0x66, 0xa2, 0x85, 0x98, 0x39, 0x57, 0xca, 0x8f, 0xa0, 0xda, 0x53, 0xef, 0xf9, 0xc7, - 0x49, 0x13, 0x97, 0x53, 0x67, 0x37, 0xf9, 0xd9, 0x5e, 0x0b, 0x75, 0x7a, 0x50, 0xa0, 0x09, 0xbe, - 0xf0, 0xf8, 0x1c, 0x7b, 0x6d, 0xc4, 0x70, 0x45, 0x16, 0x11, 0x2b, 0x68, 0xe6, 0xb4, 0x33, 0xe7, - 0xd1, 0x5d, 0x69, 0x16, 0xda, 0xe0, 0x36, 0x80, 0xa8, 0x5e, 0x27, 0xff, 0xe0, 0x5a, 0xa5, 0x86, - 0x9b, 0x84, 0x7a, 0x8c, 0x04, 0x34, 0x33, 0x55, 0x88, 0x99, 0x33, 0xe5, 0xcc, 0xd5, 0x79, 0x31, - 0xad, 0xd6, 0xe0, 0xa7, 0x5a, 0x2d, 0xc0, 0x94, 0xee, 0xb1, 0xc0, 0xf3, 0x5d, 0x27, 0xa5, 0x72, - 0xb6, 0x3a, 0x29, 0x70, 0x09, 0x7c, 0xc6, 0x08, 0x43, 0xf5, 0x0a, 0x3d, 0x44, 0x01, 0xa6, 0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0x54, 0xa5, 0x12, 0xee, 0x5f, - 0x09, 0x28, 0x46, 0xab, 0x9a, 0x10, 0x3f, 0xb5, 0xdf, 0x7d, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xf4, - 0x79, 0x11, 0x40, 0x9a, 0x08, 0x00, 0x00, + // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4b, 0x6f, 0xeb, 0x44, + 0x14, 0x8e, 0xf3, 0x52, 0x3b, 0xe1, 0x5e, 0xc8, 0x34, 0xa0, 0x24, 0x97, 0x3a, 0xa9, 0x2f, 0xb7, + 0xd7, 0x45, 0x8a, 0x4d, 0x53, 0x09, 0x36, 0x15, 0x12, 0xa1, 0xa2, 0x2a, 0x0b, 0x54, 0x9c, 0xd2, + 0x05, 0x12, 0xb2, 0x26, 0xcd, 0xc8, 0xb5, 0x92, 0x78, 0x52, 0xcf, 0x24, 0x50, 0x10, 0x42, 0xaa, + 0xc4, 0x1e, 0x89, 0xff, 0xc0, 0xa2, 0xeb, 0xfe, 0x88, 0x2e, 0xab, 0xb2, 0x41, 0x2c, 0x5a, 0xda, + 0xb2, 0x66, 0xcd, 0x12, 0xcd, 0xc3, 0x79, 0xa7, 0xa9, 0x58, 0x25, 0x73, 0x1e, 0xdf, 0xf7, 0x9d, + 0x99, 0x73, 0x8e, 0xc1, 0x6a, 0x0b, 0xf5, 0x91, 0x8d, 0x51, 0x18, 0xd8, 0xfd, 0xcd, 0x06, 0x66, + 0x68, 0xd3, 0x3e, 0xe9, 0xe1, 0xf0, 0xd4, 0xea, 0x86, 0x84, 0x11, 0x98, 0xe5, 0x6e, 0x8b, 0xbb, + 0x2d, 0xe5, 0x2e, 0x16, 0x8e, 0x08, 0xed, 0x10, 0xea, 0x8a, 0x00, 0x5b, 0x1e, 0x64, 0x74, 0xf1, + 0x7d, 0x79, 0xb2, 0x1b, 0x88, 0x62, 0x09, 0x33, 0x00, 0xed, 0x22, 0xcf, 0x0f, 0x10, 0xf3, 0x49, + 0xa0, 0x62, 0xf5, 0xd1, 0xd8, 0x28, 0xea, 0x88, 0xf8, 0x91, 0x3f, 0xe7, 0x11, 0x8f, 0x48, 0x0e, + 0xfe, 0x4f, 0x59, 0xdf, 0xf5, 0x08, 0xf1, 0xda, 0xd8, 0x46, 0x5d, 0xdf, 0x46, 0x41, 0x40, 0x98, + 0x80, 0x8c, 0xf8, 0xf5, 0xe9, 0x62, 0xba, 0x28, 0x44, 0x9d, 0xc8, 0x5f, 0x9e, 0xf6, 0x53, 0x16, + 0x22, 0x86, 0x3d, 0x55, 0x6f, 0x71, 0xc6, 0x75, 0xf4, 0x51, 0xaf, 0xcd, 0xa4, 0xdb, 0xc8, 0x01, + 0xf8, 0x25, 0x2f, 0x6b, 0x5f, 0xa0, 0x3a, 0xf8, 0xa4, 0x87, 0x29, 0x33, 0xbe, 0x00, 0x2b, 0x63, + 0x56, 0xda, 0x25, 0x01, 0xc5, 0xf0, 0x23, 0x90, 0x96, 0xec, 0x79, 0xad, 0xac, 0x99, 0x99, 0x6a, + 0xc1, 0x9a, 0xba, 0x4c, 0x4b, 0xa6, 0xd4, 0x92, 0x97, 0x37, 0xa5, 0x98, 0xa3, 0xc2, 0x07, 0x2c, + 0x87, 0x9c, 0x79, 0xc0, 0xf2, 0x95, 0x62, 0x89, 0xac, 0x8a, 0xe5, 0x63, 0x90, 0x16, 0x0a, 0x39, + 0x4b, 0xc2, 0xcc, 0x54, 0xcb, 0x33, 0x58, 0x44, 0x4a, 0x94, 0x11, 0x91, 0xc9, 0x2c, 0x63, 0x03, + 0x64, 0x87, 0xb0, 0x8a, 0x0b, 0xe6, 0x40, 0xaa, 0x89, 0x03, 0xd2, 0x11, 0xca, 0x97, 0x1d, 0x79, + 0x30, 0x9c, 0x51, 0x5d, 0x03, 0x01, 0xdb, 0x20, 0x25, 0xa0, 0x54, 0x95, 0x4f, 0xe5, 0x97, 0x49, + 0x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, + 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1008,7 +1012,17 @@ func (m *QueryDepositsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 + } + if m.ValueInStakedTokens { + i-- + if m.ValueInStakedTokens { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 } if len(m.Denom) > 0 { i -= len(m.Denom) @@ -1262,6 +1276,9 @@ func (m *QueryDepositsRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + if m.ValueInStakedTokens { + n += 2 + } if m.Pagination != nil { l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) @@ -2114,6 +2131,26 @@ func (m *QueryDepositsRequest) Unmarshal(dAtA []byte) error { m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValueInStakedTokens", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ValueInStakedTokens = bool(v != 0) + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) }