Documentation ¶
Index ¶
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewQuerier(keeper Keeper) types.QueryServer
- type Hooks
- type IterateExchangeRateVote
- type IterateFeederDelegationHandler
- type Keeper
- func (k Keeper) AcceptList(ctx sdk.Context) (res types.DenomList)
- func (k Keeper) AddHistoricPrice(ctx sdk.Context, denom string, exchangeRate sdk.Dec)
- func (k Keeper) CalcAndSetMedian(ctx sdk.Context, denom string)
- func (k Keeper) ClearExchangeRates(ctx sdk.Context)
- func (k Keeper) ClearMedianDeviations(ctx sdk.Context)
- func (k Keeper) ClearMedians(ctx sdk.Context)
- func (k Keeper) ClearVotes(ctx sdk.Context, votePeriod uint64)
- func (k Keeper) DeleteAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress)
- func (k Keeper) DeleteAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress)
- func (k Keeper) DeleteHistoricPrice(ctx sdk.Context, denom string, blockNum uint64)
- func (k Keeper) DeleteMedian(ctx sdk.Context, denom string)
- func (k Keeper) DeleteMedianDeviation(ctx sdk.Context, denom string)
- func (k Keeper) DeleteMissCounter(ctx sdk.Context, operator sdk.ValAddress)
- func (k Keeper) GetAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress) (types.AggregateExchangeRatePrevote, error)
- func (k Keeper) GetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress) (types.AggregateExchangeRateVote, error)
- func (k Keeper) GetExchangeRate(ctx sdk.Context, symbol string) (sdk.Dec, error)
- func (k Keeper) GetExchangeRateBase(ctx sdk.Context, denom string) (sdk.Dec, error)
- func (k Keeper) GetFeederDelegation(ctx sdk.Context, vAddr sdk.ValAddress) (sdk.AccAddress, error)
- func (k Keeper) GetMedian(ctx sdk.Context, denom string) (sdk.Dec, error)
- func (k Keeper) GetMedianDeviation(ctx sdk.Context, denom string) (sdk.Dec, error)
- func (k Keeper) GetMissCounter(ctx sdk.Context, operator sdk.ValAddress) uint64
- func (k Keeper) GetOracleAccount(ctx sdk.Context) authtypes.ModuleAccountI
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetRewardPool(ctx sdk.Context, denom string) sdk.Coin
- func (k Keeper) HasAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress) bool
- func (k Keeper) HistoricAcceptList(ctx sdk.Context) (res types.DenomList)
- func (k Keeper) Hooks() Hooks
- func (k Keeper) IsHistoricAsset(ctx sdk.Context, denom string) bool
- func (k Keeper) IterateAggregateExchangeRatePrevotes(ctx sdk.Context, ...)
- func (k Keeper) IterateAggregateExchangeRateVotes(ctx sdk.Context, handler IterateExchangeRateVote)
- func (k Keeper) IterateAllHistoricPrices(ctx sdk.Context, handler func(types.HistoricPrice) bool)
- func (k Keeper) IterateAllMedianDeviationPrices(ctx sdk.Context, handler func(types.ExchangeRateTuple) bool)
- func (k Keeper) IterateAllMedianPrices(ctx sdk.Context, handler func(types.ExchangeRateTuple) bool)
- func (k Keeper) IterateExchangeRates(ctx sdk.Context, handler func(string, sdk.Dec) bool)
- func (k Keeper) IterateFeederDelegations(ctx sdk.Context, handler IterateFeederDelegationHandler)
- func (k Keeper) IterateHistoricPrices(ctx sdk.Context, denom string, handler func(sdk.Dec) bool)
- func (k Keeper) IterateMissCounters(ctx sdk.Context, handler func(sdk.ValAddress, uint64) bool)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MedianPeriod(ctx sdk.Context) (res uint64)
- func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) OrganizeBallotByDenom(ctx sdk.Context, validatorClaimMap map[string]types.Claim) []types.BallotDenom
- func (k Keeper) PrunePeriod(ctx sdk.Context) (res uint64)
- func (k Keeper) RewardBallotWinners(ctx sdk.Context, votePeriod int64, rewardDistributionWindow int64, ...)
- func (k Keeper) RewardBand(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) RewardDistributionWindow(ctx sdk.Context) (res uint64)
- func (k Keeper) SetAcceptList(ctx sdk.Context, acceptList types.DenomList)
- func (k Keeper) SetAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress, ...)
- func (k Keeper) SetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress, vote types.AggregateExchangeRateVote)
- func (k Keeper) SetExchangeRate(ctx sdk.Context, denom string, exchangeRate sdk.Dec)
- func (k Keeper) SetExchangeRateWithEvent(ctx sdk.Context, denom string, exchangeRate sdk.Dec) error
- func (k Keeper) SetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress)
- func (k Keeper) SetHistoricAcceptList(ctx sdk.Context, historicAcceptList types.DenomList)
- func (k Keeper) SetHistoricPrice(ctx sdk.Context, denom string, blockNum uint64, exchangeRate sdk.Dec)
- func (k Keeper) SetMedian(ctx sdk.Context, denom string, median sdk.Dec)
- func (k Keeper) SetMedianDeviation(ctx sdk.Context, denom string, medianDeviation sdk.Dec)
- func (k Keeper) SetMedianPeriod(ctx sdk.Context, medianPeriod uint64)
- func (k Keeper) SetMissCounter(ctx sdk.Context, operator sdk.ValAddress, missCounter uint64)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPrunePeriod(ctx sdk.Context, prunePeriod uint64)
- func (k Keeper) SetStampPeriod(ctx sdk.Context, stampPeriod uint64)
- func (k Keeper) SlashAndResetMissCounters(ctx sdk.Context)
- func (k Keeper) SlashFraction(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) SlashWindow(ctx sdk.Context) (res uint64)
- func (k Keeper) StampPeriod(ctx sdk.Context) (res uint64)
- func (k Keeper) ValidateFeeder(ctx sdk.Context, feederAddr sdk.AccAddress, valAddr sdk.ValAddress) error
- func (k Keeper) VotePeriod(ctx sdk.Context) (res uint64)
- func (k Keeper) VoteThreshold(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) WithinMedianDeviation(ctx sdk.Context, denom string, price sdk.Dec) (bool, error)
- type Migrator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the oracle MsgServer interface for the provided Keeper.
func NewQuerier ¶
func NewQuerier(keeper Keeper) types.QueryServer
NewQuerier returns an implementation of the oracle QueryServer interface for the provided Keeper.
Types ¶
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks defines a structure around the x/oracle Keeper that implements various Hooks interface defined by other modules such as x/leverage.
func (Hooks) AfterRegisteredTokenRemoved ¶
func (h Hooks) AfterRegisteredTokenRemoved(ctx sdk.Context, token leveragetypes.Token)
AfterRegisteredTokenRemoved implements the x/leverage Hooks interface. Currently, it performs a no-op, however, we may want to remove tokens from the accept list in the future when they're removed from the x/leverage Token registry.
We don't remove the token from the accept list because it might prove to be useful to still have price data for assets outside of the scope of the x/leverage registry. If assets need to be removed, they can always be purged via param change proposals.
func (Hooks) AfterTokenRegistered ¶
func (h Hooks) AfterTokenRegistered(ctx sdk.Context, token leveragetypes.Token)
AfterTokenRegistered implements the x/leverage Hooks interface. Specifically, it checks if the provided Token should be added to the existing accepted list of assets for the x/oracle module.
type IterateExchangeRateVote ¶
type IterateExchangeRateVote = func( voterAddr sdk.ValAddress, aggregateVote types.AggregateExchangeRateVote, ) (stop bool)
type IterateFeederDelegationHandler ¶
type IterateFeederDelegationHandler func(delegator sdk.ValAddress, delegate sdk.AccAddress) (stop bool)
type Keeper ¶
type Keeper struct { StakingKeeper types.StakingKeeper // contains filtered or unexported fields }
Keeper of the oracle store
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, paramspace paramstypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, distrKeeper types.DistributionKeeper, stakingKeeper types.StakingKeeper, distrName string, ) Keeper
NewKeeper constructs a new keeper for oracle
func (Keeper) AcceptList ¶
AcceptList returns the denom list that can be activated
func (Keeper) AddHistoricPrice ¶ added in v3.2.0
AddHistoricPrice adds the historic price of a denom at the current block height.
func (Keeper) CalcAndSetMedian ¶ added in v3.2.0
SetMedian uses all the historic prices of a given denom to calculate its median price in the last prune period since the current block and set it to the store. It will also call setMedianDeviation with the calculated median.
func (Keeper) ClearExchangeRates ¶
func (Keeper) ClearMedianDeviations ¶ added in v3.2.0
ClearMedianDeviations iterates through all median deviations in the store and deletes them.
func (Keeper) ClearMedians ¶ added in v3.2.0
ClearMedians iterates through all medians in the store and deletes them.
func (Keeper) ClearVotes ¶ added in v3.2.0
ClearVotes clears all tallied prevotes and votes from the store.
func (Keeper) DeleteAggregateExchangeRatePrevote ¶
func (k Keeper) DeleteAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress)
DeleteAggregateExchangeRatePrevote deletes an oracle prevote from the store.
func (Keeper) DeleteAggregateExchangeRateVote ¶
func (k Keeper) DeleteAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress)
DeleteAggregateExchangeRateVote deletes an oracle prevote from the store.
func (Keeper) DeleteHistoricPrice ¶ added in v3.2.0
DeleteHistoricPrice deletes the historic price of a denom at a given block.
func (Keeper) DeleteMedian ¶ added in v3.2.0
DeleteMedian deletes a given denom's median price.
func (Keeper) DeleteMedianDeviation ¶ added in v3.2.0
DeleteMedianDeviation deletes a given denom's standard deviation around its median price.
func (Keeper) DeleteMissCounter ¶
func (k Keeper) DeleteMissCounter(ctx sdk.Context, operator sdk.ValAddress)
DeleteMissCounter removes miss counter for the validator.
func (Keeper) GetAggregateExchangeRatePrevote ¶
func (k Keeper) GetAggregateExchangeRatePrevote( ctx sdk.Context, voter sdk.ValAddress, ) (types.AggregateExchangeRatePrevote, error)
GetAggregateExchangeRatePrevote retrieves an oracle prevote from the store.
func (Keeper) GetAggregateExchangeRateVote ¶
func (k Keeper) GetAggregateExchangeRateVote( ctx sdk.Context, voter sdk.ValAddress, ) (types.AggregateExchangeRateVote, error)
GetAggregateExchangeRateVote retrieves an oracle prevote from the store.
func (Keeper) GetExchangeRate ¶
GetExchangeRate gets the consensus exchange rate of USD denominated in the denom asset from the store.
func (Keeper) GetExchangeRateBase ¶
GetExchangeRateBase gets the consensus exchange rate of an asset in the base denom (e.g. ATOM -> uatom)
func (Keeper) GetFeederDelegation ¶
func (k Keeper) GetFeederDelegation(ctx sdk.Context, vAddr sdk.ValAddress) (sdk.AccAddress, error)
GetFeederDelegation gets the account address to which the validator operator delegated oracle vote rights.
func (Keeper) GetMedian ¶ added in v3.2.0
GetMedian returns a given denom's median price in the last prune period since a given block.
func (Keeper) GetMedianDeviation ¶ added in v3.2.0
GetMedianDeviation returns a given denom's standard deviation around its median price in the last prune period since a given block.
func (Keeper) GetMissCounter ¶
GetMissCounter retrieves the # of vote periods missed in this oracle slash window.
func (Keeper) GetOracleAccount ¶
func (k Keeper) GetOracleAccount(ctx sdk.Context) authtypes.ModuleAccountI
GetOracleAccount returns oracle ModuleAccount.
func (Keeper) GetRewardPool ¶
GetRewardPool retrieves the balance of the oracle module account.
func (Keeper) HasAggregateExchangeRatePrevote ¶
HasAggregateExchangeRatePrevote checks if a validator has an existing prevote.
func (Keeper) HistoricAcceptList ¶ added in v3.2.0
HistoricAcceptList returns the list of assets whose historic prices and medians are getting tracked.
func (Keeper) IsHistoricAsset ¶ added in v3.2.0
IsHistoricAsset returns whether or not a given denom is being tracked as a historic asset.
func (Keeper) IterateAggregateExchangeRatePrevotes ¶
func (k Keeper) IterateAggregateExchangeRatePrevotes( ctx sdk.Context, handler func(sdk.ValAddress, types.AggregateExchangeRatePrevote) bool, )
IterateAggregateExchangeRatePrevotes iterates rate over prevotes in the store
func (Keeper) IterateAggregateExchangeRateVotes ¶
func (k Keeper) IterateAggregateExchangeRateVotes( ctx sdk.Context, handler IterateExchangeRateVote, )
IterateAggregateExchangeRateVotes iterates rate over prevotes in the store.
func (Keeper) IterateAllHistoricPrices ¶ added in v3.2.0
func (k Keeper) IterateAllHistoricPrices( ctx sdk.Context, handler func(types.HistoricPrice) bool, )
IterateAllHistoricPrices iterates over all historic prices. Iterator stops when exhausting the source, or when the handler returns `true`.
func (Keeper) IterateAllMedianDeviationPrices ¶ added in v3.2.0
func (k Keeper) IterateAllMedianDeviationPrices( ctx sdk.Context, handler func(types.ExchangeRateTuple) bool, )
IterateAllMedianDeviationPrices iterates over all median deviation prices. Iterator stops when exhausting the source, or when the handler returns `true`.
func (Keeper) IterateAllMedianPrices ¶ added in v3.2.0
func (k Keeper) IterateAllMedianPrices( ctx sdk.Context, handler func(types.ExchangeRateTuple) bool, )
IterateAllMedianPrices iterates over all median prices. Iterator stops when exhausting the source, or when the handler returns `true`.
func (Keeper) IterateExchangeRates ¶
IterateExchangeRates iterates over all USD rates in the store.
func (Keeper) IterateFeederDelegations ¶
func (k Keeper) IterateFeederDelegations(ctx sdk.Context, handler IterateFeederDelegationHandler)
IterateFeederDelegations iterates over the feed delegates and performs a callback function.
func (Keeper) IterateHistoricPrices ¶ added in v3.2.0
IterateHistoricPrices iterates over historic prices of a given denom in the store. Iterator stops when exhausting the source, or when the handler returns `true`.
func (Keeper) IterateMissCounters ¶
IterateMissCounters iterates over the miss counters and performs a callback function.
func (Keeper) MedianPeriod ¶ added in v3.2.0
MedianPeriod returns the amount blocks we will wait between calculating the median and standard deviation of the median of historic prices in the last Prune Period.
func (Keeper) MinValidPerWindow ¶
MinValidPerWindow returns oracle slashing threshold
func (Keeper) OrganizeBallotByDenom ¶
func (k Keeper) OrganizeBallotByDenom( ctx sdk.Context, validatorClaimMap map[string]types.Claim, ) []types.BallotDenom
OrganizeBallotByDenom collects all oracle votes for the current vote period, categorized by the votes' denom parameter.
func (Keeper) PrunePeriod ¶ added in v3.2.0
PrunePeriod returns the max amount of blocks that a record of the set of exchanges is kept.
func (Keeper) RewardBallotWinners ¶
func (k Keeper) RewardBallotWinners( ctx sdk.Context, votePeriod int64, rewardDistributionWindow int64, voteTargets []string, ballotWinners []types.Claim, )
RewardBallotWinners is executed at the end of every voting period, where we give out a portion of seigniorage reward(reward-weight) to the oracle voters that voted correctly.
func (Keeper) RewardBand ¶
RewardBand returns the ratio of allowable exchange rate error that a validator can be rewarded.
func (Keeper) RewardDistributionWindow ¶
RewardDistributionWindow returns the number of vote periods during which seigniorage reward comes in and then is distributed.
func (Keeper) SetAcceptList ¶
SetAcceptList updates the accepted list of assets supported by the x/oracle module.
func (Keeper) SetAggregateExchangeRatePrevote ¶
func (k Keeper) SetAggregateExchangeRatePrevote( ctx sdk.Context, voter sdk.ValAddress, prevote types.AggregateExchangeRatePrevote, )
SetAggregateExchangeRatePrevote set an oracle aggregate prevote to the store.
func (Keeper) SetAggregateExchangeRateVote ¶
func (k Keeper) SetAggregateExchangeRateVote( ctx sdk.Context, voter sdk.ValAddress, vote types.AggregateExchangeRateVote, )
SetAggregateExchangeRateVote adds an oracle aggregate prevote to the store.
func (Keeper) SetExchangeRate ¶
SetExchangeRate sets the consensus exchange rate of USD denominated in the denom asset to the store.
func (Keeper) SetExchangeRateWithEvent ¶
SetExchangeRateWithEvent sets an consensus exchange rate to the store with ABCI event
func (Keeper) SetFeederDelegation ¶
func (k Keeper) SetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress)
SetFeederDelegation sets the account address to which the validator operator delegated oracle vote rights.
func (Keeper) SetHistoricAcceptList ¶ added in v3.2.0
SetHistoricAcceptList updates the the list of assets whose historic prices and medians are getting tracked.
func (Keeper) SetHistoricPrice ¶ added in v3.2.0
func (Keeper) SetMedianDeviation ¶ added in v3.2.0
func (Keeper) SetMedianPeriod ¶ added in v3.2.0
MedianPeriod updates the amount blocks we will wait between calculating the median and standard deviation of the median of historic prices in the last Prune Period.
func (Keeper) SetMissCounter ¶
SetMissCounter updates the # of vote periods missed in this oracle slash window.
func (Keeper) SetPrunePeriod ¶ added in v3.2.0
SetPrunePeriod updates the max amount of blocks that a record of the set of exchanges is kept.
func (Keeper) SetStampPeriod ¶ added in v3.2.0
SetStampPeriod updates the amount of blocks the oracle module waits between recording a set of prices.
func (Keeper) SlashAndResetMissCounters ¶
SlashAndResetMissCounters iterates over all the current missed counters and calculates the "valid vote rate" as: (votePeriodsPerWindow - missCounter)/votePeriodsPerWindow.
If the valid vote rate is below the minValidPerWindow, the validator will be slashed and jailed.
func (Keeper) SlashFraction ¶
SlashFraction returns oracle voting penalty rate
func (Keeper) SlashWindow ¶
SlashWindow returns # of vote period for oracle slashing
func (Keeper) StampPeriod ¶ added in v3.2.0
StampPeriod returns the amount of blocks the oracle module waits between recording a set of prices.
func (Keeper) ValidateFeeder ¶
func (k Keeper) ValidateFeeder(ctx sdk.Context, feederAddr sdk.AccAddress, valAddr sdk.ValAddress) error
ValidateFeeder returns error if the given feeder is not allowed to feed the message.
func (Keeper) VotePeriod ¶
VotePeriod returns the number of blocks during which voting takes place.
func (Keeper) VoteThreshold ¶
VoteThreshold returns the minimum percentage of votes that must be received for a ballot to pass.
type Migrator ¶ added in v3.2.0
type Migrator struct {
// contains filtered or unexported fields
}
Migrator is a struct for handling in-place store migrations.
func NewMigrator ¶ added in v3.2.0
NewMigrator creates a Migrator.