Skip to content

Comments

feat(transaction-pay): add Across strategy support#7886

Open
pedronfigueiredo wants to merge 1 commit intomainfrom
cor-6997-across-strategy
Open

feat(transaction-pay): add Across strategy support#7886
pedronfigueiredo wants to merge 1 commit intomainfrom
cor-6997-across-strategy

Conversation

@pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Feb 10, 2026

Explanation

This PR extracts the Across strategy work on top of the provider-fallback baseline.

It adds:

  • Across strategy wiring (across strategy type + registration)
  • Across quote retrieval/parsing/normalization
  • Across submit flow for approval + swap/deposit execution paths
  • Across-specific types/constants required for compilation
  • Minimal selection/config hooks to make Across selectable
  • Changelog entries for transaction-controller and transaction-pay-controller

References

Addresses: https://github.com/MetaMask/MetaMask-planning/issues/6997

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 transaction submission path (including batched approvals and on-chain gas estimation/fallback) and new transaction types, which could impact how pay transactions are created and tracked if misconfigured.

Overview
Adds an Across-based pay strategy to transaction-pay-controller, including quote fetching/normalization and a submission flow that can execute approval + deposit (batched) or deposit-only transactions and optionally poll Across for completion.

Extends configuration and utilities to support this: introduces TransactionPayStrategy.Across, feature-flag-driven payStrategies config (incl. default Across API base), validated optional metaMaskFee params, shared amounts helpers, and a new estimateGasLimitWithBufferOrFallback helper used by Across; RelayStrategy now has an explicit supports() gate.

Updates transaction-controller transaction typing with perpsAcrossDeposit/predictAcrossDeposit for attribution, and adds comprehensive tests plus changelog entries.

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

@pedronfigueiredo pedronfigueiredo force-pushed the cor-6997-across-strategy branch 2 times, most recently from 665488f to 8be8f8c Compare February 10, 2026 12:09
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 4 times, most recently from 9cd0f37 to a6c9af9 Compare February 13, 2026 10:47
return getFeatureFlags(messenger).relayFallbackGas;
}

export async function estimateGasWithBufferOrFallback({
Copy link
Member

Choose a reason for hiding this comment

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

estimateGasLimit?

};
}

export function getFallbackGas(messenger: TransactionPayControllerMessenger): {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be in feature-flags.ts?

error = caughtError;
}

const fallbackGas = getFallbackGas(messenger);
Copy link
Member

Choose a reason for hiding this comment

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

Debatable whether we should have fallback gas or throw as it implies the transaction would revert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fallback is now option but off by default

across?: PayStrategyConfigRaw;
relay?: {
enabled?: boolean;
relayQuoteUrl?: string;
Copy link
Member

Choose a reason for hiding this comment

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

Is this redundant as we already have the top level value?

slippage: number;
};

export type PayStrategyConfigRaw = {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be AcrossConfig?

messenger,
});

const max = calculateGasCost({
Copy link
Member

Choose a reason for hiding this comment

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

We also need gas station support here, but can do that in a future PR and re-use the Relay logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a ticket for this

request: QuoteRequest,
): Promise<TransactionPayQuote<AcrossQuote>['fees']['sourceNetwork']> {
const { from } = request;
const { swapTx } = quote;
Copy link
Member

Choose a reason for hiding this comment

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

Do we also need to include gas cost of approvalTxns?

const chainId = toHex(params.chainId);
const value = toHex(params.value ?? '0x0');

const gas = await estimateGasWithBuffer(
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to duplicate the gas logic again, but store the gas limits in the quote to use during submit, so we know the network fees will match.

data: params.data,
from,
gas: toHex(gas),
maxFeePerGas: normalizeOptionalHex(params.maxFeePerGas),
Copy link
Member

Choose a reason for hiding this comment

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

Can they not return gas fee properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure I understand the question here, it's simply normalising to hex if needed.

}

await Promise.all(
transactionIds.map((txId) => waitForTransactionConfirmed(txId, messenger)),
Copy link
Member

Choose a reason for hiding this comment

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

We're waiting for the deposit transactions to succeed, but we also need to poll the Across API to verify the status of their transactions on the target chain.

Looks like /deposit/status?

@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 4 times, most recently from 08bac6a to 26c090a Compare February 16, 2026 10:51
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 3 times, most recently from d7d7490 to b6a43e3 Compare February 20, 2026 14:44
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6997-across-strategy branch 2 times, most recently from bee7414 to ca79a44 Compare February 20, 2026 16:54
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from b6a43e3 to 7908026 Compare February 23, 2026 11:35
Base automatically changed from cor-6992-extract-fallback-mechanism to main February 23, 2026 11:50
Copy link

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


export type AcrossActionRequestBody = {
actions: AcrossAction[];
};
Copy link

Choose a reason for hiding this comment

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

Unused exported types are dead code

Low Severity

AcrossActionArg, AcrossAction, and AcrossActionRequestBody are exported from this file but never imported or referenced anywhere in the codebase. These types appear to be scaffolding for future delegation support (per PR discussion), but they are currently dead code that adds maintenance surface area without being used.

Fix in Cursor Fix in Web

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.

2 participants