@curvefi/api 2.29.0 → 2.30.1

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/README.md CHANGED
@@ -23,8 +23,8 @@ import curve from "@curvefi/api";
23
23
  await curve.init('Web3', { externalProvider: <WEB3_PROVIDER> }, { chainId: 1 });
24
24
 
25
25
  // Fetch factory pools
26
- await curve.fetchFactoryPools();
27
- await curve.getCryptoFactoryPoolList();
26
+ await curve.factory.fetchPools();
27
+ await curve.cryptoFactory.fetchPools();
28
28
  })()
29
29
  ```
30
30
  **Note 1.** ```chainId``` parameter is optional, but you must specify it in the case you use Metamask on localhost network, because Metamask has that [bug](https://hardhat.org/metamask-issue.html)
@@ -184,8 +184,8 @@ import curve from "@curvefi/api";
184
184
 
185
185
  (async () => {
186
186
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
187
- await curve.fetchFactoryPools();
188
- await curve.fetchCryptoFactoryPools();
187
+ await curve.factory.fetchPools();
188
+ await curve.cryptoFactory.fetchPools();
189
189
 
190
190
  curve.getPoolList();
191
191
  // [
@@ -204,7 +204,7 @@ import curve from "@curvefi/api";
204
204
  // '2pool', '4pool'
205
205
  // ]
206
206
 
207
- curve.getFactoryPoolList();
207
+ curve.factory.getPoolList();
208
208
  // [
209
209
  // 'factory-v2-0', 'factory-v2-2', 'factory-v2-3', 'factory-v2-4',
210
210
  // 'factory-v2-5', 'factory-v2-6', 'factory-v2-7', 'factory-v2-8',
@@ -234,7 +234,7 @@ import curve from "@curvefi/api";
234
234
  // ... 27 more items
235
235
  // ]
236
236
 
237
- curve.getCryptoFactoryPoolList();
237
+ curve.cryptoFactory.getPoolList();
238
238
  // [
239
239
  // 'factory-crypto-0', 'factory-crypto-1', 'factory-crypto-2',
240
240
  // 'factory-crypto-3', 'factory-crypto-4', 'factory-crypto-5',
@@ -267,8 +267,8 @@ import curve from "@curvefi/api";
267
267
 
268
268
  (async () => {
269
269
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
270
- await curve.fetchFactoryPools();
271
- await curve.fetchCryptoFactoryPools();
270
+ await curve.factory.fetchPools();
271
+ await curve.cryptoFactory.fetchPools();
272
272
 
273
273
  const pool = curve.getPool('factory-v2-11');
274
274
 
@@ -330,6 +330,8 @@ import curve from "@curvefi/api";
330
330
  // [ 18, 18 ]
331
331
  pool.useLending;
332
332
  // [ false, false, false, false ]
333
+ pool.inApi;
334
+ // true
333
335
  })()
334
336
  ````
335
337
 
@@ -970,8 +972,8 @@ import curve from "@curvefi/api";
970
972
 
971
973
  (async () => {
972
974
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
973
- await curve.fetchFactoryPools();
974
- await curve.getCryptoFactoryPoolList();
975
+ await curve.factory.fetchPools();
976
+ await curve.cryptoFactory.fetchPools();
975
977
 
976
978
  await curve.getBalances(['DAI', 'CRV']);
977
979
  // [ '9900.0', '100049.744832225238317557' ]
@@ -1283,6 +1285,26 @@ import curve from "@curvefi/api";
1283
1285
 
1284
1286
  ## Factory
1285
1287
 
1288
+ ### Fetch new pools from blockchain
1289
+
1290
+ ```ts
1291
+ import curve from "@curvefi/api";
1292
+
1293
+ (async () => {
1294
+ await curve.init('JsonRpc', {}, { gasPrice: 0 });
1295
+
1296
+ // Fetch pools from api (if false arg is not passed)
1297
+ await curve.factory.fetchPools();
1298
+ await curve.cryptoFactory.fetchPools();
1299
+
1300
+ // Fetch very new pools (that haven't been added to api yet) from blockchain
1301
+ await curve.factory.fetchNewPools();
1302
+ // [ 'factory-v2-285' ]
1303
+ await curve.cryptoFactory.fetchNewPools();
1304
+ // [ 'factory-crypto-232' ]
1305
+ })()
1306
+ ```
1307
+
1286
1308
  ### Deploy stable plain pool
1287
1309
 
1288
1310
  ```ts
package/lib/curve.d.ts CHANGED
@@ -71,10 +71,16 @@ declare class Curve implements ICurve {
71
71
  }): Promise<void>;
72
72
  setContract(address: string, abi: any): void;
73
73
  _filterHiddenPools(pools: IDict<IPoolData>): Promise<IDict<IPoolData>>;
74
- fetchFactoryPools(useApi?: boolean): Promise<void>;
75
- fetchCryptoFactoryPools(useApi?: boolean): Promise<void>;
76
- fetchRecentlyDeployedFactoryPool(poolAddress: string): Promise<string>;
77
- fetchRecentlyDeployedCryptoFactoryPool(poolAddress: string): Promise<string>;
74
+ _updateDecimalsAndGauges(pools: IDict<IPoolData>): void;
75
+ fetchFactoryPools: (useApi?: boolean) => Promise<void>;
76
+ fetchCryptoFactoryPools: (useApi?: boolean) => Promise<void>;
77
+ fetchNewFactoryPools: () => Promise<string[]>;
78
+ fetchNewCryptoFactoryPools: () => Promise<string[]>;
79
+ fetchRecentlyDeployedFactoryPool: (poolAddress: string) => Promise<string>;
80
+ fetchRecentlyDeployedCryptoFactoryPool: (poolAddress: string) => Promise<string>;
81
+ getPoolList: () => string[];
82
+ getFactoryPoolList: () => string[];
83
+ getCryptoFactoryPoolList: () => string[];
78
84
  setCustomFeeData(customFeeData: {
79
85
  gasPrice?: number;
80
86
  maxFeePerGas?: number;
package/lib/curve.js CHANGED
@@ -299,6 +299,156 @@ exports.NETWORK_CONSTANTS = {
299
299
  };
300
300
  var Curve = /** @class */ (function () {
301
301
  function Curve() {
302
+ var _this = this;
303
+ this.fetchFactoryPools = function (useApi) {
304
+ if (useApi === void 0) { useApi = true; }
305
+ return __awaiter(_this, void 0, void 0, function () {
306
+ var _a, _b, _c, _d, _e;
307
+ return __generator(this, function (_f) {
308
+ switch (_f.label) {
309
+ case 0:
310
+ if (this.chainId === 1313161554)
311
+ return [2 /*return*/];
312
+ if (!useApi) return [3 /*break*/, 2];
313
+ _a = this.constants;
314
+ _b = utils_1.lowerCasePoolDataAddresses;
315
+ return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, false)];
316
+ case 1:
317
+ _a.FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
318
+ return [3 /*break*/, 4];
319
+ case 2:
320
+ _c = this.constants;
321
+ _d = utils_1.lowerCasePoolDataAddresses;
322
+ return [4 /*yield*/, factory_1.getFactoryPoolData.call(this)];
323
+ case 3:
324
+ _c.FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
325
+ _f.label = 4;
326
+ case 4:
327
+ _e = this.constants;
328
+ return [4 /*yield*/, this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA)];
329
+ case 5:
330
+ _e.FACTORY_POOLS_DATA = _f.sent();
331
+ this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
332
+ return [4 /*yield*/, _killGauges(this.constants.FACTORY_POOLS_DATA)];
333
+ case 6:
334
+ _f.sent();
335
+ return [2 /*return*/];
336
+ }
337
+ });
338
+ });
339
+ };
340
+ this.fetchCryptoFactoryPools = function (useApi) {
341
+ if (useApi === void 0) { useApi = true; }
342
+ return __awaiter(_this, void 0, void 0, function () {
343
+ var _a, _b, _c, _d, _e;
344
+ return __generator(this, function (_f) {
345
+ switch (_f.label) {
346
+ case 0:
347
+ if (![1, 137, 250].includes(this.chainId))
348
+ return [2 /*return*/];
349
+ if (!useApi) return [3 /*break*/, 2];
350
+ _a = this.constants;
351
+ _b = utils_1.lowerCasePoolDataAddresses;
352
+ return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, true)];
353
+ case 1:
354
+ _a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
355
+ return [3 /*break*/, 4];
356
+ case 2:
357
+ _c = this.constants;
358
+ _d = utils_1.lowerCasePoolDataAddresses;
359
+ return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this)];
360
+ case 3:
361
+ _c.CRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
362
+ _f.label = 4;
363
+ case 4:
364
+ _e = this.constants;
365
+ return [4 /*yield*/, this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
366
+ case 5:
367
+ _e.CRYPTO_FACTORY_POOLS_DATA = _f.sent();
368
+ this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
369
+ return [4 /*yield*/, _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
370
+ case 6:
371
+ _f.sent();
372
+ return [2 /*return*/];
373
+ }
374
+ });
375
+ });
376
+ };
377
+ this.fetchNewFactoryPools = function () { return __awaiter(_this, void 0, void 0, function () {
378
+ var currentPoolIds, lastPoolIdx, poolData, _a;
379
+ return __generator(this, function (_b) {
380
+ switch (_b.label) {
381
+ case 0:
382
+ if (this.chainId === 1313161554)
383
+ return [2 /*return*/, []];
384
+ currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
385
+ lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
386
+ _a = utils_1.lowerCasePoolDataAddresses;
387
+ return [4 /*yield*/, factory_1.getFactoryPoolData.call(this, lastPoolIdx + 1)];
388
+ case 1:
389
+ poolData = _a.apply(void 0, [_b.sent()]);
390
+ this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
391
+ this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
392
+ return [2 /*return*/, Object.keys(poolData)];
393
+ }
394
+ });
395
+ }); };
396
+ this.fetchNewCryptoFactoryPools = function () { return __awaiter(_this, void 0, void 0, function () {
397
+ var currentPoolIds, lastPoolIdx, poolData, _a;
398
+ return __generator(this, function (_b) {
399
+ switch (_b.label) {
400
+ case 0:
401
+ if (![1, 137, 250].includes(this.chainId))
402
+ return [2 /*return*/, []];
403
+ currentPoolIds = Object.keys(this.constants.CRYPTO_FACTORY_POOLS_DATA);
404
+ lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
405
+ _a = utils_1.lowerCasePoolDataAddresses;
406
+ return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this, lastPoolIdx + 1)];
407
+ case 1:
408
+ poolData = _a.apply(void 0, [_b.sent()]);
409
+ this.constants.CRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
410
+ this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
411
+ return [2 /*return*/, Object.keys(poolData)];
412
+ }
413
+ });
414
+ }); };
415
+ this.fetchRecentlyDeployedFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
416
+ var poolData, _a;
417
+ return __generator(this, function (_b) {
418
+ switch (_b.label) {
419
+ case 0:
420
+ if (this.chainId === 1313161554)
421
+ return [2 /*return*/, ''];
422
+ _a = utils_1.lowerCasePoolDataAddresses;
423
+ return [4 /*yield*/, factory_1.getFactoryPoolData.call(this, 0, poolAddress)];
424
+ case 1:
425
+ poolData = _a.apply(void 0, [_b.sent()]);
426
+ this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
427
+ this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
428
+ return [2 /*return*/, Object.keys(poolData)[0]]; // id
429
+ }
430
+ });
431
+ }); };
432
+ this.fetchRecentlyDeployedCryptoFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
433
+ var poolData, _a;
434
+ return __generator(this, function (_b) {
435
+ switch (_b.label) {
436
+ case 0:
437
+ if (![1, 137, 250].includes(this.chainId))
438
+ return [2 /*return*/, ''];
439
+ _a = utils_1.lowerCasePoolDataAddresses;
440
+ return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this, 0, poolAddress)];
441
+ case 1:
442
+ poolData = _a.apply(void 0, [_b.sent()]);
443
+ this.constants.CRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
444
+ this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
445
+ return [2 /*return*/, Object.keys(poolData)[0]]; // id
446
+ }
447
+ });
448
+ }); };
449
+ this.getPoolList = function () { return Object.keys(_this.constants.POOLS_DATA); };
450
+ this.getFactoryPoolList = function () { return Object.keys(_this.constants.FACTORY_POOLS_DATA); };
451
+ this.getCryptoFactoryPoolList = function () { return Object.keys(_this.constants.CRYPTO_FACTORY_POOLS_DATA); };
302
452
  // @ts-ignore
