timelock-sdk 0.0.109 → 0.0.111

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.
@@ -31824,6 +31824,53 @@ declare const getTimelockLens: (client: Client | PublicClient) => {
31824
31824
  declare const timelockLenses: Record<number, Address>;
31825
31825
  declare const uniswapMathLenses: Record<number, Address>;
31826
31826
  //#endregion
31827
+ //#region src/lib/perpsOperator.d.ts
31828
+ type MintPerpBody = {
31829
+ marketAddr: Address;
31830
+ optionType: 'CALL' | 'PUT';
31831
+ amount: bigint;
31832
+ duration: number;
31833
+ strikeTick: number;
31834
+ };
31835
+ type ExercisePerpBody = {
31836
+ marketAddr: Address;
31837
+ optionId: bigint;
31838
+ liquidities: bigint[];
31839
+ };
31840
+ declare class PerpsOperator {
31841
+ #private;
31842
+ auth?: {
31843
+ message: string;
31844
+ signature: Hex;
31845
+ };
31846
+ constructor(baseUrl: string);
31847
+ getOperatorAddr: () => Promise<Address>;
31848
+ genAuthMessage: (userAddr: Address) => Promise<string>;
31849
+ validateAuthMessage: (message: string, signature: Hex) => Promise<{
31850
+ address: `0x${string}`;
31851
+ createdAt: number;
31852
+ validUntil: number;
31853
+ }>;
31854
+ setAuth: (message: string, signature: Hex) => void;
31855
+ getUserPerps: (userAddr: Address, marketAddr?: Address, type?: "active" | "closed", offset?: number, limit?: number) => Promise<{
31856
+ optionId: bigint;
31857
+ id: string;
31858
+ ownerAddr: Address;
31859
+ marketAddr: Address;
31860
+ perpDuration: number;
31861
+ expiresAt: number;
31862
+ closed: boolean;
31863
+ }[]>;
31864
+ mintPerp: (body: MintPerpBody) => Promise<{
31865
+ txHash: string;
31866
+ optionId: bigint;
31867
+ }>;
31868
+ exercisePerp: (body: ExercisePerpBody) => Promise<{
31869
+ txHash: string;
31870
+ optionId: bigint;
31871
+ }>;
31872
+ }
31873
+ //#endregion
31827
31874
  //#region src/providers/TimelockProvider.d.ts
31828
31875
  type TimelockContextValue = {
31829
31876
  marketData: Partial<TimelockMarketData>;
@@ -31831,6 +31878,7 @@ type TimelockContextValue = {
31831
31878
  uniswapMathLensAddr?: Address;
31832
31879
  envioGraphqlUrl?: string;
31833
31880
  graphqlClient?: ReturnType<typeof getSdk>;
31881
+ perpsOperator?: PerpsOperator;
31834
31882
  perpsOperatorUrl?: string;
31835
31883
  };
31836
31884
  declare const TimelockProvider: ({
@@ -34904,53 +34952,6 @@ declare const useMintPerp: (marketAddr?: Address) => _tanstack_react_query0.UseM
34904
34952
  strikeTick?: number;
34905
34953
  }, unknown>;
34906
34954
  //#endregion
34907
- //#region src/lib/perpsOperator.d.ts
34908
- type MintPerpBody = {
34909
- marketAddr: Address;
34910
- optionType: 'CALL' | 'PUT';
34911
- amount: bigint;
34912
- duration: number;
34913
- strikeTick: number;
34914
- };
34915
- type ExercisePerpBody = {
34916
- marketAddr: Address;
34917
- optionId: bigint;
34918
- liquidities: bigint[];
34919
- };
34920
- declare class PerpsOperator {
34921
- #private;
34922
- auth?: {
34923
- message: string;
34924
- signature: Hex;
34925
- };
34926
- constructor(baseUrl: string);
34927
- getOperatorAddr: () => Promise<Address>;
34928
- genAuthMessage: (userAddr: Address) => Promise<string>;
34929
- validateAuthMessage: (message: string, signature: Hex) => Promise<{
34930
- address: `0x${string}`;
34931
- createdAt: number;
34932
- validUntil: number;
34933
- }>;
34934
- setAuth: (message: string, signature: Hex) => void;
34935
- getUserPerps: (userAddr: Address, marketAddr?: Address, type?: "active" | "closed", offset?: number, limit?: number) => Promise<{
34936
- optionId: bigint;
34937
- id: string;
34938
- ownerAddr: Address;
34939
- marketAddr: Address;
34940
- perpDuration: number;
34941
- expiresAt: number;
34942
- closed: boolean;
34943
- }[]>;
34944
- mintPerp: (body: MintPerpBody) => Promise<{
34945
- txHash: string;
34946
- optionId: bigint;
34947
- }>;
34948
- exercisePerp: (body: ExercisePerpBody) => Promise<{
34949
- txHash: string;
34950
- optionId: bigint;
34951
- }>;
34952
- }
34953
- //#endregion
34954
34955
  //#region src/hooks/perps/useClosePerp.d.ts
34955
34956
  declare const useClosePerp: () => _tanstack_react_query0.UseMutationResult<void, Error, ExercisePerpBody, unknown>;
34956
34957
  //#endregion
@@ -62851,4 +62852,4 @@ declare const useApproval: () => {
62851
62852
  };
62852
62853
  //#endregion
62853
62854
  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 };
62854
- //# sourceMappingURL=client-61tvmrlq.d.cts.map
62855
+ //# sourceMappingURL=client-BioBT1mO.d.cts.map
@@ -31824,6 +31824,53 @@ declare const getTimelockLens: (client: Client | PublicClient) => {
31824
31824
  declare const timelockLenses: Record<number, Address>;
31825
31825
  declare const uniswapMathLenses: Record<number, Address>;
31826
31826
  //#endregion
31827
+ //#region src/lib/perpsOperator.d.ts
31828
+ type MintPerpBody = {
31829
+ marketAddr: Address;
31830
+ optionType: 'CALL' | 'PUT';
31831
+ amount: bigint;
31832
+ duration: number;
31833
+ strikeTick: number;
31834
+ };
31835
+ type ExercisePerpBody = {
31836
+ marketAddr: Address;
31837
+ optionId: bigint;
31838
+ liquidities: bigint[];
31839
+ };
31840
+ declare class PerpsOperator {
31841
+ #private;
31842
+ auth?: {
31843
+ message: string;
31844
+ signature: Hex;
31845
+ };
31846
+ constructor(baseUrl: string);
31847
+ getOperatorAddr: () => Promise<Address>;
31848
+ genAuthMessage: (userAddr: Address) => Promise<string>;
31849
+ validateAuthMessage: (message: string, signature: Hex) => Promise<{
31850
+ address: `0x${string}`;
31851
+ createdAt: number;
31852
+ validUntil: number;
31853
+ }>;
31854
+ setAuth: (message: string, signature: Hex) => void;
31855
+ getUserPerps: (userAddr: Address, marketAddr?: Address, type?: "active" | "closed", offset?: number, limit?: number) => Promise<{
31856
+ optionId: bigint;
31857
+ id: string;
31858
+ ownerAddr: Address;
31859
+ marketAddr: Address;
31860
+ perpDuration: number;
31861
+ expiresAt: number;
31862
+ closed: boolean;
31863
+ }[]>;
31864
+ mintPerp: (body: MintPerpBody) => Promise<{
31865
+ txHash: string;
31866
+ optionId: bigint;
31867
+ }>;
31868
+ exercisePerp: (body: ExercisePerpBody) => Promise<{
31869
+ txHash: string;
31870
+ optionId: bigint;
31871
+ }>;
31872
+ }
31873
+ //#endregion
31827
31874
  //#region src/providers/TimelockProvider.d.ts
31828
31875
  type TimelockContextValue = {
31829
31876
  marketData: Partial<TimelockMarketData>;
@@ -31831,6 +31878,7 @@ type TimelockContextValue = {
31831
31878
  uniswapMathLensAddr?: Address;
31832
31879
  envioGraphqlUrl?: string;
31833
31880
  graphqlClient?: ReturnType<typeof getSdk>;
31881
+ perpsOperator?: PerpsOperator;
31834
31882
  perpsOperatorUrl?: string;
31835
31883
  };
31836
31884
  declare const TimelockProvider: ({
@@ -34904,53 +34952,6 @@ declare const useMintPerp: (marketAddr?: Address) => _tanstack_react_query0.UseM
34904
34952
  strikeTick?: number;
34905
34953
  }, unknown>;
34906
34954
  //#endregion
34907
- //#region src/lib/perpsOperator.d.ts
34908
- type MintPerpBody = {
34909
- marketAddr: Address;
34910
- optionType: 'CALL' | 'PUT';
34911
- amount: bigint;
34912
- duration: number;
34913
- strikeTick: number;
34914
- };
34915
- type ExercisePerpBody = {
34916
- marketAddr: Address;
34917
- optionId: bigint;
34918
- liquidities: bigint[];
34919
- };
34920
- declare class PerpsOperator {
34921
- #private;
34922
- auth?: {
34923
- message: string;
34924
- signature: Hex;
34925
- };
34926
- constructor(baseUrl: string);
34927
- getOperatorAddr: () => Promise<Address>;
34928
- genAuthMessage: (userAddr: Address) => Promise<string>;
34929
- validateAuthMessage: (message: string, signature: Hex) => Promise<{
34930
- address: `0x${string}`;
34931
- createdAt: number;
34932
- validUntil: number;
34933
- }>;
34934
- setAuth: (message: string, signature: Hex) => void;
34935
- getUserPerps: (userAddr: Address, marketAddr?: Address, type?: "active" | "closed", offset?: number, limit?: number) => Promise<{
34936
- optionId: bigint;
34937
- id: string;
34938
- ownerAddr: Address;
34939
- marketAddr: Address;
34940
- perpDuration: number;
34941
- expiresAt: number;
34942
- closed: boolean;
34943
- }[]>;
34944
- mintPerp: (body: MintPerpBody) => Promise<{
34945
- txHash: string;
34946
- optionId: bigint;
34947
- }>;
34948
- exercisePerp: (body: ExercisePerpBody) => Promise<{
34949
- txHash: string;
34950
- optionId: bigint;
34951
- }>;
34952
- }
34953
- //#endregion
34954
34955
  //#region src/hooks/perps/useClosePerp.d.ts
34955
34956
  declare const useClosePerp: () => _tanstack_react_query0.UseMutationResult<void, Error, ExercisePerpBody, unknown>;
34956
34957
  //#endregion
@@ -62851,4 +62852,4 @@ declare const useApproval: () => {
62851
62852
  };
62852
62853
  //#endregion
62853
62854
  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 };
62854
- //# sourceMappingURL=client-BcsbWPvK.d.ts.map
62855
+ //# sourceMappingURL=client-Di3SarC6.d.ts.map
package/dist/client.cjs CHANGED
@@ -288,6 +288,102 @@ function getSdk(client, withWrapper = defaultWrapper) {
288
288
  };
289
289
  }
290
290
 
291
+ //#endregion
292
+ //#region src/lib/perpsOperator.ts
293
+ var PerpsOperator = class {
294
+ #baseUrl;
295
+ auth;
296
+ constructor(baseUrl) {
297
+ this.#baseUrl = baseUrl;
298
+ }
299
+ #request = async (path, body) => {
300
+ const url = new URL(path, this.#baseUrl);
301
+ const res = await fetch(url, {
302
+ method: body ? "POST" : "GET",
303
+ headers: {
304
+ Connection: "keep-alive",
305
+ "Content-Type": "application/json",
306
+ "Keep-Alive": "timeout=120"
307
+ },
308
+ body: body ? JSON.stringify(body) : void 0
309
+ });
310
+ if (res.ok) {
311
+ const { data } = await res.json();
312
+ return data;
313
+ }
314
+ const resText = await res.text();
315
+ try {
316
+ const error = JSON.parse(resText);
317
+ throw new Error(`${res.status} ${res.statusText}: ${error.error}`);
318
+ } catch (error) {
319
+ throw new Error(`${res.status} ${res.statusText}: ${resText}`);
320
+ }
321
+ };
322
+ getOperatorAddr = async () => {
323
+ const { address } = await this.#request("api/operator/address");
324
+ return address;
325
+ };
326
+ genAuthMessage = async (userAddr) => {
327
+ const { message } = await this.#request("api/auth/gen", { userAddr });
328
+ return message;
329
+ };
330
+ validateAuthMessage = async (message, signature) => {
331
+ const { address, createdAt, validUntil } = await this.#request("api/auth/validate", {
332
+ message,
333
+ signature
334
+ });
335
+ return {
336
+ address,
337
+ createdAt,
338
+ validUntil
339
+ };
340
+ };
341
+ setAuth = (message, signature) => {
342
+ this.auth = {
343
+ message,
344
+ signature
345
+ };
346
+ };
347
+ getUserPerps = async (userAddr, marketAddr, type, offset = 0, limit = 1e3) => {
348
+ const params = new URLSearchParams({
349
+ offset: offset.toString(),
350
+ limit: limit.toString()
351
+ });
352
+ if (type) params.append("type", type);
353
+ if (marketAddr) params.append("marketAddr", marketAddr);
354
+ const url = `api/positions/${userAddr}?${params.toString()}`;
355
+ return (await this.#request(url)).map((p) => ({
356
+ ...p,
357
+ optionId: BigInt(p.optionId)
358
+ }));
359
+ };
360
+ mintPerp = async (body) => {
361
+ if (!this.auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
362
+ const { txHash, optionId } = await this.#request("api/positions/mint", {
363
+ ...body,
364
+ amount: body.amount.toString(),
365
+ auth: this.auth
366
+ });
367
+ return {
368
+ txHash,
369
+ optionId: BigInt(optionId)
370
+ };
371
+ };
372
+ exercisePerp = async (body) => {
373
+ if (!this.auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
374
+ const { txHash, optionId } = await this.#request("api/positions/exercise", {
375
+ ...body,
376
+ optionId: body.optionId.toString(),
377
+ liquidities: body.liquidities.map((l) => l.toString()),
378
+ auth: this.auth
379
+ });
380
+ return {
381
+ txHash,
382
+ optionId: BigInt(optionId)
383
+ };
384
+ };
385
+ };
386
+
291
387
  //#endregion
