timelock-sdk 0.0.175 → 0.0.177

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,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
 
4
- const require_optionUtils = require('./optionUtils-C1TXirKy.cjs');
4
+ const require_optionUtils = require('./optionUtils-BHU2evq2.cjs');
5
5
  const require_statelessStateView = require('./statelessStateView-CtzW08Yu.cjs');
6
6
  const require_factory = require('./factory-DitVXzjQ.cjs');
7
7
  let viem = require("viem");
@@ -10,8 +10,8 @@ react = require_optionUtils.__toESM(react);
10
10
  let graphql_request = require("graphql-request");
11
11
  let graphql_tag = require("graphql-tag");
12
12
  graphql_tag = require_optionUtils.__toESM(graphql_tag);
13
- let wagmi = require("wagmi");
14
13
  let __tanstack_react_query = require("@tanstack/react-query");
14
+ let wagmi = require("wagmi");
15
15
  let viem_actions = require("viem/actions");
16
16
  let zod = require("zod");
17
17
 
@@ -441,11 +441,21 @@ const useTimelockConfig = () => {
441
441
  //#endregion
442
442
  //#region src/hooks/useLens.ts
443
443
  const useLens = () => {
444
- const client = (0, wagmi.useClient)();
445
- return (0, react.useMemo)(() => ({
446
- timelockLens: client ? require_optionUtils.getTimelockLens(client) : void 0,
447
- stateView: client ? require_optionUtils.getStateView(client) : void 0
448
- }), [client]);
444
+ const client = (0, wagmi.usePublicClient)();
445
+ const { data: timelockLens } = (0, __tanstack_react_query.useQuery)({
446
+ queryKey: ["timelockLens", client === null || client === void 0 ? void 0 : client.uid],
447
+ queryFn: () => client ? require_optionUtils.getTimelockLens(client) : void 0,
448
+ enabled: !!client
449
+ });
450
+ const { data: stateView } = (0, __tanstack_react_query.useQuery)({
451
+ queryKey: ["stateView", client === null || client === void 0 ? void 0 : client.uid],
452
+ queryFn: () => client ? require_optionUtils.getStateView(client) : void 0,
453
+ enabled: !!client
454
+ });
455
+ return {
456
+ timelockLens,
457
+ stateView
458
+ };
449
459
  };
450
460
 
451
461
  //#endregion
@@ -606,7 +616,7 @@ const useMintOption = (marketAddr) => {
606
616
  if (!timelockLens) throw new Error("Timelock lens not available");
607
617
  if (!tickSpacing) throw new Error("Pool data not available");
608
618
  if (!vault || !payoutAsset || optionAssetIsToken0 === void 0) throw new Error("Market data not available");
609
- const { data: { exact: currentTick } = {} } = await refetchCurrentTick();
619
+ const { data: { currentTick } = {} } = await refetchCurrentTick();
610
620
  if (currentTick === void 0) throw new Error("Could not fetch current tick");
611
621
  strikeTick = require_optionUtils.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
612
622
  const [premium, protocolFee] = await require_optionUtils.getTimelockMarket(marketAddr, client).read.calculatePremium([
@@ -616,7 +626,8 @@ const useMintOption = (marketAddr) => {
616
626
  duration,
617
627
  0
618
628
  ]);
619
- await askForApproval(payoutAsset, marketAddr, (premium + protocolFee) * 11n / 10n);
629
+ const maxPremium = (premium + protocolFee) * 11n / 10n;
630
+ await askForApproval(payoutAsset, marketAddr, maxPremium);
620
631
  const hash = await writeContractAsync({
621
632
  address: marketAddr,
622
633
  abi: require_statelessStateView.optionsMarketAbi,
@@ -627,7 +638,7 @@ const useMintOption = (marketAddr) => {
627
638
  amount,
628
639
  strikeTick,
629
640
  duration,
630
- viem.maxUint256,
641
+ maxPremium,
631
642
  maxSteps,
632
643
  await timelockLens.read.getRefTick([vault, strikeTick])
633
644
  ]