forked from beefyfinance/cowcentrated-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.graphql
433 lines (367 loc) · 14.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
##################################
##### Common dimensions ##########
##################################
"""
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!
}
#########################
##### Protocol Data #####
#########################
"""
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: BeefyCL
"""
id: Bytes!
"Protocol name"
name: String!
"All vaults in the protocol"
vaults: [BeefyCLVault!]! @derivedFrom(field: "protocol")
}
#############################
##### CL Vault Contracts ####
#############################
enum VaultLifecycle {
"The vault is in the process of being initialized"
INITIALIZING
"The vault is able to accept deposits and earn yield"
RUNNING
"A vault can be paused for a variety of reasons, this is always to protect investors funds"
PAUSED
}
type BeefyCLVault @entity {
"The vault address"
id: Bytes!
"The protocol the vault belongs to"
protocol: Protocol!
"The transaction that created the vault"
createdWith: Transaction!
"The strategy of the vault. The strategy is responsible for managing the vault's assets."
strategy: BeefyCLStrategy!
"The reward pool of the vault. The reward pool is where the vault's earnings are sent if the vault does not automatically compound."
rewardPool: BeefyCLRewardPool
"Technical field to remember if the vault was already initialized"
isInitialized: Boolean!
"The current lifecycle status of the vault"
lifecycle: VaultLifecycle!
"The token data of the vault. The vault is also an ERC20 token. This tokens represents the shares of the vault."
sharesToken: Token!
"The reward pool token of the vault. This is where the vault's earnings are sent if the vault does not automatically compound."
rewardPoolToken: Token!
"The underlying tokens contained in the vault. This is the first token."
underlyingToken0: Token!
"The underlying tokens contained in the vault. This is the second token."
underlyingToken1: Token!
# ----- PRICES & STATS -----
"The total supply of the shares token in circulation. Express with `sharesToken.decimals` decimals."
totalSupply: BigInt!
"Total supply of the reward pool token. Express with `rewardPoolToken.decimals` decimals."
rewardPoolTotalSupply: 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!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
"""
The current price of the token zero expressed as a token1 value.
For example, if the vault is a BTC/ETH vault, this is the price of 1 BTC in ETH.
This is expressed in token1 decimals.
"""
priceOfToken0InToken1: BigInt!
"Price range start this vault is currently configured to operate in, in token 1"
priceRangeMin1: BigInt!
"Price range end this vault is currently configured to operate in, in token 1"
priceRangeMax1: BigInt!
"Amount of underlying tokens in the vault assigned to the main position in the first token."
underlyingMainAmount0: BigInt!
"Amount of underlying tokens in the vault assigned to the main position in the second token."
underlyingMainAmount1: BigInt!
"Amount of underlying tokens in the vault assigned to the alt position in the first token."
underlyingAltAmount0: BigInt!
"Amount of underlying tokens in the vault assigned to the alt position in the second token."
underlyingAltAmount1: BigInt!
"All investors positions in the vault"
positions: [InvestorPosition!]! @derivedFrom(field: "vault")
"All underlying fees collected by the vault"
collectedFees: [BeefyCLVaultUnderlyingFeesCollectedEvent!]! @derivedFrom(field: "vault")
"All harvest events of the vault"
harvests: [BeefyCLVaultHarvestEvent!]! @derivedFrom(field: "vault")
"Snapshot of the vault's stats"
snapshots: [BeefyCLVaultSnapshot!]! @derivedFrom(field: "vault")
"All vault interactions for this vault"
interactions: [InvestorPositionInteraction!]! @derivedFrom(field: "vault")
}
"""
A snapshot of the vault's stats.
Any event that happens in the vault is recorded in a snapshot.
We keep multiple snapshots time frames as noted by the "period" field.
Snapshots include: daily, weekly, yearly.
"""
type BeefyCLVaultSnapshot @entity {
"vault.id + period + timestamp"
id: Bytes!
"The vault the snapshot is for"
vault: BeefyCLVault!
"""
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 shares token in circulation. Express with `sharesToken.decimals` decimals."
totalSupply: BigInt!
"Total supply of the reward pool token. Express with `rewardPoolToken.decimals` decimals."
rewardPoolTotalSupply: 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!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
"""
The current price of the token zero expressed as a token1 value.
For example, if the vault is a BTC/ETH vault, this is the price of 1 BTC in ETH.
This is expressed in token1 decimals.
"""
priceOfToken0InToken1: BigInt!
"Price range start this vault is currently configured to operate in, in token 1"
priceRangeMin1: BigInt!
"Price range end this vault is currently configured to operate in, in token 1"
priceRangeMax1: BigInt!
"Amount of underlying tokens in the vault assigned to the main position in the first token."
underlyingMainAmount0: BigInt!
"Amount of underlying tokens in the vault assigned to the main position in the second token."
underlyingMainAmount1: BigInt!
"Amount of underlying tokens in the vault assigned to the alt position in the first token."
underlyingAltAmount0: BigInt!
"Amount of underlying tokens in the vault assigned to the alt position in the second token."
underlyingAltAmount1: BigInt!
}
"""
A strategy is a contract that manages the assets of a vault.
This entity is mostly used to start tracking the events and link them to the vault on new event
"""
type BeefyCLStrategy @entity {
"The strategy address"
id: Bytes!
"The vault the strategy is managing"
vault: BeefyCLVault!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
Some vaults do not automatically compound their earnings. Those earnings are sent to the reward pool instead.
This entit is mostly used to start tracking the events and link them to the vault on new event
"""
type BeefyCLRewardPool @entity {
"The strategy address"
id: Bytes!
"The vault the strategy is managing"
vault: BeefyCLVault!
"Technical field to remember if the strategy was already initialized"
isInitialized: Boolean!
}
"""
Vault are harvested by the strategy. This event is emitted when the strategy harvests the vault.
"""
type BeefyCLVaultHarvestEvent @entity(immutable: true) {
"transaction hash + log index"
id: Bytes!
"The vault the harvest event is for"
vault: BeefyCLVault!
"The strategy that harvested the vault"
strategy: BeefyCLStrategy!
"The transaction that created the vault harvest event"
createdWith: Transaction!
"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!
"Total amount of liquidity at time of harvest"
totalSupply: BigInt!
"Total amount of reward pool shares at time of harvest"
rewardPoolTotalSupply: 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!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}
"""
This event is emitted when we collect earned trading fees from the underlying pool.
"""
type BeefyCLVaultUnderlyingFeesCollectedEvent @entity(immutable: true) {
"transaction hash + log index"
id: Bytes!
"The vault the collect event is for"
vault: BeefyCLVault!
"The strategy that collect for the vault"
strategy: BeefyCLStrategy!
"The transaction that created the vault collect event"
createdWith: Transaction!
"The timestamp of the collect event so you can sort by time"
timestamp: BigInt!
"Amount of underlying tokens in the vault assigned to the main position in the first token."
underlyingMainAmount0: BigInt!
"Amount of underlying tokens in the vault assigned to the main position in the second token."
underlyingMainAmount1: BigInt!
"Amount of underlying tokens in the vault assigned to the alt position in the first token."
underlyingAltAmount0: BigInt!
"Amount of underlying tokens in the vault assigned to the alt position in the second token."
underlyingAltAmount1: BigInt!
"Amount of collected fees in the first token"
collectedAmount0: BigInt!
"Amount of collected fees in the second token"
collectedAmount1: 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!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}
############################
##### Investor Position ####
############################
type Investor @entity {
"The investor address"
id: Bytes!
"All investor beefy positions"
positions: [InvestorPosition!]! @derivedFrom(field: "investor")
"All investor interactions"
interactions: [InvestorPositionInteraction!]! @derivedFrom(field: "investor")
}
"""
An investor position is a record of an investor's position in a vault.
"""
type InvestorPosition @entity {
"Vault address + investor address"
id: Bytes!
"The vault the investor has a position in"
vault: BeefyCLVault!
"The investor that has a position in the vault"
investor: Investor!
"The transaction that created the investor position"
createdWith: Transaction!
"The amount of shares the investor holds"
sharesBalance: BigInt!
"Amount of reward pool shares the investor holds"
rewardPoolBalance: BigInt!
"All investor position interactions"
interactions: [InvestorPositionInteraction!]! @derivedFrom(field: "investorPosition")
}
enum InvestorPositionInteractionType {
"The investor deposited funds into the vault"
VAULT_DEPOSIT
"The investor withdrew funds from the vault"
VAULT_WITHDRAW
"The investor staked in the reward pool of the vault and received reward pool shares"
REWARD_POOL_STAKE
"The investor unstaked from the reward pool of the vault and received underlying tokens"
REWARD_POOL_UNSTAKE
"The investor claimed their rewards from the reward pool of the vault"
REWARD_POOL_CLAIM
}
type InvestorPositionInteraction @entity(immutable: true) {
"transaction hash + event log index"
id: Bytes!
"The vault the investor has a position in"
vault: BeefyCLVault!
"The investor that has a position in the vault"
investor: Investor!
"The investor position the interaction is for"
investorPosition: InvestorPosition!
"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: InvestorPositionInteractionType!
"The amount of shares the investor holds at the time of the interaction"
sharesBalance: BigInt!
"The amount of reward pool shares the investor holds at the time of the interaction"
rewardPoolBalance: 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 shares change in the interaction"
sharesBalanceDelta: BigInt!
"Amount of reward pool shares change in the interaction"
rewardPoolBalanceDelta: BigInt!
"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!
"Native token price at the time of the interaction. Expressed with 18 decimals."
nativeToUSDPrice: BigInt!
}