# Audit report

> Audit src/Parameters.sol, src/ParametersBase.sol, src/ParametersRules.sol, src/Governed.sol, src/GovernedByKind.sol, src/managers/RateManager.sol, at the pinned commit, for a capped mainnet beta. Read whatever else in src/ these depend on, but report on this scope.
>
> imdUSD v2 is a multi-collateral CDP stablecoin; this is its capped mainnet beta on Ethereum. Positions are NFT ids; borrowers set their own interest rate and redemptions take from the lowest rates first; liquidation is mark then bite, with a standing bid from Backstop sleeves; the peg pool is a Uniswap v4 pool with our own hook; prices come from Chainlink and from swarm-attested feeds (EIP-712 attestations bound to pinned questions). README.md gives the scope, the key invariants, the trust model and the known issues: read it first.
>
> BUILD AND TEST (required; Foundry, solc 0.8.26 via_ir per foundry.toml). Never build or test the whole project: with every suite it needs about 49 GB and the compiler will be killed. Run only this panel's tests: `forge test --match-path 'test/unit/{PanelParams,CapAndSlots,RiskVersions,RateManager,PanelRecheck}.t.sol'` (measured: about 3.6 GB peak, 5 minutes). One build at a time on your machine. Write each proof as a new file test/unit/Proof<Name>.t.sol, add it to the glob and run it; paste it with its output into the finding, then delete it: your submission must leave the tree unchanged. With Foundry 1.9 or later, `forge test --use solar --no-match-path 'test/fork/*'` builds everything and runs all 1,179 tests in seconds under 1 GB (Solar accepts a little syntax solc refuses: confirm a proof with the solc command).
>
> Answer each numbered question, including the ones where nothing is wrong:
> 1. TIMELOCKS PER KIND (propose, applyPending, cancel, locks, pendingKinds, BATCH, expiry). Any change that takes effect without its 48 hours, a raise smuggled inside a batch, an instant lower undone by an older proposal, or a slot that can be stuck for good.
> 2. BOUNDS (ParametersRules._validate, _checkRisk, _checkIlk, the MAX_* constants). Any value that passes validation and then breaks the Ledger, the Liquidator or the Redeemer (a zero or extreme mat, chop, dust above line, divisor 0, a cap that blocks de-risking).
> 3. INSTANT LOWERS (lowerLine, lowerCap, lowerKeeperCap, lowerEdgePremium, lowerUnbackedBrake, postLowerDepth, disableSleeveIlk; _cancelPending). Prove each only reduces risk; find one that harms a borrower or blocks liquidation or redemption.
> 4. GENESIS AND SEAL (wire, the setGenesis* setters, seal, sealed_). Any wirer power left after the seal, or anything set before it that later governance cannot correct.
> 5. DEPTH RULE (depthLine, depthK, depthCap, SET_DEPTH, the D1 check at apply, measured depth through ImdDepth). Can the sIMD line ever stand above what the rule allows, or be lowered by anyone but the rule and the Safe?
> 6. RATE MANAGER (join, leave, setLimits, setRates, minInterval, maxStep, the operator right). Move a member's rate outside the limits they set, or charge them a premium they did not choose.
>
> Not findings: anything listed under README.md 'Known issues and accepted risks' (say so if you find it worse than written); src/bridge, src/dex, src/earn/LoopVault.sol and src/stocks (after the beta) unless a question names them; test/ and its mocks; gas optimisations unless they change behaviour.
>
> For every finding: severity by impact; file, line and the lines copied; the call sequence from an external caller; a concrete failing input or state with expected against actual; whether it is reachable with the values in script/DeployConfig.sol (BetaConfig); the smallest fix; and a Foundry test that fails on this commit, RUN as BUILD says and pasted in full in the finding with its output (the judge reruns it). The test/ tree has harnesses to reuse (test/utils/System.sol, the unit suites). Answer every numbered question, including those where nothing is wrong. Give a coverage row (holds, finding or unreached, with a reason) for every external function of the contracts in scope. Also report every comment or NatSpec that claims a property the code does not have.

| | |
|---|---|
| Repository | https://github.com/fa11up/imdusd-v2-audit.git |
| Commit | `2875ffb22a726f041bd6891f32f35ddc7cdb983d` |
| Job | `cd9184ac-e25e-4415-8605-194bf21e3501` |
| Judged | 2026-11-10 21:01 UTC |
| Findings | 6 low · 10 info |

Four agents audited the code as it is at `2875ffb`, each in one area (math, permissions, economics, control flow),
and a judge reproduced, merged and ranked what they found, then read the code once more itself. Nothing in the repository was changed or deployed.

## Findings

### 1. Low: A one-word SET_MIGRATOR_LINE / SET_DEPTH item in a pending BATCH makes every instant per-type lower (lowerLine, lowerDepthLine, lowerCap, disableSleeveIlk) revert, for every type, until the batch is c

`src/Parameters.sol:287`

```
        (uint8 k, bytes32 i) = abi.decode(p, (uint8, bytes32));
```

Merged from all four specialists (economics, flow, math, permissions). ParametersRules._validate does not decode SET_MIGRATOR_LINE (ParametersRules.sol:39-40) or SET_DEPTH (:66-67), so a 32-byte item such as abi.encode(uint8(3)) passes propose inside a BATCH. The BATCH locks every item kind (ParametersBase._kindsOf). An instant per-type lower calls _cancelPending(kind, ilk) (Parameters.sol:279-284); when `kind` is locked by the BATCH it runs _touches over the batch, which abi.decodes EVERY item as (uint8, bytes32) until one matches. The 32-byte item makes that decode revert, so the whole lower reverts, including for types the batch never names. Call sequence: Safe.propose(abi.encode(uint8(17), [abi.encode(uint8(1), ETH, risk), abi.encode(uint8(3))])) -> Safe.lowerLine(WBTC, 0) -> _lowerLine -> _cancelPending(SET_RISK, WBTC) -> _touches -> abi.decode reverts. The same holds for lowerCap (a batch carrying SET_CAP), lowerDepthLine, and disableSleeveIlk (a batch carrying ADD_SLEEVE_ILK). The batch's expiry does not release it; only cancel(17) does, which also drops every other item. README's known issue says a malformed SET_DEPTH/SET_MIGRATOR_LINE payload 'blocks only its own kind'; the consequence is worse than written: it disables the instant brakes (README: 'a type that has just booked bad debt must be stoppable without a 48h wait') on every type for the batch's kinds, costing the Safe an extra 2-of-3 transaction, after diagnosing an empty-data revert, during an incident. Needs a governor encoding mistake. Reachable with BetaConfig: the day-7 Safe batch is a BATCH carrying SET_DEPTH next to SET_RISK (sIMD line); a SET_DEPTH item missing its uint256 word reproduces it. Smallest fix: decode the two kinds in _validate (`abi.decode(payload, (uint8, uint256));` in the SET_MIGRATOR_LINE and SET_DEPTH branches), which also closes the known issue; defensively, `if (p.length < 64) return false;` first in _touches.

**Reproduction**

Reproduced: test/scratch/ProofBatchTouches.t.sol (proof below; self-contained, stub ledger/token/join). State: Parameters sealed with ETH and WBTC, line 1,000,000e18. Governor proposes BATCH [SET_RISK(ETH, line 2,000,000e18), abi.encode(uint8(3))]: accepted, pendingOf(17) set. Governor calls lowerLine(WBTC, 0). Expected: WBTC line 0 at once (the batch does not touch WBTC; the control with a well-formed abi.encode(uint8(3), uint256(0)) item does exactly that). Actual: revert in Parameters.lowerLine. Output on this commit: `[PASS] test_control_wellFormedBatchKeepsInstantLowers() (gas: 772910)` / `[FAIL: EvmError: Revert] test_malformedBatchItemBlocksInstantLowerOfAnotherType() (gas: 801940)`. Also confirmed with lowerLine(ETH, 0) (the batch's own type: [FAIL: EvmError: Revert] test_instantLowerLineSurvivesMalformedBatchItem) and with lowerCap via a batch carrying SET_CAP (flow specialist). Passes once _validate decodes the two kinds (propose then rejects the batch, so the test must be adjusted to expect that) or _touches skips short items.

**Proof**: a Foundry test that fails on this code and passes once it is fixed.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import {Parameters} from "src/Parameters.sol";
import {ParametersBase} from "src/ParametersBase.sol";
import {IFeed} from "src/interfaces/IFeed.sol";

contract Stub {}

contract StubJoin {
    address public token;
    address public ledger;

    constructor(address t, address l) {
        (token, ledger) = (t, l);
    }
}

/// @notice A pending BATCH with one item shorter than two words (a SET_MIGRATOR_LINE / SET_DEPTH payload, which
/// `propose` does not decode) makes `Parameters._touches` revert, so every instant per-type lower whose kind the batch
/// locks (lowerLine, lowerCap, disableSleeveIlk) reverts for EVERY type, not only the batch's own.
contract ProofBatchTouches is Test {
    Parameters params;
    address gov = makeAddr("gov");
    bytes32 constant ETH = "ETH";
    bytes32 constant WBTC = "WBTC";

    function setUp() public {
        params = new Parameters(gov, address(this));
        address ledger = address(new Stub());
        params.wire(ledger, address(new Stub()));
        _add(ETH, ledger);
        _add(WBTC, ledger);
        params.seal();
    }

    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {
        return ParametersBase.Risk({
            mat: 1.5e18,
            chop: 0.1e18,
            cut: 0.1e18,
            chip: 0.01e18,
            rateFloor: 0.005e18,
            yieldFee: 0,
            skew: 0.02e18,
            pegFloor: 0,
            line: line,
            dust: 100e18,
            redeemFloor: 0.005e18,
            redeemDivisor: 4,
            redeemCap: 0
        });
    }

    function _add(bytes32 ilk, address ledger) internal {
        address t = address(new Stub());
        ParametersBase.Config memory c;
        c.token = t;
        c.join = address(new StubJoin(t, ledger));
        c.median = IFeed(address(new Stub()));
        c.spot = c.median;
        c.redeemable = true;
        params.addGenesisIlk(ilk, c, _risk(1_000_000e18));
    }

    function _proposeBatch(bytes memory second) internal {
        bytes[] memory items = new bytes[](2);
        items[0] = abi.encode(uint8(1), ETH, _risk(2_000_000e18)); // an ETH line raise
        items[1] = second;
        vm.prank(gov);
        params.propose(abi.encode(uint8(17), items)); // BATCH
    }

    /// Control: with well-formed items, the Safe can freeze WBTC at once and the ETH batch stays queued.
    function test_control_wellFormedBatchKeepsInstantLowers() public {
        _proposeBatch(abi.encode(uint8(3), uint256(0)));
        vm.prank(gov);
        params.lowerLine(WBTC, 0);
        assertEq(params.storedRisk(WBTC).line, 0);
    }

    /// FAILS on this commit: the one-word item (accepted by `propose`) makes lowerLine(WBTC) revert inside `_touches`.
    function test_malformedBatchItemBlocksInstantLowerOfAnotherType() public {
        _proposeBatch(abi.encode(uint8(3))); // one word: passes propose (not decoded)
        (bytes memory p, uint256 eta) = params.pendingOf(17);
        assertGt(eta, 0, "batch queued");
        assertGt(p.length, 0);
        // WBTC just booked bad debt: the Safe freezes it at once, as the trust model promises.
        vm.prank(gov);
        params.lowerLine(WBTC, 0); // expected: line 0. actual: reverts decoding the 32-byte item in _touches
        assertEq(params.storedRisk(WBTC).line, 0, "WBTC frozen");
    }
}
```

### 2. Low: lowerOtherImdLines is an instant governor act that RAISES the enforced sIMD (depth-gated) line with no 48h timelock

`src/Parameters.sol:205`

```
    function lowerOtherImdLines(uint256 lines) external onlyGovernor {
        if (depthIlk == bytes32(0) || lines >= otherImdLines) revert OutOfBounds();
        _cancelPending(SET_OTHER_IMD, 0);
        otherImdLines = lines;
        emit OtherImdSet(lines, otherImdChop);
        _flagDepth();
```

The line the Ledger enforces for the depth-gated type is risk(depthIlk).line = min(stored line, depthLine()) (Parameters.sol:332-338), and depthLine() (ParametersBase.sol:480-487) subtracts otherImdLines x (1 + otherImdChop) from k x depth. lowerOtherImdLines lowers otherImdLines at once and checks nothing else, so whenever depthLine() binds (the beta's normal state: the day-7 sIMD line is set to what D1 admits) it raises the enforced sIMD line in the same transaction. Nothing checks that the other chain actually lowered its IMD line, so after the call the sIMD line can stand above what D1 allows for the real combined IMD exposure (question 5). README invariant 7 says every governed raise of lines waits 48h and only risk-reducing lowerings are instant; the trust model's list of instant acts does not include this one; ParametersBase.sol:180-183 calls it 'lowered instantly' as if it were a brake. It is a governor power (2-of-3 Safe), so severity is low. Reachable with BetaConfig: MainnetConfig sets otherImdLines = RobinhoodConfig.IMD_LINE = 3,000e18 at chop 0.2 and BetaConfig inherits it, so lowerOtherImdLines(0) raises the beta sIMD line by 3,600/1.2 = 3,000 imdUSD at once (bounded by the stored line). Smallest fix: drop the instant function (SET_OTHER_IMD is timelocked and already accepts decreases), or refuse it while depthLine() < the stored line of depthIlk.

**Reproduction**

Reproduced: test/scratch/ProofOtherImd.t.sol (proof below). SIMD with chop 0.2, stored line 50,000; setGenesisDepthRule(SIMD, k 0.8, posted depth 60,000, otherLines 3,000, otherChop 0.2), no ImdDepth: risk(SIMD).line = (48,000 - 3,600)/1.2 = 37,000. Governor lowerOtherImdLines(0). Expected: an instant act never raises a line (stays 37,000 until a 48h proposal). Actual: 40,000 in the same transaction. Output on this commit: `[FAIL: instant act raised the sIMD line: 40000000000000000000000 > 37000000000000000000000] test_instantLowerDoesNotRaiseDepthGatedLine() (gas: 126971)`.

**Proof**: a Foundry test that fails on this code and passes once it is fixed.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import {Parameters} from "src/Parameters.sol";
import {ParametersBase} from "src/ParametersBase.sol";
import {IFeed} from "src/interfaces/IFeed.sol";

contract PoCode {}

contract PoJoin {
    address public token;
    address public ledger;
    constructor(address t, address l) { token = t; ledger = l; }
}

contract PoFeed {
    function latestValue() external view returns (uint256, uint64) { return (1e18, uint64(block.timestamp)); }
    function isStale() external pure returns (bool) { return false; }
    function maxAge() external pure returns (uint256) { return 1 hours; }
}

/// `lowerOtherImdLines` is an instant governor act that RAISES the depth-gated type's effective line
/// (`risk(depthIlk).line` = min(stored, depthLine())), with no 48h timelock. Beta values: k 0.8, otherImdLines
/// 3,000 at chop 0.2, sIMD chop 0.2.
contract ProofOtherImd is Test {
    Parameters params;
    address gov = address(0xA11CE);
    bytes32 constant SIMD = "SIMD";

    function setUp() public {
        params = new Parameters(gov, address(this));
        address ledger = address(new PoCode());
        address token = address(new PoCode());
        params.wire(ledger, token);
        address coll = address(new PoCode());
        address join = address(new PoJoin(coll, ledger));
        IFeed f = IFeed(address(new PoFeed()));
        ParametersBase.Config memory c = ParametersBase.Config(
            coll, join, f, f, IFeed(address(0)), address(0), address(0), IFeed(address(0)), true, false
        );
        ParametersBase.Risk memory r = ParametersBase.Risk({
            mat: 1.5e18, chop: 0.2e18, cut: 0, chip: 0, rateFloor: 0.01e18, yieldFee: 0, skew: 0.02e18,
            pegFloor: 0, line: 50_000e18, dust: 0, redeemFloor: 0.005e18, redeemDivisor: 1, redeemCap: 0
        });
        params.addGenesisIlk(SIMD, c, r);
        // no ImdDepth here, so the posted 60k is the depth: room 48k, other chains 3,600, line (48k-3.6k)/1.2 = 37k
        params.setGenesisDepthRule(SIMD, 0.8e18, 60_000e18, 3_000e18, 0.2e18);
        params.seal();
    }

    function test_instantLowerDoesNotRaiseDepthGatedLine() public {
        uint256 before = params.risk(SIMD).line;
        assertEq(before, 37_000e18);
        vm.prank(gov);
        params.lowerOtherImdLines(0); // the other chain still runs its 3,000 line; nothing checks that
        // Expected (README invariant 7 / trust model: instant acts only reduce risk): the sIMD line does not rise.
        assertLe(params.risk(SIMD).line, before, "instant act raised the sIMD line"); // actual: 40,000
    }
}
```

### 3. Low: lowerLine (and any fall of the live depth line) blocks a borrower's in-cooldown rate change; 'Positions are untouched' does not hold

`src/Parameters.sol:221`

```
    /// @notice Lower ANY type's line at once (a type that has just booked bad debt must be stoppable without a
    /// 48h wait). Strictly lowering; raising stays a SET_RISK proposal. Positions are untouched.
```

lowerLine / lowerDepthLine set a type's line below its debt, and for sIMD a fall in measured depth does the same live through depthLine(). Ledger.setRate's charged branch (Ledger.sol:155-162) mints the 7-day cooldown premium as debt and then checks `uint256(s.debt) + s.badDebt > params.risk(ilk).line` -> CeilingExceeded, so an owner who opened or changed their rate in the last 7 days cannot change their rate at all, in either direction, until the cooldown lapses. A borrower at the front of the redemption queue cannot raise their rate to leave it (question 3: an instant lower that harms a borrower). Repay, deposit, redemption and liquidation are unaffected, so the lower still reduces protocol risk; the defect is the false NatSpec (Parameters.sol:215 and 222; ParametersBase.sol:170-171 lists only repay/redemption/liquidation as carrying on) and the borrower harm. Reachable with BetaConfig on every type, and on sIMD without any governor action whenever depth falls. Smallest fix: exempt the cooldown premium (it is interest, not new borrowing) from the per-type line check, or document the effect.

**Reproduction**

Reproduced with test/scratch/ProofLedgerSide.t.sol (System harness): ETH mat 1.4, line 1,000,000, price 2000; alice opens 10 ETH / 5,000 imdUSD at 5%. Governor lowerLine(ETH, 1000e18). Alice (owner, inside cooldown) setRate(id, 0.06e18, 0, 0). Expected per NatSpec: position untouched, premium paid, new rate set. Actual: `[FAIL: CeilingExceeded()] test_lowerLineBlocksChargedRateChange() (gas: 818398)`, trace `Parameters::risk(ETH) -> line 1e21 ... Ledger.setRate <- [Revert] CeilingExceeded()`. After 7 days the free change succeeds (flow specialist's test).

### 4. Low: lowerCap NatSpec says it 'only stops new borrowing; positions untouched', but an instant cap also refuses every plain collateral withdrawal from an indebted position

`src/Parameters.sol:193`

```
    /// @notice Set a ceiling on a type with none, or lower one, at once (it only stops new borrowing; positions untouched).
    /// Refused below 1/100 of the live low (a unit error, e.g. a per-token figure for an 8-decimal token).
```

Pricer quote.borrow = min(low, cap), and Ledger._adjustPrice (Ledger.sol:344-352) measures any adjust that is not a proportional repay-and-withdraw at q.borrow. lowerCap is instant, onlyGovernor, and floors the cap only at _liveLow(ilk)/100 (0 while the median is stale, so then any non-zero cap). A cap at that floor makes every indebted position fail health at the borrow price, so no owner can withdraw excess collateral (only repay first) until SET_CAP lifts it after 48h; a cap is never removed. ParametersBase.sol:196-197 states the withdrawal effect correctly; the lowerCap NatSpec and the README trust model ('instant risk-reducing actions ... lowering a cap') do not. Governor power, reachable with BetaConfig on every type. Fix: correct the NatSpec/README; if the power is unwanted, bound lowerCap below by a larger fraction of the live low and refuse it while low reads 0.

**Reproduction**

Reproduced with test/scratch/ProofLedgerSide.t.sol: ETH at 2000, mat 1.4; alice 10 ETH / 5,000 debt (CR 400%). Governor lowerCap(ETH, 20e18) (= low/100, accepted). Alice adjust(id, dCollateral -1e18, dDebt 0). Expected per NatSpec: allowed (CR 360% at market). Actual: `[FAIL: Unhealthy()] test_lowerCapBlocksWithdrawal() (gas: 857649)` (9 ETH x $20 = $180 < 1.4 x 5,000).

### 5. Low: postLowerDepth (an instant 'lower') raises the depth from 0 on a chain with no ImdDepth, opening the depth-gated line without the timelock

`src/Parameters.sol:263`

```
        if (depthIlk == bytes32(0) || depth == 0 || (depthCap != 0 && depth >= depthCap)) revert OutOfBounds();
```

postLowerDepth treats depthCap == 0 as 'no ceiling', so any value counts as a lowering. That is true only with an ImdDepth: depthIMD() (ParametersBase.sol:469-470) returns depthCap itself when imdDepth is unset, where 0 means zero depth and depthLine() = 0. On such a chain (ParametersBase D1 NatSpec supports it: 'Chains without an ImdDepth fall back to the posted figure alone') the governor's instant postLowerDepth(X) raises depth from 0 to X and opens the depth-gated type up to its stored line with no 48h wait. depthCap 0 is reached by setGenesisDepthRule(.., depth 0, ..) or an applied SET_DEPTH(0). Not reachable with BetaConfig on mainnet (an ImdDepth is wired, and there 0 does mean 'no ceiling'); relevant to any deployment with a depth rule and no ImdDepth. Smallest fix: `if (depthIlk == bytes32(0) || depth == 0 || ((depthCap != 0 || address(imdDepth) == address(0)) && depth >= depthCap)) revert OutOfBounds();`.

**Reproduction**

Reproduced: test/scratch/ProofPostLower.t.sol (proof below). SIMD stored line 50,000, chop 0.2; setGenesisDepthRule(SIMD, 0.8e18, 0, 0, 0), no ImdDepth: risk(SIMD).line = 0. Governor postLowerDepth(1e30). Expected: an instant depth lower never raises the line (stays 0). Actual: 50,000. Output on this commit: `[FAIL: instant post raised the line: 50000000000000000000000 != 0] test_postLowerDepthNeverRaisesLine() (gas: 141973)`. Passes with the fix above.

**Proof**: a Foundry test that fails on this code and passes once it is fixed.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import {Parameters} from "src/Parameters.sol";
import {ParametersBase} from "src/ParametersBase.sol";
import {IFeed} from "src/interfaces/IFeed.sol";

contract PlCode {}

contract PlJoin {
    address public token;
    address public ledger;
    constructor(address t, address l) { token = t; ledger = l; }
}

/// postLowerDepth, the instant "lower" of the posted depth, raises depth from 0 on a chain with no ImdDepth.
contract ProofPostLower is Test {
    Parameters params;
    address gov = address(0xA11CE);
    bytes32 constant SIMD = "SIMD";

    function setUp() public {
        params = new Parameters(gov, address(this));
        address ledger = address(new PlCode());
        params.wire(ledger, address(new PlCode()));
        address coll = address(new PlCode());
        IFeed f = IFeed(address(new PlCode()));
        ParametersBase.Config memory c = ParametersBase.Config(
            coll, address(new PlJoin(coll, ledger)), f, f, IFeed(address(0)), address(0), address(0), IFeed(address(0)), true, false
        );
        ParametersBase.Risk memory r = ParametersBase.Risk({
            mat: 1.5e18, chop: 0.2e18, cut: 0, chip: 0, rateFloor: 0.01e18, yieldFee: 0, skew: 0.02e18,
            pegFloor: 0, line: 50_000e18, dust: 0, redeemFloor: 0.005e18, redeemDivisor: 1, redeemCap: 0
        });
        params.addGenesisIlk(SIMD, c, r);
        params.setGenesisDepthRule(SIMD, 0.8e18, 0, 0, 0); // no ImdDepth: posted depth 0 = zero depth
        params.seal();
    }

    function test_postLowerDepthNeverRaisesLine() public {
        assertEq(params.risk(SIMD).line, 0);
        vm.prank(gov);
        params.postLowerDepth(1e30); // an instant "lower"
        assertEq(params.risk(SIMD).line, 0, "instant post raised the line");
    }
}
```

### 6. Low: RateManager: a target of 0 (allowed when a type's minRate is 0) resets the maxStep reference, so the next call can jump the whole range

`src/managers/RateManager.sol:176`

```
        uint64 prior = lastRate[ilk];
        if (prior != 0 && (rate > prior ? rate - prior : prior - rate) > maxStep) revert StepTooLarge();
```

setRates uses lastRate[ilk] == 0 as 'no previous call', but 0 is a legal target whenever the constructor listed the type with minRate == 0 (line 124 only requires min <= max; line 173 then accepts rate 0). After setRates(ilk, 0, ...) the next call one minInterval later skips the step check and may set maxRate, moving every listed member straight to min(maxRate, their ceiling). This defeats the NatSpec guarantee at RateManager.sol:42-44 ('Move rates by more than maxStep per call'); the README known issue describes a walk of range/maxStep intervals, this is two intervals (e.g. 2h instead of 20h for 0-20% at a 1% step). Members' own floor/ceiling still bound the result (question 6: no member moved outside their limits, no premium charged). Not reachable in the beta: BetaConfig deploys no RateManager. Fix: test `lastCall[ilk] != 0` instead of `prior != 0` for the step check, or require minRate > 0.

**Reproduction**

Reproduced: test/scratch/ProofRateStep.t.sol (proof below). RateManager(ETH: minRate 0, maxRate 0.2e18, minInterval 1h, maxStep 0.01e18). t: setRates(ETH, 0.01e18); t+1h: setRates(ETH, 0); t+2h: setRates(ETH, 0.2e18). Expected: StepTooLarge. Actual: accepted. Output on this commit: `[FAIL: next call did not revert as expected] test_maxStepHoldsAfterZeroTarget() (gas: 173567)`.

**Proof**: a Foundry test that fails on this code and passes once it is fixed.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import {RateManager, IManagedLedger} from "src/managers/RateManager.sol";

contract PrLedger {
    address public nft = address(0xBEEF);
    function RATE_COOLDOWN() external pure returns (uint256) { return 7 days; }
}

/// With a type minRate of 0 (accepted by the constructor), a target of 0 stores lastRate = 0, which
/// `setRates` reads as "no prior call": the next call skips the maxStep check entirely.
contract ProofRateStep is Test {
    RateManager rm;
    bytes32 constant ETH = "ETH";

    function setUp() public {
        bytes32[] memory ilks = new bytes32[](1);
        uint64[] memory mins = new uint64[](1);
        uint64[] memory maxs = new uint64[](1);
        (ilks[0], mins[0], maxs[0]) = (ETH, 0, 0.2e18);
        rm = new RateManager(IManagedLedger(address(new PrLedger())), address(this), ilks, mins, maxs, 1 hours, 0.01e18);
    }

    function test_maxStepHoldsAfterZeroTarget() public {
        uint256[] memory none = new uint256[](0);
        vm.warp(1_000_000);
        rm.setRates(ETH, 0.01e18, none, none, none); // first call: 1%
        vm.warp(1_000_000 + 1 hours);
        rm.setRates(ETH, 0, none, none, none); // one 1-point step down to 0: allowed
        vm.warp(1_000_000 + 2 hours);
        vm.expectRevert(RateManager.StepTooLarge.selector); // expected: 0 -> 20% is a 20-point step
        rm.setRates(ETH, 0.2e18, none, none, none); // actual: accepted (prior == 0 skips the check)
    }
}
```

### 7. Info: SET_KEEPER / SET_BRIDGE are validated only for code; a second one passes propose, waits 48h, then always fails (AlreadySet) and holds its slot

`src/ParametersRules.sol:41`

```
        } else if (kind == SET_BRIDGE || kind == SET_KEEPER) {
            (, address minter) = abi.decode(payload, (uint8, address));
            if (minter.code.length == 0) revert BadConfig();
```

ImdUSD.setKeeper / setBridge revert AlreadySet once set (ImdUSD.sol:89, 98). The beta names the keeper at genesis (setGenesisKeeper), so every SET_KEEPER proposal is accepted at propose and can never apply; slot 6 stays held until cancel. Same class as the README's malformed-payload issue but trivially checkable. Fix: in _validate revert BadConfig when IImdUSD(token).keeper() (or bridge()) is already non-zero.

**Reproduction**

Reproduced with test/scratch/ProofLedgerSide.t.sol: setGenesisKeeper(x); seal; governor propose(abi.encode(uint8(6), address(weth))) succeeds (validateKind -> Stop); +48h applyPending(6) -> `[FAIL: AlreadySet()] test_secondKeeperPassesProposeFailsApply()` (trace: ImdUSD::setKeeper <- [Revert] AlreadySet()). Expected: refused at propose.

### 8. Info: ADD_SLEEVE_ILK validation does not check the sleeve's MAX_ILKS, although its comment says propose refuses what apply would fail on

`src/ParametersRules.sol:105`

```
            if (!ISleeve(sleeve).isToken(c.token) && ISleeve(sleeve).tokenCount() >= ISleeve(sleeve).MAX_TOKENS()) {
                revert OutOfBounds();
            }
```

Backstop.addIlk reverts TooManyTokens when a NEW type is listed and ilkList.length == MAX_ILKS (12) (Backstop.sol:245). _validate checks only MAX_TOKENS for a new token. A new type whose token the sleeve already holds passes propose, waits 48h and reverts at apply; the ADD_SLEEVE_ILK slot is held until cancel. Comment at ParametersRules.sol:101-104 claims otherwise. Fix: expose ilkList length (or a full flag) on Backstop and check it in _validate.

**Reproduction**

Code trace: sleeve with ilkList.length == 12 and the new type's token already held (isToken true): _validate passes (lines 105-110), applyPending -> Backstop.addIlk new-ilk path -> line 245 `if (ilkList.length == MAX_ILKS) revert TooManyTokens();`. Not reached in the beta (fewer than 12 types per sleeve).

### 9. Info: _movesTokens deny-list misses approving selectors its NatSpec says can never be allowlisted (increaseApproval, Permit2 approve)

`src/ParametersRules.sol:215`

```
    /// @dev A SeatAccount forwards any calldata after an allowlisted (target, selector), so a claim rule may never
    /// name a selector that moves or approves the account's tokens (ERC-20 / 721 / 1155 / 777 / 1363 transfers, approvals,
    /// permits, and multicall, which reaches any of them): allowlisting one would let anyone move every account's unpaid rewards. Removing a rule (rule 0) is always allowed.
```

The NatSpec says a claim rule may never name a selector that moves or approves the account's tokens. The list omits increaseApproval(address,uint256) 0xd73dd623 (older Zeppelin/OZ 1.x tokens) and Permit2 approve(address,address,uint160,uint48) 0x87517c45 (selectors computed with `cast sig`). Needs a governor SET_SEAT_CLAIM naming such a target; a deny-list cannot be complete. Fix: add these, or move to an allow-list of reward-claim selectors.

**Reproduction**

propose(abi.encode(uint8(10), seatJoin, tokenWithIncreaseApproval, bytes4(0xd73dd623), uint8(1))) passes _validate line 149 (_movesTokens returns false for 0xd73dd623 / 0x87517c45 by inspection of lines 219-240).

### 10. Info: disableSleeveIlk on an edge type also stops all borrowing and charged rate changes on it until a 48h relisting; its NatSpec says only the bid stops

`src/Parameters.sol:179`

```
    /// @notice Stop a sleeve's standing bid on a type at once (the safe direction; liquidations fall back to the
    /// caller/auction path). ADD_SLEEVE_ILK lists it again.
```

edgeIlk[ilk] is never cleared. After disableSleeveIlk(ilk, true), Backstop.edgeCapacity returns 0 for that type (Backstop.sol:375), and LedgerBase._checkEdge (LedgerBase.sol:421-431) reverts EdgeCapacityExceeded(sum, 0) on every borrow and charged rate change of that type while the summed edge debt is above 0. Risk-reducing, but stronger than documented (ParametersRules.sol:188-189 documents it; the function NatSpec and README trust model do not). Fix: document it.

**Reproduction**

Code trace: beta sIMD edge type with debt > 0; governor disableSleeveIlk(SIMD, true); a healthy sIMD borrower adjust(+1 imdUSD) -> _checkEdge -> edgeCapacity(SIMD) = 0 -> EdgeCapacityExceeded(sum, 0). Expected per NatSpec: borrowing unaffected.

### 11. Info: Parameters header says the savers' share may be set within 0-80%; MAX_SAVINGS_SHARE is 50%

`src/Parameters.sol:11`

```
///    within 0-80%; open a fee-note series (tenor 30/90/180 days, discount <= 10%, a size cap); move a capped chain's
```

Merged (economics, flow, math, permissions). ParametersBase.MAX_SAVINGS_SHARE = 0.5e18 (ParametersBase.sol:119), enforced in setGenesisSavings (Parameters.sol:55) and SET_SAVINGS_SHARE (ParametersRules.sol:46). Fix the text to 0-50% with a 10-point step.

**Reproduction**

With savingsShare 0.5e18, propose(abi.encode(uint8(5), uint64(0.55e18))) reverts OutOfBounds at ParametersRules.sol:46 although the header says it is in range.

### 12. Info: SET_CAP NatSpec says a charged rate change is measured at min(low, cap); the Ledger measures it at low

`src/ParametersBase.sol:196`

```
    /// @notice A type's BORROW price ceiling (Sky's capped OSM): borrowing, withdrawing and a charged rate change
    /// are measured at min(low, cap) (`Pricer.Quote.borrow`); liquidation health, liquidation prices and redemption payouts
```

Merged (economics, math). Ledger.setRate's charged branch checks `_healthy(p.collateral, debt, q.low, q.mat)` (Ledger.sol:167-168, 'A rate change is not a borrow, so the cap does not measure its premium'); test/unit/CapAndSlots.t.sol test_cap_chargedRateChangeMeasuredAtLowNotCap asserts that. Fix: drop 'and a charged rate change'.

**Reproduction**

Type with cap = low/2, position healthy at low but not at low/2, owner's charged setRate inside cooldown succeeds (existing passing test above).

### 13. Info: SET_CHAIN_LINE NatSpec says 'mainnet is uncapped'; the beta caps mainnet at 300k for good

`src/ParametersBase.sol:145`

```
    /// @notice The chain's global debt cap, on chains whose genesis capped it (Robinhood); mainnet is uncapped.
```

BetaConfig sets (c.chain.capped, c.chain.chainLine) = (true, TOTAL_LINES) (script/DeployConfig.sol:678) and setGenesisChainLine sets chainCapped = true permanently. Fix the comment.

**Reproduction**

On a BetaConfig deployment params.chainCap() returns (true, 300000e18).

### 14. Info: ManagedPosition is said to mirror LedgerBase.Position's ABI exactly; Position has an eighth field (uint32 version)

`src/managers/RateManager.sol:4`

```
/// @dev The slice of the Ledger a manager reads and calls. Mirrors LedgerBase.Position's ABI exactly.
```

Merged (flow, math, permissions). LedgerBase.Position ends with `uint32 version` (LedgerBase.sol:92-101). Decoding works today only because the trailing word is ignored; a field inserted before lastRateChange would shift the cooldown read at RateManager.sol:193. Fix: add `uint32 version;` or reword to 'a prefix of'.

**Reproduction**

abi.encode(ledger.position(id)).length == 256 vs 224 for ManagedPosition (flow specialist's test).

### 15. Info: seal() NatSpec: 'From here on only the timelock changes anything', yet eleven instant governor acts remain (two of which raise a line)

`src/Parameters.sol:307`

```
    /// @notice End genesis. From here on only the timelock changes anything.
```

After seal the governor still acts at once with lowerLine, lowerDepthLine, lowerCap, lowerKeeperCap, lowerUnbackedBrake, lowerEdgePremium, lowerDepthK, lowerOtherImdLines, postLowerDepth, removeDepthSampler and disableSleeveIlk. Fix the text.

**Reproduction**

After seal(), governor lowerLine(ETH, 0) applies in the same block without a proposal.

### 16. Info: D1 NatSpec says a SET_DEPTH post applies only if the rule then holds; SET_DEPTH never checks the rule

`src/ParametersBase.sol:165`

```
    /// (SET_RISK), raising k (SET_DEPTH_K) or posting a depth (SET_DEPTH) goes through the 48h timelock, and a raise
    /// applies only if the rule then holds. Lowering the line, k or the depth is instant by the governor; if that breaks
```

ParametersRules._apply SET_DEPTH (lines 293-298) only calls _flagDepth, never _requireDepth. A depth raise cannot worsen the rule, so this is harmless, but the sentence is false. Fix the text.

**Reproduction**

Rule broken (need 50k, room 40k); a SET_DEPTH raising room to 45k applies without revert.

---

Judge's submission `8bde1837d45c051443a4733bd3c47d63f2ae76da5ca72f329403c1de775624dc`, accepted on the IdentityMD network. Acceptance means the report met the job's checks;
it is not a guarantee that the code has no other defects.
