@defillama/sdk 2.3.110 → 2.3.112

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,8 +317,6 @@ function multicallAddress(chainId) {
317
317
  return "0x176CcFFbAB792Aaa0da7C430FE20a7106d969f66";
318
318
  case 53935: // dfk
319
319
  return "0x5b24224dC16508DAD755756639E420817DD4c99E";
320
- case 3000: // echelon
321
- return "0xe6d0cEE385992029Cb64C94A2dF6d0331937B2C8";
322
320
  default:
323
321
  return null;
324
322
  }
@@ -55,5 +55,6 @@ export default function (rawBalances: Balances, timestamp: number | "now", verbo
55
55
  usdTvl: number;
56
56
  usdTokenBalances: ReturnedTokenBalances;
57
57
  tokenBalances: ReturnedTokenBalances;
58
+ rawTokenBalances: ReturnedTokenBalances;
58
59
  }>;
59
60
  export {};
@@ -189,7 +189,7 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
189
189
  if (getCoingeckoLock === void 0) { getCoingeckoLock = function () { return Promise.resolve(); }; }
190
190
  if (coingeckoMaxRetries === void 0) { coingeckoMaxRetries = 3; }
191
191
  return __awaiter(this, void 0, void 0, function () {
192
- var balances, callTokenDecimals_1, chainIds, _i, chains_1, chain, normalizedBalances, _a, _b, tokenAddressOrName, normalizedAddressOrName, normalizedBalance, chain, symbolsAndDecimals, allChainTokenPrices, usdTokenBalances, tokenBalances, usdAmounts, usdTvl;
192
+ var balances, callTokenDecimals_1, chainIds, _i, chains_1, chain, normalizedBalances, _a, _b, tokenAddressOrName, normalizedAddressOrName, normalizedBalance, chain, symbolsAndDecimals, allChainTokenPrices, usdTokenBalances, tokenBalances, rawTokenBalances, usdAmounts, usdTvl;
193
193
  var _this = this;
194
194
  return __generator(this, function (_c) {
195
195
  switch (_c.label) {
@@ -285,6 +285,7 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
285
285
  case 7:
286
286
  usdTokenBalances = {};
287
287
  tokenBalances = {};
288
+ rawTokenBalances = {};
288
289
  usdAmounts = Object.entries(normalizedBalances).map(function (_a) {
289
290
  var address = _a[0], balance = _a[1];
290
291
  return __awaiter(_this, void 0, void 0, function () {
@@ -316,11 +317,13 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
316
317
  amount = Number(balance) / Math.pow(10, Number(tokenDecimals));
317
318
  }
318
319
  price = (_d = chainTokenPrices[normalizedAddress_1.toLowerCase()]) === null || _d === void 0 ? void 0 : _d.usd;
320
+ addTokenBalance(rawTokenBalances, normalizedAddress_1.toLowerCase(), amount);
319
321
  }
320
322
  else {
321
323
  tokenSymbol = address;
322
324
  price = (_e = allChainTokenPrices["coingecko"][address.toLowerCase()]) === null || _e === void 0 ? void 0 : _e.usd;
323
325
  amount = Number(balance);
326
+ addTokenBalance(rawTokenBalances, "coingecko:" + address.toLowerCase(), amount);
324
327
  }
325
328
  if (price === undefined) {
326
329
  if (verbose) {
@@ -362,6 +365,7 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
362
365
  usdTvl: usdTvl,
363
366
  usdTokenBalances: usdTokenBalances,
364
367
  tokenBalances: tokenBalances,
368
+ rawTokenBalances: rawTokenBalances
365
369
  }];
366
370
  }
367
371
  });
package/build/general.js CHANGED
@@ -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://rpc.icecreamswap.com,https://serverrpc.com,https://chainrpc.com,https://mainnet-rpc.brisescan.com", 32520),
107
+ bitgert: createProvider("bitgert", "https://chainrpc.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),
@@ -33,3 +33,10 @@ export declare function getLogs(params: {
33
33
  } | {
34
34
  output: Log[];
35
35
  }>;
36
+ export declare function normalizeAddress(address: string): string;
37
+ export declare function normalizePrefixes(address: string): string;
38
+ export declare function normalizeBalances(balances: {
39
+ [address: string]: string;
40
+ }): {
41
+ [address: string]: string;
42
+ };
@@ -50,10 +50,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.getLogs = exports.kyberTokens = exports.lookupBlock = exports.getLatestBlock = void 0;
53
+ exports.normalizeBalances = exports.normalizePrefixes = exports.normalizeAddress = exports.getLogs = exports.kyberTokens = exports.lookupBlock = exports.getLatestBlock = void 0;
54
+ var bignumber_js_1 = __importDefault(require("bignumber.js"));
54
55
  var general_1 = require("../general");
55
56
  var node_fetch_1 = __importDefault(require("node-fetch"));
56
57
  var ethers_1 = require("ethers");
58
+ var generalUtil_1 = require("../generalUtil");
57
59
  var kavaBlockProvider = {
58
60
  getBlock: function (height) { return __awaiter(void 0, void 0, void 0, function () {
59
61
  return __generator(this, function (_a) {
@@ -264,3 +266,45 @@ function getLogs(params) {
264
266
  });
265
267
  }
266
268
  exports.getLogs = getLogs;
269
+ function normalizeAddress(address) {
270
+ // sol amd tezos case sensitive so no normalising
271
+ var prefix = address.substring(0, address.indexOf(":"));
272
+ if (["solana", "tezos"].includes(prefix))
273
+ return address;
274
+ return address.toLowerCase();
275
+ }
276
+ exports.normalizeAddress = normalizeAddress;
277
+ function normalizePrefixes(address) {
278
+ var normalizedAddress = normalizeAddress(address);
279
+ if (address != normalizedAddress)
280
+ return address;
281
+ return address.startsWith("0x")
282
+ ? "ethereum:" + address.toLowerCase()
283
+ : !address.includes(":")
284
+ ? "coingecko:" + address.toLowerCase()
285
+ : address.toLowerCase();
286
+ }
287
+ exports.normalizePrefixes = normalizePrefixes;
288
+ var ethereumAddress = "0x0000000000000000000000000000000000000000";
289
+ var weth = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
290
+ function normalizeBalances(balances) {
291
+ Object.keys(balances).map(function (key) {
292
+ var _a;
293
+ if (+balances[key] === 0) {
294
+ delete balances[key];
295
+ return;
296
+ }
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);
303
+ if (normalisedKey == key)
304
+ return;
305
+ generalUtil_1.sumSingleBalance(balances, normalisedKey, balances[key]);
306
+ delete balances[key];
307
+ });
308
+ return balances;
309
+ }
310
+ exports.normalizeBalances = normalizeBalances;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "2.3.110",
3
+ "version": "2.3.112",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -18,11 +18,10 @@
18
18
  "author": "",
19
19
  "license": "ISC",
20
20
  "types": "build/index.d.ts",
21
- "files": [
22
- "build"
23
- ],
21
+ "files": ["build"],
24
22
  "dependencies": {
25
23
  "@supercharge/promise-pool": "^2.1.0",
24
+ "bignumber.js": "^9.1.0",
26
25
  "ethers": "^5.4.5",
27
26
  "graphql": "^15.5.0",
28
27
  "graphql-request": "^3.4.0",