-
Notifications
You must be signed in to change notification settings - Fork 15
/
schema.graphql
776 lines (645 loc) · 18.5 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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
type Token @entity {
id: ID!
symbol: String
name: String
decimals: Int!
address: String!
cap: BigDecimal
supply: BigDecimal
isDatatoken: Boolean!
"address of ERC721 that owns the token, valid only for datatokens"
nft: Nft
"array of addresses with minter role"
minter: [String!]
"array of addresses with payment manager minter role"
paymentManager: [String!]
"address that collects the payments (NOT fees)"
paymentCollector: String
"address of the market where the datatoken was created. This address collects market fees."
publishMarketFeeAddress: String
"adreess of fee token (can be Ocean, ETH, etc.)"
publishMarketFeeToken: String
"fee amount. Fixed value."
publishMarketFeeAmount: BigDecimal
"template ID of the datatoken"
templateId: BigInt!
"number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts"
holderCount: BigInt!
"number of orders executed for this datatoken"
orderCount: BigInt!
"orders created with the datatoken, only available for datatokens"
orders: [Order!] @derivedFrom(field:"datatoken")
"fixed rate exchanges, only available for datatokens"
fixedRateExchanges: [FixedRateExchange!] @derivedFrom(field:"datatoken")
"dispensers using this token"
dispensers: [Dispenser!] @derivedFrom(field:"token")
"block time datatoken was created"
createdTimestamp: Int!
"datatoken creation transaction id"
tx: String!
eventIndex: Int!
"block number when it was created"
block: Int!
lastPriceToken: Token
lastPriceValue: BigDecimal!
}
"utility type"
type TokenValuePair @entity {
"address of the token"
id : ID!
token : Token!
value : BigDecimal!
}
type Nft @entity{
"nft address"
id: ID!
symbol: String!
name: String!
tokenUri: String
"address of the owner of the nft"
owner: User!
"address of the creator of the nft"
creator: User!
"same as id, it's just for easy discoverability"
address: String!
"provider url that can decrypt the ddo"
providerUrl: String
"state of the asset (described in docs)"
assetState: Int!
managerRole: [String!]
erc20DeployerRole: [String!]
storeUpdateRole: [String!]
"addresses that can update the metadata"
metadataRole: [String!]
"template address"
template: String!
"template ID of the datatoken"
templateId: Int
"set if NFT is transferable"
transferable: Boolean!
"block time nft was created"
createdTimestamp: Int!
"nft creation transaction id"
tx: String!
eventIndex: Int!
"block number when it was created"
block: Int
"number of orders executed for all underlying datatokens"
orderCount: BigInt!
"has metadata"
hasMetadata: Boolean!
nftData: [NftData!] @derivedFrom(field: "nft")
transferHistory: [NftTransferHistory!] @derivedFrom(field: "nft")
}
type NftData @entity{
"nft address+key"
id: ID!
nft: Nft!
key: Bytes
value: Bytes
}
type OrderReuse @entity {
id: ID!
order: Order!
caller: String!
createdTimestamp: Int!
tx: String!
eventIndex: Int!
block: Int!
providerFee: String
providerFeeValidUntil: BigInt
"gas price in Wei"
gasPrice: BigInt
gasUsed: BigDecimal
}
type Order @entity {
"transaction hash - token address - from address - eventIndex"
id: ID!
datatoken: Token!
consumer: User!
payer: User!
amount: BigDecimal!
serviceIndex: Int!
nftOwner: User!
# the fees will be updated from an event that will be created after (todo)
publishingMarket: User
publishingMarketToken: Token #
publishingMarketAmmount: BigDecimal #call contract to get fee amount
providerFee: String
providerFeeValidUntil: BigInt
consumerMarket: User
consumerMarketToken: Token #
consumerMarketAmmount: BigDecimal #call contract to get fee amount
reuses: [OrderReuse!] @derivedFrom(field: "order")
createdTimestamp: Int!
tx: String!
eventIndex: Int!
block: Int!
lastPriceToken: Token
lastPriceValue: BigDecimal!
estimatedUSDValue: BigDecimal!
gasUsed: BigDecimal
"gas price in Wei"
gasPrice: BigInt
}
type User @entity {
id: ID!
tokenBalancesOwned: [TokenValuePair!]
orders: [Order!] @derivedFrom(field: "payer")
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
"total number of orders made by this user"
totalOrders: BigInt!
"total number of orders made on assets owned by this user"
totalSales: BigInt!
}
type FixedRateExchange @entity {
"fixed rate exchange id"
id: ID!
contract: String!
exchangeId: String!
owner: User!
datatoken: Token!
baseToken: Token!
"amount of datatokens available to be sold, this is relevant if the exchange is not able to mint"
datatokenSupply: BigDecimal!
"amount of basetokens available to be collected by the owner"
baseTokenSupply: BigDecimal!
datatokenBalance: BigDecimal!
baseTokenBalance: BigDecimal!
price: BigDecimal!
active: Boolean!
"amount of total basetokens spent"
totalSwapValue: BigDecimal!
"address that is allowed to swap tokens"
allowedSwapper: String
"if the owner allowes the fre to mint"
withMint: Boolean
"if the fre has the minter role on the datatoken"
isMinter: Boolean
updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId")
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
createdTimestamp: Int!
tx: String!
eventIndex: Int!
block: Int!
"address of the market where the datatoken was created. This address collects market fees."
publishMarketFeeAddress: String
"fee amount. Fixed value"
publishMarketSwapFee: BigDecimal
}
type FixedRateExchangeUpdate @entity {
id: ID!
exchangeId: FixedRateExchange!
oldPrice: BigDecimal
newPrice: BigDecimal
oldActive: Boolean
newActive: Boolean
oldAllowedSwapper: String
newAllowedSwapper: String
block: Int!
createdTimestamp: Int!
tx: String!
eventIndex: Int!
}
type FixedRateExchangeSwap @entity {
id: ID!
exchangeId: FixedRateExchange!
by: User!
baseTokenAmount: BigDecimal!
dataTokenAmount: BigDecimal!
block: Int!
createdTimestamp: Int!
tx: String!
eventIndex: Int!
oceanFeeAmount: BigDecimal!
marketFeeAmount: BigDecimal!
consumeMarketFeeAmount: BigDecimal!
}
type Dispenser @entity {
"token address"
id: ID!
contract: String!
active: Boolean!
"if using the enterprise template the owner will always be the erc721 factory, for normal template it will a user"
owner: String
token: Token!
allowedSwapper: String
isMinter: Boolean
"max tokens that can be dispensed"
maxTokens: BigDecimal!
"max balance of requester. If the balance is higher, the dispense is rejected"
maxBalance: BigDecimal!
"how many tokens are left"
balance: BigDecimal!
block: Int!
createdTimestamp: Int!
tx: String!
eventIndex: Int!
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenser")
}
type DispenserTransaction @entity {
id: ID!
dispenser: Dispenser!
user: User!
amount: BigDecimal!
block: Int!
createdTimestamp: Int!
tx: String!
eventIndex: Int!
}
"utility type"
type GlobalTotalLiquidityPair @entity {
"address of the token"
id : ID!
globalStatistic: GlobalStatistic!
token : Token!
value : BigDecimal!
}
"utility type"
type GlobalTotalFixedSwapPair @entity {
"address of the token"
id : ID!
globalStatistic: GlobalStatistic!
token : Token!
value : BigDecimal!
count: BigInt!
}
type GlobalStatistic @entity {
id: ID!
"total swap volume for each base token in fixed rate exchanges"
totalFixedSwapVolume: [GlobalTotalFixedSwapPair!] @derivedFrom(field: "globalStatistic")
"number of total orders. fixed rate exchange orders + dispenser orders"
orderCount: Int!
"total nfts(erc721) created"
nftCount: Int!
"total datatokens (tokens with isDatatoken = true) created"
datatokenCount:Int!
"number of fixed rate exchanges"
fixedCount: Int!
"number of dispensers created"
dispenserCount: Int!
"total ocean locked in veOcean"
totalOceanLocked:BigDecimal!
"current version"
version: String
}
type OPC @entity {
id: ID!
"fee in percent for swaps involving OPC approved tokens"
swapOceanFee: BigDecimal
"fee in percent for swaps involving non OPC approved tokens"
swapNonOceanFee: BigDecimal
"fee in percent taken by OPC from orderFees"
orderFee: BigDecimal
"fee in percent taken by OPC from providerFees"
providerFee: BigDecimal
approvedTokens: [Token!]
}
enum NftUpdateType {
METADATA_CREATED,
METADATA_UPDATED,
STATE_UPDATED,
TOKENURI_UPDATED
}
type NftUpdate @entity {
id: ID! # update tx + nft address
tokenUri: String
nft: Nft!
"provider url that can decrypt the ddo"
providerUrl: String
"user that made the update"
userAddress: String!
"state of the asset in this update"
assetState: Int!
"type of the update: metadata created, metadata update, state update, token uri update"
type: NftUpdateType!
block: Int!
timestamp: Int!
tx: String!
eventIndex: Int!
}
type Template @entity{
id: ID!
fixedRateTemplates: [String!]
dispenserTemplates: [String!]
}
# Not tracking allocationToId or idToAllocation
type VeAllocateUser @entity{
"id = {user}"
id: ID!
veAllocation: [VeAllocation!] @derivedFrom(field: "allocationUser")
allocatedTotal: BigDecimal!
block: Int!
firstContact: Int!
lastContact: Int!
tx: String!
eventIndex: Int!
veOcean: VeOCEAN!
}
type VeAllocateId @entity{
"id = {DataNFT Address}-{chain id}"
id: ID!
nftAddress: String!
chainId: BigInt!
veAllocation: [VeAllocation!] @derivedFrom(field: "allocationId")
allocatedTotal: BigDecimal!
block: Int!
firstContact: Int!
lastContact: Int!
tx: String!
eventIndex: Int!
}
# we need to track allocation of user to id
type VeAllocation @entity {
"id = {user}-{DataNFT Address}-{chain id}"
id: ID!
allocationUser: VeAllocateUser!
allocationId: VeAllocateId!
updates: [VeAllocationUpdate!] @derivedFrom(field: "veAllocation")
allocated: BigDecimal!
chainId: BigInt!
nftAddress: String!
block: Int!
firstContact: Int!
lastContact: Int!
tx: String!
eventIndex: Int!
}
enum veAllocationUpdateType {
SET,
REMOVED
}
type VeAllocationUpdate @entity {
"{tx}-{VeAllocation id}-{eventIndex}"
id: ID!
veAllocation: VeAllocation!
type: veAllocationUpdateType!
allocatedTotal: BigDecimal!
block: Int!
timestamp: Int!
tx: String!
eventIndex: Int!
}
type VeDelegation @entity {
"id = VeDelegation contract + tokenId"
id: ID!
delegator: VeOCEAN!
receiver: VeOCEAN!
tokenId: BigInt!
amount: BigDecimal!
lockedAmount: BigDecimal!
timeLeftUnlock: Int!
cancelTime: BigInt!
expireTime: BigInt!
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
}
type VeDelegationUpdate @entity {
"id = {tx}-{eventIndex}"
id: ID!
block: Int!
timestamp: Int!
tx: String!
eventIndex: Int!
sender: String!
amount: BigDecimal!
cancelTime: BigInt!
expireTime: BigInt!
"type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2"
type:Int!
veDelegation:VeDelegation!
}
type VeOCEAN @entity {
"id = {user address}"
id: ID!
"total amount of locked tokens"
lockedAmount: BigDecimal!
"unlock timestamp"
unlockTime: BigInt!
delegation: [VeDelegation!] @derivedFrom(field: "delegator")
delegates: [VeDelegation!] @derivedFrom(field: "receiver")
deposits: [VeDeposit!] @derivedFrom(field: "veOcean")
claims: [VeClaim!] @derivedFrom(field: "veOcean")
allocation: VeAllocateUser @derivedFrom(field: "veOcean")
block: Int!
}
type VeDeposit @entity {
"id = {user address}-{tx}-{eventIndex}"
id: ID!
"veOcean holder"
provider:String!
"who initiated the tx"
sender: String!
"amount of tokens locked"
value: BigDecimal!
"unlock timestamp"
unlockTime: BigInt!
"deposit type: DEPOSIT_FOR = 0, CREATE_LOCK_TYPE = 1,INCREASE_LOCK_AMOUNT = 2,INCREASE_UNLOCK_TIME = 3, WITHDRAW = 4"
type:BigInt!
timestamp: BigInt!
block: Int!
tx: String!
eventIndex: Int!
veOcean: VeOCEAN!
totalOceanLocked:BigDecimal!
}
type VeFeeDistributor @entity {
"id = contract address"
id: ID!
"token used by FeeDistributor"
token: Token!
claims: [VeClaim!] @derivedFrom(field: "VeFeeDistributor")
checkpoints: [VeFeeDistributorCheckPoint!] @derivedFrom(field: "VeFeeDistributor")
}
type VeFeeDistributorCheckPoint @entity {
"id = {tx}-{eventno}"
id: ID!
"amount of tokens for rewards"
tokens: BigDecimal!
"who initiated the tx"
sender: String!
VeFeeDistributor: VeFeeDistributor!
timestamp: BigInt!
block: Int!
tx: String!
eventIndex: Int!
}
type VeClaim @entity {
"id = {tx}-{eventno}"
id: ID!
"amount of tokens claimed"
amount: BigDecimal!
"claim epoch"
claim_epoch: BigInt
"max_epoch"
max_epoch: BigInt
timestamp: BigInt!
block: Int!
tx: String!
eventIndex: Int!
veOcean: VeOCEAN!
VeFeeDistributor: VeFeeDistributor!
}
enum DFHistoryType {
Allocated,
Claimed
}
type DFAvailableClaim @entity {
"id = {userId}-{tokenId}"
id: ID!
receiver: DFReward!
amount: BigDecimal!
token: Token!
}
type DFHistory @entity {
"id = {user-id}-{txId}-{eventId}"
id: ID!
receiver: DFReward!
amount: BigDecimal!
token: Token!
type: DFHistoryType!
timestamp: BigInt!
block: Int!
tx: String!
eventIndex: Int!
}
type DFReward @entity {
"id = {user address}"
id: ID!
receiver: User!
availableClaims: [DFAvailableClaim!] @derivedFrom(field: "receiver")
history: [DFHistory!] @derivedFrom(field: "receiver")
}
type NftTransferHistory @entity {
# ID = hash(nftAddress+txId+eventNumber)
id: ID!
nft: Nft!
oldOwner: User!
newOwner: User!
txId: String
eventIndex: Int!
timestamp: Int!
block: Int!
}
type Erc721Template @entity {
#ID = template address
id: ID!
templateId: BigInt!
}
type Erc20Template @entity {
#ID = template address
id: ID!
templateId: BigInt!
}
type PredictSubscription @entity{
"id = {contract address}-{txid}-{eventIndex}"
id: ID!
predictContract: PredictContract!
user: User!
expireTime: BigInt!
"txId"
txId: String
eventIndex:Int!
timestamp: Int!
block: Int!
}
enum PredictSlotStatus {
Pending,
Paying,
Canceled
}
type PredictPayout @entity{
"id = {contract address}-{slot}-{user}"
id: ID!
prediction: PredictPrediction!
payout: BigDecimal!
predictedValue: Boolean!
trueValue: Boolean!
aggregatedPredictedValue: BigDecimal!
"txId"
txId: String
eventIndex:Int!
timestamp: Int!
block: Int!
}
type PredictPrediction @entity{
"id = {contract address}-{slot}-{user}"
id: ID!
slot: PredictSlot!
user: User!
stake: BigDecimal!
payout: PredictPayout
"txId"
txId: String
eventIndex:Int!
timestamp: Int!
block: Int!
}
type PredictTrueVal @entity{
"id = {contract address}-{slot}"
id: ID!
slot: PredictSlot!
trueValue: Boolean!
"txId"
txId: String
eventIndex:Int!
timestamp: Int!
block: Int!
}
type PredictionRevenue @entity{
"id = {contract address}-{slot}-{txid}-{eventIndex}"
id: ID!
slot: PredictSlot!
amount: BigDecimal!
"txId"
txId: String
eventIndex:Int!
timestamp: Int!
block: Int!
}
type PredictSlot @entity{
"id = {contract address}-{slot}"
id: ID!
predictContract: PredictContract!
slot: Int!
predictions:[PredictPrediction!] @derivedFrom(field: "slot")
trueValues: [PredictTrueVal!] @derivedFrom(field: "slot")
revenue: BigDecimal!
revenues: [PredictionRevenue!] @derivedFrom(field: "slot")
status: PredictSlotStatus!
roundSumStakesUp: BigDecimal!
roundSumStakes: BigDecimal!
}
type PredictSettingUpdate @entity{
"id = {contract address}-{txId}-{eventIndex}"
id: ID!
predictContract: PredictContract!
secondsPerEpoch: BigInt!
secondsPerSubscription: BigInt!
truevalSubmitTimeout: BigInt!
stakeToken: Token
"txId"
txId: String
eventIndex:Int!
timestamp: Int!
block: Int!
}
type PredictContract @entity{
"id = {contract address}"
id: ID!
token: Token!
paused: Boolean!
slots: [PredictSlot!] @derivedFrom(field: "predictContract")
settingUpdates: [PredictSettingUpdate!] @derivedFrom(field: "predictContract")
subscriptions: [PredictSubscription!] @derivedFrom(field: "predictContract")
secondsPerEpoch: BigInt!
secondsPerSubscription: BigInt!
truevalSubmitTimeout: BigInt!
stakeToken: Token
"creation txId"
txId: String
"timestamp of creation tx"
timestamp: Int!
"block of creation tx"
block: Int!
eventIndex: Int!
}