timelock-sdk 0.0.35 → 0.0.37

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 CHANGED
@@ -27,6 +27,7 @@ const GetActiveUserOptionsDocument = graphql_tag.default`
27
27
  limit: 1000
28
28
  ) {
29
29
  id
30
+ optionId
30
31
  ownerAddr
31
32
  exerciseEvents {
32
33
  transactionHash
@@ -60,6 +61,7 @@ const GetClosedUserOptionsDocument = graphql_tag.default`
60
61
  limit: 1000
61
62
  ) {
62
63
  id
64
+ optionId
63
65
  ownerAddr
64
66
  exerciseEvents {
65
67
  transactionHash
@@ -231,7 +233,7 @@ const useExerciseOption = (marketAddr) => {
231
233
  abi: require_optionsMarket.optionsMarketAbi,
232
234
  functionName: "exerciseOption",
233
235
  args: [
234
- option.id,
236
+ option.optionId,
235
237
  liquidities,
236
238
  0n,
237
239
  refTick
@@ -460,7 +462,7 @@ const useUserOptions = (user, active = false) => {
460
462
  if (!graphqlClient) return [];
461
463
  return (active ? await graphqlClient.GetActiveUserOptions({ user: user.toLowerCase() }) : await graphqlClient.GetClosedUserOptions({ user: user.toLowerCase() })).UserOption.map((option) => ({
462
464
  ...option,
463
- id: BigInt(option.id),
465
+ optionId: BigInt(option.optionId),
464
466
  marketAddr: option.marketAddr,
465
467
  optionType: option.optionType,
466
468
  createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
@@ -551,30 +553,32 @@ const resolutionToGeckoTerminal = (resolution) => {
551
553
  const getPriceHistory = async (poolAddress, resolution, startTimestamp, endTimestamp) => {
552
554
  const network = "monad-testnet";
553
555
  const { timeframe, aggregate, seconds } = resolutionToGeckoTerminal(resolution);
554
- const timeDiff = endTimestamp - startTimestamp;
555
- const url = `https://api.geckoterminal.com/api/v2/networks/${network}/pools/${poolAddress}/ohlcv/${timeframe}?aggregate=${aggregate}&limit=${Math.min(Math.ceil(timeDiff / seconds), 1e3)}&token=quote&currency=usd&before_timestamp=${endTimestamp}`;
556
+ const startSecs = Math.floor(startTimestamp.getTime() / 1e3);
557
+ const endSecs = Math.floor(endTimestamp.getTime() / 1e3);
558
+ const diffSeconds = endSecs - startSecs;
559
+ const url = `https://api.geckoterminal.com/api/v2/networks/${network}/pools/${poolAddress}/ohlcv/${timeframe}?aggregate=${aggregate}&limit=${Math.min(Math.ceil(diffSeconds / seconds), 1e3)}&token=quote&currency=usd&before_timestamp=${endSecs}`;
556
560
  const res = await fetch(url, { headers: { Accept: "application/json" } });
557
561
  if (!res.ok) throw new Error(`Failed to fetch price history: ${res.statusText}`);
558
562
  return (await res.json()).data.attributes.ohlcv_list.map(({ 0: timestamp, 4: price }) => ({
559
563
  timestamp,
560
564
  price
561
- })).filter((point) => point.timestamp >= startTimestamp && point.timestamp <= endTimestamp).sort((a, b) => a.timestamp - b.timestamp);
565
+ })).filter((point) => point.timestamp >= startSecs && point.timestamp <= endSecs).sort((a, b) => a.timestamp - b.timestamp);
562
566
  };
563
567
 
564
568
  //#endregion
565
569
  //#region src/hooks/pool/usePriceHistory.ts
566
- const usePriceHistory = ({ poolAddress, resolution, startTimestamp, endTimestamp, enabled = true }) => {
570
+ const usePriceHistory = (pool, resolution, startTimestamp, endTimestamp) => {
567
571
  return (0, __tanstack_react_query.useQuery)({
568
572
  queryKey: [
569
573
  "priceHistory",
570
- poolAddress,
574
+ pool,
571
575
  (0, wagmi.useChainId)(),
572
576
  resolution,
573
577
  startTimestamp,
574
578
  endTimestamp
575
579
  ],
576
- queryFn: () => getPriceHistory(poolAddress, resolution, startTimestamp, endTimestamp),
577
- enabled: enabled && !!poolAddress && startTimestamp < endTimestamp,
580
+ queryFn: () => getPriceHistory(pool, resolution, startTimestamp, endTimestamp),
581
+ enabled: !!pool && startTimestamp < endTimestamp,
578
582
  staleTime: 60 * 1e3,
579
583
  gcTime: 300 * 1e3,
580
584
  retry: 2