keeper

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginBlockerProcessMTP added in v0.12.0

func BeginBlockerProcessMTP(ctx sdk.Context, k Keeper, mtp *types.MTP, pool types.Pool, ammPool ammtypes.Pool)

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

Types

type AmmHooks added in v0.11.0

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

Hooks wrapper struct for tvl keeper

func (AmmHooks) AfterExitPool added in v0.11.0

func (h AmmHooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, pool ammtypes.Pool, shareInAmount sdk.Int, exitCoins sdk.Coins)

AfterExitPool is called after ExitPool, ExitSwapShareAmountIn, and ExitSwapExternAmountOut

func (AmmHooks) AfterJoinPool added in v0.11.0

func (h AmmHooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, pool ammtypes.Pool, enterCoins sdk.Coins, shareOutAmount sdk.Int)

AfterJoinPool is called after JoinPool, JoinSwapExternAmountIn, and JoinSwapShareAmountOut

func (AmmHooks) AfterPoolCreated added in v0.11.0

func (h AmmHooks) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, pool ammtypes.Pool)

AfterPoolCreated is called after CreatePool

func (AmmHooks) AfterSwap added in v0.11.0

func (h AmmHooks) AfterSwap(ctx sdk.Context, sender sdk.AccAddress, pool ammtypes.Pool, input sdk.Coins, output sdk.Coins)

AfterSwap is called after SwapExactAmountIn and SwapExactAmountOut

type Hooks added in v0.11.0

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

Hooks wrapper struct for incentive keeper

func (Hooks) AfterEpochEnd added in v0.11.0

func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64)

AfterEpochEnd implements EpochHooks

func (Hooks) BeforeEpochStart added in v0.11.0

func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)

BeforeEpochStart implements EpochHooks

type Keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey storetypes.StoreKey,
	authority string,
	amm types.AmmKeeper,
	bk types.BankKeeper,
	oracleKeeper ammtypes.OracleKeeper,
) *Keeper

func (Keeper) AfterEpochEnd added in v0.11.0

func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ int64)

AfterEpochEnd distributes vested tokens at the end of each epoch

func (Keeper) AfterExitPool added in v0.11.0

func (k Keeper) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool, shareInAmount sdk.Int, exitCoins sdk.Coins)

AfterExitPool is called after ExitPool, ExitSwapShareAmountIn, and ExitSwapExternAmountOut

func (Keeper) AfterJoinPool added in v0.11.0

func (k Keeper) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool, enterCoins sdk.Coins, shareOutAmount sdk.Int)

AfterJoinPool is called after JoinPool, JoinSwapExternAmountIn, and JoinSwapShareAmountOut

func (Keeper) AfterPoolCreated added in v0.11.0

func (k Keeper) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool)

AfterPoolCreated is called after CreatePool

func (Keeper) AfterSwap added in v0.11.0

func (k Keeper) AfterSwap(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool, input sdk.Coins, output sdk.Coins)

AfterSwap is called after SwapExactAmountIn and SwapExactAmountOut

func (Keeper) AmmHooks added in v0.11.0

func (k Keeper) AmmHooks() AmmHooks

Return the wrapper struct

func (Keeper) AmmPoolBalanceCheck added in v0.11.0

func (k Keeper) AmmPoolBalanceCheck(ctx sdk.Context, poolId uint64) error

func (Keeper) BeforeEpochStart added in v0.11.0

func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)

BeforeEpochStart performs a no-op

func (Keeper) BeginBlocker added in v0.12.0

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

func (Keeper) Borrow added in v0.10.0

func (k Keeper) Borrow(ctx sdk.Context, collateralAsset string, custodyAsset string, collateralAmount sdk.Int, custodyAmount sdk.Int, mtp *types.MTP, ammPool *ammtypes.Pool, pool *types.Pool, eta sdk.Dec) error

func (Keeper) CalcMTPConsolidateCollateral added in v0.12.0

func (k Keeper) CalcMTPConsolidateCollateral(ctx sdk.Context, mtp *types.MTP) error

func (Keeper) CalcMTPConsolidateLiability added in v0.12.0

func (k Keeper) CalcMTPConsolidateLiability(ctx sdk.Context, mtp *types.MTP)

func (Keeper) CalcMTPInterestLiabilities added in v0.12.0

