Skip to content

feat: Mantle mainnet custom gas fee#8376

Closed
jeremy-consensys wants to merge 7 commits intomainfrom
chore/add-mantle-gas-fee-flow
Closed

feat: Mantle mainnet custom gas fee#8376
jeremy-consensys wants to merge 7 commits intomainfrom
chore/add-mantle-gas-fee-flow

Conversation

@jeremy-consensys
Copy link
Copy Markdown
Contributor

@jeremy-consensys jeremy-consensys commented Apr 3, 2026

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 existing OptimismLayer1GasFeeFlow would 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 of OracleLayer1GasFeeFlow that:

  1. Calls getL1Fee(bytes) to get the L1 data fee (ETH-denominated)
  2. Calls tokenRatio() on the same oracle contract (0x420...000F) to get the ETH/MNT exchange rate
  3. Multiplies the L1 fee by tokenRatio to convert to MNT
  4. Adds the operator fee (already in MNT) from getOperatorFee(uint256)

The flow is registered first in #getLayer1GasFeeFlows() so it matches Mantle transactions before OptimismLayer1GasFeeFlow can claim them.

Verified on-chain:

  • tokenRatio() returns ~3330 (current ETH/MNT price ratio)
  • getL1Fee returns ETH-denominated values confirmed by comparing oracle output against real transaction receipt l1Fee fields on Mantlescan
  • getOperatorFee reverts on mainnet (Arsia not yet deployed), handled gracefully with default to 0

Changes

File Change
constants.ts Add MANTLE: '0x1388'
MantleLayer1GasFeeFlow.ts New flow: getL1Fee * tokenRatio + operatorFee
MantleLayer1GasFeeFlow.test.ts 8 tests covering matching, conversion, error handling
TransactionController.ts Register MantleLayer1GasFeeFlow first in flow list
CHANGELOG.md Unreleased entry

References

  • Mantle fee model: L2 Execution Fee (EIP-1559) + L1 Data Fee (oracle, ETH-denominated) + Operator Fee (oracle, MNT-denominated)
  • Oracle contract: 0x420000000000000000000000000000000000000F
  • Pattern follows ScrollLayer1GasFeeFlow / OptimismLayer1GasFeeFlow

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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 getL1Fee result via tokenRatio().

OracleLayer1GasFeeFlow now supports an overridable transformOracleFee hook applied before adding any operator fee, and TransactionController registers the new MantleLayer1GasFeeFlow ahead of other OP-stack flows to ensure correct matching for 0x1388 and 0x138b.

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.

@jeremy-consensys jeremy-consensys requested review from a team as code owners April 3, 2026 08:47
@jeremy-consensys jeremy-consensys marked this pull request as draft April 3, 2026 09:15
@jeremy-consensys jeremy-consensys changed the title feat: add Mantle layer 1 gas fee flow with tokenRatio conversion feat: add Mantle layer 1 custom gas fee Apr 3, 2026
@jeremy-consensys jeremy-consensys changed the title feat: add Mantle layer 1 custom gas fee feat: Mantle mainnet custom gas fee Apr 3, 2026
@jeremy-consensys jeremy-consensys force-pushed the chore/add-mantle-gas-fee-flow branch from f9016e3 to ca12036 Compare April 3, 2026 09:17
@jeremy-consensys jeremy-consensys marked this pull request as ready for review April 9, 2026 08:22
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
@jeremy-consensys jeremy-consensys force-pushed the chore/add-mantle-gas-fee-flow branch from ca12036 to f784b2c Compare April 9, 2026 08:22
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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.
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.

1 participant