keeper

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatGrowRatePercent

func CalculatGrowRatePercent(backing_ratio sdk.Int) (sdk.Int, error)

MATH

func CheckCoinDenom

func CheckCoinDenom(coins sdk.Coins, denom string) error

func CheckCoinsLen

func CheckCoinsLen(coins sdk.Coins, amt int) error

Coins Helpers

func GetLendAssetIDBytes

func GetLendAssetIDBytes(id uint64) []byte

func GetLendAssetIDFromBytes

func GetLendAssetIDFromBytes(bz []byte) uint64

func GetLiquidatorPositionIDBytes

func GetLiquidatorPositionIDBytes(id uint64) []byte

func GetLiquidatorPositionIDFromBytes

func GetLiquidatorPositionIDFromBytes(bz []byte) uint64

func GetLoanIDBytes

func GetLoanIDBytes(id uint64) []byte

GetLoanIDBytes returns the byte representation of the ID

func GetLoanIDFromBytes

func GetLoanIDFromBytes(bz []byte) uint64

GetLoanIDFromBytes returns ID in uint64 format from a byte array

func GetPairIDBytes

func GetPairIDBytes(id uint64) []byte

func GetPairIDFromBytes

func GetPairIDFromBytes(bz []byte) uint64

func GetPositionIDBytes

func GetPositionIDBytes(id uint64) []byte

func GetPositionIDFromBytes

func GetPositionIDFromBytes(bz []byte) uint64

Types

type Data

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

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey storetypes.StoreKey,
	ps paramtypes.Subspace,

	bankKeeper types.BankKeeper,
	oracleKeeper types.OracleKeeper,

	stableKeeper types.StableKeeper,
) *Keeper

func (Keeper) AddressEmptyCheck added in v0.1.2

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

func (Keeper) AllPairs added in v0.2.0

func (k Keeper) AllPairs(goCtx context.Context, req *types.AllPairsRequest) (*types.AllPairsResponse, error)

func (Keeper) AppendLendAsset

func (k Keeper) AppendLendAsset(
	ctx sdk.Context,
	LendAsset types.LendAsset,
) uint64

func (Keeper) AppendLiquidatorPosition

func (k Keeper) AppendLiquidatorPosition(
	ctx sdk.Context,
	LiquidatorPosition types.LiquidatorPosition,
) uint64

func (Keeper) AppendLoan

func (k Keeper) AppendLoan(
	ctx sdk.Context,
	loan types.Loan,
) uint64

AppendLoan appends a loan in the store with a new id and update the count

func (Keeper) AppendPair

func (k Keeper) AppendPair(
	ctx sdk.Context,
	pair types.GTokenPair,
) uint64

func (Keeper) AppendPosition

func (k Keeper) AppendPosition(
	ctx sdk.Context,
	Position types.Position,
) uint64

func (Keeper) CalculateAddToReserveValue

func (k Keeper) CalculateAddToReserveValue(ctx sdk.Context, val sdk.Int, gTokenPair types.GTokenPair) (sdk.Int, bool)

func (Keeper) CalculateAmountForRemoveFromCollateral

func (k Keeper) CalculateAmountForRemoveFromCollateral(amt sdk.Int, price sdk.Int) sdk.Int

func (Keeper) CalculateAmountLiquidate

func (k Keeper) CalculateAmountLiquidate(ctx sdk.Context, collateral sdk.Int, borrow sdk.Int) sdk.Int

#nosec

func (Keeper) CalculateCreateLendAmountOut

func (k Keeper) CalculateCreateLendAmountOut(amount sdk.Int, price sdk.Int) sdk.Int

func (Keeper) CalculateDeleteLendAmountOut

func (k Keeper) CalculateDeleteLendAmountOut(amount sdk.Int, price sdk.Int) sdk.Int

func (Keeper) CalculateDepositId

func (k Keeper) CalculateDepositId(address string, denom string) string

func (Keeper) CalculateGTokenAPY

func (k Keeper) CalculateGTokenAPY(lastAmount sdk.Int, growRate sdk.Int, day sdk.Int) sdk.Int

#nosec

func (Keeper) CalculateGTokenAmountOut

func (k Keeper) CalculateGTokenAmountOut(amount sdk.Int, price sdk.Int) sdk.Int

func (Keeper) CalculateGrowRate

func (k Keeper) CalculateGrowRate(ctx sdk.Context, gTokenPair types.GTokenPair) (sdk.Int, error)

func (Keeper) CalculateGrowYield

func (k Keeper) CalculateGrowYield(ctx sdk.Context, gTokenPair types.GTokenPair) (sdk.Int, error)

func (Keeper) CalculateNeedAmountToGet

func (k Keeper) CalculateNeedAmountToGet(borrow_amount sdk.Int, borrow_time sdk.Int) sdk.Int

func (Keeper) CalculatePremiumAmount

func (k Keeper) CalculatePremiumAmount(ctx sdk.Context, amount sdk.Int, price sdk.Int, premium int64) (sdk.Int, sdk.Int)

func (Keeper) CalculateRealYield

func (k Keeper) CalculateRealYield(ctx sdk.Context, gTokenPair types.GTokenPair) (sdk.Int, error)

func (Keeper) CalculateReturnQubeStableAmountOut

func (k Keeper) CalculateReturnQubeStableAmountOut(amount sdk.Int, price sdk.Int) sdk.Int

func (Keeper) CalculateRiskRate

func (k Keeper) CalculateRiskRate(collateral sdk.Int, price sdk.Int, borrow sdk.Int) (sdk.Int, error)

#nosec

func (Keeper) ChangeBorrowMethodStatus added in v0.2.1

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

func (Keeper) ChangeCollateralMethodStatus added in v0.2.1

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

func (Keeper) ChangeDepositMethodStatus added in v0.2.1

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

Grow Helper

func (Keeper) ChangeGrowStakingReserveAddress

func (k Keeper) ChangeGrowStakingReserveAddress(ctx sdk.Context, address sdk.AccAddress) error

func (Keeper) ChangeGrowYieldReserveAddress

func (k Keeper) ChangeGrowYieldReserveAddress(ctx sdk.Context, address sdk.AccAddress) error

func (Keeper) ChangeUSQReserveAddress

func (k Keeper) ChangeUSQReserveAddress(ctx sdk.Context, address sdk.AccAddress) error

func (Keeper) CheckBorrowMethodStatus added in v0.2.1

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

func (Keeper) CheckCollateralMethodStatus added in v0.2.1

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

func (Keeper) CheckDepositAmount

func (k Keeper) CheckDepositAmount(ctx sdk.Context, msgAmountIn string, pair types.GTokenPair) error

Deposit Helpers

func (Keeper) CheckDepositMethodStatus added in v0.2.1

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

func (Keeper) CheckIfLiquidatorPositionAlredyCreate

func (k Keeper) CheckIfLiquidatorPositionAlredyCreate(ctx sdk.Context, depositor string, denom string) error

func (Keeper) CheckIfPositionAlredyCreate

func (k Keeper) CheckIfPositionAlredyCreate(ctx sdk.Context, depositor string, denom string) error

func (Keeper) CheckLiquidator

func (k Keeper) CheckLiquidator(liq sdk.Address, pos types.LiquidatorPosition) error

func (Keeper) CheckLoanIdInPosition

func (k Keeper) CheckLoanIdInPosition(ctx sdk.Context, loanId string, position types.Position) bool

func (Keeper) CheckOracleAssetId

func (k Keeper) CheckOracleAssetId(ctx sdk.Context, LendAsset types.LendAsset) error

Lend Helpers

func (Keeper) CheckRiskRate

func (k Keeper) CheckRiskRate(collateral sdk.Int, price sdk.Int, borrow sdk.Int, desiredAmount sdk.Int) error

func (Keeper) CheckWithdrawalAmount

func (k Keeper) CheckWithdrawalAmount(msgAmountIn string, pair types.GTokenPair) error

func (Keeper) CheckYieldRate

func (k Keeper) CheckYieldRate(ctx sdk.Context, gTokenPair types.GTokenPair) (string, sdk.Int, error)

func (Keeper) CloseLiquidationPosition

Msg for close liquidation postion

func (Keeper) CreateLend

func (k Keeper) CreateLend(goCtx context.Context, msg *types.MsgCreateLend) (*types.MsgCreateLendResponse, error)

Msg for lend asset

func (Keeper) DeleteLend

func (k Keeper) DeleteLend(goCtx context.Context, msg *types.MsgDeleteLend) (*types.MsgDeleteLendResponse, error)

Msg for delete lend

func (Keeper) DepositCollateral

Msg of deposit collateral for borrowing money from x/grow

func (Keeper) ExecuteCloseLiqPosition

func (k Keeper) ExecuteCloseLiqPosition(ctx sdk.Context, msg *types.MsgCloseLiquidationPosition) (error, sdk.Coin)

func (Keeper) ExecuteCreateLiqPosition

func (k Keeper) ExecuteCreateLiqPosition(ctx sdk.Context, msg *types.MsgOpenLiquidationPosition, LendAsset types.LendAsset) (error, string)

func (Keeper) ExecuteDeleteLend

func (k Keeper) ExecuteDeleteLend(ctx sdk.Context, msg *types.MsgDeleteLend, LendAsset types.LendAsset) (error, string)

#nosec

func (Keeper) ExecuteDeposit

func (k Keeper) ExecuteDeposit(ctx sdk.Context, msg *types.MsgGrowDeposit, gTokenPair types.GTokenPair) (error, sdk.Coin)

func (Keeper) ExecuteDepositCollateral

func (k Keeper) ExecuteDepositCollateral(ctx sdk.Context, msg *types.MsgDepositCollateral, LendAsset types.LendAsset) (error, string)

func (Keeper) ExecuteLend

func (k Keeper) ExecuteLend(ctx sdk.Context, msg *types.MsgCreateLend, LendAsset types.LendAsset) (error, sdk.Coin, string)

#nosec

func (Keeper) ExecuteLiquidation

func (k Keeper) ExecuteLiquidation(ctx sdk.Context, liquidateLendPositionList []string) error

#nosec

func (Keeper) ExecuteWithdrawal

func (k Keeper) ExecuteWithdrawal(ctx sdk.Context, msg *types.MsgGrowWithdrawal, gTokenPair types.GTokenPair) (error, sdk.Coin)

func (Keeper) ExecuteWithdrawalCollateral

func (k Keeper) ExecuteWithdrawalCollateral(ctx sdk.Context, msg *types.MsgWithdrawalCollateral, LendAsset types.LendAsset) (error, sdk.Coin)

func (Keeper) FastCoins

func (k Keeper) FastCoins(denom string, amt sdk.Int) sdk.Coins

func (Keeper) GenerateDenomIdHash

func (k Keeper) GenerateDenomIdHash(denom1 string) string

func (Keeper) GenerateLendAssetIdHash

func (k Keeper) GenerateLendAssetIdHash(denom1 string) string

func (Keeper) GenerateLiquidatorPositionId

func (k Keeper) GenerateLiquidatorPositionId(address string, denom string, amount string, premium string) string

func (Keeper) GenerateLoadIdHash

func (k Keeper) GenerateLoadIdHash(denom1 string, denom2 string, amount string, borrower string, time string) string

func (Keeper) GetAllLendAsset

func (k Keeper) GetAllLendAsset(ctx sdk.Context) (list []types.LendAsset)

func (Keeper) GetAllLiquidatorPosition

func (k Keeper) GetAllLiquidatorPosition(ctx sdk.Context) (list []types.LiquidatorPosition)

func (Keeper) GetAllLoan

func (k Keeper) GetAllLoan(ctx sdk.Context) (list []types.Loan)

GetAllLoan returns all loan

func (Keeper) GetAllPair

func (k Keeper) GetAllPair(ctx sdk.Context) (list []types.GTokenPair)

func (Keeper) GetAllPosition

func (k Keeper) GetAllPosition(ctx sdk.Context) (list []types.Position)

func (Keeper) GetAmountIntFromCoins

func (k Keeper) GetAmountIntFromCoins(coins string) (sdk.Int, string, error)

func (Keeper) GetBorrowRate

func (k Keeper) GetBorrowRate(ctx sdk.Context, id string) sdk.Int

func (Keeper) GetDenomIdWithdrawal

func (k Keeper) GetDenomIdWithdrawal(amountIn string) (string, error)

func (Keeper) GetGTokenPrice

func (k Keeper) GetGTokenPrice(ctx sdk.Context, denomID string) (sdk.Int, error)

func (Keeper) GetGrowStakingReserveAddress

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

func (Keeper) GetGrowYieldReserveAddress

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

func (Keeper) GetLastTimeUpdateReserve added in v0.2.0

func (k Keeper) GetLastTimeUpdateReserve(ctx sdk.Context) sdk.Int

func (Keeper) GetLendAssetByID

func (k Keeper) GetLendAssetByID(ctx sdk.Context, id uint64) (val types.LendAsset, found bool)

func (Keeper) GetLendAssetByLendAssetId

func (k Keeper) GetLendAssetByLendAssetId(ctx sdk.Context, LendAssetId string) (val types.LendAsset, found bool)

func (Keeper) GetLendAssetByOracleAssetId

func (k Keeper) GetLendAssetByOracleAssetId(ctx sdk.Context, oracleAssetId string) (val types.LendAsset, err error)

func (Keeper) GetLendAssetCount

func (k Keeper) GetLendAssetCount(ctx sdk.Context) uint64

func (Keeper) GetLendAssetIdByCoins

func (k Keeper) GetLendAssetIdByCoins(amountIn string) (string, error)

func (Keeper) GetLiquidatorPositionByID

func (k Keeper) GetLiquidatorPositionByID(ctx sdk.Context, id uint64) (val types.LiquidatorPosition, found bool)

func (Keeper) GetLiquidatorPositionByLiquidatorPositionId

func (k Keeper) GetLiquidatorPositionByLiquidatorPositionId(ctx sdk.Context, LiquidatorPositionId string) (val types.LiquidatorPosition, found bool)

func (Keeper) GetLiquidatorPositionCount

func (k Keeper) GetLiquidatorPositionCount(ctx sdk.Context) uint64

func (Keeper) GetLoadByLoadId

func (k Keeper) GetLoadByLoadId(ctx sdk.Context, loadId string) (val types.Loan, found bool)

func (Keeper) GetLoan

func (k Keeper) GetLoan(ctx sdk.Context, id uint64) (val types.Loan, found bool)

GetLoan returns a loan from its id

func (Keeper) GetLoanCount

func (k Keeper) GetLoanCount(ctx sdk.Context) uint64

GetLoanCount get the total number of loan

func (Keeper) GetPairByDenomID

func (k Keeper) GetPairByDenomID(ctx sdk.Context, denomID string) (val types.GTokenPair, found bool)

func (Keeper) GetPairByID

func (k Keeper) GetPairByID(ctx sdk.Context, id uint64) (val types.GTokenPair, found bool)

func (Keeper) GetPairByPairID

func (k Keeper) GetPairByPairID(ctx sdk.Context, id string) (stabletypes.Pair, bool)

func (Keeper) GetPairCount

func (k Keeper) GetPairCount(ctx sdk.Context) uint64

func (Keeper) GetParams

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

GetParams get all parameters as types.Params

func (Keeper) GetPositionByID

func (k Keeper) GetPositionByID(ctx sdk.Context, id uint64) (val types.Position, found bool)

func (Keeper) GetPositionByPositionId

func (k Keeper) GetPositionByPositionId(ctx sdk.Context, PositionId string) (val types.Position, found bool)

func (Keeper) GetPositionCount

func (k Keeper) GetPositionCount(ctx sdk.Context) uint64

func (Keeper) GetPriceByDenom

func (k Keeper) GetPriceByDenom(ctx sdk.Context, denom string) (sdk.Int, error)

Price Helpers

func (Keeper) GetRealRate

func (k Keeper) GetRealRate(ctx sdk.Context, id string) sdk.Int

func (Keeper) GetUSQReserveAddress

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

func (Keeper) GrowDeposit added in v0.2.1

Msg for deposit

func (Keeper) GrowWithdrawal added in v0.2.1

Msg for withdrawal

func (Keeper) IncreaseBorrowedAmountInUSDInPosition

func (k Keeper) IncreaseBorrowedAmountInUSDInPosition(ctx sdk.Context, position types.Position, amt sdk.Int) types.Position

func (Keeper) IncreaseGrowStakingReserve

func (k Keeper) IncreaseGrowStakingReserve(ctx sdk.Context, amountIn sdk.Coins, gTokenPair types.GTokenPair, qStablePair stabletypes.Pair) (types.GTokenPair, error)

func (Keeper) LiquidatePosition

func (k Keeper) LiquidatePosition(ctx sdk.Context, liqPosition types.LiquidatorPosition, posId string) (bool, error)

#nosec

func (Keeper) LoanById

func (Keeper) Logger

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

func (Keeper) OpenLiquidationPosition

Msg for open liquidation postion

func (Keeper) PairByDenomId added in v0.2.0

func (Keeper) Params

func (Keeper) ParseAndCheckPremium

func (k Keeper) ParseAndCheckPremium(amount string) (sdk.Int, error)

