Documentation ¶
Index ¶
- Variables
- func AllInvariants(k Keeper) sdk.Invariant
- func HandlePublicPlanProposal(ctx sdk.Context, k Keeper, proposal *types.PublicPlanProposal) error
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NonNegativeHistoricalRewardsInvariant(k Keeper) sdk.Invariant
- func NonNegativeOutstandingRewardsInvariant(k Keeper) sdk.Invariant
- func OutstandingRewardsAmountInvariant(k Keeper) sdk.Invariant
- func PositiveQueuedStakingAmountInvariant(k Keeper) sdk.Invariant
- func PositiveStakingAmountInvariant(k Keeper) sdk.Invariant
- func PositiveTotalStakingsAmountInvariant(k Keeper) sdk.Invariant
- func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)
- func RemainingRewardsAmountInvariant(k Keeper) sdk.Invariant
- func StakingReservedAmountInvariant(k Keeper) sdk.Invariant
- func UnharvestedRewardsAmountInvariant(k Keeper) sdk.Invariant
- type AllocationInfo
- type Keeper
- func (k Keeper) AddPublicPlanProposal(ctx sdk.Context, proposals []types.AddPlanRequest) error
- func (k Keeper) AdvanceEpoch(ctx sdk.Context) error
- func (k Keeper) AllRewards(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins
- func (k Keeper) AllUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins
- func (k Keeper) AllocateRewards(ctx sdk.Context) error
- func (k Keeper) AllocationInfos(ctx sdk.Context) []AllocationInfo
- func (k Keeper) CalculateRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, ...) (rewards sdk.DecCoins)
- func (k Keeper) CreateFixedAmountPlan(ctx sdk.Context, msg *types.MsgCreateFixedAmountPlan, ...) (types.PlanI, error)
- func (k Keeper) CreateRatioPlan(ctx sdk.Context, msg *types.MsgCreateRatioPlan, ...) (types.PlanI, error)
- func (k Keeper) DecreaseOutstandingRewards(ctx sdk.Context, stakingCoinDenom string, amount sdk.DecCoins)
- func (k Keeper) DecreaseTotalStakings(ctx sdk.Context, stakingCoinDenom string, amount sdk.Int)
- func (k Keeper) DeleteAllHistoricalRewards(ctx sdk.Context, stakingCoinDenom string)
- func (k Keeper) DeleteCurrentEpoch(ctx sdk.Context, stakingCoinDenom string)
- func (k Keeper) DeleteCurrentEpochDays(ctx sdk.Context)
- func (k Keeper) DeleteGlobalPlanId(ctx sdk.Context)
- func (k Keeper) DeleteHistoricalRewards(ctx sdk.Context, stakingCoinDenom string, epoch uint64)
- func (k Keeper) DeleteLastEpochTime(ctx sdk.Context)
- func (k Keeper) DeleteOutstandingRewards(ctx sdk.Context, stakingCoinDenom string)
- func (k Keeper) DeletePlan(ctx sdk.Context, plan types.PlanI)
- func (k Keeper) DeletePublicPlanProposal(ctx sdk.Context, proposals []types.DeletePlanRequest) error
- func (k Keeper) DeleteQueuedStaking(ctx sdk.Context, endTime time.Time, stakingCoinDenom string, ...)
- func (k Keeper) DeleteStaking(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress)
- func (k Keeper) DeleteTotalStakings(ctx sdk.Context, stakingCoinDenom string)
- func (k Keeper) DeleteUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string)
- func (k Keeper) DerivePrivatePlanFarmingPoolAcc(ctx sdk.Context, name string) (sdk.AccAddress, error)
- func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
- func (k Keeper) GetAllQueuedCoinsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins
- func (k Keeper) GetAllQueuedStakingAmountByFarmerAndDenom(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string) sdk.Int
- func (k Keeper) GetAllStakedCoinsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress) sdk.Coins
- func (k Keeper) GetCodec() codec.BinaryCodec
- func (k Keeper) GetCurrentEpoch(ctx sdk.Context, stakingCoinDenom string) uint64
- func (k Keeper) GetCurrentEpochDays(ctx sdk.Context) uint32
- func (k Keeper) GetGlobalPlanId(ctx sdk.Context) uint64
- func (k Keeper) GetHistoricalRewards(ctx sdk.Context, stakingCoinDenom string, epoch uint64) (rewards types.HistoricalRewards, found bool)
- func (k Keeper) GetLastEpochTime(ctx sdk.Context) (t time.Time, found bool)
- func (k Keeper) GetNextPlanIdWithUpdate(ctx sdk.Context) uint64
- func (k Keeper) GetNumActivePrivatePlans(ctx sdk.Context) int
- func (k Keeper) GetOutstandingRewards(ctx sdk.Context, stakingCoinDenom string) (rewards types.OutstandingRewards, found bool)
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetPlan(ctx sdk.Context, id uint64) (plan types.PlanI, found bool)
- func (k Keeper) GetPlans(ctx sdk.Context) (plans []types.PlanI)
- func (k Keeper) GetQueuedStaking(ctx sdk.Context, endTime time.Time, stakingCoinDenom string, ...) (queuedStaking types.QueuedStaking, found bool)
- func (k Keeper) GetStaking(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress) (staking types.Staking, found bool)
- func (k Keeper) GetTotalStakings(ctx sdk.Context, stakingCoinDenom string) (totalStakings types.TotalStakings, found bool)
- func (k Keeper) GetUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string) (rewards types.UnharvestedRewards, found bool)
- func (k Keeper) Harvest(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenoms []string) error
- func (k Keeper) IncreaseOutstandingRewards(ctx sdk.Context, stakingCoinDenom string, amount sdk.DecCoins)
- func (k Keeper) IncreaseTotalStakings(ctx sdk.Context, stakingCoinDenom string, amount sdk.Int)
- func (k Keeper) IncreaseUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, ...)
- func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)
- func (k Keeper) IterateAllUnharvestedRewards(ctx sdk.Context, ...)
- func (k Keeper) IterateCurrentEpochs(ctx sdk.Context, ...)
- func (k Keeper) IterateHistoricalRewards(ctx sdk.Context, ...)
- func (k Keeper) IterateMatureQueuedStakings(ctx sdk.Context, currTime time.Time, ...)
- func (k Keeper) IterateOutstandingRewards(ctx sdk.Context, ...)
- func (k Keeper) IteratePlans(ctx sdk.Context, cb func(plan types.PlanI) (stop bool))
- func (k Keeper) IterateQueuedStakings(ctx sdk.Context, ...)
- func (k Keeper) IterateQueuedStakingsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress, ...)
- func (k Keeper) IterateQueuedStakingsByFarmerAndDenom(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, ...)
- func (k Keeper) IterateQueuedStakingsByFarmerAndDenomReverse(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, ...)
- func (k Keeper) IterateStakings(ctx sdk.Context, ...)
- func (k Keeper) IterateStakingsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress, ...)
- func (k Keeper) IterateTotalStakings(ctx sdk.Context, ...)
- func (k Keeper) IterateUnharvestedRewardsByFarmer(ctx sdk.Context, farmerAcc sdk.AccAddress, ...)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MarshalPlan(plan types.PlanI) ([]byte, error)
- func (k Keeper) ModifyPublicPlanProposal(ctx sdk.Context, proposals []types.ModifyPlanRequest) error
- func (k Keeper) ProcessQueuedCoins(ctx sdk.Context, currTime time.Time)
- func (k Keeper) ReleaseStakingCoins(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoins sdk.Coins) error
- func (k Keeper) RemovePlan(ctx sdk.Context, creator sdk.AccAddress, planId uint64) error
- func (k Keeper) ReserveStakingCoins(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoins sdk.Coins) error
- func (k Keeper) Rewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string) sdk.Coins
- func (k Keeper) SetCurrentEpoch(ctx sdk.Context, stakingCoinDenom string, currentEpoch uint64)
- func (k Keeper) SetCurrentEpochDays(ctx sdk.Context, epochDays uint32)
- func (k Keeper) SetGlobalPlanId(ctx sdk.Context, id uint64)
- func (k Keeper) SetHistoricalRewards(ctx sdk.Context, stakingCoinDenom string, epoch uint64, ...)
- func (k Keeper) SetLastEpochTime(ctx sdk.Context, t time.Time)
- func (k Keeper) SetOutstandingRewards(ctx sdk.Context, stakingCoinDenom string, rewards types.OutstandingRewards)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPlan(ctx sdk.Context, plan types.PlanI)
- func (k Keeper) SetQueuedStaking(ctx sdk.Context, endTime time.Time, stakingCoinDenom string, ...)
- func (k Keeper) SetStaking(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress, ...)
- func (k Keeper) SetTotalStakings(ctx sdk.Context, stakingCoinDenom string, totalStakings types.TotalStakings)
- func (k Keeper) SetUnharvestedRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, ...)
- func (k Keeper) Stake(ctx sdk.Context, farmerAcc sdk.AccAddress, amount sdk.Coins) error
- func (k Keeper) TerminateEndedPlans(ctx sdk.Context) error
- func (k Keeper) TerminatePlan(ctx sdk.Context, plan types.PlanI) error
- func (k Keeper) UnmarshalPlan(bz []byte) (plan types.PlanI, err error)
- func (k Keeper) Unstake(ctx sdk.Context, farmerAcc sdk.AccAddress, amount sdk.Coins) error
- func (k Keeper) ValidateOutstandingRewardsAmount(ctx sdk.Context) error
- func (k Keeper) ValidateRemainingRewardsAmount(ctx sdk.Context) error
- func (k Keeper) ValidateStakingReservedAmount(ctx sdk.Context) error
- func (k Keeper) ValidateUnharvestedRewardsAmount(ctx sdk.Context) error
- func (k Keeper) WithdrawAllRewards(ctx sdk.Context, farmerAcc sdk.AccAddress) (sdk.Coins, error)
- func (k Keeper) WithdrawRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string, ...) (sdk.Coins, error)
- type Migrator
- type Querier
- func (k Querier) CurrentEpochDays(c context.Context, req *types.QueryCurrentEpochDaysRequest) (*types.QueryCurrentEpochDaysResponse, error)
- func (k Querier) HistoricalRewards(c context.Context, req *types.QueryHistoricalRewardsRequest) (*types.QueryHistoricalRewardsResponse, error)
- func (k Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Querier) Plan(c context.Context, req *types.QueryPlanRequest) (*types.QueryPlanResponse, error)
- func (k Querier) Plans(c context.Context, req *types.QueryPlansRequest) (*types.QueryPlansResponse, error)
- func (k Querier) Position(c context.Context, req *types.QueryPositionRequest) (*types.QueryPositionResponse, error)
- func (k Querier) QueuedStakings(c context.Context, req *types.QueryQueuedStakingsRequest) (*types.QueryQueuedStakingsResponse, error)
- func (k Querier) Rewards(c context.Context, req *types.QueryRewardsRequest) (*types.QueryRewardsResponse, error)
- func (k Querier) Stakings(c context.Context, req *types.QueryStakingsRequest) (*types.QueryStakingsResponse, error)
- func (k Querier) TotalStakings(c context.Context, req *types.QueryTotalStakingsRequest) (*types.QueryTotalStakingsResponse, error)
- func (k Querier) UnharvestedRewards(c context.Context, req *types.QueryUnharvestedRewardsRequest) (*types.QueryUnharvestedRewardsResponse, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
AllInvariants runs all invariants of the farming module.
func HandlePublicPlanProposal ¶
HandlePublicPlanProposal is a handler for executing a public plan creation proposal.
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the farming MsgServer interface for the provided Keeper.
func NonNegativeHistoricalRewardsInvariant ¶
NonNegativeHistoricalRewardsInvariant checks that all HistoricalRewards are non-negative.
func NonNegativeOutstandingRewardsInvariant ¶
NonNegativeOutstandingRewardsInvariant checks that all OutstandingRewards are non-negative.
func OutstandingRewardsAmountInvariant ¶
OutstandingRewardsAmountInvariant checks that OutstandingRewards are consistent with rewards that can be withdrawn.
func PositiveQueuedStakingAmountInvariant ¶
PositiveQueuedStakingAmountInvariant checks that the amount of queued staking coins is positive.
func PositiveStakingAmountInvariant ¶
PositiveStakingAmountInvariant checks that the amount of staking coins is positive.
func PositiveTotalStakingsAmountInvariant ¶
PositiveTotalStakingsAmountInvariant checks that all TotalStakings have positive amount.
func RegisterInvariants ¶
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)
RegisterInvariants registers all farming invariants.
func RemainingRewardsAmountInvariant ¶
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 ¶
StakingReservedAmountInvariant checks that the balance of StakingReserveAcc greater than the amount of staked, Queued coins in all staking objects.
func UnharvestedRewardsAmountInvariant ¶
UnharvestedRewardsAmountInvariant checks that UnharvestedRewards are consistent with rewards that can be withdrawn.
Types ¶
type AllocationInfo ¶
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 ¶
AddPublicPlanProposal adds a new public plan once the governance proposal is passed.
func (Keeper) AdvanceEpoch ¶
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 ¶
AllRewards returns truncated total rewards accumulated until the current epoch for a farmer.
func (Keeper) AllUnharvestedRewards ¶
AllUnharvestedRewards returns all unharvested rewards of a farmer.
func (Keeper) AllocateRewards ¶
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 ¶
DecreaseTotalStakings decreases total stakings for given staking coin denom by given amount.
func (Keeper) DeleteAllHistoricalRewards ¶
DeleteAllHistoricalRewards deletes all historical rewards for a staking coin denom.
func (Keeper) DeleteCurrentEpoch ¶
DeleteCurrentEpoch deletes current epoch info for a given staking coin denom.
func (Keeper) DeleteCurrentEpochDays ¶
func (Keeper) DeleteGlobalPlanId ¶
func (Keeper) DeleteHistoricalRewards ¶
DeleteHistoricalRewards deletes historical rewards for a given staking coin denom and an epoch number.
func (Keeper) DeleteLastEpochTime ¶
func (Keeper) DeleteOutstandingRewards ¶
DeleteOutstandingRewards deletes outstanding rewards for a given staking coin denom.
func (Keeper) DeletePlan ¶
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 ¶
DeleteStaking deletes a staking for given staking coin denom and farmer.
func (Keeper) DeleteTotalStakings ¶
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 ¶
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 ¶
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 ¶
GetCurrentEpoch returns the current epoch number for a given staking coin denom.
func (Keeper) GetCurrentEpochDays ¶
GetCurrentEpochDays returns the current epoch days(period).
func (Keeper) GetGlobalPlanId ¶
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 ¶
GetLastEpochTime returns the last time the epoch ended.
func (Keeper) GetNextPlanIdWithUpdate ¶
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 ¶
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) 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 ¶
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 ¶
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) MarshalPlan ¶
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 ¶
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 ¶
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 ¶
SetCurrentEpoch sets the current epoch number for a given staking coin denom.
func (Keeper) SetCurrentEpochDays ¶
SetCurrentEpochDays sets the current epoch days(period).
func (Keeper) SetGlobalPlanId ¶
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 ¶
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) 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 ¶
Stake stores staking coins to queued coins, and it will be processed in the next epoch.
func (Keeper) TerminateEndedPlans ¶
TerminateEndedPlans terminates plans that have been ended.
func (Keeper) TerminatePlan ¶
TerminatePlan marks the plan as terminated. It moves the plan under different store key, which is for terminated plans.
func (Keeper) UnmarshalPlan ¶
UnmarshalPlan returns a plan from raw serialized bytes of a Proto-based Plan type.
func (Keeper) Unstake ¶
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 ¶
ValidateOutstandingRewardsAmount checks that the balance of the rewards reserve pool is greater than the total amount of outstanding rewards.
func (Keeper) ValidateRemainingRewardsAmount ¶
ValidateRemainingRewardsAmount checks that the balance of the rewards reserve pool is greater than the total amount of unwithdrawn rewards.
func (Keeper) ValidateStakingReservedAmount ¶
ValidateStakingReservedAmount checks that the balance of StakingReserveAcc greater than the amount of staked, queued coins in all staking objects.
func (Keeper) ValidateUnharvestedRewardsAmount ¶
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 ¶
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 ¶
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 ¶
func (k Querier) CurrentEpochDays(c context.Context, req *types.QueryCurrentEpochDaysRequest) (*types.QueryCurrentEpochDaysResponse, error)
CurrentEpochDays queries current epoch days.
func (Querier) HistoricalRewards ¶
func (k Querier) HistoricalRewards(c context.Context, req *types.QueryHistoricalRewardsRequest) (*types.QueryHistoricalRewardsResponse, error)
HistoricalRewards queries HistoricalRewards records for a staking coin denom.
func (Querier) Params ¶
func (k Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params queries the parameters of the farming module.
func (Querier) Plan ¶
func (k Querier) Plan(c context.Context, req *types.QueryPlanRequest) (*types.QueryPlanResponse, error)
Plan queries a specific plan.
func (Querier) Plans ¶
func (k Querier) Plans(c context.Context, req *types.QueryPlansRequest) (*types.QueryPlansResponse, error)
Plans queries all plans.
func (Querier) Position ¶
func (k Querier) Position(c context.Context, req *types.QueryPositionRequest) (*types.QueryPositionResponse, error)
Position queries farming position for a farmer.
func (Querier) QueuedStakings ¶
func (k Querier) QueuedStakings(c context.Context, req *types.QueryQueuedStakingsRequest) (*types.QueryQueuedStakingsResponse, error)
QueuedStakings queries all queued stakings of the farmer.
func (Querier) Rewards ¶
func (k Querier) Rewards(c context.Context, req *types.QueryRewardsRequest) (*types.QueryRewardsResponse, error)
Rewards queries all accumulated rewards for a farmer.
func (Querier) Stakings ¶
func (k Querier) Stakings(c context.Context, req *types.QueryStakingsRequest) (*types.QueryStakingsResponse, error)
Stakings queries all stakings of the farmer.
func (Querier) TotalStakings ¶
func (k Querier) TotalStakings(c context.Context, req *types.QueryTotalStakingsRequest) (*types.QueryTotalStakingsResponse, error)
TotalStakings queries total staking coin amount for a specific staking coin denom.
func (Querier) UnharvestedRewards ¶
func (k Querier) UnharvestedRewards(c context.Context, req *types.QueryUnharvestedRewardsRequest) (*types.QueryUnharvestedRewardsResponse, error)
UnharvestedRewards queries all unharvested rewards for the farmer.