-
Notifications
You must be signed in to change notification settings - Fork 368
/
querier.go
96 lines (84 loc) · 3.55 KB
/
querier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Querier routes for the incentive module
const (
QueryGetHardRewards = "hard-rewards"
QueryGetUSDXMintingRewards = "usdx-minting-rewards"
QueryGetDelegatorRewards = "delegator-rewards"
QueryGetSwapRewards = "swap-rewards"
QueryGetSavingsRewards = "savings-rewards"
QueryGetEarnRewards = "earn-rewards"
QueryGetRewardFactors = "reward-factors"
QueryGetParams = "parameters"
QueryGetAPYs = "apys"
RestClaimCollateralType = "collateral_type"
RestClaimOwner = "owner"
RestClaimType = "type"
RestUnsynced = "unsynced"
)
// QueryRewardsParams params for query /incentive/rewards/<claim type>
type QueryRewardsParams struct {
Page int `json:"page" yaml:"page"`
Limit int `json:"limit" yaml:"limit"`
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
Unsynchronized bool `json:"unsynchronized" yaml:"unsynchronized"`
}
// NewQueryRewardsParams returns QueryRewardsParams
func NewQueryRewardsParams(page, limit int, owner sdk.AccAddress, unsynchronized bool) QueryRewardsParams {
return QueryRewardsParams{
Page: page,
Limit: limit,
Owner: owner,
Unsynchronized: unsynchronized,
}
}
// QueryGetRewardFactorsResponse holds the response to a reward factor query
type QueryGetRewardFactorsResponse struct {
USDXMintingRewardFactors RewardIndexes `json:"usdx_minting_reward_factors" yaml:"usdx_minting_reward_factors"`
HardSupplyRewardFactors MultiRewardIndexes `json:"hard_supply_reward_factors" yaml:"hard_supply_reward_factors"`
HardBorrowRewardFactors MultiRewardIndexes `json:"hard_borrow_reward_factors" yaml:"hard_borrow_reward_factors"`
DelegatorRewardFactors MultiRewardIndexes `json:"delegator_reward_factors" yaml:"delegator_reward_factors"`
SwapRewardFactors MultiRewardIndexes `json:"swap_reward_factors" yaml:"swap_reward_factors"`
SavingsRewardFactors MultiRewardIndexes `json:"savings_reward_factors" yaml:"savings_reward_factors"`
EarnRewardFactors MultiRewardIndexes `json:"earn_reward_factors" yaml:"earn_reward_factors"`
}
// NewQueryGetRewardFactorsResponse returns a new instance of QueryAllRewardFactorsResponse
func NewQueryGetRewardFactorsResponse(usdxMintingFactors RewardIndexes, supplyFactors,
hardBorrowFactors, delegatorFactors, swapFactors, savingsFactors, earnFactors MultiRewardIndexes,
) QueryGetRewardFactorsResponse {
return QueryGetRewardFactorsResponse{
USDXMintingRewardFactors: usdxMintingFactors,
HardSupplyRewardFactors: supplyFactors,
HardBorrowRewardFactors: hardBorrowFactors,
DelegatorRewardFactors: delegatorFactors,
SwapRewardFactors: swapFactors,
SavingsRewardFactors: savingsFactors,
EarnRewardFactors: earnFactors,
}
}
// 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"`
}
// NewQueryGetAPYsResponse returns a new instance of QueryGetAPYsResponse
func NewQueryGetAPYsResponse(earn []APY) QueryGetAPYsResponse {
return QueryGetAPYsResponse{
Earn: earn,
}
}