@across-protocol/sdk 3.3.32 → 3.4.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 (142) hide show
  1. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
  2. package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +2 -1
  3. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +2 -2
  4. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  5. package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +6 -4
  6. package/dist/cjs/gasPriceOracle/adapters/ethereum.js +21 -13
  7. package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
  8. package/dist/cjs/gasPriceOracle/adapters/linea-viem.d.ts +2 -1
  9. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +16 -10
  10. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  11. package/dist/cjs/gasPriceOracle/adapters/linea.d.ts +2 -1
  12. package/dist/cjs/gasPriceOracle/adapters/linea.js +2 -2
  13. package/dist/cjs/gasPriceOracle/adapters/linea.js.map +1 -1
  14. package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +21 -1
  15. package/dist/cjs/gasPriceOracle/adapters/polygon.js +45 -5
  16. package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
  17. package/dist/cjs/gasPriceOracle/oracle.d.ts +11 -3
  18. package/dist/cjs/gasPriceOracle/oracle.js +29 -27
  19. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  20. package/dist/cjs/providers/types.d.ts +3 -3
  21. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
  22. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js +2 -12
  23. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js.map +1 -1
  24. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +10 -5
  25. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +55 -11
  26. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  27. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  28. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +4 -5
  29. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  30. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
  31. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js +2 -12
  32. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js.map +1 -1
  33. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  34. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  35. package/dist/cjs/utils/common.d.ts +1 -8
  36. package/dist/cjs/utils/common.js +1 -83
  37. package/dist/cjs/utils/common.js.map +1 -1
  38. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
  39. package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +10 -1
  40. package/dist/esm/gasPriceOracle/adapters/arbitrum.js +10 -4
  41. package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  42. package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +19 -6
  43. package/dist/esm/gasPriceOracle/adapters/ethereum.js +38 -16
  44. package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
  45. package/dist/esm/gasPriceOracle/adapters/linea-viem.d.ts +19 -1
  46. package/dist/esm/gasPriceOracle/adapters/linea-viem.js +33 -10
  47. package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  48. package/dist/esm/gasPriceOracle/adapters/linea.d.ts +2 -1
  49. package/dist/esm/gasPriceOracle/adapters/linea.js +6 -2
  50. package/dist/esm/gasPriceOracle/adapters/linea.js.map +1 -1
  51. package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +27 -1
  52. package/dist/esm/gasPriceOracle/adapters/polygon.js +49 -5
  53. package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
  54. package/dist/esm/gasPriceOracle/oracle.d.ts +16 -8
  55. package/dist/esm/gasPriceOracle/oracle.js +35 -33
  56. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  57. package/dist/esm/providers/types.d.ts +3 -3
  58. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
  59. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js +3 -13
  60. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js.map +1 -1
  61. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +21 -7
  62. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +68 -15
  63. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  64. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  65. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +4 -5
  66. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  67. package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
  68. package/dist/esm/relayFeeCalculator/chain-queries/polygon.js +3 -13
  69. package/dist/esm/relayFeeCalculator/chain-queries/polygon.js.map +1 -1
  70. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  71. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  72. package/dist/esm/utils/common.d.ts +1 -19
  73. package/dist/esm/utils/common.js +3 -95
  74. package/dist/esm/utils/common.js.map +1 -1
  75. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
  76. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +10 -1
  77. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
  78. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +19 -6
  79. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
  80. package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts +19 -1
  81. package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts.map +1 -1
  82. package/dist/types/gasPriceOracle/adapters/linea.d.ts +2 -1
  83. package/dist/types/gasPriceOracle/adapters/linea.d.ts.map +1 -1
  84. package/dist/types/gasPriceOracle/adapters/polygon.d.ts +27 -1
  85. package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
  86. package/dist/types/gasPriceOracle/oracle.d.ts +16 -8
  87. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  88. package/dist/types/providers/types.d.ts +3 -3
  89. package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
  90. package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts.map +1 -1
  91. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +21 -7
  92. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  93. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  94. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  95. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
  96. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -1
  97. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  98. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  99. package/dist/types/utils/common.d.ts +1 -19
  100. package/dist/types/utils/common.d.ts.map +1 -1
  101. package/package.json +1 -1
  102. package/src/gasPriceOracle/adapters/arbitrum.ts +13 -6
  103. package/src/gasPriceOracle/adapters/ethereum.ts +43 -12
  104. package/src/gasPriceOracle/adapters/linea-viem.ts +32 -6
  105. package/src/gasPriceOracle/adapters/linea.ts +7 -2
  106. package/src/gasPriceOracle/adapters/polygon.ts +46 -5
  107. package/src/gasPriceOracle/oracle.ts +53 -28
  108. package/src/relayFeeCalculator/chain-queries/alephZero.ts +1 -29
  109. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +73 -20
  110. package/src/relayFeeCalculator/chain-queries/factory.ts +6 -6
  111. package/src/relayFeeCalculator/chain-queries/polygon.ts +1 -29
  112. package/src/relayFeeCalculator/relayFeeCalculator.ts +6 -1
  113. package/src/utils/common.ts +2 -92
  114. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -3
  115. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js +0 -21
  116. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js.map +0 -1
  117. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -4
  118. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js +0 -26
  119. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js.map +0 -1
  120. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.d.ts +0 -3
  121. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js +0 -84
  122. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js.map +0 -1
  123. package/dist/cjs/package.json +0 -1
  124. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -3
  125. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js +0 -20
  126. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js.map +0 -1
  127. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -4
  128. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js +0 -21
  129. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js.map +0 -1
  130. package/dist/esm/gasPriceOracle/adapters/polygon-viem.d.ts +0 -3
  131. package/dist/esm/gasPriceOracle/adapters/polygon-viem.js +0 -82
  132. package/dist/esm/gasPriceOracle/adapters/polygon-viem.js.map +0 -1
  133. package/dist/esm/package.json +0 -1
  134. package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -4
  135. package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts.map +0 -1
  136. package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -5
  137. package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts.map +0 -1
  138. package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts +0 -4
  139. package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts.map +0 -1
  140. package/src/gasPriceOracle/adapters/arbitrum-viem.ts +0 -13
  141. package/src/gasPriceOracle/adapters/ethereum-viem.ts +0 -19
  142. package/src/gasPriceOracle/adapters/polygon-viem.ts +0 -86
@@ -1,25 +1,33 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
2
  import assert from "assert";
3
- import { BigNumber, bnZero, getNetworkName } from "../../utils";
3
+ import { BigNumber, bnZero, fixedPointAdjustment, getNetworkName } from "../../utils";
4
4
  import { gasPriceError } from "../util";
5
+ // TODO: We intend to remove `eip1559Bad()` as an option and make eip1559Raw the only option eventually. The reason
6
+ // they both exist currently is because eip1559Raw is new and untested on production so we will slowly roll it out
7
+ // by using the convenient environment variable safety guard.
5
8
  /**
9
+ * @dev If GAS_PRICE_EIP1559_RAW_${chainId}=true, then constructs total fee by adding
10
+ * eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas, otherwise calls the ethers provider's
11
+ * getFeeData() method which adds eth_getBlock("latest").baseFee to a hardcoded priority fee of 1.5 gwei.
6
12
  * @param provider ethers RPC provider instance.
7
- * @param chainId Chain ID of provider instance.
8
13
  * @returns Promise of gas price estimate object.
9
14
  */
10
- export function eip1559(provider, chainId) {
11
- var useRaw = process.env["GAS_PRICE_EIP1559_RAW_".concat(chainId)] === "true";
12
- return useRaw ? eip1559Raw(provider, chainId) : eip1559Bad(provider, chainId);
15
+ export function eip1559(provider, opts) {
16
+ var useRaw = process.env["GAS_PRICE_EIP1559_RAW_".concat(opts.chainId)] === "true";
17
+ return useRaw
18
+ ? eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier)
19
+ : eip1559Bad(provider, opts.chainId, opts.baseFeeMultiplier);
13
20
  }
14
21
  /**
15
22
  * @note Performs direct RPC calls to retrieve the RPC-suggested priority fee for the next block.
23
+ * @dev Constructs total fee by adding eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas
16
24
  * @param provider ethers RPC provider instance.
17
25
  * @param chainId Chain ID of the provider instance.
18
26
  * @returns Promise of gas price estimate object.
19
27
  */
