Documentation ¶
Index ¶
- func NewMsgServerImpl(keeper *Keeper) types.MsgServer
- type Keeper
- func (k Keeper) DelegateToValidatorSet(ctx sdk.Context, delegatorAddr string, coin sdk.Coin) error
- func (k Keeper) ForceUnlockBondedOsmo(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) GetValSetPreferencesWithDelegations(ctx sdk.Context, delegator string) (types.ValidatorSetPreferences, error)
- func (k Keeper) GetValSetStruct(validator types.ValidatorPreference, amountFromShares osmomath.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) SetValidatorSetPreferences(ctx sdk.Context, delegator string, validators types.ValidatorSetPreferences)
- func (k Keeper) UndelegateFromRebalancedValidatorSet(ctx sdk.Context, delegatorAddr string, undelegation sdk.Coin) error
- func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string, undelegation sdk.Coin) error
- func (k Keeper) ValidateValidatorSetPreference(ctx sdk.Context, delegator string, preferences []types.ValidatorPreference) (types.ValidatorSetPreferences, error)
- func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delegatorAddr string) error
- type ValRatio
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 storetypes.StoreKey, paramSpace paramtypes.Subspace, stakingKeeper types.StakingInterface, distirbutionKeeper types.DistributionKeeper, lockupKeeper types.LockupKeeper, ) Keeper
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 10osmo with validator-set {ValA -> 0.5, ValB -> 0.3, ValC -> 0.2} our delegate logic would attempt to delegate 5osmo to A , 2osmo to B, 3osmo to C nolint: staticcheck
func (Keeper) ForceUnlockBondedOsmo ¶
func (k Keeper) ForceUnlockBondedOsmo(ctx sdk.Context, lockID uint64, delegatorAddr string) (sdk.Coin, error)
ForceUnlockBondedOsmo allows breaking of a bonded lockup (by ID) of osmo, of length <= 2 weeks. We want to later have osmo incentives get auto-staked, we want people w/ no staking positions to get their osmo auto-locked. This function takes all that osmo 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) GetValSetPreferencesWithDelegations ¶
func (k Keeper) GetValSetPreferencesWithDelegations(ctx sdk.Context, delegator string) (types.ValidatorSetPreferences, error)
GetValSetPreferencesWithDelegations fetches the delegator's validator set preferences considering their existing delegations. -If validator set preference does not exist and there are no existing delegations, it returns an error. -If validator set preference exists and there are no existing delegations, it returns the existing preference. -If there is any existing delegation: calculates the delegator's shares in each delegation as a ratio of the total shares and returns it as part of ValidatorSetPreferences.
func (Keeper) GetValSetStruct ¶
func (k Keeper) GetValSetStruct(validator types.ValidatorPreference, amountFromShares osmomath.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 (10osmo) from valA
- valA --redelegate--> valB (ERROR: new redelegation while unbonding is in progress)
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) UndelegateFromRebalancedValidatorSet ¶
func (k Keeper) UndelegateFromRebalancedValidatorSet(ctx sdk.Context, delegatorAddr string, undelegation sdk.Coin) error
UndelegateFromRebalancedValidatorSet undelegates a specified amount of tokens from a delegator's existing validator set, but takes into consideration the user's existing delegations to the validators in the set. The method first fetches the delegator's validator set preferences, checks their existing delegations, and returns a set with modified weights that consider their existing delegations. If there is no existing delegation, it returns an error. The method then computes the total amount delegated and the amount to undelegate for each validator under this newly calculated valset-ratio set.
If the undelegation amount is greater than the total delegated amount, it returns an error. The validators are then sorted in descending order of VRatio. The method ensures that the largest VRatio is under 1. If it is greater than 1, it returns an error. Finally, the method undelegates the target amount from each validator. If an error occurs during the undelegation process, it is returned.
func (Keeper) UndelegateFromValidatorSet ¶
func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string, undelegation sdk.Coin) error
UndelegateFromValidatorSet undelegates {coin} amount from the validator set. If the valset does not exist, it undelegates from existing staking position. Ex: user A has staked 10tokens with weight {Val->0.5, ValB->0.3, ValC->0.2} undelegate 6osmo with validator-set {ValA -> 0.5, ValB -> 0.3, ValC -> 0.2} our undelegate logic would attempt to undelegate 3osmo from A, 1.8osmo from B, 1.2osmo from C Truncation ensures we do not undelegate more than the user has staked with the validator set. NOTE: check README.md for more verbose description of the algorithm. TODO: This is currently disabled. Properly implement for vratio > 1 to hit steps 5-7, then re-enable https://github.com/osmosis-labs/osmosis/issues/6686
func (Keeper) ValidateValidatorSetPreference ¶
func (k Keeper) ValidateValidatorSetPreference(ctx sdk.Context, delegator string, preferences []types.ValidatorPreference) (types.ValidatorSetPreferences, error)
ValidateValidatorSetPreference derives given validator set. It validates the list and formats the inputs such as rounding. Errors when the given preference is the same as the existing preference in state. NOTE: this function does not add valset to the state
func (Keeper) WithdrawDelegationRewards ¶
WithdrawDelegationRewards withdraws all the delegation rewards from all validators the user is delegated to, disregarding 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 delegation 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. |