forked from SteffQing/721-Clone-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.graphql
753 lines (548 loc) · 15.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
enum SaleType {
FIXEDSALE
AUCTIONSALE
NONE
}
enum LoanStatus {
PENDING
ACTIVE
CLOSED
LIQUIDATED
LOAN_REPAID
}
enum BidStatus {
PENDING
ACCEPTED
REJECTED
CANCELLED
}
enum LockStatus {
ACTIVE
LIQUIDATED
UNLOCKED
}
enum TransactionType {
TRANSFER
FIXED_SALE_LISTING
FIXED_SALE_SOLD
FIXED_SALE_CANCELLED
FIXED_SALE_UPDATED
AUCTION_SALE_LISTING
AUCTION_SALE_CANCELLED
AUCTION_BID_CREATED
AUCTION_BID_ACCEPTED
COLLECTION_OFFER_ACCEPTED
TOKEN_OFFER_CREATED
TOKEN_OFFER_UPDATED
TOKEN_OFFER_ACCEPTED
TOKEN_OFFER_DELETED
LOAN_REQUEST_OPEN
LOAN_REQUEST_CANCELLED
LOAN_REQUEST_ACTIVE
LOAN_REQUEST_BID_OPEN
LOAN_REQUEST_BID_CANCELLED
LOAN_REQUEST_BID_LOST
LOAN_LIQUIDATED
LOAN_REPAID
TOKENS_LOCKED
}
enum CollectionStatus {
VERIFIED
UNVERIFIED
}
type supportedCollection @entity {
" the ID is supportedcollection and collection address "
id: ID!
" Collection fee revenue collector "
creator: Bytes!
" The trading fee for the collection "
royaltyFees: BigInt!
" The collection images "
metadata: CollectionMetadata
" The collection address "
collection: collection!
" The collection status "
status: CollectionStatus!
}
type CollectionMetadata @entity {
" The ID is the ipfs hash "
id: ID!
" The collection banner image "
bannerImage: String!
" The collection description "
description: String!
" The collection placeholder Image "
placeholderImage: String!
" The collection small image "
smallImage: String!
" The collection twitter link "
twitter: String
" The collection discord link "
discord: String
" The collection telegram link "
telegram: String
" The collection website link "
website: String
}
type saleInfo @entity {
" The ID is the concatenation of kcc, collection address, and token ID "
id: ID!
" The collection address for the sale "
collection: collection!
" The token ID involved in the sale "
token: token!
" The price of the token "
salePrice: BigInt
" The state of the sale; fixedSale, auctionSale and none "
state: SaleType!
" The starting bid for the auction if sale is an auction "
startingBid: BigInt
" The highest bid and current for the auction "
highestBid: BigInt
" The highest bidder for the auction "
highestBidder: account
" The time the auction ends "
validity: BigInt
" The transactions for the sales "
transactions: [transaction!] @derivedFrom(field: "saleInfo")
" An array of bid entities "
auctionBids: [auctionBid!]
" timestamp of the last listing "
timestamp: Int!
}
type auctionBid @entity {
" The id is the collection address, token ID and its bidder "
id: ID!
" The bidder "
bidder: account!
" The bid value "
bid: BigInt!
}
type collectionOffer @entity {
" ID is the concatenation of collection address and the offer creator "
id: ID!
" The collection address for the offer "
collection: collection!
" The offer creator "
creator: account!
" The offer amount or value "
amount: BigInt!
" The total count of nfts the Offer creator is offering to buy "
total: Int!
" The validity period of the offer "
validity: BigInt!
}
type collectionTokenOffer @entity {
" ID is the concatenation of collection, creator address and tokenId "
id: ID!
" The collection address for the offer "
collection: collection!
" The offer creator "
creator: account!
" The token ID involved in the offer "
token: token!
" The offer amount/value "
value: BigInt!
" The validity period of the offer "
validity: BigInt!
}
type contract @entity {
id: ID!
asERC721: collection
}
type accountStatistic @entity {
" account address "
id: Bytes!
" The points earned by this account "
points: Int!
" The total volume of sales for this account "
salesVolume: BigInt!
" The total sales for this account "
totalSales: Int!
" total interest paid as a borrower "
paidInterest: BigInt!
" total interest earned as a lender "
earnedInterest: BigInt!
" total loans taken as a borrower "
borrowCount: Int!
" total loans funded as a lender "
lendCount: Int!
" total loans defaulted on as a borrower "
defaultCount: Int!
" withdrawable bids from failed bids "
withdrawableBid: BigInt!
" total revenue generated by the account "
revenue: BigInt!
" total borrowed "
totalBorrowedAmount: BigInt!
" total lent "
totalLentAmount: BigInt!
" account pointer "
account: account!
}
type account @entity {
" the wallet address "
id: ID!
" The NFTs owned by this account "
tokens: [token!]! @derivedFrom(field: "owner")
" The transfers originating from this account "
transfersFrom: [transfer!] @derivedFrom(field: "senderAddress")
" The transfers recevied by this account"
transfersTo: [transfer!] @derivedFrom(field: "receiverAddress")
" M:M relationship for Accounts and Collections "
accountCollection: [accountCollection!] @derivedFrom(field: "account")
" Tokens bidded by account"
auctionBids: [saleInfo!] @derivedFrom(field: "highestBidder")
" Collection offers made by account "
collectionOffers: [collectionOffer!] @derivedFrom(field: "creator")
" Token offer made for by account "
tokenCollectionOffers: [collectionTokenOffer!] @derivedFrom(field: "creator")
" locked nfts "
lockedIds: [lockId!] @derivedFrom(field: "depositor")
" loan contract bids "
loanBids: [loanBid!] @derivedFrom(field: "bidder")
" loanContract as a borrower "
borrows: [loanContract!] @derivedFrom(field: "borrower")
" loanContract as a lender "
lends: [loanContract!] @derivedFrom(field: "lender")
" account statistics "
accountStatistic: accountStatistic @derivedFrom(field: "account")
}
type collection @entity {
" The address of the collection "
id: ID!
" The name of the collection "
name: String
" The symbol for the collection "
symbol: String
" Total Supply of Tokens "
totalSupply: BigInt
" Total Value locked for offers "
valueLocked: BigInt!
" Mint Price "
mintPrice: BigDecimal
" Collection creator "
creator: account
" Tokens for the collection"
tokens: [token!]! @derivedFrom(field: "collection")
" Tokens in the collection for sale"
saleInfos: [saleInfo!] @derivedFrom(field: "collection")
" offers made for tokens in this collection "
collectionOffers: [collectionOffer!] @derivedFrom(field: "collection")
" Collection supports metadata "
supportsMetadata: Boolean
" Total sales "
totalSales: Int!
" Total volume "
totalVolume: BigDecimal!
" Top Sale ever "
topSale: BigDecimal!
" Floor price of collection "
floorPrice: BigDecimal!
" Listing prices of items in collection "
listingPrices: [BigInt!]!
" Hourly info about the collection "
hourlyCollectionSnapshot: [hourlyCollectionSnapshot!]!
@derivedFrom(field: "collection")
" Daily info about the collection "
dailyCollectionSnapshot: [dailyCollectionSnapshot!]!
@derivedFrom(field: "collection")
" Weekly info about the collection "
weeklyCollectionSnapshot: [weeklyCollectionSnapshot!]!
@derivedFrom(field: "collection")
" M:M relationship for Accounts and Collections "
accountCollection: [accountCollection!]! @derivedFrom(field: "collection")
" Collection loan statistics "
loanStatistic: collectionLoanStatistic @derivedFrom(field: "collection")
}
type collectionLoanStatistic @entity {
" Collection address as id "
id: Bytes!
" Average loan size: division of all loans taken from this collection "
averageLoanAmount: BigDecimal!
" total loan amount taken in this collection "
totalLoanVolume: BigDecimal!
" total loans taken in this collection "
totalLoanCount: Int!
" largest single loan taken for the collection "
largestLoan: BigDecimal!
" total interest paid by borrowers "
totalPaidInterest: BigInt!
" the collection pointer for this statistics "
collection: collection!
}
type token @entity {
" kcc / Collection Addrress - Token Id "
id: ID!
" The collection address "
collection: collection!
" The token URI "
tokenURI: String!
" The token metadata "
metadata: TokenMetadata
" Used to track last fetched time for token metadata "
updatedAtTimestamp: BigInt!
" Token ID / identifier but as a string for fullTextSearch "
tokenId: String!
" The address that currently owns the token "
owner: account
" Transfers involving this token "
transfers: [transfer!]! @derivedFrom(field: "token")
" token saleInfo "
saleInfo: saleInfo @derivedFrom(field: "token")
" offers made for this token "
tokenOffers: [collectionTokenOffer!] @derivedFrom(field: "token")
}
type TokenMetadata @entity {
" metadata hash "
id: ID!
" The image of the NFT"
image: String
" The name of the NFT"
name: String
" The description of the NFT"
description: String
" The token attributes "
attributes: [TokenAttribute!] @derivedFrom(field: "metadata")
}
type TokenAttribute @entity {
" the metadata for token "
id: ID!
" the metadata for token "
metadata: TokenMetadata!
" The attribute trait type "
traitType: String
" The attribute value "
value: String
}
type accountCollection @entity {
" Account Id - Collection Id "
id: ID!
" Address of the account "
account: account
" Address of the NFT Collection "
collection: collection
" Count of NFT's owned in a collection by the Address"
tokenCount: Int!
}
type transaction @entity {
" the hash of the tx"
id: ID!
" Timestamp for block "
timestamp: Int!
" Block Number "
blockNumber: Int!
" Address who initiated the transaction "
transactionFrom: Bytes!
" Count of how many transfers were not matched to a sale "
unmatchedTransferCount: Int!
" Transfers that occured within the transaction "
transfers: [transfer!]!
" Sale events that occured within the transaction "
sales: [sale!] @derivedFrom(field: "transaction")
" Gas Spent "
gasPrice: BigInt
" transaction type to reference "
txType: TransactionType
" saleInfo reference if the transaction involved a listing "
saleInfo: saleInfo
}
type transfer @entity {
" Block Number and Event Id in which the transfers event occured"
id: ID!
" Transaction hash in which the transfer event occured"
transaction: transaction!
" The collection address "
collection: collection!
" The collection addrress - The token id "
token: token!
" The sender address "
senderAddress: account
" The receiver address "
receiverAddress: account
" Timestamp for block "
timestamp: Int!
" Block Number "
blockNumber: Int!
" The amount of KCS/WKCS paid"
amount: BigDecimal!
" matched sale event for the transfer "
matchedSale: sale
}
type sale @entity {
" Block Number and Event Id in which the sale event occured"
id: ID!
" tx that the sale occured in "
transaction: transaction!
" the amount of the sale "
amount: BigDecimal!
}
type hourlyCollectionSnapshot @entity {
" The collection address - The hour "
id: ID!
" Unix Hour (Timestamp / 3600 * 3600) "
timestamp: Int
" The collection address "
collection: collection!
" The hourly volume "
hourlyVolume: BigDecimal!
" Number of hourly transactions "
hourlyTransactions: Int
" Average sale amount for the day "
hourlyAvgSale: BigDecimal!
" Hourly top sales "
topSale: BigDecimal!
" Hourly bottom sales "
bottomSale: BigDecimal!
}
type dailyCollectionSnapshot @entity {
" The collection address - The day "
id: ID!
" Unix Day (Timestamp / 86400 * 86400) "
timestamp: Int
" The collection address "
collection: collection!
" The daily volume "
dailyVolume: BigDecimal!
" Number of daily transactions "
dailyTransactions: Int
" Average sale amount for the day "
dailyAvgSale: BigDecimal!
" Daily top sales "
topSale: BigDecimal!
" Daily bottom sales "
bottomSale: BigDecimal!
}
type weeklyCollectionSnapshot @entity {
" The collection address - The week "
id: ID!
" Unix Week (Timestamp / 604800 * 604800) "
timestamp: Int
" The collection address "
collection: collection!
" The monthly volume "
weeklyVolume: BigDecimal!
" Number of monthly transactions "
weeklyTransactions: Int
" Average sale amount for the day "
weeklyAvgSale: BigDecimal!
" Weekly top sales "
topSale: BigDecimal!
" Weekly bottom sales "
bottomSale: BigDecimal!
}
type protocol @entity {
" The protocol contract address "
id: Bytes!
" The protocol name "
name: String!
" The tokens locked by this protocol "
lockedIds: [lockId!] @derivedFrom(field: "protocol")
" The protocol fee "
protocolFee: Int!
" The security fee "
securityFee: Int!
" total borrows "
totalLoanVolume: BigDecimal!
" total loan count "
totalLoanCount: Int!
" interest paid by borrowers "
totalPaidInterest: BigInt!
" Average loan size: division of all loans taken from the protocol "
averageLoanAmount: BigDecimal!
" largest single loan taken in the protocol "
largestLoan: BigDecimal!
}
type lockId @entity {
" The lock id in string "
id: ID!
" The collection from which the tokens are locked "
collection: collection!
" An array of token entity of this collection that was locked "
tokens: [token!]!
" The address that locked the collections "
depositor: account!
" The protocol that locked the collections "
protocol: protocol!
" The timestamp of when the lock expires "
expires: BigInt!
" the contract it was opened for "
contract: loanContract
" the lock status "
status: LockStatus!
" Transaction hash in which the deposit event occured"
transaction: transaction!
}
type loanContract @entity {
" the loanContract id in bytes"
id: ID!
" The borrower address "
borrower: account!
" The lender address "
lender: account!
" The interest/apr to be paid "
interest: Int!
" The amount borrowed "
amount: BigInt!
" The loan expiry date. changes from days count to unix period when active "
expiry: BigInt!
" The start block of the loan "
checkPointBlock: BigInt
" state of the loan "
status: LoanStatus!
" the lockId of the tokens locked for the loan "
lockId: lockId! @derivedFrom(field: "contract")
" Bids made to this loan contract "
bids: [loanBid!] @derivedFrom(field: "contract")
" Transactions in which a loan contract event occured"
transactions: [transaction!]
" The loan contract collection statistics "
collection: String!
}
type loanBid @entity {
" the loanContract id - the bidder address "
id: ID!
" bidder address "
bidder: account!
" proposed interest "
proposedInterest: Int!
" Contract bidding for "
contract: loanContract!
" the bid status "
status: BidStatus!
}
type _Schema_
@fulltext(
name: "search"
language: en
algorithm: rank
include: [
{ entity: "token", fields: [{ name: "tokenId" }] }
{ entity: "account", fields: [{ name: "id" }] }
{
entity: "collection"
fields: [{ name: "id", name: "name", name: "symbol" }]
}
{ entity: "TokenMetadata", fields: [{ name: "name" }] }
{
entity: "TokenAttribute"
fields: [{ name: "traitType", name: "value" }]
}
]
)
@fulltext(
name: "searchCollection"
language: en
algorithm: rank
include: [
{ entity: "collection", fields: [{ name: "id" }] }
{ entity: "collection", fields: [{ name: "name" }] }
{ entity: "collection", fields: [{ name: "symbol" }] }
{ entity: "token", fields: [{ name: "tokenId" }] }
{ entity: "TokenMetadata", fields: [{ name: "name" }] }
{
entity: "TokenAttribute"
fields: [{ name: "traitType", name: "value" }]
}
]
)