keeper

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

func NewQueryServerImpl

func NewQueryServerImpl(keeper Keeper) types.QueryServer

Types

type Hooks

type Hooks struct {
	// contains filtered or unexported fields
}

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(ctx sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) AfterUnbondingInitiated

func (h Hooks) AfterUnbondingInitiated(_ sdk.Context, _ uint64) error

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(ctx sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorCreated

func (h Hooks) AfterValidatorCreated(_ sdk.Context, _ sdk.ValAddress) error

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorSlashed

func (h Hooks) AfterValidatorSlashed(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress, _ sdk.Dec)

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) error

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey storetypes.StoreKey,
	ps paramtypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	stakingKeeper types.StakingKeeper,
	distributionKeeper types.DistributionKeeper,
) Keeper

func (Keeper) AddAssetsToRewardPool

func (k Keeper) AddAssetsToRewardPool(ctx sdk.Context, from sdk.AccAddress, val types.AllianceValidator, coins sdk.Coins) error

AddAssetsToRewardPool increments a reward history array. A reward history stores the average reward per token/reward_weight. To calculate the number of rewards claimable, take reward_history * alliance_token_amount * reward_weight

func (Keeper) BlockValidatorUpdates

func (k Keeper) BlockValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate

func (Keeper) CalculateDelegationRewards

func (k Keeper) CalculateDelegationRewards(ctx sdk.Context, delegation types.Delegation, val types.AllianceValidator, asset types.AllianceAsset) (sdk.Coins, types.RewardHistories, error)

CalculateDelegationRewards calculates the rewards that can be claimed for a delegation It takes past reward_rate changes into account by using the RewardRateChangeSnapshot entry

func (Keeper) ClaimDelegationRewards

func (k Keeper) ClaimDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, val types.AllianceValidator, denom string) (sdk.Coins, error)

ClaimDelegationRewards claims delegation rewards and transfers to the delegator account This method updates the delegation so you will need to re-query an updated version from the database

func (Keeper) ClaimValidatorRewards

func (k Keeper) ClaimValidatorRewards(ctx sdk.Context, val types.AllianceValidator) (sdk.Coins, error)

ClaimValidatorRewards claims the validator rewards (minus commission) from the distribution module This should be called everytime validator delegation changes (e.g. [un/re]delegation) to update the reward claim history

func (Keeper) ClearDustDelegation

func (k Keeper) ClearDustDelegation(ctx sdk.Context, delAddr sdk.AccAddress, validator types.AllianceValidator, asset types.AllianceAsset)

func (Keeper) CompleteRedelegations

func (k Keeper) CompleteRedelegations(ctx sdk.Context) int

CompleteRedelegations Go through the re-delegations queue and remove all that have passed the completion time

func (Keeper) CompleteUndelegations

func (k Keeper) CompleteUndelegations(ctx sdk.Context) error

CompleteUndelegations Go through all queued undelegations and send the tokens to the delegators

func (Keeper) ComputeValidatorConsensusPower

func (k Keeper) ComputeValidatorConsensusPower(ctx sdk.Context) []abci.ValidatorUpdate

func (Keeper) ConsumeAssetRebalanceEvent

func (k Keeper) ConsumeAssetRebalanceEvent(ctx sdk.Context) bool

func (Keeper) CreateAlliance

func (k Keeper) CreateAlliance(ctx context.Context, req *types.MsgCreateAllianceProposal) error

func (Keeper) CreateInitialRewardWeightChangeSnapshot

func (k Keeper) CreateInitialRewardWeightChangeSnapshot(ctx sdk.Context, denom string, valAddr sdk.ValAddress, info types.AllianceValidatorInfo)

func (Keeper) DeductAssetsHook

func (k Keeper) DeductAssetsHook(ctx sdk.Context, assets []*types.AllianceAsset) (sdk.Coins, error)

DeductAssetsHook is called periodically to deduct from an alliance asset (calculated by take_rate). The interval in which assets are deducted is set in module params

func (Keeper) DeductAssetsWithTakeRate

func (k Keeper) DeductAssetsWithTakeRate(ctx sdk.Context, lastClaim time.Time, assets []*types.AllianceAsset) (sdk.Coins, error)

DeductAssetsWithTakeRate Deducts an alliance asset using the take_rate The deducted asset is distributed to the fee_collector module account to be redistributed to stakers

func (Keeper) Delegate

func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, validator types.AllianceValidator, coin sdk.Coin) (*sdk.Dec, error)

Delegate is the entry point for delegators to delegate alliance assets to validators Voting power is not immediately accured to the delegators in this method and a flag is set to rebalance voting power at the end of the block. This improves performance since rebalancing only needs to happen once regardless of how many delegations are made in a single block

