types

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

noalias

nolint:deadcode unused noalias

Index

Constants

View Source
const (
	EventTypeExchangeRateUpdate = "exchange_rate_update"
	EventTypePrevote            = "prevote"
	EventTypeVote               = "vote"
	EventTypeFeedDelegate       = "feed_delegate"
	EventTypeAggregatePrevote   = "aggregate_prevote"
	EventTypeAggregateVote      = "aggregate_vote"

	AttributeKeyDenom         = "denom"
	AttributeKeyVoter         = "voter"
	AttributeKeyExchangeRate  = "exchange_rate"
	AttributeKeyExchangeRates = "exchange_rates"
	AttributeKeyOperator      = "operator"
	AttributeKeyFeeder        = "feeder"

	AttributeValueCategory = ModuleName
)

Oracle module event types

View Source
const (
	// ModuleName is the name of the oracle module
	ModuleName = "oracle"

	// StoreKey is the string store representation
	StoreKey = ModuleName

	// RouterKey is the msg router key for the oracle module
	RouterKey = ModuleName

	// QuerierRoute is the query router key for the oracle module
	QuerierRoute = ModuleName
)
View Source
const (
	DefaultVotePeriod               = core.BlocksPerMinute / 2 // 30 seconds
	DefaultSlashWindow              = core.BlocksPerWeek       // window for a week
	DefaultRewardDistributionWindow = core.BlocksPerYear       // window for a year
)

Default parameter values

View Source
const (
	QueryParameters       = "parameters"
	QueryExchangeRate     = "exchangeRate"
	QueryExchangeRates    = "exchangeRates"
	QueryActives          = "actives"
	QueryPrevotes         = "prevotes"
	QueryVotes            = "votes"
	QueryFeederDelegation = "feederDelegation"
	QueryMissCounter      = "missCounter"
	QueryAggregatePrevote = "aggregatePrevote"
	QueryAggregateVote    = "aggregateVote"
	QueryVoteTargets      = "voteTargets"
	QueryTobinTax         = "tobinTax"
	QueryTobinTaxes       = "tobinTaxes"
)

Defines the prefix of each query path

View Source
const DefaultParamspace = ModuleName

DefaultParamspace defines default space for oracle params

Variables

View Source
var (
	ErrInternal              = sdkerrors.Register(ModuleName, 1, "internal error")
	ErrInvalidExchangeRate   = sdkerrors.Register(ModuleName, 2, "invalid exchange rate")
	ErrNoPrevote             = sdkerrors.Register(ModuleName, 3, "no prevote")
	ErrNoVote                = sdkerrors.Register(ModuleName, 4, "no vote")
	ErrNoVotingPermission    = sdkerrors.Register(ModuleName, 5, "unauthorized voter")
	ErrInvalidHash           = sdkerrors.Register(ModuleName, 6, "invalid hash")
	ErrInvalidHashLength     = sdkerrors.Register(ModuleName, 7, fmt.Sprintf("invalid hash length; should equal %d", tmhash.TruncatedSize))
	ErrVerificationFailed    = sdkerrors.Register(ModuleName, 8, "hash verification failed")
	ErrRevealPeriodMissMatch = sdkerrors.Register(ModuleName, 9, "reveal period of submitted vote do not match with registered prevote")
	ErrInvalidSaltLength     = sdkerrors.Register(ModuleName, 10, "invalid salt length; should be 1~4")
	ErrNoAggregatePrevote    = sdkerrors.Register(ModuleName, 11, "no aggregate prevote")
	ErrNoAggregateVote       = sdkerrors.Register(ModuleName, 12, "no aggregate vote")
	ErrNoTobinTax            = sdkerrors.Register(ModuleName, 13, "no tobin tax")
	ErrUnknownDenom          = sdkerrors.Register(ModuleName, 14, "unknown denom")
)

Oracle Errors

View Source
var (
	// Keys for store prefixes
	PrevoteKey                      = []byte{0x01} // prefix for each key to a prevote
	VoteKey                         = []byte{0x02} // prefix for each key to a vote
	ExchangeRateKey                 = []byte{0x03} // prefix for each key to a rate
	FeederDelegationKey             = []byte{0x04} // prefix for each key to a feeder delegation
	MissCounterKey                  = []byte{0x05} // prefix for each key to a miss counter
	AggregateExchangeRatePrevoteKey = []byte{0x06} // prefix for each key to a aggregate prevote
	AggregateExchangeRateVoteKey    = []byte{0x07} // prefix for each key to a aggregate vote
	TobinTaxKey                     = []byte{0x08} // prefix for each key to a tobin tax
)

Keys for oracle store Items are stored with the following key: values

- 0x01<denom_Bytes><valAddress_Bytes>: ExchangeRatePrevote

- 0x02<denom_Bytes><valAddress_Bytes>: ExchangeRateVote

- 0x03<denom_Bytes>: sdk.Dec

- 0x04<valAddress_Bytes>: accAddress

- 0x05<valAddress_Bytes>: int64

- 0x06<valAddress_Bytes>: AggregateExchangeRatePrevote

- 0x07<valAddress_Bytes>: AggregateExchangeRateVote

