-
Notifications
You must be signed in to change notification settings - Fork 1
/
covalent.js
52 lines (50 loc) · 1.57 KB
/
covalent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const axios = require("axios").default;
const config = require("./config");
async function getData(url) {
try {
console.log(url);
const response = await axios.get(url);
return response.data;
} catch (error) {
console.error(error);
return false;
}
}
module.exports.getHealth = async function getHealth(chainID, dexName) {
const url = `${config.covalentURL}/v1/${chainID}/xy=k/${dexName}/health/?key=${config.covalentAPIKey}`;
return await getData(url);
};
module.exports.getInfo = async function (chainID, dexName) {
const url = `${config.covalentURL}/v1/${chainID}/xy=k/${dexName}/ecosystem/?key=${config.covalentAPIKey}`;
return await getData(url);
};
module.exports.getPools = async function (
chainID,
dexName,
pageSize = 100,
pageNumber = 0
) {
const url = `${config.covalentURL}/v1/${chainID}/xy=k/${dexName}/pools/?key=${config.covalentAPIKey}&page-size=${pageSize}&page-number=${pageNumber}`;
return await getData(url);
};
module.exports.getPoolData = async function (chainID, dexName, address) {};
module.exports.getPoolTransactions = async function (
chainID,
dexName,
address
) {};
module.exports.getTokens = async function (
chainID,
dexName,
pageSize = 100,
pageNumber = 0
) {
const url = `${config.covalentURL}/v1/${chainID}/xy=k/${dexName}/tokens/?key=${config.covalentAPIKey}&page-size=${pageSize}&page-number=${pageNumber}`;
return await getData(url);
};
module.exports.getTokenData = async function (chainID, dexName, address) {};
module.exports.getTokenTransactions = async function (
chainID,
dexName,
address
) {};