@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
@@ -3,8 +3,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
3
3
  bundleDepositsV3: Record<string, Record<string, {
4
4
  blockNumber: number;
5
5
  transactionIndex: number;
6
- transactionHash: string;
7
6
  logIndex: number;
7
+ transactionHash: string;
8
8
  message: string;
9
9
  originChainId: number;
10
10
  inputToken: string;
@@ -32,8 +32,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
32
32
  fills: {
33
33
  blockNumber: number;
34
34
  transactionIndex: number;
35
- transactionHash: string;
36
35
  logIndex: number;
36
+ transactionHash: string;
37
37
  message: string;
38
38
  originChainId: number;
39
39
  inputToken: string;
@@ -65,8 +65,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
65
65
  bundleSlowFillsV3: Record<string, Record<string, {
66
66
  blockNumber: number;
67
67
  transactionIndex: number;
68
- transactionHash: string;
69
68
  logIndex: number;
69
+ transactionHash: string;
70
70
  message: string;
71
71
  originChainId: number;
72
72
  inputToken: string;
@@ -94,8 +94,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
94
94
  expiredDepositsToRefundV3: Record<string, Record<string, {
95
95
  blockNumber: number;
96
96
  transactionIndex: number;
97
- transactionHash: string;
98
97
  logIndex: number;
98
+ transactionHash: string;
99
99
  message: string;
100
100
  originChainId: number;
101
101
  inputToken: string;
@@ -122,8 +122,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
122
122
  unexecutableSlowFills: Record<string, Record<string, {
123
123
  blockNumber: number;
124
124
  transactionIndex: number;
125
- transactionHash: string;
126
125
  logIndex: number;
126
+ transactionHash: string;
127
127
  message: string;
128
128
  originChainId: number;
129
129
  inputToken: string;
@@ -152,8 +152,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
152
152
  bundleDepositsV3: import("superstruct").Struct<Record<string, Record<string, {
153
153
  blockNumber: number;
154
154
  transactionIndex: number;
155
- transactionHash: string;
156
155
  logIndex: number;
156
+ transactionHash: string;
157
157
  message: string;
158
158
  originChainId: number;
159
159
  inputToken: string;
@@ -180,8 +180,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
180
180
  expiredDepositsToRefundV3: import("superstruct").Struct<Record<string, Record<string, {
181
181
  blockNumber: number;
182
182
  transactionIndex: number;
183
- transactionHash: string;
184
183
  logIndex: number;
184
+ transactionHash: string;
185
185
  message: string;
186
186
  originChainId: number;
187
187
  inputToken: string;
@@ -208,8 +208,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
208
208
  unexecutableSlowFills: import("superstruct").Struct<Record<string, Record<string, {
209
209
  blockNumber: number;
210
210
  transactionIndex: number;
211
- transactionHash: string;
212
211
  logIndex: number;
212
+ transactionHash: string;
213
213
  message: string;
214
214
  originChainId: number;
215
215
  inputToken: string;
@@ -237,8 +237,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
237
237
  bundleSlowFillsV3: import("superstruct").Struct<Record<string, Record<string, {
238
238
  blockNumber: number;
239
239
  transactionIndex: number;
240
- transactionHash: string;
241
240
  logIndex: number;
241
+ transactionHash: string;
242
242
  message: string;
243
243
  originChainId: number;
244
244
  inputToken: string;
@@ -267,8 +267,8 @@ export declare const BundleDataSS: import("superstruct").Struct<{
267
267
  fills: {
268
268
  blockNumber: number;
269
269
  transactionIndex: number;
270
- transactionHash: string;
271
270
  logIndex: number;
271
+ transactionHash: string;
272
272
  message: string;
273
273
  originChainId: number;
274
274
  inputToken: string;
@@ -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>;
@@ -4,12 +4,12 @@ exports.eip1559 = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var utils_1 = require("../../utils");
6
6
  var ethereum = tslib_1.__importStar(require("./ethereum"));
7
- function eip1559(provider, chainId) {
7
+ function eip1559(provider, opts) {
8
8
  return tslib_1.__awaiter(this, void 0, void 0, function () {
9
9
  var _a, _maxFeePerGas, maxPriorityFeePerGas, maxFeePerGas;
10
10
  return tslib_1.__generator(this, function (_b) {
11
11
  switch (_b.label) {
12
- case 0: return [4, ethereum.eip1559(provider, chainId)];
12
+ case 0: return [4, ethereum.eip1559(provider, opts)];
13
13
  case 1:
14
14
  _a = _b.sent(), _maxFeePerGas = _a.maxFeePerGas, maxPriorityFeePerGas = _a.maxPriorityFeePerGas;
15
15
  maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(utils_1.bnOne);
@@ -1 +1 @@
1
- {"version":3,"file":"arbitrum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum.ts"],"names":[],"mappings":";;;;AACA,qCAAoC;AAEpC,2DAAuC;AAIvC,SAAsB,OAAO,CAAC,QAA4B,EAAE,OAAe;;;;;wBACX,WAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAA;;oBAAjG,KAAwD,SAAyC,EAAjF,aAAa,kBAAA,EAAE,oBAAoB,0BAAA;oBAInD,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,aAAK,CAAC,CAAC;oBAExE,WAAO,EAAE,oBAAoB,EAAE,aAAK,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CACtD;AARD,0BAQC"}
1
+ {"version":3,"file":"arbitrum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum.ts"],"names":[],"mappings":";;;;AACA,qCAAoC;AAEpC,2DAAuC;AAWvC,SAAsB,OAAO,CAAC,QAA4B,EAAE,IAA6B;;;;;wBACzB,WAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAA;;oBAA9F,KAAwD,SAAsC,EAA9E,aAAa,kBAAA,EAAE,oBAAoB,0BAAA;oBAInD,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,aAAK,CAAC,CAAC;oBAExE,WAAO,EAAE,oBAAoB,EAAE,aAAK,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CACtD;AARD,0BAQC"}
@@ -1,6 +1,8 @@
1
1
  import { providers } from "ethers";
2
+ import { BigNumber } from "../../utils";
2
3
  import { GasPriceEstimate } from "../types";
3
- export declare function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
4
- export declare function eip1559Raw(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
5
- export declare function eip1559Bad(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
6
- export declare function legacy(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate>;
4
+ import { GasPriceEstimateOptions } from "../oracle";
5
+ export declare function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
6
+ export declare function eip1559Raw(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
7
+ export declare function eip1559Bad(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
8
+ export declare function legacy(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
@@ -5,14 +5,16 @@ var tslib_1 = require("tslib");
5
5
  var assert_1 = tslib_1.__importDefault(require("assert"));
6
6
  var utils_1 = require("../../utils");
7
7
  var util_1 = require("../util");
8
- function eip1559(provider, chainId) {
9
- var useRaw = process.env["GAS_PRICE_EIP1559_RAW_".concat(chainId)] === "true";
10
- return useRaw ? eip1559Raw(provider, chainId) : eip1559Bad(provider, chainId);
8
+ function eip1559(provider, opts) {
9
+ var useRaw = process.env["GAS_PRICE_EIP1559_RAW_".concat(opts.chainId)] === "true";
10
+ return useRaw
11
+ ? eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier)
12
+ : eip1559Bad(provider, opts.chainId, opts.baseFeeMultiplier);
11
13
  }
12
14
  exports.eip1559 = eip1559;
13
- function eip1559Raw(provider, chainId) {
15
+ function eip1559Raw(provider, chainId, baseFeeMultiplier) {
14
16
  return tslib_1.__awaiter(this, void 0, void 0, function () {
15
- var _a, baseFeePerGas, _maxPriorityFeePerGas, maxPriorityFeePerGas;
17
+ var _a, baseFeePerGas, _maxPriorityFeePerGas, maxPriorityFeePerGas, scaledBaseFee;
16
18
  return tslib_1.__generator(this, function (_b) {
17
19
  switch (_b.label) {
18
20
  case 0: return [4, Promise.all([
@@ -23,8 +25,9 @@ function eip1559Raw(provider, chainId) {
23
25
  _a = _b.sent(), baseFeePerGas = _a[0].baseFeePerGas, _maxPriorityFeePerGas = _a[1];
24
26
  maxPriorityFeePerGas = utils_1.BigNumber.from(_maxPriorityFeePerGas);
25
27
  (0, assert_1.default)(utils_1.BigNumber.isBigNumber(baseFeePerGas), "No baseFeePerGas received on ".concat((0, utils_1.getNetworkName)(chainId)));
28
+ scaledBaseFee = baseFeePerGas.mul(baseFeeMultiplier).div(utils_1.fixedPointAdjustment);
26
29
  return [2, {
27
- maxFeePerGas: maxPriorityFeePerGas.add(baseFeePerGas),
30
+ maxFeePerGas: maxPriorityFeePerGas.add(scaledBaseFee),
28
31
  maxPriorityFeePerGas: maxPriorityFeePerGas,
29
32
  }];
30
33
  }
@@ -32,9 +35,9 @@ function eip1559Raw(provider, chainId) {
32
35
  });
33
36
  }
34
37
  exports.eip1559Raw = eip1559Raw;
35
- function eip1559Bad(provider, chainId) {
38
+ function eip1559Bad(provider, chainId, baseFeeMultiplier) {
36
39
  return tslib_1.__awaiter(this, void 0, void 0, function () {
37
- var feeData, maxPriorityFeePerGas, maxFeePerGas;
40
+ var feeData, maxPriorityFeePerGas, scaledLastBaseFeePerGas, maxFeePerGas;
38
41
  return tslib_1.__generator(this, function (_a) {
39
42
  switch (_a.label) {
40
43
  case 0: return [4, provider.getFeeData()];
@@ -45,25 +48,30 @@ function eip1559Bad(provider, chainId) {
45
48
  (0, util_1.gasPriceError)("getFeeData()", chainId, feeData);
46
49
  });
47
50
  maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
48
- maxFeePerGas = maxPriorityFeePerGas.add(feeData.lastBaseFeePerGas);
51
+ scaledLastBaseFeePerGas = feeData.lastBaseFeePerGas
52
+ .mul(baseFeeMultiplier)
53
+ .div(utils_1.fixedPointAdjustment);
54
+ maxFeePerGas = maxPriorityFeePerGas.add(scaledLastBaseFeePerGas);
49
55
  return [2, { maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas }];
50
56
  }
51
57
  });
52
58
  });
53
59
  }
54
60
  exports.eip1559Bad = eip1559Bad;
55
- function legacy(provider, chainId) {
61
+ function legacy(provider, opts) {
56
62
  return tslib_1.__awaiter(this, void 0, void 0, function () {
57
- var gasPrice;
63
+ var chainId, baseFeeMultiplier, gasPrice;
58
64
  return tslib_1.__generator(this, function (_a) {
59
65
  switch (_a.label) {
60
- case 0: return [4, provider.getGasPrice()];
66
+ case 0:
67
+ chainId = opts.chainId, baseFeeMultiplier = opts.baseFeeMultiplier;
68
+ return [4, provider.getGasPrice()];
61
69
  case 1:
62
70
  gasPrice = _a.sent();
63
71
  if (!utils_1.BigNumber.isBigNumber(gasPrice) || gasPrice.lt(utils_1.bnZero))
64
72
  (0, util_1.gasPriceError)("getGasPrice()", chainId, gasPrice);
65
73
  return [2, {
66
- maxFeePerGas: gasPrice,
74
+ maxFeePerGas: gasPrice.mul(baseFeeMultiplier).div(utils_1.fixedPointAdjustment),
67
75
  maxPriorityFeePerGas: utils_1.bnZero,
68
76
  }];
69
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":";;;;AAAA,0DAA4B;AAE5B,qCAAgE;AAEhE,gCAAwC;AAOxC,SAAgB,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;AAHD,0BAGC;AAQD,SAAsB,UAAU,CAAC,QAA4B,EAAE,OAAe;;;;;wBACzB,WAAM,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,iBAAS,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;oBACnE,IAAA,gBAAM,EAAC,iBAAS,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,uCAAgC,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAE,CAAC,CAAC;oBAExG,WAAO;4BACL,YAAY,EAAE,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC;4BACrD,oBAAoB,sBAAA;yBACrB,EAAC;;;;CACH;AAZD,gCAYC;AAQD,SAAsB,UAAU,CAAC,QAA4B,EAAE,OAAe;;;;;wBAC5D,WAAM,QAAQ,CAAC,UAAU,EAAE,EA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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,uBAAuB,GAAI,OAAO,CAAC,iBAA+B;yBACrE,GAAG,CAAC,iBAAiB,CAAC;yBACtB,GAAG,CAAC,4BAAoB,CAAC,CAAC;oBACvB,YAAY,GAAG,oBAAoB,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;oBAEvE,WAAO,EAAE,oBAAoB,sBAAA,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CAC/C;AAlBD,gCAkBC;AAOD,SAAsB,MAAM,CAAC,QAA4B,EAAE,IAA6B;;;;;;oBAC9E,OAAO,GAAwB,IAAI,QAA5B,EAAE,iBAAiB,GAAK,IAAI,kBAAT,CAAU;oBAC3B,WAAM,QAAQ,CAAC,WAAW,EAAE,EAAA;;oBAAvC,QAAQ,GAAG,SAA4B;oBAE7C,IAAI,CAAC,iBAAS,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,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,4BAAoB,CAAC;4BACvE,oBAAoB,EAAE,cAAM;yBAC7B,EAAC;;;;CACH;AAVD,wBAUC"}
@@ -1,3 +1,4 @@
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
+ export declare function eip1559(provider: PublicClient, opts: GasPriceEstimateOptions): Promise<InternalGasPriceEstimate>;
@@ -4,18 +4,24 @@ exports.eip1559 = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var linea_1 = require("viem/linea");
6
6
  var constants_1 = require("../../constants");
7
- function eip1559(provider, _chainId) {
7
+ var utils_1 = require("../../utils");
8
+ function eip1559(provider, opts) {
9
+ var _a, _b, _c, _d, _e;
8
10
  return tslib_1.__awaiter(this, void 0, void 0, function () {
9
- var _a, baseFeePerGas, priorityFeePerGas;
10
- return tslib_1.__generator(this, function (_b) {
11
- switch (_b.label) {
12
- case 0: return [4, (0, linea_1.estimateGas)(provider, {
13
- account: constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
14
- to: constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
15
- value: BigInt(1),
16
- })];
11
+ var unsignedTx, baseFeeMultiplier, _f, baseFeePerGas, _priorityFeePerGas, priorityFeePerGas;
12
+ return tslib_1.__generator(this, function (_g) {
13
+ switch (_g.label) {
14
+ case 0:
15
+ unsignedTx = opts.unsignedTx, baseFeeMultiplier = opts.baseFeeMultiplier;
16
+ return [4, (0, linea_1.estimateGas)(provider, {
17
+ account: (_a = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.from) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
18
+ to: (_b = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.to) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
19
+ 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"),
20
+ data: (_e = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.data) !== null && _e !== void 0 ? _e : "0x",
21
+ })];
17
22
  case 1:
18
- _a = _b.sent(), baseFeePerGas = _a.baseFeePerGas, priorityFeePerGas = _a.priorityFeePerGas;
23
+ _f = _g.sent(), baseFeePerGas = _f.baseFeePerGas, _priorityFeePerGas = _f.priorityFeePerGas;
24
+ priorityFeePerGas = (_priorityFeePerGas * BigInt(baseFeeMultiplier.toString())) / BigInt(utils_1.fixedPointAdjustment.toString());
19
25
  return [2, {
20
26
  maxFeePerGas: baseFeePerGas + priorityFeePerGas,
21
27
  maxPriorityFeePerGas: priorityFeePerGas,
@@ -1 +1 @@
1
- {"version":3,"file":"linea-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea-viem.ts"],"names":[],"mappings":";;;;AACA,oCAAyC;AACzC,6CAA+E;AAG/E,SAAsB,OAAO,CAAC,QAAsB,EAAE,QAAiB;;;;;wBACxB,WAAM,IAAA,mBAAW,EAAC,QAAQ,EAAE;wBACvE,OAAO,+CAAA;wBACP,EAAE,EAAE,6CAAO;wBACX,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;qBACjB,CAAC,EAAA;;oBAJI,KAAuC,SAI3C,EAJM,aAAa,mBAAA,EAAE,iBAAiB,uBAAA;oBAMxC,WAAO;4BACL,YAAY,EAAE,aAAa,GAAG,iBAAiB;4BAC/C,oBAAoB,EAAE,iBAAiB;yBACxC,EAAC;;;;CACH;AAXD,0BAWC"}
1
+ {"version":3,"file":"linea-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea-viem.ts"],"names":[],"mappings":";;;;AACA,oCAAyC;AACzC,6CAA+E;AAG/E,qCAAmD;AAmBnD,SAAsB,OAAO,CAC3B,QAAsB,EACtB,IAA6B;;;;;;;oBAErB,UAAU,GAAwB,IAAI,WAA5B,EAAE,iBAAiB,GAAK,IAAI,kBAAT,CAAU;oBACkB,WAAM,IAAA,mBAAW,EAAC,QAAQ,EAAE;4BAC3F,OAAO,EAAE,MAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAgB,mCAAI,6CAAO;4BACjD,EAAE,EAAE,MAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,EAAc,mCAAI,6CAAO;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,4BAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC;oBAExG,WAAO;4BACL,YAAY,EAAE,aAAa,GAAG,iBAAiB;4BAC/C,oBAAoB,EAAE,iBAAiB;yBACxC,EAAC;;;;CACH;AAlBD,0BAkBC"}
@@ -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>;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.eip1559 = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var ethereum = tslib_1.__importStar(require("./ethereum"));
6
- function eip1559(provider, chainId) {
7
- return ethereum.legacy(provider, chainId);
6
+ function eip1559(provider, opts) {
7
+ return ethereum.legacy(provider, opts);
8
8
  }
9
9
  exports.eip1559 = eip1559;
10
10
  //# sourceMappingURL=linea.js.map
@@ -1 +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
+ {"version":3,"file":"linea.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea.ts"],"names":[],"mappings":";;;;AAMA,2DAAuC;AAGvC,SAAgB,OAAO,CAAC,QAA4B,EAAE,IAA6B;IAKjF,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAND,0BAMC"}
@@ -1,3 +1,23 @@
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
+ export declare function gasStation(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
23
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gasStation = void 0;
3
+ exports.gasStation = exports.MockPolygonGasStationPriorityFee = exports.MockPolygonGasStationBaseFee = exports.PolygonGasStation = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var baseAdapter_1 = require("../../priceClient/adapters/baseAdapter");
6
6
  var utils_1 = require("../../utils");
@@ -53,24 +53,64 @@ var PolygonGasStation = (function (_super) {
53
53
  };
54
54
  return PolygonGasStation;
55
55
  }(baseAdapter_1.BaseHTTPAdapter));
56
- function gasStation(provider, chainId) {
56
+ exports.PolygonGasStation = PolygonGasStation;
57
+ var MockRevertingPolygonGasStation = (function (_super) {
58
+ tslib_1.__extends(MockRevertingPolygonGasStation, _super);
59
+ function MockRevertingPolygonGasStation() {
60
+ return _super !== null && _super.apply(this, arguments) || this;
61
+ }
62
+ MockRevertingPolygonGasStation.prototype.getFeeData = function () {
63
+ throw new Error();
64
+ };
65
+ return MockRevertingPolygonGasStation;
66
+ }(PolygonGasStation));
67
+ var MockPolygonGasStationBaseFee = function () { return (0, utils_1.parseUnits)("12", 9); };
68
+ exports.MockPolygonGasStationBaseFee = MockPolygonGasStationBaseFee;
69
+ var MockPolygonGasStationPriorityFee = function () { return (0, utils_1.parseUnits)("1", 9); };
70
+ exports.MockPolygonGasStationPriorityFee = MockPolygonGasStationPriorityFee;
71
+ var MockPolygonGasStation = (function (_super) {
72
+ tslib_1.__extends(MockPolygonGasStation, _super);
73
+ function MockPolygonGasStation() {
74
+ return _super !== null && _super.apply(this, arguments) || this;
75
+ }
76
+ MockPolygonGasStation.prototype.getFeeData = function () {
77
+ return Promise.resolve({
78
+ maxPriorityFeePerGas: (0, exports.MockPolygonGasStationPriorityFee)(),
79
+ maxFeePerGas: (0, exports.MockPolygonGasStationBaseFee)().add((0, exports.MockPolygonGasStationPriorityFee)()),
80
+ });
81
+ };
82
+ return MockPolygonGasStation;
83
+ }(PolygonGasStation));
84
+ function gasStation(provider, opts) {
57
85
  return tslib_1.__awaiter(this, void 0, void 0, function () {
58
- var gasStation, maxPriorityFeePerGas, maxFeePerGas, err_1, minPriorityFee, priorityDelta;
86
+ var chainId, baseFeeMultiplier, gasStation, maxPriorityFeePerGas, maxFeePerGas, baseFeeMinusPriorityFee, scaledBaseFee, err_1, minPriorityFee, priorityDelta;
59
87
  var _a, _b;
60
88
  return tslib_1.__generator(this, function (_c) {
61
89
  switch (_c.label) {
62
90
  case 0:
63
- gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
91
+ chainId = opts.chainId, baseFeeMultiplier = opts.baseFeeMultiplier;
92
+ if (process.env.TEST_POLYGON_GAS_STATION === "true") {
93
+ gasStation = new MockPolygonGasStation();
94
+ }
95
+ else if (process.env.TEST_REVERTING_POLYGON_GAS_STATION === "true") {
96
+ gasStation = new MockRevertingPolygonGasStation();
97
+ }
98
+ else {
99
+ gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
100
+ }
64
101
  _c.label = 1;
65
102
  case 1:
66
103
  _c.trys.push([1, 3, , 5]);
67
104
  return [4, gasStation.getFeeData()];
68
105
  case 2:
69
106
  (_a = _c.sent(), maxPriorityFeePerGas = _a.maxPriorityFeePerGas, maxFeePerGas = _a.maxFeePerGas);
107
+ baseFeeMinusPriorityFee = maxFeePerGas.sub(maxPriorityFeePerGas);
108
+ scaledBaseFee = baseFeeMinusPriorityFee.mul(baseFeeMultiplier).div(utils_1.fixedPointAdjustment);
109
+ maxFeePerGas = scaledBaseFee.add(maxPriorityFeePerGas);
70
110
  return [3, 5];
71
111
  case 3:
72
112
  err_1 = _c.sent();
73
- return [4, (0, ethereum_1.eip1559)(provider, chainId)];
113
+ return [4, (0, ethereum_1.eip1559)(provider, opts)];
74
114
  case 4:
75
115
  (_b = _c.sent(), maxPriorityFeePerGas = _b.maxPriorityFeePerGas, maxFeePerGas = _b.maxFeePerGas);
76
116
  minPriorityFee = (0, utils_1.parseUnits)("30", 9);
@@ -1 +1 @@
1
- {"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon.ts"],"names":[],"mappings":";;;;AACA,sEAA8F;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,8BAA8B,EAAE,CAAC;qBACnD;yBAAM;wBACL,UAAU,GAAG,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;qBACrF;;;;oBAI2C,WAAM,UAAU,CAAC,UAAU,EAAE,EAAA;;oBAAvE,CAAC,KAAyC,SAA6B,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,4BAAoB,CAAC,CAAC;oBAC/F,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;;;;oBAGb,WAAM,IAAA,kBAAO,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAA;;oBAAvE,CAAC,KAAyC,SAA6B,EAApE,oBAAoB,0BAAA,EAAE,YAAY,kBAAA,CAAmC,CAAC;oBAInE,cAAc,GAAG,IAAA,kBAAU,EAAC,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,WAAO,EAAE,oBAAoB,sBAAA,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CAC/C;AArCD,gCAqCC"}
@@ -1,5 +1,13 @@
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";
4
- export declare function getGasPriceEstimate(provider: providers.Provider, chainId?: number, transport?: Transport, legacyFallback?: boolean): Promise<GasPriceEstimate>;
5
- export declare function getViemGasPriceEstimate(providerOrChainId: providers.Provider | number, transport?: Transport): Promise<GasPriceEstimate>;
5
+ export interface GasPriceEstimateOptions {
6
+ baseFeeMultiplier: BigNumber;
7
+ legacyFallback: boolean;
8
+ chainId: number;
9
+ unsignedTx?: PopulatedTransaction;
10
+ transport?: Transport;
11
+ }
12
+ export declare function getGasPriceEstimate(provider: providers.Provider, opts?: Partial<GasPriceEstimateOptions>): Promise<GasPriceEstimate>;
13
+ export declare function _getViemGasPriceEstimate(providerOrChainId: providers.Provider | number, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getViemGasPriceEstimate = exports.getGasPriceEstimate = void 0;
3
+ exports._getViemGasPriceEstimate = exports.getGasPriceEstimate = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var assert_1 = tslib_1.__importDefault(require("assert"));
6
6
  var constants_1 = require("../constants");
@@ -10,38 +10,42 @@ var arbitrum = tslib_1.__importStar(require("./adapters/arbitrum"));
10
10
  var ethereum = tslib_1.__importStar(require("./adapters/ethereum"));
11
11
  var linea = tslib_1.__importStar(require("./adapters/linea"));
12
12
  var polygon = tslib_1.__importStar(require("./adapters/polygon"));
13
- var arbitrumViem = tslib_1.__importStar(require("./adapters/arbitrum-viem"));
14
13
  var lineaViem = tslib_1.__importStar(require("./adapters/linea-viem"));
15
- var polygonViem = tslib_1.__importStar(require("./adapters/polygon-viem"));
16
- function getGasPriceEstimate(provider, chainId, transport, legacyFallback) {
17
- if (legacyFallback === void 0) { legacyFallback = true; }
14
+ var GAS_PRICE_ESTIMATE_DEFAULTS = {
15
+ legacyFallback: true,
16
+ };
17
+ function getGasPriceEstimate(provider, opts) {
18
+ var _a, _b;
19
+ if (opts === void 0) { opts = {}; }
18
20
  return tslib_1.__awaiter(this, void 0, void 0, function () {
19
- var _a, useViem;
20
- var _b;
21
- return tslib_1.__generator(this, function (_c) {
22
- switch (_c.label) {
21
+ var baseFeeMultiplier, chainId, _c, optsWithDefaults, useViem;
22
+ return tslib_1.__generator(this, function (_d) {
23
+ switch (_d.label) {
23
24
  case 0:
24
- if (!(chainId !== null && chainId !== void 0)) return [3, 1];
25
- _a = chainId;
25
+ baseFeeMultiplier = (_a = opts.baseFeeMultiplier) !== null && _a !== void 0 ? _a : (0, utils_1.toBNWei)("1");
26
+ (0, assert_1.default)(baseFeeMultiplier.gte((0, utils_1.toBNWei)("1.0")) && baseFeeMultiplier.lte((0, utils_1.toBNWei)("5")), "Require 1.0 < base fee multiplier (".concat(baseFeeMultiplier, ") <= 5.0 for a total gas multiplier within [+1.0, +5.0]"));
27
+ if (!((_b = opts.chainId) !== null && _b !== void 0)) return [3, 1];
28
+ _c = _b;
26
29
  return [3, 3];
27
30
  case 1: return [4, provider.getNetwork()];
28
31
  case 2:
29
- _a = (_b = _c.sent(), chainId = _b.chainId, _b);
30
- _c.label = 3;
32
+ _c = (_d.sent()).chainId;
33
+ _d.label = 3;
31
34
  case 3:
32
- _a;
35
+ chainId = _c;
36
+ optsWithDefaults = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, GAS_PRICE_ESTIMATE_DEFAULTS), { baseFeeMultiplier: baseFeeMultiplier }), opts), { chainId: chainId });
33
37
  useViem = process.env["NEW_GAS_PRICE_ORACLE_".concat(chainId)] === "true";
34
38
  return [2, useViem
35
- ? getViemGasPriceEstimate(chainId, transport)
36
- : getEthersGasPriceEstimate(provider, chainId, legacyFallback)];
39
+ ? _getViemGasPriceEstimate(chainId, optsWithDefaults)
40
+ : _getEthersGasPriceEstimate(provider, optsWithDefaults)];
37
41
  }
38
42
  });
39
43
  });
40
44
  }
41
45
  exports.getGasPriceEstimate = getGasPriceEstimate;
42
- function getEthersGasPriceEstimate(provider, chainId, legacyFallback) {
46
+ function _getEthersGasPriceEstimate(provider, opts) {
43
47
  var _a;
44
- if (legacyFallback === void 0) { legacyFallback = true; }
48
+ var chainId = opts.chainId, legacyFallback = opts.legacyFallback;
45
49
  var gasPriceFeeds = (_a = {},
46
50
  _a[constants_1.CHAIN_IDs.ALEPH_ZERO] = arbitrum.eip1559,
47
51
  _a[constants_1.CHAIN_IDs.ARBITRUM] = arbitrum.eip1559,
@@ -54,15 +58,16 @@ function getEthersGasPriceEstimate(provider, chainId, legacyFallback) {
54
58
  var gasPriceFeed = gasPriceFeeds[chainId];
55
59
  (0, assert_1.default)(gasPriceFeed || legacyFallback, "No suitable gas price oracle for Chain ID ".concat(chainId));
56
60
  gasPriceFeed !== null && gasPriceFeed !== void 0 ? gasPriceFeed : (gasPriceFeed = (0, utils_1.chainIsOPStack)(chainId) ? ethereum.eip1559 : ethereum.legacy);
57
- return gasPriceFeed(provider, chainId);
61
+ return gasPriceFeed(provider, opts);
58
62
  }
59
- function getViemGasPriceEstimate(providerOrChainId, transport) {
63
+ function _getViemGasPriceEstimate(providerOrChainId, opts) {
60
64
  return tslib_1.__awaiter(this, void 0, void 0, function () {
61
- var chainId, _a, viemProvider, gasPriceFeeds, maxFeePerGas, maxPriorityFeePerGas, gasPrice;
65
+ var baseFeeMultiplier, transport, chainId, _a, viemProvider, gasPriceFeeds, maxFeePerGas, maxPriorityFeePerGas, gasPrice;
62
66
  var _b, _c, _d;
63
67
  return tslib_1.__generator(this, function (_e) {
64
68
  switch (_e.label) {
65
69
  case 0:
70
+ baseFeeMultiplier = opts.baseFeeMultiplier, transport = opts.transport;
66
71
  if (!(typeof providerOrChainId === "number")) return [3, 1];
67
72
  _a = providerOrChainId;
68
73
  return [3, 3];
@@ -74,13 +79,10 @@ function getViemGasPriceEstimate(providerOrChainId, transport) {
74
79
  chainId = _a;
75
80
  viemProvider = (0, util_1.getPublicClient)(chainId, transport);
76
81
  gasPriceFeeds = (_b = {},
77
- _b[constants_1.CHAIN_IDs.ALEPH_ZERO] = arbitrumViem.eip1559,
78
- _b[constants_1.CHAIN_IDs.ARBITRUM] = arbitrumViem.eip1559,
79
82
  _b[constants_1.CHAIN_IDs.LINEA] = lineaViem.eip1559,
80
- _b[constants_1.CHAIN_IDs.POLYGON] = polygonViem.gasStation,
81
83
  _b);
82
84
  if (!gasPriceFeeds[chainId]) return [3, 5];
83
- return [4, gasPriceFeeds[chainId](viemProvider, chainId)];
85
+ return [4, gasPriceFeeds[chainId](viemProvider, opts)];
84
86
  case 4:
85
87
  (_c = _e.sent(), maxFeePerGas = _c.maxFeePerGas, maxPriorityFeePerGas = _c.maxPriorityFeePerGas);
86
88
  return [3, 7];
@@ -89,7 +91,7 @@ function getViemGasPriceEstimate(providerOrChainId, transport) {
89
91
  return [4, viemProvider.estimateFeesPerGas()];
90
92
  case 6:
91
93
  (_d = _e.sent(), maxFeePerGas = _d.maxFeePerGas, maxPriorityFeePerGas = _d.maxPriorityFeePerGas, gasPrice = _d.gasPrice);
92
- maxFeePerGas !== null && maxFeePerGas !== void 0 ? maxFeePerGas : (maxFeePerGas = gasPrice);
94
+ maxFeePerGas !== null && maxFeePerGas !== void 0 ? maxFeePerGas : (maxFeePerGas = (gasPrice * BigInt(baseFeeMultiplier.toString())) / BigInt(utils_1.fixedPointAdjustment.toString()));
93
95
  maxPriorityFeePerGas !== null && maxPriorityFeePerGas !== void 0 ? maxPriorityFeePerGas : (maxPriorityFeePerGas = BigInt(0));
94
96
  _e.label = 7;
95
97
  case 7: return [2, {
@@ -100,5 +102,5 @@ function getViemGasPriceEstimate(providerOrChainId, transport) {
100
102
  });
101
103
  });
102
104
  }
103
- exports.getViemGasPriceEstimate = getViemGasPriceEstimate;
105
+ exports._getViemGasPriceEstimate = _getViemGasPriceEstimate;
104
106
  //# sourceMappingURL=oracle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oracle.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":";;;;AAAA,0DAA4B;AAG5B,0CAAyC;AAC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BAAoB,aAApB,oBAAoB,cAApB,oBAAoB,IAApB,oBAAoB,GAAK,MAAM,CAAC,CAAC,CAAC,EAAC;;wBAGrC,WAAO;wBACL,YAAY,EAAE,iBAAS,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;wBACrD,oBAAoB,EAAE,iBAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC;qBACtE,EAAC;;;;CACH;AA9BD,4DA8BC"}
@@ -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>;