@across-protocol/sdk 4.1.11 → 4.1.12

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.
@@ -4,5 +4,4 @@ import { GasPriceEstimate } from "../types";
4
4
  import { GasPriceEstimateOptions } from "../oracle";
5
5
  export declare function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
6
6
  export declare function eip1559Raw(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber, priorityFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
7
- export declare function eip1559Bad(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber, priorityFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
8
7
  export declare function legacy(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.legacy = exports.eip1559Bad = exports.eip1559Raw = exports.eip1559 = void 0;
3
+ exports.legacy = exports.eip1559Raw = exports.eip1559 = void 0;
4
4
  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
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, opts.priorityFeeMultiplier)
12
- : eip1559Bad(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier);
9
+ return eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier);
13
10
  }
14
11
  exports.eip1559 = eip1559;
15
12
  function eip1559Raw(provider, chainId, baseFeeMultiplier, priorityFeeMultiplier) {
@@ -40,30 +37,6 @@ function eip1559Raw(provider, chainId, baseFeeMultiplier, priorityFeeMultiplier)
40
37
  });
41
38
  }
42
39
  exports.eip1559Raw = eip1559Raw;
43
- function eip1559Bad(provider, chainId, baseFeeMultiplier, priorityFeeMultiplier) {
44
- return tslib_1.__awaiter(this, void 0, void 0, function () {
45
- var feeData, maxPriorityFeePerGas, scaledPriorityFee, scaledLastBaseFeePerGas, maxFeePerGas;
46
- return tslib_1.__generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0: return [4, provider.getFeeData()];
49
- case 1:
50
- feeData = _a.sent();
51
- [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach(function (field) {
52
- if (!utils_1.BigNumber.isBigNumber(field) || field.lt(utils_1.bnZero))
53
- (0, util_1.gasPriceError)("getFeeData()", chainId, feeData);
54
- });
55
- maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
56
- scaledPriorityFee = maxPriorityFeePerGas.mul(priorityFeeMultiplier).div(utils_1.fixedPointAdjustment);
57
- scaledLastBaseFeePerGas = feeData.lastBaseFeePerGas
58
- .mul(baseFeeMultiplier)
59
- .div(utils_1.fixedPointAdjustment);
60
- maxFeePerGas = scaledPriorityFee.add(scaledLastBaseFeePerGas);
61
- return [2, { maxPriorityFeePerGas: scaledPriorityFee, maxFeePerGas: maxFeePerGas }];
62
- }
63
- });
64
- });
65
- }
66
- exports.eip1559Bad = eip1559Bad;
67
40
  function legacy(provider, opts) {
68
41
  return tslib_1.__awaiter(this, void 0, void 0, function () {
69
42
  var chainId, baseFeeMultiplier, gasPrice;
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":";;;;AAAA,0DAA4B;AAE5B,qCAAkG;AAElG,gCAAwC;AAiBxC,SAAgB,OAAO,CAAC,QAA4B,EAAE,IAA6B;IACjF,IAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gCAAyB,IAAI,CAAC,OAAO,CAAE,CAAC,KAAK,MAAM,CAAC;IAC/E,OAAO,MAA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,GAAG,CAAC,4BAAoB,CAAC,CAAC;oBAC5F,wBAAwB,GAAG,IAAA,kBAAU,EAAC,OAAO,CAAC,GAAG,CAAC,mCAA4B,OAAO,CAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;oBAC1G,IAAI,iBAAiB,CAAC,EAAE,CAAC,wBAAwB,CAAC,EAAE;wBAClD,iBAAiB,GAAG,iBAAS,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;qBAC9D;oBACK,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,4BAAoB,CAAC,CAAC;oBACrF,WAAO;4BACL,YAAY,EAAE,iBAAiB,CAAC,GAAG,CAAC,aAAa,CAAC;4BAClD,oBAAoB,EAAE,iBAAiB;yBACxC,EAAC;;;;CACH;AAvBD,gCAuBC;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"}
@@ -8,12 +8,12 @@ var utils_1 = require("../utils");
8
8
  var util_1 = require("./util");
9
9
  var arbitrum = tslib_1.__importStar(require("./adapters/arbitrum"));
10
10
  var ethereum = tslib_1.__importStar(require("./adapters/ethereum"));
11
- var linea = tslib_1.__importStar(require("./adapters/linea"));
12
11
  var polygon = tslib_1.__importStar(require("./adapters/polygon"));
13
12
  var lineaViem = tslib_1.__importStar(require("./adapters/linea-viem"));
14
13
  var GAS_PRICE_ESTIMATE_DEFAULTS = {
15
14
  legacyFallback: true,
16
15
  };
16
+ var VIEM_CHAINS = [constants_1.CHAIN_IDs.LINEA];
17
17
  function getGasPriceEstimate(provider, opts) {
18
18
  var _a, _b, _c;
19
19
  if (opts === void 0) { opts = {}; }
@@ -36,7 +36,7 @@ function getGasPriceEstimate(provider, opts) {
36
36
  case 3:
37
37
  chainId = _d;
38
38
  optsWithDefaults = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, GAS_PRICE_ESTIMATE_DEFAULTS), { baseFeeMultiplier: baseFeeMultiplier, priorityFeeMultiplier: priorityFeeMultiplier }), opts), { chainId: chainId });
39
- useViem = process.env["NEW_GAS_PRICE_ORACLE_".concat(chainId)] === "true";
39
+ useViem = VIEM_CHAINS.includes(chainId);
40
40
  return [2, useViem
41
41
  ? _getViemGasPriceEstimate(chainId, optsWithDefaults)
42
42
  : _getEthersGasPriceEstimate(provider, optsWithDefaults)];
@@ -48,10 +48,10 @@ exports.getGasPriceEstimate = getGasPriceEstimate;
48
48
  function _getEthersGasPriceEstimate(provider, opts) {
49
49
  var _a;
50
50
  var chainId = opts.chainId, legacyFallback = opts.legacyFallback;
51
+ (0, assert_1.default)(!VIEM_CHAINS.includes(chainId), "Chain ID ".concat(chainId, " will use Viem gas price estimation"));
51
52
  var gasPriceFeeds = (_a = {},
52
53
  _a[constants_1.CHAIN_IDs.ALEPH_ZERO] = arbitrum.eip1559,
53
54
  _a[constants_1.CHAIN_IDs.ARBITRUM] = arbitrum.eip1559,
54
- _a[constants_1.CHAIN_IDs.LINEA] = linea.eip1559,
55
55
  _a[constants_1.CHAIN_IDs.MAINNET] = ethereum.eip1559,
56
56
  _a[constants_1.CHAIN_IDs.POLYGON] = polygon.gasStation,
57
57
  _a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AQ,EAAE,CAAC,EAAC;oBAC9G,oBAAoB,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"}
@@ -3,9 +3,7 @@ import { BigNumber } from "../../utils";
3
3
  import { GasPriceEstimate } from "../types";
4
4
  import { GasPriceEstimateOptions } from "../oracle";
5
5
  /**
6
- * @dev If GAS_PRICE_EIP1559_RAW_${chainId}=true, then constructs total fee by adding
7
- * eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas, otherwise calls the ethers provider's
8
- * getFeeData() method which adds eth_getBlock("latest").baseFee to a hardcoded priority fee of 1.5 gwei.
6
+ * @dev Constructs total fee by adding eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas
9
7
  * @param provider ethers RPC provider instance.
10
8
  * @param {GasPriceEstimateOptions} opts See notes below on specific parameters.
11
9
  * @param baseFeeMultiplier Amount to multiply base fee or total fee for legacy gas pricing.
@@ -21,16 +19,6 @@ export declare function eip1559(provider: providers.Provider, opts: GasPriceEsti
21
19
  * @returns Promise of gas price estimate object.
22
20
  */
23
21
  export declare function eip1559Raw(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber, priorityFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
24
- /**
25
- * @notice Returns fee data using provider's getFeeData() method.
26
- * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5's
27
- * getFeeData() method
28
- * @dev TODO: Remove this function soon. See note above about slowly rolling out eip1559Raw.
29
- * @param provider ethers RPC provider instance.
30
- * @param chainId Chain ID of the provider instance.
31
- * @returns Promise of gas price estimate object.
32
- */
33
- export declare function eip1559Bad(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber, priorityFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
34
22
  /**
35
23
  * @notice Returns result of eth_gasPrice RPC call
36
24
  * @dev Its recommended to use the eip1559Raw method over this one where possible as it will be more accurate.
@@ -2,13 +2,8 @@ import { __awaiter, __generator } from "tslib";
2
2
  import assert from "assert";
3
3
  import { BigNumber, bnZero, fixedPointAdjustment, getNetworkName, parseUnits } 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.
8
5
  /**
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
+ * @dev Constructs total fee by adding eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas
12
7
  * @param provider ethers RPC provider instance.
13
8
  * @param {GasPriceEstimateOptions} opts See notes below on specific parameters.
14
9
  * @param baseFeeMultiplier Amount to multiply base fee or total fee for legacy gas pricing.
@@ -16,10 +11,7 @@ import { gasPriceError } from "../util";
16
11
  * @returns Promise of gas price estimate object.
17
12
  */
18
13
  export function eip1559(provider, opts) {
19
- var useRaw = process.env["GAS_PRICE_EIP1559_RAW_".concat(opts.chainId)] === "true";
20
- return useRaw
21
- ? eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier)
22
- : eip1559Bad(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier);
14
+ return eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier);
23
15
  }
24
16
  /**
25
17
  * @note Performs direct RPC calls to retrieve the RPC-suggested priority fee for the next block.
@@ -55,38 +47,6 @@ export function eip1559Raw(provider, chainId, baseFeeMultiplier, priorityFeeMult
55
47
  });
56
48
  });
57
49
  }
58
- /**
59
- * @notice Returns fee data using provider's getFeeData() method.
60
- * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5's
61
- * getFeeData() method
62
- * @dev TODO: Remove this function soon. See note above about slowly rolling out eip1559Raw.
63
- * @param provider ethers RPC provider instance.
64
- * @param chainId Chain ID of the provider instance.
65
- * @returns Promise of gas price estimate object.
66
- */
67
- export function eip1559Bad(provider, chainId, baseFeeMultiplier, priorityFeeMultiplier) {
68
- return __awaiter(this, void 0, void 0, function () {
69
- var feeData, maxPriorityFeePerGas, scaledPriorityFee, scaledLastBaseFeePerGas, maxFeePerGas;
70
- return __generator(this, function (_a) {
71
- switch (_a.label) {
72
- case 0: return [4 /*yield*/, provider.getFeeData()];
73
- case 1:
74
- feeData = _a.sent();
75
- [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach(function (field) {
76
- if (!BigNumber.isBigNumber(field) || field.lt(bnZero))
77
- gasPriceError("getFeeData()", chainId, feeData);
78
- });
79
- maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
80
- scaledPriorityFee = maxPriorityFeePerGas.mul(priorityFeeMultiplier).div(fixedPointAdjustment);
81
- scaledLastBaseFeePerGas = feeData.lastBaseFeePerGas
82
- .mul(baseFeeMultiplier)
83
- .div(fixedPointAdjustment);
84
- maxFeePerGas = scaledPriorityFee.add(scaledLastBaseFeePerGas);
85
- return [2 /*return*/, { maxPriorityFeePerGas: scaledPriorityFee, maxFeePerGas: maxFeePerGas }];
86
- }
87
- });
88
- });
89
- }
90
50
  /**
91
51
  * @notice Returns result of eth_gasPrice RPC call
92
52
  * @dev Its recommended to use the eip1559Raw method over this one where possible as it will be more accurate.
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/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BAC3B,qBAAM,QAAQ,CAAC,WAAW,EAAE,EAAA;;oBAAvC,QAAQ,GAAG,SAA4B;oBAE7C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,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"}
@@ -5,12 +5,13 @@ import { BigNumber, chainIsOPStack, fixedPointAdjustment, toBNWei } from "../uti
5
5
  import { getPublicClient } from "./util";
6
6
  import * as arbitrum from "./adapters/arbitrum";
7
7
  import * as ethereum from "./adapters/ethereum";
8
- import * as linea from "./adapters/linea";
9
8
  import * as polygon from "./adapters/polygon";
10
9
  import * as lineaViem from "./adapters/linea-viem";
11
10
  var GAS_PRICE_ESTIMATE_DEFAULTS = {
12
11
  legacyFallback: true,
13
12
  };
13
+ // Chains that use the Viem gas price oracle.
14
+ var VIEM_CHAINS = [CHAIN_IDs.LINEA];
14
15
  /**
15
16
  * Provide an estimate for the current gas price for a particular chain.
16
17
  * @param provider A valid ethers provider.
@@ -39,7 +40,7 @@ export function getGasPriceEstimate(provider, opts) {
39
40
  case 3:
40
41
  chainId = _d;
41
42
  optsWithDefaults = __assign(__assign(__assign(__assign({}, GAS_PRICE_ESTIMATE_DEFAULTS), { baseFeeMultiplier: baseFeeMultiplier, priorityFeeMultiplier: priorityFeeMultiplier }), opts), { chainId: chainId });
42
- useViem = process.env["NEW_GAS_PRICE_ORACLE_".concat(chainId)] === "true";
43
+ useViem = VIEM_CHAINS.includes(chainId);
43
44
  return [2 /*return*/, useViem
44
45
  ? _getViemGasPriceEstimate(chainId, optsWithDefaults)
45
46
  : _getEthersGasPriceEstimate(provider, optsWithDefaults)];
@@ -57,10 +58,11 @@ export function getGasPriceEstimate(provider, opts) {
57
58
  function _getEthersGasPriceEstimate(provider, opts) {
58
59
  var _a;
59
60
  var chainId = opts.chainId, legacyFallback = opts.legacyFallback;
61
+ // There shouldn't be any chains in here that we have a Viem adapter for because we'll always use Viem in that case.
62
+ assert(!VIEM_CHAINS.includes(chainId), "Chain ID ".concat(chainId, " will use Viem gas price estimation"));
60
63
  var gasPriceFeeds = (_a = {},
61
64
  _a[CHAIN_IDs.ALEPH_ZERO] = arbitrum.eip1559,
62
65
  _a[CHAIN_IDs.ARBITRUM] = arbitrum.eip1559,
63
- _a[CHAIN_IDs.LINEA] = linea.eip1559,
64
66
  _a[CHAIN_IDs.MAINNET] = ethereum.eip1559,
65
67
  _a[CHAIN_IDs.POLYGON] = polygon.gasStation,
66
68
  _a[CHAIN_IDs.SCROLL] = ethereum.legacy,
@@ -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,oBAAoB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEpF,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,SAAS,MAAM,uBAAuB,CAAC;AAiBnD,IAAM,2BAA2B,GAAG;IAClC,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAgB,mBAAmB,CACvC,QAA4B,EAC5B,IAA2C;;I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C,YAAY,CAAC,QAAQ,EAAE,CAAC;wBACrD,oBAAoB,EAAE,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC;qBACtE,EAAC;;;;CACH"}
@@ -3,9 +3,7 @@ import { BigNumber } from "../../utils";
3
3
  import { GasPriceEstimate } from "../types";
4
4
  import { GasPriceEstimateOptions } from "../oracle";
5
5
  /**
6
- * @dev If GAS_PRICE_EIP1559_RAW_${chainId}=true, then constructs total fee by adding
7
- * eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas, otherwise calls the ethers provider's
8
- * getFeeData() method which adds eth_getBlock("latest").baseFee to a hardcoded priority fee of 1.5 gwei.
6
+ * @dev Constructs total fee by adding eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas
9
7
  * @param provider ethers RPC provider instance.
10
8
  * @param {GasPriceEstimateOptions} opts See notes below on specific parameters.
11
9
  * @param baseFeeMultiplier Amount to multiply base fee or total fee for legacy gas pricing.
@@ -21,16 +19,6 @@ export declare function eip1559(provider: providers.Provider, opts: GasPriceEsti
21
19
  * @returns Promise of gas price estimate object.
22
20
  */
23
21
  export declare function eip1559Raw(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber, priorityFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
24
- /**
25
- * @notice Returns fee data using provider's getFeeData() method.
26
- * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5's
27
- * getFeeData() method
28
- * @dev TODO: Remove this function soon. See note above about slowly rolling out eip1559Raw.
29
- * @param provider ethers RPC provider instance.
30
- * @param chainId Chain ID of the provider instance.
31
- * @returns Promise of gas price estimate object.
32
- */
33
- export declare function eip1559Bad(provider: providers.Provider, chainId: number, baseFeeMultiplier: BigNumber, priorityFeeMultiplier: BigNumber): Promise<GasPriceEstimate>;
34
22
  /**
35
23
  * @notice Returns result of eth_gasPrice RPC call
36
24
  * @dev Its recommended to use the eip1559Raw method over this one where possible as it will be more accurate.
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,SAAS,EAA4D,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAMpD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAK9G;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,SAAS,EAC5B,qBAAqB,EAAE,SAAS,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAkB3B;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,SAAS,EAC5B,qBAAqB,EAAE,SAAS,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAe3B;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAUnH"}
1
+ {"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,SAAS,EAA4D,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAA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B;AAgCD;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,iBAAiB,EAAE,SAAS,CAAC,QAAQ,GAAG,MAAM,EAC9C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CA2B3B"}
1
+ {"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAiD,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAO3C,MAAM,WAAW,uBAAuB;IAEtC,iBAAiB,EAAE,SAAS,CAAC;IAE7B,qBAAqB,EAAE,SAAS,CAAC;IAEjC,cAAc,EAAE,OAAO,CAAC;IAExB,OAAO,EAAE,MAAM,CAAC;IAEhB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAElC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AASD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,IAAI,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAC1C,OAAO,CAAC,gBAAgB,CAAC,CA0B3B;AAiCD;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,iBAAiB,EAAE,SAAS,CAAC,QAAQ,GAAG,MAAM,EAC9C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CA2B3B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "4.1.11",
4
+ "version": "4.1.12",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -5,14 +5,8 @@ import { GasPriceEstimate } from "../types";
5
5
  import { gasPriceError } from "../util";
6
6
  import { GasPriceEstimateOptions } from "../oracle";
7
7
 
8
- // TODO: We intend to remove `eip1559Bad()` as an option and make eip1559Raw the only option eventually. The reason
9
- // they both exist currently is because eip1559Raw is new and untested on production so we will slowly roll it out
10
- // by using the convenient environment variable safety guard.
11
-
12
8
  /**
13
- * @dev If GAS_PRICE_EIP1559_RAW_${chainId}=true, then constructs total fee by adding
14
- * eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas, otherwise calls the ethers provider's
15
- * getFeeData() method which adds eth_getBlock("latest").baseFee to a hardcoded priority fee of 1.5 gwei.
9
+ * @dev Constructs total fee by adding eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas
16
10
  * @param provider ethers RPC provider instance.
17
11
  * @param {GasPriceEstimateOptions} opts See notes below on specific parameters.
18
12
  * @param baseFeeMultiplier Amount to multiply base fee or total fee for legacy gas pricing.
@@ -20,10 +14,7 @@ import { GasPriceEstimateOptions } from "../oracle";
20
14
  * @returns Promise of gas price estimate object.
21
15
  */
22
16
  export function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate> {
23
- const useRaw = process.env[`GAS_PRICE_EIP1559_RAW_${opts.chainId}`] === "true";
24
- return useRaw
25
- ? eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier)
26
- : eip1559Bad(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier);
17
+ return eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier);
27
18
  }
28
19
 
29
20
  /**
@@ -58,37 +49,6 @@ export async function eip1559Raw(
58
49
  };
59
50
  }
60
51
 
61
- /**
62
- * @notice Returns fee data using provider's getFeeData() method.
63
- * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5's
64
- * getFeeData() method
65
- * @dev TODO: Remove this function soon. See note above about slowly rolling out eip1559Raw.
66
- * @param provider ethers RPC provider instance.
67
- * @param chainId Chain ID of the provider instance.
68
- * @returns Promise of gas price estimate object.
69
- */
70
- export async function eip1559Bad(
71
- provider: providers.Provider,
72
- chainId: number,
73
- baseFeeMultiplier: BigNumber,
74
- priorityFeeMultiplier: BigNumber
75
- ): Promise<GasPriceEstimate> {
76
- const feeData = await provider.getFeeData();
77
-
78
- [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach((field: BigNumber | null) => {
79
- if (!BigNumber.isBigNumber(field) || field.lt(bnZero)) gasPriceError("getFeeData()", chainId, feeData);
80
- });
81
-
82
- const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas as BigNumber;
83
- const scaledPriorityFee = maxPriorityFeePerGas.mul(priorityFeeMultiplier).div(fixedPointAdjustment);
84
- const scaledLastBaseFeePerGas = (feeData.lastBaseFeePerGas as BigNumber)
85
- .mul(baseFeeMultiplier)
86
- .div(fixedPointAdjustment);
87
- const maxFeePerGas = scaledPriorityFee.add(scaledLastBaseFeePerGas);
88
-
89
- return { maxPriorityFeePerGas: scaledPriorityFee, maxFeePerGas };
90
- }
91
-
92
52
  /**
93
53
  * @notice Returns result of eth_gasPrice RPC call
94
54
  * @dev Its recommended to use the eip1559Raw method over this one where possible as it will be more accurate.
@@ -7,7 +7,6 @@ import { GasPriceEstimate } from "./types";
7
7
  import { getPublicClient } from "./util";
8
8
  import * as arbitrum from "./adapters/arbitrum";
9
9
  import * as ethereum from "./adapters/ethereum";
10
- import * as linea from "./adapters/linea";
11
10
  import * as polygon from "./adapters/polygon";
12
11
  import * as lineaViem from "./adapters/linea-viem";
13
12
 
@@ -30,6 +29,9 @@ const GAS_PRICE_ESTIMATE_DEFAULTS = {
30
29
  legacyFallback: true,
31
30
  };
32
31
 
32
+ // Chains that use the Viem gas price oracle.
33
+ const VIEM_CHAINS = [CHAIN_IDs.LINEA];
34
+
33
35
  /**
34
36
  * Provide an estimate for the current gas price for a particular chain.
35
37
  * @param provider A valid ethers provider.
@@ -61,7 +63,7 @@ export async function getGasPriceEstimate(
61
63
  };
62
64
 
63
65
  // We only use the unsignedTx in the viem flow.
64
- const useViem = process.env[`NEW_GAS_PRICE_ORACLE_${chainId}`] === "true";
66
+ const useViem = VIEM_CHAINS.includes(chainId);
65
67
  return useViem
66
68
  ? _getViemGasPriceEstimate(chainId, optsWithDefaults)
67
69
  : _getEthersGasPriceEstimate(provider, optsWithDefaults);
@@ -80,10 +82,11 @@ function _getEthersGasPriceEstimate(
80
82
  ): Promise<GasPriceEstimate> {
81
83
  const { chainId, legacyFallback } = opts;
82
84
 
85
+ // There shouldn't be any chains in here that we have a Viem adapter for because we'll always use Viem in that case.
86
+ assert(!VIEM_CHAINS.includes(chainId), `Chain ID ${chainId} will use Viem gas price estimation`);
83
87
  const gasPriceFeeds = {
84
88
  [CHAIN_IDs.ALEPH_ZERO]: arbitrum.eip1559,
85
89
  [CHAIN_IDs.ARBITRUM]: arbitrum.eip1559,
86
- [CHAIN_IDs.LINEA]: linea.eip1559, // @todo: Support linea_estimateGas in adapter.
87
90
  [CHAIN_IDs.MAINNET]: ethereum.eip1559,
88
91
  [CHAIN_IDs.POLYGON]: polygon.gasStation,
89
92
  [CHAIN_IDs.SCROLL]: ethereum.legacy,
@@ -1,4 +0,0 @@
1
- import { providers } from "ethers";
2
- import { GasPriceEstimate } from "../types";
3
- import { GasPriceEstimateOptions } from "../oracle";
4
- export declare function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
@@ -1,10 +0,0 @@
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, opts) {
7
- return ethereum.legacy(provider, opts);
8
- }
9
- exports.eip1559 = eip1559;
10
- //# sourceMappingURL=linea.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"linea.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea.ts"],"names":[],"mappings":";;;;AAMA,2DAAuC;AAWvC,SAAgB,OAAO,CAAC,QAA4B,EAAE,IAA6B;IAKjF,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAND,0BAMC"}
@@ -1,12 +0,0 @@
1
- import { providers } from "ethers";
2
- import { GasPriceEstimate } from "../types";
3
- import { GasPriceEstimateOptions } from "../oracle";
4
- /**
5
- * Returns Linea gas price using the legacy eth_gasPrice RPC call.
6
- * @param provider
7
- * @param opts See notes below on specific parameters.
8
- * @param baseFeeMultiplier Amount to multiply total fee because this function defaults to legacy gas pricing.
9
- * @param priorityFeeMultiplier Unused in this function because this defaults to legacy gas computation.
10
- * @returns
11
- */
12
- export declare function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
@@ -1,17 +0,0 @@
1
- import * as ethereum from "./ethereum";
2
- /**
3
- * Returns Linea gas price using the legacy eth_gasPrice RPC call.
4
- * @param provider
5
- * @param opts See notes below on specific parameters.
6
- * @param baseFeeMultiplier Amount to multiply total fee because this function defaults to legacy gas pricing.
7
- * @param priorityFeeMultiplier Unused in this function because this defaults to legacy gas computation.
8
- * @returns
9
- */
10
- export function eip1559(provider, opts) {
11
- // We use the legacy method to call `eth_gasPrice` which empirically returns a more accurate
12
- // gas price estimate than `eth_maxPriorityFeePerGas` or ethersProvider.getFeeData in the EIP1559 "raw" or "bad"
13
- // cases. Based on testing, `eth_gasPrice` returns the closest price to the Linea-specific `linea_estimateGas`
14
- // endpoint which the Viem Linea adapter queries.
15
- return ethereum.legacy(provider, opts);
16
- }
17
- //# sourceMappingURL=linea.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"linea.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/linea.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAGvC;;;;;;;GAOG;AACH,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,13 +0,0 @@
1
- import { providers } from "ethers";
2
- import { GasPriceEstimate } from "../types";
3
- import { GasPriceEstimateOptions } from "../oracle";
4
- /**
5
- * Returns Linea gas price using the legacy eth_gasPrice RPC call.
6
- * @param provider
7
- * @param opts See notes below on specific parameters.
8
- * @param baseFeeMultiplier Amount to multiply total fee because this function defaults to legacy gas pricing.
9
- * @param priorityFeeMultiplier Unused in this function because this defaults to legacy gas computation.
10
- * @returns
11
- */
12
- export declare function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate>;
13
- //# sourceMappingURL=linea.d.ts.map
@@ -1 +0,0 @@
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;AAE5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAM9G"}
@@ -1,24 +0,0 @@
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
- import { GasPriceEstimateOptions } from "../oracle";
9
-
10
- /**
11
- * Returns Linea gas price using the legacy eth_gasPrice RPC call.
12
- * @param provider
13
- * @param opts See notes below on specific parameters.
14
- * @param baseFeeMultiplier Amount to multiply total fee because this function defaults to legacy gas pricing.
15
- * @param priorityFeeMultiplier Unused in this function because this defaults to legacy gas computation.
16
- * @returns
17
- */
18
- export function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate> {
19
- // We use the legacy method to call `eth_gasPrice` which empirically returns a more accurate
20
- // gas price estimate than `eth_maxPriorityFeePerGas` or ethersProvider.getFeeData in the EIP1559 "raw" or "bad"
21
- // cases. Based on testing, `eth_gasPrice` returns the closest price to the Linea-specific `linea_estimateGas`
22
- // endpoint which the Viem Linea adapter queries.
23
- return ethereum.legacy(provider, opts);
24
- }