chore: refactor quickbuy to use fetchQuotes v2#29165
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
✅ E2E Fixture Validation — Schema is up to date |
| return () => { | ||
| debouncedFetchQuotes.cancel(); | ||
| }; | ||
| }, [debouncedFetchQuotes]); |
There was a problem hiding this comment.
Missing abort on dependency change causes stale quote acceptance
Medium Severity
The effect cleanup cancels the debounce but does not abort the in-flight fetch. When a dependency changes (e.g., user edits the amount), the old API call can resolve and update rawQuotes/isQuoteLoading with stale data before the new debounced fetch starts. In useQuickBuyBottomSheet, the settledSourceTokenAmountRef effect sees isQuoteLoading transition to false and stamps settledSourceTokenAmountRef.current with the current sourceTokenAmount, making isPendingQuoteRefresh false — even though the quote data corresponds to the previous amount. This enables the confirm button with a stale quote for ~300ms, potentially allowing submission of a bridge transaction for the wrong amount.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d00a194. Configure here.
AI PR Analysis🚫 Merge safe: false | 🟠 Risk: high
AI analysis did not complete. Manual review recommended. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: The PR introduces changes to three areas:
The QuickBuyBottomSheet is used in the SocialLeaderboard/TraderPositionView which is related to:
The changes are primarily refactoring with good unit test coverage. No changes to core controllers, navigation, or shared infrastructure. Risk is medium because the quote fetching path for QuickBuy has been significantly refactored. Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 50226d7. Configure here.
| abortControllerRef.current = controller; | ||
|
|
||
| setIsQuoteLoading(true); | ||
| setQuoteFetchError(null); |
There was a problem hiding this comment.
Stale isNoQuotesAvailable persists during new fetch
Medium Severity
When a new fetch begins, quoteFetchError is correctly reset to null but isNoQuotesAvailable is not reset to false. If a previous fetch returned zero quotes, the stale isNoQuotesAvailable = true persists throughout the next fetch. Since hasError in useQuickBuyBottomSheet is derived from quoteFetchError || isNoQuotesAvailable, the button incorrectly shows "unavailable" text while a new quote is actively loading. The resetQuotesIdle helper does reset it, but it's only called for invalid inputs — not before a valid fetch starts.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 50226d7. Configure here.
|





Description
useBridgeQuoteRequest+useBridgeQuoteData) with a one-shotBridgeController.fetchQuotescall managed by a new local hook,useQuickBuyQuotes.BridgeController.state.quotesis never populated, so opening QuickBuy no longer pollutes the shared Bridge slice.quoteOverrideparameter touseIsInsufficientBalanceso the gas-adjusted native-token balance check still works when the quote lives in local state instead of Redux. All existing callers are unaffected (param is optional).Out of scope / follow-ups
Blockaid validation on Solana source quotes is not ported (was in useBridgeQuoteData).No need because this is already handled byfetchQuotes.Changelog
CHANGELOG entry: no-changelog
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
QuickBuy’s quote lifecycle is refactored from shared Redux/polling hooks to local
fetchQuotescalls, which can affect quote timing, error states, and balance gating. Balance checks now accept an optional quote override, so regressions are mostly limited to QuickBuy/bridge UX rather than core transaction signing.Overview
QuickBuy now manages quotes locally by replacing the polling-based
useBridgeQuoteRequest/useBridgeQuoteDataflow with a newuseQuickBuyQuoteshook that debounces one-shotBridgeController.fetchQuotesrequests, tracks loading/error/no-quotes state, and derives the recommended/enriched quote viaselectBridgeQuoteswithout populating shared controller/Redux quote state.Balance validation is updated:
useIsInsufficientBalanceadds an optionalquoteOverride(including explicitnullto ignore Redux quotes) so QuickBuy can still include gas fee context when quotes live outside Redux; tests were updated/added to cover override precedence and QuickBuy wiring.Reviewed by Cursor Bugbot for commit 50226d7. Bugbot is set up for automated code reviews on this repo. Configure here.