@curvefi/api 2.66.15 → 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.
@@ -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
- rewards[this.gauge.address].forEach((r) => _setContracts(r.tokenAddress, ERC20Abi));
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
- _setContracts(token, ERC20Abi);
315
- const tokenMulticallContract = curve.contracts[token].multicallContract;
316
- tokenInfoCalls.push(tokenMulticallContract.symbol(), tokenMulticallContract.decimals());
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++) {
@@ -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
- _setContracts(token, ERC20Abi);
163
- const tokenMulticallContract = curve.contracts[token].multicallContract;
164
- rewardInfoCalls.push(tokenMulticallContract.symbol(), tokenMulticallContract.decimals());
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
  }
@@ -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
- _setContracts(r.token, ERC20Abi);
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) => void;
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
- curve.contracts[address] = {
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.66.15",
3
+ "version": "2.66.16",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",