timelock-sdk 0.0.171 → 0.0.173

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
 
4
- const require_optionUtils = require('./optionUtils-cd5h0wkz.cjs');
5
- const require_statelessStateView = require('./statelessStateView-XdTJQxsY.cjs');
4
+ const require_optionUtils = require('./optionUtils-C1TXirKy.cjs');
5
+ const require_statelessStateView = require('./statelessStateView-CtzW08Yu.cjs');
6
6
  const require_factory = require('./factory-DitVXzjQ.cjs');
7
7
  let viem = require("viem");
8
8
  let react = require("react");
@@ -465,23 +465,19 @@ const useMarketData = (marketAddr) => {
465
465
  //#region src/hooks/options/useMarketState.ts
466
466
  const useMarketState = (marketAddr) => {
467
467
  const { timelockLens } = useLens();
468
- const { data, ...rest } = (0, wagmi.useReadContract)({
468
+ return (0, wagmi.useReadContract)({
469
469
  address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
470
470
  abi: require_statelessStateView.lensAbi,
471
471
  functionName: "getMarketState",
472
472
  args: marketAddr ? [marketAddr] : void 0
473
473
  });
474
- return {
475
- data: data || {},
476
- ...rest
477
- };
478
474
  };
479
475
 
480
476
  //#endregion
481
477
  //#region src/hooks/options/useMarketVolume.ts
482
478
  const useMarketVolume = (marketAddr) => {
483
479
  const { graphqlClient } = useTimelockConfig();
484
- const { data, ...rest } = (0, __tanstack_react_query.useQuery)({
480
+ return (0, __tanstack_react_query.useQuery)({
485
481
  queryKey: ["marketVolume", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
486
482
  queryFn: async () => {
487
483
  const result = await graphqlClient.GetMarketVolume({ marketAddr: marketAddr.toLowerCase() });
@@ -495,10 +491,6 @@ const useMarketVolume = (marketAddr) => {
495
491
  },
496
492
  enabled: !!marketAddr && !!graphqlClient
497
493
  });
498
- return {
499
- data: data || {},
500
- ...rest
501
- };
502
494
  };
503
495
 
504
496
  //#endregion
@@ -525,32 +517,11 @@ const useMaxPositionSize = (marketAddr, strikeTick, maxSteps = 100) => {
525
517
  };
526
518
  };
527
519
 
528
- //#endregion
529
- //#region src/hooks/pool/usePoolData.ts
530
- const usePoolData = (poolManager, poolKey) => {
531
- const { timelockLens } = useLens();
532
- const { data } = (0, wagmi.useReadContract)({
533
- address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
534
- abi: require_statelessStateView.lensAbi,
535
- functionName: "getPoolData",
536
- args: poolManager && poolKey ? [poolManager, poolKey] : void 0,
537
- query: { enabled: !!poolManager && !!poolKey }
538
- });
539
- const _default = (0, react.useMemo)(() => ({
540
- token0: poolKey === null || poolKey === void 0 ? void 0 : poolKey.currency0,
541
- token1: poolKey === null || poolKey === void 0 ? void 0 : poolKey.currency1,
542
- tickSpacing: poolKey === null || poolKey === void 0 ? void 0 : poolKey.tickSpacing,
543
- fee: poolKey === null || poolKey === void 0 ? void 0 : poolKey.fee
544
- }), [poolKey]);
545
- return data || _default;
546
- };
547
-
548
520
  //#endregion
549
521
  //#region src/hooks/pool/useCurrentTick.ts
550
522
  const useCurrentTick = (poolManager, poolKey) => {
551
523
  const { stateView } = useLens();
552
- const { tickSpacing } = usePoolData(poolManager, poolKey);
553
- const { data, ...rest } = (0, wagmi.useReadContract)({
524
+ return (0, wagmi.useReadContract)({
554
525
  address: stateView === null || stateView === void 0 ? void 0 : stateView.address,
555
526
  abi: require_statelessStateView.statelessStateViewAbi,
556
527
  functionName: "getSlot0",
@@ -560,21 +531,33 @@ const useCurrentTick = (poolManager, poolKey) => {
560
531
  refetchInterval: 3e3,
561
532
  select: (raw) => {
562
533
  const sqrtPriceX96 = raw[0];
563
- const exact = raw[1];
564
534
  return {
565
- exact,
566
- rounded: tickSpacing ? require_optionUtils.roundTick(exact, tickSpacing) : void 0,
535
+ currentTick: raw[1],
567
536
  sqrtPriceX96
568
537
  };
569
538
  }
570
539
  }
571
540
  });
572
- return {
573
- exact: data === null || data === void 0 ? void 0 : data.exact,
574
- rounded: data === null || data === void 0 ? void 0 : data.rounded,
575
- sqrtPriceX96: data === null || data === void 0 ? void 0 : data.sqrtPriceX96,
576
- ...rest
577
- };
541
+ };
542
+
543
+ //#endregion
544
+ //#region src/hooks/pool/usePoolData.ts
545
+ const usePoolData = (poolManager, poolKey) => {
546
+ const { timelockLens } = useLens();
547
+ const { data } = (0, wagmi.useReadContract)({
548
+ address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
549
+ abi: require_statelessStateView.lensAbi,
550
+ functionName: "getPoolData",
551
+ args: poolManager && poolKey ? [poolManager, poolKey] : void 0,
552
+ query: { enabled: !!poolManager && !!poolKey }
553
+ });
554
+ const _default = (0, react.useMemo)(() => ({
555
+ token0: poolKey === null || poolKey === void 0 ? void 0 : poolKey.currency0,
556
+ token1: poolKey === null || poolKey === void 0 ? void 0 : poolKey.currency1,
557
+ tickSpacing: poolKey === null || poolKey === void 0 ? void 0 : poolKey.tickSpacing,
558
+ fee: poolKey === null || poolKey === void 0 ? void 0 : poolKey.fee
559
+ }), [poolKey]);
560
+ return data || _default;
578
561
  };
579
562
 
580
563
  //#endregion
@@ -683,20 +666,13 @@ const usePriceAtSqrtPriceX96 = (poolManager, poolKey, sqrtPriceX96) => {
683
666
  //#endregion
684
667
  //#region src/hooks/pool/useCurrentPrice.ts
685
668
  const useCurrentPrice = (poolManager, poolKey) => {
686
- const { sqrtPriceX96, exact, rounded } = useCurrentTick(poolManager, poolKey);
669
+ const { data: { sqrtPriceX96, currentTick } = {} } = useCurrentTick(poolManager, poolKey);
687
670
  const currentPrice = usePriceAtSqrtPriceX96(poolManager, poolKey, sqrtPriceX96);
688
671
  return (0, react.useMemo)(() => ({
689
672
  currentPrice,
690
673
  sqrtPriceX96,
691
- currentTick: {
692
- exact,
693
- rounded
694
- }
695
- }), [
696
- currentPrice,
697
- exact,
698
- rounded
699
- ]);
674
+ currentTick
675
+ }), [currentPrice, currentTick]);
700
676
  };
701
677
 
702
678
  //#endregion
@@ -816,7 +792,7 @@ const useOptionPnl = (option) => {
816
792
  const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, remainingDuration = 0, strikeTick) => {
817
793
  const { poolManager, poolKey, payoutAssetDecimals, optionAssetIsToken0 } = useMarketData(marketAddr);
818
794
  const { tickSpacing } = usePoolData(poolManager, poolKey);
819
- const { exact: currentTick } = useCurrentTick(poolManager, poolKey);
795
+ const { data: { currentTick } = {} } = useCurrentTick(poolManager, poolKey);
820
796
  const strikeTickRounded = (0, react.useMemo)(() => {
821
797
  if (!tickSpacing || currentTick === void 0) return;
822
798
  let strikeTickRounded$1 = require_optionUtils.roundTick(strikeTick ?? currentTick, tickSpacing);
@@ -1115,7 +1091,7 @@ const useMintPerp = (marketAddr) => {
1115
1091
  if (optionAssetIsToken0 === void 0 || !payoutAsset) throw new Error("Market data not found");
1116
1092
  if (!operator.auth) await signMessage();
1117
1093
  const market = require_optionUtils.getTimelockMarket(marketAddr, client);
1118
- const { data: { exact: currentTick } = {} } = await refetchCurrentTick();
1094
+ const { data: { currentTick } = {} } = await refetchCurrentTick();
1119
1095
  if (currentTick === void 0) throw new Error("Could not fetch current tick");
1120
1096
  const validStrikeTick = require_optionUtils.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
1121
1097
  const [premium, protocolFee] = await market.read.calculatePremium([
@@ -1540,16 +1516,12 @@ const useVaultTVL = (vaultAddr) => {
1540
1516
  //#region src/hooks/guardian/useGuardianGlobalState.ts
1541
1517
  const useGuardianGlobalState = (guardianAddr) => {
1542
1518
  const { timelockLens } = useLens();
1543
- const { data, ...rest } = (0, wagmi.useReadContract)({
1519
+ return (0, wagmi.useReadContract)({
1544
1520
  address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
1545
1521
  abi: require_statelessStateView.lensAbi,
1546
1522
  functionName: "getGlobalGuardianState",
1547
1523
  args: guardianAddr ? [guardianAddr] : void 0
1548
1524
  });
1549
- return {
1550
- data: data || {},
1551
- ...rest
1552
- };
1553
1525
  };
1554
1526
 
1555
1527
  //#endregion
@@ -1625,7 +1597,7 @@ const useUpdateMarketFees = (marketAddr) => {
1625
1597
  const queryClient = (0, __tanstack_react_query.useQueryClient)();
1626
1598
  const publicClient = (0, wagmi.usePublicClient)();
1627
1599
  const chainId = (0, wagmi.useChainId)();
1628
- const { data: { feeStrategy, optionPricing } } = useMarketState(marketAddr);
1600
+ const { data: { feeStrategy, optionPricing } = {} } = useMarketState(marketAddr);
1629
1601
  const { openingFeeRate, baseFeeRate, minOpeningFee, minBaseFee, feeRecipient } = useFeeRates(feeStrategy);
1630
1602
  const updateMarketFees = async (rates) => {
1631
1603
  if (openingFeeRate === void 0 || baseFeeRate === void 0 || minOpeningFee === void 0 || minBaseFee === void 0 || feeRecipient === void 0) throw new Error("Missing current fee rates");
@@ -1765,7 +1737,7 @@ const useUpdateMarketPricing = (marketAddr) => {
1765
1737
  const queryClient = (0, __tanstack_react_query.useQueryClient)();
1766
1738
  const publicClient = (0, wagmi.usePublicClient)();
1767
1739
  const chainId = (0, wagmi.useChainId)();
1768
- const { data: { feeStrategy, optionPricing }, error: stateError } = useMarketState(marketAddr);
1740
+ const { data: { feeStrategy, optionPricing } = {}, error: stateError } = useMarketState(marketAddr);
1769
1741
  const { data: pricingData, error: pricingError } = usePricingParams(optionPricing);
1770
1742
  const updateMarketPricing = async (data) => {
1771
1743
  if (!marketAddr) throw new Error("Market address not found");