Skip to content

fix(bundler): make default maxFeePerGas floor chain-aware - #19

Open
Alicepoltora wants to merge 1 commit into
circlefin:masterfrom
Alicepoltora:fix/chain-aware-max-fee-floor
Open

Alicepoltora wants to merge 1 commit into
circlefin:masterfrom
Alicepoltora:fix/chain-aware-max-fee-floor

Conversation

@Alicepoltora

Copy link
Copy Markdown

Summary

Fixes #15

prepareUserOperation used a hardcoded 3 gwei maxFeePerGas floor when neither the caller-supplied partialUserOp fields nor a custom estimateFeesPerGas callback provided fees. On L2s where base fees sit well below 1 gwei (Base, Arbitrum, Optimism regularly see 0.001–0.1 gwei) this inflates the worst-case spend (gasLimit × maxFeePerGas) that Gas Station policies check by 100–500×, rejecting otherwise-trivial UserOperations with a typical ~0.01 USDC budget.

Changes

  • Add defaultMaxFeePerGasFor(chainId): 0.05 gwei floor on L2s with routine sub-gwei base fees (Base / Base Sepolia, Arbitrum One / Sepolia, Optimism / OP Sepolia, Polygon / Amoy); keep the 3 gwei L1-tuned default for Ethereum mainnet and unknown chains
  • The existing max(estimated × 2) clamp is unchanged — when the node estimates non-trivial fees they still win
  • Custom estimateFeesPerGas override path untouched

Notes

0.05 gwei is chosen as a floor that clears current L2 minimum base fees while being ~60× smaller than the old 3 gwei constant; on these chains a typical UserOp uses < 300k gas, so the checked worst-case spend drops from ~0.0009 ETH to ~0.000015 ETH — comfortably inside Gas Station budgets.

internal fun defaultMaxFeePerGasFor(chainId: Long): BigInteger = when (chainId) {
    8453L, 84532L,      // Base, Base Sepolia
    42161L, 421614L,    // Arbitrum One, Arbitrum Sepolia
    10L, 11155420L,     // Optimism, OP Sepolia
    137L, 80002L,       // Polygon, Polygon Amoy
        -> parseGwei("0.05")
    else -> parseGwei("3")
}

Fixes circlefin#15

prepareUserOperation used a hardcoded 3 gwei maxFeePerGas floor when neither
the caller-supplied partialUserOp fields nor a custom estimateFeesPerGas
callback provided fees. On L2s where base fees sit well below 1 gwei this
inflates the worst-case spend (gasLimit x maxFeePerGas) that Gas Station
policies check by 100-500x, rejecting otherwise-trivial UserOperations with
a budget of ~0.01 USDC.

Add defaultMaxFeePerGasFor(chainId) applying a 0.05 gwei floor on L2 chains
where sub-gwei base fees are routine (Base, Base Sepolia, Arbitrum One and
Sepolia, Optimism and OP Sepolia, Polygon and Amoy) and keep the
conservative L1-tuned 3 gwei default for Ethereum mainnet and unknown
chains. The max(estimated x 2) clamp is unchanged, so when the node
estimates non-trivial fees they still win.

The custom estimateFeesPerGas override path is untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BundlerApiImpl hardcoded 3-gwei maxFeePerGas floor breaks Gas Station policy on every L2

1 participant