- 0x08<denom_Bytes>: sdk.Dec

View Source
var (
	ParamStoreKeyVotePeriod               = []byte("voteperiod")
	ParamStoreKeyVoteThreshold            = []byte("votethreshold")
	ParamStoreKeyRewardBand               = []byte("rewardband")
	ParamStoreKeyRewardDistributionWindow = []byte("rewarddistributionwindow")
	ParamStoreKeyWhitelist                = []byte("whitelist")
	ParamStoreKeySlashFraction            = []byte("slashfraction")
	ParamStoreKeySlashWindow              = []byte("slashwindow")
	ParamStoreKeyMinValidPerWindow        = []byte("minvalidperwindow")
)

Parameter keys

View Source
var (
	DefaultVoteThreshold = sdk.NewDecWithPrec(50, 2) // 50%
	DefaultRewardBand    = sdk.NewDecWithPrec(2, 2)  // 2% (-1, 1)
	DefaultTobinTax      = sdk.NewDecWithPrec(25, 4) // 0.25%
	DefaultWhitelist     = DenomList{
		{Name: core.MicroKRWDenom, TobinTax: DefaultTobinTax},
		{Name: core.MicroSDRDenom, TobinTax: DefaultTobinTax},
		{Name: core.MicroUSDDenom, TobinTax: DefaultTobinTax},
		{Name: core.MicroMNTDenom, TobinTax: DefaultTobinTax.MulInt64(8)}}
	DefaultSlashFraction     = sdk.NewDecWithPrec(1, 4) // 0.01%
	DefaultMinValidPerWindow = sdk.NewDecWithPrec(5, 2) // 5%
)

Default parameter values

View Source
var ModuleCdc = codec.New()

ModuleCdc module codec

Functions

func ExtractDenomFromTobinTaxKey added in v0.4.0

func ExtractDenomFromTobinTaxKey(key []byte) (denom string)

ExtractDenomFromTobinTaxKey - split denom from the tobin tax key

func GetAggregateExchangeRatePrevoteKey added in v0.4.0

func GetAggregateExchangeRatePrevoteKey(v sdk.ValAddress) []byte

GetAggregateExchangeRatePrevoteKey - stored by *Validator* address

func GetAggregateExchangeRateVoteKey added in v0.4.0

func GetAggregateExchangeRateVoteKey(v sdk.ValAddress) []byte

GetAggregateExchangeRateVoteKey - stored by *Validator* address

func GetExchangeRateKey

func GetExchangeRateKey(denom string) []byte

GetExchangeRateKey - stored by *denom*

func GetExchangeRatePrevoteKey

func GetExchangeRatePrevoteKey(denom string, v sdk.ValAddress) []byte

GetExchangeRatePrevoteKey - stored by *Validator* address and denom

func GetFeederDelegationKey

func GetFeederDelegationKey(v sdk.ValAddress) []byte

GetFeederDelegationKey - stored by *Validator* address

func GetMissCounterKey

func GetMissCounterKey(v sdk.ValAddress) []byte

GetMissCounterKey - stored by *Validator* address

func GetTobinTaxKey added in v0.4.0

func GetTobinTaxKey(d string) []byte

GetTobinTaxKey - stored by *denom* bytes

func GetVoteKey

func GetVoteKey(denom string, v sdk.ValAddress) []byte

GetVoteKey - stored by *Validator* address and denom

func ParamKeyTable added in v0.4.0

func ParamKeyTable() params.KeyTable

ParamKeyTable returns the parameter key table.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the oracle genesis parameters

Types

type AggregateExchangeRatePrevote added in v0.4.0

type AggregateExchangeRatePrevote struct {
	Hash        AggregateVoteHash `json:"hash"`  // Vote hex hash to protect centralize data source problem
	Voter       sdk.ValAddress    `json:"voter"` // Voter val address
	SubmitBlock int64             `json:"submit_block"`
}

AggregateExchangeRatePrevote - struct to store a validator's aggregate prevote on the rate of Luna in the denom asset

func NewAggregateExchangeRatePrevote added in v0.4.0

func NewAggregateExchangeRatePrevote(hash AggregateVoteHash, voter sdk.ValAddress, submitBlock int64) AggregateExchangeRatePrevote

NewAggregateExchangeRatePrevote returns AggregateExchangeRatePrevote object

func (AggregateExchangeRatePrevote) String added in v0.4.0

String implements fmt.Stringer interface

type AggregateExchangeRateVote added in v0.4.0

type AggregateExchangeRateVote struct {
	ExchangeRateTuples ExchangeRateTuples `json:"exchange_rate_tuples"` // ExchangeRates of Luna in target fiat currencies
	Voter              sdk.ValAddress     `json:"voter"`                // voter val address of validator
}

AggregateExchangeRateVote - struct to store a validator's aggregate vote on the rate of Luna in the denom asset

func NewAggregateExchangeRateVote added in v0.4.0

func NewAggregateExchangeRateVote(tuples ExchangeRateTuples, voter sdk.ValAddress) AggregateExchangeRateVote

NewAggregateExchangeRateVote creates a AggregateExchangeRateVote instance

func (AggregateExchangeRateVote) String added in v0.4.0

func (pv AggregateExchangeRateVote) String() string

String implements fmt.Stringer interface

type AggregateVoteHash added in v0.4.0

type AggregateVoteHash []byte

AggregateVoteHash is hash value to hide vote exchange rates which is formatted as hex string in SHA256("{salt}:{exchange rate}{denom},...,{exchange rate}{denom}:{voter}")

func AggregateVoteHashFromHexString added in v0.4.0

func AggregateVoteHashFromHexString(s string) (AggregateVoteHash, error)

AggregateVoteHashFromHexString convert hex string to AggregateVoteHash

func GetAggregateVoteHash added in v0.4.0

func GetAggregateVoteHash(salt string, exchangeRatesStr string, voter sdk.ValAddress) AggregateVoteHash

VoteHash computes hash value of ExchangeRateVote to avoid redundant DecCoins stringify operation, use string argument

func (AggregateVoteHash) Bytes added in v0.4.0

func (h AggregateVoteHash) Bytes() []byte

Bytes returns the raw address bytes.

func (AggregateVoteHash) Empty added in v0.4.0

func (h AggregateVoteHash) Empty() bool

Empty check the name hash has zero length

func (AggregateVoteHash) Equal added in v0.4.0

Equal does bytes equal check

func (AggregateVoteHash) Format added in v0.4.0

func (h AggregateVoteHash) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface.

func (AggregateVoteHash) Marshal added in v0.4.0

func (h AggregateVoteHash) Marshal() ([]byte, error)

Marshal returns the raw address bytes. It is needed for protobuf compatibility.

func (AggregateVoteHash) MarshalJSON added in v0.4.0

func (h AggregateVoteHash) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON using Bech32.

func (AggregateVoteHash) MarshalYAML added in v0.4.0

func (h AggregateVoteHash) MarshalYAML() (interface{}, error)

MarshalYAML marshals to YAML using Bech32.

func (AggregateVoteHash) String added in v0.4.0

func (h AggregateVoteHash) String() string

String implements fmt.Stringer interface

func (*AggregateVoteHash) Unmarshal added in v0.4.0

func (h *AggregateVoteHash) Unmarshal(data []byte) error

Unmarshal sets the address to the given data. It is needed for protobuf compatibility.

func (*AggregateVoteHash) UnmarshalJSON added in v0.4.0

func (h *AggregateVoteHash) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.

type Claim

type Claim struct {
	Weight    int64          `json:"weight"`
	Recipient sdk.ValAddress `json:"recipient"`
}

Claim is an interface that directs its rewards to an attached bank account.

func NewClaim

func NewClaim(weight int64, recipient sdk.ValAddress) Claim

NewClaim generates a Claim instance.

type Denom added in v0.4.0

type Denom struct {
	Name     string  `json:"name" yaml:"name"`
	TobinTax sdk.Dec `json:"tobin_tax" yaml:"tobin_tax"`
}

Denom is the object to hold configurations of each denom

func (Denom) String added in v0.4.0

func (d Denom) String() string

String implements fmt.Stringer interface

type DenomList

type DenomList []Denom

DenomList is array of Denom

func (DenomList) String

func (dl DenomList) String() (out string)

String implements fmt.Stringer interface

type DistributionKeeper

type DistributionKeeper interface {
	AllocateTokensToValidator(ctx sdk.Context, val stakingexported.ValidatorI, tokens sdk.DecCoins)
}

DistributionKeeper is expected keeper for distribution module

type DummyStakingKeeper

type DummyStakingKeeper struct {
	// contains filtered or unexported fields
}

DummyStakingKeeper dummy staking keeper to test ballot

func GenerateRandomTestCase

func GenerateRandomTestCase() (rates []float64, valValAddrs []sdk.ValAddress, stakingKeeper DummyStakingKeeper)

GenerateRandomTestCase nolint

func NewDummyStakingKeeper

func NewDummyStakingKeeper(validators []MockValidator) DummyStakingKeeper

NewDummyStakingKeeper returns new DummyStakingKeeper instance

func (DummyStakingKeeper) IterateValidators

func (DummyStakingKeeper) IterateValidators(sdk.Context, func(index int64, validator exported.ValidatorI) (stop bool))

IterateValidators nolint

func (DummyStakingKeeper) Jail

Jail nolint

func (DummyStakingKeeper) Slash

Slash nolint

func (DummyStakingKeeper) TotalBondedTokens

func (DummyStakingKeeper) TotalBondedTokens(_ sdk.Context) sdk.Int

TotalBondedTokens nolint

func (DummyStakingKeeper) Validator

func (sk DummyStakingKeeper) Validator(ctx sdk.Context, address sdk.ValAddress) exported.ValidatorI

Validator nolint

func (DummyStakingKeeper) Validators

func (sk DummyStakingKeeper) Validators() []MockValidator

Validators nolint

type ExchangeRateBallot

type ExchangeRateBallot []VoteForTally

ExchangeRateBallot is a convinience wrapper around a ExchangeRateVote slice

func (ExchangeRateBallot) Len

func (pb ExchangeRateBallot) Len() int

Len implements sort.Interface

