Documentation
¶
Index ¶
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- type ActivePairsState
- func (state ActivePairsState) AddActivePairs(ctx sdk.Context, pairs []common.AssetPair)
- func (state ActivePairsState) Get(ctx sdk.Context, pair common.AssetPair) (active bool)
- func (state ActivePairsState) Iterate(ctx sdk.Context, do func(*types.ActivePairMarshaler) (stop bool))
- func (state ActivePairsState) Set(ctx sdk.Context, pair common.AssetPair, active bool)
- func (state ActivePairsState) SetMany(ctx sdk.Context, pairs common.AssetPairs, active bool)
- type Keeper
- func (k Keeper) ActivePairsStore() ActivePairsState
- func (k Keeper) CalculateMedianPrice(prices []types.CurrentPrice) sdk.Dec
- func (k Keeper) GatherRawPrices(ctx sdk.Context, token0 string, token1 string) error
- func (k Keeper) GetCurrentPrice(ctx sdk.Context, token0 string, token1 string) (currPrice types.CurrentPrice, err error)
- func (k Keeper) GetCurrentPrices(ctx sdk.Context) types.CurrentPrices
- func (k Keeper) GetCurrentTWAP(ctx sdk.Context, token0 string, token1 string) (twap sdk.Dec, err error)
- func (k Keeper) GetOraclesForPair(ctx sdk.Context, pairID string) (oracles []sdk.AccAddress)
- func (k Keeper) GetOraclesForPairs(ctx sdk.Context, pairs common.AssetPairs) map[common.AssetPair][]sdk.AccAddress
- func (k Keeper) GetPairs(ctx sdk.Context) common.AssetPairs
- func (k Keeper) GetParams(ctx sdk.Context) types.Params
- func (k Keeper) GetRawPrices(ctx sdk.Context, pairStr string) types.PostedPrices
- func (k Keeper) GetTwapLookbackWindow(ctx sdk.Context) time.Duration
- func (k Keeper) IsActivePair(ctx sdk.Context, pairID string) bool
- func (k Keeper) IsWhitelistedOracle(ctx sdk.Context, pairID string, address sdk.AccAddress) bool
- func (k Keeper) IterateCurrentPrices(ctx sdk.Context, cb func(cp types.CurrentPrice) (stop bool))
- func (k Keeper) IteratePriceSnapshotsFrom(ctx sdk.Context, start, end []byte, reverse bool, ...)
- func (k Keeper) IterateRawPricesByPair(ctx sdk.Context, marketId string, ...)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) OraclesStore() OraclesState
- func (k Keeper) PostRawPrice(ctx sdk.Context, oracle sdk.AccAddress, pairStr string, price sdk.Dec, ...) (postedPrice types.PostedPrice, err error)
- func (k Keeper) QueryMarkets(goCtx context.Context, req *types.QueryMarketsRequest) (*types.QueryMarketsResponse, error)
- func (k Keeper) QueryOracles(goCtx context.Context, req *types.QueryOraclesRequest) (*types.QueryOraclesResponse, error)
- func (k Keeper) QueryParams(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) QueryPrice(goCtx context.Context, req *types.QueryPriceRequest) (*types.QueryPriceResponse, error)
- func (k Keeper) QueryPrices(goCtx context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error)
- func (k Keeper) QueryRawPrices(goCtx context.Context, req *types.QueryRawPricesRequest) (*types.QueryRawPricesResponse, error)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) WhitelistOracles(ctx sdk.Context, oracles []sdk.AccAddress)
- func (k Keeper) WhitelistOraclesForPairs(ctx sdk.Context, oracles []sdk.AccAddress, proposedPairs []common.AssetPair)
- type OraclesState
- func (state OraclesState) AddOracles(ctx sdk.Context, pair common.AssetPair, oracles []sdk.AccAddress)
- func (state OraclesState) Get(ctx sdk.Context, pair common.AssetPair) (oracles []sdk.AccAddress)
- func (state OraclesState) Iterate(ctx sdk.Context, do func(*types.OraclesMarshaler) (stop bool))
- func (state OraclesState) Set(ctx sdk.Context, pair common.AssetPair, oracles []sdk.AccAddress)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.
Types ¶
type ActivePairsState ¶ added in v0.5.2
type ActivePairsState Keeper
----------------------------------------------------------------------------- ActivePairsState implements methods for updating the "active pairs" sdk.KVStore
func (ActivePairsState) AddActivePairs ¶ added in v0.5.2
func (state ActivePairsState) AddActivePairs( ctx sdk.Context, pairs []common.AssetPair, )
func (ActivePairsState) Iterate ¶ added in v0.5.2
func (state ActivePairsState) Iterate( ctx sdk.Context, do func(*types.ActivePairMarshaler) (stop bool), )
func (ActivePairsState) Set ¶ added in v0.5.2
ActivePairsState.Set either sets a pair to active or deletes it from the
key-value store (i.e., pairs default to inactive if they don't exist).
func (ActivePairsState) SetMany ¶ added in v0.5.2
func (state ActivePairsState) SetMany( ctx sdk.Context, pairs common.AssetPairs, active bool, )
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, ps paramtypes.Subspace, ) Keeper
func (Keeper) ActivePairsStore ¶ added in v0.5.2
func (k Keeper) ActivePairsStore() ActivePairsState
ActivePairsStore maintains the "active pairs" KVStore: maps pair name → isActive. If a pair doesn't have a key in the store, the pair is inactive.
func (Keeper) CalculateMedianPrice ¶
func (k Keeper) CalculateMedianPrice(prices []types.CurrentPrice) sdk.Dec
CalculateMedianPrice calculates the median prices for the input prices.
func (Keeper) GatherRawPrices ¶ added in v0.9.2
GatherRawPrices updates the current price of an asset to the median of all valid posted oracle prices.
args:
- ctx: cosmos-sdk context
- token0: the base asset
- token1: the quote asset
ret:
- err: error if any
func (Keeper) GetCurrentPrice ¶
func (k Keeper) GetCurrentPrice(ctx sdk.Context, token0 string, token1 string, ) (currPrice types.CurrentPrice, err error)
GetCurrentPrice fetches the current median price of all oracles for a specific market.
args:
- ctx: cosmos-sdk context
- token0: the base asset
- token1: the quote asset
ret:
- currPrice: the current price
- err: error if any
func (Keeper) GetCurrentPrices ¶
func (k Keeper) GetCurrentPrices(ctx sdk.Context) types.CurrentPrices
GetCurrentPrices returns all current price objects from the store
func (Keeper) GetCurrentTWAP ¶ added in v0.9.2
func (k Keeper) GetCurrentTWAP(ctx sdk.Context, token0 string, token1 string, ) (twap sdk.Dec, err error)
Gets the time-weighted average price from [ ctx.BlockTime() - interval, ctx.BlockTime() ) Note the open-ended right bracket.
Args: - ctx: cosmos-sdk context - pair: the token pair
Returns: - twap: TWAP as sdk.Dec - err: error
func (Keeper) GetOraclesForPair ¶ added in v0.5.2
GetOraclesForPair returns the oracles for a valid asset pair
func (Keeper) GetOraclesForPairs ¶ added in v0.5.2
func (k Keeper) GetOraclesForPairs(ctx sdk.Context, pairs common.AssetPairs, ) map[common.AssetPair][]sdk.AccAddress
GetOraclesForPairs returns the 'oraclesMatrix' corresponding to 'pairs'. 'oraclesMap' is a map from pair → list of oracles. This function effectively gives a subset of the OraclesState KVStore.
func (Keeper) GetPairs ¶
func (k Keeper) GetPairs(ctx sdk.Context) common.AssetPairs
GetPairs returns the pairs from params
func (Keeper) GetRawPrices ¶
GetRawPrices fetches the set of all prices posted by oracles for an asset
func (Keeper) GetTwapLookbackWindow ¶ added in v0.12.0
func (Keeper) IsActivePair ¶ added in v0.5.2
GetPair returns the market if it is in the pricefeed system
func (Keeper) IsWhitelistedOracle ¶ added in v0.5.2
IsWhitelistedOracle returns true if the address is whitelisted, false if not.
func (Keeper) IterateCurrentPrices ¶
IterateCurrentPrices iterates over all current price objects in the store and performs a callback function
func (Keeper) IteratePriceSnapshotsFrom ¶ added in v0.12.0
func (Keeper) IterateRawPricesByPair ¶
func (k Keeper) IterateRawPricesByPair(ctx sdk.Context, marketId string, cb func(record types.PostedPrice) (stop bool))
IterateRawPrices iterates over all raw prices in the store and performs a callback function
func (Keeper) OraclesStore ¶ added in v0.5.2
func (k Keeper) OraclesStore() OraclesState
OraclesStore maintains the "oracles" KVStore: maps pair name → oracles.
func (Keeper) PostRawPrice ¶ added in v0.9.2
func (k Keeper) PostRawPrice( ctx sdk.Context, oracle sdk.AccAddress, pairStr string, price sdk.Dec, expiry time.Time, ) (postedPrice types.PostedPrice, err error)
PostRawPrice updates the posted price for a specific oracle
func (Keeper) QueryMarkets ¶ added in v0.6.0
func (k Keeper) QueryMarkets(goCtx context.Context, req *types.QueryMarketsRequest, ) (*types.QueryMarketsResponse, error)
func (Keeper) QueryOracles ¶ added in v0.5.2
func (k Keeper) QueryOracles(goCtx context.Context, req *types.QueryOraclesRequest) (*types.QueryOraclesResponse, error)
func (Keeper) QueryParams ¶ added in v0.5.2
func (k Keeper) QueryParams(c context.Context, req *types.QueryParamsRequest, ) (*types.QueryParamsResponse, error)
func (Keeper) QueryPrice ¶ added in v0.5.2
func (k Keeper) QueryPrice(goCtx context.Context, req *types.QueryPriceRequest) (*types.QueryPriceResponse, error)
func (Keeper) QueryPrices ¶ added in v0.5.2
func (k Keeper) QueryPrices(goCtx context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error)
func (Keeper) QueryRawPrices ¶ added in v0.5.2
func (k Keeper) QueryRawPrices( goCtx context.Context, req *types.QueryRawPricesRequest, ) (*types.QueryRawPricesResponse, error)
func (Keeper) WhitelistOracles ¶ added in v0.1.0
func (k Keeper) WhitelistOracles(ctx sdk.Context, oracles []sdk.AccAddress)
Whitelists given 'oracles' for all of the current pairs in the module params.
func (Keeper) WhitelistOraclesForPairs ¶ added in v0.5.2
func (k Keeper) WhitelistOraclesForPairs( ctx sdk.Context, oracles []sdk.AccAddress, proposedPairs []common.AssetPair, )
WhitelistOracleForPairs whitelists 'oracles' for the given 'pairs'.
type OraclesState ¶ added in v0.5.2
type OraclesState Keeper
----------------------------------------------------------------------------- OraclesState implements methods for updating the "oracles" sdk.KVStore
func (OraclesState) AddOracles ¶ added in v0.5.2
func (state OraclesState) AddOracles( ctx sdk.Context, pair common.AssetPair, oracles []sdk.AccAddress, )
func (OraclesState) Get ¶ added in v0.5.2
func (state OraclesState) Get( ctx sdk.Context, pair common.AssetPair, ) (oracles []sdk.AccAddress)
func (OraclesState) Iterate ¶ added in v0.5.2
func (state OraclesState) Iterate( ctx sdk.Context, do func(*types.OraclesMarshaler) (stop bool), )
func (OraclesState) Set ¶ added in v0.5.2
func (state OraclesState) Set( ctx sdk.Context, pair common.AssetPair, oracles []sdk.AccAddress, )