-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.graphql
244 lines (229 loc) · 7.71 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
enum LendingType {
"Collateralized Debt Position (CDP) protocols have singular isolated positions created by users. We aggregate them to give a single view of a market"
CDP
"Pooled protocols pool all users assets into a single market"
POOLED
}
enum RiskType {
"Global risk means each users position in a market is combined for one score to determine if they can be liquidated"
GLOBAL
"Isolated risk means each users position in a market or CDP is isolated for risk of liquidation"
ISOLATED
}
enum Network {
"The ethereum network"
ETHEREUM
"The polygon network"
POLYGON
"The avalanche network"
AVALANCHE
}
"""
Protocol represents all aggregated information of a single protocol on a single network.
"""
type Protocol @entity {
"The Name of the Protocol"
id: ID!
"The Network the protocol exists on - Ethereum, Polygon, etc."
network: Network!
"Type of lending protocol"
type: LendingType!
"Protocol Main Address"
address: Bytes!
"Address of price oracle the comptroller uses"
priceOracle: Bytes
"Factor used to determine repayAmount for liquidating"
closeFactor: BigInt
"The percent bonus liquidators get for liquidating"
liquidationIncentive: BigInt
"Max assets a single user can enter"
maxAssets: BigInt
"All Markets within this Protocol"
markets: [Market!]! @derivedFrom(field: "protocol")
"All Accounts that have used this Protocol"
accounts: [AccountInProtocol!]! @derivedFrom(field: "protocol")
"All events that happened in the protocol"
events: [Event!]! @derivedFrom(field: "protocol")
}
"""
An asset used in a lending protocol. All assets should follow ERC-20 Standard
"""
type Asset @entity {
"Contract address"
id: ID!
"Token symbol"
symbol: String!
"Name of asset"
name: String!
"Decimals of the asset"
decimals: Int!
}
"""
A single Market within a Protocol. A Market can be a single pool where all assets are pooled together. It can also be a combination of Collateralized Debt Positions (CDPs). The CDPs are aggregated together to represent a uniform Market. A Market can only contain 1 depositAsset and 1 borrowAsset.
"""
type Market @entity {
"Contract address"
id: ID!
"Name of the Market"
name: String!
"The Protocol the Market is a part of"
protocol: Protocol!
"Underlying Asset"
asset: Asset!
"Borrowed asset if there is one"
collateralBackedAsset: Asset
"CToken symbol"
symbol: String!
"Current deposited amount in depositAsset"
deposited: BigDecimal!
"Current borrowed amount in borrowAsset"
borrowed: BigDecimal!
"Address of the interest rate model"
interestRateModelAddress: Bytes!
"Exchange rate of tokens / cTokens"
exchangeRate: BigDecimal!
"Collateral factor determining how much one can borrow"
collateralFactor: BigDecimal!
"Stable interest debt token"
stableInterestDebtToken: Bytes
"Variable interest debt token"
variableInterestDebtToken: Bytes
"The next liquidity rate"
liquidityRate: BigInt
"The next stable borrow rate"
stableBorrowRate: BigInt
"The next variable borrow rate"
variableBorrowRate: BigInt
"The next liquidity Index"
liquidityIndex: BigInt
"The next variable Borrow Index"
variableBorrowIndex: BigInt
}
"""
An account that has interacted with at least 1 lending protocol tracked in the Subgraph
"""
type Account @entity {
"Contract address"
id: ID!
"True if user has ever borrowed"
hasBorrowed: Boolean!
"Number of times the account has gotten liquidated"
liquidatedCount: Int!
"Number of times the account liquidated others"
liquidatingCount: Int!
}
"""
History of an Account within a single Protocol
"""
type AccountInProtocol @entity {
"Account ID concatenated with Protocol ID"
id: ID!
"Protocol the Account is active in"
protocol: Protocol!
"Account which has participated in the Protocol"
account: Account!
"Accumulated deposited amount in USD. Conversion into USD done at event time"
lifetimeDepositedUSD: BigInt
"Accumulated withdrawn amount in USD. Conversion into USD done at event time"
lifetimeWithdrawnUSD: BigInt
"Accumulated borrowed amount in USD. Conversion into USD done at event time"
lifetimeBorrowedUSD: BigDecimal
"Accumulated repaid amount in USD. Conversion into USD done at event time"
lifetimeRepaidUSD: BigDecimal
"Accumulated liquidated amount in USD. Conversion into USD done at event time"
lifetimeLiquidatedUSD: BigDecimal
"The number of time Deposits have occurred in all Protocols by this Account"
depositCount: Int!
"The number of time Withdraws have occurred in all Protocols by this Account"
withdrawCount: Int!
"The number of time Borrows have occurred in all Protocols by this Account"
borrowCount: Int!
"The number of time Repays have occurred in all Protocols by this Account"
repayCount: Int!
"The number of time Liquidations have occurred in all Protocols by this Account"
liquidatedCount: Int!
}
"""
Actions and history of an Account within a single Market
"""
type AccountInMarket @entity {
"Account ID concatenated with Market ID"
id: ID!
"Market the account is involved with"
market: Market!
"Account involved in this market"
account: Account!
"Current deposit amount in depositAsset"
deposited: BigDecimal!
"Current borrow amount in borrowAsset"
borrowed: BigDecimal!
"Accumulated deposited amount in depositAsset"
lifetimeDeposited: BigDecimal!
"Accumulated deposited amount in USD. Conversion into USD done at event time"
lifetimeDepositedUSD: BigDecimal
"Accumulated withdrawn amount in depositAsset"
lifetimeWithdrawn: BigDecimal!
"Accumulated withdrawn amount in USD. Conversion into USD done at event time"
lifetimeWithdrawnUSD: BigDecimal
"Accumulated borrowed amount in borrowAsset"
lifetimeBorrowed: BigDecimal!
"Accumulated borrowed amount in USD. Conversion into USD done at event time"
lifetimeBorrowedUSD: BigDecimal
"Accumulated repaid amount in borrowAsset"
lifetimeRepaid: BigDecimal!
"Accumulated repaid amount in USD. Conversion into USD done at event time"
lifetimeRepaidUSD: BigDecimal
"Accumulated liquidated amount in depositAsset"
lifetimeLiquidated: BigDecimal!
"Accumulated liquidated amount in USD. Conversion into USD done at event time"
lifetimeLiquidatedUSD: BigDecimal
"The number of times Deposits have occurred in this Market by this Account"
depositCount: Int!
"The number of times Withdraws have occurred in this Market by this Account"
withdrawCount: Int!
"The number of times Borrows have occurred in this Market by this Account"
borrowCount: Int!
"The number of times Repays have occurred in this Market by this Account"
repayCount: Int!
"The number of times Liquidations have occurred in this Market by this Account"
liquidatedCount: Int!
}
"""
An event is a general action that occurs in a Lending Protocol
"""
type Event @entity {
"The Protocol the event originated from"
protocol: Protocol!
"Transaction hash concatenated with log index"
id: ID!
"The Market within a Protocol the event originated from"
market: Market!
"Main account involved in the event"
account: Account!
"Account to be transferred to - Relevant to Transfer event"
to: Account
"Event type: Deposit Withdraw Borrow Repay Liquidate"
eventType: String!
"Amount of Tokens transferred - Underlying"
amount: BigDecimal!
"Block timestamp"
blockTime: Int!
"Block number"
blockNumber: Int!
"Amount of Tokens transferred - used only in specific cases"
xTokenAmount: BigDecimal
"Liquidator that paid the debt: Relevant only for Liquidation event"
liquidator: Account
"Account of the payer - Related to Repay event"
payer: Account
"Account that was paid by account field"
onBehalfOf: Account
"Interest rate mode"
interestRateMode: Int
"Borrow rate"
borrowRate: BigInt
}
type Contract @entity {
id: ID!
name: String
}