keeper

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// EnableAdvanceEpoch indicates whether msgServer accepts MsgAdvanceEpoch or not.
	// Never set this to true in production mode. Doing that will expose serious attack vector.
	EnableAdvanceEpoch = false
	// EnableRatioPlan indicates whether msgServer and proposal handler accept
	// creation of RatioPlans.
	// Default is false, which means that RatioPlans can't be created through a
	// MsgCreateRatioPlan msg and a PublicPlanProposal.
	EnableRatioPlan = false
)

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the farming module.

func HandlePublicPlanProposal

func HandlePublicPlanProposal(ctx sdk.Context, k Keeper, proposal *types.PublicPlanProposal) error

HandlePublicPlanProposal is a handler for executing a public plan creation proposal.

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NonNegativeHistoricalRewardsInvariant

func NonNegativeHistoricalRewardsInvariant(k Keeper) sdk.Invariant

NonNegativeHistoricalRewardsInvariant checks that all HistoricalRewards are non-negative.

func NonNegativeOutstandingRewardsInvariant

func NonNegativeOutstandingRewardsInvariant(k Keeper) sdk.Invariant

NonNegativeOutstandingRewardsInvariant checks that all OutstandingRewards are non-negative.

func OutstandingRewardsAmountInvariant

func OutstandingRewardsAmountInvariant(k Keeper) sdk.Invariant

OutstandingRewardsAmountInvariant checks that OutstandingRewards are consistent with rewards that can be withdrawn.

func PositiveQueuedStakingAmountInvariant

func PositiveQueuedStakingAmountInvariant(k Keeper) sdk.Invariant

PositiveQueuedStakingAmountInvariant checks that the amount of queued staking coins is positive.

func PositiveStakingAmountInvariant

func PositiveStakingAmountInvariant(k Keeper) sdk.Invariant

PositiveStakingAmountInvariant checks that the amount of staking coins is positive.

func PositiveTotalStakingsAmountInvariant

func PositiveTotalStakingsAmountInvariant(k Keeper) sdk.Invariant

PositiveTotalStakingsAmountInvariant checks that all TotalStakings have positive amount.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers all farming invariants.

func RemainingRewardsAmountInvariant

func RemainingRewardsAmountInvariant(k Keeper) sdk.Invariant

RemainingRewardsAmountInvariant checks that the balance of the RewardsReserveAcc of all plans greater than the total amount of unwithdrawn reward coins in all reward objects

func StakingReservedAmountInvariant

func StakingReservedAmountInvariant(k Keeper) sdk.Invariant

StakingReservedAmountInvariant checks that the balance of StakingReserveAcc greater than the amount of staked, Queued coins in all staking objects.

func UnharvestedRewardsAmountInvariant

func UnharvestedRewardsAmountInvariant(k Keeper) sdk.Invariant

UnharvestedRewardsAmountInvariant checks that UnharvestedRewards are consistent with rewards that can be withdrawn.

Types

type AllocationInfo

type AllocationInfo struct {
	Plan   types.PlanI
	Amount sdk.Coins
}

AllocationInfo holds information about an allocation for a plan.

type Keeper

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

Keeper of the farming store

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
	accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper,
) Keeper

NewKeeper returns a farming keeper. It handles: - creating new ModuleAccounts for each pool ReserveAccount - sending to and from ModuleAccounts - minting, burning PoolCoins

func (Keeper) AddPublicPlanProposal

func (k Keeper) AddPublicPlanProposal(ctx sdk.Context, proposals []types.AddPlanRequest) error

AddPublicPlanProposal adds a new public plan once the governance proposal is passed.

func (Keeper) AdvanceEpoch

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

AdvanceEpoch allocates rewards and advances epoch by one. AdvanceEpoch also forcefully makes queued stakings to be staked. Use this only for simulation and testing purpose.

func (Keeper) AllRewards