292
388
  //#region src/providers/TimelockProvider.tsx
293
389
  const TimelockContext = (0, react.createContext)(void 0);
@@ -298,11 +394,15 @@ const TimelockProvider = ({ children, marketData, envioGraphqlUrl, perpsOperator
298
394
  const graphqlClient = (0, react.useMemo)(() => {
299
395
  if (envioGraphqlUrl) return getSdk(new graphql_request.GraphQLClient(envioGraphqlUrl));
300
396
  }, [envioGraphqlUrl]);
397
+ const perpsOperator = (0, react.useMemo)(() => {
398
+ if (perpsOperatorUrl) return new PerpsOperator(perpsOperatorUrl);
399
+ }, [perpsOperatorUrl]);
301
400
  const contextValue = (0, react.useMemo)(() => ({
302
401
  marketData: marketData || {},
303
402
  lensAddr,
304
403
  uniswapMathLensAddr,
305
404
  envioGraphqlUrl,
405
+ perpsOperator,
306
406
  graphqlClient,
307
407
  perpsOperatorUrl
308
408
  }), [
@@ -310,6 +410,7 @@ const TimelockProvider = ({ children, marketData, envioGraphqlUrl, perpsOperator
310
410
  lensAddr,
311
411
  uniswapMathLensAddr,
312
412
  envioGraphqlUrl,
413
+ perpsOperator,
313
414
  graphqlClient,
314
415
  perpsOperatorUrl
315
416
  ]);
@@ -418,7 +519,16 @@ const useExerciseOption = (marketAddr) => {
418
519
  ]
419
520
  });
420
521
  await (0, viem_actions.waitForTransactionReceipt)(client, { hash });
421
- queryClient.invalidateQueries({ queryKey: ["userOptions", address.toLowerCase()] });
522
+ queryClient.invalidateQueries({ queryKey: [
523
+ "userOptions",
524
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
525
+ true
526
+ ] });
527
+ queryClient.invalidateQueries({ queryKey: [
528
+ "userOptions",
529
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
530
+ false
531
+ ] });
422
532
  queryClient.invalidateQueries({ queryKey: ["readContract"] });
423
533
  return hash;
424
534
  };
@@ -551,7 +661,16 @@ const useMintOption = (marketAddr) => {
551
661
  ]
552
662
  });
