keeper

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

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 the MsgServer interface for the provided Keeper.

Types

type AmmHooks

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

EpochHooks wrapper struct for tvl keeper

func (AmmHooks) AfterExitPool

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

AfterExitPool is called after ExitPool, ExitSwapShareAmountIn, and ExitSwapExternAmountOut

func (AmmHooks) AfterJoinPool

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

AfterJoinPool is called after JoinPool, JoinSwapExternAmountIn, and JoinSwapShareAmountOut

func (AmmHooks) AfterPoolCreated

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

AfterPoolCreated is called after CreatePool We are already creating accounted pool using amm hooks in accounted pool module, so no need to create it here ideally we should create accounted pool after perpetual pool is needed but then that would follow a complicated process as perpetual module isn't aware of when amm pool is created directly This method also allows if any other module in future requires accounted pool, it doesn't need to do create any new accounted pool.

func (AmmHooks) AfterSwap

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

AfterSwap is called after SwapExactAmountIn and SwapExactAmountOut

type EpochHooks added in v0.48.0

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

EpochHooks wrapper struct for incentive keeper

func (EpochHooks) AfterEpochEnd added in v0.48.0

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

AfterEpochEnd implements EpochHooks

func (EpochHooks) BeforeEpochStart added in v0.48.0

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

BeforeEpochStart implements EpochHooks

type Keeper

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

func NewKeeper

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

func (Keeper) AmmHooks

func (k Keeper) AmmHooks() AmmHooks

Return the wrapper struct

func (Keeper) BeginBlocker

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

func (Keeper) Borrow

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

func (Keeper) BorrowInterestRateComputation

func (k Keeper) BorrowInterestRateComputation(ctx sdk.Context, pool types.Pool) (sdk.Dec, error)

func (Keeper) BorrowInterestRateComputationByPosition

func (k Keeper) BorrowInterestRateComputationByPosition(pool types.Pool, ammPool ammtypes.Pool, position types.Position) (sdk.Dec, error)

func (Keeper) CalOpenPrice added in v0.48.0

func (k Keeper) CalOpenPrice(ctx sdk.Context, mtp *types.MTP, ammPool ammtypes.Pool, baseCurrency string) (math.LegacyDec, error)

func (Keeper) CalcMTPTakeProfitBorrowFactor added in v0.48.0

func (k Keeper) CalcMTPTakeProfitBorrowFactor(mtp types.MTP) (sdk.Dec, error)

func (Keeper) CalcMTPTakeProfitLiability

func (k Keeper) CalcMTPTakeProfitLiability(ctx sdk.Context, mtp *types.MTP, baseCurrency string) (math.Int, error)

func (Keeper) CalcMinCollateral

func (k Keeper) CalcMinCollateral(ctx sdk.Context, leverage sdk.Dec, price sdk.Dec, decimals uint64) (math.Int, error)

CalcMinCollateral calculates the minimum collateral required to open a position

func (Keeper) CalcRepayAmount added in v0.48.0

func (k Keeper) CalcRepayAmount(ctx sdk.Context, mtp *types.MTP, ammPool *ammtypes.Pool, closingRatio sdk.Dec) (repayAmount math.Int, payingLiabilities math.Int, err error)

CalcRepayAmount repay amount is in custody asset for liabilities with closing ratio

func (Keeper) CalcReturnAmount added in v0.47.0

func (k Keeper) CalcReturnAmount(mtp types.MTP, repayAmount math.Int, closingRatio sdk.Dec) (returnAmount math.Int, err error)

need to make sure unpaid liability interest is paid

func (Keeper) CalcTotalLiabilities added in v0.46.0

func (k Keeper) CalcTotalLiabilities(
	ctx sdk.Context,
	assets []types.PoolAsset,
	ammPoolId uint64,
	uusdcDenom string,
) (math.Int, error)

CalcTotalLiabilities computes the total liabilities for a list of pool assets. It processes each asset, adding its liabilities directly if it's denominated in uusdc, or estimating the swap value otherwise.

