keeper

package
v0.0.0-...-6577280 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the swap module

func HandleCommunityPoolDepositProposal

func HandleCommunityPoolDepositProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolDepositProposal) error

HandleCommunityPoolDepositProposal is a handler for executing a passed community pool deposit proposal

func HandleCommunityPoolWithdrawProposal

func HandleCommunityPoolWithdrawProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolWithdrawProposal) error

HandleCommunityPoolWithdrawProposal is a handler for executing a passed community pool withdraw proposal.

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewQueryServerImpl

func NewQueryServerImpl(k Keeper) types.QueryServer

NewQueryServerImpl creates a new server for handling gRPC queries.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers the swap module invariants

func ShareRecordsInvariant

func ShareRecordsInvariant(k Keeper) sdk.Invariant

ShareRecordsInvariant iterates all share records and asserts that they are valid

func VaultRecordsInvariant

func VaultRecordsInvariant(k Keeper) sdk.Invariant

VaultRecordsInvariant iterates all vault records and asserts that they are valid

func VaultSharesInvariant

func VaultSharesInvariant(k Keeper) sdk.Invariant

VaultSharesInvariant iterates all vaults and shares and ensures the total vault shares match the sum of depositor shares

Types

type HardStrategy

type HardStrategy Keeper

HardStrategy defines the strategy that deposits assets to Hard

func (*HardStrategy) Deposit

func (s *HardStrategy) Deposit(ctx sdk.Context, amount sdk.Coin) error

Deposit deposits the specified amount of coins into hard.

func (*HardStrategy) GetEstimatedTotalAssets

func (s *HardStrategy) GetEstimatedTotalAssets(ctx sdk.Context, denom string) (sdk.Coin, error)

GetEstimatedTotalAssets returns the current value of all assets deposited in hard.

func (*HardStrategy) GetStrategyType

func (s *HardStrategy) GetStrategyType() types.StrategyType

GetStrategyType returns the strategy type

func (*HardStrategy) Withdraw

func (s *HardStrategy) Withdraw(ctx sdk.Context, amount sdk.Coin) error

Withdraw withdraws the specified amount of coins from hard.

type Keeper

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

Keeper keeper for the earn module

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	key storetypes.StoreKey,
	paramstore paramtypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	liquidKeeper types.LiquidKeeper,
	hardKeeper types.HardKeeper,
	savingsKeeper types.SavingsKeeper,
	distKeeper types.DistributionKeeper,
) Keeper

NewKeeper creates a new keeper

func (Keeper) AfterVaultDepositCreated

func (k Keeper) AfterVaultDepositCreated(
	ctx sdk.Context,
	vaultDenom string,
	depositor sdk.AccAddress,
	sharesOwned sdk.Dec,
)

AfterVaultDepositCreated - call hook if registered

func (Keeper) BeforeVaultDepositModified

func (k Keeper) BeforeVaultDepositModified(
	ctx sdk.Context,
	vaultDenom string,
	depositor sdk.AccAddress,
	sharesOwned sdk.Dec,
)

BeforeVaultDepositModified - call hook if registered

func (*Keeper) ClearHooks

func (k *Keeper) ClearHooks()

ClearHooks clears the hooks on the keeper

func (*Keeper) ConvertToAssets

func (k *Keeper) ConvertToAssets(ctx sdk.Context, share types.VaultShare) (sdk.Coin, error)

ConvertToAssets converts a given amount of shares to tokens.

func (*Keeper) ConvertToShares

func (k *Keeper) ConvertToShares(ctx sdk.Context, assets sdk.Coin) (types.VaultShare, error)

ConvertToShares converts a given amount of tokens to shares.

func (*Keeper) DeleteVaultRecord

func (k *Keeper) DeleteVaultRecord(ctx sdk.Context, vaultDenom string)

DeleteVaultRecord deletes the vault record for a given denom.

func (*Keeper) DeleteVaultShareRecord

func (k *Keeper) DeleteVaultShareRecord(
	ctx sdk.Context,
	acc sdk.AccAddress,
)

DeleteVaultShareRecord deletes the vault share record for a given account.

