-
Notifications
You must be signed in to change notification settings - Fork 169
/
params.go
135 lines (113 loc) · 4.53 KB
/
params.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/umee-network/umee/v3/x/oracle/types"
)
// VotePeriod returns the number of blocks during which voting takes place.
func (k Keeper) VotePeriod(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeyVotePeriod, &res)
return
}
// VoteThreshold returns the minimum percentage of votes that must be received
// for a ballot to pass.
func (k Keeper) VoteThreshold(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeyVoteThreshold, &res)
return
}
// RewardBand returns the ratio of allowable exchange rate error that a validator
// can be rewarded.
func (k Keeper) RewardBand(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeyRewardBand, &res)
return
}
// RewardDistributionWindow returns the number of vote periods during which
// seigniorage reward comes in and then is distributed.
func (k Keeper) RewardDistributionWindow(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeyRewardDistributionWindow, &res)
return
}
// AcceptList returns the denom list that can be activated
func (k Keeper) AcceptList(ctx sdk.Context) (res types.DenomList) {
k.paramSpace.Get(ctx, types.KeyAcceptList, &res)
return
}
// SetAcceptList updates the accepted list of assets supported by the x/oracle
// module.
func (k Keeper) SetAcceptList(ctx sdk.Context, acceptList types.DenomList) {
k.paramSpace.Set(ctx, types.KeyAcceptList, acceptList)
}
// HistoricAcceptList returns the list of assets whose historic prices and
// medians are getting tracked.
func (k Keeper) HistoricAcceptList(ctx sdk.Context) (res types.DenomList) {
k.paramSpace.Get(ctx, types.KeyHistoricAcceptList, &res)
return
}
// IsHistoricAsset returns whether or not a given denom is being tracked as
// a historic asset.
func (k Keeper) IsHistoricAsset(ctx sdk.Context, denom string) bool {
return k.HistoricAcceptList(ctx).Contains(denom)
}
// SetHistoricAcceptList updates the the list of assets whose historic prices and
// medians are getting tracked.
func (k Keeper) SetHistoricAcceptList(ctx sdk.Context, historicAcceptList types.DenomList) {
k.paramSpace.Set(ctx, types.KeyHistoricAcceptList, historicAcceptList)
}
// SlashFraction returns oracle voting penalty rate
func (k Keeper) SlashFraction(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeySlashFraction, &res)
return
}
// SlashWindow returns # of vote period for oracle slashing
func (k Keeper) SlashWindow(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeySlashWindow, &res)
return
}
// MinValidPerWindow returns oracle slashing threshold
func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeyMinValidPerWindow, &res)
return
}
// StampPeriod returns the amount of blocks the oracle module waits
// between recording a set of prices.
func (k Keeper) StampPeriod(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeyStampPeriod, &res)
return
}
// SetStampPeriod updates the amount of blocks the oracle module waits
// between recording a set of prices.
func (k Keeper) SetStampPeriod(ctx sdk.Context, stampPeriod uint64) {
k.paramSpace.Set(ctx, types.KeyStampPeriod, stampPeriod)
}
// PrunePeriod returns the max amount of blocks that a record of the set
// of exchanges is kept.
func (k Keeper) PrunePeriod(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeyPrunePeriod, &res)
return
}
// SetPrunePeriod updates the max amount of blocks that a record of the set
// of exchanges is kept.
func (k Keeper) SetPrunePeriod(ctx sdk.Context, prunePeriod uint64) {
k.paramSpace.Set(ctx, types.KeyPrunePeriod, prunePeriod)
}
// MedianPeriod returns the amount blocks we will wait between calculating the
// median and standard deviation of the median of historic prices in the
// last Prune Period.
func (k Keeper) MedianPeriod(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeyMedianPeriod, &res)
return
}
// MedianPeriod updates the amount blocks we will wait between calculating the
// median and standard deviation of the median of historic prices in the
// last Prune Period.
func (k Keeper) SetMedianPeriod(ctx sdk.Context, medianPeriod uint64) {
k.paramSpace.Set(ctx, types.KeyMedianPeriod, medianPeriod)
}
// GetParams returns the total set of oracle parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
k.paramSpace.GetParamSet(ctx, ¶ms)
return params
}
// SetParams sets the total set of oracle parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramSpace.SetParamSet(ctx, ¶ms)
}