func (ExchangeRateBallot) Less

func (pb ExchangeRateBallot) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (ExchangeRateBallot) Power

func (pb ExchangeRateBallot) Power() int64

Power returns the total amount of voting power in the ballot

func (ExchangeRateBallot) StandardDeviation

func (pb ExchangeRateBallot) StandardDeviation() (standardDeviation sdk.Dec)

StandardDeviation returns the standard deviation by the power of the ExchangeRateVote.

func (ExchangeRateBallot) Swap

func (pb ExchangeRateBallot) Swap(i, j int)

Swap implements sort.Interface.

func (ExchangeRateBallot) ToCrossRate added in v0.4.0

func (pb ExchangeRateBallot) ToCrossRate(bases map[string]sdk.Dec) (cb ExchangeRateBallot)

ToCrossRate return cross_rate(base/exchange_rate) ballot

func (ExchangeRateBallot) ToMap added in v0.4.0

func (pb ExchangeRateBallot) ToMap() map[string]sdk.Dec

ToMap return organized exchange rate map by validator

func (ExchangeRateBallot) WeightedMedian

func (pb ExchangeRateBallot) WeightedMedian() sdk.Dec

WeightedMedian returns the median weighted by the power of the ExchangeRateVote.

type ExchangeRatePrevote

type ExchangeRatePrevote struct {
	Hash        VoteHash       `json:"hash"`  // Vote hex hash to protect centralize data source problem
	Denom       string         `json:"denom"` // Ticker name of target fiat currency
	Voter       sdk.ValAddress `json:"voter"` // Voter val address
	SubmitBlock int64          `json:"submit_block"`
}

ExchangeRatePrevote - struct to store a validator's prevote on the rate of Luna in the denom asset

func NewExchangeRatePrevote

func NewExchangeRatePrevote(hash VoteHash, denom string, voter sdk.ValAddress, submitBlock int64) ExchangeRatePrevote

NewExchangeRatePrevote returns ExchangeRatePrevote object

func (ExchangeRatePrevote) String

func (pp ExchangeRatePrevote) String() string

String implements fmt.Stringer interface

type ExchangeRatePrevotes

type ExchangeRatePrevotes []ExchangeRatePrevote

ExchangeRatePrevotes is a collection of ExchangeRatePrevote

func (ExchangeRatePrevotes) String

func (v ExchangeRatePrevotes) String() (out string)

String implements fmt.Stringer interface

type ExchangeRateTuple added in v0.4.0

type ExchangeRateTuple struct {
	Denom        string  `json:"denom"`
	ExchangeRate sdk.Dec `json:"exchange_rate"`
}

ExchangeRateTuple - struct to represent a exchange rate of Luna in the denom asset

func (ExchangeRateTuple) String added in v0.4.0

func (tuple ExchangeRateTuple) String() string

String implements fmt.Stringer interface

type ExchangeRateTuples added in v0.4.0

type ExchangeRateTuples []ExchangeRateTuple

ExchangeRateTuples - array of ExchangeRateTuple

func ParseExchangeRateTuples added in v0.4.0

func ParseExchangeRateTuples(tuplesStr string) (ExchangeRateTuples, error)

ParseExchangeRateTuples ExchangeRateTuple parser

func (ExchangeRateTuples) String added in v0.4.0

func (tuples ExchangeRateTuples) String() (out string)

String implements fmt.Stringer interface

type ExchangeRateVote

type ExchangeRateVote struct {
	ExchangeRate sdk.Dec        `json:"exchange_rate"` // ExchangeRate of Luna in target fiat currency
	Denom        string         `json:"denom"`         // Ticker name of target fiat currency
	Voter        sdk.ValAddress `json:"voter"`         // voter val address of validator
}

ExchangeRateVote - struct to store a validator's vote on the rate of Luna in the denom asset

func NewExchangeRateVote

func NewExchangeRateVote(rate sdk.Dec, denom string, voter sdk.ValAddress) ExchangeRateVote

NewExchangeRateVote creates a ExchangeRateVote instance

func (ExchangeRateVote) String

func (pv ExchangeRateVote) String() string

String implements fmt.Stringer interface

type ExchangeRateVotes

type ExchangeRateVotes []ExchangeRateVote

ExchangeRateVotes is a collection of ExchangeRateVote

func (ExchangeRateVotes) String

func (v ExchangeRateVotes) String() (out string)

String implements fmt.Stringer interface

type GenesisState

type GenesisState struct {
	Params                        Params                         `json:"params" yaml:"params"`
	FeederDelegations             map[string]sdk.AccAddress      `json:"feeder_delegations" yaml:"feeder_delegations"`
	ExchangeRates                 map[string]sdk.Dec             `json:"exchange_rates" yaml:"exchange_rates"`
	ExchangeRatePrevotes          []ExchangeRatePrevote          `json:"exchange_rate_prevotes" yaml:"exchange_rate_prevotes"`
	ExchangeRateVotes             []ExchangeRateVote             `json:"exchange_rate_votes" yaml:"exchange_rate_votes"`
	MissCounters                  map[string]int64               `json:"miss_counters" yaml:"miss_counters"`
	AggregateExchangeRatePrevotes []AggregateExchangeRatePrevote `json:"aggregate_exchange_rate_prevotes" yaml:"aggregate_exchange_rate_prevotes"`
	AggregateExchangeRateVotes    []AggregateExchangeRateVote    `json:"aggregate_exchange_rate_votes" yaml:"aggregate_exchange_rate_votes"`
	TobinTaxes                    map[string]sdk.Dec             `json:"tobin_taxes" yaml:"tobin_taxes"`
}

