W7-C4: Size input has three gaps — no USD notional estimate, amount carries over on side switch, MAX does not recalculate on side switch #155

Closed
opened 2026-05-11 13:40:05 +00:00 by totdking · 9 comments
totdking commented 2026-05-11 13:40:05 +00:00 (Migrated from gitlab.com)
No description provided.
totdking commented 2026-05-11 13:46:44 +00:00 (Migrated from gitlab.com)

Issue Summary

The Amount field in the Place Limit panel has three related gaps affecting how traders size their orders:

  1. No USD notional estimate (https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/154)— entering an amount shows no USD value equivalent, so the trader cannot evaluate the notional size of their order in a familiar unit

    image.png{width=900 height=469}

  2. Amount carries over on Bid → Ask switch — when switching sides, the entered amount is preserved in the field even though the token and available balance have changed; the stale value may exceed the balance on the new side with no warning

    Before

    image.png{width=900 height=469}

    After

    image.png{width=900 height=481}

  3. MAX does not recalculate on side switch — clicking MAX on Bid fills the Bid token balance, but switching to Ask does not recalculate MAX for the Ask token; the field retains the Bid MAX value, which may be higher than the Ask balance

    MAX ON ASK

    image.png{width=900 height=482}

    MAX ON BID

    image.png{width=900 height=525}


Reproduction Steps

Finding 1 — No USD notional:

  1. Navigate to /trade, select EMBER / CORAL, connect wallet
  2. Enter any amount in the Amount field (e.g. 5)
  3. Observe — no USD value appears next to or below the field at any point

Finding 2 — Amount carries over on side switch:

  1. Select Bid (CORAL) and enter an amount (e.g. 5)
  2. Switch to Ask (EMBER)
  3. Observe — the Amount field still shows 5; the field is not cleared or recalculated for the new token

Finding 3 — MAX does not recalculate on side switch:

  1. Select Bid (CORAL) and click MAX — field fills with Bid token balance (e.g. 9.7828)
  2. Switch to Ask (EMBER)
  3. Observe — the Amount field still shows 9.7828 (Bid MAX); it does not recalculate to the Ask token balance (e.g. 9.9988)

Expected Behavior

  1. USD notional — a USD equivalent should appear next to or below the Amount field and update in real time as the trader types (based on the current token price)
  2. Side switch resets amount — switching Bid <-> Ask should clear the Amount field (or recalculate it proportionally) since the token and balance context has changed
  3. MAX recalculates on side switch — if MAX was applied on one side, switching sides should either clear the field or re-apply MAX for the new token's balance

Actual Behavior

  1. No USD notional is shown at any point — the field shows token units only
  2. Switching from Bid to Ask (or Ask to Bid) leaves the entered amount unchanged in the field
  3. Clicking MAX on Bid then switching to Ask leaves the Bid MAX value in the field; the Ask balance is not applied

Environment Details

Field Value
OS macOS (Apple M1 Pro, 14-inch)
Browser Google Chrome (desktop)
Viewport ~1440px desktop
Network localterra (local Docker)
Frontend VITE_NETWORK=local npm run dev at localhost:3000
Indexer Running (make indexer-dev)
Contracts Deployed via make deploy-local

Wallet / Device Details

  • Wallet: Keplr browser extension
  • Wallet state: Connected — terra1...sl7cvv
  • Pair tested: EMBER / CORAL (terra146...c9mjav)

Severity / Impact

Medium. Findings 2 and 3 have the highest priority: a trader who clicks MAX on Bid, switches to Ask, and submits without noticing the stale value may attempt to place an order larger than their Ask balance — burning gas on a guaranteed-to-fail transaction . Finding 1 (https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/154 no USD notional) means the trader cannot sanity-check their order size in a familiar unit before signing. Found under W7-C4 (Size input — Display and Updates dimensions).

cc: @PlasticDigits

