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.js
CHANGED
|
@@ -178,21 +178,22 @@ const useTimelockConfig = () => {
|
|
|
178
178
|
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/hooks/market/useMarketData.ts
|
|
181
|
-
const selectMarket = (data) => ({
|
|
182
|
-
...data.TimelockMarket[0],
|
|
183
|
-
pool: data.TimelockMarket[0].pool,
|
|
184
|
-
vault: data.TimelockMarket[0].vault,
|
|
185
|
-
optionAsset: data.TimelockMarket[0].optionAsset,
|
|
186
|
-
payoutAsset: data.TimelockMarket[0].payoutAsset,
|
|
187
|
-
optionsCount: BigInt(data.TimelockMarket[0].optionsCount),
|
|
188
|
-
tradersCount: BigInt(data.TimelockMarket[0].tradersCount)
|
|
189
|
-
});
|
|
190
181
|
const useMarketData = (marketAddr) => {
|
|
191
182
|
const { graphqlClient } = useTimelockConfig();
|
|
192
183
|
const { data } = useQuery({
|
|
193
184
|
queryKey: ["marketData", marketAddr || "--"],
|
|
194
|
-
queryFn: () =>
|
|
195
|
-
|
|
185
|
+
queryFn: async () => {
|
|
186
|
+
const result = await graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() });
|
|
187
|
+
return {
|
|
188
|
+
...result.TimelockMarket[0],
|
|
189
|
+
pool: result.TimelockMarket[0].pool,
|
|
190
|
+
vault: result.TimelockMarket[0].vault,
|
|
191
|
+
optionAsset: result.TimelockMarket[0].optionAsset,
|
|
192
|
+
payoutAsset: result.TimelockMarket[0].payoutAsset,
|
|
193
|
+
optionsCount: BigInt(result.TimelockMarket[0].optionsCount),
|
|
194
|
+
tradersCount: BigInt(result.TimelockMarket[0].tradersCount)
|
|
195
|
+
};
|
|
196
|
+
},
|
|
196
197
|
enabled: !!marketAddr && !!graphqlClient
|
|
197
198
|
});
|
|
198
199
|
return data || {};
|
|
@@ -441,25 +442,6 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, duration) => {
|
|
|
441
442
|
|
|
442
443
|
//#endregion
|
|
443
444
|
//#region src/hooks/market/useUserOptions.ts
|
|
444
|
-
const selectOptions = (data) => {
|
|
445
|
-
if (!(data === null || data === void 0 ? void 0 : data.UserOption)) return [];
|
|
446
|
-
return data.UserOption.map((option) => ({
|
|
447
|
-
...option,
|
|
448
|
-
id: BigInt(option.id),
|
|
449
|
-
marketAddr: option.marketAddr,
|
|
450
|
-
optionType: option.optionType,
|
|
451
|
-
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
452
|
-
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
453
|
-
premiumPaid: BigInt(option.premiumPaid),
|
|
454
|
-
realizedPayout: BigInt(option.realizedPayout),
|
|
455
|
-
liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
|
|
456
|
-
liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
|
|
457
|
-
positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
|
|
458
|
-
positionSizeCurrent: BigInt(option.positionSizeCurrent),
|
|
459
|
-
strikePrice: BigInt(option.strikePrice),
|
|
460
|
-
entryPrice: BigInt(option.entryPrice)
|
|
461
|
-
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
462
|
-
};
|
|
463
445
|
const useUserOptions = (user, active = false) => {
|
|
464
446
|
const { graphqlClient } = useTimelockConfig();
|
|
465
447
|
const { data,...rest } = useQuery({
|
|
@@ -468,8 +450,25 @@ const useUserOptions = (user, active = false) => {
|
|
|
468
450
|
user || "--",
|
|
469
451
|
active
|
|
470
452
|
],
|
|
471
|
-
queryFn: () =>
|
|
472
|
-
|
|
453
|
+
queryFn: async () => {
|
|
454
|
+
if (!graphqlClient) return [];
|
|
455
|
+
return (active ? await graphqlClient.GetActiveUserOptions({ user: user.toLowerCase() }) : await graphqlClient.GetClosedUserOptions({ user: user.toLowerCase() })).UserOption.map((option) => ({
|
|
456
|
+
...option,
|
|
457
|
+
id: BigInt(option.id),
|
|
458
|
+
marketAddr: option.marketAddr,
|
|
459
|
+
optionType: option.optionType,
|
|
460
|
+
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
461
|
+
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
462
|
+
premiumPaid: BigInt(option.premiumPaid),
|
|
463
|
+
realizedPayout: BigInt(option.realizedPayout),
|
|
464
|
+
liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
|
|
465
|
+
liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
|
|
466
|
+
positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
|
|
467
|
+
positionSizeCurrent: BigInt(option.positionSizeCurrent),
|
|
468
|
+
strikePrice: BigInt(option.strikePrice),
|
|
469
|
+
entryPrice: BigInt(option.entryPrice)
|
|
470
|
+
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
471
|
+
},
|
|
473
472
|
enabled: !!user && !!graphqlClient
|
|
474
473
|
});
|
|
475
474
|
return {
|