GenesisState - all oracle state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - default GenesisState used by columbus-2

func NewGenesisState

func NewGenesisState(
	params Params, exchangeRatePrevotes []ExchangeRatePrevote,
	exchangeRateVotes []ExchangeRateVote, rates map[string]sdk.Dec,
	feederDelegations map[string]sdk.AccAddress, missCounters map[string]int64,
	aggregateExchangeRatePrevotes []AggregateExchangeRatePrevote,
	aggregateExchangeRateVotes []AggregateExchangeRateVote,
	TobinTaxes map[string]sdk.Dec,
) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Equal

func (data GenesisState) Equal(data2 GenesisState) bool

Equal checks whether 2 GenesisState structs are equivalent.

func (GenesisState) IsEmpty

func (data GenesisState) IsEmpty() bool

IsEmpty returns if a GenesisState is empty or has data in it

type MockValidator

type MockValidator struct {
	// contains filtered or unexported fields
}

func NewMockValidator

func NewMockValidator(valAddr sdk.ValAddress, power int64) MockValidator

func (MockValidator) GetBondedTokens

func (v MockValidator) GetBondedTokens() sdk.Int

func (MockValidator) GetCommission

func (v MockValidator) GetCommission() sdk.Dec

func (MockValidator) GetConsAddr

func (MockValidator) GetConsAddr() sdk.ConsAddress

func (MockValidator) GetConsPubKey

func (MockValidator) GetConsPubKey() crypto.PubKey

func (MockValidator) GetConsensusPower

func (v MockValidator) GetConsensusPower() int64

func (MockValidator) GetDelegatorShares

func (v MockValidator) GetDelegatorShares() sdk.Dec

func (MockValidator) GetMinSelfDelegation

func (v MockValidator) GetMinSelfDelegation() sdk.Int

func (MockValidator) GetMoniker

func (MockValidator) GetMoniker() string

func (MockValidator) GetOperator

func (v MockValidator) GetOperator() sdk.ValAddress

func (MockValidator) GetStatus

func (MockValidator) GetStatus() sdk.BondStatus

func (MockValidator) GetTokens

func (v MockValidator) GetTokens() sdk.Int

func (MockValidator) IsBonded

func (MockValidator) IsBonded() bool

func (MockValidator) IsJailed

func (MockValidator) IsJailed() bool

func (MockValidator) IsUnbonded

func (MockValidator) IsUnbonded() bool

func (MockValidator) IsUnbonding

func (MockValidator) IsUnbonding() bool

func (MockValidator) SetPower

func (v MockValidator) SetPower(power int64)

func (MockValidator) SharesFromTokens

func (v MockValidator) SharesFromTokens(amt sdk.Int) (sdk.Dec, error)

func (MockValidator) SharesFromTokensTruncated

func (v MockValidator) SharesFromTokensTruncated(amt sdk.Int) (sdk.Dec, error)

func (MockValidator) TokensFromShares

func (v MockValidator) TokensFromShares(sdk.Dec) sdk.Dec

func (MockValidator) TokensFromSharesRoundUp

func (v MockValidator) TokensFromSharesRoundUp(sdk.Dec) sdk.Dec

func (MockValidator) TokensFromSharesTruncated

func (v MockValidator) TokensFromSharesTruncated(sdk.Dec) sdk.Dec

type MsgAggregateExchangeRatePrevote added in v0.4.0

type MsgAggregateExchangeRatePrevote struct {
	Hash      AggregateVoteHash `json:"hash" yaml:"hash"`
	Feeder    sdk.AccAddress    `json:"feeder" yaml:"feeder"`
	Validator sdk.ValAddress    `json:"validator" yaml:"validator"`
}

MsgAggregateExchangeRatePrevote - struct for aggregate prevoting on the ExchangeRateVote. The purpose of aggregate prevote is to hide vote exchange rates with hash which is formatted as hex string in SHA256("{salt}:{exchange rate}{denom},...,{exchange rate}{denom}:{voter}")

func NewMsgAggregateExchangeRatePrevote added in v0.4.0

func NewMsgAggregateExchangeRatePrevote(hash AggregateVoteHash, feeder sdk.AccAddress, validator sdk.ValAddress) MsgAggregateExchangeRatePrevote

NewMsgAggregateExchangeRatePrevote returns MsgAggregateExchangeRatePrevote instance

func (MsgAggregateExchangeRatePrevote) GetSignBytes added in v0.4.0

func (msg MsgAggregateExchangeRatePrevote) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgAggregateExchangeRatePrevote) GetSigners added in v0.4.0

func (msg MsgAggregateExchangeRatePrevote) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (MsgAggregateExchangeRatePrevote) Route added in v0.4.0

