Skip to content

feat: add rebasing token extension with on-chain sync tool - #161

Merged
ScreamingHawk merged 2 commits into
masterfrom
feat/rebasing-flag
Sep 28, 2026
Merged

ScreamingHawk merged 2 commits into
masterfrom
feat/rebasing-flag

Conversation

@ScreamingHawk

Copy link
Copy Markdown
Contributor

Problem

Rebasing tokens change balances without a transfer. Aave aTokens also round transfers by a unit, so any fixed amount computed at quote time can be short by the time it executes. Trails hit this with aBasUSDC on Base: the origin fee transfer underflowed by 1 unit and the intent executed without collecting the fee. There is no flag for consumers to detect these tokens.

Change

  • Adds extensions.rebasing: true, modelled on feeOnTransfer (present only when true).
  • Adds tools/sync-rebasing.ts (pnpm sync-rebasing), which detects rebasing tokens on-chain by probing for selector pairs only rebasing implementations expose:
    • Aave v2/v3: UNDERLYING_ASSET_ADDRESS + scaledBalanceOf
    • Aave v1: underlyingAssetAddress + principalBalanceOf
    • Lido stETH: getPooledEthByShares + sharesOf
    • Origin OUSD: rebasingCreditsPerToken + nonRebasingSupply
    • Ampleforth: scaledBalanceOf + scaledTotalSupply
  • Flags 285 tokens across mainnet, polygon, base, arbitrum, optimism, avalanche, bnb, gnosis and base-sepolia (277 Aave v2/v3, 5 Aave v1, stETH, OUSD, AMPL).
  • ERC-4626 and share-price tokens (sUSDe, wstETH, cbETH, rETH) are not flagged. Their balances don't move, so fixed-amount math against them holds.
  • Documents both sync-rebasing and the existing sync-fee-on-transfer tool in the README, and links both from the token schema.

Notes

  • Each probe carries a totalSupply sentinel. Public RPCs silently drop calls from large multicalls, which otherwise reads as "not rebasing". Failed sentinels are retried in smaller batches, then as individual eth_calls.
  • 15 tokens could not be probed and are reported, not assumed clean. None are rebasing. 7 of them are Aave Pool contract addresses wrongly listed as tokens, which is a pre-existing data issue left untouched here.
  • Removing the rebasing key from every changed file gives JSON identical to master, and re-running --write is a no-op.

Adds extensions.rebasing for tokens whose balances change without a
transfer (Aave aTokens, stETH, AMPL, OUSD), populated by
tools/sync-rebasing.ts via on-chain selector probes. Flags 285 tokens.
@ScreamingHawk
ScreamingHawk merged commit 8fbcc34 into master Sep 28, 2026
7 checks passed
@ScreamingHawk
ScreamingHawk deleted the feat/rebasing-flag branch September 28, 2026 22:24
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