20
- export function eip1559Raw(provider, chainId) {
28
+ export function eip1559Raw(provider, chainId, baseFeeMultiplier) {
21
29
  return __awaiter(this, void 0, void 0, function () {
22
- var _a, baseFeePerGas, _maxPriorityFeePerGas, maxPriorityFeePerGas;
30
+ var _a, baseFeePerGas, _maxPriorityFeePerGas, maxPriorityFeePerGas, scaledBaseFee;
23
31
  return __generator(this, function (_b) {
24
32
  switch (_b.label) {
25
33
  case 0: return [4 /*yield*/, Promise.all([
@@ -30,8 +38,9 @@ export function eip1559Raw(provider, chainId) {
30
38
  _a = _b.sent(), baseFeePerGas = _a[0].baseFeePerGas, _maxPriorityFeePerGas = _a[1];
31
39
  maxPriorityFeePerGas = BigNumber.from(_maxPriorityFeePerGas);
32
40
  assert(BigNumber.isBigNumber(baseFeePerGas), "No baseFeePerGas received on ".concat(getNetworkName(chainId)));
41
+ scaledBaseFee = baseFeePerGas.mul(baseFeeMultiplier).div(fixedPointAdjustment);
33
42
  return [2 /*return*/, {
34
- maxFeePerGas: maxPriorityFeePerGas.add(baseFeePerGas),
43
+ maxFeePerGas: maxPriorityFeePerGas.add(scaledBaseFee),
35
44
  maxPriorityFeePerGas: maxPriorityFeePerGas,
36
45
  }];
37
46
  }
@@ -39,14 +48,17 @@ export function eip1559Raw(provider, chainId) {
39
48
  });
40
49
  }
41
50
  /**
42
- * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5.
51
+ * @notice Returns fee data using provider's getFeeData() method.
52
+ * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5's
53
+ * getFeeData() method
54
+ * @dev TODO: Remove this function soon. See note above about slowly rolling out eip1559Raw.
43
55
  * @param provider ethers RPC provider instance.
44
56
  * @param chainId Chain ID of the provider instance.
45
57
  * @returns Promise of gas price estimate object.
46
58
  */
47
- export function eip1559Bad(provider, chainId) {
59
+ export function eip1559Bad(provider, chainId, baseFeeMultiplier) {
48
60
  return __awaiter(this, void 0, void 0, function () {
49
- var feeData, maxPriorityFeePerGas, maxFeePerGas;
61
+ var feeData, maxPriorityFeePerGas, scaledLastBaseFeePerGas, maxFeePerGas;
50
62
  return __generator(this, function (_a) {
51
63
  switch (_a.label) {
52
64
  case 0: return [4 /*yield*/, provider.getFeeData()];
@@ -57,24 +69,34 @@ export function eip1559Bad(provider, chainId) {
57
69
  gasPriceError("getFeeData()", chainId, feeData);
58
70
  });
59
71
  maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
60
- maxFeePerGas = maxPriorityFeePerGas.add(feeData.lastBaseFeePerGas);
72
+ scaledLastBaseFeePerGas = feeData.lastBaseFeePerGas
73
+ .mul(baseFeeMultiplier)
74
+ .div(fixedPointAdjustment);
75
+ maxFeePerGas = maxPriorityFeePerGas.add(scaledLastBaseFeePerGas);
61
76
  return [2 /*return*/, { maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas }];
62
77
  }
63
78
  });
64
79
  });
65
80
  }
66
- export function legacy(provider, chainId) {
81
+ /**
82
+ * @notice Returns result of eth_gasPrice RPC call
83
+ * @dev Its recommended to use the eip1559Raw method over this one where possible as it will be more accurate.
84
+ * @returns GasPriceEstimate
85
+ */
86
+ export function legacy(provider, opts) {
67
87
  return __awaiter(this, void 0, void 0, function () {
68
- var gasPrice;
88
+ var chainId, baseFeeMultiplier, gasPrice;
69
89
  return __generator(this, function (_a) {
70
90
  switch (_a.label) {
71
- case 0: return [4 /*yield*/, provider.getGasPrice()];
91
+ case 0:
92
+ chainId = opts.chainId, baseFeeMultiplier = opts.baseFeeMultiplier;
93
+ return [4 /*yield*/, provider.getGasPrice()];
72
94
  case 1:
73
95
  gasPrice = _a.sent();
74
96
  if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(bnZero))
75
97
  gasPriceError("getGasPrice()", chainId, gasPrice);
76
98
  return [2 /*return*/, {
77
- maxFeePerGas: gasPrice,
99
+ maxFeePerGas: gasPrice.mul(baseFeeMultiplier).div(fixedPointAdjustment),
78
100
  maxPriorityFeePerGas: bnZero,
79
101
  }];
80
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,QAA4B,EAAE,OAAe;IACnE,IAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gCAAyB,OAAO,CAAE,CAAC,KAAK,MAAM,CAAC;IAC1E,OAAO,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAgB,UAAU,CAAC,QAA4B,EAAE,OAAe;;;;;wBACzB,qBAAM,OAAO,CAAC,GAAG,CAAC;wBACnE,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;wBAC3B,QAAsC,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,CAAC;qBAC7E,CAAC,EAAA;;oBAHI,KAA6C,SAGjD,EAHO,aAAa,sBAAA,EAAI,qBAAqB,QAAA;oBAIzC,oBAAoB,GAAG,SAAS,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;oBACnE,MAAM,CAAC,SAA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AAC,MAAM,CAAC;wBAAE,aAAa,CAAC,eAAe,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAE/G,sBAAO;4BACL,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC;4BACvE,oBAAoB,EAAE,MAAM;yBAC7B,EAAC;;;;CACH"}
@@ -1,3 +1,21 @@
1
1
  import { PublicClient } from "viem";
2
2
  import { InternalGasPriceEstimate } from "../types";
3
- export declare function eip1559(provider: PublicClient, _chainId?: number): Promise<InternalGasPriceEstimate>;
3
+ import { GasPriceEstimateOptions } from "../oracle";
4
+ /**
5
+ * @notice The Linea viem provider calls the linea_estimateGas RPC endpoint to estimate gas. Linea is unique
6
+ * in that the recommended fee per gas is hardcoded to 7 wei while the priority fee is dynamic based on the
7
+ * compressed transaction size, layer 1 verification costs and capacity, gas price ratio between layer 1 and layer 2,
8
+ * the transaction's gas usage, the minimum gas price on layer 2,
9
+ * and a minimum margin (for error) for gas price estimation.
10
+ * Source: https://docs.linea.build/get-started/how-to/gas-fees#how-gas-works-on-linea
11
+ * @dev Because the Linea priority fee is more volatile than the base fee, the base fee multiplier will be applied
12
+ * to the priority fee.
13
+ * @param provider Viem PublicClient
14
+ * @param _chainId Unused in this adapter
15
+ * @param baseFeeMultiplier Amount to multiply priority fee, since Linea's base fee is hardcoded while its priority
16
+ * fee is dynamic
17
+ * @param _unsignedTx Should contain any params passed to linea_estimateGas, which are listed
18
+ * here: https://docs.linea.build/api/reference/linea-estimategas#parameters
19
+ * @returns
20
+ */
21
+ export declare function eip1559(provider: PublicClient, opts: GasPriceEstimateOptions): Promise<InternalGasPriceEstimate>;
@@ -1,18 +1,41 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
2
  import { estimateGas } from "viem/linea";
3
3
  import { DEFAULT_SIMULATED_RELAYER_ADDRESS as account } from "../../constants";
4
- export function eip1559(provider, _chainId) {
4
+ import { fixedPointAdjustment } from "../../utils";
5
+ /**
6
+ * @notice The Linea viem provider calls the linea_estimateGas RPC endpoint to estimate gas. Linea is unique
7
+ * in that the recommended fee per gas is hardcoded to 7 wei while the priority fee is dynamic based on the
8
+ * compressed transaction size, layer 1 verification costs and capacity, gas price ratio between layer 1 and layer 2,
9
+ * the transaction's gas usage, the minimum gas price on layer 2,
10
+ * and a minimum margin (for error) for gas price estimation.
11
+ * Source: https://docs.linea.build/get-started/how-to/gas-fees#how-gas-works-on-linea
12
+ * @dev Because the Linea priority fee is more volatile than the base fee, the base fee multiplier will be applied
13
+ * to the priority fee.
14
+ * @param provider Viem PublicClient
15
+ * @param _chainId Unused in this adapter
16
+ * @param baseFeeMultiplier Amount to multiply priority fee, since Linea's base fee is hardcoded while its priority
17
+ * fee is dynamic
18
+ * @param _unsignedTx Should contain any params passed to linea_estimateGas, which are listed
19
+ * here: https://docs.linea.build/api/reference/linea-estimategas#parameters
20
+ * @returns
21
+ */
22
+ export function eip1559(provider, opts) {
23
+ var _a, _b, _c, _d, _e;
5
24
  return __awaiter(this, void 0, void 0, function () {
6
- var _a, baseFeePerGas, priorityFeePerGas;
7
- return __generator(this, function (_b) {
8
- switch (_b.label) {
9
- case 0: return [4 /*yield*/, estimateGas(provider, {
10
- account: account,
11
- to: account,
12
- value: BigInt(1),
13
- })];
25
+ var unsignedTx, baseFeeMultiplier, _f, baseFeePerGas, _priorityFeePerGas, priorityFeePerGas;
26
+ return __generator(this, function (_g) {
27
+ switch (_g.label) {
28
+ case 0:
29
+ unsignedTx = opts.unsignedTx, baseFeeMultiplier = opts.baseFeeMultiplier;
30
+ return [4 /*yield*/, estimateGas(provider, {
31
+ account: (_a = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.from) !== null && _a !== void 0 ? _a : account,
32
+ to: (_b = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.to) !== null && _b !== void 0 ? _b : account,
33
+ value: BigInt((_d = (_c = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.value) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "1"),
34
+ data: (_e = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.data) !== null && _e !== void 0 ? _e : "0x",
35
+ })];
14
36
  case 1:
15
- _a = _b.sent(), baseFeePerGas = _a.baseFeePerGas, priorityFeePerGas = _a.priorityFeePerGas;
37
+ _f = _g.sent(), baseFeePerGas = _f.baseFeePerGas, _priorityFeePerGas = _f.priorityFeePerGas;
38
+ priorityFeePerGas = (_priorityFeePerGas * BigInt(baseFeeMultiplier.toString())) / BigInt(fixedPointAdjustment.toString());
16
39
  return [2 /*return*/, {
17
40
  maxFeePerGas: baseFeePerGas + priorityFeePerGas,
18
41
  maxPriorityFeePerGas: priorityFeePerGas,
@@ -1 +1 @@
1
- {"version":3,"file":"linea-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea-viem.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,iCAAiC,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/E,MAAM,UAAgB,OAAO,CAAC,QAAsB,EAAE,QAAiB;;;;;wBACxB,qBAAM,WAAW,CAAC,QAAQ,EAAE;wBACvE,OAAO,SAAA;wBACP,EAAE,EAAE,OAAO;wBACX,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;qBACjB,CAAC,EAAA;;oBAJI,KAAuC,SAI3C,EAJM,aAAa,mBAAA,EAAE,iBAAiB,uBAAA;oBAMxC,sBAAO;4BACL,YAAY,EAAE,aAAa,GAAG,iBAAiB;4BAC/C,oBAAoB,EAAE,iBAAiB;yBACxC,EAAC;;;;CACH"}
1
+ {"version":3,"file":"linea-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea-viem.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,iCAAiC,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAgB,OAAO,CAC3B,QAAsB,EACtB,IAA6B;;;;;;;oBAErB,UAAU,GAAwB,IAAI,WAA5B,EAAE,iBAAiB,GAAK,IAAI,kBAAT,CAAU;oBACkB,qBAAM,WAAW,CAAC,QAAQ,EAAE;4BAC3F,OAAO,EAAE,MAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAgB,mCAAI,OAAO;4BACjD,EAAE,EAAE,MAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,EAAc,mCAAI,OAAO;4BAC1C,KAAK,EAAE,MAAM,CAAC,MAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,0CAAE,QAAQ,EAAE,mCAAI,GAAG,CAAC;4BACnD,IAAI,EAAE,MAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAY,mCAAI,IAAI;yBACxC,CAAC,EAAA;;oBALI,KAA2D,SAK/D,EALM,aAAa,mBAAA,EAAqB,kBAAkB,uBAAA;oBAMtD,iBAAiB,GACrB,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC;oBAExG,sBAAO;4BACL,YAAY,EAAE,aAAa,GAAG,iBAAiB;4BAC/C,oBAAoB,EAAE,iBAAiB;yBACxC,EAAC;;;;CACH"}
@@ -1,3 +1,4 @@
1
1
  import { providers } from "ethers";
2
2
  import { GasPriceEstimate } from "../types";
3
- export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
3
+ import { GasPriceEstimateOptions } from "../oracle";
4
+ export declare function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
@@ -1,5 +1,9 @@
1
1
  import * as ethereum from "./ethereum";
2
- export function eip1559(provider, chainId) {
3
- return ethereum.legacy(provider, chainId);
2
+ export function eip1559(provider, opts) {
3
+ // We use the legacy method to call `eth_gasPrice` which empirically returns a more accurate
4
+ // gas price estimate than `eth_maxPriorityFeePerGas` or ethersProvider.getFeeData in the EIP1559 "raw" or "bad"
5
+ // cases. Based on testing, `eth_gasPrice` returns the closest price to the Linea-specific `linea_estimateGas`
6
+ // endpoint which the Viem Linea adapter queries.
7
+ return ethereum.legacy(provider, opts);
4
8
  }
5
9
  //# sourceMappingURL=linea.js.map
@@ -1 +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
+ {"version":3,"file":"linea.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAGvC,MAAM,UAAU,OAAO,CAAC,QAA4B,EAAE,IAA6B;IACjF,4FAA4F;IAC5F,gHAAgH;IAChH,8GAA8G;IAC9G,iDAAiD;IACjD,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC"}
@@ -1,3 +1,29 @@
1
1
  import { providers } from "ethers";
2
+ import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "../../priceClient/adapters/baseAdapter";
3
+ import { BigNumber } from "../../utils";
2
4
  import { GasPriceEstimate } from "../types";
3
- export declare function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
5
+ import { GasPriceEstimateOptions } from "../oracle";
6
+ type Polygon1559GasPrice = {
7
+ maxPriorityFee: number | string;
8
+ maxFee: number | string;
9
+ };
10
+ type GasStationArgs = BaseHTTPAdapterArgs & {
11
+ chainId?: number;
12
+ host?: string;
13
+ };
14
+ export declare class PolygonGasStation extends BaseHTTPAdapter {
15
+ readonly chainId: number;
16
+ constructor({ chainId, host, timeout, retries }?: GasStationArgs);
17
+ getFeeData(strategy?: "safeLow" | "standard" | "fast"): Promise<GasPriceEstimate>;
18
+ protected isPolygon1559GasPrice(gasPrice: unknown): gasPrice is Polygon1559GasPrice;
19
+ }
20
+ export declare const MockPolygonGasStationBaseFee: () => BigNumber;
21
+ export declare const MockPolygonGasStationPriorityFee: () => BigNumber;
22
+ /**
23
+ * @notice Returns the gas price suggested by the Polygon GasStation API or reconstructs it using
24
+ * the eip1559() method as a fallback.
25
+ * @param provider Ethers Provider.
26
+ * @returns GasPriceEstimate
27
+ */
28
+ export declare function gasStation(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
29
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { __awaiter, __extends, __generator } from "tslib";
2
2
  import { BaseHTTPAdapter } from "../../priceClient/adapters/baseAdapter";
3
- import { bnZero, isDefined, parseUnits } from "../../utils";
3
+ import { bnZero, fixedPointAdjustment, isDefined, parseUnits } from "../../utils";
4
4
  import { CHAIN_IDs } from "../../constants";
5
5
  import { gasPriceError } from "../util";
6
6
  import { eip1559 } from "./ethereum";
@@ -51,24 +51,68 @@ var PolygonGasStation = /** @class */ (function (_super) {
51
51
  };
52
52
  return PolygonGasStation;
53
53
  }(BaseHTTPAdapter));
54
- export function gasStation(provider, chainId) {
54
+ export { PolygonGasStation };
55
+ var MockRevertingPolygonGasStation = /** @class */ (function (_super) {
56
+ __extends(MockRevertingPolygonGasStation, _super);
57
+ function MockRevertingPolygonGasStation() {
58
+ return _super !== null && _super.apply(this, arguments) || this;
59
+ }
60
+ MockRevertingPolygonGasStation.prototype.getFeeData = function () {
61
+ throw new Error();
62
+ };
63
+ return MockRevertingPolygonGasStation;
64
+ }(PolygonGasStation));
65
+ export var MockPolygonGasStationBaseFee = function () { return parseUnits("12", 9); };
66
+ export var MockPolygonGasStationPriorityFee = function () { return parseUnits("1", 9); };
67
+ var MockPolygonGasStation = /** @class */ (function (_super) {
68
+ __extends(MockPolygonGasStation, _super);
69
+ function MockPolygonGasStation() {
70
+ return _super !== null && _super.apply(this, arguments) || this;
71
+ }
72
+ MockPolygonGasStation.prototype.getFeeData = function () {
73
+ return Promise.resolve({
74
+ maxPriorityFeePerGas: MockPolygonGasStationPriorityFee(),
75
+ maxFeePerGas: MockPolygonGasStationBaseFee().add(MockPolygonGasStationPriorityFee()),
76
+ });
77
+ };
78
+ return MockPolygonGasStation;
79
+ }(PolygonGasStation));
80
+ /**
81
+ * @notice Returns the gas price suggested by the Polygon GasStation API or reconstructs it using
82
+ * the eip1559() method as a fallback.
83
+ * @param provider Ethers Provider.
84
+ * @returns GasPriceEstimate
85
+ */
86
+ export function gasStation(provider, opts) {
55
87
  return __awaiter(this, void 0, void 0, function () {
56
- var gasStation, maxPriorityFeePerGas, maxFeePerGas, err_1, minPriorityFee, priorityDelta;
88
+ var chainId, baseFeeMultiplier, gasStation, maxPriorityFeePerGas, maxFeePerGas, baseFeeMinusPriorityFee, scaledBaseFee, err_1, minPriorityFee, priorityDelta;
57
89
  var _a, _b;
58
90
  return __generator(this, function (_c) {
59
91
  switch (_c.label) {
60
92
  case 0:
61
- gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
93
+ chainId = opts.chainId, baseFeeMultiplier = opts.baseFeeMultiplier;
94
+ if (process.env.TEST_POLYGON_GAS_STATION === "true") {
95
+ gasStation = new MockPolygonGasStation();
96
+ }
97
+ else if (process.env.TEST_REVERTING_POLYGON_GAS_STATION === "true") {
98
+ gasStation = new MockRevertingPolygonGasStation();
99
+ }
100
+ else {
101
+ gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
102
+ }
62
103
  _c.label = 1;
63
104
  case 1:
64
105
  _c.trys.push([1, 3, , 5]);
65
106
  return [4 /*yield*/, gasStation.getFeeData()];
66
107
  case 2:
67
108
  (_a = _c.sent(), maxPriorityFeePerGas = _a.maxPriorityFeePerGas, maxFeePerGas = _a.maxFeePerGas);
109
+ baseFeeMinusPriorityFee = maxFeePerGas.sub(maxPriorityFeePerGas);
110
+ scaledBaseFee = baseFeeMinusPriorityFee.mul(baseFeeMultiplier).div(fixedPointAdjustment);
111
+ maxFeePerGas = scaledBaseFee.add(maxPriorityFeePerGas);
68
112
  return [3 /*break*/, 5];
69
113
  case 3:
70
114
  err_1 = _c.sent();
71
- return [4 /*yield*/, eip1559(provider, chainId)];
115
+ return [4 /*yield*/, eip1559(provider, opts)];
72
116
  case 4:
73
117
  // Fall back to the RPC provider. May be less accurate.
74
118
  (_b = _c.sent(), maxPriorityFeePerGas = _b.maxPriorityFeePerGas, maxFeePerGas = _b.maxFeePerGas);
@@ -1 +1 @@
1
- {"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAa,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAqB7B,IAAA,OAAO,GAAK,SAAS,QAAd,CAAe;AAE9B;IAAgC,qCAAe;IAG7C,2BAAY,EAA6E;QAAzF,iBAKC;YALW,qBAA2E,EAAE,KAAA,EAA3E,eAAiB,EAAjB,OAAO,mBAAG,OAAO,KAAA,EAAE,IAAI,UAAA,EAAE,eAAc,EAAd,OAAO,mBAAG,IAAI,KAAA,EAAE,eAAW,EAAX,OAAO,mBAAG,C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A6B,EAApE,oBAAoB,0BAAA,EAAE,YAAY,kBAAA,CAAmC,CAAC;oBAGnE,uBAAuB,GAAG,YAAY,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;oBACjE,aAAa,GAAG,uBAAuB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;oBAC/F,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;;;;oBAGb,qBAAM,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAA;;oBADvE,uDAAuD;oBACvD,CAAC,KAAyC,SAA6B,EAApE,oBAAoB,0BAAA,EAAE,YAAY,kBAAA,CAAmC,CAAC;oBAInE,cAAc,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;oBAC3C,IAAI,oBAAoB,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE;wBACrC,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;wBAC/D,oBAAoB,GAAG,cAAc,CAAC;wBACtC,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;qBAChD;;wBAGH,sBAAO,EAAE,oBAAoB,sBAAA,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CAC/C"}
@@ -1,18 +1,26 @@
1
1
  import { Transport } from "viem";
2
- import { providers } from "ethers";
2
+ import { PopulatedTransaction, providers } from "ethers";
3
+ import { BigNumber } from "../utils";
3
4
  import { GasPriceEstimate } from "./types";
5
+ export interface GasPriceEstimateOptions {
6
+ baseFeeMultiplier: BigNumber;
7
+ legacyFallback: boolean;
8
+ chainId: number;
9
+ unsignedTx?: PopulatedTransaction;
10
+ transport?: Transport;
11
+ }
4
12
  /**
5
13
  * Provide an estimate for the current gas price for a particular chain.
6
- * @param chainId The chain ID to query for gas prices.
7
14
  * @param provider A valid ethers provider.
8
- * @param legacyFallback In the case of an unrecognised chain, fall back to type 0 gas estimation.
9
- * @returns Am object of type GasPriceEstimate.
15
+ * @param {opts} GasPriceEstimateOptions optional parameters.
16
+ * @returns An object of type GasPriceEstimate.
10
17
  */
11
- export declare function getGasPriceEstimate(provider: providers.Provider, chainId?: number, transport?: Transport, legacyFallback?: boolean): Promise<GasPriceEstimate>;
18
+ export declare function getGasPriceEstimate(provider: providers.Provider, opts?: Partial<GasPriceEstimateOptions>): Promise<GasPriceEstimate>;
12
19
  /**
13
20
  * Provide an estimate for the current gas price for a particular chain.
14
21
  * @param providerOrChainId A valid ethers provider or a chain ID.
15
- * @param transport An optional transport object for custom gas price retrieval.
16
- * @returns Am object of type GasPriceEstimate.
22
+ * @param transport An optional Viem Transport object for custom gas price retrieval.
23
+ * @param unsignedTx Only used in Linea provider to estimate priority gas fee.
24
+ * @returns An object of type GasPriceEstimate.
17
25
  */
18
- export declare function getViemGasPriceEstimate(providerOrChainId: providers.Provider | number, transport?: Transport): Promise<GasPriceEstimate>;
26
+ export declare function _getViemGasPriceEstimate(providerOrChainId: providers.Provider | number, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
@@ -1,43 +1,46 @@
1
- import { __awaiter, __generator } from "tslib";
1
+ import { __assign, __awaiter, __generator } from "tslib";
2
2
  import assert from "assert";
3
3
  import { CHAIN_IDs } from "../constants";
4
- import { BigNumber, chainIsOPStack } from "../utils";
4
+ import { BigNumber, chainIsOPStack, fixedPointAdjustment, toBNWei } from "../utils";
5
5
  import { getPublicClient } from "./util";
6
6
  import * as arbitrum from "./adapters/arbitrum";
7
7
  import * as ethereum from "./adapters/ethereum";
8
8
  import * as linea from "./adapters/linea";
9
9
  import * as polygon from "./adapters/polygon";
10
- import * as arbitrumViem from "./adapters/arbitrum-viem";
11
10
  import * as lineaViem from "./adapters/linea-viem";
12
- import * as polygonViem from "./adapters/polygon-viem";
11
+ var GAS_PRICE_ESTIMATE_DEFAULTS = {
12
+ legacyFallback: true,
13
+ };
13
14
  /**
14
15
  * Provide an estimate for the current gas price for a particular chain.
15
- * @param chainId The chain ID to query for gas prices.
16
16
  * @param provider A valid ethers provider.
17
- * @param legacyFallback In the case of an unrecognised chain, fall back to type 0 gas estimation.
18
- * @returns Am object of type GasPriceEstimate.
17
+ * @param {opts} GasPriceEstimateOptions optional parameters.
18
+ * @returns An object of type GasPriceEstimate.
19
19
  */
20
- export function getGasPriceEstimate(provider, chainId, transport, legacyFallback) {
21
- if (legacyFallback === void 0) { legacyFallback = true; }
20
+ export function getGasPriceEstimate(provider, opts) {
21
+ var _a, _b;
22
+ if (opts === void 0) { opts = {}; }
22
23
  return __awaiter(this, void 0, void 0, function () {
23
- var _a, useViem;
24
- var _b;
25
- return __generator(this, function (_c) {
26
- switch (_c.label) {
24
+ var baseFeeMultiplier, chainId, _c, optsWithDefaults, useViem;
25
+ return __generator(this, function (_d) {
26
+ switch (_d.label) {
27
27
  case 0:
28
- if (!(chainId !== null && chainId !== void 0)) return [3 /*break*/, 1];
29
- _a = chainId;
28
+ baseFeeMultiplier = (_a = opts.baseFeeMultiplier) !== null && _a !== void 0 ? _a : toBNWei("1");
29
+ assert(baseFeeMultiplier.gte(toBNWei("1.0")) && baseFeeMultiplier.lte(toBNWei("5")), "Require 1.0 < base fee multiplier (".concat(baseFeeMultiplier, ") <= 5.0 for a total gas multiplier within [+1.0, +5.0]"));
30
+ if (!((_b = opts.chainId) !== null && _b !== void 0)) return [3 /*break*/, 1];
31
+ _c = _b;
30
32
  return [3 /*break*/, 3];
31
33
  case 1: return [4 /*yield*/, provider.getNetwork()];
32
34
  case 2:
33
- _a = (_b = _c.sent(), chainId = _b.chainId, _b);
34
- _c.label = 3;
35
+ _c = (_d.sent()).chainId;
36
+ _d.label = 3;
35
37
  case 3:
36
- _a;
38
+ chainId = _c;
39
+ optsWithDefaults = __assign(__assign(__assign(__assign({}, GAS_PRICE_ESTIMATE_DEFAULTS), { baseFeeMultiplier: baseFeeMultiplier }), opts), { chainId: chainId });
37
40
  useViem = process.env["NEW_GAS_PRICE_ORACLE_".concat(chainId)] === "true";
38
41
  return [2 /*return*/, useViem
39
- ? getViemGasPriceEstimate(chainId, transport)
40
- : getEthersGasPriceEstimate(provider, chainId, legacyFallback)];
42
+ ? _getViemGasPriceEstimate(chainId, optsWithDefaults)
43
+ : _getEthersGasPriceEstimate(provider, optsWithDefaults)];
41
44
  }
42
45
  });
43
46
  });
@@ -47,11 +50,11 @@ export function getGasPriceEstimate(provider, chainId, transport, legacyFallback
47
50
  * @param chainId The chain ID to query for gas prices.
48
51
  * @param provider A valid ethers provider.
49
52
  * @param legacyFallback In the case of an unrecognised chain, fall back to type 0 gas estimation.
50
- * @returns Am object of type GasPriceEstimate.
53
+ * @returns An object of type GasPriceEstimate.
51
54
  */
52
- function getEthersGasPriceEstimate(provider, chainId, legacyFallback) {
55
+ function _getEthersGasPriceEstimate(provider, opts) {
53
56
  var _a;
54
- if (legacyFallback === void 0) { legacyFallback = true; }
57
+ var chainId = opts.chainId, legacyFallback = opts.legacyFallback;
55
58
  var gasPriceFeeds = (_a = {},
56
59
  _a[CHAIN_IDs.ALEPH_ZERO] = arbitrum.eip1559,
57
60
  _a[CHAIN_IDs.ARBITRUM] = arbitrum.eip1559,
@@ -64,21 +67,23 @@ function getEthersGasPriceEstimate(provider, chainId, legacyFallback) {
64
67
  var gasPriceFeed = gasPriceFeeds[chainId];
65
68
  assert(gasPriceFeed || legacyFallback, "No suitable gas price oracle for Chain ID ".concat(chainId));
66
69
  gasPriceFeed !== null && gasPriceFeed !== void 0 ? gasPriceFeed : (gasPriceFeed = chainIsOPStack(chainId) ? ethereum.eip1559 : ethereum.legacy);
67
- return gasPriceFeed(provider, chainId);
70
+ return gasPriceFeed(provider, opts);
68
71
  }
69
72
  /**
70
73
  * Provide an estimate for the current gas price for a particular chain.
71
74
  * @param providerOrChainId A valid ethers provider or a chain ID.
72
- * @param transport An optional transport object for custom gas price retrieval.
73
- * @returns Am object of type GasPriceEstimate.
75
+ * @param transport An optional Viem Transport object for custom gas price retrieval.
76
+ * @param unsignedTx Only used in Linea provider to estimate priority gas fee.
77
+ * @returns An object of type GasPriceEstimate.
74
78
  */
75
- export function getViemGasPriceEstimate(providerOrChainId, transport) {
79
+ export function _getViemGasPriceEstimate(providerOrChainId, opts) {
76
80
  return __awaiter(this, void 0, void 0, function () {
77
- var chainId, _a, viemProvider, gasPriceFeeds, maxFeePerGas, maxPriorityFeePerGas, gasPrice;
81
+ var baseFeeMultiplier, transport, chainId, _a, viemProvider, gasPriceFeeds, maxFeePerGas, maxPriorityFeePerGas, gasPrice;
78
82
  var _b, _c, _d;
79
83
  return __generator(this, function (_e) {
80
84
  switch (_e.label) {
81
85
  case 0:
86
+ baseFeeMultiplier = opts.baseFeeMultiplier, transport = opts.transport;
82
87
  if (!(typeof providerOrChainId === "number")) return [3 /*break*/, 1];
83
88
  _a = providerOrChainId;
84
89
  return [3 /*break*/, 3];
@@ -90,13 +95,10 @@ export function getViemGasPriceEstimate(providerOrChainId, transport) {
90
95
  chainId = _a;
91
96
  viemProvider = getPublicClient(chainId, transport);
92
97
  gasPriceFeeds = (_b = {},
93
- _b[CHAIN_IDs.ALEPH_ZERO] = arbitrumViem.eip1559,
94
- _b[CHAIN_IDs.ARBITRUM] = arbitrumViem.eip1559,
95
98
  _b[CHAIN_IDs.LINEA] = lineaViem.eip1559,
96
- _b[CHAIN_IDs.POLYGON] = polygonViem.gasStation,
97
99
  _b);
98
100
  if (!gasPriceFeeds[chainId]) return [3 /*break*/, 5];
99
- return [4 /*yield*/, gasPriceFeeds[chainId](viemProvider, chainId)];
101
+ return [4 /*yield*/, gasPriceFeeds[chainId](viemProvider, opts)];
100
102
  case 4:
101
103
  (_c = _e.sent(), maxFeePerGas = _c.maxFeePerGas, maxPriorityFeePerGas = _c.maxPriorityFeePerGas);
102
104
  return [3 /*break*/, 7];
@@ -105,7 +107,7 @@ export function getViemGasPriceEstimate(providerOrChainId, transport) {
105
107
  return [4 /*yield*/, viemProvider.estimateFeesPerGas()];
106
108
  case 6:
107
109
  (_d = _e.sent(), maxFeePerGas = _d.maxFeePerGas, maxPriorityFeePerGas = _d.maxPriorityFeePerGas, gasPrice = _d.gasPrice);
108
- maxFeePerGas !== null && maxFeePerGas !== void 0 ? maxFeePerGas : (maxFeePerGas = gasPrice);
110
+ maxFeePerGas !== null && maxFeePerGas !== void 0 ? maxFeePerGas : (maxFeePerGas = (gasPrice * BigInt(baseFeeMultiplier.toString())) / BigInt(fixedPointAdjustment.toString()));
109
111
  maxPriorityFeePerGas !== null && maxPriorityFeePerGas !== void 0 ? maxPriorityFeePerGas : (maxPriorityFeePerGas = BigInt(0));
110
112
  _e.label = 7;
111
113
  case 7: return [2 /*return*/, {
@@ -1 +1 @@
1
- {"version":3,"file":"oracle.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,UAAgB,mBAAmB,CACvC,QAA4B,EAC5B,OAAgB,EAChB,SAAqB,EACrB,cAAqB;IAArB,+BAAA,EAAA,qBAAqB;;;;;;;0BAErB,OAAO,aAAP,OAAO;oBAAP,KAAA,OAAO,CAAA;;wBAAmB,qBAAM,QAAQ,CAAC,UAAU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,IAApB,oBAAoB,GAAK,MAAM,CAAC,CAAC,CAAC,EAAC;;wBAGrC,sBAAO;wBACL,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;wBACrD,oBAAoB,EAAE,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC;qBACtE,EAAC;;;;CACH"}
@@ -1,19 +1,19 @@
1
1
  export type RPCProvider = "ALCHEMY" | "DRPC" | "INFURA" | "INFURA_DIN";
2
2
  export type RPCTransport = "https" | "wss";
3
3
  export declare const JsonRpcError: import("superstruct").Struct<{
4
- id: string | number;
5
4
  error: {
6
- code: number;
7
5
  message: string;
6
+ code: number;
8
7
  data?: any;
9
8
  };
9
+ id: string | number;
10
10
  jsonrpc: "2.0";
11
11
  }, {
12
12
  jsonrpc: import("superstruct").Struct<"2.0", "2.0">;
13
13
  id: import("superstruct").Struct<string | number, null>;
14
14
  error: import("superstruct").Struct<{
15
- code: number;
16
15
  message: string;
16
+ code: number;
17
17
  data?: any;
18
18
  }, {
19
19
  code: import("superstruct").Struct<number, null>;