@defillama/sdk 4.0.80 → 5.0.1

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.
@@ -245,13 +245,12 @@ var intialBlocks = {
245
245
  };
246
246
  var blockTimeCache = (0, cache_1.getTempLocalCache)({ file: 'BlockCache.json', defaultData: {} });
247
247
  function validateCurrentBlock(block, chain) {
248
- var _a, _b, _c, _d, _e, _f;
249
248
  if (chain === void 0) { chain = 'ethereum'; }
250
249
  var provider = getExtraProvider(chain);
251
250
  var now = Math.floor(Date.now() / 1000);
252
251
  var minutesDiff = Math.floor((now - block.timestamp) / 60);
253
252
  if (minutesDiff > 60)
254
- throw new Error("Last block for ".concat(chain, " is ").concat(minutesDiff, " minutes behind (").concat(new Date(block.timestamp * 1000), "). Provider is \"").concat((_b = (_a = provider === null || provider === void 0 ? void 0 : provider.connection) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : (_f = (_e = (_d = ((_c = provider === null || provider === void 0 ? void 0 : provider.providerConfigs) !== null && _c !== void 0 ? _c : [])[0]) === null || _d === void 0 ? void 0 : _d.provider) === null || _e === void 0 ? void 0 : _e.connection) === null || _f === void 0 ? void 0 : _f.url, "\""));
253
+ throw new Error("Last block for ".concat(chain, " is ").concat(minutesDiff, " minutes behind (").concat(new Date(block.timestamp * 1000), "). Provider is \"").concat((0, generalUtil_1.getProviderUrl)(provider), "\""));
255
254
  }
256
255
  function lookupBlock(timestamp, extraParams) {
257
256
  var _a, _b;
@@ -236,6 +236,7 @@ function getTempLocalCache(_a) {
236
236
  var fileData = emptyFile;
237
237
  var filePath = getFilePath(file);
238
238
  var saveCacheFlag = false;
239
+ createSubPath(path.dirname(filePath)); // create folder if not exists, this is async but we don't care
239
240
  try {
240
241
  var data = _fs.readFileSync(filePath);
241
242
  fileData = JSON.parse(data.toString());
@@ -256,9 +257,7 @@ function getTempLocalCache(_a) {
256
257
  removePromisesAndFunctions(fileData);
257
258
  _fs.writeFileSync(filePath, JSON.stringify(fileData));
258
259
  }
259
- catch (error) {
260
- (0, debugLog_1.debugLog)('Error writing cache:', error, file);
261
- }
260
+ catch (error) { }
262
261
  }
263
262
  function removePromisesAndFunctions(data) {
264
263
  if (typeof data === 'object') {
@@ -1,6 +1,6 @@
1
1
  import { Chain } from "../general";
2
2
  import type { Address } from "../types";
3
- import type { Log } from "@ethersproject/abstract-provider";
3
+ import { ethers } from "ethers";
4
4
  import runInPromisePoolOrig from "./promisePool";
5
5
  export { getLatestBlock, getTimestamp, lookupBlock, } from "./blocks";
6
6
  export declare const runInPromisePool: typeof runInPromisePoolOrig;
@@ -14,9 +14,9 @@ export declare function getLogs(params: {
14
14
  topics?: string[];
15
15
  chain?: Chain;
16
16
  }): Promise<{
17
- output: string[][];
17
+ output: (readonly string[])[];
18
18
  } | {
19
- output: Log[];
19
+ output: ethers.Log[];
20
20
  }>;
21
21
  export declare function normalizeAddress(address: string): string;
22
22
  export declare function normalizePrefixes(address: string): string;
@@ -84,7 +84,7 @@ function getLogs(params) {
84
84
  }
85
85
  filter = {
86
86
  address: params.target,
87
- topics: (_a = params.topics) !== null && _a !== void 0 ? _a : [ethers_1.utils.id(params.topic)],
87
+ topics: (_a = params.topics) !== null && _a !== void 0 ? _a : [ethers_1.ethers.id(params.topic)],
88
88
  fromBlock: params.fromBlock,
89
89
  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
90
90
  };
@@ -173,7 +173,7 @@ function normalizeBalances(balances) {
173
173
  });
174
174
  var eth = balances[ethereumAddress];
175
175
  if (eth !== undefined) {
176
- balances[weth] = ethers_1.BigNumber.from((_a = balances[weth]) !== null && _a !== void 0 ? _a : 0).add(eth).toString();
176
+ balances[weth] = (BigInt((_a = balances[weth]) !== null && _a !== void 0 ? _a : 0) + BigInt(eth)).toString();
177
177
  delete balances[ethereumAddress];
178
178
  }
179
179
  return balances;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "4.0.80",
3
+ "version": "5.0.1",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@aws-sdk/client-s3": "^3.400.0",
27
27
  "@supercharge/promise-pool": "^2.1.0",
28
- "ethers": "^5.4.5",
28
+ "ethers": "^6.0.0",
29
29
  "node-fetch": "^2.6.7",
30
30
  "p-limit": "^3.0.0",
31
31
  "tron-format-address": "^0.1.11"
@@ -34,8 +34,8 @@
34
34
  "@types/jest": "^29.2.3",
35
35
  "@types/node-fetch": "^2.5.8",
36
36
  "jest": "^29.3.1",
37
- "ts-jest": "^29.0.3",
37
+ "ts-jest": "^29.1.1",
38
38
  "ts-node": "^10.9.1",
39
- "typescript": "^4.2.3"
39
+ "typescript": "^5.0.0"
40
40
  }
41
41
  }