func (Keeper) CalculatePoolHealth

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

func (Keeper) CalculatePoolHealthByPosition

func (k Keeper) CalculatePoolHealthByPosition(pool *types.Pool, ammPool ammtypes.Pool, position types.Position) sdk.Dec

func (Keeper) CheckAndCloseAtStopLoss added in v0.45.0

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

func (Keeper) CheckAndCloseAtTakeProfit added in v0.48.0

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

func (Keeper) CheckAndLiquidateUnhealthyPosition added in v0.45.0

func (k Keeper) CheckAndLiquidateUnhealthyPosition(ctx sdk.Context, mtp *types.MTP, pool types.Pool, ammPool ammtypes.Pool, baseCurrency string, baseCurrencyDecimal uint64) error

func (Keeper) CheckIfWhitelisted

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

func (Keeper) CheckLowPoolHealth added in v0.48.0

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

func (Keeper) CheckMTPExist added in v0.48.0

func (k Keeper) CheckMTPExist(ctx sdk.Context, mtpAddress sdk.AccAddress, id uint64) bool

func (Keeper) CheckMaxOpenPositions

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

func (Keeper) CheckSameAssetPosition

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

func (Keeper) CheckUserAuthorization

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

func (Keeper) Close

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

func (Keeper) CloseEstimation added in v0.47.0

func (Keeper) ClosePosition added in v0.48.0

func (k Keeper) ClosePosition(ctx sdk.Context, msg *types.MsgClose, baseCurrency string) (*types.MTP, math.Int, error)

func (Keeper) ComputeFundingRate added in v0.48.0

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

func (Keeper) DeleteAllFundingRate added in v0.48.0

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

Deletes all pool blocks at delBlock

func (Keeper) DeleteAllInterestRate added in v0.48.0

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

Deletes all pool blocks at delBlock

func (Keeper) DeleteBorrowRate added in v0.45.0

func (k Keeper) DeleteBorrowRate(ctx sdk.Context, delBlock uint64)

Test it out Deletes all pool blocks at delBlock

func (Keeper) DeleteFundingRate added in v0.45.0

func (k Keeper) DeleteFundingRate(ctx sdk.Context, delBlock uint64)

Test it out Deletes all pool blocks at delBlock

func (Keeper) DeleteToPay added in v0.46.0

func (k Keeper) DeleteToPay(ctx sdk.Context, address sdk.AccAddress, id uint64) error

func (Keeper) DestroyMTP

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

func (Keeper) DewhitelistAddress

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

func (Keeper) EmitCloseEvent added in v0.29.3

func (k Keeper) EmitCloseEvent(ctx sdk.Context, mtp *types.MTP, repayAmount math.Int)

func (Keeper) EmitForceClose

func (k Keeper) EmitForceClose(ctx sdk.Context, mtp *types.MTP, repayAmount math.Int, closer string)

func (Keeper) EmitFundPayment

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

func (Keeper) EmitFundingFeePayment

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

func (Keeper) EmitOpenEvent

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

func (Keeper) EpochHooks added in v0.48.0

func (k Keeper) EpochHooks() EpochHooks

Return the wrapper struct

func (Keeper) EstimateAndRepay

func (k Keeper) EstimateAndRepay(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool *ammtypes.Pool, baseCurrency string, closingRatio sdk.Dec) (math.Int, error)

EstimateAndRepay ammPool has to be pointer because RemoveFromPoolBalance (in Repay) updates pool assets Important to send pointer mtp and pool

func (Keeper) EstimateSwap

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

Swap estimation using amm CalcOutAmtGivenIn function

func (Keeper) EstimateSwapGivenOut

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

Swap estimation using amm CalcInAmtGivenOut function

func (Keeper) ForceCloseLong

func (k Keeper) ForceCloseLong(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, takeFundPayment bool, baseCurrency string) (math.Int, error)

func (Keeper) ForceCloseShort

