Skip to content

feat: implement order entry improvements (OB-072, OB-068, OB-071, OB-073) - #809

Merged
IbrahimIjai merged 2 commits into
SO4-Markets:mainfrom
heymariam:feature/order-entry-improvements
Sep 26, 2026
Merged

IbrahimIjai merged 2 commits into
SO4-Markets:mainfrom
heymariam:feature/order-entry-improvements

Conversation

@heymariam

Copy link
Copy Markdown
Contributor

Description

Summary

Implemented four interconnected order-entry improvements to enable exact input validation, chart recovery, capability-driven UI, and balance-aware sizing.

Closes #724
Closes #720
Closes #723
Closes #726

OB-072: Exact Size and Limit-Price Input Validation

  • Added: Core validation module (input-validation.ts) with functions for amount, price, tick, lot, notional, and balance validation
  • Coverage: 60+ tests covering paste operations, partial decimal input, tiny/large values, increment boundaries, and unsupported notation
  • Integration: Real-time validation in TradePanel with field-specific error messages
  • Features:
    • Prevents precision loss through exact numeric handling
    • Distinguishes validation errors (empty → "Enter an amount", zero → "Amount must be greater than zero", etc.)
    • Blocks submission until all validations pass
    • Validates against wallet balance to prevent failed transactions

OB-068: Chart-Local Empty, Error, and Stale Recovery

  • States: Implemented three distinct failure modes:
    • No history (new market)
    • Failed load (fetch error)
    • Stale data (live feed stopped)
  • Recovery: Added refetch buttons with appropriate messaging
  • Preserve: Chart geometry and readability maintained during failures
  • Tests: 7 new tests verify state transitions and recovery messaging
  • UI: Clear explanations for each state without reconnecting wallet or clearing inputs

OB-071: Rebuild Ticket Around Verified Capabilities

  • Filtering: Verified Swap gets Market/Limit only, Long/Short get all modes
  • Wording: Confirmed correct labels (Pay/Collateral, Receive/Market, Long/Short/Swap)
  • Transitions:
    • Mode changes preserve compatible fields
    • Toast notifications explain discarded fields
    • Motion tokens added (150ms base, 100ms fast for smooth transitions)
    • Fade-in animations respect prefers-reduced-motion
  • Tests: 6 new tests verify mode stability, keyboard focus, and field preservation

OB-073: Available-Balance and Percentage Sizing

  • Utilities: Created available-balance.ts with:
    • calculateAvailableBalance(): Deducts fees, execution costs, and reserves
    • getPercentageAmount(): Calculates 0/25/50/75/100% of available
    • canExecuteAmount(): Validates amount won't exceed available funds
  • Fixtures: Exact tests verify 0%, 25%, 50%, 75%, 100% and MAX sizing
  • Safety: All percentages guaranteed not to exceed available balance after fees
  • Architecture: Enables background balance updates to refresh without overwriting manual input

Files Changed

New Files

  • apps/web/src/lib/input-validation.ts - Core validation functions
  • apps/web/src/lib/input-validation.test.ts - 60+ validation tests
  • apps/web/src/features/trade/lib/available-balance.ts - Balance calculation utilities
  • apps/web/src/features/trade/lib/available-balance.test.ts - Balance fixture tests

Modified Files

  • apps/web/src/features/trade/components/trade-panel/TradePanel.tsx - Added validation, mode notifications, motion tokens
  • apps/web/src/features/trade/components/trade-panel/TradePanel.test.tsx - Added 6 mode transition tests
  • apps/web/src/features/trade/components/chart/TVChartContainer.tsx - Implemented three recovery states
  • apps/web/src/features/trade/components/chart/TVChartContainer.test.tsx - Added 7 recovery tests

Testing

  • Unit Tests: 80+ new tests covering all acceptance criteria
  • Fixtures: Exact test cases for percentages (0/25/50/75/100) without exceeding balance
  • Integration: Tests verify motion, focus stability, and field preservation across transitions
  • Validation: Edge cases tested (negative amounts, zero balance, insufficient funds, etc.)

…073)

- OB-072: Add exact size and limit-price input validation with comprehensive test coverage for paste, partial decimals, tiny/large values, increment boundaries, and unsupported notation
- OB-068: Provide chart-local empty, error, and stale recovery with distinct states and retry/refresh buttons
- OB-071: Rebuild ticket around verified capabilities with correct wording, mode filtering, and smooth transitions
- OB-073: Implement available-balance and percentage sizing utilities with exact fixtures for 0/25/50/75/100 percent
@drips-wave

drips-wave Bot commented Sep 25, 2026

Copy link
Copy Markdown

@heymariam 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

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@heymariam is attempting to deploy a commit to the Ijai's projects Team on Vercel.

A member of the Team first needs to authorize it.

@IbrahimIjai
IbrahimIjai merged commit 69c2a2d into SO4-Markets:main Sep 26, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants