From 1addbfd217c4d7ec8587149051ea1a1d4fa66f90 Mon Sep 17 00:00:00 2001 From: vladjito <95035799+vladjito@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:08:36 +0100 Subject: [PATCH 1/6] Create index.ts --- dexs/cvex/index.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 dexs/cvex/index.ts diff --git a/dexs/cvex/index.ts b/dexs/cvex/index.ts new file mode 100644 index 0000000000..9eaa3ce902 --- /dev/null +++ b/dexs/cvex/index.ts @@ -0,0 +1,34 @@ +import type { SimpleAdapter } from '../../adapters/types' +import { httpPost } from '../../utils/fetchURL'; +import {CHAIN} from "../../helpers/chains"; + +const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/volume' + +const api = (url: string, ts: any) => + httpPost(url, { timestamp: ts }, + { headers: { 'Content-Type': 'application/json', } } + ).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; From 3a2773f07a8d2ab705c125d0f1a1e96c84f63ce5 Mon Sep 17 00:00:00 2001 From: vladjito <95035799+vladjito@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:13:49 +0100 Subject: [PATCH 2/6] Create index.ts --- fees/cvex/index.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 fees/cvex/index.ts diff --git a/fees/cvex/index.ts b/fees/cvex/index.ts new file mode 100644 index 0000000000..96a2d51d0f --- /dev/null +++ b/fees/cvex/index.ts @@ -0,0 +1,34 @@ +import type { SimpleAdapter } from '../../adapters/types' +import { httpPost } from '../../utils/fetchURL'; +import {CHAIN} from "../../helpers/chains"; + +const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/fee' + +const api = (url: string, ts: any) => + httpPost(url, { timestamp: ts }, + { headers: { 'Content-Type': 'application/json', } } + ).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; From 46d9a859f21e0f21a9b3e3e335b824b628b1498a Mon Sep 17 00:00:00 2001 From: vladjito <95035799+vladjito@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:17:59 +0100 Subject: [PATCH 3/6] Update index.ts --- dexs/cvex/index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dexs/cvex/index.ts b/dexs/cvex/index.ts index 9eaa3ce902..f99d8df1d4 100644 --- a/dexs/cvex/index.ts +++ b/dexs/cvex/index.ts @@ -4,15 +4,18 @@ import {CHAIN} from "../../helpers/chains"; const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/volume' -const api = (url: string, ts: any) => - httpPost(url, { timestamp: ts }, - { headers: { 'Content-Type': 'application/json', } } - ).then(res => { - if (res.error) - throw new Error(res.error.message) +const buildUrl = (baseUrl: string, params: Record) => { + const query = new URLSearchParams(params).toString(); + return `${baseUrl}?${query}`; +}; - return res +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: { From 562ed0ffcac3d9270295d8523ff16b1010c3f718 Mon Sep 17 00:00:00 2001 From: vladjito <95035799+vladjito@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:18:43 +0100 Subject: [PATCH 4/6] Update index.ts --- fees/cvex/index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fees/cvex/index.ts b/fees/cvex/index.ts index 96a2d51d0f..e3c9ec882c 100644 --- a/fees/cvex/index.ts +++ b/fees/cvex/index.ts @@ -4,15 +4,18 @@ import {CHAIN} from "../../helpers/chains"; const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/fee' -const api = (url: string, ts: any) => - httpPost(url, { timestamp: ts }, - { headers: { 'Content-Type': 'application/json', } } - ).then(res => { - if (res.error) - throw new Error(res.error.message) +const buildUrl = (baseUrl: string, params: Record) => { + const query = new URLSearchParams(params).toString(); + return `${baseUrl}?${query}`; +}; - return res +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: { From 0c6402d710eb1d5cb0433f1bd2ffc27cac4a82f2 Mon Sep 17 00:00:00 2001 From: vladjito <95035799+vladjito@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:31:57 +0100 Subject: [PATCH 5/6] Update index.ts --- dexs/cvex/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dexs/cvex/index.ts b/dexs/cvex/index.ts index f99d8df1d4..a957ba4633 100644 --- a/dexs/cvex/index.ts +++ b/dexs/cvex/index.ts @@ -1,5 +1,5 @@ import type { SimpleAdapter } from '../../adapters/types' -import { httpPost } from '../../utils/fetchURL'; +import { httpGet } from '../../utils/fetchURL'; import {CHAIN} from "../../helpers/chains"; const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/volume' From 929c8bcd690fca3ab23db0432ab213d250c9824f Mon Sep 17 00:00:00 2001 From: vladjito <95035799+vladjito@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:34:37 +0100 Subject: [PATCH 6/6] Update index.ts --- fees/cvex/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fees/cvex/index.ts b/fees/cvex/index.ts index e3c9ec882c..cc2dc2deb5 100644 --- a/fees/cvex/index.ts +++ b/fees/cvex/index.ts @@ -1,5 +1,5 @@ import type { SimpleAdapter } from '../../adapters/types' -import { httpPost } from '../../utils/fetchURL'; +import { httpGet } from '../../utils/fetchURL'; import {CHAIN} from "../../helpers/chains"; const API_SERVICE_URL = 'https://api.cvex.trade/v1/statistics/fee'