forked from AudiusProject/audius-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
470 lines (409 loc) · 11.3 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
type AudiusNetwork @entity {
"ID is set to 1"
id: ID!
# ==================== Addresses ====================
"audiusToken address"
audiusTokenAddress: Bytes
"claimsManager address"
claimsManagerAddress: Bytes
"delegateManager address"
delegateManagerAddress: Bytes
"governance address"
governanceAddress: Bytes
"registry address"
registry: Bytes
"serviceProviderFactory address"
serviceProviderFactoryAddress: Bytes
"serviceTypeManager address"
serviceTypeManagerAddress: Bytes
"staking address"
stakingAddress: Bytes
"registry address"
registryAddress: Bytes
# ==================== Token ====================
"Total supply of $AUDIO"
totalSupply: BigInt!
"Total amount of $AUDIO minted"
totalAUDIOMinted: BigInt!
"Total amount of $AUDIO burned"
totalAUDIOBurned: BigInt!
# ==================== Staking global aggregate values ====================
"Total amount of $AUDIO staked"
totalTokensStaked: BigInt
"Total tokens that are settled and claimable"
totalTokensClaimable: BigInt
"Total tokens that are currently locked or withdrawable in the network from unstaking/undelegating"
totalTokensLocked: BigInt
"Total delegated tokens in the protocol"
totalTokensDelegated: BigInt
# ==================== Delegate global aggregate values ====================
"The max number of delegators per service provider"
maxDelegators: BigInt
"The minimum amount needed to delegate"
minDelegationAmount: BigInt
"The minimum number of blocks the user must wait from requesting undelegation to evaluating"
undelegateLockupDuration: BigInt
"The minimum number of blocks the user must wait from requesting remove delegator to evaluating"
removeDelegatorLockupDuration: BigInt
"Evaluation period for a remove delegator request"
removeDelegatorEvalDuration: BigInt
# ==================== Service Provider Factory globals ====================
"Number of blocks a decrease stake request is in lockup before evaluation is allowed"
decreaseStakeLockupDuration: BigInt
"Number of blocks an update deployer cut request is in lockup before evaluation is allowed"
updateDeployerCutLockupDuration: BigInt
# ==================== Claims Manager globals ====================
""
fundingRoundBlockDiff: BigInt
""
fundingAmount: BigInt
""
recurringCommunityFundingAmount: BigInt
"address"
communityPoolAddress: Bytes
# ==================== Governance globals ====================
""
votingQuorumPercent: BigInt
""
votingPeriod: BigInt
""
executionDelay: BigInt
""
maxInProgressProposals: Int
""
guardianAddress: Bytes
# ==================== Helper for lockup event ====================
""
requestCount: BigInt!
totalStaked: BigInt!
}
type ServiceType @entity {
"The type of the service ie. creator-node"
id: ID!
"If the service is removed of not"
isValid: Boolean!
"Minimum Token Stake to run the service"
minStake: BigInt!
"Max Token Stake to run the service"
maxStake: BigInt!
versions: [ServiceTypeVersion!]! @derivedFrom(field: "serviceType")
}
type ServiceTypeVersion @entity {
id: ID!
serviceType: ServiceType!
serviceVersion: String!
blockNumber: BigInt!
}
type ServiceNode @entity {
"ID - generated from service-type and spID"
id: ID!
"Service provider ID - autoincrementing id created for each new service node"
spId: BigInt!
"Reference to user that registered this service"
owner: User!
"Reference to the service type"
type: ServiceType!
"URI to access the service node"
endpoint: String!
"Address used to confirm the ownership of the service node"
delegateOwnerWallet: Bytes!
"When the service node was created"
createdAt: Int!
"Boolean if th service is registered/deregistered"
isRegistered: Boolean!
}
type User @entity {
"Eth address of User"
id: ID!
"Token balance"
balance: BigInt!
"The total staked/delegated minus pending decrease stake/delegation"
totalClaimableAmount: BigInt!
"The total staked minus pending decrease stake"
claimableStakeAmount: BigInt!
"The total delegation received from other users minus their pending decrease delegation"
claimableDelegationReceivedAmount: BigInt!
"The total delegation sent to other users minus my own pending decrease delegation"
claimableDelegationSentAmount: BigInt!
"The total staked"
stakeAmount: BigInt!
"The total delegated"
delegationReceivedAmount: BigInt!
"The total delegation sent"
delegationSentAmount: BigInt!
"Boolean set to true if the user has stake or delegation"
hasStakeOrDelegation: Boolean!
"If the user's stake is between the min/max stake"
validBounds: Boolean
"The percentage of the claim from the delegator that the the deployer takes"
deployerCut: BigInt
"List of services operated by the user"
services: [ServiceNode!] @derivedFrom(field: "owner")
"Max stake of the user as determined by number of services and service types"
minAccountStake: BigInt
"Min stake of the user as determined by number of services and service types"
maxAccountStake: BigInt
# ===== Keep track of delegations to/from =====
"Reference to delegations (user & amount) sent by user"
delegateTo: [Delegate!] @derivedFrom(field: "fromUser")
"Reference to delegations (user & amount) received by user"
delegateFrom: [Delegate!] @derivedFrom(field: "toUser")
# ===== Keep track of pending events =====
"Reference to request to pending decrease stake"
pendingDecreaseStake: DecreaseStakeEvent
"DEPRECATED: Use event with service operator and delegator id"
pendingRemoveDelegator: RemoveDelegatorEvent
"Reference to request to update deployer cut"
pendingUpdateDeployerCut: UpdateDeployerCutEvent
"Reference to request to update undelegate stake"
pendingUndelegateStake: UndelegateStakeEvent
# ===== Keep track of governance events =====
"Reference to votes by the user"
votes: [Vote!] @derivedFrom(field: "voter")
createdAt: BigInt!
}
type Delegate @entity {
"ID - generated w/ the service provider's & delegator's addresses"
id: ID!
"The amount delegated minus the pending decrease delegation"
claimableAmount: BigInt!
"The amount delegated"
amount: BigInt!
"Reference to the user sending/delegating tokens"
fromUser: User!
"Reference to the user receiving delegation"
toUser: User!
}
# ==================== Delegation & Staking Event Mappings ==============================
enum LockupStatus {
Requested
Cancelled
Evaluated
}
interface LockupEvent {
id: ID!
status: LockupStatus!
owner: User!
expiryBlock: BigInt!
createdBlockNumber: BigInt!
endedBlockNumber: BigInt
}
type DecreaseStakeEvent implements LockupEvent @entity {
id: ID!
status: LockupStatus!
owner: User!
expiryBlock: BigInt!
createdBlockNumber: BigInt!
endedBlockNumber: BigInt
decreaseAmount: BigInt!
newStakeAmount: BigInt
}
type UpdateDeployerCutEvent implements LockupEvent @entity {
id: ID!
status: LockupStatus!
owner: User!
expiryBlock: BigInt!
createdBlockNumber: BigInt!
endedBlockNumber: BigInt
updatedCut: BigInt!
}
type RemoveDelegatorEvent implements LockupEvent @entity {
id: ID!
status: LockupStatus!
owner: User!
expiryBlock: BigInt!
createdBlockNumber: BigInt!
endedBlockNumber: BigInt
delegator: User!
}
type UndelegateStakeEvent implements LockupEvent @entity {
id: ID!
status: LockupStatus!
owner: User!
expiryBlock: BigInt!
createdBlockNumber: BigInt!
endedBlockNumber: BigInt
serviceProvider: User!
amount: BigInt!
}
# Regular events
type IncreasedStakeEvent @entity {
id: ID!
owner: User!
newStakeAmount: BigInt!
increaseAmount: BigInt!
blockNumber: BigInt!
}
type IncreaseDelegatedStakeEvent @entity {
id: ID!
delegator: User!
serviceProvider: User!
increaseAmount: BigInt!
blockNumber: BigInt!
}
type ClaimEvent @entity {
id: ID!
claimer: User!
rewards: BigInt!
newTotal: BigInt!
blockNumber: BigInt!
}
type SlashEvent @entity {
id: ID!
target: User!
amount: BigInt!
newTotal: BigInt!
blockNumber: BigInt!
}
type ClaimRound @entity {
"The round number"
id: ID!
fundAmount: BigInt!
blockNumber: BigInt!
}
type ClaimProcessedEvent @entity {
id: ID!
rewards: BigInt!
claimer: User!
oldTotal: BigInt!
newTotal: BigInt!
blockNumber: BigInt!
}
type RegisteredServiceProviderEvent @entity {
id: ID!
type: ServiceType!
spId: BigInt!
node: ServiceNode!
owner: User!
endpoint: String!
stakeAmount: BigInt!
blockNumber: BigInt!
}
type DeregisteredServiceProviderEvent @entity {
id: ID!
type: ServiceType!
spId: BigInt!
node: ServiceNode!
owner: User!
endpoint: String!
unstakeAmount: BigInt!
blockNumber: BigInt!
}
# ==================== Governance Proposals & Votes Event Mappings ==============================
# TODO: implement the enum by converting the raw event type to string enum
# Voting Events
enum VoteType {
None
Yes
No
}
# enum in sol
enum Outcome {
InProgress
Rejected
ApprovedExecuted
QuorumNotMet
ApprovedExecutionFailed
Evaluating
Vetoed
TargetContractAddressChanged
TargetContractCodeHashChanged
}
type Proposal @entity {
"Proposal ID from the event (auto-incrementing)"
id: ID!
"Proposal name"
name: String!
"Proposal description"
description: String!
"Reference to the user submitting the proposal"
proposer: User!
submissionBlockNumber: BigInt!
targetContractRegistryKey: Bytes!
targetContractAddress: Bytes!
callValue: BigInt!
functionSignature: String!
callData: Bytes!
"TODO: convert int to enum - Outcome"
outcome: Outcome
"Total vote weight for 'Yes'"
voteMagnitudeYes: BigInt!
"Total vote weight for 'No'"
voteMagnitudeNo: BigInt!
"Number of votes"
numVotes: BigInt!
"Reference to the votes - user & vote weight"
votes: [Vote!]! @derivedFrom(field: "proposal")
}
type Vote @entity {
"ID - generated from proposal id and user address"
id: ID!
"Reference to the proposal"
proposal: Proposal!
"TODO: update to enum - the voter's vote"
vote: VoteType
"The vote weight - the voter's claimable stake"
magnitude: BigInt!
"Reference the the user submitting the voter"
voter: User!
"The block number the vote was created"
createdBlockNumber: BigInt!
"The block number the vote was updated"
updatedBlockNumber: BigInt
}
type ProposalSubmittedEvent @entity {
id: ID!
proposal: Proposal!
proposer: User!
name: String!
description: String!
}
type ProposalVoteSubmittedEvent @entity {
id: ID!
proposal: Proposal!
voter: User!
vote: Vote!
currentVote: VoteType!
voterStake: BigInt!
blockNumber: BigInt!
}
type ProposalVoteUpdatedEvent @entity {
id: ID!
proposal: Proposal!
voter: User!
vote: Vote!
voterStake: BigInt!
currentVote: VoteType!
previousVote: VoteType!
blockNumber: BigInt!
}
type ProposalOutcomeEvaluatedEvent @entity {
id: ID!
proposal: Proposal!
outcome: Outcome
voteMagnitudeYes: BigInt!
voteMagnitudeNo: BigInt!
numVotes: BigInt!
blockNumber: BigInt!
}
type ProposalTransactionExecutedEvent @entity {
id: ID!
proposal: Proposal!
success: Boolean!
returnData: Bytes
blockNumber: BigInt!
}
type GuardianTransactionExecutedEvent @entity {
id: ID!
targetContractAddress: Bytes!
callValue: BigInt!
functionSignature: String!
callData: Bytes!
returnData: Bytes!
blockNumber: BigInt!
}
type ProposalVetoedEvent @entity {
id: ID!
proposal: Proposal!
blockNumber: BigInt!
}