@curvefi/api 2.31.1 → 2.33.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.
Files changed (62) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/abis/stable_calc.json +151 -0
  3. package/lib/constants/abis/wbeth/swap.json +1086 -0
  4. package/lib/constants/aliases.js +33 -11
  5. package/lib/constants/coins/arbitrum.js +5 -5
  6. package/lib/constants/coins/aurora.js +5 -5
  7. package/lib/constants/coins/avalanche.js +6 -6
  8. package/lib/constants/coins/celo.js +5 -5
  9. package/lib/constants/coins/ethereum.js +10 -9
  10. package/lib/constants/coins/fantom.js +7 -7
  11. package/lib/constants/coins/kava.js +5 -5
  12. package/lib/constants/coins/moonbeam.js +5 -5
  13. package/lib/constants/coins/optimism.js +5 -5
  14. package/lib/constants/coins/polygon.js +6 -6
  15. package/lib/constants/coins/xdai.js +5 -5
  16. package/lib/constants/pools/arbitrum.js +1 -1
  17. package/lib/constants/pools/aurora.js +1 -1
  18. package/lib/constants/pools/avalanche.js +1 -1
  19. package/lib/constants/pools/celo.js +1 -1
  20. package/lib/constants/pools/ethereum.js +26 -1
  21. package/lib/constants/pools/fantom.js +1 -1
  22. package/lib/constants/pools/kava.js +1 -1
  23. package/lib/constants/pools/moonbeam.js +1 -1
  24. package/lib/constants/pools/optimism.js +1 -1
  25. package/lib/constants/pools/polygon.js +1 -1
  26. package/lib/constants/pools/xdai.js +1 -1
  27. package/lib/constants/utils.d.ts +1 -1
  28. package/lib/constants/utils.js +19 -18
  29. package/lib/curve.js +507 -281
  30. package/lib/external-api.js +132 -45
  31. package/lib/factory/common.js +3 -3
  32. package/lib/factory/constants-crypto.js +21 -21
  33. package/lib/factory/constants.js +32 -31
  34. package/lib/factory/deploy.js +336 -176
  35. package/lib/factory/factory-api.js +256 -180
  36. package/lib/factory/factory-crypto.js +309 -163
  37. package/lib/factory/factory.d.ts +1 -1
  38. package/lib/factory/factory.js +336 -186
  39. package/lib/index.js +98 -44
  40. package/lib/interfaces.d.ts +1 -1
  41. package/lib/pools/PoolTemplate.js +2882 -1511
  42. package/lib/pools/mixins/common.js +106 -22
  43. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  44. package/lib/pools/mixins/depositMixins.js +413 -144
  45. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  46. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  47. package/lib/pools/mixins/swapMixins.js +347 -125
  48. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  49. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  50. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  51. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  52. package/lib/pools/mixins/withdrawMixins.js +385 -122
  53. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  54. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  55. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  56. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  57. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  58. package/lib/pools/poolConstructor.js +25 -5
  59. package/lib/pools/utils.js +488 -298
  60. package/lib/router.js +636 -378
  61. package/lib/utils.js +675 -354
  62. package/package.json +1 -1
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";
@@ -15,6 +71,7 @@ import gaugeControllerABI from './constants/abis/gaugecontroller.json' assert {
15
71
  import routerABI from './constants/abis/router.json' assert { type: 'json' };
16
72
  import depositAndStakeABI from './constants/abis/deposit_and_stake.json' assert { type: 'json' };
17
73
  import depositAndStake6CoinsABI from './constants/abis/deposit_and_stake_6coins.json' assert { type: 'json' };
74
+ import StableCalcZapABI from './constants/abis/stable_calc.json' assert { type: 'json' };
18
75
  import registryExchangeABI from './constants/abis/registry_exchange.json' assert { type: 'json' };
19
76
  import streamerABI from './constants/abis/streamer.json' assert { type: 'json' };
20
77
  import factoryABI from './constants/abis/factory.json' assert { type: 'json' };
@@ -34,19 +91,28 @@ import { COINS_KAVA, cTokensKava, yTokensKava, ycTokensKava, aTokensKava } from
34
91
  import { COINS_CELO, cTokensCelo, yTokensCelo, ycTokensCelo, aTokensCelo } from "./constants/coins/celo.js";
35
92
  import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./constants/utils.js";
36
93
  import { _getAllGauges, _getHiddenPools } from "./external-api.js";
37
- const _killGauges = async (poolsData) => {
38
- const gaugeData = await _getAllGauges();
39
- const isKilled = {};
40
- Object.values(gaugeData).forEach((d) => {
41
- isKilled[d.gauge.toLowerCase()] = d.is_killed ?? false;
42
- });
43
- for (const poolId in poolsData) {
44
- if (isKilled[poolsData[poolId].gauge_address]) {
45
- 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*/];
46
112
  }
47
- }
48
- };
49
- export const NATIVE_TOKENS = {
113
+ });
114
+ }); };
115
+ export var NATIVE_TOKENS = {
50
116
  1: {
51
117
  symbol: 'ETH',
52
118
  wrappedSymbol: 'WETH',
@@ -114,7 +180,7 @@ export const NATIVE_TOKENS = {
114
180
  wrappedAddress: '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB'.toLowerCase(),
115
181
  },
116
182
  };
117
- export const NETWORK_CONSTANTS = {
183
+ export var NETWORK_CONSTANTS = {
118
184
  1: {
119
185
  NAME: 'ethereum',
120
186
  ALIASES: ALIASES_ETHEREUM,
@@ -226,73 +292,168 @@ export const NETWORK_CONSTANTS = {
226
292
  aTokens: aTokensAurora,
227
293
  },
228
294
  };
229
- class Curve {
230
- constructor() {
231
- this.fetchFactoryPools = async (useApi = true) => {
232
- if (this.chainId === 1313161554)
233
- return;
234
- if (useApi) {
235
- this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, false));
236
- }
237
- else {
238
- this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this));
239
- }
240
- this.constants.FACTORY_POOLS_DATA = await this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA);
241
- this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
242
- await _killGauges(this.constants.FACTORY_POOLS_DATA);
243
- };
244
- this.fetchCryptoFactoryPools = async (useApi = true) => {
245
- if (![1, 137, 250].includes(this.chainId))
246
- return;
247
- if (useApi) {
248
- this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, true));
249
- }
250
- else {
251
- this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this));
252
- }
253
- this.constants.CRYPTO_FACTORY_POOLS_DATA = await this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA);
254
- this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
255
- await _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
256
- };
257
- this.fetchNewFactoryPools = async () => {
258
- if (this.chainId === 1313161554)
259
- return [];
260
- const currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
261
- const lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
262
- const poolData = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this, lastPoolIdx + 1));
263
- this.constants.FACTORY_POOLS_DATA = { ...this.constants.FACTORY_POOLS_DATA, ...poolData };
264
- this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
265
- return Object.keys(poolData);
266
- };
267
- this.fetchNewCryptoFactoryPools = async () => {
268
- if (![1, 137, 250].includes(this.chainId))
269
- return [];
270
- const currentPoolIds = Object.keys(this.constants.CRYPTO_FACTORY_POOLS_DATA);
271
- const lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
272
- const poolData = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this, lastPoolIdx + 1));
273
- this.constants.CRYPTO_FACTORY_POOLS_DATA = { ...this.constants.CRYPTO_FACTORY_POOLS_DATA, ...poolData };
274
- this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
275
- return Object.keys(poolData);
276
- };
277
- this.fetchRecentlyDeployedFactoryPool = async (poolAddress) => {
278
- if (this.chainId === 1313161554)
279
- return '';
280
- const poolData = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this, 0, poolAddress));
281
- this.constants.FACTORY_POOLS_DATA = { ...this.constants.FACTORY_POOLS_DATA, ...poolData };
282
- this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
283
- 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
+ });
284
344
  };
285
- this.fetchRecentlyDeployedCryptoFactoryPool = async (poolAddress) => {
286
- if (![1, 137, 250].includes(this.chainId))
287
- return '';
288
- const poolData = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this, 0, poolAddress));
289
- this.constants.CRYPTO_FACTORY_POOLS_DATA = { ...this.constants.CRYPTO_FACTORY_POOLS_DATA, ...poolData };
290
- this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
291
- 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
+ });
292
381
  };
293
- this.getPoolList = () => Object.keys(this.constants.POOLS_DATA);
294
- this.getFactoryPoolList = () => Object.keys(this.constants.FACTORY_POOLS_DATA);
295
- 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); };
296
457
  // @ts-ignore
297
458
  this.provider = null;
298
459
  // @ts-ignore
@@ -318,214 +479,279 @@ class Curve {
318
479
  ZERO_ADDRESS: ethers.ZeroAddress,
319
480
  };
320
481
  }
321
- async init(providerType, providerSettings, options = {} // gasPrice in Gwei
482
+ Curve.prototype.init = function (providerType, providerSettings, options // gasPrice in Gwei
322
483
  ) {
323
- // @ts-ignore
324
- this.provider = null;
325
- // @ts-ignore
326
- this.signer = null;
327
- this.signerAddress = '';
328
- this.chainId = 1;
329
- // @ts-ignore
330
- this.multicallProvider = null;
331
- this.contracts = {};
332
- this.feeData = {};
333
- this.constantOptions = { gasLimit: 12000000 };
334
- this.options = {};
335
- this.constants = {
336
- NATIVE_TOKEN: NATIVE_TOKENS[1],
337
- NETWORK_NAME: 'ethereum',
338
- ALIASES: {},
339
- POOLS_DATA: {},
340
- FACTORY_POOLS_DATA: {},
341
- CRYPTO_FACTORY_POOLS_DATA: {},
342
- COINS: {},
343
- DECIMALS: {},
344
- GAUGES: [],
345
- ZERO_ADDRESS: ethers.ZeroAddress,
346
- };
347
- // JsonRpc provider
348
- if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
349
- providerSettings = providerSettings;
350
- if (providerSettings.url) {
351
- this.provider = new ethers.JsonRpcProvider(providerSettings.url);
352
- }
353
- else {
354
- this.provider = new ethers.JsonRpcProvider('http://localhost:8545/');
355
- }
356
- if (providerSettings.privateKey) {
357
- this.signer = new ethers.Wallet(providerSettings.privateKey, this.provider);
358
- }
359
- else if (!providerSettings.url?.startsWith("https://rpc.gnosischain.com")) {
360
- try {
361
- this.signer = await this.provider.getSigner();
362
- }
363
- catch (e) {
364
- this.signer = null;
365
- }
366
- }
367
- // Web3 provider
368
- }
369
- else if (providerType.toLowerCase() === 'Web3'.toLowerCase()) {
370
- providerSettings = providerSettings;
371
- this.provider = new ethers.BrowserProvider(providerSettings.externalProvider);
372
- this.signer = await this.provider.getSigner();
373
- // Infura provider
374
- }
375
- else if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
376
- providerSettings = providerSettings;
377
- this.provider = new ethers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
378
- this.signer = null;
379
- // Alchemy provider
380
- }
381
- else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
382
- providerSettings = providerSettings;
383
- this.provider = new ethers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
384
- this.signer = null;
385
- }
386
- else {
387
- throw Error('Wrong providerType');
388
- }
389
- const network = await this.provider.getNetwork();
390
- console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
391
- this.chainId = Number(network.chainId) === 1337 ? 1 : Number(network.chainId);
392
- this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
393
- this.constants.NETWORK_NAME = NETWORK_CONSTANTS[this.chainId].NAME;
394
- this.constants.ALIASES = NETWORK_CONSTANTS[this.chainId].ALIASES;
395
- this.constants.POOLS_DATA = NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
396
- for (const poolId in this.constants.POOLS_DATA)
397
- this.constants.POOLS_DATA[poolId].in_api = true;
398
- this.constants.COINS = NETWORK_CONSTANTS[this.chainId].COINS;
399
- this.constants.DECIMALS = extractDecimals(this.constants.POOLS_DATA);
400
- this.constants.DECIMALS[this.constants.NATIVE_TOKEN.address] = 18;
401
- this.constants.DECIMALS[this.constants.NATIVE_TOKEN.wrappedAddress] = 18;
402
- this.constants.GAUGES = extractGauges(this.constants.POOLS_DATA);
403
- const [cTokens, yTokens, ycTokens, aTokens] = [
404
- NETWORK_CONSTANTS[this.chainId].cTokens,
405
- NETWORK_CONSTANTS[this.chainId].yTokens,
406
- NETWORK_CONSTANTS[this.chainId].ycTokens,
407
- NETWORK_CONSTANTS[this.chainId].aTokens,
408
- ];
409
- const customAbiTokens = [...cTokens, ...yTokens, ...ycTokens, ...aTokens];
410
- await _killGauges(this.constants.POOLS_DATA);
411
- this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
412
- if (this.signer) {
413
- try {
414
- this.signerAddress = await this.signer.getAddress();
415
- }
416
- catch (err) {
417
- this.signer = null;
418
- }
419
- }
420
- else {
421
- this.signerAddress = '';
422
- }
423
- this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
424
- await this.updateFeeData();
425
- for (const pool of Object.values(this.constants.POOLS_DATA)) {
426
- this.setContract(pool.swap_address, pool.swap_abi);
427
- if (pool.token_address !== pool.swap_address) {
428
- this.setContract(pool.token_address, ERC20Abi);
429
- }
430
- if (pool.gauge_address !== this.constants.ZERO_ADDRESS) {
431
- this.setContract(pool.gauge_address, pool.gauge_abi);
432
- }
433
- if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
434
- this.setContract(pool.deposit_address, pool.deposit_abi);
435
- }
436
- for (const coinAddr of pool.underlying_coin_addresses) {
437
- this.setContract(coinAddr, ERC20Abi);
438
- }
439
- for (const coinAddr of pool.wrapped_coin_addresses) {
440
- if (customAbiTokens.includes(coinAddr))
441
- continue;
442
- if (coinAddr in this.contracts)
443
- continue;
444
- this.setContract(coinAddr, ERC20Abi);
445
- }
446
- // TODO add all coins
447
- for (const coinAddr of pool.wrapped_coin_addresses) {
448
- if (cTokens.includes(coinAddr)) {
449
- this.setContract(coinAddr, cERC20Abi);
450
- }
451
- if (aTokens.includes(coinAddr)) {
452
- 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*/];
453
686
  }
454
- if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
455
- this.setContract(coinAddr, yERC20Abi);
456
- }
457
- }
458
- if (pool.reward_contract) {
459
- this.setContract(pool.reward_contract, streamerABI);
460
- }
461
- if (pool.sCurveRewards_address) {
462
- this.setContract(pool.sCurveRewards_address, pool.sCurveRewards_abi);
463
- }
464
- }
465
- this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20Abi);
466
- this.setContract(this.constants.ALIASES.crv, ERC20Abi);
467
- this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
468
- const _minterABI = this.chainId === 1 ? minterABI : minterChildABI;
469
- this.setContract(this.constants.ALIASES.minter, _minterABI);
470
- this.setContract(this.constants.ALIASES.voting_escrow, votingEscrowABI);
471
- this.setContract(this.constants.ALIASES.fee_distributor, feeDistributorABI);
472
- this.setContract(this.constants.ALIASES.address_provider, addressProviderABI);
473
- const addressProviderContract = this.contracts[this.constants.ALIASES.address_provider].contract;
474
- this.constants.ALIASES.registry_exchange = (await addressProviderContract.get_address(2, this.constantOptions)).toLowerCase();
475
- this.setContract(this.constants.ALIASES.registry_exchange, registryExchangeABI);
476
- this.setContract(this.constants.ALIASES.gauge_controller, gaugeControllerABI);
477
- this.setContract(this.constants.ALIASES.router, routerABI);
478
- if (this.chainId === 137) {
479
- this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStake6CoinsABI);
480
- }
481
- else {
482
- this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeABI);
483
- }
484
- this.setContract(this.constants.ALIASES.factory, factoryABI);
485
- this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
486
- }
487
- setContract(address, abi) {
687
+ });
688
+ });
689
+ };
690
+ Curve.prototype.setContract = function (address, abi) {
488
691
  this.contracts[address] = {
489
692
  contract: new Contract(address, abi, this.signer || this.provider),
490
693
  multicallContract: new MulticallContract(address, abi),
491
694
  };
492
- }
493
- async _filterHiddenPools(pools) {
494
- const hiddenPools = (await _getHiddenPools())[this.constants.NETWORK_NAME] || [];
495
- // @ts-ignore
496
- return Object.fromEntries(Object.entries(pools).filter(([id]) => !hiddenPools.includes(id)));
497
- }
498
- _updateDecimalsAndGauges(pools) {
499
- this.constants.DECIMALS = { ...this.constants.DECIMALS, ...extractDecimals(pools) };
500
- this.constants.GAUGES = [...this.constants.GAUGES, ...extractGauges(pools)];
501
- }
502
- setCustomFeeData(customFeeData) {
503
- this.feeData = { ...this.feeData, ...customFeeData };
504
- }
505
- 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) {
506
721
  return ethers.formatUnits(value, unit);
507
- }
508
- parseUnits(value, unit) {
722
+ };
723
+ Curve.prototype.parseUnits = function (value, unit) {
509
724
  return ethers.parseUnits(value, unit);
510
- }
511
- async updateFeeData() {
512
- const feeData = await this.provider.getFeeData();
513
- if (feeData.maxFeePerGas === null || feeData.maxPriorityFeePerGas === null) {
514
- delete this.options.maxFeePerGas;
515
- delete this.options.maxPriorityFeePerGas;
516
- this.options.gasPrice = this.feeData.gasPrice !== undefined ?
517
- this.parseUnits(this.feeData.gasPrice.toString(), "gwei") :
518
- (feeData.gasPrice || this.parseUnits("20", "gwei"));
519
- }
520
- else {
521
- delete this.options.gasPrice;
522
- this.options.maxFeePerGas = this.feeData.maxFeePerGas !== undefined ?
523
- this.parseUnits(this.feeData.maxFeePerGas.toString(), "gwei") :
524
- feeData.maxFeePerGas;
525
- this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
526
- this.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
527
- feeData.maxPriorityFeePerGas;
528
- }
529
- }
530
- }
531
- 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();