-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport incentive grpc query service (#1504)
* 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
Showing
11 changed files
with
4,187 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} |
Oops, something went wrong.