@curvefi/api 2.52.0 → 2.52.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.
package/lib/curve.d.ts CHANGED
@@ -90,6 +90,7 @@ declare class Curve implements ICurve {
90
90
  fetchNewCryptoFactoryPools: () => Promise<string[]>;
91
91
  fetchNewTricryptoFactoryPools: () => Promise<string[]>;
92
92
  fetchRecentlyDeployedFactoryPool: (poolAddress: string) => Promise<string>;
93
+ fetchRecentlyDeployedStableNgFactoryPool: (poolAddress: string) => Promise<string>;
93
94
  fetchRecentlyDeployedCryptoFactoryPool: (poolAddress: string) => Promise<string>;
94
95
  fetchRecentlyDeployedTricryptoFactoryPool: (poolAddress: string) => Promise<string>;
95
96
  getMainPoolList: () => string[];
package/lib/curve.js CHANGED
@@ -702,6 +702,23 @@ var Curve = /** @class */ (function () {
702
702
  }
703
703
  });
704
704
  }); };
705
+ this.fetchRecentlyDeployedStableNgFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
706
+ var poolData, _a;
707
+ return __generator(this, function (_b) {
708
+ switch (_b.label) {
709
+ case 0:
710
+ if (this.chainId === 1313161554)
711
+ return [2 /*return*/, ''];
712
+ _a = lowerCasePoolDataAddresses;
713
+ return [4 /*yield*/, getFactoryPoolData.call(this, 0, poolAddress, this.constants.ALIASES.stable_ng_factory)];
714
+ case 1:
715
+ poolData = _a.apply(void 0, [_b.sent()]);
716
+ this.constants.STABLE_NG_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.STABLE_NG_FACTORY_POOLS_DATA), poolData);
717
+ this._updateDecimalsAndGauges(this.constants.STABLE_NG_FACTORY_POOLS_DATA);
718
+ return [2 /*return*/, Object.keys(poolData)[0]]; // id
719
+ }
720
+ });
721
+ }); };
705
722
  this.fetchRecentlyDeployedCryptoFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
706
723
  var poolData, _a;
707
724
  return __generator(this, function (_b) {
@@ -174,8 +174,6 @@ oracleAddresses, methodNames, estimateGas) {
174
174
  throw Error("Invalid number of coins. Must be more than 1");
175
175
  if (coins.length > 9)
176
176
  throw Error("Invalid number of coins. Must be less than 9");
177
- if (BN(fee).lt(0.04))
178
- throw Error("fee must be >= 0.04%. Passed fee = ".concat(fee));
179
177
  if (BN(fee).gt(1))
180
178
  throw Error("fee must be <= 1%. Passed fee = ".concat(fee));
181
179
  if (oracleAddresses.length === 0) {
@@ -106,13 +106,14 @@ export function getBasePoolIds(factoryAddress, rawSwapAddresses, tmpPools) {
106
106
  });
107
107
  });
108
108
  }
109
- function getRecentlyCreatedPoolId(swapAddress) {
109
+ function getRecentlyCreatedPoolId(swapAddress, factoryAddress) {
110
110
  return __awaiter(this, void 0, void 0, function () {
111
- var factoryContract, poolCount, _a, _b, _c, i, address;
111
+ var factoryContract, prefix, poolCount, _a, _b, _c, i, address;
112
112
  return __generator(this, function (_e) {
113
113
  switch (_e.label) {
114
114
  case 0:
115
- factoryContract = this.contracts[this.constants.ALIASES.factory].contract;
115
+ factoryContract = this.contracts[factoryAddress].contract;
116
+ prefix = factoryAddress === this.constants.ALIASES.factory ? 'factory-v2' : 'factory-stable-ng';
116
117
  _a = Number;
117
118
  _c = (_b = curve).formatUnits;
118
119
  return [4 /*yield*/, factoryContract.pool_count(this.constantOptions)];
@@ -126,7 +127,7 @@ function getRecentlyCreatedPoolId(swapAddress) {
126
127
  case 3:
127
128
  address = _e.sent();
128
129
  if (address.toLowerCase() === swapAddress.toLowerCase())
129
- return [2 /*return*/, "factory-v2-".concat(poolCount - i)];
130
+ return [2 /*return*/, "".concat(prefix, "-").concat(poolCount - i)];
130
131
  _e.label = 4;
131
132
  case 4:
132
133
  i++;
@@ -335,7 +336,7 @@ export function getFactoryPoolData(fromIdx, swapAddress, factoryAddress) {
335
336
  switch (_f.label) {
336
337
  case 0:
337
338
  if (!swapAddress) return [3 /*break*/, 2];
338
- return [4 /*yield*/, getRecentlyCreatedPoolId.call(this, swapAddress)];
339
+ return [4 /*yield*/, getRecentlyCreatedPoolId.call(this, swapAddress, factoryAddress)];
339
340
  case 1:
340
341
  _b = [[_f.sent()], [swapAddress.toLowerCase()]];
341
342
  return [3 /*break*/, 4];
package/lib/index.d.ts CHANGED
@@ -101,6 +101,7 @@ declare const curve: {
101
101
  deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, offpegFeeMultiplier: string | number, emaTime: number, implementationIdx: 0, assetType: 0 | 1 | 2 | 3, methodName: string, oracleAddress: string) => Promise<ethers.ContractTransactionResponse>;
102
102
  getDeployedPlainPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
103
103
  getDeployedMetaPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
104
+ fetchRecentlyDeployedPool: (poolAddress: string) => Promise<string>;
104
105
  estimateGas: {
105
106
  deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, offpegFeeMultiplier: string | number, assetTypes: (0 | 1 | 2 | 3)[], implementationIdx: 0, emaTime: number, oracleAddresses: string[], methodNames: string[]) => Promise<number>;
106
107
  deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, offpegFeeMultiplier: string | number, assetType: 0 | 1 | 2 | 3, emaTime: number, implementationIdx: 0, methodName: string, oracleAddress: string) => Promise<number>;
package/lib/index.js CHANGED
@@ -141,6 +141,7 @@ var curve = {
141
141
  deployMetaPool: deployStableNgMetaPool,
142
142
  getDeployedPlainPoolAddress: getDeployedStablePlainPoolAddress,
143
143
  getDeployedMetaPoolAddress: getDeployedStableMetaPoolAddress,
144
+ fetchRecentlyDeployedPool: _curve.fetchRecentlyDeployedStableNgFactoryPool,
144
145
  estimateGas: {
145
146
  deployPlainPool: deployStableNgPlainPoolEstimateGas,
146
147
  deployMetaPool: deployStableNgMetaPoolEstimateGas,
@@ -466,7 +466,7 @@ var PoolTemplate = /** @class */ (function () {
466
466
  case 6:
467
467
  _c.trys.push([6, 13, , 15]);
468
468
  contract = curve.contracts[curve.constants.ALIASES.stable_calc].contract;
469
- if (!(curve.constants.ALIASES.stable_calc === curve.constants.ZERO_ADDRESS)) return [3 /*break*/, 8];
469
+ if (!(curve.constants.ALIASES.stable_calc === curve.constants.ZERO_ADDRESS || this.id.startsWith("factory-stable-ng"))) return [3 /*break*/, 8];
470
470
  return [4 /*yield*/, this._pureCalcLpTokenAmount(_amounts, isDeposit, useUnderlying)];
471
471
  case 7: return [2 /*return*/, _c.sent()];
472
472
  case 8:
@@ -2996,44 +2996,56 @@ var PoolTemplate = /** @class */ (function () {
2996
2996
  };
2997
2997
  PoolTemplate.prototype._swapRequired = function (i, j, _amount, isUnderlying) {
2998
2998
  return __awaiter(this, void 0, void 0, function () {
2999
- var poolAddress, contract, basePool, secondPool, basePool;
2999
+ var contract, basePool, secondPool, contract_1, contract, basePool;
3000
3000
  return __generator(this, function (_c) {
3001
3001
  switch (_c.label) {
3002
3002
  case 0:
3003
- poolAddress = this.address;
3004
- contract = this.isCrypto ? curve.contracts[curve.constants.ALIASES.crypto_calc].contract : curve.contracts[curve.constants.ALIASES.stable_calc].contract;
3005
3003
  if (!this.isCrypto) return [3 /*break*/, 9];
3004
+ contract = curve.contracts[curve.constants.ALIASES.crypto_calc].contract;
3006
3005
  if (!(this.isMeta && isUnderlying)) return [3 /*break*/, 6];
3007
3006
  basePool = new PoolTemplate(this.basePool);
3008
3007
  if (!(this.wrappedCoins.length === 3)) return [3 /*break*/, 2];
3009
- return [4 /*yield*/, contract.get_dx_tricrypto_meta_underlying(poolAddress, i, j, _amount, this.wrappedCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
3008
+ return [4 /*yield*/, contract.get_dx_tricrypto_meta_underlying(this.address, i, j, _amount, this.wrappedCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
3010
3009
  case 1: return [2 /*return*/, _c.sent()];
3011
3010
  case 2:
3012
3011
  if (!basePool.isFake) return [3 /*break*/, 4];
3013
3012
  secondPool = new PoolTemplate(basePool.basePool);
3014
- return [4 /*yield*/, contract.get_dx_double_meta_underlying(poolAddress, i, j, _amount, basePool.address, basePool.zap, secondPool.address, secondPool.lpToken, curve.constantOptions)];
3013
+ return [4 /*yield*/, contract.get_dx_double_meta_underlying(this.address, i, j, _amount, basePool.address, basePool.zap, secondPool.address, secondPool.lpToken, curve.constantOptions)];
3015
3014
  case 3: return [2 /*return*/, _c.sent()];
3016
- case 4: return [4 /*yield*/, contract.get_dx_meta_underlying(poolAddress, i, j, _amount, this.underlyingCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
3015
+ case 4: return [4 /*yield*/, contract.get_dx_meta_underlying(this.address, i, j, _amount, this.underlyingCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
3017
3016
  case 5: return [2 /*return*/, _c.sent()];
3018
- case 6: return [4 /*yield*/, contract.get_dx(poolAddress, i, j, _amount, this.wrappedCoins.length, curve.constantOptions)];
3017
+ case 6: return [4 /*yield*/, contract.get_dx(this.address, i, j, _amount, this.wrappedCoins.length, curve.constantOptions)];
3019
3018
  case 7: return [2 /*return*/, _c.sent()];
3020
- case 8: return [3 /*break*/, 18];
3019
+ case 8: return [3 /*break*/, 25];
3021
3020
  case 9:
3021
+ if (!this.id.startsWith("factory-stable-ng")) return [3 /*break*/, 16];
3022
+ contract_1 = curve.contracts[this.address].contract;
3022
3023
  if (!this.isMeta) return [3 /*break*/, 14];
3023
- basePool = new PoolTemplate(this.basePool);
3024
3024
  if (!isUnderlying) return [3 /*break*/, 11];
3025
- return [4 /*yield*/, contract.get_dx_meta_underlying(poolAddress, i, j, _amount, this.underlyingCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
3025
+ return [4 /*yield*/, contract_1.get_dx_underlying(i, j, _amount, curve.constantOptions)];
3026
3026
  case 10: return [2 /*return*/, _c.sent()];
3027
- case 11: return [4 /*yield*/, contract.get_dx_meta(poolAddress, i, j, _amount, this.wrappedCoins.length, basePool.address, curve.constantOptions)];
3027
+ case 11: return [4 /*yield*/, contract_1.get_dx(i, j, _amount, curve.constantOptions)];
3028
3028
  case 12: return [2 /*return*/, _c.sent()];
3029
- case 13: return [3 /*break*/, 18];
3030
- case 14:
3031
- if (!(isUnderlying && this.isLending)) return [3 /*break*/, 16];
3032
- return [4 /*yield*/, contract.get_dx_underlying(poolAddress, i, j, _amount, this.underlyingCoins.length, curve.constantOptions)];
3029
+ case 13: return [3 /*break*/, 16];
3030
+ case 14: return [4 /*yield*/, contract_1.get_dx(i, j, _amount)];
3033
3031
  case 15: return [2 /*return*/, _c.sent()];
3034
- case 16: return [4 /*yield*/, contract.get_dx(poolAddress, i, j, _amount, this.wrappedCoins.length, curve.constantOptions)];
3032
+ case 16:
3033
+ contract = curve.contracts[curve.constants.ALIASES.stable_calc].contract;
3034
+ if (!this.isMeta) return [3 /*break*/, 21];
3035
+ basePool = new PoolTemplate(this.basePool);
3036
+ if (!isUnderlying) return [3 /*break*/, 18];
3037
+ return [4 /*yield*/, contract.get_dx_meta_underlying(this.address, i, j, _amount, this.underlyingCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
3035
3038
  case 17: return [2 /*return*/, _c.sent()];
3036
- case 18: return [2 /*return*/];
3039
+ case 18: return [4 /*yield*/, contract.get_dx_meta(this.address, i, j, _amount, this.wrappedCoins.length, basePool.address, curve.constantOptions)];
3040
+ case 19: return [2 /*return*/, _c.sent()];
3041
+ case 20: return [3 /*break*/, 25];
3042
+ case 21:
3043
+ if (!(isUnderlying && this.isLending)) return [3 /*break*/, 23];
3044
+ return [4 /*yield*/, contract.get_dx_underlying(this.address, i, j, _amount, this.underlyingCoins.length, curve.constantOptions)];
3045
+ case 22: return [2 /*return*/, _c.sent()];
3046
+ case 23: return [4 /*yield*/, contract.get_dx(this.address, i, j, _amount, this.wrappedCoins.length, curve.constantOptions)];
3047
+ case 24: return [2 /*return*/, _c.sent()];
3048
+ case 25: return [2 /*return*/];
3037
3049
  }
3038
3050
  });
3039
3051
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.52.0",
3
+ "version": "2.52.2",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",