Skip to content

fix: surface oracle reverts from ERC20PriceOracleReceiptVault._nextId#302

Merged
thedavidmeister merged 3 commits into
mainfrom
2026-05-14-issue-299-oracle-revert-passthrough
May 14, 2026
Merged

fix: surface oracle reverts from ERC20PriceOracleReceiptVault._nextId#302
thedavidmeister merged 3 commits into
mainfrom
2026-05-14-issue-299-oracle-revert-passthrough

Conversation

@thedavidmeister
Copy link
Copy Markdown
Collaborator

@thedavidmeister thedavidmeister commented May 14, 2026

Summary

  • Drop the bare try/catch around priceOracle.price() in _nextId. The catch returned 0, collapsing every oracle error into a downstream Panic(0x12) from divide-by-zero in _calculateMint/_calculateDeposit, erasing the actual selector (e.g. Pyth StalePrice()).
  • ERC4626's "MUST NOT revert" surface (max*) is unaffected — those functions don't route through _nextId. mint/deposit may revert, and previewMint/previewDeposit may revert "due to other conditions that would also cause deposit/mint to revert" per spec; a reverting oracle qualifies.
  • Independent of this PR, the max* surface has its own MUST-NOT-revert gap (maxWithdraw(owner, 0) panics) tracked in Add ERC4626 spec compliance test suite #303.

Closes #299

Test plan

  • New fuzz tests assert the oracle's custom selector propagates through mint, deposit, previewMint, previewDeposit.
  • TDD-verified: tests fail against unfixed code with Panic(0x12) / ZeroSharesAmount(); pass after the fix.
  • Full suite green (344/344 non-fork tests pass).
  • CI passes

🤖 Generated with Claude Code

Drops the bare `try/catch` around `priceOracle.price()`. The catch returned
0, which collapsed every oracle error into a downstream `Panic(0x12)` from
divide-by-zero in `_calculateMint`/`_calculateDeposit`, erasing the actual
selector (e.g. Pyth `StalePrice()`) from integrators and on-chain monitors.

The ERC4626 "MUST NOT revert" requirement applies to the view-only `max*`
functions; `mint`/`deposit` may revert, and `previewMint`/`previewDeposit`
may revert "due to other conditions that would also cause deposit/mint to
revert" — a reverting oracle qualifies.

Closes #299

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this May 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Warning

Rate limit exceeded

@thedavidmeister has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 17 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0d82b0cf-14c5-44a8-ae18-7e86b00e3f7d

📥 Commits

Reviewing files that changed from the base of the PR and between 78390b1 and 096b0f4.

📒 Files selected for processing (2)
  • src/concrete/vault/ERC20PriceOracleReceiptVault.sol
  • test/src/concrete/vault/ERC20PriceOracleReceiptVault.oracleRevert.t.sol
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-05-14-issue-299-oracle-revert-passthrough

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

Comment @coderabbitai help to get the list of available commands and usage tips.

thedavidmeister and others added 2 commits May 14, 2026 17:25
Asserts the MUST-NOT-revert clause that PR #302's description references:
`max*` view functions don't route through `_nextId` so a reverting oracle
can't propagate into them. `id` is bounded > 0 to isolate the oracle
hypothesis — `maxWithdraw(owner, 0)` separately panics inside
`_calculateRedeem`, which is a pre-existing ERC4626 violation tracked in
#303 and out of scope here.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`max*` view functions never call `_nextId`, so an oracle revert can't
reach them whether or not the try/catch exists. The bounded-id assertion
passed equivalently before and after this PR — it pinned nothing this
change affects. The MUST-NOT-revert clause is tracked in #303 (full
ERC4626 spec compliance), which `maxWithdraw(owner, 0)` already violates
independently of oracle state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thedavidmeister thedavidmeister merged commit d581ee7 into main May 14, 2026
4 checks passed
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.

ERC20PriceOracleReceiptVault._nextId() swallows oracle revert, hiding cause behind divide-by-zero panic

1 participant