timelock-sdk 0.0.111 → 0.0.112

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.
@@ -35914,12 +35914,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
35914
35914
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
35915
35915
  queryKey: _tanstack_query_core0.QueryKey;
35916
35916
  data: {
35917
- canExtend: boolean;
35918
- canExercise: boolean;
35919
- canTransfer: boolean;
35920
- canMint: boolean;
35921
- spendingApproval: bigint;
35922
- } | undefined;
35917
+ canExtend: boolean | undefined;
35918
+ canExercise: boolean | undefined;
35919
+ canTransfer: boolean | undefined;
35920
+ canMint: boolean | undefined;
35921
+ spendingApproval: bigint | undefined;
35922
+ effectiveApproval: bigint;
35923
+ };
35923
35924
  } | {
35924
35925
  error: null;
35925
35926
  isError: false;
@@ -35948,12 +35949,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
35948
35949
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
35949
35950
  queryKey: _tanstack_query_core0.QueryKey;
35950
35951
  data: {
35951
- canExtend: boolean;
35952
- canExercise: boolean;
35953
- canTransfer: boolean;
35954
- canMint: boolean;
35955
- spendingApproval: bigint;
35956
- } | undefined;
35952
+ canExtend: boolean | undefined;
35953
+ canExercise: boolean | undefined;
35954
+ canTransfer: boolean | undefined;
35955
+ canMint: boolean | undefined;
35956
+ spendingApproval: bigint | undefined;
35957
+ effectiveApproval: bigint;
35958
+ };
35957
35959
  } | {
35958
35960
  error: viem0.ReadContractErrorType;
35959
35961
  isError: true;
@@ -35982,12 +35984,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
35982
35984
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
35983
35985
  queryKey: _tanstack_query_core0.QueryKey;
35984
35986
  data: {
35985
- canExtend: boolean;
35986
- canExercise: boolean;
35987
- canTransfer: boolean;
35988
- canMint: boolean;
35989
- spendingApproval: bigint;
35990
- } | undefined;
35987
+ canExtend: boolean | undefined;
35988
+ canExercise: boolean | undefined;
35989
+ canTransfer: boolean | undefined;
35990
+ canMint: boolean | undefined;
35991
+ spendingApproval: bigint | undefined;
35992
+ effectiveApproval: bigint;
35993
+ };
35991
35994
  } | {
35992
35995
  error: null;
35993
35996
  isError: false;
@@ -36016,12 +36019,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
36016
36019
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
36017
36020
  queryKey: _tanstack_query_core0.QueryKey;
36018
36021
  data: {
36019
- canExtend: boolean;
36020
- canExercise: boolean;
36021
- canTransfer: boolean;
36022
- canMint: boolean;
36023
- spendingApproval: bigint;
36024
- } | undefined;
36022
+ canExtend: boolean | undefined;
36023
+ canExercise: boolean | undefined;
36024
+ canTransfer: boolean | undefined;
36025
+ canMint: boolean | undefined;
36026
+ spendingApproval: bigint | undefined;
36027
+ effectiveApproval: bigint;
36028
+ };
36025
36029
  } | {
36026
36030
  error: null;
36027
36031
  isError: false;
@@ -36050,12 +36054,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
36050
36054
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
36051
36055
  queryKey: _tanstack_query_core0.QueryKey;
36052
36056
  data: {
36053
- canExtend: boolean;
36054
- canExercise: boolean;
36055
- canTransfer: boolean;
36056
- canMint: boolean;
36057
- spendingApproval: bigint;
36058
- } | undefined;
36057
+ canExtend: boolean | undefined;
36058
+ canExercise: boolean | undefined;
36059
+ canTransfer: boolean | undefined;
36060
+ canMint: boolean | undefined;
36061
+ spendingApproval: bigint | undefined;
36062
+ effectiveApproval: bigint;
36063
+ };
36059
36064
  } | {
36060
36065
  isError: false;
36061
36066
  error: null;
@@ -36084,12 +36089,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
36084
36089
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
36085
36090
  queryKey: _tanstack_query_core0.QueryKey;
36086
36091
  data: {
36087
- canExtend: boolean;
36088
- canExercise: boolean;
36089
- canTransfer: boolean;
36090
- canMint: boolean;
36091
- spendingApproval: bigint;
36092
- } | undefined;
36092
+ canExtend: boolean | undefined;
36093
+ canExercise: boolean | undefined;
36094
+ canTransfer: boolean | undefined;
36095
+ canMint: boolean | undefined;
36096
+ spendingApproval: bigint | undefined;
36097
+ effectiveApproval: bigint;
36098
+ };
36093
36099
  };
36094
36100
  //#endregion
36095
36101
  //#region src/hooks/operators/useUserOperators.d.ts
@@ -62852,4 +62858,4 @@ declare const useApproval: () => {
62852
62858
  };
62853
62859
  //#endregion
62854
62860
  export { formatCondensed as $, PriceDataPoint as A, usePerpsOperator as B, liquiditiesToAmount1 as C, getErc20 as Ct, token0ToToken1 as D, timelockLenses as Dt, roundTickUp as E, getUniswapMathLens as Et, useUserOperators as F, useExtendOption as G, useMintPerp as H, useOperatorPerms as I, useMintOption as J, useOptionPremium as K, useActiveUserPerps as L, getCurrentPrice as M, getPriceHistory as N, token1ToToken0 as O, uniswapMathLenses as Ot, useSetOperatorPerms as P, formatAmount as Q, useClosedUserPerps as R, liquiditiesToAmount0 as S, UniswapMathLens as St, roundTickDown as T, getTimelockMarket as Tt, OptionTimelineData as U, useClosePerp as V, useOptionTimeline as W, Amount as X, useMaxPositionSize as Y, EMPTY_ARRAY as Z, PRICE_PRECISION as _, useCurrentMarket as _t, batchGetAmountsFromLiquidity as a, unscalePrice as at, getPriceAtTick as b, TimelockMarket as bt, useLiquidityBlocks as c, wrapPrice as ct, usePriceAtTick as d, useMarketData as dt, formatUSD as et, UniswapPoolData as f, useExerciseOption as ft, getPayoutAtTick as g, TimelockProvider as gt, useCurrentPrice as h, useClosedUserOptions as ht, useVaultData as i, unscaleAmount as it, PriceResolution as j, PriceData as k, useBurnLiquidity as l, wrapPriceUnscaled as lt, useCurrentTick as m, useActiveUserOptions as mt, useLens as n, scaleAmount as nt, useMintLiquidity as o, wrapAmount as ot, usePoolData as p, OptionData as pt, useOptionPnl as q, useVaultTVL as r, scalePrice as rt, LiquidityBlockData as s, wrapAmountUnscaled as st, useApproval as t, formatVagueAmount as tt, usePriceHistory as u, zero as ut, getAmountsFromLiquidity as v, useTimelockConfig as vt, liquiditiesToAmounts as w, getTimelockLens as wt, getTickAtPrice as x, TimelockMarketData as xt, getNearestValidStrikeTick as y, TimelockLens as yt, useUserPerps as z };
62855
- //# sourceMappingURL=client-BioBT1mO.d.cts.map
62861
+ //# sourceMappingURL=client-191_W3kB.d.cts.map
@@ -35914,12 +35914,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
35914
35914
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
35915
35915
  queryKey: _tanstack_query_core0.QueryKey;
