@curvefi/api 2.46.5 → 2.46.7

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.
@@ -0,0 +1 @@
1
+ [{ "name": "Minted", "inputs": [{ "type": "address", "name": "recipient", "indexed": true }, { "type": "address", "name": "gauge", "indexed": false }, { "type": "uint256", "name": "minted", "indexed": false }], "anonymous": false, "type": "event" }, { "outputs": [], "inputs": [{ "type": "address", "name": "_token" }, { "type": "address", "name": "_controller" }], "stateMutability": "nonpayable", "type": "constructor" }, { "name": "mint", "outputs": [], "inputs": [{ "type": "address", "name": "gauge_addr" }], "stateMutability": "nonpayable", "type": "function", "gas": 100038 }, { "name": "mint_many", "outputs": [], "inputs": [{ "type": "address[8]", "name": "gauge_addrs" }], "stateMutability": "nonpayable", "type": "function", "gas": 408502 }, { "name": "mint_for", "outputs": [], "inputs": [{ "type": "address", "name": "gauge_addr" }, { "type": "address", "name": "_for" }], "stateMutability": "nonpayable", "type": "function", "gas": 101219 }, { "name": "toggle_approve_mint", "outputs": [], "inputs": [{ "type": "address", "name": "minting_user" }], "stateMutability": "nonpayable", "type": "function", "gas": 36726 }, { "name": "token", "outputs": [{ "type": "address", "name": "" }], "inputs": [], "stateMutability": "view", "type": "function", "gas": 1301 }, { "name": "controller", "outputs": [{ "type": "address", "name": "" }], "inputs": [], "stateMutability": "view", "type": "function", "gas": 1331 }, { "name": "minted", "outputs": [{ "type": "uint256", "name": "" }], "inputs": [{ "type": "address", "name": "arg0" }, { "type": "address", "name": "arg1" }], "stateMutability": "view", "type": "function", "gas": 1669 }, { "name": "allowed_to_mint_for", "outputs": [{ "type": "bool", "name": "" }], "inputs": [{ "type": "address", "name": "arg0" }, { "type": "address", "name": "arg1" }], "stateMutability": "view", "type": "function", "gas": 1699 }]
@@ -1,6 +1,7 @@
1
1
  import { lowerCaseValues } from "./utils.js";
2
2
  export var ALIASES_ETHEREUM = lowerCaseValues({
3
3
  "crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
4
+ "minter": '0xd061D61a4d941c39E5453435B6345Dc261C2fcE0',
4
5
  "gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
5
6
  "voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
6
7
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
package/lib/curve.js CHANGED
@@ -65,6 +65,7 @@ import cERC20Abi from './constants/abis/cERC20.json' assert { type: 'json' };
65
65
  import yERC20Abi from './constants/abis/yERC20.json' assert { type: 'json' };
66
66
  import gaugeFactoryABI from './constants/abis/gauge_factory_mainnet.json' assert { type: 'json' };
67
67
  import gaugeFactorySidechainABI from './constants/abis/gauge_factory_sidechain.json' assert { type: 'json' };
68
+ import minterMainnetABI from './constants/abis/minter_mainnet.json' assert { type: 'json' };
68
69
  import votingEscrowABI from './constants/abis/votingescrow.json' assert { type: 'json' };
69
70
  import anycallABI from './constants/abis/anycall.json' assert { type: 'json' };
70
71
  import votingEscrowOracleABI from './constants/abis/voting_escrow_oracle.json' assert { type: 'json' };
@@ -893,6 +894,9 @@ var Curve = /** @class */ (function () {
893
894
  this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
894
895
  _gaugeFactoryABI = this.chainId === 1 ? gaugeFactoryABI : gaugeFactorySidechainABI;
895
896
  this.setContract(this.constants.ALIASES.gauge_factory, _gaugeFactoryABI);
897
+ if (this.chainId === 1) {
898
+ this.setContract(this.constants.ALIASES.minter, minterMainnetABI);
899
+ }
896
900
  this.setContract(this.constants.ALIASES.voting_escrow, votingEscrowABI);
897
901
  this.setContract(this.constants.ALIASES.fee_distributor, feeDistributorABI);
898
902
  this.setContract(this.constants.ALIASES.address_provider, addressProviderABI);
@@ -1738,15 +1738,20 @@ var PoolTemplate = /** @class */ (function () {
1738
1738
  };
1739
1739
  PoolTemplate.prototype.claimCrvEstimateGas = function () {
1740
1740
  return __awaiter(this, void 0, void 0, function () {
1741
- var _c;
1742
- return __generator(this, function (_d) {
1743
- switch (_d.label) {
1741
+ var _c, _d;
1742
+ return __generator(this, function (_e) {
1743
+ switch (_e.label) {
1744
1744
  case 0:
1745
1745
  if (this.rewardsOnly())
1746
1746
  throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimRewards instead"));
1747
+ if (!(curve.chainId === 1)) return [3 /*break*/, 2];
1747
1748
  _c = Number;
1749
+ return [4 /*yield*/, curve.contracts[curve.constants.ALIASES.minter].contract.mint.estimateGas(this.gauge, curve.constantOptions)];
1750
+ case 1: return [2 /*return*/, _c.apply(void 0, [_e.sent()])];
1751
+ case 2:
1752
+ _d = Number;
1748
1753
  return [4 /*yield*/, curve.contracts[curve.constants.ALIASES.gauge_factory].contract.mint.estimateGas(this.gauge, curve.constantOptions)];
1749
- case 1: return [2 /*return*/, _c.apply(void 0, [_d.sent()])];
1754
+ case 3: return [2 /*return*/, _d.apply(void 0, [_e.sent()])];
1750
1755
  }
1751
1756
  });
1752
1757
  });
@@ -1759,7 +1764,7 @@ var PoolTemplate = /** @class */ (function () {
1759
1764
  case 0:
1760
1765
  if (this.rewardsOnly())
1761
1766
  throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimRewards instead"));
1762
- contract = curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
1767
+ contract = curve.chainId === 1 ? curve.contracts[curve.constants.ALIASES.minter].contract : curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
1763
1768
  _c = mulBy1_3;
1764
1769
  return [4 /*yield*/, contract.mint.estimateGas(this.gauge, curve.constantOptions)];
1765
1770
  case 1:
package/lib/utils.js CHANGED
@@ -408,7 +408,7 @@ var _getTokenAddressBySwapAddress = function (swapAddress) {
408
408
  return res[0][1].token_address;
409
409
  };
410
410
  export var _getUsdPricesFromApi = function () { return __awaiter(void 0, void 0, void 0, function () {
411
- var network, allTypesExtendedPoolData, priceDict, _i, allTypesExtendedPoolData_1, extendedPoolData, _a, _b, pool, lpTokenAddress, totalSupply, _c, _d, coin, _e, _f, coin;
411
+ var network, allTypesExtendedPoolData, priceDict, priceDictByMaxTvl, _i, allTypesExtendedPoolData_1, extendedPoolData, _a, _b, pool, lpTokenAddress, totalSupply, _c, _d, coin, _e, _f, coin, address, maxTvlItem;
412
412
  var _g, _h;
413
413
  return __generator(this, function (_j) {
414
414
  switch (_j.label) {
@@ -418,26 +418,81 @@ export var _getUsdPricesFromApi = function () { return __awaiter(void 0, void 0,
418
418
  case 1:
419
419
  allTypesExtendedPoolData = _j.sent();
420
420
  priceDict = {};
421
+ priceDictByMaxTvl = {};
421
422
  for (_i = 0, allTypesExtendedPoolData_1 = allTypesExtendedPoolData; _i < allTypesExtendedPoolData_1.length; _i++) {
422
423
  extendedPoolData = allTypesExtendedPoolData_1[_i];
423
424
  for (_a = 0, _b = extendedPoolData.poolData; _a < _b.length; _a++) {
424
425
  pool = _b[_a];
425
426
  lpTokenAddress = (_g = pool.lpTokenAddress) !== null && _g !== void 0 ? _g : pool.address;
426
427
  totalSupply = pool.totalSupply / (Math.pow(10, 18));
427
- priceDict[lpTokenAddress.toLowerCase()] = pool.usdTotal && totalSupply ? pool.usdTotal / totalSupply : 0;
428
+ if (lpTokenAddress.toLowerCase() in priceDict) {
429
+ priceDict[lpTokenAddress.toLowerCase()].push({
430
+ price: pool.usdTotal && totalSupply ? pool.usdTotal / totalSupply : 0,
431
+ tvl: pool.usdTotal
432
+ });
433
+ }
434
+ else {
435
+ priceDict[lpTokenAddress.toLowerCase()] = [];
436
+ priceDict[lpTokenAddress.toLowerCase()].push({
437
+ price: pool.usdTotal && totalSupply ? pool.usdTotal / totalSupply : 0,
438
+ tvl: pool.usdTotal
439
+ });
440
+ }
428
441
  for (_c = 0, _d = pool.coins; _c < _d.length; _c++) {
429
442
  coin = _d[_c];
430
- if (typeof coin.usdPrice === "number")
431
- priceDict[coin.address.toLowerCase()] = coin.usdPrice;
443
+ if (typeof coin.usdPrice === "number") {
444
+ if (coin.address.toLowerCase() in priceDict) {
445
+ priceDict[coin.address.toLowerCase()].push({
446
+ price: coin.usdPrice,
447
+ tvl: pool.usdTotal
448
+ });
449
+ }
450
+ else {
451
+ priceDict[coin.address.toLowerCase()] = [];
452
+ priceDict[coin.address.toLowerCase()].push({
453
+ price: coin.usdPrice,
454
+ tvl: pool.usdTotal
455
+ });
456
+ }
457
+ }
432
458
  }
433
459
  for (_e = 0, _f = (_h = pool.gaugeRewards) !== null && _h !== void 0 ? _h : []; _e < _f.length; _e++) {
434
460
  coin = _f[_e];
435
- if (typeof coin.tokenPrice === "number")
436
- priceDict[coin.tokenAddress.toLowerCase()] = coin.tokenPrice;
461
+ if (typeof coin.tokenPrice === "number") {
462
+ if (coin.tokenAddress.toLowerCase() in priceDict) {
463
+ priceDict[coin.tokenAddress.toLowerCase()].push({
464
+ price: coin.tokenPrice,
465
+ tvl: pool.usdTotal
466
+ });
467
+ }
468
+ else {
469
+ priceDict[coin.tokenAddress.toLowerCase()] = [];
470
+ priceDict[coin.tokenAddress.toLowerCase()].push({
471
+ price: coin.tokenPrice,
472
+ tvl: pool.usdTotal
473
+ });
474
+ }
475
+ }
437
476
  }
438
477
  }
439
478
  }
440
- return [2 /*return*/, priceDict];
479
+ for (address in priceDict) {
480
+ if (priceDict[address].length > 0) {
481
+ maxTvlItem = priceDict[address].reduce(function (prev, current) {
482
+ if (+current.tvl > +prev.tvl) {
483
+ return current;
484
+ }
485
+ else {
486
+ return prev;
487
+ }
488
+ });
489
+ priceDictByMaxTvl[address] = maxTvlItem.price;
490
+ }
491
+ else {
492
+ priceDictByMaxTvl[address] = 0;
493
+ }
494
+ }
495
+ return [2 /*return*/, priceDictByMaxTvl];
441
496
  }
442
497
  });
443
498
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.46.5",
3
+ "version": "2.46.7",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",