keeper

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2025 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CrossingPriceUpdateCutoffPpm = uint32(500_000) // 50%
)

Variables

This section is empty.

Functions

func GenerateMarketPriceUpdateIndexerEvents

func GenerateMarketPriceUpdateIndexerEvents(
	markets []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 {
	RevShareKeeper  types.RevShareKeeper
	MarketMapKeeper types.MarketMapKeeper
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey storetypes.StoreKey,
	indexPriceCache *pricefeedtypes.MarketToExchangePrices,
	timeProvider libtime.TimeProvider,
	indexerEventManager indexer_manager.IndexerEventManager,
	authorities []string,
	revShareKeeper types.RevShareKeeper,
	marketMapKeeper types.MarketMapKeeper,
	streamingManager streamingtypes.FullNodeStreamingManager,
) *Keeper

func (Keeper) AcquireNextMarketID

func (k Keeper) AcquireNextMarketID(ctx sdk.Context) uint32

AcquireNextMarketID returns the next market id to be used and increments the next market id

func (Keeper) AddCurrencyPairIDToStore

func (k Keeper) AddCurrencyPairIDToStore(ctx sdk.Context, marketId uint32, cp slinkytypes.CurrencyPair)

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) GetAllCurrencyPairs

func (k Keeper) GetAllCurrencyPairs(_ sdk.Context) []slinkytypes.CurrencyPair

GetAllCurrencyPairs is not used with the DefaultCurrencyPair strategy. See https://github.com/dydxprotocol/slinky/blob/main/abci/strategies/currencypair/default.go

func (Keeper) GetAllMarketParamPrices

func (k Keeper) GetAllMarketParamPrices(ctx sdk.Context) ([]types.MarketParamPrice, error)

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) GetCurrencyPairFromID

func (k Keeper) GetCurrencyPairFromID(ctx sdk.Context, id uint64) (cp slinkytypes.CurrencyPair, found bool)

func (Keeper) GetCurrencyPairIDFromStore

func (k Keeper) GetCurrencyPairIDFromStore(ctx sdk.Context, cp slinkytypes.CurrencyPair) (marketId uint64, found bool)

func (Keeper) GetExponent

func (k Keeper) GetExponent(ctx sdk.Context, ticker string) (int32, error)

Get the exponent for a market as the negation of the decimals value in the market map

func (Keeper) GetFullNodeStreamingManager

func (k Keeper) GetFullNodeStreamingManager() streamingtypes.FullNodeStreamingManager

func (Keeper) GetIDForCurrencyPair

func (k Keeper) GetIDForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (uint64, bool)

func (Keeper) GetIndexerEventManager

func (k Keeper) GetIndexerEventManager() indexer_manager.IndexerEventManager

func (Keeper) GetMarketIdToValidIndexPrice

func (k Keeper) GetMarketIdToValidIndexPrice(
	ctx sdk.Context,
) map[uint32]types.MarketPrice

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

func (k Keeper) GetMarketPrice(
	ctx sdk.Context,
	id uint32,
) (types.MarketPrice, error)

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) GetNextMarketID

func (k Keeper) GetNextMarketID(ctx sdk.Context) uint32

GetNextMarketID returns the next market id to be used from the module store

func (Keeper) GetNumCurrencyPairs

func (k Keeper) GetNumCurrencyPairs(ctx sdk.Context) (uint64, error)

func (Keeper) GetNumRemovedCurrencyPairs

func (k Keeper) GetNumRemovedCurrencyPairs(_ sdk.Context) (uint64, error)

GetNumRemovedCurrencyPairs is currently a no-op since we don't support removing Markets right now.

func (Keeper) GetPriceForCurrencyPair

func (k Keeper) GetPriceForCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) (oracletypes.QuotePrice, error)

func (Keeper) GetStreamPriceUpdate

func (k Keeper) GetStreamPriceUpdate(
	ctx sdk.Context,
	id uint32,
	snapshot bool,
) (
	val types.StreamPriceUpdate,
)

GetStreamPriceUpdate returns a stream price update from its id.

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

func (k Keeper) HasAuthority(authority string) bool

func (Keeper) InitializeForGenesis

func (k Keeper) InitializeForGenesis(ctx sdk.Context)

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) MarketParam

func (Keeper) MarketPrice

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) NextMarketId

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) RemoveCurrencyPairFromStore

func (k Keeper) RemoveCurrencyPairFromStore(ctx sdk.Context, cp slinkytypes.CurrencyPair)

func (Keeper) SetNextMarketID

func (k Keeper) SetNextMarketID(ctx sdk.Context, nextID uint32)

SetNextMarketID sets the next market id to be used

func (Keeper) UpdateMarketPrices

func (k Keeper) UpdateMarketPrices(
	ctx sdk.Context,
	updates []*types.MsgUpdateMarketPrices_MarketPrice,
) error

UpdateMarketPrices updates the prices for markets.

type PriceTuple

type PriceTuple struct {
	OldPrice   uint64
	IndexPrice uint64
	NewPrice   uint64
}

PriceTuple labels and encapsulates the set of prices used for various price computations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL