diff --git a/utils/convertToChartData.ts b/utils/convertToChartData.ts index d7bdce8..ea575f5 100644 --- a/utils/convertToChartData.ts +++ b/utils/convertToChartData.ts @@ -8,7 +8,6 @@ import { IncompleteSection, ApiChartData, } from "../types/adapters"; -import { PromisePool } from "@supercharge/promise-pool"; import fetch from "node-fetch"; import { RESOLUTION_SECONDS, @@ -385,36 +384,14 @@ function discreet(raw: RawResult, config: ChartConfig): ChartData { return { timestamps, unlocked, apiData, isContinuous: false }; } -export async function mapToServerData(testData: ChartSection[], token: string) { - const allTimestamps = [ - ...new Set( - testData - .map((s: ChartSection) => { - return s.data.timestamps; - }) - .flat(), - ), - ]; - const prices: Record = {}; - - await PromisePool.withConcurrency(20) - .for(allTimestamps) - .process(async (ts: any) => { - const res = await fetch( - `https://coins.llama.fi/prices/historical/${ts}/${token}`, - ) - .then((r: any) => r.json()) - .catch(() => null); - const price = res ? res?.coins[token]?.price : 0; - prices[ts] = price; - }); + +export function mapToServerData(testData: ChartSection[]) { const serverData: any[] = testData.map((s: ChartSection) => { const label = s.section; const data = s.data.timestamps.map((timestamp: number, i: number) => ({ timestamp, unlocked: s.data.unlocked[i], - price: prices[timestamp] ?? 0, })); return { label, data };