timelock-sdk 0.0.22 → 0.0.24

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
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  import { lensAbi, optionsMarketAbi } from "./optionsMarket-DyBxHplR.js";
5
- import { getErc20, getPriceAtTick, getTimelockLens, getTimelockMarket, getUniswapMathLens, roundTickDown, timelockLenses, token0ToToken1, token1ToToken0, uniswapMathLenses, wrapAmount, wrapPrice } from "./numberUtils-CAMznXR5.js";
5
+ import { PRICE_PRECISION, getErc20, getPriceAtTick, getTimelockLens, getTimelockMarket, getUniswapMathLens, roundTickDown, timelockLenses, token0ToToken1, token1ToToken0, uniswapMathLenses, wrapAmount, wrapPrice } from "./numberUtils-CAMznXR5.js";
6
6
  import { singleOwnerVaultAbi, uniswapV3PoolAbi } from "./uniswapV3Pool-Copswrde.js";
7
7
  import { encodeFunctionData, erc20Abi, maxUint256 } from "viem";
8
8
  import React, { createContext, useContext, useMemo } from "react";
@@ -377,21 +377,22 @@ const useMintOption = (marketAddr) => {
377
377
  //#endregion
378
378
  //#region src/hooks/market/useOptionPnl.ts
379
379
  const useOptionPnl = (optionData) => {
380
- const { marketAddr, optionType, entryTick, positionSizeCurrent } = optionData;
380
+ const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
381
381
  const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
382
382
  const { exact: currentTick } = useCurrentTick(pool);
383
383
  const { displayPnl, unrealizedPayout } = useMemo(() => {
384
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);
385
+ const entrySize = positionSizeCurrent * entryPrice / PRICE_PRECISION;
386
+ const delta = (optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, currentTick) : token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
386
387
  const displayPnl$1 = wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
387
388
  return {
388
389
  unrealizedPayout: wrapAmount(displayPnl$1.scaled < 0 ? 0n : displayPnl$1.scaled, payoutAssetDecimals),
389
390
  displayPnl: displayPnl$1
390
391
  };
391
392
  }, [
393
+ entryPrice,
392
394
  optionType,
393
395
  optionAssetIsToken0,
394
- entryTick,
395
396
  currentTick,
396
397
  positionSizeCurrent,
397
398
  payoutAssetDecimals