Skip to content

Commit

Permalink
save userOp's gasPrices when calculating PVG (#402)
Browse files Browse the repository at this point in the history
* use bundler's gasPrices when calculating pvg

* revert

* calculate pvg using bundler gasPrices

---------

Co-authored-by: mouseless <[email protected]>
  • Loading branch information
mouseless0x and mouseless0x authored Jan 11, 2025
1 parent 8695d4c commit 51fdd72
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,27 +626,20 @@ export async function calcOptimismPreVerificationGas(
: gasPriceManager.getBaseFee()
])

if (!validate) {
gasPriceManager.optimismManager.saveL1FeeValue(l1Fee)
}
let l2MaxFee: bigint
let l2PriorityFee: bigint

if (op.maxFeePerGas <= 1n || op.maxPriorityFeePerGas <= 1n) {
// if user didn't provide gasPrice values, fetch current going price rate
if (validate) {
l2MaxFee = await gasPriceManager.getHighestMaxFeePerGas()
l2PriorityFee =
baseFeePerGas +
(await gasPriceManager.getHighestMaxPriorityFeePerGas())
} else {
const gasPrices = await gasPriceManager.getGasPrice()
op.maxPriorityFeePerGas = gasPrices.maxPriorityFeePerGas
op.maxFeePerGas = gasPrices.maxFeePerGas
l2MaxFee = gasPrices.maxFeePerGas
l2PriorityFee = baseFeePerGas + gasPrices.maxPriorityFeePerGas
}

const l2MaxFee = validate
? await gasPriceManager.getHighestMaxFeePerGas()
: op.maxFeePerGas

const l2PriorityFee =
baseFeePerGas +
(validate
? await gasPriceManager.getHighestMaxPriorityFeePerGas()
: op.maxPriorityFeePerGas)

const l2price = minBigInt(l2MaxFee, l2PriorityFee)

return staticFee + l1Fee / l2price
Expand Down

0 comments on commit 51fdd72

Please sign in to comment.