degenbot.registry.deployment_loader =================================== .. py:module:: degenbot.registry.deployment_loader .. autoapi-nested-parse:: Register DEX deployment records into the pool-type registry. Companion layer (ADR-005): the data itself is read by :mod:`degenbot.registry.deployment_records` (a leaf module — it knows the JSON schema and the valid ``pool_type`` keys but resolves nothing to Python classes). This module owns the ``pool_type`` → Python class map, resolves the JSON string keys (``pool_type`` → class, ``dex_variant`` → ``DexIdentity`` preset, ``family`` string → ``PoolFamily`` enum), and drives the registry's low-level ``register()``. The shipped ``deployments.json`` is the single source of deployment data (``chain_id``, ``factory`` → ``deployer`` / ``init_hash`` / ``variant`` / ``dex_identity`` preset). A user overlay path may be declared in ``config.toml`` under ``[deployments]`` → ``overlay``; entries there override shipped entries on ``(chain_id, factory)`` conflict (user wins). Module Contents --------------- .. py:class:: DeploymentRecord A single deployment row loaded from JSON. .. py:attribute:: name :type: str .. py:attribute:: chain_id :type: int .. py:attribute:: pool_type :type: str .. py:attribute:: variant :type: str | None .. py:attribute:: dex_variant :type: str | None .. py:attribute:: family :type: str | None .. py:attribute:: factory :type: str .. py:attribute:: deployer :type: str | None .. py:attribute:: init_hash :type: str | None .. py:attribute:: implementation_address :type: str | None :value: None .. py:function:: load_deployments(*, overlay_path: pathlib.Path | str | None = None) -> list[DeploymentRecord] Load deployment records from the shipped JSON, merged with an optional overlay. The overlay is resolved in this order: 1. The ``overlay_path`` argument (programmatic — used by tests). 2. The ``[deployments] overlay`` setting in ``~/.config/degenbot/config.toml``. Shipped defaults load first; overlay entries override on ``(chain_id, factory)`` conflict (overlay wins). The merged list preserves insertion order (shipped order, with overlays replacing in-place). :returns: The merged deployment records. .. py:function:: load_json_deployments(path: pathlib.Path | str) -> list[DeploymentRecord] Load deployment records from an explicit JSON file path. Convenience wrapper around the internal JSON reader — exposed for tests and programmatic callers that want to load a specific file without the shipped-defaults merge. :returns: The parsed deployment records. .. py:data:: POOL_TYPE_MAP :type: dict[str, type[degenbot.types.abstract.AbstractLiquidityPool]] .. py:function:: register_from_deployments(records: list[degenbot.registry.deployment_records.DeploymentRecord], registry: degenbot.registry.pool_type.PoolTypeRegistry) -> None Register deployment records into a :class:`PoolTypeRegistry`. Companion-layer orchestration (ADR-005): resolves the JSON string keys (``pool_type`` → Python class, ``dex_variant`` → ``DexIdentity`` preset, ``family`` string → ``PoolFamily`` enum) and calls the registry's low-level ``register()`` primitive for each record. The ``dex_variant`` preset is resolved via :func:`~degenbot._ffi.dex_identity` and asserted non-None — a preset string in the JSON must resolve, otherwise the deployment data is inconsistent with the compiled ``DexIdentity`` presets (Rust-side). :param records: The deployment records (typically from :func:`load_deployments`). :param registry: The target registry (e.g. the ``pool_type_registry`` singleton).