timelock-sdk 0.0.28 → 0.0.29
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 +31 -32
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +115 -115
- package/dist/client.js +31 -32
- package/dist/client.js.map +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -185,21 +185,22 @@ const useTimelockConfig = () => {
|
|
|
185
185
|
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/hooks/market/useMarketData.ts
|
|
188
|
-
const selectMarket = (data) => ({
|
|
189
|
-
...data.TimelockMarket[0],
|
|
190
|
-
pool: data.TimelockMarket[0].pool,
|
|
191
|
-
vault: data.TimelockMarket[0].vault,
|
|
192
|
-
optionAsset: data.TimelockMarket[0].optionAsset,
|
|
193
|
-
payoutAsset: data.TimelockMarket[0].payoutAsset,
|
|
194
|
-
optionsCount: BigInt(data.TimelockMarket[0].optionsCount),
|
|
195
|
-
tradersCount: BigInt(data.TimelockMarket[0].tradersCount)
|
|
196
|
-
});
|
|
197
188
|
const useMarketData = (marketAddr) => {
|
|
198
189
|
const { graphqlClient } = useTimelockConfig();
|
|
199
190
|
const { data } = (0, __tanstack_react_query.useQuery)({
|
|
200
191
|
queryKey: ["marketData", marketAddr || "--"],
|
|
201
|
-
queryFn: () =>
|
|
202
|
-
|
|
192
|
+
queryFn: async () => {
|
|
193
|
+
const result = await graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() });
|
|
194
|
+
return {
|
|
195
|
+
...result.TimelockMarket[0],
|
|
196
|
+
pool: result.TimelockMarket[0].pool,
|
|
197
|
+
vault: result.TimelockMarket[0].vault,
|
|
198
|
+
optionAsset: result.TimelockMarket[0].optionAsset,
|
|
199
|
+
payoutAsset: result.TimelockMarket[0].payoutAsset,
|
|
200
|
+
optionsCount: BigInt(result.TimelockMarket[0].optionsCount),
|
|
201
|
+
tradersCount: BigInt(result.TimelockMarket[0].tradersCount)
|
|
202
|
+
};
|
|
203
|
+
},
|
|
203
204
|
enabled: !!marketAddr && !!graphqlClient
|
|
204
205
|
});
|
|
205
206
|
return data || {};
|
|
@@ -448,25 +449,6 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, duration) => {
|
|
|
448
449
|
|
|
449
450
|
//#endregion
|
|
450
451
|
//#region src/hooks/market/useUserOptions.ts
|
|
451
|
-
const selectOptions = (data) => {
|
|
452
|
-
if (!(data === null || data === void 0 ? void 0 : data.UserOption)) return [];
|
|
453
|
-
return data.UserOption.map((option) => ({
|
|
454
|
-
...option,
|
|
455
|
-
id: BigInt(option.id),
|
|
456
|
-
marketAddr: option.marketAddr,
|
|
457
|
-
optionType: option.optionType,
|
|
458
|
-
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
459
|
-
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
460
|
-
premiumPaid: BigInt(option.premiumPaid),
|
|
461
|
-
realizedPayout: BigInt(option.realizedPayout),
|
|
462
|
-
liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
|
|
463
|
-
liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
|
|
464
|
-
positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
|
|
465
|
-
positionSizeCurrent: BigInt(option.positionSizeCurrent),
|
|
466
|
-
strikePrice: BigInt(option.strikePrice),
|
|
467
|
-
entryPrice: BigInt(option.entryPrice)
|
|
468
|
-
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
469
|
-
};
|
|
470
452
|
const useUserOptions = (user, active = false) => {
|
|
471
453
|
const { graphqlClient } = useTimelockConfig();
|
|
472
454
|
const { data,...rest } = (0, __tanstack_react_query.useQuery)({
|
|
@@ -475,8 +457,25 @@ const useUserOptions = (user, active = false) => {
|
|
|
475
457
|
user || "--",
|
|
476
458
|
active
|
|
477
459
|
],
|
|
478
|
-
queryFn: () =>
|
|
479
|
-
|
|
460
|
+
queryFn: async () => {
|
|
461
|
+
if (!graphqlClient) return [];
|
|
462
|
+
return (active ? await graphqlClient.GetActiveUserOptions({ user: user.toLowerCase() }) : await graphqlClient.GetClosedUserOptions({ user: user.toLowerCase() })).UserOption.map((option) => ({
|
|
463
|
+
...option,
|
|
464
|
+
id: BigInt(option.id),
|
|
465
|
+
marketAddr: option.marketAddr,
|
|
466
|
+
optionType: option.optionType,
|
|
467
|
+
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
468
|
+
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
469
|
+
premiumPaid: BigInt(option.premiumPaid),
|
|
470
|
+
realizedPayout: BigInt(option.realizedPayout),
|
|
471
|
+
liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
|
|
472
|
+
liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
|
|
473
|
+
positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
|
|
474
|
+
positionSizeCurrent: BigInt(option.positionSizeCurrent),
|
|
475
|
+
strikePrice: BigInt(option.strikePrice),
|
|
476
|
+
entryPrice: BigInt(option.entryPrice)
|
|
477
|
+
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
478
|
+
},
|
|
480
479
|
enabled: !!user && !!graphqlClient
|
|
481
480
|
});
|
|
482
481
|
return {
|