func (Keeper) PositionById

func (Keeper) PushLoanToPosition

func (k Keeper) PushLoanToPosition(ctx sdk.Context, loanId string, position types.Position) types.Position

func (Keeper) ReduceBorrowedAmountInUSDInPosition

func (k Keeper) ReduceBorrowedAmountInUSDInPosition(ctx sdk.Context, position types.Position, amt sdk.Int) types.Position

func (Keeper) ReduceCollateralInPosition

func (k Keeper) ReduceCollateralInPosition(ctx sdk.Context, position types.Position, amt sdk.Int) types.Position

func (Keeper) ReduceGrowStakingReserve

func (k Keeper) ReduceGrowStakingReserve(ctx sdk.Context, amountIn sdk.Coins, gTokenPair types.GTokenPair) (types.GTokenPair, error)

func (Keeper) RegisterLendAsset

func (k Keeper) RegisterLendAsset(ctx sdk.Context, p types.LendAsset) error

func for gov proposal

func (Keeper) RegisterPair

func (k Keeper) RegisterPair(ctx sdk.Context, p types.GTokenPair) error

#nosec

func (Keeper) RemoveLendAsset

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

func (Keeper) RemoveLiquidatorPosition

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

func (Keeper) RemoveLoan

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

RemoveLoan removes a loan from the store

func (Keeper) RemoveLoanInPosition

func (k Keeper) RemoveLoanInPosition(ctx sdk.Context, loanId string, position types.Position) types.Position

func (Keeper) RemovePair

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

func (Keeper) RemovePosition

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

func (Keeper) SendCoinsFromAccountToModule

func (k Keeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error

func (Keeper) SendCoinsFromModuleToAccount

func (k Keeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error

EndBlocker Helpers

func (Keeper) SetBorrowRate

func (k Keeper) SetBorrowRate(ctx sdk.Context, val sdk.Int, id string) error

Borrow Rate

func (Keeper) SetGrowStakingReserveAddress

func (k Keeper) SetGrowStakingReserveAddress(ctx sdk.Context, newGrowStakingReserveAddress sdk.AccAddress)

func (Keeper) SetGrowYieldReserveAddress

func (k Keeper) SetGrowYieldReserveAddress(ctx sdk.Context, newGrowYieldReserveAddress sdk.AccAddress)

func (Keeper) SetLastTimeUpdateReserve

func (k Keeper) SetLastTimeUpdateReserve(ctx sdk.Context, val sdk.Int) error

LastTimeUpdateReserve

func (Keeper) SetLendAsset

func (k Keeper) SetLendAsset(ctx sdk.Context, LendAsset types.LendAsset)

func (Keeper) SetLendAssetCount

func (k Keeper) SetLendAssetCount(ctx sdk.Context, count uint64)

func (Keeper) SetLiquidatorPosition

func (k Keeper) SetLiquidatorPosition(ctx sdk.Context, LiquidatorPosition types.LiquidatorPosition)

func (Keeper) SetLiquidatorPositionCount

func (k Keeper) SetLiquidatorPositionCount(ctx sdk.Context, count uint64)

func (Keeper) SetLoan

func (k Keeper) SetLoan(ctx sdk.Context, loan types.Loan)

SetLoan set a specific loan in the store

func (Keeper) SetLoanCount

func (k Keeper) SetLoanCount(ctx sdk.Context, count uint64)

SetLoanCount set the total number of loan

func (Keeper) SetPair

func (k Keeper) SetPair(ctx sdk.Context, Pair types.GTokenPair)

func (Keeper) SetPairCount

func (k Keeper) SetPairCount(ctx sdk.Context, count uint64)

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) SetPosition

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

func (Keeper) SetPositionCount

func (k Keeper) SetPositionCount(ctx sdk.Context, count uint64)

func (Keeper) SetRealRate

func (k Keeper) SetRealRate(ctx sdk.Context, val sdk.Int, id string) error

Real Rate

func (Keeper) SetUSQReserveAddress

func (k Keeper) SetUSQReserveAddress(ctx sdk.Context, newUSQReserveAddress sdk.AccAddress)

func (Keeper) UpdateGTokenPrice

func (k Keeper) UpdateGTokenPrice(ctx sdk.Context, gTokenPair types.GTokenPair) error

func (Keeper) WithdrawalCollateral

Msg of withdrawal collateral from x/grow

Jump to

Keyboard shortcuts

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