Repository navigation
Conversation
Contributor
🛑 Files requiring codeowner reviewTo merge this PR, you'll need to get approvals from the following owners. @MetaMask/perps (11 files)
@MetaMask/core-platform (expand for more) |
geositta
marked this pull request as ready for review
November 20, 2026 02:22
geositta
force-pushed
the
TAT-3752-withdrawal-route-core
branch
from
November 20, 2026 04:11
99be726 to
6e7a6ff
Compare
geositta
enabled auto-merge
November 20, 2026 04:26
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Clients need to know which venue a withdrawal will use before checking account support. Inferring that venue in Mobile duplicates Core's routing policy: it can ignore a saved default provider or assume Hyperliquid when Core would refuse an ambiguous multi-venue withdrawal. Neither no-argument
getAccountSupport()nor the first entry fromgetWithdrawalRoutes()answers which venuewithdrawwill sign on.This adds
PerpsController.resolveWithdrawalRoute(params?), its messenger action, and the exportedResolveWithdrawalRouteParamsandWithdrawalRoutetypes:{ status: 'resolved', providerId }for a direct provider, an explicit registered aggregated route, or the sole registered aggregated venue, including Lighter.{ status: 'route_required', error: 'PROVIDER_ROUTE_REQUIRED' }when multiple aggregated venues are registered and no route is supplied. This refusal is a value rather than a thrown error because the client's account-support error handler can fail open.PROVIDER_NOT_FOUNDfor an unknown explicit aggregated route or a route that conflicts with the active direct provider.withdrawnow rejects direct-provider conflicts before withdrawal tracking or signing begins.No-argument
getAccountSupport()continues to check the aggregated routing default, even when an unrouted withdrawal would be refused. Withdrawal-record venue stamping is unchanged. Unknown aggregated routes retain the existing withdrawal error handling: the query throws, whileAccountServicereturns a failed withdrawal result.Consumers should resolve the route, stop on
route_required, then checkgetAccountSupport({ providerId })and pass that same venue towithdraw. Preflight results must be discarded when the account, network, or provider context changes.Compatibility for other consumers: Extension and Terminal need no adoption for this change — the method, action and types are purely additive and no existing messenger surface changes behavior for valid input, so both clients keep working unchanged; they can adopt
resolveWithdrawalRoutelater for the same routing-policy parity as Mobile.Mobile adoption, pending-check retirement on provider switches, and venue-specific quote/validation changes remain separate client work; this PR does not change Mobile or publish the package.
The implementation is ported from
473ae0148c0onto perps-controller25.0.0, based on2d56e38b3e5958d7129a7b8b4a3b02fe6c0014ac. All functional source hunks remain necessary. The README insertion preserves the newer batch-routing documentation, and the aggregated-route tests now exercise withdrawal behavior against the same fixtures as the query.Validation
yarn lint:tsc:checkpassed with existing suppressions unchanged.References
Checklist
Note
Medium Risk
Changes withdrawal routing validation on a funds-moving path, though behavior is mostly additive preflight API plus earlier rejection of invalid provider routes.
Overview
Adds
resolveWithdrawalRoute(plus messenger action andWithdrawalRoute/ResolveWithdrawalRouteParamstypes) so clients can see which venuewithdrawwould sign on using the same aggregated routing rules. A resolvedproviderIdis returned when the route is unambiguous; when multiple venues are registered and no route is given, callers get{ status: 'route_required', error: 'PROVIDER_ROUTE_REQUIRED' }as a value instead of an exception, avoiding fail-open handling in account-support UIs. Unknown explicit routes or routes that conflict with the active direct provider still throwPROVIDER_NOT_FOUND, aligned withgetAccountSupport.withdrawnow applies that same direct-provider conflict check before delegation toAccountService, so invalidproviderIdvalues fail before tracking or signing. Docs and changelog describe using resolve →getAccountSupport({ providerId })→withdrawrather than inferring the venue fromgetAccountSupport()orgetWithdrawalRoutes().Reviewed by Cursor Bugbot for commit 6e7a6ff. Bugbot is set up for automated code reviews on this repo. Configure here.