keeper

package
v4.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

func CanWithdrawInvariant

func CanWithdrawInvariant(k Keeper) sdk.Invariant

CanWithdrawInvariant checks that all farmers can withdraw their rewards.

func HandleFarmingPlanProposal

func HandleFarmingPlanProposal(ctx sdk.Context, k Keeper, p *types.FarmingPlanProposal) error

HandleFarmingPlanProposal is a handler for executing a farming plan proposal.

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func OutstandingRewardsInvariant

func OutstandingRewardsInvariant(k Keeper) sdk.Invariant

OutstandingRewardsInvariant checks that the outstanding rewards of all farms are not smaller than the farm's current accrued rewards, and the reward pool has sufficient balances for those rewards.

func ReferenceCountInvariant

func ReferenceCountInvariant(k Keeper) sdk.Invariant

ReferenceCountInvariant checks that the all historical rewards object has consistent reference counts with all farms and positions.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

func TotalFarmingAmountInvariant

func TotalFarmingAmountInvariant(k Keeper) sdk.Invariant

TotalFarmingAmountInvariant checks that all farm's total farming amount are equal to the sum of all the positions' farming amount which belong to the farm.

Types

type Keeper

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

Keeper of the module's store.

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey sdk.StoreKey,
	paramSpace paramstypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	liquidityKeeper types.LiquidityKeeper,
) Keeper

NewKeeper creates a new Keeper instance.

func (Keeper) AllocateRewards

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

AllocateRewards allocates the current block's rewards to the farms based on active plans.

func (Keeper) CanCreatePrivatePlan

func (k Keeper) CanCreatePrivatePlan(ctx sdk.Context) bool

CanCreatePrivatePlan returns true if the current number of non-terminated private plans is less than the limit.

func (Keeper) CreatePrivatePlan

func (k Keeper) CreatePrivatePlan(
	ctx sdk.Context, creatorAddr sdk.AccAddress, description string,
	rewardAllocs []types.RewardAllocation, startTime, endTime time.Time,
) (types.Plan, error)

CreatePrivatePlan creates a new private farming plan.

func (Keeper) CreatePublicPlan

func (k Keeper) CreatePublicPlan(
	ctx sdk.Context, description string,
	farmingPoolAddr sdk.AccAddress,
	rewardAllocs []types.RewardAllocation, startTime, endTime time.Time,
) (types.Plan, error)

CreatePublicPlan creates a new public farming plan.

func (Keeper) DeleteHistoricalRewards

func (k Keeper) DeleteHistoricalRewards(ctx sdk.Context, denom string, period uint64)

func (Keeper) DeletePosition

func (k Keeper) DeletePosition(ctx sdk.Context, farmerAddr sdk.AccAddress, denom string)

func (Keeper) ExportGenesis

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

ExportGenesis returns the module's exported genesis.

func (Keeper) Farm

func (k Keeper) Farm(ctx sdk.Context, farmerAddr sdk.AccAddress, coin sdk.Coin) (withdrawnRewards sdk.Coins, err error)

Farm locks the coin. The farmer's rewards accrued in the given coin's denom are sent to the farmer. Farm creates a new farm object for the given coin's denom, if there wasn't.

func (Keeper) GetFarm

func (k Keeper) GetFarm(ctx sdk.Context, denom string) (farm types.Farm, found bool)

func (Keeper) GetFeeCollector

func (k Keeper) GetFeeCollector(ctx sdk.Context) (feeCollector string)

func (Keeper) GetHistoricalRewards

func (k Keeper) GetHistoricalRewards(ctx sdk.Context, denom string, period uint64) (hist types.HistoricalRewards, found bool)

func (Keeper) GetLastBlockTime

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

func (Keeper) GetLastPlanId

func (k Keeper) GetLastPlanId(ctx sdk.Context) (id uint64, found bool)

func (Keeper) GetMaxBlockDuration

func (k Keeper) GetMaxBlockDuration(ctx sdk.Context) (d time.Duration)

func (Keeper) GetMaxNumPrivatePlans

func (k Keeper) GetMaxNumPrivatePlans(ctx sdk.Context) (num uint32)

func (Keeper) GetNumPrivatePlans

func (k Keeper) GetNumPrivatePlans(ctx sdk.Context) (num uint64)

func (Keeper) GetParams

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

GetParams returns the parameters for the module.

func (Keeper) GetPlan

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

func (Keeper) GetPosition

