@curvefi/api 2.32.0 → 2.33.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.
Files changed (59) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/aliases.js +22 -11
  3. package/lib/constants/coins/arbitrum.js +5 -5
  4. package/lib/constants/coins/aurora.js +5 -5
  5. package/lib/constants/coins/avalanche.js +6 -6
  6. package/lib/constants/coins/celo.js +5 -5
  7. package/lib/constants/coins/ethereum.js +10 -9
  8. package/lib/constants/coins/fantom.js +7 -7
  9. package/lib/constants/coins/kava.js +5 -5
  10. package/lib/constants/coins/moonbeam.js +5 -5
  11. package/lib/constants/coins/optimism.js +5 -5
  12. package/lib/constants/coins/polygon.js +6 -6
  13. package/lib/constants/coins/xdai.js +5 -5
  14. package/lib/constants/pools/arbitrum.js +1 -1
  15. package/lib/constants/pools/aurora.js +1 -1
  16. package/lib/constants/pools/avalanche.js +1 -1
  17. package/lib/constants/pools/celo.js +1 -1
  18. package/lib/constants/pools/ethereum.js +1 -1
  19. package/lib/constants/pools/fantom.js +1 -1
  20. package/lib/constants/pools/kava.js +1 -1
  21. package/lib/constants/pools/moonbeam.js +1 -1
  22. package/lib/constants/pools/optimism.js +1 -1
  23. package/lib/constants/pools/polygon.js +1 -1
  24. package/lib/constants/pools/xdai.js +1 -1
  25. package/lib/constants/utils.js +19 -18
  26. package/lib/curve.js +506 -282
  27. package/lib/external-api.js +132 -45
  28. package/lib/factory/common.js +3 -3
  29. package/lib/factory/constants-crypto.js +21 -21
  30. package/lib/factory/constants.js +32 -31
  31. package/lib/factory/deploy.js +336 -176
  32. package/lib/factory/factory-api.js +256 -180
  33. package/lib/factory/factory-crypto.js +309 -163
  34. package/lib/factory/factory.d.ts +1 -1
  35. package/lib/factory/factory.js +336 -186
  36. package/lib/index.js +98 -44
  37. package/lib/interfaces.d.ts +5 -0
  38. package/lib/pools/PoolTemplate.js +2879 -1468
  39. package/lib/pools/mixins/common.js +106 -22
  40. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  41. package/lib/pools/mixins/depositMixins.js +413 -144
  42. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  43. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  44. package/lib/pools/mixins/swapMixins.js +347 -125
  45. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  46. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  47. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  48. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  49. package/lib/pools/mixins/withdrawMixins.js +385 -122
  50. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  51. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  52. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  53. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  54. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  55. package/lib/pools/poolConstructor.js +25 -5
  56. package/lib/pools/utils.js +488 -299
  57. package/lib/router.js +675 -212
  58. package/lib/utils.js +675 -354
  59. package/package.json +1 -2
package/lib/curve.js CHANGED
@@ -1,3 +1,59 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
+ if (ar || !(i in from)) {
51
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
+ ar[i] = from[i];
53
+ }
54
+ }
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
1
57
  import { ethers, Contract } from "ethers";
2
58
  import { Provider as MulticallProvider, Contract as MulticallContract } from 'ethcall';
3
59
  import { getFactoryPoolData } from "./factory/factory.js";
@@ -35,19 +91,28 @@ import { COINS_KAVA, cTokensKava, yTokensKava, ycTokensKava, aTokensKava } from
35
91
  import { COINS_CELO, cTokensCelo, yTokensCelo, ycTokensCelo, aTokensCelo } from "./constants/coins/celo.js";
36
92
  import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./constants/utils.js";
37
93
  import { _getAllGauges, _getHiddenPools } from "./external-api.js";