func (k Keeper) ForceCloseShort(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, takeFundPayment bool, baseCurrency string) (math.Int, error)

func (Keeper) FundingFeeCollection added in v0.48.0

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

func (Keeper) FundingFeeDistribution added in v0.48.0

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

func (Keeper) GetAllBorrowRate added in v0.45.0

func (k Keeper) GetAllBorrowRate(ctx sdk.Context) []types.InterestBlock

func (Keeper) GetAllFundingRate added in v0.45.0

func (k Keeper) GetAllFundingRate(ctx sdk.Context) []types.FundingRateBlock

func (Keeper) GetAllMTPs

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

func (Keeper) GetAllMTPsForAddress added in v0.45.0

func (k Keeper) GetAllMTPsForAddress(ctx sdk.Context, mtpAddress sdk.AccAddress) []*types.MTP

func (Keeper) GetAllPools

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

GetAllPool returns all pool

func (Keeper) GetAllToPay added in v0.46.0

func (Keeper) GetAllToPayStore added in v0.46.0

func (k Keeper) GetAllToPayStore(ctx sdk.Context) []types.ToPay

func (Keeper) GetAllWhitelistedAddress

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

func (Keeper) GetAmmPool

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

func (Keeper) GetAssetPrice added in v0.48.0

func (k Keeper) GetAssetPrice(ctx sdk.Context, asset string) (sdk.Dec, error)

func (Keeper) GetBaseCurreny added in v0.45.0

func (k Keeper) GetBaseCurreny(ctx sdk.Context) (atypes.Entry, bool)

func (Keeper) GetBorrowInterestAmount added in v0.48.0

func (k Keeper) GetBorrowInterestAmount(ctx sdk.Context, mtp *types.MTP) math.Int

func (Keeper) GetBorrowInterestRate added in v0.48.0

func (k Keeper) GetBorrowInterestRate(ctx sdk.Context, startBlock, startTime uint64, poolId uint64, takeProfitBorrowFactor math.LegacyDec) math.LegacyDec

func (Keeper) GetBorrowInterestRateDecrease

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

func (Keeper) GetBorrowInterestRateIncrease

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

func (Keeper) GetBorrowInterestRateMax

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

func (Keeper) GetBorrowInterestRateMin

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

func (Keeper) GetEpochPosition

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

get position of current block in epoch

func (Keeper) GetEstimatedPnL added in v0.48.0

func (k Keeper) GetEstimatedPnL(ctx sdk.Context, mtp types.MTP, baseCurrency string, useTakeProfitPrice bool) (math.Int, error)

func (Keeper) GetForceCloseFundAddress

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

func (Keeper) GetForceCloseFundPercentage

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

func (Keeper) GetFundingDistributionValue added in v0.45.0

func (k Keeper) GetFundingDistributionValue(ctx sdk.Context, startBlock uint64, pool uint64) (long sdk.Dec, short sdk.Dec)

func (Keeper) GetFundingRate added in v0.45.0

func (k Keeper) GetFundingRate(ctx sdk.Context, startBlock uint64, startTime uint64, poolId uint64) (long sdk.Dec, short sdk.Dec)

func (Keeper) GetHealthGainFactor

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

func (Keeper) GetIncrementalBorrowInterestPaymentEnabled

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

func (Keeper) GetIncrementalBorrowInterestPaymentFundAddress

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

func (Keeper) GetIncrementalBorrowInterestPaymentFundPercentage

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

func (Keeper) GetLiquidationPrice added in v0.48.0

func (k Keeper) GetLiquidationPrice(ctx sdk.Context, mtp types.MTP) sdk.Dec

func (Keeper) GetMTP

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

func (Keeper) GetMTPCount

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

func (Keeper) GetMTPData added in v0.48.0

func (k Keeper) GetMTPData(ctx sdk.Context, pagination *query.PageRequest, address sdk.AccAddress, ammPoolId *uint64) ([]*types.MtpAndPrice, *query.PageResponse, error)

func (Keeper) GetMTPHealth added in v0.45.0

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

GetMTPHealth Health = custody / liabilities It's responsibility of outer function to update mtp.BorrowInterestUnpaidLiability using UpdateMTPBorrowInterestUnpaidLiability

func (Keeper) GetMTPIterator

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

func (Keeper) GetMTPs

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

func (Keeper) GetMTPsForAddressWithPagination added in v0.45.0

func (k Keeper) GetMTPsForAddressWithPagination(ctx sdk.Context, mtpAddress sdk.AccAddress, pagination *query.PageRequest) ([]*types.MtpAndPrice, *query.PageResponse, error)

func (Keeper) GetMTPsForPool

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

func (Keeper) GetMaxLeverageParam

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

func (Keeper) GetMaxLimitOrder added in v0.46.0

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

func (Keeper) GetMaxOpenPositions

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

func (Keeper) GetNetOpenInterest added in v0.46.0

func (k Keeper) GetNetOpenInterest(ctx sdk.Context, pool types.Pool) math.Int

GetNetOpenInterest calculates the net open interest for a given pool.

func (Keeper) GetOpenMTPCount

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) GetPerpetualSwapFee added in v0.48.0

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

func (Keeper) GetPool

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

GetPool returns a pool from its index

func (Keeper) GetPoolOpenThreshold

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

func (Keeper) GetPositions

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

func (Keeper) GetPositionsByPool

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

func (Keeper) GetSafetyFactor

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

func (Keeper) GetStatus

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

func (Keeper) GetWhitelist

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

func (Keeper) GetWhitelistAddressIterator

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

func (Keeper) GetWhitelistedAddress

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

func (Keeper) HandleCloseEstimation added in v0.48.0

func (k Keeper) HandleCloseEstimation(ctx sdk.Context, req *types.QueryCloseEstimationRequest) (res *types.QueryCloseEstimationResponse, err error)

func (Keeper) HandleOpenEstimation added in v0.48.0

func (Keeper) IsWhitelisted

func (Keeper) IsWhitelistingEnabled

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

func (Keeper) LeverageLpHooks added in v0.48.0

func (k Keeper) LeverageLpHooks() LeverageLpHooks

Return the wrapper struct

func (Keeper) Logger

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

func (Keeper) MTP

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

func (Keeper) NukeDB added in v0.48.0

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

func (Keeper) OnLeverageLpDisablePool added in v0.48.0

func (k Keeper) OnLeverageLpDisablePool(ctx sdk.Context, ammPool ammtypes.Pool) error

func (Keeper) OnLeverageLpEnablePool added in v0.48.0

func (k Keeper) OnLeverageLpEnablePool(ctx sdk.Context, ammPool ammtypes.Pool) error

func (Keeper) Open

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

func (Keeper) OpenConsolidate

func (k Keeper) OpenConsolidate(ctx sdk.Context, existingMtp *types.MTP, newMtp *types.MTP, msg *types.MsgOpen, baseCurrency string) (*types.MsgOpenResponse, error)

func (Keeper) OpenConsolidateMergeMtp added in v0.48.0

func (k Keeper) OpenConsolidateMergeMtp(ctx sdk.Context, existingMtp *types.MTP, newMtp *types.MTP) (*types.MTP, error)

func (Keeper) OpenDefineAssets added in v0.48.0

func (k Keeper) OpenDefineAssets(ctx sdk.Context, poolId uint64, msg *types.MsgOpen, baseCurrency string, isBroker bool) (*types.MTP, error)

func (Keeper) Params

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

func (Keeper) Pool

func (Keeper) Pools

func (Keeper) ProcessOpen added in v0.48.0

func (k Keeper) ProcessOpen(ctx sdk.Context, mtp *types.MTP, leverage sdk.Dec, eta sdk.Dec, collateralAmountDec sdk.Dec, poolId uint64, msg *types.MsgOpen, baseCurrency string, isBroker bool) (*types.MTP, error)