303
453
  this.provider = null;
304
454
  // @ts-ignore
@@ -328,7 +478,7 @@ var Curve = /** @class */ (function () {
328
478
  var _a;
329
479
  if (options === void 0) { options = {}; }
330
480
  return __awaiter(this, void 0, void 0, function () {
331
- var network, _b, _c, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _d, err_1, _i, _e, pool, _f, _g, coinAddr, _h, _j, coinAddr, _k, _l, coinAddr, _minterABI, addressProviderContract, _m;
481
+ var network, _b, poolId, _c, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _d, err_1, _i, _e, pool, _f, _g, coinAddr, _h, _j, coinAddr, _k, _l, coinAddr, _minterABI, addressProviderContract, _m;
332
482
  return __generator(this, function (_o) {
333
483
  switch (_o.label) {
334
484
  case 0:
@@ -406,6 +556,8 @@ var Curve = /** @class */ (function () {
406
556
  this.constants.NETWORK_NAME = exports.NETWORK_CONSTANTS[this.chainId].NAME;
407
557
  this.constants.ALIASES = exports.NETWORK_CONSTANTS[this.chainId].ALIASES;
408
558
  this.constants.POOLS_DATA = exports.NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
559
+ for (poolId in this.constants.POOLS_DATA)
560
+ this.constants.POOLS_DATA[poolId].in_api = true;
409
561
  this.constants.COINS = exports.NETWORK_CONSTANTS[this.chainId].COINS;
410
562
  this.constants.DECIMALS = (0, utils_1.extractDecimals)(this.constants.POOLS_DATA);
411
563
  this.constants.DECIMALS[this.constants.NATIVE_TOKEN.address] = 18;
@@ -543,121 +695,9 @@ var Curve = /** @class */ (function () {
543
695
  });
544
696
  });
545
697
  };
546
- Curve.prototype.fetchFactoryPools = function (useApi) {
547
- if (useApi === void 0) { useApi = true; }
548
- return __awaiter(this, void 0, void 0, function () {
549
- var _a, _b, _c, _d, _e;
550
- return __generator(this, function (_f) {
551
- switch (_f.label) {
552
- case 0:
553
- if (this.chainId === 1313161554)
554
- return [2 /*return*/];
555
- if (!useApi) return [3 /*break*/, 2];
556
- _a = this.constants;
557
- _b = utils_1.lowerCasePoolDataAddresses;
558
- return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, false)];
559
- case 1:
560
- _a.FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
561
- return [3 /*break*/, 4];
562
- case 2:
563
- _c = this.constants;
564
- _d = utils_1.lowerCasePoolDataAddresses;
565
- return [4 /*yield*/, factory_1.getFactoryPoolData.call(this)];
566
- case 3:
567
- _c.FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
568
- _f.label = 4;
569
- case 4:
570
- _e = this.constants;
571
- return [4 /*yield*/, this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA)];
572
- case 5:
573
- _e.FACTORY_POOLS_DATA = _f.sent();
574
- this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.FACTORY_POOLS_DATA));
575
- this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.FACTORY_POOLS_DATA), true);
576
- return [4 /*yield*/, _killGauges(this.constants.FACTORY_POOLS_DATA)];
577
- case 6:
578
- _f.sent();
579
- return [2 /*return*/];
580
- }
581
- });
582
- });
583
- };
584
- Curve.prototype.fetchCryptoFactoryPools = function (useApi) {
585
- if (useApi === void 0) { useApi = true; }
586
- return __awaiter(this, void 0, void 0, function () {
587
- var _a, _b, _c, _d, _e;
588
- return __generator(this, function (_f) {
589
- switch (_f.label) {
590
- case 0:
591
- if (![1, 137, 250].includes(this.chainId))
592
- return [2 /*return*/];
593
- if (!useApi) return [3 /*break*/, 2];
594
- _a = this.constants;
595
- _b = utils_1.lowerCasePoolDataAddresses;
596
- return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, true)];
597
- case 1:
598
- _a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
599
- return [3 /*break*/, 4];
600
- case 2:
601
- _c = this.constants;
602
- _d = utils_1.lowerCasePoolDataAddresses;
603
- return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this)];
604
- case 3:
605
- _c.CRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
606
- _f.label = 4;
607
- case 4:
608
- _e = this.constants;
609
- return [4 /*yield*/, this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
610
- case 5:
611
- _e.CRYPTO_FACTORY_POOLS_DATA = _f.sent();
612
- this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.CRYPTO_FACTORY_POOLS_DATA));
613
- this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.CRYPTO_FACTORY_POOLS_DATA), true);
614
- return [4 /*yield*/, _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
615
- case 6:
616
- _f.sent();
617
- return [2 /*return*/];
618
- }
619
- });
620
- });
621
- };
622
- Curve.prototype.fetchRecentlyDeployedFactoryPool = function (poolAddress) {
623
- return __awaiter(this, void 0, void 0, function () {
624
- var poolData, _a;
625
- return __generator(this, function (_b) {
626
- switch (_b.label) {
627
- case 0:
628
- if (this.chainId === 1313161554)
629
- return [2 /*return*/, ''];
630
- _a = utils_1.lowerCasePoolDataAddresses;
631
- return [4 /*yield*/, factory_1.getFactoryPoolData.call(this, poolAddress)];
632
- case 1:
633
- poolData = _a.apply(void 0, [_b.sent()]);
634
- this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
635
- this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.FACTORY_POOLS_DATA));
636
- this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.FACTORY_POOLS_DATA), true);
637
- return [2 /*return*/, Object.keys(poolData)[0]]; // id
638
- }
639
- });
640
- });
641
- };
642
- Curve.prototype.fetchRecentlyDeployedCryptoFactoryPool = function (poolAddress) {
643
- return __awaiter(this, void 0, void 0, function () {
644
- var poolData, _a;
645
- return __generator(this, function (_b) {
646
- switch (_b.label) {
647
- case 0:
648
- if (![1, 137, 250].includes(this.chainId))
649
- return [2 /*return*/, ''];
650
- _a = utils_1.lowerCasePoolDataAddresses;
651
- return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this, poolAddress)];
652
- case 1:
653
- poolData = _a.apply(void 0, [_b.sent()]);
654
- this.constants.CRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
655
- this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.CRYPTO_FACTORY_POOLS_DATA));
656
- this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(this.constants.CRYPTO_FACTORY_POOLS_DATA), true);
657
- return [2 /*return*/, Object.keys(poolData)[0]]; // id
658
- }
659
- });
660
- });
698
+ Curve.prototype._updateDecimalsAndGauges = function (pools) {
699
+ this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(pools));
700
+ this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(pools), true);
661
701
  };
662
702
  Curve.prototype.setCustomFeeData = function (customFeeData) {
663
703
  this.feeData = __assign(__assign({}, this.feeData), customFeeData);
@@ -284,6 +284,10 @@ exports.basePoolIdZapDictEthereum = {
284
284
  address: "0x08780fb7E580e492c1935bEe4fA5920b94AA95Da".toLowerCase(),
285
285
  ABI: meta_zap_json_1.default,
286
286
  },
287
+ fraxusdp: {
288
+ address: "0x63B709d2118Ba0389ee75A131d1F9a473e06afbD".toLowerCase(),
289
+ ABI: meta_zap_json_1.default,
290
+ },
287
291
  sbtc: {
288
292
  address: "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(),
289
293
  ABI: deposit_json_1.default,
@@ -1,12 +1,12 @@
1
1
  import { ethers } from "ethers";
2
- export declare const deployStablePlainPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number, fee: number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<number>;
3
- export declare const deployStablePlainPool: (name: string, symbol: string, coins: string[], A: number, fee: number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<ethers.ContractTransaction>;
2
+ export declare const deployStablePlainPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number | string, fee: number | string, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<number>;
3
+ export declare const deployStablePlainPool: (name: string, symbol: string, coins: string[], A: number | string, fee: number | string, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<ethers.ContractTransaction>;
4
4
  export declare const getDeployedStablePlainPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
5
- export declare const deployStableMetaPoolEstimateGas: (basePool: string, name: string, symbol: string, coin: string, A: number, fee: number, implementationIdx: 0 | 1) => Promise<number>;
6
- export declare const deployStableMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number, fee: number, implementationIdx: 0 | 1) => Promise<ethers.ContractTransaction>;
5
+ export declare const deployStableMetaPoolEstimateGas: (basePool: string, name: string, symbol: string, coin: string, A: number | string, fee: number | string, implementationIdx: 0 | 1) => Promise<number>;
6
+ export declare const deployStableMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number | string, fee: number | string, implementationIdx: 0 | 1) => Promise<ethers.ContractTransaction>;
7
7
  export declare const getDeployedStableMetaPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
8
- export declare const deployCryptoPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number, gamma: number, midFee: number, outFee: number, allowedExtraProfit: number, feeGamma: number, adjustmentStep: number, maHalfTime: number, initialPrice: number) => Promise<number>;
9
- export declare const deployCryptoPool: (name: string, symbol: string, coins: string[], A: number, gamma: number, midFee: number, outFee: number, allowedExtraProfit: number, feeGamma: number, adjustmentStep: number, maHalfTime: number, initialPrice: number) => Promise<ethers.ContractTransaction>;
8
+ export declare const deployCryptoPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, maHalfTime: number | string, initialPrice: number | string) => Promise<number>;
9
+ export declare const deployCryptoPool: (name: string, symbol: string, coins: string[], A: number | string, gamma: number | string, midFee: number | string, outFee: number | string, allowedExtraProfit: number | string, feeGamma: number | string, adjustmentStep: number | string, maHalfTime: number | string, initialPrice: number | string) => Promise<ethers.ContractTransaction>;
10
10
  export declare const getDeployedCryptoPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
11
11
  export declare const deployGaugeEstimateGas: (pool: string, isCrypto: boolean) => Promise<number>;
12
12
  export declare const deployGauge: (pool: string, isCrypto: boolean) => Promise<ethers.ContractTransaction>;
@@ -68,10 +68,10 @@ assetType, implementationIdx, estimateGas) { return __awaiter(void 0, void 0, vo
68
68
  throw Error("Max symbol length = 10");
69
69
  if (![2, 3, 4].includes(coins.length))
70
70
  throw Error("Invalid number of coins. Must be 2, 3 or 4");
71
- if (fee < 0.04)
72
- throw Error("Fee must be >= 0.04%");
73
- if (fee > 1)
74
- throw Error("Fee must be <= 1%");
71
+ if ((0, utils_1.BN)(fee).lt(0.04))
72
+ throw Error("fee must be >= 0.04%. Passed fee = ".concat(fee));
73
+ if ((0, utils_1.BN)(fee).gt(1))
74
+ throw Error("fee must be <= 1%. Passed fee = ".concat(fee));
75
75
  if (![0, 1, 2, 3].includes(assetType))
76
76
  throw Error("Invalid assetType. Must be one of: 0 = USD, 1 = ETH, 2 = BTC, 3 = Other");
77
77
  if (![0, 1, 2, 3].includes(implementationIdx))
@@ -137,10 +137,10 @@ implementationIdx, estimateGas) { return __awaiter(void 0, void 0, void 0, funct
137
137
  throw Error("Max name length = 32");
138
138
  if (symbol.length > 10)
139
139
  throw Error("Max symbol length = 10");
140
- if (fee < 0.04)
141
- throw Error("Fee must be >= 0.04%");
142
- if (fee > 1)
143
- throw Error("Fee must be <= 1%");
140
+ if ((0, utils_1.BN)(fee).lt(0.04))
141
+ throw Error("fee must be >= 0.04%. Passed fee = ".concat(fee));
142
+ if ((0, utils_1.BN)(fee).gt(1))
143
+ throw Error("fee must be <= 1%. Passed fee = ".concat(fee));
144
144
  if (![0, 1].includes(implementationIdx))
145
145
  throw Error("Invalid implementationIdx. Must be one 0 or 1");
146
146
  _A = (0, utils_1.parseUnits)(A, 0);
@@ -187,7 +187,7 @@ var getDeployedStableMetaPoolAddress = function (tx) { return __awaiter(void 0,
187
187
  case 0: return [4 /*yield*/, tx.wait()];
188
188
  case 1:
189
189
  txInfo = _a.sent();
190
- return [2 /*return*/, txInfo.logs[txInfo.logs.length - 3].address.toLowerCase()];
190
+ return [2 /*return*/, txInfo.logs[3].address.toLowerCase()];
191
191
  }
192
192
  });
193
193
  }); };
