keeper

package
v3.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const PROVIDERS_NUM_GAS_REFUND = 50

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.

Types

type Hooks

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

Wrapper struct

func (Hooks) AfterDelegationModified

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

create new delegation period record add description

func (Hooks) AfterUnbondingInitiated

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

func (Hooks) AfterValidatorBeginUnbonding

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

func (Hooks) AfterValidatorBonded

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

func (Hooks) AfterValidatorCreated

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

initialize validator distribution record

func (Hooks) AfterValidatorRemoved

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

AfterValidatorRemoved performs clean up after a validator is removed

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

increment period

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

withdraw delegation rewards (which also increments period)

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,
	memKey storetypes.StoreKey,
	ps paramtypes.Subspace,
	bankKeeper types.BankKeeper,
	stakingKeeper types.StakingKeeper,
	accountKeeper types.AccountKeeper,
	epochstorageKeeper types.EpochstorageKeeper,
	specKeeper types.SpecKeeper,
	fixationStoreKeeper types.FixationStoreKeeper,
) *Keeper

func (Keeper) BalanceDelegator

func (k Keeper) BalanceDelegator(ctx sdk.Context, delegator sdk.AccAddress) (int, error)

func (Keeper) BalanceValidatorsDelegators

func (k Keeper) BalanceValidatorsDelegators(ctx sdk.Context, validator string)

func (Keeper) BeginBlock

func (k Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)

func (Keeper) CalcDelegatorReward

func (k Keeper) CalcDelegatorReward(ctx sdk.Context, delegatorsReward sdk.Coins, totalDelegations math.Int, delegation types.Delegation) sdk.Coins

CalcDelegatorReward calculates a single delegator reward according to its delegation delegatorReward = delegatorsReward * (delegatorStake / totalDelegations) = (delegatorsReward * delegatorStake) / totalDelegations

func (Keeper) CalcRewards

func (k Keeper) CalcRewards(ctx sdk.Context, stakeEntry epochstoragetypes.StakeEntry, totalReward sdk.Coins, delegations []types.Delegation) (providerReward sdk.Coins, delegatorsReward sdk.Coins)

CalcRewards calculates the provider reward and the total reward for delegators providerReward = totalReward * ((effectiveDelegations*commission + providerStake) / effectiveStake) delegatorsReward = totalReward - providerReward

func (Keeper) ChangeDelegationTimestampForTesting

func (k Keeper) ChangeDelegationTimestampForTesting(ctx sdk.Context, index string, block uint64, timestamp int64) error

func (Keeper) ClaimRewards

func (k Keeper) ClaimRewards(ctx sdk.Context, delegator string, provider string) (sdk.Coins, error)

func (Keeper) DelegateFull

func (k Keeper) DelegateFull(ctx sdk.Context, delegator string, validator string, provider string, chainID string, amount sdk.Coin) error

DelegateFull uses staking module for to delegate with hooks

func (Keeper) DelegatorProviders

func (Keeper) DelegatorRewards

func (Keeper) DelegatorRewardsList

func (k Keeper) DelegatorRewardsList(goCtx context.Context, req *types.QueryDelegatorRewardsRequest) (res *types.QueryDelegatorRewardsResponse, err error)

func (Keeper) ExportDelegations

func (k Keeper) ExportDelegations(ctx sdk.Context) fixationtypes.GenesisState

ExportDelegations exports dualstaking delegations data (for genesis)

func (Keeper) ExportDelegators

func (k Keeper) ExportDelegators(ctx sdk.Context) fixationtypes.GenesisState

ExportDelegators exports dualstaking delegators data (for genesis)

func (Keeper) GetAllDelegatorReward

func (k Keeper) GetAllDelegatorReward(ctx sdk.Context) (list []types.DelegatorReward)

GetAllDelegatorReward returns all DelegatorReward

func (Keeper) GetAllProviderDelegatorDelegations

func (k Keeper) GetAllProviderDelegatorDelegations(ctx sdk.Context, delegator, provider string, epoch uint64) []types.Delegation

func (Keeper) GetDelegation

func (k Keeper) GetDelegation(ctx sdk.Context, delegator, provider, chainID string, epoch uint64) (types.Delegation, bool)

func (Keeper) GetDelegatorProviders

func (k Keeper) GetDelegatorProviders(ctx sdk.Context, delegator string, epoch uint64) (providers []string, err error)

GetDelegatorProviders gets all the providers the delegator is delegated to

func (Keeper) GetDelegatorReward

func (k Keeper) GetDelegatorReward(
	ctx sdk.Context,
	index string,
) (val types.DelegatorReward, found bool)

