Documentation ¶
Index ¶
- Constants
- Variables
- func CurrentPriceKey(marketID string) []byte
- func ParamKeyTable() params.KeyTable
- func RawPriceKey(marketID string) []byte
- func RegisterCodec(cdc *codec.Codec)
- type CurrentPrice
- type CurrentPrices
- type GenesisState
- type Market
- type Markets
- type MsgPostPrice
- type Params
- type PostedPrice
- type PostedPrices
- type QueryWithMarketIDParams
- type SortDecs
Constants ¶
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
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 )
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 )
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" // QueryPrices command for quering all prices QueryPrices = "prices" )
Variables ¶
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") )
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} )
var ( KeyMarkets = []byte("Markets") DefaultMarkets = Markets{} )
Parameter keys
var ModuleCdc = codec.New()
Functions ¶
func CurrentPriceKey ¶ added in v0.8.0
CurrentPriceKey returns the prefix for the current price
func ParamKeyTable ¶
ParamKeyTable Key declaration for parameters
func RawPriceKey ¶ added in v0.8.0
RawPriceKey returns the prefix for the raw price
func RegisterCodec ¶
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
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 { 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
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) 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 (*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.
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) 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