@@ -197,7 +197,7 @@ var _deployCryptoPool = function (name, symbol, coins, A, gamma, midFee, // %
197
197
  outFee, // %
198
198
  allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, // Seconds
199
199
  initialPrice, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
200
- var _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, _initialPrice, contract, gas, gasLimit;
200
+ var _A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, _maHalfTime, _initialPrice, contract, gas, gasLimit;
201
201
  return __generator(this, function (_a) {
202
202
  switch (_a.label) {
203
203
  case 0:
@@ -209,51 +209,53 @@ initialPrice, estimateGas) { return __awaiter(void 0, void 0, void 0, function (
209
209
  throw Error("Invalid number of coins. Must be 2");
210
210
  if (coins[1] === coins[2])
211
211
  throw Error("Coins must be different");
212
- if (A < 4000)
213
- throw Error("A must be >= 4000");
214
- if (A > 4 * (Math.pow(10, 9)))
215
- throw Error("A must be <= 4 * 10 ** 9");
216
- if (gamma < 1e-8)
217
- throw Error("gamma must be >= 1e-8");
218
- if (gamma > 0.02)
219
- throw Error("gamma must be <= 0.02");
220
- if (midFee < 0.005)
221
- throw Error("midFee must be >= 0.005");
222
- if (midFee > 100)
223
- throw Error("midFee must be <= 100");
224
- if (outFee < midFee)
225
- throw Error("outFee must be >= midFee");
226
- if (outFee > 100)
227
- throw Error("outFee must be <= 100");
228
- if (allowedExtraProfit < 0)
229
- throw Error("allowedExtraProfit must be >= 0");
230
- if (allowedExtraProfit > 0.01)
231
- throw Error("allowedExtraProfit must be <= 0.01");
232
- if (feeGamma < 0)
233
- throw Error("feeGamma must be >= 0");
234
- if (feeGamma > 1)
235
- throw Error("feeGamma must be <= 1");
236
- if (adjustmentStep < 0)
237
- throw Error("adjustmentStep must be >= 0");
238
- if (adjustmentStep > 1)
239
- throw Error("adjustmentStep must be <= 1");
240
- if (maHalfTime < 0)
241
- throw Error("daoFee must be >= 0");
242
- if (maHalfTime > 604800)
243
- throw Error("daoFee must be <= 604800");
244
- if (initialPrice < 1e-12)
245
- throw Error("initialPrice must be >= 1e-12");
246
- if (initialPrice > 1e12)
247
- throw Error("initialPrice must be <= 1e12");
212
+ if ((0, utils_1.BN)(A).lt(4000))
213
+ throw Error("A must be >= 4000. Passed A = ".concat(A));
214
+ if ((0, utils_1.BN)(A).gt(4 * (Math.pow(10, 9))))
215
+ throw Error("A must be <= 4 * 10 ** 9. Passed A = ".concat(A));
216
+ if ((0, utils_1.BN)(gamma).lt(1e-8))
217
+ throw Error("gamma must be >= 1e-8. Passed gamma = ".concat(gamma));
218
+ if ((0, utils_1.BN)(gamma).gt(0.02))
219
+ throw Error("gamma must be <= 0.02. Passed gamma = ".concat(gamma));
220
+ if ((0, utils_1.BN)(midFee).lt(0.005))
221
+ throw Error("midFee must be >= 0.005. Passed midFee = ".concat(midFee));
222
+ if ((0, utils_1.BN)(midFee).gt(100))
223
+ throw Error("midFee must be <= 100. Passed midFee = ".concat(midFee));
224
+ if ((0, utils_1.BN)(outFee).lt((0, utils_1.BN)(midFee)))
225
+ throw Error("outFee must be >= midFee. Passed outFee = ".concat(outFee, " < midFee = ").concat(midFee));
226
+ if ((0, utils_1.BN)(outFee).gt(100))
227
+ throw Error("outFee must be <= 100. Passed outFee = ".concat(outFee));
228
+ if ((0, utils_1.BN)(allowedExtraProfit).lt(0))
229
+ throw Error("allowedExtraProfit must be >= 0. Passed allowedExtraProfit = ".concat(allowedExtraProfit));
230
+ if ((0, utils_1.BN)(allowedExtraProfit).gt(0.01))
231
+ throw Error("allowedExtraProfit must be <= 0.01. Passed allowedExtraProfit = ".concat(allowedExtraProfit));
232
+ if ((0, utils_1.BN)(feeGamma).lt(0))
233
+ throw Error("feeGamma must be >= 0. Passed feeGamma = ".concat(feeGamma));
234
+ if ((0, utils_1.BN)(feeGamma).gt(1))
235
+ throw Error("feeGamma must be <= 1. Passed feeGamma = ".concat(feeGamma));
236
+ if ((0, utils_1.BN)(adjustmentStep).lt(0))
237
+ throw Error("adjustmentStep must be >= 0. Passed adjustmentStep=".concat(adjustmentStep));
238
+ if ((0, utils_1.BN)(adjustmentStep).gt(1))
239
+ throw Error("adjustmentStep must be <= 1. Passed adjustmentStep=".concat(adjustmentStep));
240
+ if ((0, utils_1.BN)(maHalfTime).lt(0))
241
+ throw Error("maHalfTime must be >= 0. Passed maHalfTime=".concat(maHalfTime));
242
+ if ((0, utils_1.BN)(maHalfTime).gt(604800))
243
+ throw Error("maHalfTime must be <= 604800. Passed maHalfTime=".concat(maHalfTime));
244
+ if ((0, utils_1.BN)(initialPrice).lt(1e-12))
245
+ throw Error("initialPrice must be >= 1e-12. Passed initialPrice=".concat(initialPrice));
246
+ if ((0, utils_1.BN)(initialPrice).gt(1e12))
247
+ throw Error("initialPrice must be <= 1e12. Passed initialPrice=".concat(initialPrice));
248
+ _A = (0, utils_1.parseUnits)(A, 0);
248
249
  _gamma = (0, utils_1.parseUnits)(gamma);
249
250
  _midFee = (0, utils_1.parseUnits)(midFee, 8);
250
251
  _outFee = (0, utils_1.parseUnits)(outFee, 8);
251
252
  _allowedExtraProfit = (0, utils_1.parseUnits)(allowedExtraProfit);
252
253
  _feeGamma = (0, utils_1.parseUnits)(feeGamma);
253
254
  _adjustmentStep = (0, utils_1.parseUnits)(adjustmentStep);
255
+ _maHalfTime = (0, utils_1.parseUnits)(maHalfTime, 0);
254
256
  _initialPrice = (0, utils_1.parseUnits)(initialPrice);
255
257
  contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.crypto_factory].contract;
256
- return [4 /*yield*/, contract.estimateGas.deploy_pool(name, symbol, coins, A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, 5000000000, maHalfTime, _initialPrice, curve_1.curve.constantOptions)];
258
+ return [4 /*yield*/, contract.estimateGas.deploy_pool(name, symbol, coins, _A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, 5000000000, _maHalfTime, _initialPrice, curve_1.curve.constantOptions)];
257
259
  case 1:
258
260
  gas = _a.sent();
259
261
  if (estimateGas)
@@ -262,8 +264,8 @@ initialPrice, estimateGas) { return __awaiter(void 0, void 0, void 0, function (
262
264
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
263
265
  case 2:
264
266
  _a.sent();
265
- return [4 /*yield*/, contract.deploy_pool(name, symbol, coins, A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, 5000000000, // 50%
266
- maHalfTime, _initialPrice, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
267
+ return [4 /*yield*/, contract.deploy_pool(name, symbol, coins, _A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, 5000000000, // 50%
268
+ _maHalfTime, _initialPrice, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
267
269
  case 3: return [2 /*return*/, _a.sent()];
268
270
  }
269
271
  });