feat: Mantle mainnet custom gas fee#8376
Closed
jeremy-consensys wants to merge 7 commits intomainfrom
Closed
Conversation
packages/transaction-controller/src/gas-flows/MantleLayer1GasFeeFlow.ts
Outdated
Show resolved
Hide resolved
f9016e3 to
ca12036
Compare
4 tasks
Mantle uses MNT as its native gas token, but the OP Stack oracle's getL1Fee returns values denominated in ETH. Add MantleLayer1GasFeeFlow that multiplies the L1 fee by tokenRatio (ETH/MNT exchange rate from the oracle contract) before adding the operator fee. - New MantleLayer1GasFeeFlow extending OracleLayer1GasFeeFlow - Registered first in #getLayer1GasFeeFlows() to match before Optimism - Added MANTLE chain ID (0x1388) to constants - 8 unit tests covering conversion, operator fee, error handling
ca12036 to
f784b2c
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f784b2c. Configure here.
…ss logic Add protected transformOracleFee hook to OracleLayer1GasFeeFlow so subclasses can transform the oracle fee without reimplementing the entire getLayer1Fee method. Simplify MantleLayer1GasFeeFlow to only override transformOracleFee (tokenRatio multiplication) and matchesTransaction.
…stnet Add Mantle Sepolia (chain ID 0x138b) to MantleLayer1GasFeeFlow so the tokenRatio conversion applies to testnet transactions as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
Mantle uses MNT as its native gas token, but the OP Stack oracle's
getL1Fee(bytes)returns L1 data fees denominated in ETH. The existingOptimismLayer1GasFeeFlowwould match Mantle (via the Gas API supported networks list) and use the ETH-denominated value directly, resulting in incorrect gas fee estimates.This PR adds
MantleLayer1GasFeeFlow, a new subclass ofOracleLayer1GasFeeFlowthat:getL1Fee(bytes)to get the L1 data fee (ETH-denominated)tokenRatio()on the same oracle contract (0x420...000F) to get the ETH/MNT exchange ratetokenRatioto convert to MNTgetOperatorFee(uint256)The flow is registered first in
#getLayer1GasFeeFlows()so it matches Mantle transactions beforeOptimismLayer1GasFeeFlowcan claim them.Verified on-chain:
tokenRatio()returns ~3330 (current ETH/MNT price ratio)getL1Feereturns ETH-denominated values confirmed by comparing oracle output against real transaction receiptl1Feefields on MantlescangetOperatorFeereverts on mainnet (Arsia not yet deployed), handled gracefully with default to 0Changes
constants.tsMANTLE: '0x1388'MantleLayer1GasFeeFlow.tsMantleLayer1GasFeeFlow.test.tsTransactionController.tsMantleLayer1GasFeeFlowfirst in flow listCHANGELOG.mdReferences
ScrollLayer1GasFeeFlow/OptimismLayer1GasFeeFlowChecklist
Note
Medium Risk
Adds a new chain-specific Layer 1 fee calculation path and changes oracle fee combination logic, which can affect gas estimates for OP-stack networks if the transform step is misapplied. Risk is mitigated by focused unit tests covering conversion, operator-fee handling, and error cases.
Overview
Adds Mantle-specific Layer 1 gas fee estimation so Mantle transactions get MNT-denominated L1 fees by converting the oracle’s ETH-denominated
getL1Feeresult viatokenRatio().OracleLayer1GasFeeFlownow supports an overridabletransformOracleFeehook applied before adding any operator fee, andTransactionControllerregisters the newMantleLayer1GasFeeFlowahead of other OP-stack flows to ensure correct matching for0x1388and0x138b.Includes new chain IDs in
constants.ts, expanded unit tests for both the new Mantle flow and the updated transform behavior, and a changelog entry documenting the addition.Reviewed by Cursor Bugbot for commit 9b5a847. Bugbot is set up for automated code reviews on this repo. Configure here.