Skip to content

Commit

Permalink
Backport incentive grpc query service (#1504)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
drklee3 authored Mar 21, 2023
1 parent 357ec96 commit d512469
Show file tree
Hide file tree
Showing 11 changed files with 4,187 additions and 24 deletions.
195 changes: 195 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -4617,6 +4632,39 @@ Msg defines the hard Msg service.



<a name="kava/incentive/v1beta1/apy.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## kava/incentive/v1beta1/apy.proto



<a name="kava.incentive.v1beta1.Apy"></a>

### 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) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="kava/incentive/v1beta1/claims.proto"></a>
<p align="right"><a href="#top">Top</a></p>

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



<a name="kava/incentive/v1beta1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## kava/incentive/v1beta1/query.proto



<a name="kava.incentive.v1beta1.QueryApyRequest"></a>

### QueryApyRequest
QueryApysRequest is the request type for the Query/Apys RPC method.






<a name="kava.incentive.v1beta1.QueryApyResponse"></a>

### QueryApyResponse
QueryApysResponse is the response type for the Query/Apys RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `earn` | [Apy](#kava.incentive.v1beta1.Apy) | repeated | |






<a name="kava.incentive.v1beta1.QueryParamsRequest"></a>

### QueryParamsRequest
QueryParamsRequest is the request type for the Query/Params RPC method.






<a name="kava.incentive.v1beta1.QueryParamsResponse"></a>

### QueryParamsResponse
QueryParamsResponse is the response type for the Query/Params RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#kava.incentive.v1beta1.Params) | | |






<a name="kava.incentive.v1beta1.QueryRewardFactorsRequest"></a>

### QueryRewardFactorsRequest
QueryRewardFactorsRequest is the request type for the Query/RewardFactors RPC method.






<a name="kava.incentive.v1beta1.QueryRewardFactorsResponse"></a>

### 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 | |






<a name="kava.incentive.v1beta1.QueryRewardsRequest"></a>

### 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. |






<a name="kava.incentive.v1beta1.QueryRewardsResponse"></a>

### 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 | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="kava.incentive.v1beta1.Query"></a>

### 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|

<!-- end services -->



<a name="kava/incentive/v1beta1/tx.proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand Down
18 changes: 18 additions & 0 deletions proto/kava/incentive/v1beta1/apy.proto
Original file line number Diff line number Diff line change
@@ -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
];
}
130 changes: 130 additions & 0 deletions proto/kava/incentive/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -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];
}
Loading

0 comments on commit d512469

Please sign in to comment.