@defillama/sdk 3.0.5 → 3.0.6

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.
@@ -89,6 +89,9 @@ function sumMultiBalanceOf(balances, results, allCallsMustBeSuccessful, transfor
89
89
  }
90
90
  exports.sumMultiBalanceOf = sumMultiBalanceOf;
91
91
  function sumSingleBalance(balances, token, balance, chain) {
92
+ isValidNumber(balance);
93
+ if (+balance === 0)
94
+ return;
92
95
  if (chain)
93
96
  token = "".concat(chain, ":").concat(token);
94
97
  if (typeof balance === 'object') {
@@ -97,11 +100,11 @@ function sumSingleBalance(balances, token, balance, chain) {
97
100
  else
98
101
  throw new Error('Invalid balance value:' + balance);
99
102
  }
100
- if (typeof balance === 'number') {
103
+ if (typeof balance === 'number' || (balances[token] && typeof balances[token] === 'number')) {
101
104
  var prevBalance = +(balances.hasOwnProperty(token) ? balances[token] : 0);
102
105
  if (typeof prevBalance !== 'number' || isNaN(prevBalance))
103
106
  throw new Error("Trying to merge token balance and coingecko amount for ".concat(token, " current balance: ").concat(balance, " previous balance: ").concat(balances[token]));
104
- var value = prevBalance + balance;
107
+ var value = prevBalance + +balance;
105
108
  isValidNumber(value);
106
109
  balances[token] = value;
107
110
  }
@@ -112,7 +115,7 @@ function sumSingleBalance(balances, token, balance, chain) {
112
115
  balances[token] = value;
113
116
  }
114
117
  function isValidNumber(value) {
115
- if (isNaN(value))
118
+ if ([null, undefined].includes(value) || isNaN(+value))
116
119
  throw new Error("Invalid balance: ".concat(balance));
117
120
  }
118
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {