> For the complete documentation index, see [llms.txt](https://darksun-2.gitbook.io/darksun-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://darksun-2.gitbook.io/darksun-docs/integrations/darksun-operator-guide.md). Agents can also search and read this documentation through its [MCP server](https://darksun-2.gitbook.io/darksun-docs/~gitbook/mcp).

# DarkSun Operator Guide

This page is for the DarkSun team and operators who need to run, inspect, or troubleshoot the integration layer inside the DarkSun backend.

It complements the partner-facing integration documentation by documenting the current runtime behavior already implemented in this repository.

## What exists today

DarkSun currently ships a first integration architecture layer with:

* local manifests stored under `app-backend/data/integrations/`
* optional remote manifest registry loading
* manifest normalization and validation
* endpoint and capability resolution
* provider-level adoption for liquidity, farming, staking, and NFTs

This layer is additive. It coexists with the legacy configuration and fallback logic.

## Current bootstrap manifests

The backend currently ships these bootstrap manifests:

* `terra_classic_native`
* `terra_classic_liquidity`
* `terra_classic_farming`
* `terra_classic_staking`
* `terra_classic_nft`
* `cosmoshub_native`
* `cosmoshub_staking`
* `osmosis_native`
* `osmosis_staking`

These live under `app-backend/data/integrations/` and are registered through the local index.

## Adding another blockchain

The chain definition in `app-backend/src/chains.js` is the runtime source of truth for both backend and frontend. It publishes the native asset, endpoints, explorer templates, wallet providers and capabilities through the UI bootstrap. The frontend does not require a second chain entry.

For a standard Cosmos SDK blockchain:

1. add one `adapter: "cosmos-sdk"` definition in `chains.js`;
2. add its key to `ACTIVE_CHAINS`;
3. optionally add endpoint overrides under `chains.<key>.endpoints` in `config/runtime-config.json`;
4. add a native integration manifest for Ecosystem provenance;
5. add protocol manifests with `metadata.protocol.chains` when protocols are connected.

Enabled capabilities automatically control portfolio support, native staking, governance, transaction lookup and background indexers. Non-Cosmos execution models should use a dedicated adapter instead of pretending to be Cosmos SDK compatible.

Osmosis also demonstrates the optional `stakingEconomics` hook. Its epoch mint module is converted into annual staking provisions while the standard Cosmos Hub mint endpoints continue to use the default provider path.

## Runtime configuration

The integration layer is controlled through backend environment variables.

### Registry-level configuration

* `INTEGRATION_REGISTRY_URL` Optional remote registry location.
* `INTEGRATION_LOCAL_DIR` Local manifest directory. Defaults to the backend integrations data folder.

### Provider selection overrides

* `LIQUIDITY_INTEGRATION_ID` Forces a specific liquidity manifest when more than one candidate exists.
* `FARMING_INTEGRATION_ID` Forces a specific farming manifest when more than one candidate exists.
* `STAKING_INTEGRATION_ID` Forces a specific staking manifest when more than one candidate exists.
* `NFT_INTEGRATION_ID` Forces a specific NFT manifest when more than one candidate exists.

## How providers currently use the manifest layer

The manifest system does not replace every provider yet. It currently acts as a typed source declaration layer in front of the historical provider logic.

### Liquidity

DarkSun tries to resolve liquidity sources from an integration manifest first, then falls back to legacy sources such as:

* `LIQUIDITY_INDEXER_URL`
* `DEX_REGISTRY_URL`
* `LIQUIDITY_REGISTRY_URL`

### Farming

DarkSun tries to resolve farming sources from an integration manifest first, then falls back to:

* `FARM_REGISTRY_URL`
* `DEX_REGISTRY_URL`

### Staking

DarkSun tries to resolve staking support sources from an integration manifest first, then falls back to:

* the historical validator registry flow
* the existing validator metrics source

### NFTs

DarkSun tries to resolve the external NFT indexer declaration and known marketplace declarations from the manifest layer first, then falls back to:

* `NFT_INDEXER_URL`
* built-in discovery and marketplace bootstrap logic

## Admin inspection endpoint

The backend exposes an inspection endpoint for the integration registry:

* `GET /api/admin/integrations?chain=terra_classic`
* `GET /api/admin/integrations?id=terra_classic_native&chain=terra_classic`

Use this endpoint to:

* confirm which manifests were loaded
* inspect resolved manifest content
* review registry loading errors
* check which local directory or remote registry was used

## When to use this guide

Use this page when you are:

* operating the DarkSun backend
* debugging why a manifest is not being selected
* forcing a provider toward a specific integration id
* validating whether the registry loaded correctly

## Recommended operator workflow

1. confirm the relevant env vars
2. check that the manifest exists locally or in the remote registry
3. call `/api/admin/integrations`
4. verify the manifest id, endpoints, capabilities, and errors
5. only then debug provider-specific fallback behavior

This sequence avoids spending time inside provider code before confirming that the integration layer itself is healthy.