func (Keeper) RemovePool

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

RemovePool removes a pool from the store

func (Keeper) Repay

func (k Keeper) Repay(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool *ammtypes.Pool, returnAmount math.Int, payingLiabilities math.Int, closingRatio sdk.Dec) error

Repay ammPool has to be pointer because RemoveFromPoolBalance updates pool assets

func (Keeper) ResetStore

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

ResetStore resets all keys in the perpetual module store

func (Keeper) SetBorrowRate added in v0.45.0

func (k Keeper) SetBorrowRate(ctx sdk.Context, block uint64, pool uint64, interest types.InterestBlock)

func (Keeper) SetFundingRate added in v0.45.0

func (k Keeper) SetFundingRate(ctx sdk.Context, block uint64, pool uint64, funding types.FundingRateBlock)

func (*Keeper) SetHooks

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

Set the perpetual hooks.

func (Keeper) SetMTP

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

func (Keeper) SetMTPCount

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

Set MTP count

func (Keeper) SetOpenMTPCount

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

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

func (Keeper) SetToPay added in v0.45.0

func (k Keeper) SetToPay(ctx sdk.Context, toPay *types.ToPay) error

func (Keeper) SettleFunding added in v0.45.0

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

SettleFunding handles funding fee collection and distribution

func (Keeper) SettleMTPBorrowInterestUnpaidLiability added in v0.48.0

func (k Keeper) SettleMTPBorrowInterestUnpaidLiability(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) (math.Int, error)

SettleMTPBorrowInterestUnpaidLiability This does not update BorrowInterestUnpaidLiability, it should be done through UpdateMTPBorrowInterestUnpaidLiability beforehand

func (Keeper) TakeFundPayment

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

func (Keeper) TakeInCustody

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

func (Keeper) TakeOutCustody

func (k Keeper) TakeOutCustody(ctx sdk.Context, mtp types.MTP, pool *types.Pool, amount math.Int) error

func (Keeper) UpdateFundingFee added in v0.48.0

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

func (Keeper) UpdateMTPBorrowInterestUnpaidLiability added in v0.48.0

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

func (Keeper) UpdateMTPTakeProfitBorrowFactor added in v0.48.0

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

func (Keeper) UpdateOpenPrice added in v0.29.17

func (k Keeper) UpdateOpenPrice(ctx sdk.Context, mtp *types.MTP, ammPool ammtypes.Pool, baseCurrency string) error

func (Keeper) UpdatePoolHealth

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

func (Keeper) UpdatedLeverage added in v0.48.0

func (k Keeper) UpdatedLeverage(ctx sdk.Context, mtp types.MTP) (sdk.Dec, error)

func (Keeper) V6_MigrateWhitelistedAddress added in v0.45.0

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

func (Keeper) WhitelistAddress

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

type LeverageLpHooks added in v0.48.0

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

func (LeverageLpHooks) AfterDisablingPool added in v0.48.0

func (h LeverageLpHooks) AfterDisablingPool(ctx sdk.Context, ammPool ammtypes.Pool) error

func (LeverageLpHooks) AfterEnablingPool added in v0.48.0

func (h LeverageLpHooks) AfterEnablingPool(ctx sdk.Context, ammPool ammtypes.Pool) error

func (LeverageLpHooks) AfterLeverageLpPositionClose added in v0.48.0

func (h LeverageLpHooks) AfterLeverageLpPositionClose(ctx sdk.Context, sender sdk.AccAddress) error

func (LeverageLpHooks) AfterLeverageLpPositionOpen added in v0.48.0

func (h LeverageLpHooks) AfterLeverageLpPositionOpen(ctx sdk.Context, sender sdk.AccAddress) error

func (LeverageLpHooks) AfterLeverageLpPositionOpenConsolidate added in v0.48.0

func (h LeverageLpHooks) AfterLeverageLpPositionOpenConsolidate(ctx sdk.Context, sender sdk.AccAddress) error

Jump to

Keyboard shortcuts

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