Hybrid router: order-book leg should be always-on in the frontend (currently opt-in) #596

Closed
opened 2026-08-22 12:13:30 +00:00 by leonardocolucci · 45 comments
leonardocolucci commented 2026-08-22 12:13:30 +00:00 (Migrated from gitlab.com)

Summary

The swap UI only includes the limit-book leg when the user opts in (useHybridBook toggle + a hand-typed bookInputHuman); the default path is pool-only. So a taker swapping from the default UI routes through the AMM even when a resting order on the same pair would give a better price. The taker pays more, the maker never gets the fill, and there is no incentive to post tight book liquidity.

Follow-on to #501 (which covered computing the price-optimal split). This one is about the frontend default.

Expected

Default swap path = hybrid with the book leg always considered: the router takes whatever resting orders beat the pool's marginal price and fills the remainder from the pool. Pool-only becomes an explicit opt-out (anyone wanting v2-LP-only can run their own frontend).

Actual

useHybridBook defaults off; book_input is 0 on the large majority of venue trades even when the book is strictly better.

Notes

  • The indexer's per-trade pool_leg_volume / book_leg_volume gives a clean metric to confirm the fix: share of taker volume routed through the book.
  • Happy to provide tx examples if useful.
## Summary The swap UI only includes the limit-book leg when the user opts in (`useHybridBook` toggle + a hand-typed `bookInputHuman`); the default path is pool-only. So a taker swapping from the default UI routes through the AMM even when a resting order on the same pair would give a better price. The taker pays more, the maker never gets the fill, and there is no incentive to post tight book liquidity. Follow-on to #501 (which covered computing the price-optimal split). This one is about the frontend default. ## Expected Default swap path = hybrid with the book leg always considered: the router takes whatever resting orders beat the pool's marginal price and fills the remainder from the pool. Pool-only becomes an explicit opt-out (anyone wanting v2-LP-only can run their own frontend). ## Actual `useHybridBook` defaults off; `book_input` is 0 on the large majority of venue trades even when the book is strictly better. ## Notes - The indexer's per-trade `pool_leg_volume` / `book_leg_volume` gives a clean metric to confirm the fix: share of taker volume routed through the book. - Happy to provide tx examples if useful.
PlasticDigits commented 2026-08-22 12:16:05 +00:00 (Migrated from gitlab.com)

Direction approved. Users should not be able to opt out (or be required to opt in ) to receive best pricing. DEX frontend must always provide users with best pricing.

Direction approved. Users should not be able to opt out (or be required to opt in ) to receive best pricing. DEX frontend must always provide users with best pricing.
leonardocolucci commented 2026-08-22 12:36:58 +00:00 (Migrated from gitlab.com)

Thank you!

