{"item":"gov-live-positions","commit":"ff1c192b3798542997f600091f2dc73ff05e4c40","forge":"1.10.1 (7c15a1d), --use solar; installed forge was 1.8.3","verdict":"findings","findings":[{"id":"GLP-1","severity":"medium","title":"A SET_RISK that raises skew, applied by anyone, makes healthy open positions liquidatable in the applying block: skew is read live, makes no risk version and gets no RISK_GRACE (core and house)","property":"P1; the Parameters guarantee quoted in src/ParametersBase.sol:213-214 ('any other change binds RISK_GRACE later, so open positions are never made liquidatable by a governance change without a week to repair')","claim":"C1","files":["src/Pricer.sol:66","src/Pricer.sol:67-71","src/ParametersRules.sol:153-154","src/ParametersBase.sol:213","src/house/Pricer.sol:103","script/DeployConfig.sol:786"],"sequence":"Two-leg type (median != spot; day 1: wstETH, median = market leg, spot = rate leg), skew 5%. 1) Safe proposes SET_RISK(ilk) with only skew raised (any value up to MAX_SKEW 25%; rule-abiding, mat and chop unchanged so ParametersRules.sol:153 pushes no version). 2) Any time in the 14 days after the ETA the legs stand apart by more than the old skew and less than the new one with spot below median: Pricer returns low = median, positions are healthy. 3) A keeper sends applyPending(1) + liquidate(id) in one transaction: agree flips to true, low = min(median, spot) falls by the gap (up to 25%), the position is liquidated with the full chop. The applier picks the moment; the Safe cannot know the leg gap 48 h to 16 days ahead.","expected":"A governed change never makes an open position liquidatable in the block it lands; a harsher liquidation rule binds open positions only after RISK_GRACE (7 days), as mat and chop do.","actual":"Position at 148% (mat 140%), median unchanged at 2000, spot 1700: liquidate reverts before the apply; after applyPending in the same block it repays 13,516.65 and seizes 8.746 ETH (penalty 1,351.66 USD). riskVersion unchanged. The fuzz over (newSkew in 7-25%, gap between old and new skew) fails on the first run; the same test on the house contracts fails too (testFuzz_F1h_skewRaise_noGrace, source under GLP-6).","reachableAtDeploy":"yes: needs one rule-abiding SET_RISK by the Safe (48 h) on a two-leg type; genesis skew is 0.05e18 (script/DeployConfig.sol:336) and MAX_SKEW is 0.25e18","fix":"Treat a skew RAISE as a harsher liquidation rule: keep skew in LiqRisk (versioned with mat/chop, bindAt = now + RISK_GRACE for a raise, at once for a lower) and let liquidation health read the position's bound skew; or let a raised skew widen only the borrow side (q.borrowable) at once and the liquidation `low` after RISK_GRACE.","test":{"source":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {System} from \"../utils/System.sol\";\nimport {MockERC20, MockFeed} from \"../utils/Mocks.sol\";\nimport {ParametersBase} from \"../../src/ParametersBase.sol\";\nimport {Adjust} from \"../../src/Ledger.sol\";\nimport {_pid} from \"../utils/Pid.sol\";\n\ncontract YRate {\n uint256 public rate = 1e18;\n function set(uint256 r) external { rate = r; }\n}\n\ncontract GovLiveCore is System {\n bytes32 constant ETH = \"ETH\";\n bytes32 constant YLD = \"YLD\";\n bytes32 constant TGT = \"TGT\";\n MockERC20 weth; MockERC20 ytok; MockERC20 ttok;\n MockFeed med; MockFeed spot; MockFeed yfeed; MockFeed tfeed;\n YRate yrate;\n address alice = makeAddr(\"alice\");\n address bob = makeAddr(\"bob\");\n address dave = makeAddr(\"dave\");\n address stranger = makeAddr(\"stranger\");\n mapping(uint256 => bool) internal _opened;\n\n function setUp() public {\n  vm.warp(1_800_000_000);\n  weth = new MockERC20(\"WETH\", 18); ytok = new MockERC20(\"YLD\", 18); ttok = new MockERC20(\"TGT\", 18);\n  med = new MockFeed(2000e18); spot = new MockFeed(2000e18); yfeed = new MockFeed(100e18); tfeed = new MockFeed(2000e18);\n  yrate = new YRate();\n  _deploySystem(IERC20(address(new MockERC20(\"imdUSDv1\", 18))));\n  _addIlk(ETH, address(weth), med, spot, address(0), address(0), true, _risk(1.4e18, 1_000_000e18));\n  _addIlk(YLD, address(ytok), yfeed, yfeed, address(yrate), address(0), true, _risk(1.4e18, 1_000_000e18));\n  _addIlk(TGT, address(ttok), tfeed, tfeed, address(0), address(0), true, _risk(1.4e18, 1_000_000e18));\n  params.setGenesisTarget(TGT, 0.2e18);\n  params.setGenesisCap(ETH, 3000e18);\n  params.setGenesisChainLine(10_000_000e18);\n  params.seal();\n  for (uint256 i; i < 3; ++i) {\n   address u = [alice, bob, dave][i];\n   weth.mint(u, 1000e18); ytok.mint(u, 1000e18); ttok.mint(u, 1000e18);\n   vm.startPrank(u);\n   weth.approve(address(ledger), type(uint256).max);\n   ytok.approve(address(ledger), type(uint256).max);\n   ttok.approve(address(ledger), type(uint256).max);\n   vm.stopPrank();\n  }\n }\n\n function _skip(uint256 dt) internal { vm.warp(vm.getBlockTimestamp() + dt); }\n function _refresh() internal { med.set(med.value()); spot.set(spot.value()); yfeed.set(yfeed.value()); tfeed.set(tfeed.value()); }\n function _adjust(address u, bytes32 ilk, int256 coll, int256 debt, uint64 rate) internal {\n  Adjust memory a = Adjust(coll, debt, rate, 0, 0, false, type(uint256).max, address(0));\n  uint256 id = _pid(ilk, u);\n  bool exists = _opened[id];\n  vm.prank(u);\n  if (exists) ledger.adjust(id, a); else ledger.open(ilk, 0, a);\n  _opened[id] = ledger.ilkOf(id) != bytes32(0);\n }\n function _propose(bytes memory p) internal { vm.prank(governor); params.propose(p); }\n // ... the test functions quoted per finding go here\n}\n\n // F1: a skew raise applied by anyone makes an open position liquidatable in the applying block (no version, no grace).\n function testFuzz_F1_skewRaise_noGrace(uint64 newSkew, uint256 gap) public {\n  newSkew = uint64(bound(newSkew, 0.07e18, 0.25e18));\n  gap = bound(gap, 0.065e18, newSkew - 0.002e18);\n  _adjust(alice, ETH, 10e18, 13_500e18, 0.05e18); // 148% at mat 140%\n  ParametersBase.Risk memory r = params.storedRisk(ETH);\n  r.skew = newSkew;\n  _propose(abi.encode(params.SET_RISK(), ETH, r));\n  _skip(48 hours);\n  med.set(2000e18);\n  spot.set(2000e18 * (1e18 - gap) / 1e18); // the legs are apart past the old skew: low = median\n  uint256 id = _pid(ETH, alice);\n  (bool ok,) = ledger.healthy(id);\n  assertTrue(ok, \"healthy before the apply\");\n  uint256 v = params.riskVersion(ETH);\n  vm.prank(stranger);\n  params.applyPending(1);\n  assertEq(params.riskVersion(ETH), v, \"no version: RISK_GRACE does not apply\");\n  (ok,) = ledger.healthy(id);\n  assertTrue(ok, \"P1: a governed change made an open position liquidatable in the applying block\");\n }\n\n function test_F1_skewRaise_applyThenLiquidate_sameBlock() public {\n  _adjust(alice, ETH, 10e18, 13_500e18, 0.05e18);\n  _adjust(dave, ETH, 200e18, 50_000e18, 0.05e18);\n  ParametersBase.Risk memory r = params.storedRisk(ETH);\n  r.skew = 0.25e18;\n  _propose(abi.encode(params.SET_RISK(), ETH, r));\n  _skip(48 hours);\n  med.set(2000e18); spot.set(1700e18); // 15% apart\n  uint256 id = _pid(ETH, alice);\n  vm.prank(dave);\n  vm.expectRevert(); // Healthy\n  liquidator.liquidate(id);\n  vm.startPrank(dave);\n  params.applyPending(1);\n  (uint256 repaid, uint256 seized,) = liquidator.liquidate(id);\n  vm.stopPrank();\n  emit log_named_decimal_uint(\"repaid\", repaid, 18);\n  emit log_named_decimal_uint(\"seized ETH\", seized, 18);\n  emit log_named_decimal_uint(\"penalty USD at low\", seized * 1700 - repaid, 18);\n  assertEq(seized, 0, \"P1: liquidated in the block of the apply, median unchanged, no grace\");\n }\n","ran":"forge test --use solar --match-path test/scratch/GovLiveCore.t.sol -vv (forge 1.10.1, commit ff1c192)","result":"[FAIL: P1: a governed change made an open position liquidatable in the applying block; counterexample: args=[0, 0]] testFuzz_F1_skewRaise_noGrace(uint64,uint256) (runs: 0) | [FAIL: P1: liquidated in the block of the apply, median unchanged, no grace: 8746065953219343658 != 0] test_F1_skewRaise_applyThenLiquidate_sameBlock() Logs: repaid: 13516.647382248076562207, seized ETH: 8.746065953219343658, penalty USD at low: 1351.664738224807656393"}},{"id":"GLP-2","severity":"low","title":"A yieldFee raise is retroactive on unharvested yield and can make a healthy position liquidatable in the applying block","property":"P1; same RISK_GRACE guarantee (src/ParametersBase.sol:213)","claim":"C1","files":["src/LedgerBase.sol:394","src/LedgerBase.sol:446","src/ParametersRules.sol:154"],"sequence":"Yield type, yieldFee 0, a position with unharvested yield (share rate above its yieldMark). Safe's SET_RISK raises yieldFee (<= 25%); it matures. Health is judged on the state after the pending harvest, at the fee in force. Anyone: applyPending(1) then liquidate(id): the harvest now gives the Treasury 25% of ALL yield since the mark, the debt credit shrinks, the position that was healthy one call earlier is liquidated. Without a liquidation the borrower still loses (new fee - old fee) of the yield earned before the change. (savingsShare is split the same way at accrual, src/LedgerBase.sol:275: read from code, not tested.)","expected":"Yield earned before the apply is charged the fee in force when it was earned (the apply harvests / snapshots first), and no apply flips an open position to liquidatable.","actual":"Fuzz over the collateral price: first counterexample at price 92.946 (position opened at 100, rate +20% unharvested): healthy before applyPending, unhealthy after, same block, same feeds.","reachableAtDeploy":"yes on any type with a yieldRate, after one rule-abiding SET_RISK; bounded by 25% of the unharvested yield (anyone can harvest a position before the apply, which removes it)","fix":"Version yieldFee with the liquidation risk (a raise binds after RISK_GRACE), or stamp the fee per position at each harvest so a new fee applies only to yield after the first harvest that follows the apply.","test":{"source":"// harness: GLP-1 (ilk YLD has yieldRate = YRate)\n // F3: yieldFee raise is retroactive on unharvested yield and can flip health in the applying block.\n function testFuzz_F3_yieldFee_retroactive(uint256 px) public {\n  _adjust(alice, YLD, 100e18, 7_000e18, 0.05e18);\n  ParametersBase.Risk memory r = params.storedRisk(YLD);\n  r.yieldFee = 0.25e18;\n  _propose(abi.encode(params.SET_RISK(), YLD, r));\n  _skip(48 hours);\n  yrate.set(1.2e18);\n  yfeed.set(bound(px, 85e18, 110e18));\n  uint256 id = _pid(YLD, alice);\n  (bool ok,) = ledger.healthy(id);\n  vm.assume(ok);\n  vm.prank(stranger);\n  params.applyPending(1);\n  (ok,) = ledger.healthy(id);\n  assertTrue(ok, \"P1: yieldFee raise made an open position liquidatable in the applying block\");\n }\n","ran":"forge test --use solar --match-path test/scratch/GovLiveCore.t.sol -vv (forge 1.10.1, commit ff1c192)","result":"[FAIL: P1: yieldFee raise made an open position liquidatable in the applying block; counterexample: args=[1032139217719657317987458100644941049]] testFuzz_F3_yieldFee_retroactive(uint256) (runs: 0) Logs: Bound result 92946172531936154760"}},{"id":"GLP-3","severity":"low","title":"The liquidator's only guard (minSeized) binds neither what it receives nor what it pays: a matured cut/chip or SET_TARGET change applied in front passes the guard","property":"P1 (applied in front of any liquidator act); README.md:1180 states the guard only for a price update","claim":"C1","files":["src/Liquidator.sol:150","src/LedgerSettlement.sol:156-157","src/LedgerSettlement.sol:136","src/ParametersRules.sol:154","src/ParametersRules.sol:179"],"sequence":"(a) SET_RISK raising cut (cut + chip <= 1e18) matures. A keeper quotes liquidate(id) and sends liquidate(id, minSeized = quoted seized). A stranger (or the block builder) puts applyPending(1) in front: seized is unchanged (versioned chop) so the guard passes, but toTreasury = bonus x cut is taken from the payer's collateral: at cut + chip = 1e18 a payer who is not the marker receives collateral worth exactly what it burned. (b) SET_TARGET(ilk, 0) (or a dust raise) matures on a type with a target buffer; applied in front of the keeper's liquidate, the partial liquidation becomes a full close: seized rises, so minSeized passes; the keeper burns 2.36x the quoted imdUSD (or reverts on balance) and the borrower pays chop on all the debt instead of the part restoring mat + buffer, with no grace.","expected":"A liquidation executes as quoted or reverts: the caller can bound its payout and its repay; the borrower's liquidation size does not change inside the block of the liquidation.","actual":"(a) quoted payout 8.0869 ETH, actual 7.9328 ETH at cut 0.5 -> 0.70, guard passed (fuzz over cut 0.55-0.9 fails on run 0). (b) quoted repay 4,239.46 / seized 3.355, actual repay 10,012.33 / seized 7.923.","reachableAtDeploy":"(a) yes after a rule-abiding SET_RISK; (b) only once a target buffer is set (no setGenesisTarget call in script/: day-1 buffers are 0, so it needs a SET_TARGET first)","fix":"liquidate/bite(id, minSeized, minPayout, maxRepay) checked against what the Ledger returns (seized - toTreasury - toMarker and repaid); version cut/chip/targetBuffer with mat/chop if the borrower side should also keep the 7 days.","test":{"source":"// harness: GLP-1 (ilk TGT has targetBuffer 0.2e18)\n // F2: cut raise in front of a liquidator: minSeized passes, the payer receives less than quoted.\n function testFuzz_F2_cutRaise_guardPasses(uint64 newCut) public {\n  newCut = uint64(bound(newCut, 0.55e18, 0.9e18));\n  _adjust(alice, ETH, 10e18, 10_000e18, 0.05e18);\n  _adjust(dave, ETH, 200e18, 50_000e18, 0.05e18);\n  ParametersBase.Risk memory r = params.storedRisk(ETH);\n  r.cut = newCut;\n  _propose(abi.encode(params.SET_RISK(), ETH, r));\n  _skip(48 hours);\n  med.set(1300e18); spot.set(1300e18);\n  uint256 id = _pid(ETH, alice);\n  uint256 snap = vm.snapshotState();\n  uint256 b = weth.balanceOf(dave);\n  vm.prank(dave);\n  (, uint256 s0,) = liquidator.liquidate(id);\n  uint256 got0 = weth.balanceOf(dave) - b;\n  vm.revertToState(snap);\n  assertGt(got0, 0);\n  vm.prank(stranger);\n  params.applyPending(1);\n  vm.prank(dave);\n  (, uint256 s1,) = liquidator.liquidate(id, s0); // the guard a keeper sets from his quote\n  uint256 got1 = weth.balanceOf(dave) - b;\n  assertEq(s1, s0, \"guard passes\");\n  emit log_named_decimal_uint(\"quoted payout ETH\", got0, 18);\n  emit log_named_decimal_uint(\"actual payout ETH\", got1, 18);\n  assertGe(got1, got0, \"P1: guard passed, payer received less than quoted\");\n }\n\n // F2b: SET_TARGET to 0 in front of a liquidation: partial becomes a full close, no bound on what the payer burns.\n function test_F2_targetDrop_fullClose() public {\n  _adjust(alice, TGT, 10e18, 10_000e18, 0.05e18);\n  _adjust(dave, ETH, 200e18, 50_000e18, 0.05e18);\n  _propose(abi.encode(params.SET_TARGET(), TGT, uint64(0)));\n  _skip(48 hours);\n  _refresh();\n  tfeed.set(1390e18);\n  uint256 id = _pid(TGT, alice);\n  uint256 snap = vm.snapshotState();\n  vm.prank(dave);\n  (uint256 r0, uint256 s0,) = liquidator.liquidate(id);\n  vm.revertToState(snap);\n  vm.prank(stranger);\n  params.applyPending(22);\n  vm.prank(dave);\n  (uint256 r1, uint256 s1,) = liquidator.liquidate(id, s0);\n  emit log_named_decimal_uint(\"quoted repay\", r0, 18);\n  emit log_named_decimal_uint(\"actual repay\", r1, 18);\n  emit log_named_decimal_uint(\"quoted seized\", s0, 18);\n  emit log_named_decimal_uint(\"actual seized\", s1, 18);\n  assertLe(r1, r0, \"P1: the liquidation the keeper quoted is not the one he paid; the borrower pays chop on all debt\");\n }\n","ran":"forge test --use solar --match-path test/scratch/GovLiveCore.t.sol -vv (forge 1.10.1, commit ff1c192)","result":"[FAIL: P1: guard passed, payer received less than quoted: 7932847181233593788 < 8086883049208250935; counterexample: args=[481304084]] testFuzz_F2_cutRaise_guardPasses(uint64) (runs: 0) | [FAIL: P1: the liquidation the keeper quoted is not the one he paid; the borrower pays chop on all debt: 10012331394257834490523 > 4239460461625070369674] test_F2_targetDrop_fullClose() Logs: quoted repay: 4239.460461625070369674, actual repay: 10012.331394257834490523, quoted seized: 3.354968710638544897, actual seized: 7.923427722074545280"}},{"id":"GLP-4","severity":"low","title":"MorphoLender APPROVE has no order-independent stop: applied by a stranger in front of the Safe's cancel, the market is listed for life and the allocator can lend into it at once","property":"P1 (applied in front of any Safe act); the class fixed elsewhere by 'the lower always lands' (GovernedByKind.sol:74-76 comment)","claim":"C1","files":["src/morpho/MorphoLender.sol:318-319","src/morpho/MorphoLender.sol:241-248","src/morpho/MorphoLender.sol:336","src/GovernedByKind.sol:83-85"],"sequence":"APPROVE(market, cap) is pending and matured; the Safe learns the market must not go live (wrong oracle, wrong LLTV) and sends cancel(APPROVE). A stranger (or the allocator, an adversary in the threat model) applies first: cancel(kind) is a silent no-op (GovernedByKind.sol:84), the row exists with its cap, rows are never removed (MAX_MARKETS 24 for life, StockLiquidator accepts it for good) and the allocator can supply(n, cap) in the next call: hub-minted imdUSD lent to the market the Safe withdrew. The only other stop, lowerCap(n, 0), reverts OutOfBounds while the row does not exist (MorphoLender.sol:336), so the batch [cancel(APPROVE), lowerCap(n,0)] reverts as a whole when nobody front-ran it and leaves the proposal pending: no single Safe transaction is right in both orders. RAISE_CAP and SET_ALLOCATOR do have one (lowerCap, revokeAllocator: testFuzz_H2_lowerWins passes).","expected":"One Safe transaction leaves a withdrawn market unlendable whichever side of a stranger's applyPending it lands on.","actual":"strangerFirst = true: marketCount 4 after the Safe's cancel; allocator's supply(3, 100,000e18) succeeds. strangerFirst = false: lowerCap(3, 0) reverts.","reachableAtDeploy":"yes on 4663 after the first APPROVE proposal; loss bounded by the proposed cap and the lender's hub row","fix":"An instant `refuse(Id id)` (onlyGovernor) that never reverts: _clear(APPROVE) if the pending payload names id, else if indexOf[id] != 0 set that row's cap to 0 (and clear its RAISE_CAP); or make lowerCap take the market Id and no-op on an unlisted one after clearing APPROVE.","test":{"source":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {LenderBase} from \"../utils/LenderBase.sol\";\nimport {MockERC20} from \"../utils/Mocks.sol\";\nimport {MockStockOracle} from \"../utils/MockMorpho.sol\";\nimport {MarketParams} from \"../../src/vendor/morpho/IMorpho.sol\";\n\ncontract GovLiveLender is LenderBase {\n MarketParams p;\n\n function _pend() internal {\n  MockERC20 s = new MockERC20(\"NEW\", 18);\n  MockStockOracle o = _mockOracle(address(s), address(usd));\n  p = MarketParams(address(usd), address(s), address(o), address(irm), LLTV);\n  _seed(p);\n  vm.prank(governor);\n  lender.propose(abi.encode(APPROVE, p, uint128(100_000e18)));\n  _pass(48 hours);\n }\n\n // The Safe decides a matured APPROVE must not go live. Property: ONE Safe transaction leaves the market unlendable\n // whether or not a stranger applied the proposal in front.\n function test_F5_approve_noOrderIndependentStop(bool strangerFirst) public {\n  _pend();\n  if (strangerFirst) { vm.prank(stranger); lender.applyPending(APPROVE); }\n  vm.prank(governor);\n  lender.cancel(APPROVE); // never reverts; a silent no-op once applied\n  if (!strangerFirst) {\n   vm.prank(governor);\n   vm.expectRevert(); // OutOfBounds: the only other stop, lowerCap(3, 0), cannot ride in the same batch\n   lender.lowerCap(3, 0);\n   return;\n  }\n  assertEq(lender.marketCount(), 3, \"P1: the market the Safe cancelled is listed for life\");\n }\n\n function test_F5_allocatorLendsIntoCancelledMarket() public {\n  _pend();\n  vm.prank(stranger); lender.applyPending(APPROVE);\n  vm.prank(governor); lender.cancel(APPROVE);\n  vm.prank(allocator);\n  vm.expectRevert(); // P1: nothing is lent to a market the Safe withdrew\n  lender.supply(3, 100_000e18);\n }\n\n // testFuzz_H2_lowerWins: a passing holds test, omitted here for size\n}\n","ran":"forge test --use solar --match-path test/scratch/GovLiveLender.t.sol -vv","result":"[PASS] testFuzz_H2_lowerWins(uint128,uint128,bool,uint128) (runs: 256) | [FAIL: next call did not revert as expected] test_F5_allocatorLendsIntoCancelledMarket() | [FAIL: P1: the market the Safe cancelled is listed for life: 4 != 3; counterexample: args=[true]] test_F5_approve_noOrderIndependentStop(bool) (runs: 0)"}},{"id":"GLP-5","severity":"low","title":"MarketCalendar2 SET_OFFSETS: the same matured proposal gives a different table depending on the UTC day it is applied; an entry it was written to replace becomes permanent at its fromDay","property":"P1 (applied by anyone at any moment)","claim":"C1","files":["src/stocks/MarketCalendar2.sol:288-290","src/stocks/MarketCalendar2.sol:298-301","src/stocks/MarketCalendar2.sol:268"],"sequence":"The table holds a wrong future entry (T+5: 5 h, a week before DST really ends). The Safe proposes the correction at once (the new future part: [T+12: computed rule]); it matures on day T+4 14:00 UTC. Applied before T+5 00:00 UTC the wrong entry is popped. Applied 10 h or more later (nobody is obliged to apply; the 4663 sequencer and builders, in the threat model, can hold an applyPending back for those hours) `_kept(today)` counts the wrong entry as in force: it is kept, the proposal still applies without error, and the entry can never be removed (entries with fromDay <= today are never popped). Every stock market's session is then shifted by one hour until the next entry: the oracle reads CLOSED from 09:30 to 10:30 New York (no liquidation in the first hour) and REGULAR from 16:00 to 17:00 (after-hours prints price and liquidate). Each kept entry also uses one of MAX_OFFSETS = 32 slots for good.","expected":"A proposal applies to the same result at any moment of its 14-day window, or reverts when the state it was validated against is gone.","actual":"offsetOf(T+7) = 14400 when applied at the ETA, 18000 when applied later (first fuzz counterexample), and session(Mon 2026-10-26 16:30 New York) = REGULAR.","reachableAtDeploy":"needs a wrong offset entry first (a Safe mistake inside its rules) and an apply that slips past the entry's fromDay","fix":"Bind the payload to the table it replaces: carry the expected kept count (or the hash of the kept entries) in SET_OFFSETS and revert at apply if `_kept(today)` differs; the Safe then re-proposes knowingly.","test":{"source":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {MarketCalendar2} from \"../../src/stocks/MarketCalendar2.sol\";\nimport {RobinhoodConfig} from \"../../script/DeployConfig.sol\";\n\ncontract GovLiveCal is Test {\n address governor = makeAddr(\"safe\");\n MarketCalendar2 cal;\n uint256 T; // 2026-10-19, a Monday (EDT)\n\n function setUp() public {\n  (uint32[] memory closed, uint32[] memory early) = RobinhoodConfig.nyse2026to2028();\n  cal = new MarketCalendar2(governor, closed, early);\n  T = cal.daysFromCivil(2026, 10, 19);\n  vm.warp(T * 1 days + 14 hours);\n }\n\n function _offsets(uint256 day, uint256 west) internal {\n  uint64[] memory e = new uint64[](1);\n  e[0] = uint64(day << 32 | west);\n  vm.prank(governor);\n  cal.propose(abi.encode(uint8(2), e));\n }\n\n // F6: what a matured SET_OFFSETS does depends on the UTC day it is applied: the entries it was written to replace\n // become permanent at their fromDay. Property: applied at any moment of its window, a proposal gives the same table.\n function testFuzz_F6_offsetsApplyDate(uint256 late) public {\n  late = bound(late, 0, 7 days);\n  _offsets(T + 5, 5 hours); // a wrong entry: EST from Saturday, a week before DST ends\n  vm.warp(vm.getBlockTimestamp() + 48 hours);\n  cal.applyPending();\n  _offsets(T + 12, 0); // the correction, proposed at once: \"the future part of the table is: computed rule from T+12\"\n  vm.warp(vm.getBlockTimestamp() + 48 hours); // day T+4, 14:00 UTC\n  uint256 snap = vm.snapshotState();\n  cal.applyPending();\n  uint256 atEta = cal.offsetOf(T + 7);\n  assertEq(atEta, 4 hours);\n  vm.revertToState(snap);\n  vm.warp(vm.getBlockTimestamp() + late);\n  cal.applyPending();\n  (uint8 kind,,,) = cal.session((T + 7) * 1 days + 20 hours + 30 minutes); // Mon 2026-10-26 16:30 New York (EDT)\n  emit log_named_uint(\"session kind at 16:30 New York, after the close (1 = REGULAR)\", kind);\n  assertEq(cal.offsetOf(T + 7), atEta, \"P1: the same proposal, applied later, leaves the wrong offset in force for good\");\n }\n\n // testFuzz_H3_applyNeverMovesToday: a passing holds test, omitted here for size\n}\n","ran":"forge test --use solar --match-path test/scratch/GovLiveCal.t.sol -vv","result":"[FAIL: P1: the same proposal, applied later, leaves the wrong offset in force for good: 18000 != 14400; counterexample: args=[115792089237316195423570985008687907853269984665640564039457584007913129639933]] testFuzz_F6_offsetsApplyDate(uint256) (runs: 0) Logs: session kind at 16:30 New York, after the close (1 = REGULAR): 1 | [PASS] testFuzz_H3_applyNeverMovesToday(uint8,uint8,uint8,uint32,uint32,bool) (runs: 256)"}},{"id":"GLP-6","severity":"low","title":"House SET_MAX_LULL lowered: a marked NHI position loses the grace it was given at the mark, in the applying block","property":"P1","claim":"C1","files":["src/house/Liquidator.sol:143-144","src/house/Liquidator.sol:119","src/house/Pricer.sol:94","src/house/ParametersRules.sol:305"],"sequence":"NHI-linked type, maxLull 6 h. A position is barked: graces[id].end = now + 6 h and bite reverts InGrace. A matured SET_MAX_LULL(0) is applied by the keeper, who bites in the same block: `until = min(graces[id].end, m.at + q.lull)` re-derives the grace from the live maxLull, so the stored end is ignored. NHI types have no versioned mat (liqRisk returns 0 for them), so the lull is the only grace such a position has.","expected":"A grace given at the mark runs to the end stored with the mark; a lower maxLull applies to later marks.","actual":"bite reverts InGrace before the apply and succeeds after it in the same block, 6 h early: repaid 20,024.66, seized 8,009.87 sIMD (chop 20%).","reachableAtDeploy":"no: the staged house sets maxLull 0 (script/house/deploy/StageTypes.sol:71) and stages no NHI type; it needs SET_MAX_LULL up and an ADD_ILK with an nhi feed first","fix":"`until = graces[id].end` for a mark made before the change (store the lull in force at the mark; a lower maxLull never shortens a running grace).","test":{"source":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {System} from \"../utils/System.sol\";\nimport {MockERC20, MockFeed} from \"../utils/Mocks.sol\";\nimport {ParametersBase} from \"../../../src/house/ParametersBase.sol\";\nimport {Adjust} from \"../../../src/house/Ledger.sol\";\nimport {_pid} from \"../utils/Pid.sol\";\nimport {Pricer} from \"../../../src/house/Pricer.sol\";\nimport {IFeed} from \"../../../src/house/interfaces/IFeed.sol\";\n\ncontract GovLiveHouse is System {\n bytes32 constant ETH = \"ETH\";\n bytes32 constant SIMD = \"SIMD\";\n MockERC20 weth; MockERC20 simd;\n MockFeed med; MockFeed spot; MockFeed simdFeed; MockFeed nhi;\n address alice = makeAddr(\"alice\");\n address dave = makeAddr(\"dave\");\n address stranger = makeAddr(\"stranger\");\n mapping(uint256 => bool) internal _opened;\n\n function setUp() public {\n  vm.warp(1_800_000_000);\n  weth = new MockERC20(\"WETH\", 18); simd = new MockERC20(\"sIMD\", 18);\n  med = new MockFeed(2000e18); spot = new MockFeed(2000e18); simdFeed = new MockFeed(5e18); nhi = new MockFeed(0.98e18);\n  _deploySystem(IERC20(address(new MockERC20(\"imdUSDv1\", 18))));\n  _addIlk(ETH, address(weth), med, spot, IFeed(address(0)), address(0), address(0), true, _risk(1.4e18, 1_000_000e18));\n  ParametersBase.Risk memory ir = _risk(1.7e18, 1_000_000e18);\n  ir.chop = 0.2e18;\n  _addIlk(SIMD, address(simd), simdFeed, simdFeed, nhi, address(0), address(0), true, ir);\n  params.seal();\n  for (uint256 i; i < 2; ++i) {\n   address u = [alice, dave][i];\n   weth.mint(u, 1000e18); simd.mint(u, 1_000_000e18);\n   vm.startPrank(u);\n   weth.approve(address(ledger), type(uint256).max);\n   simd.approve(address(ledger), type(uint256).max);\n   vm.stopPrank();\n  }\n }\n function _skip(uint256 dt) internal { vm.warp(vm.getBlockTimestamp() + dt); }\n function _adjust(address u, bytes32 ilk, int256 coll, int256 debt, uint64 rate) internal {\n  Adjust memory a = Adjust(coll, debt, rate, 0, 0, false, type(uint256).max, address(0));\n  uint256 id = _pid(ilk, u);\n  bool exists = _opened[id];\n  vm.prank(u);\n  if (exists) ledger.adjust(id, a); else ledger.open(ilk, 0, a);\n  _opened[id] = ledger.ilkOf(id) != bytes32(0);\n }\n\n function testFuzz_F1h_skewRaise_noGrace(uint64 newSkew, uint256 gap) public {\n  newSkew = uint64(bound(newSkew, 0.07e18, 0.25e18));\n  gap = bound(gap, 0.065e18, newSkew - 0.002e18);\n  _adjust(alice, ETH, 10e18, 13_500e18, 0.05e18);\n  ParametersBase.Risk memory r = params.storedRisk(ETH);\n  r.skew = newSkew;\n  bytes memory pl = abi.encode(params.SET_RISK(), ETH, r); vm.prank(governor); params.propose(pl);\n  _skip(48 hours);\n  med.set(2000e18); spot.set(2000e18 * (1e18 - gap) / 1e18);\n  uint256 id = _pid(ETH, alice);\n  (bool ok,) = ledger.healthy(id);\n  assertTrue(ok, \"healthy before the apply\");\n  vm.prank(stranger); params.applyPending(1);\n  (ok,) = ledger.healthy(id);\n  assertTrue(ok, \"P1: a governed change made an open house position liquidatable in the applying block\");\n }\n\n // F7: lowering maxLull voids the grace a marked NHI position was given.\n function test_F7_maxLullLower_voidsRunningGrace() public {\n  _adjust(alice, SIMD, 10_000e18, 20_000e18, 0.05e18);\n  _adjust(dave, ETH, 200e18, 50_000e18, 0.05e18);\n  bytes memory pl = abi.encode(params.SET_MAX_LULL(), uint64(0)); vm.prank(governor); params.propose(pl);\n  _skip(48 hours);\n  med.set(2000e18); spot.set(2000e18); nhi.set(0.98e18);\n  simdFeed.set(3e18);\n  Pricer.Quote memory q = pricer.quote(SIMD);\n  emit log_named_uint(\"lull promised (s)\", q.lull);\n  uint256 id = _pid(SIMD, alice);\n  vm.prank(dave); liquidator.bark(id);\n  vm.prank(dave);\n  try liquidator.bite(id) { revert(\"no grace at all\"); } catch (bytes memory e) { assertEq(bytes4(e), bytes4(keccak256(\"InGrace(uint256)\")), \"held by the grace\"); }\n  vm.prank(stranger); params.applyPending(20);\n  vm.prank(dave);\n  (uint256 repaid, uint256 seized,) = liquidator.bite(id);\n  emit log_named_decimal_uint(\"repaid\", repaid, 18);\n  emit log_named_decimal_uint(\"seized sIMD\", seized, 18);\n  assertEq(seized, 0, \"P1: bitten in the block of the apply, 6 h before the grace given at the mark ends\");\n }\n}\n","ran":"forge test --use solar --match-path test/house/scratch/GovLiveHouse.t.sol -vv","result":"[FAIL: P1: a governed change made an open house position liquidatable in the applying block; counterexample: args=[0, 0]] testFuzz_F1h_skewRaise_noGrace(uint64,uint256) (runs: 0) | [FAIL: P1: bitten in the block of the apply, 6 h before the grace given at the mark ends: 8009865115406267592419 != 0] test_F7_maxLullLower_voidsRunningGrace() Logs: lull promised (s): 21600, repaid: 20024.662788515668981047, seized sIMD: 8009.865115406267592419"}},{"id":"GLP-7","severity":"info","title":"Core rateFloor raise does not reach open positions: they keep borrowing new debt below the floor (the core has no `lift`, the house has)","property":"P1 (rateFloor: 'lowest borrower-set annual rate', src/ParametersBase.sol:62)","claim":"C1","files":["src/Ledger.sol:238-239","src/house/LedgerSettlement.sol:57"],"sequence":"Position opened at 1% under floor 1%. SET_RISK raises rateFloor to 20%. A newcomer at 1% is refused (RateOutOfRange); the old position draws 400,000 more at 1%: the floor is checked only `if (!hadDebt)`. Sub-floor positions also stay first in the redemption order. No funds are lost; the governed number does not do what it says for live positions, in the direction the Safe wanted tighter.","expected":"No new debt is issued below the floor in force (or a permissionless lift as in the house).","actual":"adjust(+400,000e18) at 1% succeeds under a 20% floor.","reachableAtDeploy":"yes after a SET_RISK raising rateFloor","fix":"In `_adjust`, when dDebt > 0 and the position's rate is below the floor, move it to the floor (the house's `lift` rule), or port `lift` to the core.","test":{"source":"// harness: GLP-1\n // F4: a rateFloor raise does not bind top-ups of open positions.\n function test_F4_rateFloor_topUpBelowFloor() public {\n  _adjust(alice, ETH, 500e18, 10_000e18, 0.01e18);\n  ParametersBase.Risk memory r = params.storedRisk(ETH);\n  r.rateFloor = 0.2e18;\n  _propose(abi.encode(params.SET_RISK(), ETH, r));\n  _skip(48 hours); _refresh();\n  params.applyPending(1);\n  Adjust memory a = Adjust(100e18, 10_000e18, 0.01e18, 0, 0, false, type(uint256).max, address(0));\n  vm.prank(bob);\n  vm.expectRevert();\n  ledger.open(ETH, 0, a); // a newcomer at 1% is refused\n  a = Adjust(0, 400_000e18, 0.01e18, 0, 0, false, type(uint256).max, address(0));\n  uint256 id = _pid(ETH, alice);\n  vm.prank(alice);\n  vm.expectRevert(); // P: no new debt below the floor in force\n  ledger.adjust(id, a);\n }\n","ran":"forge test --use solar --match-path test/scratch/GovLiveCore.t.sol -vv (forge 1.10.1, commit ff1c192)","result":"[FAIL: next call did not revert as expected] test_F4_rateFloor_topUpBelowFloor()"}}],"claims":[{"id":"C1","result":"refuted","evidence":"P1 does not hold. The next sites after the ones the sheet lists as fixed, each with a failing test run at ff1c192: GLP-1 skew raise (core and house Pricer), GLP-2 yieldFee, GLP-3 cut/chip/targetBuffer in front of a liquidator, GLP-4 lender APPROVE vs cancel, GLP-5 calendar SET_OFFSETS apply day, GLP-6 house maxLull, GLP-7 core rateFloor. Fuzzed and passing (256 runs each): testFuzz_H1_versionedGrace (SET_RISK over mat, chop, dust, rateFloor, redeemFloor, redeemDivisor, line), testFuzz_C2_differentFieldCommutes, testFuzz_H2_lowerWins (lender RAISE_CAP / SET_ALLOCATOR), testFuzz_H3_applyNeverMovesToday (calendar SET_DAYS / SET_OFFSETS)."},{"id":"C2","result":"holds","evidence":"Core: testFuzz_C2_differentFieldCommutes [PASS, 256 runs]: a matured SET_CAP / SET_UNBACKED_BRAKE / SET_CHAIN_LINE / SET_TARGET / SET_RISK of another type / SET_EXOTIC_MARGIN (alone or inside a BATCH) and the Safe's lowerLine / lowerCap / lowerUnbackedBrake / lowerExoticMargin of a DIFFERENT field give the same final state in both orders and neither reverts. Lender: testFuzz_H2_lowerWins [PASS]. Calendar: closeDay vs a pending SET_OFFSETS read from code (MarketCalendar2.sol:230-250: closeDay drops only a SET_DAYS listing the day; SET_OFFSETS cannot move today or re-open a CLOSED day), not tested with closeDay itself. By design and not a finding: lowerLine(ilk) drops a pending SET_RISK of that type whole (its other fields with it), and SET_CHAIN_LINE, SET_TARGET, SET_SAVINGS_SHARE have no instant counterpart, so cancel(kind) after a stranger's apply is a no-op (the same shape as GLP-4, where it matters)."},{"id":"C3","result":"refuted","evidence":"No contract here has one invariant that covers every kind. Parameters (core, house): the only general rule is RISK_GRACE and it covers mat and chop only. Invariant to adopt: for every position p and every pending payload x, healthy(p) and the result of liquidatePosition(p) are the same immediately before and after applyPending(x), and stay so until min(RISK_GRACE, p's next risk-taking act). Smallest design: put every number a liquidation reads (mat, chop, skew, yieldFee, cut, chip, dust, targetBuffer, house maxLull) in the versioned LiqRisk with the existing bindAt rule, read them only through liqRisk(ilk, p.version), and have `_apply` settle what a rate-like number splits (harvest mark, accrue) before it writes. MorphoLender: invariant 'after an instant Safe act that tightens X to x, no applyPending leaves X looser than x, in either order' holds for RAISE_CAP and SET_ALLOCATOR and is missing for APPROVE (GLP-4): add refuse(Id). MarketCalendar2: 'no apply changes session(t) for any t of today or earlier' holds (H3 fuzz); missing: 'an apply's result does not depend on when it lands' (GLP-5): bind SET_OFFSETS to the kept count."}],"holds":[{"property":"P1, core SET_RISK (mat, chop, dust, rateFloor, redeemFloor, redeemDivisor, line)","tried":"testFuzz_H1_versionedGrace, 256 runs PASS: any rule-abiding values applied by a stranger; the open position is healthy at apply and through RISK_GRACE - 1; liqRisk stays at the old (mat, chop) unless kinder; a liquidation at a fallen price does not revert."},{"property":"P1 / C2, core SET_CAP, SET_UNBACKED_BRAKE, SET_CHAIN_LINE, SET_TARGET, SET_EXOTIC_MARGIN, SET_RISK of another type vs the instant lowers","tried":"testFuzz_C2_differentFieldCommutes, 256 runs PASS (both orders, alone and in a BATCH)."},{"property":"P1, MorphoLender RAISE_CAP and SET_ALLOCATOR","tried":"testFuzz_H2_lowerWins, 256 runs PASS (same file as GLP-4): either order around lowerCap / revokeAllocator, cap below live supply, the proposals are dead afterwards, withdraw of the live supply still works. Read from code: no unchecked cap - principal (MorphoLender.sol:156, 177, 370), rows append-only so no index shifts."},{"property":"P1, MarketCalendar2 SET_DAYS and SET_OFFSETS vs live pricing","tried":"testFuzz_H3_applyNeverMovesToday, 256 runs PASS (same file as GLP-5): for any status / offset, any apply moment in the 14 days and any probe up to 3 days back, session() of now and of the probe is identical before and after applyPending."},{"property":"P1, arithmetic of the readers under any rule-abiding value","tried":"Read, not fuzzed beyond H1: liquidation sizing guards t <= 1e18 + chop (src/LedgerBase.sol:492-501); line and chainLine are only compared (src/Ledger.sol:269, src/LedgerBase.sol:476); redeemDivisor >= 1; cut + chip <= 1e18. No underflow or locked exit found."}],"notRun":["No [fork] / [data] claim in this sheet; nothing was run on a fork or against an RPC.","The machine's forge was 1.8.3 (no solar, no solc 0.8.38): forge 1.10.1 was downloaded into .cache and every test above ran with it and --use solar.","Stateful invariant campaigns were not written; the tests are fuzz and sequence tests.","Not tested, read only: SET_SAVINGS_SHARE (step-bounded; interest since lastAccrual is split at the share in force at the next accrual, the applier picks the side, src/LedgerBase.sol:275); SET_CHAIN_LINE and SET_UNBACKED_BRAKE beyond C2; house SET_OTHER_IMD / SET_DEPTH_K / SET_DEPTH (read only by depthLine, i.e. borrow and charged rate change; a pending SET_OTHER_IMD lowering or SET_DEPTH_K raise survives postLowerDepth and can re-widen the depth line up to the stored line); house SET_GROUP and SET_GROUP_LINE both write groupLine in separate slots (last applied wins).","Earlier submissions (api.imd.fun/jobs/<id>/submissions) were not fetched: the sheet names no job id.","Test sources are pasted with indentation reduced to one space per level; the four passing holds tests (H1, C2, H2, H3) are described under holds and their source is omitted for size."]}