Route implements sdk.Msg

func (MsgAggregateExchangeRatePrevote) String added in v0.4.0

String implements fmt.Stringer interface

func (MsgAggregateExchangeRatePrevote) Type added in v0.4.0

Type implements sdk.Msg

func (MsgAggregateExchangeRatePrevote) ValidateBasic added in v0.4.0

func (msg MsgAggregateExchangeRatePrevote) ValidateBasic() error

ValidateBasic Implements sdk.Msg

type MsgAggregateExchangeRateVote added in v0.4.0

type MsgAggregateExchangeRateVote struct {
	Salt          string         `json:"salt" yaml:"salt"`
	ExchangeRates string         `json:"exchange_rates" yaml:"exchange_rates"` // comma separated dec coins
	Feeder        sdk.AccAddress `json:"feeder" yaml:"feeder"`
	Validator     sdk.ValAddress `json:"validator" yaml:"validator"`
}

MsgAggregateExchangeRateVote - struct for voting on the exchange rates of Luna denominated in various Terra assets.

func NewMsgAggregateExchangeRateVote added in v0.4.0

func NewMsgAggregateExchangeRateVote(salt string, exchangeRates string, feeder sdk.AccAddress, validator sdk.ValAddress) MsgAggregateExchangeRateVote

NewMsgAggregateExchangeRateVote returns MsgAggregateExchangeRateVote instance

func (MsgAggregateExchangeRateVote) GetSignBytes added in v0.4.0

func (msg MsgAggregateExchangeRateVote) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgAggregateExchangeRateVote) GetSigners added in v0.4.0

func (msg MsgAggregateExchangeRateVote) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (MsgAggregateExchangeRateVote) Route added in v0.4.0

Route implements sdk.Msg

func (MsgAggregateExchangeRateVote) String added in v0.4.0

func (msg MsgAggregateExchangeRateVote) String() string

String implements fmt.Stringer interface

func (MsgAggregateExchangeRateVote) Type added in v0.4.0

Type implements sdk.Msg

func (MsgAggregateExchangeRateVote) ValidateBasic added in v0.4.0

func (msg MsgAggregateExchangeRateVote) ValidateBasic() error

ValidateBasic implements sdk.Msg

type MsgDelegateFeedConsent

type MsgDelegateFeedConsent struct {
	Operator sdk.ValAddress `json:"operator" yaml:"operator"`
	Delegate sdk.AccAddress `json:"delegate" yaml:"delegate"`
}

MsgDelegateFeedConsent - struct for delegating oracle voting rights to another address.

func NewMsgDelegateFeedConsent

func NewMsgDelegateFeedConsent(operatorAddress sdk.ValAddress, feederAddress sdk.AccAddress) MsgDelegateFeedConsent

NewMsgDelegateFeedConsent creates a MsgDelegateFeedConsent instance

func (MsgDelegateFeedConsent) GetSignBytes

func (msg MsgDelegateFeedConsent) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgDelegateFeedConsent) GetSigners

func (msg MsgDelegateFeedConsent) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (MsgDelegateFeedConsent) Route

func (msg MsgDelegateFeedConsent) Route() string

Route implements sdk.Msg

func (MsgDelegateFeedConsent) String

func (msg MsgDelegateFeedConsent) String() string

String implements fmt.Stringer interface

func (MsgDelegateFeedConsent) Type

func (msg MsgDelegateFeedConsent) Type() string

Type implements sdk.Msg

func (MsgDelegateFeedConsent) ValidateBasic

func (msg MsgDelegateFeedConsent) ValidateBasic() error

ValidateBasic implements sdk.Msg

type MsgExchangeRatePrevote

type MsgExchangeRatePrevote struct {
	Hash      VoteHash       `json:"hash" yaml:"hash"`
	Denom     string         `json:"denom" yaml:"denom"`
	Feeder    sdk.AccAddress `json:"feeder" yaml:"feeder"`
	Validator sdk.ValAddress `json:"validator" yaml:"validator"`
}

MsgExchangeRatePrevote - struct for prevoting on the ExchangeRateVote. The purpose of prevote is to hide vote exchange rate with hash which is formatted as hex string in SHA256("{salt}:{exchange_rate}:{denom}:{voter}") Deprecated: normal prevote and vote will be deprecated after columbus-4

func NewMsgExchangeRatePrevote

func NewMsgExchangeRatePrevote(hash VoteHash, denom string, feederAddress sdk.AccAddress, valAddress sdk.ValAddress) MsgExchangeRatePrevote

NewMsgExchangeRatePrevote creates a MsgExchangeRatePrevote instance

func (MsgExchangeRatePrevote) GetSignBytes

func (msg MsgExchangeRatePrevote) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgExchangeRatePrevote) GetSigners

func (msg MsgExchangeRatePrevote) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (MsgExchangeRatePrevote) Route

func (msg MsgExchangeRatePrevote) Route() string

Route implements sdk.Msg

func (MsgExchangeRatePrevote) String

func (msg MsgExchangeRatePrevote) String() string

String implements fmt.Stringer interface

func (MsgExchangeRatePrevote) Type

