timelock-sdk 0.0.152 → 0.0.153

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-Ca6wNxS_.cjs');
5
- const require_optionsMarket = require('./optionsMarket-XbnJNwMF.cjs');
4
+ const require_optionUtils = require('./optionUtils-D4d_u_d3.cjs');
5
+ const require_optionsMarket = require('./optionsMarket-DmR1QeKW.cjs');
6
6
  const require_singleOwnerVault = require('./singleOwnerVault-GCpQV7pN.cjs');
7
7
  let viem = require("viem");
8
8
  let react = require("react");
@@ -451,42 +451,14 @@ const useLens = () => {
451
451
  //#endregion
452
452
  //#region src/hooks/options/useMarketData.ts
453
453
  const useMarketData = (marketAddr) => {
454
- const { graphqlClient } = useTimelockConfig();
455
454
  const { timelockLens } = useLens();
456
- const { data } = (0, __tanstack_react_query.useQuery)({
457
- queryKey: ["marketData", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
458
- queryFn: async () => {
459
- const result = await graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() });
460
- return {
461
- ...result.TimelockMarket[0],
462
- address: result.TimelockMarket[0].address,
463
- poolManager: result.TimelockMarket[0].poolManager,
464
- poolKey: {
465
- currency0: result.TimelockMarket[0].currency0,
466
- currency1: result.TimelockMarket[0].currency1,
467
- fee: result.TimelockMarket[0].fee,
468
- tickSpacing: result.TimelockMarket[0].tickSpacing,
469
- hooks: result.TimelockMarket[0].hooks
470
- },
471
- vault: result.TimelockMarket[0].vault,
472
- optionAsset: result.TimelockMarket[0].optionAsset,
473
- payoutAsset: result.TimelockMarket[0].payoutAsset
474
- };
475
- },
476
- enabled: !!marketAddr && !!graphqlClient
477
- });
478
- const { data: fallback } = (0, __tanstack_react_query.useQuery)({
479
- queryKey: ["marketData", marketAddr || "--"],
480
- queryFn: async () => {
481
- if (!marketAddr || !timelockLens) return void 0;
482
- return {
483
- ...await timelockLens.read.getMarketData([marketAddr]),
484
- tradersCount: void 0
485
- };
486
- },
487
- enabled: !!marketAddr && !!timelockLens
455
+ const { data } = (0, wagmi.useReadContract)({
456
+ address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
457
+ abi: require_optionsMarket.lensAbi,
458
+ functionName: "getMarketData",
459
+ args: marketAddr ? [marketAddr] : void 0
488
460
  });
489
- return data || fallback || {};
461
+ return data || {};
490
462
  };
491
463
 
492
464
  //#endregion
@@ -743,7 +715,7 @@ const useMintOption = (marketAddr) => {
743
715
  const { timelockLens } = useLens();
744
716
  const { askForApproval } = useApproval();
745
717
  const { writeContractAsync } = (0, wagmi.useWriteContract)();
746
- const mintOption = async ({ optionType, amount, duration, strikeTick, maxSteps }) => {
718
+ const mintOption = async ({ optionType, amount, duration, strikeTick, maxSteps = 100 }) => {
747
719
  if (!client || !address) throw new Error("Wallet not connected");
748
720
  if (!marketAddr) throw new Error("Market address not available");
749
721
  if (!timelockLens) throw new Error("Timelock lens not available");
@@ -751,7 +723,6 @@ const useMintOption = (marketAddr) => {
751
723
  if (!vault || !payoutAsset || optionAssetIsToken0 === void 0) throw new Error("Market data not available");
752
724
  const { data: { exact: currentTick } = {} } = await refetchCurrentTick();
753
725
  if (currentTick === void 0) throw new Error("Could not fetch current tick");
754
- maxSteps = maxSteps || 100;
755
726
  strikeTick = require_optionUtils.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
756
727
  const [premium, protocolFee] = await require_optionUtils.getTimelockMarket(marketAddr, client).read.calculatePremium([
757
728
  optionType === "CALL" ? 0 : 1,
@@ -790,7 +761,8 @@ const useMintOption = (marketAddr) => {
790
761
  //#region src/hooks/options/useOptionPnl.ts
791
762
  const useOptionPnl = (option) => {
792
763
  const { marketAddr, optionType, strikeTick, positionSizeCurrent } = option;
793
- const { poolManager, poolKey, optionAssetIsToken0, payoutAssetDecimals, tickSpacing } = useMarketData(marketAddr);
764
+ const { poolManager, poolKey, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
765
+ const { tickSpacing } = usePoolData(poolManager, poolKey);
794
766
  const { currentPrice } = useCurrentPrice(poolManager, poolKey);
795
767
  const displayPnl = (0, react.useMemo)(() => {
796
768
  if (optionAssetIsToken0 === void 0 || currentPrice === void 0 || !payoutAssetDecimals) return void 0;