> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clypt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Onchain Data

> RPC-based and DeFiLlama onchain data collection across 16 chains and 20 DeFiLlama ecosystems

## Overview

ClyptQ collects onchain data from two complementary sources:

1. **RPC Direct Collection** — Hourly granularity (1h). Direct blockchain node queries for gas, DeFi rates, stablecoin supply, DEX pools, exchange flow, whale transfers, and network metrics.
2. **DeFiLlama API** — Daily granularity (1d). Aggregate chain-level TVL, DEX volume, fees/revenue, and stablecoin circulating supply across 20 chains.

All data is public and requires no API keys or licenses. RPC endpoints use public fallbacks with optional private override via environment variables.

## 1. RPC Direct Collection (1h)

### Chain × Data Type Matrix

| Chain         |     gas    | defi\_rates | stablecoin\_supply | dex\_pools | market\_reserves | exchange\_flow | whale\_transfers | network |    mempool    |
| ------------- | :--------: | :---------: | :----------------: | :--------: | :--------------: | :------------: | :--------------: | :-----: | :-----------: |
| **Bitcoin**   |      -     |      -      |          -         |      -     |         -        |        O       |         O        |    O    | O (live only) |
| **Ethereum**  |      O     |      O      |          O         |      -     |         -        |        O       |         O        |    -    |       -       |
| **Arbitrum**  |      O     |      O      |          O         |      O     |         O        |        O       |         O        |    -    |       -       |
| **Base**      |      O     |      O      |          O         |      O     |         O        |        O       |         O        |    -    |       -       |
| **Optimism**  |      O     |      O      |          O         |      O     |         O        |        O       |         O        |    -    |       -       |
| **Polygon**   |      O     |      O      |          O         |      O     |         O        |        O       |         O        |    -    |       -       |
| **BSC**       |      O     |  O (Venus)  |          O         |      -     |         -        |        O       |         O        |    -    |       -       |
| **Avalanche** |      O     |   O (Aave)  |          O         |      O     |         O        |        O       |         O        |    -    |       -       |
| **Mantle**    |      O     |      -      |          O         |      -     |         -        |        O       |         O        |    -    |       -       |
| **zkSync**    |      O     |      -      |          O         |      -     |         -        |        O       |         O        |    -    |       -       |
| **Solana**    |  O (fees)  |      -      |          -         |      -     |         -        |        -       |         -        |    O    |       -       |
| **Aptos**     |      O     |      -      |          -         |      -     |         -        |        -       |         -        |    O    |       -       |
| **TON**       |      O     |      -      |          -         |      -     |         -        |        -       |         -        |    O    |       -       |
| **TRON**      | O (energy) |      -      |          -         |      -     |         -        |        -       |         -        |    O    |       -       |
| **Cosmos**    |      -     |      -      |          -         |      -     |         -        |        -       |         -        |    O    |       -       |
| **Sui**       |      O     |      -      |          -         |      -     |         -        |        -       |         -        |    O    |       -       |

**Data sources**: Bitcoin = Mempool.space, EVM = Archive Node RPC, Others = chain-native RPC.

### EVM DeFi Protocol Support

Not all EVM chains support the same DeFi protocols:

| Chain         | Aave V3 | Compound V3 | Venus | DEX Pool (UniV3) | Market Reserves |
| ------------- | :-----: | :---------: | :---: | :--------------: | :-------------: |
| **Arbitrum**  |    O    |      O      |   -   |         O        |        O        |
| **Base**      |    O    |      O      |   -   |         O        |        O        |
| **Optimism**  |    O    |      O      |   -   |         O        |        O        |
| **Polygon**   |    O    |      O      |   -   |         O        |        O        |
| **BSC**       |    -    |      -      |   O   |         O        |        -        |
| **Avalanche** |    O    |      -      |   -   |         O        |        O        |
| **Mantle**    |    -    |      -      |   -   |         -        |        -        |
| **zkSync**    |    -    |      -      |   -   |         -        |        -        |

### DeFi Rates Fields (per chain)

| Chain                                | Fields                                                                                                 |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| Arbitrum / Base / Optimism / Polygon | `aave_v3_supply_rate_usdc`, `aave_v3_borrow_rate_usdc`, `compound_v3_borrow_rate`                      |
| Avalanche                            | `aave_v3_supply_rate_usdc`, `aave_v3_borrow_rate_usdc` (no Compound)                                   |
| BSC                                  | `venus_supply_rate_usdc`, `venus_supply_rate_usdt`, `venus_borrow_rate_usdc`, `venus_borrow_rate_usdt` |
| Mantle / zkSync                      | *None — no DeFi protocol support*                                                                      |

### Stablecoin Supply Fields

| Chain      | Fields                                     |
| ---------- | ------------------------------------------ |
| **Base**   | `usdc_total_supply` only (no USDT on Base) |
| All others | `usdc_total_supply`, `usdt_total_supply`   |

### Data Types per Chain (Summary)

| Chain         | Supported data\_types                                                                                            |
| ------------- | ---------------------------------------------------------------------------------------------------------------- |
| **Arbitrum**  | gas, defi\_rates, stablecoin\_supply, dex\_pools, market\_reserves, exchange\_flow, whale\_transfers             |
| **Base**      | gas, defi\_rates, stablecoin\_supply, dex\_pools, market\_reserves, exchange\_flow, whale\_transfers             |
| **Optimism**  | gas, defi\_rates, stablecoin\_supply, dex\_pools, market\_reserves, exchange\_flow, whale\_transfers             |
| **Polygon**   | gas, defi\_rates, stablecoin\_supply, dex\_pools, market\_reserves, exchange\_flow, whale\_transfers             |
| **BSC**       | gas, defi\_rates (Venus), stablecoin\_supply, dex\_pools, exchange\_flow, whale\_transfers                       |
| **Avalanche** | gas, defi\_rates (Aave only), stablecoin\_supply, dex\_pools, market\_reserves, exchange\_flow, whale\_transfers |
| **Mantle**    | gas, stablecoin\_supply, exchange\_flow, whale\_transfers                                                        |
| **zkSync**    | gas, stablecoin\_supply, exchange\_flow, whale\_transfers                                                        |
| **Ethereum**  | gas, defi\_rates, stablecoin\_supply, exchange\_flow, whale\_transfers                                           |
| **Bitcoin**   | exchange\_flow, whale\_transfers, network, mempool (live only)                                                   |
| **Solana**    | gas (fees), network                                                                                              |
| **Aptos**     | gas, network                                                                                                     |
| **TON**       | gas, network                                                                                                     |
| **TRON**      | gas (energy), network                                                                                            |
| **Cosmos**    | network                                                                                                          |
| **Sui**       | gas, network                                                                                                     |

## 2. DeFiLlama API (1d)

All 27 chains receive the same 4 data types at daily granularity. No API key required.

### Supported Chains (from collect.yaml)

| Chain       | tvl\_usd | volume\_24h\_usd | daily\_fees / revenue\_usd | stablecoin\_circulating\_usd |
| ----------- | :------: | :--------------: | :------------------------: | :--------------------------: |
| ethereum    |     O    |         O        |              O             |               O              |
| bsc         |     O    |         O        |              O             |               O              |
| tron        |     O    |         O        |              O             |               O              |
| solana      |     O    |         O        |              O             |               O              |
| arbitrum    |     O    |         O        |              O             |               O              |
| base        |     O    |         O        |              O             |               O              |
| avalanche   |     O    |         O        |              O             |               O              |
| polygon     |     O    |         O        |              O             |               O              |
| optimism    |     O    |         O        |              O             |               O              |
| sui         |     O    |         O        |              O             |               O              |
| aptos       |     O    |         O        |              O             |               O              |
| ton         |     O    |         O        |              O             |               O              |
| mantle      |     O    |         O        |              O             |               O              |
| manta       |     O    |         O        |              O             |               O              |
| linea       |     O    |         O        |              O             |               O              |
| zksync-era  |     O    |         O        |              O             |               O              |
| blast       |     O    |         O        |              O             |               O              |
| scroll      |     O    |         O        |              O             |               O              |
| starknet    |     O    |         O        |              O             |               O              |
| fantom      |     O    |         O        |              O             |               O              |
| hyperliquid |     O    |         O        |              O             |               O              |
| cronos      |     O    |         O        |              O             |               O              |
| near        |     O    |         O        |              O             |               O              |
| cardano     |     O    |         O        |              O             |               O              |
| berachain   |     O    |         O        |              O             |               O              |
| sonic       |     O    |         O        |              O             |               O              |
| sei         |     O    |         O        |              O             |               O              |

Chain slug-to-API-name mapping is loaded dynamically from `/v2/chains`, with hardcoded fallback for offline use.

## 3. Coverage Summary

| Source     | Chains | Data Types | Total Combinations | Granularity |
| ---------- | ------ | ---------- | ------------------ | ----------- |
| RPC Direct | 16     | up to 9    | \~62               | 1h          |
| DeFiLlama  | 27     | 4          | 108                | 1d          |
| **Total**  |        |            | **\~170**          |             |

### Tradeable Chains (Binance Futures)

| DeFiLlama Chain | Symbol | RPC Data                                                                         | Status |
| --------------- | ------ | -------------------------------------------------------------------------------- | ------ |
| ethereum        | ETH    | gas, defi\_rates, stablecoin\_supply, exchange\_flow, whale\_transfers           | O      |
| bsc             | BNB    | gas, defi\_rates                                                                 | O      |
| solana          | SOL    | fees, network                                                                    | O      |
| arbitrum        | ARB    | gas, defi\_rates, dex\_pools, market\_reserves, exchange\_flow, whale\_transfers | O      |
| avalanche       | AVAX   | gas, defi\_rates                                                                 | O      |
| polygon         | POL    | gas, defi\_rates                                                                 | O      |
| optimism        | OP     | gas, defi\_rates                                                                 | O      |
| sui             | SUI    | gas, network                                                                     | O      |
| aptos           | APT    | gas, network                                                                     | O      |
| ton             | TON    | gas, network                                                                     | O      |
| tron            | TRX    | energy, network                                                                  | O      |
| cosmos          | ATOM   | network, staking                                                                 | O      |
| manta           | MANTA  | -                                                                                | O      |
| starknet        | STRK   | -                                                                                | O      |
| linea           | LINEA  | -                                                                                | O      |
| zksync-era      | ZK     | gas                                                                              | O      |
| cardano         | ADA    | -                                                                                | O      |

## RPC Configuration

EVM chains use **Alchemy archive nodes** by default for exchange flow and whale transfer data (requires archive access). Each chain reads its RPC URL from an environment variable, with public fallback for non-archive data:

```bash theme={null}
# Alchemy (recommended for exchange_flow + whale_transfers)
export ETHEREUM_RPC_URL="https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"
export ARBITRUM_RPC_URL="https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY"
export BASE_RPC_URL="https://base-mainnet.g.alchemy.com/v2/YOUR_KEY"

# Non-EVM chains use native RPCs
export SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"
export BITCOIN_RPC_URL="https://mempool.space/api"
```

Clients sharing the same Alchemy API key automatically share a rate limiter (330 CU/sec) to prevent throttling.

## Using Onchain Data in Alphas

Onchain metrics flow into the graph as FIELD inputs, just like OHLCV data:

```python theme={null}
from clyptq.apps.trading.operators import AlphaOperator
from clyptq.system.graph import Input

class TVLMomentumAlpha(AlphaOperator):
    """Alpha based on chain TVL momentum."""

    def __init__(self, tvl_input: Input, close_input: Input, window: int = 14):
        super().__init__(inputs=[tvl_input, close_input])
        self._window = window
        self._validate_lookback()

    def compute_signal(self, data):
        tvl = data[0].value    # (T, N) — daily TVL per chain
        close = data[1].value  # (T, N) — price data
        tvl_change = self._delta(tvl, self._window) / self._delay(tvl, self._window)
        return self._rank(tvl_change)
```

## Related Pages

* [Data Sources Overview](/data/overview) — All supported data types
* [FRED Macro Data](/data/fred) — Federal Reserve economic indicators
* [AlphaOperator DSL](/operators/signals/alpha-operator) — Using onchain data in alpha formulas