38
- const _killGauges = async (poolsData) => {
39
- const gaugeData = await _getAllGauges();
40
- const isKilled = {};
41
- Object.values(gaugeData).forEach((d) => {
42
- isKilled[d.gauge.toLowerCase()] = d.is_killed ?? false;
43
- });
44
- for (const poolId in poolsData) {
45
- if (isKilled[poolsData[poolId].gauge_address]) {
46
- poolsData[poolId].gauge_address = ethers.ZeroAddress;
94
+ var _killGauges = function (poolsData) { return __awaiter(void 0, void 0, void 0, function () {
95
+ var gaugeData, isKilled, poolId;
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0: return [4 /*yield*/, _getAllGauges()];
99
+ case 1:
100
+ gaugeData = _a.sent();
101
+ isKilled = {};
102
+ Object.values(gaugeData).forEach(function (d) {
103
+ var _a;
104
+ isKilled[d.gauge.toLowerCase()] = (_a = d.is_killed) !== null && _a !== void 0 ? _a : false;
105
+ });
106
+ for (poolId in poolsData) {
107
+ if (isKilled[poolsData[poolId].gauge_address]) {
108
+ poolsData[poolId].gauge_address = ethers.ZeroAddress;
109
+ }
110
+ }
111
+ return [2 /*return*/];
47
112
  }
48
- }
49
- };
50
- export const NATIVE_TOKENS = {
113
+ });
114
+ }); };
115
+ export var NATIVE_TOKENS = {
51
116
  1: {
52
117
  symbol: 'ETH',
53
118
  wrappedSymbol: 'WETH',
@@ -115,7 +180,7 @@ export const NATIVE_TOKENS = {
115
180
  wrappedAddress: '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB'.toLowerCase(),
116
181
  },
117
182
  };
118
- export const NETWORK_CONSTANTS = {
183
+ export var NETWORK_CONSTANTS = {
119
184
  1: {
120
185
  NAME: 'ethereum',
121
186
  ALIASES: ALIASES_ETHEREUM,
@@ -227,73 +292,168 @@ export const NETWORK_CONSTANTS = {
227
292
  aTokens: aTokensAurora,
228
293
  },
229
294
  };
230
- class Curve {
231
- constructor() {
232
- this.fetchFactoryPools = async (useApi = true) => {
233
- if (this.chainId === 1313161554)
234
- return;
235
- if (useApi) {
236
- this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, false));
237
- }
238
- else {
239
- this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this));
240
- }
241
- this.constants.FACTORY_POOLS_DATA = await this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA);
242
- this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
243
- await _killGauges(this.constants.FACTORY_POOLS_DATA);
244
- };
245
- this.fetchCryptoFactoryPools = async (useApi = true) => {
246
- if (![1, 137, 250].includes(this.chainId))
247
- return;
248
- if (useApi) {
249
- this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, true));
250
- }
251
- else {
252
- this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this));
253
- }
254
- this.constants.CRYPTO_FACTORY_POOLS_DATA = await this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA);
255
- this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
256
- await _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
257
- };
258
- this.fetchNewFactoryPools = async () => {
259
- if (this.chainId === 1313161554)
260
- return [];
261
- const currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
262
- const lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
263
- const poolData = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this, lastPoolIdx + 1));
264
- this.constants.FACTORY_POOLS_DATA = { ...this.constants.FACTORY_POOLS_DATA, ...poolData };
265
- this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
266
- return Object.keys(poolData);
267
- };
268
- this.fetchNewCryptoFactoryPools = async () => {
269
- if (![1, 137, 250].includes(this.chainId))
270
- return [];
271
- const currentPoolIds = Object.keys(this.constants.CRYPTO_FACTORY_POOLS_DATA);
272
- const lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
273
- const poolData = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this, lastPoolIdx + 1));
274
- this.constants.CRYPTO_FACTORY_POOLS_DATA = { ...this.constants.CRYPTO_FACTORY_POOLS_DATA, ...poolData };
275
- this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
276
- return Object.keys(poolData);
277
- };
278
- this.fetchRecentlyDeployedFactoryPool = async (poolAddress) => {
279
- if (this.chainId === 1313161554)
280
- return '';
281
- const poolData = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this, 0, poolAddress));
282
- this.constants.FACTORY_POOLS_DATA = { ...this.constants.FACTORY_POOLS_DATA, ...poolData };
283
- this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
284
- return Object.keys(poolData)[0]; // id
295
+ var Curve = /** @class */ (function () {
296
+ function Curve() {
297
+ var _this = this;
298
+ this.fetchFactoryPools = function (useApi) {
299
+ if (useApi === void 0) { useApi = true; }
300
+ return __awaiter(_this, void 0, void 0, function () {
301
+ var _a, _b, poolData, _c, _d, _e, poolData, _f, _g;
302
+ return __generator(this, function (_h) {
303
+ switch (_h.label) {
304
+ case 0:
305
+ if (this.chainId === 1313161554)
306
+ return [2 /*return*/];
307
+ if (!useApi) return [3 /*break*/, 3];
308
+ _a = this.constants;
309
+ _b = lowerCasePoolDataAddresses;
310
+ return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, false)];
311
+ case 1:
312
+ _a.FACTORY_POOLS_DATA = _b.apply(void 0, [_h.sent()]);
313
+ _c = lowerCasePoolDataAddresses;
314
+ return [4 /*yield*/, getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.crvusd_factory)];
315
+ case 2:
316
+ poolData = _c.apply(void 0, [_h.sent()]);
317
+ this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
318
+ return [3 /*break*/, 6];
319
+ case 3:
320
+ _d = this.constants;
321
+ _e = lowerCasePoolDataAddresses;
322
+ return [4 /*yield*/, getFactoryPoolData.call(this)];
323
+ case 4:
324
+ _d.FACTORY_POOLS_DATA = _e.apply(void 0, [_h.sent()]);
325
+ _f = lowerCasePoolDataAddresses;
326
+ return [4 /*yield*/, getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.crvusd_factory)];
327
+ case 5:
328
+ poolData = _f.apply(void 0, [_h.sent()]);
329
+ this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
330
+ _h.label = 6;
331
+ case 6:
332
+ _g = this.constants;
333
+ return [4 /*yield*/, this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA)];
334
+ case 7:
335
+ _g.FACTORY_POOLS_DATA = _h.sent();
336
+ this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
337
+ return [4 /*yield*/, _killGauges(this.constants.FACTORY_POOLS_DATA)];
338
+ case 8:
339
+ _h.sent();
340
+ return [2 /*return*/];
341
+ }
342
+ });
343
+ });
285
344
  };
