@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,7 @@
|
|
|
1
1
|
import { L2Provider } from "@eth-optimism/sdk/dist/interfaces/l2-provider";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { isL2Provider as isOptimismL2Provider } from "@eth-optimism/sdk/dist/l2-provider";
|
|
3
|
+
|
|
4
|
+
import { PopulatedTransaction, providers, VoidSigner } from "ethers";
|
|
4
5
|
import { Coingecko } from "../../coingecko";
|
|
5
6
|
import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS } from "../../constants";
|
|
6
7
|
import { Deposit } from "../../interfaces";
|
|
@@ -8,14 +9,16 @@ import { SpokePool, SpokePool__factory } from "../../typechain";
|
|
|
8
9
|
import {
|
|
9
10
|
BigNumberish,
|
|
10
11
|
TransactionCostEstimate,
|
|
11
|
-
estimateTotalGasRequiredByUnsignedTransaction,
|
|
12
|
-
fixedPointAdjustment,
|
|
13
12
|
populateV3Relay,
|
|
13
|
+
BigNumber,
|
|
14
14
|
toBNWei,
|
|
15
|
+
bnZero,
|
|
16
|
+
assert,
|
|
17
|
+
chainIsOPStack,
|
|
15
18
|
} from "../../utils";
|
|
16
19
|
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
17
20
|
import { Transport } from "viem";
|
|
18
|
-
|
|
21
|
+
import { getGasPriceEstimate } from "../../gasPriceOracle/oracle";
|
|
19
22
|
type Provider = providers.Provider;
|
|
20
23
|
type OptimismProvider = L2Provider<Provider>;
|
|
21
24
|
type SymbolMappingType = Record<
|
|
@@ -38,7 +41,6 @@ export class QueryBase implements QueryInterface {
|
|
|
38
41
|
* @param symbolMapping A mapping to valid ERC20 tokens and their respective characteristics
|
|
39
42
|
* @param spokePoolAddress The valid address of the Spoke Pool deployment
|
|
40
43
|
* @param simulatedRelayerAddress The address that these queries will reference as the sender. Note: This address must be approved for USDC
|
|
41
|
-
* @param gasMarkup A multiplier that is applied to the total gas estimate
|
|
42
44
|
* @param logger A logging utility to report logs
|
|
43
45
|
* @param coingeckoProApiKey An optional CoinGecko API key that links to a PRO account
|
|
44
46
|
* @param fixedGasPrice Overrides the gas price with a fixed value. Note: primarily used for the Boba blockchain
|
|
@@ -49,7 +51,6 @@ export class QueryBase implements QueryInterface {
|
|
|
49
51
|
readonly symbolMapping: SymbolMappingType,
|
|
50
52
|
readonly spokePoolAddress: string,
|
|
51
53
|
readonly simulatedRelayerAddress: string,
|
|
52
|
-
readonly gasMarkup: number,
|
|
53
54
|
readonly logger: Logger,
|
|
54
55
|
readonly coingeckoProApiKey?: string,
|
|
55
56
|
readonly fixedGasPrice?: BigNumberish,
|
|
@@ -65,7 +66,6 @@ export class QueryBase implements QueryInterface {
|
|
|
65
66
|
* @param options
|
|
66
67
|
* @param options.gasPrice Optional gas price to use for the simulation.
|
|
67
68
|
* @param options.gasUnits Optional gas units to use for the simulation.
|
|
68
|
-
* @param options.omitMarkup Optional flag to omit the gas markup.
|
|
69
69
|
* @param options.transport Optional transport object for custom gas price retrieval.
|
|
70
70
|
* @returns The gas estimate for this function call (multiplied with the optional buffer).
|
|
71
71
|
*/
|
|
@@ -75,37 +75,90 @@ export class QueryBase implements QueryInterface {
|
|
|
75
75
|
options: Partial<{
|
|
76
76
|
gasPrice: BigNumberish;
|
|
77
77
|
gasUnits: BigNumberish;
|
|
78
|
-
|
|
78
|
+
baseFeeMultiplier: BigNumber;
|
|
79
79
|
transport: Transport;
|
|
80
80
|
}> = {}
|
|
81
81
|
): Promise<TransactionCostEstimate> {
|
|
82
|
-
const { gasPrice = this.fixedGasPrice, gasUnits,
|
|
83
|
-
|
|
84
|
-
const gasMarkup = omitMarkup ? 0 : this.gasMarkup;
|
|
85
|
-
assert(
|
|
86
|
-
gasMarkup > -1 && gasMarkup <= 4,
|
|
87
|
-
`Require -1.0 < Gas Markup (${gasMarkup}) <= 4.0 for a total gas multiplier within (0, +5.0]`
|
|
88
|
-
);
|
|
89
|
-
const gasTotalMultiplier = toBNWei(1.0 + gasMarkup);
|
|
82
|
+
const { gasPrice = this.fixedGasPrice, gasUnits, baseFeeMultiplier, transport } = options;
|
|
90
83
|
|
|
91
84
|
const tx = await populateV3Relay(this.spokePool, deposit, relayer);
|
|
92
85
|
const {
|
|
93
86
|
nativeGasCost,
|
|
94
87
|
tokenGasCost,
|
|
95
88
|
gasPrice: impliedGasPrice,
|
|
96
|
-
} = await
|
|
89
|
+
} = await this.estimateGas(tx, relayer, this.provider, {
|
|
97
90
|
gasPrice,
|
|
98
91
|
gasUnits,
|
|
92
|
+
baseFeeMultiplier,
|
|
99
93
|
transport,
|
|
100
94
|
});
|
|
101
95
|
|
|
102
96
|
return {
|
|
103
|
-
nativeGasCost
|
|
104
|
-
tokenGasCost
|
|
97
|
+
nativeGasCost,
|
|
98
|
+
tokenGasCost,
|
|
105
99
|
gasPrice: impliedGasPrice,
|
|
106
100
|
};
|
|
107
101
|
}
|
|
108
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Estimates the total gas cost required to submit an unsigned (populated) transaction on-chain.
|
|
105
|
+
* @param unsignedTx The unsigned transaction that this function will estimate.
|
|
106
|
+
* @param senderAddress The address that the transaction will be submitted from.
|
|
107
|
+
* @param provider A valid ethers provider - will be used to reason the gas price.
|
|
108
|
+
* @param options
|
|
109
|
+
* @param options.gasPrice A manually provided gas price - if set, this function will not resolve the current gas price.
|
|
110
|
+
* @param options.gasUnits A manually provided gas units - if set, this function will not estimate the gas units.
|
|
111
|
+
* @param options.transport A custom transport object for custom gas price retrieval.
|
|
112
|
+
* @returns Estimated cost in units of gas and the underlying gas token (gasPrice * estimatedGasUnits).
|
|
113
|
+
*/
|
|
114
|
+
async estimateGas(
|
|
115
|
+
unsignedTx: PopulatedTransaction,
|
|
116
|
+
senderAddress: string,
|
|
117
|
+
provider: providers.Provider | L2Provider<providers.Provider>,
|
|
118
|
+
options: Partial<{
|
|
119
|
+
gasPrice: BigNumberish;
|
|
120
|
+
gasUnits: BigNumberish;
|
|
121
|
+
baseFeeMultiplier: BigNumber;
|
|
122
|
+
transport: Transport;
|
|
123
|
+
}> = {}
|
|
124
|
+
): Promise<TransactionCostEstimate> {
|
|
125
|
+
const { gasPrice: _gasPrice, gasUnits, baseFeeMultiplier = toBNWei("1"), transport } = options || {};
|
|
126
|
+
|
|
127
|
+
const { chainId } = await provider.getNetwork();
|
|
128
|
+
const voidSigner = new VoidSigner(senderAddress, provider);
|
|
129
|
+
|
|
130
|
+
// Estimate the Gas units required to submit this transaction.
|
|
131
|
+
const queries = [
|
|
132
|
+
gasUnits ? Promise.resolve(BigNumber.from(gasUnits)) : voidSigner.estimateGas(unsignedTx),
|
|
133
|
+
_gasPrice
|
|
134
|
+
? Promise.resolve({ maxFeePerGas: _gasPrice })
|
|
135
|
+
: getGasPriceEstimate(provider, { chainId, baseFeeMultiplier, transport, unsignedTx }),
|
|
136
|
+
] as const;
|
|
137
|
+
const [nativeGasCost, { maxFeePerGas: gasPrice }] = await Promise.all(queries);
|
|
138
|
+
assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
|
|
139
|
+
let tokenGasCost: BigNumber;
|
|
140
|
+
|
|
141
|
+
// OP stack is a special case; gas cost is computed by the SDK, without having to query price.
|
|
142
|
+
if (chainIsOPStack(chainId)) {
|
|
143
|
+
assert(isOptimismL2Provider(provider), `Unexpected provider for chain ID ${chainId}.`);
|
|
144
|
+
const populatedTransaction = await voidSigner.populateTransaction({
|
|
145
|
+
...unsignedTx,
|
|
146
|
+
gasLimit: nativeGasCost, // prevents additional gas estimation call
|
|
147
|
+
});
|
|
148
|
+
const l1GasCost = await provider.estimateL1GasCost(populatedTransaction);
|
|
149
|
+
const l2GasCost = nativeGasCost.mul(gasPrice);
|
|
150
|
+
tokenGasCost = l1GasCost.add(l2GasCost);
|
|
151
|
+
} else {
|
|
152
|
+
tokenGasCost = nativeGasCost.mul(gasPrice);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
nativeGasCost, // Units: gas
|
|
157
|
+
tokenGasCost, // Units: wei (nativeGasCost * wei/gas)
|
|
158
|
+
gasPrice: tokenGasCost.div(nativeGasCost), // Units: wei/gas
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
109
162
|
/**
|
|
110
163
|
* Retrieves the current price of a token
|
|
111
164
|
* @param tokenSymbol A valid [CoinGecko-ID](https://api.coingecko.com/api/v3/coins/list)
|
|
@@ -27,7 +27,6 @@ export class QueryBase__factory {
|
|
|
27
27
|
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
28
28
|
coingeckoProApiKey?: string,
|
|
29
29
|
logger: Logger = DEFAULT_LOGGER,
|
|
30
|
-
gasMarkup = 0,
|
|
31
30
|
coingeckoBaseCurrency = "eth"
|
|
32
31
|
): QueryBase {
|
|
33
32
|
assert(isDefined(spokePoolAddress));
|
|
@@ -38,9 +37,10 @@ export class QueryBase__factory {
|
|
|
38
37
|
symbolMapping,
|
|
39
38
|
spokePoolAddress,
|
|
40
39
|
simulatedRelayerAddress,
|
|
41
|
-
coingeckoProApiKey,
|
|
42
40
|
logger,
|
|
43
|
-
|
|
41
|
+
coingeckoProApiKey,
|
|
42
|
+
fixedGasPrice[chainId],
|
|
43
|
+
"usd"
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -50,9 +50,10 @@ export class QueryBase__factory {
|
|
|
50
50
|
symbolMapping,
|
|
51
51
|
spokePoolAddress,
|
|
52
52
|
simulatedRelayerAddress,
|
|
53
|
-
coingeckoProApiKey,
|
|
54
53
|
logger,
|
|
55
|
-
|
|
54
|
+
coingeckoProApiKey,
|
|
55
|
+
fixedGasPrice[chainId],
|
|
56
|
+
"usd"
|
|
56
57
|
);
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -64,7 +65,6 @@ export class QueryBase__factory {
|
|
|
64
65
|
symbolMapping,
|
|
65
66
|
spokePoolAddress,
|
|
66
67
|
simulatedRelayerAddress,
|
|
67
|
-
gasMarkup,
|
|
68
68
|
logger,
|
|
69
69
|
coingeckoProApiKey,
|
|
70
70
|
fixedGasPrice[chainId],
|
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getDeployedAddress } from "../../utils/DeploymentUtils";
|
|
3
|
-
import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator";
|
|
4
|
-
import { providers } from "ethers";
|
|
5
|
-
import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../../constants";
|
|
1
|
+
import { CHAIN_IDs } from "../../constants";
|
|
6
2
|
import { Coingecko } from "../../coingecko/Coingecko";
|
|
7
|
-
import { isDefined } from "../../utils";
|
|
8
3
|
import { QueryBase } from "./baseQuery";
|
|
9
4
|
|
|
10
5
|
export class PolygonQueries extends QueryBase {
|
|
11
|
-
constructor(
|
|
12
|
-
provider: providers.Provider,
|
|
13
|
-
symbolMapping = TOKEN_SYMBOLS_MAP,
|
|
14
|
-
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.POLYGON),
|
|
15
|
-
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
16
|
-
coingeckoProApiKey?: string,
|
|
17
|
-
logger: Logger = DEFAULT_LOGGER,
|
|
18
|
-
gasMarkup = 0
|
|
19
|
-
) {
|
|
20
|
-
assert(isDefined(spokePoolAddress));
|
|
21
|
-
super(
|
|
22
|
-
provider,
|
|
23
|
-
symbolMapping,
|
|
24
|
-
spokePoolAddress,
|
|
25
|
-
simulatedRelayerAddress,
|
|
26
|
-
gasMarkup,
|
|
27
|
-
logger,
|
|
28
|
-
coingeckoProApiKey,
|
|
29
|
-
undefined,
|
|
30
|
-
"usd"
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
6
|
override async getTokenPrice(tokenSymbol: string): Promise<number> {
|
|
35
7
|
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
|
|
36
8
|
const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey);
|
|
@@ -24,7 +24,12 @@ export interface QueryInterface {
|
|
|
24
24
|
getGasCosts: (
|
|
25
25
|
deposit: Deposit,
|
|
26
26
|
relayer: string,
|
|
27
|
-
options?: Partial<{
|
|
27
|
+
options?: Partial<{
|
|
28
|
+
gasPrice: BigNumberish;
|
|
29
|
+
gasUnits: BigNumberish;
|
|
30
|
+
baseFeeMultiplier: BigNumber;
|
|
31
|
+
transport: Transport;
|
|
32
|
+
}>
|
|
28
33
|
) => Promise<TransactionCostEstimate>;
|
|
29
34
|
getTokenPrice: (tokenSymbol: string) => Promise<number>;
|
|
30
35
|
getTokenDecimals: (tokenSymbol: string) => number;
|
|
@@ -125,6 +125,18 @@ export async function queryHistoricalDepositForFill(
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Returns true if filling this deposit (as a slow or fast fill) or refunding it would not change any state
|
|
130
|
+
* on-chain. The dataworker functions can use this to conveniently filter out useless deposits.
|
|
131
|
+
* @dev The reason we allow a 0-input deposit to have a non-empty message is that the message might be used
|
|
132
|
+
* to pay the filler in an indirect way so it might have economic value as a fast or slow fill.
|
|
133
|
+
* @param deposit Deposit to check.
|
|
134
|
+
* @returns True if deposit's input amount is 0 and message is empty.
|
|
135
|
+
*/
|
|
136
|
+
export function isZeroValueDeposit(deposit: Pick<Deposit, "inputAmount" | "message">): boolean {
|
|
137
|
+
return deposit.inputAmount.eq(0) && isMessageEmpty(deposit.message);
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
/**
|
|
129
141
|
* Determines if a message is empty or not.
|
|
130
142
|
* @param message The message to check.
|
package/src/utils/Multicall.ts
CHANGED
|
@@ -21,20 +21,15 @@ const NON_DETERMINISTIC_MULTICALL_ADDRESSES = {
|
|
|
21
21
|
[CHAIN_IDs.ZK_SYNC]: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
// Multicall3 is an OP stack
|
|
24
|
+
// @notice Multicall3 is an OP stack preinstall, so don't specify it here.
|
|
25
25
|
const DETERMINISTIC_MULTICALL_CHAINS = [
|
|
26
26
|
CHAIN_IDs.ALEPH_ZERO,
|
|
27
27
|
CHAIN_IDs.ARBITRUM,
|
|
28
|
-
CHAIN_IDs.INK,
|
|
29
28
|
CHAIN_IDs.LINEA,
|
|
30
29
|
CHAIN_IDs.MAINNET,
|
|
31
30
|
CHAIN_IDs.POLYGON,
|
|
32
31
|
CHAIN_IDs.SCROLL,
|
|
33
|
-
CHAIN_IDs.ZORA,
|
|
34
32
|
// Testnet:
|
|
35
|
-
CHAIN_IDs.BASE_SEPOLIA,
|
|
36
|
-
CHAIN_IDs.BLAST_SEPOLIA,
|
|
37
|
-
CHAIN_IDs.INK_SEPOLIA,
|
|
38
33
|
CHAIN_IDs.POLYGON_AMOY,
|
|
39
34
|
CHAIN_IDs.SCROLL_SEPOLIA,
|
|
40
35
|
CHAIN_IDs.SEPOLIA,
|
package/src/utils/common.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import { L2Provider } from "@eth-optimism/sdk/dist/interfaces/l2-provider";
|
|
2
|
-
import { isL2Provider as isOptimismL2Provider } from "@eth-optimism/sdk/dist/l2-provider";
|
|
3
|
-
import assert from "assert";
|
|
4
1
|
import Decimal from "decimal.js";
|
|
5
|
-
import { ethers
|
|
6
|
-
import {
|
|
7
|
-
import { BigNumber, BigNumberish, BN, bnZero, formatUnits, parseUnits, toBN } from "./BigNumberUtils";
|
|
2
|
+
import { ethers } from "ethers";
|
|
3
|
+
import { BigNumber, BigNumberish, BN, formatUnits, parseUnits, toBN } from "./BigNumberUtils";
|
|
8
4
|
import { ConvertDecimals } from "./FormattingUtils";
|
|
9
|
-
import { chainIsOPStack } from "./NetworkUtils";
|
|
10
|
-
import { Address, Transport } from "viem";
|
|
11
|
-
import { CHAIN_IDs } from "@across-protocol/constants";
|
|
12
|
-
import { estimateGas } from "viem/linea";
|
|
13
|
-
import { getPublicClient } from "../gasPriceOracle/util";
|
|
14
5
|
|
|
15
6
|
export type Decimalish = string | number | Decimal;
|
|
16
7
|
export const AddressZero = ethers.constants.AddressZero;
|
|
@@ -238,87 +229,6 @@ export type TransactionCostEstimate = {
|
|
|
238
229
|
gasPrice: BigNumber; // Units: wei/gas
|
|
239
230
|
};
|
|
240
231
|
|
|
241
|
-
/**
|
|
242
|
-
* Estimates the total gas cost required to submit an unsigned (populated) transaction on-chain.
|
|
243
|
-
* @param unsignedTx The unsigned transaction that this function will estimate.
|
|
244
|
-
* @param senderAddress The address that the transaction will be submitted from.
|
|
245
|
-
* @param provider A valid ethers provider - will be used to reason the gas price.
|
|
246
|
-
* @param options
|
|
247
|
-
* @param options.gasPrice A manually provided gas price - if set, this function will not resolve the current gas price.
|
|
248
|
-
* @param options.gasUnits A manually provided gas units - if set, this function will not estimate the gas units.
|
|
249
|
-
* @param options.transport A custom transport object for custom gas price retrieval.
|
|
250
|
-
* @returns Estimated cost in units of gas and the underlying gas token (gasPrice * estimatedGasUnits).
|
|
251
|
-
*/
|
|
252
|
-
export async function estimateTotalGasRequiredByUnsignedTransaction(
|
|
253
|
-
unsignedTx: PopulatedTransaction,
|
|
254
|
-
senderAddress: string,
|
|
255
|
-
provider: providers.Provider | L2Provider<providers.Provider>,
|
|
256
|
-
options: Partial<{
|
|
257
|
-
gasPrice: BigNumberish;
|
|
258
|
-
gasUnits: BigNumberish;
|
|
259
|
-
transport: Transport;
|
|
260
|
-
}> = {}
|
|
261
|
-
): Promise<TransactionCostEstimate> {
|
|
262
|
-
const { gasPrice: _gasPrice, gasUnits, transport } = options || {};
|
|
263
|
-
|
|
264
|
-
const { chainId } = await provider.getNetwork();
|
|
265
|
-
const voidSigner = new VoidSigner(senderAddress, provider);
|
|
266
|
-
|
|
267
|
-
// Estimate the Gas units required to submit this transaction.
|
|
268
|
-
const queries = [
|
|
269
|
-
gasUnits ? Promise.resolve(BigNumber.from(gasUnits)) : voidSigner.estimateGas(unsignedTx),
|
|
270
|
-
_gasPrice ? Promise.resolve({ maxFeePerGas: _gasPrice }) : getGasPriceEstimate(provider, chainId, transport),
|
|
271
|
-
] as const;
|
|
272
|
-
let [nativeGasCost, { maxFeePerGas: gasPrice }] = await Promise.all(queries);
|
|
273
|
-
assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
|
|
274
|
-
let tokenGasCost: BigNumber;
|
|
275
|
-
|
|
276
|
-
// OP stack is a special case; gas cost is computed by the SDK, without having to query price.
|
|
277
|
-
if (chainIsOPStack(chainId)) {
|
|
278
|
-
assert(isOptimismL2Provider(provider), `Unexpected provider for chain ID ${chainId}.`);
|
|
279
|
-
const populatedTransaction = await voidSigner.populateTransaction({
|
|
280
|
-
...unsignedTx,
|
|
281
|
-
gasLimit: nativeGasCost, // prevents additional gas estimation call
|
|
282
|
-
});
|
|
283
|
-
const l1GasCost = await provider.estimateL1GasCost(populatedTransaction);
|
|
284
|
-
const l2GasCost = nativeGasCost.mul(gasPrice);
|
|
285
|
-
tokenGasCost = l1GasCost.add(l2GasCost);
|
|
286
|
-
} else {
|
|
287
|
-
if (chainId === CHAIN_IDs.LINEA && process.env[`NEW_GAS_PRICE_ORACLE_${chainId}`] === "true") {
|
|
288
|
-
// Permit linea_estimateGas via NEW_GAS_PRICE_ORACLE_59144=true
|
|
289
|
-
let baseFeePerGas: BigNumber, priorityFeePerGas: BigNumber;
|
|
290
|
-
({
|
|
291
|
-
gasLimit: nativeGasCost,
|
|
292
|
-
baseFeePerGas,
|
|
293
|
-
priorityFeePerGas,
|
|
294
|
-
} = await getLineaGasFees(chainId, transport, unsignedTx));
|
|
295
|
-
gasPrice = baseFeePerGas.add(priorityFeePerGas);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
tokenGasCost = nativeGasCost.mul(gasPrice);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return {
|
|
302
|
-
nativeGasCost, // Units: gas
|
|
303
|
-
tokenGasCost, // Units: wei (nativeGasCost * wei/gas)
|
|
304
|
-
gasPrice: tokenGasCost.div(nativeGasCost), // Units: wei/gas
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
async function getLineaGasFees(chainId: number, transport: Transport | undefined, unsignedTx: PopulatedTransaction) {
|
|
309
|
-
const { gasLimit, baseFeePerGas, priorityFeePerGas } = await estimateGas(getPublicClient(chainId, transport), {
|
|
310
|
-
account: unsignedTx.from as Address,
|
|
311
|
-
to: unsignedTx.to as Address,
|
|
312
|
-
value: BigInt(unsignedTx.value?.toString() || "1"),
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
return {
|
|
316
|
-
gasLimit: BigNumber.from(gasLimit.toString()),
|
|
317
|
-
baseFeePerGas: BigNumber.from(baseFeePerGas.toString()),
|
|
318
|
-
priorityFeePerGas: BigNumber.from(priorityFeePerGas.toString()),
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
|
|
322
232
|
export function randomAddress() {
|
|
323
233
|
return ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));
|
|
324
234
|
}
|
|
@@ -1,21 +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 MAX_PRIORITY_FEE_PER_GAS = BigInt(1);
|
|
6
|
-
function eip1559(provider, _chainId) {
|
|
7
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
8
|
-
var _a, _maxFeePerGas, maxPriorityFeePerGas, maxFeePerGas;
|
|
9
|
-
return tslib_1.__generator(this, function (_b) {
|
|
10
|
-
switch (_b.label) {
|
|
11
|
-
case 0: return [4, provider.estimateFeesPerGas()];
|
|
12
|
-
case 1:
|
|
13
|
-
_a = _b.sent(), _maxFeePerGas = _a.maxFeePerGas, maxPriorityFeePerGas = _a.maxPriorityFeePerGas;
|
|
14
|
-
maxFeePerGas = BigInt(_maxFeePerGas) - maxPriorityFeePerGas + MAX_PRIORITY_FEE_PER_GAS;
|
|
15
|
-
return [2, { maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: MAX_PRIORITY_FEE_PER_GAS }];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
exports.eip1559 = eip1559;
|
|
21
|
-
//# sourceMappingURL=arbitrum-viem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arbitrum-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum-viem.ts"],"names":[],"mappings":";;;;AAGA,IAAM,wBAAwB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAK3C,SAAsB,OAAO,CAAC,QAAsB,EAAE,QAAgB;;;;;wBACN,WAAM,QAAQ,CAAC,kBAAkB,EAAE,EAAA;;oBAA3F,KAAwD,SAAmC,EAA3E,aAAa,kBAAA,EAAE,oBAAoB,0BAAA;oBACnD,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,oBAAoB,GAAG,wBAAwB,CAAC;oBAC7F,WAAO,EAAE,YAAY,cAAA,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,EAAC;;;;CACzE;AAJD,0BAIC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PublicClient } from "viem";
|
|
2
|
-
import { InternalGasPriceEstimate } from "../types";
|
|
3
|
-
export declare function eip1559(provider: PublicClient, _chainId: number): Promise<InternalGasPriceEstimate>;
|
|
4
|
-
export declare function legacy(provider: PublicClient, _chainId: number, _test?: number): Promise<InternalGasPriceEstimate>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.legacy = exports.eip1559 = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
function eip1559(provider, _chainId) {
|
|
6
|
-
return provider.estimateFeesPerGas();
|
|
7
|
-
}
|
|
8
|
-
exports.eip1559 = eip1559;
|
|
9
|
-
function legacy(provider, _chainId, _test) {
|
|
10
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
11
|
-
var gasPrice;
|
|
12
|
-
return tslib_1.__generator(this, function (_a) {
|
|
13
|
-
switch (_a.label) {
|
|
14
|
-
case 0: return [4, provider.getGasPrice()];
|
|
15
|
-
case 1:
|
|
16
|
-
gasPrice = _a.sent();
|
|
17
|
-
return [2, {
|
|
18
|
-
maxFeePerGas: gasPrice,
|
|
19
|
-
maxPriorityFeePerGas: BigInt(0),
|
|
20
|
-
}];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.legacy = legacy;
|
|
26
|
-
//# sourceMappingURL=ethereum-viem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum-viem.ts"],"names":[],"mappings":";;;;AAGA,SAAgB,OAAO,CAAC,QAAsB,EAAE,QAAgB;IAC9D,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC;AACvC,CAAC;AAFD,0BAEC;AAED,SAAsB,MAAM,CAC1B,QAAsB,EACtB,QAAgB,EAChB,KAAc;;;;;wBAEG,WAAM,QAAQ,CAAC,WAAW,EAAE,EAAA;;oBAAvC,QAAQ,GAAG,SAA4B;oBAE7C,WAAO;4BACL,YAAY,EAAE,QAAQ;4BACtB,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;yBAChC,EAAC;;;;CACH;AAXD,wBAWC"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gasStation = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var baseAdapter_1 = require("../../priceClient/adapters/baseAdapter");
|
|
6
|
-
var utils_1 = require("../../utils");
|
|
7
|
-
var constants_1 = require("../../constants");
|
|
8
|
-
var util_1 = require("../util");
|
|
9
|
-
var ethereum_viem_1 = require("./ethereum-viem");
|
|
10
|
-
var POLYGON = constants_1.CHAIN_IDs.POLYGON;
|
|
11
|
-
var GWEI = BigInt(1000000000);
|
|
12
|
-
var PolygonGasStation = (function (_super) {
|
|
13
|
-
tslib_1.__extends(PolygonGasStation, _super);
|
|
14
|
-
function PolygonGasStation(_a) {
|
|
15
|
-
var _this = this;
|
|
16
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.chainId, chainId = _c === void 0 ? POLYGON : _c, host = _b.host, _d = _b.timeout, timeout = _d === void 0 ? 1500 : _d, _e = _b.retries, retries = _e === void 0 ? 1 : _e;
|
|
17
|
-
host = (host !== null && host !== void 0 ? host : chainId === POLYGON) ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
|
|
18
|
-
_this = _super.call(this, "Polygon Gas Station", host, { timeout: timeout, retries: retries }) || this;
|
|
19
|
-
_this.chainId = chainId;
|
|
20
|
-
return _this;
|
|
21
|
-
}
|
|
22
|
-
PolygonGasStation.prototype.getFeeData = function (strategy) {
|
|
23
|
-
if (strategy === void 0) { strategy = "fast"; }
|
|
24
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
25
|
-
var gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas;
|
|
26
|
-
return tslib_1.__generator(this, function (_a) {
|
|
27
|
-
switch (_a.label) {
|
|
28
|
-
case 0: return [4, this.query("v2", {})];
|
|
29
|
-
case 1:
|
|
30
|
-
gas = _a.sent();
|
|
31
|
-
gasPrice = gas === null || gas === void 0 ? void 0 : gas[strategy];
|
|
32
|
-
if (!this.isPolygon1559GasPrice(gasPrice)) {
|
|
33
|
-
(0, util_1.gasPriceError)("getFeeData()", this.chainId, gasPrice);
|
|
34
|
-
}
|
|
35
|
-
maxPriorityFeePerGas = BigInt(gasPrice.maxPriorityFee) * GWEI;
|
|
36
|
-
maxFeePerGas = BigInt(gasPrice.maxFee) * GWEI;
|
|
37
|
-
return [2, { maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas }];
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
PolygonGasStation.prototype.isPolygon1559GasPrice = function (gasPrice) {
|
|
43
|
-
if (!(0, utils_1.isDefined)(gasPrice)) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
var _gasPrice = gasPrice;
|
|
47
|
-
return [_gasPrice.maxPriorityFee, _gasPrice.maxFee].every(function (field) { return ["number", "string"].includes(typeof field); });
|
|
48
|
-
};
|
|
49
|
-
return PolygonGasStation;
|
|
50
|
-
}(baseAdapter_1.BaseHTTPAdapter));
|
|
51
|
-
function gasStation(provider, chainId) {
|
|
52
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
53
|
-
var gasStation, maxPriorityFeePerGas, maxFeePerGas, err_1, minPriorityFee, priorityDelta;
|
|
54
|
-
var _a, _b;
|
|
55
|
-
return tslib_1.__generator(this, function (_c) {
|
|
56
|
-
switch (_c.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
|
|
59
|
-
_c.label = 1;
|
|
60
|
-
case 1:
|
|
61
|
-
_c.trys.push([1, 3, , 5]);
|
|
62
|
-
return [4, gasStation.getFeeData()];
|
|
63
|
-
case 2:
|
|
64
|
-
(_a = _c.sent(), maxPriorityFeePerGas = _a.maxPriorityFeePerGas, maxFeePerGas = _a.maxFeePerGas);
|
|
65
|
-
return [3, 5];
|
|
66
|
-
case 3:
|
|
67
|
-
err_1 = _c.sent();
|
|
68
|
-
return [4, (0, ethereum_viem_1.eip1559)(provider, chainId)];
|
|
69
|
-
case 4:
|
|
70
|
-
(_b = _c.sent(), maxPriorityFeePerGas = _b.maxPriorityFeePerGas, maxFeePerGas = _b.maxFeePerGas);
|
|
71
|
-
minPriorityFee = BigInt(30) * GWEI;
|
|
72
|
-
if (minPriorityFee > maxPriorityFeePerGas) {
|
|
73
|
-
priorityDelta = minPriorityFee - maxPriorityFeePerGas;
|
|
74
|
-
maxPriorityFeePerGas = minPriorityFee;
|
|
75
|
-
maxFeePerGas = maxFeePerGas + priorityDelta;
|
|
76
|
-
}
|
|
77
|
-
return [3, 5];
|
|
78
|
-
case 5: return [2, { maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas }];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
exports.gasStation = gasStation;
|
|
84
|
-
//# sourceMappingURL=polygon-viem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polygon-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon-viem.ts"],"names":[],"mappings":"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"}
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
var MAX_PRIORITY_FEE_PER_GAS = BigInt(1);
|
|
3
|
-
// Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller.
|
|
4
|
-
// Swap it for 1 Wei to avoid inaccurate transaction cost estimates.
|
|
5
|
-
// Reference: https://developer.arbitrum.io/faqs/gas-faqs#q-priority
|
|
6
|
-
export function eip1559(provider, _chainId) {
|
|
7
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
8
|
-
var _a, _maxFeePerGas, maxPriorityFeePerGas, maxFeePerGas;
|
|
9
|
-
return __generator(this, function (_b) {
|
|
10
|
-
switch (_b.label) {
|
|
11
|
-
case 0: return [4 /*yield*/, provider.estimateFeesPerGas()];
|
|
12
|
-
case 1:
|
|
13
|
-
_a = _b.sent(), _maxFeePerGas = _a.maxFeePerGas, maxPriorityFeePerGas = _a.maxPriorityFeePerGas;
|
|
14
|
-
maxFeePerGas = BigInt(_maxFeePerGas) - maxPriorityFeePerGas + MAX_PRIORITY_FEE_PER_GAS;
|
|
15
|
-
return [2 /*return*/, { maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: MAX_PRIORITY_FEE_PER_GAS }];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=arbitrum-viem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arbitrum-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum-viem.ts"],"names":[],"mappings":";AAGA,IAAM,wBAAwB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAE3C,qGAAqG;AACrG,oEAAoE;AACpE,oEAAoE;AACpE,MAAM,UAAgB,OAAO,CAAC,QAAsB,EAAE,QAAgB;;;;;wBACN,qBAAM,QAAQ,CAAC,kBAAkB,EAAE,EAAA;;oBAA3F,KAAwD,SAAmC,EAA3E,aAAa,kBAAA,EAAE,oBAAoB,0BAAA;oBACnD,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,oBAAoB,GAAG,wBAAwB,CAAC;oBAC7F,sBAAO,EAAE,YAAY,cAAA,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,EAAC;;;;CACzE"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PublicClient } from "viem";
|
|
2
|
-
import { InternalGasPriceEstimate } from "../types";
|
|
3
|
-
export declare function eip1559(provider: PublicClient, _chainId: number): Promise<InternalGasPriceEstimate>;
|
|
4
|
-
export declare function legacy(provider: PublicClient, _chainId: number, _test?: number): Promise<InternalGasPriceEstimate>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
export function eip1559(provider, _chainId) {
|
|
3
|
-
return provider.estimateFeesPerGas();
|
|
4
|
-
}
|
|
5
|
-
export function legacy(provider, _chainId, _test) {
|
|
6
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
7
|
-
var gasPrice;
|
|
8
|
-
return __generator(this, function (_a) {
|
|
9
|
-
switch (_a.label) {
|
|
10
|
-
case 0: return [4 /*yield*/, provider.getGasPrice()];
|
|
11
|
-
case 1:
|
|
12
|
-
gasPrice = _a.sent();
|
|
13
|
-
return [2 /*return*/, {
|
|
14
|
-
maxFeePerGas: gasPrice,
|
|
15
|
-
maxPriorityFeePerGas: BigInt(0),
|
|
16
|
-
}];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=ethereum-viem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum-viem.ts"],"names":[],"mappings":";AAGA,MAAM,UAAU,OAAO,CAAC,QAAsB,EAAE,QAAgB;IAC9D,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAgB,MAAM,CAC1B,QAAsB,EACtB,QAAgB,EAChB,KAAc;;;;;wBAEG,qBAAM,QAAQ,CAAC,WAAW,EAAE,EAAA;;oBAAvC,QAAQ,GAAG,SAA4B;oBAE7C,sBAAO;4BACL,YAAY,EAAE,QAAQ;4BACtB,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;yBAChC,EAAC;;;;CACH"}
|