timelock-sdk 0.0.26 → 0.0.27
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 +32 -30
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +92 -92
- package/dist/client.d.ts +91 -91
- package/dist/client.js +32 -30
- package/dist/client.js.map +1 -1
- package/dist/{index-CA5kB-yT.d.cts → index-B7b3c8cu.d.cts} +92 -92
- package/dist/package.d.cts +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -172,20 +172,21 @@ const useTimelockConfig = () => {
|
|
|
172
172
|
|
|
173
173
|
//#endregion
|
|
174
174
|
//#region src/hooks/market/useMarketData.ts
|
|
175
|
+
const selectMarket = (data) => ({
|
|
176
|
+
...data.TimelockMarket[0],
|
|
177
|
+
pool: data.TimelockMarket[0].pool,
|
|
178
|
+
vault: data.TimelockMarket[0].vault,
|
|
179
|
+
optionAsset: data.TimelockMarket[0].optionAsset,
|
|
180
|
+
payoutAsset: data.TimelockMarket[0].payoutAsset,
|
|
181
|
+
optionsCount: BigInt(data.TimelockMarket[0].optionsCount),
|
|
182
|
+
tradersCount: BigInt(data.TimelockMarket[0].tradersCount)
|
|
183
|
+
});
|
|
175
184
|
const useMarketData = (marketAddr) => {
|
|
176
185
|
const { graphqlClient } = useTimelockConfig();
|
|
177
186
|
const { data } = useQuery({
|
|
178
187
|
queryKey: ["marketData", marketAddr || "--"],
|
|
179
188
|
queryFn: () => graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() }),
|
|
180
|
-
select:
|
|
181
|
-
...data$1.TimelockMarket[0],
|
|
182
|
-
pool: data$1.TimelockMarket[0].pool,
|
|
183
|
-
vault: data$1.TimelockMarket[0].vault,
|
|
184
|
-
optionAsset: data$1.TimelockMarket[0].optionAsset,
|
|
185
|
-
payoutAsset: data$1.TimelockMarket[0].payoutAsset,
|
|
186
|
-
optionsCount: BigInt(data$1.TimelockMarket[0].optionsCount),
|
|
187
|
-
tradersCount: BigInt(data$1.TimelockMarket[0].tradersCount)
|
|
188
|
-
}),
|
|
189
|
+
select: selectMarket,
|
|
189
190
|
enabled: !!marketAddr && !!graphqlClient
|
|
190
191
|
});
|
|
191
192
|
return data || {};
|
|
@@ -434,38 +435,39 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, duration) => {
|
|
|
434
435
|
|
|
435
436
|
//#endregion
|
|
436
437
|
//#region src/hooks/market/useUserOptions.ts
|
|
438
|
+
const selectOptions = (data) => {
|
|
439
|
+
if (!(data === null || data === void 0 ? void 0 : data.UserOption)) return [];
|
|
440
|
+
return data.UserOption.map((option) => ({
|
|
441
|
+
...option,
|
|
442
|
+
id: BigInt(option.id),
|
|
443
|
+
marketAddr: option.marketAddr,
|
|
444
|
+
optionType: option.optionType,
|
|
445
|
+
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
446
|
+
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
447
|
+
premiumPaid: BigInt(option.premiumPaid),
|
|
448
|
+
realizedPayout: BigInt(option.realizedPayout),
|
|
449
|
+
liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
|
|
450
|
+
liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
|
|
451
|
+
positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
|
|
452
|
+
positionSizeCurrent: BigInt(option.positionSizeCurrent),
|
|
453
|
+
strikePrice: BigInt(option.strikePrice),
|
|
454
|
+
entryPrice: BigInt(option.entryPrice)
|
|
455
|
+
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
456
|
+
};
|
|
437
457
|
const useUserOptions = (user, active = false) => {
|
|
438
458
|
const { graphqlClient } = useTimelockConfig();
|
|
439
|
-
const { data
|
|
459
|
+
const { data,...rest } = useQuery({
|
|
440
460
|
queryKey: [
|
|
441
461
|
"userTrades",
|
|
442
462
|
user || "--",
|
|
443
463
|
active
|
|
444
464
|
],
|
|
445
465
|
queryFn: () => active ? graphqlClient === null || graphqlClient === void 0 ? void 0 : graphqlClient.GetActiveUserOptions({ user: user.toLowerCase() }) : graphqlClient === null || graphqlClient === void 0 ? void 0 : graphqlClient.GetClosedUserOptions({ user: user.toLowerCase() }),
|
|
446
|
-
select:
|
|
447
|
-
var _data$UserOption;
|
|
448
|
-
return data === null || data === void 0 || (_data$UserOption = data.UserOption) === null || _data$UserOption === void 0 ? void 0 : _data$UserOption.map((option) => ({
|
|
449
|
-
...option,
|
|
450
|
-
id: BigInt(option.id),
|
|
451
|
-
marketAddr: option.marketAddr,
|
|
452
|
-
optionType: option.optionType,
|
|
453
|
-
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
454
|
-
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
455
|
-
premiumPaid: BigInt(option.premiumPaid),
|
|
456
|
-
realizedPayout: BigInt(option.realizedPayout),
|
|
457
|
-
liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
|
|
458
|
-
liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
|
|
459
|
-
positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
|
|
460
|
-
positionSizeCurrent: BigInt(option.positionSizeCurrent),
|
|
461
|
-
strikePrice: BigInt(option.strikePrice),
|
|
462
|
-
entryPrice: BigInt(option.entryPrice)
|
|
463
|
-
}));
|
|
464
|
-
},
|
|
466
|
+
select: selectOptions,
|
|
465
467
|
enabled: !!user && !!graphqlClient
|
|
466
468
|
});
|
|
467
469
|
return {
|
|
468
|
-
data:
|
|
470
|
+
data: data || [],
|
|
469
471
|
...rest
|
|
470
472
|
};
|
|
471
473
|
};
|