Feat/amm registry - #335
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an AMM “registry” configuration path to the AMM UI so known tokens/pools can be sourced either from existing local JSON files or from a single multi-network registry document (with a simple disk cache), and refreshes can propagate to QML via a revision counter.
Changes:
- Introduces
RegistryLoader(local-over-remote resolution, remote fetch + disk cache, network selection + deployment guard). - Wires
RegistryLoaderintoAmmUiBackendand exposesregistryRevision+refreshRegistry()so QML can re-fetch lists when the snapshot updates. - Updates testnet setup script to emit a single-file registry for exercising
AMM_REGISTRY_URL, and updates QML pages to reload lists whenregistryRevisionchanges.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| artifacts/amm-registry.json | Adds an on-repo registry JSON document/template. |
| apps/amm/tests/testnet/setup-amm-testnet.sh | Writes a test-only single-file registry and documents how to use AMM_REGISTRY_URL locally. |
| apps/amm/src/RegistryLoader.h | Declares new loader interface for registry-backed token/pool snapshots. |
| apps/amm/src/RegistryLoader.cpp | Implements local/remote loading, network selection, deployment checks, and disk caching. |
| apps/amm/src/AmmUiBackend.rep | Exposes registryRevision and refreshRegistry() over QtRO for QML consumers. |
| apps/amm/src/AmmUiBackend.h | Adds RegistryLoader member and new refreshRegistry() slot. |
| apps/amm/src/AmmUiBackend.cpp | Replaces direct file parsing with RegistryLoader snapshot and revision propagation. |
| apps/amm/qml/pages/SwapPage.qml | Reloads token list when registryRevision changes. |
| apps/amm/qml/pages/PoolsPage.qml | Reloads pool list when registryRevision changes. |
| apps/amm/qml/pages/LiquidityPage.qml | Reloads resolved tokens when registryRevision changes. |
| apps/amm/CMakeLists.txt | Adds RegistryLoader sources and links Qt Network. |
| apps/amm/.gitignore | Ignores test-generated amm-registry.json. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+9
to
+12
| class QNetworkAccessManager; | ||
| class QJsonArray; | ||
| class QJsonObject; | ||
|
|
| return true; | ||
| if (m_connectedAmm.isEmpty() && m_connectedToken.isEmpty()) | ||
| return true; | ||
| return amm == m_connectedAmm && token == m_connectedToken; |
| "name": "Logos AMM registry", | ||
| "version": "0.1.0", | ||
| "timestamp": "2026-08-27T00:00:00Z", | ||
| "networks": [], |
gravityblast
approved these changes
Aug 28, 2026
Collaborator
Author
0x-r4bbit
force-pushed
the
feat/amm-registry
branch
from
August 31, 2026 11:23
17e164c to
8fa1cdf
Compare
Split the AMM UI's known-tokens/known-pools loading into two concerns: - reading raw JSON bytes from a source (`readConfigFileBytes`, currently a local file at TOKENS_CONFIG / AMM_POOLS_CONFIG), and - parsing those bytes into the UI list (`parseTokensJson` / `parsePoolsJson`). The parsers are now source-agnostic, so a remote payload can feed the exact same validation and shaping. No behavior change: the local-file env-var path is preserved, including the fail-soft / skip-malformed-entry semantics.
Introduce apps/amm/src/RegistryLoader, a QObject that owns the known-tokens / known-pools snapshot and serves it to the backend's QtRO slots. The JSON parsers move here; AmmUiBackend now reads tokenList/poolList/resolveTokens from the loader's snapshot instead of re-parsing the config files inline. Add the refresh plumbing the UI will drive: - PROP(int registryRevision READONLY) — bumped on every snapshot refresh so QML replicas re-fetch the lists. - SLOT(void refreshRegistry()) — manual re-load. No behavior change: the source is still the local TOKENS_CONFIG / AMM_POOLS_CONFIG files. This is Phase 2a of docs/amm-registry-plan.md; Phase 2b reshapes RegistryLoader::refresh() into the async remote (AMM_REGISTRY_URL) fetch — manifest + deployment guard + disk cache — with the same snapshot contract.
When no local TOKENS_CONFIG / AMM_POOLS_CONFIG is set, RegistryLoader now loads the known-tokens / known-pools from a remote GitHub registry named by AMM_REGISTRY_URL: an async QNetworkAccessManager fetch of a registry.json manifest, then the tokens.json / pools.json it points at (resolved relative to the manifest URL). - Stale-while-revalidate: the on-disk cache is served immediately and revalidated against the network (the manifest `timestamp` is the freshness key); a failed/offline fetch keeps the last cache. - Deployment guard: a manifest whose programIds don't match the app's deployment (from configAccount) is rejected; a manifest that omits programIds is trusted. - Precedence unchanged: local files replace the remote source when set; user custom tokens still merge on top. - registryRevision bumps on each snapshot update; SwapPage/PoolsPage/ LiquidityPage re-fetch on it. CMake links Qt6::Network. Add apps/amm/registry-sample/ — a manifest plus empty tokens.json / pools.json and a README — to exercise the remote path end to end (start with the empty case). Compile-verified via `nix build .#amm-ui`; not yet run end to end.
Replace the per-network manifest + separate tokens.json/pools.json with a single
Uniswap-token-list-style document: { networks:[{id,name,programIds}],
tokens:[{network,...}], pools:[{network,...}] }. RegistryLoader now fetches one
file, selects the active network, and filters entries to it.
- Active network = AMM_NETWORK (override) -> else the network whose programIds
match the connected deployment (configAccount) -> else the lone network. The
programIds match doubles as the deployment guard.
- Registry lives in-repo at artifacts/amm-registry.json (no separate repo yet);
remove apps/amm/registry-sample/.
- Rename setExpectedProgramIds -> setConnectedProgramIds (drives selection + guard);
add activeNetwork(). Local dev source (bare arrays) is unchanged.
0x-r4bbit
force-pushed
the
feat/amm-registry
branch
from
September 1, 2026 15:39
8fa1cdf to
0e11589
Compare
Comment on lines
+100
to
+108
| Button { | ||
| id: saveButton | ||
| objectName: "settingsRegistrySaveButton" | ||
| Layout.fillWidth: true | ||
| text: qsTr("Save") | ||
| onClicked: { | ||
| if (root.backend) | ||
| root.backend.saveRegistryUrl(registryUrlField.text) | ||
| } |
setup-amm-testnet.sh now also writes tests/testnet/amm-registry.json — the seeded tokens/pools in the single-file multi-network registry shape (one "local" network with empty programIds so the lone-network rule auto-selects it; holding-agnostic tokens; a fresh timestamp each run). This lets the AMM_REGISTRY_URL path be exercised against the local sequencer without hosting anything — point AMM_REGISTRY_URL at the file with a file:// URL.
…ntime The module derives its program id from AMM_PROGRAM_BIN. Add setAmmProgramId so a caller can adopt a specific id instead — the app uses it to target the network it selected from its registry, dropping the AMM_PROGRAM_BIN requirement. ammProgramId() prefers the adopted id and falls back to the bin when none is set, so headless callers are unaffected.
RegistryLoader no longer infers the network from the connected deployment (which needed AMM_PROGRAM_BIN and can't tell apart networks that share deterministic program/account ids). It selects by AMM_NETWORK, or the lone network when the registry declares exactly one, and exposes that network's amm program id via activeAmmProgramId(). AmmUiBackend adopts it on the module with setAmmProgramId whenever the snapshot changes, so ops target the selected network with no bin. A multi-network registry now requires AMM_NETWORK to disambiguate. The testnet setup script writes the freshly deployed program ids into the local registry network and drops AMM_PROGRAM_BIN from the remote-registry launch line.
Add a registryUrl PROP and saveRegistryUrl SLOT to the backend, backed by a global
(per-user) QSettings value ("Logos"/"AmmUI"). RegistryLoader falls back to this
configured URL when AMM_REGISTRY_URL is unset, so a packaged build needs no env
var. saveRegistryUrl persists the value and reloads the registry; the disk cache is
now keyed by the effective URL (env or configured) so it stays consistent. The
config-field UI comes in the next commit.
Add a "Registry settings" entry to the wallet menu that opens a page with a text field bound to the backend's registryUrl and saved via saveRegistryUrl. A packaged build can now set the registry URL in the UI instead of via AMM_REGISTRY_URL, which still overrides when set. The menu opens when a wallet is connected.
The timestamp only fed a revalidation skip: a re-fetch reused the current snapshot when the document's timestamp matched the last applied one. Nothing polls in the background — a fetch happens only at startup, on manual refresh, or on a URL change — so the skip saved almost nothing and could wrongly skip a switch between two registries that happened to share a timestamp. Remove the field and always apply a fetched registry; the disk cache keeps its stale-while-revalidate behavior (keyed by URL, no stamp). Drop the timestamp from the setup script and the sample registry.
Add a cogwheel in the bottom-right corner that opens an app settings modal with a Registry section: the known-tokens / known-pools registry URL (a persisted global setting) and a network picker over the registry's networks, defaulting to the first. This is AMM-specific, so it lives in the app rather than the shared wallet UI. Bound to the backend's registryUrl / saveRegistryUrl / networks / activeNetwork / selectNetwork.
0x-r4bbit
force-pushed
the
feat/amm-registry
branch
from
September 2, 2026 10:41
8c5697c to
fbb3189
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.