func (k Keeper) CalcMTPInterestLiabilities(ctx sdk.Context, mtp *types.MTP, interestRate sdk.Dec, epochPosition, epochLength int64, ammPool ammtypes.Pool, collateralAsset string) sdk.Int

func (Keeper) CalculatePoolHealth added in v0.10.0

func (k Keeper) CalculatePoolHealth(ctx sdk.Context, pool *types.Pool) sdk.Dec

func (Keeper) CheckIfWhitelisted added in v0.10.0

func (k Keeper) CheckIfWhitelisted(ctx sdk.Context, address string) bool

func (Keeper) CheckLongAssets added in v0.12.0

func (k Keeper) CheckLongAssets(ctx sdk.Context, collateralAsset string, borrowAsset string) error

func (Keeper) CheckMaxOpenPositions added in v0.10.0

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

func (Keeper) CheckMinLiabilities added in v0.10.0

func (k Keeper) CheckMinLiabilities(ctx sdk.Context, collateralAmount sdk.Coin, eta sdk.Dec, pool types.Pool, ammPool ammtypes.Pool, custodyAsset string) error

func (Keeper) CheckPoolHealth added in v0.10.0

func (k Keeper) CheckPoolHealth(ctx sdk.Context, poolId uint64) error

func (Keeper) CheckSamePosition added in v0.12.0

func (k Keeper) CheckSamePosition(ctx sdk.Context, msg *types.MsgOpen) *types.MTP

func (Keeper) CheckShortAssets added in v0.12.0

func (k Keeper) CheckShortAssets(ctx sdk.Context, collateralAsset string, borrowAsset string) error

func (Keeper) CheckUserAuthorization added in v0.10.0

func (k Keeper) CheckUserAuthorization(ctx sdk.Context, msg *types.MsgOpen) error

func (Keeper) Close added in v0.11.0

func (k Keeper) Close(ctx sdk.Context, msg *types.MsgClose) (*types.MsgCloseResponse, error)

func (Keeper) CloseLong added in v0.11.0

func (k Keeper) CloseLong(ctx sdk.Context, msg *types.MsgClose) (*types.MTP, sdk.Int, error)

func (Keeper) CloseShort added in v0.12.0

func (k Keeper) CloseShort(ctx sdk.Context, msg *types.MsgClose) (*types.MTP, sdk.Int, error)

func (Keeper) DestroyMTP added in v0.10.0

func (k Keeper) DestroyMTP(ctx sdk.Context, mtpAddress string, id uint64) error

func (Keeper) DewhitelistAddress added in v0.10.0

func (k Keeper) DewhitelistAddress(ctx sdk.Context, address string)

func (Keeper) EmitFundPayment added in v0.10.0

func (k Keeper) EmitFundPayment(ctx sdk.Context, mtp *types.MTP, takeAmount sdk.Int, takeAsset string, paymentType string)

func (Keeper) EmitOpenEvent added in v0.12.0

func (k Keeper) EmitOpenEvent(ctx sdk.Context, mtp *types.MTP)

func (Keeper) EstimateAndRepay added in v0.12.0

func (k Keeper) EstimateAndRepay(ctx sdk.Context, mtp types.MTP, pool types.Pool, ammPool ammtypes.Pool, collateralAsset string, custodyAsset string) (sdk.Int, error)

func (Keeper) EstimateSwap added in v0.10.0

func (k Keeper) EstimateSwap(ctx sdk.Context, tokenInAmount sdk.Coin, tokenOutDenom string, ammPool ammtypes.Pool) (sdk.Int, error)

Swap estimation using amm CalcOutAmtGivenIn function

func (Keeper) EstimateSwapGivenOut added in v0.12.0

func (k Keeper) EstimateSwapGivenOut(ctx sdk.Context, tokenOutAmount sdk.Coin, tokenInDenom string, ammPool ammtypes.Pool) (sdk.Int, error)

Swap estimation using amm CalcInAmtGivenOut function

func (Keeper) GenerateOpenEvent added in v0.10.0

func (k Keeper) GenerateOpenEvent(mtp *types.MTP) sdk.Event

func (Keeper) GetAllMTPs added in v0.10.0

func (k Keeper) GetAllMTPs(ctx sdk.Context) []types.MTP

func (Keeper) GetAllPools added in v0.10.0

func (k Keeper) GetAllPools(ctx sdk.Context) (list []types.Pool)

GetAllPool returns all pool

func (Keeper) GetAllWhitelistedAddress added in v0.10.0

func (k Keeper) GetAllWhitelistedAddress(ctx sdk.Context) []string

func (Keeper) GetAmmPool added in v0.10.0

func (k Keeper) GetAmmPool(ctx sdk.Context, poolId uint64, tradingAsset string) (ammtypes.Pool, error)

func (Keeper) GetAmmPoolBalance added in v0.10.0

func (k Keeper) GetAmmPoolBalance(ctx sdk.Context, ammPool ammtypes.Pool, assetDenom string) (sdk.Int, error)

Get balance of a denom

func (Keeper) GetEnabledPools added in v0.10.0

func (k Keeper) GetEnabledPools(ctx sdk.Context) []uint64

func (Keeper) GetEpochLength added in v0.10.0

func (k Keeper) GetEpochLength(ctx sdk.Context) int64

func (Keeper) GetEpochPosition added in v0.12.0

func (k Keeper) GetEpochPosition(ctx sdk.Context, epochLength int64) int64

get position of current block in epoch

func (Keeper) GetFirstValidPool added in v0.10.0

func (k Keeper) GetFirstValidPool(ctx sdk.Context, borrowAsset string) (uint64, error)

func (Keeper) GetForceCloseFundAddress added in v0.10.0

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

func (Keeper) GetForceCloseFundPercentage added in v0.10.0

func (k Keeper) GetForceCloseFundPercentage(ctx sdk.Context) sdk.Dec

func (Keeper) GetHealthGainFactor added in v0.10.0

func (k Keeper) GetHealthGainFactor(ctx sdk.Context) sdk.Dec

func (Keeper) GetIncrementalInterestPaymentEnabled added in v0.10.0

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

func (Keeper) GetIncrementalInterestPaymentFundAddress added in v0.10.0

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

func (Keeper) GetIncrementalInterestPaymentFundPercentage added in v0.10.0

func (k Keeper) GetIncrementalInterestPaymentFundPercentage(ctx sdk.Context) sdk.Dec

func (Keeper) GetInterestRateDecrease added in v0.10.0

func (k Keeper) GetInterestRateDecrease(ctx sdk.Context) sdk.Dec

func (Keeper) GetInterestRateIncrease added in v0.10.0

func (k Keeper) GetInterestRateIncrease(ctx sdk.Context) sdk.Dec

func (Keeper) GetInterestRateMax added in v0.10.0

func (k Keeper) GetInterestRateMax(ctx sdk.Context) sdk.Dec

func (Keeper) GetInterestRateMin added in v0.10.0

func (k Keeper) GetInterestRateMin(ctx sdk.Context) sdk.Dec

func (Keeper) GetMTP added in v0.10.0

func (k Keeper) GetMTP(ctx sdk.Context, mtpAddress string, id uint64) (types.MTP, error)

func (Keeper) GetMTPAssetIndex added in v0.12.0

func (k Keeper) GetMTPAssetIndex(mtp *types.MTP, collateralAsset string, borrowAsset string) (int, int)

Get Assets Index

func (Keeper) GetMTPCount added in v0.10.0

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

func (Keeper) GetMTPIterator added in v0.10.0

func (k Keeper) GetMTPIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) GetMTPs added in v0.10.0

func (k Keeper) GetMTPs(ctx sdk.Context, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error)

func (Keeper) GetMTPsForAddress added in v0.10.0

func (k Keeper) GetMTPsForAddress(ctx sdk.Context, mtpAddress sdk.Address, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error)

func (Keeper) GetMTPsForPool added in v0.10.0

func (k Keeper) GetMTPsForPool(ctx sdk.Context, ammPoolId uint64, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error)

func (Keeper) GetMarginPoolBalances added in v0.11.0

func (k Keeper) GetMarginPoolBalances(marginPool types.Pool, denom string) (sdk.Int, sdk.Int, sdk.Int)

Get Margin Pool Balance

func (Keeper) GetMaxLeverageParam added in v0.10.0

func (k Keeper) GetMaxLeverageParam(ctx sdk.Context) sdk.Dec

func (Keeper) GetMaxOpenPositions added in v0.10.0

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

func (Keeper) GetOpenMTPCount added in v0.10.0

func (k Keeper) GetOpenMTPCount(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) GetPool added in v0.10.0

func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (val types.Pool, found bool)

GetPool returns a pool from its index

func (Keeper) GetPoolOpenThreshold added in v0.10.0

func (k Keeper) GetPoolOpenThreshold(ctx sdk.Context) sdk.Dec

func (Keeper) GetPositions added in v0.10.0

func (k Keeper) GetPositions(goCtx context.Context, req *types.PositionsRequest) (*types.PositionsResponse, error)

func (Keeper) GetPositionsByPool added in v0.10.0

func (k Keeper) GetPositionsByPool(goCtx context.Context, req *types.PositionsByPoolRequest) (*types.PositionsByPoolResponse, error)

func (Keeper) GetPositionsForAddress added in v0.10.0

func (Keeper) GetRemovalQueueThreshold added in v0.10.0

func (k Keeper) GetRemovalQueueThreshold(ctx sdk.Context) sdk.Dec

func (Keeper) GetSafetyFactor added in v0.10.0

func (k Keeper) GetSafetyFactor(ctx sdk.Context) sdk.Dec

func (Keeper) GetSqModifier added in v0.10.0

func (k Keeper) GetSqModifier(ctx sdk.Context) sdk.Dec

func (Keeper) GetStatus added in v0.10.0

func (k Keeper) GetStatus(goCtx context.Context, req *types.StatusRequest) (*types.StatusResponse, error)

func (Keeper) GetTradingAsset added in v0.12.0

func (k Keeper) GetTradingAsset(collateralAsset string, borrowAsset string) string

func (Keeper) GetWhitelist added in v0.10.0

func (k Keeper) GetWhitelist(goCtx context.Context, req *types.WhitelistRequest) (*types.WhitelistResponse, error)

func (Keeper) GetWhitelistAddressIterator added in v0.10.0

func (k Keeper) GetWhitelistAddressIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) GetWhitelistedAddress added in v0.10.0

func (k Keeper) GetWhitelistedAddress(ctx sdk.Context, pagination *query.PageRequest) ([]string, *query.PageResponse, error)

func (Keeper) HandleInterest added in v0.12.0

func (k Keeper) HandleInterest(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool, collateralAsset string, custodyAsset string) error

func (Keeper) HandleInterestPayment added in v0.10.0

func (k Keeper) HandleInterestPayment(ctx sdk.Context, collateralAsset string, custodyAsset string, interestPayment sdk.Int, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) sdk.Int

func (Keeper) HasSufficientPoolBalance added in v0.10.0

func (k Keeper) HasSufficientPoolBalance(ctx sdk.Context, ammPool ammtypes.Pool, assetDenom string, requiredAmount sdk.Int) bool

Check if amm pool has sufficcient balance

func (Keeper) Hooks added in v0.11.0

func (k Keeper) Hooks() Hooks

Return the wrapper struct

func (Keeper) IncrementalInterestPayment added in v0.10.0

func (k Keeper) IncrementalInterestPayment(ctx sdk.Context, collateralAsset string, custodyAsset string, interestPayment sdk.Int, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) (sdk.Int, error)

func (Keeper) InterestRateComputation added in v0.10.0

func (k Keeper) InterestRateComputation(ctx sdk.Context, pool types.Pool, ammPool ammtypes.Pool) (sdk.Dec, error)

func (Keeper) InvariantCheck added in v0.11.0

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

Check if amm pool balance in bank module is correct

func (Keeper) IsPoolClosed added in v0.10.0

func (k Keeper) IsPoolClosed(ctx sdk.Context, poolId uint64) bool

func (Keeper) IsPoolEnabled added in v0.10.0

func (k Keeper) IsPoolEnabled(ctx sdk.Context, poolId uint64) bool

func (Keeper) IsWhitelisted added in v0.10.0

func (Keeper) IsWhitelistingEnabled added in v0.10.0

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

func (Keeper) Logger

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

func (Keeper) MTP added in v0.10.0

func (k Keeper) MTP(goCtx context.Context, req *types.MTPRequest) (*types.MTPResponse, error)

func (Keeper) Open added in v0.11.0

func (k Keeper) Open(ctx sdk.Context, msg *types.MsgOpen) (*types.MsgOpenResponse, error)

func (Keeper) OpenConsolidate added in v0.12.0

func (k Keeper) OpenConsolidate(ctx sdk.Context, mtp *types.MTP, msg *types.MsgOpen) (*types.MsgOpenResponse, error)

