impermax-sdk 1.2.56 → 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.
@@ -13,6 +13,7 @@ export default class OffchainPriceHelper {
13
13
  }>;
14
14
  private getCoingeckoTokenPrice;
15
15
  private getDexscreenerTokenPrice;
16
+ private getFantomTokenPrice;
16
17
  private initializeDebankTokenPrice;
17
18
  getDebankTokenPrice(tokenAddress: Address): Promise<number>;
18
19
  }
@@ -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) {
@@ -118,6 +123,8 @@ class OffchainPriceHelper {
118
123
  offchainTokenPrice["0x60bb3d364b765c497c8ce50ae0ae3f0882c5bd05"] = 0;
119
124
  offchainTokenPrice["0x900f1ec5819fa087d368877cd03b265bf1802667"] = 0;
120
125
  offchainTokenPrice["0xea38f1ccf77bf43f352636241b05dd8f6f5f52b2"] = 0;
126
+ offchainTokenPrice["0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83"] = 0;
127
+ offchainTokenPrice["0xc19669a405067927865b40ea045a2baabbbe57f5"] = 0;
121
128
  return offchainTokenPrice;
122
129
  });
123
130
  }
@@ -128,7 +135,6 @@ class OffchainPriceHelper {
128
135
  return this.subgraphTokensPrice;
129
136
  });
130
137
  }
131
- // Second source of token price: Debank (more accurate, slower)
132
138
  getCoingeckoTokenPrice(tokenAddress) {
133
139
  return __awaiter(this, void 0, void 0, function* () {
134
140
  try {
@@ -165,8 +171,31 @@ class OffchainPriceHelper {
165
171
  }
166
172
  });
167
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
+ }
168
192
  initializeDebankTokenPrice(tokenAddress) {
169
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
+ }
170
199
  if (Object.keys(dexscreener_ids).includes(tokenAddress.toLowerCase())) {
171
200
  const result = yield this.getDexscreenerTokenPrice(tokenAddress.toLowerCase());
172
201
  if (result)
@@ -178,21 +207,6 @@ class OffchainPriceHelper {
178
207
  return result;
179
208
  }
180
209
  return 0;
181
- // openapi is currently failing always so just commented out
182
- // try {
183
- // const response = await fetch("https://openapi.debank.com/v1/token?chain_id=" + DEBANK_IDS[this.offchain.network] + "&id=" + tokenAddress);
184
- // /*const response = await fetch(
185
- // "https://pro-openapi.debank.com/v1/token?chain_id=" + debank_chain_ids[this.offchain.network] + "&id=" + tokenAddress,
186
- // {headers: {"AccessKey": "0ac0fba6aeb0905b4c9a1c5cfd9d48d74fbc60e0"}}
187
- // );*/
188
- // if (response.status != 200) return 0;
189
- // const data = await response.json();
190
- // if (!data) return 0;
191
- // return data.price ? data.price : 0;
192
- // }
193
- // catch {
194
- // return 0;
195
- // }
196
210
  });
197
211
  }
198
212
  getDebankTokenPrice(tokenAddress) {
@@ -215,6 +229,9 @@ class OffchainPriceHelper {
215
229
  if (tokenAddress.toLowerCase() === '0x2fc5cf65fd0a660801f119832b2158756968266d') { // TEMPORARY fix for CHI
216
230
  return 1;
217
231
  }
232
+ if (tokenAddress.toLowerCase() === '0xc19669a405067927865b40ea045a2baabbbe57f5') { // TEMPORARY fix for STAR
233
+ return 1;
234
+ }
218
235
  if (tokenAddress.toLowerCase() === '0xb79dd08ea68a908a97220c76d19a6aa9cbde4376') { // TEMPORARY fix for usd+
219
236
  return 1;
220
237
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "1.2.56",
3
+ "version": "1.2.58",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",