chainq 0.11.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. chainq-0.11.0/.env.example +5 -0
  2. chainq-0.11.0/.github/workflows/ci.yml +18 -0
  3. chainq-0.11.0/.github/workflows/release.yml +81 -0
  4. chainq-0.11.0/.gitignore +8 -0
  5. chainq-0.11.0/AGENTS.md +32 -0
  6. chainq-0.11.0/CLAUDE.md +1 -0
  7. chainq-0.11.0/LICENSE +21 -0
  8. chainq-0.11.0/PKG-INFO +241 -0
  9. chainq-0.11.0/README.md +216 -0
  10. chainq-0.11.0/ROADMAP.md +45 -0
  11. chainq-0.11.0/chainq/__init__.py +6 -0
  12. chainq-0.11.0/chainq/cache.py +42 -0
  13. chainq-0.11.0/chainq/cli.py +50 -0
  14. chainq-0.11.0/chainq/commands/__init__.py +0 -0
  15. chainq-0.11.0/chainq/commands/aave.py +97 -0
  16. chainq-0.11.0/chainq/commands/chain.py +239 -0
  17. chainq-0.11.0/chainq/commands/config.py +105 -0
  18. chainq-0.11.0/chainq/commands/ethena.py +40 -0
  19. chainq-0.11.0/chainq/commands/hl.py +368 -0
  20. chainq-0.11.0/chainq/commands/lighter.py +169 -0
  21. chainq-0.11.0/chainq/commands/llama.py +80 -0
  22. chainq-0.11.0/chainq/commands/market.py +257 -0
  23. chainq-0.11.0/chainq/commands/morpho.py +125 -0
  24. chainq-0.11.0/chainq/commands/nft.py +178 -0
  25. chainq-0.11.0/chainq/commands/pendle.py +84 -0
  26. chainq-0.11.0/chainq/commands/portfolio.py +119 -0
  27. chainq-0.11.0/chainq/commands/protocols.py +17 -0
  28. chainq-0.11.0/chainq/commands/sky.py +34 -0
  29. chainq-0.11.0/chainq/commands/stables.py +67 -0
  30. chainq-0.11.0/chainq/commands/uniswap.py +361 -0
  31. chainq-0.11.0/chainq/config.py +24 -0
  32. chainq-0.11.0/chainq/errors.py +2 -0
  33. chainq-0.11.0/chainq/fmt.py +50 -0
  34. chainq-0.11.0/chainq/http.py +32 -0
  35. chainq-0.11.0/chainq/networks.py +307 -0
  36. chainq-0.11.0/chainq/output.py +158 -0
  37. chainq-0.11.0/chainq/providers/__init__.py +0 -0
  38. chainq-0.11.0/chainq/providers/aave.py +50 -0
  39. chainq-0.11.0/chainq/providers/coingecko.py +189 -0
  40. chainq-0.11.0/chainq/providers/defillama.py +137 -0
  41. chainq-0.11.0/chainq/providers/ethena.py +35 -0
  42. chainq-0.11.0/chainq/providers/hyperliquid.py +102 -0
  43. chainq-0.11.0/chainq/providers/lighter.py +60 -0
  44. chainq-0.11.0/chainq/providers/morpho.py +69 -0
  45. chainq-0.11.0/chainq/providers/opensea.py +56 -0
  46. chainq-0.11.0/chainq/providers/pendle.py +25 -0
  47. chainq-0.11.0/chainq/providers/sky.py +28 -0
  48. chainq-0.11.0/chainq/providers/uniswap.py +258 -0
  49. chainq-0.11.0/chainq/rpc.py +96 -0
  50. chainq-0.11.0/chainq/tokens.py +85 -0
  51. chainq-0.11.0/chainq/update.py +128 -0
  52. chainq-0.11.0/install.sh +73 -0
  53. chainq-0.11.0/npm/README.md +19 -0
  54. chainq-0.11.0/npm/bin/chainq.js +17 -0
  55. chainq-0.11.0/npm/package.json +30 -0
  56. chainq-0.11.0/pyproject.toml +55 -0
  57. chainq-0.11.0/scripts/chainq.rb.tmpl +21 -0
  58. chainq-0.11.0/scripts/update_tap_formula.py +21 -0
  59. chainq-0.11.0/skills/chainq/SKILL.md +158 -0
  60. chainq-0.11.0/tests/test_cache.py +32 -0
  61. chainq-0.11.0/tests/test_config_cmd.py +39 -0
  62. chainq-0.11.0/tests/test_fmt.py +37 -0
  63. chainq-0.11.0/tests/test_networks.py +29 -0
  64. chainq-0.11.0/tests/test_output.py +55 -0
  65. chainq-0.11.0/tests/test_tokens.py +30 -0
  66. chainq-0.11.0/tests/test_update.py +12 -0
  67. chainq-0.11.0/uv.lock +1581 -0
@@ -0,0 +1,5 @@
1
+ CHAINQ_COINGECKO_API_KEY=
2
+ CHAINQ_OPENSEA_API_KEY=
3
+ CHAINQ_HTTP_TIMEOUT=10
4
+ CHAINQ_RPC_TIMEOUT=6
5
+ CHAINQ_RPC_ETHEREUM=
@@ -0,0 +1,18 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: astral-sh/setup-uv@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: uv sync --dev
17
+ - run: uv run ruff check .
18
+ - run: uv run pytest -q
@@ -0,0 +1,81 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: astral-sh/setup-uv@v5
13
+ with:
14
+ python-version: "3.12"
15
+ - run: uv sync --dev
16
+ - run: uv run ruff check .
17
+ - run: uv run pytest -q
18
+
19
+ publish:
20
+ needs: test
21
+ runs-on: ubuntu-latest
22
+ environment: pypi
23
+ permissions:
24
+ id-token: write
25
+ contents: write
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: astral-sh/setup-uv@v5
29
+ with:
30
+ python-version: "3.12"
31
+ - run: uv build
32
+ - uses: pypa/gh-action-pypi-publish@release/v1
33
+ - uses: softprops/action-gh-release@v2
34
+ with:
35
+ files: dist/*
36
+ generate_release_notes: true
37
+
38
+ npm:
39
+ needs: publish
40
+ runs-on: ubuntu-latest
41
+ permissions:
42
+ id-token: write
43
+ steps:
44
+ - uses: actions/checkout@v4
45
+ - uses: actions/setup-node@v4
46
+ with:
47
+ node-version: 22
48
+ registry-url: https://registry.npmjs.org
49
+ - run: npm install -g npm@latest
50
+ - run: npm version --no-git-tag-version --allow-same-version "${GITHUB_REF_NAME#v}"
51
+ working-directory: npm
52
+ - run: npm publish
53
+ working-directory: npm
54
+
55
+ homebrew:
56
+ needs: publish
57
+ runs-on: ubuntu-latest
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+ - name: Wait for PyPI to serve the release
61
+ run: |
62
+ VERSION="${GITHUB_REF_NAME#v}"
63
+ for _ in $(seq 1 30); do
64
+ curl -fsS "https://pypi.org/pypi/chainq/$VERSION/json" >/dev/null && exit 0
65
+ sleep 10
66
+ done
67
+ echo "PyPI never served chainq $VERSION" >&2
68
+ exit 1
69
+ - name: Bump tap formula
70
+ env:
71
+ TAP_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
72
+ run: |
73
+ VERSION="${GITHUB_REF_NAME#v}"
74
+ git clone "https://x-access-token:${TAP_TOKEN}@github.com/Sergio-prog/homebrew-tap.git" tap
75
+ python3 scripts/update_tap_formula.py "$VERSION" tap/Formula/chainq.rb
76
+ cd tap
77
+ git config user.name "github-actions[bot]"
78
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
79
+ git add Formula/chainq.rb
80
+ git commit -m "chainq $VERSION"
81
+ git push
@@ -0,0 +1,8 @@
1
+ .env
2
+ .venv/
3
+ __pycache__/
4
+ .ruff_cache/
5
+ .pytest_cache/
6
+ dist/
7
+ *.egg-info/
8
+ .DS_Store
@@ -0,0 +1,32 @@
1
+ # AGENTS.md
2
+
3
+ chainq is an agent-first CLI for onchain and crypto market data. Python 3.12+, uv, Typer, httpx, web3.py. Vision and priorities live in [ROADMAP.md](ROADMAP.md) — keep it in sync when shipping features.
4
+
5
+ ## Rules
6
+
7
+ - No code comments; code must be self-explanatory.
8
+ - Conventional commits, branches, and PR titles. Never commit, push, or open a PR without the owner's explicit ask.
9
+ - Before any commit: `uv run ruff check .` and `uv run pytest -q` must pass.
10
+ - Live-test every new or changed command against real endpoints (`uv run chainq ...`) — unit tests deliberately don't mock providers.
11
+ - Version is defined only in `pyproject.toml` (read at runtime via importlib.metadata). Bump semver on user-visible changes.
12
+ - `.env` holds real keys and is gitignored; never commit it, never print its values.
13
+ - Data sources, in order of preference: the protocol's official API (Aave GraphQL, Pendle, Hyperliquid/Lighter info APIs) → onchain helper/periphery contracts (most protocols deploy them — e.g. Uniswap v3 factory/pool, Aave UiPoolDataProvider) → third-party indexers (DexScreener, DefiLlama) only for discovery/ranking that the first two can't do. Verify new RPC endpoints and API shapes live before shipping (`eth_chainId`, sample responses) — do not trust remembered addresses or schemas.
14
+
15
+ ## Output contract (do not break)
16
+
17
+ - Every query command supports `--json`, `-q`, `-v`, and `--format text|json|table|toon`; default text is one human-readable line per result.
18
+ - Errors go to stderr with exit code 1; stdout stays clean for parsing.
19
+ - A new command ships with: the contract flags above, an entry in `skills/chainq/SKILL.md`, and a README example.
20
+
21
+ ## Architecture
22
+
23
+ - `chainq/cli.py` registers commands; `chainq/commands/*` are thin Typer layers; protocol commands (aave, hl) mount under the `protocols` group.
24
+ - `chainq/providers/*` are HTTP clients (CoinGecko, Hyperliquid, Aave GraphQL) using `chainq/cache.py` (TTL 30–300s, `~/.cache/chainq/`).
25
+ - `chainq/networks.py` and `chainq/tokens.py` are curated registries (checksummed addresses — tests enforce); `chainq/rpc.py` wraps web3 with RPC fallback; `chainq/output.py` owns all formatting.
26
+ - `chainq/update.py` — self-update + once-daily version reminder (disable via `CHAINQ_NO_UPDATE_CHECK`).
27
+
28
+ ## Important files
29
+
30
+ - `ROADMAP.md` — vision, shipped versions, what to build next.
31
+ - `skills/chainq/SKILL.md` — the agent skill, primary distribution channel; update on any command change.
32
+ - `install.sh` — public installer (uv/pipx from git; switch to PyPI after publishing).
@@ -0,0 +1 @@
1
+ @AGENTS.md
chainq-0.11.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sergio-prog
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
chainq-0.11.0/PKG-INFO ADDED
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: chainq
3
+ Version: 0.11.0
4
+ Summary: Agent-friendly CLI for onchain and crypto market data: balances, gas, transactions, raw RPC, asset prices, Aave, Hyperliquid.
5
+ Project-URL: Repository, https://github.com/Sergio-prog/chainq
6
+ Project-URL: Issues, https://github.com/Sergio-prog/chainq/issues
7
+ Project-URL: Roadmap, https://github.com/Sergio-prog/chainq/blob/main/ROADMAP.md
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,blockchain,cli,crypto,defi,ethereum,onchain,web3
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Office/Business :: Financial
18
+ Classifier: Topic :: Utilities
19
+ Requires-Python: >=3.12
20
+ Requires-Dist: httpx>=0.27
21
+ Requires-Dist: pydantic-settings>=2.6
22
+ Requires-Dist: typer>=0.12
23
+ Requires-Dist: web3>=7.6
24
+ Description-Content-Type: text/markdown
25
+
26
+ # chainq
27
+
28
+ **One CLI for the crypto world — built for AI agents, pleasant for humans.**
29
+
30
+ Query asset prices, wallet balances, gas, transactions, raw EVM RPC, Aave markets, and Hyperliquid perps from a single tool. Zero setup: curated public RPC endpoints with automatic fallback are built in, and no command below needs an API key.
31
+
32
+ ```console
33
+ $ chainq price eth btc hype
34
+ ETH (Ethereum): $1,691.88 24h +4.82% mcap $204.11B
35
+ BTC (Bitcoin): $61,302.00 24h +1.85% mcap $1.23T
36
+ HYPE (Hyperliquid): $65.79 24h +4.38% mcap $14.63B
37
+
38
+ $ chainq balance vitalik.eth
39
+ vitalik.eth (0xd8dA…6045) on Ethereum: 5.6955 ETH (~$9,635.87)
40
+
41
+ $ chainq protocols aave markets -n base --format table -l 3
42
+ network: base
43
+ market symbol supply_apy_pct borrow_apy_pct supplied_usd utilization_pct
44
+ ------ ------ -------------- -------------- -------------- ---------------
45
+ Base USDC 3.1684 4.2507 176,010,037.57 83.2569
46
+ Base WETH 1.5411 2.2608 160,504,459.31 80.4814
47
+ Base cbBTC 0.0149 0.7126 144,452,332.80 4.2015
48
+ ```
49
+
50
+ ## Why
51
+
52
+ Agents are terrible at juggling five different APIs, auth schemes, and SDKs — and great at running one predictable CLI. chainq gives every command three output modes:
53
+
54
+ | Mode | Flag | Output |
55
+ |---|---|---|
56
+ | human | *(default)* | one readable line per result |
57
+ | machine | `--json` | structured JSON for parsing |
58
+ | table | `--format table` | aligned columns for humans scanning lists |
59
+ | toon | `--format toon` | compact tabular text — fewer tokens than JSON for LLM contexts |
60
+ | pipe | `-q` | bare primary value only |
61
+
62
+ Plus `-v` for provenance (RPC endpoint used, data source, explorer links). Errors go to stderr with exit code 1. Responses are cached briefly (30–60s) so repeated queries stay fast and under rate limits.
63
+
64
+ ## Install
65
+
66
+ One-liner:
67
+
68
+ ```bash
69
+ curl -LsSf https://raw.githubusercontent.com/Sergio-prog/chainq/main/install.sh | sh
70
+ ```
71
+
72
+ Homebrew:
73
+
74
+ ```bash
75
+ brew install sergio-prog/tap/chainq
76
+ ```
77
+
78
+ No install at all — via npx (needs [uv](https://docs.astral.sh/uv/) or pipx on PATH):
79
+
80
+ ```bash
81
+ npx chainq price eth btc
82
+ ```
83
+
84
+ Or directly with uv / pipx:
85
+
86
+ ```bash
87
+ uv tool install chainq
88
+ pipx install chainq
89
+ ```
90
+
91
+ From source:
92
+
93
+ ```bash
94
+ git clone https://github.com/Sergio-prog/chainq && cd chainq
95
+ uv tool install .
96
+ ```
97
+
98
+ Requires Python 3.12+ (the install script bootstraps uv, which handles that for you). Update any time with `chainq update` — chainq also checks for new versions once a day and prints a reminder, homebrew/pnpm style. Shell tab-completion: `chainq --install-completion`.
99
+
100
+ ## Commands
101
+
102
+ ### Market data (CoinGecko)
103
+
104
+ ```bash
105
+ chainq price eth btc sol # spot price, 24h change, market cap
106
+ chainq price 0xTokenAddress # any token by contract address (DexScreener fallback for long-tail)
107
+ chainq trending # trending assets right now
108
+ chainq stables # stablecoins by mcap: peg price, supply changes, mechanism
109
+ chainq asset ethena # full profile: price, mcap/FDV, supply, ATH, links
110
+ chainq search "sky protocol" # resolve fuzzy names to asset ids
111
+ ```
112
+
113
+ ### Onchain (EVM)
114
+
115
+ ```bash
116
+ chainq networks # supported networks and aliases
117
+ chainq balance vitalik.eth # native balance, ENS supported
118
+ chainq balance 0x... --coin usdt -n arbitrum # ERC-20 by symbol or contract address
119
+ chainq portfolio vitalik.eth # all networks: native + known tokens, USD total
120
+ chainq gas -n base # gas price, base fee, transfer cost in USD
121
+ chainq tx 0xHASH -n ethereum # status, parties, value, fee, block
122
+ chainq rpc eth_blockNumber -n optimism # raw JSON-RPC escape hatch
123
+ ```
124
+
125
+ 25 networks: **ethereum, arbitrum, base, optimism, polygon, bsc, avalanche, gnosis, unichain, linea, scroll, zksync, mantle, blast, sonic, berachain, worldchain, ink, soneium, celo, sei, hyperevm, monad, plasma, katana** — by key, alias (`eth`, `arb`, `op`, ...), or chain id. Multiple public RPCs per network are tried in order; override with `CHAINQ_RPC_<NETWORK>`.
126
+
127
+ ### Protocols
128
+
129
+ Aave v3:
130
+
131
+ ```bash
132
+ chainq protocols aave markets -n ethereum # reserves: supply/borrow APY, size, utilization
133
+ chainq protocols aave markets -c usdc -n base # one asset across markets
134
+ chainq protocols aave markets -s borrow-apy # sort: supplied | supply-apy | borrow-apy | utilization
135
+ ```
136
+
137
+ Uniswap and Pendle:
138
+
139
+ ```bash
140
+ chainq protocols uniswap pool weth usdc # onchain pool state: v2+v3+v4, price + reserves per fee tier
141
+ chainq protocols uniswap pool eth usdc -V v4 # native-currency v4 pools; -V v2|v3|v4|all
142
+ chainq protocols uniswap pool 0xPoolAddress # one pool by address, v2/v3 auto-detected
143
+ chainq protocols uniswap pools "weth usdc" # pool discovery: price, 24h volume, liquidity, v2/v3/v4
144
+ chainq protocols uniswap stats # protocol TVL + volumes
145
+ chainq protocols pendle markets -s implied-apy # yield markets: implied APY, LP APY, expiry
146
+ ```
147
+
148
+ Sky and Ethena:
149
+
150
+ ```bash
151
+ chainq protocols sky rate # Sky Savings Rate (sUSDS) + legacy DSR, onchain
152
+ chainq protocols ethena yield # sUSDe APY, protocol yield, USDe supply/peg
153
+ ```
154
+
155
+ Hyperliquid (public data, incl. HIP-3 builder dexs and HIP-4 outcome markets):
156
+
157
+ ```bash
158
+ chainq protocols hl price BTC ETH # perps: mark price, 24h change, volume, OI, funding
159
+ chainq protocols hl markets -s oi # top perp markets by volume | oi | funding | change
160
+ chainq protocols hl funding # most extreme funding rates (hourly + APR)
161
+ chainq protocols hl positions 0xADDRESS # perp account: value, margin, positions with PnL
162
+ chainq protocols hl dexs # HIP-3 builder-deployed perp dexs
163
+ chainq protocols hl markets --dex xyz # markets on a builder dex (tokenized stocks etc.)
164
+ chainq protocols hl outcomes "world cup" # HIP-4 prediction markets with live Yes/No prices
165
+ chainq protocols hl spot price HYPE # spot pairs: price, 24h change, volume, mcap
166
+ chainq protocols hl spot markets # top spot markets by volume
167
+ chainq protocols hl spot balances 0xADDRESS # spot token balances with USD values
168
+ ```
169
+
170
+ Morpho and DefiLlama:
171
+
172
+ ```bash
173
+ chainq protocols morpho markets -c usdc -n base # Morpho lending markets: APYs, lltv, utilization
174
+ chainq protocols morpho vaults -c usdc # Morpho vaults: APY, TVL
175
+ chainq protocols llama protocol lido # any protocol's TVL/fees/volume via DefiLlama
176
+ chainq protocols llama top -c Lending # top protocols by TVL
177
+ chainq protocols llama chains # chains ranked by DeFi TVL
178
+ ```
179
+
180
+ NFTs (OpenSea):
181
+
182
+ ```bash
183
+ chainq nft floor pudgypenguins azuki # floor price (native + USD), 24h volume, owners
184
+ chainq nft collection pudgypenguins # profile: floor, supply, volumes, contract, links
185
+ chainq nft top -s volume # top collections (requires OpenSea API key)
186
+ ```
187
+
188
+ Lighter (public data):
189
+
190
+ ```bash
191
+ chainq protocols lighter markets -s oi # perp markets: last price, volume, OI, funding
192
+ chainq protocols lighter price BTC ETH # single markets
193
+ chainq protocols lighter funding # funding rates (hourly + APR)
194
+ chainq protocols lighter positions 0xADDRESS # account value, collateral, open positions
195
+ ```
196
+
197
+ ## Configuration
198
+
199
+ Everything works without configuration. To persist settings, use `chainq config`:
200
+
201
+ ```bash
202
+ chainq config set coingecko-api-key CG-xxxx
203
+ chainq config set chainq-rpc-ethereum https://my-node.example.com
204
+ chainq config list # secrets masked; --show-secrets to reveal
205
+ ```
206
+
207
+ Values live in `~/.config/chainq/.env`; plain env vars and a `.env` in cwd work too:
208
+
209
+ | Variable | Purpose |
210
+ |---|---|
211
+ | `COINGECKO_API_KEY` | raises CoinGecko rate limits (free demo key works) |
212
+ | `CHAINQ_RPC_<NETWORK>` | custom RPC endpoint, tried first (e.g. `CHAINQ_RPC_ETHEREUM`) |
213
+ | `CHAINQ_HTTP_TIMEOUT` / `CHAINQ_RPC_TIMEOUT` | timeouts in seconds |
214
+ | `CHAINQ_NO_UPDATE_CHECK` | disable the daily update check |
215
+ | `OPENSEA_API_KEY` | unlocks `nft top` and long-tail collection slugs |
216
+
217
+ ## For AI agents
218
+
219
+ chainq ships a [skill](skills/chainq/SKILL.md) that teaches agents when and how to use it:
220
+
221
+ ```bash
222
+ npx skills add Sergio-prog/chainq
223
+ ```
224
+
225
+ No skill installed? Agents can self-discover everything via `chainq -h` and `chainq <command> -h`.
226
+
227
+ ## Roadmap
228
+
229
+ NFT floors, Uniswap pools, stablecoin protocols (Sky, Ethena), portfolio sweep, Solana, and more — see [ROADMAP.md](ROADMAP.md).
230
+
231
+ ## Development
232
+
233
+ ```bash
234
+ uv sync
235
+ uv run pytest
236
+ uv run ruff check .
237
+ ```
238
+
239
+ ## License
240
+
241
+ [MIT](LICENSE)
@@ -0,0 +1,216 @@
1
+ # chainq
2
+
3
+ **One CLI for the crypto world — built for AI agents, pleasant for humans.**
4
+
5
+ Query asset prices, wallet balances, gas, transactions, raw EVM RPC, Aave markets, and Hyperliquid perps from a single tool. Zero setup: curated public RPC endpoints with automatic fallback are built in, and no command below needs an API key.
6
+
7
+ ```console
8
+ $ chainq price eth btc hype
9
+ ETH (Ethereum): $1,691.88 24h +4.82% mcap $204.11B
10
+ BTC (Bitcoin): $61,302.00 24h +1.85% mcap $1.23T
11
+ HYPE (Hyperliquid): $65.79 24h +4.38% mcap $14.63B
12
+
13
+ $ chainq balance vitalik.eth
14
+ vitalik.eth (0xd8dA…6045) on Ethereum: 5.6955 ETH (~$9,635.87)
15
+
16
+ $ chainq protocols aave markets -n base --format table -l 3
17
+ network: base
18
+ market symbol supply_apy_pct borrow_apy_pct supplied_usd utilization_pct
19
+ ------ ------ -------------- -------------- -------------- ---------------
20
+ Base USDC 3.1684 4.2507 176,010,037.57 83.2569
21
+ Base WETH 1.5411 2.2608 160,504,459.31 80.4814
22
+ Base cbBTC 0.0149 0.7126 144,452,332.80 4.2015
23
+ ```
24
+
25
+ ## Why
26
+
27
+ Agents are terrible at juggling five different APIs, auth schemes, and SDKs — and great at running one predictable CLI. chainq gives every command three output modes:
28
+
29
+ | Mode | Flag | Output |
30
+ |---|---|---|
31
+ | human | *(default)* | one readable line per result |
32
+ | machine | `--json` | structured JSON for parsing |
33
+ | table | `--format table` | aligned columns for humans scanning lists |
34
+ | toon | `--format toon` | compact tabular text — fewer tokens than JSON for LLM contexts |
35
+ | pipe | `-q` | bare primary value only |
36
+
37
+ Plus `-v` for provenance (RPC endpoint used, data source, explorer links). Errors go to stderr with exit code 1. Responses are cached briefly (30–60s) so repeated queries stay fast and under rate limits.
38
+
39
+ ## Install
40
+
41
+ One-liner:
42
+
43
+ ```bash
44
+ curl -LsSf https://raw.githubusercontent.com/Sergio-prog/chainq/main/install.sh | sh
45
+ ```
46
+
47
+ Homebrew:
48
+
49
+ ```bash
50
+ brew install sergio-prog/tap/chainq
51
+ ```
52
+
53
+ No install at all — via npx (needs [uv](https://docs.astral.sh/uv/) or pipx on PATH):
54
+
55
+ ```bash
56
+ npx chainq price eth btc
57
+ ```
58
+
59
+ Or directly with uv / pipx:
60
+
61
+ ```bash
62
+ uv tool install chainq
63
+ pipx install chainq
64
+ ```
65
+
66
+ From source:
67
+
68
+ ```bash
69
+ git clone https://github.com/Sergio-prog/chainq && cd chainq
70
+ uv tool install .
71
+ ```
72
+
73
+ Requires Python 3.12+ (the install script bootstraps uv, which handles that for you). Update any time with `chainq update` — chainq also checks for new versions once a day and prints a reminder, homebrew/pnpm style. Shell tab-completion: `chainq --install-completion`.
74
+
75
+ ## Commands
76
+
77
+ ### Market data (CoinGecko)
78
+
79
+ ```bash
80
+ chainq price eth btc sol # spot price, 24h change, market cap
81
+ chainq price 0xTokenAddress # any token by contract address (DexScreener fallback for long-tail)
82
+ chainq trending # trending assets right now
83
+ chainq stables # stablecoins by mcap: peg price, supply changes, mechanism
84
+ chainq asset ethena # full profile: price, mcap/FDV, supply, ATH, links
85
+ chainq search "sky protocol" # resolve fuzzy names to asset ids
86
+ ```
87
+
88
+ ### Onchain (EVM)
89
+
90
+ ```bash
91
+ chainq networks # supported networks and aliases
92
+ chainq balance vitalik.eth # native balance, ENS supported
93
+ chainq balance 0x... --coin usdt -n arbitrum # ERC-20 by symbol or contract address
94
+ chainq portfolio vitalik.eth # all networks: native + known tokens, USD total
95
+ chainq gas -n base # gas price, base fee, transfer cost in USD
96
+ chainq tx 0xHASH -n ethereum # status, parties, value, fee, block
97
+ chainq rpc eth_blockNumber -n optimism # raw JSON-RPC escape hatch
98
+ ```
99
+
100
+ 25 networks: **ethereum, arbitrum, base, optimism, polygon, bsc, avalanche, gnosis, unichain, linea, scroll, zksync, mantle, blast, sonic, berachain, worldchain, ink, soneium, celo, sei, hyperevm, monad, plasma, katana** — by key, alias (`eth`, `arb`, `op`, ...), or chain id. Multiple public RPCs per network are tried in order; override with `CHAINQ_RPC_<NETWORK>`.
101
+
102
+ ### Protocols
103
+
104
+ Aave v3:
105
+
106
+ ```bash
107
+ chainq protocols aave markets -n ethereum # reserves: supply/borrow APY, size, utilization
108
+ chainq protocols aave markets -c usdc -n base # one asset across markets
109
+ chainq protocols aave markets -s borrow-apy # sort: supplied | supply-apy | borrow-apy | utilization
110
+ ```
111
+
112
+ Uniswap and Pendle:
113
+
114
+ ```bash
115
+ chainq protocols uniswap pool weth usdc # onchain pool state: v2+v3+v4, price + reserves per fee tier
116
+ chainq protocols uniswap pool eth usdc -V v4 # native-currency v4 pools; -V v2|v3|v4|all
117
+ chainq protocols uniswap pool 0xPoolAddress # one pool by address, v2/v3 auto-detected
118
+ chainq protocols uniswap pools "weth usdc" # pool discovery: price, 24h volume, liquidity, v2/v3/v4
119
+ chainq protocols uniswap stats # protocol TVL + volumes
120
+ chainq protocols pendle markets -s implied-apy # yield markets: implied APY, LP APY, expiry
121
+ ```
122
+
123
+ Sky and Ethena:
124
+
125
+ ```bash
126
+ chainq protocols sky rate # Sky Savings Rate (sUSDS) + legacy DSR, onchain
127
+ chainq protocols ethena yield # sUSDe APY, protocol yield, USDe supply/peg
128
+ ```
129
+
130
+ Hyperliquid (public data, incl. HIP-3 builder dexs and HIP-4 outcome markets):
131
+
132
+ ```bash
133
+ chainq protocols hl price BTC ETH # perps: mark price, 24h change, volume, OI, funding
134
+ chainq protocols hl markets -s oi # top perp markets by volume | oi | funding | change
135
+ chainq protocols hl funding # most extreme funding rates (hourly + APR)
136
+ chainq protocols hl positions 0xADDRESS # perp account: value, margin, positions with PnL
137
+ chainq protocols hl dexs # HIP-3 builder-deployed perp dexs
138
+ chainq protocols hl markets --dex xyz # markets on a builder dex (tokenized stocks etc.)
139
+ chainq protocols hl outcomes "world cup" # HIP-4 prediction markets with live Yes/No prices
140
+ chainq protocols hl spot price HYPE # spot pairs: price, 24h change, volume, mcap
141
+ chainq protocols hl spot markets # top spot markets by volume
142
+ chainq protocols hl spot balances 0xADDRESS # spot token balances with USD values
143
+ ```
144
+
145
+ Morpho and DefiLlama:
146
+
147
+ ```bash
148
+ chainq protocols morpho markets -c usdc -n base # Morpho lending markets: APYs, lltv, utilization
149
+ chainq protocols morpho vaults -c usdc # Morpho vaults: APY, TVL
150
+ chainq protocols llama protocol lido # any protocol's TVL/fees/volume via DefiLlama
151
+ chainq protocols llama top -c Lending # top protocols by TVL
152
+ chainq protocols llama chains # chains ranked by DeFi TVL
153
+ ```
154
+
155
+ NFTs (OpenSea):
156
+
157
+ ```bash
158
+ chainq nft floor pudgypenguins azuki # floor price (native + USD), 24h volume, owners
159
+ chainq nft collection pudgypenguins # profile: floor, supply, volumes, contract, links
160
+ chainq nft top -s volume # top collections (requires OpenSea API key)
161
+ ```
162
+
163
+ Lighter (public data):
164
+
165
+ ```bash
166
+ chainq protocols lighter markets -s oi # perp markets: last price, volume, OI, funding
167
+ chainq protocols lighter price BTC ETH # single markets
168
+ chainq protocols lighter funding # funding rates (hourly + APR)
169
+ chainq protocols lighter positions 0xADDRESS # account value, collateral, open positions
170
+ ```
171
+
172
+ ## Configuration
173
+
174
+ Everything works without configuration. To persist settings, use `chainq config`:
175
+
176
+ ```bash
177
+ chainq config set coingecko-api-key CG-xxxx
178
+ chainq config set chainq-rpc-ethereum https://my-node.example.com
179
+ chainq config list # secrets masked; --show-secrets to reveal
180
+ ```
181
+
182
+ Values live in `~/.config/chainq/.env`; plain env vars and a `.env` in cwd work too:
183
+
184
+ | Variable | Purpose |
185
+ |---|---|
186
+ | `COINGECKO_API_KEY` | raises CoinGecko rate limits (free demo key works) |
187
+ | `CHAINQ_RPC_<NETWORK>` | custom RPC endpoint, tried first (e.g. `CHAINQ_RPC_ETHEREUM`) |
188
+ | `CHAINQ_HTTP_TIMEOUT` / `CHAINQ_RPC_TIMEOUT` | timeouts in seconds |
189
+ | `CHAINQ_NO_UPDATE_CHECK` | disable the daily update check |
190
+ | `OPENSEA_API_KEY` | unlocks `nft top` and long-tail collection slugs |
191
+
192
+ ## For AI agents
193
+
194
+ chainq ships a [skill](skills/chainq/SKILL.md) that teaches agents when and how to use it:
195
+
196
+ ```bash
197
+ npx skills add Sergio-prog/chainq
198
+ ```
199
+
200
+ No skill installed? Agents can self-discover everything via `chainq -h` and `chainq <command> -h`.
201
+
202
+ ## Roadmap
203
+
204
+ NFT floors, Uniswap pools, stablecoin protocols (Sky, Ethena), portfolio sweep, Solana, and more — see [ROADMAP.md](ROADMAP.md).
205
+
206
+ ## Development
207
+
208
+ ```bash
209
+ uv sync
210
+ uv run pytest
211
+ uv run ruff check .
212
+ ```
213
+
214
+ ## License
215
+
216
+ [MIT](LICENSE)
@@ -0,0 +1,45 @@
1
+ # Roadmap
2
+
3
+ ## Vision
4
+
5
+ Software for agents, not just people. chainq is one universal CLI where any agent (or human) can query the crypto world: RPC state on popular networks with good predefined endpoints, asset prices and metadata, and aggregated data from major protocols — with zero setup, one-line human output, and `--json` everywhere. Distribution is skill-first: a Claude Code skill instead of an MCP server, because a CLI is self-documenting, composable, costs no context until used, and works in any agent with a shell.
6
+
7
+ ## Shipped
8
+
9
+ - **v0.1** — 9 EVM networks with curated fallback RPCs; `balance` (native + ERC-20, ENS), `gas`, `tx`, raw `rpc`; CoinGecko `price`/`asset`/`search`; Hyperliquid perps (`hl price/markets/funding/positions`); `--json` / `-q` / `-v` output contract; agent skill.
10
+ - **v0.2** — Aave v3 markets (official GraphQL API); TTL cache; `chainq update` + daily new-version reminder; `install.sh`.
11
+ - **v0.3** — `protocols` command group (aave, hl); Hyperliquid spot (prices, markets, balances); `trending`; `--format table|toon` output formats; AGENTS.md; banner installer.
12
+ - **v0.4** — Uniswap (pools via DexScreener, protocol stats via DefiLlama) and Pendle (active markets, implied/LP APY) under `protocols`.
13
+ - **v0.5** — 25 networks (added linea, scroll, zksync, mantle, blast, sonic, berachain, worldchain, ink, soneium, celo, sei, hyperevm, monad, plasma, katana); onchain Uniswap v3 `pool` command (factory + slot0); Lighter perps (markets, price, funding, positions); Hyperliquid HIP-3 builder dexs (`hl dexs`, `--dex`) and HIP-4 outcome markets (`hl outcomes`); skill install via `npx skills add`.
14
+ - **v0.6** — onchain Uniswap `pool` covers v2 + v3 + v4 (v2 pairs via getReserves, v4 via StateView + computed poolId, native-currency support with `eth`).
15
+ - **v0.7** — address-based discovery: `price`/`asset` accept token contract addresses (DexScreener locates the chain → CoinGecko contract lookup → DexScreener price fallback for long-tail tokens); `uniswap pool` accepts a bare pool address with v2/v3 auto-detection.
16
+ - **v0.8** — Morpho (markets + vaults via official GraphQL API); DefiLlama adapter (`llama protocol/top/chains` for any protocol); `chainq config` command; HTTP retry with backoff on all providers; parallel RPC endpoint racing; shell completions.
17
+ - **v0.9** — NFTs via OpenSea (`nft floor/collection/top`): floors with USD conversion, volumes, owners, supply; keyless for well-known collections, API key unlocks `top` and long-tail slugs.
18
+ - **v0.10** — stablecoins: `stables` overview (mcap ranking, peg price, supply changes via DefiLlama stablecoins API), `sky rate` (SSR + legacy DSR read onchain), `ethena yield` (sUSDe APY via official API, USDe supply/peg).
19
+ - **v0.11** — `portfolio`: parallel sweep of native + registry tokens across all 25 networks with one batched CoinGecko pricing call, sorted by USD value; `--min-usd` dust filter, `-n` repeatable network filter.
20
+
21
+ ## Next
22
+
23
+ - **Release channels** — tag-triggered release workflow publishes to PyPI (trusted publishing), npm (`npx chainq` launcher running the pinned Python CLI via uvx), and bumps the Homebrew formula in [Sergio-prog/homebrew-tap](https://github.com/Sergio-prog/homebrew-tap) (needs `TAP_GITHUB_TOKEN` secret). One-time owner setup: PyPI pending trusted publisher, first `npm publish`, tap PAT.
24
+ - **Historical data** — `candles <asset> --days 30` (CoinGecko OHLC), `price <asset> --at 2025-01-01`, Hyperliquid funding history (`fundingHistory` info endpoint). Agents constantly want "price N days ago" and can't get it today.
25
+ - **Portfolio depth** — fold Hyperliquid perp/spot balances (providers already exist) and Aave/Morpho supplied positions into `portfolio` behind a `--defi` flag; auto token lists per network from CoinGecko (top ~50 by mcap, cached daily) so the sweep catches far more than the curated registry.
26
+ - **Gas across all networks** — `gas --all`: one parallel sweep (reuse the portfolio executor) answering "where is it cheapest to transact right now".
27
+ - **Solana** — read-only first pass: SOL balance, SPL token accounts with USD values, prices already work via CoinGecko. Biggest missing chain; needs its own RPC pool (no web3.py).
28
+
29
+ ## Later
30
+
31
+ - Address intelligence: `chainq address 0x...` — contract vs EOA, deploy date, tx count, verified source, token/NFT holdings summary.
32
+ - Generic ERC-4626 inspector: `chainq vault 0xADDR -n base` — asset, share price, APY from share-price delta, TVL; covers thousands of yield vaults with zero per-protocol work.
33
+ - NFT: wallet holdings and collection-by-contract-address lookup (both need a valid OpenSea key), floor cross-check via a second marketplace.
34
+ - CEX spot prices via ccxt as a CoinGecko alternative/cross-check.
35
+ - More protocols: Lido/staking yields (stETH APR), Curve pools, bridge status.
36
+ - Watch/stream mode (`chainq gas --watch`) and threshold alerts (reuse PriceAlerts bot).
37
+ - Thin MCP wrapper over the CLI if demand appears from non-shell agents.
38
+
39
+ ## Engineering improvements
40
+
41
+ - Structured error output in `--json` mode (`{"error": ...}` on stdout) so agents can branch on failures without parsing stderr.
42
+ - Multicall3 batching for `portfolio` and `uniswap pool` — one `eth_call` per network instead of one per token/tier; Multicall3 is deployed at the same address on all 25 networks.
43
+ - Versioned CHANGELOG generated from conventional commits.
44
+ - Live smoke-test suite behind a pytest marker (`-m live`) exercising one command per provider, run on a weekly scheduled CI job to catch upstream API drift.
45
+ - Cross-platform check: Windows terminal output (the banner and `…` glyphs) and CI matrix entry.