func (*Keeper) Deposit

func (k *Keeper) Deposit(
	ctx sdk.Context,
	depositor sdk.AccAddress,
	amount sdk.Coin,
	depositStrategy types.StrategyType,
) error

Deposit adds the provided amount from a depositor to a vault. The vault is specified by the denom in the amount.

func (*Keeper) DepositFromModuleAccount

func (k *Keeper) DepositFromModuleAccount(
	ctx sdk.Context,
	from string,
	wantAmount sdk.Coin,
	withdrawStrategy types.StrategyType,
) error

DepositFromModuleAccount adds the provided amount from a depositor module account to a vault. The vault is specified by the denom in the amount.

func (Keeper) GetAllVaultRecords

func (k Keeper) GetAllVaultRecords(ctx sdk.Context) types.VaultRecords

GetAllVaultRecords returns all vault records from the store.

func (Keeper) GetAllVaultShareRecords

func (k Keeper) GetAllVaultShareRecords(ctx sdk.Context) types.VaultShareRecords

GetAllVaultShareRecords returns all vault share records from the store.

func (*Keeper) GetAllowedVault

func (k *Keeper) GetAllowedVault(
	ctx sdk.Context,
	vaultDenom string,
) (types.AllowedVault, bool)

GetAllowedVault returns the AllowedVault that corresponds to the given denom. If the denom starts with "bfury-" where it will return the "bfury" AllowedVault. Otherwise, it will return the exact match for the corresponding AllowedVault denom.

func (Keeper) GetAllowedVaults

func (k Keeper) GetAllowedVaults(ctx sdk.Context) types.AllowedVaults

GetAllowedVaults returns the list of allowed vaults from the module params.

func (Keeper) GetParams

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

GetParams returns the params from the store

func (*Keeper) GetStrategy

func (k *Keeper) GetStrategy(strategyType types.StrategyType) (Strategy, error)

GetStrategy returns the strategy for the given strategy type.

func (*Keeper) GetVaultAccountShares

func (k *Keeper) GetVaultAccountShares(
	ctx sdk.Context,
	acc sdk.AccAddress,
) (types.VaultShares, bool)

GetVaultAccountShares returns the shares for a single address for all vaults.

func (*Keeper) GetVaultAccountValue

func (k *Keeper) GetVaultAccountValue(
	ctx sdk.Context,
	denom string,
	acc sdk.AccAddress,
) (sdk.Coin, error)

GetVaultAccountValue returns the value of a single address within a vault if the account were to withdraw their entire balance.

func (*Keeper) GetVaultRecord

func (k *Keeper) GetVaultRecord(
	ctx sdk.Context,
	vaultDenom string,
) (types.VaultRecord, bool)

GetVaultRecord returns the vault record for a given denom.

func (*Keeper) GetVaultShareRecord

func (k *Keeper) GetVaultShareRecord(
	ctx sdk.Context,
	acc sdk.AccAddress,
) (types.VaultShareRecord, bool)

GetVaultShareRecord returns the vault share record for a given denom and account.

func (*Keeper) GetVaultTotalShares

func (k *Keeper) GetVaultTotalShares(
	ctx sdk.Context,
	denom string,
) (types.VaultShare, bool)

GetVaultTotalShares returns the total shares of a vault.

func (*Keeper) GetVaultTotalValue

func (k *Keeper) GetVaultTotalValue(
	ctx sdk.Context,
	denom string,
) (sdk.Coin, error)

GetVaultTotalValue returns the total value of a vault, i.e. the realizable total value if the vault were to liquidate its entire strategies.

**Note:** This does not include the tokens held in bank by the module account. If it were to be included, also note that the module account is unblocked and can receive funds from bank sends.

func (Keeper) IterateVaultRecords

func (k Keeper) IterateVaultRecords(
	ctx sdk.Context,
	cb func(record types.VaultRecord) (stop bool),
)

IterateVaultRecords iterates over all vault objects in the store and performs a callback function.

func (Keeper) IterateVaultShareRecords

func (k Keeper) IterateVaultShareRecords(
	ctx sdk.Context,
	cb func(record types.VaultShareRecord) (stop bool),
)

