timelock-sdk 0.0.60 → 0.0.62

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 CHANGED
@@ -1,4 +1,4 @@
1
- const require_optionsMarket = require('./optionsMarket-C5z_ZrhG.cjs');
1
+ const require_optionsMarket = require('./optionsMarket-D192aXEZ.cjs');
2
2
  const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
3
3
 
4
4
  exports.erc20Abi = require_optionsMarket.erc20Abi;
package/dist/abis.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-Dd_BqyEk.cjs";
1
+ import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-D3iSMTdz.cjs";
2
2
 
3
3
  //#region src/abis/erc20.d.ts
4
4
  declare const erc20Abi: readonly [{
package/dist/abis.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-DS1i63oR.js";
1
+ import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-Ddy91uWa.js";
2
2
 
3
3
  //#region src/abis/erc20.d.ts
4
4
  declare const erc20Abi: readonly [{
package/dist/abis.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as erc20Abi, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-BW3qSfsm.js";
1
+ import { i as erc20Abi, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-DD4CWMqv.js";
2
2
  import { n as uniswapV3PoolAbi, t as singleOwnerVaultAbi } from "./singleOwnerVault-BeJChjfJ.js";
3
3
 
4
4
  export { erc20Abi, lensAbi, optionsMarketAbi, singleOwnerVaultAbi, uniswapMathLensAbi, uniswapV3PoolAbi };
package/dist/client.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
 
4
- const require_numberUtils = require('./numberUtils-DaQ_5dq6.cjs');
5
- const require_optionsMarket = require('./optionsMarket-C5z_ZrhG.cjs');
4
+ const require_numberUtils = require('./numberUtils-CmVB4kX7.cjs');
5
+ const require_optionsMarket = require('./optionsMarket-D192aXEZ.cjs');
6
6
  const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
7
7
  let viem = require("viem");
8
8
  viem = require_numberUtils.__toESM(viem);
@@ -23,12 +23,17 @@ __tanstack_react_query = require_numberUtils.__toESM(__tanstack_react_query);
23
23
  const GetActiveUserOptionsDocument = graphql_tag.default`
24
24
  query GetActiveUserOptions($user: String!) {
25
25
  UserOption(
26
- where: {ownerAddr: {_eq: $user}, fullyExercised: {_eq: false}}
26
+ where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: false}}
27
27
  limit: 1000
28
28
  ) {
29
29
  id
30
30
  optionId
31
- ownerAddr
31
+ owner {
32
+ address
33
+ }
34
+ market {
35
+ address
36
+ }
32
37
  exerciseEvents {
33
38
  transactionHash
34
39
  }
@@ -46,7 +51,6 @@ const GetActiveUserOptionsDocument = graphql_tag.default`
46
51
  premium
47
52
  protocolFee
48
53
  realizedPayout
49
- marketAddr
50
54
  liquiditiesAtOpen
51
55
  liquiditiesCurrent
52
56
  positionSizeAtOpen
@@ -58,12 +62,17 @@ const GetActiveUserOptionsDocument = graphql_tag.default`
58
62
  const GetClosedUserOptionsDocument = graphql_tag.default`
59
63
  query GetClosedUserOptions($user: String!) {
60
64
  UserOption(
61
- where: {ownerAddr: {_eq: $user}, fullyExercised: {_eq: true}}
65
+ where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: true}}
62
66
  limit: 1000
63
67
  ) {
64
68
  id
65
69
  optionId
66
- ownerAddr
70
+ owner {
71
+ address
72
+ }
73
+ market {
74
+ address
75
+ }
67
76
  exerciseEvents {
68
77
  transactionHash
69
78
  }
@@ -81,7 +90,6 @@ const GetClosedUserOptionsDocument = graphql_tag.default`
81
90
  premium
82
91
  protocolFee
83
92
  realizedPayout
84
- marketAddr
85
93
  liquiditiesAtOpen
86
94
  liquiditiesCurrent
87
95
  positionSizeAtOpen
@@ -92,8 +100,9 @@ const GetClosedUserOptionsDocument = graphql_tag.default`
92
100
  `;
93
101
  const GetMarketDataDocument = graphql_tag.default`
94
102
  query GetMarketData($marketAddr: String!) {
95
- TimelockMarket(where: {id: {_eq: $marketAddr}}, limit: 1) {
103
+ TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
96
104
  id
105
+ address
97
106
  optionsCount
98
107
  tradersCount
99
108
  vault
@@ -111,6 +120,27 @@ const GetMarketDataDocument = graphql_tag.default`
111
120
  }
112
121
  }
113
122
  `;
123
+ const GetUserMarketOperatorsDocument = graphql_tag.default`
124
+ query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
125
+ UserMarketOperator(
126
+ where: {
127
+ user: {address: {_eq: $userAddr}}
128
+ market: {address: {_eq: $marketAddr}}
129
+ }
130
+ limit: 1000
131
+ ) {
132
+ id
133
+ operator {
134
+ address
135
+ }
136
+ canExtend
137
+ canExercise
138
+ canTransfer
139
+ canMint
140
+ spendingApproval
141
+ }
142
+ }
143
+ `;
114
144
  const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
115
145
  function getSdk(client, withWrapper = defaultWrapper) {
116
146
  return {
@@ -146,6 +176,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
146
176
  },
147
177
  signal
148
178
  }), "GetMarketData", "query", variables);
179
+ },
180
+ GetUserMarketOperators(variables, requestHeaders, signal) {
181
+ return withWrapper((wrappedRequestHeaders) => client.request({
182
+ document: GetUserMarketOperatorsDocument,
183
+ variables,
184
+ requestHeaders: {
185
+ ...requestHeaders,
186
+ ...wrappedRequestHeaders
187
+ },
188
+ signal
189
+ }), "GetUserMarketOperators", "query", variables);
149
190
  }
150
191
  };
151
192
  }
@@ -411,6 +452,7 @@ const useMintOption = (marketAddr) => {
411
452
  abi: require_optionsMarket.optionsMarketAbi,
412
453
  functionName: "mintOption",
413
454
  args: [
455
+ address,
414
456
  optionType === "CALL" ? 0 : 1,
415
457
  amount,
416
458
  strikeTick,
@@ -533,7 +575,8 @@ const useUserOptions = (user, active = false) => {
533
575
  return (active ? await graphqlClient.GetActiveUserOptions({ user }) : await graphqlClient.GetClosedUserOptions({ user })).UserOption.map((option) => ({
534
576
  ...option,
535
577
  optionId: BigInt(option.optionId),
536
- marketAddr: option.marketAddr,
578
+ marketAddr: option.market.address,
579
+ ownerAddr: option.owner.address,
537
580
  optionType: option.optionType,
538
581
  createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
539
582
  expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
@@ -613,6 +656,28 @@ const useExtendOption = (marketAddr) => {
613
656
  };
614
657
  };
615
658
 
659
+ //#endregion
660
+ //#region src/hooks/market/useUserOperators.ts
661
+ const useUserOperators = (userAddr, marketAddr) => {
662
+ const { graphqlClient } = useTimelockConfig();
663
+ const { data } = (0, __tanstack_react_query.useQuery)({
664
+ queryKey: ["marketData", marketAddr || "--"],
665
+ queryFn: async () => {
666
+ if (!userAddr || !marketAddr) return void 0;
667
+ return (await graphqlClient.GetUserMarketOperators({
668
+ userAddr: userAddr.toLowerCase(),
669
+ marketAddr: marketAddr.toLowerCase()
670
+ })).UserMarketOperator.map((operator) => ({
671
+ ...operator,
672
+ spendingApproval: BigInt(operator.spendingApproval),
673
+ operatorAddr: operator.operator.address.toLowerCase()
674
+ }));
675
+ },
676
+ enabled: !!marketAddr && !!graphqlClient
677
+ });
678
+ return data || {};
679
+ };
680
+
616
681
  //#endregion
617
682
  //#region src/hooks/pool/usePriceAtTick.ts
618
683
  const usePriceAtTick = (tick, poolAddr) => {
@@ -1006,6 +1071,7 @@ exports.usePoolData = usePoolData;
1006
1071
  exports.usePriceAtTick = usePriceAtTick;
1007
1072
  exports.usePriceHistory = usePriceHistory;
1008
1073
  exports.useTimelockConfig = useTimelockConfig;
1074
+ exports.useUserOperators = useUserOperators;
1009
1075
  exports.useVaultData = useVaultData;
1010
1076
  exports.useVaultTVL = useVaultTVL;
1011
1077
  //# sourceMappingURL=client.cjs.map