feat(topup): show net "you'll receive" and enforce $10 minimum on card top-ups - #688
Merged
Conversation
…d top-ups Fast-follow to the merged backend fee feature (lnflash/flash#473), which exposes Globals.fygaroTopup with the processor/Flash fee params and the top-up minimum. - Add `fygaroTopup { minimumAmount processorFeePercent processorFeeFixed flashFeePercent flashFeeFixed }` to the `transferFlags` globals query that the topup/cashout entry screen already fetches, so the data is cache-warm on arrival. The field + the `FygaroTopupInfo` type were hand-added to public-schema.graphql (no backend access to re-introspect) and codegen was regenerated. - TopupDetails now shows "You'll receive $X.XX" (net after fees) live as the user types, mirroring the cashout settlement-amount preview (#683). Card-only; the line is hidden when `fygaroTopup` is null so a wrong number is never shown. - Raise/enforce the card minimum to `fygaroTopup.minimumAmount` (fallback $10 when null); the invalid-amount alert now states the real minimum. - New i18n keys added to en + all 23 locale files. Tests cover the $10 floor, the $5 rejection (incl. null fallback), and the $9.01 net for a $10 gross. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NcEjF6SS3Ci5D4CzZqdPjb
…w on minimum Address code-review findings on the "you'll receive" top-up disclosure: - estimateTopupNet now computes in integer cents, rounding each fee component (processor %+fixed, flash %+fixed) to the nearest cent before subtracting, exactly as the backend does (flash#473). The prior float-dollar math with a single final round diverged by a cent for a large fraction of non-round amounts (e.g. $10.25 showed $9.25 while the backend credits $9.24), over-promising the headline number. - The net preview is now gated on the enforced minimum, so a below-floor amount (e.g. $5) no longer shows a concrete receive figure that Continue will immediately refuse. - Tests: added a non-round unit case (10.25 → $9.24) and a preview case (10.25 → $9.24, not $9.25) that fail under the old float math, plus a below-minimum hide case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014QwZjNcKfkMhrBE33HcUVN
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.
What & why
Fast-follow to the merged backend fee feature (lnflash/flash#473), which added a nullable
Globals.fygaroTopupfield carrying the Fygaro processor + Flash fee params and the top-up minimum. This wires the app to consume them so a card top-up is transparent about fees and enforces a real minimum.Two user-facing changes on the card top-up amount screen (
TopupDetails,paymentType: "card"):>= $1.00card check is replaced withfygaroTopup.minimumAmount, and the invalid-amount alert now states the real minimum.Net is computed as:
e.g. $10 gross with 2.99% + $0.49 processor and 2% flash → $9.01.
Null-degradation
fygaroTopupis null when the instance's Fygaro settings are unavailable. The app handles that gracefully:Both are card-only — bank-transfer / bridge flows keep the existing $1 floor and show no net line.
GraphQL field consumed
Added
fygaroTopup { minimumAmount processorFeePercent processorFeeFixed flashFeePercent flashFeeFixed }to the existingtransferFlagsglobals query (the one that already surfacesbridgeEnabled, fetched by the topup/cashout entry screen — so the data is cache-warm on arrival toTopupDetails).Since this worktree has no backend access to re-introspect, the
FygaroTopupInfotype and thefygaroTopup: FygaroTopupInfofield were hand-added to the committedapp/graphql/public-schema.graphqlto match flash#473, then codegen was regenerated (yarn dev:codegen) —generated.ts/generated.gqlare in the diff.graphql-inspectorvalidates clean.i18n
New keys (
TopupDetails.youllReceive,TopupDetails.feeNote, and a parameterizedTopupDetails.minimumAmount) added toapp/i18n/en/index.tsand to all 23 locale files underraw-i18n/translations/(English placeholder, per convention).yarn update-translationsandcheck:translation-driftboth clean.Tests
app/screens/topup-cashout-flow/__tests__/TopupDetails.test.tsxextended (globals hook mocked the way CardPayment mocks its query hook):fygaroTopupis null and for bank transfersestimateTopupNetunit tests (sample + negative clamp)yarn check-code(tsc + translations + codegen + graphql-check) passes;yarn testfor the flow is green (23/23).🤖 Generated with Claude Code
https://claude.ai/code/session_01NcEjF6SS3Ci5D4CzZqdPjb