func (k Keeper) AllRewards(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins

AllRewards returns truncated total rewards accumulated until the current epoch for a farmer.

func (Keeper) AllUnharvestedRewards

func (k Keeper) AllUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins

AllUnharvestedRewards returns all unharvested rewards of a farmer.

func (Keeper) AllocateRewards

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

AllocateRewards updates historical rewards and current epoch info based on the allocation infos.

func (Keeper) AllocationInfos

func (k Keeper) AllocationInfos(ctx sdk.Context) []AllocationInfo

AllocationInfos returns allocation infos for the end of the current epoch. When total allocated coins for a farming pool exceeds the pool's balance, then allocation will not happen.

func (Keeper) CalculateRewards

func (k Keeper) CalculateRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, endingEpoch uint64) (rewards sdk.DecCoins)

CalculateRewards returns rewards accumulated until endingEpoch for a farmer for a given staking coin denom.

func (Keeper) CreateFixedAmountPlan

func (k Keeper) CreateFixedAmountPlan(ctx sdk.Context, msg *types.MsgCreateFixedAmountPlan, farmingPoolAcc, terminationAcc sdk.AccAddress, typ types.PlanType) (types.PlanI, error)

CreateFixedAmountPlan sets fixed amount plan.

func (Keeper) CreateRatioPlan

func (k Keeper) CreateRatioPlan(ctx sdk.Context, msg *types.MsgCreateRatioPlan, farmingPoolAcc, terminationAcc sdk.AccAddress, typ types.PlanType) (types.PlanI, error)

CreateRatioPlan sets ratio plan.

func (Keeper) DecreaseOutstandingRewards

func (k Keeper) DecreaseOutstandingRewards(ctx sdk.Context, stakingCoinDenom string, amount sdk.DecCoins)

DecreaseOutstandingRewards decreases outstanding rewards for a given staking coin denom by given amount.

func (Keeper) DecreaseTotalStakings

func (k Keeper) DecreaseTotalStakings(ctx sdk.Context, stakingCoinDenom string, amount sdk.Int)

DecreaseTotalStakings decreases total stakings for given staking coin denom by given amount.

func (Keeper) DeleteAllHistoricalRewards

func (k Keeper) DeleteAllHistoricalRewards(ctx sdk.Context, stakingCoinDenom string)

DeleteAllHistoricalRewards deletes all historical rewards for a staking coin denom.

func (Keeper) DeleteCurrentEpoch

func (k Keeper) DeleteCurrentEpoch(ctx sdk.Context, stakingCoinDenom string)

DeleteCurrentEpoch deletes current epoch info for a given staking coin denom.

func (Keeper) DeleteHistoricalRewards

func (k Keeper) DeleteHistoricalRewards(ctx sdk.Context, stakingCoinDenom string, epoch uint64)

DeleteHistoricalRewards deletes historical rewards for a given staking coin denom and an epoch number.

func (Keeper) DeleteOutstandingRewards

func (k Keeper) DeleteOutstandingRewards(ctx sdk.Context, stakingCoinDenom string)

DeleteOutstandingRewards deletes outstanding rewards for a given staking coin denom.

func (Keeper) DeletePlan

func (k Keeper) DeletePlan(ctx sdk.Context, plan types.PlanI)

DeletePlan deletes a plan from the store. NOTE: this will cause supply invariant violation if called

func (Keeper) DeletePublicPlanProposal

func (k Keeper) DeletePublicPlanProposal(ctx sdk.Context, proposals []types.DeletePlanRequest) error

DeletePublicPlanProposal deletes public plan proposal once the governance proposal is passed.

func (Keeper) DeleteQueuedStaking

func (k Keeper) DeleteQueuedStaking(ctx sdk.Context, endTime time.Time, stakingCoinDenom string, farmerAcc sdk.AccAddress)

DeleteQueuedStaking deletes a queued staking for given staking coin denom and farmer.

func (Keeper) DeleteStaking

func (k Keeper) DeleteStaking(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress)

DeleteStaking deletes a staking for given staking coin denom and farmer.

func (Keeper) DeleteTotalStakings

func (k Keeper) DeleteTotalStakings(ctx sdk.Context, stakingCoinDenom string)

DeleteTotalStakings deletes total stakings for given staking coin denom.

func (Keeper) DeleteUnharvestedRewards

func (k Keeper) DeleteUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string)

DeleteUnharvestedRewards deletes unharvested rewards of the farmer.

func (Keeper) DerivePrivatePlanFarmingPoolAcc

func (k Keeper) DerivePrivatePlanFarmingPoolAcc(ctx sdk.Context, name string) (sdk.AccAddress, error)

