@across-protocol/sdk 3.3.27 → 3.3.29
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/gasPriceOracle/adapters/arbitrum.js +1 -7
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +2 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +30 -2
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/oracle.js +27 -43
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/utils/BlockUtils.js +1 -0
- package/dist/cjs/utils/BlockUtils.js.map +1 -1
- package/dist/cjs/utils/Multicall.js +2 -1
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/common.js +30 -41
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +4 -12
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +19 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +44 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/oracle.js +27 -43
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/utils/BlockUtils.js +1 -0
- package/dist/esm/utils/BlockUtils.js.map +1 -1
- package/dist/esm/utils/Multicall.js +2 -1
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/common.js +31 -42
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +19 -0
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/utils/BlockUtils.d.ts.map +1 -1
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/gasPriceOracle/adapters/arbitrum.ts +3 -12
- package/src/gasPriceOracle/adapters/ethereum.ts +39 -2
- package/src/gasPriceOracle/oracle.ts +7 -19
- package/src/utils/BlockUtils.ts +1 -0
- package/src/utils/Multicall.ts +2 -1
- package/src/utils/common.ts +19 -22
package/src/utils/common.ts
CHANGED
|
@@ -4,7 +4,7 @@ import assert from "assert";
|
|
|
4
4
|
import Decimal from "decimal.js";
|
|
5
5
|
import { ethers, PopulatedTransaction, providers, VoidSigner } from "ethers";
|
|
6
6
|
import { getGasPriceEstimate } from "../gasPriceOracle";
|
|
7
|
-
import { BigNumber, BigNumberish, BN, formatUnits, parseUnits, toBN } from "./BigNumberUtils";
|
|
7
|
+
import { BigNumber, BigNumberish, BN, bnZero, formatUnits, parseUnits, toBN } from "./BigNumberUtils";
|
|
8
8
|
import { ConvertDecimals } from "./FormattingUtils";
|
|
9
9
|
import { chainIsOPStack } from "./NetworkUtils";
|
|
10
10
|
import { Address, Transport } from "viem";
|
|
@@ -265,8 +265,12 @@ export async function estimateTotalGasRequiredByUnsignedTransaction(
|
|
|
265
265
|
const voidSigner = new VoidSigner(senderAddress, provider);
|
|
266
266
|
|
|
267
267
|
// Estimate the Gas units required to submit this transaction.
|
|
268
|
-
const
|
|
269
|
-
|
|
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");
|
|
270
274
|
let tokenGasCost: BigNumber;
|
|
271
275
|
|
|
272
276
|
// OP stack is a special case; gas cost is computed by the SDK, without having to query price.
|
|
@@ -276,28 +280,21 @@ export async function estimateTotalGasRequiredByUnsignedTransaction(
|
|
|
276
280
|
...unsignedTx,
|
|
277
281
|
gasLimit: nativeGasCost, // prevents additional gas estimation call
|
|
278
282
|
});
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const [l1GasCost, l2GasPrice] = await Promise.all([
|
|
282
|
-
provider.estimateL1GasCost(populatedTransaction),
|
|
283
|
-
_gasPrice || provider.getGasPrice(),
|
|
284
|
-
]);
|
|
285
|
-
const l2GasCost = nativeGasCost.mul(l2GasPrice);
|
|
283
|
+
const l1GasCost = await provider.estimateL1GasCost(populatedTransaction);
|
|
284
|
+
const l2GasCost = nativeGasCost.mul(gasPrice);
|
|
286
285
|
tokenGasCost = l1GasCost.add(l2GasCost);
|
|
287
|
-
} else 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
|
-
const {
|
|
290
|
-
gasLimit: nativeGasCost,
|
|
291
|
-
baseFeePerGas,
|
|
292
|
-
priorityFeePerGas,
|
|
293
|
-
} = await getLineaGasFees(chainId, transport, unsignedTx);
|
|
294
|
-
tokenGasCost = baseFeePerGas.add(priorityFeePerGas).mul(nativeGasCost);
|
|
295
286
|
} else {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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);
|
|
300
296
|
}
|
|
297
|
+
|
|
301
298
|
tokenGasCost = nativeGasCost.mul(gasPrice);
|
|
302
299
|
}
|
|
303
300
|
|