timelock-sdk 0.0.79 → 0.0.80

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
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
 
4
- const require_optionUtils = require('./optionUtils-CDD_7qmy.cjs');
4
+ const require_optionUtils = require('./optionUtils-DAjhbiQ5.cjs');
5
5
  const require_optionsMarket = require('./optionsMarket-DxGdV3HF.cjs');
6
6
  const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
7
7
  let viem = require("viem");
@@ -881,81 +881,6 @@ const useCurrentPrice = (poolAddr) => {
881
881
  }), [currentPrice, currentTick]);
882
882
  };
883
883
 
884
- //#endregion
885
- //#region src/lib/price.ts
886
- const getResolutionConfig = (resolution) => {
887
- return {
888
- "1m": {
889
- timeframe: "minute",
890
- aggregate: "1",
891
- seconds: 60
892
- },
893
- "5m": {
894
- timeframe: "minute",
895
- aggregate: "5",
896
- seconds: 300
897
- },
898
- "15m": {
899
- timeframe: "minute",
900
- aggregate: "15",
901
- seconds: 900
902
- },
903
- "1h": {
904
- timeframe: "hour",
905
- aggregate: "1",
906
- seconds: 3600
907
- },
908
- "4h": {
909
- timeframe: "hour",
910
- aggregate: "4",
911
- seconds: 14400
912
- },
913
- "1d": {
914
- timeframe: "day",
915
- aggregate: "1",
916
- seconds: 86400
917
- }
918
- }[resolution];
919
- };
920
- const fillGaps = (prices, start, end, intervalMs) => {
921
- if (prices.length === 0) return [];
922
- const priceMap = /* @__PURE__ */ new Map();
923
- for (const point of prices) {
924
- const alignedTime = Math.floor(point.timestamp.getTime() / intervalMs) * intervalMs;
925
- priceMap.set(alignedTime, point);
926
- }
927
- const filled = [];
928
- let currentTime = Math.floor(prices[0].timestamp.getTime() / intervalMs) * intervalMs;
929
- let lastKnownPrice = null;
930
- while (currentTime <= end.getTime()) {
931
- const existing = priceMap.get(currentTime);
932
- if (existing) {
933
- filled.push(existing);
934
- lastKnownPrice = existing;
935
- } else if (lastKnownPrice) filled.push({
936
- timestamp: new Date(currentTime),
937
- price: lastKnownPrice.price
938
- });
939
- currentTime += intervalMs;
940
- }
941
- return filled;
942
- };
943
- const getPriceHistory = async (poolAddress, resolution, start, end) => {
944
- const network = "monad-testnet";
945
- const { timeframe, aggregate, seconds } = getResolutionConfig(resolution);
946
- if (end.getTime() > Date.now()) end = new Date(Date.now());
947
- const startSecs = Math.floor(start.getTime() / 1e3);
948
- const endSecs = Math.floor(end.getTime() / 1e3);
949
- const diffSeconds = endSecs - startSecs;
950
- 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}`;
951
- const res = await fetch(url, { headers: { Accept: "application/json" } });
952
- if (!res.ok) throw new Error(`Failed to fetch price history: ${res.statusText}`);
953
- return fillGaps((await res.json()).data.attributes.ohlcv_list.map(([timestamp, , , , close]) => ({
954
- timestamp: /* @__PURE__ */ new Date(timestamp * 1e3),
955
- price: close
956
- })).sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime()), start, end, seconds * 1e3).filter((point) => point.timestamp.getTime() / 1e3 >= startSecs && point.timestamp.getTime() / 1e3 <= endSecs);
957
- };
958
-
959
884
  //#endregion
960
885
  //#region src/hooks/pool/usePriceHistory.ts
961
886
  const usePriceHistory = (pool, resolution, startTimestamp, endTimestamp) => {
@@ -968,7 +893,7 @@ const usePriceHistory = (pool, resolution, startTimestamp, endTimestamp) => {
968
893
  startTimestamp,
969
894
  endTimestamp
970
895
  ],
971
- queryFn: () => getPriceHistory(pool, resolution, startTimestamp, endTimestamp),
896
+ queryFn: () => require_optionUtils.getPriceHistory(pool, resolution, startTimestamp, endTimestamp),
972
897
  enabled: !!pool && startTimestamp < endTimestamp,
973
898
  staleTime: 60 * 1e3,
974
899
  gcTime: 300 * 1e3,