Skip to content

feat: Withdrawal to any token (Predict)#7783

Merged
dan437 merged 37 commits intomainfrom
withdrawal-to-any-token
Feb 11, 2026
Merged

feat: Withdrawal to any token (Predict)#7783
dan437 merged 37 commits intomainfrom
withdrawal-to-any-token

Conversation

@dan437
Copy link
Contributor

@dan437 dan437 commented Jan 30, 2026

Explanation

Adds support for "post-quote" withdrawal flows, enabling users to withdraw funds to any token/chain (e.g., Predict withdrawals).

Changes:

  • Add isPostQuote flag to transaction data for withdrawal-first flows
  • Add setIsPostQuote controller action to enable post-quote mode
  • Support EXACT_INPUT trade type in Relay strategy for withdrawals (user specifies source amount, receives quote for destination)
  • Build post-quote requests in buildQuoteRequests when isPostQuote is true
  • Handle same-token-same-chain withdrawals without requiring a bridge
  • Add source amount tracking for post-quote flows
  • Put the deposit into a batch with the original transaction

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

Note

Medium Risk
Touches quote construction and Relay batch submission logic (including transaction typing and gas handling), which can impact correctness of on-chain execution for withdrawals. Changes are feature-gated by the new isPostQuote flag but broaden behavior in core transaction-pay flows.

Overview
Adds post-quote (withdrawal) support across Transaction Pay by introducing isPostQuote into TransactionData/QuoteRequest and persisting it onto TransactionMeta.metamaskPay (also extending MetamaskPayMetadata in transaction-controller).

Replaces setIsMaxAmount with a callback-based setTransactionConfig, and ensures toggling isPostQuote re-triggers source-amount and quote refresh.

Updates Relay quoting/submission to handle post-quote semantics: keep targetAmountMinimum=0 requests when isPostQuote, use EXACT_INPUT, skip transaction preprocessing, avoid Hyperliquid-deposit normalization in post-quote mode, and submit as a batch that prepends the original transaction ahead of relay steps with corrected type/gasLimit handling.

Adds post-quote-specific source amount derivation (including new source* fields and same-token-same-chain skip logic via isSameToken), includes original transaction gas as fees.transactionGas in totals, and fixes a nested-transfer detection edge case (findIndex returning -1).

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

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
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.

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
* @param relayParamCount - Number of relay-only params (excludes prepended original tx).
* @returns The transaction type.
*/
function getTransactionType(
Copy link
Member

@matthewwalsh0 matthewwalsh0 Feb 11, 2026

Choose a reason for hiding this comment

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

Minor, exported functions at the top, internal below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will include it in the next PR!

@dan437 dan437 added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit 567485a Feb 11, 2026
1181 of 1187 checks passed
@dan437 dan437 deleted the withdrawal-to-any-token branch February 11, 2026 17:51
* `calculateTransactionGasCost`, independent of any bridge quote fees.
* Only populated on totals, not on individual quotes.
*/
transactionGas?: FiatValue;
Copy link
Member

@matthewwalsh0 matthewwalsh0 Feb 12, 2026

Choose a reason for hiding this comment

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

Afraid I totally missed this, was this added between reviews?

We shouldn't need to expose the transaction specific gas externally, as it becomes part of the Relay quote deposit, so it should be encapsulated by the sourceNetwork fee.

We can remove in the upcoming gas fee PR.

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.

2 participants