@defillama/sdk 2.3.76 → 2.3.77

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.
@@ -249,7 +249,8 @@ function multicallAddress(chainId) {
249
249
  case 592: // astar
250
250
  case 269: // High performance blockchain
251
251
  case 321: // KCC
252
- // case 8217: // Klaytn - multicall doesnt work for some reason
252
+ case 20: // elastos
253
+ case 8217: // Klaytn - multicall doesnt work for some reason
253
254
  // case 88: // tomochain - multicall doesnt work for some reason
254
255
  case 122: // Fuse
255
256
  case 42220: // Celo
@@ -46,6 +46,8 @@ export declare const chainToCoingeckoId: {
46
46
  metis: string;
47
47
  telos: string;
48
48
  moonbeam: string;
49
+ meter: string;
50
+ sx: string;
49
51
  velas: string;
50
52
  milkomeda: string;
51
53
  };
@@ -108,6 +108,8 @@ exports.chainToCoingeckoId = {
108
108
  metis: "metis-andromeda",
109
109
  telos: "telos",
110
110
  moonbeam: "moonbeam",
111
+ meter: "meter",
112
+ sx: "sx-network",
111
113
  velas: "velas",
112
114
  milkomeda: "milkomeda-cardano",
113
115
  };
@@ -11,19 +11,6 @@ export declare function lookupBlock(timestamp: number, extraParams?: {
11
11
  block: number;
12
12
  timestamp: number;
13
13
  }>;
14
- export declare function tokenList(): Promise<({
15
- symbol: string;
16
- contract: string;
17
- decimals: number;
18
- } | {
19
- symbol: string;
20
- contract: string;
21
- decimals?: undefined;
22
- } | {
23
- symbol: string;
24
- contract: string;
25
- decimals: string;
26
- })[]>;
27
14
  export declare function kyberTokens(): Promise<{
28
15
  output: {
29
16
  [address: string]: {
@@ -33,15 +20,6 @@ export declare function kyberTokens(): Promise<{
33
20
  };
34
21
  };
35
22
  }>;
36
- export declare function toSymbols(tokenBalances: {
37
- [address: string]: string;
38
- }): Promise<{
39
- output: {
40
- symbol: string;
41
- address: string;
42
- balance: string;
43
- }[];
44
- }>;
45
23
  export declare function getLogs(params: {
46
24
  target: Address;
47
25
  topic: string;
@@ -50,12 +50,10 @@ 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.toSymbols = exports.kyberTokens = exports.tokenList = exports.lookupBlock = exports.getLatestBlock = void 0;
53
+ exports.getLogs = exports.kyberTokens = exports.lookupBlock = exports.getLatestBlock = void 0;
54
54
  var general_1 = require("../general");
55
55
  var node_fetch_1 = __importDefault(require("node-fetch"));
56
- var tokenList_1 = __importDefault(require("./tokenList"));
57
56
  var ethers_1 = require("ethers");
58
- var erc20_1 = require("../erc20");
59
57
  var kavaBlockProvider = {
60
58
  getBlock: function (height) { return __awaiter(void 0, void 0, void 0, function () {
61
59
  return __generator(this, function (_a) {
@@ -179,15 +177,6 @@ function lookupBlock(timestamp, extraParams) {
179
177
  });
180
178
  }
181
179
  exports.lookupBlock = lookupBlock;
182
- // TODO: Pull the data from somewhere like coingecko
183
- function tokenList() {
184
- return __awaiter(this, void 0, void 0, function () {
185
- return __generator(this, function (_a) {
186
- return [2 /*return*/, tokenList_1.default];
187
- });
188
- });
189
- }
190
- exports.tokenList = tokenList;
191
180
  function kyberTokens() {
192
181
  return __awaiter(this, void 0, void 0, function () {
193
182
  var pairs, tokens;
@@ -213,92 +202,11 @@ function kyberTokens() {
213
202
  });
214
203
  }
215
204
  exports.kyberTokens = kyberTokens;
216
- function toSymbols(tokenBalances) {
217
- return __awaiter(this, void 0, void 0, function () {
218
- var tokens, output;
219
- var _a;
220
- var _this = this;
221
- return __generator(this, function (_b) {
222
- switch (_b.label) {
223
- case 0: return [4 /*yield*/, tokenList()];
224
- case 1:
225
- tokens = _b.sent();
226
- output = Object.entries(tokenBalances).map(function (_a) {
227
- var token = _a[0], balance = _a[1];
228
- return __awaiter(_this, void 0, void 0, function () {
229
- var tokenData, tokenSymbol, tokenDecimals, e_2, decimalBalance, _b, _c, _d, _e, _f, _g;
230
- var _h;
231
- var _j;
232
- return __generator(this, function (_k) {
233
- switch (_k.label) {
234
- case 0:
235
- tokenData = tokens.find(function (possibleToken) {
236
- return possibleToken.contract.toLowerCase() === token.toLowerCase();
237
- });
238
- if (token.toLowerCase() === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") {
239
- tokenData = {
240
- symbol: "ETH",
241
- contract: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
242
- decimals: "18",
243
- };
244
- }
245
- if (!(tokenData === undefined)) return [3 /*break*/, 5];
246
- _k.label = 1;
247
- case 1:
248
- _k.trys.push([1, 4, , 5]);
249
- tokenSymbol = erc20_1.symbol(token);
250
- tokenDecimals = erc20_1.decimals(token);
251
- _h = {};
252
- return [4 /*yield*/, tokenDecimals];
253
- case 2:
254
- _h.decimals = (_k.sent()).output,
255
- _h.contract = token.toLowerCase();
256
- return [4 /*yield*/, tokenSymbol];
257
- case 3:
258
- tokenData = (_h.symbol = (_k.sent()).output,
259
- _h);
260
- return [3 /*break*/, 5];
261
- case 4:
262
- e_2 = _k.sent();
263
- throw new Error("Failed to get token data for token at " + token);
264
- case 5:
265
- _b = Number(balance);
266
- _d = (_c = Math).pow;
267
- _e = [10];
268
- _f = Number;
269
- if (!((_j = tokenData === null || tokenData === void 0 ? void 0 : tokenData.decimals) !== null && _j !== void 0)) return [3 /*break*/, 6];
270
- _g = _j;
271
- return [3 /*break*/, 8];
272
- case 6: return [4 /*yield*/, erc20_1.decimals(token)];
273
- case 7:
274
- _g = (_k.sent()).output;
275
- _k.label = 8;
276
- case 8:
277
- decimalBalance = (_b /
278
- _d.apply(_c, _e.concat([_f.apply(void 0, [_g])]))).toFixed(6);
279
- return [2 /*return*/, {
280
- symbol: tokenData.symbol,
281
- address: tokenData.contract,
282
- balance: decimalBalance,
283
- }];
284
- }
285
- });
286
- });
287
- });
288
- _a = {};
289
- return [4 /*yield*/, Promise.all(output)];
290
- case 2: return [2 /*return*/, (_a.output = _b.sent(),
291
- _a)];
292
- }
293
- });
294
- });
295
- }
296
- exports.toSymbols = toSymbols;
297
205
  // SMALL INCOMPATIBILITY: On the old API we don't return ids but we should
298
206
  function getLogs(params) {
299
207
  var _a;
300
208
  return __awaiter(this, void 0, void 0, function () {
301
- var filter, logs, blockSpread, currentBlock, nextBlock, partLogs, e_3;
209
+ var filter, logs, blockSpread, currentBlock, nextBlock, partLogs, e_2;
302
210
  return __generator(this, function (_b) {
303
211
  switch (_b.label) {
304
212
  case 0:
@@ -328,14 +236,14 @@ function getLogs(params) {
328
236
  currentBlock = nextBlock;
329
237
  return [3 /*break*/, 5];
330
238
  case 4:
331
- e_3 = _b.sent();
239
+ e_2 = _b.sent();
332
240
  if (blockSpread >= 2e3) {
333
241
  // We got too many results
334
242
  // We could chop it up into 2K block spreads as that is guaranteed to always return but then we'll have to make a lot of queries (easily >1000), so instead we'll keep dividing the block spread by two until we make it
335
243
  blockSpread = Math.floor(blockSpread / 2);
336
244
  }
337
245
  else {
338
- throw e_3;
246
+ throw e_2;
339
247
  }
340
248
  return [3 /*break*/, 5];
341
249
  case 5: return [3 /*break*/, 1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "2.3.76",
3
+ "version": "2.3.77",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- export {};