fix: add BTC swap reserve enforcement with quote-aware fee handling#30404
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 f157e30. Configure here.
f157e30 to
f102f2f
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag Selection Rationale:
The changes are scoped to the Bridge/Swap UI components and a hook used only within that feature area. No core controllers, navigation, or shared infrastructure is affected. The risk is medium because the logic change affects the swap/bridge confirmation flow validation, which could impact whether users can proceed with BTC bridge transactions. Performance Test Selection: |
|




Description
This pull request enhances the
useInsufficientNativeReserveErrorhook to support Bitcoin (BTC) native reserve logic, ensuring accurate handling of minimum reserve requirements and quote-aware calculations for BTC swaps. It also improves test coverage for these scenarios and refactors related code for better clarity and extensibility.BTC Native Reserve Support and Logic Improvements:
Testing Enhancements:
Refactoring and Type Improvements:
Integration Updates:
BridgeViewContentandSwapsConfirmButtoncomponents to pass theactiveQuoteprop to the hook, enabling quote-aware reserve checks in the UI flow.Changelog
CHANGELOG entry: added BTC swap reserve enforcement with quote-aware fee handling
Related issues
Fixes: Bridging BTC is failing at the transaction crafting in certain cases
Manual testing steps
BTC max amount / reserve validation
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
Updates swap/bridge validation for BTC to enforce a minimum native reserve using quote-provided network fees/overhead, which can block transactions if miscomputed. Changes are localized and covered by new unit tests, but affect user-facing amount limits and submit eligibility.
Overview
Adds BTC native reserve enforcement to swap/bridge submit validation.
useInsufficientNativeReserveErrornow supports CAIP chain IDs, defines a BTC mainnet minimum reserve (0.00003), and for BTC usesactiveQuoteto subtract quoted network fees and source-side overhead when computing the max swappable amount.Integrates quote-aware checks in the UI flow.
BridgeViewandSwapsConfirmButtonnow passactiveQuoteinto the hook so banners/CTAs and the confirm button correctly reflect BTC reserve + fee constraints.Expands test coverage. Adds BTC-specific unit tests covering reserve boundary conditions, quote fee consumption, decimal truncation, and cases where gas validation should own the failure.
Reviewed by Cursor Bugbot for commit da0093c. Bugbot is set up for automated code reviews on this repo. Configure here.