timelock-sdk 0.0.23 → 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
@@ -384,37 +385,26 @@ const useMintOption = (marketAddr) => {
384
385
  //#endregion
385
386
  //#region src/hooks/market/useOptionPnl.ts
386
387
  const useOptionPnl = (optionData) => {
387
- const { marketAddr, optionType, entryTick, positionSizeCurrent } = optionData;
388
+ const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
388
389
  const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
389
390
  const { exact: currentTick } = useCurrentTick(pool);
390
- const entrySize = (0, react.useMemo)(() => {
391
- if (optionAssetIsToken0 === void 0) return;
392
- return optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, entryTick) : require_numberUtils.token1ToToken0(positionSizeCurrent, entryTick);
393
- }, [
394
- optionAssetIsToken0,
395
- positionSizeCurrent,
396
- entryTick
397
- ]);
398
- const { displayPnl, unrealizedPayout } = (0, react.useMemo)(() => {
399
- if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals || !entrySize) return {};
391
+ return (0, react.useMemo)(() => {
392
+ if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
393
+ const entrySize = positionSizeCurrent * entryPrice / require_numberUtils.PRICE_PRECISION;
400
394
  const delta = (optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, currentTick) : require_numberUtils.token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
401
- const displayPnl$1 = require_numberUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
395
+ const displayPnl = require_numberUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
402
396
  return {
403
- unrealizedPayout: require_numberUtils.wrapAmount(displayPnl$1.scaled < 0 ? 0n : displayPnl$1.scaled, payoutAssetDecimals),
404
- displayPnl: displayPnl$1
397
+ unrealizedPayout: require_numberUtils.wrapAmount(displayPnl.scaled < 0 ? 0n : displayPnl.scaled, payoutAssetDecimals),
398
+ displayPnl
405
399
  };
406
400
  }, [
407
- entrySize,
401
+ entryPrice,
408
402
  optionType,
409
403
  optionAssetIsToken0,
410
404
  currentTick,
411
405
  positionSizeCurrent,
412
406
  payoutAssetDecimals
413
407
  ]);
414
- return {
415
- displayPnl,
416
- unrealizedPayout
417
- };
418
408
  };
419
409
 
420
410
  //#endregion
@@ -509,10 +499,11 @@ const usePriceAtTick = (tick, poolAddr) => {
509
499
  //#region src/hooks/pool/useCurrentPrice.ts
510
500
  const useCurrentPrice = (poolAddr) => {
511
501
  const currentTick = useCurrentTick(poolAddr);
512
- return {
513
- currentPrice: usePriceAtTick(currentTick.exact, poolAddr),
502
+ const currentPrice = usePriceAtTick(currentTick.exact, poolAddr);
503
+ return (0, react.useMemo)(() => ({
504
+ currentPrice,
514
505
  currentTick
515
- };
506
+ }), [currentPrice, currentTick]);
516
507
  };
517
508
 
518
509
  //#endregion
@@ -743,20 +734,28 @@ const useVaultTVL = (vaultAddr) => {
743
734
  args: [vaultAddr],
744
735
  query: { enabled: !!vaultAddr && !!timelockLens }
745
736
  });
746
- const totalAmount0 = data && token0Decimals ? require_numberUtils.wrapAmount(data[0], token0Decimals) : void 0;
747
- const totalAmount1 = data && token1Decimals ? require_numberUtils.wrapAmount(data[1], token1Decimals) : void 0;
748
- const borrowedAmount0 = data && token0Decimals ? require_numberUtils.wrapAmount(data[2], token0Decimals) : void 0;
749
- const borrowedAmount1 = data && token1Decimals ? require_numberUtils.wrapAmount(data[3], token1Decimals) : void 0;
750
- return {
751
- tvl0: data && token0Decimals ? require_numberUtils.wrapAmount(data[4], token0Decimals) : void 0,
752
- tvl1: data && token1Decimals ? require_numberUtils.wrapAmount(data[5], token1Decimals) : void 0,
753
- totalAmount0,
754
- totalAmount1,
755
- borrowedAmount0,
756
- borrowedAmount1,
757
- 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,
758
757
  refetch
759
- };
758
+ ]);
760
759
  };
761
760
 
762
761
  //#endregion