@curvefi/api 2.25.0 → 2.25.2

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.
File without changes
File without changes
@@ -9,8 +9,8 @@ var swap_json_2 = __importDefault(require("../abis/rai/swap.json"));
9
9
  var deposit_json_1 = __importDefault(require("../abis/rai/deposit.json"));
10
10
  var swap_json_3 = __importDefault(require("../abis/tricrypto-xdai/swap.json"));
11
11
  var zap_json_1 = __importDefault(require("../abis/tricrypto-xdai/zap.json"));
12
- var swap_json_4 = __importDefault(require("../abis/eure/swap.json"));
13
- var zap_json_2 = __importDefault(require("../abis/eure/zap.json"));
12
+ var swap_json_4 = __importDefault(require("../abis/eureusd/swap.json"));
13
+ var zap_json_2 = __importDefault(require("../abis/eureusd/zap.json"));
14
14
  var gauge_rewards_only_json_1 = __importDefault(require("../abis/gauge_rewards_only.json"));
15
15
  var gauge_child_json_1 = __importDefault(require("../abis/gauge_child.json"));
16
16
  var streamer_json_1 = __importDefault(require("../abis/streamer.json"));
@@ -105,20 +105,20 @@ exports.POOLS_DATA_XDAI = (0, utils_1.lowerCasePoolDataAddresses)({
105
105
  gauge_abi: gauge_rewards_only_json_1.default,
106
106
  deposit_abi: zap_json_1.default,
107
107
  },
108
- eure: {
109
- name: "eure",
110
- full_name: "eure",
111
- symbol: "eure",
108
+ eureusd: {
109
+ name: "eureusd",
110
+ full_name: "eureusd",
111
+ symbol: "eureusd",
112
112
  reference_asset: 'CRYPTO',
113
- swap_address: '0x0F6565DF9a25aA057Ddc65Dbc78804087665764B',
114
- token_address: '0x5A6dBE2c3746aB927c214D751cBb36f1512F6100',
113
+ swap_address: '0x056C6C5e684CeC248635eD86033378Cc444459B0',
114
+ token_address: '0x0CA1C1eC4EBf3CC67a9f545fF90a3795b318cA4a',
115
115
  gauge_address: '0x0000000000000000000000000000000000000000',
116
- deposit_address: '0x3D1a8cc1894340c3E60e0f7D7A10b9efB490dC74',
116
+ deposit_address: '0xE3FFF29d4DC930EBb787FeCd49Ee5963DADf60b6',
117
117
  is_meta: true,
118
118
  is_crypto: true,
119
119
  base_pool: '3pool',
120
- underlying_coins: ['EURe', 'DAI', 'USDC', 'USDT'],
121
- wrapped_coins: ['EURe', '3Crv'],
120
+ underlying_coins: ['EURe', 'WXDAI', 'USDC', 'USDT'],
121
+ wrapped_coins: ['EURe', 'x3CRV'],
122
122
  underlying_coin_addresses: [
123
123
  '0xcB444e90D8198415266c6a2724b7900fb12FC56E',
124
124
  '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
package/lib/curve.d.ts CHANGED
@@ -70,6 +70,7 @@ declare class Curve implements ICurve {
70
70
  chainId?: number;
71
71
  }): Promise<void>;
72
72
  setContract(address: string, abi: any): void;
73
+ _filterHiddenPools(pools: IDict<IPoolData>): Promise<IDict<IPoolData>>;
73
74
  fetchFactoryPools(useApi?: boolean): Promise<void>;
74
75
  fetchCryptoFactoryPools(useApi?: boolean): Promise<void>;
75
76
  fetchRecentlyDeployedFactoryPool(poolAddress: string): Promise<string>;
package/lib/curve.js CHANGED
@@ -623,12 +623,29 @@ var Curve = /** @class */ (function () {
623
623
  multicallContract: new ethcall_1.Contract(address, abi),
624
624
  };
625
625
  };
626
+ Curve.prototype._filterHiddenPools = function (pools) {
627
+ return __awaiter(this, void 0, void 0, function () {
628
+ var hiddenPools;
629
+ return __generator(this, function (_a) {
630
+ switch (_a.label) {
631
+ case 0: return [4 /*yield*/, (0, external_api_1._getHiddenPools)()];
632
+ case 1:
633
+ hiddenPools = (_a.sent())[this.constants.NETWORK_NAME] || [];
634
+ // @ts-ignore
635
+ return [2 /*return*/, Object.fromEntries(Object.entries(pools).filter(function (_a) {
636
+ var id = _a[0];
637
+ return !hiddenPools.includes(id);
638
+ }))];
639
+ }
640
+ });
641
+ });
642
+ };
626
643
  Curve.prototype.fetchFactoryPools = function (useApi) {
627
644
  if (useApi === void 0) { useApi = true; }
628
645
  return __awaiter(this, void 0, void 0, function () {
629
- var _a, _b, _c, _d;
630
- return __generator(this, function (_e) {
631
- switch (_e.label) {
646
+ var _a, _b, _c, _d, _e;
647
+ return __generator(this, function (_f) {
648
+ switch (_f.label) {
632
649
  case 0:
633
650
  if (this.chainId === 1313161554)
634
651
  return [2 /*return*/];
@@ -637,21 +654,25 @@ var Curve = /** @class */ (function () {
637
654
  _b = utils_1.lowerCasePoolDataAddresses;
638
655
  return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, false)];
639
656
  case 1:
640
- _a.FACTORY_POOLS_DATA = _b.apply(void 0, [_e.sent()]);
657
+ _a.FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
641
658
  return [3 /*break*/, 4];
642
659
  case 2:
643
660
  _c = this.constants;
644
661
  _d = utils_1.lowerCasePoolDataAddresses;
645
662
  return [4 /*yield*/, factory_1.getFactoryPoolData.call(this)];
646
663
  case 3:
647
- _c.FACTORY_POOLS_DATA = _d.apply(void 0, [_e.sent()]);
648
- _e.label = 4;
664
+ _c.FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
665
+ _f.label = 4;
649
666
  case 4:
667
+ _e = this.constants;
668
+ return [4 /*yield*/, this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA)];
669
+ case 5:
670
+ _e.FACTORY_POOLS_DATA = _f.sent();
650
671
  this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.FACTORY_POOLS_DATA));
651
672
  this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.FACTORY_POOLS_DATA), true);
652
673
  return [4 /*yield*/, _killGauges(this.constants.FACTORY_POOLS_DATA)];
653
- case 5:
654
- _e.sent();
674
+ case 6:
675
+ _f.sent();
655
676
  return [2 /*return*/];
656
677
  }
657
678
  });
@@ -660,9 +681,9 @@ var Curve = /** @class */ (function () {
660
681
  Curve.prototype.fetchCryptoFactoryPools = function (useApi) {
661
682
  if (useApi === void 0) { useApi = true; }
662
683
  return __awaiter(this, void 0, void 0, function () {
663
- var _a, _b, _c, _d;
664
- return __generator(this, function (_e) {
665
- switch (_e.label) {
684
+ var _a, _b, _c, _d, _e;
685
+ return __generator(this, function (_f) {
686
+ switch (_f.label) {
666
687
  case 0:
667
688
  if (![1, 137, 250].includes(this.chainId))
668
689
  return [2 /*return*/];
@@ -671,21 +692,25 @@ var Curve = /** @class */ (function () {
671
692
  _b = utils_1.lowerCasePoolDataAddresses;
672
693
  return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, true)];
673
694
  case 1:
674
- _a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_e.sent()]);
695
+ _a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
675
696
  return [3 /*break*/, 4];
676
697
  case 2:
677
698
  _c = this.constants;
678
699
  _d = utils_1.lowerCasePoolDataAddresses;
679
700
  return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this)];
680
701
  case 3:
681
- _c.CRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_e.sent()]);
682
- _e.label = 4;
702
+ _c.CRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
703
+ _f.label = 4;
683
704
  case 4:
705
+ _e = this.constants;
706
+ return [4 /*yield*/, this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
707
+ case 5:
708
+ _e.CRYPTO_FACTORY_POOLS_DATA = _f.sent();
684
709
  this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.CRYPTO_FACTORY_POOLS_DATA));
685
710
  this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.CRYPTO_FACTORY_POOLS_DATA), true);
686
711
  return [4 /*yield*/, _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
687
- case 5:
688
- _e.sent();
712
+ case 6:
713
+ _f.sent();
689
714
  return [2 /*return*/];
690
715
  }
691
716
  });
@@ -723,9 +748,9 @@ var Curve = /** @class */ (function () {
723
748
  return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this, poolAddress)];
724
749
  case 1:
725
750
  poolData = _a.apply(void 0, [_b.sent()]);
726
- this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
727
- this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.FACTORY_POOLS_DATA));
728
- this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.FACTORY_POOLS_DATA), true);
751
+ this.constants.CRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
752
+ this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.CRYPTO_FACTORY_POOLS_DATA));
753
+ this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.CRYPTO_FACTORY_POOLS_DATA), true);
729
754
  return [2 /*return*/, Object.keys(poolData)[0]]; // id
