Documentation ¶
Overview ¶
nolint
nolint
Index ¶
- Constants
- Variables
- func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNilWithdrawAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNoDelegationDistInfo(codespace sdk.CodespaceType) sdk.Error
- func ErrNoValidatorDistInfo(codespace sdk.CodespaceType) sdk.Error
- func RegisterCodec(cdc *codec.Codec)
- type BankKeeper
- type CodeType
- type DecCoin
- type DecCoins
- func (coins DecCoins) AmountOf(denom string) sdk.Dec
- func (coins DecCoins) HasNegative() bool
- func (coins DecCoins) Minus(coinsB DecCoins) DecCoins
- func (coins DecCoins) MulDec(d sdk.Dec) DecCoins
- func (coins DecCoins) Negative() DecCoins
- func (coins DecCoins) Plus(coinsB DecCoins) DecCoins
- func (coins DecCoins) QuoDec(d sdk.Dec) DecCoins
- func (coins DecCoins) TruncateDecimal() (sdk.Coins, DecCoins)
- type DelegationDistInfo
- func (di DelegationDistInfo) CurrentRewards(wc WithdrawContext, vi ValidatorDistInfo, ...) DecCoins
- func (di DelegationDistInfo) GetDelAccum(height int64, delegatorShares sdk.Dec) sdk.Dec
- func (di DelegationDistInfo) WithdrawRewards(wc WithdrawContext, vi ValidatorDistInfo, ...) (DelegationDistInfo, ValidatorDistInfo, FeePool, DecCoins)
- type DelegatorWithdrawInfo
- type FeeCollectionKeeper
- type FeePool
- type GenesisState
- type MsgSetWithdrawAddress
- type MsgWithdrawDelegatorReward
- type MsgWithdrawDelegatorRewardsAll
- func (msg MsgWithdrawDelegatorRewardsAll) GetSignBytes() []byte
- func (msg MsgWithdrawDelegatorRewardsAll) GetSigners() []sdk.AccAddress
- func (msg MsgWithdrawDelegatorRewardsAll) Route() string
- func (msg MsgWithdrawDelegatorRewardsAll) Type() string
- func (msg MsgWithdrawDelegatorRewardsAll) ValidateBasic() sdk.Error
- type MsgWithdrawValidatorRewardsAll
- func (msg MsgWithdrawValidatorRewardsAll) GetSignBytes() []byte
- func (msg MsgWithdrawValidatorRewardsAll) GetSigners() []sdk.AccAddress
- func (msg MsgWithdrawValidatorRewardsAll) Route() string
- func (msg MsgWithdrawValidatorRewardsAll) Type() string
- func (msg MsgWithdrawValidatorRewardsAll) ValidateBasic() sdk.Error
- type StakeKeeper
- type TotalAccum
- type ValidatorDistInfo
- func (vi ValidatorDistInfo) CurrentCommissionRewards(wc WithdrawContext) DecCoins
- func (vi ValidatorDistInfo) CurrentPoolRewards(wc WithdrawContext) DecCoins
- func (vi ValidatorDistInfo) GetTotalDelAccum(height int64, totalDelShares sdk.Dec) sdk.Dec
- func (vi ValidatorDistInfo) GetValAccum(height int64, valTokens sdk.Dec) sdk.Dec
- func (vi ValidatorDistInfo) TakeFeePoolRewards(wc WithdrawContext) (ValidatorDistInfo, FeePool)
- func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares sdk.Dec) ValidatorDistInfo
- func (vi ValidatorDistInfo) WithdrawCommission(wc WithdrawContext) (vio ValidatorDistInfo, fpo FeePool, withdrawn DecCoins)
- type WithdrawContext
Constants ¶
const MsgRoute = "distr"
name to identify transaction types
Variables ¶
var MsgCdc *codec.Codec
generic sealed codec to be used throughout module
Functions ¶
func ErrNilDelegatorAddr ¶ added in v0.25.0
func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNilValidatorAddr ¶ added in v0.25.0
func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNilWithdrawAddr ¶ added in v0.25.0
func ErrNilWithdrawAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNoDelegationDistInfo ¶ added in v0.25.0
func ErrNoDelegationDistInfo(codespace sdk.CodespaceType) sdk.Error
func ErrNoValidatorDistInfo ¶
func ErrNoValidatorDistInfo(codespace sdk.CodespaceType) sdk.Error
Types ¶
type BankKeeper ¶
type BankKeeper interface {
AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error)
}
expected coin keeper
type CodeType ¶ added in v0.25.0
const ( DefaultCodespace sdk.CodespaceType = "DISTR" CodeInvalidInput CodeType = 103 CodeNoDistributionInfo CodeType = 104 )
type DecCoin ¶ added in v0.25.0
Coins which can have additional decimal points
func NewDecCoin ¶ added in v0.25.0
func NewDecCoinFromCoin ¶ added in v0.25.0
func NewDecCoinFromDec ¶ added in v0.27.0
type DecCoins ¶ added in v0.25.0
type DecCoins []DecCoin
coins with decimal
func NewDecCoins ¶ added in v0.25.0
func (DecCoins) HasNegative ¶ added in v0.27.0
has a negative DecCoin amount
func (DecCoins) Minus ¶ added in v0.25.0
Minus subtracts a set of coins from another (adds the inverse)
func (DecCoins) Negative ¶ added in v0.25.0
Negative returns a set of coins with all amount negative
func (DecCoins) Plus ¶ added in v0.25.0
Plus combines two sets of coins CONTRACT: Plus will never return Coins where one Coin has a 0 amount.
type DelegationDistInfo ¶ added in v0.25.0
type DelegationDistInfo struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` ValOperatorAddr sdk.ValAddress `json:"val_operator_addr"` DelPoolWithdrawalHeight int64 `json:"del_pool_withdrawal_height"` // last time this delegation withdrew rewards }
distribution info for a delegation - used to determine entitled rewards
func NewDelegationDistInfo ¶ added in v0.25.0
func NewDelegationDistInfo(delegatorAddr sdk.AccAddress, valOperatorAddr sdk.ValAddress, currentHeight int64) DelegationDistInfo
func (DelegationDistInfo) CurrentRewards ¶ added in v0.25.0
func (di DelegationDistInfo) CurrentRewards(wc WithdrawContext, vi ValidatorDistInfo, totalDelShares, delegatorShares sdk.Dec) DecCoins
get the delegators rewards at this current state,
func (DelegationDistInfo) GetDelAccum ¶ added in v0.25.0
Get the calculated accum of this delegator at the provided height
func (DelegationDistInfo) WithdrawRewards ¶ added in v0.25.0
func (di DelegationDistInfo) WithdrawRewards(wc WithdrawContext, vi ValidatorDistInfo, totalDelShares, delegatorShares sdk.Dec) ( DelegationDistInfo, ValidatorDistInfo, FeePool, DecCoins)
Withdraw rewards from delegator. Among many things, it does: * updates validator info's total del accum * calls vi.TakeFeePoolRewards, which:
- updates validator info's FeePoolWithdrawalHeight, thus setting accum to 0
- updates fee pool to latest height and total val accum w/ given totalBonded (see comment on TakeFeePoolRewards for more info)
type DelegatorWithdrawInfo ¶
type DelegatorWithdrawInfo struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` WithdrawAddr sdk.AccAddress `json:"withdraw_addr"` }
the address for where distributions rewards are withdrawn to by default this struct is only used at genesis to feed in default withdraw addresses
type FeeCollectionKeeper ¶ added in v0.25.0
type FeeCollectionKeeper interface { GetCollectedFees(ctx sdk.Context) sdk.Coins ClearCollectedFees(ctx sdk.Context) }
from ante handler
type FeePool ¶
type FeePool struct { TotalValAccum TotalAccum `json:"val_accum"` // total valdator accum held by validators ValPool DecCoins `json:"val_pool"` // funds for all validators which have yet to be withdrawn CommunityPool DecCoins `json:"community_pool"` // pool for community funds yet to be spent }
global fee pool for distribution
func (FeePool) GetTotalValAccum ¶ added in v0.25.0
get the total validator accum for the fee pool without modifying the state
type GenesisState ¶
type GenesisState struct { FeePool FeePool `json:"fee_pool"` CommunityTax sdk.Dec `json:"community_tax"` BaseProposerReward sdk.Dec `json:"base_proposer_reward"` BonusProposerReward sdk.Dec `json:"bonus_proposer_reward"` ValidatorDistInfos []ValidatorDistInfo `json:"validator_dist_infos"` DelegationDistInfos []DelegationDistInfo `json:"delegator_dist_infos"` DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos"` PreviousProposer sdk.ConsAddress `json:"previous_proposer"` }
GenesisState - all distribution state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
get raw genesis raw message for testing
func DefaultGenesisWithValidators ¶ added in v0.25.0
func DefaultGenesisWithValidators(valAddrs []sdk.ValAddress) GenesisState
default genesis utility function, initialize for starting validator set
func NewGenesisState ¶
func NewGenesisState(feePool FeePool, communityTax, baseProposerReward, bonusProposerReward sdk.Dec, vdis []ValidatorDistInfo, ddis []DelegationDistInfo, dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress) GenesisState
type MsgSetWithdrawAddress ¶
type MsgSetWithdrawAddress struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` WithdrawAddr sdk.AccAddress `json:"delegator_addr"` }
msg struct for changing the withdraw address for a delegator (or validator self-delegation)
func NewMsgSetWithdrawAddress ¶
func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress
func (MsgSetWithdrawAddress) GetSignBytes ¶
func (msg MsgSetWithdrawAddress) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgSetWithdrawAddress) GetSigners ¶
func (msg MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgSetWithdrawAddress) Route ¶
func (msg MsgSetWithdrawAddress) Route() string
func (MsgSetWithdrawAddress) Type ¶
func (msg MsgSetWithdrawAddress) Type() string
func (MsgSetWithdrawAddress) ValidateBasic ¶
func (msg MsgSetWithdrawAddress) ValidateBasic() sdk.Error
quick validity check
type MsgWithdrawDelegatorReward ¶
type MsgWithdrawDelegatorReward struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` ValidatorAddr sdk.ValAddress `json:"validator_addr"` }
msg struct for delegation withdraw from a single validator
func NewMsgWithdrawDelegatorReward ¶
func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward
func (MsgWithdrawDelegatorReward) GetSignBytes ¶
func (msg MsgWithdrawDelegatorReward) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgWithdrawDelegatorReward) GetSigners ¶
func (msg MsgWithdrawDelegatorReward) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgWithdrawDelegatorReward) Route ¶
func (msg MsgWithdrawDelegatorReward) Route() string
func (MsgWithdrawDelegatorReward) Type ¶
func (msg MsgWithdrawDelegatorReward) Type() string
func (MsgWithdrawDelegatorReward) ValidateBasic ¶
func (msg MsgWithdrawDelegatorReward) ValidateBasic() sdk.Error
quick validity check
type MsgWithdrawDelegatorRewardsAll ¶ added in v0.25.0
type MsgWithdrawDelegatorRewardsAll struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
}
msg struct for delegation withdraw for all of the delegator's delegations
func NewMsgWithdrawDelegatorRewardsAll ¶ added in v0.25.0
func NewMsgWithdrawDelegatorRewardsAll(delAddr sdk.AccAddress) MsgWithdrawDelegatorRewardsAll
func (MsgWithdrawDelegatorRewardsAll) GetSignBytes ¶ added in v0.25.0
func (msg MsgWithdrawDelegatorRewardsAll) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgWithdrawDelegatorRewardsAll) GetSigners ¶ added in v0.25.0
func (msg MsgWithdrawDelegatorRewardsAll) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgWithdrawDelegatorRewardsAll) Route ¶ added in v0.25.0
func (msg MsgWithdrawDelegatorRewardsAll) Route() string
func (MsgWithdrawDelegatorRewardsAll) Type ¶ added in v0.25.0
func (msg MsgWithdrawDelegatorRewardsAll) Type() string
func (MsgWithdrawDelegatorRewardsAll) ValidateBasic ¶ added in v0.25.0
func (msg MsgWithdrawDelegatorRewardsAll) ValidateBasic() sdk.Error
quick validity check
type MsgWithdrawValidatorRewardsAll ¶ added in v0.25.0
type MsgWithdrawValidatorRewardsAll struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
}
msg struct for validator withdraw
func NewMsgWithdrawValidatorRewardsAll ¶ added in v0.25.0
func NewMsgWithdrawValidatorRewardsAll(valAddr sdk.ValAddress) MsgWithdrawValidatorRewardsAll
func (MsgWithdrawValidatorRewardsAll) GetSignBytes ¶ added in v0.25.0
func (msg MsgWithdrawValidatorRewardsAll) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgWithdrawValidatorRewardsAll) GetSigners ¶ added in v0.25.0
func (msg MsgWithdrawValidatorRewardsAll) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgWithdrawValidatorRewardsAll) Route ¶ added in v0.25.0
func (msg MsgWithdrawValidatorRewardsAll) Route() string
func (MsgWithdrawValidatorRewardsAll) Type ¶ added in v0.25.0
func (msg MsgWithdrawValidatorRewardsAll) Type() string
func (MsgWithdrawValidatorRewardsAll) ValidateBasic ¶ added in v0.25.0
func (msg MsgWithdrawValidatorRewardsAll) ValidateBasic() sdk.Error
quick validity check
type StakeKeeper ¶ added in v0.25.0
type StakeKeeper interface { IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation sdk.Delegation) (stop bool)) Delegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation Validator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Validator ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) sdk.Validator TotalPower(ctx sdk.Context) sdk.Dec GetLastTotalPower(ctx sdk.Context) sdk.Int GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Int }
expected stake keeper
type TotalAccum ¶ added in v0.25.0
total accumulation tracker
func NewTotalAccum ¶ added in v0.25.0
func NewTotalAccum(height int64) TotalAccum
func (TotalAccum) GetAccum ¶ added in v0.25.0
get total accumulation factor for the given height CONTRACT: height should be greater than the old height
func (TotalAccum) UpdateForNewHeight ¶ added in v0.25.0
func (ta TotalAccum) UpdateForNewHeight(height int64, accumCreatedPerBlock sdk.Dec) TotalAccum
update total accumulation factor for the new height CONTRACT: height should be greater than the old height
type ValidatorDistInfo ¶ added in v0.25.0
type ValidatorDistInfo struct { OperatorAddr sdk.ValAddress `json:"operator_addr"` FeePoolWithdrawalHeight int64 `json:"fee_pool_withdrawal_height"` // last height this validator withdrew from the global pool DelAccum TotalAccum `json:"del_accum"` // total accumulation factor held by delegators DelPool DecCoins `json:"del_pool"` // rewards owed to delegators, commission has already been charged (includes proposer reward) ValCommission DecCoins `json:"val_commission"` // commission collected by this validator (pending withdrawal) }
distribution info for a particular validator
func NewValidatorDistInfo ¶ added in v0.25.0
func NewValidatorDistInfo(operatorAddr sdk.ValAddress, currentHeight int64) ValidatorDistInfo
func (ValidatorDistInfo) CurrentCommissionRewards ¶ added in v0.25.0
func (vi ValidatorDistInfo) CurrentCommissionRewards( wc WithdrawContext) DecCoins
get the validator's commission pool rewards at this current state,
func (ValidatorDistInfo) CurrentPoolRewards ¶ added in v0.25.0
func (vi ValidatorDistInfo) CurrentPoolRewards( wc WithdrawContext) DecCoins
get the validator's pool rewards at this current state,
func (ValidatorDistInfo) GetTotalDelAccum ¶ added in v0.25.0
Get the total delegator accum within this validator at the provided height
func (ValidatorDistInfo) GetValAccum ¶ added in v0.25.0
Get the validator accum at the provided height
func (ValidatorDistInfo) TakeFeePoolRewards ¶ added in v0.25.0
func (vi ValidatorDistInfo) TakeFeePoolRewards(wc WithdrawContext) ( ValidatorDistInfo, FeePool)
Move any available accumulated fees in the FeePool to the validator's pool - updates validator info's FeePoolWithdrawalHeight, thus setting accum to 0 - updates fee pool to latest height and total val accum w/ given totalBonded This is the only way to update the FeePool's validator TotalAccum. NOTE: This algorithm works as long as TakeFeePoolRewards is called after every power change. - called in ValidationDistInfo.WithdrawCommission - called in DelegationDistInfo.WithdrawRewards NOTE: When a delegator unbonds, say, onDelegationSharesModified ->
WithdrawDelegationReward -> WithdrawRewards
func (ValidatorDistInfo) UpdateTotalDelAccum ¶ added in v0.25.0
func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares sdk.Dec) ValidatorDistInfo
update total delegator accumululation
func (ValidatorDistInfo) WithdrawCommission ¶ added in v0.25.0
func (vi ValidatorDistInfo) WithdrawCommission(wc WithdrawContext) ( vio ValidatorDistInfo, fpo FeePool, withdrawn DecCoins)
withdraw commission rewards
type WithdrawContext ¶ added in v0.25.0
type WithdrawContext struct { FeePool FeePool Height int64 // block height TotalPower sdk.Dec // total bonded tokens in the network ValPower sdk.Dec // validator's bonded tokens CommissionRate sdk.Dec // validator commission rate }
common parameters used in withdraws from validators
func NewWithdrawContext ¶ added in v0.25.0
func NewWithdrawContext(feePool FeePool, height int64, totalPower, valPower, commissionRate sdk.Dec) WithdrawContext