timelock-sdk 0.0.24 → 0.0.25

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
@@ -242,11 +242,10 @@ const useExerciseOption = (marketAddr) => {
242
242
  //#region src/hooks/useLens.ts
243
243
  const useLens = () => {
244
244
  const client = (0, wagmi.useClient)();
245
- const timelockLens = (0, react.useMemo)(() => client ? require_numberUtils.getTimelockLens(client) : void 0, [client]);
246
- return {
247
- uniswapLens: (0, react.useMemo)(() => client ? require_numberUtils.getUniswapMathLens(client) : void 0, [client]),
248
- timelockLens
249
- };
245
+ return (0, react.useMemo)(() => ({
246
+ timelockLens: client ? require_numberUtils.getTimelockLens(client) : void 0,
247
+ uniswapLens: client ? require_numberUtils.getUniswapMathLens(client) : void 0
248
+ }), [client]);
250
249
  };
251
250
 
252
251
  //#endregion
@@ -315,11 +314,13 @@ const useCurrentTick = (poolAddr) => {
315
314
  functionName: "slot0",
316
315
  args: []
317
316
  });
318
- const exact = data === null || data === void 0 ? void 0 : data[1];
319
- return {
320
- exact,
321
- rounded: exact && tickSpacing ? Math.floor(exact / tickSpacing) * tickSpacing : void 0
322
- };
317
+ return (0, react.useMemo)(() => {
318
+ const exact = data === null || data === void 0 ? void 0 : data[1];
319
+ return {
320
+ exact,
321
+ rounded: exact && tickSpacing ? Math.floor(exact / tickSpacing) * tickSpacing : void 0
322
+ };
323
+ }, [data, tickSpacing]);
323
324
  };
324
325
 
325
326
  //#endregion
@@ -387,14 +388,14 @@ const useOptionPnl = (optionData) => {
387
388
  const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
388
389
  const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
389
390
  const { exact: currentTick } = useCurrentTick(pool);
390
- const { displayPnl, unrealizedPayout } = (0, react.useMemo)(() => {
391
+ return (0, react.useMemo)(() => {
391
392
  if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
392
393
  const entrySize = positionSizeCurrent * entryPrice / require_numberUtils.PRICE_PRECISION;
393
394
  const delta = (optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, currentTick) : require_numberUtils.token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
394
- const displayPnl$1 = require_numberUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
395
+ const displayPnl = require_numberUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
395
396
  return {
396
- unrealizedPayout: require_numberUtils.wrapAmount(displayPnl$1.scaled < 0 ? 0n : displayPnl$1.scaled, payoutAssetDecimals),
397
- displayPnl: displayPnl$1
397
+ unrealizedPayout: require_numberUtils.wrapAmount(displayPnl.scaled < 0 ? 0n : displayPnl.scaled, payoutAssetDecimals),
398
+ displayPnl
398
399
  };
399
400
  }, [
400
401
  entryPrice,
@@ -404,10 +405,6 @@ const useOptionPnl = (optionData) => {
404
405
  positionSizeCurrent,
405
406
  payoutAssetDecimals
406
407
  ]);
407
- return {
408
- displayPnl,
409
- unrealizedPayout
410
- };
411
408
  };
412
409
 
413
410
  //#endregion
@@ -502,10 +499,11 @@ const usePriceAtTick = (tick, poolAddr) => {
502
499
  //#region src/hooks/pool/useCurrentPrice.ts
503
500
  const useCurrentPrice = (poolAddr) => {
504
501
  const currentTick = useCurrentTick(poolAddr);
505
- return {
506
- currentPrice: usePriceAtTick(currentTick.exact, poolAddr),
502
+ const currentPrice = usePriceAtTick(currentTick.exact, poolAddr);
503
+ return (0, react.useMemo)(() => ({
504
+ currentPrice,
507
505
  currentTick
508
- };
506
+ }), [currentPrice, currentTick]);
509
507
  };
510
508
 
511
509
  //#endregion
@@ -736,20 +734,28 @@ const useVaultTVL = (vaultAddr) => {
736
734
  args: [vaultAddr],
737
735
  query: { enabled: !!vaultAddr && !!timelockLens }
738
736
  });
739
- const totalAmount0 = data && token0Decimals ? require_numberUtils.wrapAmount(data[0], token0Decimals) : void 0;
740
- const totalAmount1 = data && token1Decimals ? require_numberUtils.wrapAmount(data[1], token1Decimals) : void 0;
741
- const borrowedAmount0 = data && token0Decimals ? require_numberUtils.wrapAmount(data[2], token0Decimals) : void 0;
742
- const borrowedAmount1 = data && token1Decimals ? require_numberUtils.wrapAmount(data[3], token1Decimals) : void 0;
743
- return {
744
- tvl0: data && token0Decimals ? require_numberUtils.wrapAmount(data[4], token0Decimals) : void 0,
745
- tvl1: data && token1Decimals ? require_numberUtils.wrapAmount(data[5], token1Decimals) : void 0,
746
- totalAmount0,
747
- totalAmount1,
748
- borrowedAmount0,
749
- borrowedAmount1,
750
- blocksCount: data === null || data === void 0 ? void 0 : data[6],
737
+ return (0, react.useMemo)(() => {
738
+ if (!token0Decimals || !token1Decimals || !data) return {};
739
+ const totalAmount0 = require_numberUtils.wrapAmount(data[0], token0Decimals);
740
+ const totalAmount1 = require_numberUtils.wrapAmount(data[1], token1Decimals);
741
+ const borrowedAmount0 = require_numberUtils.wrapAmount(data[2], token0Decimals);
742
+ const borrowedAmount1 = require_numberUtils.wrapAmount(data[3], token1Decimals);
743
+ return {
744
+ tvl0: require_numberUtils.wrapAmount(data[4], token0Decimals),
745
+ tvl1: require_numberUtils.wrapAmount(data[5], token1Decimals),
746
+ totalAmount0,
747
+ totalAmount1,
748
+ borrowedAmount0,
749
+ borrowedAmount1,
750
+ blocksCount: data[6],
751
+ refetch
752
+ };
753
+ }, [
754
+ data,
755
+ token0Decimals,
756
+ token1Decimals,
751
757
  refetch
752
- };
758
+ ]);
753
759
  };
754
760
 
755
761
  //#endregion