Frontend: deep-book ladder placement (failure detection, ladder→batch per-rung hints, single-anchor, adaptive max_adjust_steps) #268
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#268
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Make the dApp place ladders reliably and cheaply into deep, actively-traded books. Bundled frontend work (all consuming the indexer insert-hint APIs from the companion indexer issue — never direct LCD/RPC):
hint_after_order_idfor deep-book placement.max_adjust_stepssized from observed local depth, with a safety floor so churn on actively-traded books does not cause reverts/skips.Current codebase
frontend-dapp/src/components/trade/LimitOrderLadderPanel.tsx— buildsLimitOrderLadderSpecWireand callsplaceLimitOrderLadderWithAllowance; success path pollsgetPairLimitPlacementsfor placed ids. No hints, no depth awareness.frontend-dapp/src/services/terraclassic/pair.ts—LimitOrderPlacementItemWire(~L127, hashint_after_order_id),LimitOrderLadderSpecWire(~L135, no hint),placeLimitOrderBatch(~L163),placeLimitOrderLadder(~L181),placeLimitOrderWithAllowance(~L227, single-rung resolves a hint).frontend-dapp/src/utils/limitBookInsertHint.ts—resolveLimitInsertHintAfter+flattenLimitBookPages; used today only byTradeOrderTicket.tsx(single order, ~L260) andLimitOrdersPage.tsx(~L107). Returnsnullon pagination gap.frontend-dapp/src/hooks/useLimitBookInfinite.ts,frontend-dapp/src/utils/limitBookPagination.ts— paginated book;frontend-dapp/src/services/indexer/client.ts::getPairLimitBookPage(~L235).frontend-dapp/src/hooks/useLimitLadderPlaceGates.ts,frontend-dapp/src/utils/limitOrderBatchGasSummary.ts,frontend-dapp/src/utils/limitOrderLadder.ts— ladder gates, gas summary, expansion preview.max_adjust_stepsviaLimitOrderAdvancedLimitSettings(default32).Why the current shape is insufficient
batch_skipped_countand partial fills with no warning.null) across gaps — unusable for deep ladders.max_adjust_stepsis simultaneously too low for deep/churny books (reverts/skips) and wasteful on thin ones.Why this is needed
Ladders are a headline feature for market makers, who operate on the deepest books. Today those are the books where ladders silently underperform. This issue gives the dApp depth-aware placement: warn when a ladder will skip, route deep ladders through the hinted batch path, and size the step budget so normal book churn does not revert transactions.
Constraints / guardrails
resolved:falseas "no hint" (omit field) and fall back to on-chain chaining/head walk — never fabricate an id.MAX_ADJUST_STEPS_HARD_CAPand keep gas within the dApp's batch limit model (terraGas.ts: base400_000+180_000×rungs). Never set steps so high that the gas estimate exceeds block/UX limits.sumLadderAmountsRawmust not string-concat (#233 regression).useQuerylogic (#231); reuse existing hooks.Relevant files
frontend-dapp/src/components/trade/LimitOrderLadderPanel.tsxfrontend-dapp/src/services/terraclassic/pair.tsfrontend-dapp/src/utils/limitBookInsertHint.tsfrontend-dapp/src/hooks/useLimitBookInfinite.ts,frontend-dapp/src/utils/limitBookPagination.tsfrontend-dapp/src/services/indexer/client.tsfrontend-dapp/src/hooks/useLimitLadderPlaceGates.tsfrontend-dapp/src/utils/limitOrderLadder.ts,frontend-dapp/src/utils/limitOrderBatchGasSummary.tsfrontend-dapp/src/components/trade/LimitOrderAdvancedLimitSettings.tsx,LimitOrderExpiryField.tsxskills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md,skills/AGENTS_FRONTEND_DEEP_ORDER_BOOK.md,skills/AGENTS_FRONTEND_LIMIT_ORDER_PLACEMENT_GAS.md,docs/integrators.mdRecommended direction
resolved:true→ per-runghint_after_order_id;resolved:false→ omit (let chaining/head walk handle it).limitOrderLadder.ts) and submit viaplaceLimitOrderBatchwith per-rung hints instead ofplaceLimitOrderLadder. KeepplaceLimitOrderLadderfor the cheap/thin-book path.LimitOrderLadderSpec.hint_after_order_id) and skip per-rung resolution — one indexer call.max_adjust_stepsper rung (or one conservative value) from the depth probe:clamp(observed_local_depth × safety_multiplier + churn_floor, FLOOR, HARD_CAP). Surface in advanced settings with the computed value as default.limitOrderBatchGasSummary.ts).Acceptance criteria
resolved:falserungs omit the hint field (never fabricate an id) and still attempt placement.max_adjust_stepsdefault visibly scales with probed depth, with a documented floor that prevents skip/revert under normal churn on a busy book.sumLadderAmountsRaw(#233) or escrow gates (#231).Test plan — all paths
resolved:false; those omit hints; placement still attempted; UI flags reduced confidence.terraGas.tsmodel for chosen rung count and steps.resolveLimitInsertHintAfterfixtures).Test plan — attack / abuse / hack vectors
resolved:falsefor everything: graceful degradation to no-hint ladder; no fabricated ids.max_batch_rungs): client clamps to pair cap before submit (existing gate) and bounds the prices list sent to the resolver.parseFloatprecision/concat bugs; reuse decimal utils).Verification criteria
cd frontend-dapp && npm test -- limitBookInsertHint limitOrderLadder limitOrderBatchGasSummary useLimitLadderPlaceGates LimitOrderLadderPanelgreen, incl. new depth/hint/adaptive-steps unit tests.skills/AGENTS_E2E_LIMIT_ORDERS_TX.md.npm run lint && npm run typecheckclean.AGENTS_LIMIT_ORDER_BATCH_LADDER.md,AGENTS_FRONTEND_DEEP_ORDER_BOOK.md).mentioned in issue #266
mentioned in issue #267
Depends on:
mentioned in commit
8c6832e349Implementation summary (pushed to
main@8c6832e)Deep-book ladder placement is now wired in the dApp ladder panel. All depth/hint data flows through the indexer only (
GET .../limit-book?price_from&price_to+GET .../limit-book/insert-hints) — no direct LCD/RPC added.What changed
useLimitLadderPlacementPlanprobes the ladder price band and scores foreign orders / head→boundary distance before submit; UI shows expected placed/skipped and path notes.thin_ladder(empty/thin book) ·single_anchor_ladder(boundaryhint_after_order_idonly, #266) ·deep_batch(per-rung hints viaplaceLimitOrderBatch).resolved:false/pagination_gap→ hint field omitted (never fabricated).max_adjust_steps— default scales from probed depth (floor 32, cap 256); manual override in advanced settings is preserved once touched.skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md, crosslinks inAGENTS_FRONTEND_DEEP_ORDER_BOOK.mdanddocs/integrators.md.Key files
frontend-dapp/src/hooks/useLimitLadderPlacementPlan.tsfrontend-dapp/src/utils/limitLadderPlacementPlan.ts,limitLadderDepth.ts,limitLadderAdaptiveSteps.tsfrontend-dapp/src/components/trade/LimitOrderLadderPanel.tsxfrontend-dapp/src/services/indexer/client.ts(getPairLimitBookInsertHints, price-window params)Verification checklist
place_limit_order_ladder; zero or one indexer call pair.insert-hints+ price-windowlimit-bookonly (no LCD from browser).pagination_gap(or budget exhausted) — hints omitted on wire, placement still attempted, UI flags reduced confidence.data-testid="ladder-placement-summary"shows path, expected rungs, gas estimate.sumLadderAmountsRaw).npm test -- limitBookInsertHint limitOrderLadder limitOrderBatchGasSummary limitLadderDepth limitLadderPlacementPlan useLimitLadderPlacementPlangreen.limit-orders-tx.spec.tsladder test still passes.Tests run locally
limitLadder*,limitOrderBatchGasSummary,useLimitLadderPlacementPlan,limitBookInsertHint,limitOrderLadderFollow-ups
resolveLimitInsertHintAfterto indexerinsert-hints(separate scope).Requesting verification from the QA agent team when LocalTerra + indexer are available.
mentioned in issue #270
mentioned in issue #246
mentioned in merge request !737
#268 deep-book ladder verified at the unit/source layer; aligned to the acceptance + verification criteria.
Acceptance criteria:
Verification criteria:
So the ladder feature is verified here; the only gate that wasn't clean was typecheck, and that was an unrelated #246-era build break now fixed in !737. Good to close from my side once !737 lands and the e2e-tx ladder run is signed off on a clean host. @PlasticDigits
mentioned in issue #546