timelock-sdk 0.0.30 → 0.0.31

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
@@ -414,29 +414,32 @@ const useOptionPnl = (optionData) => {
414
414
 
415
415
  //#endregion
416
416
  //#region src/hooks/market/useOptionPremium.ts
417
- const useOptionPremium = (marketAddr, optionType, optionAmount, duration) => {
418
- const { pool, payoutAssetDecimals } = useMarketData(marketAddr);
417
+ const useOptionPremium = (marketAddr, optionType, optionAmount, duration, strikeTick) => {
418
+ const { pool, payoutAssetDecimals, optionAssetIsToken0 } = useMarketData(marketAddr);
419
419
  const { tickSpacing } = usePoolData(pool);
420
- const currentTick = useCurrentTick(pool);
421
- const strikeTick = (0, react.useMemo)(() => {
422
- if (currentTick.rounded === void 0 || tickSpacing === void 0) return;
423
- return optionType === "CALL" ? currentTick.rounded + tickSpacing : currentTick.rounded;
420
+ const { exact: currentTick } = useCurrentTick(pool);
421
+ const strikeTickRounded = (0, react.useMemo)(() => {
422
+ if (!tickSpacing || currentTick === void 0) return;
423
+ strikeTick = require_numberUtils.roundTickDown(strikeTick ?? currentTick, tickSpacing);
424
+ if (optionType === "CALL" && optionAssetIsToken0 || optionType === "PUT" && !optionAssetIsToken0) strikeTick += tickSpacing;
424
425
  }, [
425
- currentTick.rounded,
426
+ currentTick,
426
427
  tickSpacing,
427
- optionType
428
+ optionType,
429
+ optionAssetIsToken0,
430
+ strikeTick
428
431
  ]);
429
432
  const { data: premiumData } = (0, wagmi.useReadContract)({
430
433
  address: marketAddr,
431
434
  abi: require_optionsMarket.optionsMarketAbi,
432
435
  functionName: "calculatePremium",
433
- args: strikeTick !== void 0 ? [
436
+ args: [
434
437
  optionType === "CALL" ? 0 : 1,
435
438
  optionAmount,
436
- strikeTick,
439
+ strikeTickRounded,
437
440
  BigInt(duration)
438
- ] : void 0,
439
- query: { enabled: currentTick.rounded !== void 0 && payoutAssetDecimals !== void 0 && tickSpacing !== void 0 && strikeTick !== void 0 }
441
+ ],
442
+ query: { enabled: strikeTickRounded !== void 0 }
440
443
  });
441
444
  return (0, react.useMemo)(() => {
442
445
  if (premiumData === void 0 || payoutAssetDecimals === void 0) return;