contracts: greedy opt-out default on pair Swap + router TerraSwap #718

Open
opened 2026-09-01 08:15:54 +00:00 by PlasticDigits · 8 comments
PlasticDigits commented 2026-09-01 08:15:54 +00:00 (Migrated from gitlab.com)

Summary

Owner follow-up from #708 / G1 (called out as out of scope on #712): greedy becomes the omitted-params default on pair Swap and router TerraSwap.

A bot that treats CL8Y like TerraSwap / TerraPort (CW20 Send + {"swap":{…}} with max_spread, no hybrid, no greedy) must still execute and get OK (not perfect) pricing: fill live same-side makers that strictly beat the pool, remainder to the AMM. Perfect execution stays indexer GET /route/solve (official dApp, G4 / #501 / #596).

Greedy is opt-out, not opt-in. Missing greedy is not pool-only.

Gate (do not columbus-5 migrate this wasm first)

Blocked by #712 — pair 1.16.0 opt-in greedy must be live on columbus-5 (config.pair_code_id + all pairs) before this default-greedy wasm (pair 1.17.0 + router migrate) is stored/migrated.

Implementation in-repo may proceed in parallel. Do not reopen #708 / #709 / #710.

This leftover does require a router migrate (live router 11576 / 1.1.0 rejects unknown greedy today). #712 does not.

New G1 (replaces opt-in)

Inputs Mode
hybrid: None, greedy: None (TerraSwap-shaped) Greedy with a protocol default max_maker_fills (suggest 8, same as dApp hybrid cap) and book_start_hint: None (head, L17).
hybrid: Some(_) Pattern C unchanged (official dApp / solver hops). Includes explicit pool-only book_input: 0.
greedy: Some(params) Explicit greedy (cap / hint). max_maker_fills == 0 still rejects (G5) unless we pick a different opt-out wire — do not overload 0.
both set Reject (G11).

Pool-only opt-out for callers who want classic v2: send Pattern C hybrid: { pool_input: offer, book_input: "0", max_maker_fills: 1, book_start_hint: null } (already pool-only). Do not invent a second pool_only flag unless serde on TerraSwap-compat Swap cannot carry hybrid.

Same mutex on query and execute (G7 / G11): omitted greedy on HybridSimulation must resolve the same way as execute.

Must not break TerraSwap-shaped execute (G8)

Today explicit greedy requires belief_price or min_return (G8). Classic TerraSwap/TerraPort txs usually send max_spread only. If default greedy keeps G8 as-is, those bots start reverting after migrate — worse than pool-only.

For the omitted-greedy default path, use the existing pool/Pattern C slippage story (max_spread / belief_price). Keep G8 for explicit greedy: Some if we still want a hard floor on the integrator-opt-in shape — or unify, but naive omitted-params txs must succeed.

Router dummy G8 string (“book_input 1 requires per-hop min_return”) on hops with no book_input is already a #712 should-fix; this issue must not ship that LCD error on default-greedy hops.

Router

  • Omitted hybrid + omitted greedy on a TerraSwap hop → default greedy (same as pair).
  • Declared hybrid on a hop stays Pattern C / solver (G12 flip only for the omitted case).
  • Reverse sim must not silently pool-only-quote a default-greedy hop (#712 should-fix). Error or greedy-aware reverse; document if reverse stays non-greedy.

Gas (G13)

Default greedy with cap 8 must not fall through to silent 600k. Naive bots often simulate ~pool gas; they may OOG if the book is live. Cap 8 is the “OK not perfect” bound. Swarm / getGasLimitForTx must treat omitted-greedy hook "swap" as the greedy/hybrid envelope once this wasm is live — never BASE_GAS.

Official dApp

Do not take Swap/Trade off /route/solve. Solver hops send explicit hybrid; they are unaffected.

Docs / #707

#707 (pair.swap is pool-only) must be updated or closed as superseded when this lands — TerraSwap-compat Swap will no longer be pool-only.

Update G1 / G12 in skills/AGENTS_GREEDY_BOOK_FIRST.md, docs/contracts-security-audit.md, docs/integrators.md, docs/adr/0001-hybrid-quoting-and-routing.md, docs/limit-orders.md.

Acceptance criteria

  • #712 pair 1.16.0 migrate is done on columbus-5 before this wasm is migrated.
  • Pair execute + HybridSimulation: omitted hybrid/greedy → greedy (default cap), not pool-only.
  • Router TerraSwap hop: omitted hybrid/greedy → greedy; explicit hybrid unchanged.
  • TerraSwap-shaped swap with max_spread and no belief_price / min_return succeeds on the default path (G8 does not brick clones).
  • Explicit Pattern C book_input: 0 remains pool-only (opt-out).
  • Both hybrid + greedy still reject.
  • Quote = execute for omitted greedy.
  • Official dApp still GET /route/solve.
  • Gas map: omitted greedy is not 600k.
  • cw2 bump (pair 1.17.0, router >1.1.0) + factory UpdateConfig { pair_code_id } + pair fleet + router migrate.
  • Integrator docs + G1/G12 rewritten; #707 reconciled.

Out of scope

  • Replacing indexer best-execution with greedy.
  • Auto-deriving book_start_hint on-chain.
  • Flipping the official dApp off /route/solve.
  • Landing this migrate before #712.
## Summary Owner follow-up from [#708](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/708) / **G1** (called out as out of scope on [#712](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/712)): **greedy becomes the omitted-params default** on pair `Swap` and router `TerraSwap`. A bot that treats CL8Y like TerraSwap / TerraPort (CW20 `Send` + `{"swap":{…}}` with `max_spread`, no `hybrid`, no `greedy`) must still execute and get **OK (not perfect)** pricing: fill live same-side makers that strictly beat the pool, remainder to the AMM. Perfect execution stays indexer `GET /route/solve` (official dApp, **G4** / [#501](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/501) / [#596](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/596)). **Greedy is opt-out, not opt-in.** Missing `greedy` is not pool-only. ## Gate (do not columbus-5 migrate this wasm first) **Blocked by [#712](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/712)** — pair **1.16.0** opt-in greedy must be live on columbus-5 (`config.pair_code_id` + all pairs) before this default-greedy wasm (pair **1.17.0** + **router** migrate) is stored/migrated. Implementation in-repo may proceed in parallel. Do **not** reopen #708 / #709 / #710. This leftover **does** require a **router** migrate (live router **11576 / 1.1.0** rejects unknown `greedy` today). #712 does not. ## New G1 (replaces opt-in) | Inputs | Mode | |--------|------| | `hybrid: None`, `greedy: None` (TerraSwap-shaped) | **Greedy** with a protocol default `max_maker_fills` (suggest **8**, same as dApp hybrid cap) and `book_start_hint: None` (head, **L17**). | | `hybrid: Some(_)` | Pattern C unchanged (official dApp / solver hops). Includes explicit pool-only `book_input: 0`. | | `greedy: Some(params)` | Explicit greedy (cap / hint). `max_maker_fills == 0` still rejects (**G5**) unless we pick a different opt-out wire — do not overload `0`. | | both set | Reject (**G11**). | **Pool-only opt-out** for callers who want classic v2: send Pattern C `hybrid: { pool_input: offer, book_input: "0", max_maker_fills: 1, book_start_hint: null }` (already pool-only). Do **not** invent a second `pool_only` flag unless serde on TerraSwap-compat `Swap` cannot carry `hybrid`. Same mutex on **query and execute** (**G7** / **G11**): omitted `greedy` on `HybridSimulation` must resolve the same way as execute. ## Must not break TerraSwap-shaped execute (**G8**) Today explicit greedy requires `belief_price` or `min_return` (**G8**). Classic TerraSwap/TerraPort txs usually send **`max_spread` only**. If default greedy keeps G8 as-is, those bots **start reverting** after migrate — worse than pool-only. For the **omitted-greedy default path**, use the existing pool/Pattern C slippage story (`max_spread` / `belief_price`). Keep G8 for **explicit** `greedy: Some` if we still want a hard floor on the integrator-opt-in shape — or unify, but naive omitted-params txs must succeed. Router dummy G8 string (“book_input 1 requires per-hop min_return”) on hops with no `book_input` is already a #712 should-fix; this issue must not ship that LCD error on default-greedy hops. ## Router - Omitted `hybrid` + omitted `greedy` on a `TerraSwap` hop → default greedy (same as pair). - Declared `hybrid` on a hop stays Pattern C / solver (**G12** flip only for the omitted case). - Reverse sim must not silently pool-only-quote a default-greedy hop (#712 should-fix). Error or greedy-aware reverse; document if reverse stays non-greedy. ## Gas (**G13**) Default greedy with cap 8 must not fall through to silent **600k**. Naive bots often simulate ~pool gas; they may OOG if the book is live. Cap 8 is the “OK not perfect” bound. Swarm / `getGasLimitForTx` must treat omitted-greedy hook `"swap"` as the greedy/hybrid envelope once this wasm is live — never `BASE_GAS`. ## Official dApp Do **not** take Swap/Trade off `/route/solve`. Solver hops send explicit `hybrid`; they are unaffected. ## Docs / #707 [#707](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/707) (pair.swap is pool-only) must be updated or closed as superseded when this lands — TerraSwap-compat `Swap` will no longer be pool-only. Update **G1** / **G12** in `skills/AGENTS_GREEDY_BOOK_FIRST.md`, `docs/contracts-security-audit.md`, `docs/integrators.md`, `docs/adr/0001-hybrid-quoting-and-routing.md`, `docs/limit-orders.md`. ## Acceptance criteria - [ ] #712 pair 1.16.0 migrate is done on columbus-5 before this wasm is migrated. - [ ] Pair execute + `HybridSimulation`: omitted `hybrid`/`greedy` → greedy (default cap), not pool-only. - [ ] Router `TerraSwap` hop: omitted `hybrid`/`greedy` → greedy; explicit `hybrid` unchanged. - [ ] TerraSwap-shaped swap with `max_spread` and **no** `belief_price` / `min_return` **succeeds** on the default path (G8 does not brick clones). - [ ] Explicit Pattern C `book_input: 0` remains pool-only (opt-out). - [ ] Both `hybrid` + `greedy` still reject. - [ ] Quote = execute for omitted greedy. - [ ] Official dApp still GET `/route/solve`. - [ ] Gas map: omitted greedy is not 600k. - [ ] cw2 bump (pair **1.17.0**, router **>1.1.0**) + factory `UpdateConfig { pair_code_id }` + pair fleet + **router** migrate. - [ ] Integrator docs + G1/G12 rewritten; #707 reconciled. ## Out of scope - Replacing indexer best-execution with greedy. - Auto-deriving `book_start_hint` on-chain. - Flipping the official dApp off `/route/solve`. - Landing this migrate before #712.
PlasticDigits commented 2026-09-01 08:16:09 +00:00 (Migrated from gitlab.com)

marked as related to #712

marked as related to #712
PlasticDigits commented 2026-09-01 08:16:22 +00:00 (Migrated from gitlab.com)

mentioned in issue #712

mentioned in issue #712
PlasticDigits commented 2026-09-01 08:25:11 +00:00 (Migrated from gitlab.com)

#712 columbus-5 pair migrate is done — gate is open.

  • Pair code 11639 / cw2 1.16.0, config.pair_code_id 11639, 20/20 pairs.
  • Router already migrated to 11640 (cw2 still 1.1.0, opt-in greedy hops decode). This ticket still needs a new router wasm (version bump) plus pair 1.17.0 for omitted-params default greedy.
  • Live G1 check: omitted hybrid/greedy is still pool-only (EMBER/CORAL 929574 matches Pattern C book_input=0).
  • CL8Y/cUSTC greedy query already beats pool (99440 vs 98538, greedy_stop=filled).

Do not migrate 718 wasm until the default-greedy cw2 bump is in-tree.

[#712](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/712) columbus-5 pair migrate is **done** — gate is open. - Pair code **11639** / cw2 **1.16.0**, `config.pair_code_id` **11639**, **20/20** pairs. - Router already migrated to **11640** (cw2 still **1.1.0**, opt-in greedy hops decode). This ticket still needs a **new** router wasm (version bump) plus pair **1.17.0** for omitted-params **default greedy**. - Live G1 check: omitted `hybrid`/`greedy` is still **pool-only** (EMBER/CORAL `929574` matches Pattern C `book_input=0`). - CL8Y/cUSTC greedy query already beats pool (`99440` vs `98538`, `greedy_stop=filled`). Do not migrate 718 wasm until the default-greedy cw2 bump is in-tree.
PlasticDigits commented 2026-09-01 08:48:57 +00:00 (Migrated from gitlab.com)

mentioned in issue #704

mentioned in issue #704

/agent implement

/agent implement

Verified against origin/main 54c4868e: keep #718 open. Pair G1 still maps omitted hybrid+greedy to pool-only (9 dex-common mode tests and 21 greedy-book-first multitests pass; the G1 test leaves a better resting bid untouched). Router sim/execute also select pool-only when fields are omitted. #712 is closed; no newer issue tracks this default flip. #1324 only tracks the unrelated pair 1.18.0 TWAP migration; source is pair 1.18.0 / router 1.1.0. Remaining: implement omitted-default on pair query/execute and router (including max_spread-only slippage, reverse-quote policy, and greedy gas envelope); update version/migrate and reconcile still-open #707. This verification updates G1/G12 crosslinks in the contract, integrator, audit, and agent docs; keep #718 open until implementation and deployment acceptance pass.

Verified against origin/main 54c4868e: keep #718 open. Pair G1 still maps omitted hybrid+greedy to pool-only (9 dex-common mode tests and 21 greedy-book-first multitests pass; the G1 test leaves a better resting bid untouched). Router sim/execute also select pool-only when fields are omitted. #712 is closed; no newer issue tracks this default flip. #1324 only tracks the unrelated pair 1.18.0 TWAP migration; source is pair 1.18.0 / router 1.1.0. Remaining: implement omitted-default on pair query/execute and router (including max_spread-only slippage, reverse-quote policy, and greedy gas envelope); update version/migrate and reconcile still-open #707. This verification updates G1/G12 crosslinks in the contract, integrator, audit, and agent docs; keep #718 open until implementation and deployment acceptance pass.

PR #1337 merged while refreshed Woodpecker CI remained Pending under the explicit CI-skip authorization. Local greedy suites passed 9/9 and 21/21. #718 remains open for the default-greedy implementation and its #1225 liveness/parity gate.

PR #1337 merged while refreshed Woodpecker CI remained Pending under the explicit CI-skip authorization. Local greedy suites passed 9/9 and 21/21. #718 remains open for the default-greedy implementation and its #1225 liveness/parity gate.

Status clarification after merge: #1225 is currently marked Closed, while its latest verification comment still reports outstanding liveness acceptance. PR #1337 is documentation-only; #718 remains open until the default-greedy implementation, pair/router upgrade, and acceptance checks are complete.

Status clarification after merge: #1225 is currently marked Closed, while its latest verification comment still reports outstanding liveness acceptance. PR #1337 is documentation-only; #718 remains open until the default-greedy implementation, pair/router upgrade, and acceptance checks are complete.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#718
No description provided.