Documentation ¶
Index ¶
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- type AmmHooks
- func (h AmmHooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool, ...) error
- func (h AmmHooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool, ...) error
- func (h AmmHooks) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, pool ammtypes.Pool) error
- func (h AmmHooks) AfterSwap(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool, input sdk.Coins, ...) error
- type EpochHooks
- type Keeper
- func (k Keeper) AmmHooks() AmmHooks
- func (k Keeper) BeginBlocker(ctx sdk.Context)
- func (k Keeper) Borrow(ctx sdk.Context, collateralAmount math.Int, custodyAmount math.Int, ...) error
- func (k Keeper) BorrowInterestRateComputation(ctx sdk.Context, pool types.Pool) (math.LegacyDec, error)
- func (k Keeper) BorrowInterestRateComputationByPosition(pool types.Pool, ammPool ammtypes.Pool, position types.Position) (math.LegacyDec, error)
- func (k Keeper) CalcMTPTakeProfitLiability(ctx sdk.Context, mtp types.MTP) (math.Int, error)
- func (k Keeper) CalcMinCollateral(ctx sdk.Context, leverage sdkmath.LegacyDec, price sdkmath.LegacyDec, ...) (sdkmath.Int, error)
- func (k Keeper) CalcRepayAmount(ctx sdk.Context, mtp *types.MTP, ammPool *ammtypes.Pool, ...) (repayAmount, payingLiabilities math.Int, ...)
- func (k Keeper) CalcReturnAmount(mtp types.MTP, repayAmount math.Int, closingRatio math.LegacyDec) (returnAmount math.Int, err error)
- func (k Keeper) CalculatePoolHealth(ctx sdk.Context, pool *types.Pool) math.LegacyDec
- func (k Keeper) CalculatePoolHealthByPosition(pool *types.Pool, ammPool ammtypes.Pool, position types.Position) math.LegacyDec
- func (k Keeper) CheckAndCloseAtStopLoss(ctx sdk.Context, mtp *types.MTP, pool types.Pool, baseCurrency string) error
- func (k Keeper) CheckAndCloseAtTakeProfit(ctx sdk.Context, mtp *types.MTP, pool types.Pool, baseCurrency string) error
- func (k Keeper) CheckAndLiquidateUnhealthyPosition(ctx sdk.Context, mtp *types.MTP, pool types.Pool, ammPool ammtypes.Pool, ...) error
- func (k Keeper) CheckIfWhitelisted(ctx sdk.Context, address sdk.AccAddress) bool
- func (k Keeper) CheckLowPoolHealthAndMinimumCustody(ctx sdk.Context, poolId uint64) error
- func (k Keeper) CheckMTPExist(ctx sdk.Context, mtpAddress sdk.AccAddress, id uint64) bool
- func (k Keeper) CheckMaxOpenPositions(ctx sdk.Context) error
- func (k Keeper) CheckMinimumCustodyAmt(ctx sdk.Context, poolId uint64) error
- func (k Keeper) CheckSameAssetPosition(ctx sdk.Context, msg *types.MsgOpen) *types.MTP
- func (k Keeper) CheckUserAuthorization(ctx sdk.Context, msg *types.MsgOpen) error
- func (k Keeper) Close(ctx sdk.Context, msg *types.MsgClose) (*types.MsgCloseResponse, error)
- func (k Keeper) CloseEstimation(goCtx context.Context, req *types.QueryCloseEstimationRequest) (res *types.QueryCloseEstimationResponse, err error)
- func (k Keeper) ClosePosition(ctx sdk.Context, msg *types.MsgClose, baseCurrency string) (*types.MTP, math.Int, math.LegacyDec, error)
- func (k Keeper) ComputeFundingRate(ctx sdk.Context, pool types.Pool) (math.LegacyDec, math.LegacyDec)
- func (k Keeper) DeleteAllFundingRate(ctx sdk.Context)
- func (k Keeper) DeleteAllInterestRate(ctx sdk.Context)
- func (k Keeper) DeleteAllToPay(ctx sdk.Context) error
- func (k Keeper) DeleteBorrowRate(ctx sdk.Context, delBlock uint64)
- func (k Keeper) DeleteFundingRate(ctx sdk.Context, delBlock uint64)
- func (k Keeper) DestroyMTP(ctx sdk.Context, mtpAddress sdk.AccAddress, id uint64) error
- func (k Keeper) DewhitelistAddress(ctx sdk.Context, address sdk.AccAddress)
- func (k Keeper) EmitCloseEvent(ctx sdk.Context, mtp *types.MTP, repayAmount sdkmath.Int, ...)
- func (k Keeper) EmitForceClose(ctx sdk.Context, eventType string, mtp *types.MTP, repayAmount math.Int, ...)
- func (k Keeper) EmitFundPayment(ctx sdk.Context, mtp *types.MTP, takeAmount math.Int, takeAsset string, ...)
- func (k Keeper) EmitFundingFeePayment(ctx sdk.Context, mtp *types.MTP, takeAmount math.Int, takeAsset string, ...)
- func (k Keeper) EmitOpenEvent(ctx sdk.Context, mtp *types.MTP)
- func (k Keeper) EpochHooks() EpochHooks
- func (k Keeper) EstimateAndRepay(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool *ammtypes.Pool, ...) (math.Int, error)
- func (k Keeper) EstimateSwapGivenIn(ctx sdk.Context, tokenInAmount sdk.Coin, tokenOutDenom string, ...) (math.Int, math.LegacyDec, math.LegacyDec, error)
- func (k Keeper) EstimateSwapGivenOut(ctx sdk.Context, tokenOutAmount sdk.Coin, tokenInDenom string, ...) (math.Int, math.LegacyDec, math.LegacyDec, error)
- func (k Keeper) ForceCloseLong(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, takeFundPayment bool, ...) (math.Int, error)
- func (k Keeper) ForceCloseShort(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, takeFundPayment bool, ...) (math.Int, error)
- func (k Keeper) FundingFeeCollection(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) error
- func (k Keeper) FundingFeeDistribution(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) error
- func (k Keeper) GetAllBorrowRate(ctx sdk.Context) []types.InterestBlock
- func (k Keeper) GetAllFundingRate(ctx sdk.Context) []types.FundingRateBlock
- func (k Keeper) GetAllMTPs(ctx sdk.Context) []types.MTP
- func (k Keeper) GetAllMTPsForAddress(ctx sdk.Context, mtpAddress sdk.AccAddress) []*types.MTP
- func (k Keeper) GetAllPools(ctx sdk.Context) (list []types.Pool)
- func (k Keeper) GetAllWhitelistedAddress(ctx sdk.Context) []sdk.AccAddress
- func (k Keeper) GetAmmPool(ctx sdk.Context, poolId uint64) (ammtypes.Pool, error)
- func (k Keeper) GetAssetPrice(ctx sdk.Context, asset string) (math.LegacyDec, error)
- func (k Keeper) GetBaseCurreny(ctx sdk.Context) (atypes.Entry, bool)
- func (k Keeper) GetBorrowInterestAmount(ctx sdk.Context, mtp *types.MTP) math.Int
- func (k Keeper) GetBorrowInterestPaymentEnabled(ctx sdk.Context) bool
- func (k Keeper) GetBorrowInterestPaymentFundAddress(ctx sdk.Context) sdk.AccAddress
- func (k Keeper) GetBorrowInterestPaymentFundPercentage(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetBorrowInterestRate(ctx sdk.Context, startBlock, startTime uint64, poolId uint64, ...) math.LegacyDec
- func (k Keeper) GetBorrowInterestRateDecrease(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetBorrowInterestRateIncrease(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetBorrowInterestRateMax(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetBorrowInterestRateMin(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetEffectiveLeverage(ctx sdk.Context, mtp types.MTP) (math.LegacyDec, error)
- func (k Keeper) GetEpochPosition(ctx sdk.Context, epochLength int64) int64
- func (k Keeper) GetEstimatedPnL(ctx sdk.Context, mtp types.MTP, baseCurrency string, useTakeProfitPrice bool) (math.Int, error)
- func (k Keeper) GetFundingDistributionValue(ctx sdk.Context, startBlock uint64, pool uint64) (long math.LegacyDec, short math.LegacyDec)
- func (k Keeper) GetFundingPaymentRates(ctx sdk.Context, pool types.Pool) (long math.LegacyDec, short math.LegacyDec)
- func (k Keeper) GetFundingRate(ctx sdk.Context, startBlock uint64, startTime uint64, poolId uint64) (long math.LegacyDec, short math.LegacyDec)
- func (k Keeper) GetHealthGainFactor(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams)
- func (k Keeper) GetLiquidationPrice(ctx sdk.Context, mtp types.MTP) math.LegacyDec
- func (k Keeper) GetMTP(ctx sdk.Context, mtpAddress sdk.AccAddress, id uint64) (types.MTP, error)
- func (k Keeper) GetMTPCount(ctx sdk.Context) uint64
- func (k Keeper) GetMTPData(ctx sdk.Context, pagination *query.PageRequest, address sdk.AccAddress, ...) ([]*types.MtpAndPrice, *query.PageResponse, error)
- func (k Keeper) GetMTPHealth(ctx sdk.Context, mtp types.MTP, ammPool ammtypes.Pool, baseCurrency string) (math.LegacyDec, error)
- func (k Keeper) GetMTPIterator(ctx sdk.Context) storetypes.Iterator
- func (k Keeper) GetMTPs(ctx sdk.Context, pagination *query.PageRequest) ([]*types.MtpAndPrice, *query.PageResponse, error)
- func (k Keeper) GetMTPsForAddressWithPagination(ctx sdk.Context, mtpAddress sdk.AccAddress, pagination *query.PageRequest) ([]*types.MtpAndPrice, *query.PageResponse, error)
- func (k Keeper) GetMTPsForPool(ctx sdk.Context, ammPoolId uint64, pagination *query.PageRequest) ([]*types.MtpAndPrice, *query.PageResponse, error)
- func (k Keeper) GetMaxLeverageParam(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetMaxLimitOrder(ctx sdk.Context) int64
- func (k Keeper) GetMaxOpenPositions(ctx sdk.Context) int64
- func (k Keeper) GetOpenMTPCount(ctx sdk.Context) uint64
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetPerpetualSwapFee(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (val types.Pool, found bool)
- func (k Keeper) GetPoolOpenThreshold(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetPoolTotalBaseCurrencyLiabilities(ctx sdk.Context, pool types.Pool) (sdk.Coin, error)
- func (k Keeper) GetPositions(goCtx context.Context, req *types.PositionsRequest) (*types.PositionsResponse, error)
- func (k Keeper) GetPositionsByPool(goCtx context.Context, req *types.PositionsByPoolRequest) (*types.PositionsByPoolResponse, error)
- func (k Keeper) GetPositionsForAddress(goCtx context.Context, req *types.PositionsForAddressRequest) (*types.PositionsForAddressResponse, error)
- func (k Keeper) GetSafetyFactor(ctx sdk.Context) sdkmath.LegacyDec
- func (k Keeper) GetStatus(goCtx context.Context, req *types.StatusRequest) (*types.StatusResponse, error)
- func (k *Keeper) GetTierKeeper() *tierkeeper.Keeper
- func (k Keeper) GetWhitelist(goCtx context.Context, req *types.WhitelistRequest) (*types.WhitelistResponse, error)
- func (k Keeper) GetWhitelistAddressIterator(ctx sdk.Context) storetypes.Iterator
- func (k Keeper) GetWhitelistedAddress(ctx sdk.Context, pagination *query.PageRequest) ([]sdk.AccAddress, *query.PageResponse, error)
- func (k Keeper) HandleCloseEstimation(ctx sdk.Context, req *types.QueryCloseEstimationRequest) (res *types.QueryCloseEstimationResponse, err error)
- func (k Keeper) HandleOpenEstimation(ctx sdk.Context, req *types.QueryOpenEstimationRequest) (*types.QueryOpenEstimationResponse, error)
- func (k Keeper) IsWhitelisted(goCtx context.Context, req *types.IsWhitelistedRequest) (*types.IsWhitelistedResponse, error)
- func (k Keeper) IsWhitelistingEnabled(ctx sdk.Context) bool
- func (k Keeper) LeverageLpHooks() LeverageLpHooks
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MTP(goCtx context.Context, req *types.MTPRequest) (*types.MTPResponse, error)
- func (k Keeper) OnLeverageLpDisablePool(ctx sdk.Context, ammPool ammtypes.Pool) error
- func (k Keeper) OnLeverageLpEnablePool(ctx sdk.Context, ammPool ammtypes.Pool) error
- func (k Keeper) Open(ctx sdk.Context, msg *types.MsgOpen) (*types.MsgOpenResponse, error)
- func (k Keeper) OpenConsolidate(ctx sdk.Context, existingMtp *types.MTP, newMtp *types.MTP, msg *types.MsgOpen, ...) (*types.MsgOpenResponse, error)
- func (k Keeper) OpenConsolidateMergeMtp(ctx sdk.Context, existingMtp *types.MTP, newMtp *types.MTP) (*types.MTP, error)
- func (k Keeper) OpenDefineAssets(ctx sdk.Context, poolId uint64, msg *types.MsgOpen, baseCurrency string) (*types.MTP, error)
- func (k Keeper) OpenEstimation(goCtx context.Context, req *types.QueryOpenEstimationRequest) (*types.QueryOpenEstimationResponse, error)
- func (k Keeper) Params(goCtx context.Context, req *types.ParamsRequest) (*types.ParamsResponse, error)
- func (k Keeper) Pool(goCtx context.Context, req *types.QueryGetPoolRequest) (*types.QueryGetPoolResponse, error)
- func (k Keeper) Pools(goCtx context.Context, req *types.QueryAllPoolRequest) (*types.QueryAllPoolResponse, error)
- func (k Keeper) ProcessOpen(ctx sdk.Context, mtp *types.MTP, proxyLeverage sdkmath.LegacyDec, ...) (*types.MTP, error)
- func (k Keeper) RemovePool(ctx sdk.Context, index uint64)
- func (k Keeper) Repay(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool *ammtypes.Pool, ...) error
- func (k Keeper) ResetStore(ctx sdk.Context) error
- func (k Keeper) SendFromAmmPool(ctx sdk.Context, ammPool *ammtypes.Pool, receiverAddress sdk.AccAddress, ...) error
- func (k Keeper) SendToAmmPool(ctx sdk.Context, senderAddress sdk.AccAddress, ammPool *ammtypes.Pool, ...) error
- func (k Keeper) SetBorrowRate(ctx sdk.Context, block uint64, pool uint64, interest types.InterestBlock)
- func (k Keeper) SetFundingRate(ctx sdk.Context, block uint64, pool uint64, funding types.FundingRateBlock)
- func (k *Keeper) SetHooks(gh types.PerpetualHooks) *Keeper
- func (k Keeper) SetMTP(ctx sdk.Context, mtp *types.MTP) error
- func (k Keeper) SetMTPCount(ctx sdk.Context, count uint64)
- func (k Keeper) SetOpenMTPCount(ctx sdk.Context, count uint64)
- func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error
- func (k Keeper) SetPool(ctx sdk.Context, pool types.Pool)
- func (k *Keeper) SetTierKeeper(tk *tierkeeper.Keeper)
- func (k Keeper) SettleFunding(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) error
- func (k Keeper) SettleMTPBorrowInterestUnpaidLiability(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) (math.Int, error)
- func (k Keeper) TakeFundPayment(ctx sdk.Context, amount math.Int, returnAsset string, ammPool *ammtypes.Pool) (math.Int, error)
- func (k Keeper) TransferRevenueAmount(ctx sdk.Context, revenueAmt math.Int, returnAsset string, ...) error
- func (k Keeper) UpdateFundingFee(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool) error
- func (k Keeper) UpdateMTPBorrowInterestUnpaidLiability(ctx sdk.Context, mtp *types.MTP)
- func (k Keeper) UpdateOpenPrice(ctx sdk.Context, mtp *types.MTP) error
- func (k Keeper) UpdatePoolHealth(ctx sdk.Context, pool *types.Pool) error
- func (k Keeper) V6_MigrateWhitelistedAddress(ctx sdk.Context)
- func (k Keeper) WhitelistAddress(ctx sdk.Context, address sdk.AccAddress)
- type LeverageLpHooks
- func (h LeverageLpHooks) AfterDisablingPool(ctx sdk.Context, ammPool ammtypes.Pool) error
- func (h LeverageLpHooks) AfterEnablingPool(ctx sdk.Context, ammPool ammtypes.Pool) error
- func (h LeverageLpHooks) AfterLeverageLpPositionClose(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool) error
- func (h LeverageLpHooks) AfterLeverageLpPositionOpen(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool) error
- func (h LeverageLpHooks) AfterLeverageLpPositionOpenConsolidate(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMsgServerImpl ¶
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.
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
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, storeService store.KVStoreService, authority string, amm types.AmmKeeper, bk types.BankKeeper, oracleKeeper types.OracleKeeper, assetProfileKeeper types.AssetProfileKeeper, parameterKeeper *pkeeper.Keeper, tierKeeper *tierkeeper.Keeper, ) *Keeper
func (Keeper) BeginBlocker ¶
func (Keeper) BorrowInterestRateComputation ¶
func (Keeper) BorrowInterestRateComputationByPosition ¶
func (Keeper) CalcMTPTakeProfitLiability ¶
func (Keeper) CalcMinCollateral ¶
func (k Keeper) CalcMinCollateral(ctx sdk.Context, leverage sdkmath.LegacyDec, price sdkmath.LegacyDec, decimals uint64) (sdkmath.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 math.LegacyDec) (repayAmount, payingLiabilities math.Int, slippage, weightBreakingFee math.LegacyDec, 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 math.LegacyDec) (returnAmount math.Int, err error)
need to make sure unpaid liability interest is paid
func (Keeper) CalculatePoolHealth ¶
func (Keeper) CalculatePoolHealthByPosition ¶
func (Keeper) CheckAndCloseAtStopLoss ¶ added in v0.45.0
func (Keeper) CheckAndCloseAtTakeProfit ¶ added in v0.48.0
func (Keeper) CheckAndLiquidateUnhealthyPosition ¶ added in v0.45.0
func (Keeper) CheckIfWhitelisted ¶
func (Keeper) CheckLowPoolHealthAndMinimumCustody ¶ added in v0.49.2
func (Keeper) CheckMTPExist ¶ added in v0.48.0
func (Keeper) CheckMinimumCustodyAmt ¶ added in v0.49.0
CheckMinimumCustodyAmt Should be called after opening positions and when real pool balance changes
func (Keeper) CheckSameAssetPosition ¶
func (Keeper) CheckUserAuthorization ¶
func (Keeper) CloseEstimation ¶ added in v0.47.0
func (k Keeper) CloseEstimation(goCtx context.Context, req *types.QueryCloseEstimationRequest) (res *types.QueryCloseEstimationResponse, err error)
func (Keeper) ClosePosition ¶ added in v0.48.0
func (Keeper) ComputeFundingRate ¶ added in v0.48.0
func (Keeper) DeleteAllFundingRate ¶ added in v0.48.0
Deletes all pool blocks at delBlock
func (Keeper) DeleteAllInterestRate ¶ added in v0.48.0
Deletes all pool blocks at delBlock
func (Keeper) DeleteAllToPay ¶ added in v0.52.0
Delete all to pay if any
func (Keeper) DeleteBorrowRate ¶ added in v0.45.0
Test it out Deletes all pool blocks at delBlock
func (Keeper) DeleteFundingRate ¶ added in v0.45.0
Test it out Deletes all pool blocks at delBlock
func (Keeper) DestroyMTP ¶
func (Keeper) DewhitelistAddress ¶
func (k Keeper) DewhitelistAddress(ctx sdk.Context, address sdk.AccAddress)
func (Keeper) EmitCloseEvent ¶ added in v0.29.3
func (Keeper) EmitForceClose ¶
func (Keeper) EmitFundPayment ¶
func (Keeper) EmitFundingFeePayment ¶
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 math.LegacyDec) (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) EstimateSwapGivenIn ¶ added in v0.49.0
func (k Keeper) EstimateSwapGivenIn(ctx sdk.Context, tokenInAmount sdk.Coin, tokenOutDenom string, ammPool ammtypes.Pool, owner string) (math.Int, math.LegacyDec, 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, owner string) (math.Int, math.LegacyDec, math.LegacyDec, error)
Swap estimation using amm CalcInAmtGivenOut function
func (Keeper) ForceCloseLong ¶
func (Keeper) ForceCloseShort ¶
func (Keeper) FundingFeeCollection ¶ added in v0.48.0
func (Keeper) FundingFeeDistribution ¶ added in v0.48.0
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) GetAllMTPsForAddress ¶ added in v0.45.0
func (Keeper) GetAllPools ¶
GetAllPools returns all pool
func (Keeper) GetAllWhitelistedAddress ¶
func (k Keeper) GetAllWhitelistedAddress(ctx sdk.Context) []sdk.AccAddress
func (Keeper) GetAmmPool ¶
func (Keeper) GetAssetPrice ¶ added in v0.48.0
func (Keeper) GetBaseCurreny ¶ added in v0.45.0
func (Keeper) GetBorrowInterestAmount ¶ added in v0.48.0
func (Keeper) GetBorrowInterestPaymentEnabled ¶ added in v0.54.0
func (Keeper) GetBorrowInterestPaymentFundAddress ¶ added in v0.54.0
func (k Keeper) GetBorrowInterestPaymentFundAddress(ctx sdk.Context) sdk.AccAddress
func (Keeper) GetBorrowInterestPaymentFundPercentage ¶ added in v0.54.0
func (Keeper) GetBorrowInterestRate ¶ added in v0.48.0
func (Keeper) GetBorrowInterestRateDecrease ¶
func (Keeper) GetBorrowInterestRateIncrease ¶
func (Keeper) GetBorrowInterestRateMax ¶
func (Keeper) GetBorrowInterestRateMin ¶
func (Keeper) GetEffectiveLeverage ¶ added in v0.49.0
GetEffectiveLeverage = custody / (custody - liabilities), has to be dimensionless
func (Keeper) GetEpochPosition ¶
get position of current block in epoch
func (Keeper) GetEstimatedPnL ¶ added in v0.48.0
func (Keeper) GetFundingDistributionValue ¶ added in v0.45.0
func (Keeper) GetFundingPaymentRates ¶ added in v0.49.0
func (Keeper) GetFundingRate ¶ added in v0.45.0
func (Keeper) GetHealthGainFactor ¶
func (Keeper) GetLegacyParams ¶ added in v0.54.0
func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams)
func (Keeper) GetLiquidationPrice ¶ added in v0.48.0
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) (math.LegacyDec, 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) storetypes.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 (Keeper) GetMaxLimitOrder ¶ added in v0.46.0
func (Keeper) GetPerpetualSwapFee ¶ added in v0.48.0
func (Keeper) GetPoolOpenThreshold ¶
func (Keeper) GetPoolTotalBaseCurrencyLiabilities ¶ added in v0.49.0
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) GetPositionsForAddress ¶
func (k Keeper) GetPositionsForAddress(goCtx context.Context, req *types.PositionsForAddressRequest) (*types.PositionsForAddressResponse, error)
func (Keeper) GetStatus ¶
func (k Keeper) GetStatus(goCtx context.Context, req *types.StatusRequest) (*types.StatusResponse, error)
func (*Keeper) GetTierKeeper ¶ added in v0.51.0
func (k *Keeper) GetTierKeeper() *tierkeeper.Keeper
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) storetypes.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 (k Keeper) HandleOpenEstimation(ctx sdk.Context, req *types.QueryOpenEstimationRequest) (*types.QueryOpenEstimationResponse, error)
func (Keeper) IsWhitelisted ¶
func (k Keeper) IsWhitelisted(goCtx context.Context, req *types.IsWhitelistedRequest) (*types.IsWhitelistedResponse, error)
func (Keeper) LeverageLpHooks ¶ added in v0.48.0
func (k Keeper) LeverageLpHooks() LeverageLpHooks
Return the wrapper struct
func (Keeper) MTP ¶
func (k Keeper) MTP(goCtx context.Context, req *types.MTPRequest) (*types.MTPResponse, error)
func (Keeper) OnLeverageLpDisablePool ¶ added in v0.48.0
func (Keeper) OnLeverageLpEnablePool ¶ added in v0.48.0
func (Keeper) OpenConsolidate ¶
func (Keeper) OpenConsolidateMergeMtp ¶ added in v0.48.0
func (Keeper) OpenDefineAssets ¶ added in v0.48.0
func (Keeper) OpenEstimation ¶
func (k Keeper) OpenEstimation(goCtx context.Context, req *types.QueryOpenEstimationRequest) (*types.QueryOpenEstimationResponse, error)
func (Keeper) Params ¶
func (k Keeper) Params(goCtx context.Context, req *types.ParamsRequest) (*types.ParamsResponse, error)
func (Keeper) Pool ¶
func (k Keeper) Pool(goCtx context.Context, req *types.QueryGetPoolRequest) (*types.QueryGetPoolResponse, error)
func (Keeper) Pools ¶
func (k Keeper) Pools(goCtx context.Context, req *types.QueryAllPoolRequest) (*types.QueryAllPoolResponse, error)
func (Keeper) ProcessOpen ¶ added in v0.48.0
func (Keeper) RemovePool ¶
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 math.LegacyDec, baseCurrency string) error
Repay ammPool has to be pointer because RemoveFromPoolBalance updates pool assets
func (Keeper) ResetStore ¶
ResetStore resets all keys in the perpetual module store
func (Keeper) SendFromAmmPool ¶ added in v0.49.0
func (Keeper) SendToAmmPool ¶ added in v0.49.0
func (Keeper) SetBorrowRate ¶ added in v0.45.0
func (Keeper) SetFundingRate ¶ added in v0.45.0
func (*Keeper) SetHooks ¶
func (k *Keeper) SetHooks(gh types.PerpetualHooks) *Keeper
Set the perpetual hooks.
func (Keeper) SetMTPCount ¶
Set MTP count
func (Keeper) SetOpenMTPCount ¶
Set Open MTP count
func (*Keeper) SetTierKeeper ¶ added in v0.51.0
func (k *Keeper) SetTierKeeper(tk *tierkeeper.Keeper)
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 (Keeper) TransferRevenueAmount ¶ added in v0.54.0
func (Keeper) UpdateFundingFee ¶ added in v0.48.0
func (Keeper) UpdateMTPBorrowInterestUnpaidLiability ¶ added in v0.48.0
func (Keeper) UpdateOpenPrice ¶ added in v0.29.17
func (Keeper) UpdatePoolHealth ¶
func (Keeper) V6_MigrateWhitelistedAddress ¶ added in v0.45.0
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 (LeverageLpHooks) AfterEnablingPool ¶ added in v0.48.0
func (LeverageLpHooks) AfterLeverageLpPositionClose ¶ added in v0.48.0
func (h LeverageLpHooks) AfterLeverageLpPositionClose(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool) error
func (LeverageLpHooks) AfterLeverageLpPositionOpen ¶ added in v0.48.0
func (h LeverageLpHooks) AfterLeverageLpPositionOpen(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool) error
func (LeverageLpHooks) AfterLeverageLpPositionOpenConsolidate ¶ added in v0.48.0
func (h LeverageLpHooks) AfterLeverageLpPositionOpenConsolidate(ctx sdk.Context, sender sdk.AccAddress, ammPool ammtypes.Pool) error
Source Files ¶
- asset_price.go
- begin_blocker.go
- calc_min_collateral.go
- calc_mtp_take_profit_liabilities.go
- check_max_open_positions.go
- check_same_asset_position.go
- check_user_authorization.go
- close.go
- close_position.go
- estimate_and_repay.go
- estimate_swap.go
- events.go
- force_close_long.go
- force_close_short.go
- get_amm_pool.go
- get_epoch_position.go
- get_net_open_interest.go
- hooks_amm.go
- hooks_epoch.go
- hooks_leveragelp.go
- keeper.go
- msg_server.go
- msg_server_close.go
- msg_server_close_positions.go
- msg_server_dewhitelist.go
- msg_server_open.go
- msg_server_update_params.go
- msg_server_update_stop_loss.go
- msg_server_update_take_profit_price.go
- msg_server_whitelist.go
- mtp.go
- mtp_borrow_interest.go
- mtp_health.go
- mtp_leverage.go
- mtp_open_price.go
- open.go
- open_consolidate.go
- open_consolidate_merge_mtp.go
- open_define_assets.go
- params.go
- pool.go
- pool_health.go
- process_mtp.go
- process_open.go
- query.go
- query_close_estimation.go
- query_get_positions.go
- query_get_positions_by_pool.go
- query_get_positions_for_address.go
- query_get_status.go
- query_get_whitelist.go
- query_is_whitelisted.go
- query_mtp.go
- query_open_estimation.go
- query_params.go
- query_pool.go
- repay.go
- reset_store.go
- settle_funding_fee.go
- settle_funding_fee_collection.go
- settle_funding_fee_distribution.go
- whitelist.go