func (Keeper) DeleteAlliance

func (k Keeper) DeleteAlliance(ctx context.Context, req *types.MsgDeleteAllianceProposal) error

func (Keeper) DeleteAsset

func (k Keeper) DeleteAsset(ctx sdk.Context, asset types.AllianceAsset) error

func (Keeper) DeleteRedelegation

func (k Keeper) DeleteRedelegation(ctx sdk.Context, redel types.Redelegation, completion time.Time)

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

func (Keeper) GetAllAllianceValidatorInfo

func (k Keeper) GetAllAllianceValidatorInfo(ctx sdk.Context) []types.AllianceValidatorInfo

func (Keeper) GetAllAssets

func (k Keeper) GetAllAssets(ctx sdk.Context) (assets []*types.AllianceAsset)

func (Keeper) GetAllianceBondedAmount

func (k Keeper) GetAllianceBondedAmount(ctx sdk.Context, delegator sdk.AccAddress) math.Int

GetAllianceBondedAmount returns the total amount of bonded native tokens that are not in the unbonding pool

func (Keeper) GetAllianceValidator

func (k Keeper) GetAllianceValidator(ctx sdk.Context, valAddr sdk.ValAddress) (types.AllianceValidator, error)

func (Keeper) GetAllianceValidatorInfo

func (k Keeper) GetAllianceValidatorInfo(ctx sdk.Context, valAddr sdk.ValAddress) (types.AllianceValidatorInfo, bool)

func (Keeper) GetAssetByDenom

func (k Keeper) GetAssetByDenom(ctx sdk.Context, denom string) (asset types.AllianceAsset, found bool)

func (Keeper) GetDelegation

func (k Keeper) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, denom string) (d types.Delegation, found bool)

func (Keeper) HasRedelegation

func (k Keeper) HasRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, dstVal sdk.ValAddress, denom string) bool

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, g *types.GenesisState) []abci.ValidatorUpdate

func (Keeper) InitializeAllianceAssets

func (k Keeper) InitializeAllianceAssets(ctx sdk.Context, assets []*types.AllianceAsset)

InitializeAllianceAssets this hooks adds a reward change snapshot when time > asset.RewardStartTime A reward change snapshot of 0 weight is added to signify that the asset did not accrue any rewards during the warm up period so we can calculate the correct rewards when claiming

func (Keeper) IterateAllWeightChangeSnapshot

func (k Keeper) IterateAllWeightChangeSnapshot(ctx sdk.Context, cb func(denom string, valAddr sdk.ValAddress, lastClaimHeight uint64, snapshot types.RewardWeightChangeSnapshot) (stop bool))

func (Keeper) IterateAllianceValidatorInfo

func (k Keeper) IterateAllianceValidatorInfo(ctx sdk.Context, cb func(valAddr sdk.ValAddress, info types.AllianceValidatorInfo) (stop bool))

func (Keeper) IterateDelegations

func (k Keeper) IterateDelegations(ctx sdk.Context, cb func(d types.Delegation) (stop bool))

func (Keeper) IterateRedelegations

func (k Keeper) IterateRedelegations(ctx sdk.Context, cb func(redelegation types.Redelegation, completionTime time.Time) (stop bool))

func (Keeper) IterateRedelegationsByDelegator

func (k Keeper) IterateRedelegationsByDelegator(ctx sdk.Context, delAddr sdk.AccAddress) sdk.Iterator

func (Keeper) IterateRedelegationsBySrcValidator

func (k Keeper) IterateRedelegationsBySrcValidator(ctx sdk.Context, srcValAddr sdk.ValAddress) sdk.Iterator

func (Keeper) IterateUndelegations

func (k Keeper) IterateUndelegations(ctx sdk.Context, cb func(undelegation types.QueuedUndelegation, completionTime time.Time) (stop bool))

func (Keeper) IterateUndelegationsByCompletionTime

func (k Keeper) IterateUndelegationsByCompletionTime(ctx sdk.Context, completionTime time.Time) sdk.Iterator

func (Keeper) IterateUndelegationsBySrcValidator

func (k Keeper) IterateUndelegationsBySrcValidator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Iterator

func (Keeper) IterateWeightChangeSnapshot

func (k Keeper) IterateWeightChangeSnapshot(ctx sdk.Context, denom string, valAddr sdk.ValAddress, lastClaimHeight uint64) store.Iterator

func (Keeper) LastRewardClaimTime

func (k Keeper) LastRewardClaimTime(ctx sdk.Context) (res time.Time)

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) Params

func (k Keeper) Params(ctx sdk.Context) (res types.Params)

func (Keeper) QueueAssetRebalanceEvent

func (k Keeper) QueueAssetRebalanceEvent(ctx sdk.Context)