286
- this.fetchRecentlyDeployedCryptoFactoryPool = async (poolAddress) => {
287
- if (![1, 137, 250].includes(this.chainId))
288
- return '';
289
- const poolData = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this, 0, poolAddress));
290
- this.constants.CRYPTO_FACTORY_POOLS_DATA = { ...this.constants.CRYPTO_FACTORY_POOLS_DATA, ...poolData };
291
- this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
292
- return Object.keys(poolData)[0]; // id
345
+ this.fetchCryptoFactoryPools = function (useApi) {
346
+ if (useApi === void 0) { useApi = true; }
347
+ return __awaiter(_this, void 0, void 0, function () {
348
+ var _a, _b, _c, _d, _e;
349
+ return __generator(this, function (_f) {
350
+ switch (_f.label) {
351
+ case 0:
352
+ if (![1, 137, 250].includes(this.chainId))
353
+ return [2 /*return*/];
354
+ if (!useApi) return [3 /*break*/, 2];
355
+ _a = this.constants;
356
+ _b = lowerCasePoolDataAddresses;
357
+ return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, true)];
358
+ case 1:
359
+ _a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
360
+ return [3 /*break*/, 4];
361
+ case 2:
362
+ _c = this.constants;
363
+ _d = lowerCasePoolDataAddresses;
364
+ return [4 /*yield*/, getCryptoFactoryPoolData.call(this)];
365
+ case 3:
366
+ _c.CRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
367
+ _f.label = 4;
368
+ case 4:
369
+ _e = this.constants;
370
+ return [4 /*yield*/, this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
371
+ case 5:
372
+ _e.CRYPTO_FACTORY_POOLS_DATA = _f.sent();
373
+ this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
374
+ return [4 /*yield*/, _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
375
+ case 6:
376
+ _f.sent();
377
+ return [2 /*return*/];
378
+ }
379
+ });
380
+ });
293
381
  };
294
- this.getPoolList = () => Object.keys(this.constants.POOLS_DATA);
295
- this.getFactoryPoolList = () => Object.keys(this.constants.FACTORY_POOLS_DATA);
296
- this.getCryptoFactoryPoolList = () => Object.keys(this.constants.CRYPTO_FACTORY_POOLS_DATA);
382
+ this.fetchNewFactoryPools = function () { return __awaiter(_this, void 0, void 0, function () {
383
+ var currentPoolIds, lastPoolIdx, poolData, _a;
384
+ return __generator(this, function (_b) {
385
+ switch (_b.label) {
386
+ case 0:
387
+ if (this.chainId === 1313161554)
388
+ return [2 /*return*/, []];
389
+ currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
390
+ lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
391
+ _a = lowerCasePoolDataAddresses;
392
+ return [4 /*yield*/, getFactoryPoolData.call(this, lastPoolIdx + 1)];
393
+ case 1:
394
+ poolData = _a.apply(void 0, [_b.sent()]);
395
+ this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
396
+ this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
397
+ return [2 /*return*/, Object.keys(poolData)];
398
+ }
399
+ });
400
+ }); };
401
+ this.fetchNewCryptoFactoryPools = function () { return __awaiter(_this, void 0, void 0, function () {
402
+ var currentPoolIds, lastPoolIdx, poolData, _a;
403
+ return __generator(this, function (_b) {
404
+ switch (_b.label) {
405
+ case 0:
406
+ if (![1, 137, 250].includes(this.chainId))
407
+ return [2 /*return*/, []];
408
+ currentPoolIds = Object.keys(this.constants.CRYPTO_FACTORY_POOLS_DATA);
409
+ lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
410
+ _a = lowerCasePoolDataAddresses;
411
+ return [4 /*yield*/, getCryptoFactoryPoolData.call(this, lastPoolIdx + 1)];
412
+ case 1:
413
+ poolData = _a.apply(void 0, [_b.sent()]);
414
+ this.constants.CRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
415
+ this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
416
+ return [2 /*return*/, Object.keys(poolData)];
417
+ }
418
+ });
419
+ }); };
420
+ this.fetchRecentlyDeployedFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
421
+ var poolData, _a;
422
+ return __generator(this, function (_b) {
423
+ switch (_b.label) {
424
+ case 0:
425
+ if (this.chainId === 1313161554)
426
+ return [2 /*return*/, ''];
427
+ _a = lowerCasePoolDataAddresses;
428
+ return [4 /*yield*/, getFactoryPoolData.call(this, 0, poolAddress)];
429
+ case 1:
430
+ poolData = _a.apply(void 0, [_b.sent()]);
431
+ this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
432
+ this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
433
+ return [2 /*return*/, Object.keys(poolData)[0]]; // id
434
+ }
435
+ });
436
+ }); };
437
+ this.fetchRecentlyDeployedCryptoFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
438
+ var poolData, _a;
439
+ return __generator(this, function (_b) {
440
+ switch (_b.label) {
441
+ case 0:
442
+ if (![1, 137, 250].includes(this.chainId))
443
+ return [2 /*return*/, ''];
444
+ _a = lowerCasePoolDataAddresses;
445
+ return [4 /*yield*/, getCryptoFactoryPoolData.call(this, 0, poolAddress)];
446
+ case 1:
447
+ poolData = _a.apply(void 0, [_b.sent()]);
448
+ this.constants.CRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
449
+ this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
450
+ return [2 /*return*/, Object.keys(poolData)[0]]; // id
451
+ }
452
+ });
453
+ }); };
454
+ this.getPoolList = function () { return Object.keys(_this.constants.POOLS_DATA); };
455
+ this.getFactoryPoolList = function () { return Object.keys(_this.constants.FACTORY_POOLS_DATA); };
456
+ this.getCryptoFactoryPoolList = function () { return Object.keys(_this.constants.CRYPTO_FACTORY_POOLS_DATA); };
297
457
  // @ts-ignore