...

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: gitlab@mg.gitlab.com gitlab@mg.gitlab.com on behalf of Plastic Digits (@PlasticDigits) gitlab@mg.gitlab.com
Sent: Saturday, 22 August 2026 13:16:06
To: leonardo_colucci@hotmail.com leonardo_colucci@hotmail.com
Subject: Re: cl8y-dex-terraclassic | Hybrid router: order-book leg should be always-on in the frontend (currently opt-in) (#596)

Plastic Digitshttps://gitlab.com/PlasticDigits commentedhttps://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/596#note_3719688869:

Direction approved. Users should not be able to opt out (or be required to opt in ) to receive best pricing. DEX frontend must always provide users with best pricing.

—
Reply to this email directly or view it on GitLabhttps://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/596#note_3719688869.
You're receiving this email because of your account on gitlab.comhttps://gitlab.com/. Unsubscribehttps://gitlab.com/-/sent_notifications/REDACTED/unsubscribe from this thread · Manage all notificationshttps://gitlab.com/-/profile/notifications · Helphttps://gitlab.com/help Notification message regarding https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/596#note_3719688869 at 1787400966

Thank you! <details><summary>...</summary> Sent from Outlook for Android<https://aka.ms/AAb9ysg> ________________________________ From: gitlab@mg.gitlab.com <gitlab@mg.gitlab.com> on behalf of Plastic Digits (@PlasticDigits) <gitlab@mg.gitlab.com> Sent: Saturday, 22 August 2026 13:16:06 To: leonardo_colucci@hotmail.com <leonardo_colucci@hotmail.com> Subject: Re: cl8y-dex-terraclassic | Hybrid router: order-book leg should be always-on in the frontend (currently opt-in) (#596) Plastic Digits<https://gitlab.com/PlasticDigits> commented<https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/596#note_3719688869>: Direction approved. Users should not be able to opt out (or be required to opt in ) to receive best pricing. DEX frontend must always provide users with best pricing. — Reply to this email directly or view it on GitLab<https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/596#note_3719688869>. You're receiving this email because of your account on gitlab.com<https://gitlab.com/>. Unsubscribe<https://gitlab.com/-/sent_notifications/REDACTED/unsubscribe> from this thread · Manage all notifications<https://gitlab.com/-/profile/notifications> · Help<https://gitlab.com/help> Notification message regarding https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/596#note_3719688869 at 1787400966 </details>
PlasticDigits commented 2026-08-22 13:43:11 +00:00 (Migrated from gitlab.com)

mentioned in commit 685798eadd

mentioned in commit 685798eadd524be197b91ed43bc325c1a3afba1a
PlasticDigits commented 2026-08-22 13:43:37 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1116

mentioned in merge request !1116
PlasticDigits commented 2026-08-22 13:51:05 +00:00 (Migrated from gitlab.com)

mentioned in commit fff91af0fc

mentioned in commit fff91af0fc1caa2f47ac0cd3322099d4a48b195e
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-08-22 13:51:05 +00:00
PlasticDigits commented 2026-08-22 13:51:30 +00:00 (Migrated from gitlab.com)

!1116 merge notes (no automerge, CI not waited)

Merged !1116 into main (issue-596-hybrid-always-on @ 685798ea). Local merge into main was clean (0 conflicts, 0 diverged commits).

Acceptance vs #596 / H596-1–H596-8

Local make verify-issue-596: 11 PASS / 0 FAIL (Vitest 61 tests + grep/docs guards). Product AC is met: retail Swap/Trade no longer expose a hybrid opt-out; default CW20 quotes use GET /route/solve; Advanced typed book remains a POST split override; empty book still goes through the solver; integrator pool_only=true is unchanged.

Problems / leftovers (not merge blockers)

  1. GitLab CI pipeline 632 failed with ci_quota_exceeded (gitleaks, test-frontend, test-frontend-build). Jobs never ran. This is quota, not a code defect. Local verify is the gate.
  2. MR test plan still had unchecked rungs (manual Swap/Trade Advanced UI, optional VERIFY_ISSUE_596_CHAIN=1 Playwright, observational book_leg_volume vs pool_leg_volume after deploy). Unit/docs cover the UI-control removal; chain + production metrics do not.
  3. Indexer/LCD degradation still quotes pool-only (H596-5). Users cannot opt out, but an outage can still produce pool-only receive/submit.
  4. Hygiene (follow-up, not AC): TradeMarketOrderPanel.tsx header JSDoc still mentions “Hybrid off → pool-only”. Swap network-fee estimate sets cw20Hybrid only when the user typed a manual book leg, not when GET alone allocates interior book_input.

Post-merge deploy + metrics + those hygiene items will be tracked in a new issue (this one should close with !1116).

## !1116 merge notes (no automerge, CI not waited) Merged !1116 into `main` (`issue-596-hybrid-always-on` @ `685798ea`). Local merge into `main` was clean (0 conflicts, 0 diverged commits). ### Acceptance vs #596 / H596-1–H596-8 Local `make verify-issue-596`: **11 PASS / 0 FAIL** (Vitest 61 tests + grep/docs guards). Product AC is met: retail Swap/Trade no longer expose a hybrid opt-out; default CW20 quotes use `GET /route/solve`; Advanced typed book remains a POST split override; empty book still goes through the solver; integrator `pool_only=true` is unchanged. ### Problems / leftovers (not merge blockers) 1. **GitLab CI pipeline 632 failed with `ci_quota_exceeded`** (`gitleaks`, `test-frontend`, `test-frontend-build`). Jobs never ran. This is quota, not a code defect. Local verify is the gate. 2. **MR test plan still had unchecked rungs** (manual Swap/Trade Advanced UI, optional `VERIFY_ISSUE_596_CHAIN=1` Playwright, observational `book_leg_volume` vs `pool_leg_volume` after deploy). Unit/docs cover the UI-control removal; chain + production metrics do not. 3. **Indexer/LCD degradation** still quotes pool-only (`H596-5`). Users cannot opt out, but an outage can still produce pool-only receive/submit. 4. **Hygiene (follow-up, not AC):** `TradeMarketOrderPanel.tsx` header JSDoc still mentions “Hybrid off → pool-only”. Swap network-fee estimate sets `cw20Hybrid` only when the user typed a manual book leg, not when GET alone allocates interior `book_input`. Post-merge deploy + metrics + those hygiene items will be tracked in a new issue (this one should close with !1116).
PlasticDigits commented 2026-08-22 13:52:58 +00:00 (Migrated from gitlab.com)

mentioned in issue #598

mentioned in issue #598
PlasticDigits commented 2026-08-22 13:52:58 +00:00 (Migrated from gitlab.com)

marked as related to #598

marked as related to #598
PlasticDigits commented 2026-08-22 13:53:04 +00:00 (Migrated from gitlab.com)

Post-merge follow-up filed as #598 (Coolify frontend bake, optional LocalTerra Playwright, book_leg_volume vs pool_leg_volume observation, JSDoc/Swap-gas hygiene). #596 product AC is closed via !1116.

Post-merge follow-up filed as #598 (Coolify frontend bake, optional LocalTerra Playwright, `book_leg_volume` vs `pool_leg_volume` observation, JSDoc/Swap-gas hygiene). #596 product AC is closed via !1116.
PlasticDigits commented 2026-08-23 03:05:42 +00:00 (Migrated from gitlab.com)

mentioned in issue #599

mentioned in issue #599
PlasticDigits commented 2026-08-23 03:05:44 +00:00 (Migrated from gitlab.com)

marked as related to #599

marked as related to #599
PlasticDigits commented 2026-08-23 11:49:49 +00:00 (Migrated from gitlab.com)

mentioned in issue #607

mentioned in issue #607
PlasticDigits commented 2026-08-23 11:49:50 +00:00 (Migrated from gitlab.com)

marked as related to #607

marked as related to #607
PlasticDigits commented 2026-08-23 12:55:20 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1126

mentioned in merge request !1126
PlasticDigits commented 2026-08-24 00:29:00 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1127

mentioned in merge request !1127
PlasticDigits commented 2026-08-24 00:35:17 +00:00 (Migrated from gitlab.com)

mentioned in issue #615

mentioned in issue #615
PlasticDigits commented 2026-08-24 00:35:18 +00:00 (Migrated from gitlab.com)

marked as related to #615

marked as related to #615
PlasticDigits commented 2026-08-24 00:54:07 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1131

mentioned in merge request !1131
PlasticDigits commented 2026-08-24 03:01:16 +00:00 (Migrated from gitlab.com)

mentioned in issue #616

mentioned in issue #616
PlasticDigits commented 2026-08-24 03:15:38 +00:00 (Migrated from gitlab.com)

mentioned in issue #618

mentioned in issue #618
PlasticDigits commented 2026-08-24 05:54:09 +00:00 (Migrated from gitlab.com)

mentioned in issue #621

mentioned in issue #621
PlasticDigits commented 2026-08-24 05:54:15 +00:00 (Migrated from gitlab.com)

mentioned in issue #622

mentioned in issue #622
PlasticDigits commented 2026-08-24 05:54:18 +00:00 (Migrated from gitlab.com)

marked as related to #622

marked as related to #622
PlasticDigits commented 2026-08-24 07:02:37 +00:00 (Migrated from gitlab.com)

mentioned in issue #625

mentioned in issue #625
PlasticDigits commented 2026-08-24 11:49:44 +00:00 (Migrated from gitlab.com)

mentioned in issue #626

mentioned in issue #626
PlasticDigits commented 2026-08-24 13:33:33 +00:00 (Migrated from gitlab.com)

mentioned in issue #628

mentioned in issue #628
PlasticDigits commented 2026-08-25 02:04:15 +00:00 (Migrated from gitlab.com)

mentioned in issue #633

mentioned in issue #633
PlasticDigits commented 2026-08-25 02:08:33 +00:00 (Migrated from gitlab.com)

mentioned in issue #634

mentioned in issue #634
PlasticDigits commented 2026-08-25 02:29:31 +00:00 (Migrated from gitlab.com)

mentioned in issue #635

mentioned in issue #635
PlasticDigits commented 2026-08-25 03:06:23 +00:00 (Migrated from gitlab.com)

mentioned in issue #636

mentioned in issue #636
PlasticDigits commented 2026-08-27 00:20:45 +00:00 (Migrated from gitlab.com)

mentioned in issue #679

mentioned in issue #679
PlasticDigits commented 2026-08-27 00:20:46 +00:00 (Migrated from gitlab.com)

marked as related to #679

marked as related to #679
PlasticDigits commented 2026-08-27 00:20:55 +00:00 (Migrated from gitlab.com)

mentioned in issue #681

mentioned in issue #681
PlasticDigits commented 2026-08-27 00:20:56 +00:00 (Migrated from gitlab.com)

marked as related to #681

marked as related to #681
PlasticDigits commented 2026-08-27 00:37:16 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1182

mentioned in merge request !1182
PlasticDigits commented 2026-08-27 05:29:52 +00:00 (Migrated from gitlab.com)

mentioned in issue #686

mentioned in issue #686
PlasticDigits commented 2026-08-27 11:52:20 +00:00 (Migrated from gitlab.com)

mentioned in issue #690

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

mentioned in issue #693

mentioned in issue #693
leonardocolucci commented 2026-08-29 13:25:16 +00:00 (Migrated from gitlab.com)

mentioned in issue #704

mentioned in issue #704
PlasticDigits commented 2026-08-30 05:24:14 +00:00 (Migrated from gitlab.com)

mentioned in issue #707

mentioned in issue #707
PlasticDigits commented 2026-08-30 05:24:17 +00:00 (Migrated from gitlab.com)

mentioned in issue #708

mentioned in issue #708
PlasticDigits commented 2026-08-31 04:17:48 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1198

mentioned in merge request !1198
PlasticDigits commented 2026-08-31 04:56:53 +00:00 (Migrated from gitlab.com)

mentioned in issue #711

mentioned in issue #711
PlasticDigits commented 2026-08-31 05:36:05 +00:00 (Migrated from gitlab.com)

mentioned in issue #713

mentioned in issue #713
PlasticDigits commented 2026-09-01 08:15:55 +00:00 (Migrated from gitlab.com)

mentioned in issue #718

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