-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2301 from vladjito/master
Volume and Fees for CVEX
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |