fix(goodreserve-widget): unblock swap flow and limit amount precision - #166
Merged
Conversation
blueogin
requested review from
a team and
L03TJ3
and
a lite review from Copilot
August 14, 2026 14:03
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the GoodReserve swap widget’s reliability and UX by fixing stale-quote dead-ends, correctly handling reverted on-chain transactions (approval + swap), correcting exit contribution scaling, and standardizing amount display/precision without changing on-chain math.
Changes:
- Adds a quote-refresh nonce/notice path so expired quotes trigger an automatic re-quote instead of leaving the user stuck.
- Introduces an explicit
approval_pendingstep and performs a pre-flight ERC20 approval that verifiesreceipt.status, plus verifies swap receipts to avoid false “success”. - Improves UI rendering/formatting: token-aware confirm hero badges, corrected badge background, removes unsupported DOM prop usage, and formats/truncates displayed amounts while retaining full-precision values in state.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/goodreserve-widget/src/widgetRuntimeContract.ts | Adds approval_pending to the widget status union. |
| packages/goodreserve-widget/src/useReserveSwap.ts | Adds stale-quote recovery kick, pre-flight approval w/ receipt validation, and swap receipt status validation. |
| packages/goodreserve-widget/src/useReserveQuote.ts | Adds quoteRefreshNonce dependency and preserves stale-quote warning through the refetch lifecycle. |
| packages/goodreserve-widget/src/useReserveBootstrap.ts | Stores walletClientRef for manual approval; fixes exit contribution scaling via new divisor constant. |
| packages/goodreserve-widget/src/useGoodReserveAdapter.ts | Wires quoteRefreshNonce and clears quote-refresh notice on user edits/direction changes/max. |
| packages/goodreserve-widget/src/ReserveSwapView.tsx | Updates UI for approval pending, improves confirm drawer hero + minimum-received rendering, and applies new amount formatting. |
| packages/goodreserve-widget/src/constants.ts | Adds QUOTE_REFRESHED_NOTICE and EXIT_CONTRIBUTION_PPM_DIVISOR. |
| packages/goodreserve-widget/src/amount.ts | Introduces formatting utilities for display (formatTokenAmount, formatInputAmount) and responsive font sizing. |
| examples/storybook/src/stories/goodreserve-widget/GoodReserveWidget.stories.tsx | Adds QuoteRefreshing and ApprovalPending stories. |
| examples/storybook/src/fixtures/goodReserveWidgetMock.ts | Updates fixtures to use full-precision amounts and adds fixtures for the new states. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+90
to
+94
| // Stale-quote recovery: re-quoting automatically with the notice still visible. | ||
| export const QuoteRefreshing: Story = { | ||
| render: () => | ||
| renderStory(reserveWidgetMockStates.quoteRefreshing, 'GoodReserveWidget-quote-refreshing'), | ||
| } |
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.
Description
Addresses the review feedback on the GoodReserve swap widget.
Fixes
the stale-quote guard cleared it but the quote effect never re-ran (it keys on
inputs that patch doesn't change), leaving a permanently disabled "Review Swap".
A refresh nonce now forces the re-quote.
receipt.status, and viem resolves for reverted transactions — so a failedapproval looked successful and
swapInran anyway. The widget now approves andverifies the receipt itself. Same gap meant a reverted swap rendered as "Swap
Successful"; that's checked too.
MAX_WEIGHT = 1e8,so the divisor was off by 100×. Now 10.00%.
formatUnitsoutput was rendered directly(
Balance: 79812.445063704882420442). Display fields now useformatTokenAmount;the amount input truncates to 6 decimals while the exact value is retained, so MAX
still spends the full balance and no on-chain math changed.
$, and the "to" badge sat on$color— near-white in dark theme, rendering as a blank disc. Each side now namesits own token.
adjustsFontSizeToFitis React Native-onlyand did no fitting on the DOM. Removed.
Adds an
approval_pendingstatus so the two wallet signatures a swap needs areexplained, plus
QuoteRefreshingandApprovalPendingStorybook stories.About # (link your issue here)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: