timelock-sdk 0.0.138 → 0.0.140
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-CP_QHL05.d.cts → client-BLQCtXFi.d.ts} +44 -28
- package/dist/{client-D1p2JAlj.d.ts → client-FNWYyxxl.d.cts} +408 -392
- package/dist/client.cjs +40 -22
- 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 +40 -22
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-BunZxBrW.js → optionUtils-9m2sevDs.js} +15 -5
- package/dist/optionUtils-9m2sevDs.js.map +1 -0
- package/dist/{optionUtils-BUJzXFyd.cjs → optionUtils-pIZ0mbRp.cjs} +19 -3
- package/dist/optionUtils-pIZ0mbRp.cjs.map +1 -0
- package/dist/package.cjs +2 -1
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/package.json +1 -1
- package/dist/optionUtils-BUJzXFyd.cjs.map +0 -1
- package/dist/optionUtils-BunZxBrW.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_optionUtils = require('./optionUtils-
|
|
4
|
+
const require_optionUtils = require('./optionUtils-pIZ0mbRp.cjs');
|
|
5
5
|
const require_optionsMarket = require('./optionsMarket-ohPoVcdm.cjs');
|
|
6
6
|
const require_singleOwnerVault = require('./singleOwnerVault-GCpQV7pN.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
@@ -101,7 +101,6 @@ const GetMarketDataDocument = graphql_tag.default`
|
|
|
101
101
|
id
|
|
102
102
|
address
|
|
103
103
|
vault
|
|
104
|
-
pool
|
|
105
104
|
tickSpacing
|
|
106
105
|
optionAssetIsToken0
|
|
107
106
|
optionAsset
|
|
@@ -112,6 +111,12 @@ const GetMarketDataDocument = graphql_tag.default`
|
|
|
112
111
|
payoutAssetSymbol
|
|
113
112
|
optionAssetName
|
|
114
113
|
payoutAssetName
|
|
114
|
+
poolManager
|
|
115
|
+
currency0
|
|
116
|
+
currency1
|
|
117
|
+
fee
|
|
118
|
+
hooks
|
|
119
|
+
tickSpacing
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
`;
|
|
@@ -455,7 +460,14 @@ const useMarketData = (marketAddr) => {
|
|
|
455
460
|
return {
|
|
456
461
|
...result.TimelockMarket[0],
|
|
457
462
|
address: result.TimelockMarket[0].address,
|
|
458
|
-
|
|
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
|
+
},
|
|
459
471
|
vault: result.TimelockMarket[0].vault,
|
|
460
472
|
optionAsset: result.TimelockMarket[0].optionAsset,
|
|
461
473
|
payoutAsset: result.TimelockMarket[0].payoutAsset
|
|
@@ -488,7 +500,13 @@ const usePoolData = (poolManager, poolKey) => {
|
|
|
488
500
|
args: poolManager && poolKey ? [poolManager, poolKey] : void 0,
|
|
489
501
|
query: { enabled: !!poolManager && !!poolKey }
|
|
490
502
|
});
|
|
491
|
-
|
|
503
|
+
const _default = (0, react.useMemo)(() => ({
|
|
504
|
+
token0: poolKey === null || poolKey === void 0 ? void 0 : poolKey.currency0,
|
|
505
|
+
token1: poolKey === null || poolKey === void 0 ? void 0 : poolKey.currency1,
|
|
506
|
+
tickSpacing: poolKey === null || poolKey === void 0 ? void 0 : poolKey.tickSpacing,
|
|
507
|
+
fee: poolKey === null || poolKey === void 0 ? void 0 : poolKey.fee
|
|
508
|
+
}), [poolKey]);
|
|
509
|
+
return data || _default;
|
|
492
510
|
};
|
|
493
511
|
|
|
494
512
|
//#endregion
|
|
@@ -498,8 +516,8 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
498
516
|
//#endregion
|
|
499
517
|
//#region src/hooks/options/useExerciseOption.ts
|
|
500
518
|
const useExerciseOption = (marketAddr) => {
|
|
501
|
-
const { vault,
|
|
502
|
-
const { fee } = usePoolData(
|
|
519
|
+
const { vault, poolManager, poolKey } = useMarketData(marketAddr);
|
|
520
|
+
const { fee } = usePoolData(poolManager, poolKey);
|
|
503
521
|
const { timelockLens } = useLens();
|
|
504
522
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
505
523
|
const client = (0, wagmi.useClient)();
|
|
@@ -640,9 +658,9 @@ const useApproval = () => {
|
|
|
640
658
|
//#endregion
|
|
641
659
|
//#region src/hooks/options/useMintOption.ts
|
|
642
660
|
const useMintOption = (marketAddr) => {
|
|
643
|
-
const { payoutAsset, vault,
|
|
644
|
-
const { tickSpacing } = usePoolData(
|
|
645
|
-
const { refetch: refetchCurrentTick } = useCurrentTick(
|
|
661
|
+
const { payoutAsset, vault, poolManager, poolKey, optionAssetIsToken0 } = useMarketData(marketAddr);
|
|
662
|
+
const { tickSpacing } = usePoolData(poolManager, poolKey);
|
|
663
|
+
const { refetch: refetchCurrentTick } = useCurrentTick(poolManager, poolKey);
|
|
646
664
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
647
665
|
const client = (0, wagmi.useClient)();
|
|
648
666
|
const { address } = (0, wagmi.useConnection)();
|
|
@@ -692,8 +710,8 @@ const useMintOption = (marketAddr) => {
|
|
|
692
710
|
|
|
693
711
|
//#endregion
|
|
694
712
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
695
|
-
const usePriceAtTick = (
|
|
696
|
-
const { token0Decimals, token1Decimals } = usePoolData(
|
|
713
|
+
const usePriceAtTick = (poolManager, poolKey, tick) => {
|
|
714
|
+
const { token0Decimals, token1Decimals } = usePoolData(poolManager, poolKey);
|
|
697
715
|
const priceBigInt = (0, react.useMemo)(() => tick !== void 0 ? require_optionUtils.getPriceAtTick(tick) : void 0, [tick]);
|
|
698
716
|
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
699
717
|
priceBigInt,
|
|
@@ -701,8 +719,8 @@ const usePriceAtTick = (tick, poolAddr) => {
|
|
|
701
719
|
token1Decimals
|
|
702
720
|
]);
|
|
703
721
|
};
|
|
704
|
-
const
|
|
705
|
-
const { token0Decimals, token1Decimals } = usePoolData(
|
|
722
|
+
const usePriceAtSqrtPriceX96 = (poolManager, poolKey, sqrtPriceX96) => {
|
|
723
|
+
const { token0Decimals, token1Decimals } = usePoolData(poolManager, poolKey);
|
|
706
724
|
const priceBigInt = (0, react.useMemo)(() => sqrtPriceX96 !== void 0 ? require_optionUtils.getPriceAtSqrtPriceX96(sqrtPriceX96) : void 0, [sqrtPriceX96]);
|
|
707
725
|
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
708
726
|
priceBigInt,
|
|
@@ -713,9 +731,9 @@ const usePriceSqrtPriceX96 = (sqrtPriceX96, poolAddr) => {
|
|
|
713
731
|
|
|
714
732
|
//#endregion
|
|
715
733
|
//#region src/hooks/pool/useCurrentPrice.ts
|
|
716
|
-
const useCurrentPrice = (
|
|
717
|
-
const { sqrtPriceX96, exact, rounded } = useCurrentTick(
|
|
718
|
-
const currentPrice =
|
|
734
|
+
const useCurrentPrice = (poolManager, poolKey) => {
|
|
735
|
+
const { sqrtPriceX96, exact, rounded } = useCurrentTick(poolManager, poolKey);
|
|
736
|
+
const currentPrice = usePriceAtSqrtPriceX96(poolManager, poolKey, sqrtPriceX96);
|
|
719
737
|
return (0, react.useMemo)(() => ({
|
|
720
738
|
currentPrice,
|
|
721
739
|
sqrtPriceX96,
|
|
@@ -734,8 +752,8 @@ const useCurrentPrice = (poolAddr) => {
|
|
|
734
752
|
//#region src/hooks/options/useOptionPnl.ts
|
|
735
753
|
const useOptionPnl = (option) => {
|
|
736
754
|
const { marketAddr, optionType, strikeTick, positionSizeCurrent } = option;
|
|
737
|
-
const {
|
|
738
|
-
const { currentPrice } = useCurrentPrice(
|
|
755
|
+
const { poolManager, poolKey, optionAssetIsToken0, payoutAssetDecimals, tickSpacing } = useMarketData(marketAddr);
|
|
756
|
+
const { currentPrice } = useCurrentPrice(poolManager, poolKey);
|
|
739
757
|
const displayPnl = (0, react.useMemo)(() => {
|
|
740
758
|
if (optionAssetIsToken0 === void 0 || currentPrice === void 0 || !payoutAssetDecimals) return void 0;
|
|
741
759
|
const strikeSize = optionAssetIsToken0 ? require_optionUtils.token0ToToken1AtTick(positionSizeCurrent, strikeTick) : require_optionUtils.token1ToToken0AtTick(positionSizeCurrent, strikeTick);
|
|
@@ -767,9 +785,9 @@ const useOptionPnl = (option) => {
|
|
|
767
785
|
//#endregion
|
|
768
786
|
//#region src/hooks/options/useOptionPremium.ts
|
|
769
787
|
const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, remainingDuration = 0, strikeTick) => {
|
|
770
|
-
const {
|
|
771
|
-
const { tickSpacing } = usePoolData(
|
|
772
|
-
const { exact: currentTick } = useCurrentTick(
|
|
788
|
+
const { poolManager, poolKey, payoutAssetDecimals, optionAssetIsToken0 } = useMarketData(marketAddr);
|
|
789
|
+
const { tickSpacing } = usePoolData(poolManager, poolKey);
|
|
790
|
+
const { exact: currentTick } = useCurrentTick(poolManager, poolKey);
|
|
773
791
|
const strikeTickRounded = (0, react.useMemo)(() => {
|
|
774
792
|
if (!tickSpacing || currentTick === void 0) return;
|
|
775
793
|
let strikeTickRounded$1 = require_optionUtils.roundTick(strikeTick ?? currentTick, tickSpacing);
|
|
@@ -1520,9 +1538,9 @@ exports.useOptionPremium = useOptionPremium;
|
|
|
1520
1538
|
exports.useOptionTimeline = useOptionTimeline;
|
|
1521
1539
|
exports.usePerpsOperator = usePerpsOperator;
|
|
1522
1540
|
exports.usePoolData = usePoolData;
|
|
1541
|
+
exports.usePriceAtSqrtPriceX96 = usePriceAtSqrtPriceX96;
|
|
1523
1542
|
exports.usePriceAtTick = usePriceAtTick;
|
|
1524
1543
|
exports.usePriceHistory = usePriceHistory;
|
|
1525
|
-
exports.usePriceSqrtPriceX96 = usePriceSqrtPriceX96;
|
|
1526
1544
|
exports.useSetOperatorPerms = useSetOperatorPerms;
|
|
1527
1545
|
exports.useTimelockConfig = useTimelockConfig;
|
|
1528
1546
|
exports.useTokenBalance = useTokenBalance;
|