-
Notifications
You must be signed in to change notification settings - Fork 43
/
schema.graphql
396 lines (359 loc) · 10.1 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
##### 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. balanceTokensInvested, balanceTokensIdle)
# * delta - indicates this value is the difference between the prior state and the current state (e.g. deltaPricePerShare)
# Use plurals when referring to Tokens or Shares (e.g. totalShares, balanceTokens)
type Transaction @entity {
"Transaction-log"
id: ID!
"The event name"
event: String!
"The transaction sender"
from: Bytes!
"Gas price used in the transaction"
gasPrice: BigInt!
"Gas sent used in the transaction"
gasSent: 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!
"Contract address that emitted the event"
contract: Bytes!
"Timestamp when the transaction was executed"
timestamp: BigInt!
"Gas limit used in the transaction"
gasLimit: 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!
}
enum VaultClassification {
Endorsed
Experimental
}
## 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!
# }
# TODO:
# emergency shutdown
# withdrawal queue
type Vault @entity {
"Vault address"
id: ID!
"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
"All Vault Updates"
historicalUpdates: [VaultUpdate!]! @derivedFrom(field: "vault")
"Strategies for this Vault"
strategies: [Strategy!]! @derivedFrom(field: "vault")
"Token deposits into the Vault"
deposits: [Deposit!]! @derivedFrom(field: "vault")
"Token withdrawals from the Vault"
withdrawals: [Withdrawal!]! @derivedFrom(field: "vault")
"Transfers of Vault Shares"
transfers: [Transfer!]! @derivedFrom(field: "vault")
"Ethereum Transaction"
transaction: Transaction!
"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
"Balance of Tokens invested into Strategies"
balanceTokensInvested: BigInt!
"Deposit limit for Tokens in the Vault"
tokensDepositLimit: BigInt!
"Current supply of Shares"
sharesSupply: BigInt!
"Management fee in basis points"
managementFeeBps: Int!
"Performance fee in basis points"
performanceFeeBps: Int!
# TODO: refactor these fields out into vault release entity
# release fields temporary for MVP
"Creation timestamp"
activation: BigInt!
"The API version."
apiVersion: String!
}
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
"Tokens Deposited"
tokensDeposited: BigInt!
"Tokens Withdrawn"
tokensWithdrawn: BigInt!
"Sum of Shares minted over all time"
sharesMinted: BigInt!
"Sum of Shares burnt over all time"
sharesBurnt: BigInt!
### PERFORMANCE
"Current price per full share"
pricePerShare: BigInt!
"Returns generated in Tokens"
returnsGenerated: BigInt!
"Total fees in Shares" # in this VaultUpdate
totalFees: BigInt!
"Management fees in Shares"
managementFees: BigInt!
"Performance fees in Shares"
performanceFees: BigInt!
"Strategist fees in Shares"
strategistFees: BigInt!
}
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!
"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!
"Account making Deposit"
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"
amount: BigInt!
"Vault Token"
token: Token!
"Number of Tokens redeemable for shares transferred"
tokenAmount: BigInt!
"Timestamp of Transfer"
timestamp: BigInt!
"Block number of Transfer"
blockNumber: BigInt!
"Ethereum Transaction"
transaction: Transaction!
}
type AccountVaultPosition @entity {
"Account-Vault"
id: ID!
"Vault"
vault: Vault!
"Account"
account: Account!
"Vault token"
token: Token!
"Vault share token"
shareToken: Token!
"Latest account update for this Vault"
latestUpdate: AccountVaultPositionUpdate!
"Account updates over time"
historicalUpdates: [AccountVaultPositionUpdate!]!
"Share balance"
balanceShares: BigInt!
"Token balance"
balanceTokens: BigInt!
}
type AccountVaultPositionUpdate @entity {
"Account-Transaction-Log"
id: ID!
"Timestamp"
timestamp: BigInt!
"Block number"
blockNumber: BigInt!
"The Account this update applies to"
account: Account!
"Token deposits"
deposits: BigInt!
"Token withdrawals"
withdrawals: BigInt!
"Share tokens minted"
sharesMinted: BigInt!
"Share tokens burnt"
sharesBurnt: BigInt!
"Tokens sent"
tokensSent: BigInt!
"Tokens received"
tokensReceived: BigInt!
"Share tokens sent"
sharesSent: BigInt!
"Share tokens received"
sharesReceived: BigInt!
"Ethereum Transaction"
transaction: Transaction!
"Vault Update"
vaultUpdate: VaultUpdate!
}
enum StrategyStatus {
Active
Retired
}
type Strategy @entity {
"The Strategy ID."
id: ID!
"Ethereum Transaction"
transaction: Transaction!
"The Strategy address."
address: Bytes!
"The Vault"
vault: Vault!
"Defines the maximum borrow amount."
debtLimit: BigInt!
"It is the current rate limit. It increases/decreases per block."
rateLimit: BigInt!
"Defines the strategist's fee (basis points)."
performanceFeeBps: Int!
"Blocknumber the vault information was most recently updated."
blockNumber: BigInt!
"Timestamp the vault information was most recently updated."
timestamp: BigInt!
"The reports created by this strategy."
reports: [StrategyReport!]!
"The latest report for this Strategy"
latestReport: StrategyReport
"harvest() calls"
harvests: [Harvest!]! @derivedFrom(field: "strategy")
}
type StrategyReport @entity {
"The Strategy Report ID."
id: ID!
"Ethereum Transaction"
transaction: Transaction!
"The Strategy reference."
strategy: Strategy! @relation
"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!
"Blocknumber the strategy report was most recently updated."
blockNumber: BigInt!
"Timestamp the strategy report was most recently updated."
timestamp: BigInt!
# "Vault state"
# vaultUpdate: VaultUpdate!
#### 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 Harvest @entity {
"Strategy-Transaction-Log"
id: ID!
vault: Vault!
strategy: Strategy!
"Function caller"
harvester: Bytes!
"The reported gain amount for the strategy at the time of the harvest."
gain: 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!
timestamp: BigInt!
blockNumber: BigInt!
}