DerivePrivatePlanFarmingPoolAcc returns a unique account address of a farming pool for a private plan.

func (Keeper) ExportGenesis

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

ExportGenesis returns the farming module's genesis state.

func (Keeper) GetAllQueuedCoinsByFarmer

func (k Keeper) GetAllQueuedCoinsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins

GetAllQueuedCoinsByFarmer returns all coins that are queued for staking by a farmer.

func (Keeper) GetAllQueuedStakingAmountByFarmerAndDenom

func (k Keeper) GetAllQueuedStakingAmountByFarmerAndDenom(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string) sdk.Int

GetAllQueuedStakingAmountByFarmerAndDenom returns the amount of all queued stakings by the farmer for given staking coin denom.

func (Keeper) GetAllStakedCoinsByFarmer

func (k Keeper) GetAllStakedCoinsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins

GetAllStakedCoinsByFarmer returns all coins that are staked by a farmer.

func (Keeper) GetCodec

func (k Keeper) GetCodec() codec.BinaryCodec

GetCodec returns codec.Codec object used by the keeper>

func (Keeper) GetCurrentEpoch

func (k Keeper) GetCurrentEpoch(ctx sdk.Context, stakingCoinDenom string) uint64

GetCurrentEpoch returns the current epoch number for a given staking coin denom.

func (Keeper) GetCurrentEpochDays

func (k Keeper) GetCurrentEpochDays(ctx sdk.Context) uint32

GetCurrentEpochDays returns the current epoch days(period).

func (Keeper) GetGlobalPlanId

func (k Keeper) GetGlobalPlanId(ctx sdk.Context) uint64

GetGlobalPlanId returns the global Plan ID counter.

func (Keeper) GetHistoricalRewards

func (k Keeper) GetHistoricalRewards(ctx sdk.Context, stakingCoinDenom string, epoch uint64) (rewards types.HistoricalRewards, found bool)

GetHistoricalRewards returns historical rewards for a given staking coin denom and an epoch number.

func (Keeper) GetLastEpochTime

func (k Keeper) GetLastEpochTime(ctx sdk.Context) (t time.Time, found bool)

GetLastEpochTime returns the last time the epoch ended.

func (Keeper) GetNextPlanIdWithUpdate

func (k Keeper) GetNextPlanIdWithUpdate(ctx sdk.Context) uint64

GetNextPlanIdWithUpdate returns and increments the global Plan ID counter. If the global plan number is not set, it initializes it with value 0.

func (Keeper) GetNumActivePrivatePlans

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

GetNumActivePrivatePlans returns the number of active(non-terminated) private plans.

func (Keeper) GetOutstandingRewards

func (k Keeper) GetOutstandingRewards(ctx sdk.Context, stakingCoinDenom string) (rewards types.OutstandingRewards, found bool)

GetOutstandingRewards returns outstanding rewards for a given staking coin denom.

func (Keeper) GetParams

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

GetParams returns the parameters for the farming module.

func (Keeper) GetPlan

func (k Keeper) GetPlan(ctx sdk.Context, id uint64) (plan types.PlanI, found bool)

GetPlan returns a plan for a given plan id.

func (Keeper) GetPlans

func (k Keeper) GetPlans(ctx sdk.Context) (plans []types.PlanI)

GetPlans returns all plans in the store.

func (Keeper) GetQueuedStaking

func (k Keeper) GetQueuedStaking(ctx sdk.Context, endTime time.Time, stakingCoinDenom string, farmerAcc sdk.AccAddress) (queuedStaking types.QueuedStaking, found bool)

GetQueuedStaking returns a queued staking for given staking coin denom and farmer.

func (Keeper) GetStaking

func (k Keeper) GetStaking(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress) (staking types.Staking, found bool)

GetStaking returns a staking for given staking denom and farmer.

func (Keeper) GetTotalStakings

func (k Keeper) GetTotalStakings(ctx sdk.Context, stakingCoinDenom string) (totalStakings types.TotalStakings, found bool)

GetTotalStakings returns total stakings for given staking coin denom.

func (Keeper) GetUnharvestedRewards

func (k Keeper) GetUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string) (rewards types.UnharvestedRewards, found bool)

GetUnharvestedRewards returns unharvested rewards of the farmer.

