keeper

package
v0.0.0-...-3a28d7b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

Types

type EquivalentNativeCoinMultiplier

type EquivalentNativeCoinMultiplier func(ctx sdk.Context, denom string) (sdk.Dec, error)

TODO Temporarily use this method to feed prices !!!

type Hooks

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

func (Hooks) AfterDelegationModified

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

AfterDelegationModified implements types.StakingHooks

func (Hooks) AfterEpochEnd

func (h Hooks) AfterEpochEnd(ctx sdk.Context, _ string, _ int64)

func (Hooks) AfterUnbondingInitiated

func (Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error

AfterUnbondingInitiated implements types.StakingHooks.

func (Hooks) AfterValidatorBeginUnbonding

func (Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error

AfterValidatorBeginUnbonding implements types.StakingHooks

func (Hooks) AfterValidatorBonded

func (Hooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error

AfterValidatorBonded implements types.StakingHooks

func (Hooks) AfterValidatorCreated

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

AfterValidatorCreated implements types.StakingHooks

func (Hooks) AfterValidatorRemoved

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

AfterValidatorRemoved implements types.StakingHooks

func (Hooks) BeforeDelegationCreated

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

BeforeDelegationCreated implements types.StakingHooks

func (Hooks) BeforeDelegationRemoved

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

BeforeDelegationRemoved implements types.StakingHooks

func (Hooks) BeforeDelegationSharesModified

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

BeforeDelegationSharesModified implements types.StakingHooks

func (Hooks) BeforeEpochStart

func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)

BeforeEpochStart implements types.EpochHooks

func (Hooks) BeforeValidatorModified

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

BeforeValidatorModified implements types.StakingHooks

func (Hooks) BeforeValidatorSlashed

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

BeforeValidatorSlashed implements types.StakingHooks

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	storeKey storetypes.StoreKey,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	epochKeeper types.EpochKeeper,
	stakingKeeper types.StakingKeeper,
	distributionKeeper types.DistributionKeeper,
) Keeper

func (Keeper) AddMTStakingDenom

func (k Keeper) AddMTStakingDenom(ctx sdk.Context, denom string) bool

func (Keeper) CalculateEquivalentNativeCoin

func (k Keeper) CalculateEquivalentNativeCoin(ctx sdk.Context, coin sdk.Coin) (targetCoin sdk.Coin, err error)

func (Keeper) CollectAgentsReward

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

CollectAgentsReward defines a method for withdraw staking reward for all agents. TODO let user call it.

func (Keeper) CompleteUnbonding

func (k Keeper) CompleteUnbonding(ctx sdk.Context, delegatorAccAddr, agentAccAddr sdk.AccAddress) (sdk.Coins, error)

func (Keeper) DecreaseDelegatorAgentShares

func (k Keeper) DecreaseDelegatorAgentShares(ctx sdk.Context, shares math.Int, agentAddress, delegator sdk.AccAddress) error

func (Keeper) DequeueAllMatureUBDQueue

func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, curTime time.Time) (matureUnbonds []types.DAPair)

func (Keeper) EndBlocker

func (k Keeper) EndBlocker(ctx sdk.Context) ([]abci.ValidatorUpdate, error)

func (Keeper) GenerateAccount

func (k Keeper) GenerateAccount(ctx sdk.Context, prefix, suffix string) *authtypes.ModuleAccount

func (Keeper) GetAllAgent

func (k Keeper) GetAllAgent(ctx sdk.Context) []types.MTStakingAgent

func (Keeper) GetAllAgentsByVal

func (k Keeper) GetAllAgentsByVal(ctx sdk.Context, valAddr sdk.ValAddress) []types.MTStakingAgent

func (Keeper) GetDelegation

func (k Keeper) GetDelegation(ctx sdk.Context, agentAddress, delegator sdk.AccAddress) (*types.MTStakingDelegation, bool)

func (Keeper) GetDelegatorAgentShares

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

func (Keeper) GetDelegatorWithdrawRewardHeight

func (k Keeper) GetDelegatorWithdrawRewardHeight(ctx sdk.Context, delegatorAccAddr, agentAccAddr sdk.AccAddress) (int64, bool)

