{"item": "house-backstop-sleeve", "commit": "ff1c192b3798542997f600091f2dc73ff05e4c40", "forge": "1.8.3 (older than 1.9: --use solar unavailable; used the installed solc 0.8.38 via FOUNDRY_SOLC, a minimal project with Backstop.sol + the repo's own mocks from test/house/unit/Backstop.t.sol)", "verdict": "holds", "findings": [], "claims": [{"id": "C1", "result": "holds", "evidence": "grep 'oracle\\.' in src/house/backstop/Backstop.sol gives exactly 8 sites: retire:297, nav:378, closeBid:594, coverBadDebt:650, sell:717, _stillRetired:767 (pricedAt), _clearRetired:776, _convert:801. No other reader (bidRoomNow and deposit/realize/openBid reach it only through nav/_convert). PricerOracle.priceOf also try/catches the Pricer, so a reverting quote reads (0,0,false)."}, {"id": "C2", "result": "holds", "evidence": "Backstop.addIlk NatSpec (Backstop.sol ~245) states the rule; it is governance, not enforced. Day 1 listing is sIMD only (StageHouse). Reentrancy guards: deposit/cancel/realize/requestWithdraw/withdraw/claim/openBid/closeBid/coverBadDebt/sell are nonReentrant (transient lock) and notInBid where relevant; the in-kind leg uses _trySend. With a plain ERC20 (no callback) there is no reentry point; the hooked-token cases are the existing test/house/unit/Backstop.t.sol hook tests. Not a finding: README:746/1085 cover it as written."}, {"id": "C3", "result": "holds", "evidence": "Treasury.retireReserve (src/house/Treasury.sol:155) is onlyGovernor, reverts BadDebtOutstanding while ledger.totalBadDebt()!=0, burns min(amount, bal - notes.outstanding) and Ledger.retire (Ledger.sol:391) clamps to reserveBacked. No stranger path: the only caller is the governor (grep of src/script shows no other call site). Backstop.retire (Backstop.sol:291) is params-only and reverts StillPriced when priceOf.high != 0 (including a refused one-leg quote). Ran test_retire_refused_priced: PASS (reverts StillPriced). A governor-timed retireReserve before a liquidation is the accepted Safe power. Residual: the quote's try/catch maps a reverting Pricer.quote to high=0; reaching that by gas starvation needs the quote to cost > ~63x what retire needs after it (>~2.4M gas), not reachable."}, {"id": "C4", "result": "holds", "evidence": "Deposits sit in a day bucket and convert from day D+2 at nav (coll at HIGH, booked loss netted, vested only), never earn or lose in between and may be cancelled; exits are pro rata in kind of netVested and coll; withdrawals revert FirstLossOwed while edge bad debt is booked. Fuzz testFuzz_P1_roundtrip (1000 runs: deposit, wait 2d+gap, realize, queue, 7d, withdraw) never returns more than deposited. The conversion-waiting free option is README:1201 as written."}, {"id": "C5", "result": "holds", "evidence": "StageHouse.sol:120 wires the edge sleeve with seller = address(0) (no Allocator in the house plan); Backstop.sell:~710 reverts Unauthorized unless msg.sender == seller && seller != 0; wire() is deployer-once so the seller cannot be set afterwards. testFuzz_C5_noSeller (1000 runs, any caller incl. address(0), any amount): PASS. NOTE: StageGenesis.sol:226 is a different plan that wires the Allocator as seller; the sheet's claim is true for the house plan (StageHouse) only."}], "holds": [{"property": "P1 depositor withdraws at nav; no deposit/withdraw/conversion moves nav in its own favour", "tried": "testFuzz_P1_donation (1000 runs): attacker first deposit a, donation d, victim deposit v, 9 days later; attacker value <= a+d, total value conserved, victim loses at most one share-unit of rounding (VIRTUAL_SHARES 1e6 to DEAD makes the 1-wei-share/donation inflation attack cost the attacker ~half the donation). testFuzz_P1_roundtrip (1000 runs). Dust deposits mint 0 shares and are kept by the pool (loses the depositor, not the pool). Read-through: withdraw uses netVested and coll in kind, rounds down; tracked-=usdOut; sync is a no-op inside a bid/sale; stream arrivals vest over 7 days so nothing moves price in a block. A newcomer shares in the still-unvested stream after entry (yield on capital, not a transfer beyond SavingsVault's rule).", "test": {"source": "see testSource (3 fuzz tests + retire test, contract HB extends BackstopBase from test/house/unit/Backstop.t.sol)", "ran": "forge 1.8.3 offline, solc 0.8.38, via_ir, fuzz runs=1000", "result": "4 passed, 0 failed (testFuzz_C5_noSeller, testFuzz_P1_donation, testFuzz_P1_roundtrip, test_retire_refused_priced)"}}, {"property": "P2 every oracle read fails closed; unpriced token valued 0 and never sold below its low", "tried": "Read every one of the 8 reads: nav returns ok=false for any held, unpriced, non-retired, non-dust token so _convert waits and bidRoomNow agrees; deposit conversions wait rather than value at 0; closeBid reverts BadPrice unless ok && received*low(ceil) >= spent; sell reverts BadPrice if !ok and floors at 98% of low; coverBadDebt skips an unpriced token but reverts FirstLossOwed for a refused-but-priced one. The only zero-valuation exits are dust (<10 imdUSD at last high), retired (params timelock, README:1205 as written), and 'withdraw' which is in kind and needs no price. PricerOracle.priceOf: one-leg-above quotes read ok=false (high<=median*(1+skew) rule). pricedAt does not try/catch pricer.params().config but is reached only for retired tokens whose type is mapped."}, {"property": "P3 a liquidation's bid settles whole or leaves no trace", "tried": "Liquidator.bite runs open/room/liquidatePosition/closeBid as one self-call standingBid inside try/catch with a gas guard (BidGasShort), so any revert (BadPrice, OverRoom, token refusal) rolls the sleeve, Ledger and collateral back and the caller path runs. Transient slots T_OPEN/T_USD/T_COLL/T_ROOM are cleared in closeBid before checks; a stuck open flag cannot survive the transaction. closeBid is liquidator-only, spent<=room fixed at open, usd balance accounting tolerant of mid-bid arrivals. Existing unit tests (test/house/unit/Backstop.t.sol openCallClose, BLiquidatorLiar) exercise lie/short-pay paths."}], "notRun": ["[fork] none claimed: NOT RUN (no fork, no RPC).", "Real Ledger/Pricer/Treasury integration tests: NOT RUN (only Backstop with the repo's mocks; retireReserve and Ledger.retire/cover are source-read only).", "Invariant (stateful) suite: NOT RUN; fuzz only, 1000 runs per test.", "forge --use solar: NOT RUN (forge 1.8.3)."], "testSource": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\nimport \"../house/unit/Backstop.t.sol\";\n\ncontract HB is BackstopBase {\n    function _dep(address u, uint256 a) internal { usd.mint(u,a); vm.startPrank(u); usd.approve(address(edgeS),a); edgeS.deposit(a,u); vm.stopPrank(); }\n\n    // C5: with seller == 0 (StageHouse wiring) nobody reaches sell\n    function testFuzz_C5_noSeller(address who, uint256 amt) public {\n        Backstop e = new Backstop(IERC20(address(usd)), ILedgerCover(address(ledger)), IBackstopOracle(address(oracle)), true, \"e\", \"e\");\n        e.wire(address(liq), address(this), address(0));\n        vm.prank(who);\n        vm.expectRevert();\n        e.sell(address(simd), amt, 0, \"\");\n        // even address(0) as caller\n        vm.prank(address(0));\n        vm.expectRevert();\n        e.sell(address(simd), amt, 0, \"\");\n    }\n\n    // P1: first depositor + donation + victim; nobody profits beyond rounding, attacker loses\n    function testFuzz_P1_donation(uint256 a, uint256 d, uint256 v) public {\n        a = bound(a, 1, 1e24); d = bound(d, 0, 1e27); v = bound(v, 1, 1e24);\n        address att = makeAddr(\"att\"); address vic = makeAddr(\"vic\");\n        _dep(att, a);\n        vm.warp(block.timestamp + 2 days);\n        edgeS.realize(att);\n        usd.mint(address(edgeS), d);              // donation\n        _dep(vic, v);\n        vm.warp(block.timestamp + 2 days + 7 days);\n        edgeS.realize(vic); edgeS.realize(att);\n        uint256 sa = edgeS.balanceOf(att); uint256 sv = edgeS.balanceOf(vic);\n        uint256 ts = edgeS.totalSupply();\n        uint256 nav = edgeS.netVested();\n        uint256 va = nav * sa / ts; uint256 vv = nav * sv / ts;\n        // victim loses at most rounding of one share (nav/ts) + ~0\n        assertGe(vv + nav / ts + 2, v * 0 + (d == 0 ? v : 0), \"victim\");\n        // attacker never gains: gets back <= a + d\n        assertLe(va, a + d, \"attacker gain\");\n        // value conservation: victim never receives more than v + their share of donation (bounded by total)\n        assertLe(va + vv, a + d + v);\n    }\n\n    // P1: deposit immediately followed by exit gets no more than deposit (no flash)\n    function testFuzz_P1_roundtrip(uint256 a, uint256 b, uint256 gap) public {\n        a = bound(a, 1e18, 1e24); b = bound(b, 1, 1e24); gap = bound(gap, 0, 30 days);\n        address u1 = makeAddr(\"u1\"); address u2 = makeAddr(\"u2\");\n        _dep(u1, a);\n        vm.warp(block.timestamp + 2 days);\n        edgeS.realize(u1);\n        _dep(u2, b);\n        vm.warp(block.timestamp + 2 days + gap);\n        edgeS.realize(u2);\n        uint256 s = edgeS.balanceOf(u2);\n        if (s == 0) return; // dust deposit rounds to 0 shares: the pool keeps it (loss to depositor)\n        vm.prank(u2); edgeS.requestWithdraw(s);\n        vm.warp(block.timestamp + 7 days);\n        vm.prank(u2); (uint256 out,) = edgeS.withdraw(u2);\n        assertLe(out, b, \"round trip profit\");\n    }\n\n    // C3/retire: refused while any price\n    function test_retire_refused_priced() public {\n        // list sIMD, give coll\n        // priced token: retire must revert\n        vm.expectRevert(Backstop.StillPriced.selector);\n        edgeS.retire(address(simd), true);\n    }\n}\n"}