func (k Keeper) GetPosition(ctx sdk.Context, farmerAddr sdk.AccAddress, denom string) (position types.Position, found bool)

func (Keeper) GetPrivatePlanCreationFee

func (k Keeper) GetPrivatePlanCreationFee(ctx sdk.Context) (fee sdk.Coins)

func (Keeper) Harvest

func (k Keeper) Harvest(ctx sdk.Context, farmerAddr sdk.AccAddress, denom string) (withdrawnRewards sdk.Coins, err error)

Harvest sends the farmer's rewards accrued in the denom to the farmer.

func (Keeper) InitGenesis

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

InitGenesis initializes the module's state from a provided genesis state.

func (Keeper) IterateAllFarms

func (k Keeper) IterateAllFarms(ctx sdk.Context, cb func(denom string, farm types.Farm) (stop bool))

func (Keeper) IterateAllHistoricalRewards

func (k Keeper) IterateAllHistoricalRewards(ctx sdk.Context, cb func(denom string, period uint64, hist types.HistoricalRewards) (stop bool))

func (Keeper) IterateAllPlans

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

func (Keeper) IterateAllPositions

func (k Keeper) IterateAllPositions(ctx sdk.Context, cb func(position types.Position) (stop bool))

func (Keeper) IteratePositionsByFarmer

func (k Keeper) IteratePositionsByFarmer(ctx sdk.Context, farmerAddr sdk.AccAddress, cb func(position types.Position) (stop bool))

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) PoolRewardWeight

func (k Keeper) PoolRewardWeight(ctx sdk.Context, pool liquiditytypes.Pool, pair liquiditytypes.Pair) sdk.Dec

PoolRewardWeight returns the pool's reward weight.

func (Keeper) Rewards

func (k Keeper) Rewards(ctx sdk.Context, farmerAddr sdk.AccAddress, denom string) sdk.DecCoins

Rewards returns the farmer's rewards accrued in the denom so far. Rewards is a convenient query method existing for external modules.

func (Keeper) SetFarm

func (k Keeper) SetFarm(ctx sdk.Context, denom string, farm types.Farm)

func (Keeper) SetFeeCollector

func (k Keeper) SetFeeCollector(ctx sdk.Context, feeCollector string)

func (Keeper) SetHistoricalRewards

func (k Keeper) SetHistoricalRewards(ctx sdk.Context, denom string, period uint64, hist types.HistoricalRewards)

func (Keeper) SetLastBlockTime

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

func (Keeper) SetLastPlanId

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

func (Keeper) SetMaxBlockDuration

func (k Keeper) SetMaxBlockDuration(ctx sdk.Context, d time.Duration)

func (Keeper) SetMaxNumPrivatePlans

func (k Keeper) SetMaxNumPrivatePlans(ctx sdk.Context, num uint32)

func (Keeper) SetNumPrivatePlans

func (k Keeper) SetNumPrivatePlans(ctx sdk.Context, num uint64)

func (Keeper) SetParams

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

SetParams sets the parameters for the module.

func (Keeper) SetPlan

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

func (Keeper) SetPosition

func (k Keeper) SetPosition(ctx sdk.Context, position types.Position)

func (Keeper) SetPrivatePlanCreationFee

func (k Keeper) SetPrivatePlanCreationFee(ctx sdk.Context, fee sdk.Coins)

func (Keeper) TerminateEndedPlans

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

TerminateEndedPlans iterates through all plans and terminate the plans which should be ended by the current block time.

func (Keeper) TerminatePlan

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

TerminatePlan mark the plan as terminated and send remaining balances in the farming pool to the termination address.

func (Keeper) TotalRewards

func (k Keeper) TotalRewards(ctx sdk.Context, farmerAddr sdk.AccAddress) (rewards sdk.DecCoins)

TotalRewards returns the farmer's rewards accrued in all denoms so far. TotalRewards is a convenient query method existing for external modules.

func (Keeper) Unfarm

func (k Keeper) Unfarm(ctx sdk.Context, farmerAddr sdk.AccAddress, coin sdk.Coin) (withdrawnRewards sdk.Coins, err error)

Unfarm unlocks the coin. The farmer's rewards accrued in the given coin's denom are sent to the farmer. If the remaining farming coin amount becomes zero, the farming position is deleted.

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

func (Querier) Params

Params queries the parameters of the lending module.

func (Querier) Plan

func (Querier) Plans

func (Querier) Rewards

Jump to

Keyboard shortcuts

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