forked from notional-finance/subgraph-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
581 lines (509 loc) · 15.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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
type Proposal @entity {
"Proposal's unique identifier"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
createdAt: Int!
proposer: Delegate!
votes: [Vote!]!
history: [ProposalState!]
targets: [Bytes!]!
values: [BigInt!]!
calldatas: [Bytes!]!
startBlock: Int!
endBlock: Int!
isCancelled: Boolean
isQueued: Boolean
isExecuted: Boolean
}
type Vote @entity {
"Address and proposal combined as the unique identifier"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
proposal: Proposal!
delegate: Delegate!
yesToProposal: Boolean!
votingPower: BigInt!
}
type Delegate @entity {
"Ethereum address"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
votes: [Vote!] @derivedFrom(field: "delegate")
proposals: [Proposal!] @derivedFrom(field: "proposer")
}
type ProposalState @entity {
id: ID!
state: ProposalStateEnum!
transactionHash: Bytes!
lastUpdateTimestamp: Int!
}
enum TokenType {
"Token that is the base for a cToken or other mintable token"
UnderlyingToken
"Compound interest bearing token"
cToken
"Ether specific Compound interest bearing token"
cETH
"The one and only Ether"
Ether
"A token that cannot be minted as a cToken, but can be used as collateral or traded"
NonMintable
}
enum ProposalStateEnum {
PENDING
CANCELLED
QUEUED
EXECUTED
}
type Currency @entity {
"Auto incrementing unique numeric id"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Category of token that this refers to"
tokenType: TokenType!
"Name of the asset currency"
name: String!
"Symbol of the asset currency"
symbol: String!
"Address of asset token"
tokenAddress: Bytes!
"Decimals of the asset token"
decimals: BigInt!
"If asset token has a transfer fee"
hasTransferFee: Boolean!
"Maximum total contract balance for collateral, zero if no limit"
maxCollateralBalance: BigInt
"Name of the underlying currency"
underlyingName: String
"Symbol of the underlying currency"
underlyingSymbol: String
"Address of underlying token"
underlyingTokenAddress: Bytes
"Decimals of the underlying token"
underlyingDecimals: BigInt
"If underlying token has a transfer fee"
underlyingHasTransferFee: Boolean
"Exchange rate from this currency to Eth, used in free collateral calculations"
ethExchangeRate: EthExchangeRate! @derivedFrom(field: "baseCurrency")
"Exchange rate from this currency to the underlying asset"
assetExchangeRate: AssetExchangeRate @derivedFrom(field: "assetCurrency")
"Cash group for a currency, if exists"
cashGroup: CashGroup @derivedFrom(field: "currency")
"nToken for a currency, if exists"
nToken: nToken @derivedFrom(field: "currency")
}
type EthExchangeRate @entity {
"Currency id that this exchange rate refers to"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Base currency in the exchange rate"
baseCurrency: Currency!
"Rate oracle that is used to reference the exchange rate"
rateOracle: Bytes!
"Decimal places of the exchange rate"
rateDecimalPlaces: Int!
"Does the exchange rate need to invert"
mustInvert: Boolean!
"Percentage buffer used when calculating free collateral for debt balances"
buffer: Int!
"Percentage haircut used when calculating free collateral for collateral balances"
haircut: Int!
"Exchange rate discount given when liquidating this currency"
liquidationDiscount: Int!
}
type AssetExchangeRate @entity {
"Currency id that this asset rate refers to"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Asset currency in the exchange rate"
assetCurrency: Currency!
"Asset rate adapter interface to the asset token"
rateAdapterAddress: Bytes!
"Decimal places of the underlying token to the asset token"
underlyingDecimalPlaces: Int!
"Asset rates that fCash assets will settle at for given maturities"
settlementRates: [SettlementRate!] @derivedFrom(field: "assetExchangeRate")
}
type SettlementRate @entity {
"Currency id and maturity that this settlement rate refers to"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Currency of this settlement rate"
currency: Currency!
"Asset exchange rate referenced by this settlement rate"
assetExchangeRate: AssetExchangeRate!
"Maturity that this settlement rate refers to"
maturity: Int!
"Settlement rate value"
rate: BigInt!
}
type CashGroup @entity {
"Currency id that this cash group refers to"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Currency of this cash group"
currency: Currency!
"Index of the AMMs on chain that will be made available."
maxMarketIndex: Int!
"Maximum length of a market maturity in seconds"
maxMarketMaturityLengthSeconds: Int!
"Time window in minutes that the rate oracle will be averaged over"
rateOracleTimeWindowSeconds: Int!
"Total fees per trade, specified in basis points"
totalFeeBasisPoints: Int!
"Share of the fees given to the protocol, denominated in percentage"
reserveFeeSharePercent: Int!
"Debt buffer specified in basis points"
debtBufferBasisPoints: Int!
"fCash haircut specified in basis points"
fCashHaircutBasisPoints: Int!
"Penalty for settling a negative cash debt in basis points"
settlementPenaltyRateBasisPoints: Int!
"Discount on fCash given to the liquidator in basis points"
liquidationfCashHaircutBasisPoints: Int!
"Discount on negative fCash given to the liquidator in basis points"
liquidationDebtBufferBasisPoints: Int!
"Liquidity token haircut applied to cash claims, specified as a percentage between 0 and 100"
liquidityTokenHaircutsPercent: [Int!]!
"Rate scalar used to determine the slippage of the market"
rateScalars: [Int!]!
"Current size of reserves accumulated for this cash group"
reserveBalance: BigInt!
nToken: nToken! @derivedFrom(field: "cashGroup")
}
type nToken @entity {
"Currency id of the nToken"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Address of the nToken"
tokenAddress: Bytes!
name: String!
symbol: String!
decimals: BigInt!
totalSupply: BigInt!
integralTotalSupply: BigInt!
lastSupplyChangeTime: BigInt!
"Cash group that governs this nToken"
cashGroup: CashGroup!
"Currency of this nToken"
currency: Currency!
"Proportion of deposits that go into each corresponding market"
depositShares: [Int!]
"Maximum market proportion that the nToken will provide liquidity at"
leverageThresholds: [Int!]
"Annualized anchor rates used during market initialization"
annualizedAnchorRates: [Int!]
"Market proportions used during market initialization"
proportions: [Int!]
"Annual incentive emission rate"
incentiveEmissionRate: BigInt
"Residual purchase incentive in basis points"
residualPurchaseIncentiveBasisPoints: Int
"Seconds until residuals become available to purchase after market initialization"
residualPurchaseTimeBufferSeconds: Int
"Basis points of cash withholding for negative fCash"
cashWithholdingBufferBasisPoints: Int
"Percentage of the nToken PV that is used during free collateral"
pvHaircutPercentage: Int
"Discount on nToken PV given to liquidators"
liquidationHaircutPercentage: Int
"Link to the nToken account object"
account: Account @derivedFrom(field: "nToken")
}
type GlobalTransferOperator @entity {
"Address of the global transfer operator"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
}
type AuthorizedCallbackContract @entity {
"Address of the callback contract"
id: ID!
name: String!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
}
enum AssetType {
fCash
LiquidityToken_3Month
LiquidityToken_6Month
LiquidityToken_1Year
LiquidityToken_2Year
LiquidityToken_5Year
LiquidityToken_10Year
LiquidityToken_20Year
}
type Account @entity {
"Account address"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Timestamp of the next time that the account will require settlement"
nextSettleTime: BigInt!
"True if the account's portfolio has debt assets"
hasPortfolioAssetDebt: Boolean!
"True if the account's cash balances have debt, may be temporarily inconsistent after a SettleCashEvent"
hasCashDebt: Boolean!
"Currency id of an asset bitmap, if set"
assetBitmapCurrency: Currency
"Account's balances of both cash and nTokens"
balances: [Balance!]!
"Account's portfolio assets"
portfolio: [Asset!]!
"A link to the nToken object if this is an nToken"
nToken: nToken
tradeHistory: [Trade!] @derivedFrom(field: "account")
balanceChanges: [BalanceChange!] @derivedFrom(field: "account")
assetChanges: [AssetChange!] @derivedFrom(field: "account")
nTokenChanges: [nTokenChange!] @derivedFrom(field: "account")
}
type Balance @entity {
"Account Address:Currency ID combination"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Reference to currency that this balance represents"
currency: Currency!
"Cash balance denominated in asset cash terms"
assetCashBalance: BigInt!
"nToken balance of this currency"
nTokenBalance: BigInt!
"Last time token incentives were claimed on this balance"
lastClaimTime: Int!
"Last stored integral total supply amount, used to calculate incentives"
lastClaimIntegralSupply: BigInt!
}
type Asset @entity {
"Account:CurrencyId:AssetType:Maturity"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Reference to currency that this balance represents"
currency: Currency!
"Timestamp when fCash matures, if liquidity token this will still refer to fCash maturity date"
maturity: BigInt!
"Date when assets will be settled, quarterly for liquidity tokens and at maturity for fCash"
settlementDate: BigInt!
"Asset type"
assetType: AssetType!
"Notional amount"
notional: BigInt!
}
type Market @entity {
"Currency Id:Settlement Date:Maturity combination"
id: ID!
lastUpdateBlockHash: Bytes!
lastUpdateBlockNumber: Int!
lastUpdateTimestamp: Int!
lastUpdateTransactionHash: Bytes!
"Currency of this market"
currency: Currency!
"Date that fCash from this market will mature"
maturity: Int!
"Date that this market will settle"
settlementDate: Int!
"Market index"
marketIndex: Int!
"Length of market maturity in seconds"
marketMaturityLengthSeconds: Int!
"Total fCash available in the market"
totalfCash: BigInt!
"Total asset cash available in the market"
totalAssetCash: BigInt!
"Total liquidity tokens available in the market"
totalLiquidity: BigInt!
"Last annualized interest rate the market traded at"
lastImpliedRate: Int!
"Oracle rate for the market, must be averaged in using previousTradeTime"
oracleRate: Int!
"Last time when a trade occurred on the market"
previousTradeTime: Int!
}
type MarketInitialization @entity {
"Currency ID:time reference timestamp"
id: ID!
blockHash: Bytes!
blockNumber: Int!
timestamp: Int!
transactionHash: Bytes!
transactionOrigin: Bytes!
"Currency of markets"
currency: Currency!
"Markets that were initialized during this event"
markets: [Market!]!
}
enum TradeType {
Lend
Borrow
AddLiquidity
RemoveLiquidity
PurchaseNTokenResidual
SettleCashDebt
}
type Trade @entity {
"Currency ID:Account:Transaction hash:logIndex"
id: ID!
blockHash: Bytes!
blockNumber: Int!
timestamp: Int!
transactionHash: Bytes!
transactionOrigin: Bytes!
account: Account!
currency: Currency!
market: Market
tradeType: TradeType!
maturity: BigInt!
netAssetCash: BigInt!
netUnderlyingCash: BigInt!
netfCash: BigInt!
netLiquidityTokens: BigInt
}
type BalanceChange @entity {
"Currency ID:Account:Transaction hash:logIndex"
id: ID!
blockHash: Bytes!
blockNumber: Int!
timestamp: Int!
transactionHash: Bytes!
transactionOrigin: Bytes!
account: Account!
currency: Currency!
assetCashBalanceBefore: BigInt!
assetCashBalanceAfter: BigInt!
assetCashValueUnderlyingBefore: BigInt!
assetCashValueUnderlyingAfter: BigInt!
nTokenBalanceBefore: BigInt!
nTokenBalanceAfter: BigInt!
nTokenValueAssetBefore: BigInt!
nTokenValueAssetAfter: BigInt!
nTokenValueUnderlyingBefore: BigInt!
nTokenValueUnderlyingAfter: BigInt!
lastClaimTimeBefore: Int!
lastClaimTimeAfter: Int!
lastClaimIntegralSupplyBefore: BigInt!
lastClaimIntegralSupplyAfter: BigInt!
}
type AssetChange @entity {
"Account:CurrencyId:AssetType:Maturity:Transaction hash"
id: ID!
blockHash: Bytes!
blockNumber: Int!
timestamp: Int!
transactionHash: Bytes!
transactionOrigin: Bytes!
account: Account!
currency: Currency!
maturity: BigInt!
settlementDate: BigInt!
assetType: AssetType!
notionalBefore: BigInt!
notionalAfter: BigInt!
}
type nTokenChange @entity {
"nTokenAddress:Transaction hash"
id: ID!
blockHash: Bytes!
blockNumber: Int!
timestamp: Int!
transactionHash: Bytes!
transactionOrigin: Bytes!
nToken: nToken!
"Account that mints or redeems nTokens, set to null on initialize markets"
account: Account
assetChanges: [AssetChange!]!
balanceChange: BalanceChange
totalSupplyBefore: BigInt!
totalSupplyAfter: BigInt!
integralTotalSupplyBefore: BigInt!
integralTotalSupplyAfter: BigInt!
lastSupplyChangeTimeBefore: BigInt!
lastSupplyChangeTimeAfter: BigInt!
}
type AssetTransfer @entity {
"from:to:assetId:Transaction hash"
id: ID!
blockHash: Bytes!
blockNumber: Int!
timestamp: Int!
transactionHash: Bytes!
transactionOrigin: Bytes!
fromAssetChange: AssetChange!
toAssetChange: AssetChange!
}
# type IncentivesClaimed @entity {
# }
enum LiquidationType {
LocalCurrency
LocalFcash
CollateralCurrency
CrossCurrencyFcash
}
type Liquidation @entity {
id: ID!
blockHash: Bytes!
blockNumber: Int!
timestamp: Int!
transactionHash: Bytes!
transactionOrigin: Bytes!
type: LiquidationType!
account: Account!
liquidator: Account!
localCurrency: Currency!
netLocalFromLiquidator: BigInt!
collateralOrFcashCurrency: Currency
netCollateralTransfer: BigInt
netNTokenTransfer: BigInt
fCashMaturities: [BigInt!]
fCashNotionalTransfer: [BigInt!]
}
# Data accumulated and condensed into day stats for lending and borrowing
type DailyLendBorrowVolume @entity {
id: ID!
date: Int!
currency: Currency!
market: Market!
trades: [Trade!]!
marketIndex: Int!
tradeType: TradeType!
totalVolumeUnderlyingCash: BigInt!
totalVolumeNetAssetCash: BigInt!
totalVolumeNetfCash: BigInt!
txCount: BigInt!
}