-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.graphql
485 lines (357 loc) · 9.75 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
enum LoanStatus {
PENDING
ACTIVE
CLOSED
LIQUIDATED
LOAN_REPAID
}
enum BidStatus {
PENDING
ACCEPTED
REJECTED
CANCELLED
}
enum LockStatus {
ACTIVE
LIQUIDATED
UNLOCKED
}
enum TransactionType {
TRANSFER
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 contract @entity {
id: ID!
asERC721: collection
}
type accountStatistic @entity {
" account address "
id: Bytes!
" The points earned by this account "
points: 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")
" 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
" Mint Price "
mintPrice: BigDecimal
" Collection creator "
creator: account
" Tokens for the collection"
tokens: [token!]! @derivedFrom(field: "collection")
" Collection supports metadata "
supportsMetadata: Boolean
" 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 {
" eth / 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")
}
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!
" Transfers that occured within the transaction "
transfers: [transfer!]!
" Gas Spent "
gasPrice: BigInt
" transaction type to reference "
txType: TransactionType
}
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!
}
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" }]
}
]
)