feat(bridge): record the treasury fee divisor in force at reveal - #23
Merged
Merged
Conversation
`treasuryFee: 0` is ambiguous. It means either "the protocol charged no fee at the time" or "this depositor's fee was waived", and nothing in the indexed data distinguishes them. The explorer currently resolves that by showing no waiver badge at all, so a genuine full waiver renders as a blank fee. Mainnet makes the ambiguity concrete: the earliest deposit carrying a fee is 2026-04-15, none of the ~17,600 before it has one, and since then the only zero-fee deposits belong to a single address whose fee is waived. Both cases index as 0. Records `Bridge.depositParameters().depositTreasuryFeeDivisor` as it stood in the reveal block, so a consumer can tell them apart: treasuryFee 0, divisor 0 -> no fee regime; nothing waived treasuryFee 0, divisor > 0 -> genuine full waiver treasuryFee below expected -> partial waiver (already detected) The field is nullable and left null when the call reverts, so a failed read stays distinct from a real zero. The call is guarded for the same reason as the `deposits` read beside it: an unguarded one would halt indexing, as it did at block 16523905. Costs one extra eth_call per DepositRevealed, roughly 17,600 across all of history, which is negligible against 12.9M blocks. Deliberately avoids exposing the 2026-04-15 boundary as a constant, so consumers keep working when governance next changes the divisor. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FvT6VkqyTSCcs89LBem9Z8
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
treasuryFee: 0cannot distinguish a deposit made while protocol fees were disabled from a deposit whose fee was waived. Consumers need the treasury fee divisor that applied when the deposit was revealed.A contract call in the reveal handler returns end-of-block state. If a reveal is followed by a governance update from 0 to 500 in the same block, that call records divisor 500 for the earlier no-fee deposit and incorrectly makes it look fully waived.
Change
Deposit.treasuryFeeDivisorAtRevealand snapshot the tracked divisor at each reveal.BridgeState.depositTreasuryFeeDivisorto the initializer's value of 2000 onInitialized(1), then applyDepositParametersUpdatedin event order. Both configured start blocks include initialization; commit-pinned deployment receipts and initializer sources are documented indocs/treasury-fee-divisor.md.A reveal, update from 0 to 500, and second reveal in one block now retain divisors 0 and 500 respectively. Later updates cannot change either snapshot. This removes the per-reveal parameter call and does not hardcode a fee activation date.
Consumers can distinguish a zero divisor from a positive divisor when interpreting the recorded fee. Null means the historical divisor is unknown. Historical deposits require a re-sync, and consumers must query the new field after deployment.
Validation
yarn install --frozen-lockfile,yarn codegen,yarn build-mainnet, andyarn build-sepoliapass.git diff --checkpasses.The handler tests execute the mapping with mocked Graph dependencies; code generation and both network builds check schema, ABI, and AssemblyScript compatibility.