@defillama/sdk 5.0.1 → 5.0.3
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.
- package/build/general.js +2 -1
- package/build/generalUtil.js +32 -2
- package/build/util/index.js +2 -0
- package/package.json +1 -1
package/build/general.js
CHANGED
|
@@ -69,7 +69,8 @@ function createProvider(name, rpcString, chainId) {
|
|
|
69
69
|
* any other value is in ms. (default: ``250``)
|
|
70
70
|
*/
|
|
71
71
|
var batchMaxSize = 10 * (1024 * 1024); // 10Mb
|
|
72
|
-
|
|
72
|
+
// some rpcs throw error if batchMaxCount is set higher than 100
|
|
73
|
+
var jsonRpcApiProviderOptions = { staticNetwork: true, batchStallTime: 42, batchMaxSize: batchMaxSize, batchMaxCount: 99, cacheTimeout: 5 * 1000 };
|
|
73
74
|
if (url.startsWith('wss://')) {
|
|
74
75
|
delete jsonRpcApiProviderOptions.batchMaxCount;
|
|
75
76
|
return new ethers_1.ethers.WebSocketProvider(url, networkish, jsonRpcApiProviderOptions);
|
package/build/generalUtil.js
CHANGED
|
@@ -109,11 +109,41 @@ function sumSingleBalance(balances, token, balance, chain) {
|
|
|
109
109
|
balances[token] = value;
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
|
-
var prevBalance =
|
|
113
|
-
var value = (prevBalance +
|
|
112
|
+
var prevBalance = getBigInt(balances[token]);
|
|
113
|
+
var value = (prevBalance + getBigInt(balance));
|
|
114
114
|
isValidNumber(Number(value));
|
|
115
115
|
balances[token] = Number(value).toString();
|
|
116
116
|
}
|
|
117
|
+
function getBigInt(value) {
|
|
118
|
+
var balance = value;
|
|
119
|
+
if (!value)
|
|
120
|
+
return BigInt(0);
|
|
121
|
+
if (typeof value === 'bigint')
|
|
122
|
+
return value;
|
|
123
|
+
if (typeof value === 'number')
|
|
124
|
+
value = value.toString();
|
|
125
|
+
if (typeof value === 'string') {
|
|
126
|
+
if (value.includes('e')) { // Convert scientific notation to standard notation
|
|
127
|
+
var _a = value.split('e'), base = _a[0], e = _a[1];
|
|
128
|
+
var _b = base.split('.'), lead = _b[0], decimal = _b[1];
|
|
129
|
+
var final = void 0;
|
|
130
|
+
var exponent = +e;
|
|
131
|
+
if (exponent >= 0) {
|
|
132
|
+
final = lead + (decimal || '') + '0'.repeat(exponent - (decimal || '').length);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// NOTE: unforutenately BigInt doesn't support negative exponents, so this ends up being 0
|
|
136
|
+
exponent = exponent * -1;
|
|
137
|
+
final = BigInt(lead) / BigInt('1' + Array(exponent).fill(0).join(''));
|
|
138
|
+
}
|
|
139
|
+
return BigInt(final);
|
|
140
|
+
}
|
|
141
|
+
return BigInt(value);
|
|
142
|
+
}
|
|
143
|
+
if (typeof value === 'string')
|
|
144
|
+
return BigInt(value);
|
|
145
|
+
throw new Error("Invalid balance: ".concat(balance));
|
|
146
|
+
}
|
|
117
147
|
function isValidNumber(value) {
|
|
118
148
|
if (typeof value === 'bigint')
|
|
119
149
|
return;
|
package/build/util/index.js
CHANGED
|
@@ -129,6 +129,8 @@ function getLogs(params) {
|
|
|
129
129
|
output: logs.map(function (log) { return log.topics; })
|
|
130
130
|
}];
|
|
131
131
|
}
|
|
132
|
+
// ethers v5 logs had this but not ethers v6, so adding field to keep it compatible
|
|
133
|
+
logs.forEach(function (log) { var _a; return log.logIndex = (_a = log.logIndex) !== null && _a !== void 0 ? _a : log.index; });
|
|
132
134
|
return [2 /*return*/, {
|
|
133
135
|
output: logs
|
|
134
136
|
}];
|