oracle

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = "oracle"

	CodeUnknownDenom       sdk.CodeType = 1
	CodeInvalidPrice       sdk.CodeType = 2
	CodeVoterNotValidator  sdk.CodeType = 3
	CodeInvalidVote        sdk.CodeType = 4
	CodeNoVotingPermission sdk.CodeType = 5
	CodeInvalidHashLength  sdk.CodeType = 6
	CodeInvalidPrevote     sdk.CodeType = 7
	CodeVerificationFailed sdk.CodeType = 8
	CodeNotRevealPeriod    sdk.CodeType = 9
	CodeInvalidSaltLength  sdk.CodeType = 10
	CodeInvalidMsgFormat   sdk.CodeType = 11
)

Oracle error codes

View Source
const (
	QueryPrice            = "price"
	QueryVotes            = "votes"
	QueryPrevotes         = "prevotes"
	QueryActive           = "active"
	QueryParams           = "params"
	QueryFeederDelegation = "feeder"
)

query endpoints supported by the oracle Querier

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

	// DefaultParamspace is the paramspace notation
	DefaultParamspace = ModuleName
)
View Source
const (
	// LogKeyPrice is to record treasury tax for a pay msg
	LogKeyPrice = string("price")
)

Variables

This section is empty.

Functions

func EndBlocker

func EndBlocker(ctx sdk.Context, k Keeper) (resTags sdk.Tags)

EndBlocker is called at the end of every block

func ErrInvalidHashLength added in v0.2.0

func ErrInvalidHashLength(codespace sdk.CodespaceType, hashLength int) sdk.Error

ErrInvalidHashLength called when the denom is not known

func ErrInvalidMsgFormat added in v0.2.0

func ErrInvalidMsgFormat(codespace sdk.CodespaceType, msg string) sdk.Error

ErrInvalidMsgFormat called when the msg has invalid format

func ErrInvalidPrice added in v0.0.5

func ErrInvalidPrice(codespace sdk.CodespaceType, price sdk.Dec) sdk.Error

ErrInvalidPrice called when the price submitted is not valid

func ErrInvalidSaltLength added in v0.2.0

func ErrInvalidSaltLength(codespace sdk.CodespaceType, saltLength int) sdk.Error

ErrInvalidSaltLength called when the salt length is not equal 1

func ErrNoPrevote added in v0.2.0

func ErrNoPrevote(codespace sdk.CodespaceType, voter sdk.ValAddress, denom string) sdk.Error

ErrNoPrevote called when no prevote exists

func ErrNoVote added in v0.0.7

func ErrNoVote(codespace sdk.CodespaceType, voter sdk.ValAddress, denom string) sdk.Error

ErrNoVote called when no vote exists

func ErrNoVotingPermission added in v0.2.0

func ErrNoVotingPermission(codespace sdk.CodespaceType, feeder sdk.AccAddress, operator sdk.ValAddress) sdk.Error

ErrNoVotingPermission called when the feeder has no permission to submit a vote for the given operator

func ErrNotRevealPeriod added in v0.2.0

func ErrNotRevealPeriod(codespace sdk.CodespaceType) sdk.Error

ErrNotRevealPeriod called when the feeder submit price reveal vote in wrong period.

func ErrUnknownDenomination added in v0.0.4

func ErrUnknownDenomination(codespace sdk.CodespaceType, denom string) sdk.Error

ErrUnknownDenomination called when the denom is not known

func ErrVerificationFailed added in v0.2.0

func ErrVerificationFailed(codespace sdk.CodespaceType, hash []byte, retrivedHash []byte) sdk.Error

ErrInvalidSignature called when no prevote exists

func ErrVoterNotValidator added in v0.1.1

func ErrVoterNotValidator(codespace sdk.CodespaceType, voter sdk.ValAddress) sdk.Error

ErrVoterNotValidator called when the voter is not a validator

func InitGenesis added in v0.0.4

func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)

InitGenesis creates new oracle genesis

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler returns a handler for "oracle" type messages.

func NewQuerier added in v0.0.5

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func RegisterCodec added in v0.0.5

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec codec

func ValidateGenesis added in v0.0.4

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided oracle genesis state to ensure the expected invariants holds. (i.e. params in correct bounds, no duplicate validators)

func VoteHash added in v0.2.0

func VoteHash(salt string, price sdk.Dec, denom string, voter sdk.ValAddress) ([]byte, error)

