@curvefi/api 2.34.2 → 2.35.0

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
@@ -24,6 +24,7 @@ import curve from "@curvefi/api";
24
24
 
25
25
  // Fetch factory pools
26
26
  await curve.factory.fetchPools();
27
+ await curve.crvUSDFactory.fetchPools();
27
28
  await curve.cryptoFactory.fetchPools();
28
29
  })()
29
30
  ```
@@ -185,6 +186,7 @@ import curve from "@curvefi/api";
185
186
  (async () => {
186
187
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
187
188
  await curve.factory.fetchPools();
189
+ await curve.crvUSDFactory.fetchPools();
188
190
  await curve.cryptoFactory.fetchPools();
189
191
 
190
192
  curve.getPoolList();
@@ -233,6 +235,9 @@ import curve from "@curvefi/api";
233
235
  // 'factory-v2-101', 'factory-v2-102', 'factory-v2-103', 'factory-v2-104',
234
236
  // ... 27 more items
235
237
  // ]
238
+
239
+ curve.crvUSDFactory.getPoolList();
240
+ // ['factory-crvusd-0', 'factory-crvusd-1', 'factory-crvusd-2', 'factory-crvusd-3']
236
241
 
237
242
  curve.cryptoFactory.getPoolList();
238
243
  // [
@@ -268,6 +273,7 @@ import curve from "@curvefi/api";
268
273
  (async () => {
269
274
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
270
275
  await curve.factory.fetchPools();
276
+ await curve.crvUSDFactory.fetchPools();
271
277
  await curve.cryptoFactory.fetchPools();
272
278
 
273
279
  const pool = curve.getPool('factory-v2-11');
@@ -973,6 +979,7 @@ import curve from "@curvefi/api";
973
979
  (async () => {
974
980
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
975
981
  await curve.factory.fetchPools();
982
+ await curve.crvUSDFactory.fetchPools();
976
983
  await curve.cryptoFactory.fetchPools();
977
984
 
978
985
  await curve.getBalances(['DAI', 'CRV']);
@@ -10,7 +10,7 @@ export var ALIASES_ETHEREUM = lowerCaseValues({
10
10
  "deposit_and_stake": "0x271fbE8aB7f1fB262f81C77Ea5303F03DA9d3d6A",
11
11
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
12
12
  "factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
13
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
13
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
14
14
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
15
15
  "registry_exchange": "",
16
16
  });
@@ -25,7 +25,7 @@ export var ALIASES_POLYGON = lowerCaseValues({
25
25
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
26
26
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
27
27
  "factory": '0x722272d36ef0da72ff51c5a65db7b870e2e8d4ee',
28
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
28
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
29
29
  "crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
30
30
  "registry_exchange": "",
31
31
  });
@@ -40,7 +40,7 @@ export var ALIASES_FANTOM = lowerCaseValues({
40
40
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
41
41
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
42
42
  "factory": "0x686d67265703d1f124c45e33d47d794c566889ba",
43
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
43
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
44
44
  "crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
45
45
  "registry_exchange": "",
46
46
  });
@@ -55,7 +55,7 @@ export var ALIASES_AVALANCHE = lowerCaseValues({
55
55
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
56
56
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
57
57
  "factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
58
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
58
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
59
59
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
60
60
  "registry_exchange": "",
61
61
  });
@@ -70,7 +70,7 @@ export var ALIASES_ARBITRUM = lowerCaseValues({
70
70
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
71
71
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
72
72
  "factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
73
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
73
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
74
74
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
75
75
  "registry_exchange": "",
76
76
  });
@@ -85,7 +85,7 @@ export var ALIASES_OPTIMISM = lowerCaseValues({
85
85
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
86
86
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
87
87
  "factory": '0x2db0E83599a91b508Ac268a6197b8B14F5e72840',
88
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
88
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
89
89
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
90
90
  "registry_exchange": "",
91
91
  });
@@ -100,7 +100,7 @@ export var ALIASES_XDAI = lowerCaseValues({
100
100
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
101
101
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
102
102
  "factory": '0xD19Baeadc667Cf2015e395f2B08668Ef120f41F5',
103
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
103
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
104
104
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
105
105
  "registry_exchange": "",
106
106
  });
@@ -115,7 +115,7 @@ export var ALIASES_MOONBEAM = lowerCaseValues({
115
115
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
116
116
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
117
117
  "factory": '0x4244eB811D6e0Ef302326675207A95113dB4E1F8',
118
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
118
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
119
119
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
120
120
  "registry_exchange": "",
121
121
  });
@@ -130,7 +130,7 @@ export var ALIASES_AURORA = lowerCaseValues({
130
130
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
131
131
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
132
132
  "factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
133
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
133
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
134
134
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
135
135
  "registry_exchange": "",
136
136
  });
@@ -145,7 +145,7 @@ export var ALIASES_KAVA = lowerCaseValues({
145
145
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
146
146
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
147
147
  "factory": '0x40bc62805471eF53DdD5C5cF99ed3d9e5aa81b48',
148
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
148
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
149
149
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
150
150
  "registry_exchange": "",
151
151
  });
@@ -160,7 +160,7 @@ export var ALIASES_CELO = lowerCaseValues({
160
160
  "deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
161
161
  "stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
162
162
  "factory": '0x5277A0226d10392295E8D383E9724D6E416d6e6C',
163
- "crvusd_factory": '0xA504742ceFE2F9027328B49c7cffeC3d79b5ab1c',
163
+ "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
164
164
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
165
165
  "registry_exchange": "",
166
166
  });
@@ -1650,7 +1650,7 @@ export var LLAMMAS_DATA_ETHEREUM = lowerCasePoolDataAddresses({
1650
1650
  full_name: "sfrxeth",
1651
1651
  symbol: "sfrxeth",
1652
1652
  reference_asset: 'CRYPTO',
1653
- swap_address: '0x77fCFB78151c676f390a6236A78b5d3152e43384',
1653
+ swap_address: '0x136e783846ef68C8Bd00a3369F787dF8d683a696',
1654
1654
  token_address: '0x0000000000000000000000000000000000000000',
1655
1655
  gauge_address: '0x0000000000000000000000000000000000000000',
1656
1656
  is_crypto: true,
@@ -1659,11 +1659,11 @@ export var LLAMMAS_DATA_ETHEREUM = lowerCasePoolDataAddresses({
1659
1659
  underlying_coins: ['crvUSD', 'sfrxETH'],
1660
1660
  wrapped_coins: ['crvUSD', 'sfrxETH'],
1661
1661
  underlying_coin_addresses: [
1662
- '0xf71040d20Cc3FFBb28c1abcEF46134C7936624e0',
1662
+ '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
1663
1663
  '0xac3E018457B222d93114458476f3E3416Abbe38F',
1664
1664
  ],
1665
1665
  wrapped_coin_addresses: [
1666
- '0xf71040d20Cc3FFBb28c1abcEF46134C7936624e0',
1666
+ '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
1667
1667
  '0xac3E018457B222d93114458476f3E3416Abbe38F',
1668
1668
  ],
1669
1669
  underlying_decimals: [18, 18],
package/lib/curve.d.ts CHANGED
@@ -48,6 +48,7 @@ declare class Curve implements ICurve {
48
48
  ALIASES: IDict<string>;
49
49
  POOLS_DATA: IDict<IPoolData>;
50
50
  FACTORY_POOLS_DATA: IDict<IPoolData>;
51
+ CRVUSD_FACTORY_POOLS_DATA: IDict<IPoolData>;
51
52
  CRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>;
52
53
  LLAMMAS_DATA: IDict<IPoolData>;
53
54
  COINS: IDict<string>;
@@ -74,6 +75,7 @@ declare class Curve implements ICurve {
74
75
  _filterHiddenPools(pools: IDict<IPoolData>): Promise<IDict<IPoolData>>;
75
76
  _updateDecimalsAndGauges(pools: IDict<IPoolData>): void;
76
77
  fetchFactoryPools: (useApi?: boolean) => Promise<void>;
78
+ fetchCrvusdFactoryPools: (useApi?: boolean) => Promise<void>;
77
79
  fetchCryptoFactoryPools: (useApi?: boolean) => Promise<void>;
78
80
  fetchNewFactoryPools: () => Promise<string[]>;
79
81
  fetchNewCryptoFactoryPools: () => Promise<string[]>;
@@ -81,6 +83,7 @@ declare class Curve implements ICurve {
81
83
  fetchRecentlyDeployedCryptoFactoryPool: (poolAddress: string) => Promise<string>;
82
84
  getPoolList: () => string[];
83
85
  getFactoryPoolList: () => string[];
86
+ getCrvusdFactoryPoolList: () => string[];
84
87
  getCryptoFactoryPoolList: () => string[];
85
88
  setCustomFeeData(customFeeData: {
86
89
  gasPrice?: number;
package/lib/curve.js CHANGED
@@ -299,48 +299,72 @@ var Curve = /** @class */ (function () {
299
299
  this.fetchFactoryPools = function (useApi) {
300
300
  if (useApi === void 0) { useApi = true; }
301
301
  return __awaiter(_this, void 0, void 0, function () {
302
- var _a, _b, poolData, _c, _d, _e, poolData, _f, _g;
303
- return __generator(this, function (_h) {
304
- switch (_h.label) {
302
+ var _a, _b, _c, _d, _e;
303
+ return __generator(this, function (_f) {
304
+ switch (_f.label) {
305
305
  case 0:
306
306
  if (this.chainId === 1313161554)
307
307
  return [2 /*return*/];
308
- if (!useApi) return [3 /*break*/, 4];
308
+ if (!useApi) return [3 /*break*/, 2];
309
309
  _a = this.constants;
310
310
  _b = lowerCasePoolDataAddresses;
311
- return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, false)];
311
+ return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, "factory")];
312
312
  case 1:
313
- _a.FACTORY_POOLS_DATA = _b.apply(void 0, [_h.sent()]);
314
- if (!(this.chainId === 1)) return [3 /*break*/, 3];
315
- _c = lowerCasePoolDataAddresses;
316
- return [4 /*yield*/, getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.crvusd_factory)];
313
+ _a.FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
314
+ return [3 /*break*/, 4];
317
315
  case 2:
318
- poolData = _c.apply(void 0, [_h.sent()]);
319
- this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
320
- _h.label = 3;
321
- case 3: return [3 /*break*/, 7];
322
- case 4:
323
- _d = this.constants;
324
- _e = lowerCasePoolDataAddresses;
316
+ _c = this.constants;
317
+ _d = lowerCasePoolDataAddresses;
325
318
  return [4 /*yield*/, getFactoryPoolData.call(this)];
326
- case 5:
327
- _d.FACTORY_POOLS_DATA = _e.apply(void 0, [_h.sent()]);
328
- if (!(this.chainId === 1)) return [3 /*break*/, 7];
329
- _f = lowerCasePoolDataAddresses;
330
- return [4 /*yield*/, getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.crvusd_factory)];
331
- case 6:
332
- poolData = _f.apply(void 0, [_h.sent()]);
333
- this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
334
- _h.label = 7;
335
- case 7:
336
- _g = this.constants;
319
+ case 3:
320
+ _c.FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
321
+ _f.label = 4;
322
+ case 4:
323
+ _e = this.constants;
337
324
  return [4 /*yield*/, this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA)];
338
- case 8:
339
- _g.FACTORY_POOLS_DATA = _h.sent();
325
+ case 5:
326
+ _e.FACTORY_POOLS_DATA = _f.sent();
340
327
  this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
341
328
  return [4 /*yield*/, _killGauges(this.constants.FACTORY_POOLS_DATA)];
342
- case 9:
343
- _h.sent();
329
+ case 6:
330
+ _f.sent();
331
+ return [2 /*return*/];
332
+ }
333
+ });
334
+ });
335
+ };
336
+ this.fetchCrvusdFactoryPools = function (useApi) {
337
+ if (useApi === void 0) { useApi = true; }
338
+ return __awaiter(_this, void 0, void 0, function () {
339
+ var _a, _b, _c, _d, _e;
340
+ return __generator(this, function (_f) {
341
+ switch (_f.label) {
342
+ case 0:
343
+ if (this.chainId != 1)
344
+ return [2 /*return*/];
345
+ if (!useApi) return [3 /*break*/, 2];
346
+ _a = this.constants;
347
+ _b = lowerCasePoolDataAddresses;
348
+ return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, "factory-crvusd")];
349
+ case 1:
350
+ _a.CRVUSD_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
351
+ return [3 /*break*/, 4];
352
+ case 2:
353
+ _c = this.constants;
354
+ _d = lowerCasePoolDataAddresses;
355
+ return [4 /*yield*/, getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.crvusd_factory)];
356
+ case 3:
357
+ _c.CRVUSD_FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
358
+ _f.label = 4;
359
+ case 4:
360
+ _e = this.constants;
361
+ return [4 /*yield*/, this._filterHiddenPools(this.constants.CRVUSD_FACTORY_POOLS_DATA)];
362
+ case 5:
363
+ _e.CRVUSD_FACTORY_POOLS_DATA = _f.sent();
364
+ this._updateDecimalsAndGauges(this.constants.CRVUSD_FACTORY_POOLS_DATA);
365
+ return [4 /*yield*/, _killGauges(this.constants.CRVUSD_FACTORY_POOLS_DATA)];
366
+ case 6:
367
+ _f.sent();
344
368
  return [2 /*return*/];
345
369
  }
346
370
  });
@@ -358,7 +382,7 @@ var Curve = /** @class */ (function () {
358
382
  if (!useApi) return [3 /*break*/, 2];
359
383
  _a = this.constants;
360
384
  _b = lowerCasePoolDataAddresses;
361
- return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, true)];
385
+ return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, "factory-crypto")];
362
386
  case 1:
363
387
  _a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
364
388
  return [3 /*break*/, 4];
@@ -390,7 +414,7 @@ var Curve = /** @class */ (function () {
390
414
  case 0:
391
415
  if (this.chainId === 1313161554)
392
416
  return [2 /*return*/, []];
393
- currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA).filter(function (id) { return !id.includes('crvusd'); });
417
+ currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
394
418
  lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
395
419
  _a = lowerCasePoolDataAddresses;
396
420
  return [4 /*yield*/, getFactoryPoolData.call(this, lastPoolIdx + 1)];
@@ -457,6 +481,7 @@ var Curve = /** @class */ (function () {
457
481
  }); };
458
482
  this.getPoolList = function () { return Object.keys(_this.constants.POOLS_DATA); };
459
483
  this.getFactoryPoolList = function () { return Object.keys(_this.constants.FACTORY_POOLS_DATA); };
484
+ this.getCrvusdFactoryPoolList = function () { return Object.keys(_this.constants.CRVUSD_FACTORY_POOLS_DATA); };
460
485
  this.getCryptoFactoryPoolList = function () { return Object.keys(_this.constants.CRYPTO_FACTORY_POOLS_DATA); };
461
486
  // @ts-ignore
462
487
  this.provider = null;
@@ -476,6 +501,7 @@ var Curve = /** @class */ (function () {
476
501
  ALIASES: {},
477
502
  POOLS_DATA: {},
478
503
  FACTORY_POOLS_DATA: {},
504
+ CRVUSD_FACTORY_POOLS_DATA: {},
479
505
  CRYPTO_FACTORY_POOLS_DATA: {},
480
506
  LLAMMAS_DATA: {},
481
507
  COINS: {},
@@ -511,6 +537,7 @@ var Curve = /** @class */ (function () {
511
537
  ALIASES: {},
512
538
  POOLS_DATA: {},
513
539
  FACTORY_POOLS_DATA: {},
540
+ CRVUSD_FACTORY_POOLS_DATA: {},
514
541
  CRYPTO_FACTORY_POOLS_DATA: {},
515
542
  LLAMMAS_DATA: {},
516
543
  COINS: {},
@@ -1,6 +1,6 @@
1
1
  import memoize from "memoizee";
2
2
  import { IExtendedPoolDataFromApi, ISubgraphPoolData, IDict, INetworkName } from "./interfaces";
3
- export declare const _getPoolsFromApi: ((network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>>;
3
+ export declare const _getPoolsFromApi: ((network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crvusd" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: INetworkName, poolType: "main" | "crypto" | "factory" | "factory-crvusd" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>>;
4
4
  export declare const _getSubgraphData: ((network: INetworkName) => Promise<{
5
5
  poolsData: ISubgraphPoolData[];
6
6
  totalVolume: number;
@@ -52,7 +52,7 @@ export var implementationABIDictEthereum = lowerCaseKeys({
52
52
  "0x4A4d7868390EF5CaC51cDA262888f34bD3025C3F": Plain2OptimizedABI,
53
53
  "0xc629a01eC23AB04E1050500A3717A2a5c0701497": Plain2BasicABI,
54
54
  "0x94b4DFd9Ba5865Cc931195c99A2db42F3fc5d45B": Plain2ETHABI,
55
- "0xAee70429bdfbf599a979f50d5Fde5EB0d317E0f7": Plain2BasicABI,
55
+ "0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286": Plain2BasicABI,
56
56
  "0x9B52F13DF69D79Ec5aAB6D1aCe3157d29B409cC3": Plain3BasicABI,
57
57
  "0x50b085f2e5958C4A87baf93A8AB79F6bec068494": Plain3BalancesABI,
58
58
  "0x8c1aB78601c259E1B43F19816923609dC7d7de9B": Plain3ETHABI,
@@ -1,3 +1,3 @@
1
1
  import { IDict, IPoolData, ICurve, IPoolDataFromApi } from "../interfaces";
2
2
  export declare const lowerCasePoolDataAddresses: (poolsData: IPoolDataFromApi[]) => IPoolDataFromApi[];
3
- export declare function getFactoryPoolsDataFromApi(this: ICurve, isCrypto: boolean): Promise<IDict<IPoolData>>;
3
+ export declare function getFactoryPoolsDataFromApi(this: ICurve, factoryType: "factory" | "factory-crvusd" | "factory-crypto"): Promise<IDict<IPoolData>>;
@@ -146,15 +146,15 @@ function setFactoryCoinsContracts(rawPoolList) {
146
146
  }
147
147
  }
148
148
  }
149
- export function getFactoryPoolsDataFromApi(isCrypto) {
149
+ export function getFactoryPoolsDataFromApi(factoryType) {
150
150
  return __awaiter(this, void 0, void 0, function () {
151
- var network, factoryType, rawPoolList, _a, mainAddresses, FACTORY_POOLS_DATA;
151
+ var network, isCrypto, rawPoolList, _a, mainAddresses, FACTORY_POOLS_DATA;
152
152
  var _this = this;
153
153
  return __generator(this, function (_b) {
154
154
  switch (_b.label) {
155
155
  case 0:
156
156
  network = this.constants.NETWORK_NAME;
157
- factoryType = isCrypto ? "factory-crypto" : "factory";
157
+ isCrypto = factoryType === "factory-crypto";
158
158
  _a = lowerCasePoolDataAddresses;
159
159
  return [4 /*yield*/, _getPoolsFromApi(network, factoryType)];
160
160
  case 1:
@@ -251,6 +251,7 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
251
251
  coinAddrDecimalsDict[addr] = decimals[i];
252
252
  });
253
253
  coinAddrNamesDict[this.constants.NATIVE_TOKEN.address] = this.constants.NATIVE_TOKEN.symbol;
254
+ coinAddrDecimalsDict[this.constants.NATIVE_TOKEN.address] = 18;
254
255
  return [2 /*return*/, [tokenSymbols, tokenNames, coinAddrNamesDict, coinAddrDecimalsDict]];
255
256
  }
256
257
  });
package/lib/index.d.ts CHANGED
@@ -70,6 +70,10 @@ declare const curve: {
70
70
  deployGauge: (poolAddress: string) => Promise<number>;
71
71
  };
72
72
  };
73
+ crvUSDFactory: {
74
+ fetchPools: (useApi?: boolean) => Promise<void>;
75
+ getPoolList: () => string[];
76
+ };
73
77
  cryptoFactory: {
74
78
  fetchPools: (useApi?: boolean) => Promise<void>;
75
79
  fetchNewPools: () => Promise<string[]>;
package/lib/index.js CHANGED
@@ -103,6 +103,10 @@ var curve = {
103
103
  }); }); },
104
104
  },
105
105
  },
106
+ crvUSDFactory: {
107
+ fetchPools: _curve.fetchCrvusdFactoryPools,
108
+ getPoolList: _curve.getCrvusdFactoryPoolList,
109
+ },
106
110
  cryptoFactory: {
107
111
  fetchPools: _curve.fetchCryptoFactoryPools,
108
112
  fetchNewPools: _curve.fetchNewCryptoFactoryPools,
@@ -1079,7 +1079,7 @@ var PoolTemplate = /** @class */ (function () {
1079
1079
  }
1080
1080
  });
1081
1081
  }); };
1082
- var poolData = __assign(__assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA), curve.constants.LLAMMAS_DATA)[id];
1082
+ var poolData = __assign(__assign(__assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRVUSD_FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA), curve.constants.LLAMMAS_DATA)[id];
1083
1083
  this.id = id;
1084
1084
  this.name = poolData.name;
1085
1085
  this.fullName = poolData.full_name;
package/lib/router.js CHANGED
@@ -136,7 +136,7 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
136
136
  case 0:
137
137
  inputCoinAddress = inputCoinAddress.toLowerCase();
138
138
  outputCoinAddress = outputCoinAddress.toLowerCase();
139
- ALL_POOLS = Object.entries(__assign(__assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA), curve.constants.LLAMMAS_DATA));
139
+ ALL_POOLS = Object.entries(__assign(__assign(__assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRVUSD_FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA), curve.constants.LLAMMAS_DATA));
140
140
  return [4 /*yield*/, _getAmplificationCoefficientsFromApi()];
141
141
  case 1:
142
142
  amplificationCoefficientDict = _s.sent();
@@ -174,7 +174,7 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
174
174
  case 0:
175
175
  wrapped_coin_addresses = poolData.wrapped_coin_addresses.map(function (a) { return a.toLowerCase(); });
176
176
  underlying_coin_addresses = poolData.underlying_coin_addresses.map(function (a) { return a.toLowerCase(); });
177
- base_pool = poolData.is_meta ? curve.constants.POOLS_DATA[poolData.base_pool] : null;
177
+ base_pool = poolData.is_meta ? __assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA)[poolData.base_pool] : null;
178
178
  meta_coin_addresses = base_pool ? base_pool.underlying_coin_addresses.map(function (a) { return a.toLowerCase(); }) : [];
179
179
  token_address = poolData.token_address.toLowerCase();
180
180
  is_aave_like_lending = poolData.is_lending && wrapped_coin_addresses.length === 3 && !poolData.deposit_address;
@@ -424,9 +424,9 @@ var _estimateGasForDifferentRoutes = function (routes, inputCoinAddress, outputC
424
424
  });
425
425
  }); };
426
426
  var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
427
- var _a, inputCoinDecimals, outputCoinDecimals, _amount, routesRaw, routes, calls, multicallContract, _i, routesRaw_1, r, _b, _route, _swapParams, _factorySwapAddresses, _outputAmounts, i, err_2, promises, contract, _c, routesRaw_2, r, _d, _route, _swapParams, _factorySwapAddresses, res, i, _e, gasAmounts, outputCoinUsdRate, gasData, ethUsdRate, gasPrice, expectedAmounts, expectedAmountsUsd, txCostsUsd;
428
- return __generator(this, function (_f) {
429
- switch (_f.label) {
427
+ var _a, inputCoinDecimals, outputCoinDecimals, _amount, routesRaw, routes, calls, multicallContract, _i, routesRaw_1, r, _b, _route, _swapParams, _factorySwapAddresses, _outputAmounts, i, err_2, contract, _outputs, _c, routesRaw_2, r, _d, _route, _swapParams, _factorySwapAddresses, _e, _f, e_1, i, _h, gasAmounts, outputCoinUsdRate, gasData, ethUsdRate, gasPrice, expectedAmounts, expectedAmountsUsd, txCostsUsd;
428
+ return __generator(this, function (_j) {
429
+ switch (_j.label) {
430
430
  case 0:
431
431
  _a = _getCoinDecimals(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _a[0], outputCoinDecimals = _a[1];
432
432
  _amount = parseUnits(amount, inputCoinDecimals);
@@ -434,11 +434,11 @@ var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amoun
434
434
  return [2 /*return*/, []];
435
435
  return [4 /*yield*/, _findAllRoutes(inputCoinAddress, outputCoinAddress)];
436
436
  case 1:
437
- routesRaw = (_f.sent()).map(function (route) { return ({ route: route, _output: curve.parseUnits("0"), outputUsd: 0, txCostUsd: 0 }); });
437
+ routesRaw = (_j.sent()).map(function (route) { return ({ route: route, _output: curve.parseUnits("0"), outputUsd: 0, txCostUsd: 0 }); });
438
438
  routes = [];
439
- _f.label = 2;
439
+ _j.label = 2;
440
440
  case 2:
441
- _f.trys.push([2, 4, , 6]);
441
+ _j.trys.push([2, 4, , 11]);
442
442
  calls = [];
443
443
  multicallContract = curve.contracts[curve.constants.ALIASES.registry_exchange].multicallContract;
444
444
  for (_i = 0, routesRaw_1 = routesRaw; _i < routesRaw_1.length; _i++) {
@@ -448,34 +448,48 @@ var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amoun
448
448
  }
449
449
  return [4 /*yield*/, curve.multicallProvider.all(calls)];
450
450
  case 3:
451
- _outputAmounts = _f.sent();
451
+ _outputAmounts = _j.sent();
452
452
  for (i = 0; i < _outputAmounts.length; i++) {
453
453
  routesRaw[i]._output = _outputAmounts[i];
454
454
  routes.push(routesRaw[i]);
455
455
  }
456
- return [3 /*break*/, 6];
456
+ return [3 /*break*/, 11];
457
457
  case 4:
458
- err_2 = _f.sent();
459
- promises = [];
458
+ err_2 = _j.sent();
460
459
  contract = curve.contracts[curve.constants.ALIASES.registry_exchange].contract;
461
- for (_c = 0, routesRaw_2 = routesRaw; _c < routesRaw_2.length; _c++) {
462
- r = routesRaw_2[_c];
463
- _d = _getExchangeMultipleArgs(r.route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
464
- promises.push(contract.get_exchange_multiple_amount(_route, _swapParams, _amount, _factorySwapAddresses, curve.constantOptions));
465
- }
466
- return [4 /*yield*/, Promise.allSettled(promises)];
460
+ _outputs = [];
461
+ _c = 0, routesRaw_2 = routesRaw;
462
+ _j.label = 5;
467
463
  case 5:
468
- res = _f.sent();
469
- for (i = 0; i < res.length; i++) {
470
- if (res[i].status === 'rejected') {
464
+ if (!(_c < routesRaw_2.length)) return [3 /*break*/, 10];
465
+ r = routesRaw_2[_c];
466
+ _d = _getExchangeMultipleArgs(r.route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
467
+ _j.label = 6;
468
+ case 6:
469
+ _j.trys.push([6, 8, , 9]);
470
+ _f = (_e = _outputs).push;
471
+ return [4 /*yield*/, contract.get_exchange_multiple_amount(_route, _swapParams, _amount, _factorySwapAddresses, curve.constantOptions)];
472
+ case 7:
473
+ _f.apply(_e, [_j.sent()]);
474
+ return [3 /*break*/, 9];
475
+ case 8:
476
+ e_1 = _j.sent();
477
+ _outputs.push(curve.parseUnits('-1', 0));
478
+ return [3 /*break*/, 9];
479
+ case 9:
480
+ _c++;
481
+ return [3 /*break*/, 5];
482
+ case 10:
483
+ for (i = 0; i < _outputs.length; i++) {
484
+ if (_outputs[i] < 0) {
471
485
  console.log("Route ".concat((routesRaw[i].route.map(function (s) { return s.poolId; })).join(" --> "), " is unavailable"));
472
486
  continue;
473
487
  }
474
- routesRaw[i]._output = res[i].value;
488
+ routesRaw[i]._output = _outputs[i];
475
489
  routes.push(routesRaw[i]);
476
490
  }
477
- return [3 /*break*/, 6];
478
- case 6:
491
+ return [3 /*break*/, 11];
492
+ case 11:
479
493
  if (routes.length === 0)
480
494
  return [2 /*return*/, []];
481
495
  if (routes.length === 1)
@@ -486,8 +500,8 @@ var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amoun
486
500
  axios.get("https://api.curve.fi/api/getGas"),
487
501
  _getUsdRate(ETH_ADDRESS),
488
502
  ])];
489
- case 7:
490
- _e = _f.sent(), gasAmounts = _e[0], outputCoinUsdRate = _e[1], gasData = _e[2], ethUsdRate = _e[3];
503
+ case 12:
504
+ _h = _j.sent(), gasAmounts = _h[0], outputCoinUsdRate = _h[1], gasData = _h[2], ethUsdRate = _h[3];
491
505
  gasPrice = gasData.data.data.gas.standard;
492
506
  expectedAmounts = (routes).map(function (route) { return Number(curve.formatUnits(route._output, outputCoinDecimals)); });
493
507
  expectedAmountsUsd = expectedAmounts.map(function (a) { return a * outputCoinUsdRate; });
@@ -553,7 +567,7 @@ export var swapExpected = function (inputCoin, outputCoin, amount) { return __aw
553
567
  });
554
568
  }); };
555
569
  export var swapPriceImpact = function (inputCoin, outputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
556
- var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _amount, _output, smallAmountIntBN, amountIntBN, contract, _smallAmount, _d, _route, _swapParams, _factorySwapAddresses, _smallOutput, e_1, priceImpactBN;
570
+ var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _amount, _output, smallAmountIntBN, amountIntBN, contract, _smallAmount, _d, _route, _swapParams, _factorySwapAddresses, _smallOutput, e_2, priceImpactBN;
557
571
  return __generator(this, function (_e) {
558
572
  switch (_e.label) {
559
573
  case 0:
@@ -579,7 +593,7 @@ export var swapPriceImpact = function (inputCoin, outputCoin, amount) { return _
579
593
  _smallOutput = _e.sent();
580
594
  return [3 /*break*/, 6];
581
595
  case 4:
582
- e_1 = _e.sent();
596
+ e_2 = _e.sent();
583
597
  _smallAmount = curve.parseUnits("1", inputCoinDecimals); // Dirty hack
584
598
  return [4 /*yield*/, contract.get_exchange_multiple_amount(_route, _swapParams, _smallAmount, _factorySwapAddresses, curve.constantOptions)];
585
599
  case 5:
package/lib/utils.js CHANGED
@@ -391,14 +391,14 @@ export var ensureAllowance = function (coins, amounts, spender, isMax) {
391
391
  });
392
392
  };
393
393
  export var getPoolNameBySwapAddress = function (swapAddress) {
394
- var poolsData = __assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA);
394
+ var poolsData = __assign(__assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRVUSD_FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA);
395
395
  return Object.entries(poolsData).filter(function (_a) {
396
396
  var _ = _a[0], poolData = _a[1];
397
397
  return poolData.swap_address.toLowerCase() === swapAddress.toLowerCase();
398
398
  })[0][0];
399
399
  };
400
400
  var _getTokenAddressBySwapAddress = function (swapAddress) {
401
- var poolsData = __assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA);
401
+ var poolsData = __assign(__assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRVUSD_FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA);
402
402
  var res = Object.entries(poolsData).filter(function (_a) {
403
403
  var _ = _a[0], poolData = _a[1];
404
404
  return poolData.swap_address.toLowerCase() === swapAddress.toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.34.2",
3
+ "version": "2.35.0",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",