-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathschema.graphql
444 lines (405 loc) · 10.8 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
type SwapInterval @entity {
"interval"
id: ID!
"interval"
interval: BigInt!
"active interval"
active: Boolean!
}
type Pair @entity {
"address"
id: ID!
"tokenA"
tokenA: Token!
"tokenB"
tokenB: Token!
"positions ids"
activePositionIds: [String!]!
"active positions per interval: 0 index => 0 interval => amount of active positions"
activePositionsPerInterval: [BigInt!]!
"positions"
positions: [Position!]! @derivedFrom(field: "pair")
"last swapped executed at"
lastSwappedAt: [BigInt!]!
"oldest position created at"
oldestActivePositionCreatedAt: BigInt!
"swaps"
swaps: [PairSwap!]! @derivedFrom(field: "pair")
"swaps intervals"
swapsIntervals: [PairSwapInterval!]! @derivedFrom(field: "pair")
"created at transaction"
transaction: Transaction!
"created at block"
createdAtBlock: BigInt!
"created at timestamp"
createdAtTimestamp: BigInt!
}
enum POSITION_STATUS {
ACTIVE
TERMINATED
COMPLETED
}
type Position @entity {
"pair.id-position.id"
id: ID!
"user"
user: Bytes!
"from"
from: Token!
"to"
to: Token!
"pair"
pair: Pair!
"swap interval"
swapInterval: SwapInterval!
"position status"
status: POSITION_STATUS!
"permissions"
permissions: [PositionPermission!]!
"current rate of position"
rate: BigInt!
"deposited rate underlying (optional, only if type is a yield-bearing-share)"
depositedRateUnderlying: BigInt
"current remaining swaps"
remainingSwaps: BigInt!
"current amount that can be withdrawn (expressed in TO token)"
toWithdraw: BigInt!
"accum of the swapped, in terms of the underlying. underlying priced at the moment of the swap"
totalSwappedUnderlyingAccum: BigInt
"accum of the withdrawn, in terms of the underlying. underlying priced at the moment of the swap"
totalWithdrawnUnderlying: BigInt
"accum of the swapped that has not been withdrawn, in terms of the underlying. underlying priced at the moment of the swap"
toWithdrawUnderlyingAccum: BigInt
"withdrawn (expressed in TO token). needed to calculate toWithdraw."
withdrawn: BigInt!
"remaining liquidity (expressed in FROM token)"
remainingLiquidity: BigInt!
# Mimic on-chain swapped amounts
"swapped before modified"
swappedBeforeModified: BigInt!
"ratio accumulator. refers to on-chain rate accumulator"
ratioAccumulator: BigInt!
"total deposited expressed in (from)"
totalDeposited: BigInt!
"total withdrawno expressed in (to)"
totalWithdrawn: BigInt!
"historic total swapped (expressed in TO token)"
totalSwapped: BigInt!
"total swaps"
totalSwaps: BigInt!
"times it was swapped"
totalExecutedSwaps: BigInt!
"actions history"
history: [PositionActionInterface!]! @derivedFrom(field: "position")
"transaction"
transaction: Transaction!
"created at block"
createdAtBlock: BigInt!
"created at timestamp"
createdAtTimestamp: BigInt!
"terminated at block"
terminatedAtBlock: BigInt
"terminated at timestamp"
terminatedAtTimestamp: BigInt
}
enum PERMISSION {
INCREASE,
REDUCE,
WITHDRAW,
TERMINATE
}
type PositionPermission @entity {
"position.id-operator.address"
id: ID!
"operator"
operator: Bytes!
"permissions"
permissions: [PERMISSION!]!
}
type PairSwap @entity {
"pair.address-transaction.hash"
id: ID!
"pair"
pair: Pair!
"swapper"
swapper: Bytes!
"pair swap intervals"
pairSwapsIntervals: [PairSwapInterval!]! @derivedFrom(field: "pairSwap")
"ratio unit b to a"
ratioBToA: BigInt!
"ratio underlying unit b to a"
ratioUnderlyingBToA: BigInt
"ratio unit b to a with fee subtracted"
ratioBToAWithFee: BigInt!
"ratio underlying unit b to a with fee subtracted"
ratioUnderlyingBToAWithFee: BigInt
"ratio unit a to b"
ratioAToB: BigInt!
"ratio underlying unit a to b"
ratioUnderlyingAToB: BigInt
"ratio unit a to b with fee subtracted"
ratioAToBWithFee: BigInt!
"ratio underlying unit a to b with fee subtracted"
ratioUnderlyingAToBWithFee: BigInt
"executed with transaction"
transaction: Transaction!
"executed at block number"
executedAtBlock: BigInt!
"executed at timestamp"
executedAtTimestamp: BigInt!
}
type PairSwapInterval @entity {
"pairSwap.id-swapInterval.interval"
id: ID!
"pair"
pair: Pair!
"pair swap"
pairSwap: PairSwap!
"swap interval"
swapInterval: SwapInterval!
}
enum ACTION {
PERMISSIONS_MODIFIED # done
MODIFIED_RATE # done
MODIFIED_DURATION # done
MODIFIED_RATE_AND_DURATION # done
WITHDREW # done
SWAPPED # done
TRANSFERED # done
CREATED # done
TERMINATED
}
interface PositionActionInterface {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"transaction"
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type PermissionsModifiedAction implements PositionActionInterface @entity {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"new permissions set"
permissions: [PositionPermission!]!
"transaction"
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type ModifiedAction implements PositionActionInterface @entity {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"rate"
rate: BigInt!
"previous rate"
oldRate: BigInt!
"Distributed share value (optional, only if type is a yield-bearing-share)"
rateUnderlying: BigInt
"remaining swaps"
remainingSwaps: BigInt!
"previous remaining swaps"
oldRemainingSwaps: BigInt!
"Distributed share value (optional, only if type is a yield-bearing-share)"
oldRateUnderlying: BigInt
"transaction"
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type WithdrewAction implements PositionActionInterface @entity {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"withdrawn (expressed in TO token)"
withdrawn: BigInt!
"withdrawn underlying (optional, when to token is yield bearing share)"
withdrawnUnderlying: BigInt
"withdrawn underlying base accumulated since last withdraw (optional, when the token is yield bearing share)"
withdrawnUnderlyingAccum: BigInt
"transaction"
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type SwappedAction implements PositionActionInterface @entity {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"pair swap"
pairSwap: PairSwap!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"swapped (expressed in to)"
swapped: BigInt!
"swapped underlying (optional, only if type is a yield-bearing-share)"
swappedUnderlying: BigInt
"rate (expressed in from)"
rate: BigInt!
"Distributed share value (optional, only if type is a yield-bearing-share)"
depositedRateUnderlying: BigInt
"Current rate in underlying token (optional, only if type is a yield-bearing-share)"
rateUnderlying: BigInt
"transaction"
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type TransferedAction implements PositionActionInterface @entity {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"who transfers"
from: Bytes!
"to whom it transfers"
to: Bytes!
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type CreatedAction implements PositionActionInterface @entity {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"owner of the position"
owner: Bytes!
"rate"
rate: BigInt!
"Distributed share value (optional, only if type is a yield-bearing-share)"
rateUnderlying: BigInt
"remaining swaps"
remainingSwaps: BigInt!
"permissions set"
permissions: [PositionPermission!]!
"transaction"
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type TerminatedAction implements PositionActionInterface @entity {
"position.id-tx.hash-tx.index"
id: ID!
"position"
position: Position!
"action that caused the modification"
action: ACTION!
"actor who executed the action"
actor: Bytes!
"withdrawn swapped (expressed in TO token)"
withdrawnSwapped: BigInt!
"withdrawn swapped underlying (optional, when to token is yield bearing share)"
withdrawnSwappedUnderlying: BigInt
"withdrawn remaining (expressed in FROM token)"
withdrawnRemaining: BigInt!
"withdrawn remaining underlying (optional, when to token is yield bearing share)"
withdrawnRemainingUnderlying: BigInt
"withdrawn underlying base accumulated since last withdraw (optional, when the token is yield bearing share)"
withdrawnUnderlyingAccum: BigInt
"amount of underlying funds that remainged deposited before the withdraw. Basically depositedRateUnderlying * remainingSwaps (optional, when the token is yield bearing share)"
depositedRemainingUnderlying: BigInt
"transaction"
transaction: Transaction!
"createdAtBlock"
createdAtBlock: BigInt!
"createdAtTimestamp"
createdAtTimestamp: BigInt!
}
type Transaction @entity {
"transaction.hash-transaction.index"
id: ID!
"The event name / call stacktrace"
event: String!
"The transaction sender"
from: Bytes!
"Transaction hash"
hash: Bytes!
"The transaction index"
index: BigInt!
"Address that received the transaction"
to: Bytes!
"Ether value sent in the transaction"
value: BigInt!
"Gas price of the transaction"
gasPrice: BigInt!
"L1 gas fee used for a transaction on optimism"
l1GasPrice: BigInt
"fixed overhead used for a transaction on optimism"
overhead: BigInt
"Timestamp when the transaction was executed"
timestamp: BigInt!
"Block number"
blockNumber: BigInt!
}
enum TOKEN_TYPE {
BASE
WRAPPED_PROTOCOL_TOKEN
YIELD_BEARING_SHARE
}
type Token @entity {
"Token address"
id: ID!
"Name of the Token"
name: String!
"Symbol of the Token"
symbol: String!
"Allowed"
allowed: Boolean!
"Decimals"
decimals: Int!
"Magnitude"
magnitude: BigInt!
"Type of token"
type: TOKEN_TYPE!
"Underlying tokens"
underlyingTokens: [Token!]
}