35916
35916
  data: {
35917
- canExtend: boolean;
35918
- canExercise: boolean;
35919
- canTransfer: boolean;
35920
- canMint: boolean;
35921
- spendingApproval: bigint;
35922
- } | undefined;
35917
+ canExtend: boolean | undefined;
35918
+ canExercise: boolean | undefined;
35919
+ canTransfer: boolean | undefined;
35920
+ canMint: boolean | undefined;
35921
+ spendingApproval: bigint | undefined;
35922
+ effectiveApproval: bigint;
35923
+ };
35923
35924
  } | {
35924
35925
  error: null;
35925
35926
  isError: false;
@@ -35948,12 +35949,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
35948
35949
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
35949
35950
  queryKey: _tanstack_query_core0.QueryKey;
35950
35951
  data: {
35951
- canExtend: boolean;
35952
- canExercise: boolean;
35953
- canTransfer: boolean;
35954
- canMint: boolean;
35955
- spendingApproval: bigint;
35956
- } | undefined;
35952
+ canExtend: boolean | undefined;
35953
+ canExercise: boolean | undefined;
35954
+ canTransfer: boolean | undefined;
35955
+ canMint: boolean | undefined;
35956
+ spendingApproval: bigint | undefined;
35957
+ effectiveApproval: bigint;
35958
+ };
35957
35959
  } | {
35958
35960
  error: viem0.ReadContractErrorType;
35959
35961
  isError: true;
@@ -35982,12 +35984,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
35982
35984
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
35983
35985
  queryKey: _tanstack_query_core0.QueryKey;
35984
35986
  data: {
35985
- canExtend: boolean;
35986
- canExercise: boolean;
35987
- canTransfer: boolean;
35988
- canMint: boolean;
35989
- spendingApproval: bigint;
35990
- } | undefined;
35987
+ canExtend: boolean | undefined;
35988
+ canExercise: boolean | undefined;
35989
+ canTransfer: boolean | undefined;
35990
+ canMint: boolean | undefined;
35991
+ spendingApproval: bigint | undefined;
35992
+ effectiveApproval: bigint;
35993
+ };
35991
35994
  } | {
35992
35995
  error: null;
35993
35996
  isError: false;
@@ -36016,12 +36019,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
36016
36019
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
36017
36020
  queryKey: _tanstack_query_core0.QueryKey;
36018
36021
  data: {
36019
- canExtend: boolean;
36020
- canExercise: boolean;
36021
- canTransfer: boolean;
36022
- canMint: boolean;
36023
- spendingApproval: bigint;
36024
- } | undefined;
36022
+ canExtend: boolean | undefined;
36023
+ canExercise: boolean | undefined;
36024
+ canTransfer: boolean | undefined;
36025
+ canMint: boolean | undefined;
36026
+ spendingApproval: bigint | undefined;
36027
+ effectiveApproval: bigint;
36028
+ };
36025
36029
  } | {
36026
36030
  error: null;
36027
36031
  isError: false;
@@ -36050,12 +36054,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
36050
36054
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
36051
36055
  queryKey: _tanstack_query_core0.QueryKey;
36052
36056
  data: {
36053
- canExtend: boolean;
36054
- canExercise: boolean;
36055
- canTransfer: boolean;
36056
- canMint: boolean;
36057
- spendingApproval: bigint;
36058
- } | undefined;
36057
+ canExtend: boolean | undefined;
36058
+ canExercise: boolean | undefined;
36059
+ canTransfer: boolean | undefined;
36060
+ canMint: boolean | undefined;
36061
+ spendingApproval: bigint | undefined;
36062
+ effectiveApproval: bigint;
36063
+ };
36059
36064
  } | {
36060
36065
  isError: false;
36061
36066
  error: null;
@@ -36084,12 +36089,13 @@ declare const useOperatorPerms: (marketAddr?: Address, userAddr?: Address, opera
36084
36089
  promise: Promise<readonly [boolean, boolean, boolean, boolean, bigint]>;
36085
36090
  queryKey: _tanstack_query_core0.QueryKey;
36086
36091
  data: {
36087
- canExtend: boolean;
36088
- canExercise: boolean;
36089
- canTransfer: boolean;
36090
- canMint: boolean;
36091
- spendingApproval: bigint;
36092
- } | undefined;
36092
+ canExtend: boolean | undefined;
36093
+ canExercise: boolean | undefined;
36094
+ canTransfer: boolean | undefined;
36095
+ canMint: boolean | undefined;
36096
+ spendingApproval: bigint | undefined;
36097
+ effectiveApproval: bigint;
36098
+ };
36093
36099
  };
36094
36100
  //#endregion
36095
36101
  //#region src/hooks/operators/useUserOperators.d.ts
@@ -62852,4 +62858,4 @@ declare const useApproval: () => {
62852
62858
  };
62853
62859
  //#endregion
