From 27f8b31a629544a0e18b497408e49f3b47396f48 Mon Sep 17 00:00:00 2001 From: plusminushalf Date: Wed, 22 Nov 2023 20:54:01 +0530 Subject: [PATCH] don't depend on user's input --- packages/utils/src/validation.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/utils/src/validation.ts b/packages/utils/src/validation.ts index 0800a2fa..f14828ab 100644 --- a/packages/utils/src/validation.ts +++ b/packages/utils/src/validation.ts @@ -227,6 +227,8 @@ export async function calcOptimismPreVerificationGas( throw new RpcError("block does not have baseFeePerGas") } + const maxPriorityFeePerGas = await publicClient.estimateMaxPriorityFeePerGas() + const serializedTx = serializeTransaction( { to: entryPoint, @@ -251,12 +253,9 @@ export async function calcOptimismPreVerificationGas( const { result: l1Fee } = await opGasPriceOracle.simulate.getL1Fee([serializedTx]) - const l2MaxFee = op.maxFeePerGas - const l2PriorityFee = latestBlock.baseFeePerGas + op.maxPriorityFeePerGas - - const l2price = l2MaxFee < l2PriorityFee ? l2MaxFee : l2PriorityFee + const l2PriorityFee = latestBlock.baseFeePerGas + maxPriorityFeePerGas - return l1Fee / l2price + return l1Fee / l2PriorityFee } const getArbitrumL1FeeAbi = [