reconcile-token-supply-from-transfers
Use when indexed transfer sums must agree with on-chain totalSupply. Reconstructs circulating supply from mint and burn events and flags any gap between the indexer and the contract.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- reconcile-token-supply-from-transfers
- description
- Use when indexed transfer sums must agree with on-chain totalSupply. Reconstructs circulating supply from mint and burn events and flags any gap between the indexer and the contract.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md363 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
Reconcile token supply from transfers
If the sum of indexed mints minus burns does not equal totalSupply(), the indexer missed events. This is the single sharpest correctness check for a token indexer.
Procedure
- Treat
Transfer(0x0, to, amount)as a mint andTransfer(from, 0x0, amount)as a burn. - Compute net supply from indexed rows:
SELECT COALESCE(sum(CASE WHEN from_addr='\x0000000000000000000000000000000000000000' THEN amount WHEN to_addr ='\x0000000000000000000000000000000000000000' THEN -amount END),0) AS minted FROM transfers WHERE token = $TOKEN; - Read the contract's figure and compare exactly:
cast call $TOKEN "totalSupply()(uint256)" --rpc-url $RPC - A mismatch means a missed block, a decoder miss, or a non-canonical mint. Find the block where the two series first diverge, not just the end.
- For rebasing or fee-on-transfer tokens the event sum will exceed
totalSupply; account for that model explicitly before calling it a bug. - Run the check per token on a schedule and store the delta so drift is a metric, not a surprise.
- Compare at increasing granularity: total, then per-epoch, then per-block, to localise the first divergence fast.
- Persist each reconciliation snapshot (block, indexed, on-chain, delta) so the drift's slope is visible over time.
Pitfalls
- Assuming zero-address burns always reduce supply: some tokens burn to a dead address (
0x...dEaD), not the zero address; read the contract. - Wrapped or bridged tokens mint against a deposit; supply here reconciles to the wrapper, not the underlying.
- A token migrated across a proxy shows two supply histories at one address; sum per implementation.
- Comparing at
latestright after a mint can show a transient one-block gap; compare at a finalized block. - A reorg between reading the chain and reading the indexer makes a correct indexer look wrong; read both at the same finalized block.
- Bridged tokens mint on one chain against a burn on another; reconcile each side separately, not across chains.
Verification
python -c "import checker; print(checker.supply_delta('$TOKEN'))"
# expect 0 for a standard token, or a documented protocol delta for rebasing/fee tokens
Report the indexed mint-minus-burn total, the contract totalSupply, and the block where any divergence first appears.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.