Documentation ¶
Index ¶
- func AllInvariants(k *Keeper) sdk.Invariant
- func CanWithdrawInvariant(k *Keeper) sdk.Invariant
- func ModuleAccountInvariant(k *Keeper) sdk.Invariant
- func NewMsgServer(k *Keeper) types.MsgServer
- func NewQueryServer(k *Keeper) types.QueryServer
- func NonNegativeOutstandingInvariant(k *Keeper) sdk.Invariant
- func ReferenceCountInvariant(k *Keeper) sdk.Invariant
- func RegisterInvariants(ir sdk.InvariantRegistry, k *Keeper)
- type DistributionInfo
- type Hooks
- func (h Hooks) AfterOperatorDelegationModified(ctx sdk.Context, operatorID uint32, delegator string) error
- func (h Hooks) AfterPoolDelegationModified(ctx sdk.Context, poolID uint32, delegator string) error
- func (h Hooks) AfterServiceDelegationModified(ctx sdk.Context, serviceID uint32, delegator string) error
- func (h Hooks) AfterUnbondingInitiated(_ sdk.Context, _ uint64) error
- func (h Hooks) BeforeOperatorDelegationCreated(ctx sdk.Context, operatorID uint32, delegator string) error
- func (h Hooks) BeforeOperatorDelegationRemoved(_ sdk.Context, _ uint32, _ string) error
- func (h Hooks) BeforeOperatorDelegationSharesModified(ctx sdk.Context, operatorID uint32, delegator string) error
- func (h Hooks) BeforePoolDelegationCreated(ctx sdk.Context, poolID uint32, delegator string) error
- func (h Hooks) BeforePoolDelegationRemoved(_ sdk.Context, _ uint32, _ string) error
- func (h Hooks) BeforePoolDelegationSharesModified(ctx sdk.Context, poolID uint32, delegator string) error
- func (h Hooks) BeforeServiceDelegationCreated(ctx sdk.Context, serviceID uint32, delegator string) error
- func (h Hooks) BeforeServiceDelegationRemoved(_ sdk.Context, _ uint32, _ string) error
- func (h Hooks) BeforeServiceDelegationSharesModified(ctx sdk.Context, serviceID uint32, delegator string) error
- type Keeper
- func (k *Keeper) AfterDelegationModified(ctx sdk.Context, delType restakingtypes.DelegationType, targetID uint32, ...) error
- func (k *Keeper) AllocateRewards(ctx context.Context) error
- func (k *Keeper) AllocateRewardsByPlan(ctx context.Context, plan types.RewardsPlan, ...) error
- func (k *Keeper) BeforeDelegationCreated(ctx sdk.Context, delType restakingtypes.DelegationType, targetID uint32) error
- func (k *Keeper) BeforeDelegationSharesModified(ctx sdk.Context, delType restakingtypes.DelegationType, targetID uint32, ...) error
- func (k *Keeper) BeginBlocker(ctx context.Context) error
- func (k *Keeper) CalculateDelegationRewards(ctx context.Context, target restakingtypes.DelegationTarget, ...) (rewards types.DecPools, err error)
- func (k *Keeper) CreateRewardsPlan(ctx context.Context, description string, serviceID uint32, amt sdk.Coins, ...) (types.RewardsPlan, error)
- func (k *Keeper) EditRewardsPlan(ctx sdk.Context, planID uint64, newDescription string, ...) error
- func (k *Keeper) ExportGenesis(ctx sdk.Context) (*types.GenesisState, error)
- func (k *Keeper) GetAssetAndPrice(ctx context.Context, denom string) (assetstypes.Asset, math.LegacyDec, error)
- func (k *Keeper) GetAuthority() string
- func (k *Keeper) GetCoinValue(ctx context.Context, coin sdk.Coin) (math.LegacyDec, error)
- func (k *Keeper) GetCoinsValue(ctx context.Context, coins sdk.Coins) (math.LegacyDec, error)
- func (k *Keeper) GetCurrentRewards(ctx context.Context, target restakingtypes.DelegationTarget) (types.CurrentRewards, error)
- func (k *Keeper) GetDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, ...) (types.DecPools, error)
- func (k *Keeper) GetDelegationTarget(ctx context.Context, delType restakingtypes.DelegationType, targetID uint32) (restakingtypes.DelegationTarget, error)
- func (k *Keeper) GetDelegatorStartingInfo(ctx context.Context, target restakingtypes.DelegationTarget, ...) (types.DelegatorStartingInfo, error)
- func (k *Keeper) GetDelegatorWithdrawAddr(ctx context.Context, delegator sdk.AccAddress) (sdk.AccAddress, error)
- func (k *Keeper) GetHistoricalRewards(ctx context.Context, target restakingtypes.DelegationTarget, period uint64) (types.HistoricalRewards, error)
- func (k *Keeper) GetLastRewardsAllocationTime(ctx context.Context) (*time.Time, error)
- func (k *Keeper) GetOperatorAccumulatedCommission(ctx context.Context, operatorID uint32) (commission types.AccumulatedCommission, err error)
- func (k *Keeper) GetOperatorDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, operatorID uint32) (types.DecPools, error)
- func (k *Keeper) GetOutstandingRewards(ctx context.Context, target restakingtypes.DelegationTarget) (types.OutstandingRewards, error)
- func (k *Keeper) GetOutstandingRewardsCoins(ctx context.Context, target restakingtypes.DelegationTarget) (types.DecPools, error)
- func (k *Keeper) GetPoolDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, poolID uint32) (types.DecPools, error)
- func (k *Keeper) GetRewardsPlan(ctx context.Context, planID uint64) (types.RewardsPlan, error)
- func (k *Keeper) GetServiceDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, serviceID uint32) (types.DecPools, error)
- func (k *Keeper) HasCurrentRewards(ctx context.Context, target restakingtypes.DelegationTarget) (bool, error)
- func (k *Keeper) HasDelegatorStartingInfo(ctx context.Context, target restakingtypes.DelegationTarget, ...) (bool, error)
- func (k *Keeper) Hooks() Hooks
- func (k *Keeper) IncrementDelegationTargetPeriod(ctx context.Context, target restakingtypes.DelegationTarget) (uint64, error)
- func (k *Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) error
- func (k *Keeper) Logger(ctx context.Context) log.Logger
- func (k *Keeper) RemoveDelegatorStartingInfo(ctx context.Context, target restakingtypes.DelegationTarget, ...) error
- func (k *Keeper) RemoveHistoricalRewards(ctx context.Context, target restakingtypes.DelegationTarget, period uint64) error
- func (k *Keeper) SetCurrentRewards(ctx context.Context, target restakingtypes.DelegationTarget, ...) error
- func (k *Keeper) SetDelegatorStartingInfo(ctx context.Context, target restakingtypes.DelegationTarget, ...) error
- func (k *Keeper) SetHistoricalRewards(ctx context.Context, target restakingtypes.DelegationTarget, period uint64, ...) error
- func (k *Keeper) SetLastRewardsAllocationTime(ctx context.Context, t time.Time) error
- func (k *Keeper) SetOutstandingRewards(ctx context.Context, target restakingtypes.DelegationTarget, ...) error
- func (k *Keeper) SetWithdrawAddress(ctx context.Context, addr, withdrawAddr sdk.AccAddress) error
- func (k *Keeper) TerminateEndedRewardsPlans(ctx context.Context) error
- func (k *Keeper) WithdrawDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, ...) (types.Pools, error)
- func (k *Keeper) WithdrawOperatorCommission(ctx context.Context, operatorID uint32) (types.Pools, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllInvariants ¶
AllInvariants runs all invariants of the module
func CanWithdrawInvariant ¶
CanWithdrawInvariant checks that current rewards can be completely withdrawn
func ModuleAccountInvariant ¶
ModuleAccountInvariant checks that the coins held by the global rewards pool is consistent with the sum of outstanding rewards
func NewMsgServer ¶
func NewQueryServer ¶
func NewQueryServer(k *Keeper) types.QueryServer
func NonNegativeOutstandingInvariant ¶
NonNegativeOutstandingInvariant checks that outstanding unwithdrawn fees are never negative
func ReferenceCountInvariant ¶
ReferenceCountInvariant checks that the number of historical rewards records is correct
func RegisterInvariants ¶
func RegisterInvariants(ir sdk.InvariantRegistry, k *Keeper)
RegisterInvariants registers all module invariants
Types ¶
type DistributionInfo ¶
type DistributionInfo struct { DelegationTarget restakingtypes.DelegationTarget DelegationsValue math.LegacyDec }
DistributionInfo stores information about a delegation target and its delegation value.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func (Hooks) AfterOperatorDelegationModified ¶
func (Hooks) AfterPoolDelegationModified ¶
func (Hooks) AfterServiceDelegationModified ¶
func (Hooks) AfterUnbondingInitiated ¶
func (Hooks) BeforeOperatorDelegationCreated ¶
func (Hooks) BeforeOperatorDelegationRemoved ¶
func (Hooks) BeforeOperatorDelegationSharesModified ¶
func (Hooks) BeforePoolDelegationCreated ¶
func (Hooks) BeforePoolDelegationRemoved ¶
func (Hooks) BeforePoolDelegationSharesModified ¶
func (Hooks) BeforeServiceDelegationCreated ¶
func (Hooks) BeforeServiceDelegationRemoved ¶
type Keeper ¶
type Keeper struct { Schema collections.Schema Params collections.Item[types.Params] NextRewardsPlanID collections.Item[uint64] RewardsPlans collections.Map[uint64, types.RewardsPlan] LastRewardsAllocationTime collections.Item[gogotypes.Timestamp] DelegatorWithdrawAddrs collections.Map[sdk.AccAddress, sdk.AccAddress] PoolDelegatorStartingInfos collections.Map[collections.Pair[uint32, sdk.AccAddress], types.DelegatorStartingInfo] PoolHistoricalRewards collections.Map[collections.Pair[uint32, uint64], types.HistoricalRewards] PoolCurrentRewards collections.Map[uint32, types.CurrentRewards] PoolOutstandingRewards collections.Map[uint32, types.OutstandingRewards] OperatorAccumulatedCommissions collections.Map[uint32, types.AccumulatedCommission] OperatorDelegatorStartingInfos collections.Map[collections.Pair[uint32, sdk.AccAddress], types.DelegatorStartingInfo] OperatorHistoricalRewards collections.Map[collections.Pair[uint32, uint64], types.HistoricalRewards] OperatorCurrentRewards collections.Map[uint32, types.CurrentRewards] OperatorOutstandingRewards collections.Map[uint32, types.OutstandingRewards] ServiceDelegatorStartingInfos collections.Map[collections.Pair[uint32, sdk.AccAddress], types.DelegatorStartingInfo] ServiceHistoricalRewards collections.Map[collections.Pair[uint32, uint64], types.HistoricalRewards] ServiceCurrentRewards collections.Map[uint32, types.CurrentRewards] ServiceOutstandingRewards collections.Map[uint32, types.OutstandingRewards] // contains filtered or unexported fields }
func NewKeeper ¶
func NewKeeper( cdc codec.Codec, storeService corestoretypes.KVStoreService, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, communityPoolKeeper types.CommunityPoolKeeper, oracleKeeper types.OracleKeeper, poolsKeeper types.PoolsKeeper, operatorsKeeper types.OperatorsKeeper, servicesKeeper types.ServicesKeeper, restakingKeeper types.RestakingKeeper, assetsKeeper types.AssetsKeeper, authority string, ) *Keeper
func (*Keeper) AfterDelegationModified ¶
func (k *Keeper) AfterDelegationModified(ctx sdk.Context, delType restakingtypes.DelegationType, targetID uint32, delegator string) error
func (*Keeper) AllocateRewards ¶
AllocateRewards allocates restaking rewards to different entities based on active rewards plans. AllocateRewards skips rewards distribution when there's no last rewards allocation time set. In that case, AllocateRewards simply set the current block time as new last rewards allocation time.
func (*Keeper) AllocateRewardsByPlan ¶
func (k *Keeper) AllocateRewardsByPlan( ctx context.Context, plan types.RewardsPlan, timeSinceLastAllocation time.Duration, pools []poolstypes.Pool, operators []operatorstypes.Operator, ) error
AllocateRewardsByPlan allocates rewards by a specific rewards plan.
func (*Keeper) BeforeDelegationCreated ¶
func (k *Keeper) BeforeDelegationCreated(ctx sdk.Context, delType restakingtypes.DelegationType, targetID uint32) error
func (*Keeper) BeforeDelegationSharesModified ¶
func (k *Keeper) BeforeDelegationSharesModified(ctx sdk.Context, delType restakingtypes.DelegationType, targetID uint32, delegator string) error
func (*Keeper) BeginBlocker ¶
BeginBlocker is called every block and is used to terminate ended rewards plans and allocate restaking rewards for the previous block.
func (*Keeper) CalculateDelegationRewards ¶
func (k *Keeper) CalculateDelegationRewards( ctx context.Context, target restakingtypes.DelegationTarget, del restakingtypes.Delegation, endingPeriod uint64, ) (rewards types.DecPools, err error)
CalculateDelegationRewards calculates the total rewards accrued by a delegation between the starting period and the current block height
func (*Keeper) CreateRewardsPlan ¶
func (k *Keeper) CreateRewardsPlan( ctx context.Context, description string, serviceID uint32, amt sdk.Coins, startTime, endTime time.Time, poolsDistribution types.Distribution, operatorsDistribution types.Distribution, usersDistribution types.UsersDistribution, ) (types.RewardsPlan, error)
func (*Keeper) EditRewardsPlan ¶ added in v1.4.0
func (k *Keeper) EditRewardsPlan( ctx sdk.Context, planID uint64, newDescription string, newAmountPerDay sdk.Coins, newStartTime, newEndTime time.Time, newPoolsDistribution types.Distribution, newOperatorsDistribution types.Distribution, newUsersDistribution types.UsersDistribution, ) error
EditRewardsPlan edits an existing rewards plan.
func (*Keeper) ExportGenesis ¶
ExportGenesis returns the GenesisState associated with the given context
func (*Keeper) GetAssetAndPrice ¶
func (*Keeper) GetAuthority ¶
GetAuthority returns the module's authority.
func (*Keeper) GetCoinValue ¶
func (*Keeper) GetCoinsValue ¶
func (*Keeper) GetCurrentRewards ¶
func (k *Keeper) GetCurrentRewards(ctx context.Context, target restakingtypes.DelegationTarget) (types.CurrentRewards, error)
GetCurrentRewards returns the current rewards for a target
func (*Keeper) GetDelegationRewards ¶
func (k *Keeper) GetDelegationRewards( ctx context.Context, delAddr sdk.AccAddress, delType restakingtypes.DelegationType, targetID uint32, ) (types.DecPools, error)
GetDelegationRewards returns the rewards for a delegation
func (*Keeper) GetDelegationTarget ¶
func (k *Keeper) GetDelegationTarget( ctx context.Context, delType restakingtypes.DelegationType, targetID uint32, ) (restakingtypes.DelegationTarget, error)
func (*Keeper) GetDelegatorStartingInfo ¶
func (k *Keeper) GetDelegatorStartingInfo( ctx context.Context, target restakingtypes.DelegationTarget, delegator sdk.AccAddress, ) (types.DelegatorStartingInfo, error)
GetDelegatorStartingInfo returns the delegator starting info for a delegator and target
func (*Keeper) GetDelegatorWithdrawAddr ¶
func (k *Keeper) GetDelegatorWithdrawAddr(ctx context.Context, delegator sdk.AccAddress) (sdk.AccAddress, error)
GetDelegatorWithdrawAddr returns the delegator's withdraw address if set, otherwise the delegator address is returned.
func (*Keeper) GetHistoricalRewards ¶
func (k *Keeper) GetHistoricalRewards( ctx context.Context, target restakingtypes.DelegationTarget, period uint64, ) (types.HistoricalRewards, error)
GetHistoricalRewards returns the historical rewards for a target and period
func (*Keeper) GetLastRewardsAllocationTime ¶
GetLastRewardsAllocationTime returns the last time rewards were allocated. If there's no last rewards allocation time set yet, nil is returned.
func (*Keeper) GetOperatorAccumulatedCommission ¶
func (k *Keeper) GetOperatorAccumulatedCommission(ctx context.Context, operatorID uint32) (commission types.AccumulatedCommission, err error)
GetOperatorAccumulatedCommission returns the accumulated commission for an operator.
func (*Keeper) GetOperatorDelegationRewards ¶
func (k *Keeper) GetOperatorDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, operatorID uint32) (types.DecPools, error)
GetOperatorDelegationRewards returns the rewards for an operator delegation
func (*Keeper) GetOutstandingRewards ¶
func (k *Keeper) GetOutstandingRewards(ctx context.Context, target restakingtypes.DelegationTarget) (types.OutstandingRewards, error)
GetOutstandingRewards returns the outstanding rewards for a target
func (*Keeper) GetOutstandingRewardsCoins ¶
func (k *Keeper) GetOutstandingRewardsCoins(ctx context.Context, target restakingtypes.DelegationTarget) (types.DecPools, error)
GetOutstandingRewardsCoins returns the outstanding rewards coins for a target
func (*Keeper) GetPoolDelegationRewards ¶
func (k *Keeper) GetPoolDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, poolID uint32) (types.DecPools, error)
GetPoolDelegationRewards returns the rewards for a pool delegation
func (*Keeper) GetRewardsPlan ¶
GetRewardsPlan returns a rewards plan by ID.
func (*Keeper) GetServiceDelegationRewards ¶
func (k *Keeper) GetServiceDelegationRewards( ctx context.Context, delAddr sdk.AccAddress, serviceID uint32, ) (types.DecPools, error)
GetServiceDelegationRewards returns the rewards for a service delegation
func (*Keeper) HasCurrentRewards ¶
func (k *Keeper) HasCurrentRewards(ctx context.Context, target restakingtypes.DelegationTarget) (bool, error)
HasCurrentRewards returns true if the current rewards exist for a target
func (*Keeper) HasDelegatorStartingInfo ¶
func (k *Keeper) HasDelegatorStartingInfo( ctx context.Context, target restakingtypes.DelegationTarget, delegator sdk.AccAddress, ) (bool, error)
HasDelegatorStartingInfo returns true if the delegator starting info exists for a delegator and target
func (*Keeper) IncrementDelegationTargetPeriod ¶
func (k *Keeper) IncrementDelegationTargetPeriod(ctx context.Context, target restakingtypes.DelegationTarget) (uint64, error)
increment period, returning the period just ended
func (*Keeper) InitGenesis ¶
InitGenesis initializes the state from a GenesisState
func (*Keeper) RemoveDelegatorStartingInfo ¶
func (k *Keeper) RemoveDelegatorStartingInfo( ctx context.Context, target restakingtypes.DelegationTarget, delegator sdk.AccAddress, ) error
RemoveDelegatorStartingInfo removes the delegator starting info for a delegator and target
func (*Keeper) RemoveHistoricalRewards ¶
func (k *Keeper) RemoveHistoricalRewards( ctx context.Context, target restakingtypes.DelegationTarget, period uint64, ) error
RemoveHistoricalRewards removes the historical rewards for a target and period
func (*Keeper) SetCurrentRewards ¶
func (k *Keeper) SetCurrentRewards( ctx context.Context, target restakingtypes.DelegationTarget, rewards types.CurrentRewards, ) error
SetCurrentRewards sets the current rewards for a target
func (*Keeper) SetDelegatorStartingInfo ¶
func (k *Keeper) SetDelegatorStartingInfo( ctx context.Context, target restakingtypes.DelegationTarget, del sdk.AccAddress, info types.DelegatorStartingInfo, ) error
SetDelegatorStartingInfo sets the delegator starting info for a delegator.
func (*Keeper) SetHistoricalRewards ¶
func (k *Keeper) SetHistoricalRewards( ctx context.Context, target restakingtypes.DelegationTarget, period uint64, rewards types.HistoricalRewards, ) error
SetHistoricalRewards sets the historical rewards for a target and period
func (*Keeper) SetLastRewardsAllocationTime ¶
SetLastRewardsAllocationTime sets the last time rewards were allocated.
func (*Keeper) SetOutstandingRewards ¶
func (k *Keeper) SetOutstandingRewards( ctx context.Context, target restakingtypes.DelegationTarget, rewards types.OutstandingRewards, ) error
SetOutstandingRewards sets the outstanding rewards for a target.
func (*Keeper) SetWithdrawAddress ¶
SetWithdrawAddress sets a new address that will receive the rewards upon withdrawal
func (*Keeper) TerminateEndedRewardsPlans ¶
TerminateEndedRewardsPlans terminates all rewards plans that have ended.
func (*Keeper) WithdrawDelegationRewards ¶
func (k *Keeper) WithdrawDelegationRewards( ctx context.Context, delAddr sdk.AccAddress, target restakingtypes.DelegationTarget, ) (types.Pools, error)
WithdrawDelegationRewards withdraws the rewards from the delegation and reinitializes it