timelock-sdk 0.0.30 → 0.0.32
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 +15 -12
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +61 -61
- package/dist/client.d.ts +56 -56
- package/dist/client.js +15 -12
- package/dist/client.js.map +1 -1
- package/package.json +1 -1
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
|
|
422
|
-
if (
|
|
423
|
-
|
|
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
|
|
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:
|
|
436
|
+
args: [
|
|
434
437
|
optionType === "CALL" ? 0 : 1,
|
|
435
438
|
optionAmount,
|
|
436
|
-
|
|
439
|
+
strikeTickRounded,
|
|
437
440
|
BigInt(duration)
|
|
438
|
-
]
|
|
439
|
-
query: { enabled:
|
|
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;
|