Documentation ¶
Index ¶
- Constants
- func GenerateMarketPriceUpdateIndexerEvent(market 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.MarketSpotPrice
- 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) GetSmoothedSpotPrice(markedId uint32) (uint64, bool)
- func (k Keeper) GetValidMarketSpotPriceUpdates(ctx sdk.Context) []*types.MarketSpotPriceUpdate
- func (k Keeper) HasAuthority(authority string) bool
- func (k Keeper) InitializeForGenesis(ctx sdk.Context)
- func (k Keeper) IsRecentlyAvailable(ctx sdk.Context, 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, updatedMarketParam types.MarketParam) (types.MarketParam, error)
- func (k Keeper) PerformStatefulPriceUpdateValidation(ctx sdk.Context, marketPriceUpdate *types.MarketPriceUpdate) (isSpotValid bool, isPnlValid bool)
- func (k Keeper) UpdatePnlPrice(ctx sdk.Context, update *types.MarketPnlPriceUpdate) error
- func (k Keeper) UpdateSmoothedSpotPrices(ctx sdk.Context, ...) error
- func (k Keeper) UpdateSpotAndPnlMarketPrices(ctx sdk.Context, update *types.MarketPriceUpdate) error
- func (k Keeper) UpdateSpotPrice(ctx sdk.Context, update *types.MarketSpotPriceUpdate) error
- type PriceTuple
Constants ¶
const (
CrossingPriceUpdateCutoffPpm = uint32(500_000) // 50%
)
Variables ¶
This section is empty.
Functions ¶
func GenerateMarketPriceUpdateIndexerEvent ¶
func GenerateMarketPriceUpdateIndexerEvent( market types.MarketPrice, ) *indexerevents.MarketEventV1
GenerateMarketPriceUpdateIndexerEvents 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 ¶
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) GetSmoothedSpotPrice ¶
func (Keeper) GetValidMarketSpotPriceUpdates ¶
func (k Keeper) GetValidMarketSpotPriceUpdates( ctx sdk.Context, ) []*types.MarketSpotPriceUpdate
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 ¶
func (Keeper) InitializeForGenesis ¶
func (Keeper) IsRecentlyAvailable ¶
IsRecentlyAvailable returns true if the market was recently made available to the pricefeed daemon. A market is considered recently available either if it was recently created, or if the pricefeed daemon was recently started. If an index price does not exist for a recently available market, the protocol does not consider this an error condition, as it is expected that the pricefeed daemon will eventually provide a price for the market within a few seconds.
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, updatedMarketParam types.MarketParam, ) (types.MarketParam, error)
ModifyMarketParam modifies an existing market param in the store.
func (Keeper) PerformStatefulPriceUpdateValidation ¶
func (k Keeper) PerformStatefulPriceUpdateValidation( ctx sdk.Context, marketPriceUpdate *types.MarketPriceUpdate, ) (isSpotValid bool, isPnlValid bool)
PerformStatefulPriceUpdateValidation performs stateful validations on `UpdateMarketPrices`. Depending on the input, this func performs non-deterministic stateful validation.
func (Keeper) UpdatePnlPrice ¶
func (Keeper) UpdateSmoothedSpotPrices ¶
func (k Keeper) UpdateSmoothedSpotPrices( ctx sdk.Context, linearInterpolateFunc func(v0 uint64, v1 uint64, ppm uint32) (uint64, error), ) error
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.
func (Keeper) UpdateSpotAndPnlMarketPrices ¶
func (k Keeper) UpdateSpotAndPnlMarketPrices( ctx sdk.Context, update *types.MarketPriceUpdate, ) error
UpdateMarketPrices updates the prices for markets.
func (Keeper) UpdateSpotPrice ¶
type PriceTuple ¶
PriceTuple labels and encapsulates the set of prices used for various price computations.