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.cjs
CHANGED
|
@@ -43,7 +43,8 @@ const GetActiveUserOptionsDocument = graphql_tag.default`
|
|
|
43
43
|
entryPrice
|
|
44
44
|
expiresAt
|
|
45
45
|
createdAt
|
|
46
|
-
|
|
46
|
+
premium
|
|
47
|
+
protocolFee
|
|
47
48
|
realizedPayout
|
|
48
49
|
marketAddr
|
|
49
50
|
liquiditiesAtOpen
|
|
@@ -77,7 +78,8 @@ const GetClosedUserOptionsDocument = graphql_tag.default`
|
|
|
77
78
|
entryPrice
|
|
78
79
|
expiresAt
|
|
79
80
|
createdAt
|
|
80
|
-
|
|
81
|
+
premium
|
|
82
|
+
protocolFee
|
|
81
83
|
realizedPayout
|
|
82
84
|
marketAddr
|
|
83
85
|
liquiditiesAtOpen
|
|
@@ -184,10 +186,21 @@ const useTimelockConfig = () => {
|
|
|
184
186
|
return context;
|
|
185
187
|
};
|
|
186
188
|
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/hooks/useLens.ts
|
|
191
|
+
const useLens = () => {
|
|
192
|
+
const client = (0, wagmi.useClient)();
|
|
193
|
+
return (0, react.useMemo)(() => ({
|
|
194
|
+
timelockLens: client ? require_numberUtils.getTimelockLens(client) : void 0,
|
|
195
|
+
uniswapLens: client ? require_numberUtils.getUniswapMathLens(client) : void 0
|
|
196
|
+
}), [client]);
|
|
197
|
+
};
|
|
198
|
+
|
|
187
199
|
//#endregion
|
|
188
200
|
//#region src/hooks/market/useMarketData.ts
|
|
189
201
|
const useMarketData = (marketAddr) => {
|
|
190
202
|
const { graphqlClient } = useTimelockConfig();
|
|
203
|
+
const { timelockLens } = useLens();
|
|
191
204
|
const { data } = (0, __tanstack_react_query.useQuery)({
|
|
192
205
|
queryKey: ["marketData", marketAddr || "--"],
|
|
193
206
|
queryFn: async () => {
|
|
@@ -204,17 +217,18 @@ const useMarketData = (marketAddr) => {
|
|
|
204
217
|
},
|
|
205
218
|
enabled: !!marketAddr && !!graphqlClient
|
|
206
219
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
})
|
|
220
|
+
const { data: fallback } = (0, __tanstack_react_query.useQuery)({
|
|
221
|
+
queryKey: ["marketData", marketAddr || "--"],
|
|
222
|
+
queryFn: async () => {
|
|
223
|
+
if (!marketAddr || !timelockLens) return void 0;
|
|
224
|
+
return {
|
|
225
|
+
...await timelockLens.read.getMarketData([marketAddr]),
|
|
226
|
+
tradersCount: void 0
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
enabled: !!marketAddr && !!timelockLens
|
|
230
|
+
});
|
|
231
|
+
return data || fallback || {};
|
|
218
232
|
};
|
|
219
233
|
|
|
220
234
|
//#endregion
|
|
@@ -494,7 +508,8 @@ const useUserOptions = (user, active = false) => {
|
|
|
494
508
|
optionType: option.optionType,
|
|
495
509
|
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
496
510
|
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
497
|
-
|
|
511
|
+
premium: BigInt(option.premium),
|
|
512
|
+
protocolFee: BigInt(option.protocolFee),
|
|
498
513
|
realizedPayout: BigInt(option.realizedPayout),
|
|
499
514
|
liquiditiesAtOpen: option.liquiditiesAtOpen.map((l) => BigInt(l)),
|
|
500
515
|
liquiditiesCurrent: option.liquiditiesCurrent.map((l) => BigInt(l)),
|