Skip to content

feat(transaction-pay-controller): support Predict withdraw in the server strategy - #10702

Draft
matthewwalsh0 wants to merge 17 commits into
feat/transaction-pay-non-atomic-second-legfrom
feat/server-predict-withdraw
Draft

matthewwalsh0 wants to merge 17 commits into
feat/transaction-pay-non-atomic-second-legfrom
feat/server-predict-withdraw

Conversation

@matthewwalsh0

Copy link
Copy Markdown
Member

Explanation

The server strategy declined Predict withdraws, so they could only be quoted and submitted through the Relay strategy.

  • The server strategy now supports each Predict withdraw variant:
    • Safe: quotes honour refundTo, and gas estimation and gas fee token lookups use the Safe that holds the source token.
    • Polymarket deposit wallet: quotes are requested from the deposit wallet in USDC.e with useDepositAddress. On submit, the Polymarket relayer unwraps pUSD directly to the provider deposit address, then any leftover or refunded USDC.e is swept back to the deposit wallet. No source network fee is charged, as the relayer pays origin gas.
    • Payment overrides (e.g. withdrawing to a Money Account): non-atomic quotes settle on the override recipient, and the override calls run as a second leg.
  • Post-quote quotes include the original transaction in gas estimation and reserve the gas fee token cost from the source amount.
  • The Polymarket withdraw and post-quote gas logic is shared by the Relay and Server strategies, without changing Relay behaviour.
  • Server quote requests accept useDepositAddress, and server transaction steps carry an optional provider step id used to identify the deposit step.

References

Stacked on #10501.

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

… when the provider cannot execute them

Server quote providers either execute the target calls as part of the
quote or decline the request outright, so flows whose calls no provider
can run were simply unsupported.

Request such calls as optional, so providers that cannot execute them
still return a funds-only quote flagged with `callsSupported: false`.
When that happens the quote is marked `requiresSecondLeg` and the calls
are submitted separately on the target chain once the quote settles.

Extract the second-leg submission that the Money Account vault deposit
already performed into a shared `second-leg` util, reading the settled
amount from the settlement transfer logs so the second leg spends what
actually landed rather than the quoted amount. `ma-vault-deposit` is now
a thin Monad-pinned wrapper that layers on CHOMP race handling, and the
relay strategy's recipient resolution moves into the same util so both
strategies settle non-atomic funds on the executing account.
…second leg tests

Raise the `server-quotes.test.ts` counts and add a `second-leg.test.ts`
entry to cover the literals added by the new tests, matching the call
sites already suppressed in those files.

Drop the `ma-vault-deposit.test.ts` entries, whose violations no longer
occur now that the second leg resolves its own execution account.
@matthewwalsh0
matthewwalsh0 force-pushed the feat/transaction-pay-non-atomic-second-leg branch from acf8b02 to e912f9f Compare October 8, 2026 08:47

This branch has not been deployed

No deployments
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