func (Keeper) Harvest

func (k Keeper) Harvest(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenoms []string) error

Harvest claims farming rewards from the reward pool.

func (Keeper) IncreaseOutstandingRewards

func (k Keeper) IncreaseOutstandingRewards(ctx sdk.Context, stakingCoinDenom string, amount sdk.DecCoins)

IncreaseOutstandingRewards increases outstanding rewards for a given staking coin denom by given amount.

func (Keeper) IncreaseTotalStakings

func (k Keeper) IncreaseTotalStakings(ctx sdk.Context, stakingCoinDenom string, amount sdk.Int)

IncreaseTotalStakings increases total stakings for given staking coin denom by given amount.

func (Keeper) IncreaseUnharvestedRewards

func (k Keeper) IncreaseUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, amount sdk.Coins)

IncreaseUnharvestedRewards increases unharvested rewards for a farmer and a staking coin denom by given amount.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)

InitGenesis initializes the farming module's state from a given genesis state.

func (Keeper) IterateAllUnharvestedRewards

func (k Keeper) IterateAllUnharvestedRewards(ctx sdk.Context, cb func(farmerAcc sdk.AccAddress, stakingCoinDenom string, rewards types.UnharvestedRewards) (stop bool))

IterateAllUnharvestedRewards iterates through all unharvested rewards stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateCurrentEpochs

func (k Keeper) IterateCurrentEpochs(ctx sdk.Context, cb func(stakingCoinDenom string, currentEpoch uint64) (stop bool))

IterateCurrentEpochs iterates through all current epoch infos stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateHistoricalRewards

func (k Keeper) IterateHistoricalRewards(ctx sdk.Context, cb func(stakingCoinDenom string, epoch uint64, rewards types.HistoricalRewards) (stop bool))

IterateHistoricalRewards iterates through all historical rewards stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateMatureQueuedStakings

func (k Keeper) IterateMatureQueuedStakings(ctx sdk.Context, currTime time.Time, cb func(endTime time.Time, stakingCoinDenom string, farmerAcc sdk.AccAddress, queuedStaking types.QueuedStaking) (stop bool))

IterateMatureQueuedStakings iterates through all the queued stakings that are mature at currTime. Stops the iteration when the callback function returns true.

func (Keeper) IterateOutstandingRewards

func (k Keeper) IterateOutstandingRewards(ctx sdk.Context, cb func(stakingCoinDenom string, rewards types.OutstandingRewards) (stop bool))

IterateOutstandingRewards iterates through all outstanding rewards stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IteratePlans

func (k Keeper) IteratePlans(ctx sdk.Context, cb func(plan types.PlanI) (stop bool))

IteratePlans iterates over all the stored plans and performs a callback function. Stops iteration when callback returns true.

func (Keeper) IterateQueuedStakings

func (k Keeper) IterateQueuedStakings(ctx sdk.Context, cb func(endTime time.Time, stakingCoinDenom string, farmerAcc sdk.AccAddress, queuedStaking types.QueuedStaking) (stop bool))

IterateQueuedStakings iterates through all queued stakings stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateQueuedStakingsByFarmer

func (k Keeper) IterateQueuedStakingsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress, cb func(stakingCoinDenom string, endTime time.Time, queuedStaking types.QueuedStaking) (stop bool))

IterateQueuedStakingsByFarmer iterates through all queued stakings by farmer stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateQueuedStakingsByFarmerAndDenom

func (k Keeper) IterateQueuedStakingsByFarmerAndDenom(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, cb func(endTime time.Time, queuedStaking types.QueuedStaking) (stop bool))

IterateQueuedStakingsByFarmerAndDenom iterates through all the queued stakings by farmer address and staking coin denom. Stops the iteration when the callback function returns true.

func (Keeper) IterateQueuedStakingsByFarmerAndDenomReverse

func (k Keeper) IterateQueuedStakingsByFarmerAndDenomReverse(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, cb func(endTime time.Time, queuedStaking types.QueuedStaking) (stop bool))

IterateQueuedStakingsByFarmerAndDenomReverse iterates through all the queued stakings by farmer address and staking coin denom, in reverse order. Stops the iteration when the callback function returns true.

func (Keeper) IterateStakings

func (k Keeper) IterateStakings(ctx sdk.Context, cb func(stakingCoinDenom string, farmerAcc sdk.AccAddress, staking types.Staking) (stop bool))

IterateStakings iterates through all stakings stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateStakingsByFarmer

func (k Keeper) IterateStakingsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress, cb func(stakingCoinDenom string, staking types.Staking) (stop bool))

IterateStakingsByFarmer iterates through all stakings by a farmer stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateTotalStakings

func (k Keeper) IterateTotalStakings(ctx sdk.Context, cb func(stakingCoinDenom string, totalStakings types.TotalStakings) (stop bool))

IterateTotalStakings iterates through all total stakings stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateUnharvestedRewardsByFarmer

func (k Keeper) IterateUnharvestedRewardsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress, cb func(stakingCoinDenom string, rewards types.UnharvestedRewards) (stop bool))

IterateUnharvestedRewardsByFarmer iterates through all the unharvested rewards by a farmer and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MarshalPlan

func (k Keeper) MarshalPlan(plan types.PlanI) ([]byte, error)

MarshalPlan serializes a plan.

func (Keeper) ModifyPublicPlanProposal

func (k Keeper) ModifyPublicPlanProposal(ctx sdk.Context, proposals []types.ModifyPlanRequest) error

ModifyPublicPlanProposal overwrites the plan with the new plan proposal once the governance proposal is passed.

func (Keeper) ProcessQueuedCoins

func (k Keeper) ProcessQueuedCoins(ctx sdk.Context, currTime time.Time)

ProcessQueuedCoins moves queued coins into staked coins. It causes accumulated rewards to be withdrawn as UnharvestedRewards, which can be claimed later by the farmer.

func (Keeper) ReleaseStakingCoins

func (k Keeper) ReleaseStakingCoins(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoins sdk.Coins) error

ReleaseStakingCoins sends staking coins back to the farmer.

func (Keeper) RemovePlan

func (k Keeper) RemovePlan(ctx sdk.Context, creator sdk.AccAddress, planId uint64) error

RemovePlan removes a terminated plan and sends all remaining coins in the farming pool address to the termination address.

func (Keeper) ReserveStakingCoins

func (k Keeper) ReserveStakingCoins(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoins sdk.Coins) error

ReserveStakingCoins sends staking coins to the staking reserve account.

func (Keeper) Rewards

func (k Keeper) Rewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string) sdk.Coins

Rewards returns truncated rewards accumulated until the current epoch for a farmer for a given staking coin denom.

func (Keeper) SetCurrentEpoch

func (k Keeper) SetCurrentEpoch(ctx sdk.Context, stakingCoinDenom string, currentEpoch uint64)

SetCurrentEpoch sets the current epoch number for a given staking coin denom.

func (Keeper) SetCurrentEpochDays

func (k Keeper) SetCurrentEpochDays(ctx sdk.Context, epochDays uint32)

SetCurrentEpochDays sets the current epoch days(period).

func (Keeper) SetGlobalPlanId

func (k Keeper) SetGlobalPlanId(ctx sdk.Context, id uint64)

SetGlobalPlanId sets the global Plan ID counter.

func (Keeper) SetHistoricalRewards

func (k Keeper) SetHistoricalRewards(ctx sdk.Context, stakingCoinDenom string, epoch uint64, rewards types.HistoricalRewards)

SetHistoricalRewards sets historical rewards for a given staking coin denom and an epoch number.

func (Keeper) SetLastEpochTime

func (k Keeper) SetLastEpochTime(ctx sdk.Context, t time.Time)

SetLastEpochTime sets the last time the epoch ended.

func (Keeper) SetOutstandingRewards

func (k Keeper) SetOutstandingRewards(ctx sdk.Context, stakingCoinDenom string, rewards types.OutstandingRewards)

SetOutstandingRewards sets outstanding rewards for a given staking coin denom.

func (Keeper) SetParams

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

SetParams sets the parameters for the farming module.

func (Keeper) SetPlan

func (k Keeper) SetPlan(ctx sdk.Context, plan types.PlanI)

SetPlan sets a plan for a given plan id.

func (Keeper) SetQueuedStaking

func (k Keeper) SetQueuedStaking(ctx sdk.Context, endTime time.Time, stakingCoinDenom string, farmerAcc sdk.AccAddress, queuedStaking types.QueuedStaking)

