-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
1035 lines (890 loc) · 34.5 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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
####
# Core entities
####
type Protocol @entity {
"Configurator proxy address"
id: Bytes!
"Configurator proxy address"
configuratorProxy: Bytes!
"Current address of the configurator implementation"
configuratorImplementation: Bytes
"Markets that exist in the protocol"
markets: [Market!]!
"Current accounting for the whole protocol"
accounting: ProtocolAccounting!
"Current cumulative usage for the whole protocol"
cumulativeUsage: Usage!
####
# Derived
####
"Historical snapshots of hourly protocol usage"
hourlyUsage: [ProtocolHourlyUsage!]! @derivedFrom(field: "protocol")
"Historical snapshots of daily protocol usage"
dailyUsage: [ProtocolDailyUsage!]! @derivedFrom(field: "protocol")
"Historical snapshots of hourly protocol accounting"
hourlyProtocolAccounting: [HourlyProtocolAccounting!]! @derivedFrom(field: "protocol")
"Historical snapshots of daily protocol accounting"
dailyProtocolAccounting: [DailyProtocolAccounting!]! @derivedFrom(field: "protocol")
"Historical snapshots of weekly protocol accounting"
weeklyProtocolAccounting: [WeeklyProtocolAccounting!]! @derivedFrom(field: "protocol")
}
type Market @entity(immutable: true) {
"Comet proxy address"
id: Bytes!
"Comet proxy address"
cometProxy: Bytes!
"Protocol this market is part of"
protocol: Protocol!
"Block number the market was created"
creationBlockNumber: BigInt!
"Current configuration of this market"
configuration: MarketConfiguration!
rewardConfiguration: MarketRewardConfiguration!
"Current accounting of this market"
accounting: MarketAccounting!
"Current cumulative usage of this market"
cumulativeUsage: Usage!
####
# Derived
####
"DEPRECIATED (moved into MarketAccounting): Current collateral balances of this market"
collateralBalances: [MarketCollateralBalance!]! @derivedFrom(field: "market") @deprecated(reason: "Moved into MarketAccounting")
"Current positions in this market"
positions: [Position!]! @derivedFrom(field: "market")
"All interactions where the base asset was supplied to this market, including those repaying loans"
supplyBaseInteractions: [SupplyBaseInteraction!]! @derivedFrom(field: "market")
"All interactions where the base asset was withdraw from this market, including those taking loans"
withdrawBaseInteractions: [WithdrawBaseInteraction!]! @derivedFrom(field: "market")
"All interactions where a position was liquidated in this market"
absorbDebtInteractions: [AbsorbDebtInteraction!]! @derivedFrom(field: "market")
"All interactions where a collateral asset was supplied to this market"
supplyCollateralInteractions: [SupplyCollateralInteraction!]! @derivedFrom(field: "market")
"All interactions where a collateral asset was withdrawn from this market"
withdrawCollateralInteractions: [WithdrawCollateralInteraction!]! @derivedFrom(field: "market")
"All interactions where a collateral asset was transferred in this market"
transferCollateralInteractions: [TransferCollateralInteraction!]! @derivedFrom(field: "market")
"All interactions where a collateral asset was absorbed by the market during a liquidation"
absorbCollateralInteractions: [AbsorbCollateralInteraction!]! @derivedFrom(field: "market")
"All interactions where a collateral asset was bought using base assets in this market"
buyCollateralInteractions: [BuyCollateralInteraction!]! @derivedFrom(field: "market")
"All interactions where reserves were withdrawn from this market"
withdrawReservesInteractions: [WithdrawReservesInteraction!]! @derivedFrom(field: "market")
"Historical snapshots of hourly market usage"
hourlyUsage: [MarketHourlyUsage!]! @derivedFrom(field: "market")
"Historical snapshots of daily market usage"
dailyUsage: [MarketDailyUsage!]! @derivedFrom(field: "market")
"Historical snapshots of market configuration changes, these only get taken on a config change (not periodically)"
configurationSnapshots: [MarketConfigurationSnapshot!]! @derivedFrom(field: "market")
"Historical snapshots of hourly market accounting"
hourlyMarketAccounting: [HourlyMarketAccounting!]! @derivedFrom(field: "market")
"Historical snapshots of daily market accounting"
dailyMarketAccounting: [DailyMarketAccounting!]! @derivedFrom(field: "market")
"Historical snapshots of weekly market accounting"
weeklyMarketAccounting: [WeeklyMarketAccounting!]! @derivedFrom(field: "market")
}
type Position @entity(immutable: true) {
"Market proxy address + owner address"
id: Bytes!
"Block number the position was created"
creationBlockNumber: BigInt!
"Market the position is in"
market: Market!
"Owner of the position"
account: Account!
"Current accounting of this position"
accounting: PositionAccounting!
####
# Derived
####
"DEPRECIATED (moved into PositionAccounting): Current collateral balances of this position"
collateralBalances: [PositionCollateralBalance!]! @derivedFrom(field: "position") @deprecated(reason: "Moved into PositionAccounting")
"All interactions where the base asset was supplied to this position, including those repaying loans"
supplyBaseInteractions: [SupplyBaseInteraction!]! @derivedFrom(field: "position")
"All interactions where the base asset was withdraw from this position, including those taking loans"
withdrawBaseInteractions: [WithdrawBaseInteraction!]! @derivedFrom(field: "position")
"All interactions where the base asset was transferred from this position"
transferFromBaseInteractions: [TransferBaseInteraction!]! @derivedFrom(field: "fromPosition")
"All interactions where the base asset was transferred to this position"
transferToBaseInteractions: [TransferBaseInteraction!]! @derivedFrom(field: "toPosition")
"All interactions where this position was liquidated"
absorbDebtInteractions: [AbsorbDebtInteraction!]! @derivedFrom(field: "position")
"All interactions where a collateral asset was supplied to this position"
supplyCollateralInteractions: [SupplyCollateralInteraction!]! @derivedFrom(field: "position")
"All interactions where a collateral asset was withdrawn from this position"
withdrawCollateralInteractions: [WithdrawCollateralInteraction!]! @derivedFrom(field: "position")
"All interactions where a collateral asset was transferred from this position"
transferFromCollateralInteractions: [TransferCollateralInteraction!]! @derivedFrom(field: "fromPosition")
"All interactions where a collateral asset was transferred to this position"
transferToCollateralInteractions: [TransferCollateralInteraction!]! @derivedFrom(field: "toPosition")
"All interactions where a collateral asset was absorbed by the market during a liquidation of this position"
absorbCollateralInteractions: [AbsorbCollateralInteraction!]! @derivedFrom(field: "position")
"All interactions claiming rewards"
rewardsClaimedInteractions: [ClaimRewardsInteraction!]! @derivedFrom(field: "position")
"Historical snapshots of position accounting changes, these only get taken when the position accounting changes (not periodically)"
positionAccountingSnapshots: [PositionAccountingSnapshot!] @derivedFrom(field: "position")
}
####
# Configuration
####
type MarketConfiguration @entity {
"Market proxy address or block number + log index for snapshots"
id: Bytes!
"Market to configuration is for"
market: Market!
"Comet implementation that the market proxy points to"
cometImplementation: Bytes
"Last block that this configuration was updated"
lastConfigurationUpdateBlockNumber: BigInt!
"Name of the market"
name: String!
"Symbol for the ERC20 that market represents"
symbol: String!
"Factory contract address for the market"
factory: Bytes!
"Governor of the market"
governor: Bytes!
"Pause guardian for the market"
pauseGuardian: Bytes!
"Comet extension delegate for the market"
extensionDelegate: Bytes!
"Supply rate model utilization kink in percent"
supplyKink: BigDecimal!
"Slope of the supply rate model when the utilization is below the supply kink"
supplyPerSecondInterestRateSlopeLow: BigInt!
"Slope of the supply rate model when the utilization is above the supply kink"
supplyPerSecondInterestRateSlopeHigh: BigInt!
"Base for the supply rate model"
supplyPerSecondInterestRateBase: BigInt!
"Borrow rate model utilization kink in percent"
borrowKink: BigDecimal!
"Slope of the borrow rate model when the utilization is below the borrow kink"
borrowPerSecondInterestRateSlopeLow: BigInt!
"Slope of the borrow rate model when the utilization is above the borrow kink"
borrowPerSecondInterestRateSlopeHigh: BigInt!
"Base for the borrow rate model"
borrowPerSecondInterestRateBase: BigInt!
"Store front factor used to compute the discount factor for liquidations"
storeFrontPriceFactor: BigInt!
"Tracking index scale"
trackingIndexScale: BigInt!
"Base tracking supply speed for rewards"
baseTrackingSupplySpeed: BigInt!
"Base tracking borrow speed for rewards"
baseTrackingBorrowSpeed: BigInt!
"Minimum base asset in market before rewards will accrue"
baseMinForRewards: BigInt!
"Smallest amount of base that can be borrowed"
baseBorrowMin: BigInt!
"Target base reserves for the market, when reserve drop below collateral reserves become for sale to bring base reserves above this"
targetReserves: BigInt!
"Base tokens for the market"
baseToken: BaseToken!
"List of collateral tokens for the market"
collateralTokens: [CollateralToken!]!
}
type MarketRewardConfiguration @entity {
"Market id + reward token address"
id: Bytes!
tokenAddress: Bytes!
rescaleFactor: BigInt!
shouldUpscale: Boolean!
multiplier: BigInt!
}
####
# Accounting
####
type ProtocolAccounting @entity {
"Protocol ID + hour number for snapshots"
id: Bytes!
"Protocol the accounting is for"
protocol: Protocol!
"Last block the accounting was updated"
lastUpdatedBlock: BigInt!
"Total amount supplied in USD to the protocol"
totalSupplyUsd: BigDecimal!
"Total amount borrowed in USD from the protocol"
totalBorrowUsd: BigDecimal!
"Total base assets reserve balance in USD of protocol"
reserveBalanceUsd: BigDecimal!
"Total collateral balance in USD of the protocol"
collateralBalanceUsd: BigDecimal!
"Total collateral reserve balance in USD of the protocol"
collateralReservesBalanceUsd: BigDecimal!
"Total reserve balance in USD of the protocol (base reserves + collateral reserves)"
totalReserveBalanceUsd: BigDecimal!
"Utilization percent of the protocol (totalBorrowUsd / totalSupplyUsd)"
utilization: BigDecimal!
"Collateralization percent of the protocol (totalSupplyUsd / totalBorrowUsd, or 1 / utilization)"
collateralization: BigDecimal!
"Average base supply APR of the protocol (average over all markets)"
avgSupplyApr: BigDecimal!
"Average base borrow APR of the protocol (average over all markets)"
avgBorrowApr: BigDecimal!
"Average reward supply APR of the protocol (average over all markets)"
avgRewardSupplyApr: BigDecimal!
"Average reward borrow APR of the protocol (average over all markets)"
avgRewardBorrowApr: BigDecimal!
"Average net supply APR of the protocol (avgSupplyApr + avgRewardSupplyApy)"
avgNetSupplyApr: BigDecimal!
"Average net borrow APR of the protocol (avgBorrowApr - avgRewardBorrowApr)"
avgNetBorrowApr: BigDecimal!
}
type MarketAccounting @entity {
"Market ID + hour number for snapshots"
id: Bytes!
"Market the accounting is for"
market: Market!
"Last block the accounting was updated"
lastAccountingUpdatedBlockNumber: BigInt!
"Base supply index, this tracks protocol supply interest and monotonically increases"
baseSupplyIndex: BigInt!
"Base supply index, this tracks protocol borrow borrow and monotonically increases"
baseBorrowIndex: BigInt!
"Tracking supply index for supply rewards"
trackingSupplyIndex: BigInt!
"Tracking borrow index for borrow rewards"
trackingBorrowIndex: BigInt!
"Last time the market accrued interest (i.e indices changed)"
lastAccrualTime: BigInt!
"Total base principal supplied to the market, this can be used to construct the most accurate totalSupply in the case where indices changes haven't been picked up by the subgraph (can accrue without an event)"
totalBasePrincipalSupply: BigInt!
"Total base principal borrowed from the market, this can be used to construct the most accurate totalBorrow in the case where indices changes haven't been picked up by the subgraph (can accrue without an event)"
totalBasePrincipalBorrow: BigInt!
"Base asset reserve balance"
baseReserveBalance: BigInt!
"Total amount of base supplied to the market (present value)"
totalBaseSupply: BigInt!
"Total amount of base borrowed from the market (present value)"
totalBaseBorrow: BigInt!
"Collateral balances of the market"
collateralBalances: [MarketCollateralBalance!]!
"Total amount of base supplied to the market in USD"
totalBaseSupplyUsd: BigDecimal!
"Total amount of base borrowed from the market in USD"
totalBaseBorrowUsd: BigDecimal!
"Base asset reserve balance of te market in USD"
baseReserveBalanceUsd: BigDecimal!
"Total collateral balance in USD"
collateralBalanceUsd: BigDecimal!
"Total collateral reserve balance in USD"
collateralReservesBalanceUsd: BigDecimal!
"Total reserve balance in USD (collateral + base)"
totalReserveBalanceUsd: BigDecimal!
"Utilization percent of the market (totalBaseBorrowUsd / totalBaseSupplyUsd)"
utilization: BigDecimal!
"Collateralization percent of the protocol (totalBaseSupplyUsd / totalBaseBorrowUsd, or 1 / utilization)"
collateralization: BigDecimal!
"Base supply APR of the market"
supplyApr: BigDecimal!
"Base borrow APR of the market"
borrowApr: BigDecimal!
"Reward supply APR of the market"
rewardSupplyApr: BigDecimal!
"Reward borrow APR of the market"
rewardBorrowApr: BigDecimal!
"Net supply APR of the market (supplyApr + rewardSupplyApr)"
netSupplyApr: BigDecimal!
"Net borrow APR of the market (borrowApr - rewardBorrowApr)"
netBorrowApr: BigDecimal!
"Reward token price in USD"
rewardTokenUsdPrice: BigDecimal!
}
type PositionAccounting @entity {
"Position ID or block timestamp + log index for snapshots"
id: Bytes!
"Last block number that this accounting was updated"
lastUpdatedBlockNumber: BigInt!
"Position the accounting is for"
position: Position!
"Base principal of this position (+ for supply, - for borrow), this can be used to construct the most accurate balance using the market indices since position balances are only updated when the principal changes (supply, borrow, etc)"
basePrincipal: BigInt!
"Base balance of the position (from the last time it was updated, use basePrincipal and market indices for most accurate baseBalance)"
baseBalance: BigInt!
"Base tracking index for rewards for the position"
baseTrackingIndex: BigInt!
"Base tracking that this position has accrued"
baseTrackingAccrued: BigInt!
"Base balance in USD (+ for supply, - for borrow)"
baseBalanceUsd: BigDecimal!
"Collateral balance of the position in USD"
collateralBalanceUsd: BigDecimal!
"Collateral balances"
collateralBalances: [PositionCollateralBalance!]!
"Cumulative base token supplied (lend, repay)"
cumulativeBaseSupplied: BigInt!
"Cumulative base token withdrawn (remove lend, borrow)"
cumulativeBaseWithdrawn: BigInt!
"Cumulative base debt absorbed from liquidations"
cumulativeBaseDebtAbsorbed: BigInt!
"Cumulative base token supplied (supply, repay) in USD (prices from the time of the supply) - WARNING: it is possible base transfers are missed when debt it being transferred due to missing events: https://github.com/compound-finance/comet/issues/816"
cumulativeBaseSuppliedUsd: BigDecimal!
"Cumulative base token withdrawn (remove lend, borrow) in USD (prices from the time of the withdraw) - WARNING: it is possible base transfers are missed when debt it being transferred due to missing events: https://github.com/compound-finance/comet/issues/816"
cumulativeBaseWithdrawnUsd: BigDecimal!
"Cumulative collateral liquidated in USD (prices from the time of the liquidation)"
cumulativeCollateralLiquidatedUsd: BigDecimal!
"Cumulative reward tokens claimed"
cumulativeRewardsClaimed: BigInt!
"Cumulative reward tokens claimed in USD - WARNING: it is possible claims are missed as we need to infer the claim market since RewardClaimed event is missing info: https://github.com/compound-finance/comet/issues/816"
cumulativeRewardsClaimedUsd: BigDecimal!
cumulativeGasUsedWei: BigInt!
cumulativeGasUsedUsd: BigDecimal!
}
####
# Usage
####
type Usage @entity {
"Name + time qualifier (ex: PROTOCOL_HOUR + hour)"
id: Bytes!
"Protocol the usage is for"
protocol: Protocol!
"Number of unique users"
uniqueUsersCount: BigInt!
"Number of interactions"
interactionCount: BigInt!
"Number of base supply interactions"
supplyBaseCount: BigInt!
"Number of base withdraw interactions"
withdrawBaseCount: BigInt!
"Number of base transfer interactions"
transferBaseCount: BigInt!
"Number of liquidation interactions"
liquidationCount: BigInt!
"Number of supply collateral interactions"
supplyCollateralCount: BigInt!
"Number of withdraw collateral interactions"
withdrawCollateralCount: BigInt!
"Number of transfer collateral interactions"
transferCollateralCount: BigInt!
}
####
# Historical Snapshots
####
type HourlyProtocolAccounting @entity {
"Hour"
id: Bytes!
"Hours since unix epoch"
hour: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Protocol the accounting is for"
protocol: Protocol!
"Accounting snapshot"
accounting: ProtocolAccounting!
}
type DailyProtocolAccounting @entity {
"Day"
id: Bytes!
"Days since unix epoch"
day: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Protocol the accounting is for"
protocol: Protocol!
"Accounting snapshot"
accounting: ProtocolAccounting!
}
type WeeklyProtocolAccounting @entity {
"Week"
id: Bytes!
"Week since unix epoch"
week: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Protocol the accounting if for"
protocol: Protocol!
"Accounting snapshot"
accounting: ProtocolAccounting!
}
type MarketConfigurationSnapshot @entity {
"Block number + log index. Note config snapshots are only taken when config changes, not periodically"
id: Bytes!
"Timestamp in seconds since unix epoch"
timestamp: BigInt!
"Market the config is for"
market: Market!
"Configuration snapshot"
configuration: MarketConfiguration!
}
type HourlyMarketAccounting @entity {
"Market ID + hour"
id: Bytes!
"Hours since unix epoch"
hour: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Market the accounting if for"
market: Market!
"Accounting snapshot"
accounting: MarketAccounting!
}
type DailyMarketAccounting @entity {
"Market ID + day"
id: Bytes!
"Days since unix epoch"
day: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Market the accounting is for"
market: Market!
"Accounting snapshot"
accounting: MarketAccounting!
}
type WeeklyMarketAccounting @entity {
"Market ID + week"
id: Bytes!
"Weeks since unix epoch"
week: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Market the accounting if for"
market: Market!
"Accounting snapshot"
accounting: MarketAccounting!
}
type PositionAccountingSnapshot @entity {
"Position ID + block number + log index. Note that position snapshots are only taken when the position changes (supply, borrow, liquidate, etc.), not periodically"
id: Bytes!
"Timestamp in seconds since unix epoch"
timestamp: BigInt!
"Position the accounting is for"
position: Position!
"Accounting snapshot"
accounting: PositionAccounting!
}
type ProtocolHourlyUsage @entity {
"Hour"
id: Bytes!
"Hours since unix epoch"
hour: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Protocol the usage is for"
protocol: Protocol!
"Usage snapshot from that hour"
usage: Usage!
}
type ProtocolDailyUsage @entity {
"Day"
id: Bytes!
"Days since unix epoch"
day: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Protocol the usage is for"
protocol: Protocol!
"Usage snapshot from that day"
usage: Usage!
}
type MarketHourlyUsage @entity {
"Market ID + hour"
id: Bytes!
"Hours since unix epoch"
hour: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Market the usage is for"
market: Market!
"Usage snapshot from that hour"
usage: Usage!
}
type MarketDailyUsage @entity {
"Market ID + day"
id: Bytes!
"Days since unix epoch"
day: BigInt!
"Seconds since unix epoch"
timestamp: BigInt!
"Market the usage is for"
market: Market!
"Usage snapshot from that day"
usage: Usage!
}
####
# Tokens
####
type Token @entity {
"Token address"
id: Bytes!
"Token address"
address: Bytes!
"Token name"
name: String!
"Token symbol"
symbol: String!
"Token decimals"
decimals: Int
"Last token price in USD"
lastPriceUsd: BigDecimal!
"Block of the last token price update"
lastPriceBlockNumber: BigInt!
}
type BaseToken @entity {
"market ID + token ID"
id: Bytes!
"Block the base token was created"
creationBlockNumber: BigInt!
"Market the base token belongs to"
market: Market!
"Actual token"
token: Token!
"Last block that the base token config was updated"
lastConfigUpdateBlockNumber: BigInt!
"Price feed for the base token"
priceFeed: Bytes!
"Last token price in USD from the priceFeed"
lastPriceUsd: BigDecimal!
"Block of the last token price update"
lastPriceBlockNumber: BigInt!
}
type CollateralToken @entity {
"Market ID + token ID + 'Col'"
id: Bytes!
"Block the collateral token was created"
creationBlockNumber: BigInt!
"Market the collateral token belongs to"
market: Market!
"Actual token"
token: Token!
"Last block the collateral token config was updated"
lastConfigUpdateBlockNumber: BigInt!
"Price feed for the collateral token"
priceFeed: Bytes!
"Percent of collateral that can be borrowed against"
borrowCollateralFactor: BigDecimal!
"Percent of collateral that can be borrowed before the account becomes liquidate-able"
liquidateCollateralFactor: BigDecimal!
"Percent penalty incurred by the account upon liquidation, 0.93 => 7% penalty"
liquidationFactor: BigDecimal!
"Max amount that can be supplied to protect the protocol against over exposure"
supplyCap: BigInt!
"Last token price in USD from the priceFeed"
lastPriceUsd: BigDecimal!
"Block of the last token price"
lastPriceBlockNumber: BigInt!
}
####
# Collateral Token Balances
####
interface CollateralBalance {
id: Bytes!
creationBlockNumber: BigInt!
collateralToken: CollateralToken!
lastUpdateBlockNumber: BigInt!
balance: BigInt!
}
type MarketCollateralBalance implements CollateralBalance @entity {
"Collateral token ID + 'BAL'"
id: Bytes!
"Block number when this balance was created"
creationBlockNumber: BigInt!
"Collateral token the balance is for"
collateralToken: CollateralToken!
"Market balance is for"
market: Market!
"Last block number the balances and reserves were updated"
lastUpdateBlockNumber: BigInt!
"Balance of collateralToken"
balance: BigInt!
"Reserves of the collateral token"
reserves: BigInt!
"Balance in USD of the collateral token"
balanceUsd: BigDecimal!
"Reserves in USD of the collateral token"
reservesUsd: BigDecimal!
}
type PositionCollateralBalance implements CollateralBalance @entity {
"Position id + collateral token ID"
id: Bytes!
"Block number the position collateral balance was created"
creationBlockNumber: BigInt!
"Collateral token the balance is for"
collateralToken: CollateralToken!
"Position balance is for"
position: Position!
"Last block number the balances and reserves were updated"
lastUpdateBlockNumber: BigInt!
"Balance of collateralToken"
balance: BigInt!
"Balance in USD of the collateral token"
balanceUsd: BigDecimal!
}
####
# Account
####
type Account @entity {
"Address"
id: Bytes!
"Block number this account was created"
creationBlockNumber: BigInt!
"Address of the account"
address: Bytes!
####
# Derived
####
"All positions of the account"
positions: [Position!]! @derivedFrom(field: "account")
"All reward claim interactions of the account. Note that this includes all rewards claimed, where the positions may miss rewards claimed due to missing events"
rewardsClaimedInteractions: [ClaimRewardsInteraction!]! @derivedFrom(field: "account")
}
type _ActiveAccount @entity {
"Address + usecase specific metadata, this is just a helper for tracking overall usage"
id: Bytes!
}
####
# Interactions
####
type Transaction @entity(immutable: true) {
"Transaction hash"
id: Bytes!
"Transaction hash"
hash: Bytes!
"Block number transaction is part of"
blockNumber: BigInt!
"Timestamp of the transaction"
timestamp: BigInt!
"Address the transaction is from"
from: Bytes!
"Address the transaction is to"
to: Bytes
"Gas limit for the transaction"
gasLimit: BigInt!
"Gas price for the transaction"
gasPrice: BigInt!
"Amount of gas used"
gasUsed: BigInt
"Amount of gas used in USD"
gasUsedUsd: BigDecimal
# Counts which can be used for filtering on
supplyBaseInteractionCount: Int!
withdrawBaseInteractionCount: Int!
transferBaseInteractionCount: Int!
absorbDebtInteractionCount: Int!
supplyCollateralInteractionCount: Int!
withdrawCollateralInteractionCount: Int!
transferCollateralInteractionCount: Int!
absorbCollateralInteractionCount: Int!
buyCollateralInteractionCount: Int!
withdrawReservesInteractionCount: Int!
claimRewardsInteractionCount: Int!
####
# Derived
####
"All supply base interaction that were part of this transaction"
supplyBaseInteractions: [SupplyBaseInteraction!]! @derivedFrom(field: "transaction")
"All withdraw base interaction that were part of this transaction"
withdrawBaseInteractions: [WithdrawBaseInteraction!]! @derivedFrom(field: "transaction")
"All transfer base interaction that were part of this transaction"
transferBaseInteractions: [TransferBaseInteraction!]! @derivedFrom(field: "transaction")
"All absorb debt interaction that were part of this transaction"
absorbDebtInteractions: [AbsorbDebtInteraction!]! @derivedFrom(field: "transaction")
"All supply collateral interaction that were part of this transaction"
supplyCollateralInteractions: [SupplyCollateralInteraction!]! @derivedFrom(field: "transaction")
"All withdraw collateral interaction that were part of this transaction"
withdrawCollateralInteractions: [WithdrawCollateralInteraction!]! @derivedFrom(field: "transaction")
"All transfer collateral interaction that were part of this transaction"
transferCollateralInteractions: [TransferCollateralInteraction!]! @derivedFrom(field: "transaction")
"All absorb collateral interaction that were part of this transaction"
absorbCollateralInteractions: [AbsorbCollateralInteraction!]! @derivedFrom(field: "transaction")
"All buy collateral interaction that were part of this transaction"
buyCollateralInteractions: [BuyCollateralInteraction!]! @derivedFrom(field: "transaction")
"All withdraw reserves interaction that were part of this transaction"
withdrawReservesInteractions: [WithdrawReservesInteraction!]! @derivedFrom(field: "transaction")
"All claim rewards interaction that were part of this transaction"
claimRewardsInteractions: [ClaimRewardsInteraction!]! @derivedFrom(field: "transaction")
}
type SupplyBaseInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Market the interaction changes"
position: Position!
"Supplied of funds"
supplier: Bytes!
"Asset being supplied"
asset: BaseToken!
"Amount being supplied"
amount: BigInt!
"Amount being supplied in USD"
amountUsd: BigDecimal!
}
type WithdrawBaseInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Position the interaction is with"
position: Position!
"Where the funds are being withdrawn to"
destination: Bytes!
"Asset being withdrawn"
asset: BaseToken!
"Amount being withdrawn"
amount: BigInt!
"Amount being withdrawn in USD"
amountUsd: BigDecimal!
}
type TransferBaseInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Position the transfer is from, note all transfers are either mint or burns, if mint this will be null"
fromPosition: Position
"Position the transfer is to, note all transfers are either mint or burns, if burn this will be null"
toPosition: Position
"Asset being transferred"
asset: BaseToken!
"Amount being transferred, position for position balance increase (supply), negative for decrease (withdraw)"
amount: BigInt!
"Amount being transferred in USD"
amountUsd: BigDecimal!
}
type AbsorbDebtInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Position the interaction is with"
position: Position!
"Address that triggered the absorb"
absorber: Bytes!
"Asset being absorbed by the market"
asset: BaseToken!
"Amount of debt paid out"
amount: BigInt!
"Amount of debt being absorbed in USD"
amountUsd: BigDecimal!
}
type SupplyCollateralInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Position the interaction is with"
position: Position!
"Supplier of the collateral"
supplier: Bytes!
"Asset being supplied"
asset: CollateralToken!
"Amount supplied"
amount: BigInt!
"Amount supplied in USD"
amountUsd: BigDecimal!
}
type WithdrawCollateralInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Position the interaction is with"
position: Position!
"Where the assets are being withdrawn to"
destination: Bytes!
"Asset being withdrawn"
asset: CollateralToken!
"Asset being withdrawn"
amount: BigInt!
"Asset being withdrawn in USD"
amountUsd: BigDecimal!
}
type TransferCollateralInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Position the transfer is from"
fromPosition: Position!
"Position the transfer is to"
toPosition: Position!
"Asset being transferred"
asset: CollateralToken!
"Amount being transferred"
amount: BigInt!
"Amount being transferred in USD"
amountUsd: BigDecimal!
}
type AbsorbCollateralInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Position the interaction is with"
position: Position!
"Address that triggered the collateral absorb"
absorber: Bytes!
"Collateral asset being absorbed"
asset: CollateralToken!
"Amount of collateral absorbed"
amount: BigInt!
"Amount of collateral absorbed in USD"
amountUsd: BigDecimal!
}
type BuyCollateralInteraction @entity(immutable: true) {
"Transaction ID + event log index"
id: Bytes!
"Transaction this interaction is part of"
transaction: Transaction!
"Market the interaction is with"
market: Market!
"Buyer of the collateral"
buyer: Bytes!
"Asset being bought"
asset: CollateralToken!
"Collateral amount bought"
collateralAmount: BigInt!
"Base asset amount being given in exchange"
baseAmount: BigInt!
"Collateral amount bought in USD"
collateralAmountUsd: BigDecimal!
"Base asset amount being given in exchange in USD"
baseAmountUsd: BigDecimal!
}
type WithdrawReservesInteraction @entity(immutable: true) {
"Transaction ID + event log index"