func (msg MsgExchangeRatePrevote) Type() string

Type implements sdk.Msg

func (MsgExchangeRatePrevote) ValidateBasic

func (msg MsgExchangeRatePrevote) ValidateBasic() error

ValidateBasic Implements sdk.Msg

type MsgExchangeRateVote

type MsgExchangeRateVote struct {
	ExchangeRate sdk.Dec        `json:"exchange_rate" yaml:"exchange_rate"` // the effective rate of Luna in {Denom}
	Salt         string         `json:"salt" yaml:"salt"`
	Denom        string         `json:"denom" yaml:"denom"`
	Feeder       sdk.AccAddress `json:"feeder" yaml:"feeder"`
	Validator    sdk.ValAddress `json:"validator" yaml:"validator"`
}

MsgExchangeRateVote - struct for voting on the exchange rate of Luna denominated in various Terra assets. For example, if the validator believes that the effective exchange rate of Luna in USD is 10.39, that's what the exchange rate field would be, and if 1213.34 for KRW, same. Deprecated: normal prevote and vote will be deprecated after columbus-4

func NewMsgExchangeRateVote

func NewMsgExchangeRateVote(rate sdk.Dec, salt string, denom string, feederAddress sdk.AccAddress, valAddress sdk.ValAddress) MsgExchangeRateVote

NewMsgExchangeRateVote creates a MsgExchangeRateVote instance

func (MsgExchangeRateVote) GetSignBytes

func (msg MsgExchangeRateVote) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgExchangeRateVote) GetSigners

func (msg MsgExchangeRateVote) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (MsgExchangeRateVote) Route

func (msg MsgExchangeRateVote) Route() string

Route implements sdk.Msg

func (MsgExchangeRateVote) String

func (msg MsgExchangeRateVote) String() string

String implements fmt.Stringer interface

func (MsgExchangeRateVote) Type

func (msg MsgExchangeRateVote) Type() string

Type implements sdk.Msg

func (MsgExchangeRateVote) ValidateBasic

func (msg MsgExchangeRateVote) ValidateBasic() error

ValidateBasic implements sdk.Msg

type Params

type Params struct {
	VotePeriod               int64     `json:"vote_period" yaml:"vote_period"`                               // the number of blocks during which voting takes place.
	VoteThreshold            sdk.Dec   `json:"vote_threshold" yaml:"vote_threshold"`                         // the minimum percentage of votes that must be received for a ballot to pass.
	RewardBand               sdk.Dec   `json:"reward_band" yaml:"reward_band"`                               // the ratio of allowable exchange rate error that can be rewarded.
	RewardDistributionWindow int64     `json:"reward_distribution_window" yaml:"reward_distribution_window"` // the number of blocks during which seigniorage reward comes in and then is distributed.
	Whitelist                DenomList `json:"whitelist" yaml:"whitelist"`                                   // the denom list that can be activated,
	SlashFraction            sdk.Dec   `json:"slash_fraction" yaml:"slash_fraction"`                         // the ratio of penalty on bonded tokens
	SlashWindow              int64     `json:"slash_window" yaml:"slash_window"`                             // the number of blocks for slashing tallying
	MinValidPerWindow        sdk.Dec   `json:"min_valid_per_window" yaml:"min_valid_per_window"`             // the ratio of minimum valid oracle votes per slash window to avoid slashing
}

Params oracle parameters

func DefaultParams

func DefaultParams() Params

DefaultParams creates default oracle module parameters

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs returns the parameter set pairs.

func (Params) String

func (p Params) String() string

String implements fmt.Stringer interface

func (Params) ValidateBasic added in v0.4.0

func (p Params) ValidateBasic() error

ValidateBasic performs basic validation on oracle parameters.

type QueryAggregatePrevoteParams added in v0.4.0

type QueryAggregatePrevoteParams struct {
	Validator sdk.ValAddress
}

QueryAggregatePrevoteParams defines the params for the following queries: - 'custom/oracle/aggregatePrevote'

func NewQueryAggregatePrevoteParams added in v0.4.0

func NewQueryAggregatePrevoteParams(validator sdk.ValAddress) QueryAggregatePrevoteParams

NewQueryAggregatePrevoteParams returns params for feeder delegation query

type QueryAggregateVoteParams added in v0.4.0

type QueryAggregateVoteParams struct {
	Validator sdk.ValAddress
}

QueryAggregateVoteParams defines the params for the following queries: - 'custom/oracle/aggregateVote'

func NewQueryAggregateVoteParams added in v0.4.0

func NewQueryAggregateVoteParams(validator sdk.ValAddress) QueryAggregateVoteParams

NewQueryAggregateVoteParams returns params for feeder delegation query

type QueryExchangeRateParams

type QueryExchangeRateParams struct {
	Denom string
}

QueryExchangeRateParams defines the params for the following queries: - 'custom/oracle/exchange_rate'

func NewQueryExchangeRateParams

func NewQueryExchangeRateParams(denom string) QueryExchangeRateParams

NewQueryExchangeRateParams returns params for exchange_rate query

type QueryFeederDelegationParams

type QueryFeederDelegationParams struct {
	Validator sdk.ValAddress
}

