Repository navigation
fix(H3): per-share floor (mid-term flows cannot dilute protection) - #12
Merged
Merged
Conversation
Audit H3 (deepest finding): protectedAmount was a whole-vault aggregate frozen at term start, but settleEpoch mints/burns shares mid-term as routine keeper op. Nothing rescaled it, so per-share protection (protectedAmount/supply) drifted: a mid-term deposit silently halved every holder's floor (90% -> 45%) and a mid-term redeem forced a phantom shortfall + full de-risk, breaking the core promise with no attacker and no >1/m gap. Fix: FloorPolicy now stores protectedPerShareWad/hwmNavPerShareWad/ lastFloorPerShareWad and operates on navPerShare; the controller threads share supply through startTerm/assess/settleTerm and reconstructs the aggregate floor = floorPerShare * supply. Per-share protection is now invariant to mint/burn. Added controller.protectedPerShareWad(), protectedAmount(supply), lastFloorAggregate; startTerm/assess revert on zero supply. Regression tests: mid-term deposit preserves per-share floor; mid-term redeem yields zero shortfall at maturity. 114 -> 116.
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.
Audit finding H3 (High) — the deepest issue
protectedAmountwas stored as a whole-vault aggregate, frozen once at term start (termStartNav x P), butsettleEpochmints/burns shares mid-term as routine keeper operation and nothing rescaled it. So the thing that matters to a holder, the per-share floor (protectedAmount / totalSupply), drifted freely:protectedAmountunchanged against a smaller NAV, forcing a phantom shortfall and full de-risk of the survivors.Root tension: capital protection is a per-share promise stored over a variable supply.
Fix
Store and compute the floor per share:
FloorPolicy.State:protectedPerShareWad,hwmNavPerShareWad,lastFloorPerShareWad;currentFloor/previewFlooroperate onnavPerShare; the Step ratchet raises the per-share protected amount.CPPIController:startTerm/assess/settleTermtake sharesupply, initialize fromnav/supply, and reconstruct the aggregate floor =floorPerShare * supplyfor the cushion/target/drift math. New viewsprotectedPerShareWad(),protectedAmount(supply), andlastFloorAggregate/lastFloor();startTerm/assessrevert on zero supply.CPPIVault: passestotalSupply()through.Per-share protection is now invariant to mint/burn, so mid-term flows can neither dilute existing holders' floor nor manufacture a phantom shortfall.
Tests
2 new regression tests (mid-term deposit preserves per-share floor; mid-term redeem gives zero shortfall at maturity) plus all existing floor/controller/integration/invariant/crash suites updated to the supply-threaded signatures. Suite 114 -> 116; 9/9 fork tests green locally.