Skip to content

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

Merged
alpergundogdu merged 4 commits into
mainfrom
adr/450-pr4-safety-delegator
May 7, 2026
Merged

alpergundogdu merged 4 commits into
mainfrom
adr/450-pr4-safety-delegator

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Fourth slice of #450. Closes three acceptance bullets — §A.3, §A.4, §B.6 — by adding formal interface blocks for SafetyReserve (ADR 026 §5) and DelegatorBuyer (ADR 026 §6).

What's added

ADR 026 §5 — interface ISafetyReserve { ... }

Group Highlights
Payouts payout(bytes32 bundle, address recipient, uint256 usdcAmount) — single entry point; usdcAmount named explicitly to encode the USDC-only constraint
Incident registry Incident struct with bundle, recipient, usdcAmount, paidAt, paidBy, reason (enum: OutageRestitution, SlashAppealRatification, ProtocolHack, MisattributionFix, Other); incidents(id) + incidentCount() views
Slashing inflow recordSlashInflow(operator, amount) — SLASH_INFLOW_REPORTER_ROLE-gated callback from StakingRegistry; new role mirrors SETTLEMENT_REPORTER_ROLE
TOKEN→USDC swap swapAccumulatedTokens(amountIn, minOut) — KEEPER_ROLE per-call batch swap; bounded by min/maxBatchAmount
Appeal extensions (per ADR 028) Stubs: openSlashAppeal, fastTrackAppeal, rejectAppeal, ratifyAppeal, reverseAppeal — full state machine deferred to ADR 028 §6 / #451
Governance setters setGovernor, setEmergencyMultisig, setAppealWindow, setMin/MaxBatchAmount, setPool, setSlippageToleranceBps
Pause Blocks payout + swapAccumulatedTokens; recordSlashInflow stays open so slashing accounting is never lost during pauses
Events Paid, SlashInflowRecorded, SwapExecuted, five appeal-state events, six setter events

ADR 026 §6 — interface IDelegatorBuyer { ... }

Group Highlights
Swap swapDelegatorBucket(epoch, amountIn, minOut) — msg.sender == feeRouter as the sole auth check (single trust boundary, no KEEPER_ROLE needed). After Balancer swap, deposits resulting TOKEN back via IFeeRouter.depositDelegatorTokens
Read views feeRouter, pool, slippageToleranceBps, min/maxSwapAmount
Governance setters setFeeRouter, setPool, setSlippageToleranceBps, setMin/MaxSwapAmount
Pause Standard pause / unpause
Events DelegatorSwapped, five setter events

Decisions baked in (per planning conversation)

Decision Pick
payout bundle registration Inline (bundle hash is an argument; recorded as part of payout)
Incident struct fields bundle, recipient, usdcAmount, paidAt, paidBy, reason enum — five primitive fields plus the categorical tag
Multi-currency payout support None — USDC-only by ADR 026 §5 design; usdcAmount field name encodes the constraint
Slash-inflow caller authority New SLASH_INFLOW_REPORTER_ROLE granted to StakingRegistry
swapAccumulatedTokens shape Per-call batch with implementation-side min/maxBatchAmount bounds
DelegatorBuyer.swapDelegatorBucket auth msg.sender == feeRouter only (single trust boundary)
Appeal-extension surface Signature stubs; full spec deferred to ADR 028 §6 / #451

