fix: snapshot factory discount registry into new pairs (#536) #1065

Merged
PlasticDigits merged 1 commit from feat/536-factory-discount-registry into main 2026-08-17 03:31:51 +00:00
PlasticDigits commented 2026-08-17 01:01:20 +00:00 (Migrated from gitlab.com)

Summary

Closes #536. Persist a canonical discount_registry on factory Config and copy it into new pairs at CreatePair so listings after the last governance sweep are not unwired.

  • Factory Config.discount_registry: Option<Addr> with #[serde(default)] so columbus-5 state migrates as None.
  • SetDiscountRegistryAll / SetDiscountRegistryBatch with Some/None also write/clear the factory pointer. Single-pair SetDiscountRegistry does not change the pointer.
  • UpdateConfig { discount_registry } sets the pointer without touching indexed pairs.
  • CreatePair copies config.discount_registry into PairInstantiateMsg.
  • Pair instantiate uses msg.discount_registry (optional, default None).
  • Pair query GetDiscountRegistry (was documented, missing from QueryMsg).
  • Local deploy runs set_discount_registry_all before first CreatePair; per-pair set_discount_registry stays as belt-and-suspenders.
  • Invariants F5 / I14, skill skills/AGENTS_FACTORY_DISCOUNT_REGISTRY.md, make verify-issue-536.

Existing live pairs stay unwired — that remains #535.

Post-merge follow-ups (do not close with this MR): #538.

Test plan

  • make test-contracts (includes 7 inherit tests in discount_registry_inherit_tests.rs)
  • make verify-issue-536 (5/5 including retest)
  • python3 scripts/check_fee_discount_tier_docs.py
  • After factory migrate on LocalTerra: create a pair and confirm registry is set without a follow-up SetDiscountRegistry — #538
  • After columbus-5 factory migrate: run All/Batch once so the factory pointer is set before the next listing — #538

Issue criteria

Criterion Status
Factory Config.discount_registry + serde default None Done
All/Batch persist/clear factory pointer; single-pair Set does not Done
UpdateConfig { discount_registry } without touching pairs Done
CreatePair copies factory pointer into instantiate msg Done
Pair instantiate uses msg.discount_registry (default None) Done
Pair GetDiscountRegistry query Done
Local/mainnet scripts keep idempotent per-pair set Done
Tests: inherit after All/Batch; CreatePair before pointer is None; missing Config field → None; single-pair Set does not change pointer; GetDiscountRegistry Done
make test-contracts Done
LocalTerra live migrate + create-pair without follow-up Set #538 (after this merge)
Wire three live economic pairs Out of scope (#535)
Change I10 fail-closed fee behavior Out of scope (unchanged)

Frontend only adds FactoryConfigResponse.discount_registry? and getPairDiscountRegistry(). Swap/Pool still assume a wired pair; consuming that helper is #538.

Closes #536
Related to #538

## Summary Closes #536. Persist a canonical `discount_registry` on factory `Config` and copy it into new pairs at `CreatePair` so listings after the last governance sweep are not unwired. - Factory `Config.discount_registry: Option<Addr>` with `#[serde(default)]` so columbus-5 state migrates as `None`. - `SetDiscountRegistryAll` / `SetDiscountRegistryBatch` with `Some`/`None` also write/clear the factory pointer. Single-pair `SetDiscountRegistry` does **not** change the pointer. - `UpdateConfig { discount_registry }` sets the pointer without touching indexed pairs. - `CreatePair` copies `config.discount_registry` into `PairInstantiateMsg`. - Pair instantiate uses `msg.discount_registry` (optional, default `None`). - Pair query `GetDiscountRegistry` (was documented, missing from `QueryMsg`). - Local deploy runs `set_discount_registry_all` before first `CreatePair`; per-pair `set_discount_registry` stays as belt-and-suspenders. - Invariants **F5** / **I14**, skill `skills/AGENTS_FACTORY_DISCOUNT_REGISTRY.md`, `make verify-issue-536`. Existing live pairs stay unwired — that remains #535. Post-merge follow-ups (do **not** close with this MR): #538. ## Test plan - [x] `make test-contracts` (includes 7 inherit tests in `discount_registry_inherit_tests.rs`) - [x] `make verify-issue-536` (5/5 including retest) - [x] `python3 scripts/check_fee_discount_tier_docs.py` - [ ] After factory migrate on LocalTerra: create a pair and confirm registry is set without a follow-up `SetDiscountRegistry` — [#538](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/538) - [ ] After columbus-5 factory migrate: run All/Batch once so the factory pointer is set before the next listing — [#538](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/538) ## Issue criteria | Criterion | Status | |-----------|--------| | Factory `Config.discount_registry` + serde default `None` | Done | | All/Batch persist/clear factory pointer; single-pair Set does not | Done | | `UpdateConfig { discount_registry }` without touching pairs | Done | | `CreatePair` copies factory pointer into instantiate msg | Done | | Pair instantiate uses `msg.discount_registry` (default `None`) | Done | | Pair `GetDiscountRegistry` query | Done | | Local/mainnet scripts keep idempotent per-pair set | Done | | Tests: inherit after All/Batch; CreatePair before pointer is `None`; missing Config field → `None`; single-pair Set does not change pointer; GetDiscountRegistry | Done | | `make test-contracts` | Done | | LocalTerra live migrate + create-pair without follow-up Set | **#538** (after this merge) | | Wire three live economic pairs | **Out of scope** (#535) | | Change I10 fail-closed fee behavior | **Out of scope** (unchanged) | Frontend only adds `FactoryConfigResponse.discount_registry?` and `getPairDiscountRegistry()`. Swap/Pool still assume a wired pair; consuming that helper is [#538](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/538). Closes #536 Related to #538
PlasticDigits commented 2026-08-17 01:01:30 +00:00 (Migrated from gitlab.com)

marked this merge request as ready

marked this merge request as **ready**
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 01:06:58 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-08-17 01:06:59 +00:00 (Migrated from gitlab.com)

Post-merge follow-up is #538 (factory pointer after migrate, LocalTerra inherit check, optional dApp GetDiscountRegistry). That issue must stay open when this MR merges — it is related, not closed by !1065.

Post-merge follow-up is #538 (factory pointer after migrate, LocalTerra inherit check, optional dApp `GetDiscountRegistry`). That issue must stay open when this MR merges — it is related, not closed by !1065.
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) merged commit 651cb642a7 into main 2026-08-17 03:31:52 +00:00
PlasticDigits commented 2026-08-17 03:42:11 +00:00 (Migrated from gitlab.com)

mentioned in issue #536

mentioned in issue #536
Sign in to join this conversation.
No reviewers
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!1065
No description provided.