Skip to content

docs(adr): FeeRouter interface block in ADR 016 §1 (#450 §A.2 + §B.4 + §C.1) - #458

Merged
alpergundogdu merged 6 commits into
mainfrom
adr/450-pr3-feerouter
May 7, 2026
Merged

alpergundogdu merged 6 commits into
mainfrom
adr/450-pr3-feerouter

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Third slice of #450. Closes three acceptance bullets — §A.2, §B.4, §C.1 — by consolidating the IFeeRouter surface into a single canonical interface block.

Adds a "#### Contract: FeeRouter" subsection in ADR 016 §1, between "#### Tunable Economics" and "##### No proxy deployment patterns". Signatures previously scattered across the §1 classDiagram, §3 call table, ADR 026 §2 narrative, and ADR 003 references now live in one place.

What's in the block

Group Functions
Settlement entry routeSettlement(operator, bytesDelivered, amount)
Receipt anchoring (stub; full spec in ADR 027 §4) commitEpochReceiptRoot, commitEpochSummary
Claims claimBoost(epochs[]), claimDelegator(epochs[])
Keeper triggers executeDelegatorSwap(epoch, minOut), sweepUnclaimed(epochs[])
Read views workingBytes, epochTotalWorkingBytes, gaugeBucket, delegatorBucket, getShares, votingEscrow, safetyReserve, delegatorBuyer, buybackBurner, treasury, boostFloor
Tunability (atomic) setSharesAndDestinations(sharesBps[6], ShareDestinations)
Tunability (per-knob) setShares, setVotingEscrow, setSafetyReserve, setDelegatorBuyer, setBuybackBurner, setTreasury, setBoostFloor
Pause control pause, unpause
Events 13 events covering settlement, receipt commits, claims, swap, sweep, and each setter

Decisions baked in (per planning conversation)

Decision Pick
Keeper API for delegator swap executeDelegatorSwap(epoch, minOut) on FeeRouter; FeeRouter forwards to DelegatorBuyer internally
Shares + destinations updates Both atomic (setSharesAndDestinations) and per-knob setters; atomic for activation flips, per-knob for routine maintenance
Pause semantics Blocks routeSettlement + claims + swap + sweep; commitEpochReceiptRoot / commitEpochSummary stay open so operators don't lose gauge eligibility; StablePaymentChannel.closeChannel / disputeChannel are unaffected (independent contract)
workingBytes shape Single value returns (uint256); off-chain bundles with epochTotalWorkingBytes via Multicall3
Sweep behavior Explicit permissionless sweepUnclaimed(epochs[]); matches pruneBlacklistedAssignment pattern
Storage shape Implementation-defined; recommendation noted (separate maps per bucket) but not enforced by the interface
Receipt-anchoring functions Signatures only; full spec deferred to ADR 027 §4 (PR 5)
initialize(...) helper None; constructor + post-deploy setSharesAndDestinations is sufficient

Cross-references resolved

Out of scope

  • §A.3 SafetyReserve interface (PR 4)
  • §A.4 DelegatorBuyer minimal interface (PR 4)
  • §B.3 commitEpochReceiptRoot / commitEpochSummary full spec — signatures only here, full spec in ADR 027 §4 (PR 5)
  • §B.6 StakingRegistry → SafetyReserve redirect signature (PR 4)
  • §C.2 OriginAssignment edge cases (PR 6)
  • §C.3 PublisherRegistry cap/timelock setters (PR 6)

Test plan

  • pre-commit run --files adr/016-contract-interactions.md clean
  • Render the new "Contract: FeeRouter" subsection on GitHub and verify the embedded Solidity block is fenced correctly with section comments aligned
  • Spot-check that the [§ Tunable Economics] and [§ No proxy deployment patterns] cross-references still resolve after the section was inserted between them
  • Verify [ADR 026 §11] and [ADR 027 §4] cross-references in the block link to the right anchors

Related

🤖 Generated with Claude Code

…+ §C.1)

Adds a formal `interface IFeeRouter { ... }` block as a new "#### Contract:
FeeRouter" subsection in ADR 016 §1, after "#### Tunable Economics" and
before "##### No proxy deployment patterns". Closes three §450 acceptance
bullets:

- §A.2 — formal interface block consolidating signatures previously
  scattered across §1 classDiagram, §3 call table, ADR 026 §2 narrative,
  and ADR 003 references
- §B.4 — tunability surface: setSharesAndDestinations(...) atomic
  setter + per-knob setters (setShares, setVotingEscrow, etc.)
- §C.1 — zero-address dependency pattern documented in the constructor
  notes and surfaced via the cross-validation invariant on setShares

Surface highlights:

- routeSettlement(operator, bytesDelivered, amount) — entry point.
- commitEpochReceiptRoot / commitEpochSummary — signature stubs;
  full spec lives in ADR 027 §4 (PR 5).
- claimBoost / claimDelegator — return amount transferred for tooling;
  reverts on epochs older than the 26-epoch window.
- executeDelegatorSwap(epoch, minOut) — keeper trigger on FeeRouter,
  forwards to DelegatorBuyer (single Balancer V3 caller).
- sweepUnclaimed(epochs[]) — permissionless storage cleanup past the
  claim window; matches pruneBlacklistedAssignment pattern.
- workingBytes / epochTotalWorkingBytes / gaugeBucket / delegatorBucket
  — read views; off-chain bundling via Multicall3.
- setSharesAndDestinations(sharesBps[6], dests) — atomic activation
  flip; per-knob setters for routine governance after wiring.
- pause() / unpause() — blocks routeSettlement + claims +
  executeDelegatorSwap + sweepUnclaimed; commit functions stay open so
  operators don't lose gauge eligibility during pauses.
- Per-knob setter events; SharesUpdated event for setShares.

Notes section pins the design choices: epochLength and claimWindow are
immutable; workingBytes returns per-operator only (caller bundles via
Multicall3); ReceiptSummary signature stubbed pending ADR 027 §4;
no initialize() helper; storage shape is implementation-defined.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the IFeeRouter interface to the contract interactions ADR, detailing the core logic for fee routing, receipt anchoring, and governance-controlled parameters. The feedback suggests ensuring that the documentation clearly distinguishes between operator-asserted and on-chain derived values and verifying that share calculations maintain logical consistency across the protocol.

Comment thread adr/016-contract-interactions.md Resolved
Missing from the initial IFeeRouter block — `DelegatorBuyer` calls back
into FeeRouter via `depositDelegatorTokens(epoch, amount)` after the
Balancer V3 swap completes (per the §1 classDiagram and §3 call table
already on main from #449, and per the IDelegatorBuyer block landing in
PR 4 / #459).

`msg.sender == delegatorBuyer` is the sole auth check — same single
trust boundary pattern used in IDelegatorBuyer.swapDelegatorBucket
(`msg.sender == feeRouter`).

Adds matching `DelegatorTokensDeposited` event.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…iew)