730
755
  }
731
756
  });
@@ -31,3 +31,4 @@ export declare const _getAllGauges: (() => Promise<IDict<{
31
31
  gauge: string;
32
32
  is_killed?: boolean;
33
33
  }>>>;
34
+ export declare const _getHiddenPools: (() => Promise<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports._getAllGauges = exports._getFactoryAPYsAndVolumes = exports._getLegacyAPYsAndVolumes = exports._getSubgraphData = exports._getPoolsFromApi = void 0;
42
+ exports._getHiddenPools = exports._getAllGauges = exports._getFactoryAPYsAndVolumes = exports._getLegacyAPYsAndVolumes = exports._getSubgraphData = exports._getPoolsFromApi = void 0;
43
43
  var axios_1 = __importDefault(require("axios"));
44
44
  var memoizee_1 = __importDefault(require("memoizee"));
45
45
  var curve_1 = require("./curve");
@@ -139,3 +139,19 @@ exports._getAllGauges = (0, memoizee_1.default)(function () { return __awaiter(v
139
139
  promise: true,
140
140
  maxAge: 5 * 60 * 1000, // 5m
141
141
  });
142
+ exports._getHiddenPools = (0, memoizee_1.default)(function () { return __awaiter(void 0, void 0, void 0, function () {
143
+ var url, response;
144
+ return __generator(this, function (_a) {
145
+ switch (_a.label) {
146
+ case 0:
147
+ url = "https://api.curve.fi/api/getHiddenPools";
148
+ return [4 /*yield*/, axios_1.default.get(url, { validateStatus: function () { return true; } })];
149
+ case 1:
150
+ response = _a.sent();
151
+ return [2 /*return*/, response.data.data];
152
+ }
153
+ });
154
+ }); }, {
155
+ promise: true,
156
+ maxAge: 5 * 60 * 1000, // 5m
157
+ });
@@ -282,7 +282,7 @@ var PoolTemplate = /** @class */ (function () {
282
282
  this.statsTokenApy = function (useApi) {
283
283
  if (useApi === void 0) { useApi = true; }
284
284
  return __awaiter(_this, void 0, void 0, function () {
285
- var isDisabledChain, dontUseApi, crvAPYs, poolCrvApy, totalLiquidityUSD, inflationRateBN, workingSupplyBN, totalSupplyBN, gaugeContract, lpTokenContract, crvContract, currentWeek, _c, gaugeContract, lpTokenContract, gaugeControllerContract, weightBN, rateBN, crvPrice, baseApyBN, boostedApyBN;
285
+ var isDisabledChain, crvAPYs, poolCrvApy, totalLiquidityUSD, inflationRateBN, workingSupplyBN, totalSupplyBN, gaugeContract, lpTokenContract, crvContract, currentWeek, _c, gaugeContract, lpTokenContract, gaugeControllerContract, weightBN, rateBN, crvPrice, baseApyBN, boostedApyBN;
286
286
  var _d, _e;
287
287
  var _f;
288
288
  return __generator(this, function (_g) {
@@ -290,9 +290,8 @@ var PoolTemplate = /** @class */ (function () {
290
290
  case 0:
291
291
  if (this.rewardsOnly())
292
292
  throw Error("".concat(this.name, " has Rewards-Only Gauge. Use stats.rewardsApy instead"));
293
- isDisabledChain = [1284, 2222, 42220, 1313161554].includes(curve_1.curve.chainId);
294
- dontUseApi = (curve_1.curve.chainId === 250 && this.id === 'factory-v2-42') || (curve_1.curve.chainId === 42161 && this.id === 'ren') || isDisabledChain;
295
- if (!(useApi && !dontUseApi)) return [3 /*break*/, 2];
293
+ isDisabledChain = [1313161554].includes(curve_1.curve.chainId);
294
+ if (!(useApi && !isDisabledChain)) return [3 /*break*/, 2];
296
295
  return [4 /*yield*/, (0, utils_1._getCrvApyFromApi)()];
297
296
  case 1:
298
297
  crvAPYs = _g.sent();
@@ -354,18 +353,17 @@ var PoolTemplate = /** @class */ (function () {
354
353
  this.statsRewardsApy = function (useApi) {
355
354
  if (useApi === void 0) { useApi = true; }
356
355
  return __awaiter(_this, void 0, void 0, function () {
357
- var isDisabledChain, dontUseApi, rewards, apy, rewardTokens, _i, rewardTokens_1, rewardToken, contract, totalLiquidityUSD, rewardRate, rewardData, periodFinish, inflation, baseApy;
358
- return __generator(this, function (_c) {
359
- switch (_c.label) {
356
+ var isDisabledChain, rewards, apy, rewardTokens, _i, rewardTokens_1, rewardToken, gaugeContract, lpTokenContract, rewardContract, totalLiquidityUSD, rewardRate, _c, rewardData, _stakedSupply, _totalSupply, stakedSupplyBN, totalSupplyBN, inflationBN, periodFinish, baseApy;
357
+ return __generator(this, function (_d) {
358
+ switch (_d.label) {
360
359
  case 0:
361
360
  if (this.gauge === ethers_1.ethers.constants.AddressZero)
362
361
  return [2 /*return*/, []];
363
- isDisabledChain = [1284, 2222, 42220, 1313161554].includes(curve_1.curve.chainId);
364
- dontUseApi = (curve_1.curve.chainId === 10 && this.id === 'factory-v2-0') || (curve_1.curve.chainId === 1284 && this.id === 'factory-v2-14') || isDisabledChain;
365
- if (!(curve_1.curve.chainId === 1 || (useApi && !dontUseApi))) return [3 /*break*/, 2];
362
+ isDisabledChain = [1313161554].includes(curve_1.curve.chainId);
363
+ if (!(curve_1.curve.chainId === 1 || (useApi && !isDisabledChain))) return [3 /*break*/, 2];
366
364
  return [4 /*yield*/, (0, utils_1._getRewardsFromApi)()];
367
365
  case 1:
368
- rewards = _c.sent();
366
+ rewards = _d.sent();
369
367
  if (!rewards[this.gauge])
370
368
  return [2 /*return*/, []];
371
369
  return [2 /*return*/, rewards[this.gauge].map(function (r) { return ({ gaugeAddress: r.gaugeAddress, tokenAddress: r.tokenAddress, symbol: r.symbol, apy: r.apy }); })];
@@ -373,32 +371,42 @@ var PoolTemplate = /** @class */ (function () {
373
371
  apy = [];
374
372
  return [4 /*yield*/, this.rewardTokens(false)];
375
373
  case 3:
376
- rewardTokens = _c.sent();
374
+ rewardTokens = _d.sent();
377
375
  _i = 0, rewardTokens_1 = rewardTokens;
378
- _c.label = 4;
376
+ _d.label = 4;
379
377
  case 4:
380
378
  if (!(_i < rewardTokens_1.length)) return [3 /*break*/, 9];
381
379
  rewardToken = rewardTokens_1[_i];
382
- contract = curve_1.curve.contracts[this.sRewardContract || this.gauge].contract;
380
+ gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
381
+ lpTokenContract = curve_1.curve.contracts[this.lpToken].multicallContract;
382
+ rewardContract = curve_1.curve.contracts[this.sRewardContract || this.gauge].multicallContract;
383
383
  return [4 /*yield*/, this.statsTotalLiquidity()];
384
384
  case 5:
385
- totalLiquidityUSD = _c.sent();
385
+ totalLiquidityUSD = _d.sent();
386
386
  return [4 /*yield*/, (0, utils_1._getUsdRate)(rewardToken.token)];
387
387
  case 6:
388
- rewardRate = _c.sent();
389
- return [4 /*yield*/, contract.reward_data(rewardToken.token, curve_1.curve.constantOptions)];
388
+ rewardRate = _d.sent();
389
+ return [4 /*yield*/, curve_1.curve.multicallProvider.all([
390
+ rewardContract.reward_data(rewardToken.token),
391
+ gaugeContract.totalSupply(),
392
+ lpTokenContract.totalSupply(),
393
+ ])];
390
394
  case 7:
391
- rewardData = _c.sent();
395
+ _c = _d.sent(), rewardData = _c[0], _stakedSupply = _c[1], _totalSupply = _c[2];
396
+ stakedSupplyBN = (0, utils_1.toBN)(_stakedSupply);
397
+ totalSupplyBN = (0, utils_1.toBN)(_totalSupply);
398
+ inflationBN = (0, utils_1.toBN)(rewardData.rate, rewardToken.decimals);
392
399
  periodFinish = Number(ethers_1.ethers.utils.formatUnits(rewardData.period_finish, 0)) * 1000;
393
- inflation = (0, utils_1.toBN)(rewardData.rate, rewardToken.decimals);
394
- baseApy = periodFinish > Date.now() ? inflation.times(31536000).times(rewardRate).div(Number(totalLiquidityUSD)) : (0, utils_1.BN)(0);
400
+ baseApy = periodFinish > Date.now() ?
401
+ inflationBN.times(31536000).times(rewardRate).div(stakedSupplyBN).times(totalSupplyBN).div(Number(totalLiquidityUSD)) :
402
+ (0, utils_1.BN)(0);
395
403
  apy.push({
396
404
  gaugeAddress: this.gauge,
397
405
  tokenAddress: rewardToken.token,
398
406
  symbol: rewardToken.symbol,
399
407
  apy: baseApy.times(100).toNumber(),
400
408
  });
401
- _c.label = 8;
409
+ _d.label = 8;
402
410
  case 8:
403
411
  _i++;
404
412
  return [3 /*break*/, 4];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.25.0",
3
+ "version": "2.25.2",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",