timelock-sdk 0.0.51 → 0.0.53
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.cjs +29 -14
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +172 -116
- package/dist/client.d.ts +172 -116
- package/dist/client.js +29 -14
- package/dist/client.js.map +1 -1
- package/dist/{index-BPKijlT_.d.cts → index-HQTA4ETi.d.cts} +92 -92
- package/dist/package.d.cts +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -36,7 +36,8 @@ const GetActiveUserOptionsDocument = gql`
|
|
|
36
36
|
entryPrice
|
|
37
37
|
expiresAt
|
|
38
38
|
createdAt
|
|
39
|
-
|
|
39
|
+
premium
|
|
40
|
+
protocolFee
|
|
40
41
|
realizedPayout
|
|
41
42
|
marketAddr
|
|
42
43
|
liquiditiesAtOpen
|
|
@@ -70,7 +71,8 @@ const GetClosedUserOptionsDocument = gql`
|
|
|
70
71
|
entryPrice
|
|
71
72
|
expiresAt
|
|
72
73
|
createdAt
|
|
73
|
-
|
|
74
|
+
premium
|
|
75
|
+
protocolFee
|
|
74
76
|
realizedPayout
|
|
75
77
|
marketAddr
|
|
76
78
|
liquiditiesAtOpen
|
|
@@ -177,10 +179,21 @@ const useTimelockConfig = () => {
|
|
|
177
179
|
return context;
|
|
178
180
|
};
|
|
179
181
|
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/hooks/useLens.ts
|
|
184
|
+
const useLens = () => {
|
|
185
|
+
const client = useClient();
|
|
186
|
+
return useMemo(() => ({
|
|
187
|
+
timelockLens: client ? getTimelockLens(client) : void 0,
|
|
188
|
+
uniswapLens: client ? getUniswapMathLens(client) : void 0
|
|
189
|
+
}), [client]);
|
|
190
|
+
};
|
|
191
|
+
|
|
180
192
|
//#endregion
|
|
181
193
|
//#region src/hooks/market/useMarketData.ts
|
|
182
194
|
const useMarketData = (marketAddr) => {
|
|
183
195
|
const { graphqlClient } = useTimelockConfig();
|
|
196
|
+
const { timelockLens } = useLens();
|
|
184
197
|
const { data } = useQuery({
|
|
185
198
|
queryKey: ["marketData", marketAddr || "--"],
|
|
186
199
|
queryFn: async () => {
|
|
@@ -197,17 +210,18 @@ const useMarketData = (marketAddr) => {
|
|
|
197
210
|
},
|
|
198
211
|
enabled: !!marketAddr && !!graphqlClient
|
|
199
212
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
})
|
|
213
|
+
const { data: fallback } = useQuery({
|
|
214
|
+
queryKey: ["marketData", marketAddr || "--"],
|
|
215
|
+
queryFn: async () => {
|
|
216
|
+
if (!marketAddr || !timelockLens) return void 0;
|
|
217
|
+
return {
|
|
218
|
+
...await timelockLens.read.getMarketData([marketAddr]),
|
|
219
|
+
tradersCount: void 0
|
|
220
|
+
};
|
|
221
|
+
},
|
|
222
|
+
enabled: !!marketAddr && !!timelockLens
|
|
223
|
+
});
|
|
224
|
+
return data || fallback || {};
|
|
211
225
|
};
|
|
212
226
|
|
|
213
227
|
//#endregion
|
|
@@ -487,7 +501,8 @@ const useUserOptions = (user, active = false) => {
|
|
|
487
501
|
optionType: option.optionType,
|
|
488
502
|
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
489
503
|
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
490
|
-
|
|
504
|
+
premium: BigInt(option.premium),
|
|
505
|
+
protocolFee: BigInt(option.protocolFee),
|
|
491
506
|
realizedPayout: BigInt(option.realizedPayout),
|
|
492
507
|
liquiditiesAtOpen: option.liquiditiesAtOpen.map((l) => BigInt(l)),
|
|
493
508
|
liquiditiesCurrent: option.liquiditiesCurrent.map((l) => BigInt(l)),
|