QueryFeederDelegationParams defeins the params for the following queries: - 'custom/oracle/feederDelegation'

func NewQueryFeederDelegationParams

func NewQueryFeederDelegationParams(validator sdk.ValAddress) QueryFeederDelegationParams

NewQueryFeederDelegationParams returns params for feeder delegation query

type QueryMissCounterParams

type QueryMissCounterParams struct {
	Validator sdk.ValAddress
}

QueryMissCounterParams defines the params for the following queries: - 'custom/oracle/missCounter'

func NewQueryMissCounterParams

func NewQueryMissCounterParams(validator sdk.ValAddress) QueryMissCounterParams

NewQueryMissCounterParams returns params for feeder delegation query

type QueryPrevotesParams

type QueryPrevotesParams struct {
	Voter sdk.ValAddress
	Denom string
}

QueryPrevotesParams defines the params for the following queries: - 'custom/oracle/prevotes'

func NewQueryPrevotesParams

func NewQueryPrevotesParams(voter sdk.ValAddress, denom string) QueryPrevotesParams

NewQueryPrevotesParams returns params for exchange_rate prevotes query

type QueryTobinTaxParams added in v0.4.0

type QueryTobinTaxParams struct {
	Denom string
}

QueryTobinTaxParams defines the params for the following queries: - 'custom/oracle/tobinTax'

func NewQueryTobinTaxParams added in v0.4.0

func NewQueryTobinTaxParams(denom string) QueryTobinTaxParams

NewQueryTobinTaxParams returns params for tobin tax query

type QueryVotesParams

type QueryVotesParams struct {
	Voter sdk.ValAddress
	Denom string
}

QueryVotesParams defines the params for the following queries: - 'custom/oracle/votes'

func NewQueryVotesParams

func NewQueryVotesParams(voter sdk.ValAddress, denom string) QueryVotesParams

NewQueryVotesParams returns params for exchange_rate votes query

type StakingKeeper

type StakingKeeper interface {
	Validator(ctx sdk.Context, address sdk.ValAddress) stakingexported.ValidatorI // get validator by operator address; nil when validator not found
	TotalBondedTokens(sdk.Context) sdk.Int                                        // total bonded tokens within the validator set
	Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec)                    // slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
	Jail(sdk.Context, sdk.ConsAddress)                                            // jail a validator
	IterateValidators(sdk.Context, func(index int64, validator stakingexported.ValidatorI) (stop bool))
}

StakingKeeper is expected keeper for staking module

type SupplyKeeper

type SupplyKeeper interface {
	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, moduleName string) supplyexported.ModuleAccountI
	SetModuleAccount(sdk.Context, supplyexported.ModuleAccountI)
	GetSupply(ctx sdk.Context) (supply supplyexported.SupplyI)
	SetSupply(ctx sdk.Context, supply supplyexported.SupplyI)
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error
}

SupplyKeeper is expected keeper for supply module

type VoteForTally

type VoteForTally struct {
	ExchangeRateVote
	Power int64
}

VoteForTally is a convinience wrapper to reduct redundant lookup cost

func NewVoteForTally

func NewVoteForTally(vote ExchangeRateVote, power int64) VoteForTally

NewVoteForTally returns a new VoteForTally instance

type VoteHash

type VoteHash []byte

VoteHash is hash value to hide vote exchange rate which is formatted as hex string in SHA256("{salt}:{exchange_rate}:{denom}:{voter}")

func GetVoteHash added in v0.4.0

func GetVoteHash(salt string, rate sdk.Dec, denom string, voter sdk.ValAddress) VoteHash

GetVoteHash computes hash value of ExchangeRateVote

func VoteHashFromHexString added in v0.4.0

func VoteHashFromHexString(s string) (VoteHash, error)

VoteHashFromHexString convert hex string to VoteHash

func (VoteHash) Bytes added in v0.4.0

func (h VoteHash) Bytes() []byte

Bytes returns the raw address bytes.

func (VoteHash) Empty added in v0.4.0

func (h VoteHash) Empty() bool

Empty check the name hash has zero length

func (VoteHash) Equal added in v0.4.0

func (h VoteHash) Equal(h2 VoteHash) bool

Equal does bytes equal check

func (VoteHash) Format added in v0.4.0

func (h VoteHash) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface.

func (VoteHash) Marshal added in v0.4.0

func (h VoteHash) Marshal() ([]byte, error)

Marshal returns the raw address bytes. It is needed for protobuf compatibility.

func (VoteHash) MarshalJSON added in v0.4.0

func (h VoteHash) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON using Bech32.

func (VoteHash) MarshalYAML added in v0.4.0

func (h VoteHash) MarshalYAML() (interface{}, error)

MarshalYAML marshals to YAML using Bech32.

func (VoteHash) String added in v0.4.0

func (h VoteHash) String() string

String implements fmt.Stringer interface

func (*VoteHash) Unmarshal added in v0.4.0

func (h *VoteHash) Unmarshal(data []byte) error

Unmarshal sets the address to the given data. It is needed for protobuf compatibility.

func (*VoteHash) UnmarshalJSON added in v0.4.0

func (h *VoteHash) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL