forked from cowprotocol/subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.graphql
416 lines (400 loc) · 10.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
type User @entity {
"Trade event order owner"
id: ID!
"Owner's address"
address: Bytes!
"First trade block timestamp"
firstTradeTimestamp: Int!
"List of orders placed by this user"
ordersPlaced: [Order!]! @derivedFrom(field: "owner")
"Determine if user has solved a settlement"
isSolver: Boolean!
"Contains all the settlements solved by a solver"
settlementsSolved: [Settlement!]! @derivedFrom(field: "solver")
"The quantity of settlements solved by the user"
numberOfSettlements: Int
"Stores last time is solver flag changed"
lastIsSolverUpdateTimestamp: Int
"Solved trades"
numberOfTrades: Int! # write a how to do it in the query or add the prop.
"total amount solved by the user in Eth"
solvedAmountEth: BigDecimal
"total amount solved by the user in Usd"
solvedAmountUsd: BigDecimal
"total amount traded by the user in Usd"
tradedAmountUsd: BigDecimal
"total amount traded by the user in Eth"
tradedAmountEth: BigDecimal
}
type Token @entity {
"Token address to hexString"
id: ID!
"Token address"
address: Bytes!
"First token trade block timestamp"
firstTradeTimestamp: Int!
"Token name fetched by ERC20 contract call"
name: String!
"Token symbol fetched by contract call"
symbol: String!
"Token decimals fetched by contract call"
decimals: Int!
"Total volume managed in CowSwap"
totalVolume: BigInt!
"Derived price in ETH"
priceEth: BigDecimal
"Derived price in USD"
priceUsd: BigDecimal
"History of trading for this token"
history: [TokenTradingEvent!]! @derivedFrom(field: "token")
"Hourly totals"
hourlyTotals: [TokenHourlyTotal!]! @derivedFrom(field: "token")
"Daily totals"
dailyTotals: [TokenDailyTotal!]! @derivedFrom(field: "token")
"Total trades"
numberOfTrades: Int!
"Total volume in Usd"
totalVolumeUsd: BigDecimal!
"Total volume in Eth"
totalVolumeEth: BigDecimal!
}
type Order @entity {
"Trade's OrderUid to hex string"
id: ID!
"Trade's owner or presign User"
owner: User
"block's timestamp on trade event"
tradesTimestamp: Int
"block's timestamp on invalidate event"
invalidateTimestamp: Int
"block's timestamp on presign event"
presignTimestamp: Int
"Array of trades on the order"
trades: [Trade!] @derivedFrom(field: "order")
"Boolean value to show if the order is signed"
isSigned: Boolean
"Boolean value true by default unless is invalidated by the event"
isValid: Boolean
}
type Trade @entity {
"This Id is composed using orderId|txHashString|eventIndex"
id: ID!
"Block's timestamp"
timestamp: Int!
"Transaction's gas price"
gasPrice: BigInt!
"Trade's fee amount"
feeAmount: BigInt!
"Trade's fee amount in Usd"
feeAmountUsd: BigDecimal
"Trade's fee amount in Eth"
feeAmountEth: BigDecimal
"Trade event transaction hash"
txHash: Bytes!
"Settlement"
settlement: Settlement!
"Trade event buyAmount"
buyAmount: BigInt!
"Trade event sellAmount"
sellAmount: BigInt!
"Trade event sellToken"
sellToken: Token!
"Trade event buyToken"
buyToken: Token!
"Order"
order: Order!
"Buy amount in Eth"
buyAmountEth: BigDecimal
"Sell amount in Eth"
sellAmountEth: BigDecimal
"Buy amount in Usd"
buyAmountUsd: BigDecimal
"Sell amount in Usd"
sellAmountUsd: BigDecimal
gasUsed: BigInt!
}
type Settlement @entity {
"TxHash"
id: ID!
"Transaction hash"
txHash: Bytes!
"Block number"
blockNumber: BigInt!
"First trade timestamp"
firstTradeTimestamp: Int!
"Collection of trades"
trades: [Trade!] @derivedFrom(field: "settlement")
"User who solved the settlement"
solver: User
"Transaction cost in USD"
txCostUsd: BigDecimal!
"Transaction cost in Native currency"
txCostNative: BigDecimal!
"Trade's fee amount accumulated in Usd"
aggregatedFeeAmountUsd: BigDecimal!
"Profitability is aggregatedFeeAmountUsd minus txCostUsd"
profitability: BigDecimal!
}
# stores for USD calculations
type Bundle @entity {
"Singleton #1"
id: ID!
"Price of ETH in usd"
ethPriceUSD: BigDecimal!
}
type UniswapPool @entity {
"Pool address"
id: ID!
"Token0"
token0: UniswapToken!
"Token1"
token1: UniswapToken!
"In range liquidity"
liquidity: BigInt!
"Token0 per token1"
token0Price: BigDecimal!
"Token1 per token0"
token1Price: BigDecimal!
"Current tick"
tick: BigInt
"Total token 0 across all ticks"
totalValueLockedToken0: BigDecimal!
"Total token 1 across all ticks"
totalValueLockedToken1: BigDecimal!
}
type UniswapToken @entity {
"Token address to hexString"
id: ID!
"Token address"
address: Bytes!
"Token name fetched by ERC20 contract call"
name: String!
"Token symbol fetched by contract call"
symbol: String!
"Token decimals fetched by contract call"
decimals: Int!
"Derived price in ETH"
priceEth: BigDecimal
"Derived price in USD"
priceUsd: BigDecimal
"Pools token is in that are allow listed for USD pricing"
allowedPools: [UniswapToken!]!
}
type Total @entity {
"This is a singleton entity to contain accumulators for all values. Id will be always 1"
id: ID!
"Total number of tokens traded"
tokens: BigInt!
"Total number of orders placed"
orders: BigInt!
"Total number of traders"
traders: BigInt!
"Number of trades"
numberOfTrades: BigInt!
"Total number of batches settled"
settlements: BigInt!
"Total traded volume in USD"
volumeUsd: BigDecimal
"Total traded volume in ETH"
volumeEth: BigDecimal
"Total fees in USD"
feesUsd: BigDecimal
"Total fees in Eth"
feesEth: BigDecimal
}
type DailyTotal @entity {
"Day timestamp"
id: ID!
"Start day timestamp"
timestamp: Int!
"Number of trades"
numberOfTrades: BigInt!
"Total number of orders placed"
orders: BigInt!
"Total number of batches settled"
settlements: BigInt!
"Total traded volume in USD"
volumeUsd: BigDecimal
"Total traded volume in ETH"
volumeEth: BigDecimal
"Total fees in USD"
feesUsd: BigDecimal
"Total fees in Eth"
feesEth: BigDecimal
# we will remove this props for now. deltails in the following link
# https://github.com/cowprotocol/subgraph/issues/47#issuecomment-1183515135
# "Traded tokens"
# tokens: [Token!]!
# "Total number of tokens traded"
# totalTokens: BigInt!
}
type HourlyTotal @entity {
"Hour timestamp"
id: ID!
"Start hour timestamp"
timestamp: Int!
"Number of trades"
numberOfTrades: BigInt!
"Total number of orders placed"
orders: BigInt!
"Total number of batches settled"
settlements: BigInt!
"Total traded volume in USD"
volumeUsd: BigDecimal
"Total traded volume in ETH"
volumeEth: BigDecimal
"Total fees in USD"
feesUsd: BigDecimal
"Total fees in Eth"
feesEth: BigDecimal
# we will remove this props for now. deltails in the following link
# https://github.com/cowprotocol/subgraph/issues/47#issuecomment-1183515135
# "Total number of tokens traded"
# totalTokens: BigInt!
# "Traded tokens"
# tokens: [Token!]!
}
type TokenDailyTotal @entity {
"TokenAddress + timestamp day"
id: ID!
"Token address"
token: Token!
"Start day timestamp"
timestamp: Int!
"Total volume traded that day in token"
totalVolume: BigInt!
"Total amount traded that day in USD"
totalVolumeUsd: BigDecimal!
"Total amount traded that day in ETH"
totalVolumeEth: BigDecimal!
"Number of trades that day"
totalTrades: BigInt!
"First trade price"
openPrice: BigDecimal!
"Last trade price"
closePrice: BigDecimal!
"Higher trade price"
higherPrice: BigDecimal!
"Lower trade price"
lowerPrice: BigDecimal!
"Average trade price"
averagePrice: BigDecimal!
}
type TokenHourlyTotal @entity {
"TokenAddress + timestamp hour"
id: ID!
"Token address"
token: Token!
"Start hour timestamp"
timestamp: Int!
"Total volume traded that day in token"
totalVolume: BigInt!
"Total amount traded that hour in USD"
totalVolumeUsd: BigDecimal!
"Total amount traded that hour in ETH"
totalVolumeEth: BigDecimal!
"Number of trades that hour"
totalTrades: BigInt!
"First trade price"
openPrice: BigDecimal!
"Last trade price"
closePrice: BigDecimal!
"Higher trade price"
higherPrice: BigDecimal!
"Lower trade price"
lowerPrice: BigDecimal!
"Average trade price"
averagePrice: BigDecimal!
}
type TokenTradingEvent @entity {
"Id built using token-timestamp"
id: ID!
"Token"
token: Token!
"Trade"
trade: Trade!
"Timestamp"
timestamp: Int!
"Amount in Eth"
amountEth: BigDecimal
"Amount in Usd"
amountUsd: BigDecimal
}
type Pair @entity {
"Token0-token1 sorted by token0 < token1"
id: ID!
"The token 0 address lower than token1"
token0: Token!
"The token 1 address greater than token0"
token1: Token!
"Last trade timestamp"
lastTradeTimestamp: Int!
"Token0 last trade price in USD"
token0Usd: BigDecimal
"Token1 last trade price in USD"
token1Usd: BigDecimal
"Token 0 price expressed in token1 in the last trade"
token0PriceInToken1: BigDecimal
"Token 1 price expressed in token1 in the last trade"
token1PriceInToken0: BigDecimal
"Total volume of token 0 traded"
volumeToken0: BigInt!
"Total volume of token 1 traded"
volumeToken1: BigInt!
"Total volume in Eth"
volumeTradedEth: BigDecimal
"Total volume in Usd"
volumeTradedUsd: BigDecimal
}
type PairDaily @entity {
"token0-token1-timestamp sorted by token0 < token1"
id: ID!
"The token 0 address lower than token1"
token0: Token!
"The token 1 address greater than token0"
token1: Token!
"Token0 last trade price in USD"
token0Usd: BigDecimal
"Token1 last trade price in USD"
token1Usd: BigDecimal
"Token 0 price expressed in token1 in the last trade"
token0PriceInToken1: BigDecimal
"Token 1 price expressed in token1 in the last trade"
token1PriceInToken0: BigDecimal
"Start day timestamp"
timestamp: Int!
"Total volume of token 0 traded"
volumeToken0: BigInt!
"Total volume of token 1 traded"
volumeToken1: BigInt!
"Total volume in Eth"
volumeTradedEth: BigDecimal
"Total volume in Usd"
volumeTradedUsd: BigDecimal
}
type PairHourly @entity {
"token0-token1-timestamp sorted by token0 < token1"
id: ID!
"The token 0 address lower than token1"
token0: Token!
"The token 1 address greater than token0"
token1: Token!
"Token0 last trade price in USD"
token0Usd: BigDecimal
"Token1 last trade price in USD"
token1Usd: BigDecimal
"Token 0 price expressed in token1 in the last trade"
token0PriceInToken1: BigDecimal
"Token 1 price expressed in token1 in the last trade"
token1PriceInToken0: BigDecimal
"Start hour timestamp"
timestamp: Int!
"Total volume of token 0 traded"
volumeToken0: BigInt!
"Total volume of token 1 traded"
volumeToken1: BigInt!
"Total volume in Eth"
volumeTradedEth: BigDecimal
"Total volume in Usd"
volumeTradedUsd: BigDecimal
}