SetQueuedStaking sets a queued staking for given staking coin denom and farmer.

func (Keeper) SetStaking

func (k Keeper) SetStaking(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress, staking types.Staking)

SetStaking sets a staking for given staking coin denom and farmer.

func (Keeper) SetTotalStakings

func (k Keeper) SetTotalStakings(ctx sdk.Context, stakingCoinDenom string, totalStakings types.TotalStakings)

SetTotalStakings sets total stakings for given staking coin denom.

func (Keeper) SetUnharvestedRewards

func (k Keeper) SetUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, rewards types.UnharvestedRewards)

SetUnharvestedRewards sets unharvested rewards of the farmer.

func (Keeper) Stake

func (k Keeper) Stake(ctx sdk.Context, farmerAcc sdk.AccAddress, amount sdk.Coins) error

Stake stores staking coins to queued coins, and it will be processed in the next epoch.

func (Keeper) TerminateEndedPlans

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

TerminateEndedPlans terminates plans that have been ended.

func (Keeper) TerminatePlan

func (k Keeper) TerminatePlan(ctx sdk.Context, plan types.PlanI) error

TerminatePlan marks the plan as terminated. It moves the plan under different store key, which is for terminated plans.

func (Keeper) UnmarshalPlan

func (k Keeper) UnmarshalPlan(bz []byte) (plan types.PlanI, err error)

UnmarshalPlan returns a plan from raw serialized bytes of a Proto-based Plan type.

func (Keeper) Unstake

func (k Keeper) Unstake(ctx sdk.Context, farmerAcc sdk.AccAddress, amount sdk.Coins) error

Unstake unstakes an amount of staking coins from the staking reserve account. It causes accumulated rewards to be withdrawn to the farmer.

func (Keeper) ValidateOutstandingRewardsAmount

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

ValidateOutstandingRewardsAmount checks that the balance of the rewards reserve pool is greater than the total amount of outstanding rewards.

func (Keeper) ValidateRemainingRewardsAmount

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

ValidateRemainingRewardsAmount checks that the balance of the rewards reserve pool is greater than the total amount of unwithdrawn rewards.

func (Keeper) ValidateStakingReservedAmount

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

ValidateStakingReservedAmount checks that the balance of StakingReserveAcc greater than the amount of staked, queued coins in all staking objects.

func (Keeper) ValidateUnharvestedRewardsAmount

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

ValidateUnharvestedRewardsAmount checks that the balance of the unharvested rewards reserve pool is greater than(or equal to) the total amount of unharvested rewards.

func (Keeper) WithdrawAllRewards

func (k Keeper) WithdrawAllRewards(ctx sdk.Context, farmerAcc sdk.AccAddress) (sdk.Coins, error)

WithdrawAllRewards withdraws all accumulated rewards for a farmer.

func (Keeper) WithdrawRewards

func (k Keeper) WithdrawRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, harvest bool) (sdk.Coins, error)

WithdrawRewards withdraws accumulated rewards for a farmer for a given staking coin denom. It decreases outstanding rewards and set the starting epoch of a staking.

type Migrator

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

func NewMigrator

func NewMigrator(keeper Keeper) Migrator

func (Migrator) Migrate1to2

func (m Migrator) Migrate1to2(ctx sdk.Context) 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) CurrentEpochDays

CurrentEpochDays queries current epoch days.

func (Querier) HistoricalRewards

HistoricalRewards queries HistoricalRewards records for a staking coin denom.

func (Querier) Params

Params queries the parameters of the farming module.

func (Querier) Plan

Plan queries a specific plan.

func (Querier) Plans

Plans queries all plans.

func (Querier) Position

Position queries farming position for a farmer.

func (Querier) QueuedStakings

QueuedStakings queries all queued stakings of the farmer.

func (Querier) Rewards

Rewards queries all accumulated rewards for a farmer.

func (Querier) Stakings

Stakings queries all stakings of the farmer.

func (Querier) TotalStakings

TotalStakings queries total staking coin amount for a specific staking coin denom.

func (Querier) UnharvestedRewards

UnharvestedRewards queries all unharvested rewards for the farmer.

Jump to

Keyboard shortcuts

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