@across-protocol/sdk 3.1.3 → 3.1.5

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 (49) hide show
  1. package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +1 -1
  2. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +10 -8
  3. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  4. package/dist/cjs/gasPriceOracle/adapters/ethereum.js +4 -3
  5. package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
  6. package/dist/cjs/gasPriceOracle/adapters/linea.d.ts +3 -0
  7. package/dist/cjs/gasPriceOracle/adapters/linea.js +10 -0
  8. package/dist/cjs/gasPriceOracle/adapters/linea.js.map +1 -0
  9. package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +1 -1
  10. package/dist/cjs/gasPriceOracle/adapters/polygon.js +17 -27
  11. package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
  12. package/dist/cjs/gasPriceOracle/oracle.js +26 -22
  13. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  14. package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +1 -1
  15. package/dist/esm/gasPriceOracle/adapters/arbitrum.js +9 -7
  16. package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  17. package/dist/esm/gasPriceOracle/adapters/ethereum.js +5 -4
  18. package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
  19. package/dist/esm/gasPriceOracle/adapters/linea.d.ts +3 -0
  20. package/dist/esm/gasPriceOracle/adapters/linea.js +5 -0
  21. package/dist/esm/gasPriceOracle/adapters/linea.js.map +1 -0
  22. package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +1 -1
  23. package/dist/esm/gasPriceOracle/adapters/polygon.js +15 -26
  24. package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
  25. package/dist/esm/gasPriceOracle/oracle.js +26 -22
  26. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  27. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +1 -1
  28. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
  29. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
  30. package/dist/types/gasPriceOracle/adapters/linea.d.ts +4 -0
  31. package/dist/types/gasPriceOracle/adapters/linea.d.ts.map +1 -0
  32. package/dist/types/gasPriceOracle/adapters/polygon.d.ts +1 -1
  33. package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
  34. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  35. package/package.json +2 -2
  36. package/src/gasPriceOracle/adapters/arbitrum.ts +10 -7
  37. package/src/gasPriceOracle/adapters/ethereum.ts +6 -5
  38. package/src/gasPriceOracle/adapters/linea.ts +11 -0
  39. package/src/gasPriceOracle/adapters/polygon.ts +10 -7
  40. package/src/gasPriceOracle/oracle.ts +20 -15
  41. package/dist/cjs/gasPriceOracle/adapters/index.d.ts +0 -3
  42. package/dist/cjs/gasPriceOracle/adapters/index.js +0 -7
  43. package/dist/cjs/gasPriceOracle/adapters/index.js.map +0 -1
  44. package/dist/esm/gasPriceOracle/adapters/index.d.ts +0 -3
  45. package/dist/esm/gasPriceOracle/adapters/index.js +0 -4
  46. package/dist/esm/gasPriceOracle/adapters/index.js.map +0 -1
  47. package/dist/types/gasPriceOracle/adapters/index.d.ts +0 -4
  48. package/dist/types/gasPriceOracle/adapters/index.d.ts.map +0 -1
  49. package/src/gasPriceOracle/adapters/index.ts +0 -3
@@ -1,3 +1,3 @@
1
1
  import { providers } from "ethers";
2
2
  import { GasPriceEstimate } from "../types";
3
- export declare function eip1559_arbitrum(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
3
+ export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
@@ -1,25 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.eip1559_arbitrum = void 0;
3
+ exports.eip1559 = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var ethers_1 = require("ethers");
6
- var ethereum_1 = require("./ethereum");
7
- function eip1559_arbitrum(provider, chainId) {
6
+ var utils_1 = require("../../utils");
7
+ var ethereum = tslib_1.__importStar(require("./ethereum"));
8
+ var DEFAULT_PRIORITY_FEE = ethers_1.utils.parseUnits("1.5", 9);
9
+ function eip1559(provider, chainId) {
8
10
  return tslib_1.__awaiter(this, void 0, void 0, function () {
9
11
  var _a, _maxFeePerGas, maxPriorityFeePerGas, maxFeePerGas;
10
12
  return tslib_1.__generator(this, function (_b) {
11
13
  switch (_b.label) {
12
- case 0: return [4, (0, ethereum_1.eip1559)(provider, chainId)];
14
+ case 0: return [4, ethereum.eip1559(provider, chainId)];
13
15
  case 1:
14
16
  _a = _b.sent(), _maxFeePerGas = _a.maxFeePerGas, maxPriorityFeePerGas = _a.maxPriorityFeePerGas;
15
- if (!maxPriorityFeePerGas.eq(ethers_1.utils.parseUnits("1.5", 9))) {
17
+ if (!maxPriorityFeePerGas.eq(DEFAULT_PRIORITY_FEE)) {
16
18
  throw new Error("Expected hardcoded 1.5 Gwei priority fee on Arbitrum, got ".concat(maxPriorityFeePerGas));
17
19
  }
18
- maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(1);
19
- return [2, { maxPriorityFeePerGas: ethers_1.ethers.constants.One, maxFeePerGas: maxFeePerGas }];
20
+ maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(utils_1.bnOne);
21
+ return [2, { maxPriorityFeePerGas: utils_1.bnOne, maxFeePerGas: maxFeePerGas }];
20
22
  }
21
23
  });
22
24
  });
23
25
  }
24
- exports.eip1559_arbitrum = eip1559_arbitrum;
26
+ exports.eip1559 = eip1559;
25
27
  //# sourceMappingURL=arbitrum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"arbitrum.js","sourceRoot":"","sources":["../../../../src/gas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G,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,aAAK,CAAC,CAAC;oBAExE,WAAO,EAAE,oBAAoB,EAAE,aAAK,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CACtD;AAbD,0BAaC"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.legacy = exports.eip1559 = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var ethers_1 = require("ethers");
6
+ var utils_1 = require("../../utils");
6
7
  var util_1 = require("../util");
7
8
  function eip1559(provider, chainId) {
8
9
  return tslib_1.__awaiter(this, void 0, void 0, function () {
@@ -13,7 +14,7 @@ function eip1559(provider, chainId) {
13
14
  case 1:
14
15
  feeData = _a.sent();
15
16
  [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach(function (field) {
16
- if (!ethers_1.BigNumber.isBigNumber(field) || field.lt(0))
17
+ if (!ethers_1.BigNumber.isBigNumber(field) || field.lt(utils_1.bnZero))
17
18
  (0, util_1.gasPriceError)("getFeeData()", chainId, feeData);
18
19
  });
19
20
  maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
@@ -32,11 +33,11 @@ function legacy(provider, chainId) {
32
33
  case 0: return [4, provider.getGasPrice()];
33
34
  case 1:
34
35
  gasPrice = _a.sent();
35
- if (!ethers_1.BigNumber.isBigNumber(gasPrice) || gasPrice.lt(0))
36
+ if (!ethers_1.BigNumber.isBigNumber(gasPrice) || gasPrice.lt(utils_1.bnZero))
36
37
  (0, util_1.gasPriceError)("getGasPrice()", chainId, gasPrice);
37
38
  return [2, {
38
39
  maxFeePerGas: gasPrice,
39
- maxPriorityFeePerGas: ethers_1.ethers.constants.Zero,
40
+ maxPriorityFeePerGas: utils_1.bnZero,
40
41
  }];
41
42
  }
42
43
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":";;;;AAAA,iCAAsD;AA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,EAAE,OAAe;;;;;wBACzD,WAAM,QAAQ,CAAC,UAAU,EAAE,EAAA;;oBAArC,OAAO,GAAG,SAA2B;oBAE3C,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,UAAC,KAAuB;wBACxF,IAAI,CAAC,kBAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,cAAM,CAAC;4BAAE,IAAA,oBAAa,EAAC,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;oBACzG,CAAC,CAAC,CAAC;oBAEG,oBAAoB,GAAG,OAAO,CAAC,oBAAiC,CAAC;oBACjE,YAAY,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,iBAA8B,CAAC,CAAC;oBAEtF,WAAO,EAAE,oBAAoB,sBAAA,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CAC/C;AAXD,0BAWC;AAED,SAAsB,MAAM,CAAC,QAA4B,EAAE,OAAe;;;;;wBACvD,WAAM,QAAQ,CAAC,WAAW,EAAE,EAAA;;oBAAvC,QAAQ,GAAG,SAA4B;oBAE7C,IAAI,CAAC,kBAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,cAAM,CAAC;wBAAE,IAAA,oBAAa,EAAC,eAAe,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAE/G,WAAO;4BACL,YAAY,EAAE,QAAQ;4BACtB,oBAAoB,EAAE,cAAM;yBAC7B,EAAC;;;;CACH;AATD,wBASC"}
@@ -0,0 +1,3 @@
1
+ import { providers } from "ethers";
2
+ import { GasPriceEstimate } from "../types";
3
+ export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.eip1559 = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var ethereum = tslib_1.__importStar(require("./ethereum"));
6
+ function eip1559(provider, chainId) {
7
+ return ethereum.legacy(provider, chainId);
8
+ }
9
+ exports.eip1559 = eip1559;
10
+ //# sourceMappingURL=linea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linea.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea.ts"],"names":[],"mappings":";;;;AAMA,2DAAuC;AAEvC,SAAgB,OAAO,CAAC,QAA4B,EAAE,OAAe;IACnE,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAFD,0BAEC"}
@@ -1,3 +1,3 @@
1
1
  import { providers } from "ethers";
2
2
  import { GasPriceEstimate } from "../types";
3
- export declare function polygonGasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
3
+ export declare function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.polygonGasStation = void 0;
3
+ exports.gasStation = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var ethers_1 = require("ethers");
6
6
  var baseAdapter_1 = require("../../priceClient/adapters/baseAdapter");
7
- var TypeGuards_1 = require("../../utils/TypeGuards");
7
+ var utils_1 = require("../../utils");
8
+ var constants_1 = require("../../constants");
8
9
  var util_1 = require("../util");
9
10
  var ethereum_1 = require("./ethereum");
11
+ var POLYGON = constants_1.CHAIN_IDs.POLYGON;
10
12
  var PolygonGasStation = (function (_super) {
11
13
  tslib_1.__extends(PolygonGasStation, _super);
12
14
  function PolygonGasStation(_a) {
13
15
  var _this = this;
14
- var _b = _a === void 0 ? {} : _a, _c = _b.chainId, chainId = _c === void 0 ? 137 : _c, host = _b.host, _d = _b.timeout, timeout = _d === void 0 ? 1500 : _d, _e = _b.retries, retries = _e === void 0 ? 1 : _e;
15
- host = (host !== null && host !== void 0 ? host : chainId === 137) ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
16
+ var _b = _a === void 0 ? {} : _a, _c = _b.chainId, chainId = _c === void 0 ? POLYGON : _c, host = _b.host, _d = _b.timeout, timeout = _d === void 0 ? 1500 : _d, _e = _b.retries, retries = _e === void 0 ? 1 : _e;
17
+ host = (host !== null && host !== void 0 ? host : chainId === POLYGON) ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
16
18
  _this = _super.call(this, "Polygon Gas Station", host, { timeout: timeout, retries: retries }) || this;
17
19
  _this.chainId = chainId;
18
20
  return _this;
@@ -29,7 +31,7 @@ var PolygonGasStation = (function (_super) {
29
31
  gas = _a.sent();
30
32
  gasPrice = gas === null || gas === void 0 ? void 0 : gas[strategy];
31
33
  if (!this.isPolygon1559GasPrice(gasPrice)) {
32
- (0, util_1.gasPriceError)("getFeeData()", this.chainId, ethers_1.utils.parseUnits("0"));
34
+ (0, util_1.gasPriceError)("getFeeData()", this.chainId, utils_1.bnZero);
33
35
  }
34
36
  [gasPrice.maxFee, gasPrice.maxPriorityFee].forEach(function (gasPrice) {
35
37
  if (Number(gasPrice) < 0) {
@@ -44,7 +46,7 @@ var PolygonGasStation = (function (_super) {
44
46
  });
45
47
  };
46
48
  PolygonGasStation.prototype.isPolygon1559GasPrice = function (gasPrice) {
47
- if (!(0, TypeGuards_1.isDefined)(gasPrice)) {
49
+ if (!(0, utils_1.isDefined)(gasPrice)) {
48
50
  return false;
49
51
  }
50
52
  var _gasPrice = gasPrice;
@@ -52,26 +54,14 @@ var PolygonGasStation = (function (_super) {
52
54
  };
53
55
  return PolygonGasStation;
54
56
  }(baseAdapter_1.BaseHTTPAdapter));
55
- function polygonGasStation(provider, chainId) {
56
- return tslib_1.__awaiter(this, void 0, void 0, function () {
57
- var gasStation, err_1;
58
- return tslib_1.__generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0:
61
- gasStation = new PolygonGasStation({ chainId: chainId });
62
- _a.label = 1;
63
- case 1:
64
- _a.trys.push([1, 3, , 5]);
65
- return [4, gasStation.getFeeData()];
66
- case 2: return [2, _a.sent()];
67
- case 3:
68
- err_1 = _a.sent();
69
- return [4, (0, ethereum_1.eip1559)(provider, chainId)];
70
- case 4: return [2, _a.sent()];
71
- case 5: return [2];
72
- }
73
- });
74
- });
57
+ function gasStation(provider, chainId) {
58
+ var gasStation = new PolygonGasStation({ chainId: chainId });
59
+ try {
60
+ return gasStation.getFeeData();
61
+ }
62
+ catch (err) {
63
+ return (0, ethereum_1.eip1559)(provider, chainId);
64
+ }
75
65
  }
76
- exports.polygonGasStation = polygonGasStation;
66
+ exports.gasStation = gasStation;
77
67
  //# sourceMappingURL=polygon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon.ts"],"names":[],"mappings":";;;;AAAA,iCAAyD;AACzD,sEAA8F;AAC9F,qDAAmD;AAEnD,gCAAwC;AACxC,uCAAqC;AAuBrC;IAAgC,6CAAe;IAG7C,2BAAY,EAAyE;QAArF,iBAKC;YALW,qBAAuE,EAAE,KAAA,EAAvE,eAAa,EAAb,OAAO,mBAAG,GAAG,KAAA,EAAE,IAAI,UAAA,EAAE,eAAc,EAAd,OAAO,mBAAG,IAAI,KAAA,EAAE,eAAW,EAAX,OAAO,mBAAG,CAAC,KAAA;QAC5D,IAAI,GAAG,CAAA,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,OAAO,KAAK,GAAG,EAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,uCAAuC,CAAC;gBAE3G,kBAAM,qBAAqB,EAAE,IAAI,EAAE,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC;QACxD,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;IACzB,CAAC;IAEK,sCAAU,GAAhB,UAAiB,QAAkD;QAAlD,yBAAA,EAAA,iBAAkD;;;;;;4BACrD,WAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EA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,UAAC,KAAK,IAAK,OAAA,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,EAA3C,CAA2C,CAAC,CAAC;IACpH,CAAC;IACH,wBAAC;AAAD,CAAC,AAtCD,CAAgC,6BAAe,GAsC9C;AAED,SAAgB,UAAU,CAAC,QAA4B,EAAE,OAAe;IACtE,IAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,IAAI;QACF,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC;KAChC;IAAC,OAAO,GAAG,EAAE;QAEZ,OAAO,IAAA,kBAAO,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACnC;AACH,CAAC;AARD,gCAQC"}
@@ -2,41 +2,45 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGasPriceEstimate = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var adapters_1 = require("./adapters");
5
+ var constants_1 = require("../constants");
6
+ var utils_1 = require("../utils");
7
+ var arbitrum = tslib_1.__importStar(require("./adapters/arbitrum"));
8
+ var ethereum = tslib_1.__importStar(require("./adapters/ethereum"));
9
+ var linea = tslib_1.__importStar(require("./adapters/linea"));
10
+ var polygon = tslib_1.__importStar(require("./adapters/polygon"));
6
11
  function getGasPriceEstimate(provider, chainId, legacyFallback) {
7
12
  if (legacyFallback === void 0) { legacyFallback = true; }
8
13
  return tslib_1.__awaiter(this, void 0, void 0, function () {
9
- var network, gasPriceFeeds, gasPriceFeed, gasPriceEstimate;
10
- return tslib_1.__generator(this, function (_a) {
11
- switch (_a.label) {
14
+ var gasPriceFeeds, gasPriceFeed;
15
+ var _a;
16
+ return tslib_1.__generator(this, function (_b) {
17
+ switch (_b.label) {
12
18
  case 0:
13
- if (!!chainId) return [3, 2];
19
+ if (!(chainId === undefined)) return [3, 2];
14
20
  return [4, provider.getNetwork()];
15
21
  case 1:
16
- network = _a.sent();
17
- chainId = network.chainId;
18
- _a.label = 2;
22
+ (chainId = (_b.sent()).chainId);
23
+ _b.label = 2;
19
24
  case 2:
20
- gasPriceFeeds = {
21
- 1: adapters_1.eip1559,
22
- 10: adapters_1.eip1559,
23
- 137: adapters_1.polygonGasStation,
24
- 288: adapters_1.legacy,
25
- 324: adapters_1.legacy,
26
- 8453: adapters_1.eip1559,
27
- 42161: adapters_1.eip1559_arbitrum,
28
- };
25
+ gasPriceFeeds = (_a = {},
26
+ _a[constants_1.CHAIN_IDs.ARBITRUM] = arbitrum.eip1559,
27
+ _a[constants_1.CHAIN_IDs.BASE] = ethereum.eip1559,
28
+ _a[constants_1.CHAIN_IDs.BOBA] = ethereum.legacy,
29
+ _a[constants_1.CHAIN_IDs.LINEA] = linea.eip1559,
30
+ _a[constants_1.CHAIN_IDs.MAINNET] = ethereum.eip1559,
31
+ _a[constants_1.CHAIN_IDs.MODE] = ethereum.eip1559,
32
+ _a[constants_1.CHAIN_IDs.OPTIMISM] = ethereum.eip1559,
33
+ _a[constants_1.CHAIN_IDs.POLYGON] = polygon.gasStation,
34
+ _a[constants_1.CHAIN_IDs.ZK_SYNC] = ethereum.legacy,
35
+ _a);
29
36
  gasPriceFeed = gasPriceFeeds[chainId];
30
37
  if (gasPriceFeed === undefined) {
31
38
  if (!legacyFallback) {
32
39
  throw new Error("No suitable gas price oracle for Chain ID ".concat(chainId));
33
40
  }
34
- gasPriceFeed = adapters_1.legacy;
41
+ gasPriceFeed = (0, utils_1.chainIsOPStack)(chainId) ? ethereum.eip1559 : ethereum.legacy;
35
42
  }
36
- return [4, gasPriceFeed(provider, chainId)];
37
- case 3:
38
- gasPriceEstimate = _a.sent();
39
- return [2, gasPriceEstimate];
43
+ return [2, gasPriceFeed(provider, chainId)];
40
44
  }
41
45
  });
42
46
  });
@@ -1 +1 @@
1
- {"version":3,"file":"oracle.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":";;;;AACA,uCAAkF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GAAK,CAAA,SAA2B,CAAA,QAAhC,CAAiC,CAAC;;;oBAGxC,aAAa;wBACjB,GAAC,qBAAS,CAAC,QAAQ,IAAG,QAAQ,CAAC,OAAO;wBACtC,GAAC,qBAAS,CAAC,IAAI,IAAG,QAAQ,CAAC,OAAO;wBAClC,GAAC,qBAAS,CAAC,IAAI,IAAG,QAAQ,CAAC,MAAM;wBACjC,GAAC,qBAAS,CAAC,KAAK,IAAG,KAAK,CAAC,OAAO;wBAChC,GAAC,qBAAS,CAAC,OAAO,IAAG,QAAQ,CAAC,OAAO;wBACrC,GAAC,qBAAS,CAAC,IAAI,IAAG,QAAQ,CAAC,OAAO;wBAClC,GAAC,qBAAS,CAAC,QAAQ,IAAG,QAAQ,CAAC,OAAO;wBACtC,GAAC,qBAAS,CAAC,OAAO,IAAG,OAAO,CAAC,UAAU;wBACvC,GAAC,qBAAS,CAAC,OAAO,IAAG,QAAQ,CAAC,MAAM;2BACrC,CAAC;oBAEE,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;oBAC1C,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,IAAI,CAAC,cAAc,EAAE;4BACnB,MAAM,IAAI,KAAK,CAAC,oDAA6C,OAAO,CAAE,CAAC,CAAC;yBACzE;wBACD,YAAY,GAAG,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;qBAC7E;oBAED,WAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAC;;;;CACxC;AA9BD,kDA8BC"}
@@ -1,3 +1,3 @@
1
1
  import { providers } from "ethers";
2
2
  import { GasPriceEstimate } from "../types";
3
- export declare function eip1559_arbitrum(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
3
+ export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
@@ -1,23 +1,25 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
- import { ethers, utils as ethersUtils } from "ethers";
3
- import { eip1559 } from "./ethereum";
2
+ import { utils as ethersUtils } from "ethers";
3
+ import { bnOne } from "../../utils";
4
+ import * as ethereum from "./ethereum";
5
+ var DEFAULT_PRIORITY_FEE = ethersUtils.parseUnits("1.5", 9);
4
6
  // Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller. Further,
5
7
  // ethers typically hardcodes the priority fee to 1.5 Gwei. So, confirm that the priority fee supplied was 1.5
6
8
  // Gwei, and then drop it to 1 Wei. Reference: https://developer.arbitrum.io/faqs/gas-faqs#q-priority
7
- export function eip1559_arbitrum(provider, chainId) {
9
+ export function eip1559(provider, chainId) {
8
10
  return __awaiter(this, void 0, void 0, function () {
9
11
  var _a, _maxFeePerGas, maxPriorityFeePerGas, maxFeePerGas;
10
12
  return __generator(this, function (_b) {
11
13
  switch (_b.label) {
12
- case 0: return [4 /*yield*/, eip1559(provider, chainId)];
14
+ case 0: return [4 /*yield*/, ethereum.eip1559(provider, chainId)];
13
15
  case 1:
14
16
  _a = _b.sent(), _maxFeePerGas = _a.maxFeePerGas, maxPriorityFeePerGas = _a.maxPriorityFeePerGas;
15
17
  // If this throws, ethers default behaviour has changed, or Arbitrum RPCs are returning something more sensible.
16
- if (!maxPriorityFeePerGas.eq(ethersUtils.parseUnits("1.5", 9))) {
18
+ if (!maxPriorityFeePerGas.eq(DEFAULT_PRIORITY_FEE)) {
17
19
  throw new Error("Expected hardcoded 1.5 Gwei priority fee on Arbitrum, got ".concat(maxPriorityFeePerGas));
18
20
  }
19
- maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(1);
20
- return [2 /*return*/, { maxPriorityFeePerGas: ethers.constants.One, maxFeePerGas: maxFeePerGas }];
21
+ maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(bnOne);
22
+ return [2 /*return*/, { maxPriorityFeePerGas: bnOne, maxFeePerGas: maxFeePerGas }];
21
23
  }
22
24
  });
23
25
  });
@@ -1 +1 @@
1
- {"version":3,"file":"arbitrum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAa,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,8GAA8G;AAC9G,8GAA8G;AAC9G,qGAAqG;AACrG,MAAM,UAAgB,gBAAgB,CAAC,QAA4B,EAAE,OAAe;;;;;wBACpB,qBAAM,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAA;;oBAAxF,KAAwD,SAAgC,EAAxE,aAAa,kBAAA,EAAE,oBAAoB,0BAAA;oBAEzD,gHAAgH;oBAChH,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;wBAC9D,MAAM,IAAI,KAAK,CAAC,oEAA6D,oBAAoB,CAAE,CAAC,CAAC;qBACtG;oBAIK,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAEpE,sBAAO,EAAE,oBAAoB,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CACrE"}
1
+ {"version":3,"file":"arbitrum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum.ts"],"names":[],"mappings":";AAAA,OAAO,EAAa,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAEvC,IAAM,oBAAoB,GAAG,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AAE9D,8GAA8G;AAC9G,8GAA8G;AAC9G,qGAAqG;AACrG,MAAM,UAAgB,OAAO,CAAC,QAA4B,EAAE,OAAe;;;;;wBACX,qBAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAA;;oBAAjG,KAAwD,SAAyC,EAAjF,aAAa,kBAAA,EAAE,oBAAoB,0BAAA;oBAEzD,gHAAgH;oBAChH,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,oBAAoB,CAAC,EAAE;wBAClD,MAAM,IAAI,KAAK,CAAC,oEAA6D,oBAAoB,CAAE,CAAC,CAAC;qBACtG;oBAIK,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBAExE,sBAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CACtD"}
@@ -1,5 +1,6 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
- import { BigNumber, ethers } from "ethers";
2
+ import { BigNumber } from "ethers";
3
+ import { bnZero } from "../../utils";
3
4
  import { gasPriceError } from "../util";
4
5
  export function eip1559(provider, chainId) {
5
6
  return __awaiter(this, void 0, void 0, function () {
@@ -10,7 +11,7 @@ export function eip1559(provider, chainId) {
10
11
  case 1:
11
12
  feeData = _a.sent();
12
13
  [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach(function (field) {
13
- if (!BigNumber.isBigNumber(field) || field.lt(0))
14
+ if (!BigNumber.isBigNumber(field) || field.lt(bnZero))
14
15
  gasPriceError("getFeeData()", chainId, feeData);
15
16
  });
16
17
  maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
@@ -28,11 +29,11 @@ export function legacy(provider, chainId) {
28
29
  case 0: return [4 /*yield*/, provider.getGasPrice()];
29
30
  case 1:
30
31
  gasPrice = _a.sent();
31
- if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(0))
32
+ if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(bnZero))
32
33
  gasPriceError("getGasPrice()", chainId, gasPrice);
33
34
  return [2 /*return*/, {
34
35
  maxFeePerGas: gasPrice,
35
- maxPriorityFeePerGas: ethers.constants.Zero,
36
+ maxPriorityFeePerGas: bnZero,
36
37
  }];
37
38
  }
38
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,UAAgB,OAAO,CAAC,QAA4B,EAAE,OAAe;;;;;wBACzD,qBAAM,QAAQ,CAAC,UAAU,EAAE,EAAA;;oBAArC,OAAO,GAAG,SAA2B;oBAE3C,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,UAAC,KAAuB;wBACxF,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;4BAAE,aAAa,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;oBACpG,CAAC,CAAC,CAAC;oBAEG,oBAAoB,GAAG,OAAO,CAAC,oBAAiC,CAAC;oBACjE,YAAY,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,iBAA8B,CAAC,CAAC;oBAEtF,sBAAO,EAAE,oBAAoB,sBAAA,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CAC/C;AAED,MAAM,UAAgB,MAAM,CAAC,QAA4B,EAAE,OAAe;;;;;wBAC5C,qBAAM,QAAQ,CAAC,WAAW,EAAE,EAAA;;oBAAlD,QAAQ,GAAc,SAA4B;oBAExD,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;wBAAE,aAAa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CAAC,MAAM,CAAC;wBAAE,aAAa,CAAC,eAAe,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAE/G,sBAAO;4BACL,YAAY,EAAE,QAAQ;4BACtB,oBAAoB,EAAE,MAAM;yBAC7B,EAAC;;;;CACH"}
@@ -0,0 +1,3 @@
1
+ import { providers } from "ethers";
2
+ import { GasPriceEstimate } from "../types";
3
+ export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
@@ -0,0 +1,5 @@
1
+ import * as ethereum from "./ethereum";
2
+ export function eip1559(provider, chainId) {
3
+ return ethereum.legacy(provider, chainId);
4
+ }
5
+ //# sourceMappingURL=linea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linea.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAEvC,MAAM,UAAU,OAAO,CAAC,QAA4B,EAAE,OAAe;IACnE,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { providers } from "ethers";
2
2
  import { GasPriceEstimate } from "../types";
3
- export declare function polygonGasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
3
+ export declare function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
@@ -1,17 +1,19 @@
1
1
  import { __awaiter, __extends, __generator } from "tslib";
2
2
  import { utils as ethersUtils } from "ethers";
3
3
  import { BaseHTTPAdapter } from "../../priceClient/adapters/baseAdapter";
4
- import { isDefined } from "../../utils/TypeGuards";
4
+ import { bnZero, isDefined } from "../../utils";
5
+ import { CHAIN_IDs } from "../../constants";
5
6
  import { gasPriceError } from "../util";
6
7
  import { eip1559 } from "./ethereum";
8
+ var POLYGON = CHAIN_IDs.POLYGON;
7
9
  // @dev toBNWei() is not imported from ../utils because of a circular dependency loop.
8
10
  // The fix is probably to relocate the function estimateTotalGasRequiredByUnsignedTransaction().
9
11
  var PolygonGasStation = /** @class */ (function (_super) {
10
12
  __extends(PolygonGasStation, _super);
11
13
  function PolygonGasStation(_a) {
12
14
  var _this = this;
13
- var _b = _a === void 0 ? {} : _a, _c = _b.chainId, chainId = _c === void 0 ? 137 : _c, host = _b.host, _d = _b.timeout, timeout = _d === void 0 ? 1500 : _d, _e = _b.retries, retries = _e === void 0 ? 1 : _e;
14
- host = (host !== null && host !== void 0 ? host : chainId === 137) ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
15
+ var _b = _a === void 0 ? {} : _a, _c = _b.chainId, chainId = _c === void 0 ? POLYGON : _c, host = _b.host, _d = _b.timeout, timeout = _d === void 0 ? 1500 : _d, _e = _b.retries, retries = _e === void 0 ? 1 : _e;
16
+ host = (host !== null && host !== void 0 ? host : chainId === POLYGON) ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
15
17
  _this = _super.call(this, "Polygon Gas Station", host, { timeout: timeout, retries: retries }) || this;
16
18
  _this.chainId = chainId;
17
19
  return _this;
@@ -29,7 +31,7 @@ var PolygonGasStation = /** @class */ (function (_super) {
29
31
  gasPrice = gas === null || gas === void 0 ? void 0 : gas[strategy];
30
32
  if (!this.isPolygon1559GasPrice(gasPrice)) {
31
33
  // @todo: generalise gasPriceError() to accept a reason/cause?
32
- gasPriceError("getFeeData()", this.chainId, ethersUtils.parseUnits("0"));
34
+ gasPriceError("getFeeData()", this.chainId, bnZero);
33
35
  }
34
36
  [gasPrice.maxFee, gasPrice.maxPriorityFee].forEach(function (gasPrice) {
35
37
  if (Number(gasPrice) < 0) {
@@ -52,27 +54,14 @@ var PolygonGasStation = /** @class */ (function (_super) {
52
54
  };
53
55
  return PolygonGasStation;
54
56
  }(BaseHTTPAdapter));
55
- export function polygonGasStation(provider, chainId) {
56
- return __awaiter(this, void 0, void 0, function () {
57
- var gasStation, err_1;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0:
61
- gasStation = new PolygonGasStation({ chainId: chainId });
62
- _a.label = 1;
63
- case 1:
64
- _a.trys.push([1, 3, , 5]);
65
- return [4 /*yield*/, gasStation.getFeeData()];
66
- case 2: return [2 /*return*/, _a.sent()];
67
- case 3:
68
- err_1 = _a.sent();
69
- return [4 /*yield*/, eip1559(provider, chainId)];
70
- case 4:
71
- // Fall back to the RPC provider. May be less accurate.
72
- return [2 /*return*/, _a.sent()];
73
- case 5: return [2 /*return*/];
74
- }
75
- });
76
- });
57
+ export function gasStation(provider, chainId) {
58
+ var gasStation = new PolygonGasStation({ chainId: chainId });
59
+ try {
60
+ return gasStation.getFeeData();
61
+ }
62
+ catch (err) {
63
+ // Fall back to the RPC provider. May be less accurate.
64
+ return eip1559(provider, chainId);
65
+ }
77
66
  }
78
67
  //# sourceMappingURL=polygon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon.ts"],"names":[],"mappings":";AAAA,OAAO,EAAa,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAqBrC,sFAAsF;AACtF,qGAAqG;AACrG;IAAgC,qCAAe;IAG7C,2BAAY,EAAyE;QAArF,iBAKC;YALW,qBAAuE,EAAE,KAAA,EAAvE,eAAa,EAAb,OAAO,mBAAG,GAAG,KAAA,EAAE,IAAI,UAAA,EAAE,eAAc,EAAd,OAAO,mBAAG,IAAI,KAAA,EAAE,eAAW,EAAX,OAAO,mBAAG,CAAC,KAAA;QAC5D,IAAI,GAAG,CAAA,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,OAAO,KAAK,GAAG,EAA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C,CAAC,CAAC,CAAC;6BAC7F;wBACH,CAAC,CAAC,CAAC;wBAEG,oBAAoB,GAAG,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;wBACrF,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;wBAE3E,sBAAO,EAAE,oBAAoB,sBAAA,EAAE,YAAY,cAAA,EAAE,EAAC;;;;KAC/C;IAES,iDAAqB,GAA/B,UAAgC,QAAiB;QAC/C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QACD,IAAM,SAAS,GAAG,QAA+B,CAAC;QAClD,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,UAAC,KAAK,IAAK,OAAA,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,EAA3C,CAA2C,CAAC,CAAC;IACpH,CAAC;IACH,wBAAC;AAAD,CAAC,AAtCD,CAAgC,eAAe,GAsC9C;AAED,MAAM,UAAU,UAAU,CAAC,QAA4B,EAAE,OAAe;IACtE,IAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,IAAI;QACF,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC;KAChC;IAAC,OAAO,GAAG,EAAE;QACZ,uDAAuD;QACvD,OAAO,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACnC;AACH,CAAC"}
@@ -1,5 +1,10 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
- import { eip1559, eip1559_arbitrum, legacy, polygonGasStation } from "./adapters";
2
+ import { CHAIN_IDs } from "../constants";
3
+ import { chainIsOPStack } from "../utils";
4
+ import * as arbitrum from "./adapters/arbitrum";
5
+ import * as ethereum from "./adapters/ethereum";
6
+ import * as linea from "./adapters/linea";
7
+ import * as polygon from "./adapters/polygon";
3
8
  /**
4
9
  * Provide an estimate for the current gas price for a particular chain.
5
10
  * @param chainId The chain ID to query for gas prices.
@@ -10,37 +15,36 @@ import { eip1559, eip1559_arbitrum, legacy, polygonGasStation } from "./adapters
10
15
  export function getGasPriceEstimate(provider, chainId, legacyFallback) {
11
16
  if (legacyFallback === void 0) { legacyFallback = true; }
12
17
  return __awaiter(this, void 0, void 0, function () {
13
- var network, gasPriceFeeds, gasPriceFeed, gasPriceEstimate;
14
- return __generator(this, function (_a) {
15
- switch (_a.label) {
18
+ var gasPriceFeeds, gasPriceFeed;
19
+ var _a;
20
+ return __generator(this, function (_b) {
21
+ switch (_b.label) {
16
22
  case 0:
17
- if (!!chainId) return [3 /*break*/, 2];
23
+ if (!(chainId === undefined)) return [3 /*break*/, 2];
18
24
  return [4 /*yield*/, provider.getNetwork()];
19
25
  case 1:
20
- network = _a.sent();
21
- chainId = network.chainId;
22
- _a.label = 2;
26
+ (chainId = (_b.sent()).chainId);
27
+ _b.label = 2;
23
28
  case 2:
24
- gasPriceFeeds = {
25
- 1: eip1559,
26
- 10: eip1559,
27
- 137: polygonGasStation,
28
- 288: legacy,
29
- 324: legacy,
30
- 8453: eip1559,
31
- 42161: eip1559_arbitrum,
32
- };
29
+ gasPriceFeeds = (_a = {},
30
+ _a[CHAIN_IDs.ARBITRUM] = arbitrum.eip1559,
31
+ _a[CHAIN_IDs.BASE] = ethereum.eip1559,
32
+ _a[CHAIN_IDs.BOBA] = ethereum.legacy,
33
+ _a[CHAIN_IDs.LINEA] = linea.eip1559,
34
+ _a[CHAIN_IDs.MAINNET] = ethereum.eip1559,
35
+ _a[CHAIN_IDs.MODE] = ethereum.eip1559,
36
+ _a[CHAIN_IDs.OPTIMISM] = ethereum.eip1559,
37
+ _a[CHAIN_IDs.POLYGON] = polygon.gasStation,
38
+ _a[CHAIN_IDs.ZK_SYNC] = ethereum.legacy,
39
+ _a);
33
40
  gasPriceFeed = gasPriceFeeds[chainId];
34
41
  if (gasPriceFeed === undefined) {
35
42
  if (!legacyFallback) {
36
43
  throw new Error("No suitable gas price oracle for Chain ID ".concat(chainId));
37
44
  }
38
- gasPriceFeed = legacy;
45
+ gasPriceFeed = chainIsOPStack(chainId) ? ethereum.eip1559 : ethereum.legacy;
39
46
  }
40
- return [4 /*yield*/, gasPriceFeed(provider, chainId)];
41
- case 3:
42
- gasPriceEstimate = _a.sent();
43
- return [2 /*return*/, gasPriceEstimate];
47
+ return [2 /*return*/, gasPriceFeed(provider, chainId)];
44
48
  }
45
49
  });
46
50
  });
@@ -1 +1 @@
1
- {"version":3,"file":"oracle.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGlF;;;;;;GAMG;AACH,MAAM,UAAgB,mBAAmB,CACvC,QAA4B,EAC5B,OAAgB,EAChB,cAAqB;IAArB,+BAAA,EAAA,qBAAqB;;;;;;yBAEjB,CAAC,OAAO,EAAR,wBAAQ;oBACyB,qBAAM,QAAQ,CAAC,UAAU,EAAE,EAAA;;oBAAxD,OAAO,GAAsB,SAA2B;oBAC9D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;;;oBAGtB,aAAa,GAAwC;wBACzD,CAAC,EAAE,OAAO;wBACV,EAAE,EAAE,OAAO;wBACX,GAAG,EAAE,iBAAiB;wBACtB,GAAG,EAAE,MAAM;wBACX,GAAG,EAAE,MAAM;wBACX,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,gBAAgB;qBACxB,CAAC;oBAEE,YAAY,GAAiB,aAAa,CAAC,OAAO,CAAC,CAAC;oBACxD,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,IAAI,CAAC,cAAc,EAAE;4BACnB,MAA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AClC,GAAC,SAAS,CAAC,QAAQ,IAAG,QAAQ,CAAC,OAAO;wBACtC,GAAC,SAAS,CAAC,OAAO,IAAG,OAAO,CAAC,UAAU;wBACvC,GAAC,SAAS,CAAC,OAAO,IAAG,QAAQ,CAAC,MAAM;2BACrC,CAAC;oBAEE,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;oBAC1C,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,IAAI,CAAC,cAAc,EAAE;4BACnB,MAAM,IAAI,KAAK,CAAC,oDAA6C,OAAO,CAAE,CAAC,CAAC;yBACzE;wBACD,YAAY,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;qBAC7E;oBAED,sBAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAC;;;;CACxC"}
@@ -1,4 +1,4 @@
1
1
  import { providers } from "ethers";
2
2
  import { GasPriceEstimate } from "../types";
3
- export declare function eip1559_arbitrum(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
3
+ export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
4
4
  //# sourceMappingURL=arbitrum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arbitrum.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAwB,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAM5C,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAa/G"}
1
+ {"version":3,"file":"arbitrum.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,QAAQ,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAQ5C,wBAAsB,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAatG"}
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAU,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,wBAAsB,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWtG;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CASrG"}
1
+ {"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,wBAAsB,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWtG;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CASrG"}
@@ -0,0 +1,4 @@
1
+ import { providers } from "ethers";
2
+ import { GasPriceEstimate } from "../types";
3
+ export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
4
+ //# sourceMappingURL=linea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linea.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEhG"}
@@ -1,4 +1,4 @@
1
1
  import { providers } from "ethers";
2
2
  import { GasPriceEstimate } from "../types";
3
- export declare function polygonGasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
3
+ export declare function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
4
4
  //# sourceMappingURL=polygon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,QAAQ,CAAC;AAGzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAiE5C,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAQhH"}
1
+ {"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,QAAQ,CAAC;AAIzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAmE5C,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAQnG"}
@@ -1 +1 @@
1
- {"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAgB,MAAM,SAAS,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,UAAO,GACpB,OAAO,CAAC,gBAAgB,CAAC,CA0B3B"}
1
+ {"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,OAAO,EAAE,gBAAgB,EAAgB,MAAM,SAAS,CAAC;AAMzD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,UAAO,GACpB,OAAO,CAAC,gBAAgB,CAAC,CA0B3B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "3.1.3",
4
+ "version": "3.1.5",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -99,7 +99,7 @@
99
99
  },
100
100
  "dependencies": {
101
101
  "@across-protocol/across-token": "^1.0.0",
102
- "@across-protocol/constants": "^3.1.1",
102
+ "@across-protocol/constants": "^3.1.2",
103
103
  "@across-protocol/contracts": "^3.0.1",
104
104
  "@eth-optimism/sdk": "^3.3.1",
105
105
  "@pinata/sdk": "^2.1.0",
@@ -1,21 +1,24 @@
1
- import { ethers, providers, utils as ethersUtils } from "ethers";
1
+ import { providers, utils as ethersUtils } from "ethers";
2
+ import { bnOne } from "../../utils";
2
3
  import { GasPriceEstimate } from "../types";
3
- import { eip1559 } from "./ethereum";
4
+ import * as ethereum from "./ethereum";
5
+
6
+ const DEFAULT_PRIORITY_FEE = ethersUtils.parseUnits("1.5", 9);
4
7
 
5
8
  // Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller. Further,
6
9
  // ethers typically hardcodes the priority fee to 1.5 Gwei. So, confirm that the priority fee supplied was 1.5
7
10
  // Gwei, and then drop it to 1 Wei. Reference: https://developer.arbitrum.io/faqs/gas-faqs#q-priority
8
- export async function eip1559_arbitrum(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
9
- const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await eip1559(provider, chainId);
11
+ export async function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
12
+ const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await ethereum.eip1559(provider, chainId);
10
13
 
11
14
  // If this throws, ethers default behaviour has changed, or Arbitrum RPCs are returning something more sensible.
12
- if (!maxPriorityFeePerGas.eq(ethersUtils.parseUnits("1.5", 9))) {
15
+ if (!maxPriorityFeePerGas.eq(DEFAULT_PRIORITY_FEE)) {
13
16
  throw new Error(`Expected hardcoded 1.5 Gwei priority fee on Arbitrum, got ${maxPriorityFeePerGas}`);
14
17
  }
15
18
 
16
19
  // eip1559() sets maxFeePerGas = lastBaseFeePerGas + maxPriorityFeePerGas, so revert that.
17
20
  // The caller may apply scaling as they wish afterwards.
18
- const maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(1);
21
+ const maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(bnOne);
19
22
 
20
- return { maxPriorityFeePerGas: ethers.constants.One, maxFeePerGas };
23
+ return { maxPriorityFeePerGas: bnOne, maxFeePerGas };
21
24
  }
@@ -1,4 +1,5 @@
1
- import { BigNumber, providers, ethers } from "ethers";
1
+ import { BigNumber, providers } from "ethers";
2
+ import { bnZero } from "../../utils";
2
3
  import { GasPriceEstimate } from "../types";
3
4
  import { gasPriceError } from "../util";
4
5
 
@@ -6,7 +7,7 @@ export async function eip1559(provider: providers.Provider, chainId: number): Pr
6
7
  const feeData = await provider.getFeeData();
7
8
 
8
9
  [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach((field: BigNumber | null) => {
9
- if (!BigNumber.isBigNumber(field) || field.lt(0)) gasPriceError("getFeeData()", chainId, feeData);
10
+ if (!BigNumber.isBigNumber(field) || field.lt(bnZero)) gasPriceError("getFeeData()", chainId, feeData);
10
11
  });
11
12
 
12
13
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas as BigNumber;
@@ -16,12 +17,12 @@ export async function eip1559(provider: providers.Provider, chainId: number): Pr
16
17
  }
17
18
 
18
19
  export async function legacy(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
19
- const gasPrice: BigNumber = await provider.getGasPrice();
20
+ const gasPrice = await provider.getGasPrice();
20
21
 
21
- if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(0)) gasPriceError("getGasPrice()", chainId, gasPrice);
22
+ if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(bnZero)) gasPriceError("getGasPrice()", chainId, gasPrice);
22
23
 
23
24
  return {
24
25
  maxFeePerGas: gasPrice,
25
- maxPriorityFeePerGas: ethers.constants.Zero,
26
+ maxPriorityFeePerGas: bnZero,
26
27
  };
27
28
  }
@@ -0,0 +1,11 @@
1
+ // Linea recommend using the custom linea_estimateGas() RPC query.
2
+ // This query is currently only available on Linea Sepolia, ETA mainnet 30 July.
3
+ // Until then, just parrot the existing Ethereum EIP-1559 pricing strategy.
4
+ // See also: https://docs.linea.build/developers/reference/api/linea-estimategas
5
+ import { providers } from "ethers";
6
+ import { GasPriceEstimate } from "../types";
7
+ import * as ethereum from "./ethereum";
8
+
9
+ export function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
10
+ return ethereum.legacy(provider, chainId);
11
+ }
@@ -1,6 +1,7 @@
1
1
  import { providers, utils as ethersUtils } from "ethers";
2
2
  import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "../../priceClient/adapters/baseAdapter";
3
- import { isDefined } from "../../utils/TypeGuards";
3
+ import { bnZero, isDefined } from "../../utils";
4
+ import { CHAIN_IDs } from "../../constants";
4
5
  import { GasPriceEstimate } from "../types";
5
6
  import { gasPriceError } from "../util";
6
7
  import { eip1559 } from "./ethereum";
@@ -24,13 +25,15 @@ type GasStationArgs = BaseHTTPAdapterArgs & {
24
25
  host?: string;
25
26
  };
26
27
 
28
+ const { POLYGON } = CHAIN_IDs;
29
+
27
30
  // @dev toBNWei() is not imported from ../utils because of a circular dependency loop.
28
31
  // The fix is probably to relocate the function estimateTotalGasRequiredByUnsignedTransaction().
29
32
  class PolygonGasStation extends BaseHTTPAdapter {
30
33
  readonly chainId: number;
31
34
 
32
- constructor({ chainId = 137, host, timeout = 1500, retries = 1 }: GasStationArgs = {}) {
33
- host = host ?? chainId === 137 ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
35
+ constructor({ chainId = POLYGON, host, timeout = 1500, retries = 1 }: GasStationArgs = {}) {
36
+ host = host ?? chainId === POLYGON ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
34
37
 
35
38
  super("Polygon Gas Station", host, { timeout, retries });
36
39
  this.chainId = chainId;
@@ -42,7 +45,7 @@ class PolygonGasStation extends BaseHTTPAdapter {
42
45
  const gasPrice: Polygon1559GasPrice = (gas as GasStationV2Response)?.[strategy];
43
46
  if (!this.isPolygon1559GasPrice(gasPrice)) {
44
47
  // @todo: generalise gasPriceError() to accept a reason/cause?
45
- gasPriceError("getFeeData()", this.chainId, ethersUtils.parseUnits("0"));
48
+ gasPriceError("getFeeData()", this.chainId, bnZero);
46
49
  }
47
50
 
48
51
  [gasPrice.maxFee, gasPrice.maxPriorityFee].forEach((gasPrice) => {
@@ -66,12 +69,12 @@ class PolygonGasStation extends BaseHTTPAdapter {
66
69
  }
67
70
  }
68
71
 
69
- export async function polygonGasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
72
+ export function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
70
73
  const gasStation = new PolygonGasStation({ chainId: chainId });
71
74
  try {
72
- return await gasStation.getFeeData();
75
+ return gasStation.getFeeData();
73
76
  } catch (err) {
74
77
  // Fall back to the RPC provider. May be less accurate.
75
- return await eip1559(provider, chainId);
78
+ return eip1559(provider, chainId);
76
79
  }
77
80
  }
@@ -1,6 +1,11 @@
1
1
  import { providers } from "ethers";
2
- import { eip1559, eip1559_arbitrum, legacy, polygonGasStation } from "./adapters";
2
+ import { CHAIN_IDs } from "../constants";
3
+ import { chainIsOPStack } from "../utils";
3
4
  import { GasPriceEstimate, GasPriceFeed } from "./types";
5
+ import * as arbitrum from "./adapters/arbitrum";
6
+ import * as ethereum from "./adapters/ethereum";
7
+ import * as linea from "./adapters/linea";
8
+ import * as polygon from "./adapters/polygon";
4
9
 
5
10
  /**
6
11
  * Provide an estimate for the current gas price for a particular chain.
@@ -14,29 +19,29 @@ export async function getGasPriceEstimate(
14
19
  chainId?: number,
15
20
  legacyFallback = true
16
21
  ): Promise<GasPriceEstimate> {
17
- if (!chainId) {
18
- const network: providers.Network = await provider.getNetwork();
19
- chainId = network.chainId;
22
+ if (chainId === undefined) {
23
+ ({ chainId } = await provider.getNetwork());
20
24
  }
21
25
 
22
26
  const gasPriceFeeds: { [chainId: number]: GasPriceFeed } = {
23
- 1: eip1559,
24
- 10: eip1559,
25
- 137: polygonGasStation,
26
- 288: legacy,
27
- 324: legacy,
28
- 8453: eip1559,
29
- 42161: eip1559_arbitrum,
27
+ [CHAIN_IDs.ARBITRUM]: arbitrum.eip1559,
28
+ [CHAIN_IDs.BASE]: ethereum.eip1559,
29
+ [CHAIN_IDs.BOBA]: ethereum.legacy,
30
+ [CHAIN_IDs.LINEA]: linea.eip1559, // @todo: Support linea_estimateGas in adapter.
31
+ [CHAIN_IDs.MAINNET]: ethereum.eip1559,
32
+ [CHAIN_IDs.MODE]: ethereum.eip1559,
33
+ [CHAIN_IDs.OPTIMISM]: ethereum.eip1559,
34
+ [CHAIN_IDs.POLYGON]: polygon.gasStation,
35
+ [CHAIN_IDs.ZK_SYNC]: ethereum.legacy,
30
36
  };
31
37
 
32
- let gasPriceFeed: GasPriceFeed = gasPriceFeeds[chainId];
38
+ let gasPriceFeed = gasPriceFeeds[chainId];
33
39
  if (gasPriceFeed === undefined) {
34
40
  if (!legacyFallback) {
35
41
  throw new Error(`No suitable gas price oracle for Chain ID ${chainId}`);
36
42
  }
37
- gasPriceFeed = legacy;
43
+ gasPriceFeed = chainIsOPStack(chainId) ? ethereum.eip1559 : ethereum.legacy;
38
44
  }
39
45
 
40
- const gasPriceEstimate: GasPriceEstimate = await gasPriceFeed(provider, chainId);
41
- return gasPriceEstimate;
46
+ return gasPriceFeed(provider, chainId);
42
47
  }
@@ -1,3 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./ethereum"), exports);
5
- tslib_1.__exportStar(require("./arbitrum"), exports);
6
- tslib_1.__exportStar(require("./polygon"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,qDAA2B;AAC3B,oDAA0B"}
@@ -1,3 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
@@ -1,4 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";