Skip to content

4.3.0 spell: set tradingDelay at upgrade - #1311

Merged
tbrent merged 5 commits into
masterfrom
4.3.0-spell-trading-delay
Nov 17, 2026
Merged

tbrent merged 5 commits into
masterfrom
4.3.0-spell-trading-delay

Conversation

@tbrent

@tbrent tbrent commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a newTradingDelay parameter to the 4.3.0 upgrade spell: castSpell(IRToken rToken, uint48 newTradingDelay). The spell sets it on the BackingManager after the upgrade, so each community picks its tradingDelay in the same proposal that changes what tradingDelay means.

Why

4.3.0 (#1297) changes what tradingDelay delays:

  • Before 4.3.0: trading waits tradingDelay after every basket change.
  • From 4.3.0: a basket refresh by governance (OWNER) sets tradingDelayBypassed and skips the delay. Only emergency basket changes still wait: the permissionless refresh after a collateral default.

So tradingDelay is now a window for governance to step in with a better basket before automatic recollateralization starts, without slowing down governance's own basket changes. All four RTokens run tradingDelay = 0 today, a value chosen for the old meaning. Putting the setting in the spell means communities choose a value explicitly when they upgrade. The spell requires newTradingDelay to be at least the current tradingDelay (Err(14), checked before any upgrade): the delay should only increase.

Changes

  • contracts/spells/4_3_0.sol: castSpell takes newTradingDelay, requires it to be >= the current tradingDelay, and calls backingManager.setTradingDelay(newTradingDelay) after the component upgrades, while the spell still holds OWNER. setTradingDelay enforces MAX_TRADING_DELAY (1 year). The doc comment explains the change in meaning.
  • tasks/validation/proposals/4_3_0.ts: proposal_4_3_0 takes newTradingDelay and passes it to castSpell.
  • tasks/validation/spells/4.3.0.ts: the fork task casts with a test value of 1 day and checks the BackingManager reports it after the upgrade. The validator already advances time past tradingDelay before its trading checks.
  • docs/deployment-variables.md: the tradingDelay entry now describes the 4.3.0 meaning.
  • CHANGELOG.md: notes the new spell parameter.

The spell is not deployed yet, so changing the castSpell signature breaks nothing on chain.

Verification

  • yarn compile. Solhint shows 0 errors; the one warning is the existing contract-name rule for 4_3_0. ESLint and Prettier pass on the changed files.
  • FORK_NETWORK=mainnet yarn hardhat 4.3.0 at block 26430568: eUSD, ETH+, and USD3 pass, including the new tradingDelay check.
  • FORK_NETWORK=base yarn hardhat 4.3.0 at Base block 58389092: bsdETH passes. BASE_SUBGRAPH_URL pointed at dtf-yield-base/prod, as in 4.3.0: Upgrade spell #1308.

These runs include the >= check, plus a nonzero check that was removed afterwards; I recompiled and linted after removing it. The fork task casts with 1 day against a current delay of 0, so it exercises only the passing path; no test covers the Err(14) revert.

The pre-push Husky hook can't run from a nested linked worktree, so I ran the equivalent checks by hand.

🤖 Generated with Claude Code

tbrent and others added 2 commits November 16, 2026 22:28
4.3.0 changes what tradingDelay delays: governance basket refreshes now
skip it, so it only delays trading after a basket change governance did
not make, such as a refresh after a default. castSpell takes a
newTradingDelay so each community sets the value for its new meaning in
the upgrade proposal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A zero delay starts automatic trading as soon as a defaulted basket is
replaced, which is most likely a misconfiguration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The 4.3.0 upgrade spell now accepts and validates a trading delay, then sets it on the BackingManager. Proposal construction and validation pass and check the value. The changelog and deployment documentation describe the parameter and delay semantics.

Changes: Trading Delay Upgrade

Layer / File(s) Summary
Spell trading delay update
contracts/spells/4_3_0.sol, CHANGELOG.md, docs/deployment-variables.md
castSpell accepts newTradingDelay and rejects zero values or values below the current BackingManager delay with Err(14). After the basket checks, the spell sets the delay. The changelog and deployment documentation describe the parameter and delay semantics.
Proposal wiring and validation
tasks/validation/proposals/4_3_0.ts, tasks/validation/spells/4.3.0.ts
The proposal function passes newTradingDelay to the spell. The validation task supplies a one-day value and checks that the BackingManager delay matches it after execution.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ValidationTask
  participant ProposalFunction
  participant UpgradeSpell
  participant BackingManager
  ValidationTask->>ProposalFunction: pass NEW_TRADING_DELAY
  ProposalFunction->>UpgradeSpell: call castSpell with newTradingDelay
  UpgradeSpell->>BackingManager: read current tradingDelay
  UpgradeSpell->>BackingManager: set tradingDelay after basket checks
  ValidationTask->>BackingManager: check tradingDelay after execution
Loading

Possibly related PRs

Suggested reviewers: akshatmittal, pmckelvy1

Merge Risk: Minimal · up to e3e06

The 4.3.0 upgrade spell now takes a trading delay and validates it before upgrading. No concrete merge-blocking risk was found in the supplied changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "4.3.0 spell: set tradingDelay at upgrade" matches the main change. The 4.3.0 upgrade spell gains a newTradingDelay parameter, and castSpell sets the BackingManager tradingDelay during the u…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "4.3.0 spell: set tradingDelay at upgrade" matches the main change. The 4.3.0 upgrade spell gains a newTradingDelay parameter, and castSpell sets the BackingManager tradingDelay during the upgrade. The title names the spell, the setting, and the timing, so it is specific and accurate. It does not mention the nonzero or minimum-value checks, which is acceptable because the title need not cover every detail.

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: 4ee1f51f-1675-4f97-91f7-d9ca3326f2b4
Commits

Reviewing files that changed from the base of the PR and between 4a46ca4 and e3e06d4.

Files selected for processing: 5

  • CHANGELOG.md
  • contracts/spells/4_3_0.sol
  • docs/deployment-variables.md
  • tasks/validation/proposals/4_3_0.ts
  • tasks/validation/spells/4.3.0.ts

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 16, 2026 22:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tbrent
tbrent merged commit 06d22ba into master Nov 17, 2026
17 checks passed
@tbrent
tbrent deleted the 4.3.0-spell-trading-delay branch November 17, 2026 16:49
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