@curvefi/api 2.8.1 → 2.8.4

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.
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -54,6 +65,7 @@ var ethcall_1 = require("ethcall");
54
65
  var ERC20_json_1 = __importDefault(require("../constants/abis/ERC20.json"));
55
66
  var deposit_json_1 = __importDefault(require("../constants/abis/factoryPools/deposit.json"));
56
67
  var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
68
+ var gauge_child_json_1 = __importDefault(require("../constants/abis/gauge_child.json"));
57
69
  var common_1 = require("./common");
58
70
  var constants_1 = require("./constants");
59
71
  var BLACK_LIST = {
@@ -149,8 +161,8 @@ function setFactoryGaugeContracts(factoryGaugeAddresses) {
149
161
  var _this = this;
150
162
  factoryGaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; }).forEach(function (addr, i) {
151
163
  _this.contracts[addr] = {
152
- contract: new ethers_1.Contract(addr, gauge_factory_json_1.default, _this.signer || _this.provider),
153
- multicallContract: new ethcall_1.Contract(addr, gauge_factory_json_1.default),
164
+ contract: new ethers_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default, _this.signer || _this.provider),
165
+ multicallContract: new ethcall_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default),
154
166
  };
155
167
  });
156
168
  }
@@ -311,7 +323,7 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
311
323
  return __generator(this, function (_a) {
312
324
  switch (_a.label) {
313
325
  case 0:
314
- flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses)));
326
+ flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses))).filter(function (addr) { return addr !== constants_1.NATIVE_TOKEN_ADDRESS; });
315
327
  newCoinAddresses = [];
316
328
  coinAddrNamesDict = {};
317
329
  for (_i = 0, flattenedCoinAddresses_3 = flattenedCoinAddresses; _i < flattenedCoinAddresses_3.length; _i++) {
@@ -359,8 +371,7 @@ function getFactoryIsMeta(factorySwapAddresses) {
359
371
  }
360
372
  function getFactoryPoolData() {
361
373
  return __awaiter(this, void 0, void 0, function () {
362
- var _a, poolIds, swapAddresses, implementations, implementationABIDict, swapABIs, gaugeAddresses, _b, poolSymbols, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, implementationBasePoolIdDict, basePoolIds, basePoolIdCoinsDict, basePoolIdCoinAddressesDict, basePoolIdDecimalsDict, basePoolIdZapDict, FACTORY_POOLS_DATA, i;
363
- var _this = this;
374
+ var _a, poolIds, swapAddresses, implementations, implementationABIDict, swapABIs, gaugeAddresses, _b, poolSymbols, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, implementationBasePoolIdDict, basePoolIds, FACTORY_POOLS_DATA, _loop_2, this_1, i;
364
375
  return __generator(this, function (_c) {
365
376
  switch (_c.label) {
366
377
  case 0: return [4 /*yield*/, getFactoryIdsAndSwapAddresses.call(this)];
@@ -399,12 +410,8 @@ function getFactoryPoolData() {
399
410
  implementationBasePoolIdDict = constants_1.FACTORY_CONSTANTS[this.chainId].implementationBasePoolIdDict;
400
411
  basePoolIds = implementations.map(function (addr) { return implementationBasePoolIdDict[addr]; });
401
412
  common_1.setFactoryZapContracts.call(this);
402
- basePoolIdCoinsDict = Object.fromEntries(basePoolIds.map(function (poolId) { return [poolId, _this.constants.POOLS_DATA[poolId].underlying_coins]; }));
403
- basePoolIdCoinAddressesDict = Object.fromEntries(basePoolIds.map(function (poolId) { return [poolId, _this.constants.POOLS_DATA[poolId].underlying_coin_addresses]; }));
404
- basePoolIdDecimalsDict = Object.fromEntries(basePoolIds.map(function (poolId) { return [poolId, _this.constants.POOLS_DATA[poolId].underlying_decimals]; }));
405
- basePoolIdZapDict = constants_1.FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
406
413
  FACTORY_POOLS_DATA = {};
407
- for (i = 0; i < poolIds.length; i++) {
414
+ _loop_2 = function (i) {
408
415
  if (!isMeta[i]) {
409
416
  FACTORY_POOLS_DATA[poolIds[i]] = {
410
417
  name: poolNames[i].split(": ")[1].trim(),
@@ -423,10 +430,18 @@ function getFactoryPoolData() {
423
430
  underlying_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
424
431
  wrapped_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
425
432
  swap_abi: swapABIs[i],
426
- gauge_abi: gauge_factory_json_1.default,
433
+ gauge_abi: this_1.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default,
427
434
  };
428
435
  }
429
436
  else {
437
+ var allPoolsData_1 = __assign(__assign({}, this_1.constants.POOLS_DATA), FACTORY_POOLS_DATA);
438
+ // @ts-ignore
439
+ var basePoolIdCoinsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins]; }));
440
+ // @ts-ignore
441
+ var basePoolIdCoinAddressesDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
442
+ // @ts-ignore
443
+ var basePoolIdDecimalsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
444
+ var basePoolIdZapDict = constants_1.FACTORY_CONSTANTS[this_1.chainId].basePoolIdZapDict;
430
445
  FACTORY_POOLS_DATA[poolIds[i]] = {
431
446
  name: poolNames[i].split(": ")[1].trim(),
432
447
  full_name: poolNames[i],
@@ -446,10 +461,14 @@ function getFactoryPoolData() {
446
461
  underlying_decimals: __spreadArray([coinAddressDecimalsDict[coinAddresses[i][0]]], basePoolIdDecimalsDict[basePoolIds[i]], true),
447
462
  wrapped_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
448
463
  swap_abi: swapABIs[i],
449
- gauge_abi: gauge_factory_json_1.default,
464
+ gauge_abi: this_1.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default,
450
465
  deposit_abi: deposit_json_1.default,
451
466
  };
452
467
  }
468
+ };
469
+ this_1 = this;
470
+ for (i = 0; i < poolIds.length; i++) {
471
+ _loop_2(i);
453
472
  }
454
473
  return [2 /*return*/, FACTORY_POOLS_DATA];
455
474
  }
@@ -95,6 +95,7 @@ export declare class PoolTemplate {
95
95
  private statsBaseApy;
96
96
  private statsTokenApy;
97
97
  private statsRewardsApy;
98
+ private _pureCalcLpTokenAmount;
98
99
  private _calcLpTokenAmount;
99
100
  private calcLpTokenAmount;
100
101
  private calcLpTokenAmountWrapped;