timelock-sdk 0.0.40 → 0.0.42

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
@@ -553,10 +553,11 @@ const getResolutionConfig = (resolution) => {
553
553
  const getPriceHistory = async (poolAddress, resolution, startTimestamp, endTimestamp) => {
554
554
  const network = "monad-testnet";
555
555
  const { timeframe, aggregate, seconds } = getResolutionConfig(resolution);
556
+ if (endTimestamp.getTime() > Date.now()) endTimestamp = new Date(Date.now());
556
557
  const startSecs = Math.floor(startTimestamp.getTime() / 1e3);
557
558
  const endSecs = Math.floor(endTimestamp.getTime() / 1e3);
558
559
  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}`;
560
+ const url = `https://api.geckoterminal.com/api/v2/networks/${network}/pools/${poolAddress}/ohlcv/${timeframe}?aggregate=${aggregate}&limit=${Math.min(Math.ceil(diffSeconds / seconds), 1e3)}&include_empty_intervals=true&token=quote&currency=usd&before_timestamp=${endSecs}`;
560
561
  const res = await fetch(url, { headers: { Accept: "application/json" } });
561
562
  if (!res.ok) throw new Error(`Failed to fetch price history: ${res.statusText}`);
562
563
  return (await res.json()).data.attributes.ohlcv_list.map(({ 0: timestamp, 4: price }) => ({