impermax-sdk 1.2.57 → 1.2.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -46,9 +46,6 @@ const coingecko_ids = {
|
|
|
46
46
|
"0x4200000000000000000000000000000000000006": "ethereum",
|
|
47
47
|
"0x54016a4848a38f257b6e96331f7404073fd9c32c": "equalizer-base",
|
|
48
48
|
"0xa3d1a8deb97b111454b294e2324efad13a9d8396": "overnight-finance",
|
|
49
|
-
// fantom
|
|
50
|
-
"0x3fd3a0c85b70754efc07ac9ac0cbbdce664865a6": "equalizer-dex",
|
|
51
|
-
"0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83": "wrapped-fantom"
|
|
52
49
|
};
|
|
53
50
|
const dexscreener_ids = {
|
|
54
51
|
// ibex on scroll
|
|
@@ -61,8 +58,12 @@ const dexscreener_ids = {
|
|
|
61
58
|
"0xbe9f8c0d6f0fd7e46cdacca340747ea2f247991d": "zksync",
|
|
62
59
|
// fantom-bomb on scroll
|
|
63
60
|
"0x74ccbe53f77b08632ce0cb91d3a545bf6b8e0979": "scroll",
|
|
61
|
+
// more on scroll
|
|
62
|
+
"0x25ea98ac87a38142561ea70143fd44c4772a16b6": "scroll",
|
|
64
63
|
// axlOP on base
|
|
65
64
|
"0x994ac01750047B9d35431a7Ae4Ed312ee955E030": "base",
|
|
65
|
+
};
|
|
66
|
+
const fantom_ids = {
|
|
66
67
|
// uponly on ftm
|
|
67
68
|
"0x28f1d1c509495e5afc23fb47acf6cc5b217ab598": "fantom",
|
|
68
69
|
// plus-bet on ftm
|
|
@@ -81,6 +82,10 @@ const dexscreener_ids = {
|
|
|
81
82
|
"0xd361474bb19c8b98870bb67f5759cdf277dee7f9": "fantom",
|
|
82
83
|
// thc on fantom
|
|
83
84
|
"0x479673391b3818f5e3ed2fa69a58e13d685becf6": "fantom",
|
|
85
|
+
// equal
|
|
86
|
+
"0x3fd3a0c85b70754efc07ac9ac0cbbdce664865a6": "equalizer-dex",
|
|
87
|
+
// wftm
|
|
88
|
+
"0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83": "wrapped-fantom",
|
|
84
89
|
};
|
|
85
90
|
class OffchainPriceHelper {
|
|
86
91
|
constructor(offchain) {
|
|
@@ -130,7 +135,6 @@ class OffchainPriceHelper {
|
|
|
130
135
|
return this.subgraphTokensPrice;
|
|
131
136
|
});
|
|
132
137
|
}
|
|
133
|
-
// Second source of token price: Debank (more accurate, slower)
|
|
134
138
|
getCoingeckoTokenPrice(tokenAddress) {
|
|
135
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
140
|
try {
|
|
@@ -167,8 +171,31 @@ class OffchainPriceHelper {
|
|
|
167
171
|
}
|
|
168
172
|
});
|
|
169
173
|
}
|
|
174
|
+
getFantomTokenPrice(tokenAddress) {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
try {
|
|
177
|
+
const response = yield fetch("https://eqapi-beta-8868m.ondigitalocean.app/fantom/v4/tokens");
|
|
178
|
+
if (response.status != 200)
|
|
179
|
+
return 0;
|
|
180
|
+
const data = yield response.json();
|
|
181
|
+
if (!data || !data.data)
|
|
182
|
+
return 0;
|
|
183
|
+
const priceData = data.data;
|
|
184
|
+
const priceItem = Object.keys(priceData).filter((keyId) => keyId.toLowerCase() == tokenAddress);
|
|
185
|
+
return priceItem.length > 0 ? Number(priceData[priceItem[0]].priceUsd) : 0;
|
|
186
|
+
}
|
|
187
|
+
catch (_a) {
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
170
192
|
initializeDebankTokenPrice(tokenAddress) {
|
|
171
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
if (Object.keys(fantom_ids).includes(tokenAddress.toLowerCase())) {
|
|
195
|
+
const result = yield this.getFantomTokenPrice(tokenAddress);
|
|
196
|
+
if (result)
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
172
199
|
if (Object.keys(dexscreener_ids).includes(tokenAddress.toLowerCase())) {
|
|
173
200
|
const result = yield this.getDexscreenerTokenPrice(tokenAddress.toLowerCase());
|
|
174
201
|
if (result)
|
|
@@ -180,21 +207,6 @@ class OffchainPriceHelper {
|
|
|
180
207
|
return result;
|
|
181
208
|
}
|
|
182
209
|
return 0;
|
|
183
|
-
// openapi is currently failing always so just commented out
|
|
184
|
-
// try {
|
|
185
|
-
// const response = await fetch("https://openapi.debank.com/v1/token?chain_id=" + DEBANK_IDS[this.offchain.network] + "&id=" + tokenAddress);
|
|
186
|
-
// /*const response = await fetch(
|
|
187
|
-
// "https://pro-openapi.debank.com/v1/token?chain_id=" + debank_chain_ids[this.offchain.network] + "&id=" + tokenAddress,
|
|
188
|
-
// {headers: {"AccessKey": "0ac0fba6aeb0905b4c9a1c5cfd9d48d74fbc60e0"}}
|
|
189
|
-
// );*/
|
|
190
|
-
// if (response.status != 200) return 0;
|
|
191
|
-
// const data = await response.json();
|
|
192
|
-
// if (!data) return 0;
|
|
193
|
-
// return data.price ? data.price : 0;
|
|
194
|
-
// }
|
|
195
|
-
// catch {
|
|
196
|
-
// return 0;
|
|
197
|
-
// }
|
|
198
210
|
});
|
|
199
211
|
}
|
|
200
212
|
getDebankTokenPrice(tokenAddress) {
|