553
663
  await (0, viem_actions.waitForTransactionReceipt)(client, { hash });
554
- queryClient.invalidateQueries({ queryKey: ["userOptions", address.toLowerCase()] });
664
+ queryClient.invalidateQueries({ queryKey: [
665
+ "userOptions",
666
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
667
+ true
668
+ ] });
669
+ queryClient.invalidateQueries({ queryKey: [
670
+ "userOptions",
671
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
672
+ false
673
+ ] });
555
674
  queryClient.invalidateQueries({ queryKey: ["readContract"] });
556
675
  return hash;
557
676
  };
@@ -801,102 +920,6 @@ const useOptionTimeline = (marketAddr, optionId) => {
801
920
  };
802
921
  };
803
922
 
804
- //#endregion
805
- //#region src/lib/perpsOperator.ts
806
- var PerpsOperator = class {
807
- #baseUrl;
808
- auth;
809
- constructor(baseUrl) {
810
- this.#baseUrl = baseUrl;
811
- }
812
- #request = async (path, body) => {
813
- const url = new URL(path, this.#baseUrl);
814
- const res = await fetch(url, {
815
- method: body ? "POST" : "GET",
816
- headers: {
817
- Connection: "keep-alive",
818
- "Content-Type": "application/json",
819
- "Keep-Alive": "timeout=120"
820
- },
821
- body: body ? JSON.stringify(body) : void 0
822
- });
823
- if (res.ok) {
824
- const { data } = await res.json();
825
- return data;
826
- }
827
- const resText = await res.text();
828
- try {
829
- const error = JSON.parse(resText);
830
- throw new Error(`${res.status} ${res.statusText}: ${error.error}`);
831
- } catch (error) {
832
- throw new Error(`${res.status} ${res.statusText}: ${resText}`);
833
- }
834
- };
835
- getOperatorAddr = async () => {
836
- const { address } = await this.#request("api/operator/address");
837
- return address;
838
- };
839
- genAuthMessage = async (userAddr) => {
840
- const { message } = await this.#request("api/auth/gen", { userAddr });
841
- return message;
842
- };
843
- validateAuthMessage = async (message, signature) => {
844
- const { address, createdAt, validUntil } = await this.#request("api/auth/validate", {
845
- message,
846
- signature
847
- });
848
- return {
849
- address,
850
- createdAt,
851
- validUntil
852
- };
853
- };
854
- setAuth = (message, signature) => {
855
- this.auth = {
856
- message,
857
- signature
858
- };
859
- };
860
- getUserPerps = async (userAddr, marketAddr, type, offset = 0, limit = 1e3) => {
861
- const params = new URLSearchParams({
862
- offset: offset.toString(),
863
- limit: limit.toString()
864
- });
865
- if (type) params.append("type", type);
866
- if (marketAddr) params.append("marketAddr", marketAddr);
867
- const url = `api/positions/${userAddr}?${params.toString()}`;
868
- return (await this.#request(url)).map((p) => ({
869
- ...p,
870
- optionId: BigInt(p.optionId)
871
- }));
872
- };
873
- mintPerp = async (body) => {
874
- if (!this.auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
875
- const { txHash, optionId } = await this.#request("api/positions/mint", {
876
- ...body,
877
- amount: body.amount.toString(),
878
- auth: this.auth
879
- });
880
- return {
881
- txHash,
882
- optionId: BigInt(optionId)
883
- };
884
- };
885
- exercisePerp = async (body) => {
886
- if (!this.auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
887
- const { txHash, optionId } = await this.#request("api/positions/exercise", {
888
- ...body,
889
- optionId: body.optionId.toString(),
890
- liquidities: body.liquidities.map((l) => l.toString()),
891
- auth: this.auth
892
- });
893
- return {
894
- txHash,
895
- optionId: BigInt(optionId)
896
- };
897
- };
898
- };
899
-
900
923
  //#endregion
