@defillama/sdk 2.3.112 → 2.3.114

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.
@@ -317,6 +317,10 @@ function multicallAddress(chainId) {
317
317
  return "0x176CcFFbAB792Aaa0da7C430FE20a7106d969f66";
318
318
  case 53935: // dfk
319
319
  return "0x5b24224dC16508DAD755756639E420817DD4c99E";
320
+ case 3000: // echelon
321
+ return "0xe6d0cEE385992029Cb64C94A2dF6d0331937B2C8";
322
+ case 55: // zyx
323
+ return "0xd0dd5446f58D6f4F4A669f289E4268c1b12AEc31";
320
324
  default:
321
325
  return null;
322
326
  }
@@ -55,6 +55,5 @@ export default function (rawBalances: Balances, timestamp: number | "now", verbo
55
55
  usdTvl: number;
56
56
  usdTokenBalances: ReturnedTokenBalances;
57
57
  tokenBalances: ReturnedTokenBalances;
58
- rawTokenBalances: ReturnedTokenBalances;
59
58
  }>;
60
59
  export {};
@@ -45,6 +45,7 @@ var humanizeNumber_1 = require("./humanizeNumber");
45
45
  var prices_1 = require("./prices");
46
46
  var node_fetch_1 = __importDefault(require("node-fetch"));
47
47
  var generalUtil_1 = require("../generalUtil");
48
+ var index_1 = require("./../util/index");
48
49
  function tokenMulticall(addresses, abi, chain) {
49
50
  return abi_1.multiCall({
50
51
  abi: abi,
@@ -299,11 +300,11 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
299
300
  chains.forEach(function (chain) {
300
301
  if (address.startsWith(chain)) {
301
302
  chainSelector_1 = chain;
302
- normalizedAddress_1 = address.slice(chain.length + 1);
303
+ normalizedAddress_1 = index_1.normalizeAddress(address.slice(chain.length + 1));
303
304
  }
304
305
  });
305
306
  chainTokenPrices = (_b = allChainTokenPrices[chainSelector_1]) !== null && _b !== void 0 ? _b : {};
306
- chainAddress_1 = chainSelector_1 + ":" + normalizedAddress_1.toLowerCase();
307
+ chainAddress_1 = chainSelector_1 + ":" + normalizedAddress_1;
307
308
  coinData = symbolsAndDecimals.find(function (coin) { return coin.coin === chainAddress_1; });
308
309
  tokenSymbol = (_c = coinData === null || coinData === void 0 ? void 0 : coinData.symbol) === null || _c === void 0 ? void 0 : _c.toUpperCase();
309
310
  if (tokenSymbol === undefined || tokenSymbol === null) {
@@ -316,14 +317,14 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
316
317
  else {
317
318
  amount = Number(balance) / Math.pow(10, Number(tokenDecimals));
318
319
  }
319
- price = (_d = chainTokenPrices[normalizedAddress_1.toLowerCase()]) === null || _d === void 0 ? void 0 : _d.usd;
320
- addTokenBalance(rawTokenBalances, normalizedAddress_1.toLowerCase(), amount);
320
+ price = (_d = chainTokenPrices[normalizedAddress_1]) === null || _d === void 0 ? void 0 : _d.usd;
321
+ //addTokenBalance(rawTokenBalances, normalizedAddress, amount)
321
322
  }
322
323
  else {
323
324
  tokenSymbol = address;
324
325
  price = (_e = allChainTokenPrices["coingecko"][address.toLowerCase()]) === null || _e === void 0 ? void 0 : _e.usd;
325
326
  amount = Number(balance);
326
- addTokenBalance(rawTokenBalances, "coingecko:" + address.toLowerCase(), amount);
327
+ //addTokenBalance(rawTokenBalances, `coingecko:${address.toLowerCase()}`, amount)
327
328
  }
328
329
  if (price === undefined) {
329
330
  if (verbose) {
@@ -365,7 +366,7 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
365
366
  usdTvl: usdTvl,
366
367
  usdTokenBalances: usdTokenBalances,
367
368
  tokenBalances: tokenBalances,
368
- rawTokenBalances: rawTokenBalances
369
+ //rawTokenBalances
369
370
  }];
370
371
  }
371
372
  });
package/build/general.js CHANGED
@@ -64,7 +64,7 @@ exports.providers = {
64
64
  boba: createProvider("boba", "https://mainnet.boba.network/", 288),
65
65
  cronos: createProvider("cronos", "https://cronosrpc-1.xstaking.sg,https://evm.cronos.org,https://rpc.vvs.finance,https://evm-cronos.crypto.org", 25),
66
66
  polis: createProvider("polis", "https://rpc.polis.tech", 333999),
67
- zyx: createProvider("zyx", "https://rpc-1.zyx.network/,https://rpc-2.zyx.network/,https://rpc-3.zyx.network/,https://rpc-5.zyx.network/", 55),
67
+ zyx: createProvider("zyx", "https://rpc-6.zyx.network,https://rpc-4.zyx.network,https://rpc-1.zyx.network/,https://rpc-2.zyx.network/,https://rpc-3.zyx.network/,https://rpc-5.zyx.network/", 55),
68
68
  telos: createProvider("telos", "https://mainnet.telos.net/evm,https://rpc1.eu.telos.net/evm,https://rpc1.us.telos.net/evm", 40),
69
69
  metis: createProvider("metis", "https://andromeda.metis.io/?owner=1088", 1088),
70
70
  ubiq: createProvider("ubiq", "https://rpc.octano.dev", 8),
@@ -104,7 +104,7 @@ exports.providers = {
104
104
  ontology_evm: createProvider("ontology_evm", "https://dappnode1.ont.io:10339", 58),
105
105
  jfin: createProvider("jfin", "https://rpc.jfinchain.com/", 3501),
106
106
  bitkub: createProvider("bitkub", "https://rpc.bitkubchain.io/", 96),
107
- bitgert: createProvider("bitgert", "https://chainrpc.com", 32520),
107
+ bitgert: createProvider("bitgert", "https://rpc.icecreamswap.com,https://serverrpc.com,https://chainrpc.com,https://mainnet-rpc.brisescan.com", 32520),
108
108
  canto: createProvider("canto", "https://jsonrpc.canto.nodestake.top,https://canto.evm.chandrastation.com/", 7700),
109
109
  dogechain: createProvider("dogechain", "https://dogechain.ankr.com,https://rpc.dogechain.dog,https://rpc01-sg.dogechain.dog,https://rpc02-sg.dogechain.dog,https://rpc03-sg.dogechain.dog", 2000),
110
110
  posi: createProvider("posi", "https://api.posichain.org,https://api.s0.posichain.org", 900000),
@@ -63,10 +63,10 @@ var kavaBlockProvider = {
63
63
  .then(function (res) { return res.json(); })
64
64
  .then(function (block) { return ({
65
65
  number: Number(block.block.header.height),
66
- timestamp: Math.round(Date.parse(block.block.header.time) / 1000),
66
+ timestamp: Math.round(Date.parse(block.block.header.time) / 1000)
67
67
  }); })];
68
68
  });
69
- }); },
69
+ }); }
70
70
  };
71
71
  var terraBlockProvider = {
72
72
  getBlock: function (height) { return __awaiter(void 0, void 0, void 0, function () {
@@ -75,10 +75,10 @@ var terraBlockProvider = {
75
75
  .then(function (res) { return res.json(); })
76
76
  .then(function (block) { return ({
77
77
  number: Number(block.block.header.height),
78
- timestamp: Math.round(Date.parse(block.block.header.time) / 1000),
78
+ timestamp: Math.round(Date.parse(block.block.header.time) / 1000)
79
79
  }); })];
80
80
  });
81
- }); },
81
+ }); }
82
82
  };
83
83
  function getBlock(provider, height, chain) {
84
84
  return __awaiter(this, void 0, void 0, function () {
@@ -89,7 +89,7 @@ function getBlock(provider, height, chain) {
89
89
  case 1:
90
90
  block = _a.sent();
91
91
  if (block === null) {
92
- throw new Error("Can't get block of chain " + (chain !== null && chain !== void 0 ? chain : 'ethereum'));
92
+ throw new Error("Can't get block of chain " + (chain !== null && chain !== void 0 ? chain : "ethereum"));
93
93
  }
94
94
  return [2 /*return*/, block];
95
95
  }
@@ -132,14 +132,15 @@ function lookupBlock(timestamp, extraParams) {
132
132
  return [4 /*yield*/, getBlock(provider, "latest", extraParams.chain)];
133
133
  case 1:
134
134
  lastBlock = _f.sent();
135
- if (extraParams.chain !== 'bsc' && (lastBlock.timestamp - timestamp) < -30 * 60) {
135
+ if (extraParams.chain !== "bsc" &&
136
+ lastBlock.timestamp - timestamp < -30 * 60) {
136
137
  throw new Error("Last block of chain \"" + extraParams.chain + "\" is further than 30 minutes into the past. Provider is \"" + ((_b = (_a = provider) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b.url) + "\"");
137
138
  }
138
139
  if (Math.abs(lastBlock.timestamp - timestamp) < 60) {
139
140
  // Short-circuit in case we are trying to get the current block
140
141
  return [2 /*return*/, {
141
142
  block: lastBlock.number,
142
- timestamp: lastBlock.timestamp,
143
+ timestamp: lastBlock.timestamp
143
144
  }];
144
145
  }
145
146
  high = lastBlock.number;
@@ -162,17 +163,18 @@ function lookupBlock(timestamp, extraParams) {
162
163
  if (high - low > 4) return [3 /*break*/, 2];
163
164
  _f.label = 5;
164
165
  case 5:
165
- if (extraParams.chain !== 'bsc' && Math.abs(block.timestamp - timestamp) > 3600) {
166
+ if (extraParams.chain !== "bsc" &&
167
+ Math.abs(block.timestamp - timestamp) > 3600) {
166
168
  throw new Error("Block selected is more than 1 hour away from the requested timestamp");
167
169
  }
168
170
  return [2 /*return*/, {
169
171
  block: block.number,
170
- timestamp: block.timestamp,
172
+ timestamp: block.timestamp
171
173
  }];
172
174
  case 6:
173
175
  e_1 = _f.sent();
174
176
  console.log(e_1);
175
- throw new Error("Couldn't find block height for chain " + ((_e = extraParams.chain) !== null && _e !== void 0 ? _e : 'ethereum') + ", RPC node rugged");
177
+ throw new Error("Couldn't find block height for chain " + ((_e = extraParams.chain) !== null && _e !== void 0 ? _e : "ethereum") + ", RPC node rugged");
176
178
  case 7: return [2 /*return*/];
177
179
  }
178
180
  });
@@ -192,12 +194,12 @@ function kyberTokens() {
192
194
  acc[pair.contractAddress] = {
193
195
  symbol: pair.symbol,
194
196
  decimals: pair.decimals,
195
- ethPrice: pair.currentPrice,
197
+ ethPrice: pair.currentPrice
196
198
  };
197
199
  return acc;
198
200
  }, {});
199
201
  return [2 /*return*/, {
200
- output: tokens,
202
+ output: tokens
201
203
  }];
202
204
  }
203
205
  });
@@ -219,7 +221,7 @@ function getLogs(params) {
219
221
  address: params.target,
220
222
  topics: (_a = params.topics) !== null && _a !== void 0 ? _a : [ethers_1.utils.id(params.topic)],
221
223
  fromBlock: params.fromBlock,
222
- toBlock: params.toBlock, // We don't replicate Defipulse's bug because the results end up being the same anyway and hopefully they'll eventually fix it
224
+ toBlock: params.toBlock // We don't replicate Defipulse's bug because the results end up being the same anyway and hopefully they'll eventually fix it
223
225
  };
224
226
  logs = [];
225
227
  blockSpread = params.toBlock - params.fromBlock;
@@ -255,11 +257,11 @@ function getLogs(params) {
255
257
  throw new Error("Unsupported");
256
258
  }
257
259
  return [2 /*return*/, {
258
- output: logs.map(function (log) { return log.topics; }),
260
+ output: logs.map(function (log) { return log.topics; })
259
261
  }];
260
262
  }
261
263
  return [2 /*return*/, {
262
- output: logs,
264
+ output: logs
263
265
  }];
264
266
  }
265
267
  });
@@ -275,8 +277,8 @@ function normalizeAddress(address) {
275
277
  }
276
278
  exports.normalizeAddress = normalizeAddress;
277
279
  function normalizePrefixes(address) {
278
- var normalizedAddress = normalizeAddress(address);
279
- if (address != normalizedAddress)
280
+ var prefix = address.substring(0, address.indexOf(":"));
281
+ if (["solana", "tezos"].includes(prefix))
280
282
  return address;
281
283
  return address.startsWith("0x")
282
284
  ? "ethereum:" + address.toLowerCase()
@@ -285,26 +287,26 @@ function normalizePrefixes(address) {
285
287
  : address.toLowerCase();
286
288
  }
287
289
  exports.normalizePrefixes = normalizePrefixes;
288
- var ethereumAddress = "0x0000000000000000000000000000000000000000";
289
- var weth = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
290
+ var ethereumAddress = "ethereum:0x0000000000000000000000000000000000000000";
291
+ var weth = "ethereum:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
290
292
  function normalizeBalances(balances) {
293
+ var _a;
291
294
  Object.keys(balances).map(function (key) {
292
- var _a;
293
295
  if (+balances[key] === 0) {
294
296
  delete balances[key];
295
297
  return;
296
298
  }
297
- var eth = balances[ethereumAddress];
298
- if (eth !== undefined) {
299
- balances[weth] = new bignumber_js_1.default((_a = balances[weth]) !== null && _a !== void 0 ? _a : 0).plus(eth).toFixed(0);
300
- delete balances[ethereumAddress];
301
- }
302
- var normalisedKey = normalizeAddress(key);
299
+ var normalisedKey = normalizePrefixes(key);
303
300
  if (normalisedKey == key)
304
301
  return;
305
302
  generalUtil_1.sumSingleBalance(balances, normalisedKey, balances[key]);
306
303
  delete balances[key];
307
304
  });
305
+ var eth = balances[ethereumAddress];
306
+ if (eth !== undefined) {
307
+ balances[weth] = new bignumber_js_1.default((_a = balances[weth]) !== null && _a !== void 0 ? _a : 0).plus(eth).toFixed(0);
308
+ delete balances[ethereumAddress];
309
+ }
308
310
  return balances;
309
311
  }
310
312
  exports.normalizeBalances = normalizeBalances;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "2.3.112",
3
+ "version": "2.3.114",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {