Documentation ¶
Index ¶
- Constants
- Variables
- func ErrEmptyInput(codespace sdk.CodespaceType) sdk.Error
- func ErrExpired(codespace sdk.CodespaceType) sdk.Error
- func ErrInvalidMarket(codespace sdk.CodespaceType, marketId string) sdk.Error
- func ErrInvalidOracle(codespace sdk.CodespaceType, addr sdk.AccAddress) sdk.Error
- func ErrNoValidPrice(codespace sdk.CodespaceType) sdk.Error
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- type CurrentPrice
- type GenesisState
- type Market
- type Markets
- type MsgPostPrice
- type Params
- type PostedPrice
- type QueryWithMarketIDParams
- type SortDecs
Constants ¶
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 )
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
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" )
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" )
const (
// TypeMsgPostPrice type of PostPrice msg
TypeMsgPostPrice = "post_price"
)
Variables ¶
var ( KeyMarkets = []byte("Markets") DefaultMarkets = Markets{} )
Parameter keys
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 ¶
ParamKeyTable Key declaration for parameters
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.
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
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() 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 (*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
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