timelock-sdk 0.0.27 → 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 +39 -34
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +56 -56
- package/dist/client.d.ts +56 -56
- package/dist/client.js +39 -34
- package/dist/client.js.map +1 -1
- package/dist/{index-CRhFaRiq.d.ts → index-CA5kB-yT.d.cts} +2 -2
- package/dist/{index-B7b3c8cu.d.cts → index-DW-OoI-q.d.ts} +93 -93
- package/dist/package.d.cts +1 -1
- package/dist/package.d.ts +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -151,12 +151,18 @@ const TimelockMarketProvider = ({ children, marketData, envioGraphqlUrl }) => {
|
|
|
151
151
|
const chainId = (0, wagmi.useChainId)();
|
|
152
152
|
const lensAddr = require_numberUtils.timelockLenses[chainId];
|
|
153
153
|
const uniswapMathLensAddr = require_numberUtils.uniswapMathLenses[chainId];
|
|
154
|
-
|
|
154
|
+
const contextValue = (0, react.useMemo)(() => ({
|
|
155
155
|
marketData: marketData || {},
|
|
156
156
|
lensAddr,
|
|
157
157
|
uniswapMathLensAddr,
|
|
158
158
|
envioGraphqlUrl
|
|
159
|
-
}
|
|
159
|
+
}), [
|
|
160
|
+
marketData,
|
|
161
|
+
lensAddr,
|
|
162
|
+
uniswapMathLensAddr,
|
|
163
|
+
envioGraphqlUrl
|
|
164
|
+
]);
|
|
165
|
+
return /* @__PURE__ */ react.default.createElement(TimelockMarketContext.Provider, { value: contextValue }, children);
|
|
160
166
|
};
|
|
161
167
|
const useCurrentMarket = () => {
|
|
162
168
|
const context = (0, react.useContext)(TimelockMarketContext);
|
|
@@ -179,21 +185,22 @@ const useTimelockConfig = () => {
|
|
|
179
185
|
|
|
180
186
|
//#endregion
|
|
181
187
|
//#region src/hooks/market/useMarketData.ts
|
|
182
|
-
const selectMarket = (data) => ({
|
|
183
|
-
...data.TimelockMarket[0],
|
|
184
|
-
pool: data.TimelockMarket[0].pool,
|
|
185
|
-
vault: data.TimelockMarket[0].vault,
|
|
186
|
-
optionAsset: data.TimelockMarket[0].optionAsset,
|
|
187
|
-
payoutAsset: data.TimelockMarket[0].payoutAsset,
|
|
188
|
-
optionsCount: BigInt(data.TimelockMarket[0].optionsCount),
|
|
189
|
-
tradersCount: BigInt(data.TimelockMarket[0].tradersCount)
|
|
190
|
-
});
|
|
191
188
|
const useMarketData = (marketAddr) => {
|
|
192
189
|
const { graphqlClient } = useTimelockConfig();
|
|
193
190
|
const { data } = (0, __tanstack_react_query.useQuery)({
|
|
194
191
|
queryKey: ["marketData", marketAddr || "--"],
|
|
195
|
-
queryFn: () =>
|
|
196
|
-
|
|
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
|
+
},
|
|
197
204
|
enabled: !!marketAddr && !!graphqlClient
|
|
198
205
|
});
|
|
199
206
|
return data || {};
|
|
@@ -442,25 +449,6 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, duration) => {
|
|
|
442
449
|
|
|
443
450
|
//#endregion
|
|
444
451
|
//#region src/hooks/market/useUserOptions.ts
|
|
445
|
-
const selectOptions = (data) => {
|
|
446
|
-
if (!(data === null || data === void 0 ? void 0 : data.UserOption)) return [];
|
|
447
|
-
return data.UserOption.map((option) => ({
|
|
448
|
-
...option,
|
|
449
|
-
id: BigInt(option.id),
|
|
450
|
-
marketAddr: option.marketAddr,
|
|
451
|
-
optionType: option.optionType,
|
|
452
|
-
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
453
|
-
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
454
|
-
premiumPaid: BigInt(option.premiumPaid),
|
|
455
|
-
realizedPayout: BigInt(option.realizedPayout),
|
|
456
|
-
liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
|
|
457
|
-
liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
|
|
458
|
-
positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
|
|
459
|
-
positionSizeCurrent: BigInt(option.positionSizeCurrent),
|
|
460
|
-
strikePrice: BigInt(option.strikePrice),
|
|
461
|
-
entryPrice: BigInt(option.entryPrice)
|
|
462
|
-
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
463
|
-
};
|
|
464
452
|
const useUserOptions = (user, active = false) => {
|
|
465
453
|
const { graphqlClient } = useTimelockConfig();
|
|
466
454
|
const { data,...rest } = (0, __tanstack_react_query.useQuery)({
|
|
@@ -469,8 +457,25 @@ const useUserOptions = (user, active = false) => {
|
|
|
469
457
|
user || "--",
|
|
470
458
|
active
|
|
471
459
|
],
|
|
472
|
-
queryFn: () =>
|
|
473
|
-
|
|
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
|
+
},
|
|
474
479
|
enabled: !!user && !!graphqlClient
|
|
475
480
|
});
|
|
476
481
|
return {
|