Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
|
||
| // Convert L1 fee from ETH to MNT using tokenRatio (raw multiplier) | ||
| const tokenRatio = toBN(await contract.tokenRatio()); | ||
| const l1FeeInMnt = l1Fee.mul(tokenRatio); |
There was a problem hiding this comment.
Possible double-counting of tokenRatio in L1 fee
High Severity
Mantle's official documentation states that getL1Fee already incorporates tokenRatio in its calculation (L1RollupFee = rollupDataGas × L1gasPrice × tokenRatio × scalar), returning a value denominated in MNT. Multiplying the result by tokenRatio again would inflate the fee by ~3020x. The PR states this targets "post-Arsia" behavior where getL1Fee returns ETH, but the Arsia upgrade was only confirmed for Mantle Sepolia (testnet, March 25 2026) — mainnet activation (chain ID 0x1388 targeted here) is unconfirmed. If deployed before Arsia reaches mainnet, gas estimates would be grossly overestimated.
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
f9016e3 to
ca12036
Compare


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 ~3020 (≈ ETH/MNT price ratio)getL1Feereturns ETH-denominated values confirmed by comparing oracle output against real transaction receiptl1Feefields on mantlescanChanges:
MantleLayer1GasFeeFlow.ts(~90 lines) extendingOracleLayer1GasFeeFlowMantleLayer1GasFeeFlow.test.ts(8 tests)MANTLE: '0x1388'toCHAIN_IDSin constantsMantleLayer1GasFeeFlowinTransactionControllerReferences
ScrollLayer1GasFeeFlow/OptimismLayer1GasFeeFlowChecklist
Note
Medium Risk
Adds a new chain-specific L1 gas fee calculation path that changes fee estimation behavior for Mantle transactions; incorrect conversion or oracle call handling could misestimate fees on that network.
Overview
Adds a Mantle-specific
Layer1GasFeeFlowthat converts OP Stack oraclegetL1Feeresults from ETH-denominated values into MNT by multiplying by the on-chaintokenRatio(), then adds the (MNT-denominated) operator fee whengasUsedis available.Registers this flow ahead of existing OP Stack/Scroll flows so Mantle transactions match the new logic first, adds
CHAIN_IDS.MANTLE, includes a dedicated Jest test suite for conversion/error cases, and updates the transaction-controller changelog entry.Written by Cursor Bugbot for commit 0e8a69b. This will update automatically on new commits. Configure here.