forked from Perp-Protocol/perp-position-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
104 lines (98 loc) · 3.29 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
type Position @entity {
id: ID!
trader: Bytes! # address
margin: BigInt! # uint256
openNotional: BigInt! # total position notional values at open
tradingVolume: BigInt! # trading volume in notional value
leverage: BigInt! # openNotional / margin
realizedPnl: BigInt! # int256
unrealizedPnl: BigInt! # int256
fundingPayment: BigInt! # int256
fee: BigInt! # uint256
badDebt: BigInt! # uint256
liquidationPenalty: BigInt! # uint256
totalPnlAmount: BigInt! # accumulated total PnL (realizedPnl - fundingPayment - fee - liquidationPenalty)
ammPositions: [AmmPosition!]! @derivedFrom(field: "position") # breakdown for each Amm
blockNumber: BigInt # last updated block number
timestamp: BigInt # last updated timestamp
}
type AmmPosition @entity {
id: ID!
amm: Bytes! # address
trader: Bytes! # address
margin: BigInt! # uint256
positionSize: BigInt! # int256
openNotional: BigInt! # position notional value at open
tradingVolume: BigInt! # trading volume in notional value
leverage: BigInt! # openNotional / margin
entryPrice: BigInt! # openNotional / positionSize
realizedPnl: BigInt! # int256
unrealizedPnl: BigInt! # int256
fundingPayment: BigInt! # int256
fee: BigInt! # uint256
badDebt: BigInt! # uint256
liquidationPenalty: BigInt! # uint256
totalPnlAmount: BigInt! # accumulated total PnL (realizedPnl - fundingPayment - fee - liquidationPenalty)
position: Position!
blockNumber: BigInt # last updated block number
timestamp: BigInt # last updated timestamp
}
type Amm @entity {
id: ID!
address: Bytes! # address
positionBalance: BigInt! # int256
openInterestSize: BigInt! # uint256
openInterestNotional: BigInt! # uint256
tradingVolume: BigInt! # trading volume in notional value
quoteAssetReserve: BigInt! # uint256
baseAssetReserve: BigInt! # uint256
blockNumber: BigInt # last updated block number
timestamp: BigInt # last updated timestamp
}
type PositionChangedEvent @entity {
id: ID!
trader: Bytes! # address
amm: Bytes! # address
margin: BigInt! # uint256
positionNotional: BigInt! # uint256
exchangedPositionSize: BigInt! # uint256
fee: BigInt! # uint256
positionSizeAfter: BigInt! # int256
realizedPnl: BigInt! # int256
unrealizedPnlAfter: BigInt! # int256
badDebt: BigInt! # uint256
liquidationPenalty: BigInt! # uint256
spotPrice: BigInt! # uint256
fundingPayment: BigInt! # int256
blockNumber: BigInt! # last updated block number
timestamp: BigInt! # last updated timestamp
}
type PositionLiquidatedEvent @entity {
id: ID!
trader: Bytes! # address
amm: Bytes! # address
positionNotional: BigInt! # uint256
positionSize: BigInt! # uint256
liquidationFee: BigInt! # uint256
liquidator: Bytes! # address
badDebt: BigInt! # uint256
blockNumber: BigInt! # last updated block number
timestamp: BigInt! # last updated timestamp
}
type FundingRateUpdatedEvent @entity {
id: ID!
amm: Bytes! # address
rate: BigInt! # int256
underlyingPrice: BigInt! # int256
blockNumber: BigInt! # last updated block number
timestamp: BigInt! # last updated timestamp
}
type MarginChangedEvent @entity {
id: ID!
sender: Bytes! # address
amm: Bytes! # address
amount: BigInt! #int256
fundingPayment: BigInt! # int256
blockNumber: BigInt! # last updated block number
timestamp: BigInt! # last updated timestamp
}