-
Notifications
You must be signed in to change notification settings - Fork 241
/
schema-lending.graphql
2038 lines (1407 loc) · 61.3 KB
/
schema-lending.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
# Subgraph Schema: Lending Protocol
# Version: 3.1.0
# See https://github.com/messari/subgraphs/blob/master/docs/SCHEMA.md for details
enum Network {
ARBITRUM_ONE
ARWEAVE_MAINNET
AURORA
AVALANCHE
BOBA
BSC # aka BNB Chain
CELO
COSMOS
CRONOS
MAINNET # Ethereum Mainnet
FANTOM
FUSE
HARMONY
JUNO
MOONBEAM
MOONRIVER
NEAR_MAINNET
OPTIMISM
OSMOSIS
MATIC # aka Polygon
GNOSIS
BASE
}
enum ProtocolType {
EXCHANGE
LENDING
YIELD
BRIDGE
GENERIC
# Will add more
}
type Token @entity @regularPolling {
" Smart contract address of the token "
id: Bytes!
" Name of the token, mirrored from the smart contract "
name: String!
" Symbol of the token, mirrored from the smart contract "
symbol: String!
" The number of decimal places this token uses, default to 18 "
decimals: Int!
" Optional field to track the price of a token, mostly for caching purposes "
lastPriceUSD: BigDecimal
" Optional field to track the block number of the last token price "
lastPriceBlockNumber: BigInt
" The type of token the protocol creates for positions "
type: TokenType
}
enum RewardTokenType {
" For reward tokens awarded to LPs/lenders "
DEPOSIT
" For reward tokens awarded to borrowers of variable debt "
VARIABLE_BORROW
" For reward tokens awarded to borrowers of stable debt "
STABLE_BORROW
" For reward tokens awarded to stakers "
STAKE
}
type RewardToken @entity(immutable: true) @regularPolling {
" { Reward token type }-{ Smart contract address of the reward token } "
id: ID!
" Reference to the actual token "
token: Token!
" The type of the reward token "
type: RewardTokenType!
}
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 PermissionType {
" Only users that have been whitelisted can interact. e.g. Only approved institutions can borrow "
WHITELIST_ONLY
" To interact a user must be KYC'd "
PERMISSIONED
" Protocols that do not KYC. Can be used by any account "
PERMISSIONLESS
" Only the protocol admin address can make do the defined actions "
ADMIN
}
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 CollateralizationType {
" Over collateralized protocols require users to put up more collateral than the amount borrowed. "
OVER_COLLATERALIZED
" Protocols that allow users to borrow more than their collateral locked. "
UNDER_COLLATERALIZED
" Protocols that allow users to borrow without any collateral. Generally this protocol is KYC'd and only whitelist users can do this "
UNCOLLATERALIZED
}
# This is used for representative token descriptions
# e.g. collateral or debt tokens in a protocol
enum TokenType {
" Rebasing tokens continuously adjust balances / supply as interest is accrued (e.g. Aave debt balances adjust at each block with interest) "
REBASING
" Non-rebasing token balances / supply do not change as interest is accrued (e.g. Compound's cToken's do not adjust balance, the exchange rate changes with interest) "
NON_REBASING
}
enum InterestRateType {
" Stable interest rate (e.g. Aave) "
STABLE
" Variable interest rate (e.g. Compound) "
VARIABLE
" Fixed interest rate (e.g. Notional) "
FIXED
}
enum InterestRateSide {
" Interest rate accrued by lenders "
LENDER
" Interest rate paid by borrowers "
BORROWER
}
enum Tranche {
" Senior denotes debt with a higher priority. The first debt to be paid back to lenders. "
SENIOR
" Junior tranche denotes lower priority debt. This is secondary priority to be paid back to lenders. "
JUNIOR
}
enum PositionSide {
" Position opened as a lender (used as collateral) "
COLLATERAL
" Position opened as a borrower "
BORROWER
}
# Most markets only have a single interest rate given a specific type.
# However, fixed term lending protocols can have multiple rates with
# different duration/maturity per market. You can append a counter
# to the IDs to differentiate.
type InterestRate @entity @regularPolling {
" { Interest rate side }-{ Interest rate type }-{ Market ID }-{ Optional: Tranche }-{ Optional: # days/hours since epoch time } "
id: ID!
" Interest rate in percentage APY. E.g. 5.21% should be stored as 5.21 "
rate: BigDecimal!
" Duration of the loan in days. Only applies to fixed term lending (e.g. Notional) "
duration: Int
" Maturity of the loan in block height. Only applies to fixed term lending (e.g. Notional) "
maturityBlock: BigInt
" The party the interest is paid to / received from "
side: InterestRateSide!
" The type of interest rate (e.g. stable, fixed, variable, etc) "
type: InterestRateType!
" The level of debt priority at this interest rate "
tranche: Tranche
}
enum FeeType {
" Fees from liquidations "
LIQUIDATION_FEE
" Fees given to an admin "
ADMIN_FEE
" Fees that are taken by the protocol "
PROTOCOL_FEE
" Fee to mint an asset. Found mostly in CDPs "
MINT_FEE
" Fee taken on withdrawal. e.g. found in Euler "
WITHDRAW_FEE
" Flashloan Fees taken by the protocol "
FLASHLOAN_PROTOCOL_FEE
" Flashloan Fees taken by LP "
FLASHLOAN_LP_FEE
" Any fee not represented here. Please make a github issue for this to be added: https://github.com/messari/subgraphs/issues/new "
OTHER
}
type Fee @entity @regularPolling {
" { Fee type } "
id: ID!
" Fee in percentage. E.g. 5.21% should be stored as 5.21 "
rate: BigDecimal
" A flat fee in the native token. This may be a base fee in addition to the rate, or the only fee. "
flatFee: BigDecimal
" The type of fee (e.g. liquidation, admin, etc.) "
type: FeeType!
}
# This entity offers a more nuanced view of revenue types
# Use this to provide the sources of revenue and amounts of each
type RevenueDetail @entity @regularPolling {
" { Market/Protocol ID }{ Optional: Snapshot ID } "
id: Bytes!
" The source of revenue (in alphabetical order) "
sources: [Fee!]!
" The amount of revenue in USD (same order as sources) "
amountsUSD: [BigDecimal!]!
}
enum OracleSource {
UNISWAP
BALANCER
CHAINLINK
YEARN
SUSHISWAP
CURVE
## Can add more
}
# Most lending protocols get token prices through onchain oracles.
# As oracles are a source of truth it is important to understand the details.
# This entity will help track oracle-related data in a market
type Oracle @entity @regularPolling {
" { Market Address }{ Token Address } "
id: Bytes!
oracleAddress: Bytes!
" The market that this oracle is used for pricing "
market: Market!
" The block this oracle was adopted for a market "
blockCreated: BigInt!
" The timestamp this oracle was adopted for a market "
timestampCreated: BigInt!
" Is the Oracle currently used as the source of truth for a market"
isActive: Boolean!
" True if the oracle returns prices in USD (e.g. generally the other case is the network's native token) "
isUSD: Boolean!
" The hash where the oracle was no longer used "
hashEnded: Bytes
" The Protocol that is providing the oracle (nullable if non-standard source)"
oracleSource: OracleSource
}
#############################
##### Protocol Metadata #####
#############################
interface Protocol {
" Smart contract address of the protocol's main contract (Factory, Registry, etc) "
id: Bytes!
" Base name of the protocol, excluding transformations. e.g. Aave "
protocol: String!
" Name of the protocol, including version. e.g. Aave v2 "
name: String!
" Slug of protocol, including version. e.g. aave-v2 "
slug: String!
" Version of the subgraph schema, in SemVer format (e.g. 1.0.0) "
schemaVersion: String!
" Version of the subgraph implementation, in SemVer format (e.g. 1.0.0) "
subgraphVersion: String!
" Version of the methodology used to compute metrics, loosely based on SemVer format (e.g. 1.0.0) "
methodologyVersion: String!
" The blockchain network this subgraph is indexing on "
network: Network!
" The type of protocol (e.g. DEX, Lending, Yield, etc) "
type: ProtocolType!
" The specific lending protocol type "
lendingType: LendingType
" The specific permissions required to lend in this protocol "
lenderPermissionType: PermissionType
" The specific permissions required to borrow from this protocol "
borrowerPermissionType: PermissionType
" The specific permissions required to create a pool (market) in this protocol "
poolCreatorPermissionType: PermissionType
" Risk type of the lending protocol "
riskType: RiskType
" The way a positions can be collateralized "
collateralizationType: CollateralizationType
##### Quantitative Data #####
" Current TVL (Total Value Locked) of the entire protocol "
totalValueLockedUSD: BigDecimal!
" Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV. "
protocolControlledValueUSD: BigDecimal
" Number of cumulative unique users. e.g. accounts that spent gas to interact with this protocol "
cumulativeUniqueUsers: Int!
" Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. "
cumulativeSupplySideRevenueUSD: BigDecimal!
" Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. "
cumulativeProtocolSideRevenueUSD: BigDecimal!
" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
cumulativeTotalRevenueUSD: BigDecimal!
" Total number of pools "
totalPoolCount: Int!
##### Snapshots #####
" Daily usage metrics for this protocol "
dailyUsageMetrics: [UsageMetricsDailySnapshot!]!
@derivedFrom(field: "protocol")
" Hourly usage metrics for this protocol "
hourlyUsageMetrics: [UsageMetricsHourlySnapshot!]!
@derivedFrom(field: "protocol")
" Daily financial metrics for this protocol "
financialMetrics: [FinancialsDailySnapshot!]! @derivedFrom(field: "protocol")
}
type LendingProtocol implements Protocol @entity @regularPolling {
" Smart contract address of the protocol's main contract (Factory, Registry, etc) "
id: Bytes!
" Base name of the protocol, excluding transformations. e.g. Aave "
protocol: String!
" Name of the protocol, including version. e.g. Aave v2 "
name: String!
" Slug of protocol, including version. e.g. aave-v2 "
slug: String!
" Version of the subgraph schema, in SemVer format (e.g. 1.0.0) "
schemaVersion: String!
" Version of the subgraph implementation, in SemVer format (e.g. 1.0.0) "
subgraphVersion: String!
" Version of the methodology used to compute metrics, loosely based on SemVer format (e.g. 1.0.0) "
methodologyVersion: String!
" The blockchain network this subgraph is indexing on "
network: Network!
" The type of protocol (e.g. DEX, Lending, Yield, etc) "
type: ProtocolType!
" The specific lending protocol type "
lendingType: LendingType
" The specific permissions required to lend in this protocol "
lenderPermissionType: PermissionType
" The specific permissions required to borrow from this protocol "
borrowerPermissionType: PermissionType
" The specific permissions required to create a pool (market) in this protocol "
poolCreatorPermissionType: PermissionType
" Risk type of the lending protocol "
riskType: RiskType
" The way a positions can be collateralized "
collateralizationType: CollateralizationType
" Tokens that can be minted. Only applies to CDP (usually stable coins) "
mintedTokens: [Token!]
" Additional tokens that are given as reward for position in a protocol, usually in liquidity mining programs. "
rewardTokens: [RewardToken!]
##### Quantitative Data #####
" Number of cumulative unique users. e.g. accounts that spent gas to interact with this protocol "
cumulativeUniqueUsers: Int!
" Number of cumulative depositors "
cumulativeUniqueDepositors: Int!
" Number of cumulative borrowers "
cumulativeUniqueBorrowers: Int!
" Number of cumulative liquidators (accounts that performed liquidation) "
cumulativeUniqueLiquidators: Int!
" Number of cumulative liquidatees (accounts that got liquidated) "
cumulativeUniqueLiquidatees: Int!
" Current TVL (Total Value Locked) of the entire protocol "
totalValueLockedUSD: BigDecimal!
" Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV. "
protocolControlledValueUSD: BigDecimal
" Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. "
cumulativeSupplySideRevenueUSD: BigDecimal!
" Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. "
cumulativeProtocolSideRevenueUSD: BigDecimal!
" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
cumulativeTotalRevenueUSD: BigDecimal!
" All fees in the protocol. Fee should be in percentage format. e.g. 0.30% liquidation fee "
fees: [Fee!]
" Details of revenue sources and amounts "
revenueDetail: RevenueDetail
" Current balance of all deposited assets, in USD. Note this metric should be the same as TVL. "
totalDepositBalanceUSD: BigDecimal!
" Sum of all historical deposits in USD (only considers deposits and not withdrawals) "
cumulativeDepositUSD: BigDecimal!
" Current balance of all borrowed/minted assets (not historical cumulative), in USD. "
totalBorrowBalanceUSD: BigDecimal!
" Sum of all historical borrows/mints in USD (i.e. total loan origination). "
cumulativeBorrowUSD: BigDecimal!
" Sum of all historical liquidations in USD "
cumulativeLiquidateUSD: BigDecimal!
" Total supply of minted tokens in native amounts, with same ordering as mintedTokens. Only applies to CDP "
mintedTokenSupplies: [BigInt!]
" Total number of pools "
totalPoolCount: Int!
" Total number of open positions "
openPositionCount: Int!
" Total number of positions (open and closed) "
cumulativePositionCount: Int!
" Total number of transactions "
transactionCount: Int!
" Total number of deposits "
depositCount: Int!
" Total number of withdrawals "
withdrawCount: Int!
" Total number of borrows "
borrowCount: Int!
" Total number of repayments "
repayCount: Int!
" Total number of liquidations "
liquidationCount: Int!
" Total number of transfers "
transferCount: Int!
" Total number of flashloans "
flashloanCount: Int!
##### Token Balances #####
" Per-block reward token emission as of the current block normalized to a day, in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsAmount: [BigInt!]
" Per-block reward token emission as of the current block normalized to a day, in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsUSD: [BigDecimal!]
##### Snapshots #####
" Daily usage metrics for this protocol "
dailyUsageMetrics: [UsageMetricsDailySnapshot!]!
@derivedFrom(field: "protocol")
" Hourly usage metrics for this protocol "
hourlyUsageMetrics: [UsageMetricsHourlySnapshot!]!
@derivedFrom(field: "protocol")
" Daily financial metrics for this protocol "
financialMetrics: [FinancialsDailySnapshot!]! @derivedFrom(field: "protocol")
##### Markets #####
" All markets that belong to this protocol "
markets: [Market!]! @derivedFrom(field: "protocol")
}
# helper entity to iterate through all markets
type _MarketList @entity {
" Same ID as LendingProtocol "
id: Bytes!
" IDs of all markets in the LendingProtocol "
markets: [Bytes!]!
}
###############################
##### Protocol Timeseries #####
###############################
type UsageMetricsDailySnapshot @entity @dailySnapshot {
" ID is # of days since Unix epoch time "
id: Bytes!
" Number of days since Unix epoch time "
days: Int!
" Protocol this snapshot is associated with "
protocol: LendingProtocol!
" Number of unique daily active users. e.g. accounts that spent gas to interact with this protocol "
dailyActiveUsers: Int!
" Number of cumulative unique users. e.g. accounts that spent gas to interact with this protocol "
cumulativeUniqueUsers: Int!
" Number of unique daily depositors "
dailyActiveDepositors: Int!
" Number of cumulative depositors "
cumulativeUniqueDepositors: Int!
" Number of unique daily borrowers "
dailyActiveBorrowers: Int!
" Number of cumulative borrowers "
cumulativeUniqueBorrowers: Int!
" Number of unique daily liquidators (accounts that performed liquidation) "
dailyActiveLiquidators: Int!
" Number of cumulative liquidators (accounts that performed liquidation) "
cumulativeUniqueLiquidators: Int!
" Number of unique daily liquidatees (accounts that got liquidated) "
dailyActiveLiquidatees: Int!
" Number of cumulative liquidatees (accounts that got liquidated) "
cumulativeUniqueLiquidatees: Int!
" Total number of transactions occurred in a day. Transactions include all entities that implement the Event interface. "
dailyTransactionCount: Int!
" Total number of deposits in a day "
dailyDepositCount: Int!
" Total number of withdrawals in a day "
dailyWithdrawCount: Int!
" Total number of borrows/mints in a day "
dailyBorrowCount: Int!
" Total number of repayments/burns in a day "
dailyRepayCount: Int!
" Total number of liquidations in a day "
dailyLiquidateCount: Int!
" Total number of transfers in a day "
dailyTransferCount: Int!
" Total number of flashloans in a day "
dailyFlashloanCount: Int!
" Total number of positions (open and closed) "
cumulativePositionCount: Int!
" Total number of open positions "
openPositionCount: Int!
" Total number of positions touched in a day. This includes opening, closing, and modifying positions. "
dailyActivePositions: Int!
" Total number of pools "
totalPoolCount: Int!
" Block number of this snapshot "
blockNumber: BigInt!
" Timestamp of this snapshot "
timestamp: BigInt!
}
type UsageMetricsHourlySnapshot @entity @hourlySnapshot {
" { # of hours since Unix epoch time } "
id: Bytes!
" Number of hours since Unix epoch time "
hours: Int!
" Protocol this snapshot is associated with "
protocol: LendingProtocol!
" Number of unique hourly active users "
hourlyActiveUsers: Int!
" Number of cumulative unique users. e.g. accounts that spent gas to interact with this protocol "
cumulativeUniqueUsers: Int!
" Total number of transactions occurred in an hour. Transactions include all entities that implement the Event interface. "
hourlyTransactionCount: Int!
" Total number of deposits in an hour "
hourlyDepositCount: Int!
" Total number of withdrawals in an hour "
hourlyWithdrawCount: Int!
" Total number of borrows/mints in an hour "
hourlyBorrowCount: Int!
" Total number of repayments/burns in an hour "
hourlyRepayCount: Int!
" Total number of liquidations in an hour "
hourlyLiquidateCount: Int!
" Block number of this snapshot "
blockNumber: BigInt!
" Timestamp of this snapshot "
timestamp: BigInt!
}
type FinancialsDailySnapshot @entity @dailySnapshot {
" ID is # of days since Unix epoch time "
id: Bytes!
" Number of days since Unix epoch time "
days: Int!
" Protocol this snapshot is associated with "
protocol: LendingProtocol!
" Block number of this snapshot "
blockNumber: BigInt!
" Timestamp of this snapshot "
timestamp: BigInt!
" Current TVL (Total Value Locked) of the entire protocol "
totalValueLockedUSD: BigDecimal!
" Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV. "
protocolControlledValueUSD: BigDecimal
" Total supply of minted tokens in native amounts, with same ordering as mintedTokens. Only applies to CDP "
mintedTokenSupplies: [BigInt!]
##### Revenue #####
" Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. "
dailySupplySideRevenueUSD: BigDecimal!
" Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. "
cumulativeSupplySideRevenueUSD: BigDecimal!
" Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. "
dailyProtocolSideRevenueUSD: BigDecimal!
" Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. "
cumulativeProtocolSideRevenueUSD: BigDecimal!
" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
dailyTotalRevenueUSD: BigDecimal!
" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
cumulativeTotalRevenueUSD: BigDecimal!
" Details of revenue sources and amounts "
revenueDetail: RevenueDetail
##### Lending Activities #####
" Current balance of all deposited assets, in USD. Note this metric should be the same as TVL. "
totalDepositBalanceUSD: BigDecimal!
" Total assets deposited on a given day, in USD "
dailyDepositUSD: BigDecimal!
" Sum of all historical deposits in USD (only considers deposits and not withdrawals) "
cumulativeDepositUSD: BigDecimal!
" Current balance of all borrowed/minted assets, in USD. "
totalBorrowBalanceUSD: BigDecimal!
" Total assets borrowed/minted on a given day, in USD. "
dailyBorrowUSD: BigDecimal!
" Sum of all historical borrows/mints in USD (i.e. total loan origination). "
cumulativeBorrowUSD: BigDecimal!
" Total assets liquidated on a given day, in USD. "
dailyLiquidateUSD: BigDecimal!
" Sum of all historical liquidations in USD "
cumulativeLiquidateUSD: BigDecimal!
" Total assets withdrawn on a given day, in USD. "
dailyWithdrawUSD: BigDecimal!
" Total assets repaid on a given day, in USD. "
dailyRepayUSD: BigDecimal!
" Total assets transferred on a given day, in USD. "
dailyTransferUSD: BigDecimal!
" Total flashloans executed on a given day, in USD. "
dailyFlashloanUSD: BigDecimal!
}
###############################
##### Pool-Level Metadata #####
###############################
"""
A market is defined by the input token.
At a minimum that means being able to deposit/withdraw that token.
e.g. there may be related markets as they only act as collateral for other markets.
"""
type Market @entity @regularPolling {
" Smart contract address of the market "
id: Bytes!
" The protocol this pool belongs to "
protocol: LendingProtocol!
" Name of market "
name: String
" Is this market active or is it frozen "
isActive: Boolean!
" Can you borrow from this market "
canBorrowFrom: Boolean!
" Can you use the output token as collateral "
canUseAsCollateral: Boolean!
" Maximum loan-to-value ratio as a percentage value (e.g. 75% for DAI in Aave) "
maximumLTV: BigDecimal!
" Liquidation threshold as a percentage value (e.g. 80% for DAI in Aave). When it is reached, the position is defined as undercollateralised and could be liquidated "
liquidationThreshold: BigDecimal!
" Liquidation penalty (or the liquidation bonus for liquidators) as a percentage value. It is the penalty/bonus price on the collateral when liquidators purchase it as part of the liquidation of a loan that has passed the liquidation threshold "
liquidationPenalty: BigDecimal!
" Can the user choose to isolate assets in this market. e.g. only this market's collateral can be used for a borrow in Aave V3 "
canIsolate: Boolean!
" Creation timestamp "
createdTimestamp: BigInt!
" Creation block number "
createdBlockNumber: BigInt!
" Details about the price oracle used to get this token's price "
oracle: Oracle
" A unique identifier that can relate multiple markets. e.g. a common address that is the same for each related market. This is useful for markets with multiple input tokens "
relation: Bytes
##### Incentives #####
" Additional tokens that are given as reward for position in a protocol, usually in liquidity mining programs. e.g. SUSHI in the Onsen program, MATIC for Aave Polygon "
rewardTokens: [RewardToken!]
" Per-block reward token emission as of the current block normalized to a day, in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsAmount: [BigInt!]
" Per-block reward token emission as of the current block normalized to a day, in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsUSD: [BigDecimal!]
" Total supply of output tokens that are staked. Used to calculate reward APY. "
stakedOutputTokenAmount: BigInt
##### Quantitative Data #####
" Token that need to be deposited in this market to take a position in protocol (should be alphabetized) "
inputToken: Token!
" Amount of input token in the market (same order as inputTokens) "
inputTokenBalance: BigInt!
" Prices in USD of the input token (same order as inputTokens) "
inputTokenPriceUSD: BigDecimal!
" Tokens that are minted to track ownership of position in protocol (e.g. aToken, cToken). Leave as null if doesn't exist (should be alphabetized) "
outputToken: Token
" Total supply of output token (same order as outputTokens) "
outputTokenSupply: BigInt
" Prices in USD of the output token (same order as outputTokens) "
outputTokenPriceUSD: BigDecimal
" Amount of input token per full share of output token. Only applies when the output token exists (note this is a ratio and not a percentage value, i.e. 1.05 instead of 105%) "
exchangeRate: BigDecimal
" All interest rates for this input token. Should be in APR format "
rates: [InterestRate!]
" Total amount of reserves (in USD) "
reserves: BigDecimal
" The amount of revenue that is converted to reserves at the current time. 20% reserve factor should be in format 0.20 "
reserveFactor: BigDecimal
" The token that can be borrowed (e.g. inputToken in POOLED and generally a stable in CDPs) "
borrowedToken: Token
" Amount of input tokens borrowed in this market using variable interest rates (in native terms) "
variableBorrowedTokenBalance: BigInt
" Amount of input tokens borrowed in this market using stable interest rates (in native terms) "
stableBorrowedTokenBalance: BigInt
" Last updated timestamp of supply/borrow index. "
indexLastUpdatedTimestamp: BigInt
" Index used by the protocol to calculate interest generated on the supply token (ie, liquidityIndex in Aave)"
supplyIndex: BigInt
" Allowed limit to how much of the underlying asset can be supplied to this market. "
supplyCap: BigInt
" Index used by the protocol to calculate the interest paid on the borrowed token (ie, variableBorrowIndex in Aave))"
borrowIndex: BigInt
" Allowed limit for how much of the underlying asset can be borrowed from this market. "
borrowCap: BigInt
" Current TVL (Total Value Locked) of this market "
totalValueLockedUSD: BigDecimal!
" All revenue generated by the market, accrued to the supply side. "
cumulativeSupplySideRevenueUSD: BigDecimal!
" All revenue generated by the market, accrued to the protocol. "
cumulativeProtocolSideRevenueUSD: BigDecimal!
" All revenue generated by the market. "
cumulativeTotalRevenueUSD: BigDecimal!
" Details of revenue sources and amounts "
revenueDetail: RevenueDetail
" Current balance of all deposited assets (not historical cumulative), in USD "
totalDepositBalanceUSD: BigDecimal!
" Sum of all historical deposits in USD (only considers deposits and not withdrawals) "
cumulativeDepositUSD: BigDecimal!
" Current balance of all borrowed/minted assets (not historical cumulative), in USD "
totalBorrowBalanceUSD: BigDecimal!
" Sum of all historical borrows/mints in USD (i.e. total loan origination) "
cumulativeBorrowUSD: BigDecimal!
" Sum of all historical liquidations in USD "
cumulativeLiquidateUSD: BigDecimal!
" Sum of all historical transfers in USD "
cumulativeTransferUSD: BigDecimal!
" Sum of all historical flashloans in USD "
cumulativeFlashloanUSD: BigDecimal!
" Total number of transactions "
transactionCount: Int!
" Total number of deposits "
depositCount: Int!
" Total number of withdrawals "
withdrawCount: Int!
" Total number of borrows "
borrowCount: Int!
" Total number of repayments "
repayCount: Int!
" Total number of liquidations "
liquidationCount: Int!
" Total number of transfers "
transferCount: Int!
" Total number of flashloans "
flashloanCount: Int!
##### Usage Data #####
" Number of cumulative unique users. e.g. accounts that spent gas to interact with this market "
cumulativeUniqueUsers: Int!
" Number of cumulative depositors "
cumulativeUniqueDepositors: Int!
" Number of cumulative borrowers "
cumulativeUniqueBorrowers: Int!
" Number of cumulative liquidators (accounts that performed liquidation) "
cumulativeUniqueLiquidators: Int!
" Number of cumulative liquidatees (accounts that got liquidated) "
cumulativeUniqueLiquidatees: Int!
" Number of cumulative accounts that transferred positions (generally in the form of outputToken transfer) "
cumulativeUniqueTransferrers: Int!
" Number of cumulative accounts that performed flashloans "
cumulativeUniqueFlashloaners: Int!
##### Account/Position Data #####
" All positions in this market "
positions: [Position!]! @derivedFrom(field: "market")
" Number of positions in this market "
positionCount: Int!
" Number of open positions in this market "
openPositionCount: Int!
" Number of closed positions in this market "
closedPositionCount: Int!
" Number of lending positions in this market. Note: this is cumulative and strictly increasing "
lendingPositionCount: Int!
" Number of borrowing positions in this market. Note: this is cumulative and strictly increasing "
borrowingPositionCount: Int!
##### Snapshots #####
" Market daily snapshots "