Documentation ¶
Index ¶
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewQuerier(keeper Keeper) types.QueryServer
- func Tally(ballot types.ExchangeRateBallot, rewardBand sdk.Dec, ...) (sdk.Dec, error)
- type IterateExchangeRateVoteFunc
- type IterateFeederDelegationHandler
- type Keeper
- func (k Keeper) BuildClaimsMapAndTally(ctx sdk.Context, params types.Params) error
- func (k Keeper) ClearExchangeRates(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) DeleteMissCounter(ctx sdk.Context, operator sdk.ValAddress)
- func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
- func (k Keeper) FundRewardPool(ctx sdk.Context, from sdk.AccAddress, funds sdk.Coins) error
- func (k Keeper) GetAcceptList(ctx sdk.Context) (res types.DenomList)
- 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, denom string) (sdk.Dec, error)
- func (k Keeper) GetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress) (sdk.AccAddress, error)
- func (k Keeper) GetMinValidPerWindow(ctx sdk.Context) (res sdk.Dec)
- 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) GetRewardDistributionWindow(ctx sdk.Context) (res uint64)
- func (k Keeper) GetRewardPool(ctx sdk.Context, denom string) sdk.Coin
- func (k Keeper) GetRewardPoolBalance(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
- func (k Keeper) GetSlashFraction(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) GetSlashWindow(ctx sdk.Context) (res uint64)
- func (k Keeper) GetVotePeriod(ctx sdk.Context) (res uint64)
- func (k Keeper) GetVoteThreshold(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) HasAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress) bool
- func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)
- func (k Keeper) IterateAggregateExchangeRatePrevotes(ctx sdk.Context, ...)
- func (k Keeper) IterateAggregateExchangeRateVotes(ctx sdk.Context, handler IterateExchangeRateVoteFunc)
- 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) IterateMissCounters(ctx sdk.Context, handler func(sdk.ValAddress, uint64) bool)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) OrganizeBallotByDenom(ctx sdk.Context, validatorClaimMap map[string]types.Claim) []types.BallotDenom
- func (k Keeper) RewardBallotWinners(ctx sdk.Context, votePeriod int64, rewardDistributionWindow int64, ...)
- 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)
- func (k Keeper) SetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress)
- 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) SetVoteThreshold(ctx sdk.Context, threshold sdk.Dec) error
- func (k Keeper) SlashAndResetMissCounters(ctx sdk.Context)
- func (k Keeper) ValidateFeeder(ctx sdk.Context, valAddr sdk.ValAddress, feederAddr sdk.AccAddress) error
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.
func Tally ¶
func Tally( ballot types.ExchangeRateBallot, rewardBand sdk.Dec, validatorClaimMap map[string]types.Claim, ) (sdk.Dec, error)
Tally calculates the median and returns it. It sets the set of voters to be rewarded, i.e. voted within a reasonable spread from the weighted median to the store. Note, the ballot is sorted by ExchangeRate. https://classic-docs.terra.money/docs/develop/module-specifications/spec-oracle.html#tally
Types ¶
type IterateExchangeRateVoteFunc ¶
type IterateExchangeRateVoteFunc 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, recipientModule string, ) Keeper
NewKeeper constructs a new keeper for oracle
func (Keeper) BuildClaimsMapAndTally ¶
BuildClaimsMapAndTally builds a claim map over all validators in active set, marks misses and handles ballot tallying.
func (Keeper) ClearExchangeRates ¶
ClearExchangeRates clears all exchange rates from the store.
func (Keeper) ClearVotes ¶
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) DeleteMissCounter ¶
func (k Keeper) DeleteMissCounter(ctx sdk.Context, operator sdk.ValAddress)
DeleteMissCounter removes miss counter for the validator.
func (Keeper) ExportGenesis ¶
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
ExportGenesis returns the x/oracle module's keeper exported genesis state.
func (Keeper) FundRewardPool ¶
func (Keeper) GetAcceptList ¶
GetAcceptList returns the denom list that can be activated
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) GetFeederDelegation ¶
func (k Keeper) GetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress) (sdk.AccAddress, error)
GetFeederDelegation gets the account address to which the validator operator delegated oracle vote rights.
func (Keeper) GetMinValidPerWindow ¶
GetMinValidPerWindow returns oracle slashing threshold
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) GetRewardDistributionWindow ¶
GetRewardDistributionWindow returns the number of vote periods during which seigniorage reward comes in and then is distributed.
func (Keeper) GetRewardPool ¶
GetRewardPool retrieves the balance of the oracle module account.
func (Keeper) GetRewardPoolBalance ¶
func (Keeper) GetSlashFraction ¶
GetSlashFraction returns oracle voting penalty rate
func (Keeper) GetSlashWindow ¶
GetSlashWindow returns # of vote period for oracle slashing
func (Keeper) GetVotePeriod ¶
GetVotePeriod returns the number of blocks during which voting takes place.
func (Keeper) GetVoteThreshold ¶
GetVoteThreshold returns the minimum percentage of votes that must be received for a ballot to pass.
func (Keeper) HasAggregateExchangeRatePrevote ¶
HasAggregateExchangeRatePrevote checks if a validator has an existing prevote.
func (Keeper) InitGenesis ¶
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)
InitGenesis initializes the x/oracle module's keeper state from a provided genesis state.
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 IterateExchangeRateVoteFunc, )
IterateAggregateExchangeRateVotes iterates rate over prevotes in the store.
func (Keeper) IterateExchangeRates ¶
IterateExchangeRates iterates over XPRT 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) IterateMissCounters ¶
IterateMissCounters iterates over the miss counters and performs a callback function.
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) 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. https://classic-docs.terra.money/docs/develop/module-specifications/spec-oracle.html#k-rewardballotwinners
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) SetMissCounter ¶
SetMissCounter updates the # of vote periods missed in this oracle slash window.
func (Keeper) SetVoteThreshold ¶
SetVoteThreshold sets min combined validator power voting on a denom to accept it as valid. TODO: this is used in tests, we should refactor the way how this is handled.
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. https://classic-docs.terra.money/docs/develop/module-specifications/spec-oracle.html#slashandresetmisscounters
func (Keeper) ValidateFeeder ¶
func (k Keeper) ValidateFeeder(ctx sdk.Context, valAddr sdk.ValAddress, feederAddr sdk.AccAddress) error
ValidateFeeder returns the given feeder is allowed to feed the message or not.