@curvefi/api 2.48.1 → 2.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -383,6 +383,13 @@ import curve from "@curvefi/api";
383
383
  // true
384
384
  pool.isGaugeKilled;
385
385
  // false
386
+ pool.gaugeStatus;
387
+ // null OR
388
+ //{
389
+ // rewardsNeedNudging: false,
390
+ // areCrvRewardsStuckInBridge: false,
391
+ //
392
+ // }
386
393
  })()
387
394
  ````
388
395
 
@@ -1464,6 +1471,20 @@ import curve from "@curvefi/api";
1464
1471
  })()
1465
1472
  ```
1466
1473
 
1474
+ ## Gas estimation L2
1475
+ For L2 networks `estimateGas` return array `[L2GasUsed, L1GasUsed]`, where `L2GasUsed` - gas estimate for execution transaction in current L2 network, and `L1GasUsed` - gas estimate for data storage in parent L1 network.
1476
+
1477
+ Gas Price in L1 is required to calculate the fee.
1478
+ You can use `getGasPriceFromL1` for get Gas Price in L1.
1479
+ ````ts
1480
+ const L1GasPrice = await curve.L1GasPrice()
1481
+ // 13161051
1482
+ ````
1483
+
1484
+ **Calculate fee**
1485
+ `fee = L2GasUsed*L2GasPrice + L1GasUsed*L1GasPrice`
1486
+
1487
+
1467
1488
  ## Factory
1468
1489
 
1469
1490
  ### Fetch new pools from blockchain
package/lib/boosting.js CHANGED
@@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  import { Contract } from "ethers";
49
49
  import { curve } from "./curve.js";
50
50
  import feeDistributorViewABI from "./constants/abis/fee_distributor_view.json" assert { type: 'json' };
51
- import { _getBalances, _prepareAddresses, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3 } from "./utils.js";
51
+ import { _getBalances, _prepareAddresses, DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, smartNumber } from "./utils.js";
52
52
  import { _ensureAllowance, toBN, toStringFromBN, parseUnits } from './utils.js';
53
53
  import { _generateBoostingProof } from './external-api.js';
54
54
  export var getCrv = function () {
@@ -214,25 +214,26 @@ export var calcUnlockTime = function (days, start) {
214
214
  return Math.floor(unlockTime / week) * week * 1000;
215
215
  };
216
216
  export var createLock = function (amount, days) { return __awaiter(void 0, void 0, void 0, function () {
217
- var _amount, unlockTime, contract, gasLimit, _a;
218
- return __generator(this, function (_b) {
219
- switch (_b.label) {
217
+ var _amount, unlockTime, contract, gasLimit, _a, _b;
218
+ return __generator(this, function (_c) {
219
+ switch (_c.label) {
220
220
  case 0:
221
221
  _amount = parseUnits(amount);
222
222
  unlockTime = Math.floor(Date.now() / 1000) + (86400 * days);
223
223
  return [4 /*yield*/, _ensureAllowance([curve.constants.ALIASES.crv], [_amount], curve.constants.ALIASES.voting_escrow, false)];
224
224
  case 1:
225
- _b.sent();
225
+ _c.sent();
226
226
  contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
227
227
  return [4 /*yield*/, curve.updateFeeData()];
228
228
  case 2:
229
- _b.sent();
229
+ _c.sent();
230
230
  _a = mulBy1_3;
231
+ _b = DIGas;
231
232
  return [4 /*yield*/, contract.create_lock.estimateGas(_amount, unlockTime, curve.constantOptions)];
232
233
  case 3:
233
- gasLimit = _a.apply(void 0, [_b.sent()]);
234
+ gasLimit = _a.apply(void 0, [_b.apply(void 0, [_c.sent()])]);
234
235
  return [4 /*yield*/, contract.create_lock(_amount, unlockTime, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
235
- case 4: return [2 /*return*/, (_b.sent()).hash];
236
+ case 4: return [2 /*return*/, (_c.sent()).hash];
236
237
  }
237
238
  });
238
239
  }); };
@@ -260,90 +261,95 @@ export var increaseAmountEstimateGas = function (amount) { return __awaiter(void
260
261
  });
261
262
  }); };
262
263
  export var increaseAmount = function (amount) { return __awaiter(void 0, void 0, void 0, function () {
263
- var _amount, contract, gasLimit, _a;
264
- return __generator(this, function (_b) {
265
- switch (_b.label) {
264
+ var _amount, contract, gasLimit, _a, _b;
265
+ return __generator(this, function (_c) {
266
+ switch (_c.label) {
266
267
  case 0:
267
268
  _amount = parseUnits(amount);
268
269
  return [4 /*yield*/, _ensureAllowance([curve.constants.ALIASES.crv], [_amount], curve.constants.ALIASES.voting_escrow, false)];
269
270
  case 1:
270
- _b.sent();
271
+ _c.sent();
271
272
  contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
272
273
  return [4 /*yield*/, curve.updateFeeData()];
273
274
  case 2:
274
- _b.sent();
275
+ _c.sent();
275
276
  _a = mulBy1_3;
277
+ _b = DIGas;
276
278
  return [4 /*yield*/, contract.increase_amount.estimateGas(_amount, curve.constantOptions)];
277
279
  case 3:
278
- gasLimit = _a.apply(void 0, [_b.sent()]);
280
+ gasLimit = _a.apply(void 0, [_b.apply(void 0, [_c.sent()])]);
279
281
  return [4 /*yield*/, contract.increase_amount(_amount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
280
- case 4: return [2 /*return*/, (_b.sent()).hash];
282
+ case 4: return [2 /*return*/, (_c.sent()).hash];
281
283
  }
282
284
  });
283
285
  }); };
284
286
  export var increaseUnlockTimeEstimateGas = function (days) { return __awaiter(void 0, void 0, void 0, function () {
285
- var unlockTime, newUnlockTime, contract, _a;
286
- return __generator(this, function (_b) {
287
- switch (_b.label) {
287
+ var unlockTime, newUnlockTime, contract, _a, _b;
288
+ return __generator(this, function (_c) {
289
+ switch (_c.label) {
288
290
  case 0: return [4 /*yield*/, getLockedAmountAndUnlockTime()];
289
291
  case 1:
290
- unlockTime = (_b.sent()).unlockTime;
292
+ unlockTime = (_c.sent()).unlockTime;
291
293
  newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
292
294
  contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
293
295
  _a = Number;
296
+ _b = DIGas;
294
297
  return [4 /*yield*/, contract.increase_unlock_time.estimateGas(newUnlockTime, curve.constantOptions)];
295
- case 2: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
298
+ case 2: return [2 /*return*/, _a.apply(void 0, [_b.apply(void 0, [_c.sent()])])];
296
299
  }
297
300
  });
298
301
  }); };
299
302
  export var increaseUnlockTime = function (days) { return __awaiter(void 0, void 0, void 0, function () {
300
- var unlockTime, newUnlockTime, contract, gasLimit, _a;
301
- return __generator(this, function (_b) {
302
- switch (_b.label) {
303
+ var unlockTime, newUnlockTime, contract, gasLimit, _a, _b;
304
+ return __generator(this, function (_c) {
305
+ switch (_c.label) {
303
306
  case 0: return [4 /*yield*/, getLockedAmountAndUnlockTime()];
304
307
  case 1:
305
- unlockTime = (_b.sent()).unlockTime;
308
+ unlockTime = (_c.sent()).unlockTime;
306
309
  newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
307
310
  contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
308
311
  return [4 /*yield*/, curve.updateFeeData()];
309
312
  case 2:
310
- _b.sent();
313
+ _c.sent();
311
314
  _a = mulBy1_3;
315
+ _b = DIGas;
312
316
  return [4 /*yield*/, contract.increase_unlock_time.estimateGas(newUnlockTime, curve.constantOptions)];
313
317
  case 3:
314
- gasLimit = _a.apply(void 0, [_b.sent()]);
318
+ gasLimit = _a.apply(void 0, [_b.apply(void 0, [_c.sent()])]);
315
319
  return [4 /*yield*/, contract.increase_unlock_time(newUnlockTime, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
316
- case 4: return [2 /*return*/, (_b.sent()).hash];
320
+ case 4: return [2 /*return*/, (_c.sent()).hash];
317
321
  }
318
322
  });
319
323
  }); };
320
324
  export var withdrawLockedCrvEstimateGas = function () { return __awaiter(void 0, void 0, void 0, function () {
321
- var contract, _a;
322
- return __generator(this, function (_b) {
323
- switch (_b.label) {
325
+ var contract, _a, _b;
326
+ return __generator(this, function (_c) {
327
+ switch (_c.label) {
324
328
  case 0:
325
329
  contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
326
330
  _a = Number;
331
+ _b = DIGas;
327
332
  return [4 /*yield*/, contract.withdraw.estimateGas(curve.constantOptions)];
328
- case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
333
+ case 1: return [2 /*return*/, _a.apply(void 0, [_b.apply(void 0, [_c.sent()])])];
329
334
  }
330
335
  });
331
336
  }); };
332
337
  export var withdrawLockedCrv = function () { return __awaiter(void 0, void 0, void 0, function () {
333
- var contract, gasLimit, _a;
334
- return __generator(this, function (_b) {
335
- switch (_b.label) {
338
+ var contract, gasLimit, _a, _b;
339
+ return __generator(this, function (_c) {
340
+ switch (_c.label) {
336
341
  case 0:
337
342
  contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
338
343
  return [4 /*yield*/, curve.updateFeeData()];
339
344
  case 1:
340
- _b.sent();
345
+ _c.sent();
341
346
  _a = mulBy1_3;
347
+ _b = DIGas;
342
348
  return [4 /*yield*/, contract.withdraw.estimateGas(curve.constantOptions)];
343
349
  case 2:
344
- gasLimit = _a.apply(void 0, [_b.sent()]);
350
+ gasLimit = _a.apply(void 0, [_b.apply(void 0, [_c.sent()])]);
345
351
  return [4 /*yield*/, contract.withdraw(__assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
346
- case 3: return [2 /*return*/, (_b.sent()).hash];
352
+ case 3: return [2 /*return*/, (_c.sent()).hash];
347
353
  }
348
354
  });
349
355
  }); };
@@ -366,15 +372,16 @@ export var claimableFees = function (address) {
366
372
  export var claimFeesEstimateGas = function (address) {
367
373
  if (address === void 0) { address = ""; }
368
374
  return __awaiter(void 0, void 0, void 0, function () {
369
- var contract, _a;
370
- return __generator(this, function (_b) {
371
- switch (_b.label) {
375
+ var contract, _a, _b;
376
+ return __generator(this, function (_c) {
377
+ switch (_c.label) {
372
378
  case 0:
373
379
  address = address || curve.signerAddress;
374
380
  contract = curve.contracts[curve.constants.ALIASES.fee_distributor].contract;
375
381
  _a = Number;
382
+ _b = DIGas;
376
383
  return [4 /*yield*/, contract.claim.estimateGas(address, curve.constantOptions)];
377
- case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
384
+ case 1: return [2 /*return*/, _a.apply(void 0, [_b.apply(void 0, [_c.sent()])])];
378
385
  }
379
386
  });
380
387
  });
@@ -382,21 +389,22 @@ export var claimFeesEstimateGas = function (address) {
382
389
  export var claimFees = function (address) {
383
390
  if (address === void 0) { address = ""; }
384
391
  return __awaiter(void 0, void 0, void 0, function () {
385
- var contract, gasLimit, _a;
386
- return __generator(this, function (_b) {
387
- switch (_b.label) {
392
+ var contract, gasLimit, _a, _b;
393
+ return __generator(this, function (_c) {
394
+ switch (_c.label) {
388
395
  case 0:
389
396
  address = address || curve.signerAddress;
390
397
  contract = curve.contracts[curve.constants.ALIASES.fee_distributor].contract;
391
398
  return [4 /*yield*/, curve.updateFeeData()];
392
399
  case 1:
393
- _b.sent();
400
+ _c.sent();
394
401
  _a = mulBy1_3;
402
+ _b = DIGas;
395
403
  return [4 /*yield*/, contract.claim.estimateGas(address, curve.constantOptions)];
396
404
  case 2:
397
- gasLimit = _a.apply(void 0, [_b.sent()]);
405
+ gasLimit = _a.apply(void 0, [_b.apply(void 0, [_c.sent()])]);
398
406
  return [4 /*yield*/, contract.claim(address, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
399
- case 3: return [2 /*return*/, (_b.sent()).hash];
407
+ case 3: return [2 /*return*/, (_c.sent()).hash];
400
408
  }
401
409
  });
402
410
  });
@@ -445,11 +453,11 @@ var _topUpAnycall = function (amount, estimateGas) { return __awaiter(void 0, vo
445
453
  case 1:
446
454
  gas = _a.sent();
447
455
  if (estimateGas)
448
- return [2 /*return*/, Number(gas)];
456
+ return [2 /*return*/, smartNumber(gas)];
449
457
  return [4 /*yield*/, curve.updateFeeData()];
450
458
  case 2:
451
459
  _a.sent();
452
- gasLimit = mulBy1_3(gas);
460
+ gasLimit = mulBy1_3(DIGas(gas));
453
461
  return [4 /*yield*/, anycallContract.deposit(curve.constants.ALIASES.voting_escrow_oracle, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
454
462
  case 3: return [2 /*return*/, (_a.sent()).hash];
455
463
  }
@@ -514,11 +522,11 @@ var _sendBlockhash = function (block, chainId, estimateGas) { return __awaiter(v
514
522
  case 1:
515
523
  gas = _a.sent();
516
524
  if (estimateGas)
517
- return [2 /*return*/, Number(gas)];
525
+ return [2 /*return*/, smartNumber(gas)];
518
526
  return [4 /*yield*/, curve.updateFeeData()];
519
527
  case 2:
520
528
  _a.sent();
521
- gasLimit = mulBy1_3(gas);
529
+ gasLimit = mulBy1_3(DIGas(gas));
522
530
  return [4 /*yield*/, veOracleContract.send_blockhash(block, chainId, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
523
531
  case 3: return [2 /*return*/, (_a.sent()).hash];
524
532
  }
@@ -559,11 +567,11 @@ var _submitProof = function (block, address, estimateGas) {
559
567
  case 2:
560
568
  gas = _a.sent();
561
569
  if (estimateGas)
562
- return [2 /*return*/, Number(gas)];
570
+ return [2 /*return*/, smartNumber(gas)];
563
571
  return [4 /*yield*/, curve.updateFeeData()];
564
572
  case 3:
565
573
  _a.sent();
566
- gasLimit = mulBy1_3(gas);
574
+ gasLimit = mulBy1_3(DIGas(gas));
567
575
  return [4 /*yield*/, veOracleContract.submit_state(address, "0x" + proof.block_header_rlp, "0x" + proof.proof_rlp, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
568
576
  case 4: return [2 /*return*/, (_a.sent()).hash];
569
577
  }
@@ -0,0 +1 @@
1
+ export declare const L2Networks: number[];
@@ -0,0 +1 @@
1
+ export var L2Networks = [10]; // <-- Will be added later: 8453 (base), 42161 (arbitrum)
@@ -0,0 +1 @@
1
+ [{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "DECIMALS", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "baseFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "gasPrice", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes", "name": "_data", "type": "bytes" }], "name": "getL1Fee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes", "name": "_data", "type": "bytes" }], "name": "getL1GasUsed", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "l1BaseFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "overhead", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "scalar", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }]
@@ -107,6 +107,7 @@ export var ALIASES_OPTIMISM = lowerCaseValues({
107
107
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
108
108
  "tricrypto_factory": '0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963',
109
109
  "factory_admin": "",
110
+ "gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f', // <-- NEW
110
111
  });
111
112
  export var ALIASES_XDAI = lowerCaseValues({
112
113
  "crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
package/lib/curve.js CHANGED
@@ -54,7 +54,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
54
54
  }
55
55
  return to.concat(ar || Array.prototype.slice.call(from));
56
56
  };
57
- import { ethers, Contract } from "ethers";
57
+ import { ethers, Contract, JsonRpcSigner } from "ethers";
58
58
  import { Provider as MulticallProvider, Contract as MulticallContract } from 'ethcall';
59
59
  import { getFactoryPoolData } from "./factory/factory.js";
60
60
  import { getFactoryPoolsDataFromApi } from "./factory/factory-api.js";
@@ -84,6 +84,7 @@ import factoryEywaABI from './constants/abis/factory-eywa.json' assert { type: '
84
84
  import factoryAdminABI from './constants/abis/factory-admin.json' assert { type: 'json' };
85
85
  import cryptoFactoryABI from './constants/abis/factory-crypto.json' assert { type: 'json' };
86
86
  import tricryptoFactoryABI from './constants/abis/factory-tricrypto.json' assert { type: 'json' };
87
+ import gasOracleABI from './constants/abis/gas_oracle_optimism.json' assert { type: 'json' };
87
88
  import { POOLS_DATA_ETHEREUM, LLAMMAS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, POOLS_DATA_ZKSYNC, POOLS_DATA_BASE, } from './constants/pools/index.js';
88
89
  import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, ALIASES_ZKSYNC, ALIASES_BASE, } from "./constants/aliases.js";
89
90
  import { COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum } from "./constants/coins/ethereum.js";
@@ -101,22 +102,28 @@ import { COINS_ZKSYNC, cTokensZkSync, yTokensZkSync, ycTokensZkSync, aTokensZkSy
101
102
  import { COINS_BASE, cTokensBase, yTokensBase, ycTokensBase, aTokensBase } from "./constants/coins/base.js";
102
103
  import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./constants/utils.js";
103
104
  import { _getAllGauges, _getHiddenPools } from "./external-api.js";
105
+ import { L2Networks } from "./constants/L2Networks";
104
106
  var _killGauges = function (poolsData) { return __awaiter(void 0, void 0, void 0, function () {
105
- var gaugeData, isKilled, poolId;
107
+ var gaugeData, isKilled, gaugeStatuses, poolId;
106
108
  return __generator(this, function (_a) {
107
109
  switch (_a.label) {
108
110
  case 0: return [4 /*yield*/, _getAllGauges()];
109
111
  case 1:
110
112
  gaugeData = _a.sent();
111
113
  isKilled = {};
114
+ gaugeStatuses = {};
112
115
  Object.values(gaugeData).forEach(function (d) {
113
- var _a;
116
+ var _a, _b;
114
117
  isKilled[d.gauge.toLowerCase()] = (_a = d.is_killed) !== null && _a !== void 0 ? _a : false;
118
+ gaugeStatuses[d.gauge.toLowerCase()] = (_b = d.gaugeStatus) !== null && _b !== void 0 ? _b : null;
115
119
  });
116
120
  for (poolId in poolsData) {
117
121
  if (isKilled[poolsData[poolId].gauge_address]) {
118
122
  poolsData[poolId].is_gauge_killed = true;
119
123
  }
124
+ if (gaugeStatuses[poolsData[poolId].gauge_address]) {
125
+ poolsData[poolId].gauge_status = gaugeStatuses[poolsData[poolId].gauge_address];
126
+ }
120
127
  }
121
128
  return [2 /*return*/];
122
129
  }
@@ -701,7 +708,7 @@ var Curve = /** @class */ (function () {
701
708
  var _a;
702
709
  if (options === void 0) { options = {}; }
703
710
  return __awaiter(this, void 0, void 0, function () {
704
- var jsonRpcApiProviderOptions, _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, _gaugeFactoryABI, factoryContract, _o;
711
+ var jsonRpcApiProviderOptions, _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, _gaugeFactoryABI, factoryContract, _o, curveInstance_1, originalEstimate_1, newEstimate;
705
712
  return __generator(this, function (_p) {
706
713
  switch (_p.label) {
707
714
  case 0:
@@ -929,6 +936,31 @@ var Curve = /** @class */ (function () {
929
936
  this.setContract(this.constants.ALIASES.tricrypto_factory, tricryptoFactoryABI);
930
937
  this.setContract(this.constants.ALIASES.anycall, anycallABI);
931
938
  this.setContract(this.constants.ALIASES.voting_escrow_oracle, this.chainId === 1 ? votingEscrowOracleEthABI : votingEscrowOracleABI);
939
+ if (L2Networks.includes(this.chainId)) {
940
+ curveInstance_1 = this;
941
+ curveInstance_1.setContract(curveInstance_1.constants.ALIASES.gas_oracle, gasOracleABI);
942
+ originalEstimate_1 = JsonRpcSigner.prototype.estimateGas;
943
+ newEstimate = function (arg) {
944
+ return __awaiter(this, void 0, void 0, function () {
945
+ var L2EstimateGas, L1GasUsed, L2GasUsed;
946
+ return __generator(this, function (_a) {
947
+ switch (_a.label) {
948
+ case 0:
949
+ L2EstimateGas = originalEstimate_1.bind(this);
950
+ return [4 /*yield*/, curveInstance_1.contracts[curveInstance_1.constants.ALIASES.gas_oracle].contract.getL1GasUsed(arg.data)];
951
+ case 1:
952
+ L1GasUsed = _a.sent();
953
+ return [4 /*yield*/, L2EstimateGas(arg)];
954
+ case 2:
955
+ L2GasUsed = _a.sent();
956
+ return [2 /*return*/, [L2GasUsed, L1GasUsed]];
957
+ }
958
+ });
959
+ });
960
+ };
961
+ // @ts-ignore
962
+ JsonRpcSigner.prototype.estimateGas = newEstimate;
963
+ }
932
964
  return [2 /*return*/];
933
965
  }
934
966
  });
@@ -38,9 +38,11 @@ export declare const _getFactoryAPYsAndVolumes: ((network: string) => Promise<{
38
38
  export declare const _getAllGauges: (() => Promise<IDict<{
39
39
  gauge: string;
40
40
  is_killed?: boolean;
41
+ gaugeStatus?: Record<string, boolean> | null;
41
42
  }>>) & memoize.Memoized<() => Promise<IDict<{
42
43
  gauge: string;
43
44
  is_killed?: boolean;
45
+ gaugeStatus?: Record<string, boolean> | null;
44
46
  }>>>;
45
47
  export declare const _getHiddenPools: (() => Promise<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
46
48
  export declare const _generateBoostingProof: ((block: number, address: string) => Promise<{
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  import { ethers, Contract, Typed } from "ethers";
58
58
  import { curve } from "../curve.js";
59
59
  import { getPool } from "../pools/index.js";
60
- import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress } from "../utils.js";
60
+ import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress, DIGas, smartNumber } from '../utils.js';
61
61
  import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" assert { type: 'json' };
62
62
  import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" assert { type: 'json' };
63
63
  // ------- STABLE PLAIN POOLS -------
@@ -113,8 +113,8 @@ oracleAddress, methodName, estimateGas) { return __awaiter(void 0, void 0, void
113
113
  case 1:
114
114
  gas = _b.sent();
115
115
  if (estimateGas)
116
- return [2 /*return*/, Number(gas)];
117
- gasLimit = mulBy1_3(gas);
116
+ return [2 /*return*/, smartNumber(gas)];
117
+ gasLimit = mulBy1_3(DIGas(gas));
118
118
  return [4 /*yield*/, curve.updateFeeData()];
119
119
  case 2:
120
120
  _b.sent();
@@ -238,8 +238,8 @@ implementationIdx, estimateGas) { return __awaiter(void 0, void 0, void 0, funct
238
238
  case 1:
239
239
  gas = _a.sent();
240
240
  if (estimateGas)
241
- return [2 /*return*/, Number(gas)];
242
- gasLimit = mulBy1_3(gas);
241
+ return [2 /*return*/, smartNumber(gas)];
242
+ gasLimit = mulBy1_3(DIGas(gas));
243
243
  return [4 /*yield*/, curve.updateFeeData()];
244
244
  case 2:
245
245
  _a.sent();
@@ -353,8 +353,8 @@ initialPrice, estimateGas) { return __awaiter(void 0, void 0, void 0, function (
353
353
  case 1:
354
354
  gas = _a.sent();
355
355
  if (estimateGas)
356
- return [2 /*return*/, Number(gas)];
357
- gasLimit = mulBy1_3(gas);
356
+ return [2 /*return*/, smartNumber(gas)];
357
+ gasLimit = mulBy1_3(DIGas(gas));
358
358
  return [4 /*yield*/, curve.updateFeeData()];
359
359
  case 2:
360
360
  _a.sent();
@@ -475,8 +475,8 @@ initialPrices, estimateGas) { return __awaiter(void 0, void 0, void 0, function
475
475
  case 1:
476
476
  gas = _a.sent();
477
477
  if (estimateGas)
478
- return [2 /*return*/, Number(gas)];
479
- gasLimit = mulBy1_3(gas);
478
+ return [2 /*return*/, smartNumber(gas)];
479
+ gasLimit = mulBy1_3(DIGas(gas));
480
480
  return [4 /*yield*/, curve.updateFeeData()];
481
481
  case 2:
482
482
  _a.sent();
@@ -539,8 +539,8 @@ var _deployGauge = function (pool, factory, estimateGas) { return __awaiter(void
539
539
  case 1:
540
540
  gas = _a.sent();
541
541
  if (estimateGas)
542
- return [2 /*return*/, Number(gas)];
543
- gasLimit = mulBy1_3(gas);
542
+ return [2 /*return*/, smartNumber(gas)];
543
+ gasLimit = mulBy1_3(DIGas(gas));
544
544
  return [4 /*yield*/, curve.updateFeeData()];
545
545
  case 2:
546
546
  _a.sent();
@@ -562,8 +562,8 @@ var _deployGaugeSidechain = function (pool, salt, estimateGas) { return __awaite
562
562
  case 1:
563
563
  gas = _a.sent();
564
564
  if (estimateGas)
565
- return [2 /*return*/, Number(gas)];
566
- gasLimit = mulBy1_3(gas);
565
+ return [2 /*return*/, smartNumber(gas)];
566
+ gasLimit = mulBy1_3(DIGas(gas));
567
567
  return [4 /*yield*/, curve.updateFeeData()];
568
568
  case 2:
569
569
  _a.sent();
@@ -585,8 +585,8 @@ var _deployGaugeMirror = function (chainId, salt, estimateGas) { return __awaite
585
585
  case 1:
586
586
  gas = _a.sent();
587
587
  if (estimateGas)
588
- return [2 /*return*/, Number(gas)];
589
- gasLimit = mulBy1_3(gas);
588
+ return [2 /*return*/, smartNumber(gas)];
589
+ gasLimit = mulBy1_3(DIGas(gas));
590
590
  return [4 /*yield*/, curve.updateFeeData()];
591
591
  case 2:
592
592
  _a.sent();
package/lib/index.d.ts CHANGED
@@ -40,6 +40,7 @@ declare const curve: {
40
40
  PoolTemplate: typeof PoolTemplate;
41
41
  getPool: (poolId: string) => PoolTemplate;
42
42
  getUsdRate: (coin: string) => Promise<number>;
43
+ getGasPriceFromL1: () => Promise<number>;
43
44
  getTVL: (network?: import("./interfaces.js").INetworkName | import("./interfaces.js").IChainId) => Promise<number>;
44
45
  getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<string[] | import("./interfaces.js").IDict<string[]>>;
45
46
  getAllowance: (coins: string[], address: string, spender: string) => Promise<string[]>;
package/lib/index.js CHANGED
@@ -39,7 +39,7 @@ import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList
39
39
  import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapEstimateGas, swap, getSwappedAmount, } from "./router.js";
40
40
  import { curve as _curve } from "./curve.js";
41
41
  import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees, lastEthBlock, getAnycallBalance, topUpAnycall, topUpAnycallEstimateGas, lastBlockSent, blockToSend, sendBlockhash, sendBlockhashEstimateGas, submitProof, submitProofEstimateGas, } from "./boosting.js";
42
- import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, } from "./utils.js";
42
+ import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, } from "./utils.js";
43
43
  import { deployStablePlainPool, deployStablePlainPoolEstimateGas, getDeployedStablePlainPoolAddress, setOracle, setOracleEstimateGas, deployStableMetaPool, deployStableMetaPoolEstimateGas, getDeployedStableMetaPoolAddress, deployCryptoPool, deployCryptoPoolEstimateGas, getDeployedCryptoPoolAddress, deployTricryptoPool, deployTricryptoPoolEstimateGas, getDeployedTricryptoPoolAddress, deployGauge, deployGaugeEstimateGas, getDeployedGaugeAddress, deployGaugeSidechain, deployGaugeSidechainEstimateGas, deployGaugeMirror, deployGaugeMirrorEstimateGas, getDeployedGaugeMirrorAddress, getDeployedGaugeMirrorAddressByTx, } from './factory/deploy.js';
44
44
  function init(providerType, providerSettings, options) {
45
45
  if (options === void 0) { options = {}; }
@@ -76,6 +76,7 @@ var curve = {
76
76
  PoolTemplate: PoolTemplate,
77
77
  getPool: getPool,
78
78
  getUsdRate: getUsdRate,
79
+ getGasPriceFromL1: getGasPriceFromL1,
79
80
  getTVL: getTVL,
80
81
  getBalances: getBalances,
81
82
  getAllowance: getAllowance,
@@ -43,6 +43,7 @@ export interface IPoolData {
43
43
  sCurveRewards_abi?: any;
44
44
  in_api?: boolean;
45
45
  is_gauge_killed?: boolean;
46
+ gauge_status?: Record<string, boolean> | null;
46
47
  }
47
48
  export interface ICurve {
48
49
  provider: ethers.BrowserProvider | ethers.JsonRpcProvider;
@@ -32,6 +32,7 @@ export declare class PoolTemplate {
32
32
  useLending: boolean[];
33
33
  inApi: boolean;
34
34
  isGaugeKilled: boolean;
35
+ gaugeStatus: Record<string, boolean> | null;
35
36
  estimateGas: {
36
37
  depositApprove: (amounts: (number | string)[]) => Promise<number>;
37
38
  deposit: (amounts: (number | string)[]) => Promise<number>;
@@ -66,7 +66,7 @@ var YEAR = 365 * DAY;
66
66
  var PoolTemplate = /** @class */ (function () {
67
67
  function PoolTemplate(id) {
68
68
  var _this = this;
69
- var _c, _d, _e;
69
+ var _c, _d, _e, _f;
70
70
  this.statsParameters = function () { return __awaiter(_this, void 0, void 0, function () {
71
71
  var multicallContract, lpMulticallContract, calls, i, additionalCalls, _virtualPrice, _fee, _prices, _adminFee, _A, _lpTokenSupply, _gamma, e_1, _c, virtualPrice, fee, adminFee, A, lpTokenSupply, gamma, priceOracle, priceScale, prices, i, A_PRECISION, _d, _future_A, _initial_A, _future_A_time, _initial_A_time, _e, future_A, initial_A, future_A_time, initial_A_time;
72
72
  var _f, _g, _h;
@@ -1117,6 +1117,7 @@ var PoolTemplate = /** @class */ (function () {
1117
1117
  this.useLending = poolData.use_lending || poolData.underlying_coin_addresses.map(function () { return false; });
1118
1118
  this.inApi = (_d = poolData.in_api) !== null && _d !== void 0 ? _d : false;
1119
1119
  this.isGaugeKilled = (_e = poolData.is_gauge_killed) !== null && _e !== void 0 ? _e : false;
1120
+ this.gaugeStatus = (_f = poolData.gauge_status) !== null && _f !== void 0 ? _f : null;
1120
1121
  this.estimateGas = {
1121
1122
  depositApprove: this.depositApproveEstimateGas.bind(this),
1122
1123
  deposit: this.depositEstimateGas.bind(this),
@@ -55,7 +55,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
55
  return to.concat(ar || Array.prototype.slice.call(from));
56
56
  };
57
57
  import { curve } from "../../curve.js";
58
- import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
58
+ import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
59
59
  // @ts-ignore
60
60
  function _depositCheck(amounts, estimateGas) {
61
61
  if (estimateGas === void 0) { estimateGas = false; }
@@ -137,8 +137,8 @@ export var depositMetaFactoryMixin = {
137
137
  case 4:
138
138
  gas = _a.sent();
139
139
  if (estimateGas)
140
- return [2 /*return*/, Number(gas)];
141
- gasLimit = mulBy1_3(gas);
140
+ return [2 /*return*/, smartNumber(gas)];
141
+ gasLimit = mulBy1_3(DIGas(gas));
142
142
  return [4 /*yield*/, contract.add_liquidity(this.address, _amounts, _minMintAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
143
143
  case 5: return [2 /*return*/, (_a.sent()).hash];
144
144
  }
@@ -203,8 +203,8 @@ export var depositCryptoMetaFactoryMixin = {
203
203
  case 4:
204
204
  gas = _a.sent();
205
205
  if (estimateGas)
206
- return [2 /*return*/, Number(gas)];
207
- gasLimit = mulBy1_3(gas);
206
+ return [2 /*return*/, smartNumber(gas)];
207
+ gasLimit = mulBy1_3(DIGas(gas));
208
208
  return [4 /*yield*/, contract.add_liquidity(this.address, _amounts, _minMintAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
209
209
  case 5: return [2 /*return*/, (_a.sent()).hash];
210
210
  }
@@ -273,8 +273,8 @@ export var depositZapMixin = {
273
273
  case 4:
274
274
  gas = _b.sent();
275
275
  if (estimateGas)
276
- return [2 /*return*/, Number(gas)];
277
- gasLimit = mulBy1_3(gas);
276
+ return [2 /*return*/, smartNumber(gas)];
277
+ gasLimit = mulBy1_3(DIGas(gas));
278
278
  return [4 /*yield*/, contract.add_liquidity.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value })], false))];
279
279
  case 5: return [2 /*return*/, (_b.sent()).hash];
280
280
  }
@@ -339,8 +339,8 @@ export var depositLendingOrCryptoMixin = {
339
339
  case 4:
340
340
  gas = _a.sent();
341
341
  if (estimateGas)
342
- return [2 /*return*/, Number(gas)];
343
- gasLimit = mulBy1_3(gas);
342
+ return [2 /*return*/, smartNumber(gas)];
343
+ gasLimit = mulBy1_3(DIGas(gas));
344
344
  return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
345
345
  case 5: return [2 /*return*/, (_a.sent()).hash];
346
346
  }
@@ -405,8 +405,8 @@ export var depositPlainMixin = {
405
405
  case 4:
406
406
  gas = _a.sent();
407
407
  if (estimateGas)
408
- return [2 /*return*/, Number(gas)];
409
- gasLimit = mulBy1_3(gas);
408
+ return [2 /*return*/, smartNumber(gas)];
409
+ gasLimit = mulBy1_3(DIGas(gas));
410
410
  return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
411
411
  case 5: return [2 /*return*/, (_a.sent()).hash];
412
412
  }