-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.graphql
755 lines (675 loc) · 18.7 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
################################################################
## Cross events schemas
################################################################
#####################
## Enums
#####################
enum AdProposalStatus {
CURRENT_ACCEPTED
CURRENT_PENDING
CURRENT_REJECTED
PREV_ACCEPTED
PREV_PENDING
PREV_REJECTED
}
# each smart contract should have a single way to handle fees
enum FeeMethodology {
ADDED_TO_AMOUNT
CUT_TO_AMOUNT
}
enum ListingType {
Direct
Auction
}
enum Status {
UNSET
CREATED
COMPLETED
CANCELLED
}
enum TokenType {
ERC1155
ERC721
ERC20
}
enum TransferType {
Rent
Sale
}
#####################
## Entities
#####################
type AdOffer @entity {
id: String! # uint256 (offerId)
origin: Bytes! # address DSponsorAdmin contract address
disable: Boolean!
name: String!
metadataURL: String!
metadata: AdOfferMetadata
nftContract: NftContract!
initialCreator: Bytes! # address
creationTimestamp: BigInt!
admins: [Bytes!] # address[]
validators: [Bytes!] # address[]
adParameters: [AdOfferParameterLink!] @derivedFrom(field: "adOffer")
allProposals: [AdProposal!] @derivedFrom(field: "adOffer")
currentProposals: [CurrentProposal!] @derivedFrom(field: "adOffer")
}
type AdOfferParameterLink @entity {
id: String! # offerId-adParameter
enable: Boolean!
adOffer: AdOffer!
adParameter: AdParameter!
}
type AdParameter @entity {
id: String! #adParameter value
base: String! # adParameter.split('-')[0]
variants: [String!]! # adParameter.split('-')[1:]
adOffers: [AdOfferParameterLink!] @derivedFrom(field: "adParameter")
proposals: [AdProposal!] @derivedFrom(field: "adParameter")
currentProposals: [CurrentProposal!] @derivedFrom(field: "adParameter")
}
type AdProposal @entity {
id: String! # uint256 (proposalId)
adOffer: AdOffer!
token: Token!
adParameter: AdParameter!
status: AdProposalStatus!
data: String!
rejectReason: String
creationTimestamp: BigInt!
lastUpdateTimestamp: BigInt!
# parsedData: String
}
type CurrentProposal @entity {
id: String! # offerId-tokenId-adParameter
adOffer: AdOffer!
token: Token!
adParameter: AdParameter!
pendingProposal: AdProposal
acceptedProposal: AdProposal
rejectedProposal: AdProposal
}
type EpochCurrencyRevenue @entity {
id: String! ## YYYY-MM-currencyAddress
year: Int!
month: Int!
currency: Bytes! # address
totalAmount: BigInt!
callsWithProtocolFee: [CallWithProtocolFee!]
@derivedFrom(field: "epochCurrencyRevenue")
}
type FeeParamsForContract @entity {
id: Bytes! # smart contract address (which implements ProtocolFee.sol)
feeRecipient: Bytes! # treasury address
feeBps: BigInt! # uint96
lastUpdateTimestamp: BigInt!
}
type NftContract @entity {
id: Bytes! # address
name: String
symbol: String
baseURI: String
contractURI: String
metadata: NftContractMetadata
maxSupply: BigInt
minter: Bytes # address
forwarder: Bytes # address
owner: Bytes # address
royalty: RoyaltiesSet
allowList: Boolean
adOffers: [AdOffer!] @derivedFrom(field: "nftContract")
prices: [NftPrice!] @derivedFrom(field: "nftContract") # contract level / default prices
tokens: [Token!] @derivedFrom(field: "nftContract")
}
type NftPrice @entity {
id: String! # nftContractAddress-currencyAddress-all|tokenId
currency: Bytes! # address
amount: BigInt! # uint256
enabled: Boolean! # bool
nftContract: NftContract!
}
type MarketplaceBid @entity {
id: String! # listingId-bidPosition
listing: MarketplaceListing! # NewBid listingId
bidder: Bytes! # NewBid bidder
quantity: BigInt! # NewBid quantity
newPricePerToken: BigInt! # NewBid pricePerToken
totalBidAmount: BigInt! # NewBid totalBidAmount
paidBidAmount: BigInt! # NewBid paidBidAmount
refundBonus: BigInt! # NEXT NewBid refundBonus
refundAmount: BigInt! # NEXT NewBid totalBidAmount + refundBonus
refundProfit: BigInt! # NEXT NewBid paidBidAmount - refundAmount
currency: Bytes! # NewBid currency
status: Status! # status
creationTxHash: Bytes! # NewBid txhash
revenueTransaction: RevenueTransaction
creationTimestamp: BigInt!
lastUpdateTimestamp: BigInt!
#
# once closed
feeMethodology: FeeMethodology
amountSentToProtocol: BigInt
protocolRecipient: Bytes
amountSentToSeller: BigInt
sellerRecipient: Bytes
amountSentToCreator: BigInt
creatorRecipient: Bytes
#
}
type MarketplaceDirectBuy @entity {
id: Bytes! # txhash-logIndex
listing: MarketplaceListing! # NewSale sale_listingId
buyer: Bytes! # NewSale sale_buyer
quantityBought: BigInt! # NewSale sale_quantityBought
totalPricePaid: BigInt! # NewSale sale_totalPricePaid
revenueTransaction: RevenueTransaction!
#
#
feeMethodology: FeeMethodology
amountSentToProtocol: BigInt
protocolRecipient: Bytes
amountSentToSeller: BigInt
sellerRecipient: Bytes
amountSentToCreator: BigInt
creatorRecipient: Bytes
#
}
type MarketplaceListing @entity {
id: String! # listingId
origin: Bytes! # address DSponsorMarketplace contract address
listingType: ListingType! # from listing_listingType uint8
lister: Bytes! # tokenOwner address (/!\ keep in mind a transfer can occurs after listing creation)
token: Token! # listing_assetContract-listing_tokenId
startTime: BigInt! # uint256
endTime: BigInt! # uint256
quantity: BigInt! # uint256
currency: Bytes! # address
reservePricePerToken: BigInt! # uint256
buyoutPricePerToken: BigInt! # uint256
tokenType: TokenType! # from listing_tokenType uint8
transferType: TransferType! # from listing_transferType uint8
rentalExpirationTimestamp: BigInt! # uint64
status: Status!
creationTimestamp: BigInt!
lastUpdateTimestamp: BigInt!
completedBid: MarketplaceBid
bids: [MarketplaceBid!] @derivedFrom(field: "listing") # the most recent bid (from creationTimestamp) is the winning bid
directBuys: [MarketplaceDirectBuy!] @derivedFrom(field: "listing") # with ERC721 one element max
}
type MarketplaceOffer @entity {
id: String! # offerId
origin: Bytes! # address DSponsorMarketplace contract address
offeror: Bytes! # address
token: Token! # offer_assetContract-offer_tokenId
quantity: BigInt! # uint256
currency: Bytes! # address
totalPrice: BigInt! # uint256
tokenType: TokenType! # uint8
transferType: TransferType! # uint8
expirationTimestamp: BigInt! # uint256
rentalExpirationTimestamp: BigInt! # uint64
status: Status! # uint8
revenueTransaction: RevenueTransaction
referralAdditionalInformation: String
creationTimestamp: BigInt!
lastUpdateTimestamp: BigInt!
#
# once accepted
feeMethodology: FeeMethodology
amountSentToProtocol: BigInt
protocolRecipient: Bytes
amountSentToSeller: BigInt
sellerRecipient: Bytes
amountSentToCreator: BigInt
creatorRecipient: Bytes
}
type RevenueTransaction @entity {
id: Bytes! # event.transaction.hash
blockTimestamp: BigInt!
protocolFees: [CallWithProtocolFee!] @derivedFrom(field: "revenueTransaction")
marketplaceBids: [MarketplaceBid!] @derivedFrom(field: "revenueTransaction")
marketplaceDirectBuys: [MarketplaceDirectBuy!]
@derivedFrom(field: "revenueTransaction")
marketplaceOffers: [MarketplaceOffer!]
@derivedFrom(field: "revenueTransaction")
mints: [Mint!] @derivedFrom(field: "revenueTransaction")
}
type Token @entity {
id: String! # nftContractAddress - tokenId
nftContract: NftContract!
tokenId: BigInt! # uint256
# owner: Bytes! # address
# lastTransferTimestamp: BigInt! # uint256
setInAllowList: Boolean
mint: Mint
owner: Bytes # address
user: UpdateUser
prices: [TokenPrice!] @derivedFrom(field: "token")
currentProposals: [CurrentProposal!] @derivedFrom(field: "token")
allProposals: [AdProposal!] @derivedFrom(field: "token")
marketplaceListings: [MarketplaceListing!] @derivedFrom(field: "token")
marketplaceOffers: [MarketplaceOffer!] @derivedFrom(field: "token")
transfers: [Transfer!] @derivedFrom(field: "token")
}
type TokenPrice @entity {
id: String! # nftContractAddress-currencyAddress-all|tokenId
currency: Bytes! # address
amount: BigInt! # uint256
enabled: Boolean! # bool
token: Token!
}
#####################
## Metadata
#####################
type AdOfferMetadata @entity {
id: ID!
content: String
creator_name: String
creator_description: String
creator_image: String
creator_categories: [String!]
offer_name: String
offer_description: String
offer_image: String
offer_terms: String
offer_categories: [String!]
offer_visibility_interfaces: [String!]
offer_visibility_targets: [String!]
offer_validFrom: BigInt # unix timestamp
offer_validTo: BigInt # unix timestamp
offer_token_metadataContent: String
offers: [AdOffer!] @derivedFrom(field: "metadata")
}
type NftContractMetadata @entity {
id: ID!
content: String
name: String
description: String
image: String
external_link: String
external_url: String
collaborators: [Bytes!]
contracts: [NftContract!] @derivedFrom(field: "metadata")
}
type _Schema_
@fulltext(
name: "offerSearch"
language: simple
algorithm: proximityRank
include: [
{ entity: "AdOffer", fields: [{ name: "name" }] }
{
entity: "AdOfferMetadata"
fields: [
{ name: "content" }
{ name: "creator_name" }
{ name: "creator_description" }
{ name: "offer_name" }
{ name: "offer_description" }
]
}
{
entity: "NftContractMetadata"
fields: [{ name: "name" }, { name: "content" }, { name: "description" }]
}
]
)
################################
type ## Common: ProtocoFee + Ownable
#################################
CallWithProtocolFee @entity(immutable: true) {
id: Bytes!
target: Bytes! # address
currency: Bytes! # address
fee: BigInt! # uint256
enabler: Bytes! # address
spender: Bytes! # address
referralAdditionalInformation: String! # string
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
revenueTransaction: RevenueTransaction
referralAddresses: [Bytes!]! # address[]
referralUnitShare: Int
referralNb: Int
epochCurrencyRevenue: EpochCurrencyRevenue!
}
type FeeUpdate @entity(immutable: true) {
id: Bytes!
feeRecipient: Bytes! # address
feeBps: BigInt! # uint96
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type OwnershipTransferred @entity(immutable: true) {
id: Bytes!
contractAddress: Bytes! # address
previousOwner: Bytes! # address
newOwner: Bytes! # address
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
#####################
## DSponsorAdmin
#####################
type UpdateAdProposal @entity(immutable: true) {
id: Bytes!
offerId: BigInt! # uint256
tokenId: BigInt! # uint256
proposalId: BigInt! # uint256
adParameter: String! # string
data: String! # string
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateAdValidation @entity(immutable: true) {
id: Bytes!
offerId: BigInt! # uint256
tokenId: BigInt! # uint256
proposalId: BigInt! # uint256
adParameter: String! # string
validated: Boolean! # bool
reason: String! # string
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateOffer @entity(immutable: true) {
id: Bytes!
offerId: BigInt! # uint256
disable: Boolean! # bool
name: String! # string
offerMetadata: String! # string
nftContract: Bytes! # address
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateOfferAdParameter @entity(immutable: true) {
id: Bytes!
offerId: BigInt! # uint256
adParameter: String! # string
enable: Boolean! # bool
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateOfferAdmin @entity(immutable: true) {
id: Bytes!
offerId: BigInt! # uint256
admin: Bytes! # address
enable: Boolean! # bool
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateOfferValidator @entity(immutable: true) {
id: Bytes!
offerId: BigInt! # uint256
validator: Bytes! # address
enable: Boolean! # bool
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
#####################
## DSponsorNFT
#####################
"""
type Approval @entity(immutable: true) {
id: Bytes!
owner: Bytes! # address
approved: Bytes! # address
tokenId: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type ApprovalForAll @entity(immutable: true) {
id: Bytes!
owner: Bytes! # address
operator: Bytes! # address
approved: Boolean! # bool
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
"""
type ContractURIUpdated @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
"""
type Initialized @entity(immutable: true) {
id: Bytes!
version: BigInt! # uint64
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
"""
type Mint @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
token: Token!
tokenId: BigInt! # uint256
from: Bytes! # address
to: Bytes! # address
currency: Bytes! # address
amount: BigInt! # uint256
tokenData: String! # string
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
revenueTransaction: RevenueTransaction
feeMethodology: FeeMethodology
amountSentToProtocol: BigInt
protocolRecipient: Bytes
totalPaid: BigInt
#
}
type RoyaltiesSet @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
receiver: Bytes! # address
bps: BigInt! # uint96
blockNumber: BigInt
blockTimestamp: BigInt
transactionHash: Bytes
}
type TokensAllowlist @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
allowed: Boolean! # bool
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type TokensAllowlistUpdated @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
token: Token!
tokenId: BigInt! # uint256
allowed: Boolean! # bool
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type Transfer @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
token: Token!
from: Bytes! # address
to: Bytes! # address
tokenId: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateDefaultMintPrice @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
currency: Bytes! # address
enabled: Boolean! # bool
amount: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateMintPrice @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
tokenId: BigInt! # uint256
currency: Bytes! # address
enabled: Boolean! # bool
amount: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type UpdateUser @entity(immutable: true) {
id: Bytes!
nftContract: NftContract!
tokenId: BigInt! # uint256
user: Bytes! # address
expires: BigInt! # uint256
blockNumber: BigInt
blockTimestamp: BigInt
transactionHash: Bytes
}
#####################
## DSponsorMarketplace
#####################
type AcceptedOffer @entity(immutable: true) {
id: Bytes!
offeror: Bytes! # address
offerId: BigInt! # uint256
assetContract: Bytes! # address
tokenId: BigInt! # uint256
seller: Bytes! # address
quantityBought: BigInt! # uint256
totalPricePaid: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type AuctionClosed @entity(immutable: true) {
id: Bytes!
listingId: BigInt! # uint256
closer: Bytes! # address
cancelled: Boolean! # bool
auctionCreator: Bytes! # address
winningBidder: Bytes! # address
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type CancelledOffer @entity(immutable: true) {
id: Bytes!
offeror: Bytes! # address
offerId: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type ListingAdded @entity(immutable: true) {
id: Bytes!
listingId: BigInt! # uint256
assetContract: Bytes! # address
lister: Bytes! # address
listing_listingId: BigInt! # uint256
listing_tokenOwner: Bytes! # address
listing_assetContract: Bytes! # address
listing_tokenId: BigInt! # uint256
listing_startTime: BigInt! # uint256
listing_endTime: BigInt! # uint256
listing_quantity: BigInt! # uint256
listing_currency: Bytes! # address
listing_reservePricePerToken: BigInt! # uint256
listing_buyoutPricePerToken: BigInt! # uint256
listing_tokenType: Int! # uint8
listing_transferType: Int! # uint8
listing_rentalExpirationTimestamp: BigInt! # uint64
listing_listingType: Int! # uint8
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type ListingRemoved @entity(immutable: true) {
id: Bytes!
listingId: BigInt! # uint256
listingCreator: Bytes! # address
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type ListingUpdated @entity(immutable: true) {
id: Bytes!
listingId: BigInt! # uint256
listingCreator: Bytes! # address
quantityToList: BigInt! # uint256
reservePricePerToken: BigInt! # uint256
buyoutPricePerToken: BigInt! # uint256
currencyToAccept: Bytes! # address
startTime: BigInt! # uint256
secondsUntilEndTime: BigInt! # uint256
rentalExpirationTimestamp: BigInt! # uint64
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type NewBid @entity(immutable: true) {
id: Bytes!
listingId: BigInt! # uint256
quantityWanted: BigInt! # uint256
newBidder: Bytes! # address
newPricePerToken: BigInt! # uint256
previousBidder: Bytes! # address
refundBonus: BigInt! # uint256
currency: Bytes! # address
newEndTime: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type NewOffer @entity(immutable: true) {
id: Bytes!
offeror: Bytes! # address
offerId: BigInt! # uint256
assetContract: Bytes! # address
offer_offerId: BigInt! # uint256
offer_tokenId: BigInt! # uint256
offer_quantity: BigInt! # uint256
offer_totalPrice: BigInt! # uint256
offer_expirationTimestamp: BigInt! # uint256
offer_offeror: Bytes! # address
offer_assetContract: Bytes! # address
offer_currency: Bytes! # address
offer_tokenType: Int! # uint8
offer_transferType: Int! # uint8
offer_rentalExpirationTimestamp: BigInt! # uint64
offer_status: Int! # uint8
offer_referralAdditionalInformation: String! # string
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type NewSale @entity(immutable: true) {
id: Bytes!
listingId: BigInt! # uint256
assetContract: Bytes! # address
lister: Bytes! # address
buyer: Bytes! # address
quantityBought: BigInt! # uint256
totalPricePaid: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}