Skip to content

feat(holders): add is_contract flag on /v1/evm/holders#534

Merged
0237h merged 1 commit into
mainfrom
feat/holders-is-contract
May 13, 2026
Merged

feat(holders): add is_contract flag on /v1/evm/holders#534
0237h merged 1 commit into
mainfrom
feat/holders-is-contract

Conversation

@0237h
Copy link
Copy Markdown
Collaborator

@0237h 0237h commented May 12, 2026

Summary

  • Adds is_contract: boolean to /v1/evm/holders and /v1/evm/holders/native responses, derived from the existing indexed contracts table.
  • Lets consumers compute accurate concentration metrics without per-address eth_getCode round trips. Top-10 holder lists routinely look catastrophic (90%+ concentration) until you discount addresses that are bridges, staking modules, LP pools, or vesting timelocks — this flag closes that gap server-side.
  • Closes TOKEN_API_NO_HOLDER_TYPE: no is_contract flag on holders #523.

SQL pattern

A straightforward LEFT ANY JOIN contracts AS c ON c.address = b.address causes ClickHouse to build a hash from the full contracts table regardless of how few left-side addresses we have. Runtime filter pushdown happens after the read, not at the primary-key index level.

To avoid that, the new SQL:

  1. Materializes the top-N balance rows once into a scalar array via groupArray(tuple(...)).
  2. Reuses the address list (extracted via arrayJoin(arrayMap(...))) as a constant IN predicate on the contracts table — small literal set, primary-key index pruning kicks in.
  3. Expands the row array via arrayJoin in the main FROM — no second balances FINAL pass.

Result: balances FINAL runs once; the contracts read is bounded by the looked-up addresses.


🤖 Generated with Claude Code

Adds an is_contract boolean field to /v1/evm/holders and
/v1/evm/holders/native, derived from the indexed contracts table.
Lets consumers compute accurate concentration metrics without
per-address eth_getCode round trips against an external RPC.

The SQL pattern materializes top-N balances once into a row array
then expands via arrayJoin, reusing the address list to pre-filter
the contracts lookup via primary key. Avoids the full-table hash
build a plain JOIN would trigger.

Closes #523

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@YaroShkvorets YaroShkvorets temporarily deployed to feat/holders-is-contract - token-api PR #534 May 12, 2026 20:41 — with Render Destroyed
@0237h 0237h merged commit b85bf7a into main May 13, 2026
3 of 5 checks passed
@0237h 0237h deleted the feat/holders-is-contract branch May 13, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TOKEN_API_NO_HOLDER_TYPE: no is_contract flag on holders

2 participants