CreatePair should snapshot factory discount registry so new pairs are not unwired #536

Closed
opened 2026-08-17 00:36:54 +00:00 by PlasticDigits · 13 comments
PlasticDigits commented 2026-08-17 00:36:54 +00:00 (Migrated from gitlab.com)

Summary

Parent: #535. Immediate ops (wire the three live economic pairs) stay there.

Pair instantiate always saves DISCOUNT_REGISTRY = None. Factory CreatePair does not pass a registry, and factory Config does not even store one — SetDiscountRegistry* only forwards to already indexed pairs. Any listing after the last governance sweep is unwired until a manual tx (this is how UST1/cUSTC, UST1/USTR, and cLUNC/UST1 launched).

Direction (agreed)

Do not rely on operators remembering a post-create sweep. Persist the canonical registry on the factory and copy it into new pairs at instantiate. Existing pairs are not fixed by this issue — that is #535.

Scope (deploy + migrate)

  1. Factory Config: add discount_registry: Option<Addr> with serde default None so existing columbus-5 state migrates.
  2. SetDiscountRegistryAll / SetDiscountRegistryBatch with Some(registry) also write the factory pointer (so the next CreatePair inherits it). Clearing via All/Batch (None) should clear the factory pointer. Single-pair SetDiscountRegistry should not change the factory default.
  3. Optional UpdateConfig { discount_registry } so governance can set the pointer without touching pairs.
  4. CreatePair copies config.discount_registry into PairInstantiateMsg.
  5. Pair instantiate uses msg.discount_registry instead of hardcoded None (optional field, default None).
  6. Add the documented pair query GetDiscountRegistry (today it is in docs/contracts-terraclassic.md but not in QueryMsg — live wasm returns unknown variant). Needed so the dApp can stop assuming every pair is wired (#535 note).
  7. Local/mainnet create-pair scripts may keep an idempotent set_discount_registry as belt-and-suspenders until this ships; then it is optional.

Tests

  • CreatePair after All/Batch inherit the registry (raw/GetDiscountRegistry).
  • CreatePair before any factory pointer remains None.
  • Factory migrate with missing discount_registry field → None.
  • Single-pair SetDiscountRegistry does not change factory config pointer.
  • GetDiscountRegistry returns the stored Option<Addr>.

Verify

make test-contracts. After migrate on LocalTerra: create a pair, confirm registry is set without a follow-up SetDiscountRegistry.

Out of scope

  • Wiring the three live economic pairs (#535 ops).
  • Changing fail-closed fee behavior when the registry query errors (I10).
## Summary Parent: [#535](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/535). Immediate ops (wire the three live economic pairs) stay there. Pair `instantiate` always saves `DISCOUNT_REGISTRY = None`. Factory `CreatePair` does not pass a registry, and factory `Config` does not even store one — `SetDiscountRegistry*` only forwards to **already indexed** pairs. Any listing after the last governance sweep is unwired until a manual tx (this is how UST1/cUSTC, UST1/USTR, and cLUNC/UST1 launched). ## Direction (agreed) Do **not** rely on operators remembering a post-create sweep. Persist the canonical registry on the factory and copy it into new pairs at instantiate. Existing pairs are **not** fixed by this issue — that is #535. ## Scope (deploy + migrate) 1. Factory `Config`: add `discount_registry: Option<Addr>` with serde default `None` so existing columbus-5 state migrates. 2. `SetDiscountRegistryAll` / `SetDiscountRegistryBatch` with `Some(registry)` also write the factory pointer (so the next `CreatePair` inherits it). Clearing via All/Batch (`None`) should clear the factory pointer. Single-pair `SetDiscountRegistry` should **not** change the factory default. 3. Optional `UpdateConfig { discount_registry }` so governance can set the pointer without touching pairs. 4. `CreatePair` copies `config.discount_registry` into `PairInstantiateMsg`. 5. Pair instantiate uses `msg.discount_registry` instead of hardcoded `None` (optional field, default `None`). 6. Add the documented pair query `GetDiscountRegistry` (today it is in [`docs/contracts-terraclassic.md`](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/blob/main/docs/contracts-terraclassic.md) but **not** in `QueryMsg` — live wasm returns `unknown variant`). Needed so the dApp can stop assuming every pair is wired ([#535](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/535) note). 7. Local/mainnet create-pair scripts may keep an idempotent `set_discount_registry` as belt-and-suspenders until this ships; then it is optional. ## Tests - `CreatePair` after All/Batch inherit the registry (raw/`GetDiscountRegistry`). - `CreatePair` before any factory pointer remains `None`. - Factory migrate with missing `discount_registry` field → `None`. - Single-pair `SetDiscountRegistry` does not change factory config pointer. - `GetDiscountRegistry` returns the stored `Option<Addr>`. ## Verify `make test-contracts`. After migrate on LocalTerra: create a pair, confirm registry is set without a follow-up `SetDiscountRegistry`. ## Out of scope - Wiring the three live economic pairs (#535 ops). - Changing fail-closed fee behavior when the registry query errors (I10).
PlasticDigits commented 2026-08-17 00:36:54 +00:00 (Migrated from gitlab.com)

marked as related to #535

marked as related to #535
PlasticDigits commented 2026-08-17 00:37:09 +00:00 (Migrated from gitlab.com)

mentioned in issue #535

mentioned in issue #535
PlasticDigits commented 2026-08-17 01:01:03 +00:00 (Migrated from gitlab.com)

mentioned in commit 4d62c40091

mentioned in commit 4d62c400912fc79c44c3a816c02c858b87829d11
PlasticDigits commented 2026-08-17 01:01:21 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1065

mentioned in merge request !1065
PlasticDigits commented 2026-08-17 01:04:45 +00:00 (Migrated from gitlab.com)

marked as related to #538

marked as related to #538
PlasticDigits commented 2026-08-17 01:04:45 +00:00 (Migrated from gitlab.com)

mentioned in issue #538

mentioned in issue #538
PlasticDigits commented 2026-08-17 03:31:52 +00:00 (Migrated from gitlab.com)

mentioned in commit 651cb642a7

mentioned in commit 651cb642a77c83b310de103fa86a686cae76e306
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-08-17 03:31:52 +00:00
PlasticDigits commented 2026-08-17 03:42:10 +00:00 (Migrated from gitlab.com)

!1065 merged to main (651cb642). In-scope #536 AC is on main (factory pointer + CreatePair inherit + GetDiscountRegistry; make verify-issue-536 5/5 after merge).

Remaining work stays on #538 (do not close that issue):

  • Set factory config.discount_registry after columbus-5 / LocalTerra migrate (All/Batch or UpdateConfig)
  • Live LocalTerra create-pair inherit check (no follow-up SetDiscountRegistry)
  • Optional dApp consume of GetDiscountRegistry (Swap/Pool still assume wired unless #537 raw probe)

UpdateConfig can set but not clear the pointer; clear via All/Batch with null.

!1065 merged to `main` (`651cb642`). In-scope #536 AC is on `main` (factory pointer + CreatePair inherit + `GetDiscountRegistry`; `make verify-issue-536` 5/5 after merge). Remaining work stays on #538 (do not close that issue): - Set factory `config.discount_registry` after columbus-5 / LocalTerra migrate (All/Batch or `UpdateConfig`) - Live LocalTerra create-pair inherit check (no follow-up `SetDiscountRegistry`) - Optional dApp consume of `GetDiscountRegistry` (Swap/Pool still assume wired unless #537 raw probe) `UpdateConfig` can set but not clear the pointer; clear via All/Batch with `null`.
PlasticDigits commented 2026-08-17 09:23:43 +00:00 (Migrated from gitlab.com)

mentioned in commit ea2e48b6911463f3a54457bcb92f93dc63abb228

mentioned in commit ea2e48b6911463f3a54457bcb92f93dc63abb228
PlasticDigits commented 2026-08-17 09:30:27 +00:00 (Migrated from gitlab.com)

mentioned in commit e6d407f490

mentioned in commit e6d407f490c0ffbc74791131c4df9a75c3790a6e
PlasticDigits commented 2026-08-17 09:31:24 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1072

mentioned in merge request !1072
PlasticDigits commented 2026-08-17 09:31:25 +00:00 (Migrated from gitlab.com)

columbus-5 factory 1.8.0 + pair 1.14.0 store/migrate is complete (#538 ops).

  • Store factory: 1E031782200FDA99FB6FA75844D164E55594B0AE330EEA76B17619BA8FC8F240 → code 11585, data_hash 4BD5A8D9…329845
  • Store pair: 4C3254261008D77CBF94CC091C08E2B85C3A232E8095F0EC967D62DAF9C3D5AA → code 11586, data_hash BD4AD1A1…ED87BF
  • Factory instance now code 11585; config.pair_code_id 11586; config.discount_registry = terra1wcczsdk7jwj99n3my6wx8wr4ee0hn6yaapgd792lgx5elrdtrn2scfnecz
  • All 13 indexed pairs are code 11586 and {"get_discount_registry":{}} returns that registry address

In-scope #536 AC was already on main via !1065. Remaining LocalTerra inherit check + optional dApp query stay on #538.

columbus-5 factory 1.8.0 + pair 1.14.0 store/migrate is complete (#538 ops). - Store factory: `1E031782200FDA99FB6FA75844D164E55594B0AE330EEA76B17619BA8FC8F240` → code **11585**, `data_hash` `4BD5A8D9…329845` - Store pair: `4C3254261008D77CBF94CC091C08E2B85C3A232E8095F0EC967D62DAF9C3D5AA` → code **11586**, `data_hash` `BD4AD1A1…ED87BF` - Factory instance now code **11585**; `config.pair_code_id` **11586**; `config.discount_registry` = `terra1wcczsdk7jwj99n3my6wx8wr4ee0hn6yaapgd792lgx5elrdtrn2scfnecz` - All **13** indexed pairs are code **11586** and `{"get_discount_registry":{}}` returns that registry address In-scope #536 AC was already on main via !1065. Remaining LocalTerra inherit check + optional dApp query stay on #538.
PlasticDigits commented 2026-08-17 10:19:53 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1075

mentioned in merge request !1075
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#536
No description provided.