@across-protocol/sdk 3.3.31 → 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.
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +8 -2
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +2 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +2 -2
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +6 -4
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +21 -13
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.d.ts +2 -1
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +16 -10
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/linea.d.ts +2 -1
- package/dist/cjs/gasPriceOracle/adapters/linea.js +2 -2
- package/dist/cjs/gasPriceOracle/adapters/linea.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +21 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.js +45 -5
- package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/cjs/gasPriceOracle/oracle.d.ts +11 -3
- package/dist/cjs/gasPriceOracle/oracle.js +29 -27
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/providers/types.d.ts +3 -3
- package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
- package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js +2 -12
- package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +10 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +55 -11
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +4 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js +2 -12
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +1 -0
- package/dist/cjs/utils/DepositUtils.js +5 -1
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/Multicall.js +0 -5
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +1 -8
- package/dist/cjs/utils/common.js +1 -83
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +16 -3
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
- package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +10 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +10 -4
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +19 -6
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +38 -16
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/linea-viem.d.ts +19 -1
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js +33 -10
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/linea.d.ts +2 -1
- package/dist/esm/gasPriceOracle/adapters/linea.js +6 -2
- package/dist/esm/gasPriceOracle/adapters/linea.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +27 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.js +49 -5
- package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/esm/gasPriceOracle/oracle.d.ts +16 -8
- package/dist/esm/gasPriceOracle/oracle.js +35 -33
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/providers/types.d.ts +3 -3
- package/dist/esm/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
- package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js +3 -13
- package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +21 -7
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +68 -15
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +4 -5
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.js +3 -13
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +9 -0
- package/dist/esm/utils/DepositUtils.js +11 -0
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/Multicall.js +1 -6
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/common.d.ts +1 -19
- package/dist/esm/utils/common.js +3 -95
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +10 -1
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +19 -6
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts +19 -1
- package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/linea.d.ts +2 -1
- package/dist/types/gasPriceOracle/adapters/linea.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts +27 -1
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts +16 -8
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/providers/types.d.ts +3 -3
- package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
- package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +21 -7
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
- package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +9 -0
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts +1 -19
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +17 -2
- package/src/gasPriceOracle/adapters/arbitrum.ts +13 -6
- package/src/gasPriceOracle/adapters/ethereum.ts +43 -12
- package/src/gasPriceOracle/adapters/linea-viem.ts +32 -6
- package/src/gasPriceOracle/adapters/linea.ts +7 -2
- package/src/gasPriceOracle/adapters/polygon.ts +46 -5
- package/src/gasPriceOracle/oracle.ts +53 -28
- package/src/relayFeeCalculator/chain-queries/alephZero.ts +1 -29
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +73 -20
- package/src/relayFeeCalculator/chain-queries/factory.ts +6 -6
- package/src/relayFeeCalculator/chain-queries/polygon.ts +1 -29
- package/src/relayFeeCalculator/relayFeeCalculator.ts +6 -1
- package/src/utils/DepositUtils.ts +12 -0
- package/src/utils/Multicall.ts +1 -6
- package/src/utils/common.ts +2 -92
- package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -3
- package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js +0 -21
- package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js.map +0 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -4
- package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js +0 -26
- package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js.map +0 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon-viem.d.ts +0 -3
- package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js +0 -84
- package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -3
- package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js +0 -20
- package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js.map +0 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -4
- package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js +0 -21
- package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js.map +0 -1
- package/dist/esm/gasPriceOracle/adapters/polygon-viem.d.ts +0 -3
- package/dist/esm/gasPriceOracle/adapters/polygon-viem.js +0 -82
- package/dist/esm/gasPriceOracle/adapters/polygon-viem.js.map +0 -1
- package/dist/esm/package.json +0 -1
- package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -4
- package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts.map +0 -1
- package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -5
- package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts.map +0 -1
- package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts +0 -4
- package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts.map +0 -1
- package/src/gasPriceOracle/adapters/arbitrum-viem.ts +0 -13
- package/src/gasPriceOracle/adapters/ethereum-viem.ts +0 -19
- package/src/gasPriceOracle/adapters/polygon-viem.ts +0 -86
|
@@ -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
|
|
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
|
-
|
|
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,
|
|
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;
|
|
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,oBAAoB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAsB7B,IAAA,OAAO,GAAK,SAAS,QAAd,CAAe;AAE9B;IAAuC,qCAAe;IAGpD,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,CAAC,KAAA;QAChE,IAAI,GAAG,CAAA,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,OAAO,KAAK,OAAO,EAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,uCAAuC,CAAC;gBAE/G,kBAAM,qBAAqB,EAAE,IAAI,EAAE,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC;QACxD,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;IACzB,CAAC;IAEK,sCAAU,GAAhB,UAAiB,QAAkD;QAAlD,yBAAA,EAAA,iBAAkD;;;;;;4BACrD,qBAAM,I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OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;qBACrF;;;;oBAI2C,qBAAM,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,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
|
|
9
|
-
* @returns
|
|
15
|
+
* @param {opts} GasPriceEstimateOptions optional parameters.
|
|
16
|
+
* @returns An object of type GasPriceEstimate.
|
|
10
17
|
*/
|
|
11
|
-
export declare function getGasPriceEstimate(provider: providers.Provider,
|
|
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
|
|
16
|
-
* @
|
|
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
|
|
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
|
-
|
|
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
|
|
18
|
-
* @returns
|
|
17
|
+
* @param {opts} GasPriceEstimateOptions optional parameters.
|
|
18
|
+
* @returns An object of type GasPriceEstimate.
|
|
19
19
|
*/
|
|
20
|
-
export function getGasPriceEstimate(provider,
|
|
21
|
-
|
|
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
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
+
_c = (_d.sent()).chainId;
|
|
36
|
+
_d.label = 3;
|
|
35
37
|
case 3:
|
|
36
|
-
|
|
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
|
-
?
|
|
40
|
-
:
|
|
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
|
|
53
|
+
* @returns An object of type GasPriceEstimate.
|
|
51
54
|
*/
|
|
52
|
-
function
|
|
55
|
+
function _getEthersGasPriceEstimate(provider, opts) {
|
|
53
56
|
var _a;
|
|
54
|
-
|
|
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,
|
|
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
|
|
73
|
-
* @
|
|
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
|
|
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,
|
|
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,EAA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,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>;
|
|
@@ -1,233 +1,4 @@
|
|
|
1
|
-
import { Logger } from "../relayFeeCalculator";
|
|
2
|
-
import { providers } from "ethers";
|
|
3
1
|
import { QueryBase } from "./baseQuery";
|
|
4
2
|
export declare class AlephZeroQueries extends QueryBase {
|
|
5
|
-
constructor(provider: providers.Provider, symbolMapping?: {
|
|
6
|
-
ACX: {
|
|
7
|
-
name: string;
|
|
8
|
-
symbol: string;
|
|
9
|
-
decimals: number;
|
|
10
|
-
addresses: {
|
|
11
|
-
[x: number]: string;
|
|
12
|
-
};
|
|
13
|
-
coingeckoId: string;
|
|
14
|
-
};
|
|
15
|
-
ARB: {
|
|
16
|
-
name: string;
|
|
17
|
-
symbol: string;
|
|
18
|
-
decimals: number;
|
|
19
|
-
addresses: {
|
|
20
|
-
[x: number]: string;
|
|
21
|
-
};
|
|
22
|
-
coingeckoId: string;
|
|
23
|
-
};
|
|
24
|
-
AZERO: {
|
|
25
|
-
name: string;
|
|
26
|
-
symbol: string;
|
|
27
|
-
decimals: number;
|
|
28
|
-
addresses: {
|
|
29
|
-
[x: number]: string;
|
|
30
|
-
};
|
|
31
|
-
coingeckoId: string;
|
|
32
|
-
};
|
|
33
|
-
BAL: {
|
|
34
|
-
name: string;
|
|
35
|
-
symbol: string;
|
|
36
|
-
decimals: number;
|
|
37
|
-
addresses: {
|
|
38
|
-
[x: number]: string;
|
|
39
|
-
};
|
|
40
|
-
coingeckoId: string;
|
|
41
|
-
};
|
|
42
|
-
BADGER: {
|
|
43
|
-
name: string;
|
|
44
|
-
symbol: string;
|
|
45
|
-
decimals: number;
|
|
46
|
-
addresses: {
|
|
47
|
-
[x: number]: string;
|
|
48
|
-
};
|
|
49
|
-
coingeckoId: string;
|
|
50
|
-
};
|
|
51
|
-
BOBA: {
|
|
52
|
-
name: string;
|
|
53
|
-
symbol: string;
|
|
54
|
-
decimals: number;
|
|
55
|
-
addresses: {
|
|
56
|
-
[x: number]: string;
|
|
57
|
-
};
|
|
58
|
-
coingeckoId: string;
|
|
59
|
-
};
|
|
60
|
-
DAI: {
|
|
61
|
-
name: string;
|
|
62
|
-
symbol: string;
|
|
63
|
-
decimals: number;
|
|
64
|
-
addresses: {
|
|
65
|
-
[x: number]: string;
|
|
66
|
-
};
|
|
67
|
-
coingeckoId: string;
|
|
68
|
-
};
|
|
69
|
-
ETH: {
|
|
70
|
-
name: string;
|
|
71
|
-
symbol: string;
|
|
72
|
-
decimals: number;
|
|
73
|
-
addresses: {
|
|
74
|
-
[x: number]: string;
|
|
75
|
-
};
|
|
76
|
-
coingeckoId: string;
|
|
77
|
-
};
|
|
78
|
-
GHO: {
|
|
79
|
-
name: string;
|
|
80
|
-
symbol: string;
|
|
81
|
-
decimals: number;
|
|
82
|
-
addresses: {
|
|
83
|
-
[x: number]: string;
|
|
84
|
-
};
|
|
85
|
-
coingeckoId: string;
|
|
86
|
-
};
|
|
87
|
-
LSK: {
|
|
88
|
-
name: string;
|
|
89
|
-
symbol: string;
|
|
90
|
-
decimals: number;
|
|
91
|
-
addresses: {
|
|
92
|
-
[x: number]: string;
|
|
93
|
-
};
|
|
94
|
-
coingeckoId: string;
|
|
95
|
-
};
|
|
96
|
-
MATIC: {
|
|
97
|
-
name: string;
|
|
98
|
-
symbol: string;
|
|
99
|
-
decimals: number;
|
|
100
|
-
addresses: {
|
|
101
|
-
[x: number]: string;
|
|
102
|
-
};
|
|
103
|
-
coingeckoId: string;
|
|
104
|
-
};
|
|
105
|
-
OP: {
|
|
106
|
-
name: string;
|
|
107
|
-
symbol: string;
|
|
108
|
-
decimals: number;
|
|
109
|
-
addresses: {
|
|
110
|
-
[x: number]: string;
|
|
111
|
-
};
|
|
112
|
-
coingeckoId: string;
|
|
113
|
-
};
|
|
114
|
-
POOL: {
|
|
115
|
-
name: string;
|
|
116
|
-
symbol: string;
|
|
117
|
-
decimals: number;
|
|
118
|
-
addresses: {
|
|
119
|
-
[x: number]: string;
|
|
120
|
-
};
|
|
121
|
-
coingeckoId: string;
|
|
122
|
-
};
|
|
123
|
-
SNX: {
|
|
124
|
-
name: string;
|
|
125
|
-
symbol: string;
|
|
126
|
-
decimals: number;
|
|
127
|
-
addresses: {
|
|
128
|
-
[x: number]: string;
|
|
129
|
-
};
|
|
130
|
-
coingeckoId: string;
|
|
131
|
-
};
|
|
132
|
-
UMA: {
|
|
133
|
-
name: string;
|
|
134
|
-
symbol: string;
|
|
135
|
-
decimals: number;
|
|
136
|
-
addresses: {
|
|
137
|
-
[x: number]: string;
|
|
138
|
-
};
|
|
139
|
-
coingeckoId: string;
|
|
140
|
-
};
|
|
141
|
-
USDB: {
|
|
142
|
-
name: string;
|
|
143
|
-
symbol: string;
|
|
144
|
-
decimals: number;
|
|
145
|
-
addresses: {
|
|
146
|
-
[x: number]: string;
|
|
147
|
-
};
|
|
148
|
-
coingeckoId: string;
|
|
149
|
-
};
|
|
150
|
-
USDC: {
|
|
151
|
-
name: string;
|
|
152
|
-
symbol: string;
|
|
153
|
-
decimals: number;
|
|
154
|
-
addresses: {
|
|
155
|
-
[x: number]: string;
|
|
156
|
-
};
|
|
157
|
-
coingeckoId: string;
|
|
158
|
-
};
|
|
159
|
-
"USDC.e": {
|
|
160
|
-
name: string;
|
|
161
|
-
symbol: string;
|
|
162
|
-
decimals: number;
|
|
163
|
-
addresses: {
|
|
164
|
-
[x: number]: string;
|
|
165
|
-
};
|
|
166
|
-
coingeckoId: string;
|
|
167
|
-
};
|
|
168
|
-
USDbC: {
|
|
169
|
-
name: string;
|
|
170
|
-
symbol: string;
|
|
171
|
-
decimals: number;
|
|
172
|
-
addresses: {
|
|
173
|
-
[x: number]: string;
|
|
174
|
-
};
|
|
175
|
-
coingeckoId: string;
|
|
176
|
-
};
|
|
177
|
-
USDzC: {
|
|
178
|
-
name: string;
|
|
179
|
-
symbol: string;
|
|
180
|
-
decimals: number;
|
|
181
|
-
addresses: {
|
|
182
|
-
[x: number]: string;
|
|
183
|
-
};
|
|
184
|
-
coingeckoId: string;
|
|
185
|
-
};
|
|
186
|
-
USDT: {
|
|
187
|
-
name: string;
|
|
188
|
-
symbol: string;
|
|
189
|
-
decimals: number;
|
|
190
|
-
addresses: {
|
|
191
|
-
[x: number]: string;
|
|
192
|
-
};
|
|
193
|
-
coingeckoId: string;
|
|
194
|
-
};
|
|
195
|
-
WAZERO: {
|
|
196
|
-
name: string;
|
|
197
|
-
symbol: string;
|
|
198
|
-
decimals: number;
|
|
199
|
-
addresses: {
|
|
200
|
-
[x: number]: string;
|
|
201
|
-
};
|
|
202
|
-
coingeckoId: string;
|
|
203
|
-
};
|
|
204
|
-
WBTC: {
|
|
205
|
-
name: string;
|
|
206
|
-
symbol: string;
|
|
207
|
-
decimals: number;
|
|
208
|
-
addresses: {
|
|
209
|
-
[x: number]: string;
|
|
210
|
-
};
|
|
211
|
-
coingeckoId: string;
|
|
212
|
-
};
|
|
213
|
-
WETH: {
|
|
214
|
-
name: string;
|
|
215
|
-
symbol: string;
|
|
216
|
-
decimals: number;
|
|
217
|
-
addresses: {
|
|
218
|
-
[x: number]: string;
|
|
219
|
-
};
|
|
220
|
-
coingeckoId: string;
|
|
221
|
-
};
|
|
222
|
-
WMATIC: {
|
|
223
|
-
name: string;
|
|
224
|
-
symbol: string;
|
|
225
|
-
decimals: number;
|
|
226
|
-
addresses: {
|
|
227
|
-
[x: number]: string;
|
|
228
|
-
};
|
|
229
|
-
coingeckoId: string;
|
|
230
|
-
};
|
|
231
|
-
}, spokePoolAddress?: string | undefined, simulatedRelayerAddress?: string, coingeckoProApiKey?: string, logger?: Logger, gasMarkup?: number);
|
|
232
3
|
getTokenPrice(tokenSymbol: string): Promise<number>;
|
|
233
4
|
}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import { __awaiter, __extends, __generator } from "tslib";
|
|
2
|
-
import
|
|
3
|
-
import { getDeployedAddress } from "../../utils/DeploymentUtils";
|
|
4
|
-
import { DEFAULT_LOGGER } from "../relayFeeCalculator";
|
|
5
|
-
import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../../constants";
|
|
2
|
+
import { CHAIN_IDs } from "../../constants";
|
|
6
3
|
import { Coingecko } from "../../coingecko/Coingecko";
|
|
7
|
-
import { isDefined } from "../../utils";
|
|
8
4
|
import { QueryBase } from "./baseQuery";
|
|
9
5
|
var AlephZeroQueries = /** @class */ (function (_super) {
|
|
10
6
|
__extends(AlephZeroQueries, _super);
|
|
11
|
-
function AlephZeroQueries(
|
|
12
|
-
|
|
13
|
-
if (spokePoolAddress === void 0) { spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.ALEPH_ZERO); }
|
|
14
|
-
if (simulatedRelayerAddress === void 0) { simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS; }
|
|
15
|
-
if (logger === void 0) { logger = DEFAULT_LOGGER; }
|
|
16
|
-
if (gasMarkup === void 0) { gasMarkup = 0; }
|
|
17
|
-
assert(isDefined(spokePoolAddress));
|
|
18
|
-
return _super.call(this, provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey, undefined, "usd") || this;
|
|
7
|
+
function AlephZeroQueries() {
|
|
8
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
19
9
|
}
|
|
20
10
|
AlephZeroQueries.prototype.getTokenPrice = function (tokenSymbol) {
|
|
21
11
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alephZero.js","sourceRoot":"","sources":["../../../../src/relayFeeCalculator/chain-queries/alephZero.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"alephZero.js","sourceRoot":"","sources":["../../../../src/relayFeeCalculator/chain-queries/alephZero.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;IAAsC,oCAAS;IAA/C;;IAeA,CAAC;IAdgB,wCAAa,GAA5B,UAA6B,WAAmB;;;;;;wBAC9C,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;4BAAE,MAAM,IAAI,KAAK,CAAC,UAAG,WAAW,+BAA4B,CAAC,CAAC;wBAC5F,iBAAiB,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;wBACvD,qBAAM,iBAAiB,CAAC,yBAAyB,CACtE,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,EAC5D,KAAK,CACN,EAAA;;wBAHK,KAAiB,SAGtB,EAHQ,UAAU,QAAA;wBAKQ,qBAAM,iBAAiB,CAAC,yBAAyB,CAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,EACxD,KAAK,CACN,EAAA;;wBAHK,KAAqB,SAG1B,EAHQ,cAAc,QAAA;wBAIvB,sBAAO,MAAM,CAAC,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAC;;;;KAC5F;IACH,uBAAC;AAAD,CAAC,AAfD,CAAsC,SAAS,GAe9C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { L2Provider } from "@eth-optimism/sdk/dist/interfaces/l2-provider";
|
|
2
|
-
import { providers } from "ethers";
|
|
2
|
+
import { PopulatedTransaction, providers } from "ethers";
|
|
3
3
|
import { Deposit } from "../../interfaces";
|
|
4
4
|
import { SpokePool } from "../../typechain";
|
|
5
|
-
import { BigNumberish, TransactionCostEstimate } from "../../utils";
|
|
5
|
+
import { BigNumberish, TransactionCostEstimate, BigNumber } from "../../utils";
|
|
6
6
|
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
7
7
|
import { Transport } from "viem";
|
|
8
8
|
type Provider = providers.Provider;
|
|
@@ -20,7 +20,6 @@ export declare class QueryBase implements QueryInterface {
|
|
|
20
20
|
readonly symbolMapping: SymbolMappingType;
|
|
21
21
|
readonly spokePoolAddress: string;
|
|
22
22
|
readonly simulatedRelayerAddress: string;
|
|
23
|
-
readonly gasMarkup: number;
|
|
24
23
|
readonly logger: Logger;
|
|
25
24
|
readonly coingeckoProApiKey?: string | undefined;
|
|
26
25
|
readonly fixedGasPrice?: BigNumberish | undefined;
|
|
@@ -32,13 +31,12 @@ export declare class QueryBase implements QueryInterface {
|
|
|
32
31
|
* @param symbolMapping A mapping to valid ERC20 tokens and their respective characteristics
|
|
33
32
|
* @param spokePoolAddress The valid address of the Spoke Pool deployment
|
|
34
33
|
* @param simulatedRelayerAddress The address that these queries will reference as the sender. Note: This address must be approved for USDC
|
|
35
|
-
* @param gasMarkup A multiplier that is applied to the total gas estimate
|
|
36
34
|
* @param logger A logging utility to report logs
|
|
37
35
|
* @param coingeckoProApiKey An optional CoinGecko API key that links to a PRO account
|
|
38
36
|
* @param fixedGasPrice Overrides the gas price with a fixed value. Note: primarily used for the Boba blockchain
|
|
39
37
|
* @param coingeckoBaseCurrency The basis currency that CoinGecko will use to resolve pricing
|
|
40
38
|
*/
|
|
41
|
-
constructor(provider: Provider | OptimismProvider, symbolMapping: SymbolMappingType, spokePoolAddress: string, simulatedRelayerAddress: string,
|
|
39
|
+
constructor(provider: Provider | OptimismProvider, symbolMapping: SymbolMappingType, spokePoolAddress: string, simulatedRelayerAddress: string, logger: Logger, coingeckoProApiKey?: string | undefined, fixedGasPrice?: BigNumberish | undefined, coingeckoBaseCurrency?: string);
|
|
42
40
|
/**
|
|
43
41
|
* Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
|
|
44
42
|
* @param deposit V3 deposit instance.
|
|
@@ -46,14 +44,30 @@ export declare class QueryBase implements QueryInterface {
|
|
|
46
44
|
* @param options
|
|
47
45
|
* @param options.gasPrice Optional gas price to use for the simulation.
|
|
48
46
|
* @param options.gasUnits Optional gas units to use for the simulation.
|
|
49
|
-
* @param options.omitMarkup Optional flag to omit the gas markup.
|
|
50
47
|
* @param options.transport Optional transport object for custom gas price retrieval.
|
|
51
48
|
* @returns The gas estimate for this function call (multiplied with the optional buffer).
|
|
52
49
|
*/
|
|
53
50
|
getGasCosts(deposit: Deposit, relayer?: string, options?: Partial<{
|
|
54
51
|
gasPrice: BigNumberish;
|
|
55
52
|
gasUnits: BigNumberish;
|
|
56
|
-
|
|
53
|
+
baseFeeMultiplier: BigNumber;
|
|
54
|
+
transport: Transport;
|
|
55
|
+
}>): Promise<TransactionCostEstimate>;
|
|
56
|
+
/**
|
|
57
|
+
* Estimates the total gas cost required to submit an unsigned (populated) transaction on-chain.
|
|
58
|
+
* @param unsignedTx The unsigned transaction that this function will estimate.
|
|
59
|
+
* @param senderAddress The address that the transaction will be submitted from.
|
|
60
|
+
* @param provider A valid ethers provider - will be used to reason the gas price.
|
|
61
|
+
* @param options
|
|
62
|
+
* @param options.gasPrice A manually provided gas price - if set, this function will not resolve the current gas price.
|
|
63
|
+
* @param options.gasUnits A manually provided gas units - if set, this function will not estimate the gas units.
|
|
64
|
+
* @param options.transport A custom transport object for custom gas price retrieval.
|
|
65
|
+
* @returns Estimated cost in units of gas and the underlying gas token (gasPrice * estimatedGasUnits).
|
|
66
|
+
*/
|
|
67
|
+
estimateGas(unsignedTx: PopulatedTransaction, senderAddress: string, provider: providers.Provider | L2Provider<providers.Provider>, options?: Partial<{
|
|
68
|
+
gasPrice: BigNumberish;
|
|
69
|
+
gasUnits: BigNumberish;
|
|
70
|
+
baseFeeMultiplier: BigNumber;
|
|
57
71
|
transport: Transport;
|
|
58
72
|
}>): Promise<TransactionCostEstimate>;
|
|
59
73
|
/**
|