func (Keeper) GetEquivalentNativeCoinMultiplier

func (k Keeper) GetEquivalentNativeCoinMultiplier(ctx sdk.Context, denom string) (multiplier sdk.Dec, found bool)

func (Keeper) GetMTStakingAgent

func (k Keeper) GetMTStakingAgent(ctx sdk.Context, denom string, valAddr sdk.ValAddress) (*types.MTStakingAgent, bool)

func (Keeper) GetMTStakingAgentAddressByDenomAndVal

func (k Keeper) GetMTStakingAgentAddressByDenomAndVal(ctx sdk.Context, denom string, valAddr sdk.ValAddress) ([]byte, bool)

func (Keeper) GetMTStakingAgentByAddress

func (k Keeper) GetMTStakingAgentByAddress(ctx sdk.Context, agentAccAddr sdk.AccAddress) (*types.MTStakingAgent, bool)

func (Keeper) GetMTStakingDenomWhiteList

func (k Keeper) GetMTStakingDenomWhiteList(ctx sdk.Context) (*types.MTStakingDenomWhiteList, bool)

func (Keeper) GetMTStakingUnbonding

func (k Keeper) GetMTStakingUnbonding(ctx sdk.Context, agentAddress sdk.AccAddress, delegatorAddr sdk.AccAddress) (*types.MTStakingUnbondingDelegation, bool)

func (Keeper) GetOrCreateMTStakingAgent

func (k Keeper) GetOrCreateMTStakingAgent(ctx sdk.Context, denom string, validatorAddr sdk.ValAddress) *types.MTStakingAgent

func (Keeper) GetOrCreateMTStakingUnbonding

func (k Keeper) GetOrCreateMTStakingUnbonding(ctx sdk.Context, agentAddress, delegatorAddr sdk.AccAddress) *types.MTStakingUnbondingDelegation

func (Keeper) GetUBDQueueTimeSlice

func (k Keeper) GetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (dvPairs []types.DAPair)

func (Keeper) GetUnbondingDelegationFromAgent

func (k Keeper) GetUnbondingDelegationFromAgent(ctx sdk.Context, agentAddress sdk.AccAddress) (ubds []types.MTStakingUnbondingDelegation)

func (Keeper) HandleMultiTokenStakingAdditionProposal

func (k Keeper) HandleMultiTokenStakingAdditionProposal(ctx sdk.Context, proposal *types.AddNonNativeTokenToStakingProposal) error

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

func (Keeper) IncreaseDelegatorAgentShares

func (k Keeper) IncreaseDelegatorAgentShares(ctx sdk.Context, shares math.Int, agentAddress, delegator sdk.AccAddress) error

func (Keeper) InsertUBDQueue

func (k Keeper) InsertUBDQueue(ctx sdk.Context, ubd *types.MTStakingUnbondingDelegation, completionTime time.Time)

func (Keeper) InstantSlash

func (k Keeper) InstantSlash(ctx sdk.Context, valAddr sdk.ValAddress, delegator sdk.AccAddress, slashCoin sdk.Coin) error

InstantSlash define a method for slash the delegator of an agent. TODO rename such as InstantSlashAgent?

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MTStakingDelegate

func (k Keeper) MTStakingDelegate(
	ctx sdk.Context, delegatorAccAddr sdk.AccAddress, validatorAddr sdk.ValAddress, balance sdk.Coin,
) (newShares math.Int, err error)

func (Keeper) MTStakingUndelegate

func (k Keeper) MTStakingUndelegate(
	ctx sdk.Context, delegatorAccAddr sdk.AccAddress, valAddr sdk.ValAddress, balance sdk.Coin,
) (completeTime time.Time, err error)

MTStakingUndelegate defines a method for performing an undelegation from a delegate and a validator. Delegator burn the shares of the agents. Then agent account begin undelegate.

func (Keeper) ProcessCompletedUnbonding

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

func (Keeper) RefreshAgentDelegation

func (k Keeper) RefreshAgentDelegation(ctx sdk.Context, agent *types.MTStakingAgent) error

func (Keeper) RefreshAllAgentDelegation

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

