forked from 0xNSHuman/frabric-subgraph-rinkeby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.graphql
488 lines (419 loc) · 9.99 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
# Thread (a Frabric DAO)
type Thread @entity {
id: ID!
contract: Bytes!
variant: Int!
frabric: Frabric!
governor: Bytes!
erc20: FrabricERC20!
descriptor: Bytes!
descriptorChangeProposals: [DesriptorChangeProposal!]! @derivedFrom(field: "thread")
upgradeProposals: [UpgradeProposal!]! @derivedFrom(field: "thread")
tokenActionProposals: [TokenActionProposal!]! @derivedFrom(field: "thread")
participantRemovalProposals: [ParticipantRemovalProposal!]! @derivedFrom(field: "thread")
frabricChangeProposals: [FrabricChangeProposal!]! @derivedFrom(field: "thread")
governorChangeProposals: [GovernorChangeProposal!]! @derivedFrom(field: "thread")
ecosystemLeaveProposals: [EcosystemLeaveWithUpgradesProposal!]! @derivedFrom(field: "thread")
dissolutionProposals: [DissolutionProposal!]! @derivedFrom(field: "thread")
}
type DesriptorChangeProposal @entity {
id: ID!
thread: Thread!
descriptor: Bytes!
baseProposal: BaseProposal!
}
type FrabricChangeProposal @entity {
id: ID!
thread: Thread!
frabric: Bytes!
governor: Bytes!
baseProposal: BaseProposal!
}
type GovernorChangeProposal @entity {
id: ID!
thread: Thread!
governor: Bytes!
baseProposal: BaseProposal!
}
type EcosystemLeaveWithUpgradesProposal @entity {
id: ID!
thread: Thread!
frabric: Bytes!
governor: Bytes!
baseProposal: BaseProposal!
}
type DissolutionProposal @entity {
id: ID!
thread: Thread!
token: Bytes!
price: BigInt!
baseProposal: BaseProposal!
}
enum ThreadProposalType {
DescriptorChange
FrabricChange
GovernorChange
EcosystemLeaveWithUpgrades
Dissolution
}
# Frabric (a Frabric DAO)
type Frabric @entity {
id: ID!
token: FrabricERC20!
participants: [FrabricParticipantRecord!]! @derivedFrom(field: "frabric")
governorStatuses: [GovernorStatusRecord!]! @derivedFrom(field: "frabric")
threads: [Thread!]! @derivedFrom(field: "frabric")
threadProposals: [ThreadProposal!]! @derivedFrom(field: "frabric")
participantProposals: [ParticipantProposal!]! @derivedFrom(field: "frabric")
upgradeProposals: [UpgradeProposal!]! @derivedFrom(field: "frabric")
tokenActionProposals: [TokenActionProposal!]! @derivedFrom(field: "frabric")
participantRemovalProposals: [ParticipantRemovalProposal!]! @derivedFrom(field: "frabric")
bondRemovalProposals: [BondRemovalProposal!]! @derivedFrom(field: "frabric")
threadProposalProposals: [ThreadProposalProposal!]! @derivedFrom(field: "frabric")
paperProposals: [PaperProposal!]! @derivedFrom(field: "frabric")
vouchers: [Voucher!]! @derivedFrom(field: "frabric")
}
type FrabricParticipantRecord @entity {
id: ID!
frabric: Frabric!
address: Bytes!
type: ParticipantType!
}
type GovernorStatusRecord @entity {
id: ID!
frabric: Frabric!
address: Bytes!
status: GovernorStatus!
}
enum GovernorStatus {
Null
Active
Removed
}
type ThreadProposal @entity {
id: ID!
frabric: Frabric!
governor: Bytes!
name: String!
symbol: String!
descriptor: Bytes!
data: Bytes! # Not sure if this is any useful here
baseProposal: BaseProposal!
}
type ParticipantProposal @entity {
id: ID!
frabric: Frabric!
proposer: Bytes!
participant: Bytes!
participantType: String!
baseProposal: BaseProposal!
}
type BondRemovalProposal @entity {
id: ID!
frabric: Frabric!
participant: Bytes!
slash: Boolean!
amount: BigInt!
baseProposal: BaseProposal!
}
type ThreadProposalProposal @entity {
id: ID!
frabric: Frabric!
thread: Bytes!
info: Bytes!
baseProposal: BaseProposal!
}
type Voucher @entity {
id: ID!
frabric: Frabric!
signer: Bytes!
participant: Bytes!
}
enum FrabricProposalType {
Participant
RemoveBond
Thread
ThreadProposal
}
enum ParticipantType {
Null
Removed
Genesis
KYC
Governor
Voucher
Individual
Corporation
}
# Frabric DAO (a DAO)
## Note: the types below are shared by Frabric and Thread types
# which are both kinds of Frabric DAO. Because of that each object of the
# types below can reference either 'frabric' or 'thread' as its parent.
# This could be done using an abstract type instead of having these two fields
# with one of them always null for obvious reasons. However in the current implementation
# a choice was made to keep two weak references to the concrete types.
type UpgradeProposal @entity {
id: ID!
frabric: Frabric
thread: Thread
beacon: Bytes!
instance: Bytes!
version: BigInt!
code: Bytes!
data: Bytes!
baseProposal: BaseProposal!
}
type TokenActionProposal @entity {
id: ID!
frabric: Frabric
thread: Thread
token: Bytes!
target: Bytes!
mint: Boolean!
price: BigInt!
amount: BigInt!
baseProposal: BaseProposal!
}
type ParticipantRemovalProposal @entity {
id: ID!
frabric: Frabric
thread: Thread
participant: Bytes!
removalFee: Int!
baseProposal: BaseProposal!
}
type PaperProposal @entity {
id: ID!
frabric: Frabric
thread: Thread
baseProposal: BaseProposal!
}
enum CommonProposalType {
Paper
Upgrade
TokenAction
ParticipantRemoval
}
# DAO
type BaseProposal @entity {
id: ID!
proposalId: String!
thread: Thread
frabric: Frabric
creator: Bytes!
## Note: This can be either a CommonProposalType or a ThreadProposalType
# The frontend is supposed to define the correct enums / constants locally
# Please refer to the smart-contract definitions for the types mentioned above
# to see how they are encoded
## TODO: Handle this in the subgraph mapping
type: Int!
state: ProposalState!
votes: [Vote!]! @derivedFrom(field: "proposal")
info: Bytes!
supermajority: Boolean!
startTimestamp: Int!
endTimestamp: Int!
}
type Vote @entity {
id: ID!
proposal: BaseProposal!
voter: Bytes!
voteDirection: VoteDirection!
count: BigInt!
}
enum ProposalState {
Null
Active
Queued
Executed
Cancelled
}
enum VoteDirection {
Yes
No
Abstain
}
# Crowdfund
type Crowdfund @entity {
id: ID!
state: CrowdfundState!
amountDeposited: BigInt!
target: BigInt!
thread: Thread!
deposits: [CrowdfundDeposit!]! @derivedFrom(field: "crowdfund")
withdrawals: [CrowdfundWithdrawal!]! @derivedFrom(field: "crowdfund")
distributions: [CrowdfundDistribution!]! @derivedFrom(field: "crowdfund")
}
type CrowdfundDeposit @entity {
id: ID!
crowdfund: Crowdfund!
depositor: Bytes!
amount: BigInt!
}
type CrowdfundWithdrawal @entity {
id: ID!
crowdfund: Crowdfund!
depositor: Bytes!
amount: BigInt!
}
type CrowdfundDistribution @entity {
id: ID!
crowdfund: Crowdfund!
distribution: Distribution!
}
enum CrowdfundState {
Active
Executing
Refunding
Finished
}
# Auction
type Auction @entity {
id: ID!
seller: Bytes!
token: Bytes!
traded: Bytes!
totalAmount: BigInt!
start: Int! # TODO: Make sure this accommodates 64 bit
length: Int!
batches: [AuctionBatch!]! @derivedFrom(field: "auction")
}
type AuctionBatch @entity {
id: ID!
auction: Auction!
bids: [Bid!]! @derivedFrom(field: "auctionBatch")
isComplete: Boolean!
}
type Bid @entity {
id: ID!
auctionBatch: AuctionBatch!
bidder: Bytes!
amount: BigInt!
}
# ERC-20
type FrabricERC20 @entity {
id: ID!
name: String!
symbol: String!
decimals: Int!
supply: BigInt!
tradeToken: Bytes!
globalAcceptance: Boolean!
whitelist: [WhitelistRecord!]! @derivedFrom(field: "frabricERC20")
freezelist: [FreezeRecord!]! @derivedFrom(field: "frabricERC20")
orderBook: [PricePoint!]! @derivedFrom(field: "frabricERC20")
executedOrders: [ExecutedOrder!]! @derivedFrom(field: "frabricERC20")
balances: [FrabricERC20Balance!]! @derivedFrom(field: "frabricERC20")
}
type FrabricERC20Holder @entity {
id: ID!
balances: [FrabricERC20Balance!]! @derivedFrom(field: "holder")
transferFromEvents: [FrabricERC20Transfer!]! @derivedFrom(field: "from")
transferToEvents: [FrabricERC20Transfer!]! @derivedFrom(field: "to")
}
type FrabricERC20Balance @entity {
id: ID!
frabricERC20: FrabricERC20!
holder: FrabricERC20Holder!
amount: BigInt!
transfersFrom: [FrabricERC20Transfer!]! @derivedFrom(field: "fromBalance")
transfersTo: [FrabricERC20Transfer!]! @derivedFrom(field: "toBalance")
}
type FrabricERC20Transfer @entity {
id: ID!
timestamp: BigInt!
frabricERC20: FrabricERC20!
from: FrabricERC20Holder
fromBalance: FrabricERC20Balance
to: FrabricERC20Holder
toBalance: FrabricERC20Balance
amount: BigInt!
}
# Distribution
type Distribution @entity {
id: ID!
token: Bytes!
amount: BigInt!
claims: [Claim!]! @derivedFrom(field: "distribution")
}
type Claim @entity {
id: ID!
distribution: Distribution!
person: Bytes!
amount: BigInt!
}
# Whitelist
# TODO: Add support for global whitelist
type WhitelistRecord @entity {
id: ID!
frabricERC20: FrabricERC20!
person: Bytes!
kycHash: Bytes
removed: Boolean
}
## Note: This is how the contract manages the whitelist state
# The UI doesn't really have to follow this pattern
# Leaving it here for reference
# enum WhitelistStatus {
# Null
# Removed
# Whitelisted
# KYC
# }
# Freezelist
type FreezeRecord @entity {
id: ID!
frabricERC20: FrabricERC20!
person: Bytes!
frozenUntil: Int # TODO: Make sure this accommodates 64 bit
}
# Exchange
## Note: This type can help the frontend get an idea about
# the available liquidity below/above a certain price
# which is informative for buyers and sellers making decisions
type PricePoint @entity {
id: ID!
frabricERC20: FrabricERC20!
price: BigInt!
type: OrderType!
totalAmount: BigInt!
}
## Note: This type describes an atomic order history item.
type ExecutedOrder @entity {
id: ID!
frabricERC20: FrabricERC20!
blockTimestamp: Int!
orderer: Bytes!
executor: Bytes!
price: BigInt!
amount: BigInt!
}
enum OrderType {
Null
Buy
Sell
}
# Bonds
type Bond @entity {
id: ID!
holdings: [BondHoldings!]! @derivedFrom(field: "bond")
}
type BondHoldings @entity {
id: ID!
bond: Bond!
governor: Bytes!
amount: BigInt!
}
type BondDistribution @entity {
id: ID!
bond: Bond!
distribution: Distribution!
}
# Timelocks
type Timelock @entity {
id: ID!
timestamp: Int!
token: Bytes!
months: Int!
amountClaimed: BigInt!
}