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
1
{
2
marginAccounts(where:{position_not:0 perpetual:"0xdb282bbace4e375ff2901b84aceb33016d0d663d-0"}) {
3
id
4
user {
5
id
6
}
7
perpetual {
8
id
9
}
10
position
11
entryValue
12
entryFunding
13
}
14
}
Copied!

Calculate Funding Payment

Query Example

Query BUSD Pool's BTC perpetual margin account funding paid for position bsc: getAccountFunding
1
{
2
marginAccounts(where:{user:"0x01a5ec3c9d006f94417e029c09c5f0531b0a4194" perpetual:"0xdb282bbace4e375ff2901b84aceb33016d0d663d-0"}) {
3
id
4
user {
5
id
6
}
7
perpetual {
8
id
9
unitAccumulativeFunding
10
}
11
position
12
entryValue
13
entryFunding
14
}
15
}
Copied!
1
positionFunding = (position * perpetual.unitAccumulativeFunding) - entryFunding
Copied!

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
1
{
2
liquidityAccounts(where:{shareAmount_gt:0 liquidityPool:"0xdb282bbace4e375ff2901b84aceb33016d0d663d"}) {
3
id
4
liquidityPool {
5
id
6
}
7
user {
8
id
9
}
10
shareAmount
11
entryPoolMargin
12
}
13
}
Copied!

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
1
{
2
trades(first: 10 orderBy:timestamp orderDirection:desc,
3
where: {trader: "0x57f4d3071e99d0a4baef0b274526215f939a6575"}) {
4
id
5
perpetual {
6
id
7
}
8
trader {
9
id
10
}
11
price
12
markPrice
13
fee
14
isClose
15
pnl
16
type
17
transactionHash
18
blockNumber
19
timestamp
20
logIndex
21
}
22
}
Copied!

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
1
{
2
liquidates(first: 10 orderBy:timestamp orderDirection:desc,
3
where: {trader: "0xaafad6543e236653aff9aff87b47635d64243b9a"}) {
4
id
5
perpetual {
6
id
7
}
8
trader
9
liquidator
10
amount
11
price
12
markPrice
13
penalty
14
penaltyToLP
15
type
16
transactionHash
17
blockNumber
18
timestamp
19
logIndex
20
}
21
}
Copied!
Last modified 14d ago