timelock-sdk 0.0.132 → 0.0.134
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/abis.cjs +1 -1
- package/dist/abis.d.cts +1 -1
- package/dist/abis.d.ts +1 -1
- package/dist/abis.js +1 -1
- package/dist/{client-VhkUQ-HJ.d.cts → client-CJcTIGGv.d.cts} +3145 -1200
- package/dist/{client-gQvld5wF.d.ts → client-CZdmjIOb.d.ts} +3283 -1338
- package/dist/client.cjs +64 -28
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +3 -3
- package/dist/client.d.ts +3 -3
- package/dist/client.js +64 -29
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-DTutSZPI.js → optionUtils-CQzUsKpO.js} +3 -3
- package/dist/{optionUtils-DTutSZPI.js.map → optionUtils-CQzUsKpO.js.map} +1 -1
- package/dist/{optionUtils-BQIg6hnc.cjs → optionUtils-OfLzCR6R.cjs} +3 -3
- package/dist/{optionUtils-BQIg6hnc.cjs.map → optionUtils-OfLzCR6R.cjs.map} +1 -1
- package/dist/{optionsMarket-Hq7O-Hry.js → optionsMarket-B2IsvbeA.js} +48 -25
- package/dist/optionsMarket-B2IsvbeA.js.map +1 -0
- package/dist/{optionsMarket-C8-v8IvX.cjs → optionsMarket-C6K82im8.cjs} +48 -25
- package/dist/optionsMarket-C6K82im8.cjs.map +1 -0
- package/dist/package.cjs +2 -2
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/dist/{uniswapMathLens-EIuBr8ZZ.d.cts → uniswapMathLens-Be6lFJcD.d.cts} +31 -13
- package/dist/{uniswapMathLens-BGtGI-Nm.d.ts → uniswapMathLens-DHfzEjej.d.ts} +31 -13
- package/package.json +1 -1
- package/dist/optionsMarket-C8-v8IvX.cjs.map +0 -1
- package/dist/optionsMarket-Hq7O-Hry.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_optionUtils = require('./optionUtils-
|
|
5
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
4
|
+
const require_optionUtils = require('./optionUtils-OfLzCR6R.cjs');
|
|
5
|
+
const require_optionsMarket = require('./optionsMarket-C6K82im8.cjs');
|
|
6
6
|
const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
8
8
|
let react = require("react");
|
|
@@ -100,8 +100,6 @@ const GetMarketDataDocument = graphql_tag.default`
|
|
|
100
100
|
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
101
101
|
id
|
|
102
102
|
address
|
|
103
|
-
optionsCount
|
|
104
|
-
tradersCount
|
|
105
103
|
vault
|
|
106
104
|
pool
|
|
107
105
|
tickSpacing
|
|
@@ -117,6 +115,17 @@ const GetMarketDataDocument = graphql_tag.default`
|
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
`;
|
|
118
|
+
const GetMarketVolumeDocument = graphql_tag.default`
|
|
119
|
+
query GetMarketVolume($marketAddr: String!) {
|
|
120
|
+
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
121
|
+
id
|
|
122
|
+
address
|
|
123
|
+
optionsCount
|
|
124
|
+
tradersCount
|
|
125
|
+
volume
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
120
129
|
const GetUserMarketOperatorsDocument = graphql_tag.default`
|
|
121
130
|
query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
|
|
122
131
|
UserMarketOperator(
|
|
@@ -256,6 +265,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
256
265
|
signal
|
|
257
266
|
}), "GetMarketData", "query", variables);
|
|
258
267
|
},
|
|
268
|
+
GetMarketVolume(variables, requestHeaders, signal) {
|
|
269
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
270
|
+
document: GetMarketVolumeDocument,
|
|
271
|
+
variables,
|
|
272
|
+
requestHeaders: {
|
|
273
|
+
...requestHeaders,
|
|
274
|
+
...wrappedRequestHeaders
|
|
275
|
+
},
|
|
276
|
+
signal
|
|
277
|
+
}), "GetMarketVolume", "query", variables);
|
|
278
|
+
},
|
|
259
279
|
GetUserMarketOperators(variables, requestHeaders, signal) {
|
|
260
280
|
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
261
281
|
document: GetUserMarketOperatorsDocument,
|
|
@@ -441,12 +461,11 @@ const useMarketData = (marketAddr) => {
|
|
|
441
461
|
const result = await graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() });
|
|
442
462
|
return {
|
|
443
463
|
...result.TimelockMarket[0],
|
|
464
|
+
address: result.TimelockMarket[0].address,
|
|
444
465
|
pool: result.TimelockMarket[0].pool,
|
|
445
466
|
vault: result.TimelockMarket[0].vault,
|
|
446
467
|
optionAsset: result.TimelockMarket[0].optionAsset,
|
|
447
|
-
payoutAsset: result.TimelockMarket[0].payoutAsset
|
|
448
|
-
optionsCount: BigInt(result.TimelockMarket[0].optionsCount),
|
|
449
|
-
tradersCount: BigInt(result.TimelockMarket[0].tradersCount)
|
|
468
|
+
payoutAsset: result.TimelockMarket[0].payoutAsset
|
|
450
469
|
};
|
|
451
470
|
},
|
|
452
471
|
enabled: !!marketAddr && !!graphqlClient
|
|
@@ -526,44 +545,60 @@ const useExerciseOption = (marketAddr) => {
|
|
|
526
545
|
return (0, __tanstack_react_query.useMutation)({ mutationFn: exerciseOption });
|
|
527
546
|
};
|
|
528
547
|
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/hooks/options/useMarketVolume.ts
|
|
550
|
+
const useMarketVolume = (marketAddr) => {
|
|
551
|
+
const { graphqlClient } = useTimelockConfig();
|
|
552
|
+
const { timelockLens } = useLens();
|
|
553
|
+
const { data } = (0, __tanstack_react_query.useQuery)({
|
|
554
|
+
queryKey: ["marketData", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
|
|
555
|
+
queryFn: async () => {
|
|
556
|
+
const result = await graphqlClient.GetMarketVolume({ marketAddr: marketAddr.toLowerCase() });
|
|
557
|
+
return {
|
|
558
|
+
...result.TimelockMarket[0],
|
|
559
|
+
address: result.TimelockMarket[0].address,
|
|
560
|
+
volume: BigInt(result.TimelockMarket[0].volume),
|
|
561
|
+
optionsCount: BigInt(result.TimelockMarket[0].optionsCount),
|
|
562
|
+
tradersCount: BigInt(result.TimelockMarket[0].tradersCount)
|
|
563
|
+
};
|
|
564
|
+
},
|
|
565
|
+
enabled: !!marketAddr && !!graphqlClient
|
|
566
|
+
});
|
|
567
|
+
const { data: fallback } = (0, __tanstack_react_query.useQuery)({
|
|
568
|
+
queryKey: ["marketData", marketAddr || "--"],
|
|
569
|
+
queryFn: async () => {
|
|
570
|
+
if (!marketAddr || !timelockLens) return void 0;
|
|
571
|
+
return {
|
|
572
|
+
...await timelockLens.read.getMarketData([marketAddr]),
|
|
573
|
+
tradersCount: void 0
|
|
574
|
+
};
|
|
575
|
+
},
|
|
576
|
+
enabled: !!marketAddr && !!timelockLens
|
|
577
|
+
});
|
|
578
|
+
return data || fallback || {};
|
|
579
|
+
};
|
|
580
|
+
|
|
529
581
|
//#endregion
|
|
530
582
|
//#region src/hooks/options/useMaxPositionSize.ts
|
|
531
|
-
const useMaxPositionSize = (marketAddr,
|
|
583
|
+
const useMaxPositionSize = (marketAddr, maxBorrowableRange = 100) => {
|
|
532
584
|
const { timelockLens } = useLens();
|
|
533
585
|
const { optionAssetDecimals } = useMarketData(marketAddr);
|
|
534
|
-
const { data
|
|
586
|
+
const { data, ...rest } = (0, wagmi.useReadContract)({
|
|
535
587
|
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
536
588
|
abi: require_optionsMarket.lensAbi,
|
|
537
|
-
functionName: "
|
|
589
|
+
functionName: "getMaxATMSizes",
|
|
538
590
|
args: [marketAddr, maxBorrowableRange],
|
|
539
591
|
query: { enabled: !!marketAddr && !!timelockLens },
|
|
540
592
|
gas: 100000000n
|
|
541
593
|
});
|
|
542
|
-
const { data: data1, refetch: refetch1 } = (0, wagmi.useReadContract)({
|
|
543
|
-
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
544
|
-
abi: require_optionsMarket.lensAbi,
|
|
545
|
-
functionName: "getMaxPositionSize",
|
|
546
|
-
args: [
|
|
547
|
-
marketAddr,
|
|
548
|
-
strikeTick,
|
|
549
|
-
maxBorrowableRange
|
|
550
|
-
],
|
|
551
|
-
query: { enabled: !!marketAddr && !!timelockLens && strikeTick !== void 0 },
|
|
552
|
-
gas: 100000000n
|
|
553
|
-
});
|
|
554
|
-
const data = strikeTick !== void 0 ? data1 : data0;
|
|
555
594
|
const { maxCallSize, maxPutSize } = (0, react.useMemo)(() => data && optionAssetDecimals ? {
|
|
556
595
|
maxCallSize: require_optionUtils.wrapAmount(data[0], optionAssetDecimals),
|
|
557
596
|
maxPutSize: require_optionUtils.wrapAmount(data[1], optionAssetDecimals)
|
|
558
597
|
} : {}, [data, optionAssetDecimals]);
|
|
559
|
-
const refetch = () => {
|
|
560
|
-
refetch0();
|
|
561
|
-
refetch1();
|
|
562
|
-
};
|
|
563
598
|
return {
|
|
564
599
|
maxCallSize,
|
|
565
600
|
maxPutSize,
|
|
566
|
-
|
|
601
|
+
...rest
|
|
567
602
|
};
|
|
568
603
|
};
|
|
569
604
|
|
|
@@ -1462,6 +1497,7 @@ exports.useLens = useLens;
|
|
|
1462
1497
|
exports.useLiquidityBlocks = useLiquidityBlocks;
|
|
1463
1498
|
exports.useMarketData = useMarketData;
|
|
1464
1499
|
exports.useMarketPriceHistory = useMarketPriceHistory;
|
|
1500
|
+
exports.useMarketVolume = useMarketVolume;
|
|
1465
1501
|
exports.useMaxPositionSize = useMaxPositionSize;
|
|
1466
1502
|
exports.useMintLiquidity = useMintLiquidity;
|
|
1467
1503
|
exports.useMintOption = useMintOption;
|