keeper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EnableAdvanceEpoch = 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 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 RewardPoolAddresses 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.

Types

type AllocationInfo

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

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,
	blockedAddrs map[string]bool,
) 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.AddRequestProposal) error

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

func (Keeper) AdvanceEpoch

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

func (Keeper) AllocateRewards

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

func (Keeper) AllocationInfos

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

func (Keeper) CalculateRewards

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

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)

func (Keeper) DecreaseTotalStakings

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

func (Keeper) DeleteHistoricalRewards

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

func (Keeper) DeleteOutstandingRewards

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

func (Keeper) DeletePublicPlanProposal

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

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

func (Keeper) DeleteQueuedStaking

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

func (Keeper) DeleteStaking

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

func (Keeper) DeleteTotalStakings

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

func (Keeper) ExportGenesis

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

ExportGenesis returns the farming module's genesis state.

func (Keeper) GeneratePrivatePlanFarmingPoolAddress

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

func (Keeper) GetAllPlans

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

GetAllPlans returns all plans in the Keeper.

func (Keeper) GetAllQueuedStakedCoinsByFarmer

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

func (Keeper) GetAllStakedCoinsByFarmer

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

func (Keeper) GetCodec

func (k Keeper) GetCodec() codec.BinaryCodec

GetCodec return codec.Codec object used by the keeper

func (Keeper) GetCurrentEpoch

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

func (Keeper) GetCurrentEpochDays

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

GetCurrentEpochDays returns the current epoch days.

func (Keeper) GetFarmingFeeCollectorAcc

func (k Keeper) GetFarmingFeeCollectorAcc(ctx sdk.Context) sdk.AccAddress

GetFarmingFeeCollectorAcc returns module account for the farming fee collector account.

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)

func (Keeper) GetLastEpochTime

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

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) GetOutstandingRewards

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

func (Keeper) GetParams

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

GetParams gets the parameters for the farming module.

func (Keeper) GetPlan

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

GetPlan implements PlanI.

func (Keeper) GetQueuedStaking

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

func (Keeper) GetRewardsReservePoolAcc

func (k Keeper) GetRewardsReservePoolAcc(ctx sdk.Context) sdk.AccAddress

GetRewardsReservePoolAcc returns temporary module account for Reward coins Reserve Pool account

func (Keeper) GetStaking

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

GetStaking returns a specific staking identified by id.

func (Keeper) GetStakingReservePoolAcc

func (k Keeper) GetStakingReservePoolAcc(ctx sdk.Context) sdk.AccAddress

GetStakingReservePoolAcc returns module account for Staking Reserve Pool account

func (Keeper) GetTotalStakings

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

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)

func (Keeper) IncreaseTotalStakings

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

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) IterateAllPlans

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

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

func (Keeper) IterateCurrentEpochs

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

func (Keeper) IterateHistoricalRewards

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

func (Keeper) IterateOutstandingRewards

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

func (Keeper) IterateQueuedStakings

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

func (Keeper) IterateQueuedStakingsByFarmer

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

func (Keeper) IterateStakings

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

func (Keeper) IterateStakingsByFarmer

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

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 protobuf serializes an Plan interface

func (Keeper) NewPlan

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

NewPlan sets the next plan number to a given plan interface

func (Keeper) ProcessQueuedCoins

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

ProcessQueuedCoins moves queued coins into staked coins.

func (Keeper) ReleaseStakingCoins

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

ReleaseStakingCoins sends staking coins back to the farmer.

func (Keeper) RemovePlan

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

RemovePlan removes an plan for the plan mapper store. NOTE: this will cause supply invariant violation if called

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) SetCurrentEpoch

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

func (Keeper) SetCurrentEpochDays

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

SetCurrentEpochDays sets the current epoch days.

func (Keeper) SetGlobalPlanId

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

SetGlobalPlanId set the global Plan ID counter.

func (Keeper) SetHistoricalRewards

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

func (Keeper) SetLastEpochTime

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

func (Keeper) SetOutstandingRewards

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

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 implements PlanI.

func (Keeper) SetQueuedStaking

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

func (Keeper) SetStaking

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

SetStaking implements Staking.

func (Keeper) SetTotalStakings

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

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) TerminatePlan

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

TerminatePlan sends all remaining coins in the plan's farming pool to the termination address and mark the plan as terminated.

func (Keeper) UnmarshalPlan

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

UnmarshalPlan returns an Plan interface from raw encoded plan 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.

func (Keeper) UpdatePublicPlanProposal

func (k Keeper) UpdatePublicPlanProposal(ctx sdk.Context, proposals []*types.UpdateRequestProposal) error

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

func (Keeper) ValidateRemainingRewardsAmount

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

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

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) WithdrawAllRewards

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

func (Keeper) WithdrawRewards

func (k Keeper) WithdrawRewards(ctx sdk.Context, farmerAcc sdk.AccAddress, stakingCoinDenom string) (sdk.Coins, 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) 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) Rewards

Jump to

Keyboard shortcuts

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