MCDEX
Search…
Get Perpetual Info
This guide shows how to get perpetual by using the ILiquidityPoolFull interface and get related information from perpetual object.

Get Perpetual Object

Function

function getPerpetualInfo(uint256 perpetualIndex)
parameters
type
description
perpetualIndex
uint256
index of perpetual in the liquidity pool
Return information from perpetual object
returns
type
description
PerpetualState
PerpetualState
state The state of the perpetual
oracle
address
oracle's address of the perpetual
nums
int256[42]
related numbers of the perpetual
  • nums: information
index
description
[0]
totalCollateral
[1]
markPrice (return settlementPrice if it is in EMERGENCY state)
[2]
indexPrice
[3]
fundingRate
[4]
unitAccumulativeFunding
[5]
initialMarginRate
[6]
maintenanceMarginRate
[7]
operatorFeeRate
[8]
lpFeeRate
[9]
referralRebateRate
[10]
liquidationPenaltyRate
[11]
keeperGasReward
[12]
insuranceFundRate
[13-15]
halfSpread value, min, max
[16-18]
openSlippageFactor value, min, max
[19-21]
closeSlippageFactor value, min, max
[22-24]
fundingRateLimit value, min, max
[25-27]
ammMaxLeverage value, min, max
[28-30]
maxClosePriceDiscount value, min, max
[31]
openInterest
[32]
maxOpenInterestRate
[33-35]
fundingRateFactor value, min, max
[36-38]
defaultTargetLeverage value, min, max
[39-41]
baseFundingRate value, min, max

Example

WARN: before calling getLiquidityPoolInfo(), need to sync the state by using the forceToSyncState function.
1
ILiquidityPoolFull liquidityPool = ILiquidityPoolFull(liquidityPoolAddress)
2
liquidityPool.forceToSyncState()
3
(state, oracle, nums) = liquidityPool.getPerpetualInfo(perpetualIndex)
Copied!

Sample Code

Github
Last modified 14d ago