GetDelegatorReward returns a DelegatorReward from its index

func (Keeper) GetDisableDualstakingHook

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

GetDisableDualstakingHook returns disableDualstakingHook

func (Keeper) GetParams

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

GetParams get all parameters as types.Params

func (Keeper) GetProviderDelegators

func (k Keeper) GetProviderDelegators(ctx sdk.Context, provider string, epoch uint64) ([]types.Delegation, error)

func (Keeper) GetSlashedValidators

func (k Keeper) GetSlashedValidators(ctx sdk.Context) []string

GetDisableDualstakingHook returns disableDualstakingHook

func (Keeper) HandleSlashedValidators

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

balance delegators dualstaking after potential validators slashing

func (Keeper) Hooks

func (k Keeper) Hooks() *Hooks

Create new dualstaking hooks

func (Keeper) InitDelegations

func (k Keeper) InitDelegations(ctx sdk.Context, data fixationtypes.GenesisState)

InitDelegations imports dualstaking delegations data (from genesis)

func (Keeper) InitDelegators

func (k Keeper) InitDelegators(ctx sdk.Context, data fixationtypes.GenesisState)

InitDelegators imports dualstaking delegators data (from genesis)

func (Keeper) Logger

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

func (Keeper) MinSelfDelegation

func (k Keeper) MinSelfDelegation(ctx sdk.Context) (res sdk.Coin)

MinSelfDelegation returns the MinSelfDelegation param

func (Keeper) Params

func (Keeper) PayContributors

func (k Keeper) PayContributors(ctx sdk.Context, senderModule string, contributorAddresses []sdk.AccAddress, contributorReward sdk.Coins, specId string) error

func (Keeper) ProviderDelegators

func (Keeper) Redelegate

func (k Keeper) Redelegate(ctx sdk.Context, delegator, from, to, fromChainID, toChainID string, amount sdk.Coin) error

Redelegate lets a delegator transfer its delegation between providers, but without the funds being subject to unstakeHoldBlocks witholding period. (effective on next epoch)

func (Keeper) RemoveDelegatorReward

func (k Keeper) RemoveDelegatorReward(
	ctx sdk.Context,
	index string,
)

RemoveDelegatorReward removes a DelegatorReward from the store

func (Keeper) RewardProvidersAndDelegators

func (k Keeper) RewardProvidersAndDelegators(ctx sdk.Context, provider string, chainID string, totalReward sdk.Coins, senderModule string, calcOnlyProvider bool, calcOnlyDelegators bool, calcOnlyContributor bool) (providerReward sdk.Coins, claimableRewards sdk.Coins, err error)

RewardProvidersAndDelegators is the main function handling provider rewards with delegations it returns the provider reward amount and updates the delegatorReward map with the reward portion for each delegator

func (Keeper) SetDelegatorReward

func (k Keeper) SetDelegatorReward(ctx sdk.Context, delegatorReward types.DelegatorReward)

SetDelegatorReward set a specific DelegatorReward in the store from its index

func (Keeper) SetDisableDualstakingHook

func (k Keeper) SetDisableDualstakingHook(ctx sdk.Context, val bool)

SetDisableDualstakingHook set disableDualstakingHook in the store

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) SetSlashedValidators

func (k Keeper) SetSlashedValidators(ctx sdk.Context, val []string)

SetDisableDualstakingHook set disableDualstakingHook in the store

func (Keeper) UnbondFull

func (k Keeper) UnbondFull(ctx sdk.Context, delegator string, validator string, provider string, chainID string, amount sdk.Coin, unstake bool) error

UnbondFul uses staking module for to unbond with hooks

func (Keeper) UnbondUniformProviders

func (k Keeper) UnbondUniformProviders(ctx sdk.Context, delegator string, amount sdk.Coin) error

func (Keeper) VerifyDelegatorBalance

func (k Keeper) VerifyDelegatorBalance(ctx sdk.Context, delAddr sdk.AccAddress) (math.Int, int, error)

returns the difference between validators delegations and provider delegation (validators-providers)

type Migrator

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

func NewMigrator

func NewMigrator(keeper Keeper) Migrator

func (Migrator) GetAllDelegatorRewardV4

func (m Migrator) GetAllDelegatorRewardV4(ctx sdk.Context) (list []dualstakingv4.DelegatorRewardv4)

func (Migrator) MigrateVersion4To5

func (m Migrator) MigrateVersion4To5(ctx sdk.Context) error

MigrateVersion4To5 change the DelegatorReward object amount's field from sdk.Coin to sdk.Coins

Jump to

Keyboard shortcuts

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