-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
params.go
70 lines (58 loc) · 2.17 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
package gov
import (
"fmt"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Param around deposits for governance
type DepositParams struct {
MinDeposit sdk.Coins `json:"min_deposit"` // Minimum deposit for a proposal to enter voting period.
MaxDepositPeriod time.Duration `json:"max_deposit_period"` // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months
}
func (dp DepositParams) String() string {
return fmt.Sprintf(`Deposit Params:
Min Deposit: %s
Max Deposit Period: %s`, dp.MinDeposit, dp.MaxDepositPeriod)
}
// Checks equality of DepositParams
func (dp DepositParams) Equal(dp2 DepositParams) bool {
return dp.MinDeposit.IsEqual(dp2.MinDeposit) && dp.MaxDepositPeriod == dp2.MaxDepositPeriod
}
// Param around Tallying votes in governance
type TallyParams struct {
Quorum sdk.Dec `json:"quorum"` // Minimum percentage of total stake needed to vote for a result to be considered valid
Threshold sdk.Dec `json:"threshold"` // Minimum propotion of Yes votes for proposal to pass. Initial value: 0.5
Veto sdk.Dec `json:"veto"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3
}
func (tp TallyParams) String() string {
return fmt.Sprintf(`Tally Params:
Quorum: %s
Threshold: %s
Veto: %s`,
tp.Quorum, tp.Threshold, tp.Veto)
}
// Param around Voting in governance
type VotingParams struct {
VotingPeriod time.Duration `json:"voting_period"` // Length of the voting period.
}
func (vp VotingParams) String() string {
return fmt.Sprintf(`Voting Params:
Voting Period: %s`, vp.VotingPeriod)
}
// Params returns all of the governance params
type Params struct {
VotingParams VotingParams `json:"voting_params"`
TallyParams TallyParams `json:"tally_params"`
DepositParams DepositParams `json:"deposit_params"`
}
func (gp Params) String() string {
return gp.VotingParams.String() + "\n" +
gp.TallyParams.String() + "\n" + gp.DepositParams.String()
}
func NewParams(vp VotingParams, tp TallyParams, dp DepositParams) Params {
return Params{
VotingParams: vp,
DepositParams: dp,
TallyParams: tp,
}
}