Documentation ¶
Index ¶
- func NewMsgServerImpl(keeper *Keeper) types.MsgServer
- type Keeper
- func (k Keeper) CheckUndelegateTotalAmount(tokenAmt sdk.Dec, existingSet []types.ValidatorPreference) error
- func (k Keeper) DelegateToValidatorSet(ctx sdk.Context, delegatorAddr string, coin sdk.Coin) error
- func (k Keeper) ForceUnlockBondedPerco(ctx sdk.Context, lockID uint64, delegatorAddr string) (sdk.Coin, error)
- func (k Keeper) GetDelegationPreferences(ctx sdk.Context, delegator string) (types.ValidatorSetPreferences, error)
- func (k Keeper) GetExistingStakingDelegations(ctx sdk.Context, delAddr sdk.AccAddress) ([]types.ValidatorPreference, error)
- func (k Keeper) GetValSetStruct(validator types.ValidatorPreference, amountFromShares sdk.Dec) (valStruct valSet, valStructZeroAmt valSet)
- func (k Keeper) GetValidatorInfo(ctx sdk.Context, existingValAddr string) (sdk.ValAddress, stakingtypes.Validator, error)
- func (k Keeper) GetValidatorSetPreference(ctx sdk.Context, delegator string) (types.ValidatorSetPreferences, bool)
- func (k Keeper) IsPreferenceValid(ctx sdk.Context, preferences []types.ValidatorPreference) ([]types.ValidatorPreference, error)
- func (k Keeper) IsValidatorSetEqual(newPreferences, existingPreferences []types.ValidatorPreference) bool
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) PreformRedelegation(ctx sdk.Context, delegator sdk.AccAddress, ...) error
- func (k Keeper) SetValidatorSetPreference(ctx sdk.Context, delegator string, preferences []types.ValidatorPreference) (types.ValidatorSetPreferences, error)
- func (k Keeper) SetValidatorSetPreferences(ctx sdk.Context, delegator string, validators types.ValidatorSetPreferences)
- func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string, coin sdk.Coin) error
- func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delegatorAddr string) error
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 Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, stakingKeeper types.StakingInterface, distirbutionKeeper types.DistributionKeeper, lockupKeeper types.LockupKeeper, ) Keeper
func (Keeper) CheckUndelegateTotalAmount ¶
func (k Keeper) CheckUndelegateTotalAmount(tokenAmt sdk.Dec, existingSet []types.ValidatorPreference) error
CheckUndelegateTotalAmount checks if the tokenAmount equals the total amount calculated from valset weights.
func (Keeper) DelegateToValidatorSet ¶
DelegateToValidatorSet delegates to a delegators existing validator-set. If the valset does not exist, it delegates to existing staking position. For ex: delegate 10perco with validator-set {ValA -> 0.5, ValB -> 0.3, ValC -> 0.2} our delegate logic would attempt to delegate 5perco to A , 2perco to B, 3perco to C nolint: staticcheck
func (Keeper) ForceUnlockBondedPerco ¶
func (k Keeper) ForceUnlockBondedPerco(ctx sdk.Context, lockID uint64, delegatorAddr string) (sdk.Coin, error)
ForceUnlockBondedPerco allows breaking of a bonded lockup (by ID) of perco, of length <= 2 weeks. We want to later have perco incentives get auto-staked, we want people w/ no staking positions to get their perco auto-locked. This function takes all that perco and stakes according to your current validator set preference. (Note: Noting that there is an implicit valset preference if you've already staked) CONTRACT: This method should **never** be used alone.
func (Keeper) GetDelegationPreferences ¶
func (k Keeper) GetDelegationPreferences(ctx sdk.Context, delegator string) (types.ValidatorSetPreferences, error)
GetDelegationPreferences checks if valset position exists, if it does return that else return existing delegation that's not valset.
func (Keeper) GetExistingStakingDelegations ¶
func (k Keeper) GetExistingStakingDelegations(ctx sdk.Context, delAddr sdk.AccAddress) ([]types.ValidatorPreference, error)
GetExistingStakingDelegations returns the existing delegation that's not valset. This function also formats the output into ValidatorSetPreference struct {valAddr, weight}. The weight is calculated based on (valDelegation / totalDelegations) for each validator. This method erros when given address does not have any existing delegations.
func (Keeper) GetValSetStruct ¶
func (k Keeper) GetValSetStruct(validator types.ValidatorPreference, amountFromShares sdk.Dec) (valStruct valSet, valStructZeroAmt valSet)
GetValSetStruct initializes valSet struct with valAddr, weight and amount. It also creates an extra struct with zero amount, that can be appended to newValSet that will be created. We do this to make sure the struct array length is the same to calculate their difference.
func (Keeper) GetValidatorInfo ¶
func (k Keeper) GetValidatorInfo(ctx sdk.Context, existingValAddr string) (sdk.ValAddress, stakingtypes.Validator, error)
func (Keeper) GetValidatorSetPreference ¶
func (k Keeper) GetValidatorSetPreference(ctx sdk.Context, delegator string) (types.ValidatorSetPreferences, bool)
GetValidatorSetPreference returns the existing valset position for a delegator.
func (Keeper) IsPreferenceValid ¶
func (k Keeper) IsPreferenceValid(ctx sdk.Context, preferences []types.ValidatorPreference) ([]types.ValidatorPreference, error)
IsPreferenceValid loops through the validator preferences and checks its existence and validity.
func (Keeper) IsValidatorSetEqual ¶
func (k Keeper) IsValidatorSetEqual(newPreferences, existingPreferences []types.ValidatorPreference) bool
IsValidatorSetEqual returns true if the two preferences are equal.
func (Keeper) PreformRedelegation ¶
func (k Keeper) PreformRedelegation(ctx sdk.Context, delegator sdk.AccAddress, existingSet []types.ValidatorPreference, newSet []types.ValidatorPreference) error
The redelegation command allows delegators to instantly switch validators. Once the unbonding period has passed, the redelegation is automatically completed in the EndBlocker. A redelegation object is created every time a redelegation occurs. To prevent "redelegation hopping" where delegatorA can redelegate between many validators over small period of time, redelegations may not occur under the following situation: 1. delegatorA attempts to redelegate to the same validator
- valA --redelegate--> valB
- valB --redelegate--> valB (ERROR: Self redelegation is not allowed)
2. delegatorA attempts to redelegate to an immature redelegation validator
- valA --redelegate--> valB
- valB --redelegate--> valA (ERROR: Redelegation to ValB is already in progress)
3. delegatorA attempts to redelegate while unbonding is in progress
- unbond (10perco) from valA
- valA --redelegate--> valB (ERROR: new redelegation while unbonding is in progress)
func (Keeper) SetValidatorSetPreference ¶
func (k Keeper) SetValidatorSetPreference(ctx sdk.Context, delegator string, preferences []types.ValidatorPreference) (types.ValidatorSetPreferences, error)
SetValidatorSetPreference creates or updates delegators validator set. Errors when the given preference is the same as the existing preference in state.
func (Keeper) SetValidatorSetPreferences ¶
func (k Keeper) SetValidatorSetPreferences(ctx sdk.Context, delegator string, validators types.ValidatorSetPreferences)
SetValidatorSetPreferences sets a new valset position for a delegator in modules state.
func (Keeper) UndelegateFromValidatorSet ¶
func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string, coin sdk.Coin) error
UndelegateFromValidatorSet undelegates {coin} amount from the validator set. If the valset does not exist, it undelegates from existing staking position. For ex: userA has staked 10tokens with weight {Val->0.5, ValB->0.3, ValC->0.2} undelegate 6perco with validator-set {ValA -> 0.5, ValB -> 0.3, ValC -> 0.2} our undelegate logic would attempt to undelegate 3perco from A, 1.8perco from B, 1.2perco from C nolint: staticcheck
func (Keeper) WithdrawDelegationRewards ¶
WithdrawDelegationRewards withdraws all the delegation rewards from the validator in the val-set. If the valset does not exist, it withdraws from existing staking position. Delegation reward is collected by the validator and in doing so, they can charge commission to the delegators. Rewards are calculated per period, and is updated each time validator delegation changes. For ex: when a delegator receives new delgation the rewards can be calculated by taking (total rewards before new delegation - the total current rewards).
Directories ¶
Path | Synopsis |
---|---|
queryproto
Package queryproto is a reverse proxy.
|
Package queryproto is a reverse proxy. |