Skip to content

Update Holders/Token Metadata to latest v0.3.0 Balances (with FINAL)#331

Open
DenisCarriere wants to merge 2 commits intomainfrom
fix/evm-holders
Open

Update Holders/Token Metadata to latest v0.3.0 Balances (with FINAL)#331
DenisCarriere wants to merge 2 commits intomainfrom
fix/evm-holders

Conversation

@DenisCarriere
Copy link
Contributor

This pull request updates how token holders and token metadata are queried, switching all relevant SQL queries to use the new *_balances_final tables and aligning with the latest v0.3.0 balances schema. This improves data accuracy, query performance, and consistency across ERC20 and native token holders and supply calculations.

Migration to new balances tables:

  • Updated ERC20 and native token holder queries in holders_for_contract/evm.sql and holders_for_contract_native/evm.sql to use {db_balances:Identifier}.erc20_balances_final and {db_balances:Identifier}.native_balances_final instead of legacy tables, simplifying logic and improving performance. [1] [2]

Query logic and metadata improvements:

  • Refactored selection of latest balances and timestamps to use direct fields (balance, timestamp, block_num) from the new tables, removing complex subqueries and intermediate CTEs. [1] [2]
  • Updated joins with metadata.metadata to ensure correct contract and network matching, and applied FINAL for consistency. [1] [2]

Circulating supply and holders calculation:

  • Changed circulating supply and holders aggregation queries in tokens_for_contract/evm.sql and tokens_for_contract_native/evm.sql to use the new final tables, streamlining the logic and removing unnecessary grouping and filtering. [1] [2]
  • Unified the calculation and selection of circulating supply and holders to use a single CTE and direct table scans, improving readability and maintainability. [1] [2]

Documentation and versioning:

  • Added a changeset documenting the upgrade to v0.3.0 balances and marking the release as a patch for the token-api package. (.changeset/legal-walls-judge.md)

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

🦋 Changeset detected

Latest commit: 444ec05

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
token-api Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

2 participants