diff --git a/aggregator-derivatives/logx-aggregator/index.ts b/aggregator-derivatives/logx-aggregator/index.ts index c498f199d7..badc642553 100644 --- a/aggregator-derivatives/logx-aggregator/index.ts +++ b/aggregator-derivatives/logx-aggregator/index.ts @@ -13,7 +13,7 @@ interface IAPIResponse { const fetch = async (timestamp: number): Promise => { const { dailyVolume, totalVolume }: IAPIResponse = ( await fetchURL(`${URL}${endpoint}${timestamp}`) - ).data; + ); return { dailyVolume, totalVolume, diff --git a/aggregators/1inch-agg/index.ts b/aggregators/1inch-agg/index.ts index c38e0718e5..b1e0f1adbe 100644 --- a/aggregators/1inch-agg/index.ts +++ b/aggregators/1inch-agg/index.ts @@ -16,16 +16,10 @@ const chainsMap: Record = { const fetch = (chain: string) => - async (_: number): Promise => { - const unixTimestamp = getUniqStartOfTodayTimestamp(); - - try { - const data = ( - await fetchURLWithRetry( - `https://api.dune.com/api/v1/query/1736855/results` - ) - ).data; - const chainData = data?.result?.rows?.find( + async (_: number): Promise => { + const unixTimestamp = getUniqStartOfTodayTimestamp(); + const data = await fetchURLWithRetry(`https://api.dune.com/api/v1/query/1736855/results`) + const chainData = data.result.rows.find( (row: any) => chainsMap[row.blockchain] === chain ); @@ -33,13 +27,7 @@ const fetch = dailyVolume: chainData.volume_24h, timestamp: unixTimestamp, }; - } catch (e) { - return { - dailyVolume: "0", - timestamp: unixTimestamp, - }; - } - }; + }; const adapter: any = { adapter: { diff --git a/aggregators/aftermath-aggregator/index.ts b/aggregators/aftermath-aggregator/index.ts index b4aed5a06e..3532e08920 100644 --- a/aggregators/aftermath-aggregator/index.ts +++ b/aggregators/aftermath-aggregator/index.ts @@ -7,7 +7,7 @@ const URL = "https://aftermath.finance/api/router/volume-24hrs"; const fetch = async (timestamp: number): Promise => { const dailyVolume = ( await fetchURL(`${URL}`) - ).data; + ); return { dailyVolume, diff --git a/aggregators/avnu/index.ts b/aggregators/avnu/index.ts index fd45fa14da..9577584512 100644 --- a/aggregators/avnu/index.ts +++ b/aggregators/avnu/index.ts @@ -14,7 +14,7 @@ interface IAPIResponse { } const fetch = async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const {dailyVolume, totalVolume}: IAPIResponse = (await fetchURL(`${URL}${endpoint}${timestamp * 1000}`)).data; + const {dailyVolume, totalVolume}: IAPIResponse = (await fetchURL(`${URL}${endpoint}${timestamp * 1000}`)); return { dailyVolume, totalVolume, diff --git a/aggregators/conveyor/index.ts b/aggregators/conveyor/index.ts index cf9a668133..f2dc19f517 100644 --- a/aggregators/conveyor/index.ts +++ b/aggregators/conveyor/index.ts @@ -13,15 +13,10 @@ const chainsMap: Record = { const fetch = (chain: string) => - async (_: number): Promise => { - const unixTimestamp = getUniqStartOfTodayTimestamp(); + async (_: number): Promise => { + const unixTimestamp = getUniqStartOfTodayTimestamp(); - try { - const data = ( - await fetchURLWithRetry( - `https://api.dune.com/api/v1/query/3325921/results` - ) - ).data; + const data = await fetchURLWithRetry(`https://api.dune.com/api/v1/query/3325921/results`) const chainData = data?.result?.rows?.find( (row: any) => chainsMap[row.blockchain] === chain ); @@ -30,13 +25,7 @@ const fetch = dailyVolume: chainData.volume_24h, timestamp: unixTimestamp, }; - } catch (e) { - return { - dailyVolume: "0", - timestamp: unixTimestamp, - }; - } - }; + }; const adapter: any = { adapter: { diff --git a/aggregators/cowswap/index.ts b/aggregators/cowswap/index.ts index ddcf35419f..27f50a0d18 100644 --- a/aggregators/cowswap/index.ts +++ b/aggregators/cowswap/index.ts @@ -9,17 +9,10 @@ const chainsMap: Record = { const fetch = () => - async (timestamp: number): Promise => { - const unixTimestamp = getUniqStartOfTodayTimestamp( - new Date(timestamp * 1000) - ); + async (timestamp: number): Promise => { + const unixTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - try { - const data = ( - await fetchURLWithRetry( - "https://api.dune.com/api/v1/query/3321375/results" - ) - ).data; + const data = await fetchURLWithRetry("https://api.dune.com/api/v1/query/3321375/results") const chainData = data?.result?.rows.find( ({ aggregate_by }: { aggregate_by: string }) => getUniqStartOfTodayTimestamp(new Date(aggregate_by)) === unixTimestamp @@ -29,13 +22,7 @@ const fetch = dailyVolume: chainData?.volume ?? "0", timestamp: unixTimestamp, }; - } catch (e) { - return { - dailyVolume: "0", - timestamp: unixTimestamp, - }; - } - }; + }; const adapter: any = { adapter: { diff --git a/aggregators/deflex/index.ts b/aggregators/deflex/index.ts index 579750cc33..a03aac68b8 100644 --- a/aggregators/deflex/index.ts +++ b/aggregators/deflex/index.ts @@ -10,7 +10,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse[] = (await fetchURL(URL)).data.last_24h; + const response: IAPIResponse[] = (await fetchURL(URL)).last_24h; return { dailyVolume: `${response.reduce((prev: number, current: any) => current.volume + prev, 0)}`, timestamp: dayTimestamp, diff --git a/aggregators/dexhunter/index.ts b/aggregators/dexhunter/index.ts index 983101a567..154dba05a1 100644 --- a/aggregators/dexhunter/index.ts +++ b/aggregators/dexhunter/index.ts @@ -14,7 +14,7 @@ interface IAPIResponse { const fetchData = async (period: '24h' | 'all'): Promise => { const response = await postURL(`${URL}${endpoint}`, { period }); - const data: IAPIResponse[] = response.data; + const data: IAPIResponse[] = response; const dexhunterData = data.find(d => d.is_dexhunter); if (!dexhunterData) { diff --git a/aggregators/dforce/index.ts b/aggregators/dforce/index.ts index 0c47a8c0b1..a155d37fc7 100644 --- a/aggregators/dforce/index.ts +++ b/aggregators/dforce/index.ts @@ -22,7 +22,7 @@ interface IAPIResponse { }; const fetch = (chain: string) => async (timestamp: number) => { - const response: IAPIResponse = (await fetchURL(endpoints[chain])).data; + const response: IAPIResponse = (await fetchURL(endpoints[chain])); const totalDailyVolume = response.data.preChain.reduce((acc,cur) => {return acc + parseInt(cur.volume)/10**18}, 0) const t = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) return { diff --git a/aggregators/jupiter-aggregator/index.ts b/aggregators/jupiter-aggregator/index.ts index d2bc121878..d9027ee180 100644 --- a/aggregators/jupiter-aggregator/index.ts +++ b/aggregators/jupiter-aggregator/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volumeInUSD; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.volumeInUSD; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.groupTimestamp).getTime() / 1000) <= dayTimestamp) .reduce((acc, { amount }) => acc + Number(amount), 0) @@ -31,7 +31,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volumeInUSD; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.volumeInUSD; return (new Date(historicalVolume[historicalVolume.length - 1].groupTimestamp).getTime() / 1000); } const adapter: SimpleAdapter = { diff --git a/aggregators/kanalabs/index.ts b/aggregators/kanalabs/index.ts index 915601054f..2d9cc8e693 100644 --- a/aggregators/kanalabs/index.ts +++ b/aggregators/kanalabs/index.ts @@ -5,7 +5,7 @@ import { CHAIN } from "../../helpers/chains"; const URL = "https://stats.kanalabs.io/volume"; const fetch = async (timestamp: number): Promise => { - const dailyVolume = (await fetchURL(`${URL}?chainId=1`)).data.data; + const dailyVolume = (await fetchURL(`${URL}?chainId=1`)).data; return { timestamp, dailyVolume: dailyVolume.today.volume, diff --git a/aggregators/kyberswap/index.ts b/aggregators/kyberswap/index.ts index 1a1440ff94..8cc2d3f96d 100644 --- a/aggregators/kyberswap/index.ts +++ b/aggregators/kyberswap/index.ts @@ -40,7 +40,7 @@ const fetch = (chain: string) => async (timestamp: number) => { await fetchURL( `https://common-service.kyberswap.com/api/v1/aggregator/volume/daily?chainId=${chainToId[chain]}×tamps=${unixTimestamp}` ) - ).data.data?.volumes?.[0]; + ).data?.volumes?.[0]; return { dailyVolume: data?.value ?? "0", diff --git a/aggregators/llamaswap/index.ts b/aggregators/llamaswap/index.ts index f56ebe87b9..bce146184a 100644 --- a/aggregators/llamaswap/index.ts +++ b/aggregators/llamaswap/index.ts @@ -52,8 +52,8 @@ const fetch = ); return { - dailyVolume: dailyVolume.data.volume || "0", - totalVolume: totalVolume.data.volume || "0", + dailyVolume: dailyVolume.volume || "0", + totalVolume: totalVolume.volume || "0", timestamp: dayTimestamp, }; } catch (e) { diff --git a/aggregators/logx/index.ts b/aggregators/logx/index.ts index c498f199d7..badc642553 100644 --- a/aggregators/logx/index.ts +++ b/aggregators/logx/index.ts @@ -13,7 +13,7 @@ interface IAPIResponse { const fetch = async (timestamp: number): Promise => { const { dailyVolume, totalVolume }: IAPIResponse = ( await fetchURL(`${URL}${endpoint}${timestamp}`) - ).data; + ); return { dailyVolume, totalVolume, diff --git a/aggregators/openocean/index.tsx b/aggregators/openocean/index.tsx index 41d3c22fe8..c9591acfe8 100644 --- a/aggregators/openocean/index.tsx +++ b/aggregators/openocean/index.tsx @@ -39,7 +39,7 @@ const fetch = ); return { - dailyVolume: data.data.data[chainsMap[chain] || chain]?.volume, + dailyVolume: data.data[chainsMap[chain] || chain]?.volume, timestamp: unixTimestamp, }; } catch (e) { diff --git a/aggregators/plexus/index.ts b/aggregators/plexus/index.ts index e6811edbf6..5355d8278e 100644 --- a/aggregators/plexus/index.ts +++ b/aggregators/plexus/index.ts @@ -29,7 +29,7 @@ const fetch = (chainId: number) => { await fetchURL( `https://api.plexus.app/v1/dashboard/volume?date=${dateString}` ) - ).data.data; + ).data; const dailyVolume: number = data[chainId] || 0; return { dailyVolume: dailyVolume.toString(), diff --git a/aggregators/swapgpt/index.ts b/aggregators/swapgpt/index.ts index 1048e2f9e7..c9414769c3 100644 --- a/aggregators/swapgpt/index.ts +++ b/aggregators/swapgpt/index.ts @@ -16,7 +16,7 @@ const endpoint = "stats/getDefiLamaStats" const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(`${baseUrl}/${endpoint}`))?.data.volumeInUsd + const historicalVolume: IVolumeall[] = (await fetchURL(`${baseUrl}/${endpoint}`))?.volumeInUsd const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.grouptimestamp).getTime() / 1000) <= dayTimestamp) .reduce((acc, { amount }) => acc + Number(amount), 0) diff --git a/aggregators/unidex/index.ts b/aggregators/unidex/index.ts index f7946141cd..2da1e4e6d7 100644 --- a/aggregators/unidex/index.ts +++ b/aggregators/unidex/index.ts @@ -18,15 +18,10 @@ const chainsMap: Record = { const fetch = (chain: string) => - async (_: number): Promise => { - const unixTimestamp = getUniqStartOfTodayTimestamp(); + async (_: number): Promise => { + const unixTimestamp = getUniqStartOfTodayTimestamp(); - try { - const response = ( - await fetchURLWithRetry( - `https://unidexswaps.metabaseapp.com/api/public/dashboard/f0dd81ef-7bc7-47b5-9ac4-281c7cd71bdc/dashcard/11/card/12?parameters=%5B%5D` - ) - ).data; + const response = await fetchURLWithRetry(`https://unidexswaps.metabaseapp.com/api/public/dashboard/f0dd81ef-7bc7-47b5-9ac4-281c7cd71bdc/dashcard/11/card/12?parameters=%5B%5D`) const rows = response.data.rows; const chainData = rows.find( @@ -37,13 +32,7 @@ const fetch = dailyVolume: chainData ? chainData[2].toString() : "0", timestamp: unixTimestamp, }; - } catch (e) { - return { - dailyVolume: "0", - timestamp: unixTimestamp, - }; - } - }; + }; const adapter: any = { adapter: { diff --git a/aggregators/yield-yak/index.ts b/aggregators/yield-yak/index.ts index 72383e5f04..5cf9c92fe5 100644 --- a/aggregators/yield-yak/index.ts +++ b/aggregators/yield-yak/index.ts @@ -15,37 +15,18 @@ const fetch = (chain: string) => async (timestamp: number) => { new Date(timestamp * 1000) ); - try { - const data = await ( - await fetchURLWithRetry( - "https://api.dune.com/api/v1/query/3321376/results" - ) - ).data?.result?.rows; - const dayData = data.find( - ({ - block_date, - blockchain, - project, - }: { - block_date: number; - blockchain: string; - project: string; - }) => - getUniqStartOfTodayTimestamp(new Date(block_date)) === unixTimestamp && - blockchain === (chainMap[chain] || chain) && - project === NAME - ); + const data = (await fetchURLWithRetry("https://api.dune.com/api/v1/query/3321376/results")).result?.rows; + const dayData = data.find( + ({ block_date, blockchain, project, }: { block_date: number; blockchain: string; project: string; }) => + getUniqStartOfTodayTimestamp(new Date(block_date)) === unixTimestamp && + blockchain === (chainMap[chain] || chain) && + project === NAME + ); - return { - dailyVolume: dayData?.trade_amount ?? "0", - timestamp: unixTimestamp, - }; - } catch (e) { - return { - dailyVolume: "0", - timestamp: unixTimestamp, - }; - } + return { + dailyVolume: dayData?.trade_amount ?? "0", + timestamp: unixTimestamp, + }; }; const adapter: any = { diff --git a/dexs/10kswap/index.ts b/dexs/10kswap/index.ts index b77d9e0f35..e665e4cd98 100644 --- a/dexs/10kswap/index.ts +++ b/dexs/10kswap/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.volumes; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volumes; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date).getTime() / 1000) <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) diff --git a/dexs/4swap/index.ts b/dexs/4swap/index.ts index f7712ce71e..b27b5bcbed 100644 --- a/dexs/4swap/index.ts +++ b/dexs/4swap/index.ts @@ -12,7 +12,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse[] = (await fetchURL(URL))?.data?.data.pairs; + const response: IAPIResponse[] = (await fetchURL(URL))?.data.pairs; const dailyVolume = response .reduce((acc, { volume_24h }) => acc + Number(volume_24h), 0); diff --git a/dexs/ICDex/index.ts b/dexs/ICDex/index.ts index 4bf92ed027..9d78b135b0 100644 --- a/dexs/ICDex/index.ts +++ b/dexs/ICDex/index.ts @@ -4,7 +4,7 @@ import fetchURL from "../../utils/fetchURL"; const fetch = async (timestamp: number): Promise => { - let historicalVolume = (await fetchURL('https://gwhbq-7aaaa-aaaar-qabya-cai.raw.icp0.io/v1/latest')).data; + let historicalVolume = (await fetchURL('https://gwhbq-7aaaa-aaaar-qabya-cai.raw.icp0.io/v1/latest')); let dailyVolume = 0; let totalVolume = 0; for (let key in historicalVolume) { diff --git a/dexs/MantisSwap/index.ts b/dexs/MantisSwap/index.ts index 4c541b46fd..4ccb415fef 100644 --- a/dexs/MantisSwap/index.ts +++ b/dexs/MantisSwap/index.ts @@ -14,7 +14,7 @@ const fetch = (chain: string) => async (timestamp: number) => { await fetchURL( `https://api.mantissa.finance/api/pool/stats/volume/${chain}/?from_timestamp=${from}&to_timestamp=${to}` ) - ).data; + ); return { totalVolume: `${stats.total_volume}`, dailyVolume: `${stats.daily_volume}`, diff --git a/dexs/aark/index.ts b/dexs/aark/index.ts index 44f315d190..d564fa2873 100644 --- a/dexs/aark/index.ts +++ b/dexs/aark/index.ts @@ -8,7 +8,7 @@ const endpoint = "https://api.aark.digital/stats/volume/futures"; const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const res = (await fetchURL(`${endpoint}/${timestamp}`))?.data + const res = (await fetchURL(`${endpoint}/${timestamp}`)) return { totalVolume: res.data.totalVolume, diff --git a/dexs/aevo/index.ts b/dexs/aevo/index.ts index 945f6fe8d3..41c84f5297 100644 --- a/dexs/aevo/index.ts +++ b/dexs/aevo/index.ts @@ -39,7 +39,7 @@ export async function fetchAevoVolumeData( } async function getAevoVolumeData(endpoint: string): Promise { - return (await fetchURL(endpoint))?.data; + return (await fetchURL(endpoint)); } export default adapter; diff --git a/dexs/aftermath-fi-amm/index.ts b/dexs/aftermath-fi-amm/index.ts index aef2c781fe..6df60315e8 100644 --- a/dexs/aftermath-fi-amm/index.ts +++ b/dexs/aftermath-fi-amm/index.ts @@ -7,7 +7,7 @@ const URL = "https://aftermath.finance/api/pools/volume-24hrs"; const fetch = async (timestamp: number): Promise => { const dailyVolume = ( await fetchURL(`${URL}`) - ).data; + ); return { dailyVolume, diff --git a/dexs/alex/index.ts b/dexs/alex/index.ts index 462639ee84..c222e8efed 100644 --- a/dexs/alex/index.ts +++ b/dexs/alex/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.data.rows; + const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint)).data.rows; const historicalVolume: IVolumeall[] = callhistoricalVolume.map((e: string[] | number[]) => { const [time, volume] = e; return { @@ -38,7 +38,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.data.rows; + const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint)).data.rows; const historicalVolume: IVolumeall[] = callhistoricalVolume.map((e: string[] | number[]) => { const [time, volume] = e; return { diff --git a/dexs/algofi/index.ts b/dexs/algofi/index.ts index 7f717b35b3..67fe48661a 100644 --- a/dexs/algofi/index.ts +++ b/dexs/algofi/index.ts @@ -12,7 +12,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse = (await fetchURL(URL))?.data.amm.volume.day; + const response: IAPIResponse = (await fetchURL(URL)).amm.volume.day; return { dailyVolume: `${response}`, diff --git a/dexs/allbridge-classic/index.ts b/dexs/allbridge-classic/index.ts index 67b65bb2f6..e572cdfed3 100644 --- a/dexs/allbridge-classic/index.ts +++ b/dexs/allbridge-classic/index.ts @@ -10,7 +10,7 @@ interface ChainData { const getVolume = async (chainCode: string, fromDate: string, toDate: string): Promise => { const url = `https://stats.a11bd.net/aggregated?dateFrom=${fromDate}&dateTo=${toDate}`; - const responseBody = (await fetchURL(url)).data; + const responseBody = (await fetchURL(url)); const chainData = responseBody.data.chains .filter((d: ChainData) => d.id === chainCode) .pop(); diff --git a/dexs/apex/index.ts b/dexs/apex/index.ts index 5c76395c5c..a1f3890cbc 100644 --- a/dexs/apex/index.ts +++ b/dexs/apex/index.ts @@ -49,10 +49,10 @@ interface IOpenInterest { const getVolume = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) const historical: any[] = (await Promise.all(symbol.map((coins: string) => fetchURL(historicalVolumeEndpoint(coins, dayTimestamp + 60 * 60 * 24))))) - .map((e: any) => Object.values(e.data.data)).flat().flat() + .map((e: any) => Object.values(e.data)).flat().flat() .map((e: any) => { return { timestamp: e.t / 1000, volume: e.v, price: e.c } }); const openInterestHistorical: IOpenInterest[] = (await Promise.all(symbol.map((coins: string) => fetchURL(allTiker(coins))))) - .map((e: any) => e.data.data).flat().map((e: any) => { return { id: e.symbol, openInterest: e.openInterest, lastPrice: e.lastPrice } }); + .map((e: any) => e.data).flat().map((e: any) => { return { id: e.symbol, openInterest: e.openInterest, lastPrice: e.lastPrice } }); const dailyOpenInterest = openInterestHistorical.reduce((a: number, { openInterest, lastPrice }) => a + Number(openInterest) * Number(lastPrice), 0); const historicalUSD = historical.map((e: IVolumeall) => { return { diff --git a/dexs/arctic/index.ts b/dexs/arctic/index.ts index 476ef8449d..89e49c1289 100644 --- a/dexs/arctic/index.ts +++ b/dexs/arctic/index.ts @@ -23,7 +23,7 @@ const chains: TChains = { const fetch = (chain: Chain) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historical: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chains[chain])))?.data.data; + const historical: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chains[chain])))?.data; const historicalVolume = historical.filter(e => e.chainId === chains[chain]); const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.timestamp).getTime()) <= dayTimestamp) @@ -41,7 +41,7 @@ const fetch = (chain: Chain) => { }; const getStartTimestamp = async (chain_id: number) => { - const historical: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chain_id)))?.data.data; + const historical: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chain_id)))?.data; const historicalVolume = historical.filter(e => e.chainId === chain_id); return (new Date(historicalVolume[historicalVolume.length - 1].timestamp).getTime()); } diff --git a/dexs/astroport-v2/index.ts b/dexs/astroport-v2/index.ts index eeffb1edba..7a34f187af 100644 --- a/dexs/astroport-v2/index.ts +++ b/dexs/astroport-v2/index.ts @@ -20,7 +20,7 @@ const url = 'https://app.astroport.fi/api/trpc/protocol.stats?input={"json":{"ch const fetch = (chainId: string) => { return async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const results = (await fetchURL(url)).data?.result.data.json.chains[chainId]; + const results = (await fetchURL(url)).result.data.json.chains[chainId]; const totalVolume24h = results?.dayVolumeUSD; return { timestamp: dayTimestamp, diff --git a/dexs/axial/index.ts b/dexs/axial/index.ts index ab32d65452..b6cf35f1bf 100644 --- a/dexs/axial/index.ts +++ b/dexs/axial/index.ts @@ -11,7 +11,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse[] = (await fetchURL(URL))?.data; + const response: IAPIResponse[] = (await fetchURL(URL)); const dailyVolume = response .reduce((acc, { last_vol }) => acc + Number(last_vol), 0); diff --git a/dexs/bancor/index.ts b/dexs/bancor/index.ts index fe091bba99..303b1e481c 100644 --- a/dexs/bancor/index.ts +++ b/dexs/bancor/index.ts @@ -28,7 +28,7 @@ const endpoints = { }; const fetchV3 = async (timestamp: number): Promise => { - const res: BancorV3Response = (await fetchURL(v3Url)).data.data.totalVolume24h; + const res: BancorV3Response = (await fetchURL(v3Url)).data.totalVolume24h; return { timestamp, dailyVolume: res.usd @@ -40,7 +40,7 @@ const graphs = (chain: string) => const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) switch (chain) { case "ethereum": - return fetchURL(endpoints.ethereum(dayTimestamp)).then((res: any) => res.data) + return fetchURL(endpoints.ethereum(dayTimestamp)) .then(({ data }: BancorV2Response) => { const volume = data.find(item => (item.timestamp / 1000) === dayTimestamp) if (!volume) throw new Error(`Unexpected error: No volume found for ${dayTimestamp}`) diff --git a/dexs/baryon/index.ts b/dexs/baryon/index.ts index 1225a5332e..91f88faf14 100644 --- a/dexs/baryon/index.ts +++ b/dexs/baryon/index.ts @@ -12,8 +12,8 @@ const graphs: Fetch = async (_timestamp: number) => { return { timestamp: Math.trunc(Date.now() / 1000), - dailyVolume: res?.data?.volume24h, - totalVolume: res?.data?.totalvolume, + dailyVolume: res?.volume24h, + totalVolume: res?.totalvolume, }; }; diff --git a/dexs/bisq/index.ts b/dexs/bisq/index.ts index 1df374ae1c..ec35283590 100644 --- a/dexs/bisq/index.ts +++ b/dexs/bisq/index.ts @@ -13,7 +13,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const totalVolume = historicalVolume .filter(volItem => volItem.period_start <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) diff --git a/dexs/bitkeep/index.ts b/dexs/bitkeep/index.ts index cba2b83476..2135b6c0fd 100644 --- a/dexs/bitkeep/index.ts +++ b/dexs/bitkeep/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const graph = (chain: Chain) => { return async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint + `?chain=${chain}`))?.data.data.list; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint + `?chain=${chain}`))?.data.list; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date).getTime() / 1000) <= dayTimestamp) diff --git a/dexs/bogged-finance/index.ts b/dexs/bogged-finance/index.ts index 8250d0ef1b..f64199c2c4 100644 --- a/dexs/bogged-finance/index.ts +++ b/dexs/bogged-finance/index.ts @@ -26,7 +26,7 @@ const chains: TChains = { const fetch = (chain: Chain) => { return async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chains[chain])))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chains[chain]))); const totalVolume = historicalVolume .filter(volItem => Math.floor(Number(volItem.timestamp)/1000) <= dayTimestamp) .reduce((acc, { dailyVolume }) => acc + Number(dailyVolume), 0) @@ -43,7 +43,7 @@ const fetch = (chain: Chain) => { }; const getStartTimestamp = async (chain: string) => { - const historical: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chains[chain])))?.data; + const historical: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(chains[chain]))); return (new Date(historical[0].timestamp).getTime() / 1000); } diff --git a/dexs/brine/index.ts b/dexs/brine/index.ts index a9edfd1e59..86ebeba2ff 100644 --- a/dexs/brine/index.ts +++ b/dexs/brine/index.ts @@ -5,7 +5,7 @@ import { CHAIN } from "../../helpers/chains"; const VOLUME_URL = `https://api.brine.fi/external-aggregator/defillama/volume24/`; const fetch = async (timestamp: number) => { - const dailyVolume = (await fetchURL(`${VOLUME_URL}?timestamp=${timestamp}`)).data.payload.volume; + const dailyVolume = (await fetchURL(`${VOLUME_URL}?timestamp=${timestamp}`)).payload.volume; return { dailyVolume, timestamp, diff --git a/dexs/caviarnine-lsu-pool/index.ts b/dexs/caviarnine-lsu-pool/index.ts index fe7d6b81f3..5fa0b68355 100644 --- a/dexs/caviarnine-lsu-pool/index.ts +++ b/dexs/caviarnine-lsu-pool/index.ts @@ -20,7 +20,7 @@ interface CaviarNineLSUPool { }; } const fetchFees = async (timestamp: number): Promise => { - const response: CaviarNineLSUPool = (await fetchURL("https://api-core.caviarnine.com/v1.0/stats/product/lsupool")).data.summary; + const response: CaviarNineLSUPool = (await fetchURL("https://api-core.caviarnine.com/v1.0/stats/product/lsupool")).summary; const dailyVolume = Number(response.volume.interval_1d.usd); return { dailyVolume: `${dailyVolume}`, diff --git a/dexs/caviarnine/index.ts b/dexs/caviarnine/index.ts index 8d78c6ccdf..2a6c999f99 100644 --- a/dexs/caviarnine/index.ts +++ b/dexs/caviarnine/index.ts @@ -9,14 +9,14 @@ const url_trades = 'https://api-core.caviarnine.com/v1.0/stats/product/shapeliqu const fetchSpot = async (timestamp: number): Promise => { let dailyVolume = 0; try { - const orderbookVolume = (await fetchURL(url_orderbook)).data.summary.volume.interval_1d.usd; + const orderbookVolume = (await fetchURL(url_orderbook)).summary.volume.interval_1d.usd; dailyVolume += Number(orderbookVolume); } catch (e) { console.error('Failed to fetch orderbook volume', e); } try { - const dailyVolumeTrades = (await fetchURL(url_trades)).data.summary.volume.interval_1d.usd; + const dailyVolumeTrades = (await fetchURL(url_trades)).summary.volume.interval_1d.usd; dailyVolume += Number(dailyVolumeTrades); } catch (e) { console.error('Failed to fetch trades volume', e); @@ -39,7 +39,7 @@ const adapters: BreakdownAdapter = { aggregator: { [CHAIN.RADIXDLT]: { fetch: async (timestamp: number): Promise => { - const data = (await fetchURL(url_aggregator)).data.volume_by_resource; + const data = (await fetchURL(url_aggregator)).volume_by_resource; const dailyVolume = Object.keys(data).reduce((acc, key) => { return acc + Number(data[key].interval_1d.usd); }, 0); diff --git a/dexs/cetus/index.ts b/dexs/cetus/index.ts index 4a2347bded..c1055d7c72 100644 --- a/dexs/cetus/index.ts +++ b/dexs/cetus/index.ts @@ -21,7 +21,7 @@ interface IVolumeall { const fetch = (chain: Chain) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(url[chain]))?.data.data.list; + const historicalVolume: IVolumeall[] = (await fetchURL(url[chain])).data.list; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date.split('T')[0]).getTime() / 1000) <= dayTimestamp) .reduce((acc, { num }) => acc + Number(num), 0) diff --git a/dexs/chainge-finance/index.ts b/dexs/chainge-finance/index.ts index bc7efa5650..b2cce2b306 100644 --- a/dexs/chainge-finance/index.ts +++ b/dexs/chainge-finance/index.ts @@ -11,7 +11,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse = (await fetchURL(URL)).data.data.Total; + const response: IAPIResponse = (await fetchURL(URL)).data.Total; return { dailyVolume: `${response.totalVolume}`, timestamp: dayTimestamp, diff --git a/dexs/claimswap/index.ts b/dexs/claimswap/index.ts index c002b8a38d..ae0535ece5 100644 --- a/dexs/claimswap/index.ts +++ b/dexs/claimswap/index.ts @@ -26,7 +26,7 @@ const fetch = async (timestamp: number) => { const query = `?startdt=${startTime.toISOString()}&enddt=${dateToday.toISOString()}&timeunit=day`; const url = `${endpoint}${query}` const dayTimestamp = getUniqStartOfTodayTimestamp(dateToday); - const response: IRawResponse = (await fetchURL(url)).data; + const response: IRawResponse = (await fetchURL(url)); const historicalVolume: IVolume[] = response.data.map((val: number, index: number) => { return { diff --git a/dexs/clober/index.ts b/dexs/clober/index.ts index ba6a193b73..085155aad7 100644 --- a/dexs/clober/index.ts +++ b/dexs/clober/index.ts @@ -15,11 +15,11 @@ type TVolume = { const fetch = (chain: string) => async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const { markets }: { markets: TMarket[] } = (await fetchURL(`https://prod.clober-api.com/${chain}/markets`)).data; + const { markets }: { markets: TMarket[] } = (await fetchURL(`https://prod.clober-api.com/${chain}/markets`)); let dailyVolume = markets.map(market => market.volumeUsd24h).reduce((acc, cur) => acc + cur, 0) let totalVolume = markets.map(market => market.accumulatedVolumeUsd).reduce((acc, cur) => acc + cur, 0) if (chain === '1101') { - const {result}: {result: TVolume} = (await fetchURL(`https://pathfinder.clober-api.com/status`)).data; + const {result}: {result: TVolume} = (await fetchURL(`https://pathfinder.clober-api.com/status`)); dailyVolume += result.volume_usd24h; totalVolume += result.accumulated_volume_usd; } diff --git a/dexs/concordex-io/index.ts b/dexs/concordex-io/index.ts index 214b3e25be..7137e38d61 100644 --- a/dexs/concordex-io/index.ts +++ b/dexs/concordex-io/index.ts @@ -4,25 +4,12 @@ import { httpPost } from '../../utils/fetchURL'; const POOLS_SERVICE_URL = 'https://cdex-liquidity-pool.concordex.io/v1/rpc' const rpc = (url: string, method: string, params: any) => - httpPost( - url, - { - jsonrpc: '2.0', - method, - params, - id: '0', - }, - { - headers: { - 'Content-Type': 'application/json', - } - } - ) + httpPost(url, { jsonrpc: '2.0', method, params, id: '0', }, + { headers: { 'Content-Type': 'application/json', } }) .then(res => { - if (res.data.error) { - throw new Error(res.data.error.message) - } - return res.data.result + if (res.error) + throw new Error(res.error.message) + return res.result }); diff --git a/dexs/crema-finance/index.ts b/dexs/crema-finance/index.ts index 0f22965d0c..bb2afedcb8 100644 --- a/dexs/crema-finance/index.ts +++ b/dexs/crema-finance/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.list; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.list; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date.split('T')[0]).getTime() / 1000) <= dayTimestamp) .reduce((acc, { num }) => acc + Number(num), 0) @@ -30,7 +30,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.list; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.list; return (new Date(historicalVolume[0].date.split('T')[0]).getTime()) / 1000 } diff --git a/dexs/curve/index.ts b/dexs/curve/index.ts index 515257e59c..6b0d035615 100644 --- a/dexs/curve/index.ts +++ b/dexs/curve/index.ts @@ -22,7 +22,7 @@ interface IAPIResponse { } const fetch = (chain: string) => async (timestamp: number) => { - const response: IAPIResponse = (await fetchURL(endpoints[chain])).data; + const response: IAPIResponse = (await fetchURL(endpoints[chain])); const t = response.data.generatedTimeMs ? response.data.generatedTimeMs / 1000 : timestamp return { dailyVolume: `${response.data.totalVolume}`, diff --git a/dexs/danogo/index.ts b/dexs/danogo/index.ts index b5fdbfbe55..b4ee003d98 100644 --- a/dexs/danogo/index.ts +++ b/dexs/danogo/index.ts @@ -11,7 +11,7 @@ const ADA_DECIMAL = 6; const fetchDanogoGatewayData = async (timestamp: number): Promise => { const response = await fetchURL(`${DANOGO_GATEWAY_ENDPOINT}?timestamp=${timestamp}`); - return response.data.data; + return response.data; } const fetchADAprice = async (timestamp: number) => { diff --git a/dexs/darkness/index.ts b/dexs/darkness/index.ts index b80405360f..7a706deca1 100644 --- a/dexs/darkness/index.ts +++ b/dexs/darkness/index.ts @@ -13,11 +13,11 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse = (await fetchURL(URL))?.data?.data; + const response: IAPIResponse = (await fetchURL(URL))?.data; const dailyVolume = response.volume24h; return { - dailyVolume: dailyVolume ? `${dailyVolume}` : undefined, + dailyVolume: dailyVolume, timestamp: dayTimestamp, }; }; diff --git a/dexs/deepbook-sui/index.ts b/dexs/deepbook-sui/index.ts index afa46415c9..3a5e8ea4a8 100644 --- a/dexs/deepbook-sui/index.ts +++ b/dexs/deepbook-sui/index.ts @@ -13,7 +13,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); const dateString = new Date(timestamp * 1000).toISOString().split("T")[0]; - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date).getTime() / 1000) <= dayTimestamp) .filter((e: IVolumeall) => !isNaN(Number(e.volume))) // Fix: Convert volume to number diff --git a/dexs/defibox/index.ts b/dexs/defibox/index.ts index 94726a9cd3..529fa2ff2f 100644 --- a/dexs/defibox/index.ts +++ b/dexs/defibox/index.ts @@ -14,11 +14,11 @@ const graph = (chain: string) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) let volume = 0 if(chain === CHAIN.EOS){ - const bal_reponse: IVolume = (await fetchURL(bal_endpoint))?.data.data - const swap_response: IVolume = (await fetchURL(endpoint(chain)))?.data.data + const bal_reponse: IVolume = (await fetchURL(bal_endpoint))?.data + const swap_response: IVolume = (await fetchURL(endpoint(chain)))?.data volume = (bal_reponse?.volume_usd_24h? Number(bal_reponse.volume_usd_24h): 0) +(swap_response?.volume_usd_24h?Number(swap_response.volume_usd_24h):0) }else{ - const response: IVolume = chain !== CHAIN.BSC ? (await fetchURL(endpoint(chain)))?.data.data : (await httpPost(endpoint(chain), {} , { headers: {chainid: 56} })).data; + const response: IVolume = chain !== CHAIN.BSC ? (await fetchURL(endpoint(chain)))?.data : (await httpPost(endpoint(chain), {} , { headers: {chainid: 56} })).data; volume = response?.volume_usd_24h ? Number(response.volume_usd_24h): 0 } diff --git a/dexs/defichain-dex/index.ts b/dexs/defichain-dex/index.ts index 3be3b81d80..7a38e8046b 100644 --- a/dexs/defichain-dex/index.ts +++ b/dexs/defichain-dex/index.ts @@ -14,7 +14,7 @@ interface IVolume { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IData[] = (await fetchURL(historicalVolumeEndpoint))?.data.data; + const historicalVolume: IData[] = (await fetchURL(historicalVolumeEndpoint))?.data; const dailyVolume = historicalVolume .reduce((acc, { volume }) => acc + Number(volume.h24), 0) diff --git a/dexs/defiplaza/index.ts b/dexs/defiplaza/index.ts index fe8e7af150..3e0ee47f27 100644 --- a/dexs/defiplaza/index.ts +++ b/dexs/defiplaza/index.ts @@ -60,7 +60,7 @@ const adapter: SimpleAdapter = { }, [CHAIN.RADIXDLT]: { fetch: async (timestamp: number): Promise => { - const daily: RadixPlazaResponse = (await fetchURL(radix_endpoint + `?timestamp=${timestamp}`)).data; + const daily: RadixPlazaResponse = (await fetchURL(radix_endpoint + `?timestamp=${timestamp}`)); const dailySupplySideRevenue = daily.feesUSD; const dailyProtocolRevenue = daily.royaltiesUSD; diff --git a/dexs/demex/index.ts b/dexs/demex/index.ts index 027fcaf183..8ac50f7c0f 100644 --- a/dexs/demex/index.ts +++ b/dexs/demex/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(dayTimestamp)))?.data.result.entries; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(dayTimestamp))).result.entries; const volume = historicalVolume .find(dayItem => (new Date(dayItem.date.split('T')[0]).getTime() / 1000) === dayTimestamp) diff --git a/dexs/dodo/index.ts b/dexs/dodo/index.ts index 6d78d9a496..731c7aa535 100644 --- a/dexs/dodo/index.ts +++ b/dexs/dodo/index.ts @@ -55,8 +55,8 @@ interface ITotalResponse { const getFetch = (chain: string): Fetch => async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const dailyResponse = (await postURL(dailyEndpoint, dailyVolumePayload(chain))).data as IDailyResponse - // const totalResponse = (await postURL(totalEndpoint, totalVolumePayload(chain))).data as ITotalResponse + const dailyResponse = (await postURL(dailyEndpoint, dailyVolumePayload(chain))) as IDailyResponse + // const totalResponse = (await postURL(totalEndpoint, totalVolumePayload(chain))) as ITotalResponse return { timestamp: dayTimestamp, @@ -66,7 +66,7 @@ const getFetch = (chain: string): Fetch => async (timestamp: number) => { } const getStartTimestamp = (chain: string): IStartTimestamp => async () => { - const response = (await postURL(dailyEndpoint, dailyVolumePayload(chain))).data as IDailyResponse + const response = (await postURL(dailyEndpoint, dailyVolumePayload(chain))) as IDailyResponse const firstDay = response.data.dashboard_chain_day_data.list.find((item: any) => item.volume[chain] !== '0') return firstDay?.timestamp ?? 0 } diff --git a/dexs/dydx-v4/index.ts b/dexs/dydx-v4/index.ts index a0aabc00a0..ae6412f773 100644 --- a/dexs/dydx-v4/index.ts +++ b/dexs/dydx-v4/index.ts @@ -3,7 +3,7 @@ import { FetchResultVolume, SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; const fetch = async (timestamp: number): Promise => { - const markets = (await fetchURL("https://indexer.dydx.trade/v4/perpetualMarkets")).data.markets; + const markets = (await fetchURL("https://indexer.dydx.trade/v4/perpetualMarkets")).markets; const dailyolume = Object.values(markets).reduce((a: number, b: any) => a+Number(b.volume24H), 0) const dailyOpenInterest = Object.values(markets).reduce((a: number, b: any) => a+(Number(b.openInterest)*Number(b.oraclePrice)), 0) return { diff --git a/dexs/dydx/index.ts b/dexs/dydx/index.ts index 54705e4c50..e9cf6b40a5 100644 --- a/dexs/dydx/index.ts +++ b/dexs/dydx/index.ts @@ -23,8 +23,8 @@ const fetch = async (timestamp: number): Promise => { const fromTimestamp = dayTimestamp - 60 * 60 * 24 const fromISO = new Date(fromTimestamp * 1000).toISOString(); const dateString = new Date(dayTimestamp * 1000).toISOString(); - const markets: string[] = Object.keys((await fetchURL(historicalVolumeEndpoint))?.data.markets); - const historical: IVolumeall[] = (await Promise.all(markets.map((market: string) => fetchURL(candles(market, fromISO))))).map((e: any) => e.data.candles).flat() + const markets: string[] = Object.keys((await fetchURL(historicalVolumeEndpoint)).markets); + const historical: IVolumeall[] = (await Promise.all(markets.map((market: string) => fetchURL(candles(market, fromISO))))).map((e: any) => e.candles).flat() const dailyolume = historical.filter((e: IVolumeall) => e.startedAt === dateString) .reduce((a: number, b: IVolumeall) => a+Number(b.usdVolume), 0) const dailyOpenInterest = historical.filter((e: IVolumeall) => e.startedAt === dateString) diff --git a/dexs/ekubo/index.ts b/dexs/ekubo/index.ts index 1e22a848d9..f3b9d8b1d5 100644 --- a/dexs/ekubo/index.ts +++ b/dexs/ekubo/index.ts @@ -7,7 +7,7 @@ const toki = (n: any) => "starknet:0x" + BigInt(n).toString(16).padStart("049d36 const fetch = async (timestamp: number) => { const balances = new sdk.Balances({ chain: CHAIN.STARKNET, timestamp }) - const response = ((await fetchURL("https://mainnet-api.ekubo.org/overview")).data.volumeByToken_24h as any[]) + const response = ((await fetchURL("https://mainnet-api.ekubo.org/overview")).volumeByToken_24h as any[]) .map(t => ({ token: toki(t.token), vol: t.volume })) response.map((token) => { balances.add(token.token, token.vol, { skipChain: true }) diff --git a/dexs/ellipsis/index.ts b/dexs/ellipsis/index.ts index a83e6f4782..9aa5cb1e8b 100644 --- a/dexs/ellipsis/index.ts +++ b/dexs/ellipsis/index.ts @@ -16,7 +16,7 @@ interface IAPIResponse { } const fetch = (chain: string) => async () => { - const response: IAPIResponse = (await fetchURL(endpoints[chain])).data.data; + const response: IAPIResponse = (await fetchURL(endpoints[chain])).data; return { dailyVolume: `${response.getVolume.day}`, totalVolume: `${response.getVolume.total}`, diff --git a/dexs/exinswap/index.ts b/dexs/exinswap/index.ts index ac31da4d29..e7c4830fcb 100644 --- a/dexs/exinswap/index.ts +++ b/dexs/exinswap/index.ts @@ -12,7 +12,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse[] = (await fetchURL(URL))?.data?.data.list.map((e: any) => { + const response: IAPIResponse[] = (await fetchURL(URL))?.data.list.map((e: any) => { return { time: e[0], volume: e[1] diff --git a/dexs/fcon-dex/index.ts b/dexs/fcon-dex/index.ts index 441ed51d6e..879763fd13 100644 --- a/dexs/fcon-dex/index.ts +++ b/dexs/fcon-dex/index.ts @@ -16,7 +16,7 @@ interface IRes { const url = "https://api.fcon.ai/swapping/token_address/charts/?interval=90"; const fetch = async (timestamp: number): Promise => { const dateString = new Date(timestamp * 1000).toISOString().split("T")[0]; - const data: IRes = (await fetchURL(url)).data; + const data: IRes = (await fetchURL(url)); const dailyVolume = data.volumes.find((e: IData) => e.date.split('T')[0] === dateString)?.value; const dailyFee = data.fees.find((e: IData) => e.date.split('T')[0] === dateString)?.value; return { diff --git a/dexs/flamingo-finance/index.ts b/dexs/flamingo-finance/index.ts index 108b24701b..19613cf5d7 100644 --- a/dexs/flamingo-finance/index.ts +++ b/dexs/flamingo-finance/index.ts @@ -5,7 +5,7 @@ const { getUniqStartOfTodayTimestamp } = require("../../helpers/getUniSubgraphVo const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const data = (await fetchURL('https://api.flamingo.finance/project-info/defillama-volume?timestamp=' + dayTimestamp)).data; + const data = (await fetchURL('https://api.flamingo.finance/project-info/defillama-volume?timestamp=' + dayTimestamp)); return { dailyVolume: data.volume, diff --git a/dexs/frax-swap/index.ts b/dexs/frax-swap/index.ts index 1d96ba567a..2f8705f1b5 100644 --- a/dexs/frax-swap/index.ts +++ b/dexs/frax-swap/index.ts @@ -33,7 +33,7 @@ interface IVolumeall { const graphs = (chain: Chain) => { return async (timestamp: number, _chainBlocks: ChainBlocks): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historical: IVolumeall[] = (await fetchURL(poolsDataEndpoint))?.data.items; + const historical: IVolumeall[] = (await fetchURL(poolsDataEndpoint)).items; const historicalVolume = historical .filter(e => e.chain.toLowerCase() === chains[chain].toLowerCase()); @@ -52,7 +52,7 @@ const graphs = (chain: Chain) => { }; const getStartTimestamp = async (chain: Chain) => { - const historical: IVolumeall[] = (await fetchURL(poolsDataEndpoint))?.data.items; + const historical: IVolumeall[] = (await fetchURL(poolsDataEndpoint)).items; const historicalVolume = historical.filter(e => e.chain.toLowerCase() === chains[chain].toLowerCase()); return (new Date(historicalVolume[historicalVolume.length - 1].intervalTimestamp).getTime()) / 1000 } diff --git a/dexs/goosefx/index.ts b/dexs/goosefx/index.ts index 6723ae3f8e..2d1d96956a 100644 --- a/dexs/goosefx/index.ts +++ b/dexs/goosefx/index.ts @@ -12,8 +12,8 @@ const fetch = async (timestamp: number) => { }); return { timestamp: timeStampInMs, - dailyVolume: res?.data?.volume24H, - totalVolume: res?.data?.totalVolume, + dailyVolume: res?.volume24H, + totalVolume: res?.totalVolume, }; }; diff --git a/dexs/helix-perp/index.ts b/dexs/helix-perp/index.ts index 959bd1bb47..dc2afddee5 100644 --- a/dexs/helix-perp/index.ts +++ b/dexs/helix-perp/index.ts @@ -9,7 +9,7 @@ interface IVolume { } const fetch = async (timestamp: number): Promise => { - const volume: IVolume[] = (await fetchURL(URL)).data; + const volume: IVolume[] = (await fetchURL(URL)); const dailyVolume = volume.reduce((e: number, a: IVolume) => a.target_volume + e, 0); const dailyOpenInterest = volume.reduce((e: number, a: IVolume) => a.open_interest + e, 0); diff --git a/dexs/helix/index.ts b/dexs/helix/index.ts index b04ab83397..5b0f55356a 100644 --- a/dexs/helix/index.ts +++ b/dexs/helix/index.ts @@ -8,7 +8,7 @@ interface IVolume { } const fetch = async (timestamp: number): Promise => { - const volume: IVolume[] = (await fetchURL(URL)).data; + const volume: IVolume[] = (await fetchURL(URL)); const dailyVolume = volume.reduce((e: number, a: IVolume) => a.target_volume + e, 0); return { dailyVolume: dailyVolume.toString(), diff --git a/dexs/heraswap/index.ts b/dexs/heraswap/index.ts index 7c00447223..533b3e1390 100644 --- a/dexs/heraswap/index.ts +++ b/dexs/heraswap/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(dayTimestamp)))?.data.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(dayTimestamp))).data; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.record_date).getTime() / 1000) <= dayTimestamp) .reduce((acc, { value }) => acc + Number(value), 0) diff --git a/dexs/humble-defi/index.ts b/dexs/humble-defi/index.ts index 5a0b76afa0..d9a70b9f69 100644 --- a/dexs/humble-defi/index.ts +++ b/dexs/humble-defi/index.ts @@ -11,7 +11,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse[] = (await fetchURL(URL)).data; + const response: IAPIResponse[] = (await fetchURL(URL)); const dailyVolume = response .reduce((acc, { volume24h }) => acc + Number(volume24h), 0) diff --git a/dexs/hydradx/index.ts b/dexs/hydradx/index.ts index 3273ecd7dc..c9a97f82a9 100644 --- a/dexs/hydradx/index.ts +++ b/dexs/hydradx/index.ts @@ -11,7 +11,7 @@ type IAPIResponse = { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse = (await fetchURL(URL)).data; + const response: IAPIResponse = (await fetchURL(URL)); const dailyVolume = response[0].volume_usd; return { diff --git a/dexs/icpswap/index.ts b/dexs/icpswap/index.ts index 253be025ed..bb4ff9d86f 100644 --- a/dexs/icpswap/index.ts +++ b/dexs/icpswap/index.ts @@ -26,7 +26,7 @@ const fetch = async (timestamp: number): Promise => { const pools = pairs.map((e: IPairs) => e.pool_id); const todayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); const dateId = Math.floor(getTimestampAtStartOfDayUTC(todayTimestamp) / 86400) - const historicalVolume: IVolume[] = (await Promise.all(pools.map((e: string) => fetchURL(volumeURL(e))))).map((e: any) => e.data).flat(); + const historicalVolume: IVolume[] = (await Promise.all(pools.map((e: string) => fetchURL(volumeURL(e))))).map((e: any) => e).flat(); const dailyVolume = historicalVolume.filter((e: IVolume) => Number(e.day) === dateId) .reduce((a: number, b: IVolume) => a + Number(b.volumeUSD), 0) const totalVolume = historicalVolume.filter((e: IVolume) => Number(e.day) <= dateId) diff --git a/dexs/increment-swap/index.ts b/dexs/increment-swap/index.ts index 0860ac539e..9a62c7438e 100644 --- a/dexs/increment-swap/index.ts +++ b/dexs/increment-swap/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.vol; + const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint)).vol; const historicalVolume: IVolumeall[] = callhistoricalVolume.map((e: string[] | number[]) => { const [time, volume] = e; return { @@ -39,7 +39,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.vol; + const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint)).vol; const historicalVolume: IVolumeall[] = callhistoricalVolume.map((e: string[] | number[]) => { const [time, volume] = e; return { diff --git a/dexs/interest-protocol/index.ts b/dexs/interest-protocol/index.ts index d2db59fb08..6193200b55 100644 --- a/dexs/interest-protocol/index.ts +++ b/dexs/interest-protocol/index.ts @@ -14,7 +14,7 @@ interface GetVolumeReturn { } const fetch = async (_timestamp: number) => { - const volumeData: GetVolumeReturn = (await fetchURL(getVolumeURL)).data; + const volumeData: GetVolumeReturn = (await fetchURL(getVolumeURL)); return { totalVolume: volumeData.totalVolume.toString(), diff --git a/dexs/iziswap/index.ts b/dexs/iziswap/index.ts index cc0e514288..2f82a1ed08 100644 --- a/dexs/iziswap/index.ts +++ b/dexs/iziswap/index.ts @@ -44,8 +44,8 @@ const fetch = (chain: Chain) => { const historical: IVolumeall[] = []; while (isSuccess) { const response = (await fetchURL(historicalVolumeEndpoint(chains[chain], page))); - if (response.data.is_success){ - Array.prototype.push.apply(historical, response.data.data); + if (response.is_success){ + Array.prototype.push.apply(historical, response.data); page += 1; } else { isSuccess = false; diff --git a/dexs/jojo/index.ts b/dexs/jojo/index.ts index f9a65c1bc9..20cd92e61b 100644 --- a/dexs/jojo/index.ts +++ b/dexs/jojo/index.ts @@ -18,7 +18,7 @@ interface IVolumeall { const getVolume = async (timestamp: number, chain: string) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) const historical = (await Promise.all(Object.keys(coins).map((coins: string) => fetchURL(historicalVolumeEndpointZk(coins, chain))))) - .map((a: any, index: number) => a.data.map((e: any) => { return { timestamp: e.time / 1000, volume: e.volume, id: Object.values(coins)[index], quoteVolume: e.quote_volume } })).flat() + .map((a: any, index: number) => a.map((e: any) => { return { timestamp: e.time / 1000, volume: e.volume, id: Object.values(coins)[index], quoteVolume: e.quote_volume } })).flat() const historicalUSD = historical.map((e: IVolumeall) => { return { diff --git a/dexs/kava-swap/index.ts b/dexs/kava-swap/index.ts index 0de987d68a..a20af24a88 100644 --- a/dexs/kava-swap/index.ts +++ b/dexs/kava-swap/index.ts @@ -61,7 +61,7 @@ const convertSymbol = (symbol: string): ITokenInfo => { const fetch = async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const poolCall = (await fetchURL(URL))?.data; + const poolCall = (await fetchURL(URL)); const poolDetail = poolCall .map((pool: any) => pool.volume .map((p: ICallPoolData) => p)).flat(); diff --git a/dexs/kiloex/index.ts b/dexs/kiloex/index.ts index 9f8ee7d1d7..572f9200c8 100644 --- a/dexs/kiloex/index.ts +++ b/dexs/kiloex/index.ts @@ -24,7 +24,7 @@ interface IVolume { const fetch = (chainId: string) => { return async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolume[] = (await fetchURL(historicalVolumeEndpoints[chainId]))?.data; + const historicalVolume: IVolume[] = (await fetchURL(historicalVolumeEndpoints[chainId])); const totalVolume = historicalVolume .find(item => item.time === dayTimestamp)?.totalTradeAmount diff --git a/dexs/klayswap/index.ts b/dexs/klayswap/index.ts index e98294a6a5..f5d728ed4d 100644 --- a/dexs/klayswap/index.ts +++ b/dexs/klayswap/index.ts @@ -15,7 +15,7 @@ const historicalVolumeEndpoint = "https://ss.klayswap.com/stat/dashboardInfo.jso const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IKlaySwapInfoDayVolumeItem[] = (await fetchURL(historicalVolumeEndpoint))?.data + const historicalVolume: IKlaySwapInfoDayVolumeItem[] = (await fetchURL(historicalVolumeEndpoint)) .dayVolume; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.dateId).getTime() / 1000) <= dayTimestamp) @@ -29,7 +29,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IKlaySwapInfoDayVolumeItem[] = (await fetchURL(historicalVolumeEndpoint))?.data + const historicalVolume: IKlaySwapInfoDayVolumeItem[] = (await fetchURL(historicalVolumeEndpoint)) .dayVolume; return (new Date(historicalVolume[0].dateId).getTime()) / 1000 diff --git a/dexs/kokonut-swap/index.ts b/dexs/kokonut-swap/index.ts index 724c936c6c..63e2e34474 100644 --- a/dexs/kokonut-swap/index.ts +++ b/dexs/kokonut-swap/index.ts @@ -11,7 +11,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall = (await fetchURL(historicalVolumeEndpoint)); return { dailyVolume: historicalVolume ? `${historicalVolume.volume24hrOnlySwap}` : undefined, timestamp: dayTimestamp, @@ -20,7 +20,7 @@ const fetch = async (timestamp: number) => { const fetchZKEVM = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const volume24hrOnlySwap = (await fetchURL('https://prod.kokonut-api.com/zkevm-24hr-volume'))?.data; + const volume24hrOnlySwap = (await fetchURL('https://prod.kokonut-api.com/zkevm-24hr-volume')); return { dailyVolume: volume24hrOnlySwap, timestamp: dayTimestamp, @@ -29,7 +29,7 @@ const fetchZKEVM = async (timestamp: number) => { const fetchBASE = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const volume24hrOnlySwap = (await fetchURL('https://prod.kokonut-api.com/base-24hr-volume'))?.data; + const volume24hrOnlySwap = (await fetchURL('https://prod.kokonut-api.com/base-24hr-volume')); return { dailyVolume: volume24hrOnlySwap, timestamp: dayTimestamp, diff --git a/dexs/kriya-dex/index.ts b/dexs/kriya-dex/index.ts index b847703afa..0433d0f1da 100644 --- a/dexs/kriya-dex/index.ts +++ b/dexs/kriya-dex/index.ts @@ -24,7 +24,7 @@ const fetch = (chain: Chain) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); // fetch for the passed timestamp. const volumeUrl = url[chain] + String(timestamp); - const volume: IVolume = (await fetchURL(volumeUrl))?.data; + const volume: IVolume = (await fetchURL(volumeUrl)); return { totalVolume: `${volume?.totalVolume || undefined}`, dailyVolume: `${volume?.dailyVolume || undefined}`, diff --git a/dexs/kwenta/index.ts b/dexs/kwenta/index.ts index 19d2922c99..2dc3cafe85 100644 --- a/dexs/kwenta/index.ts +++ b/dexs/kwenta/index.ts @@ -13,7 +13,7 @@ const url = 'https://storage.kwenta.io/25710180-23d8-43f4-b0c9-5b7f55f63165-buck const fetchData = (_: Chain) => { return async (timestamp: number): Promise => { const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp) - const value: IData[] = (await fetchURL(url)).data; + const value: IData[] = (await fetchURL(url)); const dailyVolume = value.find((d) => d.timestamp === todaysTimestamp)?.volume; const totalVolume = value.filter((e: IData) => e.timestamp <= todaysTimestamp) .reduce((acc: number, e: IData) => acc + e.volume, 0) diff --git a/dexs/levana/fetch.ts b/dexs/levana/fetch.ts index d81999257b..57cce29212 100644 --- a/dexs/levana/fetch.ts +++ b/dexs/levana/fetch.ts @@ -12,5 +12,5 @@ export async function fetchVolume(kind: "daily" | "total", marketInfos: MarketIn const url = `${INDEXER_URL}/rolling_trade_volume?${marketsStr}×tamp=${timestamp}&interval_days=${intervalDays}` - return new BigNumber((await fetchURL(url)).data); + return new BigNumber((await fetchURL(url))); } \ No newline at end of file diff --git a/dexs/levana/utils.ts b/dexs/levana/utils.ts index 8f86924b4e..c12d8bce98 100644 --- a/dexs/levana/utils.ts +++ b/dexs/levana/utils.ts @@ -17,5 +17,5 @@ export async function queryContract({contract, chain, msg}:{contract: string, await fetchURL( `${endpoint}/cosmwasm/wasm/v1/contract/${contract}/smart/${data}` ) - ).data.data; + ).data; } \ No newline at end of file diff --git a/dexs/lifinity/index.ts b/dexs/lifinity/index.ts index 39a9ddfb30..9de281e50c 100644 --- a/dexs/lifinity/index.ts +++ b/dexs/lifinity/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volume.daily.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).volume.daily.data; const dateStr = new Date(dayTimestamp * 1000).toLocaleDateString('en-US', { timeZone: 'UTC' }) const [month, day, year] = dateStr.split('/'); const formattedDate = `${year}/${String(month).padStart(2, '0')}/${String(day).padStart(2, '0')}`; @@ -33,7 +33,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volume.daily.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).volume.daily.data; return (new Date(historicalVolume[0].date).getTime()) / 1000 } diff --git a/dexs/lighterv2/index.ts b/dexs/lighterv2/index.ts index 30b972e00e..6db2c35419 100644 --- a/dexs/lighterv2/index.ts +++ b/dexs/lighterv2/index.ts @@ -31,10 +31,10 @@ const fetchV2 = async (timestamp: number) => { `×tamp=${dayTimestamp}` ); - const result: IVolumeall = (await fetchURL(lighterV2VolumeEndpoint)).data; - const markets = (await fetchURL(marketurl)).data as IMarket[] + const result: IVolumeall = (await fetchURL(lighterV2VolumeEndpoint)); + const markets = (await fetchURL(marketurl)) as IMarket[] const res = (await Promise.all(markets.map(async ({ symbol }) => fetchURL(url(symbol, dayTimestamp + 86400))))) - .map((res) => res.data) + .map((res) => res) .map((res) => res.candlesticks).flat() as ICandlesticks[] const dailyVolume = res.filter(e => e.timestamp === dayTimestamp) .reduce((acc, { volume0, close }) => acc + (volume0) * close, 0) diff --git a/dexs/liquidswap/index.ts b/dexs/liquidswap/index.ts index 383d477414..13b189db72 100644 --- a/dexs/liquidswap/index.ts +++ b/dexs/liquidswap/index.ts @@ -13,7 +13,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).data; const totalVolume = historicalVolume .filter(volItem => Number(volItem.timestamp) <= dayTimestamp) .reduce((acc, { value }) => acc + Number(value), 0) diff --git a/dexs/luigiswap/index.ts b/dexs/luigiswap/index.ts index 82149b53a1..c8bac66113 100644 --- a/dexs/luigiswap/index.ts +++ b/dexs/luigiswap/index.ts @@ -10,7 +10,7 @@ interface IData { } const getUrl = (end: number) => `https://api-scroll.luigiswap.finance/report/volume-day?start_time=${START_TIMESTAMP}&end_time=${end}`; const fetchVolume = async (timestamp: number) => { - const response: IData[] = (await fetchURL(getUrl(timestamp))).data.data; + const response: IData[] = (await fetchURL(getUrl(timestamp))).data; const dateString = new Date(timestamp * 1000).toISOString().split("T")[0]; const dailyVolume = response.find((e: IData) => e.record_date.split('T')[0] === dateString)?.value; return { diff --git a/dexs/lumenswap/index.ts b/dexs/lumenswap/index.ts index 2d6af898f1..261c290c72 100644 --- a/dexs/lumenswap/index.ts +++ b/dexs/lumenswap/index.ts @@ -13,7 +13,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.periodTime.split('T')[0]).getTime() / 1000) <= dayTimestamp) diff --git a/dexs/mango-v4/index.ts b/dexs/mango-v4/index.ts index c134a31382..2eef1f3c69 100644 --- a/dexs/mango-v4/index.ts +++ b/dexs/mango-v4/index.ts @@ -31,8 +31,8 @@ interface DailyStats { const fetchSpotVolume = async ( timestamp: number, ): Promise => { - const totalStats: TotalStats = (await fetchURL(urlTotalStats)).data; - const dailyStats: DailyStats = (await fetchURL(urlDailyStats)).data; + const totalStats: TotalStats = (await fetchURL(urlTotalStats)); + const dailyStats: DailyStats = (await fetchURL(urlDailyStats)); return { dailyVolume: dailyStats?.spot_volume_24h.toString(), totalVolume: totalStats?.spot_volume.toString(), @@ -43,8 +43,8 @@ const fetchSpotVolume = async ( const fetchPerpVolume = async ( timestamp: number, ): Promise => { - const totalStats: TotalStats = (await fetchURL(urlTotalStats)).data; - const dailyStats: DailyStats = (await fetchURL(urlDailyStats)).data; + const totalStats: TotalStats = (await fetchURL(urlTotalStats)); + const dailyStats: DailyStats = (await fetchURL(urlDailyStats)); return { dailyVolume: dailyStats?.perp_volume_24h.toString(), totalVolume: totalStats?.perp_volume.toString(), diff --git a/dexs/mcdex/index.ts b/dexs/mcdex/index.ts index 13ae5f3656..a090c0d645 100644 --- a/dexs/mcdex/index.ts +++ b/dexs/mcdex/index.ts @@ -27,7 +27,7 @@ const chainsMap: chains = { const fetch = (chain: Chain) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.data.rows; + const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.rows; const historicalVolume: IVolumeall[] = callhistoricalVolume.map((e: string[] | number[]) => { const [time, title, volume] = e; @@ -55,7 +55,7 @@ const fetch = (chain: Chain) => { }; const getStartTimestamp = async (chain: Chain) => { - const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.data.rows; + const callhistoricalVolume = (await fetchURL(historicalVolumeEndpoint))?.data.rows; const historicalVolume: IVolumeall[] = callhistoricalVolume.map((e: string[] | number[]) => { const [time, title, volume] = e; return { diff --git a/dexs/mdex/index.ts b/dexs/mdex/index.ts index 0f061e00c5..c97b189637 100644 --- a/dexs/mdex/index.ts +++ b/dexs/mdex/index.ts @@ -24,7 +24,7 @@ const fetch = (chain: Chain) => { return async (timestamp: number) => { const queryByChainId = `?chain_id=${mapChainId[chain]}`; const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const historicalVolume: IVolume[] = (await fetchURL(`${historicalVolumeEndpoint}${queryByChainId}`))?.data.result; + const historicalVolume: IVolume[] = (await fetchURL(`${historicalVolumeEndpoint}${queryByChainId}`)).result; const totalVolume = historicalVolume .filter(volItem => getUniqStartOfTodayTimestamp(new Date(volItem.created_time)) <= dayTimestamp) .reduce((acc, { max_swap_amount }) => acc + Number(max_swap_amount), 0) @@ -42,7 +42,7 @@ const fetch = (chain: Chain) => { const getStartTimestamp = async (chain: Chain) => { const queryByChainId = `?chain_id=${mapChainId[chain]}`; - const historicalVolume: IVolume[] = (await fetchURL(`${historicalVolumeEndpoint}${queryByChainId}`))?.data.result; + const historicalVolume: IVolume[] = (await fetchURL(`${historicalVolumeEndpoint}${queryByChainId}`)).result; return (new Date(historicalVolume[0].created_time).getTime()) / 1000 } const adapter: SimpleAdapter = { diff --git a/dexs/megaton-finance/index.ts b/dexs/megaton-finance/index.ts index f604e1608e..d11f20181b 100644 --- a/dexs/megaton-finance/index.ts +++ b/dexs/megaton-finance/index.ts @@ -12,7 +12,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.dayVolume; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).dayVolume; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.dateId).getTime() / 1000) <= dayTimestamp) .reduce((acc, { amount }) => acc + Number(amount), 0) diff --git a/dexs/merkle-trade/index.ts b/dexs/merkle-trade/index.ts index 31c7e625f5..57c4d325b9 100644 --- a/dexs/merkle-trade/index.ts +++ b/dexs/merkle-trade/index.ts @@ -8,7 +8,7 @@ const endpoint = const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const res = (await fetchURL(`${endpoint}?ts=${timestamp}`))?.data; + const res = (await fetchURL(`${endpoint}?ts=${timestamp}`)); return { totalVolume: res.totalVolume, diff --git a/dexs/meshswap/index.ts b/dexs/meshswap/index.ts index 0844eba227..03da870ef6 100644 --- a/dexs/meshswap/index.ts +++ b/dexs/meshswap/index.ts @@ -11,7 +11,7 @@ interface IVolume { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolume[] = (await fetchURL(historicalVolumeEndpoint))?.data?.dayVolume; + const historicalVolume: IVolume[] = (await fetchURL(historicalVolumeEndpoint))?.dayVolume; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.dateId).getTime() / 1000) <= dayTimestamp) .reduce((acc, { amount }) => acc + Number(amount), 0) @@ -27,7 +27,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolume[] = (await fetchURL(historicalVolumeEndpoint))?.data?.dayVolume; + const historicalVolume: IVolume[] = (await fetchURL(historicalVolumeEndpoint))?.dayVolume; return (new Date(historicalVolume[0].dateId).getTime()) / 1000 } diff --git a/dexs/metatdex/index.ts b/dexs/metatdex/index.ts index 2dd9c74c0e..e5501bd6ad 100644 --- a/dexs/metatdex/index.ts +++ b/dexs/metatdex/index.ts @@ -23,7 +23,7 @@ interface IVolumeall { const graphs = (chain: Chain) => { return async (timestamp: number, _chainBlocks: ChainBlocks): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain]))?.data.result; + const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain])).result; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date).getTime() / 1000) <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) @@ -39,7 +39,7 @@ const graphs = (chain: Chain) => { }; const getStartTimestamp = async (chain: Chain) => { - const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain]))?.data.result; + const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain])).result; return (new Date(historicalVolume[0].date).getTime()) / 1000; } diff --git a/dexs/myswap/index.ts b/dexs/myswap/index.ts index a0c397648f..0d6ccc8bd1 100644 --- a/dexs/myswap/index.ts +++ b/dexs/myswap/index.ts @@ -16,7 +16,7 @@ const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); const poolCall = Array.from(Array(NUMBER_OF_POOL).keys()).map((e: number) => fetchURL(historicalVolumeEndpoint(e + 1))); const historicalVolume: IVolumeall[] = (await Promise.all(poolCall)) - .map((e:any) => e.data.data).flat() + .map((e:any) => e.data).flat() .map((p: any) => Object.keys(p.volume_usd).map((x: any) => { return { volume: p.volume_usd[x].usd, diff --git a/dexs/openbook/index.ts b/dexs/openbook/index.ts index 10541de120..869de687fd 100644 --- a/dexs/openbook/index.ts +++ b/dexs/openbook/index.ts @@ -11,7 +11,7 @@ interface IVolume { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); const url = `https://dry-ravine-67635.herokuapp.com/pairs`; - const historicalVolume: IVolume[] = (await fetchURL(url)).data; + const historicalVolume: IVolume[] = (await fetchURL(url)); const dailyVolume = historicalVolume.reduce((a: number, b: IVolume) => a + b.volume_24h, 0); return { diff --git a/dexs/openleverage/index.ts b/dexs/openleverage/index.ts index 2016132063..57dba50704 100644 --- a/dexs/openleverage/index.ts +++ b/dexs/openleverage/index.ts @@ -23,7 +23,7 @@ interface IVolumeall { const graphs = (chain: Chain) => { return async (timestamp: number, _chainBlocks: ChainBlocks): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain]))?.data.tradingChart; + const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain])).tradingChart; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date).getTime() / 1000) <= dayTimestamp) @@ -40,7 +40,7 @@ const graphs = (chain: Chain) => { }; const getStartTimestamp = async (chain: Chain) => { - const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain]))?.data.tradingChart; + const historicalVolume: IVolumeall[] = (await fetchURL(endpoints[chain])).tradingChart; return (new Date(historicalVolume[0].date).getTime()) / 1000; } diff --git a/dexs/oraidex/index.ts b/dexs/oraidex/index.ts index d0a6f1a768..e6b40c4587 100644 --- a/dexs/oraidex/index.ts +++ b/dexs/oraidex/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const dailyVolume = historicalVolume .reduce((acc, { volume24Hour }) => acc + Number(volume24Hour), 0) / 1e6; diff --git a/dexs/osmosis/index.ts b/dexs/osmosis/index.ts index 524234df06..d527bf2e62 100644 --- a/dexs/osmosis/index.ts +++ b/dexs/osmosis/index.ts @@ -12,7 +12,7 @@ interface IChartItem { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IChartItem[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IChartItem[] = (await fetchURL(historicalVolumeEndpoint)); const dateStr = new Date(timestamp * 1000).toISOString().split('T')[0]; @@ -31,7 +31,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IChartItem[] = (await fetchURL(historicalVolumeEndpoint))?.data + const historicalVolume: IChartItem[] = (await fetchURL(historicalVolumeEndpoint)) return (new Date(historicalVolume[0].time).getTime()) / 1000 } diff --git a/dexs/pact/index.ts b/dexs/pact/index.ts index 9dacef4bb1..501e502807 100644 --- a/dexs/pact/index.ts +++ b/dexs/pact/index.ts @@ -15,7 +15,7 @@ const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); const yesterdaysTimestamp = getTimestampAtStartOfPreviousDayUTC(timestamp) const url = URL(new Date(yesterdaysTimestamp * 1000).toISOString()); - const response: IAPIResponse[] = (await fetchURL(url)).data; + const response: IAPIResponse[] = (await fetchURL(url)); const dailyVolume = response .find(dayItem => (new Date(dayItem.for_datetime.split('T')[0]).getTime() / 1000) === dayTimestamp)?.volume; diff --git a/dexs/paint-swap/index.ts b/dexs/paint-swap/index.ts index bf32d66215..2a5214e4af 100644 --- a/dexs/paint-swap/index.ts +++ b/dexs/paint-swap/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(dayTimestamp)))?.data.marketPlaceDayDatas; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint(dayTimestamp))).marketPlaceDayDatas; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date).getTime()) <= dayTimestamp) .reduce((acc, { dailyVolume }) => acc + Number(dailyVolume), 0) diff --git a/dexs/paradex/index.ts b/dexs/paradex/index.ts index 4ac615c197..dfc2222aa6 100644 --- a/dexs/paradex/index.ts +++ b/dexs/paradex/index.ts @@ -15,8 +15,8 @@ const fetch = async (timestamp: number): Promise => { const end = timestamp //need to calculate start time of timestamp - 24h const start = end - (60 * 60 * 24) - const markets: string[] = ((await fetchURL(marketsEndpoint))?.data.results).map((m: any) => m.symbol); - const historical: IVolumeall[] = (await Promise.all(markets.map((market: string) => fetchURL(historicalVolumeEndpoint(market, start*1000, end*1000))))).map((e: any) => e.data.results.slice(-1)).flat() + const markets: string[] = ((await fetchURL(marketsEndpoint)).results).map((m: any) => m.symbol); + const historical: IVolumeall[] = (await Promise.all(markets.map((market: string) => fetchURL(historicalVolumeEndpoint(market, start*1000, end*1000))))).map((e: any) => e.results.slice(-1)).flat() const dailyVol = historical.reduce((a: number, b: IVolumeall) => a+Number(b.volume_24h), 0) diff --git a/dexs/penguin/index.ts b/dexs/penguin/index.ts index b1f333d17a..1deb118991 100644 --- a/dexs/penguin/index.ts +++ b/dexs/penguin/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.dashboards.chartDatas; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.dashboards.chartDatas; const totalVolume = historicalVolume .filter(volItem => getUniqStartOfTodayTimestamp(new Date(volItem.date)) <= dayTimestamp) .reduce((acc, { value }) => acc + Number(value), 0) @@ -30,7 +30,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.dashboards.chartDatas; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.dashboards.chartDatas; return (new Date(historicalVolume[0].date).getTime()) / 1000 } diff --git a/dexs/pheasantswap/index.ts b/dexs/pheasantswap/index.ts index e27006389d..7949aca37e 100644 --- a/dexs/pheasantswap/index.ts +++ b/dexs/pheasantswap/index.ts @@ -12,7 +12,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volumeList; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).volumeList; const dailyVolume = historicalVolume .find(dayItem => Number(dayItem.date) === dayTimestamp)?.amount diff --git a/dexs/plenty/index.ts b/dexs/plenty/index.ts index bcefd6bba2..e4935d7be7 100644 --- a/dexs/plenty/index.ts +++ b/dexs/plenty/index.ts @@ -10,7 +10,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); const dateString = new Date(timestamp * 1000).toISOString().split("T")[0]; - const plentyData: IVolumeall[] = (await fetchURL("https://analytics.plenty.network/api/v1/overall-volume/24hours")).data; + const plentyData: IVolumeall[] = (await fetchURL("https://analytics.plenty.network/api/v1/overall-volume/24hours")); const dailyVolumeItem = plentyData.find(e => e.time === dateString)?.value return { diff --git a/dexs/polynomial-trade/index.ts b/dexs/polynomial-trade/index.ts index b949b0e160..b530b5923e 100644 --- a/dexs/polynomial-trade/index.ts +++ b/dexs/polynomial-trade/index.ts @@ -23,7 +23,7 @@ const fetch = async (timestamp: number) => { async function getDailyVolume(startDayTimestamp: number) : Promise { const endDayTimeStamp = startDayTimestamp + oneDay const dailyVolumeQuery = '?from='+startDayTimestamp.toString()+'&to='+endDayTimeStamp.toString() - return (await fetchURL(volumeEndpoint+dailyVolumeQuery))?.data; + return (await fetchURL(volumeEndpoint+dailyVolumeQuery)); } async function getTotalVolume(endtimestamp: number) : Promise { diff --git a/dexs/ponytaswap/index.ts b/dexs/ponytaswap/index.ts index 175bb96c49..32c8b3d1d8 100644 --- a/dexs/ponytaswap/index.ts +++ b/dexs/ponytaswap/index.ts @@ -13,7 +13,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).data; const totalVolume = historicalVolume .filter(volItem => getUniqStartOfTodayTimestamp(new Date(volItem.date * 1000)) <= dayTimestamp) .reduce((acc, { volumeUSD }) => acc + Number(volumeUSD), 0) diff --git a/dexs/quickswap/index.ts b/dexs/quickswap/index.ts index 73c46b890c..a873d09f94 100644 --- a/dexs/quickswap/index.ts +++ b/dexs/quickswap/index.ts @@ -67,12 +67,12 @@ const v3GraphsUni = getGraphDimensions({ const fetchLiquidityHub = async (timestamp: number) => { - let dailyResult = (await fetchURL('https://hub.orbs.network/analytics-daily/v1')).data; + let dailyResult = (await fetchURL('https://hub.orbs.network/analytics-daily/v1')); let rows = dailyResult.result.rows; let lastDay = rows[rows.length - 1]; let dailyVolume = lastDay.daily_total_calculated_value; - let totalVolume = (await fetchURL(`https://hub.orbs.network/analytics/v1`)).data.result.rows[0].total_calculated_value; + let totalVolume = (await fetchURL(`https://hub.orbs.network/analytics/v1`)).result.rows[0].total_calculated_value; return { dailyVolume: `${dailyVolume}`, diff --git a/dexs/rabbitx/index.ts b/dexs/rabbitx/index.ts index 036e3aba27..c5bcee11f0 100644 --- a/dexs/rabbitx/index.ts +++ b/dexs/rabbitx/index.ts @@ -21,11 +21,11 @@ const fetchVolume = async (timestamp: number): Promise => { // Get market data const response = await fetchURL(historicalVolumeEndpoint); - const marketsData = response.data.result; + const marketsData = response.result; // Fetch candles for each USD market const historical: IVolumeall[] = (await Promise.all(marketsData.map((market: any) => fetchURL(candles(market.id, fromTimestamp, toTimestamp))))) - .map((e: any) => e.data.result) + .map((e: any) => e.result) .flat(); // Calculate daily volume diff --git a/dexs/raydium/index.ts b/dexs/raydium/index.ts index 96dd59e38d..3071b57556 100644 --- a/dexs/raydium/index.ts +++ b/dexs/raydium/index.ts @@ -16,8 +16,8 @@ interface IAmmPooolStandar { } const graphs = async (timestamp: number): Promise => { - const ammPool: IAmmPoool = (await fetchURL(urlAmmPool)).data; - const ammPoolStandard: any[] = (await fetchURL(urlAmmPoolStandard)).data.data;; + const ammPool: IAmmPoool = (await fetchURL(urlAmmPool)); + const ammPoolStandard: any[] = (await fetchURL(urlAmmPoolStandard)).data;; const ammPoolStandardVolume: IAmmPooolStandar[] = ammPoolStandard.map((e: any) => e.day); const dailyVolumeAmmPool = ammPoolStandardVolume .filter((e: IAmmPooolStandar) => e.tvl > 100_000) diff --git a/dexs/saros/index.ts b/dexs/saros/index.ts index c14d03dd2f..9e6ae49534 100644 --- a/dexs/saros/index.ts +++ b/dexs/saros/index.ts @@ -19,8 +19,8 @@ const graphs = (chain: string) => async (timestamp: number) => { return { timestamp, - dailyVolume: res.data.volume24h, - totalVolume: res.data.totalvolume, + dailyVolume: res.volume24h, + totalVolume: res.totalvolume, }; }; diff --git a/dexs/satori/index.ts b/dexs/satori/index.ts index b0f0c467a1..4899861d61 100644 --- a/dexs/satori/index.ts +++ b/dexs/satori/index.ts @@ -29,7 +29,7 @@ const linea = { "exchange":"linea" } const evm_fetch = async (_timestamp: number) => { - const volumeData: VolumeInfo = (await postURL(ZKEVM_URL,zk_evm)).data.data; + const volumeData: VolumeInfo = (await postURL(ZKEVM_URL,zk_evm)).data; return { totalVolume: volumeData.totalTradVol, @@ -41,7 +41,7 @@ const evm_fetch = async (_timestamp: number) => { }; const era_fetch = async (_timestamp: number) => { - const volumeData: VolumeInfo = (await postURL(ZkSYNC_URL,zk_era)).data.data; + const volumeData: VolumeInfo = (await postURL(ZkSYNC_URL,zk_era)).data; return { totalVolume: volumeData.totalTradVol, @@ -53,7 +53,7 @@ const era_fetch = async (_timestamp: number) => { }; const linea_fetch = async (_timestamp: number) => { - const volumeData: VolumeInfo = (await postURL(ZkSYNC_URL,linea)).data.data; + const volumeData: VolumeInfo = (await postURL(ZkSYNC_URL,linea)).data; return { totalVolume: volumeData.totalTradVol, @@ -65,7 +65,7 @@ const linea_fetch = async (_timestamp: number) => { }; const scroll_fetch = async (_timestamp: number) => { - const volumeData: VolumeInfo = (await postURL(ZkSYNC_URL,scroll)).data.data; + const volumeData: VolumeInfo = (await postURL(ZkSYNC_URL,scroll)).data; return { totalVolume: volumeData.totalTradVol, diff --git a/dexs/spectrum/index.ts b/dexs/spectrum/index.ts index bd1646b2a6..e5b2468f33 100644 --- a/dexs/spectrum/index.ts +++ b/dexs/spectrum/index.ts @@ -14,7 +14,7 @@ interface IResponseERGO { } const fetchVolumeADA = async (timestamp: number): Promise => { - const response: IResponse = (await fetchURL(`https://analytics-balanced.spectrum.fi/cardano/platform/stats`)).data; + const response: IResponse = (await fetchURL(`https://analytics-balanced.spectrum.fi/cardano/platform/stats`)); const coinId = "coingecko:cardano"; const prices = await getPrices([coinId], timestamp) const adaPrice = prices[coinId].price; @@ -28,7 +28,7 @@ const fetchVolumeADA = async (timestamp: number): Promise => const fetchVolumeERGO = async (timestamp: number): Promise => { const from = timestamp - 24 * 60 * 60 * 1000; - const response: IResponseERGO = (await fetchURL(`https://api.spectrum.fi/v1/amm/platform/stats?from=${from}`)).data; + const response: IResponseERGO = (await fetchURL(`https://api.spectrum.fi/v1/amm/platform/stats?from=${from}`)); const dailyVolume = Number(response.volume.value); return { dailyVolume: `${dailyVolume}`, diff --git a/dexs/spicyswap/index.ts b/dexs/spicyswap/index.ts index b1c414604f..13aeeebd1a 100644 --- a/dexs/spicyswap/index.ts +++ b/dexs/spicyswap/index.ts @@ -10,7 +10,7 @@ interface IResponse { } const fetchVolume = async (timestamp: number): Promise => { - const response = (await fetchURL(url)).data.spicy_day_data as IResponse[]; + const response = (await fetchURL(url)).spicy_day_data as IResponse[]; const dateString = new Date(timestamp * 1000).toISOString().split("T")[0]; const dailyVolume = response.find(item => item.day.split(" ")[0].trim() === dateString)?.dailyvolumeusd diff --git a/dexs/stellarx/index.ts b/dexs/stellarx/index.ts index 9a323809ed..557baf3dbd 100644 --- a/dexs/stellarx/index.ts +++ b/dexs/stellarx/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const totalVolume = historicalVolume .filter(volItem => getUniqStartOfTodayTimestamp(new Date(Number(`${volItem.time}`.split('.')[0]) * 1000)) <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) @@ -30,7 +30,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); return getUniqStartOfTodayTimestamp(new Date(Number(`${historicalVolume[0].time}`.split('.')[0]) * 1000)) } diff --git a/dexs/stormtrade/index.ts b/dexs/stormtrade/index.ts index 55f5ece667..e728aba5d8 100644 --- a/dexs/stormtrade/index.ts +++ b/dexs/stormtrade/index.ts @@ -16,13 +16,9 @@ export default { fetch: async () => { const response = await fetchURL('https://api.redoubt.online/dapps/v1/export/defi/storm') - if (!response.data) { - throw new Error('Error during re:doubt API call') - } - return { - dailyVolume: response.data.volume.toString(), - timestamp: response.data.timestamp + dailyVolume: response.volume.toString(), + timestamp: response.timestamp } }, }, diff --git a/dexs/sundaeswap/index.ts b/dexs/sundaeswap/index.ts index 68d34fc86e..b209cf74e9 100644 --- a/dexs/sundaeswap/index.ts +++ b/dexs/sundaeswap/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.response; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).response; const dailyVolume = historicalVolume .find(dayItem => getUniqStartOfTodayTimestamp(new Date(dayItem.day)) === dayTimestamp)?.volumeLovelace diff --git a/dexs/sunswap-v2/index.ts b/dexs/sunswap-v2/index.ts index 75784b3313..33de65964d 100644 --- a/dexs/sunswap-v2/index.ts +++ b/dexs/sunswap-v2/index.ts @@ -14,7 +14,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).data; const totalVolume = historicalVolume .filter(volItem => volItem.time <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) diff --git a/dexs/sunswap-v3/index.ts b/dexs/sunswap-v3/index.ts index 248c46310c..15dfc906ed 100644 --- a/dexs/sunswap-v3/index.ts +++ b/dexs/sunswap-v3/index.ts @@ -10,7 +10,7 @@ interface IValue { } const fetchVolume = async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const data: IValue[] = (await fetchURL("https://sbc.endjgfsv.link/scan/volume?version=v3&startDate=2023-12-16"))?.data?.data?.list; + const data: IValue[] = (await fetchURL("https://sbc.endjgfsv.link/scan/volume?version=v3&startDate=2023-12-16")).data?.list; const dailyVolume = data.find((item) => (item.time / 1000) === dayTimestamp)?.volume ?? "0"; const totalVolume = data .filter(volItem => (volItem.time / 1000) <= dayTimestamp) diff --git a/dexs/sunswap/index.ts b/dexs/sunswap/index.ts index 2b19425a32..af3d391140 100644 --- a/dexs/sunswap/index.ts +++ b/dexs/sunswap/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.time).getTime() / 1000) <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) @@ -31,7 +31,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); return (new Date(historicalVolume[0].time).getTime()) / 1000 } diff --git a/dexs/surfone/index.ts b/dexs/surfone/index.ts index 40e4ea1af3..56228b97d9 100644 --- a/dexs/surfone/index.ts +++ b/dexs/surfone/index.ts @@ -19,7 +19,6 @@ const fetch = () => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) const response = (await httpGet(volumeEndpoint, { headers })); - //const response = await fetchURL(url[chain]); const volume: IVolume = response.data; return { totalVolume: `${volume?.totalVolume || undefined}`, diff --git a/dexs/swapline/index.ts b/dexs/swapline/index.ts index f2d7958965..66cdf3b4c8 100644 --- a/dexs/swapline/index.ts +++ b/dexs/swapline/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const graph = (_chain: number) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint+_chain))?.data[0]?.chainEntries; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint+_chain))[0]?.chainEntries; const totalVolume = historicalVolume .filter(volItem => volItem.date <= dayTimestamp) .reduce((acc, { volumeUSD }) => acc + Number(volumeUSD), 0) diff --git a/dexs/synthetify/index.ts b/dexs/synthetify/index.ts index ae69febd0d..a774618baf 100644 --- a/dexs/synthetify/index.ts +++ b/dexs/synthetify/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const totalVolume = historicalVolume .filter(volItem => volItem.timestamp <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) @@ -31,7 +31,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); return (new Date(historicalVolume[0].timestamp).getTime()) } diff --git a/dexs/tealswap/index.ts b/dexs/tealswap/index.ts index cc7890a159..dfedf31913 100644 --- a/dexs/tealswap/index.ts +++ b/dexs/tealswap/index.ts @@ -16,7 +16,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const rawData: IRawData = (await fetchURL(historicalVolumeEndpoint))?.data; + const rawData: IRawData = (await fetchURL(historicalVolumeEndpoint)); const historicalVolume: any[] = rawData.timestamps.map((value: number, index: number) => { return { volume: rawData.volumes[index] || 0, diff --git a/dexs/thalaswap/index.ts b/dexs/thalaswap/index.ts index b860e2f6f5..86e194ab75 100644 --- a/dexs/thalaswap/index.ts +++ b/dexs/thalaswap/index.ts @@ -19,19 +19,19 @@ interface IVolumeall { } const fetch = async (timestamp: number) => { - const dayVolumeQuery = (await fetchURL(volumeEndpoint(timestamp, "1D")))?.data.data; + const dayVolumeQuery = (await fetchURL(volumeEndpoint(timestamp, "1D"))).data; const dailyVolume = dayVolumeQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0); - const totalVolumeQuery = (await fetchURL(volumeEndpoint(0, "ALL")))?.data.data; + const totalVolumeQuery = (await fetchURL(volumeEndpoint(0, "ALL"))).data; const totalVolume = totalVolumeQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0); - const dayFeesQuery = (await fetchURL(feesEndpoint(timestamp, "1D")))?.data.data; + const dayFeesQuery = (await fetchURL(feesEndpoint(timestamp, "1D"))).data; const dailyFees = dayFeesQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0); - const totalFeesQuery = (await fetchURL(feesEndpoint(0, "ALL")))?.data.data; + const totalFeesQuery = (await fetchURL(feesEndpoint(0, "ALL"))).data; const totalFees = totalFeesQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0); - const protocolFeeRatio = (await fetchURL(protocolRatioQueryURL))?.data.data; + const protocolFeeRatio = (await fetchURL(protocolRatioQueryURL)).data; const dailyProtocolRevenue = dailyFees * protocolFeeRatio; const totalProtocolRevenue = totalFees * protocolFeeRatio; diff --git a/dexs/tinyman/index.ts b/dexs/tinyman/index.ts index c7702f8e7b..9c08d05884 100644 --- a/dexs/tinyman/index.ts +++ b/dexs/tinyman/index.ts @@ -12,7 +12,7 @@ interface IAPIResponse { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const response: IAPIResponse = (await fetchURL(URL)).data; + const response: IAPIResponse = (await fetchURL(URL)); return { dailyVolume: `${response.last_day_total_volume_in_usd}`, timestamp: dayTimestamp, diff --git a/dexs/traderjoe/index.ts b/dexs/traderjoe/index.ts index d50cdf96fc..376566db99 100644 --- a/dexs/traderjoe/index.ts +++ b/dexs/traderjoe/index.ts @@ -25,7 +25,7 @@ interface IVolume { const fetchV2 = (chain: Chain) => { return async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolume[] = (await fetchURL(endpointsV2[chain]))?.data; + const historicalVolume: IVolume[] = (await fetchURL(endpointsV2[chain])); const totalVolume = historicalVolume .filter(volItem => volItem.timestamp <= dayTimestamp) .reduce((acc, { volumeUsd }) => acc + Number(volumeUsd), 0) diff --git a/dexs/ttswap/index.ts b/dexs/ttswap/index.ts index eed1d535f4..ff76643683 100644 --- a/dexs/ttswap/index.ts +++ b/dexs/ttswap/index.ts @@ -11,7 +11,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall = (await fetchURL(historicalVolumeEndpoint))?.data.data.overview; + const historicalVolume: IVolumeall = (await fetchURL(historicalVolumeEndpoint)).data.overview; return { dailyVolume: historicalVolume ? `${historicalVolume.volume24H}` : undefined, timestamp: dayTimestamp, diff --git a/dexs/turbos/index.ts b/dexs/turbos/index.ts index 84789fcfec..2722738a9f 100644 --- a/dexs/turbos/index.ts +++ b/dexs/turbos/index.ts @@ -22,7 +22,7 @@ interface IVolume { const fetch = (chain: Chain) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const volume: IVolume = (await fetchURL(url[chain]))?.data; + const volume: IVolume = (await fetchURL(url[chain])); return { totalVolume: `${volume?.totalVolume || undefined}`, dailyVolume: `${volume?.dailyVolume || undefined}`, diff --git a/dexs/unifi/index.ts b/dexs/unifi/index.ts index 16625d3eac..13ffaf9b34 100644 --- a/dexs/unifi/index.ts +++ b/dexs/unifi/index.ts @@ -33,7 +33,7 @@ interface IVolumeall { const graphs = (chain: Chain) => { return async (timestamp: number, _chainBlocks: ChainBlocks): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(poolsDataEndpoint(chains[chain])))?.data.results; + const historicalVolume: IVolumeall[] = (await fetchURL(poolsDataEndpoint(chains[chain]))).results; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.datetime).getTime() / 1000) <= dayTimestamp) @@ -50,7 +50,7 @@ const graphs = (chain: Chain) => { }; const getStartTimestamp = async (chain: Chain) => { - const historicalVolume: IVolumeall[] = (await fetchURL(poolsDataEndpoint(chains[chain])))?.data.results; + const historicalVolume: IVolumeall[] = (await fetchURL(poolsDataEndpoint(chains[chain]))).results; return (new Date(historicalVolume[historicalVolume.length - 1].datetime).getTime()) / 1000 } diff --git a/dexs/urdex/index.ts b/dexs/urdex/index.ts index 01b42f2a3f..2cac761db2 100644 --- a/dexs/urdex/index.ts +++ b/dexs/urdex/index.ts @@ -7,7 +7,7 @@ const volumeEndpoint = "https://api.urdex.finance/kol/getVolumeData" const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const volumeData = (await fetchURL(`${volumeEndpoint}?date=${dayTimestamp}`))?.data.data; + const volumeData = (await fetchURL(`${volumeEndpoint}?date=${dayTimestamp}`)).data; return { totalVolume: `${volumeData.total.TotalTradingVolume}`, dailyVolume: volumeData.daily.TotalTradingVolume ? `${volumeData.daily.TotalTradingVolume}` : '0', diff --git a/dexs/vexchange/index.ts b/dexs/vexchange/index.ts index 70f7ff2a5e..4d48f43a4a 100644 --- a/dexs/vexchange/index.ts +++ b/dexs/vexchange/index.ts @@ -12,7 +12,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: any = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: any = (await fetchURL(historicalVolumeEndpoint)); const prespose: IVolumeall[] = Object.keys(historicalVolume).map((key: string) => { const {token0Volume, token1Volume, token0, token1, price} = historicalVolume[key]; return { diff --git a/dexs/wemix.fi/index.ts b/dexs/wemix.fi/index.ts index c240eaa566..8f289e2f46 100644 --- a/dexs/wemix.fi/index.ts +++ b/dexs/wemix.fi/index.ts @@ -13,7 +13,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.history; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).data.history; const totalVolume = historicalVolume .filter(volItem => volItem.timestamp / 1000 <= dayTimestamp) .reduce((acc, { volume }) => acc + Number(volume), 0) diff --git a/dexs/wineryswap/index.ts b/dexs/wineryswap/index.ts index c0c462c1b6..c176e83aca 100644 --- a/dexs/wineryswap/index.ts +++ b/dexs/wineryswap/index.ts @@ -15,7 +15,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.volume; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volume; const totalVolume = historicalVolume .filter(volItem => volItem.date <= dayTimestamp) .reduce((acc, { volumeUSD }) => acc + Number(volumeUSD), 0) @@ -31,7 +31,7 @@ const fetch = async (timestamp: number) => { }; const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.volume; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volume; return historicalVolume[0].date; } diff --git a/dexs/wx.network/index.ts b/dexs/wx.network/index.ts index 0894cbc8ca..47f2020ce7 100644 --- a/dexs/wx.network/index.ts +++ b/dexs/wx.network/index.ts @@ -14,7 +14,7 @@ interface IAPIResponse { }; const fetch = async (timestamp: number) => { - const response: IAPIResponse[] = (await fetchURL(URL)).data.items; + const response: IAPIResponse[] = (await fetchURL(URL)).items; const dailyVolume = response.map(e => e.volumes.filter(p => p.interval === "1d") .map(x => x)).flat() .filter((e: IVolume) => Number(e.quote_volume) < 1_000_000) diff --git a/dexs/zigzag/index.ts b/dexs/zigzag/index.ts index 3b08505d54..5bf7559301 100644 --- a/dexs/zigzag/index.ts +++ b/dexs/zigzag/index.ts @@ -20,8 +20,8 @@ type TMarketInfo = { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const markets: TMarket = (await fetchURL('https://zigzag-exchange.herokuapp.com/api/v1/markets')).data; - const marketInfos: TMarketInfo = (await fetchURL('https://zigzag-exchange.herokuapp.com/api/v1/marketinfos?chain_id=1&market=' + Object.keys(markets).join(','))).data; + const markets: TMarket = (await fetchURL('https://zigzag-exchange.herokuapp.com/api/v1/markets')); + const marketInfos: TMarketInfo = (await fetchURL('https://zigzag-exchange.herokuapp.com/api/v1/marketinfos?chain_id=1&market=' + Object.keys(markets).join(','))); const amountUSD: number[] = Object.keys(markets).map(market => { const info = marketInfos[market] const { baseVolume } = markets[market] diff --git a/dexs/zilswap/index.ts b/dexs/zilswap/index.ts index 0e82bc33bc..1a09d3478a 100644 --- a/dexs/zilswap/index.ts +++ b/dexs/zilswap/index.ts @@ -12,7 +12,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const _dailyVolume = historicalVolume.filter(volItem => (new Date(volItem.time.split('T')[0]).getTime() / 1000) === dayTimestamp); const dailyVolume = Math.abs(Number(_dailyVolume[0].value) - Number(_dailyVolume[_dailyVolume.length-1].value)) const priceId = 'coingecko:zilliqa'; diff --git a/fees/allbridge-classic.ts b/fees/allbridge-classic.ts index 872e62ab97..cbf78dc002 100644 --- a/fees/allbridge-classic.ts +++ b/fees/allbridge-classic.ts @@ -10,7 +10,7 @@ interface ChainData { const getFees = async (chainCode: string, fromDate: string, toDate: string): Promise => { const url = `https://stats.a11bd.net/aggregated?dateFrom=${fromDate}&dateTo=${toDate}`; - const responseBody = (await fetchURL(url)).data; + const responseBody = (await fetchURL(url)); const chainData = responseBody.data.chains .filter((d: ChainData) => d.id === chainCode) .pop(); diff --git a/fees/apex.ts b/fees/apex.ts index 1a81c359e7..49d35f0fad 100644 --- a/fees/apex.ts +++ b/fees/apex.ts @@ -10,7 +10,7 @@ interface IFees { const fees = async (timestamp: number): Promise => { const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp) * 1000; const url = `https://pro.apex.exchange/api/v1/data/fee-by-date?time=${todaysTimestamp}`; - const feesData: IFees = (await fetchURL(url)).data.data; + const feesData: IFees = (await fetchURL(url)).data; const dailyFees = feesData?.feeOfDate || '0'; return { dailyFees: dailyFees, diff --git a/fees/bluefin.ts b/fees/bluefin.ts index de5c7826bc..1b196d4aaa 100644 --- a/fees/bluefin.ts +++ b/fees/bluefin.ts @@ -8,8 +8,8 @@ const url_sui="https://dapi.api.sui-prod.bluefin.io/marketData/fees" const fetch_sui = async (timestamp: number): Promise => { const result= await fetchURL(url_sui); - const dailyFees=result.data.last24HoursFees; - const totalFees=result.data.totalFees; + const dailyFees=result.last24HoursFees; + const totalFees=result.totalFees; return { dailyFees: dailyFees ? `${dailyFees}` : undefined, diff --git a/fees/bluemove/index.ts b/fees/bluemove/index.ts index 3ca689ab46..65f879ae77 100644 --- a/fees/bluemove/index.ts +++ b/fees/bluemove/index.ts @@ -12,7 +12,7 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.data.list; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.list; const totalVolume = historicalVolume .filter(volItem => (new Date(volItem.date.split('T')[0]).getTime() / 1000) <= dayTimestamp) .reduce((acc, { num }) => acc + Number(num), 0) diff --git a/fees/caviarnine-lsu-pool.ts b/fees/caviarnine-lsu-pool.ts index 82aaef480c..b452fad321 100644 --- a/fees/caviarnine-lsu-pool.ts +++ b/fees/caviarnine-lsu-pool.ts @@ -15,7 +15,7 @@ interface CaviarNineLSUPool { }; } const fetchFees = async (timestamp: number): Promise => { - const response: CaviarNineLSUPool = (await fetchURL("https://api-core.caviarnine.com/v1.0/stats/product/lsupool")).data.summary; + const response: CaviarNineLSUPool = (await fetchURL("https://api-core.caviarnine.com/v1.0/stats/product/lsupool")).summary; const dailyFees = Number(response.protocol_fees.interval_1d.usd) + Number(response.lp_revenue.interval_1d.usd); const dailyRevenue = response.protocol_fees.interval_1d.usd; const supplySideRevenue = response.lp_revenue.interval_1d.usd; diff --git a/fees/caviarnine-shape-liquidity.ts b/fees/caviarnine-shape-liquidity.ts index 3f3389f76a..b1621482b8 100644 --- a/fees/caviarnine-shape-liquidity.ts +++ b/fees/caviarnine-shape-liquidity.ts @@ -18,7 +18,7 @@ interface CaviarNinePool { const fetchFees = async (timestamp: number): Promise => { const url = 'https://api-core.caviarnine.com/v1.0/stats/product/shapeliquidity'; - const response: CaviarNinePool = (await fetchURL(url)).data.summary; + const response: CaviarNinePool = (await fetchURL(url)).summary; const dailyFees = Number(response.protocol_fees.interval_1d.usd) + Number(response.lp_revenue.interval_1d.usd); const dailyRevenue = response.protocol_fees.interval_1d.usd; const supplySideRevenue = response.lp_revenue.interval_1d.usd; diff --git a/fees/danogo/index.ts b/fees/danogo/index.ts index 1f7fe5d2a9..2902b9a8bb 100644 --- a/fees/danogo/index.ts +++ b/fees/danogo/index.ts @@ -11,7 +11,7 @@ const ADA_DECIMAL = 6; const fetchDanogoGatewayData = async (timestamp: number): Promise => { const response = await fetchURL(`${DANOGO_GATEWAY_ENDPOINT}?timestamp=${timestamp}`); - return response.data.data; + return response.data; } const fetchADAprice = async (timestamp: number) => { diff --git a/fees/defiplaza/index.ts b/fees/defiplaza/index.ts index 5edd2524f1..b97fbb355a 100644 --- a/fees/defiplaza/index.ts +++ b/fees/defiplaza/index.ts @@ -62,7 +62,7 @@ const adapter: SimpleAdapter = { }, [CHAIN.RADIXDLT]: { fetch: async (timestamp: number): Promise => { - const daily: RadixPlazaResponse = (await fetchURL(radix_endpoint + `?timestamp=${timestamp}`)).data; + const daily: RadixPlazaResponse = (await fetchURL(radix_endpoint + `?timestamp=${timestamp}`)); const dailySupplySideRevenue = daily.feesUSD; const dailyProtocolRevenue = daily.royaltiesUSD; diff --git a/fees/dln/index.ts b/fees/dln/index.ts index 6bdfca3a4e..636d573b14 100644 --- a/fees/dln/index.ts +++ b/fees/dln/index.ts @@ -10,7 +10,7 @@ const fetch = (chainId: number) => { const dateTo = dateFrom; const url = `https://stats-api.dln.trade/api/Satistics/getDaily?dateFrom=${dateFrom}&dateTo=${dateTo}`; const response = await fetchURL(url); - const dailyDatas = response.data.dailyData; + const dailyDatas = response.dailyData; let fees = 0; for (const dailyData of dailyDatas) { if (dailyData.giveChainId.bigIntegerValue === chainId) { diff --git a/fees/dydx.ts b/fees/dydx.ts index d2644a9723..23d6138142 100644 --- a/fees/dydx.ts +++ b/fees/dydx.ts @@ -10,8 +10,8 @@ interface IStats { } const fetch = async (timestamp: number): Promise => { - const markets: string[] = Object.keys((await fetchURL(historicalVolumeEndpoint))?.data.markets); - const historical: IStats[] = (await Promise.all(markets.map((market: string) => fetchURL(stats(market))))).map((e: any) => Object.values(e.data.markets) as unknown as IStats).flat() + const markets: string[] = Object.keys((await fetchURL(historicalVolumeEndpoint)).markets); + const historical: IStats[] = (await Promise.all(markets.map((market: string) => fetchURL(stats(market))))).map((e: any) => Object.values(e.markets) as unknown as IStats).flat() const dailyFees = historical.filter((e: IStats) => e.fees !== '0') .reduce((a: number, b: IStats) => a+Number(b.fees), 0) return { diff --git a/fees/ekubo.ts b/fees/ekubo.ts index 6b0075a892..9bcbeb312b 100644 --- a/fees/ekubo.ts +++ b/fees/ekubo.ts @@ -18,8 +18,8 @@ async function getDimension(responseRaw:any[], key: string, timestamp:number){ } const fetch = async (timestamp: number) => { - const fees = await getDimension((await fetchURL("https://mainnet-api.ekubo.org/overview")).data.volumeByToken_24h, "fees", timestamp) - const rev = await getDimension((await fetchURL("https://mainnet-api.ekubo.org/overview")).data.revenueByToken_24h, "revenue", timestamp) + const fees = await getDimension((await fetchURL("https://mainnet-api.ekubo.org/overview")).volumeByToken_24h, "fees", timestamp) + const rev = await getDimension((await fetchURL("https://mainnet-api.ekubo.org/overview")).revenueByToken_24h, "revenue", timestamp) return { timestamp: timestamp, dailyFees: `${fees}`, diff --git a/fees/ethereum/index.ts b/fees/ethereum/index.ts index 4973709ce7..4b1e9feb9a 100644 --- a/fees/ethereum/index.ts +++ b/fees/ethereum/index.ts @@ -22,7 +22,7 @@ const graphs = () => { const yesterday = new Date(yesterdaysTimestamp * 1000).toISOString() const dailyFee = await getOneDayFees('eth', yesterday, today); - const burnData: IChartItem[] = (await fetchURL(burnEndpoint))?.data.chart.jsonFile.Series['ETH Burned']['Data'] + const burnData: IChartItem[] = (await fetchURL(burnEndpoint)).chart.jsonFile.Series['ETH Burned']['Data'] const dailyRevEth = burnData .filter(item => item.Timestamp === yesterdaysTimestamp) diff --git a/fees/frax-swap.ts b/fees/frax-swap.ts index 1543a54af7..662e102815 100644 --- a/fees/frax-swap.ts +++ b/fees/frax-swap.ts @@ -34,7 +34,7 @@ const graphs = () => { return (chain: Chain) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historical: IHistory[] = (await fetchURL(poolsDataEndpoint))?.data.items; + const historical: IHistory[] = (await fetchURL(poolsDataEndpoint)).items; const historicalVolume = historical .filter(e => e.chain.toLowerCase() === chains[chain].toLowerCase()); @@ -57,7 +57,7 @@ const graphs = () => { }; const getStartTimestamp = async (chain: Chain) => { - const historical: IHistory[] = (await fetchURL(poolsDataEndpoint))?.data.items; + const historical: IHistory[] = (await fetchURL(poolsDataEndpoint)).items; const historicalVolume = historical.filter(e => e.chain.toLowerCase() === chains[chain].toLowerCase()); return (new Date(historicalVolume[historicalVolume.length - 1].intervalTimestamp).getTime()) / 1000 } diff --git a/fees/gamma.ts b/fees/gamma.ts index c69c7ac644..1f3bc70a13 100644 --- a/fees/gamma.ts +++ b/fees/gamma.ts @@ -23,7 +23,7 @@ interface IData { const _fetchApi = async (from_timestamp: number) => { const url = `https://wire2.gamma.xyz/frontend/revenue_status/main_charts?from_timestamp=${from_timestamp}&yearly=false&monthly=false&filter_zero_revenue=false`; - const data: IData[] = (await fetchURL(url)).data; + const data: IData[] = (await fetchURL(url)); return data; } diff --git a/fees/garden/index.ts b/fees/garden/index.ts index d8d0bee29f..1cd336e2bf 100644 --- a/fees/garden/index.ts +++ b/fees/garden/index.ts @@ -25,11 +25,11 @@ type IApiFeeResponse = { const fetch = (chain: string) => async (timestamp: number): Promise => { const dailyFeeResponse: IApiFeeResponse = ( await fetchURL(feeUrl(chainMapper[chain], timestamp, "day")) - ).data; + ); const totalFeeResponse: IApiFeeResponse = ( await fetchURL(feeUrl(chainMapper[chain], timestamp)) - ).data; + ); const dailyUserFees = new BigNumber(dailyFeeResponse.data.fee); const totalUserFees = new BigNumber(totalFeeResponse.data.fee); diff --git a/fees/geist-finance/index.ts b/fees/geist-finance/index.ts index dc3e8a6fec..ecc3a86874 100644 --- a/fees/geist-finance/index.ts +++ b/fees/geist-finance/index.ts @@ -16,7 +16,7 @@ const graphs = () => { return (_: CHAIN) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const historicalVolume: IFees[] = (await fetchURL(yieldPool))?.data.data.dailyFees; + const historicalVolume: IFees[] = (await fetchURL(yieldPool))?.data.dailyFees; const totalFees = historicalVolume .filter((volItem: IFees) => volItem.timestamp <= dayTimestamp) .reduce((acc, { added }) => acc + Number(added), 0) diff --git a/fees/ghostmarket/index.ts b/fees/ghostmarket/index.ts index dbdc619e4d..caf8c94009 100644 --- a/fees/ghostmarket/index.ts +++ b/fees/ghostmarket/index.ts @@ -32,7 +32,7 @@ const apis = (apiUrls: ChainEndpoints) => { return async (timestamp: number) => { const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp); const url = await buildUrl(apiUrls[chain], todaysTimestamp); - const data = (await fetchURL(url)).data; + const data = (await fetchURL(url)); return { timestamp, diff --git a/fees/goku-money/index.ts b/fees/goku-money/index.ts index d92da15b37..9bee4c04bc 100644 --- a/fees/goku-money/index.ts +++ b/fees/goku-money/index.ts @@ -3,38 +3,6 @@ import { Adapter, ChainBlocks } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; import { getBlock } from "../../helpers/getBlock"; import { Chain } from "@defillama/sdk/build/general"; -import { ethers } from "ethers"; -import BigNumber from "bignumber.js"; -import { httpGet } from "../../utils/fetchURL"; - -interface DexScreenerResponse { - pairs: { - baseToken: { - address: string; - name: string; - symbol: string; - }; - quoteToken: { - address: string; - name: string; - symbol: string; - }; - priceUsd: string; - }[]; -} - -interface PriceInfo { - price: string; - conf: string; - expo: number; - publish_time: number; -} - -interface Feed { - id: string; - price: PriceInfo; - ema_price: PriceInfo; -} const BORROW_CONTRACT_ADDRESS = [ "0x2f6E14273514bc53deC831028CB91cB1D7b78237", // USDC @@ -44,206 +12,82 @@ const BORROW_CONTRACT_ADDRESS = [ "0x95CeF13441Be50d20cA4558CC0a27B601aC544E5", // MANTA ]; -const GAI_PAID_TOPIC = [ - "0x82db03bc05d9c2d04d268827ae58bb9dbfeec9acae002850df31476dfa0e0364", // USDC GAIBorrowingFeePaid -]; - -const COLLATERAL_REDEMPTION_FEE = [ - "0x43a3f4082a4dbc33d78e317d2497d3a730bc7fc3574159dcea1056e62e5d9ad8", // Redemption Topic -]; - -const PYTH_PRICE_FEED_IDS = [ - "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a", // USDC - "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b", // USDT - "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace", // WETH - "0x09f7c1d7dfbb7df2b8fe3d3d87ee94a2259d212da4f30c1f0540d066dfa44723", // TIA - "0xc3883bcf1101c111e9fcfe2465703c47f2b638e21fef2cce0502e6c8f416e0e2", // MANTA -]; - -const GAI_TOKEN_DECIMAL = 18; const PYTH_CONFIG = { USDC: { contractAddress: "0x5B27B4ACA9573F26dd12e30Cb188AC53b177006e", - priceFeedId: - "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a", - decimal: 6, - revenue: BigNumber(0), + address: '0xb73603C5d87fA094B7314C74ACE2e64D165016fb', }, USDT: { contractAddress: "0x2D18cE2adC5B7c4d8558b62D49A0137A6B87049b", - priceFeedId: - "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b", - decimal: 6, - revenue: BigNumber(0), + address: '0xf417F5A458eC102B90352F697D6e2Ac3A3d2851f', }, WETH: { contractAddress: "0x17Efd0DbAAdc554bAFDe3cC0E122f0EEB94c8661", - priceFeedId: - "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace", - decimal: 18, - revenue: BigNumber(0), + address: '0x0Dc808adcE2099A9F62AA87D9670745AbA741746', }, TIA: { contractAddress: "0xaa41F9e1f5B6d27C22f557296A0CDc3d618b0113", - priceFeedId: - "0x09f7c1d7dfbb7df2b8fe3d3d87ee94a2259d212da4f30c1f0540d066dfa44723", - decimal: 9, - revenue: BigNumber(0), + address: '0x6Fae4D9935E2fcb11fC79a64e917fb2BF14DaFaa', }, MANTA: { contractAddress: "0x3683Ee89f1928B69962D20c08315bb7059C21dD9", - priceFeedId: - "0xc3883bcf1101c111e9fcfe2465703c47f2b638e21fef2cce0502e6c8f416e0e2", - decimal: 18, - revenue: BigNumber(0), + address: '0x95CeF13441Be50d20cA4558CC0a27B601aC544E5', }, }; type PYTH_CONFIG_TYPE = typeof PYTH_CONFIG; type PYTH_CONFIG_KEYS = keyof PYTH_CONFIG_TYPE; -const fetchGAIPrice = async () => { - try { - const response: DexScreenerResponse = await httpGet("https://api.dexscreener.com/latest/dex/tokens/0xcd91716ef98798A85E79048B78287B13ae6b99b2"); - return response.pairs[0].priceUsd ?? "1"; - } catch (error) { - return "1"; - } -}; - -const fetchPriceFeeds = async (): Promise> => { - const baseURL = "https://hermes.pyth.network/"; - const resource = "api/latest_price_feeds"; - const params = new URLSearchParams(); - - PYTH_PRICE_FEED_IDS.forEach((id) => params.append("ids[]", id)); - - const response: Feed[] = await httpGet(`${baseURL}${resource}`, { params: params, }); - // price array to price map - // key is price feed id - // value is price in standard unit like $1.00 - return response.reduce((acc, curr) => { - const adjustedPrice = - Number(curr.price.price) * Math.pow(10, curr.price.expo); - acc[curr.id] = adjustedPrice.toFixed(Math.abs(curr.price.expo)); - return acc; - }, {} as Record); -}; - -const fetchGaiRevenue = async (timestamp: number) => { +const fetchGaiRevenue = async (timestamp: number, balances: sdk.Balances) => { const fromTimestamp = timestamp - 60 * 60 * 24; const toTimestamp = timestamp; - // open vault fee - const eventABI = [ - "event GAIBorrowingFeePaid(address indexed _borrower, uint256 _GAIFee)", - ]; - - const iface = new ethers.Interface(eventABI); - const fromBlock = await getBlock(fromTimestamp, CHAIN.MANTA as Chain, {}); const toBlock = await getBlock(toTimestamp, CHAIN.MANTA as Chain, {}); - let totalGaiPaid = BigNumber(0); - - for (const address of BORROW_CONTRACT_ADDRESS) { - const logs = await sdk.getEventLogs({ - target: address, - topic: "", - toBlock: toBlock, - fromBlock: fromBlock, - keys: [], - chain: CHAIN.MANTA as Chain, - topics: GAI_PAID_TOPIC, - }); + const logs = await sdk.getEventLogs({ + targets: BORROW_CONTRACT_ADDRESS, + toBlock: toBlock, + fromBlock: fromBlock, + chain: CHAIN.MANTA as Chain, + eventAbi: "event GAIBorrowingFeePaid(address indexed _borrower, uint256 _GAIFee)", + onlyArgs: true, + }); - for (const log of logs) { - if (!Array.isArray(log)) { - const event = iface.parseLog(log as any); - event!.args.forEach((arg, index) => { - if (!arg.toString().startsWith("0x") && index === 1) { - totalGaiPaid = totalGaiPaid.plus(BigNumber(arg)); - } - }); - } - } - } - const gaiCounts = ethers.formatUnits( - totalGaiPaid.toString(), - GAI_TOKEN_DECIMAL - ); - const gaiUsd = await fetchGAIPrice(); - const gaiRevenue = (parseFloat(gaiCounts) * parseFloat(gaiUsd)).toFixed(6); - return gaiRevenue; + logs.forEach(log => balances.add('0xcd91716ef98798A85E79048B78287B13ae6b99b2', log._GAIFee)) }; -const fetchCollateralRedemptionRevenue = async (timestamp: number) => { +const fetchCollateralRedemptionRevenue = async (timestamp: number, balances: sdk.Balances) => { const fromTimestamp = timestamp - 60 * 60 * 24; const toTimestamp = timestamp; - // redemption fee - const eventABI = [ - "event Redemption(uint256 _attemptedGAIAmount, uint256 _actualGAIAmount, uint256 _COLSent, uint256 _COLFee)", - ]; - - const iface = new ethers.Interface(eventABI); - const fromBlock = await getBlock(fromTimestamp, CHAIN.MANTA as Chain, {}); const toBlock = await getBlock(toTimestamp, CHAIN.MANTA as Chain, {}); for (const token of Object.keys(PYTH_CONFIG) as PYTH_CONFIG_KEYS[]) { + const { contractAddress, address, } = PYTH_CONFIG[token]; const logs = await sdk.getEventLogs({ - target: PYTH_CONFIG[token].contractAddress, - topic: "", + target: contractAddress, toBlock: toBlock, fromBlock: fromBlock, - keys: [], chain: CHAIN.MANTA as Chain, - topics: COLLATERAL_REDEMPTION_FEE, + onlyArgs: true, + eventAbi: "event Redemption(uint256 _attemptedGAIAmount, uint256 _actualGAIAmount, uint256 _COLSent, uint256 _COLFee)", }); - for (const log of logs) { - if (!Array.isArray(log)) { - const event = iface.parseLog(log as any); - event!.args.forEach((arg, index) => { - if (BigNumber.isBigNumber(arg) && index === 3) { - PYTH_CONFIG[token].revenue = PYTH_CONFIG[token].revenue.plus(arg); - } - }); - } - } + for (const log of logs) + balances.add(address, log._COLFee) } - - const priceFeeds = await fetchPriceFeeds(); - - let totalValue = 0.0; - - Object.values(PYTH_CONFIG).forEach(({ priceFeedId, decimal, revenue }) => { - const price = priceFeeds[priceFeedId.substring(2)]; - if (price) { - const revenueInStandardUnit = ethers.formatUnits( - revenue.toString(), - decimal - ); - totalValue += parseFloat(revenueInStandardUnit) * parseFloat(price); - } - }); - - return totalValue.toFixed(6); }; const adapter: Adapter = { adapter: { [CHAIN.MANTA]: { fetch: async (timestamp: number, _: ChainBlocks) => { - const gaiRevenue = await fetchGaiRevenue(timestamp); - - const collateralRevenue = await fetchCollateralRedemptionRevenue( - timestamp - ); + const balances = new sdk.Balances({ chain: CHAIN.MANTA as Chain, timestamp }); + await fetchGaiRevenue(timestamp, balances); + await fetchCollateralRedemptionRevenue(timestamp, balances); - const totalRevenue = ( - parseFloat(collateralRevenue) + parseFloat(gaiRevenue) - ).toFixed(6); + const totalRevenue = await balances.getUSDString() return { timestamp, dailyFees: totalRevenue, diff --git a/fees/hipo/index.ts b/fees/hipo/index.ts index 70ceefdbd9..e9b6fdc6bf 100644 --- a/fees/hipo/index.ts +++ b/fees/hipo/index.ts @@ -28,10 +28,10 @@ export default { method: 'get_treasury_state', stack: [], }) - if (!response1.data.ok) { + if (!response1.ok) { throw new Error('Error in calling toncenter.com/api/v2/runGetMethod') } - const getTreasuryState = response1.data.result + const getTreasuryState = response1.result if (getTreasuryState.exit_code !== 0) { throw new Error('Expected a zero exit code, but got ' + getTreasuryState.exit_code) } @@ -41,10 +41,10 @@ export default { method: 'get_times', stack: [], }) - if (!response2.data.ok) { + if (!response2.ok) { throw new Error('Error in calling toncenter.com/api/v2/runGetMethod') } - const getTimes = response2.data.result + const getTimes = response2.result if (getTimes.exit_code !== 0) { throw new Error('Expected a zero exit code, but got ' + getTimes.exit_code) } diff --git a/fees/holdstation-defutures.ts b/fees/holdstation-defutures.ts index 369fbf85bb..5792f67862 100644 --- a/fees/holdstation-defutures.ts +++ b/fees/holdstation-defutures.ts @@ -24,8 +24,8 @@ const fetch = async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); const fromTimestamp = new Date(dayTimestamp * 1000).toISOString().split("T")[0]; const toTimestamp = new Date((dayTimestamp + 60 * 60 * 24) * 1000).toISOString().split("T")[0]; - const data: IFees = (await fetchURL(historicalVolumeEndpoint(fromTimestamp, toTimestamp))).data.result; - const dailyVolume: DailyVolume[] = (await fetchURL(dailyVolumeEndpoint(fromTimestamp, fromTimestamp))).data; + const data: IFees = (await fetchURL(historicalVolumeEndpoint(fromTimestamp, toTimestamp))).result; + const dailyVolume: DailyVolume[] = (await fetchURL(dailyVolumeEndpoint(fromTimestamp, fromTimestamp))); const dailyFees = data.totalFee; const dailyRevenue = data.govFee; diff --git a/fees/impermax-finance.ts b/fees/impermax-finance.ts index f6829510d7..316ed1089a 100644 --- a/fees/impermax-finance.ts +++ b/fees/impermax-finance.ts @@ -21,7 +21,7 @@ interface IYield { const graphs = () => { return (chain: CHAIN) => { return async (timestamp: number) => { - const poolsCall: IYield[] = (await fetchURL(yieldPool))?.data.data; + const poolsCall: IYield[] = (await fetchURL(yieldPool))?.data; const pools = poolsCall .filter((e: IYield) => e.project === "impermax-finance") .filter((e: IYield) => e.chain.toLowerCase() === chain.toLowerCase()); diff --git a/fees/junoswap.ts b/fees/junoswap.ts index 2838b15e97..f8c2ca55d8 100644 --- a/fees/junoswap.ts +++ b/fees/junoswap.ts @@ -13,7 +13,7 @@ interface IVolumeall { const TOTAL_FEES = 0.003; const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)); const totalVolume = historicalVolume .filter(volItem => getUniqStartOfTodayTimestamp(new Date(volItem.date)) <= dayTimestamp) .reduce((acc, { volume_total }) => acc + Number(volume_total), 0) diff --git a/fees/kiloex/index.ts b/fees/kiloex/index.ts index 98f0d0106f..37a02b8000 100644 --- a/fees/kiloex/index.ts +++ b/fees/kiloex/index.ts @@ -24,7 +24,7 @@ interface IFee { const fetch = (chainId: string) => { return async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const fees: IFee[] = (await fetchURL(endpoints[chainId]))?.data; + const fees: IFee[] = (await fetchURL(endpoints[chainId])); const dailyFees = fees .find(item => item.time === dayTimestamp)?.dayTradeFee diff --git a/fees/kwenta.ts b/fees/kwenta.ts index c4fd90332a..5b0ad38e73 100644 --- a/fees/kwenta.ts +++ b/fees/kwenta.ts @@ -13,7 +13,7 @@ const url = 'https://storage.kwenta.io/25710180-23d8-43f4-b0c9-5b7f55f63165-buck const fetchData = (_: Chain) => { return async (timestamp: number): Promise => { const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp) - const value: IData[] = (await fetchURL(url)).data; + const value: IData[] = (await fetchURL(url)); const dailyFee = value.find((d) => d.timestamp === todaysTimestamp)?.feesKwenta; const totalFees = value.filter((e: IData) => e.timestamp <= todaysTimestamp) .reduce((acc: number, e: IData) => acc + e.feesKwenta, 0) diff --git a/fees/lifinity.ts b/fees/lifinity.ts index 1570111ab6..6a0198532e 100644 --- a/fees/lifinity.ts +++ b/fees/lifinity.ts @@ -16,7 +16,7 @@ const fetch = async (timestamp: number): Promise => { const dateStr = new Date(dayTimestamp * 1000).toLocaleDateString('en-US', { timeZone: 'UTC' }) const [month, day, year] = dateStr.split('/'); const formattedDate = `${year}/${String(month).padStart(2, '0')}/${String(day).padStart(2, '0')}`; - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volume.daily.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).volume.daily.data; const totalFees = historicalVolume .filter(volItem => Number(new Date(volItem.date.split('/').join('-')).getTime() / 1000) <= dayTimestamp) .reduce((acc, { fees }) => acc + Number(fees), 0); @@ -57,7 +57,7 @@ const methodology = { } const getStartTimestamp = async () => { - const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint))?.data.volume.daily.data; + const historicalVolume: IVolumeall[] = (await fetchURL(historicalVolumeEndpoint)).volume.daily.data; return Number(new Date(historicalVolume[0].date.split('/').join('-')).getTime() / 1000) } diff --git a/fees/mango-v4.ts b/fees/mango-v4.ts index 9a558e1619..2e0af6d0cc 100644 --- a/fees/mango-v4.ts +++ b/fees/mango-v4.ts @@ -33,8 +33,8 @@ const methodology = { } const fetchMangoStats = async (timestamp: number): Promise => { - const totalStats: TotalStats = (await fetchURL(urlTotalStats)).data; - const dailyStats: DailyStats = (await fetchURL(urlDailyStats)).data; + const totalStats: TotalStats = (await fetchURL(urlTotalStats)); + const dailyStats: DailyStats = (await fetchURL(urlDailyStats)); return { timestamp, dailyFees: dailyStats.total_fees_24h.toString(), diff --git a/fees/move-dollar.ts b/fees/move-dollar.ts index a677ef9a67..4a9133cab4 100644 --- a/fees/move-dollar.ts +++ b/fees/move-dollar.ts @@ -14,10 +14,10 @@ interface IVolumeall { } const fetch = async (timestamp: number) => { - const dayFeesQuery = (await fetchURL(feesEndpoint(timestamp, "1D")))?.data.data; + const dayFeesQuery = (await fetchURL(feesEndpoint(timestamp, "1D"))).data; const dailyFees = dayFeesQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0); - const totalFeesQuery = (await fetchURL(feesEndpoint(0, "ALL")))?.data.data; + const totalFeesQuery = (await fetchURL(feesEndpoint(0, "ALL"))).data; const totalFees = totalFeesQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0); return { diff --git a/fees/multichain/index.ts b/fees/multichain/index.ts index aadcac5073..0fdea02387 100644 --- a/fees/multichain/index.ts +++ b/fees/multichain/index.ts @@ -6,9 +6,6 @@ import { CHAIN } from "../../helpers/chains"; const stableStatsUrl = "https://bridgeapi.anyswap.exchange/data/stats/stable"; const statsUrl = "https://bridgeapi.anyswap.exchange/data/stats"; -interface ICall { - data: IStats -}; interface IStats { h24fee: string; allfee: string; @@ -16,7 +13,6 @@ interface IStats { const fetch = async (timestamp: number) => { const stats: IStats[] = (await Promise.all([fetchURL(stableStatsUrl),fetchURL(statsUrl)])) - .map((e: ICall) => e.data); const fees = stats.reduce((prev: number, curr: IStats) => prev + Number(curr.h24fee), 0); const totalFees = stats.reduce((prev: number, curr: IStats) => prev + Number(curr.allfee), 0); return { diff --git a/fees/mux.ts b/fees/mux.ts index 267faf549e..fe1b9bc3c5 100644 --- a/fees/mux.ts +++ b/fees/mux.ts @@ -59,8 +59,8 @@ const getFees = (chainId: CHAIN_ID) => { const parameter = `[{"type":"date/single","value":"${dateTime}","target":["variable",["template-tag","timestamp"]],"id":"eff4a885"}]` const feePathUrl = `${feesDataEndpoint}?parameters=${encodeURIComponent(parameter)}&dashboard_id=2` const porPathUrl = `${porDataEndpoint}?parameters=${encodeURIComponent(parameter)}&dashboard_id=2` - const feeData = (await fetchURL(feePathUrl))?.data.data - const por = (await fetchURL(porPathUrl))?.data.data.rows[0][0] + const feeData = (await fetchURL(feePathUrl))?.data + const por = (await fetchURL(porPathUrl))?.data.rows[0][0] const result = formatMetaBaseData(feeData.cols, feeData.rows) as FeesMetaBaseData[] let dailyFees = 0 diff --git a/fees/osmosis.ts b/fees/osmosis.ts index 71f9c34981..dc32919601 100644 --- a/fees/osmosis.ts +++ b/fees/osmosis.ts @@ -12,7 +12,7 @@ interface IChartItem { const fetch = async (timestamp: number) => { const dayTimestamp = getTimestampAtStartOfPreviousDayUTC(timestamp) - const historicalFees: IChartItem[] = (await fetchURL(feeEndpoint))?.data + const historicalFees: IChartItem[] = (await fetchURL(feeEndpoint)) const totalFee = historicalFees .filter(feeItem => (new Date(feeItem.time).getTime() / 1000) <= dayTimestamp) diff --git a/fees/pact.ts b/fees/pact.ts index 0aba7c465f..175838f341 100644 --- a/fees/pact.ts +++ b/fees/pact.ts @@ -7,7 +7,7 @@ interface IAPIResponse { } const url = 'https://api.pact.fi/api/internal/pools_details/all' const fetchFees = async (timestamp: number): Promise => { - const response = (await fetchURL(url)).data.map((e: any) => { return {fee_usd_24h: e.fee_usd_24h}}) as IAPIResponse[] + const response = (await fetchURL(url)).map((e: any) => { return {fee_usd_24h: e.fee_usd_24h}}) as IAPIResponse[] const dailyFees = response.reduce((a: number, b: IAPIResponse) => a + Number(b.fee_usd_24h), 0) return { dailyFees: `${dailyFees}`, diff --git a/fees/paraswap.ts b/fees/paraswap.ts index a37100017c..671b4a3ea8 100644 --- a/fees/paraswap.ts +++ b/fees/paraswap.ts @@ -27,7 +27,7 @@ interface IResponse { const fetch = (chain: Chain) => { return async (timestamp: number): Promise => { const timestampToday = getTimestampAtStartOfDayUTC(timestamp) - const response: IResponse = (await fetchURL(feesMMURL)).data; + const response: IResponse = (await fetchURL(feesMMURL)); const dailyResultFees: any[] = response.daily; const [__,totalPartnerRevenue, totalProtocolRevenue]: number[] = response.allTime[mapChainId[chain]]; const [_, partnerRevenue, protocolRevenue]: number[] = dailyResultFees.filter(([time]: any) => time === timestampToday) diff --git a/fees/pepe-swaves/index.ts b/fees/pepe-swaves/index.ts index f8408405f1..8d94674c3b 100644 --- a/fees/pepe-swaves/index.ts +++ b/fees/pepe-swaves/index.ts @@ -26,11 +26,11 @@ interface IBlockHeader { type RewardShares = { [address: string]: number }; const getData = async (address: string, key: string): Promise => { - return (await fetchURL(`${WAVES_NODE}/addresses/data/${address}/${key}`)).data + return fetchURL(`${WAVES_NODE}/addresses/data/${address}/${key}`) } const getHeaders = async (start: number, end: number): Promise => { - return (await fetchURL(`${WAVES_NODE}/blocks/headers/seq/${start}/${end}`)).data + return fetchURL(`${WAVES_NODE}/blocks/headers/seq/${start}/${end}`) } const extractShareReward = (rewardShares: RewardShares, miner: string): number => { diff --git a/fees/plenty.ts b/fees/plenty.ts index 4681dc7e0a..96d5a5a049 100644 --- a/fees/plenty.ts +++ b/fees/plenty.ts @@ -5,7 +5,7 @@ import { getUniqStartOfTodayTimestamp } from "../helpers/getUniSubgraphVolume"; const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const plentyData = (await fetchURL("https://analytics.plenty.network/api/v1/overall")).data; + const plentyData = (await fetchURL("https://analytics.plenty.network/api/v1/overall")); const dailyFeesItem = plentyData.fees_24hours_dollar; return { @@ -15,7 +15,7 @@ const fetch = async (timestamp: number) => { }; const getStartTime = async () => { - const plentyData = (await fetchURL("https://api.analytics.plenty.network/analytics/plenty")).data; + const plentyData = (await fetchURL("https://api.analytics.plenty.network/analytics/plenty")); return parseInt(Object.keys(plentyData.fees.history[0])[0]); } diff --git a/fees/plexus.ts b/fees/plexus.ts index 1de4dc0b1e..c8fd8d675a 100644 --- a/fees/plexus.ts +++ b/fees/plexus.ts @@ -26,7 +26,7 @@ const fetch = (chainId: number) => { await fetchURL( `https://api.plexus.app/v1/dashboard/fee?date=${dateString}` ) - ).data.data; + ).data; const dailyFee: number = data[chainId] || 0; return { timestamp, diff --git a/fees/rollbit.ts b/fees/rollbit.ts index 14b5a3bbd6..73474f46e1 100644 --- a/fees/rollbit.ts +++ b/fees/rollbit.ts @@ -6,7 +6,7 @@ import { getUniqStartOfTodayTimestamp } from "../helpers/getUniSubgraphVolume"; const fetch = async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) // Doesnt work because of CF block - const historicalVolume: any[] = (await fetchURL(`https://rollbit.com/public/lottery/pools`))?.data.response; + const historicalVolume: any[] = (await fetchURL(`https://rollbit.com/public/lottery/pools`)).response; const dailyDistributed = historicalVolume .find(dayItem => getUniqStartOfTodayTimestamp(new Date(dayItem.distributed_at)) === dayTimestamp)?.distributed diff --git a/fees/scatter.ts b/fees/scatter.ts index 039c63773d..69726a0164 100644 --- a/fees/scatter.ts +++ b/fees/scatter.ts @@ -15,7 +15,7 @@ const graph = (chain: Chain) => { try { const startblock = (await getBlock(fromTimestamp, chain, {})); const endblock = (await getBlock(toTimestamp, chain, {})); - const data: string[] = (await fetchURL('https://scatter-api.fly.dev/api/contracts')).data.body; + const data: string[] = (await fetchURL('https://scatter-api.fly.dev/api/contracts')).body; const to_address = data .map(toBytea) diff --git a/fees/solend.ts b/fees/solend.ts index a238d365cc..1e04040a8e 100644 --- a/fees/solend.ts +++ b/fees/solend.ts @@ -29,7 +29,7 @@ const methodology = { const fetchSolendStats = async (timestamp: number): Promise => { const url = `${solendFeesURL}?ts=${timestamp}&span=24h` - const stats: DailyStats = (await fetchURL(url)).data; + const stats: DailyStats = (await fetchURL(url)); const userFees = parseInt(stats.liquidityProviderInterest) + diff --git a/fees/stormtrade/index.ts b/fees/stormtrade/index.ts index 21a4f1b779..9f50bfa66a 100644 --- a/fees/stormtrade/index.ts +++ b/fees/stormtrade/index.ts @@ -16,14 +16,14 @@ export default { fetch: async () => { const response = await fetchURL('https://api.redoubt.online/dapps/v1/export/defi/storm') - if (!response.data) { + if (!response) { throw new Error('Error during re:doubt API call') } return { - dailyUserFees: response.data.fees.toString(), - dailyFees: response.data.fees.toString(), - timestamp: response.data.timestamp + dailyUserFees: response.fees.toString(), + dailyFees: response.fees.toString(), + timestamp: response.timestamp } }, }, diff --git a/fees/tarot.ts b/fees/tarot.ts index 05a1061a93..bfef0ba573 100644 --- a/fees/tarot.ts +++ b/fees/tarot.ts @@ -15,7 +15,7 @@ interface IYield { const graphs = () => { return (chain: CHAIN) => { return async (timestamp: number) => { - const poolsCall: IYield[] = (await fetchURL(yieldPool))?.data.data; + const poolsCall: IYield[] = (await fetchURL(yieldPool))?.data; const pools = poolsCall .filter((e: IYield) => e.project === "tarot") .filter((e: IYield) => e.chain.toLowerCase() === chain.toLowerCase()); diff --git a/fees/thalaswap.ts b/fees/thalaswap.ts index 2b410f0e50..2ea9461d44 100644 --- a/fees/thalaswap.ts +++ b/fees/thalaswap.ts @@ -19,13 +19,13 @@ interface IVolumeall { const fetch = async (timestamp: number) => { const dayTime = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const dayFeesQuery = (await fetchURL(historicalEndpoint))?.data.data; + const dayFeesQuery = (await fetchURL(historicalEndpoint))?.data; const dailyFees = dayFeesQuery.find((a:IVolumeall) => Number(a.timestamp) === dayTime)?.value; - const totalFeesQuery = (await fetchURL(feesEndpoint(0, "ALL")))?.data.data; + const totalFeesQuery = (await fetchURL(feesEndpoint(0, "ALL")))?.data; const totalFees = totalFeesQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0); - const protocolFeeRatio = (await fetchURL(protocolRatioQueryURL))?.data.data; + const protocolFeeRatio = (await fetchURL(protocolRatioQueryURL))?.data; const dailyProtocolRevenue = dailyFees * protocolFeeRatio; const totalProtocolRevenue = totalFees * protocolFeeRatio; diff --git a/fees/traderjoe.ts b/fees/traderjoe.ts index 21c3ea62e8..a16ec7eabf 100644 --- a/fees/traderjoe.ts +++ b/fees/traderjoe.ts @@ -38,7 +38,7 @@ const adapterV1 = getDexChainFees({ const graph = (chain: Chain) => { return async (timestamp: number): Promise => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) - const historical: IData[] = (await fetchURL(endpointsV2[chain]))?.data; + const historical: IData[] = (await fetchURL(endpointsV2[chain])); const dailyFees = historical .find(dayItem => dayItem.timestamp === dayTimestamp)?.feesUsd const dailyRevenue = historical diff --git a/fees/valas-finance.ts b/fees/valas-finance.ts index 3150bbdfe6..290e99d98e 100644 --- a/fees/valas-finance.ts +++ b/fees/valas-finance.ts @@ -15,7 +15,7 @@ const graphs = () => { return (_: CHAIN) => { return async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); - const historicalVolume: IFees[] = (await fetchURL(yieldPool))?.data.data.dailyFees; + const historicalVolume: IFees[] = (await fetchURL(yieldPool))?.data.dailyFees; const totalFees = historicalVolume .filter((volItem: IFees) => volItem.timestamp <= dayTimestamp) .reduce((acc, { added }) => acc + Number(added), 0) diff --git a/fees/waves/index.ts b/fees/waves/index.ts index f8c8e83d91..848a5ec720 100644 --- a/fees/waves/index.ts +++ b/fees/waves/index.ts @@ -26,10 +26,10 @@ const fetch = async (timestamp: number) => { let blockHeaders: IBlockHeader[] = []; while (startBlock < endBlock) { if (startBlock + limitPerRequest <= endBlock) { - blockHeaders = blockHeaders.concat((await fetchURL(`${blockHeadersEndpoint}/${startBlock}/${startBlock + limitPerRequest}`))?.data); + blockHeaders = blockHeaders.concat((await fetchURL(`${blockHeadersEndpoint}/${startBlock}/${startBlock + limitPerRequest}`))); startBlock += limitPerRequest; } else { - blockHeaders = blockHeaders.concat((await fetchURL(`${blockHeadersEndpoint}/${startBlock}/${endBlock}`))?.data); + blockHeaders = blockHeaders.concat((await fetchURL(`${blockHeadersEndpoint}/${startBlock}/${endBlock}`))); break; } } diff --git a/fees/zunami/index.ts b/fees/zunami/index.ts index 5e94e096c3..1e554c2ddd 100644 --- a/fees/zunami/index.ts +++ b/fees/zunami/index.ts @@ -52,12 +52,12 @@ const getData = (chain: Chain) => { }) )) / FEE_DENOMINATOR - const dailyData: YieldData = (await fetchURL(dataEndpoint(from, to))).data; + const dailyData: YieldData = (await fetchURL(dataEndpoint(from, to))); const dailyRevenue = (dailyData.omnipoolYield * omnipoolManagementFee) + (dailyData.apsYield * apsManagementFee) + dailyData.rigidYield; const dailyHoldersRevenue = dailyData.omnipoolYield + dailyData.apsYield; - const totalData: YieldData = (await fetchURL(dataEndpoint(START_TIMESTAMP, to))).data + const totalData: YieldData = (await fetchURL(dataEndpoint(START_TIMESTAMP, to))) const totalRevenue = (totalData.omnipoolYield * omnipoolManagementFee) + (totalData.apsYield * apsManagementFee) + totalData.rigidYield const totalDailyHoldersRevenue = totalData.omnipoolYield + totalData.apsYield; diff --git a/helpers/aggregators/duneAdapter.ts b/helpers/aggregators/duneAdapter.ts index 7f78b9682e..ada30ae8d0 100644 --- a/helpers/aggregators/duneAdapter.ts +++ b/helpers/aggregators/duneAdapter.ts @@ -1,4 +1,3 @@ -import fetchURL from "../../utils/fetchURL"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; import { fetchURLWithRetry } from "../duneRequest"; @@ -13,39 +12,32 @@ const getAdapter = ( new Date(timestamp * 1000) ); - try { - const data = await ( - await fetchURLWithRetry( - "https://api.dune.com/api/v1/query/3321376/results" - ) - ).data?.result?.rows; + const data = await ( + await fetchURLWithRetry( + "https://api.dune.com/api/v1/query/3321376/results" + ) + ).result?.rows; - const dayData = data.find( - ({ - block_date, - blockchain, - project, - }: { - block_date: number; - blockchain: string; - project: string; - }) => - getUniqStartOfTodayTimestamp(new Date(block_date)) === - unixTimestamp && - blockchain === (chainMap[chain] || chain) && - project === name - ); + const dayData = data.find( + ({ + block_date, + blockchain, + project, + }: { + block_date: number; + blockchain: string; + project: string; + }) => + getUniqStartOfTodayTimestamp(new Date(block_date)) === + unixTimestamp && + blockchain === (chainMap[chain] || chain) && + project === name + ); - return { - dailyVolume: dayData?.trade_amount ?? "0", - timestamp: unixTimestamp, - }; - } catch (e) { - return { - dailyVolume: "0", - timestamp: unixTimestamp, - }; - } + return { + dailyVolume: dayData?.trade_amount ?? "0", + timestamp: unixTimestamp, + }; }; const adapter: any = { diff --git a/helpers/dune.ts b/helpers/dune.ts index da5d2a6e64..91fb586577 100644 --- a/helpers/dune.ts +++ b/helpers/dune.ts @@ -1,65 +1,68 @@ -import axios, { AxiosResponse } from "axios" import retry from "async-retry"; import { IJSON } from "../adapters/types"; +import { httpGet, httpPost } from "../utils/fetchURL"; const token = {} as IJSON const API_KEYS = process.env.DUNE_API_KEYS?.split(',') ?? ["L0URsn5vwgyrWbBpQo9yS1E3C1DBJpZh"] let API_KEY_INDEX = 0; const MAX_RETRIES = 20; -export async function queryDune(queryId: string, query_parameters={}) { +export async function queryDune(queryId: string, query_parameters = {}) { + /* const error = new Error("Dune: queryId is required") + delete error.stack + throw error */ return await retry( async (bail, _attempt: number) => { const API_KEY = API_KEYS[API_KEY_INDEX] - let query: undefined | AxiosResponse = undefined + let query: undefined | any = undefined if (!token[queryId]) { - try{ - query = await axios.post(`https://api.dune.com/api/v1/query/${queryId}/execute`, { - query_parameters - }, { + try { + query = await httpPost(`https://api.dune.com/api/v1/query/${queryId}/execute`, { query_parameters }, { headers: { "x-dune-api-key": API_KEY, 'Content-Type': 'application/json' } }) - if(query?.data?.execution_id){ - token[queryId] = query?.data.execution_id + if (query?.execution_id) { + token[queryId] = query?.execution_id } else { - console.log("error query data", query?.data) - throw query?.data + console.log("error query data", query) + throw query } - } catch(e:any){ + } catch (e: any) { if (API_KEY_INDEX < API_KEYS.length - 1) { console.error('api key out of limit waiting retry next key') API_KEY_INDEX = API_KEY_INDEX + 1 } else { - const error = new Error(`there is no more api key`) - console.error('there is no more api key') + const error = new Error(`Dune: there is no more api key`) + console.error(error.message, e?.message) bail(error) - throw e.error + throw error } } } if (!token[queryId]) { - throw new Error("Couldn't get a token from dune") + const error = new Error("Couldn't get a token from dune") + delete error.stack + throw error } let queryStatus = undefined try { - queryStatus = await axios.get(`https://api.dune.com/api/v1/execution/${token[queryId]}/results`, { + queryStatus = await httpGet(`https://api.dune.com/api/v1/execution/${token[queryId]}/results`, { headers: { "x-dune-api-key": API_KEY } }) - } catch(e:any){ + } catch (e: any) { if (API_KEY_INDEX < API_KEYS.length - 1) { API_KEY_INDEX = API_KEY_INDEX + 1 } else { const error = new Error(`there is no more api key`) console.error('there is no more api key') bail(error) - throw e.error + throw e } } @@ -69,10 +72,10 @@ export async function queryDune(queryId: string, query_parameters={}) { } - const status = queryStatus.data.state + const status = queryStatus.state if (status === "QUERY_STATE_COMPLETED") { return queryStatus.data.result.rows - } else if (status === "QUERY_STATE_FAILED"){ + } else if (status === "QUERY_STATE_FAILED") { console.log(queryStatus.data) const error = new Error("Dune query failed") bail(error) diff --git a/helpers/duneRequest.ts b/helpers/duneRequest.ts index dfe9d33a3f..8dd1226af3 100644 --- a/helpers/duneRequest.ts +++ b/helpers/duneRequest.ts @@ -8,6 +8,9 @@ type IRequest = { const requests: IRequest = {} export async function fetchURLWithRetry(url: string) { + /* const error = new Error("Dune: queryId is required") + delete error.stack + throw error */ if (!requests[url]) requests[url] = _fetchURLWithRetry(url) return requests[url] @@ -23,14 +26,15 @@ async function _fetchURLWithRetry(url: string): Promise { const response = await fetchURL(`${url}?api_key=${api_key}`); return response; } catch (error: any) { - console.log("Failed to fetch url", `${url}?api_key=${api_key}`); + console.log("Dune: Failed to fetch url", `${url}?api_key=${api_key}`); if (API_KEY_INDEX < API_KEYS.length - 1) { API_KEY_INDEX++; } else { - const errorMessage = "All API keys failed"; - console.log(errorMessage); + const errorMessage = "Dune: All API keys failed"; + // console.log(errorMessage); bail(new Error(errorMessage)); } + delete error.stack; throw error; } }, diff --git a/helpers/pool.ts b/helpers/pool.ts index 8e968cc1e3..9ddc9b922f 100644 --- a/helpers/pool.ts +++ b/helpers/pool.ts @@ -10,7 +10,7 @@ const yieldPool = "https://yields.llama.fi/poolsOld"; // get top pool from yield.llama export async function getTopPool(project: string, chain: string): Promise { - const poolsCall: IYield[] = (await fetchURL(yieldPool))?.data.data; + const poolsCall: IYield[] = (await fetchURL(yieldPool))?.data; const poolsData: IYield[] = poolsCall .filter((e: IYield) => e.project === project) .filter((e: IYield) => e.chain.toLowerCase() === chain.toLowerCase()); diff --git a/incentives/bitcoin/index.ts b/incentives/bitcoin/index.ts index e7960e2efa..e1ac75d1a6 100644 --- a/incentives/bitcoin/index.ts +++ b/incentives/bitcoin/index.ts @@ -17,7 +17,7 @@ const getBTCRewardByBlock = (block: number) => BASE_REWARD / Math.trunc((block / const getDailyBlocksByTimestampLast24h = async (timestamp: number) => { const url = `https://blockchain.info/blocks/${timestamp * 1000}?format=json` - return (await fetchURL(url)).data as IResponse + return (await fetchURL(url)) as IResponse } const getIncentives: Fetch = async (timestamp: number): Promise => { diff --git a/options/aevo/index.ts b/options/aevo/index.ts index 7f648ad4b0..a747307653 100644 --- a/options/aevo/index.ts +++ b/options/aevo/index.ts @@ -45,7 +45,7 @@ export async function fetchAevoVolumeData( } async function getAevoVolumeData(endpoint: string): Promise { - return (await fetchURL(endpoint))?.data; + return (await fetchURL(endpoint)); } export default adapter; diff --git a/options/hegic/index.ts b/options/hegic/index.ts index 9b943d574a..4e2fa278fb 100644 --- a/options/hegic/index.ts +++ b/options/hegic/index.ts @@ -49,7 +49,7 @@ export async function fetchArbitrumAnalyticsData( } async function getAnalyticsData(endpoint: string): Promise { - return (await fetchURL(endpoint))?.data; + return (await fetchURL(endpoint)); } function getPositionsForDaily( diff --git a/options/lyra-v2/index.ts b/options/lyra-v2/index.ts index 2cf4f130c2..866c4f1e2a 100644 --- a/options/lyra-v2/index.ts +++ b/options/lyra-v2/index.ts @@ -46,7 +46,7 @@ export async function fetchLyraVolumeData( async function getLyraVolumeData(endpoint: string): Promise { const results = await fetchURL(endpoint) - return results.data.result; + return results.result; } export default v2_adapter;