62854
62860
  export { formatCondensed as $, PriceDataPoint as A, usePerpsOperator as B, liquiditiesToAmount1 as C, getErc20 as Ct, token0ToToken1 as D, timelockLenses as Dt, roundTickUp as E, getUniswapMathLens as Et, useUserOperators as F, useExtendOption as G, useMintPerp as H, useOperatorPerms as I, useMintOption as J, useOptionPremium as K, useActiveUserPerps as L, getCurrentPrice as M, getPriceHistory as N, token1ToToken0 as O, uniswapMathLenses as Ot, useSetOperatorPerms as P, formatAmount as Q, useClosedUserPerps as R, liquiditiesToAmount0 as S, UniswapMathLens as St, roundTickDown as T, getTimelockMarket as Tt, OptionTimelineData as U, useClosePerp as V, useOptionTimeline as W, Amount as X, useMaxPositionSize as Y, EMPTY_ARRAY as Z, PRICE_PRECISION as _, useCurrentMarket as _t, batchGetAmountsFromLiquidity as a, unscalePrice as at, getPriceAtTick as b, TimelockMarket as bt, useLiquidityBlocks as c, wrapPrice as ct, usePriceAtTick as d, useMarketData as dt, formatUSD as et, UniswapPoolData as f, useExerciseOption as ft, getPayoutAtTick as g, TimelockProvider as gt, useCurrentPrice as h, useClosedUserOptions as ht, useVaultData as i, unscaleAmount as it, PriceResolution as j, PriceData as k, useBurnLiquidity as l, wrapPriceUnscaled as lt, useCurrentTick as m, useActiveUserOptions as mt, useLens as n, scaleAmount as nt, useMintLiquidity as o, wrapAmount as ot, usePoolData as p, OptionData as pt, useOptionPnl as q, useVaultTVL as r, scalePrice as rt, LiquidityBlockData as s, wrapAmountUnscaled as st, useApproval as t, formatVagueAmount as tt, usePriceHistory as u, zero as ut, getAmountsFromLiquidity as v, useTimelockConfig as vt, liquiditiesToAmounts as w, getTimelockLens as wt, getTickAtPrice as x, TimelockMarketData as xt, getNearestValidStrikeTick as y, TimelockLens as yt, useUserPerps as z };
62855
- //# sourceMappingURL=client-Di3SarC6.d.ts.map
62861
+ //# sourceMappingURL=client-Bcn8F-k3.d.ts.map
package/dist/client.cjs CHANGED
@@ -1178,6 +1178,11 @@ const useClosedUserPerps = (marketAddr, userAddr) => {
1178
1178
  //#endregion
1179
1179
  //#region src/hooks/operators/useOperatorPerms.ts
1180
1180
  const useOperatorPerms = (marketAddr, userAddr, operatorAddr) => {
1181
+ const { payoutAsset } = useMarketData(marketAddr);
1182
+ const { data: payoutAssetBalance } = (0, wagmi.useBalance)({
1183
+ address: userAddr,
1184
+ token: payoutAsset
1185
+ });
1181
1186
  const { data,...rest } = (0, wagmi.useReadContract)({
1182
1187
  abi: require_optionsMarket.optionsMarketAbi,
1183
1188
  address: marketAddr,
@@ -1185,14 +1190,25 @@ const useOperatorPerms = (marketAddr, userAddr, operatorAddr) => {
1185
1190
  args: [userAddr, operatorAddr],
1186
1191
  query: { enabled: !!userAddr && !!operatorAddr }
1187
1192
  });
1193
+ const [canExtend, canExercise, canTransfer, canMint, spendingApproval] = data || [];
1194
+ const min = (a, b) => a < b ? a : b;
1195
+ const effectiveApproval = spendingApproval && payoutAssetBalance ? min(spendingApproval, payoutAssetBalance.value) : 0n;
1188
1196
  return {
1189
- data: data ? {
1190
- canExtend: data[0],
1191
- canExercise: data[1],
1192
- canTransfer: data[2],
1193
- canMint: data[3],
1194
- spendingApproval: data[4]
1195
- } : void 0,
1197
+ data: (0, react.useMemo)(() => ({
1198
+ canExtend,
1199
+ canExercise,
1200
+ canTransfer,
1201
+ canMint,
1202
+ spendingApproval,
1203
+ effectiveApproval
1204
+ }), [
1205
+ canExtend,
1206
+ canExercise,
1207
+ canTransfer,
1208
+ canMint,
1209
+ spendingApproval,
1210
+ effectiveApproval
1211
+ ]),
1196
1212
  ...rest
1197
1213
  };
1198
1214
  };