298
458
  this.provider = null;
299
459
  // @ts-ignore
@@ -319,215 +479,279 @@ class Curve {
319
479
  ZERO_ADDRESS: ethers.ZeroAddress,
320
480
  };
321
481
  }
322
- async init(providerType, providerSettings, options = {} // gasPrice in Gwei
482
+ Curve.prototype.init = function (providerType, providerSettings, options // gasPrice in Gwei
323
483
  ) {
324
- // @ts-ignore
325
- this.provider = null;
326
- // @ts-ignore
327
- this.signer = null;
328
- this.signerAddress = '';
329
- this.chainId = 1;
330
- // @ts-ignore
331
- this.multicallProvider = null;
332
- this.contracts = {};
333
- this.feeData = {};
334
- this.constantOptions = { gasLimit: 12000000 };
335
- this.options = {};
336
- this.constants = {
337
- NATIVE_TOKEN: NATIVE_TOKENS[1],
338
- NETWORK_NAME: 'ethereum',
339
- ALIASES: {},
340
- POOLS_DATA: {},
341
- FACTORY_POOLS_DATA: {},
342
- CRYPTO_FACTORY_POOLS_DATA: {},
343
- COINS: {},
344
- DECIMALS: {},
345
- GAUGES: [],
346
- ZERO_ADDRESS: ethers.ZeroAddress,
347
- };
348
- // JsonRpc provider
349
- if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
350
- providerSettings = providerSettings;
351
- if (providerSettings.url) {
352
- this.provider = new ethers.JsonRpcProvider(providerSettings.url);
353
- }
354
- else {
355
- this.provider = new ethers.JsonRpcProvider('http://localhost:8545/');
356
- }
357
- if (providerSettings.privateKey) {
358
- this.signer = new ethers.Wallet(providerSettings.privateKey, this.provider);
359
- }
360
- else if (!providerSettings.url?.startsWith("https://rpc.gnosischain.com")) {
361
- try {
362
- this.signer = await this.provider.getSigner();
363
- }
364
- catch (e) {
365
- this.signer = null;
366
- }
367
- }
368
- // Web3 provider
369
- }
370
- else if (providerType.toLowerCase() === 'Web3'.toLowerCase()) {
371
- providerSettings = providerSettings;
372
- this.provider = new ethers.BrowserProvider(providerSettings.externalProvider);
373
- this.signer = await this.provider.getSigner();
374
- // Infura provider
375
- }
376
- else if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
377
- providerSettings = providerSettings;
378
- this.provider = new ethers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
379
- this.signer = null;
380
- // Alchemy provider
381
- }
382
- else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
383
- providerSettings = providerSettings;
384
- this.provider = new ethers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
385
- this.signer = null;
386
- }
387
- else {
388
- throw Error('Wrong providerType');
389
- }
390
- const network = await this.provider.getNetwork();
391
- console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
392
- this.chainId = Number(network.chainId) === 1337 ? 1 : Number(network.chainId);
393
- this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
394
- this.constants.NETWORK_NAME = NETWORK_CONSTANTS[this.chainId].NAME;
395
- this.constants.ALIASES = NETWORK_CONSTANTS[this.chainId].ALIASES;
396
- this.constants.POOLS_DATA = NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
397
- for (const poolId in this.constants.POOLS_DATA)
398
- this.constants.POOLS_DATA[poolId].in_api = true;
399
- this.constants.COINS = NETWORK_CONSTANTS[this.chainId].COINS;
400
- this.constants.DECIMALS = extractDecimals(this.constants.POOLS_DATA);
401
- this.constants.DECIMALS[this.constants.NATIVE_TOKEN.address] = 18;
402
- this.constants.DECIMALS[this.constants.NATIVE_TOKEN.wrappedAddress] = 18;
403
- this.constants.GAUGES = extractGauges(this.constants.POOLS_DATA);
404
- const [cTokens, yTokens, ycTokens, aTokens] = [
405
- NETWORK_CONSTANTS[this.chainId].cTokens,
406
- NETWORK_CONSTANTS[this.chainId].yTokens,
407
- NETWORK_CONSTANTS[this.chainId].ycTokens,
408
- NETWORK_CONSTANTS[this.chainId].aTokens,
409
- ];
410
- const customAbiTokens = [...cTokens, ...yTokens, ...ycTokens, ...aTokens];
411
- await _killGauges(this.constants.POOLS_DATA);
412
- this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
413
- if (this.signer) {
414
- try {
415
- this.signerAddress = await this.signer.getAddress();
416
- }
417
- catch (err) {
418
- this.signer = null;
419
- }
420
- }
421
- else {
422
- this.signerAddress = '';
423
- }
424
- this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
425
- await this.updateFeeData();
426
- for (const pool of Object.values(this.constants.POOLS_DATA)) {
427
- this.setContract(pool.swap_address, pool.swap_abi);
428
- if (pool.token_address !== pool.swap_address) {
429
- this.setContract(pool.token_address, ERC20Abi);
430
- }
431
- if (pool.gauge_address !== this.constants.ZERO_ADDRESS) {
432
- this.setContract(pool.gauge_address, pool.gauge_abi);
433
- }
434
- if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
435
- this.setContract(pool.deposit_address, pool.deposit_abi);
436
- }
437
- for (const coinAddr of pool.underlying_coin_addresses) {
438
- this.setContract(coinAddr, ERC20Abi);
439
- }
440
- for (const coinAddr of pool.wrapped_coin_addresses) {
441
- if (customAbiTokens.includes(coinAddr))
442
- continue;
443
- if (coinAddr in this.contracts)
444
- continue;
445
- this.setContract(coinAddr, ERC20Abi);
446
- }
447
- // TODO add all coins
448
- for (const coinAddr of pool.wrapped_coin_addresses) {
449
- if (cTokens.includes(coinAddr)) {
450
- this.setContract(coinAddr, cERC20Abi);
451
- }
452
- if (aTokens.includes(coinAddr)) {
453
- this.setContract(coinAddr, ERC20Abi);
484
+ var _a;
485
+ if (options === void 0) { options = {}; }
486
+ return __awaiter(this, void 0, void 0, function () {
487
+ var _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _i, _f, pool, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, coinAddr, _minterABI, addressProviderContract, _o;
488
+ return __generator(this, function (_p) {
489
+ switch (_p.label) {
490
+ case 0:
491
+ // @ts-ignore
492
+ this.provider = null;
493
+ // @ts-ignore
494
+ this.signer = null;
495
+ this.signerAddress = '';
496
+ this.chainId = 1;
497
+ // @ts-ignore
498
+ this.multicallProvider = null;
499
+ this.contracts = {};
500
+ this.feeData = {};
501
+ this.constantOptions = { gasLimit: 12000000 };
502
+ this.options = {};
503
+ this.constants = {
504
+ NATIVE_TOKEN: NATIVE_TOKENS[1],
505
+ NETWORK_NAME: 'ethereum',
506
+ ALIASES: {},
507
+ POOLS_DATA: {},
508
+ FACTORY_POOLS_DATA: {},
509
+ CRYPTO_FACTORY_POOLS_DATA: {},
510
+ COINS: {},
511
+ DECIMALS: {},
512
+ GAUGES: [],
513
+ ZERO_ADDRESS: ethers.ZeroAddress,
514
+ };
515
+ if (!(providerType.toLowerCase() === 'JsonRpc'.toLowerCase())) return [3 /*break*/, 6];
516
+ providerSettings = providerSettings;
517
+ if (providerSettings.url) {
518
+ this.provider = new ethers.JsonRpcProvider(providerSettings.url);
519
+ }
520
+ else {
521
+ this.provider = new ethers.JsonRpcProvider('http://localhost:8545/');
522
+ }
523
+ if (!providerSettings.privateKey) return [3 /*break*/, 1];
524
+ this.signer = new ethers.Wallet(providerSettings.privateKey, this.provider);
525
+ return [3 /*break*/, 5];
526
+ case 1:
527
+ if (!!((_a = providerSettings.url) === null || _a === void 0 ? void 0 : _a.startsWith("https://rpc.gnosischain.com"))) return [3 /*break*/, 5];
528
+ _p.label = 2;
529
+ case 2:
530
+ _p.trys.push([2, 4, , 5]);
531
+ _b = this;
532
+ return [4 /*yield*/, this.provider.getSigner()];
533
+ case 3:
534
+ _b.signer = _p.sent();
535
+ return [3 /*break*/, 5];
536
+ case 4:
537
+ e_1 = _p.sent();
538
+ this.signer = null;
539
+ return [3 /*break*/, 5];
540
+ case 5: return [3 /*break*/, 9];
541
+ case 6:
542
+ if (!(providerType.toLowerCase() === 'Web3'.toLowerCase())) return [3 /*break*/, 8];
543
+ providerSettings = providerSettings;
544
+ this.provider = new ethers.BrowserProvider(providerSettings.externalProvider);
545
+ _c = this;
546
+ return [4 /*yield*/, this.provider.getSigner()];
547
+ case 7:
548
+ _c.signer = _p.sent();
549
+ return [3 /*break*/, 9];
550
+ case 8:
551
+ if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
552
+ providerSettings = providerSettings;
553
+ this.provider = new ethers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
554
+ this.signer = null;
555
+ // Alchemy provider
556
+ }
557
+ else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
558
+ providerSettings = providerSettings;
559
+ this.provider = new ethers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
560
+ this.signer = null;
561
+ }
562
+ else {
563
+ throw Error('Wrong providerType');
564
+ }
565
+ _p.label = 9;
566
+ case 9: return [4 /*yield*/, this.provider.getNetwork()];
567
+ case 10:
568
+ network = _p.sent();
569
+ console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
570
+ this.chainId = Number(network.chainId) === 1337 ? 1 : Number(network.chainId);
571
+ this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
572
+ this.constants.NETWORK_NAME = NETWORK_CONSTANTS[this.chainId].NAME;
573
+ this.constants.ALIASES = NETWORK_CONSTANTS[this.chainId].ALIASES;
574
+ this.constants.POOLS_DATA = NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
575
+ for (poolId in this.constants.POOLS_DATA)
576
+ this.constants.POOLS_DATA[poolId].in_api = true;
577
+ this.constants.COINS = NETWORK_CONSTANTS[this.chainId].COINS;
578
+ this.constants.DECIMALS = extractDecimals(this.constants.POOLS_DATA);
579
+ this.constants.DECIMALS[this.constants.NATIVE_TOKEN.address] = 18;
580
+ this.constants.DECIMALS[this.constants.NATIVE_TOKEN.wrappedAddress] = 18;
581
+ this.constants.GAUGES = extractGauges(this.constants.POOLS_DATA);
582
+ _d = [
583
+ NETWORK_CONSTANTS[this.chainId].cTokens,
584
+ NETWORK_CONSTANTS[this.chainId].yTokens,
585
+ NETWORK_CONSTANTS[this.chainId].ycTokens,
586
+ NETWORK_CONSTANTS[this.chainId].aTokens,
587
+ ], cTokens = _d[0], yTokens = _d[1], ycTokens = _d[2], aTokens = _d[3];
588
+ customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
589
+ return [4 /*yield*/, _killGauges(this.constants.POOLS_DATA)];
590
+ case 11:
591
+ _p.sent();
592
+ this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
593
+ if (!this.signer) return [3 /*break*/, 16];
594
+ _p.label = 12;
595
+ case 12:
596
+ _p.trys.push([12, 14, , 15]);
597
+ _e = this;
598
+ return [4 /*yield*/, this.signer.getAddress()];
599
+ case 13:
600
+ _e.signerAddress = _p.sent();
601
+ return [3 /*break*/, 15];
602
+ case 14:
603
+ err_1 = _p.sent();
604
+ this.signer = null;
605
+ return [3 /*break*/, 15];
606
+ case 15: return [3 /*break*/, 17];
607
+ case 16:
608
+ this.signerAddress = '';
609
+ _p.label = 17;
610
+ case 17:
611
+ this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
612
+ return [4 /*yield*/, this.updateFeeData()];
613
+ case 18:
614
+ _p.sent();
615
+ for (_i = 0, _f = Object.values(this.constants.POOLS_DATA); _i < _f.length; _i++) {
616
+ pool = _f[_i];
617
+ this.setContract(pool.swap_address, pool.swap_abi);
618
+ if (pool.token_address !== pool.swap_address) {
619
+ this.setContract(pool.token_address, ERC20Abi);
620
+ }
621
+ if (pool.gauge_address !== this.constants.ZERO_ADDRESS) {
622
+ this.setContract(pool.gauge_address, pool.gauge_abi);
623
+ }
624
+ if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
625
+ this.setContract(pool.deposit_address, pool.deposit_abi);
626
+ }
627
+ for (_g = 0, _h = pool.underlying_coin_addresses; _g < _h.length; _g++) {
628
+ coinAddr = _h[_g];
629
+ this.setContract(coinAddr, ERC20Abi);
630
+ }
631
+ for (_j = 0, _k = pool.wrapped_coin_addresses; _j < _k.length; _j++) {
632
+ coinAddr = _k[_j];
633
+ if (customAbiTokens.includes(coinAddr))
634
+ continue;
635
+ if (coinAddr in this.contracts)
636
+ continue;
637
+ this.setContract(coinAddr, ERC20Abi);
638
+ }
639
+ // TODO add all coins
640
+ for (_l = 0, _m = pool.wrapped_coin_addresses; _l < _m.length; _l++) {
641
+ coinAddr = _m[_l];
642
+ if (cTokens.includes(coinAddr)) {
643
+ this.setContract(coinAddr, cERC20Abi);
644
+ }
645
+ if (aTokens.includes(coinAddr)) {
646
+ this.setContract(coinAddr, ERC20Abi);
647
+ }
648
+ if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
649
+ this.setContract(coinAddr, yERC20Abi);
650
+ }
651
+ }
652
+ if (pool.reward_contract) {
653
+ this.setContract(pool.reward_contract, streamerABI);
654
+ }
655
+ if (pool.sCurveRewards_address) {
656
+ this.setContract(pool.sCurveRewards_address, pool.sCurveRewards_abi);
657
+ }
658
+ }
659
+ this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20Abi);
660
+ this.setContract(this.constants.ALIASES.crv, ERC20Abi);
661
+ this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
662
+ _minterABI = this.chainId === 1 ? minterABI : minterChildABI;
663
+ this.setContract(this.constants.ALIASES.minter, _minterABI);
664
+ this.setContract(this.constants.ALIASES.voting_escrow, votingEscrowABI);
665
+ this.setContract(this.constants.ALIASES.fee_distributor, feeDistributorABI);
666
+ this.setContract(this.constants.ALIASES.address_provider, addressProviderABI);
667
+ addressProviderContract = this.contracts[this.constants.ALIASES.address_provider].contract;
668
+ _o = this.constants.ALIASES;
669
+ return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
670
+ case 19:
671
+ _o.registry_exchange = (_p.sent()).toLowerCase();
672
+ this.setContract(this.constants.ALIASES.registry_exchange, registryExchangeABI);
673
+ this.setContract(this.constants.ALIASES.gauge_controller, gaugeControllerABI);
674
+ this.setContract(this.constants.ALIASES.router, routerABI);
675
+ if (this.chainId === 137) {
676
+ this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStake6CoinsABI);
677
+ }
678
+ else {
679
+ this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeABI);
680
+ }
681
+ this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
682
+ this.setContract(this.constants.ALIASES.factory, factoryABI);
683
+ this.setContract(this.constants.ALIASES.crvusd_factory, factoryABI);
684
+ this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
685
+ return [2 /*return*/];
454
686
  }
