diff --git a/dexs/cvex/index.ts b/dexs/cvex/index.ts new file mode 100644 index 0000000000..a957ba4633 --- /dev/null +++ b/dexs/cvex/index.ts @@ -0,0 +1,37 @@ +import type { SimpleAdapter } from '../../adapters/types' +import { httpGet } from '../../utils/fetchURL'; +import {CHAIN} from "../../helpers/chains"; + +const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/volume' + +const buildUrl = (baseUrl: string, params: Record) => { + const query = new URLSearchParams(params).toString(); + return `${baseUrl}?${query}`; +}; + +const api = (url: string, ts: any) => { + const fullUrl = buildUrl(url, { timestamp: ts }); + return httpGet(fullUrl).then(res => { + if (res.error) throw new Error(res.error.message); + return res; + }); +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.ARBITRUM]: { + start: 1736328600, + fetch: async (ts) => { + const data = await api(API_SERVICE_URL, ts) + + return { + timestamp: ts, + dailyVolume: data.daily_volume, + totalVolume: data.total_volume, + } + } + } + } +}; + +export default adapter; diff --git a/fees/cvex/index.ts b/fees/cvex/index.ts new file mode 100644 index 0000000000..cc2dc2deb5 --- /dev/null +++ b/fees/cvex/index.ts @@ -0,0 +1,37 @@ +import type { SimpleAdapter } from '../../adapters/types' +import { httpGet } from '../../utils/fetchURL'; +import {CHAIN} from "../../helpers/chains"; + +const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/fee' + +const buildUrl = (baseUrl: string, params: Record) => { + const query = new URLSearchParams(params).toString(); + return `${baseUrl}?${query}`; +}; + +const api = (url: string, ts: any) => { + const fullUrl = buildUrl(url, { timestamp: ts }); + return httpGet(fullUrl).then(res => { + if (res.error) throw new Error(res.error.message); + return res; + }); +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.ARBITRUM]: { + start: 1736328600, + fetch: async (ts) => { + const data = await api(API_SERVICE_URL, ts) + + return { + timestamp: ts, + dailyFees: data.daily_fee, + totalFees: data.total_fee, + } + } + } + } +}; + +export default adapter;