forked from salazarguille/yearn-vaults-v2-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 41
/
schema.graphql
622 lines (576 loc) · 20 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
##### SCHEMA GUIDELINES
## Naming Conventions
# Certain prefixes may be used to indicate a particular type of value.
# * total - indicates this is a cumulative value (e.g. totalSharesMinted, totalGrossReturns)
# * balance - indicates this is a spot balance (e.g. balanceTokensIdle)
# * delta - indicates this value is the difference between the prior state and the current state (e.g. deltaPricePerShare)
# * current - used exclusively in Update entities. Similar to balance, current indicates the state of a field or value at the time of the update. These values are populated in every update whether they changed or not.
# * new - used exclusively in Update entities. Fields with this prefix will only be populated if they have changed since the last Update. If there has been no change, the value will be null.
# Use plurals when referring to Tokens or Shares (e.g. totalShares, balanceTokens)
type Transaction @entity {
"Transaction hash + Log Index"
id: ID!
"Log index related to the event. A Transaction might contain multiple events."
logIndex: BigInt!
"The event name / call stacktrace"
event: String!
"The transaction sender"
from: Bytes!
"Gas price used in the transaction"
gasPrice: BigInt!
"Gas limit used in the transaction"
gasLimit: BigInt!
"Transaction hash"
hash: Bytes!
"The transaction index"
index: BigInt!
"Address that received the transaction"
to: Bytes!
"Ether value sent in the transaction"
value: BigInt!
"Timestamp when the transaction was executed"
timestamp: BigInt!
"Gas limit used in the current block"
blockGasLimit: BigInt!
"Block number"
blockNumber: BigInt!
}
type Token @entity {
"Token address"
id: ID!
"Number of decimals for this Token"
decimals: Int!
"Name of the Token"
name: String!
"Symbol of the Token"
symbol: String!
}
type TokenFee @entity {
"Token address"
id: ID!
vault: Vault!
"The token which the fees are denominated in. Equivalent to vault.token."
token: Token!
"All time fees paid using this token to the treasury. Denominated in the vault's want token."
totalTreasuryFees: BigInt!
"All time fees paid using this token to strategists. Denominated in the vault's want token."
totalStrategyFees: BigInt!
"All time fees paid using this token to strategists and the treasury. Denominated in the vault's want token."
totalFees: BigInt!
"Internal field used by VaultUpdate. The amount of treasury fees paid using this token that has yet to be recognized by the subgraph's accounting logic."
unrecognizedTreasuryFees: BigInt!
"Internal field used by VaultUpdate. The amount of strategist fees paid using this token that has yet to be recognized by the subgraph's accounting logic."
unrecognizedStrategyFees: BigInt!
}
enum VaultClassification {
Endorsed
Experimental
Released
}
## TODO: Implement tracking the release pipeline from the Registry contract. Add these entities:
# enum VaultStatus {
# Latest # This Vault is the latest release for a given Token
# Active # This Vault is not the latest release for a given Token, but is healthy and safe
# Retired # This Vault has been deprecated and is unwinding/has deposits disabled/should not be used TODO: think this is when the Vault has an emergency shutdown, but check that this doesn't have some status within the registry release pipeline
# }
# type VaultRelease @entity {
# "Release index in Registry contract"
# id: ID!
# "Version string"
# version: String!
# "Contract address"
# contract: Bytes!
# "Vault deployments of this release version"
# vaults: [Vault!]! @derivedFrom(field: "release")
# "Timestamp of Release"
# timestamp: BigInt!
# "Block number of Release"
# blockNumber: BigInt!
# "Ethereum Transaction"
# transaction: Transaction!
# }
type Registry @entity {
"Registry address"
id: ID!
"Transaction timestamp"
timestamp: BigInt!
"Transaction/Block Block number"
blockNumber: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"Vaults registered in the registry."
vaults: [Vault!]! @derivedFrom(field: "registry")
}
# TODO:
# withdrawal queue
type Vault @entity {
"Vault address"
id: ID!
"Ethereum Transaction"
transaction: Transaction!
"Vault type defined in Registry v3. Default/legacy value is 99999999"
type: BigInt!
"The registry address"
registry: Registry!
"Token this Vault will accrue"
token: Token!
"Token representing Shares in the Vault"
shareToken: Token!
# "Vault status"
# status: VaultStatus!
"Vault classification"
classification: VaultClassification!
# "Release Information"
# release: VaultRelease!
"Latest Vault Update"
latestUpdate: VaultUpdate
vaultDayData: [VaultDayData!]! @derivedFrom(field: "vault")
"All Vault Updates"
historicalUpdates: [VaultUpdate!]! @derivedFrom(field: "vault")
"Strategies for this Vault"
strategies: [Strategy!]! @derivedFrom(field: "vault")
"Strategy Ids for this vault"
strategyIds: [Strategy!]!
"Token deposits into the Vault"
deposits: [Deposit!]! @derivedFrom(field: "vault")
"Token withdrawals from the Vault"
withdrawals: [Withdrawal!]! @derivedFrom(field: "vault")
"withdrawl queue of strategies"
withdrawalQueue:[Strategy!]!
"Transfers of Vault Shares"
transfers: [Transfer!]! @derivedFrom(field: "vault")
"Tags attached to the Vault"
tags: [String!]!
"Balance of Tokens in the Vault and its Strategies"
balanceTokens: BigInt!
"Current idle Token balance"
balanceTokensIdle: BigInt! # Tokens in the Vault contract
"Current supply of Shares"
sharesSupply: BigInt!
"Management fee in basis points"
managementFeeBps: Int!
"Performance fee in basis points"
performanceFeeBps: Int!
"The address where management fees are paid to"
rewards: Bytes!
"This technical field defines whether this vault is a custom item (created by a custom handler) or not (created by the registry dynamically)."
isTemplateListening: Boolean!
# TODO: refactor these fields out into vault release entity
# release fields temporary for MVP
"Creation timestamp"
activation: BigInt!
"The API version."
apiVersion: String!
"The vault's health check contract."
healthCheck: HealthCheck
"The address authorized for guardian interactions in the new Vault"
guardian: Bytes!
"The management address of the Vault to assert privileged functions that can only be called by management"
management: Bytes!
"The governance address of the Vault to assert privileged functions that can only be called by governance"
governance: Bytes!
"The maximum amount of underlying that can be deposited"
availableDepositLimit: BigInt!
"The maximum amount of tokens that can be deposited in this Vault"
depositLimit: BigInt!
"Is vault in emergency shutdown"
emergencyShutdown: Boolean!
"Block.timestamp of contract deployment"
activationBlockNumber: BigInt!
}
type VaultUpdate @entity {
"Vault-Transaction-Log"
id: ID!
"Timestamp of update"
timestamp: BigInt!
"Block number of update"
blockNumber: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"Vault this update is for"
vault: Vault!
### BALANCES AND SHARES
"Sum of tokens deposited"
tokensDeposited: BigInt!
"Sum of tokens withdrawn"
tokensWithdrawn: BigInt!
"Sum of Shares minted over all time"
sharesMinted: BigInt!
"Sum of Shares burnt over all time"
sharesBurnt: BigInt!
"The current balance position defined as: (vault.totalAssets() * (vault.pricePerShare() / 10**vault.decimals()))."
balancePosition: BigInt!
### PERFORMANCE
"Returns generated in Tokens"
returnsGenerated: BigInt!
"Total fees accrued over the lifetime of the vault. Denominated in want tokens."
totalFees: BigInt!
### VAULT STATE
"Price per full share at the time of the update. Denominated in want tokens."
pricePerShare: BigInt!
"Balance of Tokens in the Vault and its Strategies at the time of update. "
currentBalanceTokens: BigInt!
### TRANSIENT VALUES
"Management fee at time of update, in basis points. If this value has not been changed since the last VaultEvent, it will be null."
newManagementFee: BigInt
"New Performance fee at time of update, in basis points. If this value has not been changed since the last VaultEvent, it will be null."
newPerformanceFee: BigInt
"The new Rewards address that management fees will be paid to. If this value has not been changed since the last VaultEvent, it will be null."
newRewards: Bytes
"The vault's new health check contract. If this value has not been changed since the last VaultEvent, it will be null."
newHealthCheck: HealthCheck
"The maximum amount of underlying that can be deposited"
availableDepositLimit: BigInt!
"The maximum amount of tokens that can be deposited in this Vault"
depositLimit: BigInt!
### MANAGEMENT
"The address authorized for guardian interactions in the new Vault"
guardian: Bytes!
"The management address of the Vault to assert privileged functions that can only be called by management"
management: Bytes!
"The governance address of the Vault to assert privileged functions that can only be called by governance"
governance: Bytes!
}
type HealthCheck @entity {
"Health Check Address"
id: ID!
"Vaults that use this health check contract."
vaults: [Vault!]! @derivedFrom(field: "healthCheck")
}
type Account @entity {
"Account address"
id: ID!
"Vault deposits"
deposits: [Deposit!]! @derivedFrom(field: "account")
"Vault withdrawals"
withdrawals: [Withdrawal!]! @derivedFrom(field: "account")
"Vault positions"
vaultPositions: [AccountVaultPosition!]! @derivedFrom(field: "account")
"Incoming share transfers"
sharesReceived: [Transfer!]! @derivedFrom(field: "to")
"Outgoing share transfers"
sharesSent: [Transfer!]! @derivedFrom(field: "from")
}
type Deposit @entity {
"Transaction-Log"
id: ID!
"Timestamp of update"
timestamp: BigInt!
"Block number of update"
blockNumber: BigInt!
"Account making Deposit"
account: Account!
"Vault deposited into"
vault: Vault!
"Number of Tokens deposited into Vault"
tokenAmount: BigInt!
"Number of new Vault Shares minted"
sharesMinted: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"Vault Update"
vaultUpdate: VaultUpdate!
}
type Withdrawal @entity {
"Transaction-Log"
id: ID!
"Timestamp of update"
timestamp: BigInt!
"Block number of update"
blockNumber: BigInt!
"Account making withdraw"
account: Account!
"Vault withdrawn from"
vault: Vault!
"Number of Tokens withdrawn from Vault"
tokenAmount: BigInt!
"Number of Vault Shares burnt"
sharesBurnt: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"Vault Update"
vaultUpdate: VaultUpdate!
}
type Transfer @entity {
"Transaction-Log"
id: ID!
"Vault"
vault: Vault!
"Sender"
from: Account!
"Receiver"
to: Account!
"Vault Share Token"
shareToken: Token!
"Number of Vault Shares transferred"
shareAmount: BigInt!
"Vault Token"
token: Token!
"Number of Tokens redeemable for shares transferred"
tokenAmount: BigInt!
"Token Amount in USDC, 0 if the transaction was before the oracle was deployed at 12198044"
tokenAmountUsdc: BigInt!
"Timestamp of Transfer"
timestamp: BigInt!
"Block number of Transfer"
blockNumber: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"Whether the transfer was used to pay a fee to the vault's rewards address"
isFeeToTreasury: Boolean!
"Whether the transfer was used to pay a fee to a strategy"
isFeeToStrategy: Boolean!
}
type AccountVaultPosition @entity {
"Account-Vault"
id: ID!
"Vault"
vault: Vault!
"Account"
account: Account!
"Vault token"
token: Token!
"Vault share token"
shareToken: Token!
"Created in transaction"
transaction: Transaction!
"Latest account update for this Vault"
latestUpdate: AccountVaultPositionUpdate!
"Account updates over time"
updates: [AccountVaultPositionUpdate!]! @derivedFrom(field: "accountVaultPosition")
"Share balance"
balanceShares: BigInt!
"The current balance of tokens defined as: sum(deposits) - sum(withdrawals) + sum(received transfers) - sum(sent transfers)."
balanceTokens: BigInt!
"The current balance position defined as: (vault.balanceOf(account) * (vault.pricePerShare() / 10**vault.decimals()))."
balancePosition: BigInt!
"The accumulated profit balance for the account/vault. It is only calculated when the user withdraws all the shares."
balanceProfit: BigInt!
}
type AccountVaultPositionUpdate @entity {
"Account-Vault-Order"
id: ID!
"Incremental value for the same account/vault."
order: BigInt!
"Timestamp"
timestamp: BigInt!
"Block number"
blockNumber: BigInt!
"Account that owns position update"
account: Account!
"The account vault position that this update applies to"
accountVaultPosition: AccountVaultPosition!
"Ethereum Transaction"
transaction: Transaction!
"Sum of token deposits"
deposits: BigInt!
"Sum of token withdrawals"
withdrawals: BigInt!
"Sum of share tokens minted"
sharesMinted: BigInt!
"Sum of share tokens burnt"
sharesBurnt: BigInt!
# "Tokens sent"
tokensSent: BigInt!
# "Tokens received"
tokensReceived: BigInt!
# "Share tokens sent"
sharesSent: BigInt!
# "Share tokens received"
sharesReceived: BigInt!
# "The balance of shares"
balanceShares: BigInt!
"The balance position."
balancePosition: BigInt!
"Vault Update"
vaultUpdate: VaultUpdate!
}
enum StrategyStatus {
Active
Retired
}
type Strategy @entity {
"Strategy address"
id: ID!
"Strategy name."
name: String!
"Timestamp the vault information was most recently updated."
timestamp: BigInt!
"Blocknumber the vault information was most recently updated."
blockNumber: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"The Strategy address."
address: Bytes!
"The health check contract address."
healthCheck: Bytes
"Defines whether the strategy will call the health check or not."
doHealthCheck: Boolean!
"Defines whether this strategy is within the vault queue"
inQueue: Boolean!
"The Vault"
vault: Vault!
"Strategy reference used to clone this strategy."
clonedFrom: Strategy
"Defines the maximum borrow amount. In strategies <v0.3.5 it is debtRatio."
debtLimit: BigInt!
"Lower limit on the increase of debt since last harvest."
minDebtPerHarvest: BigInt!
"Upper limit on the increase of debt since last harvest."
maxDebtPerHarvest: BigInt!
"It is the current rate limit. It increases/decreases per block. This field is currently only populated on strategy create"
rateLimit: BigInt!
"Defines the strategist's fee (basis points)."
performanceFeeBps: BigInt!
"The latest report for this Strategy"
latestReport: StrategyReport
"The reports created by this strategy."
reports: [StrategyReport!]! @derivedFrom(field: "strategy")
"harvest() calls"
harvests: [Harvest!]! @derivedFrom(field: "strategy")
"Used to track the deployed version of this contract"
apiVersion: String!
"Determines if strategy is in emergency exit"
emergencyExit: Boolean!
"keeper is the only address that may call tend() or harvest(), other than governance() or strategist"
keeper: Bytes!
"The address of the strategist"
strategist: Bytes!
"The address for rewards"
rewards: Bytes!
"The amount of assets this strategy manages that should not be included in Yearn's Total Value Locked (TVL) calculation across it's ecosystem."
delegatedAssets: BigInt!
#"Provide an indication of whether this strategy is currently active"
#isActive: Boolean!
#"Provide an accurate estimate for the total amount of assets (principle + return) that this Strategy is currently managing, denominated in terms of want tokens."
#estimatedTotalAssets: BigInt!
}
type StrategyMigration @entity {
"The Strategy Migration ID."
id: ID!
"Old Strategy"
oldStrategy: Strategy!
"New Strategy"
newStrategy: Strategy!
"Blocknumber the migration was created."
blockNumber: BigInt!
"Timestamp the migration was created."
timestamp: BigInt!
"Ethereum Transaction"
transaction: Transaction!
}
type StrategyReport @entity {
"The Strategy Report ID."
id: ID!
"Timestamp the strategy report was most recently updated."
timestamp: BigInt!
"Blocknumber the strategy report was most recently updated."
blockNumber: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"The Strategy reference."
strategy: Strategy!
"The reported gain amount for the strategy."
gain: BigInt!
"The reported loss amount for the strategy."
loss: BigInt!
"The reported total gain amount for the strategy."
totalGain: BigInt!
"The reported total loss amount for the strategy."
totalLoss: BigInt!
"The reported total debt amount for the strategy."
totalDebt: BigInt!
"The reported debt added amount for the strategy."
debtAdded: BigInt!
"The reported debt limit amount for the strategy."
debtLimit: BigInt!
"The reported debt paid for the strategy. This field is 0 for v0.3.0 or v0.3.1."
debtPaid: BigInt!
# "Vault state"
# vaultUpdate: VaultUpdate!
"The results created by this report. They are generated comparing the previous report and the current one."
results: [StrategyReportResult!]! @derivedFrom(field: "currentReport")
#### TODO Awaiting updated Vault Yield-Oracles https://github.com/iearn-finance/yearn-vaults/pull/69
# "12-day EMA of Vault APY as reported by built-in Yield Oracle"
# apy12dEMA: Int!
# "50-day EMA of Vault APY as reported by built-in Yield Oracle"
# apy50dEMA: Int!
}
type StrategyReportResult @entity {
"The Strategy Report Result ID."
id: ID!
"Timestamp the strategy report was most recently updated."
timestamp: BigInt!
"Blocknumber the strategy report was most recently updated."
blockNumber: BigInt!
"The current strategy report."
currentReport: StrategyReport!
"The previous strategy report."
previousReport: StrategyReport!
startTimestamp: BigInt!
endTimestamp: BigInt!
"The duration (in days) from the previous report."
duration: BigDecimal!
"Duration percentage rate."
durationPr: BigDecimal!
"Annual Percentage Rate."
apr: BigDecimal!
"Ethereum Transaction"
transaction: Transaction!
}
type Harvest @entity {
"Strategy-Transaction-Log"
id: ID!
"Timestamp the strategy report was most recently updated."
timestamp: BigInt!
"Blocknumber the strategy report was most recently updated."
blockNumber: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"Vault that owns the strategy"
vault: Vault!
"Strategy that harvested"
strategy: Strategy!
"Function caller"
harvester: Bytes!
"The reported profit amount for the strategy at the time of the harvest."
profit: BigInt!
"The reported loss amount for the strategy at the time of the harvest."
loss: BigInt!
"The reported debt paid from strategy at the time of the harvest."
debtPayment: BigInt!
"The reported outstanding debt from strategy at the time of the harvest."
debtOutstanding: BigInt!
}
type VaultDayData @entity {
id: ID!
"time in UTC"
timestamp: BigInt!
vault: Vault!
pricePerShare: BigInt!
"The amount of tokens deposited to this vault this day"
deposited: BigInt!
"The amount of tokens withdrawn from this vault this day"
withdrawn: BigInt!
"The total earnings generated for this vault up to and including this day"
totalReturnsGenerated: BigInt!
"The total earnings generated in USDC for this vault up to and including this day. These returns are priced using the token's USDC-denominated price at the time each harvest was performed."
totalReturnsGeneratedUSDC: BigInt!
"The earnings generated for this vault this day"
dayReturnsGenerated: BigInt!
"The earnings generated in USDC for this vault this day. These returns are priced using the token's USDC-denominated price at the time each harvest was performed."
dayReturnsGeneratedUSDC: BigInt!
"The price of one of the vault's underlying token"
tokenPriceUSDC: BigInt!
"Block number the day data aggregation occured on"
blockNumber: BigInt!
}
type Yearn @entity {
id: ID!
"Only valid after the oracle was deployed at 12242339"
treasuryFeesUsdc: BigInt!
"Only valid after the oracle was deployed at 12242339"
strategyFeesUsdc: BigInt!
"Only valid after the oracle was deployed at 12242339"
totalFeesUsdc: BigInt!
}