diff --git a/dexs/myx-finance/index.ts b/dexs/myx-finance/index.ts index e5149c5f39..9006902082 100644 --- a/dexs/myx-finance/index.ts +++ b/dexs/myx-finance/index.ts @@ -1,6 +1,5 @@ -import { ChainEndpoints, Fetch, FetchOptions, SimpleAdapter } from "../../adapters/types"; +import { ChainEndpoints, FetchOptions, SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; -import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; import fetchURL from "../../utils/fetchURL"; const endpoints: ChainEndpoints = { @@ -16,22 +15,9 @@ const methodology = { const getFetch = async (optios: FetchOptions) => { const result = await fetchURL(endpoints[optios.chain]) - const dayTimestamp = getUniqStartOfTodayTimestamp(new Date((optios.endTimestamp * 1000))) + const dailyVolume = result.data.reduce((acc, item) => acc + (item?.target_volume || 0), 0) - - const volume = result.data.reduce((acc, item) => { - return acc + (item?.target_volume || 0) - }, 0) - - console.log({ - timestamp: dayTimestamp, - dailyVolume: volume || "0", - }) - - return { - timestamp: dayTimestamp, - dailyVolume: volume || "0", - } + return { dailyVolume } } @@ -46,6 +32,7 @@ const adapter: SimpleAdapter = { return { ...acc, [chain]: { + runAtCurrTime: true, fetch: getFetch, start: startTimestamps[chain], meta: { diff --git a/fees/myx-finance/index.tsx b/fees/myx-finance/index.tsx index 02f32fb02e..3f4e3ff0bc 100644 --- a/fees/myx-finance/index.tsx +++ b/fees/myx-finance/index.tsx @@ -1,4 +1,4 @@ -import { SimpleAdapter, FetchResultFees, FetchOptions } from "../../adapters/types"; +import { SimpleAdapter, FetchOptions } from "../../adapters/types"; import fetchURL from "../../utils/fetchURL"; import { CHAIN } from "../../helpers/chains"; @@ -30,29 +30,28 @@ const fetchApi = async (type: FetchType, startTime: number, endTime: number) => return data } -const fetchFees = async (_t: any, _b: any, optios: FetchOptions) => { - const start = optios.startOfDay; - const end = start + 86400; - const dailyAlls: Data[] = await fetchApi(FetchType.DAILY, start, end) - const dailyFees = dailyAlls.find((daily: Data)=> daily.chainId === optios.toApi.chainId) +const fetchFees = async ({ fromTimestamp, toTimestamp, api }: FetchOptions) => { + const chainId = api.chainId + const dailyAlls: Data[] = await fetchApi(FetchType.DAILY, fromTimestamp, toTimestamp ) + const dailyFees = dailyAlls.find((daily: Data)=> daily.chainId === chainId) - const totalAlls: Data[] = await fetchApi(FetchType.TOTAL, start, end) - const totalFees = totalAlls.find((daily: Data)=> daily.chainId === optios.toApi.chainId) + const totalAlls: Data[] = await fetchApi(FetchType.TOTAL, fromTimestamp, toTimestamp ) + const totalFees = totalAlls.find((daily: Data)=> daily.chainId === chainId) return { totalFees: totalFees?.tradingFee, dailyFees: dailyFees?.tradingFee, - timestamp: optios.startTimestamp } } const startTimestamps: { [chain: string]: number } = { [CHAIN.ARBITRUM]: 1706659200, [CHAIN.LINEA]: 1708473600, + [CHAIN.OP_BNB]: 1727443900 } const adapter: SimpleAdapter = { - version: 1, + version: 2, adapter: { [CHAIN.ARBITRUM]: { fetch: fetchFees, @@ -68,6 +67,13 @@ const adapter: SimpleAdapter = { methodology } }, + [CHAIN.OP_BNB]: { + fetch: fetchFees, + start: startTimestamps[CHAIN.OP_BNB], + meta: { + methodology + } + }, } }