timelock-sdk 0.0.252 → 0.0.254
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +72 -605
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1094 -1528
- package/dist/client.d.ts +6 -440
- package/dist/client.js +27 -559
- package/dist/client.js.map +1 -1
- package/dist/{numberUtils-CUbVfzKW.cjs → graphql-B4hXFsA2.cjs} +565 -1
- package/dist/graphql-B4hXFsA2.cjs.map +1 -0
- package/dist/{numberUtils-DPuYZOq0.js → graphql-OwLorEip.js} +553 -2
- package/dist/graphql-OwLorEip.js.map +1 -0
- package/dist/{index-Mexa2pa7.d.ts → index-CNYDmu55.d.ts} +435 -14
- package/dist/{index-CZkMlf3x.d.cts → index-C_d6dHDk.d.cts} +435 -14
- package/dist/package.cjs +51 -49
- package/dist/package.cjs.map +1 -1
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/package.json +1 -1
- package/dist/numberUtils-CUbVfzKW.cjs.map +0 -1
- package/dist/numberUtils-DPuYZOq0.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,558 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const require_graphql = require('./graphql-B4hXFsA2.cjs');
|
|
4
4
|
const require_stateView = require('./stateView-BXg8tiiy.cjs');
|
|
5
5
|
const require_factory = require('./factory-CzYOPurN.cjs');
|
|
6
6
|
let viem = require("viem");
|
|
7
7
|
let react = require("react");
|
|
8
|
-
react =
|
|
9
|
-
let graphql_request = require("graphql-request");
|
|
10
|
-
let graphql_tag = require("graphql-tag");
|
|
11
|
-
graphql_tag = require_numberUtils.__toESM(graphql_tag);
|
|
8
|
+
react = require_graphql.__toESM(react);
|
|
12
9
|
let wagmi = require("wagmi");
|
|
13
10
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
14
11
|
let viem_actions = require("viem/actions");
|
|
15
12
|
|
|
16
|
-
//#region src/generated/timelock.ts
|
|
17
|
-
const UserOptionFieldsFragmentDoc = graphql_tag.default`
|
|
18
|
-
fragment UserOptionFields on UserOption {
|
|
19
|
-
id
|
|
20
|
-
optionId
|
|
21
|
-
owner {
|
|
22
|
-
address
|
|
23
|
-
}
|
|
24
|
-
market {
|
|
25
|
-
address
|
|
26
|
-
}
|
|
27
|
-
optionType
|
|
28
|
-
strikeTick
|
|
29
|
-
startTick
|
|
30
|
-
strikePrice
|
|
31
|
-
entryPrice
|
|
32
|
-
expiresAt
|
|
33
|
-
createdAt
|
|
34
|
-
premium
|
|
35
|
-
protocolFee
|
|
36
|
-
realizedPayout
|
|
37
|
-
liquiditiesAtOpen
|
|
38
|
-
liquiditiesCurrent
|
|
39
|
-
positionSizeAtOpen
|
|
40
|
-
positionSizeCurrent
|
|
41
|
-
fullyExercised
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
|
-
const GetActiveUserOptionsDocument = graphql_tag.default`
|
|
45
|
-
query GetActiveUserOptions($userAddr: String!) {
|
|
46
|
-
UserOption(
|
|
47
|
-
where: {owner: {address: {_eq: $userAddr}}, fullyExercised: {_eq: false}}
|
|
48
|
-
limit: 1000
|
|
49
|
-
) {
|
|
50
|
-
...UserOptionFields
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
${UserOptionFieldsFragmentDoc}
|
|
54
|
-
`;
|
|
55
|
-
const GetActiveUserOptionsByMarketDocument = graphql_tag.default`
|
|
56
|
-
query GetActiveUserOptionsByMarket($userAddr: String!, $marketAddr: String!) {
|
|
57
|
-
UserOption(
|
|
58
|
-
where: {
|
|
59
|
-
owner: {address: {_eq: $userAddr}}
|
|
60
|
-
fullyExercised: {_eq: false}
|
|
61
|
-
market: {address: {_eq: $marketAddr}}
|
|
62
|
-
}
|
|
63
|
-
limit: 1000
|
|
64
|
-
) {
|
|
65
|
-
...UserOptionFields
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
${UserOptionFieldsFragmentDoc}
|
|
69
|
-
`;
|
|
70
|
-
const GetClosedUserOptionsDocument = graphql_tag.default`
|
|
71
|
-
query GetClosedUserOptions($userAddr: String!) {
|
|
72
|
-
UserOption(
|
|
73
|
-
where: {owner: {address: {_eq: $userAddr}}, fullyExercised: {_eq: true}}
|
|
74
|
-
limit: 1000
|
|
75
|
-
) {
|
|
76
|
-
...UserOptionFields
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
${UserOptionFieldsFragmentDoc}
|
|
80
|
-
`;
|
|
81
|
-
const GetClosedUserOptionsByMarketDocument = graphql_tag.default`
|
|
82
|
-
query GetClosedUserOptionsByMarket($userAddr: String!, $marketAddr: String!) {
|
|
83
|
-
UserOption(
|
|
84
|
-
where: {
|
|
85
|
-
owner: {address: {_eq: $userAddr}}
|
|
86
|
-
fullyExercised: {_eq: true}
|
|
87
|
-
market: {address: {_eq: $marketAddr}}
|
|
88
|
-
}
|
|
89
|
-
limit: 1000
|
|
90
|
-
) {
|
|
91
|
-
...UserOptionFields
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
${UserOptionFieldsFragmentDoc}
|
|
95
|
-
`;
|
|
96
|
-
const GetMarketDataDocument = graphql_tag.default`
|
|
97
|
-
query GetMarketData($marketAddr: String!) {
|
|
98
|
-
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
99
|
-
id
|
|
100
|
-
address
|
|
101
|
-
vault
|
|
102
|
-
tickSpacing
|
|
103
|
-
optionAssetIsToken0
|
|
104
|
-
optionAsset
|
|
105
|
-
payoutAsset
|
|
106
|
-
optionAssetDecimals
|
|
107
|
-
payoutAssetDecimals
|
|
108
|
-
optionAssetSymbol
|
|
109
|
-
payoutAssetSymbol
|
|
110
|
-
optionAssetName
|
|
111
|
-
payoutAssetName
|
|
112
|
-
poolManager
|
|
113
|
-
currency0
|
|
114
|
-
currency1
|
|
115
|
-
fee
|
|
116
|
-
hooks
|
|
117
|
-
tickSpacing
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
`;
|
|
121
|
-
const GetMarketVolumeDocument = graphql_tag.default`
|
|
122
|
-
query GetMarketVolume($marketAddr: String!) {
|
|
123
|
-
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
124
|
-
id
|
|
125
|
-
address
|
|
126
|
-
optionsCount
|
|
127
|
-
tradersCount
|
|
128
|
-
totalVolume
|
|
129
|
-
totalPremium
|
|
130
|
-
totalPayout
|
|
131
|
-
totalProtocolFee
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
`;
|
|
135
|
-
const GetMarketDailyVolumeDocument = graphql_tag.default`
|
|
136
|
-
query GetMarketDailyVolume($marketAddr: String!) {
|
|
137
|
-
MarketDailyData(
|
|
138
|
-
where: {market: {address: {_eq: $marketAddr}}}
|
|
139
|
-
order_by: {date: asc}
|
|
140
|
-
) {
|
|
141
|
-
id
|
|
142
|
-
date
|
|
143
|
-
totalVolume
|
|
144
|
-
totalPremium
|
|
145
|
-
totalPayout
|
|
146
|
-
totalProtocolFee
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
`;
|
|
150
|
-
const GetMarketUserVolumeDocument = graphql_tag.default`
|
|
151
|
-
query GetMarketUserVolume($marketAddr: String!, $userAddr: String!) {
|
|
152
|
-
TimelockMarketUser(
|
|
153
|
-
where: {address: {_eq: $userAddr}, market: {address: {_eq: $marketAddr}}}
|
|
154
|
-
limit: 1
|
|
155
|
-
) {
|
|
156
|
-
address
|
|
157
|
-
totalVolume
|
|
158
|
-
totalPayout
|
|
159
|
-
totalPremium
|
|
160
|
-
totalProtocolFee
|
|
161
|
-
optionsCount
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
`;
|
|
165
|
-
const GetUserMarketOperatorsDocument = graphql_tag.default`
|
|
166
|
-
query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
|
|
167
|
-
UserMarketOperator(
|
|
168
|
-
where: {
|
|
169
|
-
user: {address: {_eq: $userAddr}}
|
|
170
|
-
market: {address: {_eq: $marketAddr}}
|
|
171
|
-
}
|
|
172
|
-
limit: 1000
|
|
173
|
-
) {
|
|
174
|
-
id
|
|
175
|
-
operator {
|
|
176
|
-
address
|
|
177
|
-
}
|
|
178
|
-
canExtend
|
|
179
|
-
canExercise
|
|
180
|
-
canTransfer
|
|
181
|
-
canMint
|
|
182
|
-
spendingApproval
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
`;
|
|
186
|
-
const GetOptionEventsDocument = graphql_tag.default`
|
|
187
|
-
query GetOptionEvents($marketAddr: String!, $optionId: numeric!) {
|
|
188
|
-
MintOptionEvent(
|
|
189
|
-
where: {
|
|
190
|
-
option: {
|
|
191
|
-
optionId: {_eq: $optionId}
|
|
192
|
-
market: {address: {_eq: $marketAddr}}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
limit: 1000
|
|
196
|
-
) {
|
|
197
|
-
id
|
|
198
|
-
optionType
|
|
199
|
-
strikeTick
|
|
200
|
-
price
|
|
201
|
-
expiresAt
|
|
202
|
-
premium
|
|
203
|
-
protocolFee
|
|
204
|
-
liquidities
|
|
205
|
-
timestamp
|
|
206
|
-
blockNumber
|
|
207
|
-
transactionHash
|
|
208
|
-
}
|
|
209
|
-
ExerciseOptionEvent(
|
|
210
|
-
where: {
|
|
211
|
-
option: {
|
|
212
|
-
market: {address: {_eq: $marketAddr}}
|
|
213
|
-
optionId: {_eq: $optionId}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
limit: 1000
|
|
217
|
-
) {
|
|
218
|
-
id
|
|
219
|
-
liquidities
|
|
220
|
-
payout
|
|
221
|
-
timestamp
|
|
222
|
-
blockNumber
|
|
223
|
-
transactionHash
|
|
224
|
-
}
|
|
225
|
-
ExtendOptionEvent(
|
|
226
|
-
where: {
|
|
227
|
-
option: {
|
|
228
|
-
market: {address: {_eq: $marketAddr}}
|
|
229
|
-
optionId: {_eq: $optionId}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
limit: 1000
|
|
233
|
-
) {
|
|
234
|
-
id
|
|
235
|
-
premium
|
|
236
|
-
protocolFee
|
|
237
|
-
price
|
|
238
|
-
addedDuration
|
|
239
|
-
timestamp
|
|
240
|
-
blockNumber
|
|
241
|
-
transactionHash
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
`;
|
|
245
|
-
const defaultWrapper$1 = (action, _operationName, _operationType, _variables) => action();
|
|
246
|
-
function getSdk$1(client, withWrapper = defaultWrapper$1) {
|
|
247
|
-
return {
|
|
248
|
-
GetActiveUserOptions(variables, requestHeaders, signal) {
|
|
249
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
250
|
-
document: GetActiveUserOptionsDocument,
|
|
251
|
-
variables,
|
|
252
|
-
requestHeaders: {
|
|
253
|
-
...requestHeaders,
|
|
254
|
-
...wrappedRequestHeaders
|
|
255
|
-
},
|
|
256
|
-
signal
|
|
257
|
-
}), "GetActiveUserOptions", "query", variables);
|
|
258
|
-
},
|
|
259
|
-
GetActiveUserOptionsByMarket(variables, requestHeaders, signal) {
|
|
260
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
261
|
-
document: GetActiveUserOptionsByMarketDocument,
|
|
262
|
-
variables,
|
|
263
|
-
requestHeaders: {
|
|
264
|
-
...requestHeaders,
|
|
265
|
-
...wrappedRequestHeaders
|
|
266
|
-
},
|
|
267
|
-
signal
|
|
268
|
-
}), "GetActiveUserOptionsByMarket", "query", variables);
|
|
269
|
-
},
|
|
270
|
-
GetClosedUserOptions(variables, requestHeaders, signal) {
|
|
271
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
272
|
-
document: GetClosedUserOptionsDocument,
|
|
273
|
-
variables,
|
|
274
|
-
requestHeaders: {
|
|
275
|
-
...requestHeaders,
|
|
276
|
-
...wrappedRequestHeaders
|
|
277
|
-
},
|
|
278
|
-
signal
|
|
279
|
-
}), "GetClosedUserOptions", "query", variables);
|
|
280
|
-
},
|
|
281
|
-
GetClosedUserOptionsByMarket(variables, requestHeaders, signal) {
|
|
282
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
283
|
-
document: GetClosedUserOptionsByMarketDocument,
|
|
284
|
-
variables,
|
|
285
|
-
requestHeaders: {
|
|
286
|
-
...requestHeaders,
|
|
287
|
-
...wrappedRequestHeaders
|
|
288
|
-
},
|
|
289
|
-
signal
|
|
290
|
-
}), "GetClosedUserOptionsByMarket", "query", variables);
|
|
291
|
-
},
|
|
292
|
-
GetMarketData(variables, requestHeaders, signal) {
|
|
293
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
294
|
-
document: GetMarketDataDocument,
|
|
295
|
-
variables,
|
|
296
|
-
requestHeaders: {
|
|
297
|
-
...requestHeaders,
|
|
298
|
-
...wrappedRequestHeaders
|
|
299
|
-
},
|
|
300
|
-
signal
|
|
301
|
-
}), "GetMarketData", "query", variables);
|
|
302
|
-
},
|
|
303
|
-
GetMarketVolume(variables, requestHeaders, signal) {
|
|
304
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
305
|
-
document: GetMarketVolumeDocument,
|
|
306
|
-
variables,
|
|
307
|
-
requestHeaders: {
|
|
308
|
-
...requestHeaders,
|
|
309
|
-
...wrappedRequestHeaders
|
|
310
|
-
},
|
|
311
|
-
signal
|
|
312
|
-
}), "GetMarketVolume", "query", variables);
|
|
313
|
-
},
|
|
314
|
-
GetMarketDailyVolume(variables, requestHeaders, signal) {
|
|
315
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
316
|
-
document: GetMarketDailyVolumeDocument,
|
|
317
|
-
variables,
|
|
318
|
-
requestHeaders: {
|
|
319
|
-
...requestHeaders,
|
|
320
|
-
...wrappedRequestHeaders
|
|
321
|
-
},
|
|
322
|
-
signal
|
|
323
|
-
}), "GetMarketDailyVolume", "query", variables);
|
|
324
|
-
},
|
|
325
|
-
GetMarketUserVolume(variables, requestHeaders, signal) {
|
|
326
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
327
|
-
document: GetMarketUserVolumeDocument,
|
|
328
|
-
variables,
|
|
329
|
-
requestHeaders: {
|
|
330
|
-
...requestHeaders,
|
|
331
|
-
...wrappedRequestHeaders
|
|
332
|
-
},
|
|
333
|
-
signal
|
|
334
|
-
}), "GetMarketUserVolume", "query", variables);
|
|
335
|
-
},
|
|
336
|
-
GetUserMarketOperators(variables, requestHeaders, signal) {
|
|
337
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
338
|
-
document: GetUserMarketOperatorsDocument,
|
|
339
|
-
variables,
|
|
340
|
-
requestHeaders: {
|
|
341
|
-
...requestHeaders,
|
|
342
|
-
...wrappedRequestHeaders
|
|
343
|
-
},
|
|
344
|
-
signal
|
|
345
|
-
}), "GetUserMarketOperators", "query", variables);
|
|
346
|
-
},
|
|
347
|
-
GetOptionEvents(variables, requestHeaders, signal) {
|
|
348
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
349
|
-
document: GetOptionEventsDocument,
|
|
350
|
-
variables,
|
|
351
|
-
requestHeaders: {
|
|
352
|
-
...requestHeaders,
|
|
353
|
-
...wrappedRequestHeaders
|
|
354
|
-
},
|
|
355
|
-
signal
|
|
356
|
-
}), "GetOptionEvents", "query", variables);
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/generated/univ4.ts
|
|
363
|
-
const GetPoolVolumeDocument = graphql_tag.default`
|
|
364
|
-
query GetPoolVolume($poolId: String!) {
|
|
365
|
-
Pool(where: {id: {_eq: $poolId}}) {
|
|
366
|
-
id
|
|
367
|
-
volume0
|
|
368
|
-
volume1
|
|
369
|
-
fees0
|
|
370
|
-
fees1
|
|
371
|
-
txCount
|
|
372
|
-
swapCount
|
|
373
|
-
modifyLiquidityCount
|
|
374
|
-
positionCount
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
`;
|
|
378
|
-
const GetPoolUserVolumeDocument = graphql_tag.default`
|
|
379
|
-
query GetPoolUserVolume($poolId: String!, $userAddr: String!) {
|
|
380
|
-
PoolUser(where: {pool: {id: {_eq: $poolId}}, address: {_eq: $userAddr}}) {
|
|
381
|
-
address
|
|
382
|
-
volume0
|
|
383
|
-
volume1
|
|
384
|
-
fees0
|
|
385
|
-
fees1
|
|
386
|
-
swapCount
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
`;
|
|
390
|
-
const GetLpFeesDocument = graphql_tag.default`
|
|
391
|
-
query GetLPFees($lpId: String!) {
|
|
392
|
-
LiquidityProvider(where: {id: {_eq: $lpId}}) {
|
|
393
|
-
id
|
|
394
|
-
fees0
|
|
395
|
-
fees1
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
`;
|
|
399
|
-
const GetPoolDayDataDocument = graphql_tag.default`
|
|
400
|
-
query GetPoolDayData(
|
|
401
|
-
$poolId: String!
|
|
402
|
-
$startTimestamp: Int
|
|
403
|
-
$endTimestamp: Int
|
|
404
|
-
$limit: Int
|
|
405
|
-
$offset: Int
|
|
406
|
-
) {
|
|
407
|
-
PoolDayData(
|
|
408
|
-
where: {
|
|
409
|
-
pool: {id: {_eq: $poolId}}
|
|
410
|
-
startTimestamp: {_gte: $startTimestamp, _lte: $endTimestamp}
|
|
411
|
-
}
|
|
412
|
-
order_by: {startTimestamp: asc}
|
|
413
|
-
limit: $limit
|
|
414
|
-
offset: $offset
|
|
415
|
-
) {
|
|
416
|
-
startTimestamp
|
|
417
|
-
volume0
|
|
418
|
-
volume1
|
|
419
|
-
open_
|
|
420
|
-
high
|
|
421
|
-
low
|
|
422
|
-
close
|
|
423
|
-
sqrtPriceX96
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
`;
|
|
427
|
-
const GetPoolHourDataDocument = graphql_tag.default`
|
|
428
|
-
query GetPoolHourData(
|
|
429
|
-
$poolId: String!
|
|
430
|
-
$startTimestamp: Int
|
|
431
|
-
$endTimestamp: Int
|
|
432
|
-
$limit: Int
|
|
433
|
-
$offset: Int
|
|
434
|
-
) {
|
|
435
|
-
PoolHourData(
|
|
436
|
-
where: {
|
|
437
|
-
pool: {id: {_eq: $poolId}}
|
|
438
|
-
startTimestamp: {_gte: $startTimestamp, _lte: $endTimestamp}
|
|
439
|
-
}
|
|
440
|
-
order_by: {startTimestamp: asc}
|
|
441
|
-
limit: $limit
|
|
442
|
-
offset: $offset
|
|
443
|
-
) {
|
|
444
|
-
startTimestamp
|
|
445
|
-
volume0
|
|
446
|
-
volume1
|
|
447
|
-
open_
|
|
448
|
-
high
|
|
449
|
-
low
|
|
450
|
-
close
|
|
451
|
-
sqrtPriceX96
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
`;
|
|
455
|
-
const GetPool5MinuteDataDocument = graphql_tag.default`
|
|
456
|
-
query GetPool5MinuteData(
|
|
457
|
-
$poolId: String!
|
|
458
|
-
$startTimestamp: Int
|
|
459
|
-
$endTimestamp: Int
|
|
460
|
-
$limit: Int
|
|
461
|
-
$offset: Int
|
|
462
|
-
) {
|
|
463
|
-
Pool5MinuteData(
|
|
464
|
-
where: {
|
|
465
|
-
pool: {id: {_eq: $poolId}}
|
|
466
|
-
startTimestamp: {_gte: $startTimestamp, _lte: $endTimestamp}
|
|
467
|
-
}
|
|
468
|
-
order_by: {startTimestamp: asc}
|
|
469
|
-
limit: $limit
|
|
470
|
-
offset: $offset
|
|
471
|
-
) {
|
|
472
|
-
startTimestamp
|
|
473
|
-
volume0
|
|
474
|
-
volume1
|
|
475
|
-
open_
|
|
476
|
-
high
|
|
477
|
-
low
|
|
478
|
-
close
|
|
479
|
-
sqrtPriceX96
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
`;
|
|
483
|
-
const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
484
|
-
function getSdk(client, withWrapper = defaultWrapper) {
|
|
485
|
-
return {
|
|
486
|
-
GetPoolVolume(variables, requestHeaders, signal) {
|
|
487
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
488
|
-
document: GetPoolVolumeDocument,
|
|
489
|
-
variables,
|
|
490
|
-
requestHeaders: {
|
|
491
|
-
...requestHeaders,
|
|
492
|
-
...wrappedRequestHeaders
|
|
493
|
-
},
|
|
494
|
-
signal
|
|
495
|
-
}), "GetPoolVolume", "query", variables);
|
|
496
|
-
},
|
|
497
|
-
GetPoolUserVolume(variables, requestHeaders, signal) {
|
|
498
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
499
|
-
document: GetPoolUserVolumeDocument,
|
|
500
|
-
variables,
|
|
501
|
-
requestHeaders: {
|
|
502
|
-
...requestHeaders,
|
|
503
|
-
...wrappedRequestHeaders
|
|
504
|
-
},
|
|
505
|
-
signal
|
|
506
|
-
}), "GetPoolUserVolume", "query", variables);
|
|
507
|
-
},
|
|
508
|
-
GetLPFees(variables, requestHeaders, signal) {
|
|
509
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
510
|
-
document: GetLpFeesDocument,
|
|
511
|
-
variables,
|
|
512
|
-
requestHeaders: {
|
|
513
|
-
...requestHeaders,
|
|
514
|
-
...wrappedRequestHeaders
|
|
515
|
-
},
|
|
516
|
-
signal
|
|
517
|
-
}), "GetLPFees", "query", variables);
|
|
518
|
-
},
|
|
519
|
-
GetPoolDayData(variables, requestHeaders, signal) {
|
|
520
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
521
|
-
document: GetPoolDayDataDocument,
|
|
522
|
-
variables,
|
|
523
|
-
requestHeaders: {
|
|
524
|
-
...requestHeaders,
|
|
525
|
-
...wrappedRequestHeaders
|
|
526
|
-
},
|
|
527
|
-
signal
|
|
528
|
-
}), "GetPoolDayData", "query", variables);
|
|
529
|
-
},
|
|
530
|
-
GetPoolHourData(variables, requestHeaders, signal) {
|
|
531
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
532
|
-
document: GetPoolHourDataDocument,
|
|
533
|
-
variables,
|
|
534
|
-
requestHeaders: {
|
|
535
|
-
...requestHeaders,
|
|
536
|
-
...wrappedRequestHeaders
|
|
537
|
-
},
|
|
538
|
-
signal
|
|
539
|
-
}), "GetPoolHourData", "query", variables);
|
|
540
|
-
},
|
|
541
|
-
GetPool5MinuteData(variables, requestHeaders, signal) {
|
|
542
|
-
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
543
|
-
document: GetPool5MinuteDataDocument,
|
|
544
|
-
variables,
|
|
545
|
-
requestHeaders: {
|
|
546
|
-
...requestHeaders,
|
|
547
|
-
...wrappedRequestHeaders
|
|
548
|
-
},
|
|
549
|
-
signal
|
|
550
|
-
}), "GetPool5MinuteData", "query", variables);
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
//#endregion
|
|
556
13
|
//#region src/lib/perpsOperator.ts
|
|
557
14
|
var PerpsOperator = class {
|
|
558
15
|
#baseUrl;
|
|
@@ -651,31 +108,34 @@ var PerpsOperator = class {
|
|
|
651
108
|
//#endregion
|
|
652
109
|
//#region src/providers/TimelockProvider.tsx
|
|
653
110
|
const TimelockContext = (0, react.createContext)(void 0);
|
|
654
|
-
const TimelockProvider = ({ children, marketData, timelockGraphqlUrl,
|
|
111
|
+
const TimelockProvider = ({ children, marketData, timelockGraphqlUrl, univ4GraphqlUrl, perpsOperatorUrl }) => {
|
|
655
112
|
const timelockGraphqlClient = (0, react.useMemo)(() => {
|
|
656
|
-
if (timelockGraphqlUrl) return
|
|
113
|
+
if (!timelockGraphqlUrl) return;
|
|
114
|
+
return require_graphql.getTimelockGraphqlClient(timelockGraphqlUrl);
|
|
657
115
|
}, [timelockGraphqlUrl]);
|
|
658
|
-
const
|
|
659
|
-
if (
|
|
660
|
-
|
|
116
|
+
const univ4GraphqlClient = (0, react.useMemo)(() => {
|
|
117
|
+
if (!univ4GraphqlUrl) return;
|
|
118
|
+
return require_graphql.getUniv4GraphqlClient(univ4GraphqlUrl);
|
|
119
|
+
}, [univ4GraphqlUrl]);
|
|
661
120
|
const perpsOperator = (0, react.useMemo)(() => {
|
|
662
|
-
if (perpsOperatorUrl) return
|
|
121
|
+
if (!perpsOperatorUrl) return;
|
|
122
|
+
return new PerpsOperator(perpsOperatorUrl);
|
|
663
123
|
}, [perpsOperatorUrl]);
|
|
664
124
|
const contextValue = (0, react.useMemo)(() => ({
|
|
665
125
|
marketData: marketData || {},
|
|
666
126
|
timelockGraphqlUrl,
|
|
667
|
-
|
|
127
|
+
univ4GraphqlUrl,
|
|
668
128
|
perpsOperator,
|
|
669
|
-
|
|
129
|
+
univ4GraphqlClient,
|
|
670
130
|
timelockGraphqlClient,
|
|
671
131
|
perpsOperatorUrl
|
|
672
132
|
}), [
|
|
673
133
|
marketData,
|
|
674
134
|
timelockGraphqlUrl,
|
|
675
|
-
|
|
135
|
+
univ4GraphqlUrl,
|
|
676
136
|
perpsOperator,
|
|
677
137
|
timelockGraphqlClient,
|
|
678
|
-
|
|
138
|
+
univ4GraphqlClient,
|
|
679
139
|
perpsOperatorUrl
|
|
680
140
|
]);
|
|
681
141
|
return /* @__PURE__ */ react.default.createElement(TimelockContext.Provider, { value: contextValue }, children);
|
|
@@ -697,17 +157,17 @@ const useLens = () => {
|
|
|
697
157
|
const client = (0, wagmi.usePublicClient)();
|
|
698
158
|
const { data: timelockLens } = (0, _tanstack_react_query.useQuery)({
|
|
699
159
|
queryKey: ["timelockLens", client === null || client === void 0 ? void 0 : client.uid],
|
|
700
|
-
queryFn: () => client ?
|
|
160
|
+
queryFn: () => client ? require_graphql.getTimelockLens(client) : void 0,
|
|
701
161
|
enabled: !!client
|
|
702
162
|
});
|
|
703
163
|
const { data: stateView } = (0, _tanstack_react_query.useQuery)({
|
|
704
164
|
queryKey: ["stateView", client === null || client === void 0 ? void 0 : client.uid],
|
|
705
|
-
queryFn: () => client ?
|
|
165
|
+
queryFn: () => client ? require_graphql.getStateView(client) : void 0,
|
|
706
166
|
enabled: !!client
|
|
707
167
|
});
|
|
708
168
|
const { data: quoter } = (0, _tanstack_react_query.useQuery)({
|
|
709
169
|
queryKey: ["quoter", client === null || client === void 0 ? void 0 : client.uid],
|
|
710
|
-
queryFn: () => client ?
|
|
170
|
+
queryFn: () => client ? require_graphql.getQuoter(client) : void 0,
|
|
711
171
|
enabled: !!client
|
|
712
172
|
});
|
|
713
173
|
return {
|
|
@@ -902,8 +362,8 @@ const useMaxPositionSize = (marketAddr, strikeTick, maxSteps = 100) => {
|
|
|
902
362
|
gas: 100000000n
|
|
903
363
|
});
|
|
904
364
|
return {
|
|
905
|
-
maxCallSize: data && optionAssetDecimals ?
|
|
906
|
-
maxPutSize: data && optionAssetDecimals ?
|
|
365
|
+
maxCallSize: data && optionAssetDecimals ? require_graphql.wrapAmount(data[0], optionAssetDecimals) : void 0,
|
|
366
|
+
maxPutSize: data && optionAssetDecimals ? require_graphql.wrapAmount(data[1], optionAssetDecimals) : void 0,
|
|
907
367
|
...rest
|
|
908
368
|
};
|
|
909
369
|
};
|
|
@@ -1073,7 +533,7 @@ const useApproval = () => {
|
|
|
1073
533
|
const { mutateAsync, data: hash, ...rest } = (0, wagmi.useWriteContract)();
|
|
1074
534
|
const askForApproval = async (tokenAddress, spenderAddress, amount) => {
|
|
1075
535
|
if (!client || !address) throw new Error("Wallet not connected");
|
|
1076
|
-
if (await
|
|
536
|
+
if (await require_graphql.getErc20(tokenAddress, client).read.allowance([address, spenderAddress]) < amount) await (0, viem_actions.waitForTransactionReceipt)(client, { hash: await mutateAsync({
|
|
1077
537
|
address: tokenAddress,
|
|
1078
538
|
abi: viem.erc20Abi,
|
|
1079
539
|
functionName: "approve",
|
|
@@ -1141,8 +601,8 @@ const useMintOption = (marketAddr) => {
|
|
|
1141
601
|
if (!vault || !payoutAsset || optionAssetIsToken0 === void 0) throw new Error("Market data not available");
|
|
1142
602
|
const { data: { currentTick } = {} } = await refetchCurrentTick();
|
|
1143
603
|
if (currentTick === void 0) throw new Error("Could not fetch current tick");
|
|
1144
|
-
strikeTick =
|
|
1145
|
-
const [premium, protocolFee] = await
|
|
604
|
+
strikeTick = require_graphql.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
|
|
605
|
+
const [premium, protocolFee] = await require_graphql.getTimelockMarket(marketAddr, client).read.getMintFees([
|
|
1146
606
|
optionType === "CALL" ? 0 : 1,
|
|
1147
607
|
amount,
|
|
1148
608
|
strikeTick,
|
|
@@ -1181,8 +641,8 @@ const useMintOption = (marketAddr) => {
|
|
|
1181
641
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
1182
642
|
const usePriceAtTick = (poolManager, poolKey, tick, token0For1 = true) => {
|
|
1183
643
|
const { token0Decimals, token1Decimals } = usePoolData(poolManager, poolKey);
|
|
1184
|
-
const priceBigInt = (0, react.useMemo)(() => tick !== void 0 ?
|
|
1185
|
-
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ?
|
|
644
|
+
const priceBigInt = (0, react.useMemo)(() => tick !== void 0 ? require_graphql.getPriceAtTick(tick, token0For1) : void 0, [tick]);
|
|
645
|
+
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_graphql.wrapPrice(priceBigInt, token0For1 ? token0Decimals : token1Decimals, token0For1 ? token1Decimals : token0Decimals) : void 0, [
|
|
1186
646
|
priceBigInt,
|
|
1187
647
|
token0Decimals,
|
|
1188
648
|
token1Decimals
|
|
@@ -1190,10 +650,10 @@ const usePriceAtTick = (poolManager, poolKey, tick, token0For1 = true) => {
|
|
|
1190
650
|
};
|
|
1191
651
|
const usePriceAtSqrtPriceX96 = (poolManager, poolKey, sqrtPriceX96, token0For1 = true) => {
|
|
1192
652
|
const { token0Decimals, token1Decimals } = usePoolData(poolManager, poolKey);
|
|
1193
|
-
const priceBigInt = (0, react.useMemo)(() => sqrtPriceX96 !== void 0 ?
|
|
653
|
+
const priceBigInt = (0, react.useMemo)(() => sqrtPriceX96 !== void 0 ? require_graphql.getPriceAtSqrtPriceX96(sqrtPriceX96, token0For1) : void 0, [sqrtPriceX96]);
|
|
1194
654
|
return (0, react.useMemo)(() => {
|
|
1195
655
|
if (priceBigInt === void 0 || !token0Decimals || !token1Decimals) return;
|
|
1196
|
-
return
|
|
656
|
+
return require_graphql.wrapPrice(priceBigInt, token0For1 ? token0Decimals : token1Decimals, token0For1 ? token1Decimals : token0Decimals);
|
|
1197
657
|
}, [
|
|
1198
658
|
priceBigInt,
|
|
1199
659
|
token0Decimals,
|
|
@@ -1221,12 +681,12 @@ const useCurrentPrices = (pools) => {
|
|
|
1221
681
|
const { data: poolsData } = usePoolsData(pools);
|
|
1222
682
|
const pricesBigInt = (0, react.useMemo)(() => {
|
|
1223
683
|
if (!ticksData) return void 0;
|
|
1224
|
-
return ticksData.map(({ sqrtPriceX96 }, index) =>
|
|
684
|
+
return ticksData.map(({ sqrtPriceX96 }, index) => require_graphql.getPriceAtSqrtPriceX96(sqrtPriceX96, pools[index].token0For1));
|
|
1225
685
|
}, [ticksData, pools]);
|
|
1226
686
|
const data = (0, react.useMemo)(() => {
|
|
1227
687
|
if (!ticksData || !pricesBigInt || !poolsData) return void 0;
|
|
1228
688
|
return pricesBigInt.map((priceBigInt, index) => ({
|
|
1229
|
-
currentPrice:
|
|
689
|
+
currentPrice: require_graphql.wrapPrice(priceBigInt, pools[index].token0For1 ? poolsData[index].token0Decimals : poolsData[index].token1Decimals, pools[index].token0For1 ? poolsData[index].token1Decimals : poolsData[index].token0Decimals),
|
|
1230
690
|
sqrtPriceX96: ticksData[index].sqrtPriceX96,
|
|
1231
691
|
currentTick: ticksData[index].currentTick
|
|
1232
692
|
}));
|
|
@@ -1258,7 +718,7 @@ const useExerciseOption = (marketAddr) => {
|
|
|
1258
718
|
if (!vault) throw new Error("Vault not available");
|
|
1259
719
|
if (!poolKey || !poolManager) throw new Error("Pool data not available");
|
|
1260
720
|
if (!sqrtPriceX96) throw new Error("Current price not available");
|
|
1261
|
-
const swapper =
|
|
721
|
+
const swapper = require_graphql.swappers[client.chain.id];
|
|
1262
722
|
if (!swapper) throw new Error("Swapper not available");
|
|
1263
723
|
const minSqrtPrice = sqrtPriceX96 * 9n / 10n;
|
|
1264
724
|
const maxSqrtPrice = sqrtPriceX96 * 11n / 10n;
|
|
@@ -1299,17 +759,17 @@ const useExerciseOption = (marketAddr) => {
|
|
|
1299
759
|
//#endregion
|
|
1300
760
|
//#region src/hooks/options/useOptionPnl.ts
|
|
1301
761
|
const calculateDisplayPnl = (option, poolPrice, optionAssetIsToken0, payoutAssetDecimals) => {
|
|
1302
|
-
const strikeSize = optionAssetIsToken0 ?
|
|
1303
|
-
const delta = (optionAssetIsToken0 ?
|
|
1304
|
-
return
|
|
762
|
+
const strikeSize = optionAssetIsToken0 ? require_graphql.token0ToToken1AtTick(option.positionSizeCurrent, option.strikeTick) : require_graphql.token1ToToken0AtTick(option.positionSizeCurrent, option.strikeTick);
|
|
763
|
+
const delta = (optionAssetIsToken0 ? require_graphql.token0ToToken1(option.positionSizeCurrent, poolPrice) : require_graphql.token1ToToken0(option.positionSizeCurrent, poolPrice)) - strikeSize;
|
|
764
|
+
return require_graphql.wrapAmount(option.optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
1305
765
|
};
|
|
1306
766
|
const swapperData = (0, viem.encodeAbiParameters)([
|
|
1307
767
|
{ type: "uint160" },
|
|
1308
768
|
{ type: "uint160" },
|
|
1309
769
|
{ type: "uint256" }
|
|
1310
770
|
], [
|
|
1311
|
-
|
|
1312
|
-
|
|
771
|
+
require_graphql.MIN_SQRT_RATIO + 1n,
|
|
772
|
+
require_graphql.MAX_SQRT_RATIO - 1n,
|
|
1313
773
|
BigInt(Math.floor(Date.now() / 1e3) + 600)
|
|
1314
774
|
]);
|
|
1315
775
|
const useOptionPnl = (option) => {
|
|
@@ -1333,7 +793,7 @@ const useOptionPnl = (option) => {
|
|
|
1333
793
|
functionName: "getRefTick",
|
|
1334
794
|
args: vault && (option === null || option === void 0 ? void 0 : option.startTick) ? [vault, option.startTick] : void 0
|
|
1335
795
|
});
|
|
1336
|
-
const swapper =
|
|
796
|
+
const swapper = require_graphql.swappers[chainId];
|
|
1337
797
|
const { data: unrealizedPayout, ...rest } = (0, wagmi.useSimulateContract)({
|
|
1338
798
|
address: option === null || option === void 0 ? void 0 : option.marketAddr,
|
|
1339
799
|
abi: require_stateView.optionsMarketAbi,
|
|
@@ -1352,7 +812,7 @@ const useOptionPnl = (option) => {
|
|
|
1352
812
|
staleTime: 1e4,
|
|
1353
813
|
select: (data) => {
|
|
1354
814
|
if (!payoutAssetDecimals) return void 0;
|
|
1355
|
-
return
|
|
815
|
+
return require_graphql.wrapAmount(data.result, payoutAssetDecimals);
|
|
1356
816
|
}
|
|
1357
817
|
}
|
|
1358
818
|
});
|
|
@@ -1373,7 +833,7 @@ const useMintFees = (marketAddr, optionType, optionAmount, duration, strikeTick)
|
|
|
1373
833
|
const { data: { currentTick } = {} } = useCurrentTick(poolManager, poolKey);
|
|
1374
834
|
const strikeTickRounded = (0, react.useMemo)(() => {
|
|
1375
835
|
if (!tickSpacing || currentTick === void 0) return;
|
|
1376
|
-
let strikeTickRounded$1 =
|
|
836
|
+
let strikeTickRounded$1 = require_graphql.roundTick(strikeTick ?? currentTick, tickSpacing);
|
|
1377
837
|
if (optionType === "CALL" && optionAssetIsToken0 || optionType === "PUT" && !optionAssetIsToken0) strikeTickRounded$1 += tickSpacing;
|
|
1378
838
|
return strikeTickRounded$1;
|
|
1379
839
|
}, [
|
|
@@ -1398,9 +858,9 @@ const useMintFees = (marketAddr, optionType, optionAmount, duration, strikeTick)
|
|
|
1398
858
|
return (0, react.useMemo)(() => {
|
|
1399
859
|
if (premium === void 0 || protocolFee === void 0 || payoutAssetDecimals === void 0) return {};
|
|
1400
860
|
return {
|
|
1401
|
-
premium:
|
|
1402
|
-
protocolFee:
|
|
1403
|
-
totalPremium:
|
|
861
|
+
premium: require_graphql.wrapAmount(premium, payoutAssetDecimals),
|
|
862
|
+
protocolFee: require_graphql.wrapAmount(protocolFee, payoutAssetDecimals),
|
|
863
|
+
totalPremium: require_graphql.wrapAmount(premium + protocolFee, payoutAssetDecimals)
|
|
1404
864
|
};
|
|
1405
865
|
}, [
|
|
1406
866
|
premium,
|
|
@@ -1417,7 +877,7 @@ const useExtensionFees = (marketAddr, optionType, optionAmount, addedDuration, r
|
|
|
1417
877
|
const { data: { currentTick } = {} } = useCurrentTick(poolManager, poolKey);
|
|
1418
878
|
const strikeTickRounded = (0, react.useMemo)(() => {
|
|
1419
879
|
if (!tickSpacing || currentTick === void 0) return;
|
|
1420
|
-
let strikeTickRounded$1 =
|
|
880
|
+
let strikeTickRounded$1 = require_graphql.roundTick(strikeTick ?? currentTick, tickSpacing);
|
|
1421
881
|
if (optionType === "CALL" && optionAssetIsToken0 || optionType === "PUT" && !optionAssetIsToken0) strikeTickRounded$1 += tickSpacing;
|
|
1422
882
|
return strikeTickRounded$1;
|
|
1423
883
|
}, [
|
|
@@ -1443,9 +903,9 @@ const useExtensionFees = (marketAddr, optionType, optionAmount, addedDuration, r
|
|
|
1443
903
|
return (0, react.useMemo)(() => {
|
|
1444
904
|
if (premium === void 0 || protocolFee === void 0 || payoutAssetDecimals === void 0) return {};
|
|
1445
905
|
return {
|
|
1446
|
-
premium:
|
|
1447
|
-
protocolFee:
|
|
1448
|
-
totalPremium:
|
|
906
|
+
premium: require_graphql.wrapAmount(premium, payoutAssetDecimals),
|
|
907
|
+
protocolFee: require_graphql.wrapAmount(protocolFee, payoutAssetDecimals),
|
|
908
|
+
totalPremium: require_graphql.wrapAmount(premium + protocolFee, payoutAssetDecimals)
|
|
1449
909
|
};
|
|
1450
910
|
}, [
|
|
1451
911
|
premium,
|
|
@@ -1515,7 +975,7 @@ const useExtendOption = (marketAddr) => {
|
|
|
1515
975
|
const extendOption = async ({ option, duration }) => {
|
|
1516
976
|
if (!client || !address) throw new Error("Wallet not connected");
|
|
1517
977
|
if (!marketAddr || !payoutAsset) throw new Error("Market address not available");
|
|
1518
|
-
const market =
|
|
978
|
+
const market = require_graphql.getTimelockMarket(marketAddr, client);
|
|
1519
979
|
const remainingDuration = Math.max(0, Math.floor((option.expiresAt.getTime() - Date.now()) / 1e3));
|
|
1520
980
|
const [premium, protocolFee] = await market.read.getExtendFees([
|
|
1521
981
|
option.optionType === "CALL" ? 0 : 1,
|
|
@@ -1769,12 +1229,12 @@ const useMintPerp = (marketAddr) => {
|
|
|
1769
1229
|
if (!operator || !operatorAddr) throw new Error("Operator address not found");
|
|
1770
1230
|
if (optionAssetIsToken0 === void 0 || !payoutAsset) throw new Error("Market data not found");
|
|
1771
1231
|
if (!operator.auth) await signMessage();
|
|
1772
|
-
const market =
|
|
1232
|
+
const market = require_graphql.getTimelockMarket(marketAddr, client);
|
|
1773
1233
|
const { data: { currentTick } = {} } = await refetchCurrentTick();
|
|
1774
1234
|
if (currentTick === void 0) throw new Error("Could not fetch current tick");
|
|
1775
1235
|
const { data: operators = [] } = await refetchOperators();
|
|
1776
1236
|
const userPerms = operatorAddr ? operators.find((o) => o.operatorAddr.toLowerCase() === operatorAddr.toLowerCase()) : void 0;
|
|
1777
|
-
const validStrikeTick =
|
|
1237
|
+
const validStrikeTick = require_graphql.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
|
|
1778
1238
|
const [premium, protocolFee] = await market.read.getMintFees([
|
|
1779
1239
|
optionType === "CALL" ? 0 : 1,
|
|
1780
1240
|
amount,
|
|
@@ -1877,7 +1337,7 @@ const useTokenBalance = (token, user) => {
|
|
|
1877
1337
|
query: { enabled: !!token && !!user }
|
|
1878
1338
|
});
|
|
1879
1339
|
return {
|
|
1880
|
-
data: (0, react.useMemo)(() => raw !== void 0 && decimals !== void 0 ?
|
|
1340
|
+
data: (0, react.useMemo)(() => raw !== void 0 && decimals !== void 0 ? require_graphql.wrapAmount(raw, decimals) : void 0, [raw, decimals]),
|
|
1881
1341
|
...rest
|
|
1882
1342
|
};
|
|
1883
1343
|
};
|
|
@@ -1933,7 +1393,7 @@ const usePriceHistory = (pool, token, resolution, startTimestamp, endTimestamp)
|
|
|
1933
1393
|
startTimestamp,
|
|
1934
1394
|
endTimestamp
|
|
1935
1395
|
],
|
|
1936
|
-
queryFn: () =>
|
|
1396
|
+
queryFn: () => require_graphql.getPriceHistory(pool, token, resolution, startTimestamp, endTimestamp),
|
|
1937
1397
|
enabled: !!pool && startTimestamp < endTimestamp,
|
|
1938
1398
|
staleTime: 60 * 1e3,
|
|
1939
1399
|
gcTime: 300 * 1e3,
|
|
@@ -1977,7 +1437,7 @@ const usePoolVolume = (poolManager, poolKey) => {
|
|
|
1977
1437
|
//#endregion
|
|
1978
1438
|
//#region src/hooks/pool/usePoolUserVolume.ts
|
|
1979
1439
|
const usePoolUserVolume = (poolManager, poolKey, userAddr) => {
|
|
1980
|
-
const {
|
|
1440
|
+
const { univ4GraphqlClient } = useTimelockConfig();
|
|
1981
1441
|
const poolId = (0, react.useMemo)(() => poolKey ? getPoolId(poolKey) : void 0, [poolKey]);
|
|
1982
1442
|
return (0, _tanstack_react_query.useQuery)({
|
|
1983
1443
|
queryKey: [
|
|
@@ -1987,7 +1447,7 @@ const usePoolUserVolume = (poolManager, poolKey, userAddr) => {
|
|
|
1987
1447
|
(userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase()) || "--"
|
|
1988
1448
|
],
|
|
1989
1449
|
queryFn: async () => {
|
|
1990
|
-
const result = await
|
|
1450
|
+
const result = await univ4GraphqlClient.GetPoolUserVolume({
|
|
1991
1451
|
poolId,
|
|
1992
1452
|
userAddr
|
|
1993
1453
|
});
|
|
@@ -2000,7 +1460,7 @@ const usePoolUserVolume = (poolManager, poolKey, userAddr) => {
|
|
|
2000
1460
|
swapCount: BigInt(result.PoolUser[0].swapCount)
|
|
2001
1461
|
};
|
|
2002
1462
|
},
|
|
2003
|
-
enabled: !!poolId && !!userAddr && !!
|
|
1463
|
+
enabled: !!poolId && !!userAddr && !!univ4GraphqlClient
|
|
2004
1464
|
});
|
|
2005
1465
|
};
|
|
2006
1466
|
|
|
@@ -2221,7 +1681,7 @@ const batchGetAmountsFromLiquidity = (tickLowers, tickUppers, liquidities, curre
|
|
|
2221
1681
|
const amounts0 = [];
|
|
2222
1682
|
const amounts1 = [];
|
|
2223
1683
|
for (const [i, tickLower] of tickLowers.entries()) {
|
|
2224
|
-
const [amount0, amount1] =
|
|
1684
|
+
const [amount0, amount1] = require_graphql.getAmountsFromLiquidity(tickLower, tickUppers[i], liquidities[i], currentTick);
|
|
2225
1685
|
totalAmount0 += amount0;
|
|
2226
1686
|
totalAmount1 += amount1;
|
|
2227
1687
|
amounts0.push(amount0);
|
|
@@ -2294,13 +1754,13 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
2294
1754
|
});
|
|
2295
1755
|
return (0, react.useMemo)(() => {
|
|
2296
1756
|
if (!token0Decimals || !token1Decimals || !data) return {};
|
|
2297
|
-
const total0 =
|
|
2298
|
-
const total1 =
|
|
2299
|
-
const borrowed0 =
|
|
2300
|
-
const borrowed1 =
|
|
1757
|
+
const total0 = require_graphql.wrapAmount(data[0], token0Decimals);
|
|
1758
|
+
const total1 = require_graphql.wrapAmount(data[1], token1Decimals);
|
|
1759
|
+
const borrowed0 = require_graphql.wrapAmount(data[2], token0Decimals);
|
|
1760
|
+
const borrowed1 = require_graphql.wrapAmount(data[3], token1Decimals);
|
|
2301
1761
|
return {
|
|
2302
|
-
tvlAs0:
|
|
2303
|
-
tvlAs1:
|
|
1762
|
+
tvlAs0: require_graphql.wrapAmount(data[4], token0Decimals),
|
|
1763
|
+
tvlAs1: require_graphql.wrapAmount(data[5], token1Decimals),
|
|
2304
1764
|
total0,
|
|
2305
1765
|
total1,
|
|
2306
1766
|
borrowed0,
|
|
@@ -2450,7 +1910,7 @@ const useUpdateMarketFees = (marketAddr) => {
|
|
|
2450
1910
|
if (openingFeeRate === void 0 || extensionFeeRate === void 0 || minOpeningFee === void 0 || minExtensionFee === void 0 || feeRecipient === void 0) throw new Error("Missing current fee rates");
|
|
2451
1911
|
if (!optionPricing || !priceFeed) throw new Error("Market state not available: " + (stateError === null || stateError === void 0 ? void 0 : stateError.message));
|
|
2452
1912
|
if (!publicClient) throw new Error("Public client not available");
|
|
2453
|
-
const factoryAddr =
|
|
1913
|
+
const factoryAddr = require_graphql.timelockFactories[chainId].toLowerCase();
|
|
2454
1914
|
const hash = await writeContractAsync({
|
|
2455
1915
|
address: factoryAddr,
|
|
2456
1916
|
abi: require_factory.factoryAbi,
|
|
@@ -2608,7 +2068,7 @@ const useUpdateMarketPricing = (marketAddr) => {
|
|
|
2608
2068
|
if (!pricingData) throw new Error("Market pricing data not available: " + (pricingError === null || pricingError === void 0 ? void 0 : pricingError.message));
|
|
2609
2069
|
if (!publicClient) throw new Error("Public client not available");
|
|
2610
2070
|
if (!feeStrategy || !priceFeed) throw new Error("Market state not available: " + (stateError === null || stateError === void 0 ? void 0 : stateError.message));
|
|
2611
|
-
const factoryAddr =
|
|
2071
|
+
const factoryAddr = require_graphql.timelockFactories[chainId].toLowerCase();
|
|
2612
2072
|
if (data.model === "static" && pricingData.model === "static") {
|
|
2613
2073
|
data.openingRate ?? (data.openingRate = pricingData.openingRate);
|
|
2614
2074
|
data.dailyFundingRate ?? (data.dailyFundingRate = pricingData.dailyFundingRate);
|
|
@@ -2656,14 +2116,21 @@ const useUpdateMarketPricing = (marketAddr) => {
|
|
|
2656
2116
|
data.minPremiumAmount
|
|
2657
2117
|
]
|
|
2658
2118
|
});
|
|
2659
|
-
const
|
|
2660
|
-
|
|
2119
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
2120
|
+
const deployEvent = receipt.logs.find((log) => log.address.toLowerCase() === factoryAddr.toLowerCase());
|
|
2121
|
+
if (!deployEvent) {
|
|
2122
|
+
console.error(receipt);
|
|
2123
|
+
throw new Error(`Deploy event not found in tx: ${hash}`);
|
|
2124
|
+
}
|
|
2661
2125
|
const decodedEvent = (0, viem.decodeEventLog)({
|
|
2662
2126
|
abi: require_factory.factoryAbi,
|
|
2663
2127
|
data: deployEvent.data,
|
|
2664
2128
|
topics: deployEvent.topics
|
|
2665
2129
|
});
|
|
2666
|
-
if (decodedEvent.eventName !== "DeployStaticPerpsPricing" && decodedEvent.eventName !== "DeployOptionPricing")
|
|
2130
|
+
if (decodedEvent.eventName !== "DeployStaticPerpsPricing" && decodedEvent.eventName !== "DeployOptionPricing") {
|
|
2131
|
+
console.error(receipt);
|
|
2132
|
+
throw new Error(`Unexpected event ${decodedEvent.eventName} in tx ${hash}`);
|
|
2133
|
+
}
|
|
2667
2134
|
const pricingAddr = decodedEvent.args.pricing;
|
|
2668
2135
|
const hash2 = await writeContractAsync({
|
|
2669
2136
|
address: marketAddr,
|