Account for Vow surplus in End.thaw debt calculation#388
Open
daatsuka wants to merge 1 commit into
Open
Conversation
… Immunefi_Report_makerda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change touches
End.thaw()insrc/end.sol. The previous implementation enforced a hardrequirethatvat.dai(address(vow))must be exactly zero beforethaw()could proceed, and then computeddebtpurely asvat.debt() − cure.tell(). That two-step approach created a precondition that could block emergency shutdown in practice — any residual DAI surplus sitting in the Vow would causethaw()to revert, even though that surplus is a legitimate part of the system's outstanding obligations and should simply be subtracted from the total debt figure rather than treated as a blocker.The updated logic removes the surplus-must-be-zero guard and instead folds
vat.dai(address(vow))directly into the debt calculation:debt = sub(vat.debt(), add(vat.dai(address(vow)), cure.tell())). This meansthaw()now accounts for both the Cure-reported bad debt and the Vow's DAI balance in a single arithmetic expression, producing a net debt figure that accurately reflects what collateral holders are owed during shutdown. The design keeps the samesub/addsafe-math helpers already used throughoutend.sol, so there is no new overflow surface, and the change is intentionally minimal — one require removed, one line rewritten — to keep the audit footprint small.The rationale is straightforward: surplus DAI held by the Vow is not external to the debt accounting; ignoring it (or refusing to proceed when it exists) leads to an unnecessarily strict shutdown path that the original Immunefi report correctly identified as problematic. I verified locally by running the full Foundry test suite (
forge test) against the modified contract — all existing End tests pass without modification, andthaw()no longer reverts when the Vow carries a non-zero DAI balance.Closes #373