901
924
  //#region src/hooks/perps/usePerpsOperator.ts
902
925
  const ZHex = zod.z.string().regex(/^0x[a-fA-F0-9]+$/, "Invalid hex string").transform((v) => v);
@@ -929,9 +952,8 @@ const clearSignature = (userAddr) => {
929
952
  };
930
953
  const usePerpsOperator = () => {
931
954
  const { address: userAddr } = (0, wagmi.useAccount)();
932
- const { perpsOperatorUrl } = useTimelockConfig();
955
+ const { perpsOperatorUrl, perpsOperator: operator } = useTimelockConfig();
933
956
  const { signMessageAsync } = (0, wagmi.useSignMessage)();
934
- const operator = (0, react.useMemo)(() => perpsOperatorUrl ? new PerpsOperator(perpsOperatorUrl) : void 0, [perpsOperatorUrl]);
935
957
  const { data: address } = (0, __tanstack_react_query.useQuery)({
936
958
  queryKey: ["perpsOperatorAddr", perpsOperatorUrl || "--"],
937
959
  queryFn: () => operator === null || operator === void 0 ? void 0 : operator.getOperatorAddr(),
@@ -1083,7 +1105,16 @@ const useMintPerp = (marketAddr) => {
1083
1105
  duration,
1084
1106
  strikeTick: validStrikeTick
1085
1107
  });
1086
- queryClient.invalidateQueries({ queryKey: ["userOptions", address.toLowerCase()] });
1108
+ queryClient.invalidateQueries({ queryKey: [
1109
+ "userOptions",
1110
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
1111
+ true
1112
+ ] });
1113
+ queryClient.invalidateQueries({ queryKey: [
1114
+ "userOptions",
1115
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
1116
+ false
1117
+ ] });
1087
1118
  queryClient.invalidateQueries({ queryKey: ["readContract"] });
1088
1119
  };
1089
1120
  return (0, __tanstack_react_query.useMutation)({ mutationFn: mintPerp });
@@ -1099,7 +1130,16 @@ const useClosePerp = () => {
1099
1130
  if (!operator) throw new Error("Operator not connected");
1100
1131
  if (!operator.auth) await signMessage();
1101
1132
  await operator.exercisePerp(body);
1102
- queryClient.invalidateQueries({ queryKey: ["userOptions", address === null || address === void 0 ? void 0 : address.toLowerCase()] });
1133
+ queryClient.invalidateQueries({ queryKey: [
1134
+ "userOptions",
1135
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
1136
+ true
1137
+ ] });
1138
+ queryClient.invalidateQueries({ queryKey: [
1139
+ "userOptions",
1140
+ address === null || address === void 0 ? void 0 : address.toLowerCase(),
1141
+ false
1142
+ ] });
1103
1143
  queryClient.invalidateQueries({ queryKey: ["readContract"] });
1104
1144
  } });
1105
1145
  };