Documentation
¶
Index ¶
- Constants
- Variables
- func ErrEmptyInput(codespace sdk.CodespaceType) sdk.Error
- func ErrExistingAsset(codespace sdk.CodespaceType) sdk.Error
- func ErrExpired(codespace sdk.CodespaceType) sdk.Error
- func ErrInvalidAsset(codespace sdk.CodespaceType) sdk.Error
- func ErrInvalidOracle(codespace sdk.CodespaceType) sdk.Error
- func ErrInvalidReceivedAt(codespace sdk.CodespaceType, comment string) sdk.Error
- func ErrNoValidPrice(codespace sdk.CodespaceType) sdk.Error
- func GetRawPricesKey(assetCode string, blockHeight int64) []byte
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateAddress(address string) (sdk.AccAddress, error)
- func ValidateGenesis(data GenesisState) error
- type Asset
- type Assets
- type CurrentPrice
- type GenesisState
- type MsgAddAsset
- type MsgAddOracle
- type MsgPostPrice
- type MsgSetAsset
- type MsgSetOracles
- type Oracle
- type Oracles
- type ParamSubspace
- type Params
- type PendingPriceAsset
- type PostPriceParams
- type PostedPrice
- type QueryAssetsResp
- type QueryRawPricesResp
- type SortDecs
Constants ¶
const ( DefaultCodespace sdk.CodespaceType = ModuleName CodeEmptyInput sdk.CodeType = 1 CodeExpired sdk.CodeType = 2 CodeInvalidPrice sdk.CodeType = 3 CodeInvalidAsset sdk.CodeType = 4 CodeInvalidOracle sdk.CodeType = 5 CodeInvalidReceivedAt sdk.CodeType = 6 )
const ( // ModuleKey is the name of the module ModuleName = "oracle" // StoreKey is the store key string for gov StoreKey = ModuleName // RouterKey is the message route for gov RouterKey = ModuleName // QuerierRoute is the querier route for gov QuerierRoute = ModuleName // Parameter store default namestore DefaultParamspace = ModuleName // Store prefix for the raw oracle of an asset RawPriceFeedPrefix = StoreKey + ":raw:" // Store prefix for the current price of an asset CurrentPricePrefix = StoreKey + ":currentprice:" // Store Prefix for the assets in the oracle system AssetPrefix = StoreKey + ":assets" // OraclePrefix store prefix for the oracle accounts OraclePrefix = StoreKey + ":oracles" )
const ( // QueryCurrentPrice command for current price queries QueryCurrentPrice = "price" // QueryRawPrices command for raw price queries QueryRawPrices = "rawprices" // QueryAssets command for assets query QueryAssets = "assets" )
const (
PriceBytesLimit = 8
)
const (
// TypeMsgPostPrice type of PostPrice msg
TypeMsgPostPrice = "post_price"
)
Variables ¶
var ( // KeyAssets store key for assets KeyAssets = []byte("oracleassets") KeyNominees = []byte("oraclenominees") KeyPostPrice = []byte("oraclepostprice") )
var ModuleCdc *codec.Codec
generic sealed codec to be used throughout module
Functions ¶
func ErrExistingAsset ¶
func ErrExistingAsset(codespace sdk.CodespaceType) sdk.Error
Asset already exists
func ErrInvalidOracle ¶
func ErrInvalidOracle(codespace sdk.CodespaceType) sdk.Error
Oracle not found
func ErrInvalidReceivedAt ¶
func ErrInvalidReceivedAt(codespace sdk.CodespaceType, comment string) sdk.Error
New PostPrice ReceivedAt field is invalid
func GetRawPricesKey ¶
Get a key to store PostedPrices for specific assetCode and blockHeight
func ParamKeyTable ¶
ParamKeyTable Key declaration for parameters
func RegisterCodec ¶
RegisterCodec registers concrete types on the Amino codec
func ValidateAddress ¶
func ValidateAddress(address string) (sdk.AccAddress, error)
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis performs basic validation of genesis data returning an error for any failed validation criteria.
Types ¶
type Asset ¶
type Asset struct {
AssetCode string `json:"asset_code" yaml:"asset_code" example:"dfi"`
Oracles Oracles `json:"oracles" yaml:"oracles"` // List of registered RawPrice sources
Active bool `json:"active" yaml:"active"` // Not used ATM
}
Asset struct that represents an asset in the oracle
func (Asset) ValidateBasic ¶
ValidateBasic does a simple validation check that doesn't require access to any other information.
type CurrentPrice ¶
type CurrentPrice struct {
AssetCode string `json:"asset_code" yaml:"asset_code" example:"dfi"` // Denom
Price sdk.Int `json:"price" yaml:"price" swaggertype:"string" example:"1000"`
ReceivedAt time.Time `json:"received_at" yaml:"received_at" format:"RFC 3339" example:"2020-03-27T13:45:15.293426Z"` // Timestamp Price createdAt
}
CurrentPrice struct that contains the metadata of a current price for a particular asset in the oracle module.
type GenesisState ¶
type GenesisState struct {
Params Params `json:"asset_params" yaml:"asset_params"`
}
GenesisState - oracle state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState defines default GenesisState for oracle
func NewGenesisState ¶
func NewGenesisState(p Params) GenesisState
NewGenesisState creates a new genesis state for the oracle module
func (GenesisState) Equal ¶
func (data GenesisState) Equal(data2 GenesisState) bool
Equal checks whether two gov GenesisState structs are equivalent
func (GenesisState) IsEmpty ¶
func (data GenesisState) IsEmpty() bool
IsEmpty returns true if a GenesisState is empty
type MsgAddAsset ¶
type MsgAddAsset struct {
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
Asset Asset `json:"asset" yaml:"asset"`
}
func NewMsgAddAsset ¶
func NewMsgAddAsset( nominee sdk.AccAddress, denom string, asset Asset, ) MsgAddAsset
func (MsgAddAsset) GetSignBytes ¶
func (msg MsgAddAsset) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgAddAsset) GetSigners ¶
func (msg MsgAddAsset) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgAddAsset) ValidateBasic ¶
func (msg MsgAddAsset) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgAddOracle ¶
type MsgAddOracle struct {
Oracle sdk.AccAddress `json:"oracle" yaml:"oracle"`
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
}
MsgAddOracle struct representing a new nominee based oracle
func NewMsgAddOracle ¶
func NewMsgAddOracle( nominee sdk.AccAddress, denom string, oracle sdk.AccAddress, ) MsgAddOracle
MsgAddOracle creates a new add oracle message
func (MsgAddOracle) GetSignBytes ¶
func (msg MsgAddOracle) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgAddOracle) GetSigners ¶
func (msg MsgAddOracle) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgAddOracle) ValidateBasic ¶
func (msg MsgAddOracle) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgPostPrice ¶
type MsgPostPrice struct {
From sdk.AccAddress `json:"from" yaml:"from"`
AssetCode string `json:"asset_code" yaml:"asset_code"`
Price sdk.Int `json:"price" yaml:"price"`
ReceivedAt time.Time `json:"received_at" yaml:"received_at"`
}
MsgPostPrice struct representing a posted price message. Used by oracles to input prices to the oracle
func NewMsgPostPrice ¶
func NewMsgPostPrice( from sdk.AccAddress, assetCode string, price sdk.Int, receivedAt 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 MsgSetAsset ¶
type MsgSetAsset struct {
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
Asset Asset `json:"asset" yaml:"asset"`
}
MsgSetAsset struct representing a new nominee based oracle
func NewMsgSetAsset ¶
func NewMsgSetAsset( nominee sdk.AccAddress, denom string, asset Asset, ) MsgSetAsset
NewMsgSetAsset creates a new add oracle message
func (MsgSetAsset) GetSignBytes ¶
func (msg MsgSetAsset) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgSetAsset) GetSigners ¶
func (msg MsgSetAsset) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgSetAsset) ValidateBasic ¶
func (msg MsgSetAsset) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgSetOracles ¶
type MsgSetOracles struct {
Oracles Oracles `json:"oracles" yaml:"oracles"`
Nominee sdk.AccAddress `json:"nominee" yaml:"nominee"`
Denom string `json:"denom" yaml:"denom"`
}
MsgSetOracle struct representing a new nominee based oracle
func NewMsgSetOracles ¶
func NewMsgSetOracles( nominee sdk.AccAddress, denom string, oracles Oracles, ) MsgSetOracles
MsgAddOracle creates a new add oracle message
func (MsgSetOracles) GetSignBytes ¶
func (msg MsgSetOracles) GetSignBytes() []byte
GetSignBytes Implements Msg.
func (MsgSetOracles) GetSigners ¶
func (msg MsgSetOracles) GetSigners() []sdk.AccAddress
GetSigners Implements Msg.
func (MsgSetOracles) ValidateBasic ¶
func (msg MsgSetOracles) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type Oracle ¶
type Oracle struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
}
Oracle struct that documents which address an oracle is using
func NewOracle ¶
func NewOracle(address sdk.AccAddress) Oracle
type ParamSubspace ¶
type ParamSubspace interface {
Get(ctx sdk.Context, key []byte, ptr interface{})
Set(ctx sdk.Context, key []byte, param interface{})
}
ParamSubspace defines the expected Subspace interface for parameters
type Params ¶
type Params struct {
Assets Assets `json:"assets" yaml:"assets"` // Array containing the assets supported by the oracle
Nominees []string `json:"nominees" yaml:"nominees"`
PostPrice PostPriceParams `json:"post_price" yaml:"post_price"`
}
Params params for oracle. Can be altered via governance
func NewParams ¶
func NewParams(assets []Asset, nominees []string, postPrice PostPriceParams) 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 oracle module's parameters.
type PendingPriceAsset ¶
type PendingPriceAsset struct {
AssetCode string `json:"asset_code"`
}
PendingPriceAsset struct that contains the info about the asset which price is still to be determined
type PostPriceParams ¶
type PostPriceParams struct {
// allowed timestamp difference between current block time and oracle's receivedAt (0 - disabled) [sec]
ReceivedAtDiffInS uint32 `json:"received_at_diff_in_s" yaml:"received_at_diff_in_s"`
}
Posting rawPrices from oracles configuration params
func (PostPriceParams) String ¶
func (p PostPriceParams) String() string
type PostedPrice ¶
type PostedPrice struct {
AssetCode string `json:"asset_code" yaml:"asset_code" example:"dfi"` // Denom
OracleAddress sdk.AccAddress `json:"oracle_address" yaml:"oracle_address" swaggertype:"string" example:"wallet13jyjuz3kkdvqw8u4qfkwd94emdl3vx394kn07h"` // Price source
Price sdk.Int `json:"price" yaml:"price" swaggertype:"string" example:"1000"`
ReceivedAt time.Time `json:"received_at" yaml:"received_at" format:"RFC 3339" example:"2020-03-27T13:45:15.293426Z"` // Timestamp Price createdAt
}
PostedPrice struct represented a price for an asset posted by a specific oracle
type QueryRawPricesResp ¶
type QueryRawPricesResp []PostedPrice
QueryRawPricesResp response to a rawprice query
func (QueryRawPricesResp) String ¶
func (n QueryRawPricesResp) String() string
implement fmt.Stringer