timelock-sdk 0.0.22 → 0.0.23

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
@@ -380,18 +380,26 @@ const useOptionPnl = (optionData) => {
380
380
  const { marketAddr, optionType, entryTick, positionSizeCurrent } = optionData;
381
381
  const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
382
382
  const { exact: currentTick } = useCurrentTick(pool);
383
+ const entrySize = useMemo(() => {
384
+ if (optionAssetIsToken0 === void 0) return;
385
+ return optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, entryTick) : token1ToToken0(positionSizeCurrent, entryTick);
386
+ }, [
387
+ optionAssetIsToken0,
388
+ positionSizeCurrent,
389
+ entryTick
390
+ ]);
383
391
  const { displayPnl, unrealizedPayout } = useMemo(() => {
384
- if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
385
- const delta = optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, currentTick) - token0ToToken1(positionSizeCurrent, entryTick) : token1ToToken0(positionSizeCurrent, currentTick) - token1ToToken0(positionSizeCurrent, entryTick);
392
+ if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals || !entrySize) return {};
393
+ const delta = (optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, currentTick) : token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
386
394
  const displayPnl$1 = wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
387
395
  return {
388
396
  unrealizedPayout: wrapAmount(displayPnl$1.scaled < 0 ? 0n : displayPnl$1.scaled, payoutAssetDecimals),
389
397
  displayPnl: displayPnl$1
390
398
  };
391
399
  }, [
400
+ entrySize,
392
401
  optionType,
393
402
  optionAssetIsToken0,
394
- entryTick,
395
403
  currentTick,
396
404
  positionSizeCurrent,
397
405
  payoutAssetDecimals