func (Keeper) RebalanceBondTokenWeights

func (k Keeper) RebalanceBondTokenWeights(ctx sdk.Context, assets []*types.AllianceAsset) (updates []abci.ValidatorUpdate, err error)

RebalanceBondTokenWeights uses asset reward weights to calculate the expected amount of staking token that has to be minted / burned to maintain the right ratio It iterates all validators and calculates the expected staked amount based on delegations and delegates/undelegates the difference.

func (Keeper) RebalanceHook

func (k Keeper) RebalanceHook(ctx sdk.Context, assets []*types.AllianceAsset) ([]abci.ValidatorUpdate, error)

func (Keeper) Redelegate

func (k Keeper) Redelegate(ctx sdk.Context, delAddr sdk.AccAddress, srcVal types.AllianceValidator, dstVal types.AllianceValidator, coin sdk.Coin) (*time.Time, error)

Redelegate from one validator to another

func (Keeper) ResetAssetAndValidators

func (k Keeper) ResetAssetAndValidators(ctx sdk.Context, asset types.AllianceAsset)

ResetAssetAndValidators When an asset has no more tokens being delegated, go through all validators and set validator shares to zero

func (Keeper) RewardClaimInterval

func (k Keeper) RewardClaimInterval(ctx sdk.Context) (res time.Duration)

func (Keeper) RewardDelayTime

func (k Keeper) RewardDelayTime(ctx sdk.Context) (res time.Duration)

func (Keeper) RewardWeightChangeHook

func (k Keeper) RewardWeightChangeHook(ctx sdk.Context, assets []*types.AllianceAsset) error

func (Keeper) SetAsset

func (k Keeper) SetAsset(ctx sdk.Context, asset types.AllianceAsset)

SetAsset Does not check if the asset already exists and overwrites it

func (Keeper) SetDelegation

func (k Keeper) SetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, denom string, del types.Delegation)

func (Keeper) SetLastRewardClaimTime

func (k Keeper) SetLastRewardClaimTime(ctx sdk.Context, lastTime time.Time)

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

func (Keeper) SetRewardWeightChangeSnapshot

func (k Keeper) SetRewardWeightChangeSnapshot(ctx sdk.Context, asset types.AllianceAsset, val types.AllianceValidator)

func (Keeper) SetValidator

func (k Keeper) SetValidator(ctx sdk.Context, val types.AllianceValidator)

func (Keeper) SetValidatorInfo

func (k Keeper) SetValidatorInfo(ctx sdk.Context, valAddr sdk.ValAddress, val types.AllianceValidatorInfo)

func (Keeper) SlashValidator

func (k Keeper) SlashValidator(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error

SlashValidator works by reducing the amount of validator shares for all alliance assets by a `fraction` This effectively reallocates tokens from slashed validators to good validators On top of slashing currently bonded delegations, we also slash re-delegations and un-delegations that are still in the progress of unbonding

func (Keeper) StakingHooks

func (k Keeper) StakingHooks() Hooks

func (Keeper) StoreKey

func (k Keeper) StoreKey() storetypes.StoreKey

func (Keeper) TakeRateClaimInterval

func (k Keeper) TakeRateClaimInterval(ctx sdk.Context) (res time.Duration)

func (Keeper) Undelegate

func (k Keeper) Undelegate(ctx sdk.Context, delAddr sdk.AccAddress, validator types.AllianceValidator, coin sdk.Coin) (*time.Time, error)

Undelegate from a validator Staked tokens are only distributed to the delegator after the unbonding period

func (Keeper) UpdateAlliance

func (k Keeper) UpdateAlliance(ctx context.Context, req *types.MsgUpdateAllianceProposal) error

func (Keeper) UpdateAllianceAsset

func (k Keeper) UpdateAllianceAsset(ctx sdk.Context, newAsset types.AllianceAsset) error

UpdateAllianceAsset updates the alliance asset with new params Also saves a snapshot whenever rewards weight changes to make sure delegation reward calculation has reference to historical reward rates

func (Keeper) ValidateDelegatedAmount

func (k Keeper) ValidateDelegatedAmount(delegation types.Delegation, coin sdk.Coin, val types.AllianceValidator, asset types.AllianceAsset) (shares sdk.Dec, err error)

ValidateDelegatedAmount returns the amount of shares for a given coin that is staked Returns the number of shares that represents the amount of staked tokens that was requested

type MsgServer

type MsgServer struct {
	Keeper
}

func (MsgServer) Delegate

func (MsgServer) Redelegate

func (MsgServer) Undelegate

type QueryServer

type QueryServer struct {
	Keeper
}

func (QueryServer) Alliance

func (QueryServer) IBCAlliance

func (QueryServer) Params

type RewardsKeeper

type RewardsKeeper interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL