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.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./uniswapMathLens-
|
|
2
|
-
import { $ as OptionEvent, Ct as
|
|
3
|
-
export { ExerciseOptionEvent, ExtendEvent, LiquidityBlockData, MintOptionEvent, OptionData, OptionEvent, TimelockProvider, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePerpsOperator, usePoolData, usePriceAtTick, usePriceHistory, usePriceSqrtPriceX96, useSetOperatorPerms, useTimelockConfig, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
|
1
|
+
import "./uniswapMathLens-Be6lFJcD.cjs";
|
|
2
|
+
import { $ as OptionEvent, Ct as useExerciseOption, Dt as TimelockProvider, Et as useClosedUserOptions, G as useClosedUserPerps, H as useUserOperators, J as useClosePerp, K as useUserPerps, Ot as useCurrentMarket, Q as MintOptionEvent, St as useMarketData, Tt as useActiveUserOptions, U as useOperatorPerms, V as useSetOperatorPerms, W as useActiveUserPerps, X as ExerciseOptionEvent, Y as useMintPerp, Z as ExtendEvent, _ as useCurrentPrice, a as batchGetAmountsFromLiquidity, at as useMaxPositionSize, c as useLiquidityBlocks, d as usePriceHistory, et as useOptionTimeline, f as usePriceAtTick, g as useCurrentTick, h as usePoolData, i as useVaultData, it as useMintOption, kt as useTimelockConfig, l as useBurnLiquidity, m as UniswapPoolData, n as useLens, nt as useOptionPremium, o as useMintLiquidity, p as usePriceSqrtPriceX96, q as usePerpsOperator, r as useVaultTVL, rt as useOptionPnl, s as LiquidityBlockData, t as useApproval, tt as useExtendOption, u as useMarketPriceHistory, wt as OptionData, xt as useMarketVolume } from "./client-CJcTIGGv.cjs";
|
|
3
|
+
export { ExerciseOptionEvent, ExtendEvent, LiquidityBlockData, MintOptionEvent, OptionData, OptionEvent, TimelockProvider, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMarketVolume, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePerpsOperator, usePoolData, usePriceAtTick, usePriceHistory, usePriceSqrtPriceX96, useSetOperatorPerms, useTimelockConfig, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./uniswapMathLens-
|
|
2
|
-
import { $ as OptionEvent, Ct as
|
|
3
|
-
export { ExerciseOptionEvent, ExtendEvent, LiquidityBlockData, MintOptionEvent, OptionData, OptionEvent, TimelockProvider, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePerpsOperator, usePoolData, usePriceAtTick, usePriceHistory, usePriceSqrtPriceX96, useSetOperatorPerms, useTimelockConfig, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
|
1
|
+
import "./uniswapMathLens-DHfzEjej.js";
|
|
2
|
+
import { $ as OptionEvent, Ct as useExerciseOption, Dt as TimelockProvider, Et as useClosedUserOptions, G as useClosedUserPerps, H as useUserOperators, J as useClosePerp, K as useUserPerps, Ot as useCurrentMarket, Q as MintOptionEvent, St as useMarketData, Tt as useActiveUserOptions, U as useOperatorPerms, V as useSetOperatorPerms, W as useActiveUserPerps, X as ExerciseOptionEvent, Y as useMintPerp, Z as ExtendEvent, _ as useCurrentPrice, a as batchGetAmountsFromLiquidity, at as useMaxPositionSize, c as useLiquidityBlocks, d as usePriceHistory, et as useOptionTimeline, f as usePriceAtTick, g as useCurrentTick, h as usePoolData, i as useVaultData, it as useMintOption, kt as useTimelockConfig, l as useBurnLiquidity, m as UniswapPoolData, n as useLens, nt as useOptionPremium, o as useMintLiquidity, p as usePriceSqrtPriceX96, q as usePerpsOperator, r as useVaultTVL, rt as useOptionPnl, s as LiquidityBlockData, t as useApproval, tt as useExtendOption, u as useMarketPriceHistory, wt as OptionData, xt as useMarketVolume } from "./client-CZdmjIOb.js";
|
|
3
|
+
export { ExerciseOptionEvent, ExtendEvent, LiquidityBlockData, MintOptionEvent, OptionData, OptionEvent, TimelockProvider, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMarketVolume, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePerpsOperator, usePoolData, usePriceAtTick, usePriceHistory, usePriceSqrtPriceX96, useSetOperatorPerms, useTimelockConfig, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
package/dist/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import { r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-
|
|
5
|
-
import { A as token0ToToken1AtTick, B as timelockLenses, D as roundTickDown, F as getErc20, I as getTimelockLens, L as getTimelockMarket, M as token1ToToken0AtTick, P as getPriceHistory, R as getUniswapMathLens, V as uniswapMathLenses, b as getPriceAtSqrtPriceX96, f as wrapAmount, j as token1ToToken0, k as token0ToToken1, m as wrapPrice, r as EMPTY_ARRAY, t as getPayoutAtPrice, v as getAmountsFromLiquidity, x as getPriceAtTick, y as getNearestValidStrikeTick, z as swappers } from "./optionUtils-
|
|
4
|
+
import { r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-B2IsvbeA.js";
|
|
5
|
+
import { A as token0ToToken1AtTick, B as timelockLenses, D as roundTickDown, F as getErc20, I as getTimelockLens, L as getTimelockMarket, M as token1ToToken0AtTick, P as getPriceHistory, R as getUniswapMathLens, V as uniswapMathLenses, b as getPriceAtSqrtPriceX96, f as wrapAmount, j as token1ToToken0, k as token0ToToken1, m as wrapPrice, r as EMPTY_ARRAY, t as getPayoutAtPrice, v as getAmountsFromLiquidity, x as getPriceAtTick, y as getNearestValidStrikeTick, z as swappers } from "./optionUtils-CQzUsKpO.js";
|
|
6
6
|
import { n as uniswapV3PoolAbi, t as singleOwnerVaultAbi } from "./singleOwnerVault-p81IjmWe.js";
|
|
7
7
|
import { encodeAbiParameters, encodeFunctionData, erc20Abi, maxUint256, zeroAddress } from "viem";
|
|
8
8
|
import React, { createContext, useContext, useEffect, useMemo } from "react";
|
|
@@ -98,8 +98,6 @@ const GetMarketDataDocument = gql`
|
|
|
98
98
|
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
99
99
|
id
|
|
100
100
|
address
|
|
101
|
-
optionsCount
|
|
102
|
-
tradersCount
|
|
103
101
|
vault
|
|
104
102
|
pool
|
|
105
103
|
tickSpacing
|
|
@@ -115,6 +113,17 @@ const GetMarketDataDocument = gql`
|
|
|
115
113
|
}
|
|
116
114
|
}
|
|
117
115
|
`;
|
|
116
|
+
const GetMarketVolumeDocument = gql`
|
|
117
|
+
query GetMarketVolume($marketAddr: String!) {
|
|
118
|
+
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
119
|
+
id
|
|
120
|
+
address
|
|
121
|
+
optionsCount
|
|
122
|
+
tradersCount
|
|
123
|
+
volume
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
118
127
|
const GetUserMarketOperatorsDocument = gql`
|
|
119
128
|
query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
|
|
120
129
|
UserMarketOperator(
|
|
@@ -254,6 +263,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
254
263
|
signal
|
|
255
264
|
}), "GetMarketData", "query", variables);
|
|
256
265
|
},
|
|
266
|
+
GetMarketVolume(variables, requestHeaders, signal) {
|
|
267
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
268
|
+
document: GetMarketVolumeDocument,
|
|
269
|
+
variables,
|
|
270
|
+
requestHeaders: {
|
|
271
|
+
...requestHeaders,
|
|
272
|
+
...wrappedRequestHeaders
|
|
273
|
+
},
|
|
274
|
+
signal
|
|
275
|
+
}), "GetMarketVolume", "query", variables);
|
|
276
|
+
},
|
|
257
277
|
GetUserMarketOperators(variables, requestHeaders, signal) {
|
|
258
278
|
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
259
279
|
document: GetUserMarketOperatorsDocument,
|
|
@@ -439,12 +459,11 @@ const useMarketData = (marketAddr) => {
|
|
|
439
459
|
const result = await graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() });
|
|
440
460
|
return {
|
|
441
461
|
...result.TimelockMarket[0],
|
|
462
|
+
address: result.TimelockMarket[0].address,
|
|
442
463
|
pool: result.TimelockMarket[0].pool,
|
|
443
464
|
vault: result.TimelockMarket[0].vault,
|
|
444
465
|
optionAsset: result.TimelockMarket[0].optionAsset,
|
|
445
|
-
payoutAsset: result.TimelockMarket[0].payoutAsset
|
|
446
|
-
optionsCount: BigInt(result.TimelockMarket[0].optionsCount),
|
|
447
|
-
tradersCount: BigInt(result.TimelockMarket[0].tradersCount)
|
|
466
|
+
payoutAsset: result.TimelockMarket[0].payoutAsset
|
|
448
467
|
};
|
|
449
468
|
},
|
|
450
469
|
enabled: !!marketAddr && !!graphqlClient
|
|
@@ -524,44 +543,60 @@ const useExerciseOption = (marketAddr) => {
|
|
|
524
543
|
return useMutation({ mutationFn: exerciseOption });
|
|
525
544
|
};
|
|
526
545
|
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/hooks/options/useMarketVolume.ts
|
|
548
|
+
const useMarketVolume = (marketAddr) => {
|
|
549
|
+
const { graphqlClient } = useTimelockConfig();
|
|
550
|
+
const { timelockLens } = useLens();
|
|
551
|
+
const { data } = useQuery({
|
|
552
|
+
queryKey: ["marketData", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
|
|
553
|
+
queryFn: async () => {
|
|
554
|
+
const result = await graphqlClient.GetMarketVolume({ marketAddr: marketAddr.toLowerCase() });
|
|
555
|
+
return {
|
|
556
|
+
...result.TimelockMarket[0],
|
|
557
|
+
address: result.TimelockMarket[0].address,
|
|
558
|
+
volume: BigInt(result.TimelockMarket[0].volume),
|
|
559
|
+
optionsCount: BigInt(result.TimelockMarket[0].optionsCount),
|
|
560
|
+
tradersCount: BigInt(result.TimelockMarket[0].tradersCount)
|
|
561
|
+
};
|
|
562
|
+
},
|
|
563
|
+
enabled: !!marketAddr && !!graphqlClient
|
|
564
|
+
});
|
|
565
|
+
const { data: fallback } = useQuery({
|
|
566
|
+
queryKey: ["marketData", marketAddr || "--"],
|
|
567
|
+
queryFn: async () => {
|
|
568
|
+
if (!marketAddr || !timelockLens) return void 0;
|
|
569
|
+
return {
|
|
570
|
+
...await timelockLens.read.getMarketData([marketAddr]),
|
|
571
|
+
tradersCount: void 0
|
|
572
|
+
};
|
|
573
|
+
},
|
|
574
|
+
enabled: !!marketAddr && !!timelockLens
|
|
575
|
+
});
|
|
576
|
+
return data || fallback || {};
|
|
577
|
+
};
|
|
578
|
+
|
|
527
579
|
//#endregion
|
|
528
580
|
//#region src/hooks/options/useMaxPositionSize.ts
|
|
529
|
-
const useMaxPositionSize = (marketAddr,
|
|
581
|
+
const useMaxPositionSize = (marketAddr, maxBorrowableRange = 100) => {
|
|
530
582
|
const { timelockLens } = useLens();
|
|
531
583
|
const { optionAssetDecimals } = useMarketData(marketAddr);
|
|
532
|
-
const { data
|
|
584
|
+
const { data, ...rest } = useReadContract({
|
|
533
585
|
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
534
586
|
abi: lensAbi,
|
|
535
|
-
functionName: "
|
|
587
|
+
functionName: "getMaxATMSizes",
|
|
536
588
|
args: [marketAddr, maxBorrowableRange],
|
|
537
589
|
query: { enabled: !!marketAddr && !!timelockLens },
|
|
538
590
|
gas: 100000000n
|
|
539
591
|
});
|
|
540
|
-
const { data: data1, refetch: refetch1 } = useReadContract({
|
|
541
|
-
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
542
|
-
abi: lensAbi,
|
|
543
|
-
functionName: "getMaxPositionSize",
|
|
544
|
-
args: [
|
|
545
|
-
marketAddr,
|
|
546
|
-
strikeTick,
|
|
547
|
-
maxBorrowableRange
|
|
548
|
-
],
|
|
549
|
-
query: { enabled: !!marketAddr && !!timelockLens && strikeTick !== void 0 },
|
|
550
|
-
gas: 100000000n
|
|
551
|
-
});
|
|
552
|
-
const data = strikeTick !== void 0 ? data1 : data0;
|
|
553
592
|
const { maxCallSize, maxPutSize } = useMemo(() => data && optionAssetDecimals ? {
|
|
554
593
|
maxCallSize: wrapAmount(data[0], optionAssetDecimals),
|
|
555
594
|
maxPutSize: wrapAmount(data[1], optionAssetDecimals)
|
|
556
595
|
} : {}, [data, optionAssetDecimals]);
|
|
557
|
-
const refetch = () => {
|
|
558
|
-
refetch0();
|
|
559
|
-
refetch1();
|
|
560
|
-
};
|
|
561
596
|
return {
|
|
562
597
|
maxCallSize,
|
|
563
598
|
maxPutSize,
|
|
564
|
-
|
|
599
|
+
...rest
|
|
565
600
|
};
|
|
566
601
|
};
|
|
567
602
|
|
|
@@ -1442,5 +1477,5 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
1442
1477
|
};
|
|
1443
1478
|
|
|
1444
1479
|
//#endregion
|
|
1445
|
-
export { TimelockProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePerpsOperator, usePoolData, usePriceAtTick, usePriceHistory, usePriceSqrtPriceX96, useSetOperatorPerms, useTimelockConfig, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
|
1480
|
+
export { TimelockProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMarketVolume, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePerpsOperator, usePoolData, usePriceAtTick, usePriceHistory, usePriceSqrtPriceX96, useSetOperatorPerms, useTimelockConfig, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
|
1446
1481
|
//# sourceMappingURL=client.js.map
|