timelock-sdk 0.0.138 → 0.0.139

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.
@@ -131,7 +131,6 @@ type GetMarketDataQuery = {
131
131
  id: string;
132
132
  address: string;
133
133
  vault: string;
134
- pool: string;
135
134
  tickSpacing: number;
136
135
  optionAssetIsToken0: boolean;
137
136
  optionAsset: string;
@@ -142,6 +141,11 @@ type GetMarketDataQuery = {
142
141
  payoutAssetSymbol: string;
143
142
  optionAssetName: string;
144
143
  payoutAssetName: string;
144
+ poolManager: string;
145
+ currency0: string;
146
+ currency1: string;
147
+ fee: number;
148
+ hooks: string;
145
149
  }>;
146
150
  };
147
151
  type GetMarketVolumeQueryVariables = Exact<{
@@ -39588,7 +39592,14 @@ declare const useExerciseOption: (marketAddr?: Address) => _tanstack_react_query
39588
39592
  //#region src/hooks/options/useMarketData.d.ts
39589
39593
  declare const useMarketData: (marketAddr?: Address) => Partial<NonUndefinedGuard<{
39590
39594
  address: Address;
39591
- pool: Address;
39595
+ poolManager: Address;
39596
+ poolKey: {
39597
+ currency0: Address;
39598
+ currency1: Address;
39599
+ fee: number;
39600
+ tickSpacing: number;
39601
+ hooks: Address;
39602
+ };
39592
39603
  vault: Address;
39593
39604
  optionAsset: Address;
39594
39605
  payoutAsset: Address;
@@ -39602,6 +39613,10 @@ declare const useMarketData: (marketAddr?: Address) => Partial<NonUndefinedGuard
39602
39613
  payoutAssetSymbol: string;
39603
39614
  optionAssetName: string;
39604
39615
  payoutAssetName: string;
39616
+ currency0: string;
39617
+ currency1: string;
39618
+ fee: number;
39619
+ hooks: string;
39605
39620
  } | undefined>>;
39606
39621
  //#endregion
39607
39622
  //#region src/hooks/options/useMarketVolume.d.ts
@@ -42302,16 +42317,6 @@ declare const liquiditiesToAmounts: (liquidities: bigint[], startTick: number, p
42302
42317
  declare const getPayoutAtTick: (option: OptionData, liquidities: bigint[], tick: number, tickSpacing: number, optionAssetIsToken0: boolean) => bigint;
42303
42318
  declare const getPayoutAtPrice: (option: OptionData, liquidities: bigint[], price: bigint, tickSpacing: number, optionAssetIsToken0: boolean) => bigint;
42304
42319
  //#endregion
42305
- //#region src/hooks/pool/useCurrentPrice.d.ts
42306
- declare const useCurrentPrice: (poolAddr?: Address) => {
42307
- currentPrice: Amount | undefined;
42308
- sqrtPriceX96: bigint | undefined;
42309
- currentTick: {
42310
- exact: number | undefined;
42311
- rounded: number | undefined;
42312
- };
42313
- };
42314
- //#endregion
42315
42320
  //#region src/hooks/pool/usePoolData.d.ts
42316
42321
  type PoolKey = {
42317
42322
  currency0: Address;
@@ -42334,6 +42339,16 @@ declare const usePoolData: (poolManager?: Address, poolKey?: PoolKey) => Partial
42334
42339
  fee: number;
42335
42340
  } | undefined>>;
42336
42341
  //#endregion
42342
+ //#region src/hooks/pool/useCurrentPrice.d.ts
42343
+ declare const useCurrentPrice: (poolManager?: Address, poolKey?: PoolKey) => {
42344
+ currentPrice: Amount | undefined;
42345
+ sqrtPriceX96: bigint | undefined;
42346
+ currentTick: {
42347
+ exact: number | undefined;
42348
+ rounded: number | undefined;
42349
+ };
42350
+ };
42351
+ //#endregion
42337
42352
  //#region src/hooks/pool/useCurrentTick.d.ts
42338
42353
  declare const useCurrentTick: (poolManager?: Address, poolKey?: PoolKey) => {
42339
42354
  error: viem0.ReadContractErrorType;
@@ -42566,8 +42581,8 @@ declare const useCurrentTick: (poolManager?: Address, poolKey?: PoolKey) => {
42566
42581
  };
42567
42582
  //#endregion
42568
42583
  //#region src/hooks/pool/usePriceAtTick.d.ts
42569
- declare const usePriceAtTick: (tick?: number, poolAddr?: Address) => Amount | undefined;
42570
- declare const usePriceSqrtPriceX96: (sqrtPriceX96?: bigint, poolAddr?: Address) => Amount | undefined;
42584
+ declare const usePriceAtTick: (poolManager?: Address, poolKey?: PoolKey, tick?: number) => Amount | undefined;
42585
+ declare const usePriceAtSqrtPriceX96: (poolManager?: Address, poolKey?: PoolKey, sqrtPriceX96?: bigint) => Amount | undefined;
42571
42586
  //#endregion
42572
42587
  //#region src/hooks/pool/usePriceHistory.d.ts
42573
42588
  declare const usePriceHistory: (pool: Address | undefined, token: 0 | 1, resolution: PriceResolution, startTimestamp: Date, endTimestamp: Date) => _tanstack_react_query0.UseQueryResult<PriceDataPoint[], Error>;
@@ -74652,5 +74667,5 @@ declare const useLens: () => {
74652
74667
  } | undefined;
74653
74668
  };
74654
74669
  //#endregion
74655
- export { ExerciseOptionEvent as $, getTickAtPrice as A, TimelockProvider as At, PriceDataPoint as B, getTimelockMarket as Bt, getPayoutAtTick as C, zero as Ct, getPriceAtSqrtPriceX96 as D, OptionData as Dt, getNearestValidStrikeTick as E, useExerciseOption as Et, token0ToToken1 as F, TimelockMarketData as Ft, useUserOperators as G, getCurrentPrice as H, swappers as Ht, token0ToToken1AtTick as I, UniswapMathLens as It, useClosedUserPerps as J, useOperatorPerms as K, token1ToToken0 as L, getErc20 as Lt, liquiditiesToAmount1 as M, useTimelockConfig as Mt, liquiditiesToAmounts as N, TimelockLens as Nt, getPriceAtTick as O, useActiveUserOptions as Ot, roundTick as P, TimelockMarket as Pt, useMintPerp as Q, token1ToToken0AtTick as R, getStateView as Rt, getPayoutAtPrice as S, wrapPriceUnscaled as St, getAmountsFromLiquidity as T, useMarketData as Tt, getPriceHistory as U, timelockLenses as Ut, PriceResolution as V, stateViews as Vt, useSetOperatorPerms as W, usePerpsOperator as X, useUserPerps as Y, useClosePerp as Z, useCurrentTick as _, unscaleAmount as _t, useTokenData as a, useOptionPremium as at, usePoolData as b, wrapAmountUnscaled as bt, batchGetAmountsFromLiquidity as c, useMaxPositionSize as ct, useLiquidityBlocks as d, formatAmount as dt, ExtendEvent as et, useBurnLiquidity as f, formatCondensed as ft, usePriceSqrtPriceX96 as g, scalePrice as gt, usePriceAtTick as h, scaleAmount as ht, TokenData as i, useExtendOption as it, liquiditiesToAmount0 as j, useCurrentMarket as jt, getSqrtPriceX96AtPrice as k, useClosedUserOptions as kt, useMintLiquidity as l, Amount as lt, usePriceHistory as m, formatVagueAmount as mt, useApproval as n, OptionEvent as nt, useVaultTVL as o, useOptionPnl as ot, useMarketPriceHistory as p, formatUSD as pt, useActiveUserPerps as q, useTokenBalance as r, useOptionTimeline as rt, useVaultData as s, useMintOption as st, useLens as t, MintOptionEvent as tt, LiquidityBlockData as u, EMPTY_ARRAY as ut, PoolKey as v, unscalePrice as vt, PRICE_PRECISION as w, useMarketVolume as wt, useCurrentPrice as x, wrapPrice as xt, UniswapPoolData as y, wrapAmount as yt, PriceData as z, getTimelockLens as zt };
74656
- //# sourceMappingURL=client-CP_QHL05.d.cts.map
74670
+ export { ExerciseOptionEvent as $, getTickAtPrice as A, TimelockProvider as At, PriceDataPoint as B, getTimelockMarket as Bt, getPayoutAtTick as C, zero as Ct, getPriceAtSqrtPriceX96 as D, OptionData as Dt, getNearestValidStrikeTick as E, useExerciseOption as Et, token0ToToken1 as F, TimelockMarketData as Ft, useUserOperators as G, getCurrentPrice as H, swappers as Ht, token0ToToken1AtTick as I, UniswapMathLens as It, useClosedUserPerps as J, useOperatorPerms as K, token1ToToken0 as L, getErc20 as Lt, liquiditiesToAmount1 as M, useTimelockConfig as Mt, liquiditiesToAmounts as N, TimelockLens as Nt, getPriceAtTick as O, useActiveUserOptions as Ot, roundTick as P, TimelockMarket as Pt, useMintPerp as Q, token1ToToken0AtTick as R, getStateView as Rt, getPayoutAtPrice as S, wrapPriceUnscaled as St, getAmountsFromLiquidity as T, useMarketData as Tt, getPriceHistory as U, timelockLenses as Ut, PriceResolution as V, stateViews as Vt, useSetOperatorPerms as W, usePerpsOperator as X, useUserPerps as Y, useClosePerp as Z, useCurrentTick as _, unscaleAmount as _t, useTokenData as a, useOptionPremium as at, UniswapPoolData as b, wrapAmountUnscaled as bt, batchGetAmountsFromLiquidity as c, useMaxPositionSize as ct, useLiquidityBlocks as d, formatAmount as dt, ExtendEvent as et, useBurnLiquidity as f, formatCondensed as ft, usePriceAtTick as g, scalePrice as gt, usePriceAtSqrtPriceX96 as h, scaleAmount as ht, TokenData as i, useExtendOption as it, liquiditiesToAmount0 as j, useCurrentMarket as jt, getSqrtPriceX96AtPrice as k, useClosedUserOptions as kt, useMintLiquidity as l, Amount as lt, usePriceHistory as m, formatVagueAmount as mt, useApproval as n, OptionEvent as nt, useVaultTVL as o, useOptionPnl as ot, useMarketPriceHistory as p, formatUSD as pt, useActiveUserPerps as q, useTokenBalance as r, useOptionTimeline as rt, useVaultData as s, useMintOption as st, useLens as t, MintOptionEvent as tt, LiquidityBlockData as u, EMPTY_ARRAY as ut, useCurrentPrice as v, unscalePrice as vt, PRICE_PRECISION as w, useMarketVolume as wt, usePoolData as x, wrapPrice as xt, PoolKey as y, wrapAmount as yt, PriceData as z, getTimelockLens as zt };
74671
+ //# sourceMappingURL=client-DTyVaDKH.d.cts.map
package/dist/client.cjs CHANGED
@@ -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
- pool: result.TimelockMarket[0].pool,
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
- return data || {};
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, pool } = useMarketData(marketAddr);
502
- const { fee } = usePoolData(pool);
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, pool, optionAssetIsToken0 } = useMarketData(marketAddr);
644
- const { tickSpacing } = usePoolData(pool);
645
- const { refetch: refetchCurrentTick } = useCurrentTick(pool);
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 = (tick, poolAddr) => {
696
- const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
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 usePriceSqrtPriceX96 = (sqrtPriceX96, poolAddr) => {
705
- const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
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 = (poolAddr) => {
717
- const { sqrtPriceX96, exact, rounded } = useCurrentTick(poolAddr);
718
- const currentPrice = usePriceSqrtPriceX96(sqrtPriceX96, poolAddr);
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 { pool, optionAssetIsToken0, payoutAssetDecimals, tickSpacing } = useMarketData(marketAddr);
738
- const { currentPrice } = useCurrentPrice(pool);
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 { pool, payoutAssetDecimals, optionAssetIsToken0 } = useMarketData(marketAddr);
771
- const { tickSpacing } = usePoolData(pool);
772
- const { exact: currentTick } = useCurrentTick(pool);
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;