func (Keeper) OpenConsolidateLong added in v0.12.0

func (k Keeper) OpenConsolidateLong(ctx sdk.Context, poolId uint64, mtp *types.MTP, msg *types.MsgOpen) (*types.MTP, error)

func (Keeper) OpenLong added in v0.10.0

func (k Keeper) OpenLong(ctx sdk.Context, poolId uint64, msg *types.MsgOpen) (*types.MTP, error)

func (Keeper) OpenShort added in v0.12.0

func (k Keeper) OpenShort(ctx sdk.Context, poolId uint64, msg *types.MsgOpen) (*types.MTP, error)

func (Keeper) Params

func (k Keeper) Params(goCtx context.Context, req *types.ParamsRequest) (*types.ParamsResponse, error)

func (Keeper) Pool added in v0.10.0

func (Keeper) Pools added in v0.10.0

func (Keeper) PreparePools added in v0.12.0

func (k Keeper) PreparePools(ctx sdk.Context, tradingAsset string) (poolId uint64, ammPool ammtypes.Pool, pool types.Pool, err error)

func (Keeper) ProcessOpenLong added in v0.12.0

func (k Keeper) ProcessOpenLong(ctx sdk.Context, mtp *types.MTP, leverage sdk.Dec, eta sdk.Dec, collateralAmountDec sdk.Dec, poolId uint64, msg *types.MsgOpen) (*types.MTP, error)

func (Keeper) ProcessOpenShort added in v0.12.0

func (k Keeper) ProcessOpenShort(ctx sdk.Context, mtp *types.MTP, leverage sdk.Dec, eta sdk.Dec, collateralAmountDec sdk.Dec, poolId uint64, msg *types.MsgOpen) (*types.MTP, error)

func (Keeper) RemovePool added in v0.10.0

func (k Keeper) RemovePool(
	ctx sdk.Context,
	index uint64,

)

RemovePool removes a pool from the store

func (Keeper) Repay added in v0.10.0

func (k Keeper) Repay(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool, repayAmount sdk.Int, takeFundPayment bool, collateralAsset string) error

func (Keeper) SetEnabledPools added in v0.10.0

func (k Keeper) SetEnabledPools(ctx sdk.Context, pools []uint64)

func (*Keeper) SetHooks added in v0.11.0

func (k *Keeper) SetHooks(gh types.MarginHooks) *Keeper

Set the margin hooks.

func (Keeper) SetMTP added in v0.10.0

func (k Keeper) SetMTP(ctx sdk.Context, mtp *types.MTP) error

func (Keeper) SetMTPCount added in v0.10.0

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

Set MTP count

func (Keeper) SetOpenMTPCount added in v0.10.0

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

Set Open MTP count

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) SetPool added in v0.10.0

func (k Keeper) SetPool(ctx sdk.Context, pool types.Pool)

SetPool set a specific pool in the store from its index

func (Keeper) TakeFundPayment added in v0.10.0

func (k Keeper) TakeFundPayment(ctx sdk.Context, returnAmount sdk.Int, returnAsset string, takePercentage sdk.Dec, fundAddr sdk.AccAddress, ammPool *ammtypes.Pool) (sdk.Int, error)

func (Keeper) TakeInCustody added in v0.10.0

func (k Keeper) TakeInCustody(ctx sdk.Context, mtp types.MTP, pool *types.Pool) error

func (Keeper) TakeOutCustody added in v0.10.0

func (k Keeper) TakeOutCustody(ctx sdk.Context, mtp types.MTP, pool *types.Pool, custodyAsset string) error

func (Keeper) UpdateMTPHealth added in v0.10.0

func (k Keeper) UpdateMTPHealth(ctx sdk.Context, mtp types.MTP, ammPool ammtypes.Pool) (sdk.Dec, error)

func (Keeper) UpdatePoolHealth added in v0.10.0

func (k Keeper) UpdatePoolHealth(ctx sdk.Context, pool *types.Pool) error

func (Keeper) ValidateCollateralAsset added in v0.10.0

func (k Keeper) ValidateCollateralAsset(collateralAsset string) error

func (Keeper) WhitelistAddress added in v0.10.0

func (k Keeper) WhitelistAddress(ctx sdk.Context, address string)

Jump to

Keyboard shortcuts

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