-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.graphql
335 lines (285 loc) · 9.56 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
# -------------
# Actions
# -------------
enum ActionType {
Buy
Sell
Resell
Mint
Unmint
AddLiquidity
RemoveLiquidity
Exercise
Withdraw
TransferFrom
TransferTo
}
enum FeePoolType {
A
B
}
# -------------
# Elements
# -------------
type Metadata @entity {
id: ID!
optionsMintedAndSold: BigInt
feeA: Fee
feeB: Fee
}
type Action @entity {
"unique identifier resolving to the hash of the transaction (custom suffix for TransferFrom)"
id: ID!
"enum describing the type of transaction (e.g. Buy, Sell)"
type: ActionType!
"user entity triggering the action"
user: User!
"option entity for which the action is triggered"
option: Option!
"pool entity for which the action is triggered"
pool: Pool
"address of the caller"
from: Bytes!
"transaction hash"
hash: Bytes!
"amount resolving to the unix timestamp (millis) of the block that includes the action"
timestamp: Int!
"type (put/call) cloned from the option for filtering"
optionType: Int!
"amount resolving to an input for side A of the pool, the option tokens | for some cases it can hold the underlying amount for the action -- see readme"
inputTokenA: BigInt!
"amount resolving to an input for side B of the pool, the stablecoins | for some cases it can hold the strike or premium amount for the action -- see readme"
inputTokenB: BigInt!
"amount resolving to an output for side A of the pool, the option tokens"
outputTokenA: BigInt!
"amount resolving to an output for side B of the pool, the stablecoins"
outputTokenB: BigInt!
"structure (holding an amount) resolving to the spot price at the time of the action or trade"
spotPrice: SpotPrice
"special structure holding custom metadata on a case-by-case basis"
metadata: Metadata!
##### NEXT VALUES POST-ACTION ####
"amount tracking the implied volatility post-action"
nextIV: BigInt
"amount tracking the theoretical Black-Scholes price/premium for 1 option post-action"
nextABPrice: BigInt
"amount tracking the selling price for 1 option post-action"
nextSellingPrice: BigInt
"amount tracking the buying price for 1 option post-action"
nextBuyingPrice: BigInt
"amount tracking the selling price for the same amount of options as the current action, post-action (e.g. try to sell the same amount again)"
nextDynamicSellingPrice: BigInt
"amount tracking the buying price for the same amount of options as the current action, post-action (e.g. try to sell the same amount again)"
nextDynamicBuyingPrice: BigInt
"amount tracking this user's liquidity for side A of the pool, post-action"
nextUserTokenALiquidity: BigInt
"amount tracking this user's liquidity for side B of the pool, post-action"
nextUserTokenBLiquidity: BigInt
"amount tracking the total liquidity for side A of the pool, post-action"
nextTBA: BigInt
"amount tracking the total liquidity for side B of the pool, post-action"
nextTBB: BigInt
"amount tracking the deamortized balance for side A of the pool, post-action"
nextDBA: BigInt
"amount tracking the deamortized balance for side B of the pool, post-action"
nextDBB: BigInt
"amount *denominated in tokenB* tracking the balance of fees for side A of the pool, post-action"
nextFeesA: BigInt
"amount *denominated in tokenB* tracking the balance of fees for side B of the pool, post-action"
nextFeesB: BigInt
nextCollateralTVL: BigInt
nextPoolTokenATVL: BigInt
nextPoolTokenBTVL: BigInt
nextUserSnapshotFIMP: BigInt
nextUserTokenAOriginalBalance: BigInt
nextUserTokenBOriginalBalance: BigInt
}
type SpotPrice @entity {
id: ID!
"amount resolving to the spot price for the volatile asset at the time of the action"
value: BigInt!
action: Action
}
type FeePool @entity {
id: ID!
address: Bytes!
type: FeePoolType!
pool: Pool!
}
type Fee @entity {
id: ID!
feePool: FeePool!
value: BigInt!
metadata: Metadata
action: Action
}
type Manager @entity {
id: ID!
"entity array for all historical manager configurations"
configurations: [Configuration!]! @derivedFrom(field: "manager")
"entity storing the latest manager configuration that is actively used"
configuration: Configuration!
}
type Configuration @entity {
id: ID!
manager: Manager!
owner: Bytes!
optionFactory: OptionFactory
optionHelper: OptionHelper
poolFactory: PoolFactory
timestamp: Int!
}
type OptionFactory @entity {
id: ID!
options: [Option!] @derivedFrom(field: "factory")
}
type OptionHelper @entity {
id: ID!
}
type PoolFactory @entity {
id: ID!
pools: [Pool!] @derivedFrom(field: "factory")
}
type Option @entity {
"unique identifier resolving to the option address"
id: ID!
"address of the option token"
address: Bytes!
"address of the deployer"
from: Bytes!
"binary type resolving to 0 for PUT and 1 for CALL"
type: Int!
"binary type resolving to 0 for European and 1 for American"
exerciseType: Int!
"decimals of the ERC20 option token, usually 18"
decimals: BigInt!
"symbol for the ERC20 option token"
symbol: String!
"address of the underlying ERC20 token"
underlyingAsset: Bytes!
"address of the strike ERC20 token"
strikeAsset: Bytes!
"decimals of the underlying ERC20 token"
underlyingAssetDecimals: BigInt!
"decimals of the strike ERC20 token"
strikeAssetDecimals: BigInt!
"symbol of the underlying ERC20 token"
underlyingAssetSymbol: String!
"symbol of the strike ERC20 token"
strikeAssetSymbol: String!
"amount used as strike price, padded with decimals"
strikePrice: BigInt!
"amount resolving to the unix timestamp (millis) used as expiration"
expiration: Int!
"amount resolving to the duration (millis) used for the window of exercise"
exerciseWindowSize: Int!
# Generated or Bound
"actions such as Buy, Sell, Mint, ... linked to the option or the connected pool"
actions: [Action!]! @derivedFrom(field: "option")
"positions of the users (with >= 1 action) linked to the option or the connected pool"
positions: [Position!] @derivedFrom(field: "option")
"pool connected to the option 1:1"
pool: Pool
"amount resolving to the unix timestamp (millis) used as start moment for the window of exercise"
exerciseStart: Int
"factory (option factory) creating the option"
factory: OptionFactory!
"address of the inferred collateral ERC20 token (strike for PUT, underlying for CALL)"
collateralAsset: Bytes!
"decimals of the inferred collateral ERC20 token"
collateralAssetDecimals: BigInt!
"symbol of the inferred collateral ERC20 token"
collateralAssetSymbol: String!
# Series Data #
"amount *denominated in tokenB/strke* tracking the volume of fees (normally, removing liq. causes fees to be redeemed)"
seriesFeeVolume: BigInt!
}
type Pool @entity {
# Created
"unique identifier resolving to the option address"
id: ID!
"address of the option token"
address: Bytes!
"address of the deployer"
from: Bytes!
"option connected to the pool 1:1"
option: Option!
"factory (pool factory) creating the option"
factory: PoolFactory!
"address of the ERC20 token for side A of the pool, the option token"
tokenA: Bytes!
"address of the ERC20 token for side B of the pool, the stable token"
tokenB: Bytes!
"decimals of the ERC20 token for side A of the pool"
tokenADecimals: BigInt!
"decimals of the ERC20 token for side B of the pool"
tokenBDecimals: BigInt!
"symbol of the ERC20 token for side A of the pool"
tokenASymbol: String!
"symbol of the ERC20 token for side B of the pool"
tokenBSymbol: String!
"FeePool storing LP fees (accruing for side A of the pool)"
feePoolA: FeePool!
"FeePool storing LP fees (accruing for side B of the pool)"
feePoolB: FeePool!
}
type User @entity {
id: ID!
address: Bytes!
# Generated or Bound
actions: [Action!] @derivedFrom(field: "user")
positions: [Position!] @derivedFrom(field: "user")
}
type Position @entity {
id: ID!
user: User!
option: Option!
"expiration chosen as sortable param *cloned* from the option"
expiration: Int!
"Type chosen as sortable param *cloned* from the option"
optionType: Int!
# # # # # # # # #
"amount resolving to the total premium paid buying options"
premiumPaid: BigInt!
"amount resolving to the total premium received while selling or reselling options"
premiumReceived: BigInt!
#
# Buyer's cover
optionsBought: BigInt!
# Seller's goods
optionsSold: BigInt!
# Reseller's goods
optionsResold: BigInt!
#
# Minter's lock
optionsMinted: BigInt!
# Minter's release
optionsUnminted: BigInt!
#
# Exerciser options
optionsExercised: BigInt!
# Withdraw amounts
underlyingWithdrawn: BigInt!
strikeWithdrawn: BigInt!
#
# LP's input amounts
"amount resolving to the volume of option tokens provided by the user over the lifetime of the pool"
initialOptionsProvided: BigInt!
"amount resolving to the volume of stablecoins provided by the user over the lifetime of the pool"
initialTokensProvided: BigInt!
#
# LP's output/exit amounts
"amount resolving to the volume of option tokens removed by the user over the lifetime of the pool"
finalOptionsRemoved: BigInt!
"amount resolving to the volume of stablecoins removed by the user over the lifetime of the pool"
finalTokensRemoved: BigInt!
#
# LP's remaining amounts (changes after each addLiquidity, removeLiquidity, withdraw)
"amount resolving to the amount of option tokens currently available to remove from the pool"
remainingOptionsProvided: BigInt!
"amount resolving to the amount of stablecoins currently available to remove from the pool"
remainingTokensProvided: BigInt!
# Transfers
optionsSent: BigInt! # TransferFrom
optionsReceived: BigInt! # TransferTo
}