### Issue Summary The Amount field in the Place Limit panel has three related gaps affecting how traders size their orders: 1. **No USD notional estimate** (https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/154)— entering an amount shows no USD value equivalent, so the trader cannot evaluate the notional size of their order in a familiar unit ![image.png](/uploads/05b656f111143895947a78cd7d24e261/image.png){width=900 height=469} 2. **Amount carries over on Bid → Ask switch** — when switching sides, the entered amount is preserved in the field even though the token and available balance have changed; the stale value may exceed the balance on the new side with no warning **Before** ![image.png](/uploads/07ae171715b17378bfc6590c246ce689/image.png){width=900 height=469} **After** ![image.png](/uploads/cc72e00bfbb352b2ba481dca0764afb8/image.png){width=900 height=481} 3. **MAX does not recalculate on side switch** — clicking MAX on Bid fills the Bid token balance, but switching to Ask does not recalculate MAX for the Ask token; the field retains the Bid MAX value, which may be higher than the Ask balance **MAX ON ASK** ![image.png](/uploads/4f3c502754cf3aa1c534779d5dd6d233/image.png){width=900 height=482} **MAX ON BID** ![image.png](/uploads/e99f58b618d8251427301387cabbec94/image.png){width=900 height=525} --- ### Reproduction Steps **Finding 1 — No USD notional:** 1. Navigate to `/trade`, select EMBER / CORAL, connect wallet 2. Enter any amount in the Amount field (e.g. `5`) 3. Observe — no USD value appears next to or below the field at any point **Finding 2 — Amount carries over on side switch:** 1. Select **Bid (CORAL)** and enter an amount (e.g. `5`) 2. Switch to **Ask (EMBER)** 3. Observe — the Amount field still shows `5`; the field is not cleared or recalculated for the new token **Finding 3 — MAX does not recalculate on side switch:** 1. Select **Bid (CORAL)** and click **MAX** — field fills with Bid token balance (e.g. `9.7828`) 2. Switch to **Ask (EMBER)** 3. Observe — the Amount field still shows `9.7828` (Bid MAX); it does not recalculate to the Ask token balance (e.g. `9.9988`) --- ### Expected Behavior 1. **USD notional** — a USD equivalent should appear next to or below the Amount field and update in real time as the trader types (based on the current token price) 2. **Side switch resets amount** — switching Bid \<-\> Ask should clear the Amount field (or recalculate it proportionally) since the token and balance context has changed 3. **MAX recalculates on side switch** — if MAX was applied on one side, switching sides should either clear the field or re-apply MAX for the new token's balance --- ### Actual Behavior 1. No USD notional is shown at any point — the field shows token units only 2. Switching from Bid to Ask (or Ask to Bid) leaves the entered amount unchanged in the field 3. Clicking MAX on Bid then switching to Ask leaves the Bid MAX value in the field; the Ask balance is not applied --- ### Environment Details | Field | Value | |-------|-------| | OS | macOS (Apple M1 Pro, 14-inch) | | Browser | Google Chrome (desktop) | | Viewport | \~1440px desktop | | Network | `localterra` (local Docker) | | Frontend | `VITE_NETWORK=local npm run dev` at `localhost:3000` | | Indexer | Running (`make indexer-dev`) | | Contracts | Deployed via `make deploy-local` | --- ### Wallet / Device Details - **Wallet:** Keplr browser extension - **Wallet state:** Connected — `terra1...sl7cvv` - **Pair tested:** EMBER / CORAL (`terra146...c9mjav`) --- ### Severity / Impact **Medium.** Findings 2 and 3 have the highest priority: a trader who clicks MAX on Bid, switches to Ask, and submits without noticing the stale value may attempt to place an order larger than their Ask balance — burning gas on a guaranteed-to-fail transaction . Finding 1 (https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/154 no USD notional) means the trader cannot sanity-check their order size in a familiar unit before signing. Found under **W7-C4** (Size input — Display and Updates dimensions). cc: @PlasticDigits
totdking commented 2026-05-11 17:31:47 +00:00 (Migrated from gitlab.com)

