{"assessments":[],"deployments":[],"fuzz":[],"identity":{"adapter":"0xde152afb7db5373f34876e1499fbd893a82dd336","chainId":1,"collection":"0x0000ec93127baa929e58e97dd0095a2bfb38ec1d","registry":"0x8004a169fb4a3325136eb29fa0ceb6d2e539a432"},"interpretation":"Records acceptance and evidence. Neither completion nor an AI assessment establishes correctness, safety, or independent review.","jobId":"4384ebcc-37f4-4bc3-8e2b-fc48f01f0701","kind":"audit","nodes":[{"acceptedSubmissionHash":"771e3f711ae6095d24d97921ff0ca6098ae7fffaa8f5d2a7f3a5e0530e067922","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_economics","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"},{"acceptedSubmissionHash":"aecae0c13a01daa1a5dbffe689c9ebba2e472f77e9e37697dd719a61bcfcbfe6","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_flow","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"},{"acceptedSubmissionHash":"ff4ddfda10d3f6ceac4f579668743cc43acb7af857b4497d618cbd6e178c5556","dependsOn":["audit_math","audit_permissions","audit_economics","audit_flow"],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"b89279670f5a00f5d26286edee00c97dd158b997031350a01cafe6e0329ad227","skillId":"audit-judge","subagents":4,"tools":[]},"key":"audit_judge","kind":"code","role":"review","skillHash":"b89279670f5a00f5d26286edee00c97dd158b997031350a01cafe6e0329ad227","skillId":"audit-judge","state":"accepted"},{"acceptedSubmissionHash":"af73e955e9614276b81cdc4750a852c807635603c3f13bb1b4b94b57921de15c","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_math","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"},{"acceptedSubmissionHash":"8c3e0af355aeac9a4f060b2d941ab0d64d5a345cd3f6b6321f801b16c172cfa0","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_permissions","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"}],"objective":"Audit every contract in src/ the beta deploys (README.md scope), read together, at the pinned commit, for a capped mainnet beta. Read whatever else in src/ these depend on, but report on this scope.\n\nimdUSD 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.\n\nBUILD 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/FullSystem.t.sol,test/invariant/Invariants.t.sol}'` (measured: about 3.1 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).\n\ntest/utils/FullSystem.sol runs the real deploy script (script/Deploy.s.sol) and wires every module together on a local Uniswap v4 PoolManager with mock tokens, vaults and feeds; it uses MainnetConfig; BetaConfig turns some of those modules off and sets other values, so say whether each finding holds under BetaConfig. test/invariant/Invariants.t.sol fuzzes the core. Build every attack on these, across contracts, as the live system would see it.\n\nAnswer each numbered question, including the ones where nothing is wrong:\n1. SUPPLY EQUATION (README.md key invariants). Every path that mints or burns imdUSD: borrow, repay, interest, redemption, liquidation by a caller and by a sleeve, Treasury cover and retire, the peg keeper, the migrator, the flash mint. Break the equation with a sequence across contracts.\n2. THE LIQUIDATION MONEY PATH: mark, bite, the standing bid, bad debt, the edge sleeve's first loss, the Treasury's cover. Value in must equal value out at every step; find where it does not.\n3. FLASH. Flash-minted imdUSD into redemption, a caller liquidation, a Backstop deposit, peg pool swaps and PegPositionZap, within one transaction.\n4. PEG TO ALLOCATOR TO BACKSTOP: the hook's keeper and buffer, an Allocator sale through a route, Backstop.sell. Can value leak between the protocol's pots or to a caller?\n5. ORACLE INTO EVERYTHING. One accepted attestation pair at the edge of its cap: the worst outcome across liquidation, redemption, borrowing, sleeve conversion and edge capacity.\n6. Each specialist applies their lens (math, permissions, economics, control flow) to every one of these paths, not to one contract.\n\nNot 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.\n\nFor 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.","parentJobId":null,"planHash":"9c23c966e2f86db0dccbce6f6496ed477f9cb54657e2ace41fe75785e5d538bb","previousHash":"0000000000000000000000000000000000000000000000000000000000000000","projectId":"4384ebcc-37f4-4bc3-8e2b-fc48f01f0701","publication":{"commit":null,"deliveredAt":null,"repoUrl":null},"receiptIdentity":{"adapter":"0xde152afb7db5373f34876e1499fbd893a82dd336","chainId":1,"collection":"0x0000ec93127baa929e58e97dd0095a2bfb38ec1d","registry":"0x8004a169fb4a3325136eb29fa0ceb6d2e539a432"},"registry":"0xb6d0a187b050fa5bb0b87033a203f37becf4a775","research":[],"schema":"identitymd-work-v1","signals":[{"agentId":"51193","feedbackHash":"6e72ab412c49b315322bdf4a77b63aa2a75f5b637ef1fda7a555325204171c21","nodeKey":"audit_economics","submissionHash":"771e3f711ae6095d24d97921ff0ca6098ae7fffaa8f5d2a7f3a5e0530e067922","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"51199","feedbackHash":"1a13d4747a9f527a1a1f8efa5b41bbafd642eb8efd1dee64ad08f71f19df3688","nodeKey":"audit_flow","submissionHash":"aecae0c13a01daa1a5dbffe689c9ebba2e472f77e9e37697dd719a61bcfcbfe6","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"51070","feedbackHash":"81d557f85d2e6879733945a07a8f5567d8d66e1b58c2be216243e11b3f466fef","nodeKey":"audit_judge","submissionHash":"ff4ddfda10d3f6ceac4f579668743cc43acb7af857b4497d618cbd6e178c5556","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"50985","feedbackHash":"f2273322f032f12e52fc03f3b15a873e9c8a4b66eff3b380c5a6dd919b25d04b","nodeKey":"audit_math","submissionHash":"af73e955e9614276b81cdc4750a852c807635603c3f13bb1b4b94b57921de15c","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"53910","feedbackHash":"0d515295d1a5dce8aa1a0489f6b49f96aba6e04eb7395e0c3bbecf0bdd3f3223","nodeKey":"audit_permissions","submissionHash":"8c3e0af355aeac9a4f060b2d941ab0d64d5a345cd3f6b6321f801b16c172cfa0","tag1":"review:submission","tag2":"acceptance-v2","value":1}],"site":null,"snapshotHash":"3bf57c52566f08b36082f98234ed295b10ad4f14738757dbfc3dd2039810602a","state":"completed","submissions":[{"artifacts":[],"attempt":1,"bundleHash":null,"device":"fedfd42dfee2f4e6","findings":[{"citation":"resolved","description":"The brake is documented as stopping all new debt: LedgerBase.sol:320 says \"new debt stops on every type while `unbacked()` exceeds the governed fraction of the circulating\" and Ledger.sol:296-297 repeats it on the borrow path, which calls _checkBrake() before token.mint. The charged path of Ledger.setRate (Ledger.sol:156-170, a rate change inside RATE_COOLDOWN = 7 days) also adds debt (line 161, `s.debt += premium`) and mints it (line 165, `_mintInterest(ilk, premium)`), and checks the type line, _checkLines, _checkEdge, borrowable/agree and health, but not the brake. So while unbacked() is above unbackedBrake x circulating, a position owner can still grow debt and supply by debt x oldRate x 7/365 per call, and can repeat the call (alternating two rates) until the health check or the line stops it. The minted imdUSD goes to savers, the edge sleeve premium and the Treasury, not to the borrower, and the supply equation still holds (type debt and totalSupply rise by the same amount), so no value is taken from anyone: the impact is that a documented safety stop does not apply to one debt-adding path. The README's known issues list the keeper mint as outside the brake; they do not list this path. Call sequence from an external caller: Ledger.open (borrow) -> bad debt booked by Liquidator.liquidate on another position -> Ledger.open/adjust borrow reverts Braked -> Ledger.setRate(id, newRate, 0, 0) by the owner inside the cooldown succeeds. Reachable under BetaConfig: yes, on every listed type (unbackedBrake is the 0.01e18 default, RATE_COOLDOWN is a constant, only the position's owner can pay a premium). Smallest fix: call _checkBrake() in the charged path next to _checkLines/_checkEdge (Ledger.sol:163-164); or, if the premium is meant to be exempt, say so at LedgerBase.sol:320 and Ledger.sol:296-297. The fix was not applied here (review only); the test expects the same Braked error the borrow on the same position raises in the same state.","line":161,"path":"src/Ledger.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test, console2} from \"forge-std/Test.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, IERC20} 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 {Migrator} from \"src/Migrator.sol\";\nimport {Join} from \"src/Join.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {Adjust} from \"src/interfaces/IPositions.sol\";\n\ncontract Tok {\n    string public name = \"T\";\n    string public symbol = \"T\";\n    uint8 public constant decimals = 18;\n    uint256 public totalSupply;\n    mapping(address => uint256) public balanceOf;\n    mapping(address => mapping(address => uint256)) public allowance;\n\n    event Transfer(address indexed from, address indexed to, uint256 value);\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    function mint(address to, uint256 a) external {\n        totalSupply += a;\n        balanceOf[to] += a;\n        emit Transfer(address(0), to, a);\n    }\n\n    function approve(address s, uint256 a) external returns (bool) {\n        allowance[msg.sender][s] = a;\n        emit Approval(msg.sender, s, a);\n        return true;\n    }\n\n    function transfer(address to, uint256 a) external returns (bool) {\n        balanceOf[msg.sender] -= a;\n        balanceOf[to] += a;\n        emit Transfer(msg.sender, to, a);\n        return true;\n    }\n\n    function transferFrom(address f, address to, uint256 a) external returns (bool) {\n        if (allowance[f][msg.sender] != type(uint256).max) allowance[f][msg.sender] -= a;\n        balanceOf[f] -= a;\n        balanceOf[to] += a;\n        emit Transfer(f, to, a);\n        return true;\n    }\n}\n\ncontract Feed is IFeed {\n    uint256 public constant MAX_ALLOWANCE_BPS = 20_000;\n    uint256 public value;\n    uint64 public at;\n    uint256 public maxAge = 1 hours;\n\n    constructor(uint256 v) {\n        set(v);\n    }\n\n    function set(uint256 v) public {\n        value = v;\n        at = uint64(block.timestamp);\n    }\n\n    function latestValue() external view returns (uint256, uint64) {\n        return (value, at);\n    }\n\n    function isStale() external view returns (bool) {\n        return block.timestamp > at + maxAge;\n    }\n}\n\n/// The brake (LedgerBase._checkBrake, \"new debt stops on every type\") is not read by Ledger.setRate's charged path.\ncontract BrakePremiumTest is Test {\n    bytes32 constant ETH = \"ETH\";\n    address governor = makeAddr(\"governor\");\n    address alice = makeAddr(\"alice\");\n    address dave = makeAddr(\"dave\");\n\n    ImdUSD usd;\n    Parameters params;\n    Pricer pricer;\n    Treasury treasury;\n    Ledger ledger;\n    Liquidator liquidator;\n    Tok weth;\n    Feed median;\n    Feed spot;\n\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        weth = new Tok();\n        Tok v1 = new Tok();\n        median = new Feed(2000e18);\n        spot = new Feed(2000e18);\n\n        usd = new ImdUSD(address(this), 10_000_000e18);\n        params = new Parameters(governor, address(this));\n        pricer = new Pricer(params);\n        treasury = new Treasury(governor, IERC20(address(usd)), address(this));\n        PositionNFT nft = new PositionNFT(address(this));\n        ledger = new Ledger(usd, params, pricer, address(treasury), address(this), IPulse(address(0)), nft);\n        nft.bind(address(ledger));\n        Redeemer redeemer = new Redeemer(ledger);\n        liquidator = new Liquidator(ledger, pricer);\n        ledger.wire(address(redeemer), address(liquidator));\n        Migrator migrator = new Migrator(IERC20(address(v1)), usd, params);\n        usd.wire(address(ledger), address(migrator), address(params));\n        params.wire(address(ledger), address(usd));\n        treasury.wire(ICoverable(address(ledger)));\n\n        Join join = new Join(address(weth), address(this));\n        join.wire(address(ledger));\n        params.addGenesisIlk(\n            ETH,\n            ParametersBase.Config({\n                token: address(weth),\n                join: address(join),\n                median: median,\n                spot: spot,\n                nhi: IFeed(address(0)),\n                yieldRate: address(0),\n                pegAggregator: address(0),\n                liveSpot: IFeed(address(0)),\n                redeemable: true,\n                auction: false\n            }),\n            ParametersBase.Risk({\n                mat: 1.4e18,\n                chop: 0.1e18,\n                cut: 0.5e18,\n                chip: 0.1e18,\n                rateFloor: 0.01e18,\n                yieldFee: 0,\n                skew: 0.05e18,\n                pegFloor: 0,\n                line: 1_000_000e18,\n                dust: 100e18,\n                redeemFloor: 0.005e18,\n                redeemDivisor: 2,\n                redeemCap: 0\n            })\n        );\n        params.seal();\n\n        address[2] memory users = [alice, dave];\n        for (uint256 i; i < 2; ++i) {\n            weth.mint(users[i], 1000e18);\n            vm.prank(users[i]);\n            weth.approve(address(ledger), type(uint256).max);\n        }\n    }\n\n    function _ilkDebt() internal view returns (uint256) {\n        (uint128 debt,,,,) = ledger.ilkState(ETH);\n        return debt;\n    }\n\n    function test_chargedRateChangeAddsDebtWhileBraked() public {\n        // alice 10 WETH / 14,000 (142.8% at $2,000); dave 200 WETH / 50,000, both at 5%.\n        vm.prank(alice);\n        uint256 a = ledger.open(ETH, 0, Adjust(10e18, 14_000e18, 0.05e18, 0, 0, false, type(uint256).max, address(0)));\n        vm.prank(dave);\n        uint256 dv = ledger.open(ETH, 0, Adjust(200e18, 50_000e18, 0.05e18, 0, 0, false, type(uint256).max, address(0)));\n\n        // ETH halves: alice's 10 WETH are worth $10,000 against ~14,013 of debt. dave liquidates; ~4,000 is bad debt.\n        median.set(1000e18);\n        spot.set(1000e18);\n        vm.prank(dave);\n        (,, uint256 bad) = liquidator.liquidate(a);\n        assertGt(bad, 3_900e18, \"bad debt booked\");\n        uint256 allowed = usd.circulating() * params.unbackedBrake() / 1e18;\n        assertGt(ledger.unbacked(), allowed, \"the system is past the brake\");\n        console2.log(\"unbacked      \", ledger.unbacked());\n        console2.log(\"brake allows  \", allowed);\n\n        // Control: a borrow on the healthy position is refused by the brake.\n        vm.prank(dave);\n        vm.expectPartialRevert(LedgerBase.Braked.selector);\n        ledger.open(ETH, 0, Adjust(0, 1_000e18, 0, 0, 0, false, type(uint256).max, address(0)));\n\n        // What a charged rate change does on this commit (measured, then rolled back).\n        uint256 snap = vm.snapshotState();\n        uint256 debt0 = _ilkDebt();\n        uint256 supply0 = usd.totalSupply();\n        vm.prank(dave);\n        try ledger.setRate(dv, 0.06e18, 0, 0) {\n            console2.log(\"type debt added while braked \", _ilkDebt() - debt0);\n            console2.log(\"imdUSD minted while braked   \", usd.totalSupply() - supply0);\n        } catch {\n            console2.log(\"setRate reverted\");\n        }\n        vm.revertToState(snap);\n\n        // Expected (LedgerBase.sol:320, Ledger.sol:296-297): no new debt on any type while past the brake.\n        vm.prank(dave);\n        vm.expectPartialRevert(LedgerBase.Braked.selector);\n        ledger.setRate(dv, 0.06e18, 0, 0);\n    }\n}","reproduction":"Self-contained Foundry test (in `proof`), run with `forge test --match-path 'test/scratch/BrakePremium.t.sol' -vv` on this commit. State: ETH type (mat 1.4, chop 0.1, rateFloor 1%), alice 10 WETH / 14,000 imdUSD at 5%, dave 200 WETH / 50,000 imdUSD at 5%, ETH price 2,000 -> 1,000; dave liquidates alice, bad debt about 4,013. Then unbacked() = 3952.054794520547945205 imdUSD against a brake allowance of 540 (1% of circulating). Control: dave's borrow of 1,000 reverts Braked. Input: dave calls ledger.setRate(id, 0.06e18, 0, 0) in the same block (inside the 7-day cooldown). Expected (per the comments): revert Braked, no new debt. Actual: succeeds; type debt +47.991180334021392382 and totalSupply +47.991180334021392382 imdUSD. Output: `[FAIL: next call did not revert as expected] test_chargedRateChangeAddsDebtWhileBraked() (gas: 2586654)` with logs `unbacked 3952054794520547945205`, `brake allows 540000000000000000000`, `type debt added while braked 47991180334021392382`, `imdUSD minted while braked 47991180334021392382`; `Suite result: FAILED. 0 passed; 1 failed; 0 skipped`.","severity":"low","snippet":"            s.debt += premium.toUint128();","title":"A charged rate change adds debt and mints imdUSD while the bad-debt brake is on (Ledger.setRate never calls _checkBrake)"},{"citation":"resolved","description":"The comment says the sleeve's sync() is a no-op inside an open bid and that \"closeBid counts it then\". Backstop.closeBid (src/backstop/Backstop.sol:532-563) sets `spent = repaid`, does `tracked -= spent` and `coll[token] += received`, and adds no arrival to `tracked` or to the stream; its own comment says an arrival during the bid \"only raises usdAfter\". The premium is counted by the next sync() call (Backstop.sol:588-608), which starts its 7-day stream then. No value moves: the imdUSD stays in the sleeve as untracked balance until that call. Comment only; smallest fix is to reword it (\"the next sync counts it\"). Reachable under BetaConfig once the SIMD line opens (edge type with edgePremium). Read from the code; no test was written for this one.","line":293,"path":"src/LedgerBase.sol","reproduction":"State: an edge-type (SIMD) position is unhealthy, the sleeve has room, and at least one second has passed since the type last accrued. Liquidator.bite -> Backstop.openBid -> Ledger.liquidatePosition -> _accrue -> _mintInterest mints the edge premium P to the sleeve and calls sync(), which returns at Backstop.sol:595 because a bid is open -> Backstop.closeBid(ilk, repaid). Expected per the comment: after closeBid, tracked includes P. Actual: tracked fell by `repaid` only; imdUSD.balanceOf(sleeve) - tracked - staged == P until someone calls sync().","severity":"info","snippet":"                IEdgeSleeve(edge).sync(); // streams over 7 days; a no-op inside an open bid (closeBid counts it then)","title":"Comment claims closeBid counts an edge premium that arrives during an open bid; closeBid never does"},{"citation":"resolved","description":"Lines 12-14 state the live pool price is \"THE REDEMPTION PAYOUT LEG ONLY\", \"never used to measure a borrower\", and that \"the Pricer only ever raises the payout price with it\". Pricer._applyLive (src/Pricer.sol:93-104) does two more things with it: when the leg reads 0 or stale it sets `q.payout = 0` and `q.agree = false` (line 97-99), and when the pool is below `low` by more than `skew` it sets `q.agree = false` (line 102). `agree` gates the sleeve's standing bid in Liquidator.bite and a borrower's charged rate change (src/Ledger.sol:166 reverts NotPriced). The behaviour itself is described in the README's known issues (pushing the live pool in one transaction) and in Pricer's own comments; only this NatSpec is out of date. Smallest fix: reword lines 12-14 to name the two other readers. Reachable under BetaConfig on SIMD (the only type with a live leg). Read from the code; no test was written for this one.","line":13,"path":"src/feeds/LivePoolPrice.sol","reproduction":"SIMD with attested median = spot = 5.00 (low = high = 5.00), skew 5%. Input A: live pool price 4.70 (6% under low). Expected per the NatSpec: nothing but the payout reads the live leg, payout = max(5.00, 4.70) = 5.00. Actual: payout = 5.00 and also agree = false, so Liquidator.bite skips the standing bid (the caller path takes the position) and Ledger.setRate inside the cooldown reverts NotPriced. Input B: live leg returns 0 or is stale. Expected per the NatSpec (\"only ever raises the payout\"): payout >= high. Actual: payout = 0 and agree = false.","severity":"info","snippet":"/// is never used to measure a borrower: the Pricer only ever raises the payout price with it","title":"LivePoolPrice NatSpec says the live leg only ever raises the redemption payout and never measures a borrower; Pricer also zeroes the payout and clears `agree` with it"}],"hash":"771e3f711ae6095d24d97921ff0ca6098ae7fffaa8f5d2a7f3a5e0530e067922","nodeId":"04d4ef37-17fc-4a14-9268-b51a6edd284c","outcome":"completed","summary":"# imdUSD v2 economics review at `2875ffb`: one low finding, two stale comments, nothing higher\n\nI found no way to break the supply equation, the liquidation money path, the flash paths or the peg/allocator/backstop pots. The one behavioural defect is that a charged rate change still adds debt while the bad-debt brake is on. `.imd-findings.json` holds three entries (1 low with a proof, 2 info) and parses as valid JSON.\n\nLimits of this review:\n- Several in-scope files were not read (listed at the end).\n- The fix for the low finding was not applied or re-tested, since the task forbids source edits.\n- The two info entries are from reading only.\n- `FullSystem.t.sol` and `Invariants.t.sol` were not run; the only build was the single scratch test file.\n\n## Findings\n\n### 1. Low: `Ledger.setRate` adds debt and mints while the brake is on\n\n- **Where:** `src/Ledger.sol:161`, `s.debt += premium.toUint128();` (charged path, lines 156–170; mint at line 165).\n- **Claim the code lacks:** `src/LedgerBase.sol:320` says \"new debt stops on every type while `unbacked()` exceeds the governed fraction of the circulating\"; `src/Ledger.sol:296-297` repeats it. The borrow path calls `_checkBrake()`; the charged rate-change path does not.\n- **Call sequence:** `Ledger.open` (borrow) → another position is liquidated with bad debt → a borrow reverts `Braked` → the owner calls `Ledger.setRate(id, newRate, 0, 0)` inside the 7-day cooldown, and it succeeds.\n- **Failing state:**\n  - ETH type, mat 1.4, chop 0.1. Alice has 10 WETH / 14,000 debt, Dave has 200 WETH / 50,000 debt, both at 5%.\n  - Price goes 2,000 → 1,000 and Dave liquidates Alice.\n  - `unbacked()` is 3,952.05 against a brake allowance of 540.\n  - Dave's 1,000 borrow reverts `Braked`.\n  - Dave's `setRate(id, 0.06e18, 0, 0)` is expected to revert `Braked`. It actually succeeds: type debt +47.991180334021392382 and `totalSupply` +47.991180334021392382.\n- **Impact:** a documented safety stop is skipped on one debt-adding path.\n  - Each call adds `debt × oldRate × 7/365` and can be repeated until health or the line stops it.\n  - The minted imdUSD goes to savers, the edge premium and the Treasury, not the borrower.\n  - The supply equation still holds, so nobody loses value.\n- **README:** its known issues exempt the keeper mint from the brake, not this path.\n- **BetaConfig:** reachable on every listed type (`unbackedBrake` default 1%; only the position owner can pay a premium).\n- **Smallest fix:** call `_checkBrake()` next to `_checkLines`/`_checkEdge` at `src/Ledger.sol:163-164`, or state the exemption in the two comments.\n\nTest run on this commit with `forge test --match-path 'test/scratch/BrakePremium.t.sol' -vv` (full source is in the `proof` field; the file and build output are deleted):\n\n```\nRan 1 test for test/scratch/BrakePremium.t.sol:BrakePremiumTest\n[FAIL: next call did not revert as expected] test_chargedRateChangeAddsDebtWhileBraked() (gas: 2586654)\nLogs:\n  unbacked       3952054794520547945205\n  brake allows   540000000000000000000\n  type debt added while braked  47991180334021392382\n  imdUSD minted while braked    47991180334021392382\nSuite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 4.19ms (1.56ms CPU time)\n```\n\nThe test expects the same `Braked` error that the borrow on the same position raises in the same state.\n\n### 2. Info: comment at `src/LedgerBase.sol:293` says \"closeBid counts it then\"\n\n- `Backstop.closeBid` (`src/backstop/Backstop.sol:532-563`) only does `tracked -= spent` and never counts an arrival.\n- **State:** an edge premium P is minted to the sleeve during an open bid on SIMD. `sync()` returns early at `Backstop.sol:595`, and after `closeBid` the balance exceeds `tracked + staged` by P until someone calls `sync()`.\n- **Effect:** no value moves; the 7-day stream just starts later.\n- **Fix:** reword the comment.\n\n### 3. Info: NatSpec at `src/feeds/LivePoolPrice.sol:12-14`\n\n- It says the live leg is \"THE REDEMPTION PAYOUT LEG ONLY\", \"never used to measure a borro","treeHash":null,"usage":{"cachedInputTokens":3652642,"cost":{"source":"runtime","usdMicros":7223631},"inputTokens":80,"model":"claude-fable-5-2","outputTokens":129509,"runtime":"claude","turns":96,"wallClockMs":2132975}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"be306690d4a9deec","findings":[{"citation":"resolved","description":"Access-control / asymmetry. `retireReserve` lets ANY caller burn up to `reserveBacked` of the Treasury's imdUSD. The only guard refuses while bad debt is ALREADY booked; nothing stops a caller from draining the balance one block before a loss lands. The Treasury's imdUSD is the system's bad-debt cover (`LedgerBase.unbacked() = totalBadDebt - token.balanceOf(treasury)`, read by `_checkBrake` on every borrow of every type) and the only source `FeeNotes.redeem`/`Treasury.payNote` pays from. `reserveBacked` grows on every yield harvest of the beta's yield types (S-USDS, S-USDC-STEAKHOUSE, WSTETH carry `yieldFee` 0.1 and a RateFeed), so after a few weeks it is large enough to absorb the Treasury's whole interest income. Sequence from an external caller: (1) `treasury.retireReserve(type(uint256).max)` while `ledger.totalBadDebt()==0` burns the full Treasury balance (bounded by `reserveBacked`); (2) in the same block a marked blue position is bitten and books bad debt B (`Liquidator.bite` -> `_cover` -> `Treasury.coverBadDebt` finds `token.balanceOf(this)==0` and covers nothing); (3) `unbacked()` now equals B instead of B minus the interest the Treasury had earned, and when B > 1% of `circulating()` every type's borrowing reverts `Braked` until a holder burns imdUSD through `Ledger.cover`. Independently, with a FeeNotes series open, the same call makes every matured `FeeNotes.redeem` revert `TreasuryShort`. The accounting is supply-neutral (the Treasury's yield shares back the retired supply), which is why the NatSpec at Treasury.sol:35-37 calls it harmless; but the act converts the protocol's liquid imdUSD reserve into illiquid vault shares at a stranger's discretion and at the worst moment. README lists 'retireReserve is permissionless and does not check outstanding bad debt' as accepted; the check now exists, so the README entry is stale, and the remaining pre-emptive-drain consequence (brake griefing across every type, fee-note default) is reported here as the materially worse reading. Holds under BetaConfig (yield types on, FeeNotes deployed dormant, brake 1%). Smallest fix: make `retireReserve` `onlyGovernor` (instant is fine: it only burns), or require the burn to leave `max(FeeNotes.outstanding(), a governed reserve floor)` of imdUSD in the Treasury.","line":136,"path":"src/Treasury.sol","reproduction":"Measured on this commit with a scratch test extending test/unit/Core.t.sol CoreTest (run with `forge test --match-path test/scratch/RetireDrain.t.sol`, then deleted): (1) alice opens SUSDC 10,000e6 shares / 5,000e18 debt at 2%; vault.accrue(500e6+50); warp 6 days; _refresh(); ledger.harvest(SUSDC,[id]) -> ledger.reserveBacked() > 400e18. (2) alice opens ETH 10e18 / 14,000e18, dave opens ETH 200e18 / 50,000e18: usd.balanceOf(treasury) == X == 64.93e18 (interest + upfront fees), X < reserveBacked. (3) attacker = makeAddr('attacker'), holds no imdUSD: vm.prank(attacker); treasury.retireReserve(type(uint256).max). EXPECTED (NatSpec Treasury.sol:35-37 and README trust model 'governor ... cannot ... burn'): a stranger cannot touch the Treasury's imdUSD. ACTUAL: usd.balanceOf(treasury) == 0, reserveBacked fell by X. (4) ETH median/spot 2000 -> 1200; dave: liquidator.liquidate(pid(ETH, alice)) books B == 2,013.42e18. ACTUAL: ledger.totalBadDebt() == B and ledger.unbacked() == B (the in-transaction `_cover` burned 0); without step 3 the same liquidation covers X and leaves unbacked == B - X. (5) unbacked is 353 bps of circulating > the 100 bps brake: ledger.open(ETH, +1,000e18) reverts Braked. Caveat stated honestly: in this sizing B - X also exceeds the brake, so the drain's measured effect is the X of cover lost (and, with a FeeNotes series open, TreasuryShort on every redeem); the brake is TRIPPED BY the drain only when the Treasury's balance would otherwise have kept unbacked under 1% of supply, i.e. treasury imdUSD >= B - circulating/100, which is the normal state of a Treasury that has accrued interest for weeks against a few-thousand-imdUSD loss.","severity":"low","snippet":"    function retireReserve(uint256 amount) external {\n        if (ledger.totalBadDebt() != 0) revert BadDebtOutstanding();\n        uint256 bal = token.balanceOf(address(this));\n        ledger.retire(amount < bal ? amount : bal);\n    }","title":"Treasury.retireReserve is permissionless: anyone can burn the Treasury's whole imdUSD balance (the bad-debt cover and the fee-note payment pool) ahead of a loss, so the next liquidation covers nothing"},{"citation":"resolved","description":"Trust assumption, not a bypass. README key invariant 4 and the Backstop header describe `edgeCapacity = max(3 x net vested imdUSD, a 60-day bootstrap allowance)` as a one-off bootstrap. A re-listing path exists: the governor calls `Parameters.disableSleeveIlk(ilk, true)` (instant), then proposes `ADD_SLEEVE_ILK` with any `genesisLine` (<= uint128), and 48h later `Backstop.addIlk` takes the `k.token != address(0)` branch above, restarting `listedAt` and overwriting `genesisLine`. `bootstrap(ilk)` then reads the fresh allowance for another 60 days and `edgeCapacity` = max(3 x netVested, newGenesisLine) regardless of how little the sleeve holds. `ParametersRules._checkEdgeListing` only requires the EXISTING edge debt to fit `max(3 x netVested, genesisLine)`, which the proposed genesisLine itself satisfies. While the type is disabled (up to 48h) its standing bid and first-loss cover are off and its edge capacity reads 0, so new sIMD borrowing stops meanwhile. Impact: governance (2-of-3 Safe) can keep sIMD debt uncovered by real sleeve capital for as long as it likes, which weakens the 'first loss is paid for' property that depositors and the Treasury rely on; it is within the Safe's documented powers and timelocked, so reported as a trust assumption to document, not a defect. Reachable under BetaConfig (edge sleeve on, sIMD edge type, genesisLine 50k). Fix if wanted: in `addIlk` keep the original `listedAt`/`genesisLine` for a previously listed type (or cap a re-listing's genesisLine at the remaining `bootstrap()` of the old listing).","line":230,"path":"src/backstop/Backstop.sol","reproduction":"State: edge sleeve with netVested ~0, SIMD listed at genesis with genesisLine 50,000e18, day 61 (bootstrap 0). governor: params.disableSleeveIlk('SIMD', true); params.propose(abi.encode(ADD_SLEEVE_ILK, 'SIMD', true, uint128(50_000e18), saleMax, saleSlope)); warp 48h; anyone: params.applyPending(ADD_SLEEVE_ILK). Expected per README invariant 4: edgeCapacity('SIMD', 0) == 3 x netVested ~ 0 (bootstrap spent). Actual: edge.bootstrap('SIMD') == 50,000e18 and edge.edgeCapacity('SIMD', 0) == 50,000e18 for another 60 days.","severity":"info","snippet":"        if (k.token != address(0)) {\n            if (k.on || k.token != token) revert Exists();\n            k.on = true;\n            k.listedAt = uint64(block.timestamp);\n            k.genesisLine = edge ? genesisLine : 0;\n            emit IlkListed(ilk, token, edge ? genesisLine : 0);\n            return;\n        }","title":"Edge bootstrap allowance can be renewed indefinitely: disableSleeveIlk (instant) + ADD_SLEEVE_ILK (48h) resets listedAt and genesisLine, so edgeCapacity is not bounded by vested imdUSD as the README s"},{"citation":"resolved","description":"Documentation / trust-model claim the code does not have. `ImdUSD.setKeeper` is callable by `bridgeSetter` (Parameters), and Parameters exposes two callers of it: the timelocked `SET_KEEPER` kind in ParametersRules, and `setGenesisKeeper` (Parameters.sol:63-68), which the deployer (`wirer`) calls before `seal()` with no delay (the beta deploy does exactly this, script/deploy/StageGenesis.sol:106). The README's trust model states it correctly ('set by the deployer before the seal'); the token's own NatSpec, which is what an integrator reads, says it was timelocked and public for 48h first. No functional impact (one-shot, sealed afterwards); the comment should say 'wired by Parameters: at genesis by the deployer before the seal, otherwise through the 48h SET_KEEPER proposal'.","line":18,"path":"src/ImdUSD.sol","reproduction":"Read script/deploy/StageGenesis.sol:104-107 and Parameters.sol:63-68: `d.params.setGenesisKeeper(address(d.hook))` runs in the deploy transaction sequence, `IBridgeSettable(token).setKeeper(keeper_)` with `msg.sender == wirer` and no `pendingEta`. Expected per ImdUSD.sol:18: a 48h public proposal precedes `KeeperSet`. Actual: `KeeperSet` is emitted in the deploy itself.","severity":"info","snippet":"///  - `keeper` is set once by the same timelocked setter: the v4 peg hook (src/peg/PegHook.sol), capped by","title":"NatSpec: ImdUSD says the keeper minter is set 'by the same timelocked setter' as the bridge, but Parameters.setGenesisKeeper names it without any timelock before the seal"},{"citation":"resolved","description":"Comment claims a bound the code does not have. `ParametersBase.MAX_SAVINGS_SHARE = 0.5e18` (ParametersBase.sol:119, 'since 2026-10-29') and both `setGenesisSavings` and the `SET_SAVINGS_SHARE` validation revert `OutOfBounds` above it. The governance capability summary at the top of Parameters.sol was not updated. No functional impact; fix the comment to 0-50% (and mention the 10-point step).","line":11,"path":"src/Parameters.sol","reproduction":"governor: params.propose(abi.encode(SET_SAVINGS_SHARE, uint64(0.6e18))). Expected per the comment: accepted (60% is within 0-80%). Actual: reverts OutOfBounds (0.6e18 > MAX_SAVINGS_SHARE 0.5e18; also > savingsShare + MAX_SAVINGS_STEP).","severity":"info","snippet":"///    within 0-80%; open a fee-note series (tenor 30/90/180 days, discount <= 10%, a size cap); move a capped chain's","title":"NatSpec: Parameters says the savers' share may be set 'within 0-80%' but MAX_SAVINGS_SHARE is 50%"},{"citation":"resolved","description":"Stale comment versus the deployed configuration under review. `BetaConfig.get()` sets `c.chain.capped = true, chainLine = 300_000e18` (script/DeployConfig.sol:678) and StageTypes.sol:67 calls `params.setGenesisChainLine`, after which `chainCapped` can never be cleared (SET_CHAIN_LINE only moves the number). Readers of the source would otherwise expect `_checkLines` to be inert on mainnet. No functional impact; update the comment (the full MainnetConfig is uncapped, the beta is not).","line":145,"path":"src/ParametersBase.sol","reproduction":"After the beta deploy: params.chainCap() returns (true, 300_000e18). Expected per the comment: (false, 0) on chain 1. Actual: capped; Ledger._checkLines reverts ChainLineExceeded once the summed debt + bad debt of every type reaches 300k.","severity":"info","snippet":"    /// @notice The chain's global debt cap, on chains whose genesis capped it (Robinhood); mainnet is uncapped.","title":"NatSpec: ParametersBase says 'mainnet is uncapped' but the beta mainnet deployment caps the chain at 300k through setGenesisChainLine"},{"citation":"resolved","description":"The claim is true of the supply equation (the burn is matched by `reserveBacked` falling) but not of the system's loss-absorbing capacity as the code itself defines it: `LedgerBase.unbacked()` nets ONLY `token.balanceOf(treasury)` against bad debt, and `Treasury.coverBadDebt` can only burn that balance. After a permissionless `retireReserve` the Treasury's value sits in yield-vault shares the brake does not see and `coverBadDebt` cannot use, so the next loss reads as fully unbacked. The comment should either narrow the claim to the supply equation or the function should be restricted (same fix as the retireReserve finding).","line":35,"path":"src/Treasury.sol","reproduction":"See the retireReserve finding: before the call unbacked-after-loss == B - X, after the call == B, with the same Treasury net worth.","severity":"info","snippet":"/// @dev `coverBadDebt` and `retireReserve` are permissionless because both only burn the Treasury's own\n/// imdUSD against liabilities, which can never make the system less solvent. Investing reserves (the\n/// burn path's swap, peg keeper) is a Safe act through the timelock payout.","title":"NatSpec: Treasury claims permissionless retireReserve 'can never make the system less solvent'; it removes the liquid bad-debt cover (see the retireReserve finding)"}],"hash":"8c3e0af355aeac9a4f060b2d941ab0d64d5a345cd3f6b6321f801b16c172cfa0","nodeId":"c034c0ef-9250-4ffe-b8b8-e6abbbd860af","outcome":"completed","summary":"Permissions audit of the imdUSD v2 beta scope is complete. The findings file holds six entries, the required panel ran green, and the tree is unchanged.\n\n**Outcome.** No permission bypass, privilege escalation, broken initialization or confused-deputy path was found across the in-scope contracts. Every state-writing entry point has a guard that matches its effect. The one defect with a concrete loss is low severity. The rest are trust assumptions and NatSpec claims the code does not have.\n\n**Build and test.** The panel command ran on Foundry 1.9.0 (solc 0.8.26, via_ir) and passed.\n\n```\nforge test --match-path '{test/unit/FullSystem.t.sol,test/invariant/Invariants.t.sol}'\nRan 2 test suites: 5 tests passed, 0 failed  (2m51s wall, cached afterwards)\n```\n\n**Findings written to .imd-findings.json**\n\n- **Low. Treasury.retireReserve drains the bad-debt cover permissionlessly.** Anyone burns the Treasury's whole imdUSD, bounded only by reserveBacked, while no bad debt is booked yet. Reproduced with a scratch test on CoreTest: a stranger burned the full 64.93 imdUSD of accrued interest, the next liquidation booked 2,013 of bad debt and covered zero of it in its own transaction, and unbacked read 353 bps against the 100 bps brake. Caveat stated in the finding: in that sizing the brake trips even without the drain, so the measured loss is the cover itself. It trips the brake only when the Treasury balance would have kept the hole under 1 percent, which is the normal state after weeks of interest. The README known-issue text is stale: the \"no bad-debt check\" it accepts now exists, and this pre-emptive drain is the worse reading. Smallest fix is onlyGovernor on retireReserve.\n- **Info. Edge bootstrap is renewable by governance.** disableSleeveIlk (instant) then ADD_SLEEVE_ILK (48h) re-enters Backstop.addIlk's re-listing branch, resetting listedAt and genesisLine, so edgeCapacity can stay at the bootstrap figure indefinitely without vested imdUSD. Documented as a trust assumption, not a bypass.\n- **Info, four NatSpec mismatches.** ImdUSD says the keeper minter is set by the \"timelocked setter\" but setGenesisKeeper sets it untimelocked before the seal. Parameters claims a savings share of \"0-80%\" while MAX_SAVINGS_SHARE is 50 percent. ParametersBase says \"mainnet is uncapped\" while BetaConfig caps it at 300k. Treasury claims retireReserve \"can never make the system less solvent\", which the low finding contradicts for the brake's own definition of cover.\n\n**Coverage of the numbered questions, from the permissions lens.**\n\n1. Supply equation: every mint and burn site is a guarded minter path (Ledger, Migrator, PegHook, bridge empty). Burns without allowance happen only on actions the burned party initiated. Holds.\n2. Liquidation money path: Liquidator to LedgerSettlement to Join exits are caller-checked at each hop, including the delegatecall module's msg.sender check. Holds.\n3. Flash: flashOutstanding is transient and circulating() excludes it. PegPositionZap owns a position only inside its own call. Holds.\n4. Peg to Allocator to Backstop: no recipient argument, allowlisted routes, sale context pinned in transient storage, buffer leaves only to the Treasury. Holds.\n5. Oracle: swarm relays are permissionless but signer- and question-bound. Unreached in depth here.\n6. Permissions pass applied to all paths above. One defect found, listed first.\n\n**Coverage rows.** Holds for every external state-writing function of ImdUSD, Join, Migrator, PositionNFT, Ledger, LedgerSettlement, Liquidator, Redeemer, Treasury (except retireReserve: finding), Backstop (addIlk re-listing: info), PricerOracle, Allocator, PegHook, PegLPVault, PegPositionZap, PegCollateral, SavingsVault, FeeNotes, Parameters, ParametersRules, GovernedByKind, SeatJoin, SeatAccount, ImdDepth, SortedPositions. Unreached in depth: SwarmFeed signature internals, SeatFeed, DepthSampler walk, RateFeed and the Chainlink leaves, which are view-heavy and outside the permissions brief.\n\n**What was","treeHash":null,"usage":{"cachedInputTokens":3535731,"cost":{"source":"runtime","usdMicros":8886846},"inputTokens":546,"model":"claude-fable-5-1","outputTokens":41186,"runtime":"claude","turns":45,"wallClockMs":1013000}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"4fcac33561ba733d","findings":[{"citation":"resolved","description":"The contract header (ImdUSD.sol:21-23: 'up to `flashCap` PER TRANSACTION ... so nested or repeated loans inside one transaction share the cap') and flashLoan's @dev (ImdUSD.sol:148-150: 'so the cap bounds the transaction, not one call') claim a per-transaction bound. The code restores the transient counter to `before` when each loan is repaid (line 167), so after a loan unwinds the next loan in the same transaction again sees the whole cap. Only the amount in flight at one moment is bounded (which is what the `flashCap` @notice at line 28 says). No supply break follows (every loan is burned before return and `circulating()` excludes the in-flight part), but any reasoning or off-chain monitoring that relies on 'at most flashCap flash-minted per transaction' (e.g. the panel's question 3 sizing of flash attacks on redemption / Backstop / peg pool) is wrong: a single transaction can flash-mint N x flashCap sequentially. Holds under BetaConfig (flashCap 100_000e18). Smallest fix: either correct the NatSpec to 'at most flashCap in flight at any moment', or, if a per-transaction bound is intended, keep a second transient counter of the cumulative amount lent in the transaction that is never decremented and check `value <= flashCap - cumulative`.","line":167,"path":"src/ImdUSD.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {ImdUSD} from \"src/ImdUSD.sol\";\nimport {IERC3156FlashBorrower} from \"@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol\";\n\ncontract Looper is IERC3156FlashBorrower {\n    ImdUSD public immutable usd;\n    uint256 public maxSeen;\n    constructor(ImdUSD u) { usd = u; }\n    function run(uint256 amount, uint256 times) external {\n        for (uint256 i; i < times; ++i) usd.flashLoan(this, address(usd), amount, \"\");\n    }\n    function onFlashLoan(address, address, uint256 amount, uint256, bytes calldata) external returns (bytes32) {\n        if (usd.flashOutstanding() > maxSeen) maxSeen = usd.flashOutstanding();\n        usd.approve(address(usd), amount);\n        return keccak256(\"ERC3156FlashBorrower.onFlashLoan\");\n    }\n}\n\ncontract ProofFlashCap is Test {\n    function test_sequentialLoansDoNotShareTheCap() public {\n        ImdUSD usd = new ImdUSD(address(this), 100_000e18); // BetaConfig.flashCap\n        Looper l = new Looper(usd);\n        // NatSpec (ImdUSD.sol:21-23, 149): \"up to flashCap PER TRANSACTION ... nested or repeated loans inside one\n        // transaction share the cap\"; \"the cap bounds the transaction, not one call\".\n        // One call (one transaction) takes the whole cap three times in a row: 300k flash-minted in total.\n        bool ok;\n        try l.run(100_000e18, 3) {\n            ok = true;\n        } catch {}\n        assertFalse(ok, \"three sequential full-cap loans in one transaction succeeded: the cap does not bound the transaction\");\n    }\n}","reproduction":"BetaConfig flashCap = 100_000e18. One external call that loops `imdUSD.flashLoan(receiver, imdUSD, 100_000e18, \"\")` three times (each repaid in its callback) succeeds: 300_000e18 flash-minted in one transaction. Expected per the NatSpec: the second loan reverts ERC3156ExceededMaxLoan(0). Actual: all three succeed. Ran `forge test --match-path test/scratch/ProofFlashCap.t.sol -vv` on this commit: '[FAIL: three sequential full-cap loans in one transaction succeeded: the cap does not bound the transaction] test_sequentialLoansDoNotShareTheCap() (gas: 569683)'.","severity":"low","snippet":"        _setFlashOutstanding(before);","title":"ImdUSD flash cap bounds loans in flight, not the transaction: sequential loans each get the full flashCap (NatSpec claims otherwise)"},{"citation":"resolved","description":"ImdUSD.sol:116-117 states each minter only burns from `from` on an action `from` initiated. In Liquidator.bite's standing-bid path (Liquidator.sol:172) the Ledger is called with payer = the Backstop sleeve, and LedgerSettlement.liquidatePosition burns `repaid` from the sleeve's balance with no allowance, on a call any third party initiated (anyone may call Liquidator.liquidate/bite). This is the intended design (the sleeve is a standing bid, guarded by openBid/closeBid's room and BadPrice checks), but the token-level comment misstates the trust property auditors and integrators rely on: the Ledger minter burns from an address that did not initiate the action.","line":185,"path":"src/LedgerSettlement.sol","reproduction":"BetaConfig: an ETH position (blue sleeve listed for ETH, room >= its debt, legs agree) becomes unhealthy; any EOA calls Liquidator.liquidate(id). Expected per ImdUSD.sol:116-117: only the initiator's imdUSD is burned. Actual: `repaid` imdUSD is burned from the blue Backstop (payer = sleeve, Liquidator.sol:172 -> LedgerSettlement.sol:185) without its allowance. Fix: reword the NatSpec to name the standing-bid exception.","severity":"info","snippet":"        else token.burn(payer, repaid);","title":"ImdUSD.burn NatSpec: 'each minter only burns on an action `from` initiated through it' does not hold for the standing bid"},{"citation":"resolved","description":"Liquidator.bite returns before the standing bid for every auction type (Liquidator.sol:154-158), and MainnetConfig.backstopSpec (used by BetaConfig) lists only SIMD on the edge sleeve. The README says 'Seats are an auction type: no sleeve bids on them'. The contract header claims the edge sleeve covers seats and stocks. Consequence for readers: a seat type's bad debt is not edge first-loss (Treasury.coverBadDebt asks the sleeve only when params.edgeIlk(ilk)).","line":16,"path":"src/backstop/Backstop.sol","reproduction":"BetaConfig: backstopSpec(SIMD_LINE_TARGET).ilks has 7 entries, only SIMD with edge=true; SEAT is not passed to Backstop.addIlk, so edge.ilks(SEAT).on == false and edge.bidRoom(SEAT) == 0. Expected per comment: edge sleeve bids/takes first loss on seats. Actual: it does neither. Fix: correct the comment.","severity":"info","snippet":"/// exist per chain: `blue` (ETH, BTC, staked stables) and `edge` (sIMD, seats, stocks). The edge sleeve also burns its","title":"Backstop header lists seats (and stocks) as edge-sleeve types; the beta never lists them and the standing bid never reaches an auction type"},{"citation":"resolved","description":"README.md:188 lists as accepted risk that `Treasury.retireReserve` is permissionless and does not check outstanding bad debt. The code checks `ledger.totalBadDebt() != 0` and reverts. The code is the safer behaviour; the documentation claims a weaker property than the code has. Note a remaining nuance: the check is global, so a permissionless caller can still retire reserve-backed supply with the Treasury's imdUSD the instant bad debt is fully covered, which is the documented intent.","line":137,"path":"src/Treasury.sol","reproduction":"Any state with totalBadDebt = 1 wei: Treasury.retireReserve(x) reverts BadDebtOutstanding (README says it would succeed). Fix: drop the known-issue line or reword it.","severity":"info","snippet":"        if (ledger.totalBadDebt() != 0) revert BadDebtOutstanding();","title":"README known issue on Treasury.retireReserve is stale: the code does refuse while bad debt is booked"}],"hash":"aecae0c13a01daa1a5dbffe689c9ebba2e472f77e9e37697dd719a61bcfcbfe6","nodeId":"0064eb7d-130b-4d9c-98d4-300f74efbcec","outcome":"completed","summary":"I found no critical, high or medium defect in the parts I traced. The one confirmed defect is low severity: the flash-mint cap does not limit a transaction the way the code comments say. My coverage is incomplete — about 30 of the 84 minutes went to builds and waiting on tests, so several contracts were not read at all (listed at the end). Treat this as a partial review, not a clean bill.\n\n`.imd-findings.json` holds four entries: one low and three info. The panel run (`FullSystem.t.sol`, `Invariants.t.sol` and the proof) passed 5 of 6 tests. The one failure was the proof, failing on purpose. All 7 invariants passed, including `invariant_supplyEquation`. I deleted the proof afterwards, so the tracked tree is unchanged; the untracked items `git status` shows were there before I started.\n\n## Findings\n1. **Low — the flash cap doesn't bound a transaction** (`src/ImdUSD.sol:167`). The comments at lines 21–23 and 148–150 say all loans in one transaction share `flashCap`. In fact each repaid loan resets the in-flight counter, so one transaction can take 3 × 100k imdUSD back to back under BetaConfig. Supply still balances, since each loan is burned before the call returns. The fix is to correct the comment, or add a cumulative per-transaction counter. The proof (included in the file) gave: `[FAIL: three sequential full-cap loans in one transaction succeeded…] test_sequentialLoansDoNotShareTheCap() (gas: 569683)`.\n2. **Info — wrong comment on `ImdUSD.burn`** (lines 116–117). It says each minter only burns from the address that started the action. The standing bid doesn't fit: `LedgerSettlement.sol:185` burns from the sleeve on a liquidation anyone can trigger.\n3. **Info — wrong `Backstop` header** (line 16). It says the edge sleeve covers seats and stocks. The beta lists only sIMD, and `bite` exits before the standing bid for every auction type.\n4. **Info — stale README known issue** (README line 188). It says `retireReserve` doesn't check bad debt, but `Treasury.sol:137` does refuse while any bad debt is booked.\n\n## The numbered questions\n1. **Supply equation:** holds for every path I read. Borrow, repay, interest, upfront fee, rate premium, savings and edge-premium splits, redemption, both liquidation paths, `cover`, `retire`, the peg keeper's mint and burn, the migrator (line 0 in the beta) and the flash mint each move supply and the ledger side together. I found no sequence that breaks it.\n2. **Liquidation money path:** holds.\n   - The collateral covers the debt before any penalty is taken, and the Treasury's cut is zero whenever bad debt is booked.\n   - `closeBid` checks the room it opened with and rejects any purchase priced below `low`. Each collateral token has one type in `PricerOracle`, so it reads the same `low` the liquidation used.\n   - Bad debt is covered by the edge sleeve first, then the Treasury.\n   - The edge mark accounting is consistent.\n3. **Flash:** no exploit found. Redemption fees use `circulating()`. A Backstop deposit only waits in a day bucket and can't act as bid room. A donation goes into the 7-day stream. The zap's open leaves nothing behind, and only the owner can unwind. Finding 1 changes how big a flash attack can be.\n4. **Peg → Allocator → Backstop:** no leak to a caller found. The keeper checks its principal after every action. The buffer buy sends imdUSD to the Treasury. `Backstop.sell` only reaches the Allocator through an allowlisted, single-use callback. One theoretical gap: imdUSD that lands in the sleeve during a sale counts as proceeds immediately instead of streaming. That would need a route that triggers interest on an edge type, which I could not reach.\n5. **Oracle at the edge of its cap:** I didn't model this beyond what the README already accepts for sIMD (wrong pair, liquidations, the standing bid's live-pool check). I found nothing worse than written.\n6. **Lenses applied:**\n   - Math: rounding direction in liquidation, partial liquidation and conversions.\n   - Permissions: minters, `onlyL","treeHash":null,"usage":{"cachedInputTokens":2461337,"cost":{"source":"runtime","usdMicros":1770695},"inputTokens":46,"model":"claude-opus-5-5","outputTokens":28462,"runtime":"claude","turns":25,"wallClockMs":815373}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"410247426ec5a6df","findings":[{"citation":"resolved","description":"`Liquidator.bite` ends every fungible liquidation that books bad debt with `_cover(ilk, bad)` (src/Liquidator.sol:175 and :184), whose NatSpec (lines 187-191) promises that booked bad debt is covered 'in the liquidation's own transaction ... so no depositor can leave between the loss and its cover, and the unbacked brake sees only what both could not pay'. The auction path does not: `settle` (lines 202-213), reached from `SeatJoin.take` / `takeFloor` -> `_settle` (src/seats/SeatJoin.sol:578), calls `ledger.liquidatePosition` and returns `bad` to the join, which only uses it for its own penalty split. The seat type is live in BetaConfig (`_seats(c)`: SEATS ON, mat 250%, chop 10%, line 40k), so a seat sale below the debt leaves `Ledger.totalBadDebt()` and `ilkState(SEAT).badDebt` non-zero although the Treasury holds imdUSD it could burn. Until someone calls `Treasury.coverBadDebt(\"SEAT\")`: `Treasury.retireReserve` reverts `BadDebtOutstanding` for every type, `LedgerBase.unbacked()` reads non-zero (ops alert; the global brake if the Treasury balance is short of the hole), and fee-note redemptions compete for the same balance. No value is lost (the cover is permissionless and the supply equation holds: supply == debt + badDebt), hence low. Reachable under BetaConfig. Smallest fix: in `settle`, capture `bad` and call `_cover(ilk, bad)` after `ledger.liquidatePosition` (the join holds no Ledger lock at that point and `Treasury.coverBadDebt` on a non-edge type only burns Treasury imdUSD). Verified with the Foundry test below (test/scratch/ProofSeatSettleNoCover.t.sol, SeatSystem harness, run with the solc profile): the failing assertion is the one the `_cover` NatSpec promises; the companion test shows a later manual `treasury.coverBadDebt(SEAT)` clears it.\n\nOutput:\n[PASS] test_manualCoverAfterwardsClearsIt() (gas: 3739799)\n[FAIL: bad debt should have been covered in the sale's transaction: 382383706801359437877 != 0] test_seatSaleBooksBadDebtWithoutCoveringIt() (gas: 3882510)\nLogs:\n  take price: 1120000000000000000000\n  bad debt booked: 382383706801359437877\n  treasury imdUSD: 2006219323239715602262","line":212,"path":"src/Liquidator.sol","reproduction":"Seat type SEAT (BetaConfig values: mat 2.5e18, chop 0.1e18, rateFloor 0.08e18, dust 100e18; seat median 2e18 wei x ETH/USD 2000e18 = $4,000 a seat). 1) alice deposits seat #1 through SeatJoin.deposit and opens a SEAT position: collateral 1e18 units, debt 1,500 imdUSD at 8% (CR ~267%). 2) Five strictly newer median attestations of 0.8e18 wei with SeatFeed.poke between them: the 20% fall cap steps the accepted median 2 -> 1.6 -> 1.28 -> 1.024 -> 0.8192 -> 0.8 ETH ($1,600). 3) Liquidator.liquidate(id) marks and opens the Dutch auction at $1,600; after 6h of priced time the price is 0.7 x 1,600 = $1,120. 4) bob borrows 10,000 imdUSD against 100 ETH, transfers 2,000 imdUSD to the Treasury, approves the join and calls SeatJoin.take(id, max). 5) The Ledger books bad = debt (1,500 + 7-day upfront fee + interest) - 1,120 = 382.38 imdUSD. Expected (per Liquidator._cover's NatSpec and README invariant 5): ledger.totalBadDebt() == 0 after the sale, Treasury balance reduced by 382.38. Actual: ledger.totalBadDebt() == 382383706801359437877 while the Treasury holds 2,006.2 imdUSD (its balance only grew by the sale's accrued interest); treasury.retireReserve(1) reverts BadDebtOutstanding; a separate treasury.coverBadDebt(\"SEAT\") then burns the 382.38 and clears it.","severity":"low","snippet":"        return ledger.liquidatePosition(id, price, msg.sender, marker, reserve);","title":"Liquidator.settle (auction/seat sales) books bad debt without the in-transaction cover that bite performs"},{"citation":"resolved","description":"NatSpec claim the code does not have. `ParametersRules._validate` refuses `ADD_SLEEVE_ILK` for any `Config.auction` type (src/ParametersRules.sol:90 `if (c.auction) revert BadConfig();`), the deploy config lists only the seven fungible types in `backstopSpec`, and README says seats 'sell by Dutch auction' with 'no sleeve'. Consequently the seat type has no standing bid, no first-loss sleeve and no edge-capacity bound, and its bad debt reaches only the Treasury (see the low finding on `Liquidator.settle`). No code change is needed beyond the comment; it matters because a reader of the sleeve's docstring would expect seat losses to hit edge depositors first.","line":16,"path":"src/backstop/Backstop.sol","reproduction":"Propose `Parameters.propose(abi.encode(ADD_SLEEVE_ILK, \"SEAT\", true, 0, 0, 0))` under BetaConfig: `_validate` reverts `BadConfig()` at src/ParametersRules.sol:90 because `config(\"SEAT\").auction == true`. Expected per the Backstop header: seats are an edge-sleeve type. Actual: they cannot be listed in either sleeve.","severity":"info","snippet":"/// exist per chain: `blue` (ETH, BTC, staked stables) and `edge` (sIMD, seats, stocks). The edge sleeve also burns its","title":"Backstop header claims the edge sleeve covers seats and stocks; seats (an auction type) can never be listed in a sleeve"},{"citation":"resolved","description":"NatSpec claim the code does not have. `ParametersBase.MAX_SAVINGS_SHARE = 0.5e18` (src/ParametersBase.sol:119, '50% since 2026-10-29') and `ParametersRules._validate` for SET_SAVINGS_SHARE reverts `OutOfBounds` above it (src/ParametersRules.sol:46), with a 10-point step. The README (`savings share 35%, governed 0-50%`) and DeployConfig agree with the code; only this header is stale. Behaviour is the safer one (a tighter bound), so informational.","line":10,"path":"src/Parameters.sol","reproduction":"`Parameters.propose(abi.encode(SET_SAVINGS_SHARE, uint64(0.6e18)))` under BetaConfig (savingsShare 0.35e18). Expected per the header: accepted (60% is within 0-80%). Actual: reverts `OutOfBounds()` (0.6e18 > MAX_SAVINGS_SHARE 0.5e18, and the step from 0.35e18 exceeds MAX_SAVINGS_STEP 0.1e18).","severity":"info","snippet":"///    set the bridge minter once; set the peg keeper minter once and its cap; set the savers' share of interest\n///    within 0-80%; open a fee-note series (tenor 30/90/180 days, discount <= 10%, a size cap); move a capped chain's","title":"Parameters header says the savers' share is governed within 0-80%; the bound in code is 50%"},{"citation":"resolved","description":"Numerical claim slightly off. `_fee` (src/Redeemer.sol:152-156) is `min(redeemFloor + decayedBaseRate + increase, FEE_CAP)`, and `decayedBaseRate` starts at FEE_CAP (5%) at `listedAt` and decays with SECOND_DECAY (half-life ~12h). After 40h the base is 0.05 x 0.5^(40/12) ~ 0.0050, so with the 0.5% floor the fee reads ~1.0%, not 0.5%; it is within 0.1% of the floor only after ~68h (base 0.05 x 0.5^(68/12) ~ 0.001). With the beta's blue floors of 0.5% the quoted 40h understates the launch fee by about a factor of two. Informational: the formula itself is as designed (the known-issues list already covers fee sizing); only the comment misstates the number.","line":79,"path":"src/Redeemer.sol","reproduction":"Fresh type with redeemFloor 0.005e18 and no redemption yet, 40h after `Parameters.seal()`: `redeemer.feeFor(ilk, 1)` returns about 0.00997e18 (floor 0.005e18 + base 0.05e18 x 999983955055097432^144000 / 1e18 ~ 0.00497e18), not 0.005e18. Expected per the comment: ~0.005e18.","severity":"info","snippet":"    /// the fee falls from 5% to a 0.5% floor in ~40h after launch. Before the seal it reads the cap.","title":"Redeemer.decayedBaseRate NatSpec: the fee does not reach the 0.5% floor in ~40h; the base alone decays to ~0.5% then, so the fee reads ~1%"}],"hash":"af73e955e9614276b81cdc4750a852c807635603c3f13bb1b4b94b57921de15c","nodeId":"b9c7edbe-4167-4d41-a681-a15f62481aea","outcome":"completed","summary":"Scratch tests removed, the tracked tree is unchanged, and `.imd-findings.json` holds the four findings. Final report follows.\n\n## Outcome\n\nNo critical, high or medium math defect was found in the beta scope under the Math Precision, Boundary and Numerical Gap lenses. One low finding and three informational NatSpec mismatches are recorded in `.imd-findings.json`. The required panel passed (FullSystem 3 tests, Invariants 2 tests, 2m49s under solc via_ir). Two scratch probes I wrote were run and deleted: a seat-sale reproduction (fails as the finding states) and a 1024-run fuzz of the standing bid at arbitrary underwater prices plus redemption rounding (both pass, backing the \"holds\" rows below).\n\n## Findings\n\n- **Low. `Liquidator.settle` books bad debt with no in-transaction cover.** `bite` ends every fungible liquidation with `_cover(ilk, bad)`; the auction path (seats, live under BetaConfig) returns straight after `liquidatePosition`. Reproduced: a 1,500 imdUSD seat position sold at the $1,120 floor books 382.38 imdUSD of bad debt that stays booked while the Treasury holds 2,006 imdUSD; `retireReserve` reverts until someone calls `coverBadDebt(\"SEAT\")`. Fix: call `_cover` in `settle`. The `_cover` docstring (\"covered in the liquidation's own transaction\") is the claim the code lacks.\n- **Info.** Backstop header says the edge sleeve covers \"sIMD, seats, stocks\"; `ADD_SLEEVE_ILK` refuses auction types, so seats have no sleeve.\n- **Info.** Parameters header says the savers' share is governed \"within 0-80%\"; the bound is 50%.\n- **Info.** `Redeemer.decayedBaseRate` says the fee \"falls from 5% to a 0.5% floor in ~40h\"; at 40h the fee reads about 1.0% (floor plus a decayed base of 0.496%); the floor is approached after about 68h.\n\n## The six questions\n\n1. **Supply equation.** Every mint/burn pair moves both sides together: borrow, upfront fee and cooldown premium (`s.debt` plus mint), interest (`_accrue` ceil-rounded on both sides), repay, redemption (`burnFrom` of Σ taken), liquidation (burn `repaid`, book `bad`, reserve path books `reserveBacked`), write-off, `cover`/`retire`, Migrator (`outstanding`), keeper (`outstanding`), flash (transient, excluded from `circulating`). Not broken; the invariant suite confirms it. The only residue is the documented per-accrual rounding (aggregate ceil, positions floor), which is backed by minted interest.\n2. **Liquidation money path.** Holds. Solvency-before-penalty means bad debt is booked only when collateral is worth less than debt; the sleeve's `closeBid` check `ceil(received·low) ≥ spent` cannot fail from rounding (bonus in the bad-debt case is at most 1 unit, so the marker chip rounds to zero at every beta price scale). Partial liquidation `x = (T·D − C·P)/(T − 1 − chop)` is algebraically correct and `seized ≤ collateral` is guaranteed by the full-cover pre-check. The one leak is the seat path's missing automatic cover (low finding).\n3. **Flash.** Redemption fee and base-rate rise divide by `circulating()`; `settledAssets` zeroes same-timestamp savings deposits; Backstop deposits wait a day bucket and cancel for exactly the amount; peg swaps pay the toll on the unspecified leg; the zap is the intended flash user and repays exactly `imdIn`. No flash path dilutes a rule.\n4. **Peg → Allocator → Backstop.** `Backstop.sell` enforces `max(keeperMinOut, 98% of low)` and the Allocator adds `oracleMinOut` at `maxSlippageBps ≤ 5%`; proceeds go to the sleeve by balance difference; buffer funding is capped at `bufferRoom`; keeper profit split pays only `REWARD_BPS` of what the call realised. Leakage is bounded to the configured slippage per bucket, which is the design.\n5. **Oracle at the cap edge.** A pair at ±20% (40% after silence) moves `low`, redemption `payout` (never below the live pool) and `nav` together; the sleeve's `agree` gate sends a pair far above the pool to the caller path. Consequences match the README's measured known issue; nothing worse found. `_mat`/`_lull` interpolation rounds up","treeHash":null,"usage":{"cachedInputTokens":6354975,"cost":{"source":"runtime","usdMicros":11847962},"inputTokens":674,"model":"claude-fable-5-1","outputTokens":63273,"runtime":"claude","turns":57,"wallClockMs":1495224}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"89214b73ec1e0b7b","findings":[{"citation":"resolved","description":"LedgerBase.sol:320 documents the brake as 'new debt stops on every type while unbacked() exceeds the governed fraction of the circulating supply', and Ledger.sol:296-297 repeats it on the borrow path, which calls _checkBrake() before token.mint (Ledger.sol:301). The charged branch of Ledger.setRate (a rate change inside RATE_COOLDOWN = 7 days, Ledger.sol:156-170) also adds debt (line 161) and mints it (line 165, _mintInterest), and runs the type line, _checkLines, _checkEdge, the borrowable/agree check and the health check, but never _checkBrake. While the brake is on, a position owner can still grow type debt and totalSupply by debt x oldRate x 7/365 per call and repeat it by alternating two rates until the line or health stops it. The minted imdUSD goes to savers, the edge premium and the Treasury, not to the borrower, and the supply equation holds (debt and supply rise together), so no value is taken; the impact is that a documented safety stop does not apply to one debt-adding path. README known issues list the peg keeper mint as outside the brake, not this path. Reachable under BetaConfig on every listed type (unbackedBrake default 0.01e18, RATE_COOLDOWN constant). Reproduced by reading the code and with the specialist's test (its run is reported in the reproduction field). Smallest fix: call _checkBrake() next to _checkLines/_checkEdge at Ledger.sol:163-164, or document the premium as exempt at LedgerBase.sol:320 and Ledger.sol:296-297.","line":161,"path":"src/Ledger.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test, console2} from \"forge-std/Test.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, IERC20} 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 {Migrator} from \"src/Migrator.sol\";\nimport {Join} from \"src/Join.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {Adjust} from \"src/interfaces/IPositions.sol\";\n\ncontract Tok {\n    string public name = \"T\";\n    string public symbol = \"T\";\n    uint8 public constant decimals = 18;\n    uint256 public totalSupply;\n    mapping(address => uint256) public balanceOf;\n    mapping(address => mapping(address => uint256)) public allowance;\n\n    event Transfer(address indexed from, address indexed to, uint256 value);\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    function mint(address to, uint256 a) external {\n        totalSupply += a;\n        balanceOf[to] += a;\n        emit Transfer(address(0), to, a);\n    }\n\n    function approve(address s, uint256 a) external returns (bool) {\n        allowance[msg.sender][s] = a;\n        emit Approval(msg.sender, s, a);\n        return true;\n    }\n\n    function transfer(address to, uint256 a) external returns (bool) {\n        balanceOf[msg.sender] -= a;\n        balanceOf[to] += a;\n        emit Transfer(msg.sender, to, a);\n        return true;\n    }\n\n    function transferFrom(address f, address to, uint256 a) external returns (bool) {\n        if (allowance[f][msg.sender] != type(uint256).max) allowance[f][msg.sender] -= a;\n        balanceOf[f] -= a;\n        balanceOf[to] += a;\n        emit Transfer(f, to, a);\n        return true;\n    }\n}\n\ncontract Feed is IFeed {\n    uint256 public constant MAX_ALLOWANCE_BPS = 20_000;\n    uint256 public value;\n    uint64 public at;\n    uint256 public maxAge = 1 hours;\n\n    constructor(uint256 v) {\n        set(v);\n    }\n\n    function set(uint256 v) public {\n        value = v;\n        at = uint64(block.timestamp);\n    }\n\n    function latestValue() external view returns (uint256, uint64) {\n        return (value, at);\n    }\n\n    function isStale() external view returns (bool) {\n        return block.timestamp > at + maxAge;\n    }\n}\n\n/// The brake (LedgerBase._checkBrake, \"new debt stops on every type\") is not read by Ledger.setRate's charged path.\ncontract BrakePremiumTest is Test {\n    bytes32 constant ETH = \"ETH\";\n    address governor = makeAddr(\"governor\");\n    address alice = makeAddr(\"alice\");\n    address dave = makeAddr(\"dave\");\n\n    ImdUSD usd;\n    Parameters params;\n    Pricer pricer;\n    Treasury treasury;\n    Ledger ledger;\n    Liquidator liquidator;\n    Tok weth;\n    Feed median;\n    Feed spot;\n\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        weth = new Tok();\n        Tok v1 = new Tok();\n        median = new Feed(2000e18);\n        spot = new Feed(2000e18);\n\n        usd = new ImdUSD(address(this), 10_000_000e18);\n        params = new Parameters(governor, address(this));\n        pricer = new Pricer(params);\n        treasury = new Treasury(governor, IERC20(address(usd)), address(this));\n        PositionNFT nft = new PositionNFT(address(this));\n        ledger = new Ledger(usd, params, pricer, address(treasury), address(this), IPulse(address(0)), nft);\n        nft.bind(address(ledger));\n        Redeemer redeemer = new Redeemer(ledger);\n        liquidator = new Liquidator(ledger, pricer);\n        ledger.wire(address(redeemer), address(liquidator));\n        Migrator migrator = new Migrator(IERC20(address(v1)), usd, params);\n        usd.wire(address(ledger), address(migrator), address(params));\n        params.wire(address(ledger), address(usd));\n        treasury.wire(ICoverable(address(ledger)));\n\n        Join join = new Join(address(weth), address(this));\n        join.wire(address(ledger));\n        params.addGenesisIlk(\n            ETH,\n            ParametersBase.Config({\n                token: address(weth),\n                join: address(join),\n                median: median,\n                spot: spot,\n                nhi: IFeed(address(0)),\n                yieldRate: address(0),\n                pegAggregator: address(0),\n                liveSpot: IFeed(address(0)),\n                redeemable: true,\n                auction: false\n            }),\n            ParametersBase.Risk({\n                mat: 1.4e18,\n                chop: 0.1e18,\n                cut: 0.5e18,\n                chip: 0.1e18,\n                rateFloor: 0.01e18,\n                yieldFee: 0,\n                skew: 0.05e18,\n                pegFloor: 0,\n                line: 1_000_000e18,\n                dust: 100e18,\n                redeemFloor: 0.005e18,\n                redeemDivisor: 2,\n                redeemCap: 0\n            })\n        );\n        params.seal();\n\n        address[2] memory users = [alice, dave];\n        for (uint256 i; i < 2; ++i) {\n            weth.mint(users[i], 1000e18);\n            vm.prank(users[i]);\n            weth.approve(address(ledger), type(uint256).max);\n        }\n    }\n\n    function _ilkDebt() internal view returns (uint256) {\n        (uint128 debt,,,,) = ledger.ilkState(ETH);\n        return debt;\n    }\n\n    function test_chargedRateChangeAddsDebtWhileBraked() public {\n        // alice 10 WETH / 14,000 (142.8% at $2,000); dave 200 WETH / 50,000, both at 5%.\n        vm.prank(alice);\n        uint256 a = ledger.open(ETH, 0, Adjust(10e18, 14_000e18, 0.05e18, 0, 0, false, type(uint256).max, address(0)));\n        vm.prank(dave);\n        uint256 dv = ledger.open(ETH, 0, Adjust(200e18, 50_000e18, 0.05e18, 0, 0, false, type(uint256).max, address(0)));\n\n        // ETH halves: alice's 10 WETH are worth $10,000 against ~14,013 of debt. dave liquidates; ~4,000 is bad debt.\n        median.set(1000e18);\n        spot.set(1000e18);\n        vm.prank(dave);\n        (,, uint256 bad) = liquidator.liquidate(a);\n        assertGt(bad, 3_900e18, \"bad debt booked\");\n        uint256 allowed = usd.circulating() * params.unbackedBrake() / 1e18;\n        assertGt(ledger.unbacked(), allowed, \"the system is past the brake\");\n        console2.log(\"unbacked      \", ledger.unbacked());\n        console2.log(\"brake allows  \", allowed);\n\n        // Control: a borrow on the healthy position is refused by the brake.\n        vm.prank(dave);\n        vm.expectPartialRevert(LedgerBase.Braked.selector);\n        ledger.open(ETH, 0, Adjust(0, 1_000e18, 0, 0, 0, false, type(uint256).max, address(0)));\n\n        // What a charged rate change does on this commit (measured, then rolled back).\n        uint256 snap = vm.snapshotState();\n        uint256 debt0 = _ilkDebt();\n        uint256 supply0 = usd.totalSupply();\n        vm.prank(dave);\n        try ledger.setRate(dv, 0.06e18, 0, 0) {\n            console2.log(\"type debt added while braked \", _ilkDebt() - debt0);\n            console2.log(\"imdUSD minted while braked   \", usd.totalSupply() - supply0);\n        } catch {\n            console2.log(\"setRate reverted\");\n        }\n        vm.revertToState(snap);\n\n        // Expected (LedgerBase.sol:320, Ledger.sol:296-297): no new debt on any type while past the brake.\n        vm.prank(dave);\n        vm.expectPartialRevert(LedgerBase.Braked.selector);\n        ledger.setRate(dv, 0.06e18, 0, 0);\n    }\n}","reproduction":"State (standalone harness in the proof): ETH type mat 1.4, chop 0.1, rateFloor 1%; alice 10 WETH / 14,000 imdUSD at 5%, dave 200 WETH / 50,000 imdUSD at 5%; ETH median and spot 2,000 -> 1,000; dave calls Liquidator.liquidate(alice's id), which books about 4,013 bad debt so unbacked() (about 3,952) exceeds the brake allowance (1% of circulating, 540). Control: dave's ledger.open(ETH, 0, Adjust(0, 1_000e18, ...)) reverts Braked. Input: dave calls ledger.setRate(daveId, 0.06e18, 0, 0) in the same block (inside the 7-day cooldown). Expected per LedgerBase.sol:320: revert Braked, no new debt. Actual: succeeds; ilkState(ETH).debt and totalSupply both rise by about 47.99e18 (50,000 x 5% x 7/365). Test: test/scratch/BrakePremium.t.sol (the proof below), run with forge test --match-path test/scratch/BrakePremium.t.sol -vv; it fails on this commit with 'next call did not revert as expected' and passes once _checkBrake() is added to the charged path. See the proof field for the test source and the end of this field for the run status on this machine. Run on this commit (forge 1.8.3, solc 0.8.26 via_ir, foundry.toml profile): forge test --match-path test/scratch/BrakePremium.t.sol -vv -> [FAIL: next call did not revert as expected] test_chargedRateChangeAddsDebtWhileBraked() (gas: 2586654); Logs: unbacked 3952054794520547945205; brake allows 540000000000000000000; type debt added while braked 47991180334021392382; imdUSD minted while braked 47991180334021392382; Suite result: FAILED. 0 passed; 1 failed; 0 skipped.","severity":"low","snippet":"            s.debt += premium.toUint128();","title":"Ledger.setRate's charged path adds debt and mints imdUSD while the unbacked-supply brake is on (no _checkBrake)"},{"citation":"resolved","description":"Every fungible liquidation in Liquidator.bite ends with _cover(ilk, bad) (Liquidator.sol:175 and :184), whose NatSpec (lines 187-191) promises that booked bad debt is covered in the liquidation's own transaction so 'no depositor can leave between the loss and its cover, and the unbacked brake sees only what both could not pay'. The auction path does not: settle (Liquidator.sol:202-213), reached from SeatJoin.take / takeFloor -> _settle (src/seats/SeatJoin.sol:578), returns ledger.liquidatePosition's result straight to the join, which uses bad only for its own penalty split. The seat type is live in BetaConfig (seatSpec: mat 250%, chop 10%, line 40k), so a seat sale below the debt leaves Ledger.totalBadDebt() and ilkState(SEAT).badDebt non-zero although the Treasury holds imdUSD it could burn. Until someone calls Treasury.coverBadDebt('SEAT'): Treasury.retireReserve reverts BadDebtOutstanding for every type, unbacked() reads the whole hole (and brakes every type if it exceeds 1% of circulating), and fee-note redemptions compete for the same balance. No value is lost and the supply equation holds (supply == debt + badDebt), so low. Reachable under BetaConfig. Smallest fix: in settle, capture bad and call _cover(ilk, bad) after ledger.liquidatePosition (the join holds no Ledger lock there, and Treasury.coverBadDebt on a non-edge type only burns Treasury imdUSD). Reproduced by reading Liquidator.settle and SeatJoin._settle; no runnable proof is attached (the specialist's test used the SeatSystem harness, not supplied).","line":212,"path":"src/Liquidator.sol","reproduction":"BetaConfig seat type (mat 2.5e18, chop 0.1e18, rateFloor 0.08e18, dust 100e18; seat median 2e18 wei x ETH/USD 2000e18 = $4,000 a seat). 1) alice deposits seat #1 through SeatJoin.deposit and opens a SEAT position: collateral 1e18 units, debt 1,500 imdUSD at 8%. 2) Five strictly newer median attestations of 0.8e18 with SeatFeed.poke between them walk the accepted median 2 -> 1.6 -> 1.28 -> 1.024 -> 0.8192 -> 0.8 ETH ($1,600). 3) Liquidator.liquidate(id) marks and opens the Dutch auction at $1,600; after 6h of priced time the price is $1,120. 4) bob holds imdUSD, the Treasury holds 2,000 imdUSD; bob approves the join and calls SeatJoin.take(id, type(uint256).max). 5) The Ledger books bad = debt (1,500 + upfront fee + interest) - 1,120, about 382 imdUSD. Expected per Liquidator._cover's NatSpec and README invariant 5: ledger.totalBadDebt() == 0 after the sale and the Treasury balance down by about 382. Actual: ledger.totalBadDebt() == about 382e18 while the Treasury still holds its 2,000 imdUSD; treasury.retireReserve(1) reverts BadDebtOutstanding; a later treasury.coverBadDebt('SEAT') burns the 382 and clears it.","severity":"low","snippet":"        return ledger.liquidatePosition(id, price, msg.sender, marker, reserve);","title":"Liquidator.settle (seat auction sales) books bad debt without the in-transaction cover that bite performs"},{"citation":"resolved","description":"retireReserve lets any caller burn up to reserveBacked of the Treasury's imdUSD (Ledger.retire, Ledger.sol:386-391). The only guard (line 137) refuses while bad debt is ALREADY booked; nothing stops a caller from draining the balance ahead of a loss. That balance is the system's only liquid bad-debt cover: LedgerBase.unbacked() (LedgerBase.sol:224-228) nets ONLY token.balanceOf(treasury) against totalBadDebt and feeds _checkBrake on every borrow of every type, Treasury.coverBadDebt can burn only that balance, and Treasury.payNote pays matured fee notes from it. reserveBacked grows with every yield harvest of the beta's yield types (S-USDS, S-USDC-STEAKHOUSE, WSTETH carry yieldFee 0.1), so after weeks it is large enough to absorb the Treasury's whole interest income. Sequence: (1) anyone calls treasury.retireReserve(type(uint256).max) while totalBadDebt == 0, burning the whole balance (bounded by reserveBacked); (2) a blue position is bitten and books bad debt B; Liquidator._cover -> Treasury.coverBadDebt finds balance 0 and covers nothing; (3) unbacked() == B instead of B minus the Treasury's accrued income, and when B > 1% of circulating every type's borrowing reverts Braked until someone burns imdUSD through Ledger.cover; with a FeeNotes series open, every matured FeeNotes.redeem reverts TreasuryShort. The accounting is supply-neutral (yield shares back the retired supply), which is what the NatSpec at Treasury.sol:35-37 means by 'can never make the system less solvent'; but the act converts the protocol's liquid cover into illiquid vault shares at a stranger's discretion and at the worst moment, so that claim is wider than the code. README.md:188 lists 'retireReserve is permissionless and does not check outstanding bad debt' as accepted; the bad-debt check now exists (line 137), so the README entry is stale, and the remaining pre-emptive-drain consequence is reported here as the materially worse reading (brake griefing across every type, fee-note default). This merges three specialist entries (the drain, the Treasury.sol:35 NatSpec, the stale README line). Holds under BetaConfig (yield types on, FeeNotes deployed dormant, brake 1%). Smallest fix: make retireReserve onlyGovernor, or require the burn to leave max(FeeNotes outstanding, a governed reserve floor) of imdUSD in the Treasury; and update README.md:188.","line":136,"path":"src/Treasury.sol","reproduction":"Measured by the specialist on a CoreTest-derived harness and checked against the code here: (1) alice opens SUSDC 10,000e6 shares / 5,000e18 debt at 2%; the vault accrues; warp 6 days; ledger.harvest(SUSDC,[id]) -> ledger.reserveBacked() > 400e18. (2) alice opens ETH 10e18 / 14,000e18, dave opens ETH 200e18 / 50,000e18: usd.balanceOf(treasury) == X (about 65e18 of fees and interest) < reserveBacked. (3) attacker (holds no imdUSD): treasury.retireReserve(type(uint256).max). Expected per Treasury.sol:35-37 and the README trust model: a stranger cannot remove the Treasury's cover. Actual: usd.balanceOf(treasury) == 0, reserveBacked fell by X. (4) ETH 2000 -> 1200; dave: liquidator.liquidate(alice's ETH id) books B about 2,013e18. Actual: ledger.unbacked() == B (the in-transaction _cover burned 0); without step 3 the same liquidation covers X and leaves unbacked == B - X. (5) unbacked > 1% of circulating: ledger.open(ETH, +1,000e18) reverts Braked. Also: Treasury.retireReserve(x) with totalBadDebt == 1 wei reverts BadDebtOutstanding, which README.md:188 says it would not.","severity":"low","snippet":"    function retireReserve(uint256 amount) external {","title":"Treasury.retireReserve is permissionless: a stranger can burn the Treasury's liquid bad-debt cover one block before a loss (README entry stale, NatSpec overclaims)"},{"citation":"resolved","description":"The contract header (ImdUSD.sol:21-23: 'up to flashCap PER TRANSACTION ... so nested or repeated loans inside one transaction share the cap') and flashLoan's @dev (lines 148-150: 'so the cap bounds the transaction, not one call') claim a per-transaction bound. flashLoan restores the transient counter to `before` when each loan is repaid (line 167), so after a loan unwinds the next loan in the same transaction again sees the whole cap: only the amount in flight at one moment is bounded (which is what the flashCap @notice at line 28 says). No supply break follows (every loan is burned before return and circulating() excludes the in-flight part), but any reasoning or monitoring that relies on 'at most flashCap flash-minted per transaction' (for example sizing flash attacks on redemption, a caller liquidation, a Backstop deposit or the peg pool, the panel's question 3) is wrong: one transaction can flash-mint N x flashCap sequentially. Holds under BetaConfig (flashCap 100_000e18). Reproduced with the specialist's proof (status in the reproduction field). Smallest fix: correct the NatSpec to 'at most flashCap in flight at any moment', or, if a per-transaction bound is intended, keep a second transient counter of the cumulative amount lent that is never decremented and check value <= flashCap - cumulative.","line":167,"path":"src/ImdUSD.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {ImdUSD} from \"src/ImdUSD.sol\";\nimport {IERC3156FlashBorrower} from \"@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol\";\n\ncontract Looper is IERC3156FlashBorrower {\n    ImdUSD public immutable usd;\n    uint256 public maxSeen;\n    constructor(ImdUSD u) { usd = u; }\n    function run(uint256 amount, uint256 times) external {\n        for (uint256 i; i < times; ++i) usd.flashLoan(this, address(usd), amount, \"\");\n    }\n    function onFlashLoan(address, address, uint256 amount, uint256, bytes calldata) external returns (bytes32) {\n        if (usd.flashOutstanding() > maxSeen) maxSeen = usd.flashOutstanding();\n        usd.approve(address(usd), amount);\n        return keccak256(\"ERC3156FlashBorrower.onFlashLoan\");\n    }\n}\n\ncontract ProofFlashCap is Test {\n    function test_sequentialLoansDoNotShareTheCap() public {\n        ImdUSD usd = new ImdUSD(address(this), 100_000e18); // BetaConfig.flashCap\n        Looper l = new Looper(usd);\n        // NatSpec (ImdUSD.sol:21-23, 149): \"up to flashCap PER TRANSACTION ... nested or repeated loans inside one\n        // transaction share the cap\"; \"the cap bounds the transaction, not one call\".\n        // One call (one transaction) takes the whole cap three times in a row: 300k flash-minted in total.\n        bool ok;\n        try l.run(100_000e18, 3) {\n            ok = true;\n        } catch {}\n        assertFalse(ok, \"three sequential full-cap loans in one transaction succeeded: the cap does not bound the transaction\");\n    }\n}","reproduction":"ImdUSD deployed with flashCap = 100_000e18 (BetaConfig). A receiver contract loops imdUSD.flashLoan(this, imdUSD, 100_000e18, '') three times in one external call, repaying each in its callback. Expected per ImdUSD.sol:21-23 and 148-150: the second loan reverts ERC3156ExceededMaxLoan(0). Actual: all three succeed, 300_000e18 flash-minted in one transaction, flashOutstanding() never above 100_000e18. Test: test/scratch/ProofFlashCap.t.sol (proof field), forge test --match-path test/scratch/ProofFlashCap.t.sol -vv; run status on this machine is appended at the end of the proof's description. Run on this commit (forge 1.8.3, solc 0.8.26 via_ir, foundry.toml profile): forge test --match-path test/scratch/ProofFlashCap.t.sol -vv -> [FAIL: three sequential full-cap loans in one transaction succeeded: the cap does not bound the transaction] test_sequentialLoansDoNotShareTheCap() (gas: 569683); Suite result: FAILED. 0 passed; 1 failed; 0 skipped.","severity":"low","snippet":"        _setFlashOutstanding(before);","title":"ImdUSD flash cap bounds loans in flight, not the transaction: sequential loans each get the full flashCap (NatSpec claims a per-transaction bound)"},{"citation":"resolved","description":"Backstop.sync (src/backstop/Backstop.sol:588-608) returns early while a bid is open (line 595). Backstop.closeBid (lines 532-563) sets spent = repaid, does tracked -= spent and coll[token] += received, and adds no arrival to tracked or to the stream; its own comment (line 550) says an arrival during the bid 'only raises usdAfter'. The premium is folded in by the next sync() call, which starts its 7-day stream then. No value moves: the imdUSD sits in the sleeve as untracked balance until that call. Comment only; reword to 'the next sync counts it'. Reachable under BetaConfig once the SIMD line opens (edge type with edgePremium 0.2e18).","line":293,"path":"src/LedgerBase.sol","reproduction":"State: an edge-type (SIMD) position is unhealthy, the edge sleeve has room, at least one second has passed since the type last accrued. Liquidator.bite -> Backstop.openBid -> Ledger.liquidatePosition -> _accrue -> _mintInterest mints the edge premium P to the sleeve and calls sync(), which returns at Backstop.sol:595 because a bid is open -> Backstop.closeBid(ilk, repaid). Expected per the comment: after closeBid, tracked includes P. Actual: tracked fell by repaid only; imdUSD.balanceOf(sleeve) - tracked - staged == P until someone calls sync().","severity":"info","snippet":"                IEdgeSleeve(edge).sync(); // streams over 7 days; a no-op inside an open bid (closeBid counts it then)","title":"Comment claims closeBid counts an edge premium that arrives during an open bid; closeBid never does"},{"citation":"resolved","description":"Lines 12-14 state the live pool price is 'THE REDEMPTION PAYOUT LEG ONLY', 'never used to measure a borrower', and that the Pricer 'only ever raises the payout price with it'. Pricer._applyLive (src/Pricer.sol:93-104) does two more things: when the leg reads 0 or stale it sets q.payout = 0 and q.agree = false (lines 97-99), and when the pool is below low by more than skew it sets q.agree = false (line 102). agree gates the sleeve's standing bid in Liquidator.bite (line 165) and a borrower's charged rate change (Ledger.sol:166 reverts NotPriced). The behaviour is documented in the README's known issues ('The live leg sets the redemption payout and agree only') and in Pricer's comments; only this NatSpec is out of date. Reachable under BetaConfig on SIMD (the only type with a live leg). Fix: reword lines 12-14 to name the two other readers.","line":13,"path":"src/feeds/LivePoolPrice.sol","reproduction":"SIMD with attested median = spot = 5.00 (low = high = 5.00), skew 5%. Input A: live pool price 4.70 (6% under low). Expected per the NatSpec: payout = max(5.00, 4.70) = 5.00 and nothing else. Actual: payout = 5.00 and agree = false, so Liquidator.bite skips the standing bid (the caller path takes the position) and Ledger.setRate inside the cooldown reverts NotPriced. Input B: live leg returns 0 or is stale. Expected per 'only ever raises the payout': payout >= high. Actual: payout = 0 (Redeemer.redeem reverts NotPriced) and agree = false.","severity":"info","snippet":"/// is never used to measure a borrower: the Pricer only ever raises the payout price with it","title":"LivePoolPrice NatSpec says the live leg only ever raises the redemption payout and never measures a borrower; Pricer also zeroes the payout and clears agree with it"},{"citation":"resolved","description":"ImdUSD.sol:116-117 states each minter only burns from `from` on an action `from` initiated through it. In Liquidator.bite's standing-bid path (Liquidator.sol:172) the Ledger is called with payer = the Backstop sleeve, and LedgerSettlement.liquidatePosition (LedgerSettlement.sol:185, token.burn(payer, repaid)) burns repaid from the sleeve's balance with no allowance, on a call any third party initiated (anyone may call Liquidator.liquidate/bite). This is the intended design (the sleeve is a standing bid, guarded by openBid/closeBid's room and BadPrice checks), but the token-level comment misstates the trust property integrators read. Fix: reword the NatSpec to name the standing-bid exception. Holds under BetaConfig (blue sleeve lists ETH, WSTETH, CBBTC, WBTC, S-USDS, S-USDC-STEAKHOUSE).","line":116,"path":"src/ImdUSD.sol","reproduction":"BetaConfig: an ETH position becomes unhealthy while the blue sleeve has room >= its debt and the legs agree; any EOA calls Liquidator.liquidate(id). Expected per ImdUSD.sol:116-117: only the initiator's imdUSD is burned. Actual: repaid imdUSD is burned from the blue Backstop (Liquidator.sol:172 -> LedgerSettlement.sol:185) without its allowance; the sleeve's imdUSD balance falls by repaid and its collateral rises by received.","severity":"info","snippet":"    /// @notice Burn from `from` without an allowance, by a minter (each minter only burns on an action","title":"ImdUSD.burn NatSpec ('each minter only burns on an action from initiated') does not hold for the standing bid: the Ledger burns from the Backstop sleeve on a third party's call"},{"citation":"resolved","description":"ParametersRules._validate refuses ADD_SLEEVE_ILK for any auction type (src/ParametersRules.sol:90, 'if (c.auction) revert BadConfig();'), Liquidator.bite returns before the standing bid for every auction type (Liquidator.sol:154-158), MainnetConfig.backstopSpec (used by BetaConfig) lists only SIMD with edge = true, and the README says seats 'sell by Dutch auction' with no sleeve. So the seat type has no standing bid, no first-loss sleeve and no edge-capacity bound, and its bad debt reaches only the Treasury (Treasury.coverBadDebt asks the sleeve only when params.edgeIlk(ilk)). A reader of this header would expect seat losses to hit edge depositors first. Two specialists reported this; merged. Fix: correct the comment.","line":16,"path":"src/backstop/Backstop.sol","reproduction":"Under BetaConfig: backstopSpec(SIMD_LINE_TARGET).ilks has 7 entries, only SIMD with edge = true; edge.ilks('SEAT').on == false and edge.bidRoom('SEAT') == 0. Propose Parameters.propose(abi.encode(ADD_SLEEVE_ILK, 'SEAT', true, 0, 0, 0)): _validate reverts BadConfig() at ParametersRules.sol:90 because config('SEAT').auction == true. Expected per the header: seats are an edge-sleeve type. Actual: they cannot be listed in either sleeve.","severity":"info","snippet":"/// exist per chain: `blue` (ETH, BTC, staked stables) and `edge` (sIMD, seats, stocks). The edge sleeve also burns its","title":"Backstop header says the edge sleeve covers seats (and stocks); seats are an auction type that can never be listed in a sleeve"},{"citation":"resolved","description":"ParametersBase.MAX_SAVINGS_SHARE = 0.5e18 (src/ParametersBase.sol:119, '50% since 2026-10-29'); Parameters.setGenesisSavings (Parameters.sol:55) and the SET_SAVINGS_SHARE validation (ParametersRules.sol:46) revert OutOfBounds above it, with a 10-point step (MAX_SAVINGS_STEP). The README ('savings share 35%') and DeployConfig agree with the code; only this header is stale. The code's bound is the tighter one, so informational. Two specialists reported this; merged. Fix: change the header to 0-50% and mention the 10-point step.","line":11,"path":"src/Parameters.sol","reproduction":"governor: params.propose(abi.encode(SET_SAVINGS_SHARE, uint64(0.6e18))) under BetaConfig (savingsShare 0.35e18). Expected per the header: accepted (60% is within 0-80%). Actual: reverts OutOfBounds() (0.6e18 > MAX_SAVINGS_SHARE 0.5e18; the step from 0.35e18 also exceeds MAX_SAVINGS_STEP 0.1e18).","severity":"info","snippet":"///    within 0-80%; open a fee-note series (tenor 30/90/180 days, discount <= 10%, a size cap); move a capped chain's","title":"Parameters header says the savers' share is governed within 0-80%; the bound in code is 50%"},{"citation":"resolved","description":"_fee (Redeemer.sol:152-156) is min(redeemFloor + decayedBaseRate + increase, FEE_CAP), and decayedBaseRate starts at FEE_CAP (5%) at listedAt and decays by SECOND_DECAY = 999983955055097432 per second (half-life 43,200 s = 12h). After 40h the base alone is 0.05 x 0.5^(40/12) = about 0.0050, so with the beta's 0.5% blue floors the fee reads about 1.0%, not 0.5%; it is within 0.1% of the floor only after about 68h. Informational: the formula is as designed (the known-issues list covers fee sizing); only the comment misstates the number.","line":79,"path":"src/Redeemer.sol","reproduction":"Fresh type with redeemFloor 0.005e18 and no redemption yet, 40h after Parameters.seal(): redeemer.feeFor(ilk, 1) returns about 0.00997e18 (floor 0.005e18 + base 0.05e18 x 999983955055097432^144000 / 1e18 = about 0.00497e18), not about 0.005e18 as the comment says.","severity":"info","snippet":"    /// the fee falls from 5% to a 0.5% floor in ~40h after launch. Before the seal it reads the cap.","title":"Redeemer.decayedBaseRate NatSpec: the fee does not reach the 0.5% floor in ~40h; it reads about 1% then"},{"citation":"resolved","description":"README key invariant 4 and the Backstop header describe edgeCapacity = max(3 x net vested imdUSD, a 60-day bootstrap allowance) as a one-off bootstrap. A re-listing path exists: the governor calls Parameters.disableSleeveIlk(ilk, true) (instant, Parameters.sol:181-187), then proposes ADD_SLEEVE_ILK with any genesisLine, and 48h later Backstop.addIlk takes the k.token != address(0) branch (Backstop.sol:230-236), restarting listedAt and overwriting genesisLine. bootstrap(ilk) (lines 367-372) then reads a fresh 60-day allowance and edgeCapacity (lines 374-378) = max(3 x netVested, newGenesisLine) regardless of how little the sleeve holds. ParametersRules._checkEdgeListing (lines 190-205) only requires the EXISTING edge debt to fit max(3 x netVested, genesisLine), which the proposed genesisLine itself satisfies. While the type is disabled (up to 48h) its standing bid, first-loss cover and edge capacity are off. Impact: governance (2-of-3 Safe) can keep sIMD debt uncovered by real sleeve capital indefinitely, weakening the 'first loss is paid for' property depositors and the Treasury rely on; it is within the Safe's documented, timelocked powers, so reported as a trust assumption to document, not a defect. Reachable under BetaConfig (edge sleeve on, SIMD edge type, genesisLine 50k). Fix if wanted: in addIlk keep the original listedAt/genesisLine for a previously listed type, or cap a re-listing's genesisLine at the remaining bootstrap() of the old listing.","line":233,"path":"src/backstop/Backstop.sol","reproduction":"State: edge sleeve with netVested about 0, SIMD listed at genesis with genesisLine 50,000e18, day 61 (bootstrap 0). governor: params.disableSleeveIlk('SIMD', true); params.propose(abi.encode(ADD_SLEEVE_ILK, 'SIMD', true, uint128(50_000e18), saleMax, saleSlope)); warp 48h; anyone: params.applyPending(ADD_SLEEVE_ILK). Expected per README invariant 4: edgeCapacity('SIMD', 0) == 3 x netVested, about 0 (bootstrap spent). Actual: edge.bootstrap('SIMD') == 50,000e18 and edge.edgeCapacity('SIMD', 0) == 50,000e18 for another 60 days.","severity":"info","snippet":"            k.listedAt = uint64(block.timestamp);","title":"Edge bootstrap allowance can be renewed by re-listing: disableSleeveIlk (instant) + ADD_SLEEVE_ILK (48h) reset listedAt and genesisLine, so edgeCapacity is not bounded by vested imdUSD (trust assumpti"},{"citation":"resolved","description":"ImdUSD.setKeeper (lines 95-102) is callable by bridgeSetter (Parameters), and Parameters exposes two callers of it: the timelocked SET_KEEPER kind in ParametersRules, and setGenesisKeeper (Parameters.sol:63-68), which the deployer (wirer) calls before seal() with no delay; the beta deploy does exactly this (script/deploy/StageGenesis.sol:106). The README trust model states it correctly ('set by the deployer before the seal'); the token's own NatSpec, which an integrator reads, says it was timelocked and public for 48h first. No functional impact (one-shot, sealed afterwards). Fix: say 'wired by Parameters: at genesis by the deployer before the seal, otherwise through the 48h SET_KEEPER proposal'.","line":18,"path":"src/ImdUSD.sol","reproduction":"script/deploy/StageGenesis.sol:104-107 and Parameters.sol:63-68: d.params.setGenesisKeeper(address(d.hook)) runs in the deploy transaction sequence; IBridgeSettable(token).setKeeper(keeper_) executes with msg.sender == wirer and no pending proposal. Expected per ImdUSD.sol:18: a 48h public proposal precedes KeeperSet. Actual: KeeperSet is emitted in the deploy itself.","severity":"info","snippet":"///  - `keeper` is set once by the same timelocked setter: the v4 peg hook (src/peg/PegHook.sol), capped by","title":"ImdUSD NatSpec says the keeper minter is set 'by the same timelocked setter' as the bridge; Parameters.setGenesisKeeper names it with no timelock before the seal"},{"citation":"resolved","description":"BetaConfig.get() sets c.chain.capped = true and chainLine = 300_000e18 (script/DeployConfig.sol:678) and the deploy calls params.setGenesisChainLine, after which chainCapped can never be cleared (SET_CHAIN_LINE only moves the number, ParametersRules.sol:134-136). A reader of the source would otherwise expect Ledger._checkLines to be inert on mainnet. No functional impact; update the comment (the full MainnetConfig is uncapped, the beta is not).","line":145,"path":"src/ParametersBase.sol","reproduction":"After the beta deploy: params.chainCap() returns (true, 300_000e18). Expected per the comment: (false, 0) on chain 1. Actual: capped; Ledger._checkLines reverts ChainLineExceeded once the summed debt + bad debt of every type reaches 300k.","severity":"info","snippet":"    /// @notice The chain's global debt cap, on chains whose genesis capped it (Robinhood); mainnet is uncapped.","title":"ParametersBase NatSpec says 'mainnet is uncapped' but the beta mainnet deployment caps the chain at 300k through setGenesisChainLine"}],"hash":"ff4ddfda10d3f6ceac4f579668743cc43acb7af857b4497d618cbd6e178c5556","nodeId":"be59bbd7-cb78-43ce-b807-f2afdce7eddb","outcome":"completed","summary":"Review complete. The findings file holds 13 verified findings, every snippet matches the tree at its line, and the scratch tests are removed.\n\n**What I did**\n\n- Reproduced each of the 17 specialist entries against the code at the pinned commit by reading the cited paths and, for the two attached proofs, by running them with solc 0.8.26 via_ir under the repo's foundry.toml.\n- Merged duplicates: the two Backstop-header entries (seats and stocks as edge types) into one, the two savings-share 0-80% entries into one, and the three Treasury entries (permissionless retireReserve drain, its NatSpec claim at line 35, the stale README line) into one finding at `src/Treasury.sol:136`.\n- Nothing was dropped: every entry held up on reading. None rose above low.\n\n**Findings kept (4 low, 9 info)**\n\n- Low: Ledger.setRate's charged path adds and mints debt without `_checkBrake`. Proof attached; it fails on this commit with \"next call did not revert as expected\" and logs about 47.99 imdUSD minted while braked.\n- Low: Liquidator.settle (seat auction sales) books bad debt without the in-transaction cover that bite performs. No runnable proof attached, since the specialist's test used a harness that was not supplied.\n- Low: Treasury.retireReserve is permissionless, so a stranger can burn the liquid bad-debt cover ahead of a loss. The README's known-issue line is stale (the bad-debt check now exists) and the NatSpec's \"never less solvent\" claim is wider than the code.\n- Low: ImdUSD's flash cap bounds loans in flight, not the transaction, against its NatSpec. Proof attached; it fails on this commit with three sequential full-cap loans succeeding.\n- Info: nine comment or NatSpec claims the code does not have (closeBid counting the premium, LivePoolPrice's \"payout only\", burn's \"initiator only\", the edge sleeve covering seats, the 0-80% savings bound, the 40h fee decay, the renewable edge bootstrap as a trust assumption, the keeper \"timelocked setter\", and \"mainnet is uncapped\").\n\n**Build and test status, stated plainly**\n\n- The src closure compiled (196 artifacts) and both proofs ran, in a run that took about 14 minutes.\n- The panel's FullSystem suite could not complete here: each command is limited to 600 s and the sandbox kills processes when a command ends, so its compile was cut off twice with no artifacts. The invariant suite was not run for the same reason. The BetaConfig reachability claims therefore rest on reading `script/DeployConfig.sol`, not on a FullSystem run.\n\n**Tree state**\n\n- `test/scratch/` deleted. The `out/` and `cache/` build directories are gitignored. Git status shows only the sandbox's own dotfiles, which predate this review, plus `.imd-findings.json`.","treeHash":null,"usage":{"cachedInputTokens":1498024,"cost":{"source":"runtime","usdMicros":4465107},"inputTokens":484,"model":"claude-fable-5-1","outputTokens":31820,"runtime":"claude","turns":39,"wallClockMs":2114137}}],"verification":[]}