generated from zenlinkpro/zenlink-astar-subsquid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.graphql
613 lines (496 loc) · 12.6 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
type ZenlinkInfo @entity {
id: ID!
updatedDate: DateTime!
"BigDecimal"
totalVolumeUSD: String!
"BigDecimal"
totalTvlUSD: String!
# transactions
txCount: Int!
factory: Factory!
stableSwapInfo: StableSwapInfo!
}
type Factory @entity {
# factory address
id: ID!
# pair info
pairCount: Int!
# total volume
"BigDecimal"
totalVolumeUSD: String!
"BigDecimal"
totalVolumeETH: String!
# untracked values - less confident USD scores
"BigDecimal"
untrackedVolumeUSD: String!
# total liquidity
"BigDecimal"
totalLiquidityUSD: String!
"BigDecimal"
totalLiquidityETH: String!
# transactions
txCount: Int!
}
type StableSwapInfo @entity {
id: ID!
poolCount: Int!
# total volume
"BigDecimal"
totalVolumeUSD: String!
"BigDecimal"
totalTvlUSD: String!
# transactions
txCount: Int!
swaps: [StableSwap!]! @derivedFrom(field: "stableSwapInfo")
}
type StableSwap @entity {
id: ID!
# swap address
address: String!
# base swap address
baseSwapAddress: String!
# number of tokens supported
numTokens: Int!
# supported tokens
tokens: [String!]!
# supported base tokens (for SwapNormal, this is same as tokens; for MetaSwap, this is the corresbonding base pool tokens)
baseTokens: [String!]!
# supported all tokens (metapool tokens plus basepool tokens)
allTokens: [String!]!
# token balances
balances: [String!]!
# liquidity provider token
lpToken: String!
lpTotalSupply: String!
# amplification coefficient
a: BigInt!
swapFee: BigInt!
adminFee: BigInt!
virtualPrice: BigInt!
stableSwapInfo: StableSwapInfo!
events: [StableSwapEvent!] @derivedFrom(field: "stableSwap")
exchanges: [StableSwapExchange!] @derivedFrom(field: "stableSwap")
stableSwapDayData: [StableSwapDayData!] @derivedFrom(field: "stableSwap")
stableSwapHourData: [StableSwapHourData!] @derivedFrom(field: "stableSwap")
farm: [Farm!] @derivedFrom(field: "stableSwap")
"BigDecimal"
tvlUSD: String!
"BigDecimal"
volumeUSD: String!
}
type StableSwapEvent @entity{
id: ID!
stableSwap: StableSwap!
data: StableSwapEventData
block: BigInt!
timestamp: BigInt!
transaction: Bytes!
}
union StableSwapEventData =
StableSwapNewFeeEventData |
StableSwapRampAEventData |
StableSwapStopRampAEventData |
StableSwapAddLiquidityEventData |
StableSwapRemoveLiquidityEventData |
StableSwapFlashLoanEventData
type StableSwapNewFeeEventData {
swapFee: BigInt!
adminFee: BigInt!
}
type StableSwapRampAEventData {
oldA: BigInt!
newA: BigInt!
initialTime: BigInt!
futureTime: BigInt!
}
type StableSwapStopRampAEventData {
currentA: BigInt!
time: BigInt!
}
type StableSwapAddLiquidityEventData {
provider: Bytes!
tokenAmounts: [String!]!
fees: [String!]!
invariant: BigInt
lpTokenSupply: BigInt!
}
type StableSwapRemoveLiquidityEventData {
provider: Bytes!
tokenAmounts: [String!]!
fees: [String!]
lpTokenSupply: BigInt
}
type StableSwapFlashLoanEventData {
caller: Bytes!
receiver: Bytes!
amountsOut: [String!]!
}
type StableSwapExchange @entity {
id: ID!
stableSwap: StableSwap!
data: StableSwapExchangeData
block: BigInt!
timestamp: BigInt!
transaction: Bytes!
}
union StableSwapExchangeData = StableSwapTokenExchangeData | StableSwapTokenExchangeUnderlyingData
type StableSwapTokenExchangeData {
buyer: Bytes!
boughtId: BigInt!
tokensBought: BigInt!
soldId: BigInt!
tokensSold: BigInt!
}
type StableSwapTokenExchangeUnderlyingData {
buyer: Bytes!
boughtId: BigInt!
tokensBought: BigInt!
soldId: BigInt!
tokensSold: BigInt!
}
type Token @entity {
# token address
id: ID!
# mirrored from the smart contract
symbol: String!
name: String!
decimals: Int!
# used for other stats like marketcap
totalSupply: String!
# token specific volume
"BigDecimal"
tradeVolume: String!
"BigDecimal"
tradeVolumeUSD: String!
"BigDecimal"
untrackedVolumeUSD: String!
# transactions across all pairs
txCount: Int!
# liquidity across all pairs
"BigDecimal"
totalLiquidity: String!
# derived prices
"BigDecimal"
derivedETH: String!
tokenDayData: [TokenDayData!]! @derivedFrom(field: "token")
pairDayDataBase: [PairDayData!]! @derivedFrom(field: "token0")
pairDayDataQuote: [PairDayData!]! @derivedFrom(field: "token1")
pairBase: [Pair!]! @derivedFrom(field: "token0")
pairQuote: [Pair!]! @derivedFrom(field: "token1")
}
type Pair @entity {
# pair address
id: ID!
# mirrored from the smart contract
token0: Token!
token1: Token!
"BigDecimal"
reserve0: String!
"BigDecimal"
reserve1: String!
"BigDecimal"
totalSupply: String!
# derived liquidity
"BigDecimal"
reserveETH: String!
"BigDecimal"
reserveUSD: String!
# used for separating per pair reserves and global
"BigDecimal"
trackedReserveETH: String!
# Price in terms of the asset pair
"BigDecimal"
token0Price: String!
"BigDecimal"
token1Price: String!
# lifetime volume stats
"BigDecimal"
volumeToken0: String!
"BigDecimal"
volumeToken1: String!
"BigDecimal"
volumeUSD: String!
"BigDecimal"
untrackedVolumeUSD: String!
txCount: Int!
# creation stats
createdAtTimestamp: DateTime!
createdAtBlockNumber: BigInt!
# Fields used to help derived relationship
liquidityProviderCount: Int! # used to detect new exchanges
# derived fields
pairHourData: [PairHourData!]! @derivedFrom(field: "pair")
pairDayData: [PairDayData!]! @derivedFrom(field: "pair")
liquidityPositions: [LiquidityPosition!]! @derivedFrom(field: "pair")
liquidityPositionSnapshots: [LiquidityPositionSnapshot!]! @derivedFrom(field: "pair")
mints: [Mint!]! @derivedFrom(field: "pair")
burns: [Burn!]! @derivedFrom(field: "pair")
swaps: [Swap!]! @derivedFrom(field: "pair")
farm: [Farm!] @derivedFrom(field: "pair")
}
type User @entity {
# user address
id: ID!
liquidityPositions: [LiquidityPosition!] @derivedFrom(field: "user")
stableSwapLiquidityPositions: [StableSwapLiquidityPosition!] @derivedFrom(field: "user")
stakePositions: [StakePosition!] @derivedFrom(field: "user")
"BigDecimal"
usdSwapped: String!
}
type LiquidityPosition @entity {
id: ID!
user: User!
pair: Pair!
"BigDecimal"
liquidityTokenBalance: String!
}
type StableSwapLiquidityPosition @entity {
id: ID!
user: User!
stableSwap: StableSwap!
liquidityTokenBalance: String!
}
# saved over time for return calculations, gets created and never updated
type LiquidityPositionSnapshot @entity {
id: ID!
liquidityPosition: LiquidityPosition!
timestamp: DateTime! # saved for fast historical lookups
block: Int! # saved for fast historical lookups
user: User! # reference to user
pair: Pair! # reference to pair
"BigDecimal"
token0PriceUSD: String! # snapshot of token0 price
"BigDecimal"
token1PriceUSD: String! # snapshot of token1 price
"BigDecimal"
reserve0: String! # snapshot of pair token0 reserves
"BigDecimal"
reserve1: String! # snapshot of pair token1 reserves
"BigDecimal"
reserveUSD: String! # snapshot of pair reserves in USD
"BigDecimal"
liquidityTokenTotalSupply: String! # snapshot of pool token supply
"BigDecimal"
liquidityTokenBalance: String! # snapshot of users pool token balance
}
type Transaction @entity {
id: ID! # txn hash
blockNumber: BigInt!
timestamp: DateTime!
mints: [ID!]!
burns: [ID!]!
swaps: [ID!]!
}
type Mint @entity {
# transaction hash + "-" + index in mints Transaction array
id: ID!
transaction: Transaction!
timestamp: DateTime! # need this to pull recent txns for specific token or pair
pair: Pair!
# populated from the primary Transfer event
to: String!
liquidity: String!
# populated from the Mint event
sender: String
amount0: String
amount1: String
logIndex: Int
# derived amount based on available prices of tokens
amountUSD: String
# optional fee fields, if a Transfer event is fired in _mintFee
feeTo: String
feeLiquidity: String
}
type Burn @entity {
# transaction hash + "-" + index in mints Transaction array
id: ID!
transaction: Transaction!
timestamp: DateTime! # need this to pull recent txns for specific token or pair
pair: Pair!
# populated from the primary Transfer event
liquidity: String!
# populated from the Burn event
sender: String
amount0: String
amount1: String
to: String
logIndex: Int
# derived amount based on available prices of tokens
amountUSD: String
# mark uncomplete in ETH case
needsComplete: Boolean!
# optional fee fields, if a Transfer event is fired in _mintFee
feeTo: String
feeLiquidity: String
}
type Swap @entity {
# transaction hash + "-" + index in swaps Transaction array
id: ID!
transaction: Transaction!
timestamp: DateTime! # need this to pull recent txns for specific token or pair
pair: Pair!
# populated from the Swap event
sender: String!
from: String! # the EOA that initiated the txn
amount0In: String!
amount1In: String!
amount0Out: String!
amount1Out: String!
to: String!
logIndex: Int
# derived info
amountUSD: String!
}
type Bundle @entity {
id: ID!
"BigDecimal"
ethPrice: String! # price of ETH usd
}
type FactoryDayData @entity {
id: ID! # timestamp rounded to current day by dividing by 86400
date: DateTime!
dailyVolumeETH: String!
dailyVolumeUSD: String!
dailyVolumeUntracked: String!
totalVolumeETH: String!
totalLiquidityETH: String!
totalVolumeUSD: String! # Accumulate at each trade, not just calculated off whatever totalVolume is. making it more accurate as it is a live conversion
totalLiquidityUSD: String!
txCount: Int!
}
type PairHourData @entity {
id: ID!
hourStartUnix: BigInt! # unix timestamp for start of hour
pair: Pair!
# reserves
reserve0: String!
reserve1: String!
# total supply for LP historical returns
totalSupply: String!
# derived liquidity
reserveUSD: String!
# volume stats
hourlyVolumeToken0: String!
hourlyVolumeToken1: String!
hourlyVolumeUSD: String!
hourlyTxns: Int!
}
type PairDayData @entity {
id: ID!
date: DateTime!
pairAddress: String!
pair: Pair!
token0: Token!
token1: Token!
# reserves
reserve0: String!
reserve1: String!
# total supply for LP historical returns
totalSupply: String!
# derived String
reserveUSD: String!
# volume stats
dailyVolumeToken0: String!
dailyVolumeToken1: String!
dailyVolumeUSD: String!
dailyTxns: Int!
}
type TokenDayData @entity {
id: ID!
date: DateTime!
token: Token!
# volume stats
dailyVolumeToken: String!
dailyVolumeETH: String!
dailyVolumeUSD: String!
dailyTxns: Int!
# liquidity stats
totalLiquidityToken: String!
totalLiquidityETH: String!
totalLiquidityUSD: String!
# price stats
priceUSD: String!
}
type StableSwapDayData @entity {
id: ID!
date: DateTime!
stableSwap: StableSwap!
dailyVolumeUSD: String!
tvlUSD: String!
}
type StableSwapHourData @entity {
id: ID!
hourStartUnix: BigInt! # unix timestamp for start of hour
stableSwap: StableSwap!
hourlyVolumeUSD: String!
tvlUSD: String!
}
type StableDayData @entity {
id: ID!
date: DateTime!
dailyVolumeUSD: String!
tvlUSD: String!
}
type ZenlinkDayInfo @entity {
id: ID!
date: DateTime!
standardInfo: FactoryDayData!
stableInfo: StableSwapDayData!
dailyVolumeUSD: String!
tvlUSD: String!
}
type SingleTokenLockDayData @entity {
id: ID!
singleTokenLock: SingleTokenLock!
date: DateTime!
totalLiquidity: String!
totalLiquidityUSD: String!
totalLiquidityETH: String!
}
type SingleTokenLockHourData @entity {
id: ID!
hourStartUnix: BigInt! # unix timestamp for start of hour
singleTokenLock: SingleTokenLock!
totalLiquidity: String!
totalLiquidityUSD: String!
totalLiquidityETH: String!
}
type SingleTokenLock @entity {
id: ID!
token: Token!
totalLiquidityUSD: String!
totalLiquidity: String!
totalLiquidityETH: String!
singleTokenLockDayData:[SingleTokenLockDayData!] @derivedFrom(field: "singleTokenLock")
singleTokenLockHourData:[SingleTokenLockHourData!] @derivedFrom(field: "singleTokenLock")
farm: [Farm!] @derivedFrom(field: "singleTokenLock")
}
type StakePosition @entity {
id: ID!
user: User!
farm: Farm!
liquidityStakedBalance: BigInt!
}
type Farm @entity {
id: ID!
pid: BigInt!
singleTokenLock: SingleTokenLock
stableSwap: StableSwap
pair: Pair
stakeToken: String!
liquidityStaked: BigInt!
createdAtBlock: BigInt!
createdAtTimestamp: BigInt!
# stake apr
stakedUSD: String!
rewardUSDPerDay: String!
stakeApr: String!
incentives: [Incentive!]! @derivedFrom(field: "farm")
stakePositions: [StakePosition!] @derivedFrom(field: "farm")
}
type Incentive @entity {
id: ID!
farm: Farm!
rewardToken: Token!
rewardPerDay: String!
}