docs: integrator guidance — pair.swap is pool-only; best execution via indexer/router #707
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#707
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
Publish clear integrator guidance that direct
pair.swapwithoutHybridSwapParamsis pool-only, and that best execution (limit book + multi-hop split) goes through the indexer route solver and/or router ops with caller-declared hybrid.Approved from #704 as the docs/awareness path that can ship now, independent of pair wasm. Product stance (same thread): pool-only direct swaps are intentional so simple bots can trade without off-chain routing; they effectively pay arbs. Operators who want the book must opt into hybrid (Pattern C) or the solver.
Contract follow-up (greedy book-first variant, no caller split): linked design issue from #704. Do not block this docs ticket on that migrate.
Current codebase
The behavior is already implemented and partially documented, but not as a bot-facing warning at the front of integrator docs.
On-chain (do not change in this ticket)
smartcontracts/contracts/pair/src/contract.rsexecute_swap:hybrid: None→book_leg = 0. TerraSwap-compatible wallets thatCw20 Send→Swap {}never touch the FIFO book.HybridSwapParamsis required for a book leg:pool_input+book_input= offer, plusmax_maker_fillsand optionalbook_start_hint.Router
TerraSwap.hybrid: nullis also pool-only on execute (router/src/contract.rs).Off-chain best execution (already exists)
GET /api/v1/route/solve?token_in=&token_out=&amount_in=GET .../route/solve/bestamount_inrequired (#189)POST /api/v1/route/solve+hybrid_by_hoppool_only=trueLCD book for a hint:
GET /api/v1/pairs/{addr}/order-book-head(integrators.md).Docs today (gaps)
docs/integrators.mdopens on hybrid hooks (L7) and book HTTP. It does not lead with “omittinghybridskips the book.”docs/limit-orders.mdPattern C section assumes the caller already passeshybrid.docs/architecture.mdswap sequence is pool-only (k, commission, hook) — no book, no solver.docs/adr/0001-hybrid-quoting-and-routing.md/skills/AGENTS_HYBRID_QUOTING.mdare accurate for in-repo agents, not a 1-page bot recipe.docs/README.mdintegrator bullet does not mention pool-only vs best execution.Observed: columbus-5 bot ~85 pair-direct swaps/day on CL8Y-cb/cLUNC crossed a better ask by ~1.7% because it never passed
HybridSwapParams(#704).Why this is needed
#596 fixed the official UI. Third-party wallets, vaults, and MM bots still copy TerraSwap
Swap {}and systematically miss resting liquidity. That:Docs will not make every bot hybrid, but they remove “we didn’t know the book existed” as an excuse and point at the indexer the same way this repo’s dApp does.
Constraints / guardrails
Invariants I704-1–I704-8.
hybrid: Nonesemantics, pair/router execute, or force a book walk. That remains expected (see #704 product comment).hybrid/pool_only=true. (2) Declared hybrid: Pattern Cpool_input+book_input(hard; need a quote). (3) Best execution:GET /api/v1/route/solvewithamount_in, then execute the returnedrouter_operations(or pair-direct single-hop with those hybrid params). Mention greedy in-contract variant only as future / linked design, not as live API until wasm ships.book_input.” Point at the solver or LCDHybridSimulationwith a known split.book_start_hint= first live same-side order (#272, #332).Simulation(removed). Pool-only quotes =HybridSimulation+book_input = 0. Book-inclusive quotes must use the sameHybridSwapParamsas execute.#489cognitive-load dump on the dApp. This is integrator docs (+ agent skills). Official UI already always-on hybrid.max_maker_fills≤ 100,MAX_SCAN_STEPS500, hybrid gas). Do not invent new numbers.make verify-issue-<iid>is doc/skill grep + optional markdown anchors, no LocalTerra, no pair migrate.Relevant files
Must update:
docs/integrators.md— new top section (before L7 hooks): “How to swap (pool-only vs best execution)”docs/README.md— integrator index linedocs/limit-orders.md— Pattern C intro: omittinghybrid= pool-onlydocs/architecture.md— swap flow note: book only ifhybridset; best execution is indexer/routerdocs/adr/0001-hybrid-quoting-and-routing.md— short “integrator default” bulletskills/AGENTS_HYBRID_QUOTING.md— same three-rung tabledocs/route-solver.mdand/ordocs/indexer-invariants.md— one sentence: this GET is the integrator best-execution API for pair-direct bots too (submit solverhybridon the pair)Should cross-link:
docs/contracts-security-audit.mdL8 ·skills/AGENTS_INDEXER_HYBRID_BEST_EXECUTION.md·skills/AGENTS_BOOK_MATCH_HINT_SECURITY.md·docs/integrators-hybrid-volume.md(measurement:pool_leg_volume/book_leg_volume)Do not: frontend strings, pair
error.rsmessages (optional one-line comment inexecute_swaponly if it stays a comment — prefer docs-only to skip wasm).Related: #704 · #501 · #596 · #209 · #190
Recommended direction
Lead
docs/integrators.mdwith a boxed decision table:Send→ pairSwapwithhybridomittedGET {INDEXER}/api/v1/route/solve?token_in&token_out&amount_in(+ optionaltrader) → execute returned ops; 1 hop may still be pair-direct but must include solverhybridpool_only=trueorHybridSimulationwithbook_input=0Minimal execute sketch (JSON shapes only, no new SDK): pointer to
router_operationsand single-hopCw20HookMsg::Swap { hybrid }fields. Link OpenAPI / Swagger.Hint recipe:
order-book-heador solver-providedbook_start_hint; wrong-side is safe (L17) but expired heads need the first live id (#289).How to see leakage: indexer trades
book_leg_volumevspool_leg_volumeon pair-direct txs (#216).Skill: 8–12 line “Do not regress” in
AGENTS_HYBRID_QUOTING.mdso agents do not tell bots “just swap on the pair.”Verify script: grep the new heading / table strings and the architecture caveat.
Acceptance criteria
docs/integrators.mdhas a first-screen section stating: omithybrid⇒ pool-only; best execution ⇒ indexerGET /route/solve(or declared Pattern C).docs/README.mdindex points at that section.AGENTS_HYBRID_QUOTING.mdagree (no contradiction with #596 always-on dApp).make verify-issue-<iid>green without Docker/chain.Test plan (functional paths)
Docs/static only:
docs/integrators.mdcan answer in < 1 minute: “Does my TerraSwapSwap {}hit the book?” → No.amount_inrequirement.pool_only=true.make verify-issue-<iid>greps I704 heading +/api/v1/route/solve+hybrid: None/ omitted wording.python3/rgthatarchitecture.mdmentions hybrid or limit book on the swap path.No contract tests. No Playwright.
Test plan (attack, hack, abuse)
Documentation can be wrong in a way that causes loss. Treat copy as a safety surface.
book_inputHybridSimulation.Simulationtraderon pair-directtrader; pair-directtraderis ignored unless trusted router.book_start_hintfrom the wrong side as an exploitpool_only=trueonly.indexer.dex.cl8y.comas production example; say LCD/factory provenance (P1) — do not paste random third-party “solver” hosts.gas = 600000for book walks.integrators-hybrid-volume.md; do not addlimit_order_fillson top of parent swap volume.Verification criteria
make verify-issue-<iid>(newscripts/qa/verify-issue-<iid>.sh) asserts the integrators heading, three-rung table (or equivalent), architecture note, and skill sentence exist.docs/integrators.mdtop: pool-only vs solver is unambiguous.smartcontracts/orfrontend-dapp/srcchanges (comment-only in pair allowed only if called out; default zero wasm).marked as related to #704
marked as related to #708
mentioned in issue #704
Sibling contract design (does not block this docs ticket): #708. Parent: #704.
mentioned in issue #708
mentioned in issue #712
mentioned in issue #718
/agent implement
/agent implement
Verified and completed: added the first-screen decision table and I707-1–I707-7 in
docs/integrators.md, aligned architecture, Pattern C, ADR 0001, route-solver docs, docs index, and third-party skills.make verify-issue-707passes 21/21 static checks; no LocalTerra, wasm, or dApp source changes.Since #708–#710 have shipped, the docs describe greedy as the current opt-in path. Newer #718 tracks the separate omitted-parameter default change and owns doc reconciliation when that rollout lands. Closing #707 for current contract behavior. Related: #704, #708, #709, #710, #718.
PR #1336 merged after refreshed Woodpecker CI remained Pending. Local make verify-issue-707 passed 21/21, including the docs-only scope guard; the issue remains closed.