RefreshAllAgentDelegation defines a method for updating all agent delegation amount base on current multiplier.

func (Keeper) RemoveMTStakingDenom

func (k Keeper) RemoveMTStakingDenom(ctx sdk.Context, denom string) bool

func (Keeper) RemoveMTStakingUnbonding

func (k Keeper) RemoveMTStakingUnbonding(ctx sdk.Context, agentAddress, delegatorAddr sdk.AccAddress)

func (Keeper) SetDelegatorWithdrawRewardHeight

func (k Keeper) SetDelegatorWithdrawRewardHeight(ctx sdk.Context, delegatorAccAddr, agentAccAddr sdk.AccAddress, height int64) bool

func (Keeper) SetEquivalentNativeCoinMultiplier

func (k Keeper) SetEquivalentNativeCoinMultiplier(ctx sdk.Context, epoch int64, denom string, multiplier sdk.Dec)

func (Keeper) SetMTStakingAgent

func (k Keeper) SetMTStakingAgent(ctx sdk.Context, agentAccAddr sdk.AccAddress, agent *types.MTStakingAgent)

func (Keeper) SetMTStakingDenomAndValWithAgentAddress

func (k Keeper) SetMTStakingDenomAndValWithAgentAddress(ctx sdk.Context, agentAddress sdk.AccAddress, denom string, valAddr sdk.ValAddress)

func (Keeper) SetMTStakingUnbondingDelegation

func (k Keeper) SetMTStakingUnbondingDelegation(ctx sdk.Context, unbonding *types.MTStakingUnbondingDelegation)

func (Keeper) SetUBDQueueTimeSlice

func (k Keeper) SetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []types.DAPair)

func (Keeper) SlashAgentFromValidator

func (k Keeper) SlashAgentFromValidator(ctx sdk.Context, valAddr sdk.ValAddress, slashFactor sdk.Dec)

SlashAgentFromValidator define a method to slash all agent which delegate to the slashed validator.

func (Keeper) SlashUnbondingDelegation

func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation types.MTStakingUnbondingDelegation,
	infractionHeight int64, slashFactor sdk.Dec,
) (totalSlashAmount math.Int)

slash an unbonding delegation Refer to the design of cosmos sdk

func (Keeper) UBDQueueIterator

func (k Keeper) UBDQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

UBDQueueIterator returns all the unbonding queue timeslices from time 0 until endTime.

func (Keeper) Unbond

func (k Keeper) Unbond(ctx sdk.Context, delegatorAccAddr sdk.AccAddress, valAddr sdk.ValAddress, balance sdk.Coin) error

Unbond defines a method for removing shares from an agent by a delegator then agent undelegate funds from a validator.

func (Keeper) UpdateEquivalentNativeCoinMultiplier

func (k Keeper) UpdateEquivalentNativeCoinMultiplier(ctx sdk.Context, epoch int64)

UpdateEquivalentNativeCoinMultiplier defines a method for updating the equivalent native coin multiplier for all token in white list

func (Keeper) WithdrawReward

func (k Keeper) WithdrawReward(ctx sdk.Context, valAddr sdk.ValAddress, stakeDenom string, delegatorAccAddr sdk.AccAddress) (sdk.Coin, error)

type Querier

type Querier struct {
	*Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper

func (Querier) Agent

Agent implements types.QueryServer.

func (Querier) AgentDelegations

AgentDelegations implements types.QueryServer.

func (Querier) AgentUnbondingDelegations

AgentUnbondingDelegations implements types.QueryServer.

func (Querier) Agents

Agents implements types.QueryServer.

func (Querier) Delegation

Delegation implements types.QueryServer.

func (Querier) DelegatorAgents

DelegatorAgents implements types.QueryServer.

func (Querier) DelegatorDelegations

DelegatorDelegations implements types.QueryServer.

func (Querier) DelegatorUnbondingDelegations

DelegatorUnbondingDelegations implements types.QueryServer.

func (Querier) DenomAgents

DenomAgents implements types.QueryServer.

func (Querier) UnbondingDelegation

UnbondingDelegation implements types.QueryServer.

Jump to

Keyboard shortcuts

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