@curvefi/api 2.66.13 → 2.66.15
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 +8 -7
- 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] = {};
|
|
@@ -129,7 +130,7 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
129
130
|
rewardTokenCalls.push(rewardMulticallContract[method]());
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
|
-
const rawRewardTokens = (yield
|
|
133
|
+
const rawRewardTokens = (yield batchedMulticall(rewardTokenCalls)).map((t) => t.toLowerCase());
|
|
133
134
|
const rewardTokens = {};
|
|
134
135
|
for (let i = 0; i < poolsToFetch.length; i++) {
|
|
135
136
|
rewardTokens[poolsToFetch[i]] = [];
|
|
@@ -169,7 +170,7 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
|
-
const rawRewardInfo = yield
|
|
173
|
+
const rawRewardInfo = yield batchedMulticall(rewardInfoCalls);
|
|
173
174
|
for (let i = 0; i < poolsToFetch.length; i++) {
|
|
174
175
|
const poolId = poolsToFetch[i];
|
|
175
176
|
const pool = getPool(poolId);
|
|
@@ -190,7 +191,7 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
190
191
|
}
|
|
191
192
|
for (const token of rewardTokens[poolId]) {
|
|
192
193
|
const symbol = rawRewardInfo.shift();
|
|
193
|
-
const decimals = rawRewardInfo.shift();
|
|
194
|
+
const decimals = Number(rawRewardInfo.shift());
|
|
194
195
|
let _amount = rawRewardInfo.shift();
|
|
195
196
|
if ('claimable_reward(address)' in gaugeContract) {
|
|
196
197
|
const _claimedAmount = rawRewardInfo.shift();
|
|
@@ -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);
|