-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathschema.graphql
472 lines (412 loc) · 11.2 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
"""
The Comptroller type has protocol level variables stored
"""
type Comptroller @entity {
"ID is set to 1"
id: ID!
"Oracle which gives the price of any given asset"
priceOracle: String!
"The percent, ranging from 0% to 100%, of a liquidatable account's borrow that can be repaid in a single liquidate transaction"
closeFactor: BigDecimal!
"The percent bonus liquidators get for liquidating. If the liquidation incentive is 1.1, liquidators receive an extra 10% of the borrowers collateral for every unit they close."
liquidationIncentive: BigDecimal!
"Listed markets"
_markets: [Market!]!
}
"""
Market stores all high level variables for a cToken market
"""
type Market @entity {
"CToken address"
id: ID!
"Array of AccountCTokens related to this market"
accountCTokens: [AccountCToken!]! @derivedFrom(field: "market")
"Name of the cToken"
name: String!
"CToken symbol"
symbol: String!
"Underlying token address"
underlyingAddress: String!
"Underlying token name"
underlyingName: String!
"Underlying price of token in ETH (ex. 0.007 DAI)"
underlyingPrice: BigDecimal!
"Underlying token symbol"
underlyingSymbol: String!
"Underlying token price in USD"
underlyingPriceUSD: BigDecimal!
"Underlying token decimal length"
underlyingDecimals: Int!
"Borrows in the market"
totalBorrows: BigDecimal!
"CToken supply."
totalSupply: BigDecimal!
"Bad debt."
badDebt: BigDecimal!
"Reserves stored in the contract"
reserves: BigDecimal!
"The cToken contract balance of ERC20 or ETH"
cash: BigDecimal!
"Yearly supply rate."
supplyRate: BigDecimal!
"Yearly borrow rate."
borrowRate: BigDecimal!
"Collateral factor determining how much one can borrow"
collateralFactor: BigDecimal!
"Exchange rate of tokens / cTokens"
exchangeRate: BigDecimal!
"The history of the markets borrow index return (Think S&P 500)"
borrowIndex: BigInt!
borrowCap: BigInt!
"The factor determining interest that goes to reserves"
reserveFactor: BigInt!
"Block the market is updated to"
accrualBlockTimestamp: Int!
"Timestamp the market was most recently updated"
blockTimestamp: Int!
"Address of the interest rate model"
interestRateModelAddress: String!
borrowerCount: Int!
supplierCount: Int!
mintPaused: Boolean!
borrowPaused: Boolean!
" Price feed address "
_feed: String!
}
"""
Account is an ETH address, with a list of all cToken markets the account has
participated in, along with liquidation information.
"""
type Account @entity {
"User ETH address"
id: ID!
"Array of CTokens user is in"
tokens: [AccountCToken!]! @derivedFrom(field: "account")
"Count user has been liquidated"
countLiquidated: Int!
"Count user has liquidated others"
countLiquidator: Int!
"True if user has ever borrowed"
hasBorrowed: Boolean!
}
"""
AccountCToken is a single account within a single cToken market, with data such
as interest earned or paid
"""
type AccountCToken @entity {
"Concatenation of CToken address and user address"
id: ID!
"Relation to market"
market: Market!
"Symbol of the cToken"
symbol: String!
"Relation to user"
account: Account!
"Transactions data"
transactions: [AccountCTokenTransaction!]! @derivedFrom(field: "account")
"Block number this asset was updated at in the contract"
accrualBlockNumber: BigInt!
"True if user is entered, false if they are exited"
enteredMarket: Boolean!
"CToken balance of the user"
cTokenBalance: BigDecimal!
"Total amount of underlying supplied"
totalUnderlyingSupplied: BigDecimal!
"Total amount of underling redeemed"
totalUnderlyingRedeemed: BigDecimal!
"The value of the borrow index upon users last interaction"
accountBorrowIndex: BigInt!
"Total amount underlying borrowed, exclusive of interest"
totalUnderlyingBorrowed: BigDecimal!
"Total amount underlying repaid"
totalUnderlyingRepaid: BigDecimal!
"Current borrow balance stored in contract (exclusive of interest since accrualBlockNumber)"
storedBorrowBalance: BigDecimal!
}
"""
Auxiliary entity for AccountCToken
"""
type AccountCTokenTransaction @entity {
id: ID!
account: AccountCToken!
tx_hash: String!
timestamp: BigInt!
block: BigInt!
logIndex: BigInt!
}
type Governor @entity {
id: ID!
proposalCount: Int!
quorumVotes: BigInt!
proposalThreshold: BigInt!
votingDelay: Int!
proposalMaxOperations: Int!
votingPeriod: Int!
breakGlassGuardian: Bytes!
}
type Proposal @entity {
# proposal id
id: ID!
# add this because we want to support range query by proposal id, and the `id` field doesn't support this as it is String
proposalID: Int!
proposer: Proposer!
targets: [Bytes!]!
values: [BigInt!]!
signatures: [String!]!
calldatas: [Bytes!]!
startTimestamp: BigInt!
endTimestamp: BigInt!
startBlock: BigInt!
canceled: Boolean!
executed: Boolean!
forVotes: BigInt!
againstVotes: BigInt!
abstainVotes: BigInt!
totalVotes: BigInt!
description: String!
stateChanges: [ProposalStateChange!]! @derivedFrom(field: "proposal")
}
enum ProposalState {
CREATED
CANCELED
EXECUTED
QUEUED
}
type ProposalStateChange @entity {
# {txn hash}-{log index}
id: ID!
proposal: Proposal!
txnHash: Bytes!
blockNumber: BigInt!
newState: ProposalState!
queueEta: BigInt # only set this field when newState == QUEUED
}
type Vote @entity {
# {txn hash}-{log index}
id: ID!
txnHash: Bytes!
blockNumber: BigInt!
voter: Voter!
proposal: Proposal!
voteValue: Int!
votes: BigInt!
}
type Proposer @entity {
id: ID!
proposals: [Proposal!]! @derivedFrom(field: "proposer")
}
type Voter @entity {
id: ID!
votes: [Vote!]! @derivedFrom(field: "voter")
}
"""
An interface for a transfer of any cToken. TransferEvent, MintEvent,
RedeemEvent, and LiquidationEvent all use this interface
"""
interface CTokenTransfer {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"Account that received tokens"
to: String!
"Account that sent tokens"
from: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
}
"""
TransferEvent will be stored for every mint, redeem, liquidation, and any normal
transfer between two accounts.
"""
type TransferEvent implements CTokenTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"Account that received tokens"
to: String!
"Account that sent tokens"
from: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
"Underlying symbol of the cToken transferred"
underlyingSymbol: String!
}
"""
MintEvent stores information for mints. From address will always be a cToken
market address
"""
type MintEvent implements CTokenTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"Account that received tokens (minter)"
to: String!
"Account that sent tokens (CToken contract)"
from: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
"Underlying symbol of the cToken transferred"
underlyingSymbol: String!
"Underlying token amount transferred"
underlyingAmount: BigDecimal
}
"""
RedeemEvent stores information for redeems. To address will always be a
cToken market address
"""
type RedeemEvent implements CTokenTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"Account that received tokens (CToken contract)"
to: String!
"Account that sent tokens (redeemer)"
from: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
"Underlying symbol of the cToken transferred"
underlyingSymbol: String!
"Underlying token amount transferred"
underlyingAmount: BigDecimal
}
"""
LiquidationEvent stores information for liquidations. The event is emitted from
the cToken market address.
"""
type LiquidationEvent implements CTokenTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"cTokens seized"
amount: BigDecimal!
"Liquidator receiving tokens"
to: String!
"Account being liquidated (borrower)"
from: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"cToken that was sezied as collateral"
cTokenSymbol: String!
"Symbol of the underlying asset repaid through liquidation"
underlyingSymbol: String!
"Underlying cToken amount that was repaid by liquidator"
underlyingRepayAmount: BigDecimal!
}
"""
Underlying transfers are transfers of underlying collateral for both borrows
and repays
"""
interface UnderlyingTransfer {
"Transaction hash concatenated with log index"
id: ID!
"Amount of underlying borrowed"
amount: BigDecimal!
"Total borrows of this asset the account has"
accountBorrows: BigDecimal!
"Account that borrowed the tokens"
borrower: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the borrowed underlying asset"
underlyingSymbol: String!
}
"""
BorrowEvent stores information for borrows
"""
type BorrowEvent implements UnderlyingTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"Amount of underlying borrowed"
amount: BigDecimal!
"Total borrows of this asset the account has"
accountBorrows: BigDecimal!
"Account that borrowed the tokens"
borrower: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the borrowed underlying asset"
underlyingSymbol: String!
}
"""
RepayEvent stores information for repays. Payer is not always the same as
borrower, such as in the event of a Liquidation
"""
type RepayEvent implements UnderlyingTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"Amount of underlying repaid"
amount: BigDecimal!
"Total borrows of this asset the account has"
accountBorrows: BigDecimal!
"Account that borrowed the tokens"
borrower: String!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the borrowed underlying asset"
underlyingSymbol: String!
"Payer of the borrow funds"
payer: String!
}
type MarketDailySnapshot @entity {
" {market smart contract address}-{epoch days} "
id: ID!
market: Market!
totalBorrows: BigDecimal!
totalSupplies: BigDecimal!
totalBorrowsUSD: BigDecimal!
totalSuppliesUSD: BigDecimal!
}
type AccountCTokenDailySnapshot @entity {
" {accountID}-{marketID}-{epoch days} "
id: ID!
account: Account!
market: Market!
totalBorrows: BigDecimal!
totalSupplies: BigDecimal!
totalBorrowsUSD: BigDecimal!
totalSuppliesUSD: BigDecimal!
collateralFactor: BigDecimal!
collateralValueUSD: BigDecimal!
}
type AccountDailySnapshot @entity {
" {accountID}-{epoch days} "
id: ID!
account: Account!
totalBorrowsUSD: BigDecimal!
totalSuppliesUSD: BigDecimal!
collateralValueUSD: BigDecimal!
}
type StakingDailySnapshot @entity {
" {staking smart contract address}-{epoch days} "
id: ID!
stakedToken: String!
totalStaked: BigDecimal!
totalStakedUSD: BigDecimal!
}