Skip to content

Only update tradingDelayBypassed when the basket switches - #1314

Merged
tbrent merged 3 commits into
4.3.0-audit-spell-checksfrom
4.3.0-audit-bypass-on-switch
Dec 1, 2026
Merged

tbrent merged 3 commits into
4.3.0-audit-spell-checksfrom
4.3.0-audit-bypass-on-switch

Conversation

@tbrent

@tbrent tbrent commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

BasketHandler.refreshBasket() now updates tradingDelayBypassed only when the basket actually switches.

Stacked on #1313.

Why

Trust audit finding "tradingDelayBypassed is updated when basket switch fails" (QA).

refreshBasket() set the flag before calling _switchBasket(), so it changed even when no valid basket was found. That had no effect on trading: a failed switch leaves the basket disabled, and the only way out of disabled is another refreshBasket(), which writes the flag again. But the flag is documented as describing the current basket, and after a failed switch it described a basket that was never set.

Changes

  • contracts/p1/BasketHandler.sol, contracts/p0/BasketHandler.sol: set the flag after _switchBasket(), and only if the basket is not disabled.
  • test/Recollateralization.test.ts: new test covering a failed permissionless refresh (flag stays true) and a failed governance refresh (flag stays false).

No storage layout change.

Verification

  • New test passes on P0 and P1, and fails on P1 without the fix (expected false to equal true).
  • The existing tradingDelay tests in test/Recollateralization.test.ts pass on P0 and P1.

🤖 Generated with Claude Code

refreshBasket() set tradingDelayBypassed even when no valid basket was
found. A failed switch leaves the basket disabled, so the stale flag had
no effect, but it no longer described the current basket.

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

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

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: dfe16224-925b-4b68-a203-ced82cf97679
Commits

Reviewing files that changed from the base of the PR and between 7084d86 and e8da163.

Files selected for processing: 3

  • contracts/p0/BasketHandler.sol
  • contracts/p1/BasketHandler.sol
  • test/Recollateralization.test.ts
  • 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

@akshatmittal
akshatmittal added this pull request to stack #1318 November 27, 2026 19:44
@tbrent
tbrent merged commit bd01378 into master Dec 1, 2026
17 checks passed
@tbrent
tbrent deleted the 4.3.0-audit-bypass-on-switch branch December 1, 2026 17:30
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