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

  1. Install Dependencies:

    poetry install
  2. 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_url to your node’s WebSocket (e.g., ws://localhost:9944).
  • CardanoQuery: Choose one provider:
    • Blockfrost: Set project_id.
    • Ogmios/Kupo: Set ws_url and kupo_url.
  1. Running the Service:

    One-off run (fetch & submit once):

    poetry run charli3 go --once

    Continuous mode (fetch & submit periodically):

    # Run forever with a 120-second interval
    poetry run charli3 go --forever --interval 120

    Note: Ensure your config file path matches the --config argument (default is config.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.

  1. Build and Start:

    docker-compose up -d --build

    This starts 3 instances by default, connecting to host ports 9944, 9945, and 9946.

  2. 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.

FlagDefaultDescription
--configconfig.ymlPath to the YAML configuration file.
--once(Default)Run a single query and exit.
--foreverRun queries continuously.
--interval60Interval in seconds between runs (used with --forever).

Example:

poetry run charli3 go --config my-config.yml --forever --interval 300