oracle

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: Apache-2.0 Imports: 22 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
)

Oracle error codes

View Source
const (
	QueryPrice  = "price"
	QueryVotes  = "votes"
	QueryActive = "active"
	QueryParams = "params"
)

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
)

Variables

This section is empty.

Functions

func EndBlocker

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

EndBlocker is called at the end of every block

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 ErrNoVote added in v0.0.7

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

ErrNoVote called when no vote exists

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 ErrVoterNotValidator added in v0.1.1

func ErrVoterNotValidator(codespace sdk.CodespaceType, voter sdk.AccAddress) 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)

Types

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, valset sdk.ValidatorSet, paramspace params.Subspace) Keeper

NewKeeper constructs a new keeper for oracle

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) 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 MsgPriceFeed added in v0.0.7

type MsgPriceFeed struct {
	Denom  string         `json:"denom"`
	Price  sdk.Dec        `json:"price"` // the effective price of Luna in {Denom}
	Feeder sdk.AccAddress `json:"feeder"`
}

MsgPriceFeed - 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 NewMsgPriceFeed added in v0.0.7

func NewMsgPriceFeed(denom string, price sdk.Dec, feederAddress sdk.AccAddress) MsgPriceFeed

NewMsgPriceFeed creates a MsgPriceFeed instance

func (MsgPriceFeed) GetSignBytes added in v0.0.7

func (msg MsgPriceFeed) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (MsgPriceFeed) GetSigners added in v0.0.7

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

GetSigners implements sdk.Msg

func (MsgPriceFeed) Route added in v0.0.7

func (msg MsgPriceFeed) Route() string

Route Implements Msg

func (MsgPriceFeed) String added in v0.0.7

func (msg MsgPriceFeed) String() string

String Implements Msg

func (MsgPriceFeed) Type added in v0.0.7

func (msg MsgPriceFeed) Type() string

Type implements sdk.Msg

func (MsgPriceFeed) ValidateBasic added in v0.0.7

func (msg MsgPriceFeed) 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 clear vote
	DropThreshold    sdk.Int `json:"drop_threshold"`     // tolerated drops before blacklist
	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, oracleRewardBand sdk.Dec, dropThreshold sdk.Int) 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 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.AccAddress `json:"voter"` // account 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.AccAddress) PriceVote

NewPriceVote creates a PriceVote instance

func (PriceVote) String added in v0.0.5

func (pv PriceVote) String() string

String implements fmt.Stringer

type QueryVoteParams added in v0.0.5

type QueryVoteParams struct {
	Voter sdk.AccAddress
	Denom string
}

QueryVoteParams for query 'custom/oracle/votes'

func NewQueryVoteParams added in v0.0.5

func NewQueryVoteParams(voter sdk.AccAddress, denom string) QueryVoteParams

NewQueryVoteParams creates a new instance of QueryVoteParams

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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