timelock-sdk 0.0.24 → 0.0.26

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.js CHANGED
@@ -235,11 +235,10 @@ const useExerciseOption = (marketAddr) => {
235
235
  //#region src/hooks/useLens.ts
236
236
  const useLens = () => {
237
237
  const client = useClient();
238
- const timelockLens = useMemo(() => client ? getTimelockLens(client) : void 0, [client]);
239
- return {
240
- uniswapLens: useMemo(() => client ? getUniswapMathLens(client) : void 0, [client]),
241
- timelockLens
242
- };
238
+ return useMemo(() => ({
239
+ timelockLens: client ? getTimelockLens(client) : void 0,
240
+ uniswapLens: client ? getUniswapMathLens(client) : void 0
241
+ }), [client]);
243
242
  };
244
243
 
245
244
  //#endregion
@@ -308,11 +307,13 @@ const useCurrentTick = (poolAddr) => {
308
307
  functionName: "slot0",
309
308
  args: []
310
309
  });
311
- const exact = data === null || data === void 0 ? void 0 : data[1];
312
- return {
313
- exact,
314
- rounded: exact && tickSpacing ? Math.floor(exact / tickSpacing) * tickSpacing : void 0
315
- };
310
+ return useMemo(() => {
311
+ const exact = data === null || data === void 0 ? void 0 : data[1];
312
+ return {
313
+ exact,
314
+ rounded: exact && tickSpacing ? Math.floor(exact / tickSpacing) * tickSpacing : void 0
315
+ };
316
+ }, [data, tickSpacing]);
316
317
  };
317
318
 
318
319
  //#endregion
@@ -380,14 +381,14 @@ const useOptionPnl = (optionData) => {
380
381
  const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
381
382
  const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
382
383
  const { exact: currentTick } = useCurrentTick(pool);
383
- const { displayPnl, unrealizedPayout } = useMemo(() => {
384
+ return useMemo(() => {
384
385
  if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
385
386
  const entrySize = positionSizeCurrent * entryPrice / PRICE_PRECISION;
386
387
  const delta = (optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, currentTick) : token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
387
- const displayPnl$1 = wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
388
+ const displayPnl = wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
388
389
  return {
389
- unrealizedPayout: wrapAmount(displayPnl$1.scaled < 0 ? 0n : displayPnl$1.scaled, payoutAssetDecimals),
390
- displayPnl: displayPnl$1
390
+ unrealizedPayout: wrapAmount(displayPnl.scaled < 0 ? 0n : displayPnl.scaled, payoutAssetDecimals),
391
+ displayPnl
391
392
  };
392
393
  }, [
393
394
  entryPrice,
@@ -397,10 +398,6 @@ const useOptionPnl = (optionData) => {
397
398
  positionSizeCurrent,
398
399
  payoutAssetDecimals
399
400
  ]);
400
- return {
401
- displayPnl,
402
- unrealizedPayout
403
- };
404
401
  };
405
402
 
406
403
  //#endregion
@@ -468,7 +465,7 @@ const useUserOptions = (user, active = false) => {
468
465
  enabled: !!user && !!graphqlClient
469
466
  });
470
467
  return {
471
- data: useMemo(() => (options === null || options === void 0 ? void 0 : options.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())) || [], [options]),
468
+ data: useMemo(() => [...options || []].sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()), [options]),
472
469
  ...rest
473
470
  };
474
471
  };
@@ -495,10 +492,11 @@ const usePriceAtTick = (tick, poolAddr) => {
495
492
  //#region src/hooks/pool/useCurrentPrice.ts
496
493
  const useCurrentPrice = (poolAddr) => {
497
494
  const currentTick = useCurrentTick(poolAddr);
498
- return {
499
- currentPrice: usePriceAtTick(currentTick.exact, poolAddr),
495
+ const currentPrice = usePriceAtTick(currentTick.exact, poolAddr);
496
+ return useMemo(() => ({
497
+ currentPrice,
500
498
  currentTick
501
- };
499
+ }), [currentPrice, currentTick]);
502
500
  };
503
501
 
504
502
  //#endregion
@@ -729,20 +727,28 @@ const useVaultTVL = (vaultAddr) => {
729
727
  args: [vaultAddr],
730
728
  query: { enabled: !!vaultAddr && !!timelockLens }
731
729
  });
732
- const totalAmount0 = data && token0Decimals ? wrapAmount(data[0], token0Decimals) : void 0;
733
- const totalAmount1 = data && token1Decimals ? wrapAmount(data[1], token1Decimals) : void 0;
734
- const borrowedAmount0 = data && token0Decimals ? wrapAmount(data[2], token0Decimals) : void 0;
735
- const borrowedAmount1 = data && token1Decimals ? wrapAmount(data[3], token1Decimals) : void 0;
736
- return {
737
- tvl0: data && token0Decimals ? wrapAmount(data[4], token0Decimals) : void 0,
738
- tvl1: data && token1Decimals ? wrapAmount(data[5], token1Decimals) : void 0,
739
- totalAmount0,
740
- totalAmount1,
741
- borrowedAmount0,
742
- borrowedAmount1,
743
- blocksCount: data === null || data === void 0 ? void 0 : data[6],
730
+ return useMemo(() => {
731
+ if (!token0Decimals || !token1Decimals || !data) return {};
732
+ const totalAmount0 = wrapAmount(data[0], token0Decimals);
733
+ const totalAmount1 = wrapAmount(data[1], token1Decimals);
734
+ const borrowedAmount0 = wrapAmount(data[2], token0Decimals);
735
+ const borrowedAmount1 = wrapAmount(data[3], token1Decimals);
736
+ return {
737
+ tvl0: wrapAmount(data[4], token0Decimals),
738
+ tvl1: wrapAmount(data[5], token1Decimals),
739
+ totalAmount0,
740
+ totalAmount1,
741
+ borrowedAmount0,
742
+ borrowedAmount1,
743
+ blocksCount: data[6],
744
+ refetch
745
+ };
746
+ }, [
747
+ data,
748
+ token0Decimals,
749
+ token1Decimals,
744
750
  refetch
745
- };
751
+ ]);
746
752
  };
747
753
 
748
754
  //#endregion