-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.graphql
364 lines (269 loc) · 9.04 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
type ERC20Token @entity {
"Token address"
id: Bytes!
"Number of decimals for this Token"
decimals: Int!
"Name of the Token"
name: String!
"Symbol of the Token"
symbol: String!
}
type ERC4626Vault @entity {
"Vault address"
id: Bytes!
"Assumed to never change. Maybe reference ERC20Token instead?"
underlying: ERC20Token!
"Name of the vault"
name: String!
"Symbol of the vault"
symbol: String!
"Number of decimals for the vault's share token"
decimals: Int!
# totalAssets: BigInt!
# totalAssetsValueUSDC
# HasAccountingErrors
"The block in which this vault was first detected by the subgraph."
firstBlock: BigInt!
"Whether any serious accounting problems have been detected while indexing this vault."
accountingErrata: Boolean!
"""
This value is set to true if there have been withdraws/redemptions from this vault with no identifiable source.
This may be due to airdropped shares, or incorrect accounting on the vault's side with regards to how it handles deposits.
"""
containsAirdroppedShares: Boolean!
"""
The latest APY estimation for this Vault. This estimation is based on the exponential moving average of the vault's
price per share, which itself is calculated based on withdraw/redemption events. The EMA uses a half time of 15 days.
If null, there is either:
1. Not enough data to generate an estimation
2. Accounting errors or other errata that are preventing the subgraph from generating an estimation.
"""
estimatedAPY: BigDecimal
latestAPYMeasurement: VaultPerformanceSample
historicalPerformance: [VaultPerformanceSample!]! @derivedFrom(field: "vault")
"The vault's reported totalAssets. Normalized to the underlying token's decimals."
assetTvl: BigDecimal!
"""
The entity representing the latest measurement for the vault's totalAssets.
Use this to figure out how long it's been since vault.tvl was last updated.
"""
latestTVLMeasurement: VaultTVLMeasurement
"All historical TVL measurements for this vault"
historicalTVL: [VaultTVLMeasurement!]! @derivedFrom(field: "vault")
}
"""
Used to track historical TVL data for each vault.
New measurements are only taken when a user deposits, withdraws, or transfers to/from the vault.
"""
type VaultTVLMeasurement @entity @immutable {
"Concatenation of vaultAddress+blockHash"
id: Bytes!
"The vault the measurement is for"
vault: ERC4626Vault!
"The block height this measurement was taken in"
block: BigInt!
"The timestamp of the block this measurement was taken in"
timestamp: BigInt!
"The amount of assets the vault reported under its management via totalAssets()"
reportedAssets: BigDecimal!
}
" Used to keep track of contracts emitting 4626-matching events, but are not 4626 compliant."
type NonERC4626Contract @entity @immutable {
"Contract address"
id: Bytes!
}
type Account @entity {
"EOA or contract address of the account"
id: Bytes!
"Current and historical vault positions this account has"
positions: [AccountPosition!]! @derivedFrom(field: "account")
}
"""
Used to track an account's current & historical position in a specific vault.
"""
type AccountPosition @entity {
"Concatenation of accountAddress+vaultAddress"
id: Bytes!
"The account this position is for"
account: Account!
"The vault this position is for"
vault: ERC4626Vault!
"""
The amount of shares assigned to this position where the subgraph can account for their source.
If this number is different than AccountPosition.shares, then shares have been transferred/minted
to this account using a non-ERC4626 mechanism.
"""
accountableShares: BigDecimal!
"""
The amount of shares assigned to this position.
Updated on deposit, withdraw, or transfer events that touch this account.
"""
shares: BigDecimal!
"The amounts earned on this account's vault withdrawals."
earnings: [Earnings!]!
"The account's outstanding deposits that have not yet been withdrawn."
unconsumedLots: [CostBasisLot!]!
"Whether any accounting issues have been detected while indexing this account's vault position."
accountingErrata: Boolean!
}
"""
Keeps track of the cost basis of an account's vault position.
This data is used to calculate the earnings realized when an account performs a withdraw.
"""
type CostBasisLot @entity {
"Concatenation of txHash+logIdx"
id: Bytes!
block: BigInt!
"""
The amount of underlying tokens required to purchase 1 normalized share token.
This value is normalized with respect to the vault's asset token decimals.
"""
pricePerShare: BigDecimal!
"The number of underlying tokens that were exchanged for shares."
tokensInLot: BigDecimal!
"The number of shares that the account received."
sharesInLot: BigDecimal!
"""
The number of shares that have not been withdrawn from this lot yet.
If this is zero, then all of the shares from the lot have been withdrawn.
"""
unconsumedShares: BigDecimal!
}
"""
Intermediate entity used by the Earnings entity
"""
type LotConsumingAction @entity @immutable {
"Concatenation of txHash+logIdx+lotId"
id: Bytes!
lot: CostBasisLot!
sharesConsumed: BigDecimal!
}
"""
Keeps track of the amount of earnings from vault withdrawls.
Earnings are calculated using LIFO.
"""
type Earnings @entity {
"Concatenation of txHash+logIdx"
id: Bytes!
block: BigInt!
vault: ERC4626Vault!
account: Account!
"The number of shares that were redeemed for underlying tokens."
sharesRedeemed: BigDecimal!
"The number of underlying tokens that were withdrawn."
assetsWithdrawn: BigDecimal!
"""
The amount of profit earned from the withdrawal.
Negative if the transaction was made at a loss.
Measured using the underlying asset token.
"""
profit: BigDecimal!
"""
The original source(s) of shares that are being redeemed.
These sources are used to establish a cost basis price for calculating profit.
"""
sourceLots: [LotConsumingAction!]!
"""
The amount of shares redeemed in this earnings event that cannot be accounted for.
This indicates an accounting error that was probably caused by a non-4626 transfer/airdrop/etc.
If null, then all shares are accounted for.
"""
unaccountableShares: BigDecimal
}
type DepositEvent @entity @immutable {
"Concatenation of txHash+logIdx"
id: Bytes!
block: BigInt!
"The log index of the deposit event"
logIndex: BigInt!
"The transaction the deposit event came from"
transaction: Transaction!
"The vault deposited to"
vault: ERC4626Vault!
"The beneficiary of the deposit"
account: Account!
"The address that initiated the deposit event (msg.sender)"
sender: Bytes!
"The amount of assets deposited. Normalized for the asset's decimals."
assetsDeposited: BigDecimal!
"The amount of shares minted. Normalized for the vault's decimals."
sharesMinted: BigDecimal!
"The lot created by this deposit"
lot: CostBasisLot!
}
type TransferEvent @entity @immutable {
"Concatenation of txHash+logIdx"
id: Bytes!
block: BigInt!
"The log index of the transfer event"
logIndex: BigInt!
"The transaction the transfer event came from"
transaction: Transaction!
"The vault whose share token is being transferred"
vault: ERC4626Vault!
"The account sending the share token"
sender: Account!
"The account receiving the share token"
receiver: Account!
sharesTransferred: BigDecimal!
"The lot created by this transfer"
receiverLot: CostBasisLot!
"The sender's earnings"
senderEarnings: Earnings!
}
type WithdrawEvent @entity @immutable {
"Concatenation of txHash+logIdx"
id: Bytes!
block: BigInt!
"The log index of the withdraw event"
logIndex: BigInt!
"The transaction the withdraw event came from"
transaction: Transaction!
"The vault withdrawn from"
vault: ERC4626Vault!
"The account being withdrawn from"
account: Account!
"The address that initiated the deposit event (msg.sender)"
sender: Bytes!
"The amount of assets withdrawn. Normalized for the asset's decimals."
assetsWithdrawn: BigDecimal!
"The amount of shares redeemed. Normalized for the vault's decimals."
sharesRedeemed: BigDecimal!
"The earnings/profit/loss associated with the withdrawal"
earnings: Earnings!
}
"Entity for representing transactions"
type Transaction @entity @immutable {
"Transaction hash"
id: Bytes!
"Block number"
block: BigInt!
"Block timestamp"
timestamp: BigInt!
"tx.origin"
from: Bytes!
"Transaction Index"
index: BigInt!
"The deposit events from this transaction"
depositEvents: [DepositEvent!]! @derivedFrom(field: "transaction")
"The withdraw events from this transaction"
withdrawEvents: [WithdrawEvent!]! @derivedFrom(field: "transaction")
"The transfer events from this transaction"
transferEvents: [TransferEvent!]! @derivedFrom(field: "transaction")
}
type DebugMintEvent @entity @immutable {
id: Bytes!
txHash: Bytes!
blockNum: BigInt!
vault: Bytes!
receiver: Bytes!
amount: BigDecimal!
}
type VaultPerformanceSample @entity @immutable {
id: Bytes!
vault: ERC4626Vault!
block: BigInt!
timestamp: BigInt!
pricePerShare: BigDecimal!
estimatedApy: BigDecimal!
}