forked from platocrat/fuseV1-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
444 lines (405 loc) · 13.3 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
"""
Pool stores all high level variables for a Comptroller's Fuse pool
"""
type Pool @entity {
"Same as `comptroller` field to allow for dynamic loading of FusePool entities"
id: ID!
"Fuse pool index, taken from emitted `PoolRegistered` event"
index: BigInt!
# Fields that match Rari's Fuse pool API
"Name of the Fuse pool"
name: String!
"Creator/admin of the Fuse pool"
creator: Bytes!
"Comptroller address"
comptroller: Bytes!
"Block at which the tx, to create the Fuse pool, was first included"
blockPosted: BigInt!
"Block timestamp of when the tx, to create the Fuse pool, was first included"
timestampPosted: BigInt!
"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
# Fields that are not in Rari's api
"All Markets (i.e CToken) that are in a Fuse pool"
markets: [Market!]! # @derivedFrom(field: "pool")
# "Total amount of liquidity that has been supplied to this Fuse pool"
# totalSupplyUSD: BigDecimal!
# "Total amount of liquidity that has been borrowed from this Fuse pool"
# totalBorrowUSD: BigDecimal!
}
"""
Market stores all high level variables for a cToken market
"""
type Market @entity {
#Fields that match compounds API
"Yearly borrow rate. With 2102400 blocks per year"
borrowRate: BigInt!
"The cToken contract balance of ERC20 or ETH"
cash: BigDecimal!
"Collateral factor determining how much one can borrow"
collateralFactor: BigDecimal!
"Exchange rate of tokens / cTokens"
exchangeRate: BigDecimal!
"Address of the interest rate model"
interestRateModelAddress: Bytes!
"Name of the cToken"
name: String!
"Reserves stored in the contract"
reserves: BigDecimal!
"Yearly supply rate. With 2104400 blocks per year"
supplyRate: BigInt!
"Supply rate annual percent rate -- measures interest charged"
borrowRateAPR: BigInt!
"Supply rate annual percent yield -- measures interest earned"
supplyRateAPY: BigInt!
"CToken symbol"
symbol: String!
"CToken address"
id: ID!
"Borrows in the market"
totalBorrows: BigDecimal!
"CToken supply. CTokens have 8 decimals"
totalSupply: BigDecimal!
"Underlying token address"
underlyingAddress: Bytes!
"Underlying token name"
underlyingName: String!
"Underlying price of token in ETH (ex. 0.007 DAI)"
underlyingPrice: BigDecimal!
"Underlying token symbol"
underlyingSymbol: String!
# Fields that are not in compounds api
"Block the market is updated to"
accrualBlockNumber: Int!
"Timestamp the market was most recently updated"
blockTimestamp: Int!
"The history of the markets borrow index return (Think S&P 500)"
borrowIndex: BigDecimal!
"The factor determining interest that goes to reserves"
reserveFactor: BigInt!
"Underlying token price in USD"
underlyingPriceUSD: BigDecimal!
"Underlying token decimal length"
underlyingDecimals: Int!
# "Total amount of supply-side liquidity, in USD, in this market"
# totalSupplyUSD: BigDecimal!
# "Total amount of borrow-side liquidity, in USD, in this market"
# totalBorrowUSD: BigDecimal!
# Relations for `Pool` entity...
"Relation to the `Pool` entity"
pool: Pool!
}
"""
Admin is an ETH address, with a list of all cToken markets the account has
participated in, along with liquidation information.
"""
type Admin @entity {
"User ETH address"
id: ID!
"Array of Fuse pools the admin is in"
pools: [AdminFusePool!]! @derivedFrom(field: "admin")
"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
# We can add more fields to this entity.
# See `Account` entity for examples of what additional fields to add.
}
"""
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"
accountCTokens: [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!
# The following values are added by the JS Wrapper, and must be calculated with the most up
# to date values based on the block delta for market.exchangeRate and market.borrowIndex
# They do not need to be in the schema, but they will show up in the explorer playground
# "If less than 1, the account can be liquidated
# health: BigDecimal!
# "Total assets supplied by user"
# totalBorrowValueInEth: BigDecimal!
# "Total assets borrowed from user"
# totalCollateralValueInEth: BigDecimal!
}
"""
AdminFusePool is a single comptroller account of a single Fuse pool, with data such as ...
"""
type AdminFusePool @entity {
"Concatenation of Fuse pool address and its admin address"
id: ID!
"Relation to comptroller"
pool: Pool!
"Name of the Fuse pool"
name: String!
"Relation to user"
admin: Admin!
"Transactions data"
transactions: [AdminFusePoolTransaction!]! @derivedFrom(field: "admin")
"Block number this asset was updated at in the contract"
accrualBlockNumber: BigInt!
"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
# Fields that are a part of the `AccountCToken` entity that were not
# mirrored in this entity can be found in the `AccountCToken` entity.
}
"""
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: BigDecimal!
"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!
# The following values are added by the JS Wrapper, and must be calculated with the most up
# to date values based on the block delta for market.exchangeRate and market.borrowIndex
# They do not need to be in the schema, but they will show up in the explorer playground
# supplyBalanceUnderlying: BigDecimal!
# FORMULA: supplyBalanceUnderlying = cTokenBalance * market.exchangeRate
# lifetimeSupplyInterestAccrued: BigDecimal!
# FORMULA: lifetimeSupplyInterestAccrued = supplyBalanceUnderlying - totalUnderlyingSupplied + totalUnderlyingRedeemed
# borrowBalanceUnderlying: BigDecimal!
# FORMULA: borrowBalanceUnderlying = storedBorrowBalance * market.borrowIndex / accountBorrowIndex
# lifetimeBorrowInterestAccrued: BigDecimal!
# FORMULA: lifetimeBorrowInterestAccrued = borrowBalanceUnderlying - totalUnderlyingBorrowed + totalUnderlyingRepaid
}
"""
Auxiliary entity for AdminFusePool
"""
type AdminFusePoolTransaction @entity {
id: ID!
admin: AdminFusePool!
tx_hash: Bytes!
timestamp: BigInt!
block: BigInt!
logIndex: BigInt!
}
"""
Auxiliary entity for AccountCToken
"""
type AccountCTokenTransaction @entity {
id: ID!
account: AccountCToken!
tx_hash: Bytes!
timestamp: BigInt!
block: BigInt!
logIndex: BigInt!
}
"""
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: Bytes!
"Account that sent tokens"
from: Bytes!
"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: Bytes!
"Account that sent tokens"
from: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: 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: Bytes!
"Account that sent tokens (CToken contract)"
from: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: 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: Bytes!
"Account that sent tokens (redeemer)"
from: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: 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: Bytes!
"Account being liquidated (borrower)"
from: Bytes!
"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: Bytes!
"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: Bytes!
"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: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the borrowed underlying asset"
underlyingSymbol: String!
"Payer of the borrow funds"
payer: Bytes!
}