@across-protocol/sdk 3.2.13 → 3.2.14
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/utils/SuperstructUtils.d.ts +30 -30
- package/dist/cjs/coingecko/Coingecko.d.ts +9 -1
- package/dist/cjs/coingecko/Coingecko.js +94 -46
- package/dist/cjs/coingecko/Coingecko.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js +21 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.d.ts +4 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js +26 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon-viem.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js +84 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js.map +1 -0
- package/dist/cjs/gasPriceOracle/oracle.d.ts +3 -1
- package/dist/cjs/gasPriceOracle/oracle.js +71 -4
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.d.ts +3 -2
- package/dist/cjs/gasPriceOracle/util.d.ts +3 -3
- package/dist/cjs/gasPriceOracle/util.js +12 -1
- package/dist/cjs/gasPriceOracle/util.js.map +1 -1
- package/dist/cjs/providers/types.d.ts +3 -3
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +7 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +13 -8
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +8 -2
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +4 -2
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +6 -1
- package/dist/cjs/utils/common.js +21 -17
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +30 -30
- package/dist/esm/coingecko/Coingecko.d.ts +9 -1
- package/dist/esm/coingecko/Coingecko.js +96 -46
- package/dist/esm/coingecko/Coingecko.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js +20 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum-viem.d.ts +4 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js +21 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/polygon-viem.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/polygon-viem.js +82 -0
- package/dist/esm/gasPriceOracle/adapters/polygon-viem.js.map +1 -0
- package/dist/esm/gasPriceOracle/oracle.d.ts +9 -1
- package/dist/esm/gasPriceOracle/oracle.js +82 -3
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.d.ts +3 -2
- package/dist/esm/gasPriceOracle/util.d.ts +3 -3
- package/dist/esm/gasPriceOracle/util.js +9 -0
- package/dist/esm/gasPriceOracle/util.js.map +1 -1
- package/dist/esm/providers/types.d.ts +3 -3
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +12 -3
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +18 -10
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +8 -2
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +4 -2
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/common.d.ts +10 -3
- package/dist/esm/utils/common.js +25 -19
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +30 -30
- package/dist/types/coingecko/Coingecko.d.ts +9 -1
- package/dist/types/coingecko/Coingecko.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts +5 -0
- package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/oracle.d.ts +9 -1
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/types.d.ts +3 -2
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/util.d.ts +3 -3
- package/dist/types/gasPriceOracle/util.d.ts.map +1 -1
- package/dist/types/providers/types.d.ts +3 -3
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +12 -3
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +8 -2
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts +10 -3
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/coingecko/Coingecko.ts +94 -47
- package/src/gasPriceOracle/adapters/arbitrum-viem.ts +13 -0
- package/src/gasPriceOracle/adapters/ethereum-viem.ts +19 -0
- package/src/gasPriceOracle/adapters/polygon-viem.ts +86 -0
- package/src/gasPriceOracle/oracle.ts +69 -5
- package/src/gasPriceOracle/types.ts +4 -2
- package/src/gasPriceOracle/util.ts +12 -3
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +19 -7
- package/src/relayFeeCalculator/relayFeeCalculator.ts +15 -12
- package/src/utils/common.ts +15 -6
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGasPriceEstimate = void 0;
|
|
3
|
+
exports.getViemGasPriceEstimate = exports.getGasPriceEstimate = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var constants_1 = require("../constants");
|
|
6
6
|
var utils_1 = require("../utils");
|
|
7
|
+
var util_1 = require("./util");
|
|
7
8
|
var arbitrum = tslib_1.__importStar(require("./adapters/arbitrum"));
|
|
8
9
|
var ethereum = tslib_1.__importStar(require("./adapters/ethereum"));
|
|
9
10
|
var linea = tslib_1.__importStar(require("./adapters/linea"));
|
|
10
11
|
var polygon = tslib_1.__importStar(require("./adapters/polygon"));
|
|
11
|
-
|
|
12
|
+
var arbitrumViem = tslib_1.__importStar(require("./adapters/arbitrum-viem"));
|
|
13
|
+
var polygonViem = tslib_1.__importStar(require("./adapters/polygon-viem"));
|
|
14
|
+
function getGasPriceEstimate(provider, chainId, transport, legacyFallback) {
|
|
15
|
+
if (legacyFallback === void 0) { legacyFallback = true; }
|
|
16
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
17
|
+
var useViem;
|
|
18
|
+
return tslib_1.__generator(this, function (_a) {
|
|
19
|
+
switch (_a.label) {
|
|
20
|
+
case 0:
|
|
21
|
+
if (!(chainId === undefined)) return [3, 2];
|
|
22
|
+
return [4, provider.getNetwork()];
|
|
23
|
+
case 1:
|
|
24
|
+
(chainId = (_a.sent()).chainId);
|
|
25
|
+
_a.label = 2;
|
|
26
|
+
case 2:
|
|
27
|
+
useViem = process.env["NEW_GAS_PRICE_ORACLE_".concat(chainId)] === "true";
|
|
28
|
+
return [2, useViem
|
|
29
|
+
? getViemGasPriceEstimate(chainId, transport)
|
|
30
|
+
: getEthersGasPriceEstimate(provider, chainId, legacyFallback)];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.getGasPriceEstimate = getGasPriceEstimate;
|
|
36
|
+
function getEthersGasPriceEstimate(provider, chainId, legacyFallback) {
|
|
12
37
|
if (legacyFallback === void 0) { legacyFallback = true; }
|
|
13
38
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
14
39
|
var gasPriceFeeds, gasPriceFeed;
|
|
@@ -26,7 +51,6 @@ function getGasPriceEstimate(provider, chainId, legacyFallback) {
|
|
|
26
51
|
_a[constants_1.CHAIN_IDs.ALEPH_ZERO] = arbitrum.eip1559,
|
|
27
52
|
_a[constants_1.CHAIN_IDs.ARBITRUM] = arbitrum.eip1559,
|
|
28
53
|
_a[constants_1.CHAIN_IDs.BASE] = ethereum.eip1559,
|
|
29
|
-
_a[constants_1.CHAIN_IDs.BOBA] = ethereum.legacy,
|
|
30
54
|
_a[constants_1.CHAIN_IDs.LINEA] = linea.eip1559,
|
|
31
55
|
_a[constants_1.CHAIN_IDs.MAINNET] = ethereum.eip1559,
|
|
32
56
|
_a[constants_1.CHAIN_IDs.MODE] = ethereum.eip1559,
|
|
@@ -47,5 +71,48 @@ function getGasPriceEstimate(provider, chainId, legacyFallback) {
|
|
|
47
71
|
});
|
|
48
72
|
});
|
|
49
73
|
}
|
|
50
|
-
|
|
74
|
+
function getViemGasPriceEstimate(providerOrChainId, transport) {
|
|
75
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var chainId, _a, viemProvider, gasPriceFeeds, maxFeePerGas, maxPriorityFeePerGas, gasPrice;
|
|
77
|
+
var _b, _c, _d;
|
|
78
|
+
return tslib_1.__generator(this, function (_e) {
|
|
79
|
+
switch (_e.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
if (!(typeof providerOrChainId === "number")) return [3, 1];
|
|
82
|
+
_a = providerOrChainId;
|
|
83
|
+
return [3, 3];
|
|
84
|
+
case 1: return [4, providerOrChainId.getNetwork()];
|
|
85
|
+
case 2:
|
|
86
|
+
_a = (_e.sent()).chainId;
|
|
87
|
+
_e.label = 3;
|
|
88
|
+
case 3:
|
|
89
|
+
chainId = _a;
|
|
90
|
+
viemProvider = (0, util_1.getPublicClient)(chainId, transport);
|
|
91
|
+
gasPriceFeeds = (_b = {},
|
|
92
|
+
_b[constants_1.CHAIN_IDs.ALEPH_ZERO] = arbitrumViem.eip1559,
|
|
93
|
+
_b[constants_1.CHAIN_IDs.ARBITRUM] = arbitrumViem.eip1559,
|
|
94
|
+
_b[constants_1.CHAIN_IDs.POLYGON] = polygonViem.gasStation,
|
|
95
|
+
_b);
|
|
96
|
+
if (!gasPriceFeeds[chainId]) return [3, 5];
|
|
97
|
+
return [4, gasPriceFeeds[chainId](viemProvider, chainId)];
|
|
98
|
+
case 4:
|
|
99
|
+
(_c = _e.sent(), maxFeePerGas = _c.maxFeePerGas, maxPriorityFeePerGas = _c.maxPriorityFeePerGas);
|
|
100
|
+
return [3, 7];
|
|
101
|
+
case 5:
|
|
102
|
+
gasPrice = void 0;
|
|
103
|
+
return [4, viemProvider.estimateFeesPerGas()];
|
|
104
|
+
case 6:
|
|
105
|
+
(_d = _e.sent(), maxFeePerGas = _d.maxFeePerGas, maxPriorityFeePerGas = _d.maxPriorityFeePerGas, gasPrice = _d.gasPrice);
|
|
106
|
+
maxFeePerGas !== null && maxFeePerGas !== void 0 ? maxFeePerGas : (maxFeePerGas = gasPrice);
|
|
107
|
+
maxPriorityFeePerGas !== null && maxPriorityFeePerGas !== void 0 ? maxPriorityFeePerGas : (maxPriorityFeePerGas = BigInt(0));
|
|
108
|
+
_e.label = 7;
|
|
109
|
+
case 7: return [2, {
|
|
110
|
+
maxFeePerGas: utils_1.BigNumber.from(maxFeePerGas.toString()),
|
|
111
|
+
maxPriorityFeePerGas: utils_1.BigNumber.from(maxPriorityFeePerGas.toString()),
|
|
112
|
+
}];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.getViemGasPriceEstimate = getViemGasPriceEstimate;
|
|
51
118
|
//# sourceMappingURL=oracle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oracle.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"oracle.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":";;;;AAEA,0CAAyC;AACzC,kCAAqD;AAErD,+BAAyC;AACzC,oEAAgD;AAChD,oEAAgD;AAChD,8DAA0C;AAC1C,kEAA8C;AAC9C,6EAAyD;AACzD,2EAAuD;AASvD,SAAsB,mBAAmB,CACvC,QAA4B,EAC5B,OAAgB,EAChB,SAAqB,EACrB,cAAqB;IAArB,+BAAA,EAAA,qBAAqB;;;;;;yBAEjB,CAAA,OAAO,KAAK,SAAS,CAAA,EAArB,cAAqB;oBACR,WAAM,QAAQ,CAAC,UAAU,EAAE,EAAA;;oBAA1C,CAAG,OAAO,GAAK,CAAA,SAA2B,CAAA,QAAhC,CAAiC,CAAC;;;oBAGxC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,+BAAwB,OAAO,CAAE,CAAC,KAAK,MAAM,CAAC;oBAC1E,WAAO,OAAO;4BACZ,CAAC,CAAC,uBAAuB,CAAC,OAAO,EAAE,SAAS,CAAC;4BAC7C,CAAC,CAAC,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,CAAC,EAAC;;;;CAClE;AAdD,kDAcC;AASD,SAAe,yBAAyB,CACtC,QAA4B,EAC5B,OAAgB,EAChB,cAAqB;IAArB,+BAAA,EAAA,qBAAqB;;;;;;;yBAEjB,CAAA,OAAO,KAAK,SAAS,CAAA,EAArB,cAAqB;oBACR,WAAM,QAAQ,CAAC,UAAU,EAAE,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1
|
+
import { type Chain, type Transport, PublicClient, FeeValuesEIP1559 } from "viem";
|
|
2
2
|
import { BigNumber } from "../utils";
|
|
3
|
+
export type InternalGasPriceEstimate = FeeValuesEIP1559;
|
|
3
4
|
export type GasPriceEstimate = {
|
|
4
5
|
maxFeePerGas: BigNumber;
|
|
5
6
|
maxPriorityFeePerGas: BigNumber;
|
|
6
7
|
};
|
|
7
8
|
export interface GasPriceFeed {
|
|
8
|
-
(provider:
|
|
9
|
+
(provider: PublicClient<Transport, Chain>, chainId: number): Promise<InternalGasPriceEstimate>;
|
|
9
10
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
1
|
+
import { type Chain, type PublicClient, Transport } from "viem";
|
|
2
|
+
export declare function gasPriceError(method: string, chainId: number, data: unknown): void;
|
|
3
|
+
export declare function getPublicClient(chainId: number, transport?: Transport): PublicClient<Transport, Chain>;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gasPriceError = void 0;
|
|
3
|
+
exports.getPublicClient = exports.gasPriceError = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
var viem_1 = require("viem");
|
|
7
|
+
var chains = tslib_1.__importStar(require("viem/chains"));
|
|
4
8
|
function gasPriceError(method, chainId, data) {
|
|
5
9
|
throw new Error("Malformed ".concat(method, " response on chain ID ").concat(chainId, " (").concat(JSON.stringify(data), ")"));
|
|
6
10
|
}
|
|
7
11
|
exports.gasPriceError = gasPriceError;
|
|
12
|
+
function getPublicClient(chainId, transport) {
|
|
13
|
+
transport !== null && transport !== void 0 ? transport : (transport = (0, viem_1.http)());
|
|
14
|
+
var chain = Object.values(chains).find(function (chain) { return chain.id === chainId; });
|
|
15
|
+
(0, assert_1.default)(chain);
|
|
16
|
+
return (0, viem_1.createPublicClient)({ chain: chain, transport: transport });
|
|
17
|
+
}
|
|
18
|
+
exports.getPublicClient = getPublicClient;
|
|
8
19
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/gasPriceOracle/util.ts"],"names":[],"mappings":";;;;AAAA,0DAA4B;AAC5B,6BAA0F;AAC1F,0DAAsC;AAEtC,SAAgB,aAAa,CAAC,MAAc,EAAE,OAAe,EAAE,IAAa;IAC1E,MAAM,IAAI,KAAK,CAAC,oBAAa,MAAM,mCAAyB,OAAO,eAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAG,CAAC,CAAC;AACnG,CAAC;AAFD,sCAEC;AAED,SAAgB,eAAe,CAAC,OAAe,EAAE,SAAqB;IACpE,SAAS,aAAT,SAAS,cAAT,SAAS,IAAT,SAAS,GAAK,IAAA,WAAI,GAAE,EAAC;IACrB,IAAM,KAAK,GAAsB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,EAAE,KAAK,OAAO,EAApB,CAAoB,CAAC,CAAC;IAC7F,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC;IAEd,OAAO,IAAA,yBAAkB,EAAC,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC,CAAC;AAClD,CAAC;AAND,0CAMC"}
|
|
@@ -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;
|
|
4
5
|
error: {
|
|
5
|
-
message: string;
|
|
6
6
|
code: number;
|
|
7
|
+
message: string;
|
|
7
8
|
data?: any;
|
|
8
9
|
};
|
|
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
|
-
message: string;
|
|
16
15
|
code: number;
|
|
16
|
+
message: string;
|
|
17
17
|
data?: any;
|
|
18
18
|
}, {
|
|
19
19
|
code: import("superstruct").Struct<number, null>;
|
|
@@ -4,6 +4,7 @@ import { Deposit } from "../../interfaces";
|
|
|
4
4
|
import { SpokePool } from "../../typechain";
|
|
5
5
|
import { BigNumberish, TransactionCostEstimate } from "../../utils";
|
|
6
6
|
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
7
|
+
import { Transport } from "viem";
|
|
7
8
|
type Provider = providers.Provider;
|
|
8
9
|
type OptimismProvider = L2Provider<Provider>;
|
|
9
10
|
type SymbolMappingType = Record<string, {
|
|
@@ -22,7 +23,12 @@ export declare class QueryBase implements QueryInterface {
|
|
|
22
23
|
readonly coingeckoBaseCurrency: string;
|
|
23
24
|
readonly spokePool: SpokePool;
|
|
24
25
|
constructor(provider: Provider | OptimismProvider, symbolMapping: SymbolMappingType, spokePoolAddress: string, simulatedRelayerAddress: string, gasMarkup: number, logger: Logger, coingeckoProApiKey?: string | undefined, fixedGasPrice?: BigNumberish | undefined, coingeckoBaseCurrency?: string);
|
|
25
|
-
getGasCosts(deposit: Deposit, relayer?: string,
|
|
26
|
+
getGasCosts(deposit: Deposit, relayer?: string, options?: Partial<{
|
|
27
|
+
gasPrice: BigNumberish;
|
|
28
|
+
gasUnits: BigNumberish;
|
|
29
|
+
omitMarkup: boolean;
|
|
30
|
+
transport: Transport;
|
|
31
|
+
}>): Promise<TransactionCostEstimate>;
|
|
26
32
|
getTokenPrice(tokenSymbol: string): Promise<number>;
|
|
27
33
|
getTokenDecimals(tokenSymbol: string): number;
|
|
28
34
|
}
|
|
@@ -21,23 +21,28 @@ var QueryBase = (function () {
|
|
|
21
21
|
this.coingeckoBaseCurrency = coingeckoBaseCurrency;
|
|
22
22
|
this.spokePool = typechain_1.SpokePool__factory.connect(spokePoolAddress, provider);
|
|
23
23
|
}
|
|
24
|
-
QueryBase.prototype.getGasCosts = function (deposit, relayer,
|
|
24
|
+
QueryBase.prototype.getGasCosts = function (deposit, relayer, options) {
|
|
25
25
|
if (relayer === void 0) { relayer = constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS; }
|
|
26
|
-
if (
|
|
26
|
+
if (options === void 0) { options = {}; }
|
|
27
27
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
28
|
-
var gasMarkup, gasTotalMultiplier, tx,
|
|
29
|
-
return tslib_1.__generator(this, function (
|
|
30
|
-
switch (
|
|
28
|
+
var _a, gasPrice, gasUnits, omitMarkup, transport, gasMarkup, gasTotalMultiplier, tx, _b, nativeGasCost, tokenGasCost;
|
|
29
|
+
return tslib_1.__generator(this, function (_c) {
|
|
30
|
+
switch (_c.label) {
|
|
31
31
|
case 0:
|
|
32
|
+
_a = options.gasPrice, gasPrice = _a === void 0 ? this.fixedGasPrice : _a, gasUnits = options.gasUnits, omitMarkup = options.omitMarkup, transport = options.transport;
|
|
32
33
|
gasMarkup = omitMarkup ? 0 : this.gasMarkup;
|
|
33
34
|
(0, assert_1.default)(gasMarkup > -1 && gasMarkup <= 4, "Require -1.0 < Gas Markup (".concat(gasMarkup, ") <= 4.0 for a total gas multiplier within (0, +5.0]"));
|
|
34
35
|
gasTotalMultiplier = (0, utils_1.toBNWei)(1.0 + gasMarkup);
|
|
35
36
|
return [4, (0, utils_1.populateV3Relay)(this.spokePool, deposit, relayer)];
|
|
36
37
|
case 1:
|
|
37
|
-
tx =
|
|
38
|
-
return [4, (0, utils_1.estimateTotalGasRequiredByUnsignedTransaction)(tx, relayer, this.provider,
|
|
38
|
+
tx = _c.sent();
|
|
39
|
+
return [4, (0, utils_1.estimateTotalGasRequiredByUnsignedTransaction)(tx, relayer, this.provider, {
|
|
40
|
+
gasPrice: gasPrice,
|
|
41
|
+
gasUnits: gasUnits,
|
|
42
|
+
transport: transport,
|
|
43
|
+
})];
|
|
39
44
|
case 2:
|
|
40
|
-
|
|
45
|
+
_b = _c.sent(), nativeGasCost = _b.nativeGasCost, tokenGasCost = _b.tokenGasCost;
|
|
41
46
|
return [2, {
|
|
42
47
|
nativeGasCost: nativeGasCost.mul(gasTotalMultiplier).div(utils_1.fixedPointAdjustment),
|
|
43
48
|
tokenGasCost: tokenGasCost.mul(gasTotalMultiplier).div(utils_1.fixedPointAdjustment),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseQuery.js","sourceRoot":"","sources":["../../../../src/relayFeeCalculator/chain-queries/baseQuery.ts"],"names":[],"mappings":";;;;AAEA,0DAA4B;AAC5B,6CAA4C;AAC5C,6CAA+E;AAE/E,6CAAgE;AAChE,qCAOqB;
|
|
1
|
+
{"version":3,"file":"baseQuery.js","sourceRoot":"","sources":["../../../../src/relayFeeCalculator/chain-queries/baseQuery.ts"],"names":[],"mappings":";;;;AAEA,0DAA4B;AAC5B,6CAA4C;AAC5C,6CAA+E;AAE/E,6CAAgE;AAChE,qCAOqB;AAkBrB;IAcE,mBACW,QAAqC,EACrC,aAAgC,EAChC,gBAAwB,EACxB,uBAA+B,EAC/B,SAAiB,EACjB,MAAc,EACd,kBAA2B,EAC3B,aAA4B,EAC5B,qBAAqC;QAArC,sCAAA,EAAA,6BAAqC;QARrC,aAAQ,GAAR,QAAQ,CAA6B;QACrC,kBAAa,GAAb,aAAa,CAAmB;QAChC,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,4BAAuB,GAAvB,uBAAuB,CAAQ;QAC/B,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAQ;QACd,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,kBAAa,GAAb,a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G,CAAC,4BAAoB,CAAC;6BAC7E,EAAC;;;;KACH;IAOK,iCAAa,GAAnB,UAAoB,WAAmB;;;;;;wBACrC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;4BAAE,MAAM,IAAI,KAAK,CAAC,UAAG,WAAW,+BAA4B,CAAC,CAAC;wBAC5F,iBAAiB,GAAG,qBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;wBAC5D,WAAM,iBAAiB,CAAC,yBAAyB,CACjE,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,qBAAS,CAAC,OAAO,CAAC,EAC5D,IAAI,CAAC,qBAAqB,CAC3B,EAAA;;wBAHK,KAAY,SAGjB,EAHQ,KAAK,QAAA;wBAId,WAAO,KAAK,EAAC;;;;KACd;IAOD,oCAAgB,GAAhB,UAAiB,WAAmB;QAClC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,UAAG,WAAW,+BAA4B,CAAC,CAAC;QAClG,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC;IAClD,CAAC;IACH,gBAAC;AAAD,CAAC,AApGD,IAoGC;AApGY,8BAAS"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Deposit } from "../interfaces";
|
|
2
2
|
import { BigNumber, BigNumberish, TransactionCostEstimate } from "../utils";
|
|
3
|
+
import { Transport } from "viem";
|
|
3
4
|
export interface QueryInterface {
|
|
4
|
-
getGasCosts: (deposit: Deposit, relayer: string,
|
|
5
|
+
getGasCosts: (deposit: Deposit, relayer: string, options?: Partial<{
|
|
6
|
+
gasPrice: BigNumberish;
|
|
7
|
+
gasUnits: BigNumberish;
|
|
8
|
+
omitMarkup: boolean;
|
|
9
|
+
transport: Transport;
|
|
10
|
+
}>) => Promise<TransactionCostEstimate>;
|
|
5
11
|
getTokenPrice: (tokenSymbol: string) => Promise<number>;
|
|
6
12
|
getTokenDecimals: (tokenSymbol: string) => number;
|
|
7
13
|
}
|
|
@@ -304,7 +310,7 @@ export declare class RelayFeeCalculator {
|
|
|
304
310
|
};
|
|
305
311
|
coingeckoId: string;
|
|
306
312
|
};
|
|
307
|
-
}, gasPrice?: BigNumberish, gasLimit?: BigNumberish): Promise<BigNumber>;
|
|
313
|
+
}, gasPrice?: BigNumberish, gasLimit?: BigNumberish, transport?: Transport): Promise<BigNumber>;
|
|
308
314
|
capitalFeePercent(_amountToRelay: BigNumberish, _tokenSymbol: string, _originRoute?: ChainIdAsString, _destinationRoute?: ChainIdAsString): BigNumber;
|
|
309
315
|
relayerFeeDetails(deposit: Deposit, amountToRelay?: BigNumberish, simulateZeroFill?: boolean, relayerAddress?: string, _tokenPrice?: number, gasPrice?: BigNumberish, gasUnits?: BigNumberish): Promise<RelayerFeeDetails>;
|
|
310
316
|
}
|
|
@@ -86,7 +86,7 @@ var RelayFeeCalculator = (function () {
|
|
|
86
86
|
RelayFeeCalculator.prototype.getTokenPrice = function (tokenSymbol) {
|
|
87
87
|
return this.queries.getTokenPrice(tokenSymbol);
|
|
88
88
|
};
|
|
89
|
-
RelayFeeCalculator.prototype.gasFeePercent = function (deposit, amountToRelay, simulateZeroFill, relayerAddress, _tokenPrice, tokenMapping, gasPrice, gasLimit) {
|
|
89
|
+
RelayFeeCalculator.prototype.gasFeePercent = function (deposit, amountToRelay, simulateZeroFill, relayerAddress, _tokenPrice, tokenMapping, gasPrice, gasLimit, transport) {
|
|
90
90
|
if (simulateZeroFill === void 0) { simulateZeroFill = false; }
|
|
91
91
|
if (relayerAddress === void 0) { relayerAddress = constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS; }
|
|
92
92
|
if (tokenMapping === void 0) { tokenMapping = constants_1.TOKEN_SYMBOLS_MAP; }
|
|
@@ -105,7 +105,9 @@ var RelayFeeCalculator = (function () {
|
|
|
105
105
|
}
|
|
106
106
|
simulatedAmount = simulateZeroFill ? safeOutputAmount : (0, utils_1.toBN)(amountToRelay);
|
|
107
107
|
deposit = tslib_1.__assign(tslib_1.__assign({}, deposit), { outputAmount: simulatedAmount });
|
|
108
|
-
getGasCosts = this.queries
|
|
108
|
+
getGasCosts = this.queries
|
|
109
|
+
.getGasCosts(deposit, relayerAddress, { gasPrice: gasPrice, gasUnits: gasLimit, transport: transport })
|
|
110
|
+
.catch(function (error) {
|
|
109
111
|
_this.logger.error({
|
|
110
112
|
at: "sdk/gasFeePercent",
|
|
111
113
|
message: "Error while fetching gas costs",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayFeeCalculator.js","sourceRoot":"","sources":["../../../src/relayFeeCalculator/relayFeeCalculator.ts"],"names":[],"mappings":";;;;AAAA,0DAA4B;AAC5B,0CAAoF;AAEpF,kCAekB;AAcL,QAAA,wBAAwB,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AA0D9E,QAAA,cAAc,GAAW;IACpC,KAAK,EAAE;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAAK,OAAA,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;IAAnB,CAAmB;IACvC,IAAI,EAAE;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAAK,OAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IAAlB,CAAkB;IACrC,IAAI,EAAE;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAAK,OAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IAAlB,CAAkB;IACrC,KAAK,EAAE;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAAK,OAAA,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;IAAnB,CAAmB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,CAAC;4BACzE,cAAc,GAAG,IAAA,YAAI,EAAC,aAAa,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;yBACrD;wBAED,WAAO;gCACL,aAAa,EAAE,aAAa,CAAC,QAAQ,EAAE;gCACvC,WAAW,EAAE,KAAK,CAAC,MAAM;gCACzB,aAAa,EAAE,aAAa,CAAC,QAAQ,EAAE;gCACvC,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE;gCACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gCAC3C,iBAAiB,EAAE,iBAAiB,CAAC,QAAQ,EAAE;gCAC/C,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE;gCAC3C,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;gCACnD,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE;gCAC3C,aAAa,EAAE,aAAa,CAAC,QAAQ,EAAE;gCACvC,eAAe,EAAE,IAAI,CAAC,eAAe;gCACrC,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,EAAE;gCAC7C,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;gCACjC,cAAc,gBAAA;6BACf,EAAC;;;;KACH;IACH,yBAAC;AAAD,CAAC,AApUD,IAoUC;AApUY,gDAAkB"}
|
|
@@ -3,6 +3,7 @@ import Decimal from "decimal.js";
|
|
|
3
3
|
import { ethers, PopulatedTransaction, providers } from "ethers";
|
|
4
4
|
import { TypedMessage } from "../interfaces/TypedData";
|
|
5
5
|
import { BigNumber, BigNumberish, BN } from "./BigNumberUtils";
|
|
6
|
+
import { Transport } from "viem";
|
|
6
7
|
export type Decimalish = string | number | Decimal;
|
|
7
8
|
export declare const AddressZero = "0x0000000000000000000000000000000000000000";
|
|
8
9
|
export declare const MAX_BIG_INT: ethers.BigNumber;
|
|
@@ -25,7 +26,11 @@ export type TransactionCostEstimate = {
|
|
|
25
26
|
nativeGasCost: BigNumber;
|
|
26
27
|
tokenGasCost: BigNumber;
|
|
27
28
|
};
|
|
28
|
-
export declare function estimateTotalGasRequiredByUnsignedTransaction(unsignedTx: PopulatedTransaction, senderAddress: string, provider: providers.Provider | L2Provider<providers.Provider>,
|
|
29
|
+
export declare function estimateTotalGasRequiredByUnsignedTransaction(unsignedTx: PopulatedTransaction, senderAddress: string, provider: providers.Provider | L2Provider<providers.Provider>, options?: Partial<{
|
|
30
|
+
gasPrice: BigNumberish;
|
|
31
|
+
gasUnits: BigNumberish;
|
|
32
|
+
transport: Transport;
|
|
33
|
+
}>): Promise<TransactionCostEstimate>;
|
|
29
34
|
export type UpdateDepositDetailsMessageType = {
|
|
30
35
|
UpdateDepositDetails: [
|
|
31
36
|
{
|
package/dist/cjs/utils/common.js
CHANGED
|
@@ -110,48 +110,52 @@ function retry(call, times, delayS) {
|
|
|
110
110
|
return promiseChain;
|
|
111
111
|
}
|
|
112
112
|
exports.retry = retry;
|
|
113
|
-
function estimateTotalGasRequiredByUnsignedTransaction(unsignedTx, senderAddress, provider,
|
|
113
|
+
function estimateTotalGasRequiredByUnsignedTransaction(unsignedTx, senderAddress, provider, options) {
|
|
114
|
+
if (options === void 0) { options = {}; }
|
|
114
115
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
115
|
-
var chainId, voidSigner, nativeGasCost,
|
|
116
|
-
return tslib_1.__generator(this, function (
|
|
117
|
-
switch (
|
|
118
|
-
case 0:
|
|
116
|
+
var _a, _gasPrice, gasUnits, transport, chainId, voidSigner, nativeGasCost, _b, tokenGasCost, populatedTransaction, _c, l1GasCost, l2GasPrice, l2GasCost, gasPrice, gasPriceEstimate;
|
|
117
|
+
return tslib_1.__generator(this, function (_d) {
|
|
118
|
+
switch (_d.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
_a = options || {}, _gasPrice = _a.gasPrice, gasUnits = _a.gasUnits, transport = _a.transport;
|
|
121
|
+
return [4, provider.getNetwork()];
|
|
119
122
|
case 1:
|
|
120
|
-
chainId = (
|
|
123
|
+
chainId = (_d.sent()).chainId;
|
|
121
124
|
voidSigner = new ethers_1.VoidSigner(senderAddress, provider);
|
|
122
125
|
if (!gasUnits) return [3, 2];
|
|
123
|
-
|
|
126
|
+
_b = BigNumberUtils_1.BigNumber.from(gasUnits);
|
|
124
127
|
return [3, 4];
|
|
125
128
|
case 2: return [4, voidSigner.estimateGas(unsignedTx)];
|
|
126
129
|
case 3:
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
_b = _d.sent();
|
|
131
|
+
_d.label = 4;
|
|
129
132
|
case 4:
|
|
130
|
-
nativeGasCost =
|
|
133
|
+
nativeGasCost = _b;
|
|
131
134
|
if (!(0, NetworkUtils_1.chainIsOPStack)(chainId)) return [3, 7];
|
|
132
135
|
(0, assert_1.default)((0, l2_provider_1.isL2Provider)(provider), "Unexpected provider for chain ID ".concat(chainId, "."));
|
|
133
136
|
return [4, voidSigner.populateTransaction(tslib_1.__assign(tslib_1.__assign({}, unsignedTx), { gasLimit: nativeGasCost }))];
|
|
134
137
|
case 5:
|
|
135
|
-
populatedTransaction =
|
|
138
|
+
populatedTransaction = _d.sent();
|
|
136
139
|
return [4, Promise.all([
|
|
137
140
|
provider.estimateL1GasCost(populatedTransaction),
|
|
138
|
-
|
|
141
|
+
_gasPrice || provider.getGasPrice(),
|
|
139
142
|
])];
|
|
140
143
|
case 6:
|
|
141
|
-
|
|
144
|
+
_c = _d.sent(), l1GasCost = _c[0], l2GasPrice = _c[1];
|
|
142
145
|
l2GasCost = nativeGasCost.mul(l2GasPrice);
|
|
143
146
|
tokenGasCost = l1GasCost.add(l2GasCost);
|
|
144
147
|
return [3, 10];
|
|
145
148
|
case 7:
|
|
149
|
+
gasPrice = _gasPrice;
|
|
146
150
|
if (!!gasPrice) return [3, 9];
|
|
147
|
-
return [4, (0, gasPriceOracle_1.getGasPriceEstimate)(provider, chainId)];
|
|
151
|
+
return [4, (0, gasPriceOracle_1.getGasPriceEstimate)(provider, chainId, transport)];
|
|
148
152
|
case 8:
|
|
149
|
-
gasPriceEstimate =
|
|
153
|
+
gasPriceEstimate = _d.sent();
|
|
150
154
|
gasPrice = gasPriceEstimate.maxFeePerGas;
|
|
151
|
-
|
|
155
|
+
_d.label = 9;
|
|
152
156
|
case 9:
|
|
153
157
|
tokenGasCost = nativeGasCost.mul(gasPrice);
|
|
154
|
-
|
|
158
|
+
_d.label = 10;
|
|
155
159
|
case 10: return [2, {
|
|
156
160
|
nativeGasCost: nativeGasCost,
|
|
157
161
|
tokenGasCost: tokenGasCost,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":";;;;AACA,kEAA0F;AAC1F,0DAA4B;AAC5B,kEAAiC;AACjC,iCAA6E;AAC7E,oDAAwD;AAExD,mDAA8F;AAC9F,qDAAoD;AACpD,+CAAgD;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":";;;;AACA,kEAA0F;AAC1F,0DAA4B;AAC5B,kEAAiC;AACjC,iCAA6E;AAC7E,oDAAwD;AAExD,mDAA8F;AAC9F,qDAAoD;AACpD,+CAAgD;AAInC,QAAA,WAAW,GAAG,eAAM,CAAC,SAAS,CAAC,WAAW,CAAC;AAC3C,QAAA,WAAW,GAAG,0BAAS,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;AASvE,IAAM,OAAO,GAAG,UAAC,GAAiB,EAAE,QAAiB,IAAS,OAAA,IAAA,2BAAU,EAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,EAApC,CAAoC,CAAC;AAA7F,QAAA,OAAO,WAAsF;AASnG,IAAM,OAAO,GAAG,UAAC,GAAiB,EAAE,QAAiB,IAAa,OAAA,IAAA,4BAAW,EAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,EAArC,CAAqC,CAAC;AAAlG,QAAA,OAAO,WAA2F;AAS/G,SAAgB,GAAG,CAA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