Skip to content

Do not apply tradingDelay to forwardRevenue() - #1319

Merged
tbrent merged 6 commits into
4.3.0-audit-trading-delay-docsfrom
4.3.0-audit-forward-revenue-delay
Dec 1, 2026
Merged

tbrent merged 6 commits into
4.3.0-audit-trading-delay-docsfrom
4.3.0-audit-forward-revenue-delay

Conversation

@tbrent

@tbrent tbrent commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

BackingManager.forwardRevenue() no longer waits for tradingDelay. The delay now only applies to rebalancing.

Stacked on #1317.

Why

Trust audit question "tradingDelay's old purpose and check in forwardRevenue".

forwardRevenue() already requires the basket to be ready (isReady(), which includes the warmup period) and the RToken to be fully collateralized. After an emergency basket change the RToken is normally undercollateralized, so the delay check added nothing there. Where it did bind, on a fully collateralized RToken, it only paused revenue. For example, after governance swapped a plugin and a permissionless refresh followed, revenue stopped for the whole delay.

This is a change from 4.2.0, where the delay applied to forwardRevenue() after every basket change.

Changes

  • contracts/p1/BackingManager.sol, contracts/p0/BackingManager.sol: remove the tradingDelay check from forwardRevenue(). The rebalance() check is unchanged.
  • test/Revenues.test.ts: the two revenue-delay tests become one that checks forwarding waits for the warmup period and not for the trading delay. A second test covers outstanding supply: after a permissionless basket switch, forwardRevenue() reverts with undercollateralized until the backing is restored, then forwards while the trading delay is still running.
  • docs/deployment-variables.md: says the delay applies to rebalancing only, and adds a second reason for it: it gives bidders time to prepare, so rebalancing auctions do not open into poor liquidity.
  • CHANGELOG.md

BackingManagerP1 shrinks from 24,573 to 24,249 bytes (limit 24,576).

Verification

  • Both new revenue tests pass on P0 and P1. The tests they replace asserted the old trading delayed revert.
  • Full test/*.test.ts on P0 and P1, the plugin, library, scenario and registry suites, and the mainnet and Base upgrade fork task were run at the top of the stack (see the next PR); all pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Updates
    • Revenue can now be forwarded during the trading delay, provided the basket is ready, no trades are open, and the system is fully collateralized.
    • The trading delay continues to apply to rebalancing trades, not revenue forwarding.
  • Documentation
    • Clarified when the trading delay applies, including differences between emergency and governance basket changes, and noted that issuance and revenue forwarding remain available during the delay.

forwardRevenue() already requires the basket to be ready and the RToken
to be fully collateralized. The trading delay is about rebalancing, so
it no longer gates revenue forwarding.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3dce0e0-16e8-4ce8-b7d7-be5f36ea9cb9
Commits

Reviewing files that changed from the base of the PR and between 23a528c and 8fea74d.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Revenue forwarding in both BackingManager versions no longer waits for the trading delay. Tests verify that collateralization and basket readiness still affect forwarding. The changelog and deployment-variable documentation describe the revised delay behavior.

Changes: Revenue forwarding during trading delay

Layer / File(s) Summary
Remove the forwarding delay gate
contracts/p0/BackingManager.sol, contracts/p1/BackingManager.sol
Both BackingManager versions remove the trading-delay check from forwardRevenue(). Other forwarding requirements remain.
Verify and document forwarding behavior
test/Revenues.test.ts, CHANGELOG.md, docs/deployment-variables.md
Tests cover forwarding during an active delay, including collateralization and basket readiness. Documentation states that the delay applies to rebalancing, not revenue forwarding.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • reserve-protocol/protocol#1297: Changes trading-delay behavior for basket-triggered actions and adds a bypass flag that affects revenue forwarding timing.

Suggested reviewers: akshatmittal, julianmrodri

Merge Risk: Minimal · previous review 761dc

Revenue forwarding no longer waits for the trading delay, while basket readiness and full collateralization are still required. Tests and docs are updated to match. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: forwardRevenue() no longer applies tradingDelay. The raw summary shows the P0 and P1 BackingManager changes removing the delay check from forwardRevenue(), plus the ma…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: forwardRevenue() no longer applies tradingDelay. The raw summary shows the P0 and P1 BackingManager changes removing the delay check from forwardRevenue(), plus the matching docs, changelog, and revenue test updates. The title is specific and short, so it fits the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 931597d0-08a7-4fe7-adc0-33bce7b708c9
Commits

Reviewing files that changed from the base of the PR and between c56151f and 761dcbc.

Files selected for processing: 5

  • CHANGELOG.md
  • contracts/p0/BackingManager.sol
  • contracts/p1/BackingManager.sol
  • docs/deployment-variables.md
  • test/Revenues.test.ts
Files with no reviewable changes: 2

  • contracts/p0/BackingManager.sol
  • contracts/p1/BackingManager.sol

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

tbrent and others added 3 commits November 30, 2026 18:41
Review feedback: revenue auctions are not delayed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
After a permissionless basket switch, forwardRevenue() reverts with
'undercollateralized' until the backing is restored, then forwards while
rebalance() still reverts with 'trading delayed'.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Asserting 'trading delayed' from rebalance() after the backing is restored
pinned the order of two guards.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@tbrent
tbrent added this pull request to stack #1318 November 30, 2026 19:53
akshatmittal
akshatmittal previously approved these changes Nov 30, 2026
@tbrent
tbrent merged commit bd01378 into master Dec 1, 2026
17 of 33 checks passed
@tbrent
tbrent deleted the 4.3.0-audit-forward-revenue-delay branch December 1, 2026 17:31
tbrent added a commit that referenced this pull request Dec 1, 2026
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tbrent added a commit that referenced this pull request Dec 1, 2026
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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