MCDEX
Search…
User

Trader Info

Entity: MarginAccount

Field
Value Type
Description
id
ID
perpetual index + "-" + user address
user
User
user address of this margin account
perpetual
Perpetual
perpetual of this account
position
BigDecimal
position of this account
entryValue
BigDecimal
entry margin value of this account
entryFunding
BigDecimal
entry fundingRate of this account

Query Example

Query BUSD Pool's BTC perpetual margin account bsc: getMarginAccounts
{
marginAccounts(where:{position_not:0 perpetual:"0xdb282bbace4e375ff2901b84aceb33016d0d663d-0"}) {
id
user {
id
}
perpetual {
id
}
position
entryValue
entryFunding
}
}

Calculate Funding Payment

Query Example

Query BUSD Pool's BTC perpetual margin account funding paid for position bsc: getAccountFunding
{
marginAccounts(where:{user:"0x01a5ec3c9d006f94417e029c09c5f0531b0a4194" perpetual:"0xdb282bbace4e375ff2901b84aceb33016d0d663d-0"}) {
id
user {
id
}
perpetual {
id
unitAccumulativeFunding
}
position
entryValue
entryFunding
}
}
positionFunding = (position * perpetual.unitAccumulativeFunding) - entryFunding

Liquidity Provider Info

Entity: LiquidityAccount

Field
Value Type
Description
id
ID
pool address + "-" + user address
liquidityPool
LiquidityPool
liquidityPool of this account
user
User
user address of this account
shareAmount
BigDecimal
shareAmount of this account
entryPoolMargin
BigDecimal
entry pool margin of this account

Query Example

Query BUSD Pool's liquidity account bsc: getLiquidityAccounts
{
liquidityAccounts(where:{shareAmount_gt:0 liquidityPool:"0xdb282bbace4e375ff2901b84aceb33016d0d663d"}) {
id
liquidityPool {
id
}
user {
id
}
shareAmount
entryPoolMargin
}
}

Entity: Trade

Field
Value Type
Description
id
ID
trasaction hash + "-" + logIndex + "-" + close/open
perpetual
Perpetual
Perpetual of this trade
trader
User
trader of this trade
amount
BigDecimal
amount of this trade
price
BigDecimal
price of this trade
markPrice
BigDecimal
markPrice of this trade
fee
BigDecimal
fee of this trade
isClose
Boolean
true if this trade is close
pnl
BigDecimal
profit and loss
type
Int
type of this trade (NORMAL = 0, LIQUIDATEBYAMM = 1, LIQUIDATEBYTRADER = 2)
transactionHash
String
transaction hash of this trade
blockNumber
BigInt
block number of this trade
timestamp
BigInt
timestamp of this trade
logIndex
BigInt
log index of this trade

Query Example

Query user's trade history bsc: getUserTrades
{
trades(first: 10 orderBy:timestamp orderDirection:desc,
where: {trader: "0x57f4d3071e99d0a4baef0b274526215f939a6575"}) {
id
perpetual {
id
}
trader {
id
}
price
markPrice
fee
isClose
pnl
type
transactionHash
blockNumber
timestamp
logIndex
}
}

Liquidated Trader Info

Entity: Liquidate

Field
Value Type
Description
id
ID
trasaction hash + "-" + logIndex
perpetual
Perpetual
Perpetual of this liquidate
trader
User
trader of this liquidate
liquidator
User
liquidator of this liquidate
amount
BigDecimal
amount of this liquidate
price
BigDecimal
price of this liquidate
markPrice
BigDecimal
markPrice of this liquidate
penalty
BigDecimal
penalty of this liquidate
penaltyToLP
BigDecimal
penalty to LP
type
Int
type of this liquidate (LIQUIDATEBYAMM = 1, LIQUIDATEBYTRADER = 2)
transactionHash
String
transaction hash of this liquidate
blockNumber
BigInt
block number of this liquidate
timestamp
BigInt
timestamp of this liquidate
logIndex
BigInt
log index of this liquidate

Query Example

Query user's liquidate history bsc: getUserLiquidates
{
liquidates(first: 10 orderBy:timestamp orderDirection:desc,
where: {trader: "0xaafad6543e236653aff9aff87b47635d64243b9a"}) {
id
perpetual {
id
}
trader
liquidator
amount
price
markPrice
penalty
penaltyToLP
type
transactionHash
blockNumber
timestamp
logIndex
}
}
Last modified 10mo ago
Copy link
On this page
Trader Info
Entity: MarginAccount
Query Example
Calculate Funding Payment
Query Example
Liquidity Provider Info
Entity: LiquidityAccount
Query Example
Entity: Trade
Query Example
Liquidated Trader Info
Entity: Liquidate
Query Example