VoteHash computes hash value of PriceVote

Types

type DenomList added in v0.2.2

type DenomList []string

DenomList is array of denom

func (DenomList) String added in v0.2.2

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

type DistributionKeeper added in v0.2.0

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

expected coin keeper

type FeeCollectionKeeper added in v0.2.0

type FeeCollectionKeeper interface {
	AddCollectedFees(ctx sdk.Context, coins sdk.Coins) sdk.Coins
}

expected fee keeper

type GenesisState added in v0.0.4

type GenesisState struct {
	Params Params `json:"params"` // oracle params
}

GenesisState - all oracle state that must be provided at genesis

func DefaultGenesisState added in v0.0.4

func DefaultGenesisState() GenesisState

DefaultGenesisState get raw genesis raw message for testing

func ExportGenesis added in v0.0.4

func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState

ExportGenesis returns a GenesisState for a given context and keeper. The GenesisState will contain the pool, and validator/delegator distribution info's

func NewGenesisState added in v0.0.4

func NewGenesisState(params Params) GenesisState

NewGenesisState creates new oracle GenesisState

type Keeper

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

Keeper of the oracle store

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, mk MintKeeper, dk DistributionKeeper, fck FeeCollectionKeeper,
	valset sdk.ValidatorSet, paramspace params.Subspace) Keeper

NewKeeper constructs a new keeper for oracle

func (Keeper) AddSwapFeePool added in v0.2.0

func (k Keeper) AddSwapFeePool(ctx sdk.Context, fees sdk.Coins)

setSwapFeePool sets the swap fee pool to the store

func (Keeper) GetFeedDelegate added in v0.2.0

func (k Keeper) GetFeedDelegate(ctx sdk.Context, operator sdk.ValAddress) (delegate sdk.AccAddress)

GetFeedDelegate gets the account address that the feeder right was delegated to by the validator operator.

func (Keeper) GetLunaSwapRate added in v0.0.7

func (k Keeper) GetLunaSwapRate(ctx sdk.Context, denom string) (price sdk.Dec, err sdk.Error)

GetLunaSwapRate gets the consensus exchange rate of Luna denominated in the denom asset from the store.

func (Keeper) GetParams added in v0.0.4

func (k Keeper) GetParams(ctx sdk.Context) Params

GetParams get oracle params from the global param store

func (Keeper) GetSwapFeePool added in v0.2.0

func (k Keeper) GetSwapFeePool(ctx sdk.Context) (pool sdk.Coins)

GetSwapFeePool retrieves the swap fee pool from the store

func (Keeper) SetFeedDelegate added in v0.2.0

func (k Keeper) SetFeedDelegate(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress)

SetFeedDelegate sets the account address that the feeder right was delegated to by the validator operator.

func (Keeper) SetLunaSwapRate added in v0.0.7

func (k Keeper) SetLunaSwapRate(ctx sdk.Context, denom string, price sdk.Dec)

SetLunaSwapRate sets the consensus exchange rate of Luna denominated in the denom asset to the store.

func (Keeper) SetParams added in v0.0.4

func (k Keeper) SetParams(ctx sdk.Context, params Params)

SetParams set oracle params from the global param store

type Log added in v0.2.0

type Log map[string]string

Log is map type object to organize msg result

func NewLog added in v0.2.0

func NewLog() Log

func (Log) String added in v0.2.0

func (log Log) String() string

type MintKeeper added in v0.2.0

type MintKeeper interface {
	ChangeIssuance(ctx sdk.Context, denom string, delta sdk.Int) (err sdk.Error)
}

expected mint keeper

type MsgDelegateFeederPermission added in v0.2.0

type MsgDelegateFeederPermission struct {
	Operator     sdk.ValAddress `json:"operator"`
	FeedDelegate sdk.AccAddress `json:"feed_delegate"`
}

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

func NewMsgDelegateFeederPermission added in v0.2.0

func NewMsgDelegateFeederPermission(operatorAddress sdk.ValAddress, feederAddress sdk.AccAddress) MsgDelegateFeederPermission

NewMsgDelegateFeederPermission creates a MsgDelegateFeederPermission instance

func (MsgDelegateFeederPermission) GetSignBytes added in v0.2.0

func (msg MsgDelegateFeederPermission) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgDelegateFeederPermission) GetSigners added in v0.2.0

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

GetSigners implements sdk.Msg

func (MsgDelegateFeederPermission) Route added in v0.2.0

func (msg MsgDelegateFeederPermission) Route() string

Route Implements Msg

func (MsgDelegateFeederPermission) String added in v0.2.0

func (msg MsgDelegateFeederPermission) String() string

String Implements Msg

func (MsgDelegateFeederPermission) Type added in v0.2.0

Type implements sdk.Msg

func (MsgDelegateFeederPermission) ValidateBasic added in v0.2.0

func (msg MsgDelegateFeederPermission) ValidateBasic() sdk.Error

ValidateBasic Implements sdk.Msg

type MsgPricePrevote added in v0.2.0

type MsgPricePrevote struct {
	Hash      string         `json:"hash"` // hex string
	Denom     string         `json:"denom"`
	Feeder    sdk.AccAddress `json:"feeder"`
	Validator sdk.ValAddress `json:"validator"`
}

MsgPricePrevote - struct for prevoting on the PriceVote. The purpose of prevote is to hide vote price with hash which is formatted as hex string in SHA256("salt:price:denom:voter")

func NewMsgPricePrevote added in v0.2.0

func NewMsgPricePrevote(VoteHash string, denom string, feederAddress sdk.AccAddress, valAddress sdk.ValAddress) MsgPricePrevote

NewMsgPricePrevote creates a MsgPricePrevote instance

func (MsgPricePrevote) GetSignBytes added in v0.2.0

func (msg MsgPricePrevote) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgPricePrevote) GetSigners added in v0.2.0

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

GetSigners implements sdk.Msg

func (MsgPricePrevote) Route added in v0.2.0

func (msg MsgPricePrevote) Route() string

Route Implements Msg

func (MsgPricePrevote) String added in v0.2.0

func (msg MsgPricePrevote) String() string

String Implements Msg

func (MsgPricePrevote) Type added in v0.2.0

func (msg MsgPricePrevote) Type() string

Type implements sdk.Msg

func (MsgPricePrevote) ValidateBasic added in v0.2.0

func (msg MsgPricePrevote) ValidateBasic() sdk.Error

ValidateBasic Implements sdk.Msg

type MsgPriceVote added in v0.2.0

type MsgPriceVote struct {
	Price     sdk.Dec        `json:"price"` // the effective price of Luna in {Denom}
	Salt      string         `json:"salt"`
	Denom     string         `json:"denom"`
	Feeder    sdk.AccAddress `json:"feeder"`
	Validator sdk.ValAddress `json:"validator"`
}

MsgPriceVote - struct for voting on the price of Luna denominated in various Terra assets. For example, if the validator believes that the effective price of Luna in USD is 10.39, that's what the price field would be, and if 1213.34 for KRW, same.

func NewMsgPriceVote added in v0.2.0

func NewMsgPriceVote(price sdk.Dec, salt string, denom string, feederAddress sdk.AccAddress, valAddress sdk.ValAddress) MsgPriceVote

NewMsgPriceVote creates a MsgPriceVote instance

func (MsgPriceVote) GetSignBytes added in v0.2.0

func (msg MsgPriceVote) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgPriceVote) GetSigners added in v0.2.0

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

GetSigners implements sdk.Msg

func (MsgPriceVote) Route added in v0.2.0

func (msg MsgPriceVote) Route() string

Route Implements Msg

func (MsgPriceVote) String added in v0.2.0

func (msg MsgPriceVote) String() string

String Implements Msg

func (MsgPriceVote) Type added in v0.2.0

func (msg MsgPriceVote) Type() string

Type implements sdk.Msg

func (MsgPriceVote) ValidateBasic added in v0.2.0

func (msg MsgPriceVote) ValidateBasic() sdk.Error

ValidateBasic Implements sdk.Msg

type Params added in v0.0.4

type Params struct {
	VotePeriod       int64   `json:"vote_period"`        // voting period in block height; tallys and reward claim period
	VoteThreshold    sdk.Dec `json:"vote_threshold"`     // minimum stake power threshold to update price
	OracleRewardBand sdk.Dec `json:"oracle_reward_band"` // band around the oracle weighted median to reward
}

Params oracle parameters

func DefaultParams added in v0.0.4

func DefaultParams() Params

DefaultParams creates default oracle module parameters

func NewParams added in v0.0.4

func NewParams(votePeriod int64, voteThreshold sdk.Dec, oracleRewardBand sdk.Dec) Params

NewParams creates a new param instance

func (Params) String added in v0.0.5

func (params Params) String() string

type PriceBallot added in v0.0.5

type PriceBallot []PriceVote

PriceBallot is a convinience wrapper arounda a PriceVote slice

func (PriceBallot) Len added in v0.0.5

func (pb PriceBallot) Len() int

Len implements sort.Interface

func (PriceBallot) Less added in v0.0.5

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

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

func (PriceBallot) String added in v0.0.5

func (pb PriceBallot) String() (out string)

String implements fmt.Stringer interface

func (PriceBallot) Swap added in v0.0.5

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

Swap implements sort.Interface.

type PricePrevote added in v0.2.0

type PricePrevote struct {
	Hash        string         `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"`
}

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

func NewPricePrevote added in v0.2.0

func NewPricePrevote(hash string, denom string, voter sdk.ValAddress, submitBlock int64) PricePrevote

func (PricePrevote) String added in v0.2.0

func (pp PricePrevote) String() string

String implements fmt.Stringer

type PricePrevotes added in v0.2.0

type PricePrevotes []PricePrevote

PricePrevotes is a collection of PreicePrevote

func (PricePrevotes) String added in v0.2.0

func (v PricePrevotes) String() (out string)

type PriceVote

type PriceVote struct {
	Price sdk.Dec        `json:"price"` // Price 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
}

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

func NewPriceVote

func NewPriceVote(price sdk.Dec, denom string, voter sdk.ValAddress) PriceVote

NewPriceVote creates a PriceVote instance

func (PriceVote) String added in v0.0.5

func (pv PriceVote) String() string

String implements fmt.Stringer

type PriceVotes

type PriceVotes []PriceVote

PriceVotes is a collection of PriceVote

func (PriceVotes) String added in v0.2.0

func (v PriceVotes) String() (out string)

type QueryActiveResponse added in v0.2.2

type QueryActiveResponse struct {
	Actives DenomList `json:"actives"`
}

JSON response format

func (QueryActiveResponse) String added in v0.2.2

func (r QueryActiveResponse) String() (out string)

type QueryFeederDelegationParams added in v0.2.0

type QueryFeederDelegationParams struct {
	Validator sdk.ValAddress
}

QueryFeederDelegationParams for query 'custom/oracle/feeder-delegation'

func NewQueryFeederDelegationParams added in v0.2.0

func NewQueryFeederDelegationParams(validator sdk.ValAddress) QueryFeederDelegationParams

NewQueryFeederDelegationParams creates a new instance of QueryFeederDelegationParams

type QueryFeederDelegationResponse added in v0.2.2

type QueryFeederDelegationResponse struct {
	Delegatee sdk.AccAddress `json:"delegatee"`
}

JSON response format

func (QueryFeederDelegationResponse) String added in v0.2.2

func (r QueryFeederDelegationResponse) String() (out string)

type QueryPrevotesParams added in v0.2.2

type QueryPrevotesParams QueryVotesParams

QueryPrevotesParams for query 'custom/oracle/prevotes'

func NewQueryPrevotesParams added in v0.2.2

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

NewQueryPrevotesParams creates a new instance of QueryPrevotesParams

type QueryPrevotesResponse added in v0.2.2

type QueryPrevotesResponse struct {
	Prevotes PricePrevotes `json:"prevotes"`
}

JSON response format

func (QueryPrevotesResponse) String added in v0.2.2

func (r QueryPrevotesResponse) String() (out string)

type QueryPriceResponse added in v0.2.2

type QueryPriceResponse struct {
	Price sdk.Dec `json:"price"`
}

JSON response format

func (QueryPriceResponse) String added in v0.2.2

func (r QueryPriceResponse) String() (out string)

type QueryVotesParams added in v0.2.2

type QueryVotesParams struct {
	Voter sdk.ValAddress
	Denom string
}

QueryVoteParams for query 'custom/oracle/votes'

func NewQueryVotesParams added in v0.2.2

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

NewQueryVotesParams creates a new instance of QueryVotesParams

type QueryVotesResponse added in v0.2.2

type QueryVotesResponse struct {
	Votes PriceVotes `json:"votes"`
}

JSON response format

func (QueryVotesResponse) String added in v0.2.2

func (r QueryVotesResponse) String() (out string)

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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