Cardano Adapter
This guide explains how to set up, configure, and run the Charli3 Dendrite Wrapper for local development and production deployment.
Prerequisites
- Python: 3.11 or higher
- Poetry: For dependency management (
pip install poetry) - Cardano Access: Either a Blockfrost Project ID OR a running Ogmios + Kupo instance.
- Substrate Node: A running Charli3/Substrate node (e.g., locally or on a server).
Local Development Setup
-
Install Dependencies:
poetry install -
Configuration: Copy the example configuration file:
cp example-config.yml config.yml
Edit config.yml to set your providers. Below is an example matching the Chain Spec Trade Pairs:
# Configure price providers for the rates
Rates:
ADA-USD:
general_base_symbol: ADA-USD
general_quote_symbol: null # not needed when not converting
base_currency:
dexes:
- adapter: charli3-dendrite
asset_a: lovelace # ADA on-chain
asset_b: c48cbb3d5e57ed56e276bc45f99ab39abe94e6cd7ac39fb402da47ad0014df105553444d # USDM on-chain policy ID
quote_required: false
sources:
- minswapv2
- vyfi
- wingriders
- sundaeswapv3
- muesliswap
cexes:
- adapter: ccxt
asset_a: ADA
asset_b: USDT
quote_required: false
sources:
- binance
- kucoin
- bitmart
- coinbase
- mexc
- lbank
- huobi
- okx
- bitget
STUFF-ADA:
general_base_symbol: STUFF-ADA
general_quote_symbol: ADA-USD
base_currency:
dexes:
- adapter: charli3-dendrite
asset_a: 51a5e236c4de3af2b8020442e2a26f454fda3b04cb621c1294a0ef34424f4f4b
asset_b: lovelace
quote_required: true
sources:
- minswapv2
- vyfi
- wingriders
- sundaeswapv3
- muesliswap
quote_currency:
cexes:
- adapter: ccxt
asset_a: ADA
asset_b: USDT
quote_required: false
quote_calc_method: multiply
sources:
- binance
- kucoin
- bitmart
- coinbase
- mexc
- lbank
- huobi
- okx
- bitget- SubstrateQuery: Set
node_urlto your node’s WebSocket (e.g.,ws://localhost:9944). - CardanoQuery: Choose one provider:
- Blockfrost: Set
project_id. - Ogmios/Kupo: Set
ws_urlandkupo_url.
- Blockfrost: Set
-
Running the Service:
One-off run (fetch & submit once):
poetry run charli3 go --onceContinuous mode (fetch & submit periodically):
# Run forever with a 120-second interval poetry run charli3 go --forever --interval 120Note: Ensure your config file path matches the
--configargument (default isconfig.yml).
Docker Deployment
The project is containerized to support running multiple instances connecting to different Substrate nodes.
Environment Variables
The Docker container uses an entrypoint script that dynamically generates the config file based on these variables:
SUBSTRATE_NODE_URL: WebSocket URL for the target Substrate node.BLOCKFROST_PROJECT_ID: (Optional) For Blockfrost access.OGMIOS_WS_URL: (Optional) WebSocket URL for Ogmios.KUPO_URL: (Optional) HTTP URL for Kupo.
Using Docker Compose
The docker-compose.yml is pre-configured to spin up multiple dendrite instances (dendrite-1, dendrite-2, etc.) which is useful for testing multi-node networks.
-
Build and Start:
docker-compose up -d --buildThis starts 3 instances by default, connecting to host ports 9944, 9945, and 9946.
-
Custom Configuration: You can mount a base configuration file if needed, but environment variables generally suffice for connectivity settings.
CLI Reference
The main command is charli3 go.
| Flag | Default | Description |
|---|---|---|
--config | config.yml | Path to the YAML configuration file. |
--once | (Default) | Run a single query and exit. |
--forever | Run queries continuously. | |
--interval | 60 | Interval in seconds between runs (used with --forever). |
Example:
poetry run charli3 go --config my-config.yml --forever --interval 300