From 35c848dce67917b6a52f0a32ab7374adb534f175 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Tue, 21 Mar 2023 15:47:21 -0700 Subject: [PATCH] Add incentive grpc query service (#1503) * Add incentive grpc query service * Register query server * Add grpc query test * Add grpc query test * Fix proto lints * Fix missing savings field, update tests * Update proto docs * Use consts for query reward types * Add owner to queryRewards err * Add empty reward type to be valid --- docs/core/proto-docs.md | 195 ++ proto/kava/incentive/v1beta1/apy.proto | 18 + proto/kava/incentive/v1beta1/query.proto | 130 ++ x/incentive/keeper/grpc_query.go | 342 +++ x/incentive/keeper/grpc_query_test.go | 318 +++ x/incentive/module.go | 10 +- x/incentive/types/apy.go | 14 + x/incentive/types/apy.pb.go | 372 ++++ x/incentive/types/querier.go | 21 +- x/incentive/types/query.pb.go | 2425 ++++++++++++++++++++++ x/incentive/types/query.pb.gw.go | 366 ++++ 11 files changed, 4187 insertions(+), 24 deletions(-) create mode 100644 proto/kava/incentive/v1beta1/apy.proto create mode 100644 proto/kava/incentive/v1beta1/query.proto create mode 100644 x/incentive/keeper/grpc_query.go create mode 100644 x/incentive/keeper/grpc_query_test.go create mode 100644 x/incentive/types/apy.go create mode 100644 x/incentive/types/apy.pb.go create mode 100644 x/incentive/types/query.pb.go create mode 100644 x/incentive/types/query.pb.gw.go diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 12d2f855..0d944bd6 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -322,6 +322,9 @@ - [Msg](#kava.hard.v1beta1.Msg) +- [kava/incentive/v1beta1/apy.proto](#kava/incentive/v1beta1/apy.proto) + - [Apy](#kava.incentive.v1beta1.Apy) + - [kava/incentive/v1beta1/claims.proto](#kava/incentive/v1beta1/claims.proto) - [BaseClaim](#kava.incentive.v1beta1.BaseClaim) - [BaseMultiClaim](#kava.incentive.v1beta1.BaseMultiClaim) @@ -348,6 +351,18 @@ - [GenesisRewardState](#kava.incentive.v1beta1.GenesisRewardState) - [GenesisState](#kava.incentive.v1beta1.GenesisState) +- [kava/incentive/v1beta1/query.proto](#kava/incentive/v1beta1/query.proto) + - [QueryApyRequest](#kava.incentive.v1beta1.QueryApyRequest) + - [QueryApyResponse](#kava.incentive.v1beta1.QueryApyResponse) + - [QueryParamsRequest](#kava.incentive.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#kava.incentive.v1beta1.QueryParamsResponse) + - [QueryRewardFactorsRequest](#kava.incentive.v1beta1.QueryRewardFactorsRequest) + - [QueryRewardFactorsResponse](#kava.incentive.v1beta1.QueryRewardFactorsResponse) + - [QueryRewardsRequest](#kava.incentive.v1beta1.QueryRewardsRequest) + - [QueryRewardsResponse](#kava.incentive.v1beta1.QueryRewardsResponse) + + - [Query](#kava.incentive.v1beta1.Query) + - [kava/incentive/v1beta1/tx.proto](#kava/incentive/v1beta1/tx.proto) - [MsgClaimDelegatorReward](#kava.incentive.v1beta1.MsgClaimDelegatorReward) - [MsgClaimDelegatorRewardResponse](#kava.incentive.v1beta1.MsgClaimDelegatorRewardResponse) @@ -4617,6 +4632,39 @@ Msg defines the hard Msg service. + +

Top

+ +## kava/incentive/v1beta1/apy.proto + + + + + +### Apy +Apy contains the calculated APY for a given collateral type at a specific +instant in time. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `collateral_type` | [string](#string) | | | +| `apy` | [string](#string) | | | + + + + + + + + + + + + + + +

Top

@@ -5010,6 +5058,153 @@ GenesisState is the state that must be provided at genesis. + +

Top

+ +## kava/incentive/v1beta1/query.proto + + + + + +### QueryApyRequest +QueryApysRequest is the request type for the Query/Apys RPC method. + + + + + + + + +### QueryApyResponse +QueryApysResponse is the response type for the Query/Apys RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `earn` | [Apy](#kava.incentive.v1beta1.Apy) | repeated | | + + + + + + + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + + + + + + + +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#kava.incentive.v1beta1.Params) | | | + + + + + + + + +### QueryRewardFactorsRequest +QueryRewardFactorsRequest is the request type for the Query/RewardFactors RPC method. + + + + + + + + +### QueryRewardFactorsResponse +QueryRewardFactorsResponse is the response type for the Query/RewardFactors RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `usdx_minting_reward_factors` | [RewardIndex](#kava.incentive.v1beta1.RewardIndex) | repeated | | +| `hard_supply_reward_factors` | [MultiRewardIndex](#kava.incentive.v1beta1.MultiRewardIndex) | repeated | | +| `hard_borrow_reward_factors` | [MultiRewardIndex](#kava.incentive.v1beta1.MultiRewardIndex) | repeated | | +| `delegator_reward_factors` | [MultiRewardIndex](#kava.incentive.v1beta1.MultiRewardIndex) | repeated | | +| `swap_reward_factors` | [MultiRewardIndex](#kava.incentive.v1beta1.MultiRewardIndex) | repeated | | +| `savings_reward_factors` | [MultiRewardIndex](#kava.incentive.v1beta1.MultiRewardIndex) | repeated | | +| `earn_reward_factors` | [MultiRewardIndex](#kava.incentive.v1beta1.MultiRewardIndex) | repeated | | + + + + + + + + +### QueryRewardsRequest +QueryRewardsRequest is the request type for the Query/Rewards RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `owner` | [string](#string) | | owner is the address of the user to query rewards for. | +| `reward_type` | [string](#string) | | reward_type is the type of reward to query rewards for, e.g. hard, earn, swap. | +| `unsynchronized` | [bool](#bool) | | unsynchronized is a flag to query rewards that are not simulated for reward synchronized for the current block. | + + + + + + + + +### QueryRewardsResponse +QueryRewardsResponse is the response type for the Query/Rewards RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `usdx_minting_claims` | [USDXMintingClaim](#kava.incentive.v1beta1.USDXMintingClaim) | repeated | | +| `hard_liquidity_provider_claims` | [HardLiquidityProviderClaim](#kava.incentive.v1beta1.HardLiquidityProviderClaim) | repeated | | +| `delegator_claims` | [DelegatorClaim](#kava.incentive.v1beta1.DelegatorClaim) | repeated | | +| `swap_claims` | [SwapClaim](#kava.incentive.v1beta1.SwapClaim) | repeated | | +| `savings_claims` | [SavingsClaim](#kava.incentive.v1beta1.SavingsClaim) | repeated | | +| `earn_claims` | [EarnClaim](#kava.incentive.v1beta1.EarnClaim) | repeated | | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service for incentive module. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#kava.incentive.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#kava.incentive.v1beta1.QueryParamsResponse) | Params queries module params. | GET|/kava/incentive/v1beta1/params| +| `Rewards` | [QueryRewardsRequest](#kava.incentive.v1beta1.QueryRewardsRequest) | [QueryRewardsResponse](#kava.incentive.v1beta1.QueryRewardsResponse) | Rewards queries reward information for a given user. | GET|/kava/incentive/v1beta1/rewards| +| `RewardFactors` | [QueryRewardFactorsRequest](#kava.incentive.v1beta1.QueryRewardFactorsRequest) | [QueryRewardFactorsResponse](#kava.incentive.v1beta1.QueryRewardFactorsResponse) | Rewards queries the reward factors. | GET|/kava/incentive/v1beta1/reward_factors| +| `Apy` | [QueryApyRequest](#kava.incentive.v1beta1.QueryApyRequest) | [QueryApyResponse](#kava.incentive.v1beta1.QueryApyResponse) | Apy queries incentive reward apy for a reward. | GET|/kava/incentive/v1beta1/apy| + + + + +

Top

diff --git a/proto/kava/incentive/v1beta1/apy.proto b/proto/kava/incentive/v1beta1/apy.proto new file mode 100644 index 00000000..5b6abf93 --- /dev/null +++ b/proto/kava/incentive/v1beta1/apy.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package kava.incentive.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/kava-labs/kava/x/incentive/types"; + +// Apy contains the calculated APY for a given collateral type at a specific +// instant in time. +message Apy { + string collateral_type = 1; + string apy = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/kava/incentive/v1beta1/query.proto b/proto/kava/incentive/v1beta1/query.proto new file mode 100644 index 00000000..f814d66c --- /dev/null +++ b/proto/kava/incentive/v1beta1/query.proto @@ -0,0 +1,130 @@ +syntax = "proto3"; +package kava.incentive.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "kava/incentive/v1beta1/apy.proto"; +import "kava/incentive/v1beta1/claims.proto"; +import "kava/incentive/v1beta1/params.proto"; + +option go_package = "github.com/kava-labs/kava/x/incentive/types"; + +// Query defines the gRPC querier service for incentive module. +service Query { + // Params queries module params. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/kava/incentive/v1beta1/params"; + } + + // Rewards queries reward information for a given user. + rpc Rewards(QueryRewardsRequest) returns (QueryRewardsResponse) { + option (google.api.http).get = "/kava/incentive/v1beta1/rewards"; + } + + // Rewards queries the reward factors. + rpc RewardFactors(QueryRewardFactorsRequest) returns (QueryRewardFactorsResponse) { + option (google.api.http).get = "/kava/incentive/v1beta1/reward_factors"; + } + + // Apy queries incentive reward apy for a reward. + rpc Apy(QueryApyRequest) returns (QueryApyResponse) { + option (google.api.http).get = "/kava/incentive/v1beta1/apy"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryRewardsRequest is the request type for the Query/Rewards RPC method. +message QueryRewardsRequest { + // owner is the address of the user to query rewards for. + string owner = 1; + // reward_type is the type of reward to query rewards for, e.g. hard, earn, + // swap. + string reward_type = 2; + // unsynchronized is a flag to query rewards that are not simulated for reward + // synchronized for the current block. + bool unsynchronized = 3; +} + +// QueryRewardsResponse is the response type for the Query/Rewards RPC method. +message QueryRewardsResponse { + repeated USDXMintingClaim usdx_minting_claims = 1 [ + (gogoproto.customname) = "USDXMintingClaims", + (gogoproto.castrepeated) = "USDXMintingClaims", + (gogoproto.nullable) = false + ]; + + repeated HardLiquidityProviderClaim hard_liquidity_provider_claims = 2 [ + (gogoproto.castrepeated) = "HardLiquidityProviderClaims", + (gogoproto.nullable) = false + ]; + + repeated DelegatorClaim delegator_claims = 3 [ + (gogoproto.castrepeated) = "DelegatorClaims", + (gogoproto.nullable) = false + ]; + + repeated SwapClaim swap_claims = 4 [ + (gogoproto.castrepeated) = "SwapClaims", + (gogoproto.nullable) = false + ]; + + repeated SavingsClaim savings_claims = 5 [ + (gogoproto.castrepeated) = "SavingsClaims", + (gogoproto.nullable) = false + ]; + + repeated EarnClaim earn_claims = 6 [ + (gogoproto.castrepeated) = "EarnClaims", + (gogoproto.nullable) = false + ]; +} + +// QueryRewardFactorsRequest is the request type for the Query/RewardFactors RPC method. +message QueryRewardFactorsRequest {} + +// QueryRewardFactorsResponse is the response type for the Query/RewardFactors RPC method. +message QueryRewardFactorsResponse { + repeated RewardIndex usdx_minting_reward_factors = 1 [ + (gogoproto.castrepeated) = "RewardIndexes", + (gogoproto.nullable) = false + ]; + repeated MultiRewardIndex hard_supply_reward_factors = 2 [ + (gogoproto.castrepeated) = "MultiRewardIndexes", + (gogoproto.nullable) = false + ]; + repeated MultiRewardIndex hard_borrow_reward_factors = 3 [ + (gogoproto.castrepeated) = "MultiRewardIndexes", + (gogoproto.nullable) = false + ]; + repeated MultiRewardIndex delegator_reward_factors = 4 [ + (gogoproto.castrepeated) = "MultiRewardIndexes", + (gogoproto.nullable) = false + ]; + repeated MultiRewardIndex swap_reward_factors = 5 [ + (gogoproto.castrepeated) = "MultiRewardIndexes", + (gogoproto.nullable) = false + ]; + repeated MultiRewardIndex savings_reward_factors = 6 [ + (gogoproto.castrepeated) = "MultiRewardIndexes", + (gogoproto.nullable) = false + ]; + repeated MultiRewardIndex earn_reward_factors = 7 [ + (gogoproto.castrepeated) = "MultiRewardIndexes", + (gogoproto.nullable) = false + ]; +} + +// QueryApysRequest is the request type for the Query/Apys RPC method. +message QueryApyRequest {} + +// QueryApysResponse is the response type for the Query/Apys RPC method. +message QueryApyResponse { + repeated Apy earn = 1 [(gogoproto.nullable) = false]; +} diff --git a/x/incentive/keeper/grpc_query.go b/x/incentive/keeper/grpc_query.go new file mode 100644 index 00000000..956eaa40 --- /dev/null +++ b/x/incentive/keeper/grpc_query.go @@ -0,0 +1,342 @@ +package keeper + +import ( + "context" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/kava-labs/kava/x/incentive/types" + liquidtypes "github.com/kava-labs/kava/x/liquid/types" +) + +const ( + RewardTypeHard = "hard" + RewardTypeUSDXMinting = "usdx_minting" + RewardTypeDelegator = "delegator" + RewardTypeSwap = "swap" + RewardTypeSavings = "savings" + RewardTypeEarn = "earn" +) + +type queryServer struct { + keeper Keeper +} + +var _ types.QueryServer = queryServer{} + +// NewQueryServerImpl creates a new server for handling gRPC queries. +func NewQueryServerImpl(keeper Keeper) types.QueryServer { + return &queryServer{ + keeper: keeper, + } +} + +func (s queryServer) Params( + ctx context.Context, + req *types.QueryParamsRequest, +) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + return &types.QueryParamsResponse{ + Params: s.keeper.GetParams(sdkCtx), + }, nil +} + +func (s queryServer) Rewards( + ctx context.Context, + req *types.QueryRewardsRequest, +) (*types.QueryRewardsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + res := types.QueryRewardsResponse{} + + hasOwner := req.Owner != "" + + var owner sdk.AccAddress + if hasOwner { + addr, err := sdk.AccAddressFromBech32(req.Owner) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err) + } + + owner = addr + } + + if err := s.queryRewards(sdkCtx, &res, owner, hasOwner, req.RewardType); err != nil { + return nil, err + } + + if !req.Unsynchronized { + if err := s.synchronizeRewards(sdkCtx, &res); err != nil { + return nil, err + } + } + + return &res, nil +} + +func (s queryServer) RewardFactors( + ctx context.Context, + req *types.QueryRewardFactorsRequest, +) (*types.QueryRewardFactorsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + var usdxFactors types.RewardIndexes + s.keeper.IterateUSDXMintingRewardFactors(sdkCtx, func(collateralType string, factor sdk.Dec) (stop bool) { + usdxFactors = usdxFactors.With(collateralType, factor) + return false + }) + + var supplyFactors types.MultiRewardIndexes + s.keeper.IterateHardSupplyRewardIndexes(sdkCtx, func(denom string, indexes types.RewardIndexes) (stop bool) { + supplyFactors = supplyFactors.With(denom, indexes) + return false + }) + + var borrowFactors types.MultiRewardIndexes + s.keeper.IterateHardBorrowRewardIndexes(sdkCtx, func(denom string, indexes types.RewardIndexes) (stop bool) { + borrowFactors = borrowFactors.With(denom, indexes) + return false + }) + + var delegatorFactors types.MultiRewardIndexes + s.keeper.IterateDelegatorRewardIndexes(sdkCtx, func(denom string, indexes types.RewardIndexes) (stop bool) { + delegatorFactors = delegatorFactors.With(denom, indexes) + return false + }) + + var swapFactors types.MultiRewardIndexes + s.keeper.IterateSwapRewardIndexes(sdkCtx, func(poolID string, indexes types.RewardIndexes) (stop bool) { + swapFactors = swapFactors.With(poolID, indexes) + return false + }) + + var savingsFactors types.MultiRewardIndexes + s.keeper.IterateSavingsRewardIndexes(sdkCtx, func(denom string, indexes types.RewardIndexes) (stop bool) { + savingsFactors = savingsFactors.With(denom, indexes) + return false + }) + + var earnFactors types.MultiRewardIndexes + s.keeper.IterateEarnRewardIndexes(sdkCtx, func(denom string, indexes types.RewardIndexes) (stop bool) { + earnFactors = earnFactors.With(denom, indexes) + return false + }) + + return &types.QueryRewardFactorsResponse{ + UsdxMintingRewardFactors: usdxFactors, + HardSupplyRewardFactors: supplyFactors, + HardBorrowRewardFactors: borrowFactors, + DelegatorRewardFactors: delegatorFactors, + SwapRewardFactors: swapFactors, + SavingsRewardFactors: savingsFactors, + EarnRewardFactors: earnFactors, + }, nil +} + +func (s queryServer) Apy( + ctx context.Context, + req *types.QueryApyRequest, +) (*types.QueryApyResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + params := s.keeper.GetParams(sdkCtx) + var apys types.APYs + + // bkava APY (staking + incentive rewards) + stakingAPR, err := GetStakingAPR(sdkCtx, s.keeper, params) + if err != nil { + return nil, err + } + + apys = append(apys, types.NewAPY(liquidtypes.DefaultDerivativeDenom, stakingAPR)) + + // Incentive only APYs + for _, param := range params.EarnRewardPeriods { + // Skip bkava as it's calculated earlier with staking rewards + if param.CollateralType == liquidtypes.DefaultDerivativeDenom { + continue + } + + // Value in the vault in the same denom as CollateralType + vaultTotalValue, err := s.keeper.earnKeeper.GetVaultTotalValue(sdkCtx, param.CollateralType) + if err != nil { + return nil, err + } + apy, err := GetAPYFromMultiRewardPeriod(sdkCtx, s.keeper, param.CollateralType, param, vaultTotalValue.Amount) + if err != nil { + return nil, err + } + + apys = append(apys, types.NewAPY(param.CollateralType, apy)) + } + + return &types.QueryApyResponse{ + Earn: apys, + }, nil +} + +// queryRewards queries the rewards for a given owner and reward type, updating +// the response with the results in place. +func (s queryServer) queryRewards( + ctx sdk.Context, + res *types.QueryRewardsResponse, + owner sdk.AccAddress, + hasOwner bool, + rewardType string, +) error { + rewardType = strings.ToLower(rewardType) + isAllRewards := rewardType == "" + + if !rewardTypeIsValid(rewardType) { + return status.Errorf(codes.InvalidArgument, "invalid reward type for owner %s: %s", owner, rewardType) + } + + if isAllRewards || rewardType == RewardTypeUSDXMinting { + if hasOwner { + usdxMintingClaim, foundUsdxMintingClaim := s.keeper.GetUSDXMintingClaim(ctx, owner) + if foundUsdxMintingClaim { + res.USDXMintingClaims = append(res.USDXMintingClaims, usdxMintingClaim) + } + } else { + usdxMintingClaims := s.keeper.GetAllUSDXMintingClaims(ctx) + res.USDXMintingClaims = append(res.USDXMintingClaims, usdxMintingClaims...) + } + } + + if isAllRewards || rewardType == RewardTypeHard { + if hasOwner { + hardClaim, foundHardClaim := s.keeper.GetHardLiquidityProviderClaim(ctx, owner) + if foundHardClaim { + res.HardLiquidityProviderClaims = append(res.HardLiquidityProviderClaims, hardClaim) + } + } else { + hardClaims := s.keeper.GetAllHardLiquidityProviderClaims(ctx) + res.HardLiquidityProviderClaims = append(res.HardLiquidityProviderClaims, hardClaims...) + } + } + + if isAllRewards || rewardType == RewardTypeDelegator { + if hasOwner { + delegatorClaim, foundDelegatorClaim := s.keeper.GetDelegatorClaim(ctx, owner) + if foundDelegatorClaim { + res.DelegatorClaims = append(res.DelegatorClaims, delegatorClaim) + } + } else { + delegatorClaims := s.keeper.GetAllDelegatorClaims(ctx) + res.DelegatorClaims = append(res.DelegatorClaims, delegatorClaims...) + } + } + + if isAllRewards || rewardType == RewardTypeSwap { + if hasOwner { + swapClaim, foundSwapClaim := s.keeper.GetSwapClaim(ctx, owner) + if foundSwapClaim { + res.SwapClaims = append(res.SwapClaims, swapClaim) + } + } else { + swapClaims := s.keeper.GetAllSwapClaims(ctx) + res.SwapClaims = append(res.SwapClaims, swapClaims...) + } + } + + if isAllRewards || rewardType == RewardTypeSavings { + if hasOwner { + savingsClaim, foundSavingsClaim := s.keeper.GetSavingsClaim(ctx, owner) + if foundSavingsClaim { + res.SavingsClaims = append(res.SavingsClaims, savingsClaim) + } + } else { + savingsClaims := s.keeper.GetAllSavingsClaims(ctx) + res.SavingsClaims = append(res.SavingsClaims, savingsClaims...) + } + } + + if isAllRewards || rewardType == RewardTypeEarn { + if hasOwner { + earnClaim, foundEarnClaim := s.keeper.GetEarnClaim(ctx, owner) + if foundEarnClaim { + res.EarnClaims = append(res.EarnClaims, earnClaim) + } + } else { + earnClaims := s.keeper.GetAllEarnClaims(ctx) + res.EarnClaims = append(res.EarnClaims, earnClaims...) + } + } + + return nil +} + +// synchronizeRewards synchronizes all non-empty rewards in place. +func (s queryServer) synchronizeRewards( + ctx sdk.Context, + res *types.QueryRewardsResponse, +) error { + // Synchronize all non-empty rewards + for i, claim := range res.USDXMintingClaims { + res.USDXMintingClaims[i] = s.keeper.SimulateUSDXMintingSynchronization(ctx, claim) + } + + for i, claim := range res.HardLiquidityProviderClaims { + res.HardLiquidityProviderClaims[i] = s.keeper.SimulateHardSynchronization(ctx, claim) + } + + for i, claim := range res.DelegatorClaims { + res.DelegatorClaims[i] = s.keeper.SimulateDelegatorSynchronization(ctx, claim) + } + + for i, claim := range res.SwapClaims { + syncedClaim, found := s.keeper.GetSynchronizedSwapClaim(ctx, claim.Owner) + if !found { + return status.Errorf(codes.Internal, "previously found swap claim for owner %s should still be found", claim.Owner) + } + res.SwapClaims[i] = syncedClaim + } + + for i, claim := range res.SavingsClaims { + syncedClaim, found := s.keeper.GetSynchronizedSavingsClaim(ctx, claim.Owner) + if !found { + return status.Errorf(codes.Internal, "previously found savings claim for owner %s should still be found", claim.Owner) + } + res.SavingsClaims[i] = syncedClaim + } + + for i, claim := range res.EarnClaims { + syncedClaim, found := s.keeper.GetSynchronizedEarnClaim(ctx, claim.Owner) + if !found { + return status.Errorf(codes.Internal, "previously found earn claim for owner %s should still be found", claim.Owner) + } + res.EarnClaims[i] = syncedClaim + } + + return nil +} + +func rewardTypeIsValid(rewardType string) bool { + return rewardType == "" || + rewardType == RewardTypeHard || + rewardType == RewardTypeUSDXMinting || + rewardType == RewardTypeDelegator || + rewardType == RewardTypeSwap || + rewardType == RewardTypeSavings || + rewardType == RewardTypeEarn +} diff --git a/x/incentive/keeper/grpc_query_test.go b/x/incentive/keeper/grpc_query_test.go new file mode 100644 index 00000000..ec6b4759 --- /dev/null +++ b/x/incentive/keeper/grpc_query_test.go @@ -0,0 +1,318 @@ +package keeper_test + +import ( + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/kava-labs/kava/app" + hardtypes "github.com/kava-labs/kava/x/hard/types" + "github.com/kava-labs/kava/x/incentive/keeper" + "github.com/kava-labs/kava/x/incentive/types" + "github.com/stretchr/testify/suite" + tmprototypes "github.com/tendermint/tendermint/proto/tendermint/types" +) + +const ( + oneYear time.Duration = 365 * 24 * time.Hour +) + +type grpcQueryTestSuite struct { + suite.Suite + + tApp app.TestApp + ctx sdk.Context + keeper keeper.Keeper + queryClient types.QueryClient + addrs []sdk.AccAddress + + genesisTime time.Time + genesisState types.GenesisState +} + +func (suite *grpcQueryTestSuite) SetupTest() { + suite.tApp = app.NewTestApp() + cdc := suite.tApp.AppCodec() + + _, addrs := app.GeneratePrivKeyAddressPairs(5) + suite.genesisTime = time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC) + + suite.addrs = addrs + + suite.ctx = suite.tApp.NewContext(true, tmprototypes.Header{}). + WithBlockTime(time.Now().UTC()) + suite.keeper = suite.tApp.GetIncentiveKeeper() + + queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.tApp.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, keeper.NewQueryServerImpl(suite.keeper)) + + suite.queryClient = types.NewQueryClient(queryHelper) + + loanToValue, _ := sdk.NewDecFromStr("0.6") + borrowLimit := sdk.NewDec(1000000000000000) + hardGS := hardtypes.NewGenesisState( + hardtypes.NewParams( + hardtypes.MoneyMarkets{ + hardtypes.NewMoneyMarket("ukava", hardtypes.NewBorrowLimit(false, borrowLimit, loanToValue), "kava:usd", sdk.NewInt(1000000), hardtypes.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()), + hardtypes.NewMoneyMarket("bnb", hardtypes.NewBorrowLimit(false, borrowLimit, loanToValue), "bnb:usd", sdk.NewInt(1000000), hardtypes.NewInterestRateModel(sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("2"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("10")), sdk.MustNewDecFromStr("0.05"), sdk.ZeroDec()), + }, + sdk.NewDec(10), + ), + hardtypes.DefaultAccumulationTimes, + hardtypes.DefaultDeposits, + hardtypes.DefaultBorrows, + hardtypes.DefaultTotalSupplied, + hardtypes.DefaultTotalBorrowed, + hardtypes.DefaultTotalReserves, + ) + + suite.genesisState = types.NewGenesisState( + types.NewParams( + types.RewardPeriods{types.NewRewardPeriod(true, "bnb-a", suite.genesisTime.Add(-1*oneYear), suite.genesisTime.Add(oneYear), c("ukava", 122354))}, + types.MultiRewardPeriods{types.NewMultiRewardPeriod(true, "bnb", suite.genesisTime.Add(-1*oneYear), suite.genesisTime.Add(oneYear), cs(c("hard", 122354)))}, + types.MultiRewardPeriods{types.NewMultiRewardPeriod(true, "bnb", suite.genesisTime.Add(-1*oneYear), suite.genesisTime.Add(oneYear), cs(c("hard", 122354)))}, + types.MultiRewardPeriods{types.NewMultiRewardPeriod(true, "ukava", suite.genesisTime.Add(-1*oneYear), suite.genesisTime.Add(oneYear), cs(c("hard", 122354)))}, + types.MultiRewardPeriods{types.NewMultiRewardPeriod(true, "btcb/usdx", suite.genesisTime.Add(-1*oneYear), suite.genesisTime.Add(oneYear), cs(c("swp", 122354)))}, + types.MultiRewardPeriods{types.NewMultiRewardPeriod(true, "ukava", suite.genesisTime.Add(-1*oneYear), suite.genesisTime.Add(oneYear), cs(c("hard", 122354)))}, + types.MultiRewardPeriods{types.NewMultiRewardPeriod(true, "ukava", suite.genesisTime.Add(-1*oneYear), suite.genesisTime.Add(oneYear), cs(c("hard", 122354)))}, + types.MultipliersPerDenoms{ + { + Denom: "ukava", + Multipliers: types.Multipliers{ + types.NewMultiplier("large", 12, d("1.0")), + }, + }, + { + Denom: "hard", + Multipliers: types.Multipliers{ + types.NewMultiplier("small", 1, d("0.25")), + types.NewMultiplier("large", 12, d("1.0")), + }, + }, + { + Denom: "swp", + Multipliers: types.Multipliers{ + types.NewMultiplier("small", 1, d("0.25")), + types.NewMultiplier("medium", 6, d("0.8")), + }, + }, + }, + suite.genesisTime.Add(5*oneYear), + ), + types.NewGenesisRewardState( + types.AccumulationTimes{ + types.NewAccumulationTime("bnb-a", suite.genesisTime), + }, + types.MultiRewardIndexes{ + types.NewMultiRewardIndex("bnb-a", types.RewardIndexes{{CollateralType: "ukava", RewardFactor: d("0.3")}}), + }, + ), + types.NewGenesisRewardState( + types.AccumulationTimes{ + types.NewAccumulationTime("bnb", suite.genesisTime.Add(-1*time.Hour)), + }, + types.MultiRewardIndexes{ + types.NewMultiRewardIndex("bnb", types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.1")}}), + }, + ), + types.NewGenesisRewardState( + types.AccumulationTimes{ + types.NewAccumulationTime("bnb", suite.genesisTime.Add(-2*time.Hour)), + }, + types.MultiRewardIndexes{ + types.NewMultiRewardIndex("bnb", types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.05")}}), + }, + ), + types.NewGenesisRewardState( + types.AccumulationTimes{ + types.NewAccumulationTime("ukava", suite.genesisTime.Add(-3*time.Hour)), + }, + types.MultiRewardIndexes{ + types.NewMultiRewardIndex("ukava", types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.2")}}), + }, + ), + types.NewGenesisRewardState( + types.AccumulationTimes{ + types.NewAccumulationTime("bctb/usdx", suite.genesisTime.Add(-4*time.Hour)), + }, + types.MultiRewardIndexes{ + types.NewMultiRewardIndex("btcb/usdx", types.RewardIndexes{{CollateralType: "swap", RewardFactor: d("0.001")}}), + }, + ), + types.NewGenesisRewardState( + types.AccumulationTimes{ + types.NewAccumulationTime("ukava", suite.genesisTime.Add(-3*time.Hour)), + }, + types.MultiRewardIndexes{ + types.NewMultiRewardIndex("ukava", types.RewardIndexes{{CollateralType: "ukava", RewardFactor: d("0.2")}}), + }, + ), + types.NewGenesisRewardState( + types.AccumulationTimes{ + types.NewAccumulationTime("usdx", suite.genesisTime.Add(-3*time.Hour)), + }, + types.MultiRewardIndexes{ + types.NewMultiRewardIndex("usdx", types.RewardIndexes{{CollateralType: "usdx", RewardFactor: d("0.2")}}), + }, + ), + types.USDXMintingClaims{ + types.NewUSDXMintingClaim( + suite.addrs[0], + c("ukava", 1e9), + types.RewardIndexes{{CollateralType: "bnb-a", RewardFactor: d("0.3")}}, + ), + types.NewUSDXMintingClaim( + suite.addrs[1], + c("ukava", 1), + types.RewardIndexes{{CollateralType: "bnb-a", RewardFactor: d("0.001")}}, + ), + }, + types.HardLiquidityProviderClaims{ + types.NewHardLiquidityProviderClaim( + suite.addrs[0], + cs(c("ukava", 1e9), c("hard", 1e9)), + types.MultiRewardIndexes{{CollateralType: "bnb", RewardIndexes: types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.01")}}}}, + types.MultiRewardIndexes{{CollateralType: "bnb", RewardIndexes: types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.0")}}}}, + ), + types.NewHardLiquidityProviderClaim( + suite.addrs[1], + cs(c("hard", 1)), + types.MultiRewardIndexes{{CollateralType: "bnb", RewardIndexes: types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.1")}}}}, + types.MultiRewardIndexes{{CollateralType: "bnb", RewardIndexes: types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.0")}}}}, + ), + }, + types.DelegatorClaims{ + types.NewDelegatorClaim( + suite.addrs[2], + cs(c("hard", 5)), + types.MultiRewardIndexes{{CollateralType: "ukava", RewardIndexes: types.RewardIndexes{{CollateralType: "hard", RewardFactor: d("0.2")}}}}, + ), + }, + types.SwapClaims{ + types.NewSwapClaim( + suite.addrs[3], + nil, + types.MultiRewardIndexes{{CollateralType: "btcb/usdx", RewardIndexes: types.RewardIndexes{{CollateralType: "swap", RewardFactor: d("0.0")}}}}, + ), + }, + types.SavingsClaims{ + types.NewSavingsClaim( + suite.addrs[3], + nil, + types.MultiRewardIndexes{{CollateralType: "ukava", RewardIndexes: types.RewardIndexes{{CollateralType: "ukava", RewardFactor: d("0.0")}}}}, + ), + }, + types.EarnClaims{ + types.NewEarnClaim( + suite.addrs[3], + nil, + types.MultiRewardIndexes{{CollateralType: "usdx", RewardIndexes: types.RewardIndexes{{CollateralType: "usdx", RewardFactor: d("0.0")}}}}, + ), + }, + ) + + err := suite.genesisState.Validate() + suite.Require().NoError(err) + + suite.tApp = suite.tApp.InitializeFromGenesisStatesWithTime( + suite.genesisTime, + app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(&suite.genesisState)}, + app.GenesisState{hardtypes.ModuleName: cdc.MustMarshalJSON(&hardGS)}, + NewCDPGenStateMulti(cdc), + NewPricefeedGenStateMultiFromTime(cdc, suite.genesisTime), + ) +} + +func (suite *grpcQueryTestSuite) TestGrpcQueryParams() { + res, err := suite.queryClient.Params(sdk.WrapSDKContext(suite.ctx), &types.QueryParamsRequest{}) + suite.Require().NoError(err) + + expected := suite.keeper.GetParams(suite.ctx) + + suite.Equal(expected, res.Params, "params should equal default params") +} + +func (suite *grpcQueryTestSuite) TestGrpcQueryRewards() { + res, err := suite.queryClient.Rewards(sdk.WrapSDKContext(suite.ctx), &types.QueryRewardsRequest{ + Unsynchronized: true, + }) + suite.Require().NoError(err) + + suite.Equal(suite.genesisState.USDXMintingClaims, res.USDXMintingClaims) + suite.Equal(suite.genesisState.HardLiquidityProviderClaims, res.HardLiquidityProviderClaims) + suite.Equal(suite.genesisState.DelegatorClaims, res.DelegatorClaims) + suite.Equal(suite.genesisState.SwapClaims, res.SwapClaims) + suite.Equal(suite.genesisState.SavingsClaims, res.SavingsClaims) + suite.Equal(suite.genesisState.EarnClaims, res.EarnClaims) +} + +func (suite *grpcQueryTestSuite) TestGrpcQueryRewards_Owner() { + res, err := suite.queryClient.Rewards(sdk.WrapSDKContext(suite.ctx), &types.QueryRewardsRequest{ + Owner: suite.addrs[0].String(), + }) + suite.Require().NoError(err) + + suite.Len(res.USDXMintingClaims, 1) + suite.Len(res.HardLiquidityProviderClaims, 1) + + suite.Equal(suite.genesisState.USDXMintingClaims[0], res.USDXMintingClaims[0]) + suite.Equal(suite.genesisState.HardLiquidityProviderClaims[0], res.HardLiquidityProviderClaims[0]) + + // No other claims - owner has none + suite.Empty(res.DelegatorClaims) + suite.Empty(res.SwapClaims) + suite.Empty(res.SavingsClaims) + suite.Empty(res.EarnClaims) +} + +func (suite *grpcQueryTestSuite) TestGrpcQueryRewards_RewardType() { + res, err := suite.queryClient.Rewards(sdk.WrapSDKContext(suite.ctx), &types.QueryRewardsRequest{ + RewardType: keeper.RewardTypeHard, + Unsynchronized: true, + }) + suite.Require().NoError(err) + + suite.Equal(suite.genesisState.HardLiquidityProviderClaims, res.HardLiquidityProviderClaims) + + // No other reward types when specifying rewardType + suite.Empty(res.USDXMintingClaims) + suite.Empty(res.DelegatorClaims) + suite.Empty(res.SwapClaims) + suite.Empty(res.SavingsClaims) + suite.Empty(res.EarnClaims) +} + +func (suite *grpcQueryTestSuite) TestGrpcQueryRewards_RewardType_and_Owner() { + res, err := suite.queryClient.Rewards(sdk.WrapSDKContext(suite.ctx), &types.QueryRewardsRequest{ + Owner: suite.addrs[0].String(), + RewardType: keeper.RewardTypeHard, + }) + suite.Require().NoError(err) + + suite.Len(res.HardLiquidityProviderClaims, 1) + suite.Equal(suite.genesisState.HardLiquidityProviderClaims[0], res.HardLiquidityProviderClaims[0]) + + suite.Empty(res.USDXMintingClaims) + suite.Empty(res.DelegatorClaims) + suite.Empty(res.SwapClaims) + suite.Empty(res.SavingsClaims) + suite.Empty(res.EarnClaims) +} + +func (suite *grpcQueryTestSuite) TestGrpcQueryRewardFactors() { + res, err := suite.queryClient.RewardFactors(sdk.WrapSDKContext(suite.ctx), &types.QueryRewardFactorsRequest{}) + suite.Require().NoError(err) + + suite.NotEmpty(res.UsdxMintingRewardFactors) + suite.NotEmpty(res.HardSupplyRewardFactors) + suite.NotEmpty(res.HardBorrowRewardFactors) + suite.NotEmpty(res.DelegatorRewardFactors) + suite.NotEmpty(res.SwapRewardFactors) + suite.NotEmpty(res.SavingsRewardFactors) + suite.NotEmpty(res.EarnRewardFactors) +} + +func TestGrpcQueryTestSuite(t *testing.T) { + suite.Run(t, new(grpcQueryTestSuite)) +} diff --git a/x/incentive/module.go b/x/incentive/module.go index 16f89f35..6da80f70 100644 --- a/x/incentive/module.go +++ b/x/incentive/module.go @@ -1,6 +1,7 @@ package incentive import ( + "context" "encoding/json" "github.com/gorilla/mux" @@ -68,10 +69,9 @@ func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Ro // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the incentive module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - // TODO: - // if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - // panic(err) - // } + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // LegacyQuerierHandler returns sdk.Querier. @@ -136,7 +136,7 @@ func (AppModule) QuerierRoute() string { // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - // TODO: types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper, am.accountKeeper, am.bankKeeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) } // InitGenesis performs genesis initialization for the incentive module. It returns no validator updates. diff --git a/x/incentive/types/apy.go b/x/incentive/types/apy.go new file mode 100644 index 00000000..d7e54462 --- /dev/null +++ b/x/incentive/types/apy.go @@ -0,0 +1,14 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +// NewAPY returns a new instance of APY +func NewAPY(collateralType string, apy sdk.Dec) Apy { + return Apy{ + CollateralType: collateralType, + Apy: apy, + } +} + +// APYs is a slice of APY +type APYs []Apy diff --git a/x/incentive/types/apy.pb.go b/x/incentive/types/apy.pb.go new file mode 100644 index 00000000..53f5fccf --- /dev/null +++ b/x/incentive/types/apy.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kava/incentive/v1beta1/apy.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// Apy contains the calculated APY for a given collateral type at a specific +// instant in time. +type Apy struct { + CollateralType string `protobuf:"bytes,1,opt,name=collateral_type,json=collateralType,proto3" json:"collateral_type,omitempty"` + Apy github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=apy,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"apy"` +} + +func (m *Apy) Reset() { *m = Apy{} } +func (m *Apy) String() string { return proto.CompactTextString(m) } +func (*Apy) ProtoMessage() {} +func (*Apy) Descriptor() ([]byte, []int) { + return fileDescriptor_b2c1ad571f25cae9, []int{0} +} +func (m *Apy) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Apy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Apy.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 *Apy) XXX_Merge(src proto.Message) { + xxx_messageInfo_Apy.Merge(m, src) +} +func (m *Apy) XXX_Size() int { + return m.Size() +} +func (m *Apy) XXX_DiscardUnknown() { + xxx_messageInfo_Apy.DiscardUnknown(m) +} + +var xxx_messageInfo_Apy proto.InternalMessageInfo + +func (m *Apy) GetCollateralType() string { + if m != nil { + return m.CollateralType + } + return "" +} + +func init() { + proto.RegisterType((*Apy)(nil), "kava.incentive.v1beta1.Apy") +} + +func init() { proto.RegisterFile("kava/incentive/v1beta1/apy.proto", fileDescriptor_b2c1ad571f25cae9) } + +var fileDescriptor_b2c1ad571f25cae9 = []byte{ + // 248 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0x4e, 0x2c, 0x4b, + 0xd4, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, + 0x49, 0x34, 0xd4, 0x4f, 0x2c, 0xa8, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x03, 0xa9, + 0xd0, 0x83, 0xab, 0xd0, 0x83, 0xaa, 0x90, 0x92, 0x4c, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x8e, 0x07, + 0xab, 0xd2, 0x87, 0x70, 0x20, 0x5a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0x21, 0xe2, 0x20, 0x16, + 0x44, 0x54, 0xa9, 0x8e, 0x8b, 0xd9, 0xb1, 0xa0, 0x52, 0x48, 0x9d, 0x8b, 0x3f, 0x39, 0x3f, 0x27, + 0x27, 0xb1, 0x24, 0xb5, 0x28, 0x31, 0x27, 0xbe, 0xa4, 0xb2, 0x20, 0x55, 0x82, 0x51, 0x81, 0x51, + 0x83, 0x33, 0x88, 0x0f, 0x21, 0x1c, 0x52, 0x59, 0x90, 0x2a, 0xe4, 0xc7, 0xc5, 0x9c, 0x58, 0x50, + 0x29, 0xc1, 0x04, 0x92, 0x74, 0xb2, 0x39, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0xb5, 0xf4, + 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xa8, 0x9d, 0x50, 0x4a, 0xb7, 0x38, 0x25, + 0x5b, 0x1f, 0x64, 0x5a, 0xb1, 0x9e, 0x4b, 0x6a, 0xf2, 0xa5, 0x2d, 0xba, 0x5c, 0x50, 0x27, 0xb9, + 0xa4, 0x26, 0x07, 0x81, 0x0c, 0x72, 0x72, 0x3d, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, + 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, + 0x86, 0x28, 0x6d, 0x24, 0x43, 0x41, 0xbe, 0xd5, 0xcd, 0x49, 0x4c, 0x2a, 0x06, 0xb3, 0xf4, 0x2b, + 0x90, 0xc2, 0x06, 0x6c, 0x7a, 0x12, 0x1b, 0xd8, 0x37, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x95, 0x59, 0xa8, 0x77, 0x3a, 0x01, 0x00, 0x00, +} + +func (m *Apy) 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 *Apy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Apy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Apy.Size() + i -= size + if _, err := m.Apy.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintApy(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.CollateralType) > 0 { + i -= len(m.CollateralType) + copy(dAtA[i:], m.CollateralType) + i = encodeVarintApy(dAtA, i, uint64(len(m.CollateralType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintApy(dAtA []byte, offset int, v uint64) int { + offset -= sovApy(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Apy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CollateralType) + if l > 0 { + n += 1 + l + sovApy(uint64(l)) + } + l = m.Apy.Size() + n += 1 + l + sovApy(uint64(l)) + return n +} + +func sovApy(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozApy(x uint64) (n int) { + return sovApy(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Apy) 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 ErrIntOverflowApy + } + 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: Apy: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Apy: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CollateralType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApy + } + 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 ErrInvalidLengthApy + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApy + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CollateralType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Apy", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApy + } + 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 ErrInvalidLengthApy + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApy + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Apy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApy(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApy + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipApy(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, ErrIntOverflowApy + } + 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, ErrIntOverflowApy + } + 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, ErrIntOverflowApy + } + 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, ErrInvalidLengthApy + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupApy + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthApy + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthApy = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowApy = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupApy = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentive/types/querier.go b/x/incentive/types/querier.go index 808a70ad..de78529a 100644 --- a/x/incentive/types/querier.go +++ b/x/incentive/types/querier.go @@ -66,30 +66,13 @@ func NewQueryGetRewardFactorsResponse(usdxMintingFactors RewardIndexes, supplyFa } } -// APY contains the APY for a given collateral type -type APY struct { - CollateralType string `json:"collateral_type" yaml:"collateral_type"` - APY sdk.Dec `json:"apy" yaml:"apy"` -} - -// NewAPY returns a new instance of APY -func NewAPY(collateralType string, apy sdk.Dec) APY { - return APY{ - CollateralType: collateralType, - APY: apy, - } -} - -// APYs is a slice of APY -type APYs []APY - // QueryGetAPYsResponse holds the response to a APY query type QueryGetAPYsResponse struct { - Earn []APY `json:"earn" yaml:"earn"` + Earn []Apy `json:"earn" yaml:"earn"` } // NewQueryGetAPYsResponse returns a new instance of QueryGetAPYsResponse -func NewQueryGetAPYsResponse(earn []APY) QueryGetAPYsResponse { +func NewQueryGetAPYsResponse(earn []Apy) QueryGetAPYsResponse { return QueryGetAPYsResponse{ Earn: earn, } diff --git a/x/incentive/types/query.pb.go b/x/incentive/types/query.pb.go new file mode 100644 index 00000000..7fbf63f8 --- /dev/null +++ b/x/incentive/types/query.pb.go @@ -0,0 +1,2425 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kava/incentive/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryRewardsRequest is the request type for the Query/Rewards RPC method. +type QueryRewardsRequest struct { + // owner is the address of the user to query rewards for. + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // reward_type is the type of reward to query rewards for, e.g. hard, earn, + // swap. + RewardType string `protobuf:"bytes,2,opt,name=reward_type,json=rewardType,proto3" json:"reward_type,omitempty"` + // unsynchronized is a flag to query rewards that are not simulated for reward + // synchronized for the current block. + Unsynchronized bool `protobuf:"varint,3,opt,name=unsynchronized,proto3" json:"unsynchronized,omitempty"` +} + +func (m *QueryRewardsRequest) Reset() { *m = QueryRewardsRequest{} } +func (m *QueryRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsRequest) ProtoMessage() {} +func (*QueryRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{2} +} +func (m *QueryRewardsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsRequest.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 *QueryRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsRequest.Merge(m, src) +} +func (m *QueryRewardsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsRequest proto.InternalMessageInfo + +func (m *QueryRewardsRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryRewardsRequest) GetRewardType() string { + if m != nil { + return m.RewardType + } + return "" +} + +func (m *QueryRewardsRequest) GetUnsynchronized() bool { + if m != nil { + return m.Unsynchronized + } + return false +} + +// QueryRewardsResponse is the response type for the Query/Rewards RPC method. +type QueryRewardsResponse struct { + USDXMintingClaims USDXMintingClaims `protobuf:"bytes,1,rep,name=usdx_minting_claims,json=usdxMintingClaims,proto3,castrepeated=USDXMintingClaims" json:"usdx_minting_claims"` + HardLiquidityProviderClaims HardLiquidityProviderClaims `protobuf:"bytes,2,rep,name=hard_liquidity_provider_claims,json=hardLiquidityProviderClaims,proto3,castrepeated=HardLiquidityProviderClaims" json:"hard_liquidity_provider_claims"` + DelegatorClaims DelegatorClaims `protobuf:"bytes,3,rep,name=delegator_claims,json=delegatorClaims,proto3,castrepeated=DelegatorClaims" json:"delegator_claims"` + SwapClaims SwapClaims `protobuf:"bytes,4,rep,name=swap_claims,json=swapClaims,proto3,castrepeated=SwapClaims" json:"swap_claims"` + SavingsClaims SavingsClaims `protobuf:"bytes,5,rep,name=savings_claims,json=savingsClaims,proto3,castrepeated=SavingsClaims" json:"savings_claims"` + EarnClaims EarnClaims `protobuf:"bytes,6,rep,name=earn_claims,json=earnClaims,proto3,castrepeated=EarnClaims" json:"earn_claims"` +} + +func (m *QueryRewardsResponse) Reset() { *m = QueryRewardsResponse{} } +func (m *QueryRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsResponse) ProtoMessage() {} +func (*QueryRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{3} +} +func (m *QueryRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsResponse.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 *QueryRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsResponse.Merge(m, src) +} +func (m *QueryRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsResponse proto.InternalMessageInfo + +func (m *QueryRewardsResponse) GetUSDXMintingClaims() USDXMintingClaims { + if m != nil { + return m.USDXMintingClaims + } + return nil +} + +func (m *QueryRewardsResponse) GetHardLiquidityProviderClaims() HardLiquidityProviderClaims { + if m != nil { + return m.HardLiquidityProviderClaims + } + return nil +} + +func (m *QueryRewardsResponse) GetDelegatorClaims() DelegatorClaims { + if m != nil { + return m.DelegatorClaims + } + return nil +} + +func (m *QueryRewardsResponse) GetSwapClaims() SwapClaims { + if m != nil { + return m.SwapClaims + } + return nil +} + +func (m *QueryRewardsResponse) GetSavingsClaims() SavingsClaims { + if m != nil { + return m.SavingsClaims + } + return nil +} + +func (m *QueryRewardsResponse) GetEarnClaims() EarnClaims { + if m != nil { + return m.EarnClaims + } + return nil +} + +// QueryRewardFactorsRequest is the request type for the Query/RewardFactors RPC method. +type QueryRewardFactorsRequest struct { +} + +func (m *QueryRewardFactorsRequest) Reset() { *m = QueryRewardFactorsRequest{} } +func (m *QueryRewardFactorsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRewardFactorsRequest) ProtoMessage() {} +func (*QueryRewardFactorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{4} +} +func (m *QueryRewardFactorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardFactorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardFactorsRequest.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 *QueryRewardFactorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardFactorsRequest.Merge(m, src) +} +func (m *QueryRewardFactorsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardFactorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardFactorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardFactorsRequest proto.InternalMessageInfo + +// QueryRewardFactorsResponse is the response type for the Query/RewardFactors RPC method. +type QueryRewardFactorsResponse struct { + UsdxMintingRewardFactors RewardIndexes `protobuf:"bytes,1,rep,name=usdx_minting_reward_factors,json=usdxMintingRewardFactors,proto3,castrepeated=RewardIndexes" json:"usdx_minting_reward_factors"` + HardSupplyRewardFactors MultiRewardIndexes `protobuf:"bytes,2,rep,name=hard_supply_reward_factors,json=hardSupplyRewardFactors,proto3,castrepeated=MultiRewardIndexes" json:"hard_supply_reward_factors"` + HardBorrowRewardFactors MultiRewardIndexes `protobuf:"bytes,3,rep,name=hard_borrow_reward_factors,json=hardBorrowRewardFactors,proto3,castrepeated=MultiRewardIndexes" json:"hard_borrow_reward_factors"` + DelegatorRewardFactors MultiRewardIndexes `protobuf:"bytes,4,rep,name=delegator_reward_factors,json=delegatorRewardFactors,proto3,castrepeated=MultiRewardIndexes" json:"delegator_reward_factors"` + SwapRewardFactors MultiRewardIndexes `protobuf:"bytes,5,rep,name=swap_reward_factors,json=swapRewardFactors,proto3,castrepeated=MultiRewardIndexes" json:"swap_reward_factors"` + SavingsRewardFactors MultiRewardIndexes `protobuf:"bytes,6,rep,name=savings_reward_factors,json=savingsRewardFactors,proto3,castrepeated=MultiRewardIndexes" json:"savings_reward_factors"` + EarnRewardFactors MultiRewardIndexes `protobuf:"bytes,7,rep,name=earn_reward_factors,json=earnRewardFactors,proto3,castrepeated=MultiRewardIndexes" json:"earn_reward_factors"` +} + +func (m *QueryRewardFactorsResponse) Reset() { *m = QueryRewardFactorsResponse{} } +func (m *QueryRewardFactorsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardFactorsResponse) ProtoMessage() {} +func (*QueryRewardFactorsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{5} +} +func (m *QueryRewardFactorsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardFactorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardFactorsResponse.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 *QueryRewardFactorsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardFactorsResponse.Merge(m, src) +} +func (m *QueryRewardFactorsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardFactorsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardFactorsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardFactorsResponse proto.InternalMessageInfo + +func (m *QueryRewardFactorsResponse) GetUsdxMintingRewardFactors() RewardIndexes { + if m != nil { + return m.UsdxMintingRewardFactors + } + return nil +} + +func (m *QueryRewardFactorsResponse) GetHardSupplyRewardFactors() MultiRewardIndexes { + if m != nil { + return m.HardSupplyRewardFactors + } + return nil +} + +func (m *QueryRewardFactorsResponse) GetHardBorrowRewardFactors() MultiRewardIndexes { + if m != nil { + return m.HardBorrowRewardFactors + } + return nil +} + +func (m *QueryRewardFactorsResponse) GetDelegatorRewardFactors() MultiRewardIndexes { + if m != nil { + return m.DelegatorRewardFactors + } + return nil +} + +func (m *QueryRewardFactorsResponse) GetSwapRewardFactors() MultiRewardIndexes { + if m != nil { + return m.SwapRewardFactors + } + return nil +} + +func (m *QueryRewardFactorsResponse) GetSavingsRewardFactors() MultiRewardIndexes { + if m != nil { + return m.SavingsRewardFactors + } + return nil +} + +func (m *QueryRewardFactorsResponse) GetEarnRewardFactors() MultiRewardIndexes { + if m != nil { + return m.EarnRewardFactors + } + return nil +} + +// QueryApysRequest is the request type for the Query/Apys RPC method. +type QueryApyRequest struct { +} + +func (m *QueryApyRequest) Reset() { *m = QueryApyRequest{} } +func (m *QueryApyRequest) String() string { return proto.CompactTextString(m) } +func (*QueryApyRequest) ProtoMessage() {} +func (*QueryApyRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{6} +} +func (m *QueryApyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryApyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryApyRequest.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 *QueryApyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryApyRequest.Merge(m, src) +} +func (m *QueryApyRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryApyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryApyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryApyRequest proto.InternalMessageInfo + +// QueryApysResponse is the response type for the Query/Apys RPC method. +type QueryApyResponse struct { + Earn []Apy `protobuf:"bytes,1,rep,name=earn,proto3" json:"earn"` +} + +func (m *QueryApyResponse) Reset() { *m = QueryApyResponse{} } +func (m *QueryApyResponse) String() string { return proto.CompactTextString(m) } +func (*QueryApyResponse) ProtoMessage() {} +func (*QueryApyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a78d71d0cbe5e95a, []int{7} +} +func (m *QueryApyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryApyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryApyResponse.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 *QueryApyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryApyResponse.Merge(m, src) +} +func (m *QueryApyResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryApyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryApyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryApyResponse proto.InternalMessageInfo + +func (m *QueryApyResponse) GetEarn() []Apy { + if m != nil { + return m.Earn + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "kava.incentive.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "kava.incentive.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryRewardsRequest)(nil), "kava.incentive.v1beta1.QueryRewardsRequest") + proto.RegisterType((*QueryRewardsResponse)(nil), "kava.incentive.v1beta1.QueryRewardsResponse") + proto.RegisterType((*QueryRewardFactorsRequest)(nil), "kava.incentive.v1beta1.QueryRewardFactorsRequest") + proto.RegisterType((*QueryRewardFactorsResponse)(nil), "kava.incentive.v1beta1.QueryRewardFactorsResponse") + proto.RegisterType((*QueryApyRequest)(nil), "kava.incentive.v1beta1.QueryApyRequest") + proto.RegisterType((*QueryApyResponse)(nil), "kava.incentive.v1beta1.QueryApyResponse") +} + +func init() { + proto.RegisterFile("kava/incentive/v1beta1/query.proto", fileDescriptor_a78d71d0cbe5e95a) +} + +var fileDescriptor_a78d71d0cbe5e95a = []byte{ + // 904 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0xeb, 0xe6, 0x47, 0xe1, 0x55, 0xdd, 0x6e, 0xa7, 0xa1, 0x1b, 0x1c, 0x70, 0xb2, 0x29, + 0xea, 0x46, 0x2c, 0xc4, 0x6a, 0x10, 0x37, 0x2e, 0x2d, 0xbb, 0x88, 0x95, 0x58, 0x69, 0x71, 0x01, + 0x21, 0x2e, 0xd5, 0x24, 0x1e, 0x5c, 0x43, 0x3a, 0xe3, 0xce, 0xd8, 0x49, 0xbd, 0x12, 0x48, 0x70, + 0x01, 0x0e, 0x48, 0x48, 0x5c, 0x39, 0x73, 0xd8, 0xbf, 0x82, 0xe3, 0x4a, 0x5c, 0x56, 0xe2, 0xc2, + 0x69, 0x17, 0xb5, 0xfc, 0x21, 0xc8, 0x33, 0x63, 0x37, 0xf6, 0xd6, 0xd9, 0x22, 0xe5, 0xe6, 0xbc, + 0xf9, 0xbe, 0xf7, 0xfd, 0x3c, 0xeb, 0xbd, 0x8c, 0xa1, 0xfb, 0x35, 0x9e, 0x60, 0xdb, 0xa7, 0x23, + 0x42, 0x43, 0x7f, 0x42, 0xec, 0xc9, 0xee, 0x90, 0x84, 0x78, 0xd7, 0x3e, 0x89, 0x08, 0x8f, 0xfb, + 0x01, 0x67, 0x21, 0x43, 0x5b, 0x89, 0xa6, 0x9f, 0x69, 0xfa, 0x5a, 0x63, 0x36, 0x3c, 0xe6, 0x31, + 0x29, 0xb1, 0x93, 0x27, 0xa5, 0x36, 0x5f, 0xf3, 0x18, 0xf3, 0xc6, 0xc4, 0xc6, 0x81, 0x6f, 0x63, + 0x4a, 0x59, 0x88, 0x43, 0x9f, 0x51, 0xa1, 0x4f, 0x3b, 0x25, 0x7e, 0x38, 0xd0, 0x6e, 0xe6, 0x76, + 0x89, 0x62, 0x34, 0xc6, 0xfe, 0xb1, 0x78, 0x81, 0x28, 0xc0, 0x1c, 0xa7, 0xa2, 0x6e, 0x03, 0xd0, + 0xc7, 0x49, 0x1b, 0x0f, 0x64, 0xd0, 0x21, 0x27, 0x11, 0x11, 0x61, 0xf7, 0x00, 0x36, 0x73, 0x51, + 0x11, 0x30, 0x2a, 0x08, 0x7a, 0x0f, 0xea, 0x2a, 0xb9, 0x69, 0x74, 0x8c, 0xde, 0xea, 0xc0, 0xea, + 0x5f, 0xde, 0x75, 0x5f, 0xe5, 0xed, 0x57, 0x1f, 0x3f, 0x6d, 0x2f, 0x39, 0x3a, 0xa7, 0x1b, 0xea, + 0xa2, 0x0e, 0x99, 0x62, 0xee, 0xa6, 0x5e, 0xa8, 0x01, 0x35, 0x36, 0xa5, 0x84, 0xcb, 0x9a, 0x2f, + 0x3b, 0xea, 0x07, 0x6a, 0xc3, 0x2a, 0x97, 0xba, 0xc3, 0x30, 0x0e, 0x48, 0x73, 0x59, 0x9e, 0x81, + 0x0a, 0x7d, 0x12, 0x07, 0x04, 0xed, 0xc0, 0xb5, 0x88, 0x8a, 0x98, 0x8e, 0x8e, 0x38, 0xa3, 0xfe, + 0x43, 0xe2, 0x36, 0x2b, 0x1d, 0xa3, 0xf7, 0x92, 0x53, 0x88, 0x76, 0xff, 0xa8, 0x41, 0x23, 0x6f, + 0xab, 0x9b, 0xf9, 0xd1, 0x80, 0xcd, 0x48, 0xb8, 0xa7, 0x87, 0xc7, 0x3e, 0x0d, 0x7d, 0xea, 0x1d, + 0xaa, 0x97, 0xd7, 0x34, 0x3a, 0x95, 0xde, 0xea, 0xa0, 0x57, 0xd6, 0xda, 0xa7, 0x07, 0x77, 0x3e, + 0xbf, 0xaf, 0x32, 0xde, 0x4f, 0x12, 0xf6, 0xfb, 0x49, 0x93, 0x67, 0x4f, 0xdb, 0x1b, 0xc5, 0x13, + 0xf1, 0xe8, 0xd9, 0x25, 0x41, 0x67, 0x23, 0x31, 0xcd, 0x85, 0xd0, 0x6f, 0x06, 0x58, 0x47, 0x49, + 0xaf, 0x63, 0xff, 0x24, 0xf2, 0x5d, 0x3f, 0x8c, 0x0f, 0x03, 0xce, 0x26, 0xbe, 0x4b, 0x78, 0x4a, + 0xb5, 0x2c, 0xa9, 0x06, 0x65, 0x54, 0x1f, 0x62, 0xee, 0x7e, 0x94, 0x26, 0x3f, 0xd0, 0xb9, 0x8a, + 0x6f, 0x3b, 0xe1, 0x7b, 0xf4, 0xac, 0xdd, 0x2a, 0xd7, 0x08, 0xa7, 0x75, 0x54, 0x7e, 0x88, 0xbe, + 0x82, 0xeb, 0x2e, 0x19, 0x13, 0x0f, 0x87, 0x2c, 0xe3, 0xa9, 0x48, 0x9e, 0x9d, 0x32, 0x9e, 0x3b, + 0xa9, 0x5e, 0x31, 0xdc, 0xd0, 0x0c, 0xeb, 0xf9, 0xb8, 0x70, 0xd6, 0xdd, 0x7c, 0x00, 0x7d, 0x06, + 0xab, 0x62, 0x8a, 0x83, 0xd4, 0xa6, 0x2a, 0x6d, 0x6e, 0x96, 0xd9, 0x1c, 0x4c, 0x71, 0xa0, 0x1c, + 0x90, 0x76, 0x80, 0x2c, 0x24, 0x1c, 0x10, 0xd9, 0x33, 0x1a, 0xc2, 0x35, 0x81, 0x27, 0x3e, 0xf5, + 0x44, 0x5a, 0xba, 0x26, 0x4b, 0xbf, 0x51, 0x5a, 0x5a, 0xa9, 0x55, 0xf5, 0x57, 0x74, 0xf5, 0xb5, + 0xd9, 0xa8, 0x70, 0xd6, 0xc4, 0xec, 0xcf, 0x84, 0x9d, 0x60, 0x4e, 0x53, 0x83, 0xfa, 0x7c, 0xf6, + 0xbb, 0x98, 0xd3, 0x02, 0x7b, 0x16, 0x12, 0x0e, 0x90, 0xec, 0xb9, 0xdb, 0x82, 0x57, 0x67, 0x26, + 0xf8, 0x03, 0x3c, 0x0a, 0x19, 0xcf, 0x56, 0xf5, 0x87, 0x15, 0x30, 0x2f, 0x3b, 0xd5, 0x53, 0x1e, + 0x43, 0x2b, 0x37, 0xe4, 0x7a, 0xa9, 0xbe, 0x54, 0x32, 0x3d, 0xec, 0xdb, 0x65, 0x8c, 0xaa, 0xe6, + 0x3d, 0xea, 0x92, 0xd3, 0x8b, 0x77, 0x30, 0x13, 0x24, 0xc2, 0x69, 0xce, 0x8c, 0x73, 0x0e, 0x01, + 0x7d, 0x67, 0x80, 0x29, 0xa7, 0x5a, 0x44, 0x41, 0x30, 0x8e, 0x8b, 0xd6, 0xcb, 0xf3, 0xf7, 0xec, + 0x7e, 0x34, 0x0e, 0xfd, 0x59, 0x7f, 0x53, 0xfb, 0xa3, 0xe2, 0x09, 0x11, 0xce, 0x8d, 0xc4, 0xe7, + 0x40, 0xda, 0x94, 0x30, 0x0c, 0x19, 0xe7, 0x6c, 0x5a, 0x64, 0xa8, 0x2c, 0x9a, 0x61, 0x5f, 0xda, + 0xe4, 0x19, 0xbe, 0x85, 0xe6, 0xc5, 0xfa, 0x14, 0x00, 0xaa, 0x0b, 0x04, 0xd8, 0xca, 0x5c, 0xf2, + 0xfe, 0x21, 0x6c, 0xca, 0x95, 0x2a, 0x58, 0xd7, 0x16, 0x68, 0xbd, 0x91, 0x18, 0xe4, 0x5d, 0x1f, + 0xc2, 0x56, 0xba, 0x70, 0x05, 0xe3, 0xfa, 0x02, 0x8d, 0x1b, 0xda, 0xe3, 0xb9, 0x8e, 0xe5, 0x22, + 0x16, 0x8c, 0x57, 0x16, 0xd9, 0x71, 0x62, 0x90, 0x73, 0xed, 0x6e, 0xc0, 0xba, 0x5c, 0xc4, 0xbd, + 0x20, 0x4e, 0x97, 0xf3, 0x1e, 0x5c, 0xbf, 0x08, 0xe9, 0x8d, 0x7c, 0x17, 0xaa, 0x49, 0xae, 0x5e, + 0xbd, 0x56, 0x19, 0xcd, 0x5e, 0x10, 0xeb, 0xfb, 0x53, 0xca, 0x07, 0x7f, 0x56, 0xa1, 0x26, 0x6b, + 0xa1, 0x9f, 0x0c, 0xa8, 0xab, 0x0b, 0x16, 0xbd, 0x59, 0x96, 0xfd, 0xfc, 0x9d, 0x6e, 0xde, 0xbe, + 0x92, 0x56, 0x41, 0x76, 0x77, 0xbe, 0xff, 0xeb, 0xdf, 0x5f, 0x97, 0x3b, 0xc8, 0xb2, 0xe7, 0x7e, + 0x44, 0xa0, 0x9f, 0x0d, 0x58, 0xd1, 0x17, 0x2b, 0x9a, 0x6f, 0x90, 0xbf, 0xf5, 0xcd, 0xb7, 0xae, + 0x26, 0xd6, 0x38, 0xb7, 0x24, 0xce, 0x4d, 0xd4, 0x2e, 0xc3, 0xe1, 0x9a, 0xe1, 0x77, 0x03, 0xd6, + 0xf2, 0xb3, 0xb0, 0x7b, 0x05, 0xa3, 0xfc, 0x5f, 0xaa, 0x39, 0xf8, 0x3f, 0x29, 0x9a, 0xb0, 0x2f, + 0x09, 0x7b, 0x68, 0x67, 0x3e, 0x61, 0x3a, 0x8b, 0xe8, 0x1b, 0xa8, 0xec, 0x05, 0x31, 0xba, 0x35, + 0xd7, 0xea, 0x62, 0x92, 0xcc, 0xde, 0x8b, 0x85, 0x9a, 0x64, 0x5b, 0x92, 0xbc, 0x8e, 0x5a, 0x76, + 0xf9, 0x67, 0xe4, 0xfe, 0xdd, 0xc7, 0x67, 0x96, 0xf1, 0xe4, 0xcc, 0x32, 0xfe, 0x39, 0xb3, 0x8c, + 0x5f, 0xce, 0xad, 0xa5, 0x27, 0xe7, 0xd6, 0xd2, 0xdf, 0xe7, 0xd6, 0xd2, 0x17, 0xb7, 0x3d, 0x3f, + 0x3c, 0x8a, 0x86, 0xfd, 0x11, 0x3b, 0x96, 0x05, 0xde, 0x1e, 0xe3, 0xa1, 0x50, 0xa5, 0x4e, 0x67, + 0x8a, 0x25, 0x5f, 0x65, 0x62, 0x58, 0x97, 0x1f, 0x91, 0xef, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, + 0x8e, 0xce, 0x8c, 0x23, 0x22, 0x0b, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params queries module params. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Rewards queries reward information for a given user. + Rewards(ctx context.Context, in *QueryRewardsRequest, opts ...grpc.CallOption) (*QueryRewardsResponse, error) + // Rewards queries the reward factors. + RewardFactors(ctx context.Context, in *QueryRewardFactorsRequest, opts ...grpc.CallOption) (*QueryRewardFactorsResponse, error) + // Apy queries incentive reward apy for a reward. + Apy(ctx context.Context, in *QueryApyRequest, opts ...grpc.CallOption) (*QueryApyResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/kava.incentive.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Rewards(ctx context.Context, in *QueryRewardsRequest, opts ...grpc.CallOption) (*QueryRewardsResponse, error) { + out := new(QueryRewardsResponse) + err := c.cc.Invoke(ctx, "/kava.incentive.v1beta1.Query/Rewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RewardFactors(ctx context.Context, in *QueryRewardFactorsRequest, opts ...grpc.CallOption) (*QueryRewardFactorsResponse, error) { + out := new(QueryRewardFactorsResponse) + err := c.cc.Invoke(ctx, "/kava.incentive.v1beta1.Query/RewardFactors", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Apy(ctx context.Context, in *QueryApyRequest, opts ...grpc.CallOption) (*QueryApyResponse, error) { + out := new(QueryApyResponse) + err := c.cc.Invoke(ctx, "/kava.incentive.v1beta1.Query/Apy", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params queries module params. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Rewards queries reward information for a given user. + Rewards(context.Context, *QueryRewardsRequest) (*QueryRewardsResponse, error) + // Rewards queries the reward factors. + RewardFactors(context.Context, *QueryRewardFactorsRequest) (*QueryRewardFactorsResponse, error) + // Apy queries incentive reward apy for a reward. + Apy(context.Context, *QueryApyRequest) (*QueryApyResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Rewards(ctx context.Context, req *QueryRewardsRequest) (*QueryRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Rewards not implemented") +} +func (*UnimplementedQueryServer) RewardFactors(ctx context.Context, req *QueryRewardFactorsRequest) (*QueryRewardFactorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RewardFactors not implemented") +} +func (*UnimplementedQueryServer) Apy(ctx context.Context, req *QueryApyRequest) (*QueryApyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Apy not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kava.incentive.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Rewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Rewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kava.incentive.v1beta1.Query/Rewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Rewards(ctx, req.(*QueryRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RewardFactors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRewardFactorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RewardFactors(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kava.incentive.v1beta1.Query/RewardFactors", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RewardFactors(ctx, req.(*QueryRewardFactorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Apy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryApyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Apy(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kava.incentive.v1beta1.Query/Apy", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Apy(ctx, req.(*QueryApyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kava.incentive.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Rewards", + Handler: _Query_Rewards_Handler, + }, + { + MethodName: "RewardFactors", + Handler: _Query_RewardFactors_Handler, + }, + { + MethodName: "Apy", + Handler: _Query_Apy_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kava/incentive/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.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 *QueryRewardsRequest) 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 *QueryRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Unsynchronized { + i-- + if m.Unsynchronized { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.RewardType) > 0 { + i -= len(m.RewardType) + copy(dAtA[i:], m.RewardType) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RewardType))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardsResponse) 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 *QueryRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EarnClaims) > 0 { + for iNdEx := len(m.EarnClaims) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EarnClaims[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.SavingsClaims) > 0 { + for iNdEx := len(m.SavingsClaims) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SavingsClaims[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.SwapClaims) > 0 { + for iNdEx := len(m.SwapClaims) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SwapClaims[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.DelegatorClaims) > 0 { + for iNdEx := len(m.DelegatorClaims) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DelegatorClaims[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.HardLiquidityProviderClaims) > 0 { + for iNdEx := len(m.HardLiquidityProviderClaims) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.HardLiquidityProviderClaims[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.USDXMintingClaims) > 0 { + for iNdEx := len(m.USDXMintingClaims) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.USDXMintingClaims[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 (m *QueryRewardFactorsRequest) 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 *QueryRewardFactorsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardFactorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryRewardFactorsResponse) 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 *QueryRewardFactorsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardFactorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EarnRewardFactors) > 0 { + for iNdEx := len(m.EarnRewardFactors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EarnRewardFactors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.SavingsRewardFactors) > 0 { + for iNdEx := len(m.SavingsRewardFactors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SavingsRewardFactors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.SwapRewardFactors) > 0 { + for iNdEx := len(m.SwapRewardFactors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SwapRewardFactors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.DelegatorRewardFactors) > 0 { + for iNdEx := len(m.DelegatorRewardFactors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DelegatorRewardFactors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.HardBorrowRewardFactors) > 0 { + for iNdEx := len(m.HardBorrowRewardFactors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.HardBorrowRewardFactors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.HardSupplyRewardFactors) > 0 { + for iNdEx := len(m.HardSupplyRewardFactors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.HardSupplyRewardFactors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.UsdxMintingRewardFactors) > 0 { + for iNdEx := len(m.UsdxMintingRewardFactors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UsdxMintingRewardFactors[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 (m *QueryApyRequest) 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 *QueryApyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryApyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryApyResponse) 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 *QueryApyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryApyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Earn) > 0 { + for iNdEx := len(m.Earn) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Earn[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 + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.RewardType) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Unsynchronized { + n += 2 + } + return n +} + +func (m *QueryRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.USDXMintingClaims) > 0 { + for _, e := range m.USDXMintingClaims { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.HardLiquidityProviderClaims) > 0 { + for _, e := range m.HardLiquidityProviderClaims { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.DelegatorClaims) > 0 { + for _, e := range m.DelegatorClaims { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.SwapClaims) > 0 { + for _, e := range m.SwapClaims { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.SavingsClaims) > 0 { + for _, e := range m.SavingsClaims { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.EarnClaims) > 0 { + for _, e := range m.EarnClaims { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryRewardFactorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryRewardFactorsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.UsdxMintingRewardFactors) > 0 { + for _, e := range m.UsdxMintingRewardFactors { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.HardSupplyRewardFactors) > 0 { + for _, e := range m.HardSupplyRewardFactors { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.HardBorrowRewardFactors) > 0 { + for _, e := range m.HardBorrowRewardFactors { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.DelegatorRewardFactors) > 0 { + for _, e := range m.DelegatorRewardFactors { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.SwapRewardFactors) > 0 { + for _, e := range m.SwapRewardFactors { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.SavingsRewardFactors) > 0 { + for _, e := range m.SavingsRewardFactors { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.EarnRewardFactors) > 0 { + for _, e := range m.EarnRewardFactors { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryApyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryApyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Earn) > 0 { + for _, e := range m.Earn { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params.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 *QueryRewardsRequest) 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: QueryRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Unsynchronized", 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.Unsynchronized = bool(v != 0) + 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 *QueryRewardsResponse) 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: QueryRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field USDXMintingClaims", 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.USDXMintingClaims = append(m.USDXMintingClaims, USDXMintingClaim{}) + if err := m.USDXMintingClaims[len(m.USDXMintingClaims)-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 HardLiquidityProviderClaims", 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.HardLiquidityProviderClaims = append(m.HardLiquidityProviderClaims, HardLiquidityProviderClaim{}) + if err := m.HardLiquidityProviderClaims[len(m.HardLiquidityProviderClaims)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorClaims", 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.DelegatorClaims = append(m.DelegatorClaims, DelegatorClaim{}) + if err := m.DelegatorClaims[len(m.DelegatorClaims)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapClaims", 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.SwapClaims = append(m.SwapClaims, SwapClaim{}) + if err := m.SwapClaims[len(m.SwapClaims)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SavingsClaims", 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.SavingsClaims = append(m.SavingsClaims, SavingsClaim{}) + if err := m.SavingsClaims[len(m.SavingsClaims)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EarnClaims", 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.EarnClaims = append(m.EarnClaims, EarnClaim{}) + if err := m.EarnClaims[len(m.EarnClaims)-1].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 *QueryRewardFactorsRequest) 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: QueryRewardFactorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardFactorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryRewardFactorsResponse) 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: QueryRewardFactorsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardFactorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UsdxMintingRewardFactors", 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.UsdxMintingRewardFactors = append(m.UsdxMintingRewardFactors, RewardIndex{}) + if err := m.UsdxMintingRewardFactors[len(m.UsdxMintingRewardFactors)-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 HardSupplyRewardFactors", 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.HardSupplyRewardFactors = append(m.HardSupplyRewardFactors, MultiRewardIndex{}) + if err := m.HardSupplyRewardFactors[len(m.HardSupplyRewardFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HardBorrowRewardFactors", 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.HardBorrowRewardFactors = append(m.HardBorrowRewardFactors, MultiRewardIndex{}) + if err := m.HardBorrowRewardFactors[len(m.HardBorrowRewardFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorRewardFactors", 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.DelegatorRewardFactors = append(m.DelegatorRewardFactors, MultiRewardIndex{}) + if err := m.DelegatorRewardFactors[len(m.DelegatorRewardFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapRewardFactors", 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.SwapRewardFactors = append(m.SwapRewardFactors, MultiRewardIndex{}) + if err := m.SwapRewardFactors[len(m.SwapRewardFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SavingsRewardFactors", 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.SavingsRewardFactors = append(m.SavingsRewardFactors, MultiRewardIndex{}) + if err := m.SavingsRewardFactors[len(m.SavingsRewardFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EarnRewardFactors", 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.EarnRewardFactors = append(m.EarnRewardFactors, MultiRewardIndex{}) + if err := m.EarnRewardFactors[len(m.EarnRewardFactors)-1].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 *QueryApyRequest) 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: QueryApyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryApyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryApyResponse) 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: QueryApyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryApyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Earn", 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.Earn = append(m.Earn, Apy{}) + if err := m.Earn[len(m.Earn)-1].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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentive/types/query.pb.gw.go b/x/incentive/types/query.pb.gw.go new file mode 100644 index 00000000..ffc69a87 --- /dev/null +++ b/x/incentive/types/query.pb.gw.go @@ -0,0 +1,366 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: kava/incentive/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Rewards_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Rewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsRequest + 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_Rewards_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Rewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Rewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsRequest + 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_Rewards_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Rewards(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RewardFactors_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardFactorsRequest + var metadata runtime.ServerMetadata + + msg, err := client.RewardFactors(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RewardFactors_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardFactorsRequest + var metadata runtime.ServerMetadata + + msg, err := server.RewardFactors(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Apy_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryApyRequest + var metadata runtime.ServerMetadata + + msg, err := client.Apy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Apy_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryApyRequest + var metadata runtime.ServerMetadata + + msg, err := server.Apy(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. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Rewards_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_Rewards_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_Rewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardFactors_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_RewardFactors_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_RewardFactors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Apy_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_Apy_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_Apy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Rewards_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_Rewards_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_Rewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardFactors_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_RewardFactors_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_RewardFactors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Apy_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_Apy_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_Apy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "incentive", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Rewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "incentive", "v1beta1", "rewards"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RewardFactors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "incentive", "v1beta1", "reward_factors"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Apy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "incentive", "v1beta1", "apy"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Rewards_0 = runtime.ForwardResponseMessage + + forward_Query_RewardFactors_0 = runtime.ForwardResponseMessage + + forward_Query_Apy_0 = runtime.ForwardResponseMessage +)