Documentation ¶
Index ¶
- Constants
- func GenerateMarketPriceUpdateEvents(markets []types.MarketPrice) []*indexerevents.MarketEventV1
- func NewMsgServerImpl(keeper types.PricesKeeper) types.MsgServer
- type Keeper
- func (k Keeper) AllMarketParams(c context.Context, req *types.QueryAllMarketParamsRequest) (*types.QueryAllMarketParamsResponse, error)
- func (k Keeper) AllMarketPrices(c context.Context, req *types.QueryAllMarketPricesRequest) (*types.QueryAllMarketPricesResponse, error)
- func (k Keeper) CreateMarket(ctx sdk.Context, marketParam types.MarketParam, marketPrice types.MarketPrice) (types.MarketParam, error)
- func (k Keeper) GetAllMarketParamPrices(ctx sdk.Context) ([]types.MarketParamPrice, error)
- func (k Keeper) GetAllMarketParams(ctx sdk.Context) []types.MarketParam
- func (k Keeper) GetAllMarketPrices(ctx sdk.Context) []types.MarketPrice
- func (k Keeper) GetIndexerEventManager() indexer_manager.IndexerEventManager
- func (k Keeper) GetMarketIdToValidIndexPrice(ctx sdk.Context) map[uint32]types.MarketPrice
- func (k Keeper) GetMarketParam(ctx sdk.Context, id uint32) (market types.MarketParam, exists bool)
- func (k Keeper) GetMarketPrice(ctx sdk.Context, id uint32) (types.MarketPrice, error)
- func (k Keeper) GetMarketsMissingFromPriceUpdates(ctx sdk.Context, marketPriceUpdates []*types.MsgUpdateMarketPrices_MarketPrice) []uint32
- func (k Keeper) GetValidMarketPriceUpdates(ctx sdk.Context) *types.MsgUpdateMarketPrices
- func (k Keeper) HasAuthority(authority string) bool
- func (k Keeper) InitializeForGenesis(ctx sdk.Context)
- func (k Keeper) IsRecentlyAdded(marketId uint32) bool
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MarketParam(c context.Context, req *types.QueryMarketParamRequest) (*types.QueryMarketParamResponse, error)
- func (k Keeper) MarketPrice(c context.Context, req *types.QueryMarketPriceRequest) (*types.QueryMarketPriceResponse, error)
- func (k Keeper) ModifyMarketParam(ctx sdk.Context, marketParam types.MarketParam) (types.MarketParam, error)
- func (k Keeper) PerformStatefulPriceUpdateValidation(ctx sdk.Context, marketPriceUpdates *types.MsgUpdateMarketPrices, ...) error
- func (k Keeper) UnsafeModifyMarketParam(ctx sdk.Context, marketParam types.MarketParam) error
- func (k Keeper) UnsafeSetMarketPrice(ctx sdk.Context, price types.MarketPrice)
- func (k Keeper) UpdateMarketPrices(ctx sdk.Context, updates []*types.MsgUpdateMarketPrices_MarketPrice) error
- func (k Keeper) UpdateSmoothedPrices(ctx sdk.Context) error
- type PriceTuple
Constants ¶
const (
CrossingPriceUpdateCutoffPpm = uint32(500_000) // 50%
)
Variables ¶
This section is empty.
Functions ¶
func GenerateMarketPriceUpdateEvents ¶
func GenerateMarketPriceUpdateEvents(markets []types.MarketPrice) []*indexerevents.MarketEventV1
GenerateMarketPriceUpdateEvents takes in a slice of market prices and returns a slice of price updates.
func NewMsgServerImpl ¶
func NewMsgServerImpl(keeper types.PricesKeeper) types.MsgServer
NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, indexPriceCache *pricefeedtypes.MarketToExchangePrices, marketToSmoothedPrices types.MarketToSmoothedPrices, timeProvider libtime.TimeProvider, indexerEventManager indexer_manager.IndexerEventManager, authorities []string, ) *Keeper
func (Keeper) AllMarketParams ¶
func (k Keeper) AllMarketParams( c context.Context, req *types.QueryAllMarketParamsRequest, ) (*types.QueryAllMarketParamsResponse, error)
func (Keeper) AllMarketPrices ¶
func (k Keeper) AllMarketPrices( c context.Context, req *types.QueryAllMarketPricesRequest, ) (*types.QueryAllMarketPricesResponse, error)
func (Keeper) CreateMarket ¶
func (k Keeper) CreateMarket( ctx sdk.Context, marketParam types.MarketParam, marketPrice types.MarketPrice, ) (types.MarketParam, error)
CreateMarket creates a new market param in the store along with a new market price for that market param. This is the only path to creating new MarketPrices, so if we have a param defined for a market, we should expect to see a price defined, and vice versa.
func (Keeper) GetAllMarketParamPrices ¶
GetAllMarketParamPrices returns a slice of MarketParam, MarketPrice tuples for all markets.
func (Keeper) GetAllMarketParams ¶
func (k Keeper) GetAllMarketParams(ctx sdk.Context) []types.MarketParam
GetAllMarketParams returns all market params.
func (Keeper) GetAllMarketPrices ¶
func (k Keeper) GetAllMarketPrices(ctx sdk.Context) []types.MarketPrice
GetAllMarketPrices returns all market prices.
func (Keeper) GetIndexerEventManager ¶
func (k Keeper) GetIndexerEventManager() indexer_manager.IndexerEventManager
func (Keeper) GetMarketIdToValidIndexPrice ¶ added in v0.3.0
GetMarketIdToValidIndexPrice returns a map of market id to valid index price. An index price is valid iff: 1) the last update time is within a predefined threshold away from the given read time. 2) the number of prices that meet 1) are greater than the minimum number of exchanges specified in the given input. If a market does not have a valid index price, its `marketId` is not included in returned map.
func (Keeper) GetMarketParam ¶
func (k Keeper) GetMarketParam( ctx sdk.Context, id uint32, ) ( market types.MarketParam, exists bool, )
GetMarketParam returns a market param from its id.
func (Keeper) GetMarketPrice ¶
GetMarketPrice returns a market price from its id.
func (Keeper) GetMarketsMissingFromPriceUpdates ¶
func (k Keeper) GetMarketsMissingFromPriceUpdates( ctx sdk.Context, marketPriceUpdates []*types.MsgUpdateMarketPrices_MarketPrice, ) []uint32
GetMarketsMissingFromPriceUpdates returns a list of market ids that should have been included but not present in the `MsgUpdateMarketPrices`.
Note: this is NOT determistic, because it relies on "index price" that is subject to each validator.
func (Keeper) GetValidMarketPriceUpdates ¶
func (k Keeper) GetValidMarketPriceUpdates( ctx sdk.Context, ) *types.MsgUpdateMarketPrices
GetValidMarketPriceUpdates returns a msg containing a list of "valid" price updates that should be included in a block. A "valid" price update means: 1) All values used to compute the valid price must exist and be valid: - the index price exists and is nonzero. - the smoothed price exists and is nonzero. 2) The smoothed price and the index price must be on the same side compared to the oracle price. 3) The proposed price is either the index price or the smoothed price, depending on which is closer to the oracle price. 4) The proposed price meets the minimum price change ppm requirement. Note: the list of market price updates can be empty if there are no "valid" index prices, smoothed prices, and/or proposed prices for any market.
func (Keeper) HasAuthority ¶ added in v0.3.0
func (Keeper) InitializeForGenesis ¶
func (Keeper) IsRecentlyAdded ¶ added in v0.3.0
IsRecentlyAdded returns true if the market was added recently. Since it takes a few seconds for index prices to populate, we would not consider missing index prices for a recently added market to be an error.
func (Keeper) MarketParam ¶
func (k Keeper) MarketParam( c context.Context, req *types.QueryMarketParamRequest, ) ( *types.QueryMarketParamResponse, error, )
func (Keeper) MarketPrice ¶
func (k Keeper) MarketPrice( c context.Context, req *types.QueryMarketPriceRequest, ) ( *types.QueryMarketPriceResponse, error, )
func (Keeper) ModifyMarketParam ¶
func (k Keeper) ModifyMarketParam( ctx sdk.Context, marketParam types.MarketParam, ) (types.MarketParam, error)
ModifyMarketParam modifies an existing market param in the store.
func (Keeper) PerformStatefulPriceUpdateValidation ¶
func (k Keeper) PerformStatefulPriceUpdateValidation( ctx sdk.Context, marketPriceUpdates *types.MsgUpdateMarketPrices, performNonDeterministicValidation bool, ) error
PerformStatefulPriceUpdateValidation performs stateful validations on `MsgUpdateMarketPrices`. Depending on the input, this func performs non-deterministic stateful validation.
func (Keeper) UnsafeModifyMarketParam ¶ added in v0.3.0
UnsafeModifyMarketParam modifies an existing market param in the store.
func (Keeper) UnsafeSetMarketPrice ¶ added in v0.3.0
func (k Keeper) UnsafeSetMarketPrice( ctx sdk.Context, price types.MarketPrice, )
UnsafeSetMarketPrice sets market price without validation.
func (Keeper) UpdateMarketPrices ¶
func (k Keeper) UpdateMarketPrices( ctx sdk.Context, updates []*types.MsgUpdateMarketPrices_MarketPrice, ) error
UpdateMarketPrices updates the prices for markets.
func (Keeper) UpdateSmoothedPrices ¶
UpdateSmoothedPrices updates the internal map of smoothed prices for all markets. The smoothing is calculated with Basic Exponential Smoothing, see https://en.wikipedia.org/wiki/Exponential_smoothing If there is no valid index price for a market at this time, the smoothed price does not change.
type PriceTuple ¶
PriceTuple labels and encapsulates the set of prices used for various price computations.