Address Gemini review on PR #458: explicitly note that getShares()
returns the configured bucket-share percentages (governance-set, last
updated via setShares / setSharesAndDestinations) rather than
operator-asserted or per-epoch-derived values. Also pin the return-array
ordering to match the setShares parameter order so off-chain consumers
can index into the result without ambiguity.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 7, 2026
- Fix two ADR 028 §6 cross-references to use the correct GFM anchor
  (#6-contract-surface).
- Add MinBatchAmountUpdated and MaxBatchAmountUpdated events to
  ISafetyReserve, mirroring the per-setter event pattern used in
  IDelegatorBuyer and across the rest of the unified surface.

The `#contract-feerouter` anchor in IDelegatorBuyer's swapDelegatorBucket
comment is a forward reference to the heading PR #458 adds — it'll
resolve once #458 merges. Keeping the anchor as-is rather than pointing
at the existing `#feerouter` heading on main, which is the §6 Reentrancy
Analysis subsection (different semantic target).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu and others added 2 commits May 7, 2026 15:27
Cross-PR audit caught two type/signature inconsistencies between PR #458
(IFeeRouter) and the canonical surface in ADR 027 §4 / the existing prose:

1. epoch type: ADR 027 §4 prose uses `uint64 epochId` consistently
   (in commitEpochReceiptRoot signature, EpochReceiptSummary.epochId
   field, MMR addressing). PR #458's IFeeRouter declarations used
   `uint256 epoch` everywhere — inconsistent with the canonical type and
   slightly costlier for calldata-array call sites (claimBoost, etc.).
   Aligned all 11 sites + 7 event declarations to `uint64 epochId`.

2. commitEpochSummary signature: ADR 027 §4 line 144 explicitly allows
   "the operator (or any third party)" to call commitEpochSummary, with
   the operator passed as a parameter. PR #458 had a 2-param shape
   (epoch, summary) implying msg.sender-as-operator only — would have
   blocked the third-party-relay path. Changed to the 3-param canonical
   shape: commitEpochSummary(address operator, uint64 epochId,
   ReceiptSummary calldata summary).

(commitEpochReceiptRoot stays msg.sender-keyed per ADR 027 §4 line 118
"the caller is recorded as the credited operator" — the root commit is
self-authorising; only the summary submission has the third-party path.)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 7, 2026
…R_ROLE (audit fix)

Cross-PR audit caught two issues in PR #459's surface:

1. epoch type: IDelegatorBuyer.swapDelegatorBucket and the
   DelegatorSwapped event used `uint256 epoch`, inconsistent with the
   canonical `uint64 epochId` used in ADR 027 §4 prose and now in
   IFeeRouter (#458 audit fix). Aligned both.

2. SLASH_INFLOW_REPORTER_ROLE undeclared in ADR 016 §5: PR #459
   introduced this role on ISafetyReserve.recordSlashInflow but didn't
   add the corresponding row to the access control matrix. Added —
   mirrors SETTLEMENT_REPORTER_ROLE pattern (grant to StakingRegistry
   post-deploy).

3. KEEPER_ROLE row updated to remove DelegatorBuyer (the planning
   decision was msg.sender == feeRouter as the sole auth check on
   DelegatorBuyer.swapDelegatorBucket — not a KEEPER_ROLE) and add
   SafetyReserve.swapAccumulatedTokens.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…onical (audit fix)

Cross-PR audit caught struct + event-shape divergence between PR #458
(IFeeRouter) and PR #460 (ADR 027 §4 canonical):

1. struct ReceiptSummary -> EpochReceiptSummary, with the canonical
   five fields (operator, epochId, claimedBytes, claimedDistinctClients,
   aggregateRoot). PR #458's two-field stub (distinctClientCount,
   totalBytes) used the wrong field names AND the wrong types
   (claimedDistinctClients is uint32 per ADR 027 §4 line 141, not uint256)
   AND was missing aggregateRoot.

2. EpochReceiptRootCommitted event: added leafCount field (the MMR's
   current depth). Matches the PR #460 declaration in ADR 027 §4 § Events
   so indexers don't have to chain prior events to reconstruct MMR state.

3. EpochSummaryCommitted event: renamed fields to claimedBytes /
   claimedDistinctClients (canonical), changed claimedDistinctClients to
   uint32 to match the storage type, added aggregateRoot field.

The struct is mirrored (not imported) so IFeeRouter is self-contained
in ADR 016 — but the canonical layout pointer to ADR 027 §4 is preserved
as the source of truth in case the layout changes during the surface
lock-down (#451).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu merged commit a55e439 into main May 7, 2026
9 checks passed
@alpergundogdu
alpergundogdu deleted the adr/450-pr3-feerouter branch May 7, 2026 14:47
alpergundogdu added a commit that referenced this pull request May 7, 2026
… + §A.4 + §B.6) (#459)

* docs(adr): SafetyReserve + DelegatorBuyer interface blocks (#450 §A.3 + §A.4 + §B.6)

ADR 026 §5: adds "#### Contract: SafetyReserve" subsection with the
formal interface block consolidating signatures previously scattered
across ADR 016 §1, ADR 026 §5 prose, and ADR 028 §123 stubs.

ADR 026 §6: adds "#### Contract: DelegatorBuyer" subsection. Both
implementation choices (parallel contract vs BuybackBurner multi-output
mode) ship the same interface; the choice stays deferred per ADR 016 §1.

Surface highlights:

ISafetyReserve:
- payout(bytes32 bundle, address recipient, uint256 usdcAmount) — single
  entry point. usdcAmount is named explicitly to encode the USDC-only
  payout constraint (TOKEN inflow gets swapped before becoming available).
- Incident struct: bundle, recipient, usdcAmount, paidAt, paidBy, reason
  (enum: OutageRestitution, SlashAppealRatification, ProtocolHack,
  MisattributionFix, Other). Lets indexers reconstruct without aux state.
- recordSlashInflow(operator, amount) — SLASH_INFLOW_REPORTER_ROLE-gated
  callback from StakingRegistry; new role mirrors SETTLEMENT_REPORTER_ROLE.
  Resolves §B.6.
- swapAccumulatedTokens(amountIn, minOut) — KEEPER_ROLE per-call batch
  swap of accumulated TOKEN to USDC. Per-call shape lets keepers
  MEV-sequence; bounded by min/maxBatchAmount.
- Appeal extension stubs (openSlashAppeal, fastTrackAppeal, rejectAppeal,
  ratifyAppeal, reverseAppeal) — signatures only; full state machine and
  window timing live in ADR 028 §6 and finalize under #451.
- Full event set including Paid, SlashInflowRecorded, SwapExecuted, the
  five appeal-state events, and per-setter Updated events.
- Pause blocks payout + swap; recordSlashInflow stays open so slashing
  accounting is never lost.

IDelegatorBuyer:
- swapDelegatorBucket(epoch, amountIn, minOut) — msg.sender == feeRouter
  is the sole auth check (single trust boundary, no KEEPER_ROLE on
  DelegatorBuyer needed). After Balancer swap, deposits resulting TOKEN
  back via IFeeRouter.depositDelegatorTokens.
- Standard governance setters (setFeeRouter, setPool, slippage, batch
  bounds), pause/unpause, full event set.
- Notes pin the deferred implementation choice and the §97 carve-out
  application for setFeeRouter.

depositDelegatorTokens callback on FeeRouter is referenced in
IDelegatorBuyer's prose but not added to IFeeRouter here — that fix
lands on PR 3 (#458) directly since IFeeRouter is its scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): address PR #459 review comments

- Fix two ADR 028 §6 cross-references to use the correct GFM anchor
  (#6-contract-surface).
- Add MinBatchAmountUpdated and MaxBatchAmountUpdated events to
  ISafetyReserve, mirroring the per-setter event pattern used in
  IDelegatorBuyer and across the rest of the unified surface.

The `#contract-feerouter` anchor in IDelegatorBuyer's swapDelegatorBucket
comment is a forward reference to the heading PR #458 adds — it'll
resolve once #458 merges. Keeping the anchor as-is rather than pointing
at the existing `#feerouter` heading on main, which is the §6 Reentrancy
Analysis subsection (different semantic target).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): align epoch type to uint64 + register SLASH_INFLOW_REPORTER_ROLE (audit fix)

Cross-PR audit caught two issues in PR #459's surface:

1. epoch type: IDelegatorBuyer.swapDelegatorBucket and the
   DelegatorSwapped event used `uint256 epoch`, inconsistent with the
   canonical `uint64 epochId` used in ADR 027 §4 prose and now in
   IFeeRouter (#458 audit fix). Aligned both.

2. SLASH_INFLOW_REPORTER_ROLE undeclared in ADR 016 §5: PR #459
   introduced this role on ISafetyReserve.recordSlashInflow but didn't
   add the corresponding row to the access control matrix. Added —
   mirrors SETTLEMENT_REPORTER_ROLE pattern (grant to StakingRegistry
   post-deploy).

3. KEEPER_ROLE row updated to remove DelegatorBuyer (the planning
   decision was msg.sender == feeRouter as the sole auth check on
   DelegatorBuyer.swapDelegatorBucket — not a KEEPER_ROLE) and add
   SafetyReserve.swapAccumulatedTokens.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): add SLASH_INFLOW_REPORTER_ROLE grant to post-deploy step 3

Audit follow-up to 331a363. The SLASH_INFLOW_REPORTER_ROLE row was added
to ADR 016 §5, but the corresponding grant call was missing from the
"Post-Deployment Initialization" sequence — leaving auditors unable to
verify when/where this role gets bound.

Pairs the SafetyReserve.grantRole(SLASH_INFLOW_REPORTER_ROLE,
stakingRegistry) call into post-deploy step 3 (alongside the SLASH_ROLE
grant), matching the security-pairing pattern called out in the
"Deployment atomicity" note.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant