@curvefi/api 2.66.14 → 2.66.16
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/PoolTemplate.js +5 -4
- package/lib/pools/utils.js +10 -7
- package/lib/utils.d.ts +7 -1
- package/lib/utils.js +3 -1
- package/package.json +1 -1
|
@@ -291,7 +291,8 @@ export class PoolTemplate extends CorePool {
|
|
|
291
291
|
const rewards = yield _getRewardsFromApi();
|
|
292
292
|
if (!rewards[this.gauge.address])
|
|
293
293
|
return [];
|
|
294
|
-
|
|
294
|
+
// Don't reset ABI if its already set, we might override an LP token ABI
|
|
295
|
+
rewards[this.gauge.address].forEach((r) => !curve.contracts[r.tokenAddress] && _setContracts(r.tokenAddress, ERC20Abi));
|
|
295
296
|
return rewards[this.gauge.address].map((r) => ({ token: r.tokenAddress, symbol: r.symbol, decimals: Number(r.decimals) }));
|
|
296
297
|
}
|
|
297
298
|
const gaugeContract = curve.contracts[this.gauge.address].contract;
|
|
@@ -311,9 +312,9 @@ export class PoolTemplate extends CorePool {
|
|
|
311
312
|
.filter((addr) => curve.chainId === 1 || addr !== curve.constants.COINS.crv);
|
|
312
313
|
const tokenInfoCalls = [];
|
|
313
314
|
for (const token of tokens) {
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
tokenInfoCalls.push(
|
|
315
|
+
// Don't reset ABI if its already set, we might override an LP token ABI
|
|
316
|
+
const { multicallContract } = curve.contracts[token] || _setContracts(token, ERC20Abi);
|
|
317
|
+
tokenInfoCalls.push(multicallContract.symbol(), multicallContract.decimals());
|
|
317
318
|
}
|
|
318
319
|
const tokenInfo = yield curve.multicallProvider.all(tokenInfoCalls);
|
|
319
320
|
for (let i = 0; i < tokens.length; i++) {
|
package/lib/pools/utils.js
CHANGED
|
@@ -130,7 +130,7 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
130
130
|
rewardTokenCalls.push(rewardMulticallContract[method]());
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
const rawRewardTokens = (yield
|
|
133
|
+
const rawRewardTokens = (yield batchedMulticall(rewardTokenCalls)).map((t) => t.toLowerCase());
|
|
134
134
|
const rewardTokens = {};
|
|
135
135
|
for (let i = 0; i < poolsToFetch.length; i++) {
|
|
136
136
|
rewardTokens[poolsToFetch[i]] = [];
|
|
@@ -159,9 +159,9 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
159
159
|
rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
|
|
160
160
|
}
|
|
161
161
|
for (const token of rewardTokens[poolId]) {
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
rewardInfoCalls.push(
|
|
162
|
+
// Don't reset the reward ABI if the reward is the LP token itself, otherwise we lose LP contract functions
|
|
163
|
+
const { multicallContract } = token === pool.address ? curve.contracts[token] : _setContracts(token, ERC20Abi);
|
|
164
|
+
rewardInfoCalls.push(multicallContract.symbol(), multicallContract.decimals());
|
|
165
165
|
if ('claimable_reward(address,address)' in gaugeContract) {
|
|
166
166
|
rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address, token));
|
|
167
167
|
}
|
|
@@ -170,7 +170,7 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
const rawRewardInfo = yield
|
|
173
|
+
const rawRewardInfo = yield batchedMulticall(rewardInfoCalls);
|
|
174
174
|
for (let i = 0; i < poolsToFetch.length; i++) {
|
|
175
175
|
const poolId = poolsToFetch[i];
|
|
176
176
|
const pool = getPool(poolId);
|
|
@@ -191,7 +191,7 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
191
191
|
}
|
|
192
192
|
for (const token of rewardTokens[poolId]) {
|
|
193
193
|
const symbol = rawRewardInfo.shift();
|
|
194
|
-
const decimals = rawRewardInfo.shift();
|
|
194
|
+
const decimals = Number(rawRewardInfo.shift());
|
|
195
195
|
let _amount = rawRewardInfo.shift();
|
|
196
196
|
if ('claimable_reward(address)' in gaugeContract) {
|
|
197
197
|
const _claimedAmount = rawRewardInfo.shift();
|
|
@@ -245,7 +245,10 @@ const _getUserClaimableUseApi = (pools, address, useCache) => __awaiter(void 0,
|
|
|
245
245
|
rewardInfoCalls.push(gaugeMulticallContract.claimable_tokens(address));
|
|
246
246
|
}
|
|
247
247
|
for (const r of rewardTokens[poolId]) {
|
|
248
|
-
|
|
248
|
+
// Don't reset the reward ABI if the reward is the LP token itself, otherwise we lose LP contract functions
|
|
249
|
+
if (r.token !== pool.address) {
|
|
250
|
+
_setContracts(r.token, ERC20Abi);
|
|
251
|
+
}
|
|
249
252
|
if ('claimable_reward(address,address)' in gaugeContract) {
|
|
250
253
|
rewardInfoCalls.push(gaugeMulticallContract.claimable_reward(address, r.token));
|
|
251
254
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
import { Contract as MulticallContract } from "@curvefi/ethcall";
|
|
1
3
|
import BigNumber from 'bignumber.js';
|
|
2
4
|
import { Abi, AbiFunction, IBasePoolShortItem, IChainId, ICurveLiteNetwork, IDict, INetworkName, IRewardFromApi, IVolumeAndAPYs, REFERENCE_ASSET } from './interfaces';
|
|
3
5
|
export declare const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
@@ -52,7 +54,11 @@ export declare const getVolume: (chainId?: number) => Promise<{
|
|
|
52
54
|
cryptoVolume: number;
|
|
53
55
|
cryptoShare: number;
|
|
54
56
|
}>;
|
|
55
|
-
export declare const _setContracts: (address: string, abi: any) =>
|
|
57
|
+
export declare const _setContracts: (address: string, abi: any) => {
|
|
58
|
+
abi: any;
|
|
59
|
+
contract: Contract;
|
|
60
|
+
multicallContract: MulticallContract;
|
|
61
|
+
};
|
|
56
62
|
export declare const _get_small_x: (_x: bigint, _y: bigint, x_decimals: number, y_decimals: number) => BigNumber;
|
|
57
63
|
export declare const _get_price_impact: (_x: bigint, _y: bigint, _small_x: bigint, _small_y: bigint, x_decimals: number, y_decimals: number) => BigNumber;
|
|
58
64
|
export declare const getCoinsData: (...coins: string[] | string[][]) => Promise<{
|
package/lib/utils.js
CHANGED
|
@@ -615,11 +615,13 @@ export const getVolume = (...args_1) => __awaiter(void 0, [...args_1], void 0, f
|
|
|
615
615
|
return { totalVolume, cryptoVolume, cryptoShare };
|
|
616
616
|
});
|
|
617
617
|
export const _setContracts = (address, abi) => {
|
|
618
|
-
|
|
618
|
+
const contracts = {
|
|
619
619
|
abi,
|
|
620
620
|
contract: new Contract(address, abi, curve.signer || curve.provider),
|
|
621
621
|
multicallContract: new MulticallContract(address, abi),
|
|
622
622
|
};
|
|
623
|
+
curve.contracts[address] = contracts;
|
|
624
|
+
return contracts;
|
|
623
625
|
};
|
|
624
626
|
// Find k for which x * k = target_x or y * k = target_y
|
|
625
627
|
// k = max(target_x / x, target_y / y)
|