types

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 7 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// DefaultCodespace codespace for the module
	DefaultCodespace sdk.CodespaceType = ModuleName

	// CodeEmptyInput error code for empty input errors
	CodeEmptyInput sdk.CodeType = 1
	// CodeExpired error code for expired prices
	CodeExpired sdk.CodeType = 2
	// CodeInvalidPrice error code for all input prices expired
	CodeInvalidPrice sdk.CodeType = 3
	// CodeInvalidAsset error code for invalid asset
	CodeInvalidAsset sdk.CodeType = 4
	// CodeInvalidOracle error code for invalid oracle
	CodeInvalidOracle sdk.CodeType = 5
)
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"
	AttributeKeyPriceUpdateFailed = "price_update_failed"
)

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

	// RawPriceFeedPrefix prefix for the raw pricefeed of an asset
	RawPriceFeedPrefix = StoreKey + ":raw:"

	// CurrentPricePrefix prefix for the current price of an asset
	CurrentPricePrefix = StoreKey + ":currentprice:"

	// MarketPrefix Prefix for the assets in the pricefeed system
	MarketPrefix = StoreKey + ":markets"

	// OraclePrefix store prefix for the oracle accounts
	OraclePrefix = StoreKey + ":oracles"
)
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"
)
View Source
const (
	// TypeMsgPostPrice type of PostPrice msg
	TypeMsgPostPrice = "post_price"
)

Variables

View Source
var (
	KeyMarkets     = []byte("Markets")
	DefaultMarkets = Markets{}
)

Parameter keys

View Source
var ModuleCdc = codec.New()

Functions

func ErrEmptyInput

func ErrEmptyInput(codespace sdk.CodespaceType) sdk.Error

ErrEmptyInput Error constructor

func ErrExpired

func ErrExpired(codespace sdk.CodespaceType) sdk.Error

ErrExpired Error constructor for posted price messages with expired price

func ErrInvalidMarket

func ErrInvalidMarket(codespace sdk.CodespaceType, marketId string) sdk.Error

ErrInvalidMarket Error constructor for posted price messages for invalid markets

func ErrInvalidOracle

func ErrInvalidOracle(codespace sdk.CodespaceType, addr sdk.AccAddress) sdk.Error

ErrInvalidOracle Error constructor for posted price messages for invalid oracles

func ErrNoValidPrice

func ErrNoValidPrice(codespace sdk.CodespaceType) sdk.Error

ErrNoValidPrice Error constructor for posted price messages with expired price

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable Key declaration for parameters

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 (CurrentPrice) String

func (cp CurrentPrice) String() string

implement fmt.Stringer

type GenesisState

type GenesisState struct {
	Params       Params        `json:"params" yaml:"params"`
	PostedPrices []PostedPrice `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

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

type Market

type Market struct {
	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 (a Market) String() string

String implement fmt.Stringer

type Markets

type Markets []Market

Markets array type for oracle

func (Markets) String

func (ms Markets) String() string

String implements fmt.Stringer

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() sdk.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 (PostedPrice) String

func (pp PostedPrice) String() string

implement fmt.Stringer

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