forked from Secured-Finance/secured-finance-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
158 lines (141 loc) · 3.04 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
type Transaction @entity {
id: ID!
currency: Bytes!
maturity: BigInt!
side: Int!
executionPrice: BigInt!
user: User!
executionType: TransactionExecutionType!
futureValue: BigInt!
amount: BigInt!
feeInFV: BigInt!
averagePrice: BigDecimal!
lendingMarket: LendingMarket!
order: Order!
createdAt: BigInt!
blockNumber: BigInt!
txHash: Bytes!
}
type Order @entity {
id: ID!
orderId: BigInt!
user: User!
currency: Bytes!
side: Int!
maturity: BigInt!
inputUnitPrice: BigInt!
inputAmount: BigInt!
filledAmount: BigInt!
status: OrderStatus!
statusUpdatedAt: BigInt!
lendingMarket: LendingMarket!
isPreOrder: Boolean!
type: OrderType!
transactions: [Transaction!]! @derivedFrom(field: "order")
isCircuitBreakerTriggered: Boolean!
createdAt: BigInt!
blockNumber: BigInt!
txHash: Bytes!
}
type LendingMarket @entity {
id: ID!
currency: Bytes!
maturity: BigInt!
isActive: Boolean!
transactions: [Transaction!]! @derivedFrom(field: "lendingMarket")
orders: [Order!]! @derivedFrom(field: "lendingMarket")
volume: BigInt!
dailyVolume: [DailyVolume!]! @derivedFrom(field: "lendingMarket")
openingUnitPrice: BigInt!
lastLendUnitPrice: BigInt!
lastBorrowUnitPrice: BigInt!
offsetAmount: BigInt!
}
enum TransactionExecutionType {
Maker
Taker
}
enum OrderType {
Market
Limit
Unwind
}
enum OrderStatus {
Open
PartiallyFilled
Filled
Killed
Cancelled
}
type User @entity {
id: ID! # wallet address
createdAt: BigInt!
transactionCount: BigInt!
transactions: [Transaction!]! @derivedFrom(field: "user")
orderCount: BigInt!
orders: [Order!]! @derivedFrom(field: "user")
liquidationCount: BigInt!
liquidations: [Liquidation!]! @derivedFrom(field: "user")
transferCount: BigInt!
transfers: [Transfer!]! @derivedFrom(field: "user")
deposits: [Deposit!]! @derivedFrom(field: "user")
}
type DailyVolume @entity {
id: ID! # currency-maturity-date(yyyy-mm-dd)
currency: Bytes!
maturity: BigInt!
day: String! # dd-mm-yyyy
volume: BigInt!
timestamp: BigInt!
lendingMarket: LendingMarket!
}
type Protocol @entity {
id: ID! # 1
totalUsers: BigInt!
}
type Liquidation @entity {
id: ID!
collateralCurrency: Bytes!
debtCurrency: Bytes!
debtMaturity: BigInt!
debtAmount: BigInt!
user: User!
timestamp: BigInt!
blockNumber: BigInt!
txHash: Bytes!
}
enum TransferType {
Deposit
Withdraw
}
type Transfer @entity {
id: ID!
user: User!
currency: Bytes!
amount: BigInt!
transferType: TransferType!
timestamp: BigInt!
blockNumber: BigInt!
txHash: Bytes!
}
type Deposit @entity {
id: ID!
user: User!
currency: Bytes!
amount: BigInt!
}
type TransactionCandleStick @entity {
id: ID! # A composite ID, e.g., "currency-maturity-interval-epochTime"
interval: BigInt! # interval in seconds
currency: Bytes!
maturity: BigInt!
timestamp: BigInt! # The start time of the interval
open: BigInt!
close: BigInt!
high: BigInt!
low: BigInt!
average: BigDecimal!
volume: BigInt!
volumeInFV: BigInt!
lendingMarket: LendingMarket!
}