impermax-sdk 2.1.385 → 2.1.387

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.
@@ -77,7 +77,7 @@ exports.ROUTER = {
77
77
  [types_1.Networks.Sxnetwork]: {},
78
78
  [types_1.Networks.Base]: {
79
79
  [types_1.Factory.SOLV2]: '0x98b55cd14450f56355cdefa74d9443d9c48b78cd',
80
- [types_1.Factory.SOL_STABLE]: '',
80
+ [types_1.Factory.SOL_STABLE]: '0x7d2dd9a0421041ec50804965c42fca09a7a6794e',
81
81
  [types_1.Factory.V2V2]: '0x46b9B1a483f5e64A20BBbeeCbf54224167B699df'
82
82
  },
83
83
  [types_1.Networks.Scroll]: {
@@ -96,6 +96,7 @@ exports.ROUTER = {
96
96
  },
97
97
  [types_1.Networks.Sonic]: {
98
98
  [types_1.Factory.SOLV2]: '0xB3B140dBcBC649eCeac74f30487A338e9D129331',
99
+ [types_1.Factory.SOL_STABLE]: '0xD995C49266E3391baFe5dd7135c34018f63eE75C'
99
100
  },
100
101
  [types_1.Networks.Linea]: {
101
102
  [types_1.Factory.SOLV2]: '0x6E658aC2f3C061719C52FB1E56b064cE165CAF31',
@@ -7,8 +7,6 @@ export default class OffchainPriceHelper {
7
7
  private debankTokensPrice;
8
8
  private coingeckoInitialized;
9
9
  private coingeckoTokenPrices;
10
- private geckoTerminalInitialized;
11
- private geckoTerminalTokenPrices;
12
10
  constructor(offchainMultichain: OffchainMultichain);
13
11
  cleanCache(): void;
14
12
  private addPriceIfMissing;
@@ -18,8 +16,6 @@ export default class OffchainPriceHelper {
18
16
  }>;
19
17
  private getAllCoingeckoPrices;
20
18
  private getCoingeckoTokenPrice;
21
- private getAllGeckoTerminalPrices;
22
- private getGeckoTerminalTokenPrice;
23
19
  private getDexscreenerTokenPrice;
24
20
  private initializeDebankTokenPrice;
25
21
  getDebankTokenPrice(network: Networks, tokenAddress: Address): Promise<number>;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("../config/types");
4
3
  // coingecko has priority over debank for initialized tokens
5
4
  const coingecko_ids = {
6
5
  //Polygon
@@ -59,6 +58,11 @@ const coingecko_ids = {
59
58
  "0xce1581d7b4ba40176f0e219b2cac30088ad50c7a": "pearl",
60
59
  // blast
61
60
  "0x52f847356b38720b55ee18cb3e094ca11c85a192": "fenix",
61
+ "0xb785ee8752b8bf3b0c8d9857f24b491e8c0a3d92": "coinbase-wrapped-btc",
62
+ // sonic
63
+ "0x3333b97138d4b086720b5ae8a7844b1345a33333": "shadow-2",
64
+ // linea
65
+ "0x894134a25a5fac1c2c26f1d8fbf05111a3cb9487": "grai"
62
66
  };
63
67
  const dexscreener_ids = {
64
68
  // ibex on scroll
@@ -79,49 +83,19 @@ const dexscreener_ids = {
79
83
  "0xc38464250f51123078bbd7ea574e185f6623d037": "optimism",
80
84
  // fantom-bomb on scroll (removed from coingecko)
81
85
  "0x6b6882f7642ee1c15f12b51f1a4988b3e7e29f5c": "scroll",
86
+ // EliteringssUSDC
87
+ "0xd4aa386bfceeedd9de0875b3ba07f51808592e22": "sonic"
82
88
  };
83
- const geckoTerminalTokens = [
84
- "arbitrum:0xde903e2712288a1da82942dddf2c20529565ac30",
85
- "arbitrum:0x2e9a6df78e42a30712c10a9dc4b1c8656f8f2879",
86
- "arbitrum:0x3b475f6f2f41853706afc9fa6a6b8c5df1a2724c",
87
- "polygon:0x1d607faa0a51518a7728580c238d912747e71f7a",
88
- "polygon:0xc25351811983818c9fe6d8c580531819c8ade90f",
89
- "polygon:0x4eac4c4e9050464067d673102f8e24b2fcceb350",
90
- "polygon:0xc25351811983818c9fe6d8c580531819c8ade90f"
91
- ];
92
- /** Map of our network to geckoTerminal network id */
93
- const GECKOTERMINAL_IDS = {
94
- [types_1.Networks.Avalanche]: "avax",
95
- [types_1.Networks.Mainnet]: "eth",
96
- [types_1.Networks.Polygon]: "polygon_pos",
97
- [types_1.Networks.Arbitrum]: "arbitrum",
98
- [types_1.Networks.Fantom]: "ftm",
99
- [types_1.Networks.Base]: "base",
100
- [types_1.Networks.Scroll]: "scroll",
101
- [types_1.Networks.Optimism]: "optimism",
102
- [types_1.Networks.Real]: "re-al",
103
- [types_1.Networks.Mantle]: "mantle",
104
- [types_1.Networks.Canto]: "canto",
105
- [types_1.Networks.Blast]: "blast",
106
- [types_1.Networks.Sonic]: "sonic",
107
- [types_1.Networks.Linea]: "linea",
108
- [types_1.Networks.ZksyncEra]: "zksync",
109
- };
110
- const MAX_GECKO_COINS = 30;
111
- // NOTE: Geckoterminal and coingecko functions copied from our indexer
112
89
  // Sources used so far:
113
90
  // 1. Our subgraphs
114
91
  // 2. Coingecko
115
- // 3. Geckoterminal
116
- // 4. DexScreener
92
+ // 3. DexScreener
117
93
  class OffchainPriceHelper {
118
94
  // No need for dexscreener mutex since it allows only one token per call
119
95
  constructor(offchainMultichain) {
120
96
  // Initialize the subgraph prices for each network
121
97
  this.subgraphTokensPrice = {};
122
98
  this.coingeckoInitialized = null;
123
- this.geckoTerminalInitialized = null;
124
- this.geckoTerminalTokenPrices = {};
125
99
  this.offchainMultichain = offchainMultichain;
126
100
  this.debankTokensPrice = {};
127
101
  }
@@ -212,53 +186,7 @@ class OffchainPriceHelper {
212
186
  return geckoPrice || 0;
213
187
  }
214
188
  /* -----------------------------------------------------------------------
215
- * 3. GeckoTerminal
216
- * ----------------------------------------------------------------------*/
217
- async getAllGeckoTerminalPrices() {
218
- // GeckoTerminal only allows to fetch multiple tokens from a single network in 1 api call
219
- // so we group all the tokens passed by network to loop through each one.
220
- const tokensByChain = geckoTerminalTokens.reduce((acc, tokenId) => {
221
- const network = tokenId.split(":")[0];
222
- if (!acc[network])
223
- acc[network] = [];
224
- acc[network].push(tokenId);
225
- return acc;
226
- }, {});
227
- // Go through each network
228
- try {
229
- for (const [network, tokens] of Object.entries(tokensByChain)) {
230
- const geckoNetwork = GECKOTERMINAL_IDS[network];
231
- if (!geckoNetwork) {
232
- console.error(`GeckoTerminal ID missing for network: ${network}`);
233
- continue;
234
- }
235
- for (let i = 0; i < tokens.length; i += MAX_GECKO_COINS) {
236
- const maxTokens = tokens.slice(i, i + MAX_GECKO_COINS);
237
- const tokenIds = maxTokens.map((tokenId) => tokenId.split(":")[1]).join(",");
238
- const { data } = await fetch(`https://api.geckoterminal.com/api/v2/simple/networks/${geckoNetwork}/token_price/${tokenIds}`).then((res) => res.json());
239
- for (const tokenId of maxTokens) {
240
- const tokenAddress = tokenId.split(":")[1];
241
- const tokenPrice = data.attributes.token_prices[tokenAddress];
242
- if (tokenPrice)
243
- this.geckoTerminalTokenPrices[tokenAddress] = tokenPrice;
244
- }
245
- }
246
- }
247
- }
248
- catch (error) {
249
- console.error("Gecko prices fail: %s", error.message);
250
- }
251
- }
252
- ;
253
- async getGeckoTerminalTokenPrice(tokenAddress) {
254
- if (!this.geckoTerminalInitialized)
255
- this.geckoTerminalInitialized = this.getAllGeckoTerminalPrices();
256
- await this.geckoTerminalInitialized;
257
- const geckoPrice = this.geckoTerminalTokenPrices[tokenAddress];
258
- return geckoPrice || 0;
259
- }
260
- /* -----------------------------------------------------------------------
261
- * 4. Dexscreener
189
+ * 3. Dexscreener
262
190
  * ----------------------------------------------------------------------*/
263
191
  async getDexscreenerTokenPrice(tokenAddress) {
264
192
  try {
@@ -298,11 +226,6 @@ class OffchainPriceHelper {
298
226
  if (result)
299
227
  return result;
300
228
  }
301
- if (geckoTerminalTokens.some(token => token.endsWith(tokenAddress.toLowerCase()))) {
302
- const result = await this.getGeckoTerminalTokenPrice(tokenAddress);
303
- if (result)
304
- return result;
305
- }
306
229
  return 0;
307
230
  }
308
231
  // TODO: Simplify this logic and reove the old temporaries we dont need anymore
@@ -25,8 +25,6 @@ class OffchainPriceHelper {
25
25
  async getTokenPriceOld(network, tokenAddress) {
26
26
  // Initializes v1 prices once if necessary
27
27
  const price = await this.offchainPriceHelperV1.getDebankTokenPrice(network, tokenAddress);
28
- if (price === 0)
29
- console.log("Missing price: ", network, tokenAddress);
30
28
  return price;
31
29
  }
32
30
  /* -----------------------------------------------------------------------
@@ -66,9 +64,9 @@ class OffchainPriceHelper {
66
64
  // in case diff tokens have same address on diff networks
67
65
  const key = `${chainId_1.CHAIN_IDS[network]}-${tokenAddress.toLowerCase()}`;
68
66
  // First try get token price from our price-aggregator
69
- const token = apiData?.tokens[key];
70
- if (token)
71
- return parseFloat(token.derivedUSD);
67
+ const priceUsd = apiData?.tokens[key]?.priceUsd;
68
+ if (priceUsd)
69
+ return parseFloat(priceUsd);
72
70
  // Fallback to price old
73
71
  return this.getTokenPriceOld(network, tokenAddress);
74
72
  }
@@ -236,7 +236,7 @@ class PonderQueryBuilder {
236
236
  return this.userQueryV3(account, network, factory);
237
237
  return (0, graphql_tag_1.default) `{
238
238
  user(id: "${account.toLowerCase()}") {
239
- collateralPositions(limit:1000, where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}"}) {
239
+ collateralPositions(limit:1000, where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}", balance_not: "0"}) {
240
240
  items {
241
241
  balance
242
242
  collateral {
@@ -246,7 +246,7 @@ class PonderQueryBuilder {
246
246
  }
247
247
  }
248
248
  }
249
- supplyPositions(limit:1000, where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}"}) {
249
+ supplyPositions(limit:1000, where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}", balance_not: "0"}) {
250
250
  items {
251
251
  balance
252
252
  cumulativeEarnings
@@ -261,7 +261,7 @@ class PonderQueryBuilder {
261
261
  }
262
262
  }
263
263
  }
264
- borrowPositions(limit:1000, where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}"}) {
264
+ borrowPositions(limit:1000, where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}", borrowBalance_not: "0"}) {
265
265
  items {
266
266
  borrowBalance
267
267
  borrowIndex
@@ -141,7 +141,7 @@ class TheGraphQueryBuilder {
141
141
  factory;
142
142
  return (0, graphql_tag_1.default) `{
143
143
  user(id: "${account.toLowerCase()}") {
144
- collateralPositions(first:1000) {
144
+ collateralPositions(first: 1000, where: { balance_gt: "0" }) {
145
145
  balance
146
146
  collateral {
147
147
  lendingPool {
@@ -149,7 +149,7 @@ class TheGraphQueryBuilder {
149
149
  }
150
150
  }
151
151
  }
152
- supplyPositions(first:1000) {
152
+ supplyPositions(first:1000, where: { balance_gt: "0" }) {
153
153
  balance
154
154
  lastExchangeRate
155
155
  cumulativeEarnings
@@ -162,7 +162,7 @@ class TheGraphQueryBuilder {
162
162
  }
163
163
  }
164
164
  }
165
- borrowPositions(first:1000) {
165
+ borrowPositions(first:1000, where: { borrowBalance_gt: "0" }) {
166
166
  borrowBalance
167
167
  borrowIndex
168
168
  borrowable {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.385",
3
+ "version": "2.1.387",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",