@curvefi/api 2.28.3 → 2.30.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
@@ -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)
@@ -140,6 +140,12 @@ import curve from "@curvefi/api";
140
140
  (async () => {
141
141
  await curve.getTVL();
142
142
  // 7870819849.685552
143
+ await curve.getVolume();
144
+ // {
145
+ // totalVolume: 514893871.3481678,
146
+ // cryptoVolume: 162757004.96876568,
147
+ // cryptoShare: 31.609815930147377
148
+ // }
143
149
 
144
150
  const balances1 = await curve.getBalances(['DAI', 'sUSD']);
145
151
  // OR const balances1 = await curve.getBalances(['0x6B175474E89094C44Da98b954EedeAC495271d0F', '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51']);
@@ -178,8 +184,8 @@ import curve from "@curvefi/api";
178
184
 
179
185
  (async () => {
180
186
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
181
- await curve.fetchFactoryPools();
182
- await curve.fetchCryptoFactoryPools();
187
+ await curve.factory.fetchPools();
188
+ await curve.cryptoFactory.fetchPools();
183
189
 
184
190
  curve.getPoolList();
185
191
  // [
@@ -198,7 +204,7 @@ import curve from "@curvefi/api";
198
204
  // '2pool', '4pool'
199
205
  // ]
200
206
 
201
- curve.getFactoryPoolList();
207
+ curve.factory.getPoolList();
202
208
  // [
203
209
  // 'factory-v2-0', 'factory-v2-2', 'factory-v2-3', 'factory-v2-4',
204
210
  // 'factory-v2-5', 'factory-v2-6', 'factory-v2-7', 'factory-v2-8',
@@ -228,7 +234,7 @@ import curve from "@curvefi/api";
228
234
  // ... 27 more items
229
235
  // ]
230
236
 
231
- curve.getCryptoFactoryPoolList();
237
+ curve.cryptoFactory.getPoolList();
232
238
  // [
233
239
  // 'factory-crypto-0', 'factory-crypto-1', 'factory-crypto-2',
234
240
  // 'factory-crypto-3', 'factory-crypto-4', 'factory-crypto-5',
@@ -261,8 +267,8 @@ import curve from "@curvefi/api";
261
267
 
262
268
  (async () => {
263
269
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
264
- await curve.fetchFactoryPools();
265
- await curve.fetchCryptoFactoryPools();
270
+ await curve.factory.fetchPools();
271
+ await curve.cryptoFactory.fetchPools();
266
272
 
267
273
  const pool = curve.getPool('factory-v2-11');
268
274
 
@@ -964,8 +970,8 @@ import curve from "@curvefi/api";
964
970
 
965
971
  (async () => {
966
972
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
967
- await curve.fetchFactoryPools();
968
- await curve.getCryptoFactoryPoolList();
973
+ await curve.factory.fetchPools();
974
+ await curve.cryptoFactory.fetchPools();
969
975
 
970
976
  await curve.getBalances(['DAI', 'CRV']);
971
977
  // [ '9900.0', '100049.744832225238317557' ]
@@ -1277,6 +1283,26 @@ import curve from "@curvefi/api";
1277
1283
 
1278
1284
  ## Factory
1279
1285
 
1286
+ ### Fetch new pools from blockchain
1287
+
1288
+ ```ts
1289
+ import curve from "@curvefi/api";
1290
+
1291
+ (async () => {
1292
+ await curve.init('JsonRpc', {}, { gasPrice: 0 });
1293
+
1294
+ // Fetch pools from api (if false arg is not passed)
1295
+ await curve.factory.fetchPools();
1296
+ await curve.cryptoFactory.fetchPools();
1297
+
1298
+ // Fetch very new pools (that haven't been added to api yet) from blockchain
1299
+ await curve.factory.fetchNewPools();
1300
+ // [ 'factory-v2-285' ]
1301
+ await curve.cryptoFactory.fetchNewPools();
1302
+ // [ 'factory-crypto-232' ]
1303
+ })()
1304
+ ```
1305
+
1280
1306
  ### Deploy stable plain pool
1281
1307
 
1282
1308
  ```ts
package/lib/boosting.js CHANGED
@@ -180,7 +180,7 @@ exports.isApproved = isApproved;
180
180
  var approveEstimateGas = function (amount) { return __awaiter(void 0, void 0, void 0, function () {
181
181
  return __generator(this, function (_a) {
182
182
  switch (_a.label) {
183
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([curve_1.curve.constants.ALIASES.crv], [amount], curve_1.curve.constants.ALIASES.voting_escrow)];
183
+ case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([curve_1.curve.constants.ALIASES.crv], [amount], curve_1.curve.constants.ALIASES.voting_escrow, false)];
184
184
  case 1: return [2 /*return*/, _a.sent()];
185
185
  }
186
186
  });
@@ -189,7 +189,7 @@ exports.approveEstimateGas = approveEstimateGas;
189
189
  var approve = function (amount) { return __awaiter(void 0, void 0, void 0, function () {
190
190
  return __generator(this, function (_a) {
191
191
  switch (_a.label) {
192
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [amount], curve_1.curve.constants.ALIASES.voting_escrow)];
192
+ case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [amount], curve_1.curve.constants.ALIASES.voting_escrow, false)];
193
193
  case 1: return [2 /*return*/, _a.sent()];
194
194
  }
195
195
  });
@@ -233,7 +233,7 @@ var createLock = function (amount, days) { return __awaiter(void 0, void 0, void
233
233
  case 0:
234
234
  _amount = (0, utils_2.parseUnits)(amount);
235
235
  unlockTime = Math.floor(Date.now() / 1000) + (86400 * days);
236
- return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [_amount], curve_1.curve.constants.ALIASES.voting_escrow)];
236
+ return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [_amount], curve_1.curve.constants.ALIASES.voting_escrow, false)];
237
237
  case 1:
238
238
  _a.sent();
239
239
  contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.voting_escrow].contract;
@@ -278,7 +278,7 @@ var increaseAmount = function (amount) { return __awaiter(void 0, void 0, void 0
278
278
  switch (_a.label) {
279
279
  case 0:
280
280
  _amount = (0, utils_2.parseUnits)(amount);
281
- return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [_amount], curve_1.curve.constants.ALIASES.voting_escrow)];
281
+ return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.curve.constants.ALIASES.crv], [_amount], curve_1.curve.constants.ALIASES.voting_escrow, false)];
282
282
  case 1:
283
283
  _a.sent();
284
284
  contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.voting_escrow].contract;
@@ -9,7 +9,7 @@ exports.COINS_ETHEREUM = (0, utils_1.lowerCaseValues)({
9
9
  ycdai: "0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc",
10
10
  ycusdc: "0x9777d7E2b60bB01759D0E2f8be2095df444cb07E",
11
11
  ycusdt: "0x1bE5d71F2dA660BFdee8012dDc58D024448A0A59",
12
- pax: "0x8E870D67F660D95d5be530380D0eC0bd388289E1",
12
+ usdp: "0x8E870D67F660D95d5be530380D0eC0bd388289E1",
13
13
  adai: "0x028171bCA77440897B824Ca71D1c56caC55b68A3",
14
14
  ausdc: "0xBcca60bB61934080951369a648Fb03DF4F96263C",
15
15
  ausdt: "0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
@@ -34,7 +34,6 @@ exports.COINS_ETHEREUM = (0, utils_1.lowerCaseValues)({
34
34
  rsv: "0x196f4727526eA7FB1e17b2071B3d8eAA38486988",
35
35
  dusd: "0x5BC25f649fc4e26069dDF4cF4010F9f706c23831",
36
36
  ust: "0xa47c8bf37f92abed4a126bda807a7b7498661acd",
37
- usdp: "0x1456688345527bE1f37E9e627DA0837D6f08C925",
38
37
  usdn: "0x674C6Ad92Fd080e4004b2312b45f796a192D27a0",
39
38
  dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
40
39
  usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
@@ -255,8 +255,8 @@ exports.POOLS_DATA_ETHEREUM = (0, utils_1.lowerCasePoolDataAddresses)({
255
255
  gauge_address: '0x64E3C23bfc40722d3B649844055F1D51c1ac041d',
256
256
  deposit_address: '0xA50cCc70b6a011CffDdf45057E39679379187287',
257
257
  is_lending: true,
258
- underlying_coins: ['DAI', 'USDC', 'USDT', 'PAX'],
259
- wrapped_coins: ['ycDAI', 'ycUSDC', 'ycUSDT', 'PAX'],
258
+ underlying_coins: ['DAI', 'USDC', 'USDT', 'USDP'],
259
+ wrapped_coins: ['ycDAI', 'ycUSDC', 'ycUSDT', 'USDP'],
260
260
  underlying_coin_addresses: [
261
261
  '0x6B175474E89094C44Da98b954EedeAC495271d0F',
262
262
  '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
@@ -1599,4 +1599,28 @@ exports.POOLS_DATA_ETHEREUM = (0, utils_1.lowerCasePoolDataAddresses)({
1599
1599
  swap_abi: swap_json_44.default,
1600
1600
  gauge_abi: gauge_v5_json_1.default,
1601
1601
  },
1602
+ fraxusdp: {
1603
+ name: "fraxusdp",
1604
+ full_name: "fraxusdp",
1605
+ symbol: "fraxusdp",
1606
+ reference_asset: 'USD',
1607
+ swap_address: '0xaE34574AC03A15cd58A92DC79De7B1A0800F1CE3',
1608
+ token_address: '0xFC2838a17D8e8B1D5456E0a351B0708a09211147',
1609
+ gauge_address: '0xfb860600F1bE1f1c72A89B2eF5CAF345aff7D39d',
1610
+ is_plain: true,
1611
+ underlying_coins: ['FRAX', 'USDP'],
1612
+ wrapped_coins: ['FRAX', 'USDP'],
1613
+ underlying_coin_addresses: [
1614
+ '0x853d955aCEf822Db058eb8505911ED77F175b99e',
1615
+ '0x8E870D67F660D95d5be530380D0eC0bd388289E1',
1616
+ ],
1617
+ wrapped_coin_addresses: [
1618
+ '0x853d955aCEf822Db058eb8505911ED77F175b99e',
1619
+ '0x8E870D67F660D95d5be530380D0eC0bd388289E1',
1620
+ ],
1621
+ underlying_decimals: [18, 18],
1622
+ wrapped_decimals: [18, 18],
1623
+ swap_abi: swap_json_42.default,
1624
+ gauge_abi: gauge_v5_json_1.default,
1625
+ },
1602
1626
  });
package/lib/curve.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ethers, Contract } from "ethers";
2
2
  import { Networkish } from "@ethersproject/networks";
3
3
  import { Provider as MulticallProvider, Contract as MulticallContract } from 'ethcall';
4
- import { IPoolData, IDict, ICurve, INetworkName } from "./interfaces";
4
+ import { IPoolData, IDict, ICurve, INetworkName, IChainId } from "./interfaces";
5
5
  export declare const NATIVE_TOKENS: {
6
6
  [index: number]: {
7
7
  symbol: string;
@@ -18,7 +18,7 @@ declare class Curve implements ICurve {
18
18
  multicallProvider: MulticallProvider;
19
19
  signer: ethers.Signer | null;
20
20
  signerAddress: string;
21
- chainId: number;
21
+ chainId: IChainId;
22
22
  contracts: {
23
23
  [index: string]: {
24
24
  contract: Contract;
@@ -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,12 +299,162 @@ 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
305
455
  this.signer = null;
306
456
  this.signerAddress = '';
307
- this.chainId = 0;
457
+ this.chainId = 1;
308
458
  // @ts-ignore
309
459
  this.multicallProvider = null;
310
460
  this.contracts = {};
@@ -337,7 +487,7 @@ var Curve = /** @class */ (function () {
337
487
  // @ts-ignore
338
488
  this.signer = null;
339
489
  this.signerAddress = '';
340
- this.chainId = 0;
490
+ this.chainId = 1;
341
491
  // @ts-ignore
342
492
  this.multicallProvider = null;
343
493
  this.contracts = {};
@@ -543,121 +693,9 @@ var Curve = /** @class */ (function () {
543
693
  });
544
694
  });
545
695
  };
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
- });
696
+ Curve.prototype._updateDecimalsAndGauges = function (pools) {
697
+ this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(pools));
698
+ this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(pools), true);
661
699
  };
662
700
  Curve.prototype.setCustomFeeData = function (customFeeData) {
663
701
  this.feeData = __assign(__assign({}, this.feeData), customFeeData);
@@ -1,7 +1,17 @@
1
1
  import { IExtendedPoolDataFromApi, ISubgraphPoolData, IDict, INetworkName } from "./interfaces";
2
2
  import memoize from "memoizee";
3
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>>;
4
- export declare const _getSubgraphData: ((network: INetworkName) => Promise<ISubgraphPoolData[]>) & memoize.Memoized<(network: INetworkName) => Promise<ISubgraphPoolData[]>>;
4
+ export declare const _getSubgraphData: ((network: INetworkName) => Promise<{
5
+ poolsData: ISubgraphPoolData[];
6
+ totalVolume: number;
7
+ cryptoVolume: number;
8
+ cryptoShare: number;
9
+ }>) & memoize.Memoized<(network: INetworkName) => Promise<{
10
+ poolsData: ISubgraphPoolData[];
11
+ totalVolume: number;
12
+ cryptoVolume: number;
13
+ cryptoShare: number;
14
+ }>>;
5
15
  export declare const _getLegacyAPYsAndVolumes: ((network: string) => Promise<IDict<{
6
16
  apy: {
7
17
  day: number;
@@ -42,7 +42,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
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
- var curve_1 = require("./curve");
46
45
  exports._getPoolsFromApi = (0, memoizee_1.default)(function (network, poolType) { return __awaiter(void 0, void 0, void 0, function () {
47
46
  var url, response;
48
47
  var _a;
@@ -62,15 +61,20 @@ exports._getPoolsFromApi = (0, memoizee_1.default)(function (network, poolType)
62
61
  });
63
62
  exports._getSubgraphData = (0, memoizee_1.default)(function (network) { return __awaiter(void 0, void 0, void 0, function () {
64
63
  var url, response;
65
- var _a;
66
- return __generator(this, function (_b) {
67
- switch (_b.label) {
64
+ var _a, _b, _c, _d;
65
+ return __generator(this, function (_e) {
66
+ switch (_e.label) {
68
67
  case 0:
69
68
  url = "https://api.curve.fi/api/getSubgraphData/".concat(network);
70
69
  return [4 /*yield*/, axios_1.default.get(url, { validateStatus: function () { return true; } })];
71
70
  case 1:
72
- response = _b.sent();
73
- return [2 /*return*/, (_a = response.data.data.poolList) !== null && _a !== void 0 ? _a : []];
71
+ response = _e.sent();
72
+ return [2 /*return*/, {
73
+ poolsData: (_a = response.data.data.poolList) !== null && _a !== void 0 ? _a : [],
74
+ totalVolume: (_b = response.data.data.totalVolume) !== null && _b !== void 0 ? _b : 0,
75
+ cryptoVolume: (_c = response.data.data.cryptoVolume) !== null && _c !== void 0 ? _c : 0,
76
+ cryptoShare: (_d = response.data.data.cryptoShare) !== null && _d !== void 0 ? _d : 0,
77
+ }];
74
78
  }
75
79
  });
76
80
  }); }, {
@@ -83,9 +87,9 @@ exports._getLegacyAPYsAndVolumes = (0, memoizee_1.default)(function (network) {
83
87
  return __generator(this, function (_a) {
84
88
  switch (_a.label) {
85
89
  case 0:
86
- if (curve_1.curve.chainId === 2222 || curve_1.curve.chainId === 42220)
90
+ if (network === "kava" || network === "celo")
87
91
  return [2 /*return*/, {}]; // Exclude Kava and Celo
88
- url = "https://stats.curve.fi/raw-stats-".concat(network, "/apys.json");
92
+ url = "https://api.curve.fi/api/getMainPoolsAPYs/" + network;
89
93
  return [4 /*yield*/, axios_1.default.get(url, { validateStatus: function () { return true; } })];
90
94
  case 1:
91
95
  data = (_a.sent()).data;
@@ -110,7 +114,7 @@ exports._getFactoryAPYsAndVolumes = (0, memoizee_1.default)(function (network) {
110
114
  return __generator(this, function (_b) {
111
115
  switch (_b.label) {
112
116
  case 0:
113
- if (curve_1.curve.chainId === 1313161554)
117
+ if (network === "aurora")
114
118
  return [2 /*return*/, []]; // Exclude Aurora
115
119
  url = "https://api.curve.fi/api/getFactoryAPYs-".concat(network);
116
120
  return [4 /*yield*/, axios_1.default.get(url, { validateStatus: function () { return true; } })];
@@ -44,6 +44,8 @@ exports.implementationABIDictEthereum = (0, utils_1.lowerCaseKeys)({
44
44
  "0x55Aa9BF126bCABF0bDC17Fa9E39Ec9239e1ce7A9": MetaUSDBalances_json_1.default,
45
45
  "0x33bB0e62d5e8C688E645Dd46DFb48Cd613250067": MetaFraxUSD_json_1.default,
46
46
  "0x2EB24483Ef551dA247ab87Cf18e1Cc980073032D": MetaFraxUSDBalances_json_1.default,
47
+ "0xF9B62b61d108232Ef0C9DD143bb3c22c7D4A715a": MetaFraxUSD_json_1.default,
48
+ "0xB172AC2Fe440B5dA74Dc460e5E9d96bc2BF6261F": MetaFraxUSDBalances_json_1.default,
47
49
  "0xC6A8466d128Fbfd34AdA64a9FFFce325D57C9a52": MetaBTC_json_1.default,
48
50
  "0xc4C78b08fA0c3d0a312605634461A88184Ecd630": MetaBTCBalances_json_1.default,
49
51
  "0xECAaecd9d2193900b424774133B1f51ae0F29d9E": MetaBTCRen_json_1.default,
@@ -223,6 +225,8 @@ exports.implementationBasePoolIdDictEthereum = (0, utils_1.lowerCaseKeys)({
223
225
  "0x55Aa9BF126bCABF0bDC17Fa9E39Ec9239e1ce7A9": "3pool",
224
226
  "0x33bB0e62d5e8C688E645Dd46DFb48Cd613250067": "fraxusdc",
225
227
  "0x2EB24483Ef551dA247ab87Cf18e1Cc980073032D": "fraxusdc",
228
+ "0xF9B62b61d108232Ef0C9DD143bb3c22c7D4A715a": "fraxusdp",
229
+ "0xB172AC2Fe440B5dA74Dc460e5E9d96bc2BF6261F": "fraxusdp",
226
230
  "0xC6A8466d128Fbfd34AdA64a9FFFce325D57C9a52": "sbtc",
227
231
  "0xc4C78b08fA0c3d0a312605634461A88184Ecd630": "sbtc",
228
232
  "0xECAaecd9d2193900b424774133B1f51ae0F29d9E": "ren",
@@ -280,6 +284,10 @@ exports.basePoolIdZapDictEthereum = {
280
284
  address: "0x08780fb7E580e492c1935bEe4fA5920b94AA95Da".toLowerCase(),
281
285
  ABI: meta_zap_json_1.default,
282
286
  },
287
+ fraxusdp: {
288
+ address: "0x63B709d2118Ba0389ee75A131d1F9a473e06afbD".toLowerCase(),
289
+ ABI: meta_zap_json_1.default,
290
+ },
283
291
  sbtc: {
284
292
  address: "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(),
285
293
  ABI: deposit_json_1.default,
@@ -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
  }); };