design: research “draw a chart” inventory path bot (secret polyline, zig-zag / offload, risk limits) #717
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#717
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
Investigate a “draw a chart” inventory bot: an operator draws a secret price path over a chosen time window (mouse / pointer on a chart), and a bot trades the operator’s own inventory toward that path — including retracement zig-zags, offload / cash-raise legs, and a later second rally — under hard risk limits (max volume per period, stop-loss, inventory floors).
This issue is a product + architecture + threat-model spike. Do not ship a new CosmWasm message, vault, retail Draw tab, indexer schema, or hosted signer in this work item. The deliverable is a written recommendation: go / no-go / integrator-only, with architecture (off-chain keeper vs compile-to-existing ladder vs new vault), gas, secrecy model, and market-integrity constraints.
Related, not duplicates:
[P_low, P_high]). This ticket is a time-indexed price path, not a static band.OrderStatusfor bot custody (L21).packages/localnet-trading-swarm,scripts/bots/) is LocalTerra load only, not a production MM.Confidential third-party bot review (#650) stays out of this write-up. Do not copy findings from that issue into this one.
Current codebase
There is no draw-to-trade surface. Charts are read-only candles. Limits are one-shot. Bots in-repo are LocalTerra swarm, not path followers.
/trade,/charts)aria-hidden; AT uses region +aria-live. Playbook:skills/AGENTS_FRONTEND_PRICE_CHART.md.Cw20HookMsg::PlaceLimitOrderBatch/PlaceLimitOrderLadder. Ladder expandsequalonly. One side per tx. Hard cap 100 rungs. Crossing allowed on-chain; dApp is post-only UX (#297 / #385).execute_swapwalks the book undermax_maker_fills(100) andMAX_SCAN_STEPS(500) — L5. Maker payouts go to the order owner wallet. No opposite-side re-place, no timed schedule, no path object./tradeMarket (always-on hybrid quote) + Limit +/limitsLadder. No inventory planner, no stop-loss bot, no max-volume/period governor.limit-book/insert-hints,limit-fills. Placementlifecycle_status=activeis not proof the row is still inORDERS(#530). Bots must use LCDOrderStatus.network === "localterra"). Profiles are not path-following.Product confusion to avoid: this is not v2 AMM LP (
provide_liquidity), not/ust1mint, and not the V3 range grid. Support already tells users book escrow ≠ pool LP (#531). Do not call a drawn path “LP” in retail copy.On-chain truth vs secret chart: every fill, swap, and resting limit is public (wasm events, indexer tape, LCD). A “secret” drawing does not hide the resulting trades. Copy-traders and adversaries can reconstruct an approximate path from the tape.
Why this is needed
Community product ask (paraphrased, no chat transcript, identities omitted): token owners and average traders want a visual way to say “move my inventory along this curve for the next N hours/days,” including planned dips (retracements) and sell-to-cash windows so a later rally has quote inventory — with risk caps. A range grid (#546) does not express time or phase (rally vs dip vs offload).
/limitsand the Market ticket by hand. That is the actual inventory loop.Constraints / guardrails
ExecuteMsg, no vault, no/drawroute, no indexer table for paths, no production keeper keys in this issue. Follow-up implementation issues only after the write-up is accepted (including a market-integrity section signed off in the issue comments).Secret chart = operator strategy confidentiality (not uploaded to the indexer / not shown to other wallets), not concealment of illegal activity. Trades remain public.
execute_swap. Same default as #546: forbidden unless proven within L5 gas (it will not be).OrderStatusis the custody oracle. Greedy/hybrid unchanged.authzonly if columbus-5 actually supports the needed grant (verify; do not assume), or a future vault (#617-style) that the user deposits into.max_spread, max open rungs, halt on pause / blacklist /code_id_frozen. A path that would exceed caps must not arm.PriceChartLightweightCanvas./poolor a default/trademode. Do not add always-on essays.SKIP (no LocalTerra)without provisioning (make setup-cloud-localterra).Relevant files
frontend-dapp/src/components/charts/PriceChart.tsxfrontend-dapp/src/components/charts/PriceChartLightweightCanvas.tsxfrontend-dapp/src/pages/TradePage.tsx/tradeworkspacefrontend-dapp/src/components/trade/LimitOrderLadderPanel.tsxfrontend-dapp/src/utils/limitOrderLadder.tssmartcontracts/packages/dex-common/src/limit_placement.rssmartcontracts/contracts/pair/src/limit_placement.rssmartcontracts/contracts/pair/src/orderbook.rsOrderStatusdocs/limit-orders.mddocs/integrators.mdindexer/src/indexer/parser.rspackages/localnet-trading-swarm/skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.mdskills/AGENTS_ORDER_STATUS_QUERY.mdskills/AGENTS_FRONTEND_PRICE_CHART.mddocs/security-model.mdRecommended direction
Evaluate four architectures against the same user story: pair + time horizon + polyline of
(t, price)+ optional phase tags (rally / retrace / offload / hold) + inventory + risk envelope. Recommend one, or none (document as integrator-only / NO-GO).A — Path compiler → existing batch/ladder (default candidate)
max_batch_rungsmonotonic-in-time waypoints (Douglas–Peucker or bucket-by-interval).B — Off-chain keeper with schedule
Same as A, plus a local process that re-arms on fills (
OrderStatus+ indexerlimit-fills), respects time (ton the polyline), and halts on stop-loss / pause / blacklist. Chain guard like the swarm: refuse non-localterrauntil a later explicit mainnet flag. No keys inindexer/.C — New vault (only if A/B fail the non-custodial “set and forget” bar)
Reuse lessons from #546 option E / #617 (vault owns orders, permissionless crank cannot withdraw). Do not start here. Path-following inside a vault is a new strategy object, not a grid spread.
D — NO-GO / integrator-only
If honest inventory value cannot be separated from tape-painting, or gas/inventory/tax make it unusable, publish a short integrator note (“compile your polyline to
PlaceLimitOrderBatch+ your own keeper”) and do not add official Draw UX.Default assumption: A + optional B on LocalTerra; C blocked on #546/#617 decisions; official retail Draw UX not in v0.
Zig-zag / offload (must be in the model, not a later surprise):
Risk envelope (minimum fields for any GO spec):
max_volume_base/max_volume_quoteper rolling window (and per calendar day)stop_loss(mark vs path or vs entry VWAP — spike must pick one and test both)max_taker_bps/max_spreadmax_open_rungs≤ pairmax_batch_rungsmin_inventory_base/min_inventory_quotefloorscode_id_frozen, indexer/LCD outageAcceptance criteria
docs/draft only if product wants it public) covering: current gaps, grid-vs-path, A/B/C/D recommendation, gas ballpark (LocalTerra batch place vs N takes), secrecy model, tax/pause/blacklist.Test plan (all paths) — for the spike and for any later prototype
These tests are required in the write-up as a plan; implement them only on a follow-up IID (except paper/unit sketches of the compiler).
Path compiler (pure)
max_volume_*does not arm.Maker / ladder mapping
max_batch_rungs/ hard cap 100.resolved:false→ no fabricated id (L14).Time / keeper (LocalTerra only if prototyped)
OrderStatusUnknownis not treated as “definitely filled” (#505 / #530).code_id_frozen/ F6: halt (#585).UI (only if a later Draw overlay exists)
PriceCharton every pointer move; interval switch still onecreateChart(#148).aria-hidden; path summary in text (waypoint count, horizon, caps)./trademode.Docs / product
Test plan — attack, hack, and abuse vectors
Treat these as must-fail-closed. A GO design that cannot mitigate a row is NO-GO for official UX (integrator-only at most).
max_spread/min_return; prefer maker.execute_swapMsgExecuteContracton pair allowsCancel+ drainBlacklistGuardUnavailablefail-open (SEC-I03).route/solve.route/solveexclude (#585).Register; Tier 0 is governanceRegisterWalletonly (docs/security-model.md).No exploit PoCs in the public issue beyond the table. If a later implementation needs a confidential security child, file it confidential and do not paste exploits here.
Verification criteria
The spike is done when:
make has-localterra/make setup-cloud-localterra— no false “no chain in VM.”Owner type
product / architecture (spike). Later: frontend (compiler overlay), backend (optional keeper package), contracts only if C.
Priority
P2 (
priority::medium) — useful operator UX, not a launch blocker. Blocked on integrity sign-off before any implementation IID.marked as related to #546
marked as related to #617
marked as related to #618
marked as related to #206
marked as related to #505