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) 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 ¶
func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNilValidatorAddr ¶
func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNilWithdrawAddr ¶
func ErrNilWithdrawAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNoDelegationDistInfo ¶
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 ¶
const ( DefaultCodespace sdk.CodespaceType = 6 CodeInvalidInput CodeType = 103 CodeNoDistributionInfo CodeType = 104 )
type DecCoin ¶
Coins which can have additional decimal points
func NewDecCoin ¶
func NewDecCoinFromCoin ¶
type DecCoins ¶
type DecCoins []DecCoin
coins with decimal
func NewDecCoins ¶
func (DecCoins) Plus ¶
Plus combines two sets of coins CONTRACT: Plus will never return Coins where one Coin has a 0 amount.
type DelegationDistInfo ¶
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 ¶
func NewDelegationDistInfo(delegatorAddr sdk.AccAddress, valOperatorAddr sdk.ValAddress, currentHeight int64) DelegationDistInfo
func (DelegationDistInfo) CurrentRewards ¶
func (di DelegationDistInfo) CurrentRewards(wc WithdrawContext, vi ValidatorDistInfo, totalDelShares, delegatorShares sdk.Dec) DecCoins
get the delegators rewards at this current state,
func (DelegationDistInfo) GetDelAccum ¶
Get the calculated accum of this delegator at the provided height
func (DelegationDistInfo) WithdrawRewards ¶
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 ¶
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 ¶
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"` }
GenesisState - all distribution state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
get raw genesis raw message for testing
func DefaultGenesisWithValidators ¶
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) 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 ¶
type MsgWithdrawDelegatorRewardsAll struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
}
msg struct for delegation withdraw for all of the delegator's delegations
func NewMsgWithdrawDelegatorRewardsAll ¶
func NewMsgWithdrawDelegatorRewardsAll(delAddr sdk.AccAddress) MsgWithdrawDelegatorRewardsAll
func (MsgWithdrawDelegatorRewardsAll) GetSignBytes ¶
func (msg MsgWithdrawDelegatorRewardsAll) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgWithdrawDelegatorRewardsAll) GetSigners ¶
func (msg MsgWithdrawDelegatorRewardsAll) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgWithdrawDelegatorRewardsAll) Route ¶
func (msg MsgWithdrawDelegatorRewardsAll) Route() string
func (MsgWithdrawDelegatorRewardsAll) Type ¶
func (msg MsgWithdrawDelegatorRewardsAll) Type() string
func (MsgWithdrawDelegatorRewardsAll) ValidateBasic ¶
func (msg MsgWithdrawDelegatorRewardsAll) ValidateBasic() sdk.Error
quick validity check
type MsgWithdrawValidatorRewardsAll ¶
type MsgWithdrawValidatorRewardsAll struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
}
msg struct for validator withdraw
func NewMsgWithdrawValidatorRewardsAll ¶
func NewMsgWithdrawValidatorRewardsAll(valAddr sdk.ValAddress) MsgWithdrawValidatorRewardsAll
func (MsgWithdrawValidatorRewardsAll) GetSignBytes ¶
func (msg MsgWithdrawValidatorRewardsAll) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgWithdrawValidatorRewardsAll) GetSigners ¶
func (msg MsgWithdrawValidatorRewardsAll) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgWithdrawValidatorRewardsAll) Route ¶
func (msg MsgWithdrawValidatorRewardsAll) Route() string
func (MsgWithdrawValidatorRewardsAll) Type ¶
func (msg MsgWithdrawValidatorRewardsAll) Type() string
func (MsgWithdrawValidatorRewardsAll) ValidateBasic ¶
func (msg MsgWithdrawValidatorRewardsAll) ValidateBasic() sdk.Error
quick validity check
type StakeKeeper ¶
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 ¶
total accumulation tracker
func NewTotalAccum ¶
func NewTotalAccum(height int64) TotalAccum
func (TotalAccum) GetAccum ¶
get total accumulation factor for the given height CONTRACT: height should be greater than the old height
func (TotalAccum) UpdateForNewHeight ¶
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 ¶
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 ¶
func NewValidatorDistInfo(operatorAddr sdk.ValAddress, currentHeight int64) ValidatorDistInfo
func (ValidatorDistInfo) CurrentCommissionRewards ¶
func (vi ValidatorDistInfo) CurrentCommissionRewards( wc WithdrawContext) DecCoins
get the validator's commission pool rewards at this current state,
func (ValidatorDistInfo) CurrentPoolRewards ¶
func (vi ValidatorDistInfo) CurrentPoolRewards( wc WithdrawContext) DecCoins
get the validator's pool rewards at this current state,
func (ValidatorDistInfo) GetTotalDelAccum ¶
Get the total delegator accum within this validator at the provided height
func (ValidatorDistInfo) GetValAccum ¶
Get the validator accum at the provided height
func (ValidatorDistInfo) TakeFeePoolRewards ¶
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 ¶
func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares sdk.Dec) ValidatorDistInfo
update total delegator accumululation
func (ValidatorDistInfo) WithdrawCommission ¶
func (vi ValidatorDistInfo) WithdrawCommission(wc WithdrawContext) ( vio ValidatorDistInfo, fpo FeePool, withdrawn DecCoins)
withdraw commission rewards
type WithdrawContext ¶
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 ¶
func NewWithdrawContext(feePool FeePool, height int64, totalPower, valPower, commissionRate sdk.Dec) WithdrawContext