Skip to content

Conversation

Battambang
Copy link

@Battambang Battambang commented Sep 23, 2025

Explanation

What is the current state of things and why does it need to change?

  • Today, quotes can indicate when gas is embedded into the transaction itself via gasIncluded and when EIP‑7702 delegated execution can be used via gasIncluded7702, but there’s no explicit way to signal that a third party will sponsor the gas cost.
  • This prevents the UI/clients from differentiating between “quote includes gas fees” and “quote is gasless to the user because gas is sponsored,” which affects UX (badging, prioritization) and any downstream decision logic.

What is the solution your changes offer and how does it work?

  • Added an optional boolean quote.gasSponsored to QuoteSchema in @validators.ts to allow the bridge API to flag gas‑sponsored quotes.
  • Ensured end‑to‑end preservation:
    • Validation now accepts payloads with or without gasSponsored.
    • BridgeController.fetchQuotes and the fee‑augmentation path preserve the field unchanged so the UI and metrics layers can consume it.
  • Tests:
    • Added a test in bridge-controller.test.ts verifying that fetchQuotes returns quotes where quote.gasSponsored is preserved when present, and remains undefined when omitted.
  • Backward compatibility:
    • The field is optional; existing payloads and flows continue to work unchanged.
    • No sorting or fee calculations are altered by this addition.

Are there any changes whose purpose might not obvious to those unfamiliar with the domain?

  • Distinction between flags:
    • gasIncluded: Quote includes gas fees in the trade economics, but the user still submits and pays gas.
    • gasIncluded7702: Quote can use delegated execution under EIP‑7702.
    • gasSponsored: A third party sponsors the gas so the user doesn’t pay it; this is orthogonal to whether gas is “included” in pricing or delegated via 7702.

References

This PR is related to this BridgeAPI PR https://github.com/consensys-vertical-apps/va-mmcx-bridge-api/pull/527.
PR related for MM Extension: MetaMask/metamask-extension#36227.
PR related for MM Mobile: MetaMask/metamask-mobile#20878.

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Introduce optional quote.gasSponsored in schema and ensure fetchQuotes preserves it; add tests and changelog entry.

  • Validators:
    • Extend QuoteSchema in src/utils/validators.ts with optional quote.gasSponsored boolean.
  • BridgeController Tests:
    • Import GenericQuoteRequest and add makeQuoteRequest helper.
    • Add test to verify fetchQuotes preserves quote.gasSponsored when present.
  • Changelog:
    • Note that quotes returned by fetchQuotes now include gasSponsored under Unreleased.

Written by Cursor Bugbot for commit cb85254. This will update automatically on new commits. Configure here.

@Battambang Battambang marked this pull request as ready for review October 16, 2025 13:25
@Battambang Battambang requested review from a team as code owners October 16, 2025 13:25
@Battambang Battambang changed the title [WIP] feat: add gasSponsored flag to bridgeController feat: add gasSponsored flag to bridgeController Oct 16, 2025
mcmire
mcmire previously approved these changes Oct 16, 2025
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Left a couple of comments, but they are non-blocking. LGTM.

mcmire
mcmire previously approved these changes Oct 16, 2025
totalFeeAmountUsd: optional(string()),
}),
),
gasSponsored: optional(boolean()),
Copy link
Contributor

@stanleyyconsensys stanleyyconsensys Oct 17, 2025

Choose a reason for hiding this comment

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

nit

please update the comment for gasIncluded7702, as gas sponser will also set this field to true

Copy link
Contributor

@stanleyyconsensys stanleyyconsensys Oct 17, 2025

Choose a reason for hiding this comment

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

please double confirm

if gasIncluded7702 is true and gasSponsored is true

what happen to the extension when it is not ready support that from UI?

cursor[bot]

This comment was marked as outdated.

@Battambang Battambang marked this pull request as draft October 17, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants