{
 "item": "core-ledger-positions",
 "commit": "ff1c192b3798542997f600091f2dc73ff05e4c40",
 "forge": "forge Version: 1.9.0 (6056c5845d), run with --use solar (Solar 0.8.38), --match-path test/scratch/CoreLedgerPositions.t.sol",
 "verdict": "findings",
 "findings": [
  {
   "id": "CLP-1",
   "severity": "low",
   "title": "An operator holding SET_RATE alone keeps a charged change's top-up premium alive indefinitely: a same-rate setRate inside the cooldown keeps premiumRate and restarts the clock, so the owner's borrows weeks later still pay RATE_COOLDOWN at the pre-change rate",
   "property": "P4 (premium only inside a charged change's cooldown); C5 (SET_RATE alone can never add debt)",
   "claim": "C5 / README:1249 worse than written",
   "files": [
    "src/LedgerSettlement.sol:232",
    "src/LedgerSettlement.sol:253",
    "src/LedgerSettlement.sol:254",
    "src/LedgerSettlement.sol:255",
    "src/Ledger.sol:256",
    "src/Ledger.sol:257"
   ],
   "sequence": "1) owner opens 10,000 at 30%; 2) +1 day owner setRate 2% (charged at 30%, premiumRate = 30%); 3) owner grants op SET_RATE only (mask 4); 4) every 6 days op calls setRate(id, 2%) (newRate == oldRate: allowed for an operator, no premium, line 253 skipped, line 254 skipped because inCooldown, line 255 restarts lastRateChange); 5) day 19 (the charged change's cooldown ended on day 8) owner borrows 10,000.",
   "expected": "P4: the premium is owed only inside the charged change's cooldown; after day 8 a top-up pays the upfront fee only. README:1249 says an operator's change restarts the cooldown and 'the owner's next change then pays the premium'.",
   "actual": "The top-up pays 57.534246575342465754 imdUSD extra (7 days at 30% on 10,000), minted as interest. As long as the operator repeats the same-rate call within each 7 days, every owner borrow pays the premium at the ORIGINAL pre-change rate (up to MAX_RATE: 1.92% of each borrow), not only the owner's next rate change. RateManager itself cannot do this (it skips r == p.rate, src/managers/RateManager.sol:202), so it is a raw operator grant (any manager contract or key given SET_RATE).",
   "reachableAtDeploy": true,
   "fix": "In LedgerSettlement.setRate, return early (no state change) when newRate == oldRate, or only restart lastRateChange on an actual change; at least do not let a non-owner's same-rate call extend a premium window (e.g. require msg.sender == owner when newRate == oldRate && inCooldown && p.premiumRate != 0).",
   "test": {
    "source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {Modules} from \"test/utils/Modules.sol\";\nimport {Test} from \"forge-std/Test.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {ImdUSD} from \"src/ImdUSD.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Treasury, ICoverable} from \"src/Treasury.sol\";\nimport {PositionNFT} from \"src/PositionNFT.sol\";\nimport {Ledger, IPulse} from \"src/Ledger.sol\";\nimport {LedgerBase} from \"src/LedgerBase.sol\";\nimport {Redeemer} from \"src/Redeemer.sol\";\nimport {Liquidator} from \"src/Liquidator.sol\";\nimport {Join} from \"src/Join.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {Adjust} from \"src/interfaces/IPositions.sol\";\n\ncontract CTok is ERC20 {\n    constructor() ERC20(\"WETH\", \"WETH\") {}\n    function mint(address to, uint256 a) external { _mint(to, a); }\n}\n\ncontract CFeed is IFeed {\n    uint256 public value;\n    uint64 public updatedAt;\n    uint256 public age = 365 days;\n    constructor(uint256 v) { value = v; updatedAt = uint64(block.timestamp); }\n    function set(uint256 v) external { value = v; updatedAt = uint64(block.timestamp); }\n    function setAge(uint256 a) external { age = a; }\n    function latestValue() external view returns (uint256, uint64) { return (value, updatedAt); }\n    function isStale() external view returns (bool) { return block.timestamp - updatedAt > age; }\n    function maxAge() external view returns (uint256) { return age; }\n}\n\ncontract CoreLedgerPositionsTest is Test {\n    bytes32 constant ETH = \"ETH\";\n    address governor = makeAddr(\"governor\");\n    address alice = makeAddr(\"alice\");\n    address bob = makeAddr(\"bob\");\n    address op = makeAddr(\"op\");\n\n    ImdUSD usd;\n    Parameters params;\n    Pricer pricer;\n    Treasury treasury;\n    Ledger ledger;\n    PositionNFT nft;\n    Redeemer redeemer;\n    Join join;\n    CTok weth;\n    CFeed feed;\n    uint256[] ids;\n\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        weth = new CTok();\n        feed = new CFeed(2000e18);\n        usd = new ImdUSD(address(this), 10_000_000e18, address(0));\n        params = Modules.newParameters(governor, address(this));\n        pricer = new Pricer(params);\n        treasury = new Treasury(governor, IERC20(address(usd)), address(this));\n        nft = new PositionNFT(address(this));\n        ledger = Modules.newLedger(usd, params, pricer, address(treasury), address(this), IPulse(address(0)), nft);\n        nft.bind(address(ledger));\n        redeemer = new Redeemer(ledger);\n        Liquidator liquidator = new Liquidator(ledger, pricer);\n        ledger.wire(address(redeemer), address(liquidator));\n        usd.wire(address(ledger), address(Modules.newHub(usd, governor, address(treasury))), address(params));\n        params.wire(address(ledger), address(usd));\n        treasury.wire(ICoverable(address(ledger)));\n        join = new Join(address(weth), address(this));\n        join.wire(address(ledger));\n        params.addGenesisIlk(\n            ETH,\n            ParametersBase.Config({\n                token: address(weth), join: address(join), median: feed, spot: feed, yieldRate: address(0),\n                pegAggregator: address(0), redeemable: true\n            }),\n            _risk(0.01e18, 1_000_000e18)\n        );\n        params.seal();\n        address[3] memory who = [alice, bob, op];\n        for (uint256 i; i < 3; ++i) {\n            weth.mint(who[i], 1000e18);\n            vm.prank(who[i]);\n            weth.approve(address(ledger), type(uint256).max);\n        }\n        ids.push(ledger.positionId(alice, ETH, 0));\n        ids.push(ledger.positionId(alice, ETH, 1));\n        ids.push(ledger.positionId(bob, ETH, 0));\n    }\n\n    function _risk(uint64 floor, uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.4e18, chop: 0.1e18, cut: 0.5e18, chip: 0.1e18, rateFloor: floor, yieldFee: 0, skew: 0.05e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 2\n        });\n    }\n\n    function _a(int256 dc, int256 dd, uint64 rate) internal pure returns (Adjust memory) {\n        return Adjust(dc, dd, rate, 0, 0, false, type(uint256).max, address(0));\n    }\n\n    function _prem(uint256 amount, uint256 rate) internal pure returns (uint256) {\n        return (amount * rate * 7 days + 365 days * 1e18 - 1) / (365 days * 1e18);\n    }\n\n    function _owner(uint256 k) internal view returns (address) { return k == 2 ? bob : alice; }\n    function _salt(uint256 k) internal pure returns (uint256) { return k == 1 ? 1 : 0; }\n\n    /// P1 at rest after every step of a random sequence (several txs per block when dt = 0, consecutive blocks, days).\n    function _checkP1() internal view {\n        (uint128 sDebt, uint128 sColl, uint256 weighted,,) = ledger.ilkState(ETH);\n        uint256 sumDebt; uint256 sumColl; uint256 sumW;\n        for (uint256 k; k < ids.length; ++k) {\n            LedgerBase.Position memory p = ledger.position(ids[k]);\n            sumDebt += ledger.debtOf(ids[k]);\n            sumColl += p.collateral;\n            sumW += uint256(p.debt) * p.rate;\n            if (p.debt != 0) {\n                assertTrue(p.rate <= 1e18 && p.rate >= params.storedRisk(ETH).rateFloor, \"P3 rate range\");\n            }\n        }\n        assertGe(ledger.ilkDebt(ETH), sumDebt, \"P1 aggregate below sum of positions\");\n        assertGe(uint256(sDebt), 0);\n        assertEq(weighted, sumW, \"P1 weighted\");\n        assertEq(uint256(sColl), sumColl, \"P1 collateral\");\n        assertEq(weth.balanceOf(address(join)), sumColl + ledger.owedToTreasury(address(join)), \"P1 join\");\n    }\n\n    function testFuzz_P1_randomSequence(uint256 seed) public {\n        for (uint256 step; step < 30; ++step) {\n            seed = uint256(keccak256(abi.encode(seed, step)));\n            uint256 k = seed % 3;\n            uint256 op_ = (seed >> 8) % 7;\n            uint256 x = seed >> 16;\n            address who = _owner(k);\n            vm.startPrank(who);\n            if (op_ == 0) {\n                try ledger.open(ETH, _salt(k), _a(int256(1e18 + x % 50e18), int256(100e18 + x % 30_000e18), uint64(0.01e18 + x % 0.3e18))) {} catch {}\n            } else if (op_ == 1) {\n                try ledger.adjust(ids[k], _a(0, -int256(1 + x % 20_000e18), 0)) {} catch {}\n            } else if (op_ == 2) {\n                try ledger.adjust(ids[k], _a(0, -type(int256).max, 0)) {} catch {}\n                try ledger.adjust(ids[k], _a(-int256(uint256(ledger.position(ids[k]).collateral)), 0, 0)) {} catch {}\n            } else if (op_ == 3) {\n                try ledger.setRate(ids[k], uint64(0.01e18 + x % 0.5e18), 0, 0) {} catch {}\n            } else if (op_ == 4) {\n                try ledger.adjust(ids[k], _a(0, int256(1 + x % 5_000e18), 0)) {} catch {}\n            } else if (op_ == 5) {\n                if (usd.balanceOf(who) > 0) {\n                    try redeemer.redeem(ETH, 1 + x % usd.balanceOf(who), 1e18, 3, 0) {} catch {}\n                }\n            } else {\n                try ledger.adjust(ids[k], _a(-int256(1 + x % 10e18), 0, 0)) {} catch {}\n            }\n            vm.stopPrank();\n            uint256 dt = (seed >> 200) % 4;\n            vm.warp(block.timestamp + (dt == 0 ? 0 : dt == 1 ? 12 : dt == 2 ? 1 days : 8 days));\n            _checkP1();\n        }\n    }\n\n    /// P3: a charged change adds exactly RATE_COOLDOWN at the old rate; an operator with SET_RATE alone cannot pay it.\n    function testFuzz_P3_premiumExactAndOwnerOnly(uint256 debtSeed, uint64 r0, uint64 r1, uint256 dt) public {\n        uint256 d = bound(debtSeed, 100e18, 50_000e18);\n        r0 = uint64(bound(r0, 0.01e18, 1e18));\n        r1 = uint64(bound(r1, 0.01e18, 1e18));\n        vm.assume(r0 != r1);\n        dt = bound(dt, 0, 7 days - 1);\n        vm.prank(alice);\n        uint256 id = ledger.open(ETH, 0, _a(100e18, int256(d), r0));\n        vm.warp(block.timestamp + dt);\n        vm.prank(alice);\n        nft.approveOperator(id, op, 4); // SET_RATE only\n        vm.prank(op);\n        vm.expectRevert(LedgerBase.NotOwner.selector);\n        ledger.setRate(id, r1, 0, 0);\n        vm.expectRevert(LedgerBase.RateOutOfRange.selector);\n        vm.prank(alice);\n        ledger.setRate(id, 0.009e18, 0, 0);\n        uint256 before = ledger.debtOf(id);\n        uint256 collBefore = ledger.position(id).collateral;\n        vm.prank(alice);\n        ledger.setRate(id, r1, 0, 0);\n        assertEq(ledger.debtOf(id), before + _prem(before, r0), \"premium exact\");\n        assertEq(ledger.position(id).collateral, collBefore, \"no collateral moved\");\n        // after the cooldown a change is free and the operator may make it\n        vm.warp(block.timestamp + 7 days);\n        uint256 b2 = ledger.debtOf(id);\n        vm.prank(op);\n        ledger.setRate(id, r0, 0, 0);\n        assertEq(ledger.debtOf(id), b2, \"free change\");\n    }\n\n    /// Low: an operator with SET_RATE alone re-sets the SAME rate inside a charged change's cooldown; this keeps\n    /// premiumRate and restarts the clock, so the owner's borrow 20 days after the charged change still pays the premium.\n    function test_operatorSameRateExtendsTopUpPremium() public {\n        vm.prank(alice);\n        uint256 id = ledger.open(ETH, 0, _a(100e18, int256(10_000e18), 0.30e18));\n        vm.warp(block.timestamp + 1 days);\n        vm.prank(alice);\n        ledger.setRate(id, 0.02e18, 0, 0); // charged at 30%: premiumRate = 30%\n        vm.prank(alice);\n        nft.approveOperator(id, op, 4); // SET_RATE only\n        for (uint256 i; i < 3; ++i) {\n            vm.warp(block.timestamp + 6 days);\n            vm.prank(op);\n            ledger.setRate(id, 0.02e18, 0, 0); // same rate: free, allowed, restarts the cooldown, keeps premiumRate\n        }\n        // 19 days after the charged change (its cooldown ended on day 8)\n        ledger.accrue(ETH);\n        uint256 fee = ledger.upfrontFeeFor(ETH, 10_000e18, 0.02e18);\n        uint256 before = ledger.debtOf(id);\n        vm.prank(alice);\n        ledger.adjust(id, _a(0, int256(10_000e18), 0));\n        uint256 premium = ledger.debtOf(id) - before - 10_000e18 - fee;\n        emit log_named_uint(\"premium paid on a top-up 19 days after the charged change\", premium);\n        assertEq(premium, 0, \"P4: premium only inside the charged change's cooldown\");\n    }\n\n    /// P2 + C7: stale feed (unpriced), line 0 (frozen), cap far below market: full repay and full withdrawal go through;\n    /// a de-risking repay-and-withdraw goes through at low under a cap; a plain withdrawal is refused.\n    function test_P2_exitUnderEveryStop() public {\n        vm.prank(alice);\n        uint256 id = ledger.open(ETH, 0, _a(10e18, int256(5_000e18), 0.05e18));\n        vm.prank(governor);\n        params.lowerCap(ETH, 100e18);\n        vm.prank(alice);\n        vm.expectRevert(LedgerBase.Unhealthy.selector);\n        ledger.adjust(id, _a(-1e18, 0, 0));\n        vm.prank(alice);\n        ledger.adjust(id, _a(-4e18, -2_500e18, 0)); // de-risking: measured at low, not the cap\n        vm.prank(alice);\n        ledger.setRate(id, 0.06e18, 0, 0); // charged change at low, not at cap (C7)\n        vm.prank(governor);\n        params.lowerLine(ETH, 0);\n        feed.setAge(1);\n        vm.warp(block.timestamp + 3 days);\n        deal(address(usd), alice, 10_000e18, true);\n        vm.startPrank(alice);\n        ledger.adjust(id, _a(0, -type(int256).max, 0));\n        ledger.adjust(id, _a(-int256(uint256(ledger.position(id).collateral)), 0, 0));\n        vm.stopPrank();\n        assertEq(ledger.debtOf(id), 0);\n        assertEq(ledger.position(id).collateral, 0);\n        assertEq(weth.balanceOf(alice), 1000e18);\n    }\n\n    /// C2: touching a position every block (1-wei repays, same-rate setRate after cooldown) never leaves it owing less\n    /// than an untouched twin; 1-wei borrow/repay loops never lower debt.\n    function testFuzz_C2_touchLoopsNoGain(uint256 n, uint256 d, uint64 r) public {\n        n = bound(n, 1, 40);\n        d = bound(d, 200e18, 100_000e18);\n        r = uint64(bound(r, 0.01e18, 1e18));\n        vm.prank(alice);\n        uint256 a = ledger.open(ETH, 0, _a(1000e18, int256(d), r));\n        vm.prank(bob);\n        uint256 b = ledger.open(ETH, 0, _a(1000e18, int256(d), r));\n        uint256 repaid;\n        vm.warp(block.timestamp + 8 days);\n        for (uint256 i; i < n; ++i) {\n            vm.warp(block.timestamp + 12);\n            vm.startPrank(alice);\n            ledger.adjust(a, _a(0, -1, 0));\n            ++repaid;\n            uint256 pre = ledger.debtOf(a);\n            ledger.adjust(a, _a(0, 1, 0)); // 1-wei borrow pays a fee >= 1 wei\n            ledger.adjust(a, _a(0, -1, 0));\n            ++repaid;\n            assertGe(ledger.debtOf(a), pre, \"borrow/repay 1 wei lowered debt\");\n            vm.stopPrank();\n        }\n        assertGe(ledger.debtOf(a) + repaid, ledger.debtOf(b), \"touch loop gain\");\n    }\n\n    /// C4: a raised rateFloor leaves a sub-floor position borrowing NEW debt at its old rate, at the head of the order;\n    /// the owner cannot re-set that rate, and once repaid to zero cannot reopen at it.\n    function test_C4_raisedFloor() public {\n        vm.prank(alice);\n        uint256 id = ledger.open(ETH, 0, _a(100e18, int256(1_000e18), 0.01e18));\n        vm.prank(bob);\n        ledger.open(ETH, 0, _a(100e18, int256(1_000e18), 0.05e18));\n        vm.prank(governor);\n        params.propose(abi.encode(uint8(1), ETH, _risk(0.03e18, 1_000_000e18)));\n        vm.warp(block.timestamp + 48 hours);\n        params.applyPending(uint8(1));\n        vm.prank(alice);\n        ledger.adjust(id, _a(0, int256(50_000e18), 0)); // new debt at 1% under a 3% floor\n        assertEq(ledger.position(id).rate, 0.01e18);\n        assertGt(ledger.position(id).debt, 51_000e18);\n        vm.prank(alice);\n        vm.expectRevert(LedgerBase.RateOutOfRange.selector);\n        ledger.setRate(id, 0.01e18, 0, 0);\n    }\n\n    /// C3: a transfer carries rate, cooldown and premiumRate; the new owner's top-up and rate change pay as the old owner's\n    /// would, in the same block as the transfer; a stale signature/rights of the old owner do nothing.\n    function test_C3_transferCarriesCooldown() public {\n        vm.prank(alice);\n        uint256 id = ledger.open(ETH, 0, _a(100e18, int256(10_000e18), 0.30e18));\n        vm.prank(alice);\n        ledger.setRate(id, 0.02e18, 0, 0);\n        vm.prank(alice);\n        nft.approveOperator(id, op, 0xff);\n        vm.prank(alice);\n        nft.transferFrom(alice, bob, id);\n        vm.prank(op);\n        vm.expectRevert();\n        ledger.adjust(id, _a(0, 1e18, 0)); // old owner's grant died with the epoch\n        uint256 fee = ledger.upfrontFeeFor(ETH, 1_000e18, 0.02e18);\n        uint256 before = ledger.debtOf(id);\n        vm.prank(bob);\n        ledger.adjust(id, _a(0, int256(1_000e18), 0));\n        assertEq(ledger.debtOf(id) - before - 1_000e18 - fee, _prem(1_000e18, 0.30e18), \"top-up premium carried\");\n        uint256 b2 = ledger.debtOf(id);\n        vm.prank(bob);\n        ledger.setRate(id, 0.05e18, 0, 0);\n        assertEq(ledger.debtOf(id), b2 + _prem(b2, 0.02e18), \"charged change carried\");\n        // the position moved whole: collateral and debt together\n        assertEq(ledger.position(id).collateral, 100e18);\n    }\n}\n",
    "ran": "forge 1.9.0 --use solar --match-path test/scratch/CoreLedgerPositions.t.sol --fuzz-runs 2000",
    "result": "[FAIL: P4: premium only inside the charged change's cooldown: 57534246575342465754 != 0] test_operatorSameRateExtendsTopUpPremium() (gas: 1868364). Same run: [PASS] testFuzz_C2_touchLoopsNoGain (runs: 2000), [PASS] testFuzz_P1_randomSequence (runs: 2000), [PASS] testFuzz_P3_premiumExactAndOwnerOnly (runs: 2000), [PASS] test_C3_transferCarriesCooldown, [PASS] test_C4_raisedFloor, [PASS] test_P2_exitUnderEveryStop"
   }
  }
 ],
 "claims": [
  {
   "id": "C1",
   "result": "holds",
   "evidence": "Every write of Position.debt goes through LedgerBase._record (src/LedgerBase.sol:359-371). Callers: Ledger._adjust (src/Ledger.sol:304, borrow + upfront fee 229-236 + cooldown premium 255-264, repay 273-279), Ledger.harvest (src/Ledger.sol:171, records _harvest's credit), LedgerSettlement.setRate (src/LedgerSettlement.sol:256), redeemPosition (:95), liquidatePosition (:168, :172). _harvest (LedgerBase.sol:375-404) never writes p.debt (only s.debt, collateral, yieldMark). _debtOf (LedgerBase.sol:352) is a view. grep of src/ and script/ found no other writer (script/ only references them in house mutation tooling). Note: the sheet names Ledger.harvest's credit as '_harvest's credit': the record is in Ledger.harvest:171 and in each touch."
  },
  {
   "id": "C2",
   "result": "holds",
   "evidence": "_accrue rounds the aggregate up (LedgerBase.sol:265), _upfrontFee/_premium round up (:316), _debtOf rounds each position down (:355): a position never owes more than the aggregate holds. testFuzz_C2_touchLoopsNoGain (2000 runs, n<=40 consecutive blocks of 1-wei repay + 1-wei borrow + 1-wei repay, debt 200..100k, rate 1%..100%): a touched position always owes >= its untouched twin minus the wei repaid, and every 1-wei borrow raised debt (fee rounds up to >=1 wei). The per-position floor (<1 wei per touch) is outweighed by the compounding of a touch (_record writes accrued interest into principal). Residue: the aggregate's ceil minus the position's floor stays in ilk.debt with no borrower (documented at LedgerBase.sol:305-306)."
  },
  {
   "id": "C3",
   "result": "holds",
   "evidence": "A transfer moves the whole Position record under its id (collateral, debt, rate, lastRateChange, premiumRate); PositionNFT._update bumps epochOf (per-id operator grants die) and calls Ledger.onTransfer, which is nonReentrant (Ledger.sol:179), so no transfer lands inside a Ledger call. test_C3_transferCarriesCooldown: after a charged change and a transfer in the same block, the old owner's operator (mask 0xff) is refused, the new owner's top-up pays premium at premiumRate (30%) exactly, and their setRate pays 7d at the current rate exactly. Fresh salt: pays only the upfront fee at the type's average (LedgerBase.sol:309-312), as LedgerBase.sol:120-122 states; dust reopen + top-up: existing test/unit/AuditW1PremiumLaunder.t.sol PASS at this commit. The README:1249 cost is exceeded by an operator only as CLP-1."
  },
  {
   "id": "C4",
   "result": "holds",
   "evidence": "test_C4_raisedFloor: after SET_RISK raises rateFloor 1% -> 3% (proposed, 48h, applied by a stranger), a 1% position borrows 50,000 of NEW debt at 1% (Ledger.sol:238 only checks the floor when the position had no debt), staying at the head of the redemption order and pulling the type's average (and so every newcomer's upfront fee, LedgerBase.sol:310) down; its owner cannot re-set or re-confirm the 1% rate (setRate reverts RateOutOfRange, LedgerSettlement.sol:222) and after a repay to zero cannot reopen at 1%. So beyond 'redeemed first': unbounded new sub-floor debt and a lowered upfront-fee average. Within the stated design (no lift in the core); not filed as a finding."
  },
  {
   "id": "C5",
   "result": "refuted",
   "evidence": "setRate itself holds (NotOwner at LedgerSettlement.sol:235, testFuzz_P3_premiumExactAndOwnerOnly 2000 runs), and a reopen at another rate needs BORROW too (Ledger.sol:191, 245). But a SET_RATE-only operator makes the owner's later borrows carry premium debt indefinitely via same-rate calls: CLP-1."
  },
  {
   "id": "C6",
   "result": "holds",
   "evidence": "delegatecall sites in src: src/Ledger.sol:401, src/Parameters.sol:336,358, src/house/Ledger.sol:494, src/house/Parameters.sol:440,462: exactly the four pairs test/unit/AuditD1Layout.t.sol:16-19 checks; that test PASSES at this commit (--use solar). Compiler layouts (forge inspect storageLayout) of Ledger and LedgerSettlement are identical slot by slot (redeemer 0, liquidator 1, _positions 2, _ilkList 3, _ilkIndex 4, ilkState 5, reserveBacked 6, totalBadDebt 7, owedToTreasury 8); the reentrancy lock is transient (same base)."
  },
  {
   "id": "C7",
   "result": "holds",
   "evidence": "test_P2_exitUnderEveryStop: with Parameters.lowerCap at 100 (market 2000) a plain withdrawal is refused (Unhealthy, measured at cap), a ratio-keeping repay-and-withdraw passes at low (Ledger.sol:311-324) and a charged setRate passes at low (LedgerSettlement.sol:247). Both are measured at market low with the live mat, so no position is left under its line at market; no cap-sheltered gain found (_deRisking compares post-state to pre-state with the same debt including harvest)."
  },
  {
   "id": "C8",
   "result": "holds",
   "evidence": "Non-owner changes: addFor/repayFor (authorized=true, Ledger.sol:133-146: only dCollateral>0 / dDebt<0), Ledger.harvest (permissionless, yield types), redeemPosition (Redeemer), liquidatePosition (Liquidator), operator rights (PositionNFT.checkRights, per-id per-epoch or the owner's allRights), signed openFor/borrowFor/permitOperator (execute checks ownerOf == signer, Ledger.sol:127). Ledger.open on an id the caller created but no longer owns is _adjust with rights checked. ERC-721 approval holders can transfer the position (standard, owner-granted). No other route found."
  }
 ],
 "holds": [
  {
   "property": "P1",
   "tried": "testFuzz_P1_randomSequence, 2000 runs x 30 steps over 3 positions/2 owners: open, partial repay, full repay + full withdraw, setRate, top-up borrow, Redeemer.redeem, withdraw, with dt in {0 (same block), 12 s, 1 day, 8 days}; after every step: ilkDebt >= sum debtOf, weighted == sum debt_i*rate_i, ilk.collateral == sum collateral, Join balance == sum collateral + owedToTreasury, every indebted rate in [rateFloor, MAX_RATE]. No violation. Read: harvest/redeem/liquidate keep s.collateral/s.debt and the Join in step (LedgerBase.sol:397-401, LedgerSettlement.sol:92-98, 160-180). Liquidation not exercised by the fuzz (read only)."
  },
  {
   "property": "P2",
   "tried": "test_P2_exitUnderEveryStop: cap far below market, line lowered to 0 (frozen), median stale (unpriced): full repay (dDebt = -int256.max clamps) and full withdrawal succeed, collateral returned in full. Repay/deposit never read borrowable (Ledger.sol:195, 296); _accrue/_mintInterest have no revert on brake or line. Braked (hub loss) is only checked on dDebt>0 and charged setRate (Ledger.sol:271, LedgerSettlement.sol:243): read, not fuzzed. Config is never deleted (ParametersBase.sol:274 is the only writer), so _config cannot lock a repay."
  },
  {
   "property": "P3",
   "tried": "testFuzz_P3_premiumExactAndOwnerOnly 2000 runs (debt 100..50k, both rates 1%..100%, dt 0..7d-1): premium == ceil(debt*oldRate*7d/YEAR) exactly, collateral unchanged, operator with SET_RATE refused (NotOwner) in cooldown, rate below floor refused, free and allowed to the operator after the cooldown. Line/brake/lines/borrowable+agree/health at low with live mat are checked at LedgerSettlement.sol:242-247. Holds except the premium-window extension in CLP-1."
  },
  {
   "property": "P4",
   "tried": "Upfront fee on every dDebt>0 (Ledger.sol:228-237), premium on top-ups inside a charged change's cooldown (Ledger.sol:256-264), carried across a transfer (test_C3). Fails only as CLP-1 (premium outside the charged change's cooldown)."
  },
  {
   "property": "P5",
   "tried": "AuditD1Layout PASS; forge inspect storageLayout of Ledger and LedgerSettlement identical; both inherit only LedgerBase and declare only immutables."
  }
 ],
 "notRun": [
  "No [fork]/[data] claims in this sheet: NOT RUN (none needed).",
  "Liquidation and yield-type (harvest) routes were read, not fuzzed.",
  "Brake via a real hub loss: read only."
 ]
}