mentioned in issue #116

mentioned in issue #116
PlasticDigits commented 2026-05-13 06:54:30 +00:00 (Migrated from gitlab.com)

mentioned in commit 8623c9fef4

mentioned in commit 8623c9fef42c385d9bc765a3fc9371da3523d64d
PlasticDigits commented 2026-05-13 06:54:47 +00:00 (Migrated from gitlab.com)

Update (merged to main)

Implemented all three W7-C4 sizing gaps from this issue on /trade and /limits (see commit on main).

What changed

  1. USD notional (headline anchor) — When the limit Amount field is non-empty, the UI shows Headline USD (escrow): ≈ $… using escrowAmountUsdAnchorNotional in limitOrderPriceReference.ts (same tape headline + refToken1PerToken0 as the limit price “Headline-scaled USD” line). Shows — when headline/ref are unavailable (e.g. pool-only ref without tape), matching the price field’s coverage.
  2. Amount on Bid ↔ Ask — Manually typed amounts are cleared on side change so the numeric string never carries over to a different escrow token.
  3. MAX after side switch — useLimitOrderForm tracks LimitEscrowAmountSource (manual vs max). After Max, switching sides clears until the new CW20 balance loads, then re-fills full balance for the new escrow token.
  • docs/frontend.md — new anchor § Limit place — escrow amount (#limit-place-escrow-amount)
  • docs/limit-orders.md — dApp bullet for #155
  • skills/AGENTS_FRONTEND_LIMIT_ORDER_PRICE.md + skills/AGENTS_FRONTEND_LIMIT_ORDER_SIDE_SELECTOR.md

Checklist for verification

  • /trade → Limit → enter amount with indexer tape + headline price present → USD line appears and moves as you type.
  • Same with headline missing / invalid → line shows — (no crash).
  • Type an amount on Bid, switch to Ask → field clears.
  • Bid → Max → switch to Ask → amount becomes Ask token full balance (after balance query settles), not the old Bid max string.
  • /limits place form behaves the same (side selector + amount + Max).
  • Order-book Edit prefill still loads amount as manual (not stuck in max mode).

@totdking — could you confirm on your EMBER/CORAL local setup (or any pair with tape)? Leaving the issue open until you sign off.

## Update (merged to `main`) Implemented all three **W7-C4** sizing gaps from this issue on **`/trade`** and **`/limits`** (see commit on `main`). ### What changed 1. **USD notional (headline anchor)** — When the limit **Amount** field is non-empty, the UI shows **Headline USD (escrow): ≈ $…** using `escrowAmountUsdAnchorNotional` in `limitOrderPriceReference.ts` (same tape headline + `refToken1PerToken0` as the limit price “Headline-scaled USD” line). Shows **—** when headline/ref are unavailable (e.g. pool-only ref without tape), matching the price field’s coverage. 2. **Amount on Bid ↔ Ask** — Manually typed amounts are **cleared** on side change so the numeric string never carries over to a different escrow token. 3. **MAX after side switch** — `useLimitOrderForm` tracks `LimitEscrowAmountSource` (`manual` vs `max`). After **Max**, switching sides clears until the new CW20 balance loads, then **re-fills** full balance for the new escrow token. ### Docs / agent cross-links - `docs/frontend.md` — new anchor **§ Limit place — escrow amount** (`#limit-place-escrow-amount`) - `docs/limit-orders.md` — dApp bullet for #155 - `skills/AGENTS_FRONTEND_LIMIT_ORDER_PRICE.md` + `skills/AGENTS_FRONTEND_LIMIT_ORDER_SIDE_SELECTOR.md` ### Checklist for verification - [ ] `/trade` → Limit → enter amount with indexer tape + headline `price` present → USD line appears and moves as you type. - [ ] Same with headline missing / invalid → line shows **—** (no crash). - [ ] Type an amount on **Bid**, switch to **Ask** → field clears. - [ ] **Bid** → **Max** → switch to **Ask** → amount becomes Ask token full balance (after balance query settles), not the old Bid max string. - [ ] `/limits` place form behaves the same (side selector + amount + Max). - [ ] Order-book **Edit** prefill still loads amount as **manual** (not stuck in max mode). @totdking — could you confirm on your **EMBER/CORAL** local setup (or any pair with tape)? Leaving the issue **open** until you sign off.
PlasticDigits commented 2026-05-27 05:12:48 +00:00 (Migrated from gitlab.com)

Verification complete (agent)

Verified all W7-C4 checklist items on local infra (LocalTerra, host Postgres :5432, indexer :3001, frontend :3000, EMBER/CORAL pair, simulated dev wallet).

Checklist results

  • /trade → Limit — entering amount 5 on Bid (CORAL) shows Headline USD (escrow): ≈ $5.000; updates as typed.
  • Headline unavailable — unit tests confirm escrowAmountUsdAnchorNotional returns null; UI renders — (no crash). Limits page shows — for price USD anchor before pair/tape loads.
  • Manual amount + side switch — Bid amount 5 → switch Ask → field clears (EMBER context).
  • MAX + side switch — Bid → Max (CORAL full balance) → switch Ask → field clears then re-fills EMBER full balance after balance query (~10000795985.8668), not stale CORAL max.
  • /limits — same USD line, side-switch clear, and side selector behavior on EMBER/CORAL.
  • Order-book Edit — Edit order #8 prefill loads price 1.047838… and amount 135.27791 as manual draft (not max mode).

Tests

  • limitOrderPriceReference.test.ts — 16/16 passed (includes escrowAmountUsdAnchorNotional).

No regressions found; fix already on main. Closing as verified.

## Verification complete (agent) Verified all **W7-C4** checklist items on local infra (LocalTerra, host Postgres :5432, indexer :3001, frontend :3000, EMBER/CORAL pair, simulated dev wallet). ### Checklist results - [x] **`/trade` → Limit** — entering amount `5` on Bid (CORAL) shows **Headline USD (escrow): ≈ $5.000**; updates as typed. - [x] **Headline unavailable** — unit tests confirm `escrowAmountUsdAnchorNotional` returns null; UI renders **—** (no crash). Limits page shows **—** for price USD anchor before pair/tape loads. - [x] **Manual amount + side switch** — Bid amount `5` → switch Ask → field clears (EMBER context). - [x] **MAX + side switch** — Bid → Max (CORAL full balance) → switch Ask → field clears then re-fills **EMBER** full balance after balance query (~10000795985.8668), not stale CORAL max. - [x] **`/limits`** — same USD line, side-switch clear, and side selector behavior on EMBER/CORAL. - [x] **Order-book Edit** — Edit order #8 prefill loads price `1.047838…` and amount `135.27791` as manual draft (not max mode). ### Tests - `limitOrderPriceReference.test.ts` — 16/16 passed (includes `escrowAmountUsdAnchorNotional`). No regressions found; fix already on `main`. Closing as verified.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-27 05:12:50 +00:00
PlasticDigits commented 2026-08-15 12:19:49 +00:00 (Migrated from gitlab.com)

mentioned in issue #524

mentioned in issue #524
PlasticDigits commented 2026-08-15 12:19:52 +00:00 (Migrated from gitlab.com)

marked as related to #524

marked as related to #524
PlasticDigits commented 2026-08-18 12:09:34 +00:00 (Migrated from gitlab.com)

mentioned in issue #563

mentioned in issue #563
PlasticDigits commented 2026-08-28 05:28:47 +00:00 (Migrated from gitlab.com)

mentioned in issue #693

mentioned in issue #693
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#155
No description provided.