fix: limit price deviation chips always invalid for buy 0/1/5/10% and sell 0% #495

Closed
opened 2026-07-15 04:04:51 +00:00 by PlasticDigits · 3 comments
PlasticDigits commented 2026-07-15 04:04:51 +00:00 (Migrated from gitlab.com)

Summary

On the limit order price row, the deviation chips (0%, +1%, +5%, +10%) always set price to ref × (1 + pct/100). That makes every chip invalid for buy, and 0% invalid for sell, because retail limits must stay strictly on the maker side of the reference.

Observed

Side Chip Result
Buy (bid) 0%, +1%, +5%, +10% Always Invalid buy (price ≥ reference)
Sell (ask) 0% Always Invalid sell (price ≤ / equals reference)

UI shows the red “Invalid buy/sell” state and blocks place.

Expected

Deviation chips should produce valid maker prices for the active side:

  • Buy: below reference (e.g. 0%− / slightly under, -1%, -5%, -10% — or exclude at-market 0% if equality remains invalid)
  • Sell: above reference (e.g. slightly over for near-0%, +1%, +5%, +10%)

Root cause (likely)

LimitOrderPriceInputWithContext calls limitPriceFromRefDeviationPercent(ref, pct) with unsigned positive presets from LIMIT_PRICE_DEVIATION_CHIP_PRESETS = [0, 1, 5, 10], ignoring side.

Direction guard (isLimitPriceDirectionInvalid, GitLab #154):

  • bid invalid when limit >= ref
  • ask invalid when limit <= ref (equality treated as invalid)

So buy chips always land on/above ref; sell 0% lands exactly on ref.

Relevant code:

  • frontend-dapp/src/components/trade/LimitOrderPriceField.tsx (chip onClick)
  • frontend-dapp/src/utils/limitOrderPriceReference.ts (LIMIT_PRICE_DEVIATION_CHIP_PRESETS, limitPriceFromRefDeviationPercent, isLimitPriceDirectionInvalid)

Suggested fix

Make chip presets side-aware (signed deviation from ref), and decide whether a true at-market 0% chip should be omitted or map to a tiny offset so equality stays invalid.

Repro

  1. Open Trade / Limit Orders with a pair that has a reference price.
  2. Select Buy → click 0%, +1%, +5%, +10% → each shows Invalid buy.
  3. Flip to Sell → click 0% → Invalid sell.

Acceptance

  • Buy chips set prices strictly below ref and clear the invalid state.
  • Sell near-market / positive chips set prices strictly above ref.
  • Place guard / non-crossing checks still pass for chip-selected prices when the book allows.
## Summary On the limit order price row, the deviation chips (`0%`, `+1%`, `+5%`, `+10%`) always set price to `ref × (1 + pct/100)`. That makes every chip invalid for **buy**, and `0%` invalid for **sell**, because retail limits must stay strictly on the maker side of the reference. ## Observed | Side | Chip | Result | |------|------|--------| | Buy (bid) | `0%`, `+1%`, `+5%`, `+10%` | Always **Invalid buy** (price ≥ reference) | | Sell (ask) | `0%` | Always **Invalid sell** (price ≤ / equals reference) | UI shows the red “Invalid buy/sell” state and blocks place. ## Expected Deviation chips should produce **valid maker prices** for the active side: - **Buy**: below reference (e.g. `0%−` / slightly under, `-1%`, `-5%`, `-10%` — or exclude at-market `0%` if equality remains invalid) - **Sell**: above reference (e.g. slightly over for near-`0%`, `+1%`, `+5%`, `+10%`) ## Root cause (likely) `LimitOrderPriceInputWithContext` calls `limitPriceFromRefDeviationPercent(ref, pct)` with **unsigned positive** presets from `LIMIT_PRICE_DEVIATION_CHIP_PRESETS = [0, 1, 5, 10]`, ignoring side. Direction guard (`isLimitPriceDirectionInvalid`, GitLab #154): - bid invalid when `limit >= ref` - ask invalid when `limit <= ref` (equality treated as invalid) So buy chips always land on/above ref; sell `0%` lands exactly on ref. Relevant code: - `frontend-dapp/src/components/trade/LimitOrderPriceField.tsx` (chip `onClick`) - `frontend-dapp/src/utils/limitOrderPriceReference.ts` (`LIMIT_PRICE_DEVIATION_CHIP_PRESETS`, `limitPriceFromRefDeviationPercent`, `isLimitPriceDirectionInvalid`) ## Suggested fix Make chip presets **side-aware** (signed deviation from ref), and decide whether a true at-market `0%` chip should be omitted or map to a tiny offset so equality stays invalid. ## Repro 1. Open Trade / Limit Orders with a pair that has a reference price. 2. Select **Buy** → click `0%`, `+1%`, `+5%`, `+10%` → each shows Invalid buy. 3. Flip to **Sell** → click `0%` → Invalid sell. ## Acceptance - Buy chips set prices strictly below ref and clear the invalid state. - Sell near-market / positive chips set prices strictly above ref. - Place guard / non-crossing checks still pass for chip-selected prices when the book allows.
PlasticDigits commented 2026-07-25 04:34:11 +00:00 (Migrated from gitlab.com)

mentioned in commit a010b1441f

mentioned in commit a010b1441f19a0b0e9b41b652ceb162a095ef2cb
PlasticDigits commented 2026-07-25 04:34:28 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1040

mentioned in merge request !1040
PlasticDigits commented 2026-07-25 04:54:26 +00:00 (Migrated from gitlab.com)

mentioned in commit 3151a42fca

mentioned in commit 3151a42fca48952b19a6f782078d147c5ad81f98
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-07-25 04:54:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#495
No description provided.