Skip to content

fix: include Mantle operator fee in post-confirmation layer1GasFee#9630

Open
adaOctopus wants to merge 1 commit into
mainfrom
fix-add-mantle-opf
Open

fix: include Mantle operator fee in post-confirmation layer1GasFee#9630
adaOctopus wants to merge 1 commit into
mainfrom
fix-add-mantle-opf

Conversation

@adaOctopus

@adaOctopus adaOctopus commented Jul 23, 2026

Copy link
Copy Markdown

Explanation

After WPN-1001, confirmation estimates include Mantle’s L1 data fee + operator fee via transactionMeta.layer1GasFee. Activity Details still under-reported the fee after confirmation because:

  1. Receipt-based fee math only used l1Fee (L1 data fee), ignoring Mantle Arsia operatorFeeScalar / operatorFeeConstant.
  2. On confirmation, PendingTransactionTracker stored the receipt but never refreshed layer1GasFee with inclusion-time L1 + operator values.

Mantle receipts expose:

operatorFee = gasUsed * operatorFeeScalar * 100 + operatorFeeConstant
layer1GasFee = l1Fee + operatorFee   // receipt l1Fee is already MNT

This PR:

  • Extends TransactionReceipt with optional operatorFeeScalar, operatorFeeConstant, and tokenRatio.
  • Adds getOperatorFeeFromReceipt / getLayer1FeeFromReceipt and exports them.
  • Refreshes transactionMeta.layer1GasFee from the receipt on confirmation.
  • Updates getLocalTransactionFees in @metamask/client-utils to prefer layer1GasFee, else receipt-derived L1 + operator (no double-count).
  • Does not multiply receipt l1Fee by tokenRatio (that would overstate Mantle fees). Pre-confirm oracle estimation is unchanged (fix/mantle lack operator fee #8837).

References

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

Test plan

  • yarn workspace @metamask/transaction-controller run jest --no-coverage src/utils/receipt-fees.test.ts src/helpers/PendingTransactionTracker.test.ts
  • yarn workspace @metamask/client-utils run jest --no-coverage src/mappers/helpers/transactions.test.ts
  • Mantle: confirm a send — Activity Details network fee includes operator fee and aligns with confirmation / on-chain cost
  • Optimism/Base: Activity network fee still correct (L2 + l1Fee); no operator double-count
  • Ethereum (or other non-rollup): network fee unchanged when L1/operator receipt fields are absent

Suggested short summary if you need one line for the PR overview: refresh layer1GasFee from Mantle/OP receipt fields on confirm and include L1 + operator in client-utils activity fees.


Note

Medium Risk
Changes fee math shown to users on rollup chains; logic is well-tested but wrong formulas would misstate costs on Mantle/Optimism.

Overview
Fixes under-reported network fees on Mantle and other OP Stack rollups after confirmation by accounting for L1 data fee + Mantle operator fee, not L2 gas alone.

In @metamask/transaction-controller, receipt typing gains optional operatorFeeScalar, operatorFeeConstant, and tokenRatio. New getOperatorFeeFromReceipt / getLayer1FeeFromReceipt helpers compute operator fee (gasUsed × scalar × 100 + constant) and combined L1+operator totals; PendingTransactionTracker overwrites layer1GasFee from the receipt on confirm when those fields exist (inclusion-time values, not stale pre-confirm estimates).

In @metamask/client-utils, getLocalTransactionFees adds L1/operator on top of gasUsed × effectiveGasPrice, preferring layer1GasFee on meta and otherwise deriving from receipt fields (mirroring the controller logic, without double-counting).

Reviewed by Cursor Bugbot for commit 34af464. Bugbot is set up for automated code reviews on this repo. Configure here.

Derive L1 + operator fees from receipt fields on confirmation and in
client-utils activity fee mapping so Activity Details match what was paid.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adaOctopus
adaOctopus requested review from a team as code owners July 23, 2026 11:45
@matthewwalsh0
matthewwalsh0 self-requested a review July 23, 2026 12:01
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