Not included

  • IFeeRouter.depositDelegatorTokens(epoch, amount) — referenced in IDelegatorBuyer.swapDelegatorBucket prose but not added to IFeeRouter here. PR 3 (decdn#458) is the scope for the IFeeRouter block; the missing method will land as a small follow-up commit on that branch.

Out of scope

  • §B.3 commitEpochReceiptRoot / commitEpochSummary full spec (PR 5, ADR 027 §4)
  • §C.2 OriginAssignment edge cases (PR 6, ADR 011)
  • §C.3 PublisherRegistry cap/timelock setters (PR 6, ADR 002)

Test plan

  • pre-commit run --files adr/026-gauge-boost-tokenomics.md clean
  • Render the new "Contract: SafetyReserve" and "Contract: DelegatorBuyer" subsections on GitHub and verify the embedded Solidity blocks are fenced correctly with section comments aligned
  • Verify the cross-references resolve: ADR 016 §"Contract: FeeRouter" (lands in PR 3 docs(adr): FeeRouter interface block in ADR 016 §1 (#450 §A.2 + §B.4 + §C.1) #458), ADR 016 §"No proxy deployment patterns", ADR 028 §6, ADR 018

Related

🤖 Generated with Claude Code

… + §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]>
alpergundogdu added a commit that referenced this pull request May 7, 2026
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]>

@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 introduces the ISafetyReserve and IDelegatorBuyer interfaces to the adr/026-gauge-boost-tokenomics.md document, defining the logic for incident payouts, slash inflows, and delegator token swaps. Feedback was provided regarding missing anchor slugs in internal Markdown links to ensure proper navigation, the addition of missing events in the ISafetyReserve interface for consistency with its governance setters, and correcting an invalid anchor link to another ADR.

Comment thread adr/026-gauge-boost-tokenomics.md Outdated
// ─── Slash-appeal extensions (per ADR 028) ────────────────────────
// Signature stubs only; full appeal state machine, window timing,
// and authorization rules are specified in
// [ADR 028 §6](028-slashing-appeals.md) and finalized as part of the

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The link to ADR 028 §6 is missing an anchor slug. Per the repository's general rules, internal Markdown links should point to the specific section header using the correct GFM slug format.

Suggested change
// [ADR 028 §6](028-slashing-appeals.md) and finalized as part of the
// [ADR 028 §6](028-slashing-appeals.md#6-contract-surface) and finalized as part of the
References
  1. Internal Markdown links must use correct GitHub Flavored Markdown (GFM) anchor slugs, generated by converting headers to lowercase and replacing spaces with hyphens.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 1143ac1: anchor now #6-contract-surface.

event EmergencyMultisigUpdated(address indexed oldAddr, address indexed newAddr);
event AppealWindowUpdated(uint64 oldValue, uint64 newValue);
event PoolUpdated(address indexed oldPool, address indexed newPool);
event SlippageToleranceUpdated(uint256 oldBps, uint256 newBps);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The ISafetyReserve interface defines setters for minBatchAmount and maxBatchAmount (lines 249-250), but the corresponding events are missing from the Events section. For consistency with the IDelegatorBuyer interface and to ensure governance changes are observable, these events should be added.

Suggested change
event SlippageToleranceUpdated(uint256 oldBps, uint256 newBps);
event SlippageToleranceUpdated(uint256 oldBps, uint256 newBps);
event MinBatchAmountUpdated(uint256 oldValue, uint256 newValue);
event MaxBatchAmountUpdated(uint256 oldValue, uint256 newValue);
References
  1. Ensure protocol documentation is internally consistent by verifying that function descriptions, field lists, and edge-case logic are aligned across all sections of the document, including consistent use of recorded fields and exclusion criteria.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added MinBatchAmountUpdated and MaxBatchAmountUpdated events in 1143ac1.

Comment thread adr/026-gauge-boost-tokenomics.md Outdated

- **USDC-only payouts.** `usdcAmount` is named explicitly so the constraint is visible in the storage layout and on every `Paid` event. If a future ADR ever motivates multi-currency payouts, the additive shape is a `tokenOut` field plus an allowlist setter — no breaking change to existing `Incident` storage.
- **Governor and emergency-multisig addresses are governance-mutable.** The `setGovernor` / `setEmergencyMultisig` setters allow the eventual handover from the deployer EOA to `TimelockController` (per [ADR 016 § Post-Deployment Initialization](016-contract-interactions.md#post-deployment-initialization)) and any future re-pointing without contract redeployment. The 48h timelock constraint applies via `GOVERNANCE_ROLE`.
- **Appeal extensions are signature stubs.** This interface pins the function names and parameter types; the full state machine (`Open` → `FastTracked` / `Rejected` → `Ratified` / `Reversed` / `Lapsed`), window timing (filing, multisig review, ratification), and bond/restitution caps live in [ADR 028 §6](028-slashing-appeals.md) and are surface-locked under #451.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The link to ADR 028 §6 is missing an anchor slug. It should point to #6-contract-surface to adhere to GFM standards and improve document navigation.

References
  1. Internal Markdown links must use correct GitHub Flavored Markdown (GFM) anchor slugs, generated by converting headers to lowercase and replacing spaces with hyphens.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 1143ac1: anchor now #6-contract-surface.

Comment thread adr/026-gauge-boost-tokenomics.md Resolved
alpergundogdu and others added 3 commits May 7, 2026 15:07
- 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]>
…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]>
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]>
alpergundogdu added a commit that referenced this pull request May 7, 2026
…+ §C.1) (#458)

* docs(adr): FeeRouter interface block in ADR 016 §1 (#450 §A.2 + §B.4 + §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]>

* docs(adr): add depositDelegatorTokens callback to IFeeRouter

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]>

* docs(adr): clarify getShares() returns governance-set state (#458 review)

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]>

* docs(adr): align epoch type to uint64 in IFeeRouter (audit fix)

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]>

* docs(adr): also fix Settled event epoch type (uint256 -> uint64)

* docs(adr): align IFeeRouter ReceiptSummary + events to ADR 027 §4 canonical (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]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu merged commit 9c06a69 into main May 7, 2026
9 checks passed
@alpergundogdu
alpergundogdu deleted the adr/450-pr4-safety-delegator branch May 7, 2026 14:47
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