timelock-sdk 0.0.61 → 0.0.63

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.js CHANGED
@@ -16,12 +16,17 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
16
16
  const GetActiveUserOptionsDocument = gql`
17
17
  query GetActiveUserOptions($user: String!) {
18
18
  UserOption(
19
- where: {ownerAddr: {_eq: $user}, fullyExercised: {_eq: false}}
19
+ where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: false}}
20
20
  limit: 1000
21
21
  ) {
22
22
  id
23
23
  optionId
24
- ownerAddr
24
+ owner {
25
+ address
26
+ }
27
+ market {
28
+ address
29
+ }
25
30
  exerciseEvents {
26
31
  transactionHash
27
32
  }
@@ -39,7 +44,6 @@ const GetActiveUserOptionsDocument = gql`
39
44
  premium
40
45
  protocolFee
41
46
  realizedPayout
42
- marketAddr
43
47
  liquiditiesAtOpen
44
48
  liquiditiesCurrent
45
49
  positionSizeAtOpen
@@ -51,12 +55,17 @@ const GetActiveUserOptionsDocument = gql`
51
55
  const GetClosedUserOptionsDocument = gql`
52
56
  query GetClosedUserOptions($user: String!) {
53
57
  UserOption(
54
- where: {ownerAddr: {_eq: $user}, fullyExercised: {_eq: true}}
58
+ where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: true}}
55
59
  limit: 1000
56
60
  ) {
57
61
  id
58
62
  optionId
59
- ownerAddr
63
+ owner {
64
+ address
65
+ }
66
+ market {
67
+ address
68
+ }
60
69
  exerciseEvents {
61
70
  transactionHash
62
71
  }
@@ -74,7 +83,6 @@ const GetClosedUserOptionsDocument = gql`
74
83
  premium
75
84
  protocolFee
76
85
  realizedPayout
77
- marketAddr
78
86
  liquiditiesAtOpen
79
87
  liquiditiesCurrent
80
88
  positionSizeAtOpen
@@ -85,8 +93,9 @@ const GetClosedUserOptionsDocument = gql`
85
93
  `;
86
94
  const GetMarketDataDocument = gql`
87
95
  query GetMarketData($marketAddr: String!) {
88
- TimelockMarket(where: {id: {_eq: $marketAddr}}, limit: 1) {
96
+ TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
89
97
  id
98
+ address
90
99
  optionsCount
91
100
  tradersCount
92
101
  vault
@@ -104,6 +113,27 @@ const GetMarketDataDocument = gql`
104
113
  }
105
114
  }
106
115
  `;
116
+ const GetUserMarketOperatorsDocument = gql`
117
+ query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
118
+ UserMarketOperator(
119
+ where: {
120
+ user: {address: {_eq: $userAddr}}
121
+ market: {address: {_eq: $marketAddr}}
122
+ }
123
+ limit: 1000
124
+ ) {
125
+ id
126
+ operator {
127
+ address
128
+ }
129
+ canExtend
130
+ canExercise
131
+ canTransfer
132
+ canMint
133
+ spendingApproval
134
+ }
135
+ }
136
+ `;
107
137
  const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
108
138
  function getSdk(client, withWrapper = defaultWrapper) {
109
139
  return {
@@ -139,6 +169,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
139
169
  },
140
170
  signal
141
171
  }), "GetMarketData", "query", variables);
172
+ },
173
+ GetUserMarketOperators(variables, requestHeaders, signal) {
174
+ return withWrapper((wrappedRequestHeaders) => client.request({
175
+ document: GetUserMarketOperatorsDocument,
176
+ variables,
177
+ requestHeaders: {
178
+ ...requestHeaders,
179
+ ...wrappedRequestHeaders
180
+ },
181
+ signal
182
+ }), "GetUserMarketOperators", "query", variables);
142
183
  }
143
184
  };
144
185
  }
@@ -527,7 +568,8 @@ const useUserOptions = (user, active = false) => {
527
568
  return (active ? await graphqlClient.GetActiveUserOptions({ user }) : await graphqlClient.GetClosedUserOptions({ user })).UserOption.map((option) => ({
528
569
  ...option,
529
570
  optionId: BigInt(option.optionId),
530
- marketAddr: option.marketAddr,
571
+ marketAddr: option.market.address,
572
+ ownerAddr: option.owner.address,
531
573
  optionType: option.optionType,
532
574
  createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
533
575
  expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
@@ -607,6 +649,35 @@ const useExtendOption = (marketAddr) => {
607
649
  };
608
650
  };
609
651
 
652
+ //#endregion
653
+ //#region src/hooks/market/useUserOperators.ts
654
+ const useUserOperators = (userAddr, marketAddr) => {
655
+ const { graphqlClient } = useTimelockConfig();
656
+ const { data,...rest } = useQuery({
657
+ queryKey: [
658
+ "userOperators",
659
+ userAddr || "--",
660
+ marketAddr || "--"
661
+ ],
662
+ queryFn: async () => {
663
+ if (!userAddr || !marketAddr) return void 0;
664
+ return (await graphqlClient.GetUserMarketOperators({
665
+ userAddr: userAddr.toLowerCase(),
666
+ marketAddr: marketAddr.toLowerCase()
667
+ })).UserMarketOperator.map((operator) => ({
668
+ ...operator,
669
+ spendingApproval: BigInt(operator.spendingApproval),
670
+ operatorAddr: operator.operator.address.toLowerCase()
671
+ }));
672
+ },
673
+ enabled: !!userAddr && !!marketAddr && !!graphqlClient
674
+ });
675
+ return {
676
+ ...rest,
677
+ data: data || {}
678
+ };
679
+ };
680
+
610
681
  //#endregion
611
682
  //#region src/hooks/pool/usePriceAtTick.ts
612
683
  const usePriceAtTick = (tick, poolAddr) => {
@@ -978,5 +1049,5 @@ const useVaultTVL = (vaultAddr) => {
978
1049
  };
979
1050
 
980
1051
  //#endregion
981
- export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useTimelockConfig, useVaultData, useVaultTVL };
1052
+ export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
982
1053
  //# sourceMappingURL=client.js.map