@defillama/sdk 4.0.80 → 4.0.81

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.
@@ -25,5 +25,10 @@ export declare class Balances {
25
25
  getBalances(): BalancesV1;
26
26
  removeTokenBalance(token: string): void;
27
27
  getUSDValue(): Promise<number>;
28
+ getUSDJSONs(): Promise<{
29
+ usdTvl: number;
30
+ usdTokenBalances: BalancesV1;
31
+ rawTokenBalances: BalancesV1;
32
+ }>;
28
33
  }
29
34
  export default Balances;
package/build/Balances.js CHANGED
@@ -141,6 +141,19 @@ var Balances = /** @class */ (function () {
141
141
  });
142
142
  });
143
143
  };
144
+ Balances.prototype.getUSDJSONs = function () {
145
+ return __awaiter(this, void 0, void 0, function () {
146
+ var _a, usdTvl, usdTokenBalances;
147
+ return __generator(this, function (_b) {
148
+ switch (_b.label) {
149
+ case 0: return [4 /*yield*/, (0, computeTVL_1.default)(this.getBalances(), this.timestamp)];
150
+ case 1:
151
+ _a = _b.sent(), usdTvl = _a.usdTvl, usdTokenBalances = _a.usdTokenBalances;
152
+ return [2 /*return*/, { usdTvl: usdTvl, usdTokenBalances: usdTokenBalances, rawTokenBalances: this.getBalances() }];
153
+ }
154
+ });
155
+ });
156
+ };
144
157
  return Balances;
145
158
  }());
146
159
  exports.Balances = Balances;
@@ -47,5 +47,11 @@ export declare class ChainApi {
47
47
  blacklistedTokens?: string[];
48
48
  blacklistedOwners?: string[];
49
49
  }): Promise<BalancesV1>;
50
+ getUSDValue(): Promise<number>;
51
+ getUSDJSONs(): Promise<{
52
+ usdTvl: number;
53
+ usdTokenBalances: BalancesV1;
54
+ rawTokenBalances: BalancesV1;
55
+ }>;
50
56
  }
51
57
  export default ChainApi;
package/build/ChainApi.js CHANGED
@@ -236,6 +236,20 @@ var ChainApi = /** @class */ (function () {
236
236
  });
237
237
  });
238
238
  };
239
+ ChainApi.prototype.getUSDValue = function () {
240
+ return __awaiter(this, void 0, void 0, function () {
241
+ return __generator(this, function (_a) {
242
+ return [2 /*return*/, this._balances.getUSDValue()];
243
+ });
244
+ });
245
+ };
246
+ ChainApi.prototype.getUSDJSONs = function () {
247
+ return __awaiter(this, void 0, void 0, function () {
248
+ return __generator(this, function (_a) {
249
+ return [2 /*return*/, this._balances.getUSDJSONs()];
250
+ });
251
+ });
252
+ };
239
253
  return ChainApi;
240
254
  }());
241
255
  exports.ChainApi = ChainApi;
@@ -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') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "4.0.80",
3
+ "version": "4.0.81",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {