2018-06-21 17:19:14 -07:00
|
|
|
package gov
|
|
|
|
|
|
|
|
import (
|
2019-01-22 09:28:39 -08:00
|
|
|
"fmt"
|
2018-09-20 07:53:52 -07:00
|
|
|
"time"
|
|
|
|
|
2018-06-21 17:19:14 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
2019-02-08 18:33:06 -08:00
|
|
|
// Param around deposits for governance
|
2018-11-06 23:33:18 -08:00
|
|
|
type DepositParams struct {
|
2018-09-20 07:53:52 -07:00
|
|
|
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
|
2018-06-21 17:19:14 -07:00
|
|
|
}
|
|
|
|
|
2019-01-22 09:28:39 -08:00
|
|
|
func (dp DepositParams) String() string {
|
|
|
|
return fmt.Sprintf(`Deposit Params:
|
|
|
|
Min Deposit: %s
|
|
|
|
Max Deposit Period: %s`, dp.MinDeposit, dp.MaxDepositPeriod)
|
|
|
|
}
|
|
|
|
|
2019-01-07 14:24:04 -08:00
|
|
|
// Checks equality of DepositParams
|
|
|
|
func (dp DepositParams) Equal(dp2 DepositParams) bool {
|
|
|
|
return dp.MinDeposit.IsEqual(dp2.MinDeposit) && dp.MaxDepositPeriod == dp2.MaxDepositPeriod
|
|
|
|
}
|
|
|
|
|
2018-11-13 15:45:37 -08:00
|
|
|
// Param around Tallying votes in governance
|
2018-11-06 23:33:18 -08:00
|
|
|
type TallyParams struct {
|
2019-02-27 08:44:05 -08:00
|
|
|
Quorum sdk.Dec `json:"quorum"` // Minimum percentage of total stake needed to vote for a result to be considered valid
|
2019-05-02 13:50:01 -07:00
|
|
|
Threshold sdk.Dec `json:"threshold"` // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5
|
2019-02-27 08:44:05 -08:00
|
|
|
Veto sdk.Dec `json:"veto"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3
|
2018-06-21 17:19:14 -07:00
|
|
|
}
|
|
|
|
|
2019-01-22 09:28:39 -08:00
|
|
|
func (tp TallyParams) String() string {
|
|
|
|
return fmt.Sprintf(`Tally Params:
|
|
|
|
Quorum: %s
|
|
|
|
Threshold: %s
|
2019-02-27 08:44:05 -08:00
|
|
|
Veto: %s`,
|
|
|
|
tp.Quorum, tp.Threshold, tp.Veto)
|
2019-01-22 09:28:39 -08:00
|
|
|
}
|
|
|
|
|
2018-11-13 15:45:37 -08:00
|
|
|
// Param around Voting in governance
|
2018-11-06 23:33:18 -08:00
|
|
|
type VotingParams struct {
|
2018-09-20 07:53:52 -07:00
|
|
|
VotingPeriod time.Duration `json:"voting_period"` // Length of the voting period.
|
2018-06-21 17:19:14 -07:00
|
|
|
}
|
2019-01-22 09:28:39 -08:00
|
|
|
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|