keeper

package
v0.0.0-...-def7031 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

nolint: gocritic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of MsgServer for the x/leverage module.

func NewQuerier

func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

Types

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	storeKey sdk.StoreKey,
	paramStore paramtypes.Subspace,
	bk types.BankKeeper,
) Keeper

func (Keeper) BorrowAsset

func (k Keeper) BorrowAsset(ctx sdk.Context, borrowerAddr sdk.AccAddress, loan sdk.Coin) error

BorrowAsset attempts to borrow assets from the leverage module account using collateral uTokens. If asset type is invalid, collateral is insufficient, or module balance is insufficient, we return an error.

func (Keeper) FromTokenToUTokenDenom

func (k Keeper) FromTokenToUTokenDenom(ctx sdk.Context, tokenDenom string) string

FromTokenToUTokenDenom returns the associated uToken denom for the given token denom. If the token denom does not exist, we assume the association is invalid and we return an empty string.

func (Keeper) FromUTokenToTokenDenom

func (k Keeper) FromUTokenToTokenDenom(ctx sdk.Context, uTokenDenom string) string

FromUTokenToTokenDenom returns the associated token denom for the given uToken denom. If the uToken denom does not exist, we assume the association is invalid and we return an empty string.

func (Keeper) GetAllBorrowerLoans

func (k Keeper) GetAllBorrowerLoans(ctx sdk.Context, borrowerAddr sdk.AccAddress) (sdk.Coins, error)

GetAllBorrowerLoans returns an sdk.Coins object containing all open borrows associated with an address

func (Keeper) GetCollateralSetting

func (k Keeper) GetCollateralSetting(ctx sdk.Context, borrowerAddr sdk.AccAddress, denom string) bool

GetCollateralSetting checks if a uToken denom is enabled for use as collateral by a single borrower.

func (Keeper) GetLoan

func (k Keeper) GetLoan(ctx sdk.Context, borrowerAddr sdk.AccAddress, denom string) sdk.Coin

GetLoan returns an sdk.Coin representing how much of a given denom a borrower currently owes.

func (Keeper) GetParams

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

GetParams gets the x/leverage module's parameters.

func (Keeper) IsAcceptedToken

func (k Keeper) IsAcceptedToken(ctx sdk.Context, tokenDenom string) bool

IsAcceptedToken returns true if a given (non-UToken) token denom is an accepted asset type.

func (Keeper) IsAcceptedUToken

func (k Keeper) IsAcceptedUToken(ctx sdk.Context, uTokenDenom string) bool

IsAcceptedUToken returns true if a given uToken denom is an accepted asset type.

func (Keeper) LendAsset

func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr sdk.AccAddress, loan sdk.Coin) error

LendAsset attempts to deposit assets into the leverage module account in exchange for uTokens. If asset type is invalid or account balance is insufficient, we return an error.

func (Keeper) Logger

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

func (Keeper) RepayAsset

func (k Keeper) RepayAsset(ctx sdk.Context, borrowerAddr sdk.AccAddress, payment sdk.Coin) error

RepayAsset attempts to repay an open borrow position with base assets. If asset type is invalid, account balance is insufficient, or no open borrow position exists, we return an error. Additionally, if the amount provided is greater than the full repayment amount, only the necessary amount is transferred.

func (Keeper) SetAsset

func (k Keeper) SetAsset(ctx sdk.Context, asset types.Asset)

SetAsset stores an asset into the x/leverage module's KVStore.

func (Keeper) SetCollateralSetting

func (k Keeper) SetCollateralSetting(ctx sdk.Context, borrowerAddr sdk.AccAddress, denom string, enable bool) error

SetCollateralSetting enables or disables a uToken denom for use as collateral by a single borrower.

func (Keeper) SetParams

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

SetParams sets the x/leverage module's parameters.

func (Keeper) SetRegisteredToken

func (k Keeper) SetRegisteredToken(ctx sdk.Context, token types.Token)

SetRegisteredToken stores a token into the x/leverage module's KVStore.

func (Keeper) SetTokenDenom

func (k Keeper) SetTokenDenom(ctx sdk.Context, tokenDenom string)

SetTokenDenom stores the token denom along with the uToken denom association.

func (Keeper) TotalUTokenSupply

func (k Keeper) TotalUTokenSupply(ctx sdk.Context, uTokenDenom string) sdk.Coin

TotalUTokenSupply returns an sdk.Coin representing the total balance of a given uToken type if valid. If the denom is not an accepted uToken type, we return a zero amount.

func (Keeper) WithdrawAsset

func (k Keeper) WithdrawAsset(ctx sdk.Context, lenderAddr sdk.AccAddress, uToken sdk.Coin) error

WithdrawAsset attempts to deposit uTokens into the leverage module in exchange for the original tokens lent. If the uToken type is invalid or account balance insufficient on either side, we return an error.

Jump to

Keyboard shortcuts

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