455
- if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
456
- this.setContract(coinAddr, yERC20Abi);
457
- }
458
- }
459
- if (pool.reward_contract) {
460
- this.setContract(pool.reward_contract, streamerABI);
461
- }
462
- if (pool.sCurveRewards_address) {
463
- this.setContract(pool.sCurveRewards_address, pool.sCurveRewards_abi);
464
- }
465
- }
466
- this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20Abi);
467
- this.setContract(this.constants.ALIASES.crv, ERC20Abi);
468
- this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
469
- const _minterABI = this.chainId === 1 ? minterABI : minterChildABI;
470
- this.setContract(this.constants.ALIASES.minter, _minterABI);
471
- this.setContract(this.constants.ALIASES.voting_escrow, votingEscrowABI);
472
- this.setContract(this.constants.ALIASES.fee_distributor, feeDistributorABI);
473
- this.setContract(this.constants.ALIASES.address_provider, addressProviderABI);
474
- const addressProviderContract = this.contracts[this.constants.ALIASES.address_provider].contract;
475
- this.constants.ALIASES.registry_exchange = (await addressProviderContract.get_address(2, this.constantOptions)).toLowerCase();
476
- this.setContract(this.constants.ALIASES.registry_exchange, registryExchangeABI);
477
- this.setContract(this.constants.ALIASES.gauge_controller, gaugeControllerABI);
478
- this.setContract(this.constants.ALIASES.router, routerABI);
479
- if (this.chainId === 137) {
480
- this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStake6CoinsABI);
481
- }
482
- else {
483
- this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeABI);
484
- }
485
- this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
486
- this.setContract(this.constants.ALIASES.factory, factoryABI);
487
- this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
488
- }
489
- setContract(address, abi) {
687
+ });
688
+ });
689
+ };
690
+ Curve.prototype.setContract = function (address, abi) {
490
691
  this.contracts[address] = {
491
692
  contract: new Contract(address, abi, this.signer || this.provider),
492
693
  multicallContract: new MulticallContract(address, abi),
493
694
  };
494
- }
495
- async _filterHiddenPools(pools) {
496
- const hiddenPools = (await _getHiddenPools())[this.constants.NETWORK_NAME] || [];
497
- // @ts-ignore
498
- return Object.fromEntries(Object.entries(pools).filter(([id]) => !hiddenPools.includes(id)));
499
- }
500
- _updateDecimalsAndGauges(pools) {
501
- this.constants.DECIMALS = { ...this.constants.DECIMALS, ...extractDecimals(pools) };
502
- this.constants.GAUGES = [...this.constants.GAUGES, ...extractGauges(pools)];
503
- }
504
- setCustomFeeData(customFeeData) {
505
- this.feeData = { ...this.feeData, ...customFeeData };
506
- }
507
- formatUnits(value, unit) {
695
+ };
696
+ Curve.prototype._filterHiddenPools = function (pools) {
697
+ return __awaiter(this, void 0, void 0, function () {
698
+ var hiddenPools;
699
+ return __generator(this, function (_a) {
700
+ switch (_a.label) {
701
+ case 0: return [4 /*yield*/, _getHiddenPools()];
702
+ case 1:
703
+ hiddenPools = (_a.sent())[this.constants.NETWORK_NAME] || [];
704
+ // @ts-ignore
705
+ return [2 /*return*/, Object.fromEntries(Object.entries(pools).filter(function (_a) {
706
+ var id = _a[0];
707
+ return !hiddenPools.includes(id);
708
+ }))];
709
+ }
710
+ });
711
+ });
712
+ };
713
+ Curve.prototype._updateDecimalsAndGauges = function (pools) {
714
+ this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), extractDecimals(pools));
715
+ this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), extractGauges(pools), true);
716
+ };
717
+ Curve.prototype.setCustomFeeData = function (customFeeData) {
718
+ this.feeData = __assign(__assign({}, this.feeData), customFeeData);
719
+ };
720
+ Curve.prototype.formatUnits = function (value, unit) {
508
721
  return ethers.formatUnits(value, unit);
509
- }
510
- parseUnits(value, unit) {
722
+ };
723
+ Curve.prototype.parseUnits = function (value, unit) {
511
724
  return ethers.parseUnits(value, unit);
512
- }
513
- async updateFeeData() {
514
- const feeData = await this.provider.getFeeData();
515
- if (feeData.maxFeePerGas === null || feeData.maxPriorityFeePerGas === null) {
516
- delete this.options.maxFeePerGas;
517
- delete this.options.maxPriorityFeePerGas;
518
- this.options.gasPrice = this.feeData.gasPrice !== undefined ?
519
- this.parseUnits(this.feeData.gasPrice.toString(), "gwei") :
520
- (feeData.gasPrice || this.parseUnits("20", "gwei"));
521
- }
522
- else {
523
- delete this.options.gasPrice;
524
- this.options.maxFeePerGas = this.feeData.maxFeePerGas !== undefined ?
525
- this.parseUnits(this.feeData.maxFeePerGas.toString(), "gwei") :
526
- feeData.maxFeePerGas;
527
- this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
528
- this.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
529
- feeData.maxPriorityFeePerGas;
530
- }
531
- }
532
- }
533
- export const curve = new Curve();
725
+ };
726
+ Curve.prototype.updateFeeData = function () {
727
+ return __awaiter(this, void 0, void 0, function () {
728
+ var feeData;
729
+ return __generator(this, function (_a) {
730
+ switch (_a.label) {
731
+ case 0: return [4 /*yield*/, this.provider.getFeeData()];
732
+ case 1:
733
+ feeData = _a.sent();
734
+ if (feeData.maxFeePerGas === null || feeData.maxPriorityFeePerGas === null) {
735
+ delete this.options.maxFeePerGas;
736
+ delete this.options.maxPriorityFeePerGas;
737
+ this.options.gasPrice = this.feeData.gasPrice !== undefined ?
738
+ this.parseUnits(this.feeData.gasPrice.toString(), "gwei") :
739
+ (feeData.gasPrice || this.parseUnits("20", "gwei"));
740
+ }
741
+ else {
742
+ delete this.options.gasPrice;
743
+ this.options.maxFeePerGas = this.feeData.maxFeePerGas !== undefined ?
744
+ this.parseUnits(this.feeData.maxFeePerGas.toString(), "gwei") :
745
+ feeData.maxFeePerGas;
746
+ this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
747
+ this.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
748
+ feeData.maxPriorityFeePerGas;
749
+ }
750
+ return [2 /*return*/];
751
+ }
752
+ });
753
+ });
754
+ };
755
+ return Curve;
756
+ }());
757
+ export var curve = new Curve();