fix(samples/frontend): floor default quote amount to corridor minimum#605
Conversation
Corridor minimums vary widely (e.g. USD->EUR ~$23, USD->BRL ~$12, USD->MXN ~$1), so a fixed default still failed with AMOUNT_OUT_OF_RANGE on higher-min corridors. The quote step now looks up the corridor's minSendingAmount via the exchange-rates endpoint and floors the default amount to it (+5% buffer for FX drift). maxSendingAmount is intentionally not used as it is unreliable for some corridors in this environment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| const mins = (res.data ?? []).map((r) => r.minSendingAmount ?? 0) | ||
| setMinSendingAmount(mins.length ? Math.max(...mins) : null) | ||
| }) | ||
| .catch(() => { if (!cancelled) setMinSendingAmount(null) }) |
There was a problem hiding this comment.
Silent min-fetch failure leaves body at the un-floored default
When the exchange-rates request fails (transient network error, API error, non-ok response), the .catch() handler silently resets minSendingAmount to null. The body useEffect then fires with flooredToMin = 0, so lockedCurrencyAmount falls back to defaultAmount — potentially below the corridor minimum. There is no in-UI indication of this, so a developer would only discover the fallback by seeing the AMOUNT_OUT_OF_RANGE error after submitting the quote. Surfacing the error (e.g. via setError) or at least displaying a warning in the form header would make the failure visible before submission.
Prompt To Fix With AI
This is a comment left during a code review.
Path: samples/frontend/src/steps/CreateQuote.tsx
Line: 53
Comment:
**Silent min-fetch failure leaves body at the un-floored default**
When the exchange-rates request fails (transient network error, API error, non-`ok` response), the `.catch()` handler silently resets `minSendingAmount` to `null`. The body `useEffect` then fires with `flooredToMin = 0`, so `lockedCurrencyAmount` falls back to `defaultAmount` — potentially below the corridor minimum. There is no in-UI indication of this, so a developer would only discover the fallback by seeing the `AMOUNT_OUT_OF_RANGE` error after submitting the quote. Surfacing the error (e.g. via `setError`) or at least displaying a warning in the form header would make the failure visible before submission.
How can I resolve this? If you propose a fix, please make it concise.
Corridor minimums vary widely (e.g. USD->EUR ~$23, USD->BRL ~$12, USD->MXN
~$1), so a fixed default still failed with AMOUNT_OUT_OF_RANGE on higher-min
corridors. The quote step now looks up the corridor's minSendingAmount via
the exchange-rates endpoint and floors the default amount to it (+5% buffer
for FX drift). maxSendingAmount is intentionally not used as it is unreliable
for some corridors in this environment.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com