@curvefi/api 2.66.13 → 2.66.14
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/lib/pools/utils.js +5 -4
- package/package.json +1 -1
package/lib/pools/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ import { curve } from "../curve.js";
|
|
|
12
12
|
import { _getRewardsFromApi, _getUsdRate, _setContracts, toBN } from "../utils.js";
|
|
13
13
|
import { _getAllPoolsFromApi } from "../external-api.js";
|
|
14
14
|
import ERC20Abi from "../constants/abis/ERC20.json" with { type: 'json' };
|
|
15
|
-
const BATCH_SIZE =
|
|
15
|
+
const BATCH_SIZE = 50;
|
|
16
16
|
const batchedMulticall = (calls) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const results = [];
|
|
18
18
|
for (let i = 0; i < calls.length; i += BATCH_SIZE) {
|
|
@@ -33,14 +33,15 @@ const _getUserLpBalances = (pools, address, useCache) => __awaiter(void 0, void
|
|
|
33
33
|
for (const poolId of poolsToFetch) {
|
|
34
34
|
const pool = getPool(poolId);
|
|
35
35
|
calls.push(curve.contracts[pool.lpToken].multicallContract.balanceOf(address));
|
|
36
|
-
if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
|
|
36
|
+
if (pool.gauge.address && pool.gauge.address !== curve.constants.ZERO_ADDRESS) {
|
|
37
37
|
calls.push(curve.contracts[pool.gauge.address].multicallContract.balanceOf(address));
|
|
38
|
+
}
|
|
38
39
|
}
|
|
39
40
|
const _rawBalances = yield batchedMulticall(calls);
|
|
40
41
|
for (const poolId of poolsToFetch) {
|
|
41
42
|
const pool = getPool(poolId);
|
|
42
43
|
let _balance = _rawBalances.shift();
|
|
43
|
-
if (pool.gauge.address !== curve.constants.ZERO_ADDRESS)
|
|
44
|
+
if (pool.gauge.address && pool.gauge.address !== curve.constants.ZERO_ADDRESS)
|
|
44
45
|
_balance = _balance + _rawBalances.shift();
|
|
45
46
|
if (!_userLpBalanceCache[address])
|
|
46
47
|
_userLpBalanceCache[address] = {};
|
|
@@ -253,7 +254,7 @@ const _getUserClaimableUseApi = (pools, address, useCache) => __awaiter(void 0,
|
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
}
|
|
256
|
-
const rawRewardInfo = yield
|
|
257
|
+
const rawRewardInfo = yield batchedMulticall(rewardInfoCalls);
|
|
257
258
|
for (let i = 0; i < poolsToFetch.length; i++) {
|
|
258
259
|
const poolId = poolsToFetch[i];
|
|
259
260
|
const pool = getPool(poolId);
|