timelock-sdk 0.0.152 → 0.0.153
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/abis.cjs +1 -1
- package/dist/abis.d.cts +1 -1
- package/dist/abis.d.ts +1 -1
- package/dist/abis.js +1 -1
- package/dist/{client-D3bjMcG6.d.cts → client-BqydZjhA.d.cts} +795 -214
- package/dist/{client-C_K2WYRG.d.ts → client-CbVaB9SD.d.ts} +988 -407
- package/dist/client.cjs +11 -39
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +11 -39
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-Ca6wNxS_.cjs → optionUtils-D4d_u_d3.cjs} +3 -3
- package/dist/{optionUtils-Ca6wNxS_.cjs.map → optionUtils-D4d_u_d3.cjs.map} +1 -1
- package/dist/{optionUtils-y7UljRiD.js → optionUtils-DJ8kTxc_.js} +3 -3
- package/dist/{optionUtils-y7UljRiD.js.map → optionUtils-DJ8kTxc_.js.map} +1 -1
- package/dist/{optionsMarket-C_RhiADr.js → optionsMarket-C83iT_EM.js} +21 -1
- package/dist/optionsMarket-C83iT_EM.js.map +1 -0
- package/dist/{optionsMarket-XbnJNwMF.cjs → optionsMarket-DmR1QeKW.cjs} +21 -1
- package/dist/optionsMarket-DmR1QeKW.cjs.map +1 -0
- package/dist/package.cjs +2 -2
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/dist/{uniswapMathLens-BvytoF0M.d.cts → uniswapMathLens-2KoUe3_5.d.ts} +17 -1
- package/dist/{uniswapMathLens-D5k9_mba.d.ts → uniswapMathLens-td1h0_OB.d.cts} +17 -1
- package/package.json +1 -1
- package/dist/optionsMarket-C_RhiADr.js.map +0 -1
- package/dist/optionsMarket-XbnJNwMF.cjs.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_optionUtils = require('./optionUtils-
|
|
5
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
4
|
+
const require_optionUtils = require('./optionUtils-D4d_u_d3.cjs');
|
|
5
|
+
const require_optionsMarket = require('./optionsMarket-DmR1QeKW.cjs');
|
|
6
6
|
const require_singleOwnerVault = require('./singleOwnerVault-GCpQV7pN.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
8
8
|
let react = require("react");
|
|
@@ -451,42 +451,14 @@ const useLens = () => {
|
|
|
451
451
|
//#endregion
|
|
452
452
|
//#region src/hooks/options/useMarketData.ts
|
|
453
453
|
const useMarketData = (marketAddr) => {
|
|
454
|
-
const { graphqlClient } = useTimelockConfig();
|
|
455
454
|
const { timelockLens } = useLens();
|
|
456
|
-
const { data } = (0,
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
...result.TimelockMarket[0],
|
|
462
|
-
address: result.TimelockMarket[0].address,
|
|
463
|
-
poolManager: result.TimelockMarket[0].poolManager,
|
|
464
|
-
poolKey: {
|
|
465
|
-
currency0: result.TimelockMarket[0].currency0,
|
|
466
|
-
currency1: result.TimelockMarket[0].currency1,
|
|
467
|
-
fee: result.TimelockMarket[0].fee,
|
|
468
|
-
tickSpacing: result.TimelockMarket[0].tickSpacing,
|
|
469
|
-
hooks: result.TimelockMarket[0].hooks
|
|
470
|
-
},
|
|
471
|
-
vault: result.TimelockMarket[0].vault,
|
|
472
|
-
optionAsset: result.TimelockMarket[0].optionAsset,
|
|
473
|
-
payoutAsset: result.TimelockMarket[0].payoutAsset
|
|
474
|
-
};
|
|
475
|
-
},
|
|
476
|
-
enabled: !!marketAddr && !!graphqlClient
|
|
477
|
-
});
|
|
478
|
-
const { data: fallback } = (0, __tanstack_react_query.useQuery)({
|
|
479
|
-
queryKey: ["marketData", marketAddr || "--"],
|
|
480
|
-
queryFn: async () => {
|
|
481
|
-
if (!marketAddr || !timelockLens) return void 0;
|
|
482
|
-
return {
|
|
483
|
-
...await timelockLens.read.getMarketData([marketAddr]),
|
|
484
|
-
tradersCount: void 0
|
|
485
|
-
};
|
|
486
|
-
},
|
|
487
|
-
enabled: !!marketAddr && !!timelockLens
|
|
455
|
+
const { data } = (0, wagmi.useReadContract)({
|
|
456
|
+
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
457
|
+
abi: require_optionsMarket.lensAbi,
|
|
458
|
+
functionName: "getMarketData",
|
|
459
|
+
args: marketAddr ? [marketAddr] : void 0
|
|
488
460
|
});
|
|
489
|
-
return data ||
|
|
461
|
+
return data || {};
|
|
490
462
|
};
|
|
491
463
|
|
|
492
464
|
//#endregion
|
|
@@ -743,7 +715,7 @@ const useMintOption = (marketAddr) => {
|
|
|
743
715
|
const { timelockLens } = useLens();
|
|
744
716
|
const { askForApproval } = useApproval();
|
|
745
717
|
const { writeContractAsync } = (0, wagmi.useWriteContract)();
|
|
746
|
-
const mintOption = async ({ optionType, amount, duration, strikeTick, maxSteps }) => {
|
|
718
|
+
const mintOption = async ({ optionType, amount, duration, strikeTick, maxSteps = 100 }) => {
|
|
747
719
|
if (!client || !address) throw new Error("Wallet not connected");
|
|
748
720
|
if (!marketAddr) throw new Error("Market address not available");
|
|
749
721
|
if (!timelockLens) throw new Error("Timelock lens not available");
|
|
@@ -751,7 +723,6 @@ const useMintOption = (marketAddr) => {
|
|
|
751
723
|
if (!vault || !payoutAsset || optionAssetIsToken0 === void 0) throw new Error("Market data not available");
|
|
752
724
|
const { data: { exact: currentTick } = {} } = await refetchCurrentTick();
|
|
753
725
|
if (currentTick === void 0) throw new Error("Could not fetch current tick");
|
|
754
|
-
maxSteps = maxSteps || 100;
|
|
755
726
|
strikeTick = require_optionUtils.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
|
|
756
727
|
const [premium, protocolFee] = await require_optionUtils.getTimelockMarket(marketAddr, client).read.calculatePremium([
|
|
757
728
|
optionType === "CALL" ? 0 : 1,
|
|
@@ -790,7 +761,8 @@ const useMintOption = (marketAddr) => {
|
|
|
790
761
|
//#region src/hooks/options/useOptionPnl.ts
|
|
791
762
|
const useOptionPnl = (option) => {
|
|
792
763
|
const { marketAddr, optionType, strikeTick, positionSizeCurrent } = option;
|
|
793
|
-
const { poolManager, poolKey, optionAssetIsToken0, payoutAssetDecimals
|
|
764
|
+
const { poolManager, poolKey, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
|
|
765
|
+
const { tickSpacing } = usePoolData(poolManager, poolKey);
|
|
794
766
|
const { currentPrice } = useCurrentPrice(poolManager, poolKey);
|
|
795
767
|
const displayPnl = (0, react.useMemo)(() => {
|
|
796
768
|
if (optionAssetIsToken0 === void 0 || currentPrice === void 0 || !payoutAssetDecimals) return void 0;
|