-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathschema.graphql
881 lines (761 loc) · 33.6 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
################################
##### Common Entities ##########
################################
enum ProductLifecycle {
"The product is in the process of being initialized"
INITIALIZING
"The product is able to accept deposits and earn yield"
RUNNING
"A product can be paused for a variety of reasons, this is always to protect investors funds"
PAUSED
}
"""
A token is a representation of a fungible asset on the blockchain
as specified by the ERC20 standard.
"""
type Token @entity(immutable: true) {
# token address
id: Bytes!
"The token symbol"
symbol: String
"The token name"
name: String
"The number of decimals the token uses"
decimals: BigInt!
}
"""
A transaction is a record of an event that happened on the blockchain.
Transactions are identified by their hash.
"""
type Transaction @entity(immutable: true) {
"The transaction hash"
id: Bytes!
"The block number the transaction was included in"
blockNumber: BigInt!
"The timestamp of the block the transaction was included in"
blockTimestamp: BigInt!
"The address of the sender of the transaction"
sender: Bytes!
}
"""
A clock tick is a record of time passing.
This is used to update the protocol's stats at regular intervals.
"""
type ClockTick @entity(immutable: true) {
"truncated timestamp + tick period"
id: Bytes!
"""
Duration of the snapshot period in seconds.
Available periods:
- 15 minutes: 900
- 1 day: 86400
"""
period: BigInt!
"Timestamp the tick was initiated at, rounded to period"
roundedTimestamp: BigInt!
"Actual timestamp tick was initiated at"
timestamp: BigInt!
}
type Investor @entity {
"The investor address"
id: Bytes!
"All investor beefy positions"
positions: [ClmPosition!]! @derivedFrom(field: "investor")
"All investor interactions"
interactions: [ClmPositionInteraction!]! @derivedFrom(field: "investor")
}
"""
The Protocol entity is the main entity of the Beefy Finance subgraph.
It represents the Beefy Finance protocol.
This is where all stats and data about the protocol is stored.
"""
type Protocol @entity {
"""
The protocol identifier:
- 1: Beefy
- 2: CLM
"""
id: Bytes!
"Protocol name"
name: String!
"All CLM in the protocol"
clms: [CLM!]! @derivedFrom(field: "protocol")
"All Classic in the protocol"
classics: [Classic!]! @derivedFrom(field: "protocol")
}
#################################
##### Beefy Classic Contracts ###
#################################
"""
Beefy classic products are the original vaults and strategies.
Those are building on top of another prodocol like PancakeSwap, SushiSwap, etc.
TODO: find a better name for this entity
"""
type Classic @entity {
"The vault address"
id: Bytes!
"The protocol the vault belongs to"
protocol: Protocol!
"The vault"
vault: ClassicVault!
"The vault strategy"
strategy: ClassicStrategy!
"The vault boosts"
boosts: [ClassicBoost!]! @derivedFrom(field: "classic")
"""
The reward pools of this vault.
"""
rewardPools: [ClassicRewardPool!]! @derivedFrom(field: "classic")
"The current lifecycle status of the vault"
lifecycle: ProductLifecycle!
"The vault's share token"
vaultSharesToken: Token!
"The reward pool tokens of the CLM. This is where the CLM's earnings are sent if the CLM does not automatically compound."
rewardPoolTokens: [Token!]!
"The reward pool token addresses of the CLM. This is the source of truth for other tables reward ordering."
rewardPoolTokensOrder: [Bytes!]!
"The vault's underlying LP token"
underlyingToken: Token!
"The vault underlying token breakdown. If that token is composed of multiple tokens, they are listed here."
underlyingBreakdownTokens: [Token!]!
"The vault underlying token breakdown addresses. This is the source of truth for other tables breakdown ordering."
underlyingBreakdownTokensOrder: [Bytes!]!
"The boost tokens of the vault. Tokens earned by staking in the boost."
boostRewardTokens: [Token!]!
"The boost token addresses of the vault. This is the source of truth for other tables reward ordering."
boostRewardTokensOrder: [Bytes!]!
"The reward tokens of the CLM's rewardpool. These will be rewarded to positions when the CLM earns non-compounding yield."
rewardTokens: [Token!]!
"The reward token addresses of the CLM. This is the source of truth for other tables reward ordering."
rewardTokensOrder: [Bytes!]!
# ----- PRICES & STATS -----
"The total supply of the vault shares token in circulation. Express with `sharesToken.decimals` decimals."
vaultSharesTotalSupply: BigInt!
"Latest total supply of the underlying token in the vault. Expressed with `underlyingToken.decimals` decimals."
vaultUnderlyingTotalSupply: BigInt!
"Latest total supply of the underlying tokens in the vault. Ordered by classic.underlyingBreakdownTokensOrder. Expressed with `underlyingBreakdownTokens[idx].decimals` decimals."
vaultUnderlyingBreakdownBalances: [BigInt!]!
"Total supply of the reward pool token. Express with `clm.rewardTokensOrder[idx].decimals` decimals."
rewardPoolsTotalSupply: [BigInt!]!
"Latest LP token price in native we have seen. Expressed with 18 decimals."
underlyingToNativePrice: BigInt!
"Latest underlying token prices in native we have seen. Ordered by classic.underlyingBreakdownTokensOrder. Expressed with 18 decimals."
underlyingBreakdownToNativePrices: [BigInt!]!
"Latest boost token prices in native we have seen. Ordered by classic.boostRewardTokensOrder. Expressed with 18 decimals."
boostRewardToNativePrices: [BigInt!]!
"Latest reward token prices in native we have seen. Ordered by classic.rewardTokensOrder. Expressed with 18 decimals."
rewardToNativePrices: [BigInt!]!
"Latest native token price we have seen. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
"Amount of underlying token in the vault"
underlyingAmount: BigInt!
"All positions in the Classic"
positions: [ClassicPosition!]! @derivedFrom(field: "classic")
"All harvest events of the Classic"
harvests: [ClassicHarvestEvent!]! @derivedFrom(field: "classic")
"Snapshot of the Classic's stats"
snapshots: [ClassicSnapshot!]! @derivedFrom(field: "classic")
"All Classic interactions for this Classic"
interactions: [ClassicPositionInteraction!]! @derivedFrom(field: "classic")
}
"""
A snapshot of the Classic's stats.
Any event that happens in the Classic is recorded in a snapshot.
We keep multiple snapshots time frames as noted by the "period" field.
Snapshots include: daily, weekly, yearly.
"""
type ClassicSnapshot @entity {
"Classic.id + period + timestamp"
id: Bytes!
"The Classic the snapshot is for"
classic: Classic!
"""
Duration of the snapshot period in seconds.
Available periods:
- 1 day: 86400
- 1 week: 604800
- 1 year: 31536000
"""
period: BigInt!
"Timestamp the snapshot was initiated at, rounded to period"
roundedTimestamp: BigInt!
"Actual timestamp snapshot was initiated at"
timestamp: BigInt!
"The total supply of the vault shares token in circulation. Express with `sharesToken.decimals` decimals."
vaultSharesTotalSupply: BigInt!
"Latest total supply of the underlying token in the vault. Expressed with `underlyingToken.decimals` decimals."
vaultUnderlyingTotalSupply: BigInt!
"Latest total supply of the underlying tokens in the vault. Ordered by classic.underlyingBreakdownTokensOrder. Expressed with `underlyingBreakdownTokens[idx].decimals` decimals."
vaultUnderlyingBreakdownBalances: [BigInt!]!
"Total supply of the reward pool token. Ordered by clm.rewardTokensOrder. Express with `clm.rewardTokensOrder[idx].decimals` decimals."
rewardPoolsTotalSupply: [BigInt!]!
"Latest LP token price in native of this snapshot. Expressed with 18 decimals."
underlyingToNativePrice: BigInt!
"Latest underlying token prices in native of this snapshot. Ordered by classic.underlyingBreakdownTokensOrder. Expressed with 18 decimals."
underlyingBreakdownToNativePrices: [BigInt!]!
"Latest boost token prices in native of this snapshot. Ordered by classic.boostRewardTokensOrder. Expressed with 18 decimals."
boostRewardToNativePrices: [BigInt!]!
"Latest reward token prices in native of this snapshot. Ordered by classic.rewardTokensOrder. Expressed with 18 decimals."
rewardToNativePrices: [BigInt!]!
"Latest native token price of this snapshot. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
"Amount of underlying tokens in the vault"
underlyingAmount: BigInt!
}
"""
A vault is a contract that manages the assets of a Beefy product.
This entity is mostly used to start tracking the events and link them to the Beefy product on new event
"""
type ClassicVault @entity {
"The strategy address"
id: Bytes!
"The classic product the vault belongs to"
classic: Classic!
"The transaction that created the strategy"
createdWith: Transaction!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
A strategy is a contract that manages the assets of a Beefy product.
This entity is mostly used to start tracking the events and link them to the Beefy product on new event
"""
type ClassicStrategy @entity {
"The strategy address"
id: Bytes!
"The classic product the strategy belongs to"
classic: Classic!
"The vault the strategy is managing"
vault: ClassicVault!
"The transaction that created the strategy"
createdWith: Transaction!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
A boost is a contract that manages the assets of a Beefy product.
This entity is mostly used to start tracking the events and link them to the Beefy product on new event
"""
type ClassicBoost @entity {
"The boost address"
id: Bytes!
"The classic product the strategy belongs to"
classic: Classic!
"The vault the boost is managing"
vault: ClassicVault!
"The transaction that created the strategy"
createdWith: Transaction!
"The boost reward token"
rewardToken: Token!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
Some Classic do not automatically compound their earnings. Those earnings are sent to the reward pool instead.
This entity is mostly used to start tracking the events and link them to the Classic on new event
"""
type ClassicRewardPool @entity {
"The strategy address"
id: Bytes!
"The classic product the reward pool is for"
classic: Classic!
"The vault the reward pool is linked to"
vault: ClassicVault!
"The transaction that created the reward pool"
createdWith: Transaction!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
Classic products are harvested by the strategy. This event is emitted when the strategy harvests the vault.
"""
type ClassicHarvestEvent @entity(immutable: true) {
"transaction hash + log index"
id: Bytes!
"The Classic the harvest event is for"
classic: Classic!
"The strategy that harvested the vault"
strategy: ClassicStrategy!
"The transaction that created the harvest event"
createdWith: Transaction!
"The event log index in the transaction that created the harvest event."
logIndex: BigInt!
"The timestamp of the harvest event so you can sort by time"
timestamp: BigInt!
"Underlying balance after the harvest"
underlyingAmount: BigInt!
"The amount of underlying tokens compounded"
compoundedAmount: BigInt!
"Total amount of liquidity in the vault at time of harvest"
vaultSharesTotalSupply: BigInt!
"Total amount of reward pool shares at time of harvest. Ordered by classic.rewardPoolTokensOrder."
rewardPoolsTotalSupply: [BigInt!]!
"LP token price in native at the time of harvest. Expressed with 18 decimals."
underlyingToNativePrice: BigInt!
"Boost token prices in native at the time of harvest. Ordered by classic.boostRewardTokensOrder. Expressed with 18 decimals."
boostRewardToNativePrices: [BigInt!]!
"Reward token prices in native at the time of harvest. Ordered by classic.rewardTokensOrder. Expressed with 18 decimals."
rewardToNativePrices: [BigInt!]!
"Native token price at the time of harvest. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}
"""
This event is emitted when we collect earned trading fees from the underlying pool.
"""
type ClassicPosition @entity {
"Classic.id + investor address"
id: Bytes!
"The Classic the investor has a position in"
classic: Classic!
"The investor that has a position in the Classic"
investor: Investor!
"The transaction that created the investor position"
createdWith: Transaction!
"The amount of vault shares the investor holds directly"
vaultBalance: BigInt!
"The amount of vault shares the investor holds in a boost"
boostBalance: BigInt!
"Amount of reward pool shares the investor holds. Ordered by clm.rewardPoolTokensOrder."
rewardPoolBalances: [BigInt!]!
"Total amount of vault shares the investor holds. Should always equal vaultBalance + boostBalance. This is mostly used for filtering."
totalBalance: BigInt!
"All investor position interactions"
interactions: [ClassicPositionInteraction!]! @derivedFrom(field: "investorPosition")
}
enum ClassicPositionInteractionType {
"The investor deposited funds into the vault"
VAULT_DEPOSIT
"The investor withdrew funds from the vault"
VAULT_WITHDRAW
"The investor staked in the boost of the vault and received boost shares"
BOOST_STAKE
"The investor unstaked from the boost of the vault and received vault shares"
BOOST_UNSTAKE
"The investor claimed their rewards from the vault"
BOOST_REWARD_CLAIM
"The investor staked in the reward pool of the CLM and received reward pool shares"
CLASSIC_REWARD_POOL_STAKE
"The investor unstaked from the reward pool of the CLM and received underlying tokens"
CLASSIC_REWARD_POOL_UNSTAKE
"The investor claimed their rewards from the reward pool of the CLM"
CLASSIC_REWARD_POOL_CLAIM
}
type ClassicPositionInteraction @entity(immutable: true) {
"transaction hash + event log index"
id: Bytes!
"The Classic the investor has a position in"
classic: Classic!
"The investor that has a position in the Classic"
investor: Investor!
"The investor position the interaction is for"
investorPosition: ClassicPosition!
"The transaction that created the investor position interaction"
createdWith: Transaction!
"Block number of the interaction"
blockNumber: BigInt!
"The timestamp of the interaction"
timestamp: BigInt!
"The type of the interaction"
type: ClassicPositionInteractionType!
"The amount of vault shares the investor holds directly at the time of the interaction"
vaultBalance: BigInt!
"The amount of vault shares the investor holds in a boost at the time of the interaction"
boostBalance: BigInt!
"The amount of reward pool shares the investor holds at the time of the interaction. Ordered by clm.rewardPoolTokensOrder."
rewardPoolBalances: [BigInt!]!
"Total amount of vault shares the investor holds. Should always equal vaultBalance + boostBalance. This is mostly used for filtering."
totalBalance: BigInt!
"The vault total supply of shares at the time of the interaction"
vaultSharesTotalSupply: BigInt!
"The underlying token total supply at the time of the interaction"
vaultUnderlyingTotalSupply: BigInt!
"The underlying breakdown token balances at the time of the interaction. Ordered by classic.underlyingBreakdownTokensOrder."
vaultUnderlyingBreakdownBalances: [BigInt!]!
"The amount of underlying the vault contains at the time of the interaction"
vaultUnderlyingAmount: BigInt!
"Amount of vault shares change in the interaction"
vaultBalanceDelta: BigInt!
"Amount of vault shares token change on the boost contract in the interaction"
boostBalanceDelta: BigInt!
"Amount of boost tokens change in the interaction. Ordered by classic.boostRewardTokensOrder."
boostRewardBalancesDelta: [BigInt!]!
"Amount of reward pool shares change in the interaction. Ordered by clm.rewardPoolTokensOrder."
rewardPoolBalancesDelta: [BigInt!]!
"Amount of reward tokens change in the interaction. Ordered by clm.rewardTokensOrder."
rewardBalancesDelta: [BigInt!]!
"LP token price in native at the time of the interaction. Expressed with 18 decimals."
underlyingToNativePrice: BigInt!
"Breakdown token prices in native at the time of the interaction. Expressed with 18 decimals. Ordered by clm.underlyingBreakdownTokensOrder."
underlyingBreakdownToNativePrices: [BigInt!]!
"Boost token prices in native at the time of the interaction. Ordered by classic.boostRewardTokensOrder. Expressed with 18 decimals."
boostRewardToNativePrices: [BigInt!]!
"Reward token prices in native at the time of the interaction. Expressed with 18 decimals. Ordered by clm.rewardTokensOrder."
rewardToNativePrices: [BigInt!]!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}
#######################
##### CLM Contracts ###
#######################
type CLM @entity {
"The CL Manager address"
id: Bytes!
"The protocol the CLM belongs to"
protocol: Protocol!
"The manager of the CLM. The manager is responsible for accounting of a CLM."
manager: ClmManager!
"The strategy of the CLM. The strategy is responsible for managing the CLM's assets."
strategy: ClmStrategy!
"""
The reward pool of the CLM.
The reward pool is where the CLM's earnings are sent if the ClmManager does not automatically compound.
It only makes sense to have one reward pool per CLM, but it is possible to have multiple by design.
"""
rewardPools: [ClmRewardPool!]! @derivedFrom(field: "clm")
"The current lifecycle status of the CLM"
lifecycle: ProductLifecycle!
"The manager token data of the CLM. The ClmManager is also an ERC20 token. This tokens represents the shares of the manager."
managerToken: Token!
"The reward pool tokens of the CLM. This is where the CLM's earnings are sent if the CLM does not automatically compound."
rewardPoolTokens: [Token!]!
"The reward pool token addresses of the CLM. This is the source of truth for other tables reward ordering."
rewardPoolTokensOrder: [Bytes!]!
"The underlying tokens contained in the CLM. This is the first token."
underlyingToken0: Token!
"The underlying tokens contained in the CLM. This is the second token."
underlyingToken1: Token!
"The output tokens of the CLM's strategy. These will be sent to the reward pool if the strategy does not automatically compound."
outputTokens: [Token!]!
"The output token addresses of the CLM. This is the source of truth for other tables output ordering."
outputTokensOrder: [Bytes!]!
"The reward tokens of the CLM's rewardpool. These will be rewarded to positions when the CLM earns non-compounding yield."
rewardTokens: [Token!]!
"The reward token addresses of the CLM. This is the source of truth for other tables reward ordering."
rewardTokensOrder: [Bytes!]!
# ----- PRICES & STATS -----
"The total supply of the CLM shares token in circulation. Express with `managerToken.decimals` decimals."
managerTotalSupply: BigInt!
"Total supply of the reward pool token. Express with `clm.rewardTokensOrder[idx].decimals` decimals."
rewardPoolsTotalSupply: [BigInt!]!
"Latest token 0 price in native we have seen. Expressed with 18 decimals."
token0ToNativePrice: BigInt!
"Latest token 1 price in native we have seen. Expressed with 18 decimals."
token1ToNativePrice: BigInt!
"Latest output token prices in native we have seen. Ordered by clm.outputTokensOrder. Expressed with 18 decimals."
outputToNativePrices: [BigInt!]!
"Latest reward token prices in native we have seen. Ordered by clm.rewardTokensOrder. Expressed with 18 decimals."
rewardToNativePrices: [BigInt!]!
"Latest native token price we have seen. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
"""
The current price of the token zero expressed as a token1 value.
For example, if the CLM is a BTC/ETH CLM, this is the price of 1 BTC in ETH.
This is expressed in token1 decimals.
"""
priceOfToken0InToken1: BigInt!
"Price range start this CLM is currently configured to operate in, in token 1"
priceRangeMin1: BigInt!
"Price range end this CLM is currently configured to operate in, in token 1"
priceRangeMax1: BigInt!
"Total amount of token0 in the CLM. Can be slightly higher than main + alt amounts due to vested tokens."
totalUnderlyingAmount0: BigInt!
"Total amount of token1 in the CLM. Can be slightly higher than main + alt amounts due to vested tokens."
totalUnderlyingAmount1: BigInt!
"Amount of underlying tokens in the CLM assigned to the main position in the first token."
underlyingMainAmount0: BigInt!
"Amount of underlying tokens in the CLM assigned to the main position in the second token."
underlyingMainAmount1: BigInt!
"Amount of underlying tokens in the CLM assigned to the alt position in the first token."
underlyingAltAmount0: BigInt!
"Amount of underlying tokens in the CLM assigned to the alt position in the second token."
underlyingAltAmount1: BigInt!
"All positions in the CLM"
positions: [ClmPosition!]! @derivedFrom(field: "clm")
"All collections events by the CLM"
collections: [ClmManagerCollectionEvent!]! @derivedFrom(field: "clm")
"All harvest events of the CLM"
harvests: [ClmHarvestEvent!]! @derivedFrom(field: "clm")
"Snapshot of the CLM's stats"
snapshots: [ClmSnapshot!]! @derivedFrom(field: "clm")
"All CLM interactions for this CLM"
interactions: [ClmPositionInteraction!]! @derivedFrom(field: "clm")
}
"""
A snapshot of the CLM's stats.
Any event that happens in the CLM is recorded in a snapshot.
We keep multiple snapshots time frames as noted by the "period" field.
Snapshots include: daily, weekly, yearly.
"""
type ClmSnapshot @entity {
"CLM.id + period + timestamp"
id: Bytes!
"The CLM the snapshot is for"
clm: CLM!
"""
Duration of the snapshot period in seconds.
Available periods:
- 1 day: 86400
- 1 week: 604800
- 1 year: 31536000
"""
period: BigInt!
"Timestamp the snapshot was initiated at, rounded to period"
roundedTimestamp: BigInt!
"Actual timestamp snapshot was initiated at"
timestamp: BigInt!
"The total supply of the manager token in circulation. Express with `sharesToken.decimals` decimals."
managerTotalSupply: BigInt!
"Total supply of the reward pool token. Express with `clm.rewardPoolTokensOrder[idx].decimals` decimals."
rewardPoolsTotalSupply: [BigInt!]!
"Latest token 0 price in native of this snapshot. Expressed with 18 decimals."
token0ToNativePrice: BigInt!
"Latest token 1 price in native of this snapshot. Expressed with 18 decimals."
token1ToNativePrice: BigInt!
"Latest output token prices in native of this snapshot. Ordered by clm.outputTokensOrder. Expressed with 18 decimals."
outputToNativePrices: [BigInt!]!
"Latest reward token prices in native of this snapshot. Ordered by clm.rewardTokensOrder. Expressed with 18 decimals."
rewardToNativePrices: [BigInt!]!
"Latest native token price of this snapshot. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
"""
The current price of the token zero expressed as a token1 value.
For example, if the CLM is a BTC/ETH CLM, this is the price of 1 BTC in ETH.
This is expressed in token1 decimals.
"""
priceOfToken0InToken1: BigInt!
"Price range start this CLM is currently configured to operate in, in token 1"
priceRangeMin1: BigInt!
"Price range end this CLM is currently configured to operate in, in token 1"
priceRangeMax1: BigInt!
"Total amount of token0 in the CLM. Can be slightly higher than main + alt amounts due to vested tokens."
totalUnderlyingAmount0: BigInt!
"Total amount of token1 in the CLM. Can be slightly higher than main + alt amounts due to vested tokens."
totalUnderlyingAmount1: BigInt!
"Amount of underlying tokens in the CLM assigned to the main position in the first token."
underlyingMainAmount0: BigInt!
"Amount of underlying tokens in the CLM assigned to the main position in the second token."
underlyingMainAmount1: BigInt!
"Amount of underlying tokens in the CLM assigned to the alt position in the first token."
underlyingAltAmount0: BigInt!
"Amount of underlying tokens in the CLM assigned to the alt position in the second token."
underlyingAltAmount1: BigInt!
}
"""
A ClmManager handles the accounting of a CLM.
"""
type ClmManager @entity {
"The CL Manager address"
id: Bytes!
"The CLM this manager belongs to"
clm: CLM!
"The transaction that created the manager"
createdWith: Transaction!
"Technical field to remember if the CLM was already initialized"
isInitialized: Boolean!
}
"""
A strategy is a contract that manages the assets of a CLM.
This entity is mostly used to start tracking the events and link them to the CLM on new event
"""
type ClmStrategy @entity {
"The strategy address"
id: Bytes!
"The CLM the strategy is managing"
clm: CLM!
"The manager of the strategy"
manager: ClmManager!
"The output token sent to the reward pool. Set to NULL token if the strategy automatically compounds."
outputToken: Token!
"The transaction that created the strategy"
createdWith: Transaction!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
Some ClmManager do not automatically compound their earnings. Those earnings are sent to the reward pool instead.
This entity is mostly used to start tracking the events and link them to the CLM on new event
"""
type ClmRewardPool @entity {
"The strategy address"
id: Bytes!
"The CLM the reward pool is for"
clm: CLM!
"The manager that this reward pool is linked to"
manager: ClmManager!
"The transaction that created the reward pool"
createdWith: Transaction!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
ClmManagers are harvested by the strategy. This event is emitted when the strategy harvests the manager.
"""
type ClmHarvestEvent @entity(immutable: true) {
"transaction hash + log index"
id: Bytes!
"The CLM the harvest event is for"
clm: CLM!
"The strategy that harvested the Manager"
strategy: ClmStrategy!
"The transaction that created the harvest event"
createdWith: Transaction!
"The event log index in the transaction that created the harvest event."
logIndex: BigInt!
"The timestamp of the harvest event so you can sort by time"
timestamp: BigInt!
"Underlying balance of the first token after the harvest"
underlyingAmount0: BigInt!
"Underlying balance of the second token after the harvest"
underlyingAmount1: BigInt!
"The amount of first underlying tokens compounded"
compoundedAmount0: BigInt!
"The amount of second underlying tokens compounded"
compoundedAmount1: BigInt!
"The amount of output tokens collected. Ordered by clm.outputTokensOrder."
collectedOutputAmounts: [BigInt!]!
"Total amount of liquidity in the manager at time of harvest"
managerTotalSupply: BigInt!
"Total amount of reward pool shares at time of harvest. Ordered by clm.rewardPoolTokensOrder."
rewardPoolsTotalSupply: [BigInt!]!
"Token 0 price in native at the time of harvest. Expressed with 18 decimals."
token0ToNativePrice: BigInt!
"Token 1 price in native at the time of harvest. Expressed with 18 decimals."
token1ToNativePrice: BigInt!
"Output token prices in native at the time of harvest. Expressed with 18 decimals. Ordered by clm.outputTokensOrder."
outputToNativePrices: [BigInt!]!
"Reward token prices in native at the time of harvest. Expressed with 18 decimals. Ordered by clm.rewardTokensOrder."
rewardToNativePrices: [BigInt!]!
"Native token price at the time of harvest. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}
"""
This event is emitted when we collect earned trading fees from the underlying pool.
"""
type ClmManagerCollectionEvent @entity(immutable: true) {
"transaction hash + log index"
id: Bytes!
"The CLM the collect event is for"
clm: CLM!
"The strategy that collect for the Manager"
strategy: ClmStrategy!
"The transaction that created the collect event"
createdWith: Transaction!
"The event log index in the transaction that created the collection event."
logIndex: BigInt!
"The timestamp of the collect event so you can sort by time"
timestamp: BigInt!
"Amount of underlying tokens in the CLM assigned to the main position in the first token."
underlyingMainAmount0: BigInt!
"Amount of underlying tokens in the CLM assigned to the main position in the second token."
underlyingMainAmount1: BigInt!
"Amount of underlying tokens in the CLM assigned to the alt position in the first token."
underlyingAltAmount0: BigInt!
"Amount of underlying tokens in the CLM assigned to the alt position in the second token."
underlyingAltAmount1: BigInt!
"Underlying balance of the first token after event"
underlyingAmount0: BigInt!
"Underlying balance of the first token after event"
underlyingAmount1: BigInt!
"Amount of collected fees in the first token"
collectedAmount0: BigInt!
"Amount of collected fees in the second token"
collectedAmount1: BigInt!
"Amount of collected fees in the output tokens. Ordered by clm.outputTokensOrder."
collectedOutputAmounts: [BigInt!]!
"Token 0 price in native at the time of the collection. Expressed with 18 decimals."
token0ToNativePrice: BigInt!
"Token 1 price in native at the time of the collection. Expressed with 18 decimals."
token1ToNativePrice: BigInt!
"Output token prices in native at the time of the collection. Expressed with 18 decimals. Ordered by clm.outputTokensOrder."
outputToNativePrices: [BigInt!]!
"Reward token prices in native at the time of the collection. Expressed with 18 decimals. Ordered by clm.rewardTokensOrder."
rewardToNativePrices: [BigInt!]!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}
"""
An investor position is a record of an investor's position in a CLM.
"""
type ClmPosition @entity {
"CLM.id + investor address"
id: Bytes!
"The CLM the investor has a position in"
clm: CLM!
"The investor that has a position in the CLM"
investor: Investor!
"The transaction that created the investor position"
createdWith: Transaction!
"The amount of manager shares the investor holds"
managerBalance: BigInt!
"Amount of reward pool shares the investor holds. Ordered by clm.rewardPoolTokensOrder."
rewardPoolBalances: [BigInt!]!
"Total amount of CLM shares the investor holds. Should always equal to managerBalance + rewardPoolBalance. This is mostly used for filtering."
totalBalance: BigInt!
"All investor position interactions"
interactions: [ClmPositionInteraction!]! @derivedFrom(field: "investorPosition")
}
enum ClmPositionInteractionType {
"The investor deposited funds into the CLM"
MANAGER_DEPOSIT
"The investor withdrew funds from the CLM"
MANAGER_WITHDRAW
"The investor staked in the reward pool of the CLM and received reward pool shares"
CLM_REWARD_POOL_STAKE
"The investor unstaked from the reward pool of the CLM and received underlying tokens"
CLM_REWARD_POOL_UNSTAKE
"The investor claimed their rewards from the reward pool of the CLM"
CLM_REWARD_POOL_CLAIM
}
type ClmPositionInteraction @entity(immutable: true) {
"transaction hash + event log index"
id: Bytes!
"The CLM the investor has a position in"
clm: CLM!
"The investor that has a position in the CLM"
investor: Investor!
"The investor position the interaction is for"
investorPosition: ClmPosition!
"The transaction that created the investor position interaction"
createdWith: Transaction!
"Block number of the interaction"
blockNumber: BigInt!
"The timestamp of the interaction"
timestamp: BigInt!
"The type of the interaction"
type: ClmPositionInteractionType!
"The amount of manager shares the investor holds at the time of the interaction"
managerBalance: BigInt!
"The amount of reward pool shares the investor holds at the time of the interaction. Ordered by clm.rewardPoolTokensOrder."
rewardPoolBalances: [BigInt!]!
"Total amount of CLM shares the investor holds. Should always equal to managerBalance + rewardPoolBalance. This is mostly used for filtering."
totalBalance: BigInt!
"The amount of first underlying tokens the investor is entitled to at the time of the interaction"
underlyingBalance0: BigInt!
"The amount of second underlying tokens the investor is entitled to at the time of the interaction"
underlyingBalance1: BigInt!
"Amount of manager shares change in the interaction"
managerBalanceDelta: BigInt!
"Amount of reward pool shares change in the interaction. Ordered by clm.rewardPoolTokensOrder."
rewardPoolBalancesDelta: [BigInt!]!
"Amount of reward tokens change in the interaction. Ordered by clm.rewardTokensOrder."
rewardBalancesDelta: [BigInt!]!
"""
RewardPool from which rewards were claimed.
TODO: this is required because rewardBalancesDelta and clm.rewardTokensOrder contains all reward tokens of all potential rewardpools. Maybe rewardBalancesDelta should be an array of array of bigint. Or smth else altogether.
"""
claimedRewardPool: ClmRewardPool
"Amount of underlying token 0 change in the interaction"
underlyingBalance0Delta: BigInt!
"Amount of underlying token 0 change in the interaction"
underlyingBalance1Delta: BigInt!
"Token 0 price in native at the time of the interaction. Expressed with 18 decimals."
token0ToNativePrice: BigInt!
"Token 1 price in native at the time of the interaction. Expressed with 18 decimals."
token1ToNativePrice: BigInt!
"Output token prices in native at the time of the interaction. Expressed with 18 decimals. Ordered by clm.outputTokensOrder."
outputToNativePrices: [BigInt!]!
"Reward token prices in native at the time of the interaction. Expressed with 18 decimals. Ordered by clm.rewardTokensOrder."
rewardToNativePrices: [BigInt!]!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}