Skip to content

Commit

Permalink
Merge pull request #2301 from vladjito/master
Browse files Browse the repository at this point in the history
Volume and Fees for CVEX
  • Loading branch information
dtmkeng authored Jan 16, 2025
2 parents 5237000 + 929c8bc commit 1e320f4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
37 changes: 37 additions & 0 deletions dexs/cvex/index.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>) => {
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;
37 changes: 37 additions & 0 deletions fees/cvex/index.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>) => {
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;

0 comments on commit 1e320f4

Please sign in to comment.