IterateVaultShareRecords iterates over all vault share objects in the store and performs a callback function.

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(sh types.EarnHooks) *Keeper

SetHooks adds hooks to the keeper.

func (Keeper) SetParams

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

SetParams sets params on the store

func (*Keeper) SetVaultRecord

func (k *Keeper) SetVaultRecord(ctx sdk.Context, record types.VaultRecord)

SetVaultRecord sets the vault record for a given denom.

func (*Keeper) SetVaultShareRecord

func (k *Keeper) SetVaultShareRecord(
	ctx sdk.Context,
	record types.VaultShareRecord,
)

SetVaultShareRecord sets the vault share record for a given account.

func (*Keeper) ShareIsDust

func (k *Keeper) ShareIsDust(ctx sdk.Context, share types.VaultShare) (bool, error)

ShareIsDust returns true if the share value is less than 1 coin

func (*Keeper) UpdateVaultRecord

func (k *Keeper) UpdateVaultRecord(
	ctx sdk.Context,
	vaultRecord types.VaultRecord,
)

UpdateVaultRecord updates the vault record in state for a given denom. This deletes it if the supply is zero and updates the state if supply is non-zero.

func (*Keeper) UpdateVaultShareRecord

func (k *Keeper) UpdateVaultShareRecord(
	ctx sdk.Context,
	record types.VaultShareRecord,
)

UpdateVaultShareRecord updates the vault share record in state for a given denom and account. This deletes it if the supply is zero and updates the state if supply is non-zero.

func (*Keeper) Withdraw

func (k *Keeper) Withdraw(
	ctx sdk.Context,
	from sdk.AccAddress,
	wantAmount sdk.Coin,
	withdrawStrategy types.StrategyType,
) (sdk.Coin, error)

Withdraw removes the amount of supplied tokens from a vault and transfers it back to the account.

func (*Keeper) WithdrawFromModuleAccount

func (k *Keeper) WithdrawFromModuleAccount(
	ctx sdk.Context,
	from string,
	wantAmount sdk.Coin,
	withdrawStrategy types.StrategyType,
) (sdk.Coin, error)

WithdrawFromModuleAccount removes the amount of supplied tokens from a vault and transfers it back to the module account. The module account must be unblocked from receiving transfers.

type SavingsStrategy

type SavingsStrategy Keeper

SavingsStrategy defines the strategy that deposits assets to x/savings

func (*SavingsStrategy) Deposit

func (s *SavingsStrategy) Deposit(ctx sdk.Context, amount sdk.Coin) error

Deposit deposits the specified amount of coins into savings.

func (*SavingsStrategy) GetEstimatedTotalAssets

func (s *SavingsStrategy) GetEstimatedTotalAssets(ctx sdk.Context, denom string) (sdk.Coin, error)

GetEstimatedTotalAssets returns the current value of all assets deposited in savings.

func (*SavingsStrategy) GetStrategyType

func (s *SavingsStrategy) GetStrategyType() types.StrategyType

GetStrategyType returns the strategy type

func (*SavingsStrategy) Withdraw

func (s *SavingsStrategy) Withdraw(ctx sdk.Context, amount sdk.Coin) error

Withdraw withdraws the specified amount of coins from savings.

type Strategy

type Strategy interface {
	// GetStrategyType returns the strategy type
	GetStrategyType() types.StrategyType

	// GetEstimatedTotalAssets returns the estimated total assets of the
	// strategy with the specified denom. This is the value if the strategy were
	// to liquidate all assets.
	//
	// **Note:** This may not reflect the true value as it may become outdated
	// from market changes.
	GetEstimatedTotalAssets(ctx sdk.Context, denom string) (sdk.Coin, error)

	// Deposit the specified amount of coins into this strategy.
	Deposit(ctx sdk.Context, amount sdk.Coin) error

	// Withdraw the specified amount of coins from this strategy.
	Withdraw(ctx sdk.Context, amount sdk.Coin) error
}

Strategy is the interface that must be implemented by a strategy.

Jump to

Keyboard shortcuts

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