Skip to content

feat(escrow): extract reusable SlippageWarning component#350

Open
BigManly4 wants to merge 1 commit into
SwiftChainn:mainfrom
BigManly4:upgrade/fiat-slippage-warning
Open

feat(escrow): extract reusable SlippageWarning component#350
BigManly4 wants to merge 1 commit into
SwiftChainn:mainfrom
BigManly4:upgrade/fiat-slippage-warning

Conversation

@BigManly4

Copy link
Copy Markdown

Closes #331

Summary

The FX rate slippage logic and warning UI required by this issue already
existed on main (useFiatXlmSlippage hook, fiatXlmSlippageService, and the
warning markup inlined inside FiatXlmPreview) -- 60-second rate variance
tracking, a non-blocking advisory at >2% variance, and a blocking
checkbox-gated acknowledgment at >5% variance were all already in place
and already covered by tests.

This PR addresses the remaining gap: the issue's implementation directory
names components/escrow/SlippageWarning.tsx specifically, and no such
standalone component existed -- the warning UI was only reachable as
markup embedded in FiatXlmPreview, so no other escrow flow that quotes a
fiat/XLM rate could reuse it.

Changes

  • Add components/escrow/SlippageWarning.tsx: a presentational component
    that owns the three slippage UI states (none, >2% advisory, >5% blocking
    with acknowledgment checkbox), taking the slippage result and an
    acknowledgment callback as props.
  • Refactor FiatXlmPreview to compose SlippageWarning instead of inlining
    the same markup, wired to the existing useFiatXlmSlippage hook. Behavior
    is unchanged -- confirmed against the existing FiatXlmPreview test suite.
  • Add components/escrow/tests/SlippageWarning.test.tsx covering all
    three states, the acknowledgment callback, and the submitting-disabled
    state, in isolation from FiatXlmPreview.

Architecture: SlippageWarning (Component) -> useFiatXlmSlippage (Hook) ->
fiatXlmSlippageService -> fxService -> Backend.

Test plan

  • npx jest components/escrow -- 8/8 suites in this directory passing
    (SlippageWarning.test.tsx and FiatXlmPreview.test.tsx both green)

Extract the FX rate slippage warning UI out of FiatXlmPreview into a
standalone SlippageWarning component so any escrow flow that quotes a
fiat/XLM rate can reuse the same 2%/5% threshold warning and blocking
acknowledgment checkbox, rather than duplicating the markup per
consumer.

FiatXlmPreview now composes SlippageWarning, wiring it to the existing
useFiatXlmSlippage hook and fiatXlmSlippageService; behavior (2%
advisory banner, 5% blocking checkbox, submission gating) is
unchanged. Adds a dedicated test suite covering SlippageWarning in
isolation.
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@BigManly4 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade: Cross-Border Slippage Warning UI

1 participant