types

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: Apache-2.0 Imports: 9 Imported by: 12

Documentation

Index

Constants

View Source
const (
	EventTypeMarketPriceUpdated = "market_price_updated"
	EventTypeOracleUpdatedPrice = "oracle_updated_price"
	EventTypeNoValidPrices      = "no_valid_prices"

	AttributeValueCategory = ModuleName
	AttributeMarketID      = "market_id"
	AttributeMarketPrice   = "market_price"
	AttributeOracle        = "oracle"
	AttributeExpiry        = "expiry"
)

Pricefeed module event types

View Source
const (
	// ModuleName The name that will be used throughout the module
	ModuleName = "pricefeed"

	// StoreKey Top level store key where all module items will be stored
	StoreKey = ModuleName

	// RouterKey Top level router key
	RouterKey = ModuleName

	// QuerierRoute is the querier route for gov
	QuerierRoute = ModuleName

	// DefaultParamspace default namestore
	DefaultParamspace = ModuleName
)
View Source
const (
	// TypeMsgPostPrice type of PostPrice msg
	TypeMsgPostPrice = "post_price"

	// MaxExpiry defines the max expiry time defined as UNIX time (9999-12-31 23:59:59 +0000 UTC)
	MaxExpiry = 253402300799
)
View Source
const (
	// QueryGetParams command for params query
	QueryGetParams = "parameters"
	// QueryMarkets command for assets query
	QueryMarkets = "markets"
	// QueryOracles command for oracles query
	QueryOracles = "oracles"
	// QueryRawPrices command for raw price queries
	QueryRawPrices = "rawprices"
	// QueryPrice command for price queries
	QueryPrice = "price"
)

Variables

View Source
var (
	// ErrEmptyInput error for empty input
	ErrEmptyInput = sdkerrors.Register(ModuleName, 2, "input must not be empty")
	// ErrExpired error for posted price messages with expired price
	ErrExpired = sdkerrors.Register(ModuleName, 3, "price is expired")
	// ErrNoValidPrice error for posted price messages with expired price
	ErrNoValidPrice = sdkerrors.Register(ModuleName, 4, "all input prices are expired")
	// ErrInvalidMarket error for posted price messages for invalid markets
	ErrInvalidMarket = sdkerrors.Register(ModuleName, 5, "market does not exist")
	// ErrInvalidOracle error for posted price messages for invalid oracles
	ErrInvalidOracle = sdkerrors.Register(ModuleName, 6, "oracle does not exist or not authorized")
	// ErrAssetNotFound error for not found asset
	ErrAssetNotFound = sdkerrors.Register(ModuleName, 7, "asset not found")
)
View Source
var (
	// CurrentPricePrefix prefix for the current price of an asset
	CurrentPricePrefix = []byte{0x00}

	// RawPriceFeedPrefix prefix for the raw pricefeed of an asset
	RawPriceFeedPrefix = []byte{0x01}
)
View Source
var (
	KeyMarkets     = []byte("Markets")
	DefaultMarkets = Markets{}
)

Parameter keys

View Source
var ModuleCdc = codec.New()

Functions

func CurrentPriceKey added in v0.8.0

func CurrentPriceKey(marketID string) []byte

CurrentPriceKey returns the prefix for the current price

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable Key declaration for parameters

func RawPriceKey added in v0.8.0

func RawPriceKey(marketID string) []byte

RawPriceKey returns the prefix for the raw price

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino code

Types

type CurrentPrice

type CurrentPrice struct {
	MarketID string  `json:"market_id" yaml:"market_id"`
	Price    sdk.Dec `json:"price" yaml:"price"`
}

CurrentPrice struct that contains the metadata of a current price for a particular market in the pricefeed module.

func NewCurrentPrice added in v0.8.0

func NewCurrentPrice(marketID string, price sdk.Dec) CurrentPrice

NewCurrentPrice returns an instance of CurrentPrice

func (CurrentPrice) String

func (cp CurrentPrice) String() string

implement fmt.Stringer

type CurrentPrices added in v0.8.0

type CurrentPrices []CurrentPrice

CurrentPrices type for an array of CurrentPrice

type GenesisState

type GenesisState struct {
	Params       Params       `json:"params" yaml:"params"`
	PostedPrices PostedPrices `json:"posted_prices" yaml:"posted_prices"`
}

GenesisState - pricefeed state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState defines default GenesisState for pricefeed

func NewGenesisState

func NewGenesisState(p Params, pp []PostedPrice) GenesisState

NewGenesisState creates a new genesis state for the pricefeed module

func (GenesisState) Equal

func (gs GenesisState) Equal(gs2 GenesisState) bool

Equal checks whether two gov GenesisState structs are equivalent

func (GenesisState) IsEmpty

func (gs GenesisState) IsEmpty() bool

IsEmpty returns true if a GenesisState is empty

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic validation of genesis data returning an error for any failed validation criteria.

type Market

type Market struct {
	// TODO: rename to ID
	MarketID   string           `json:"market_id" yaml:"market_id"`
	BaseAsset  string           `json:"base_asset" yaml:"base_asset"`
	QuoteAsset string           `json:"quote_asset" yaml:"quote_asset"`
	Oracles    []sdk.AccAddress `json:"oracles" yaml:"oracles"`
	Active     bool             `json:"active" yaml:"active"`
}

Market an asset in the pricefeed

func (Market) String

func (m Market) String() string

String implement fmt.Stringer

func (Market) Validate added in v0.8.0

func (m Market) Validate() error

Validate performs a basic validation of the market params

type Markets

type Markets []Market

Markets array type for oracle

func (Markets) String

func (ms Markets) String() string

String implements fmt.Stringer

func (Markets) Validate added in v0.8.0

func (ms Markets) Validate() error

Validate checks if all the markets are valid and there are no duplicated entries.

type MsgPostPrice

type MsgPostPrice struct {
	From     sdk.AccAddress `json:"from" yaml:"from"`           // client that sent in this address
	MarketID string         `json:"market_id" yaml:"market_id"` // asset code used by exchanges/api
	Price    sdk.Dec        `json:"price" yaml:"price"`         // price in decimal (max precision 18)
	Expiry   time.Time      `json:"expiry" yaml:"expiry"`       // expiry time
}

MsgPostPrice struct representing a posted price message. Used by oracles to input prices to the pricefeed

func NewMsgPostPrice

func NewMsgPostPrice(
	from sdk.AccAddress,
	assetCode string,
	price sdk.Dec,
	expiry time.Time) MsgPostPrice

NewMsgPostPrice creates a new post price msg

func (MsgPostPrice) GetSignBytes

func (msg MsgPostPrice) GetSignBytes() []byte

GetSignBytes Implements Msg.

func (MsgPostPrice) GetSigners

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

GetSigners Implements Msg.

func (MsgPostPrice) Route

func (msg MsgPostPrice) Route() string

Route Implements Msg.

func (MsgPostPrice) Type

func (msg MsgPostPrice) Type() string

Type Implements Msg

func (MsgPostPrice) ValidateBasic

func (msg MsgPostPrice) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type Params

type Params struct {
	Markets Markets `json:"markets" yaml:"markets"` //  Array containing the markets supported by the pricefeed
}

Params params for pricefeed. Can be altered via governance

func DefaultParams

func DefaultParams() Params

DefaultParams default params for pricefeed

func NewParams

func NewParams(markets Markets) Params

NewParams creates a new AssetParams object

func (*Params) ParamSetPairs

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

ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of pricefeed module's parameters.

func (Params) String

func (p Params) String() string

String implements fmt.stringer

func (Params) Validate

func (p Params) Validate() error

Validate ensure that params have valid values

type PostedPrice

type PostedPrice struct {
	MarketID      string         `json:"market_id" yaml:"market_id"`
	OracleAddress sdk.AccAddress `json:"oracle_address" yaml:"oracle_address"`
	Price         sdk.Dec        `json:"price" yaml:"price"`
	Expiry        time.Time      `json:"expiry" yaml:"expiry"`
}

PostedPrice price for market posted by a specific oracle

func NewPostedPrice added in v0.8.0

func NewPostedPrice(marketID string, oracle sdk.AccAddress, price sdk.Dec, expiry time.Time) PostedPrice

NewPostedPrice returns a new PostedPrice

func (PostedPrice) String

func (pp PostedPrice) String() string

implement fmt.Stringer

func (PostedPrice) Validate added in v0.8.0

func (pp PostedPrice) Validate() error

Validate performs a basic check of a PostedPrice params.

type PostedPrices added in v0.8.0

type PostedPrices []PostedPrice

PostedPrices type for an array of PostedPrice

func (PostedPrices) String added in v0.8.0

func (ps PostedPrices) String() string

String implements fmt.Stringer

func (PostedPrices) Validate added in v0.8.0

func (pps PostedPrices) Validate() error

Validate checks if all the posted prices are valid and there are no duplicated entries.

type QueryWithMarketIDParams

type QueryWithMarketIDParams struct {
	MarketID string
}

QueryWithMarketIDParams fields for querying information from a specific market

func NewQueryWithMarketIDParams

func NewQueryWithMarketIDParams(marketID string) QueryWithMarketIDParams

NewQueryWithMarketIDParams creates a new instance of QueryWithMarketIDParams

type SortDecs

type SortDecs []sdk.Dec

SortDecs provides the interface needed to sort sdk.Dec slices

func (SortDecs) Len

func (a SortDecs) Len() int

func (SortDecs) Less

func (a SortDecs) Less(i, j int) bool

func (SortDecs) Swap

func (a SortDecs) Swap(i, j int)

Jump to

Keyboard shortcuts

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