{
 "group": "fix-sell",
 "commit": "bbeda7b27ae80abcf070e0158cb8a31e87bb2286",
 "blocked": true,
 "blockedWhy": "Clone/build impossible on this machine: the shared volume was 100% full (df: 38G size, 38G used, 4.2M available). `git clone https://github.com/morpho-org/vault-v2` failed with 'fatal: write error: No space left on device'. No Foundry build or test could run, so no PoC could be written or executed. What follows is a static, line-referenced review of the pinned commit vs the audited commit 6476e9d (both read from raw.githubusercontent.com); every statement below is UNVERIFIED by test.",
 "fixes": [
  {
   "priorId": "Cantina 3.1.1",
   "change": "Old onSell rewrote only the sold market's rate to absorb a shortfall, gated by global noSalesWithShortfall and minRate. New onSell checks each sale against maxNetSellRate (sellerAssets >= soldNetCredit/(1+maxNetSellRate*ttm)), caps the cumulative shortfall with a timelocked-to-raise shortfallAllowance, and spreads it pro-rata to remaining interest across all markets by lowering their rates. Buys now need minNetBuyRate relative to paid assets.",
   "status": "partial",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:637-687",
    "src/adapters/midnight/MidnightAdapter.sol:535-537",
    "src/adapters/midnight/MidnightAdapter.sol:305-332"
   ],
   "tested": false,
   "note": "The round-trip loss is still capitalised into the rates (blending kept), but it is now bounded by shortfallAllowance and by the per-trade rate limits. The prior mechanism is out of scope. The new cross-market spread was read for new faults: matured or zero-rate markets are skipped (line 672), shortfall<=totalInterest is required (667), each target amortized value is <= netCredit so newRate cannot underflow, and other markets that are mid-sale revert (656). No new fault found statically. Over-consumption by split sales was already found and is not repeated. UNVERIFIED (no build)."
  },
  {
   "priorId": "Cantina 3.2.4",
   "change": "Force sales must now meet sellerAssets >= soldNetCredit*minForceSellPrice/WAD. onBuy still blocks buys only once forceSellable is set. NatSpec recommends zeroing a cap when submitting setForceSellable.",
   "status": "partial",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:272-277",
    "src/adapters/midnight/MidnightAdapter.sol:334-338",
    "src/adapters/midnight/MidnightAdapter.sol:529-537",
    "src/adapters/midnight/MidnightAdapter.sol:638-639"
   ],
   "tested": false,
   "note": "Allocators can still buy while setForceSellable is pending. minForceSellPrice defaults to 0 and the curator can set it instantly in either direction (no timelock), so the floor protects only if the curator sets it. See lowInfo #1. Trusted-role path only. UNVERIFIED."
  },
  {
   "priorId": "Cantina 3.2.7",
   "change": "The global noSalesBelowFaceValue and noSalesWithShortfall flags were removed. Non-forceSellable sales use maxNetSellRate and shortfallAllowance; forceSellable markets use a per-market minForceSellPrice.",
   "status": "fixed",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:638-648"
   ],
   "tested": false,
   "note": "Exiting a distressed market no longer relaxes a global flag for healthy markets. However shortfallAllowance and maxNetSellRate are still shared by all non-forceSellable markets. Side effect: with ttm=0 (matured), line 642 forces sellerAssets >= soldNetCredit, so a matured non-forceSellable position cannot be sold below face, even net of fees (lowInfo #3). UNVERIFIED."
  },
  {
   "priorId": "Cantina 3.2.10",
   "change": "Directional setters replace the old ones. Tightening is immediate: increaseMinNetBuyRate, decreaseShortfallAllowance, decreaseMaxNetSellRate (curator) and decreaseMaxTtm (curator or sentinel). Relaxing is timelocked: decreaseMinNetBuyRate, increaseShortfallAllowance, increaseMaxNetSellRate, increaseMaxTtm.",
   "status": "fixed",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:258-270",
    "src/adapters/midnight/MidnightAdapter.sol:291-332"
   ],
   "tested": false,
   "note": "Exception: setMinForceSellPrice is not directional and not timelocked (lowInfo #1). Pending relaxations are not cancelled by an immediate tightening (lowInfo #2). UNVERIFIED."
  },
  {
   "priorId": "Cantina 3.6.4",
   "change": "No enum was added. Policy is now the rate/allowance checks for normal markets plus a per-market forceSellable flag with a minForceSellPrice floor. The face-value flag no longer applies in force-sale mode.",
   "status": "fixed",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:54-57",
    "src/adapters/midnight/MidnightAdapter.sol:638-648",
    "src/adapters/midnight/interfaces/IMidnightAdapter.sol:10-22"
   ],
   "tested": false,
   "note": "Precedence is now unambiguous: forceSellable supersedes maxNetSellRate and shortfallAllowance (NatSpec 57, 143, 147). Informational item; no new fault."
  },
  {
   "priorId": "Cantina 3.6.5",
   "change": "withdrawToVault was public at 6476e9d (old line 260, callable by anyone). It is now internal, reached only through vault.deallocate by an allocator or sentinel (deallocate branch sender != this) or through self-funded buys.",
   "status": "partial",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:416-418",
    "src/adapters/midnight/MidnightAdapter.sol:478-479",
    "src/adapters/midnight/MidnightAdapter.sol:578-581",
    "src/adapters/midnight/MidnightAdapter.sol:716-738"
   ],
   "tested": false,
   "note": "The public timing vector is gone. Repaid credit is still valued at a discount until withdrawn, so the permissioned withdrawal still realises a step gain that depositors can time if the allocator's action is predictable. Withdrawal now depends on allocator/sentinel liveness; untrusted users can only exit via forceDeallocate. Withdrawal on a forceRemoved market reverts (726). UNVERIFIED."
  },
  {
   "priorId": "TRST-R-3",
   "change": "The forceDeallocate branch no longer calls parentVault.accrueInterest (old line 314). It now sells the adapter's own reduceOnly offer at tick 0 to the taker and pulls assets plus the settlement fee from the sender.",
   "status": "fixed",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:427-477",
    "src/VaultV2.sol:790-799"
   ],
   "tested": false,
   "note": "VaultV2.forceDeallocate calls deallocateInternal and then withdraw(penaltyAssets), which accrues after the sale, as recommended. The branch was also redesigned (own offer, taker admission in the enter gate, onBuy clearing the admission); that belongs to the gate/force-deallocate groups. UNVERIFIED."
  },
  {
   "priorId": "TRST-R-15",
   "change": "setMaxTtm (timelocked both ways, curator only) was split into increaseMaxTtm (timelocked) and decreaseMaxTtm (immediate, curator or sentinel). maxTtm widened to uint128.",
   "status": "fixed",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:258-270"
   ],
   "tested": false,
   "note": "A previously submitted increaseMaxTtm(X) stays executable after an emergency decrease unless it is revoked (lowInfo #2). UNVERIFIED."
  },
  {
   "priorId": "TRST-CR-1",
   "change": "Directional timelocks were added, plus forceRemove (timelocked, irreversible) and an optional IKR-compatible enterGateFactory.",
   "status": "partial",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:73-82",
    "src/adapters/midnight/MidnightAdapter.sol:190-338",
    "src/adapters/midnight/MidnightAdapter.sol:375-391"
   ],
   "tested": false,
   "note": "Centralisation remains by design. setMinForceSellPrice is a curator power with no notice period. forceRemove permanently strands later recoveries in that market (lowInfo #4)."
  },
  {
   "priorId": "TRST-CR-2",
   "change": "Allocator take/sell authority is now bounded per trade by minNetBuyRate and maxNetSellRate, in aggregate by shortfallAllowance, and per force-sellable market by minForceSellPrice.",
   "status": "partial",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:356-373",
    "src/adapters/midnight/MidnightAdapter.sol:535-537",
    "src/adapters/midnight/MidnightAdapter.sol:638-648"
   ],
   "tested": false,
   "note": "Trusted role; the bounds work only as well as the curator configures them (minForceSellPrice defaults to 0)."
  },
  {
   "priorId": "TRST-CR-3",
   "change": "Sentinels can additionally call decreaseMaxTtm and reach withdrawToVault through vault.deallocate. They still revoke, unsetForceSellable, setConsumed and remove sub-ratifiers.",
   "status": "partial",
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:219-226",
    "src/adapters/midnight/MidnightAdapter.sol:265-283",
    "src/adapters/midnight/MidnightAdapter.sol:342-352",
    "src/adapters/midnight/MidnightAdapter.sol:416-418"
   ],
   "tested": false,
   "note": "A sentinel can set maxTtm to 0, halting all buys until a timelocked increase. That is an expected risk-off power."
  }
 ],
 "hasCandidates": false,
 "candidates": [],
 "lowInfo": [
  {
   "title": "minForceSellPrice can be lowered instantly and defaults to 0, contradicting 'Relaxing these guardrails is timelocked'",
   "class": "Informational (trusted curator; documentation/guardrail inconsistency)",
   "verified": false,
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:54-57",
    "src/adapters/midnight/MidnightAdapter.sol:334-338",
    "src/adapters/midnight/MidnightAdapter.sol:638-639"
   ],
   "detail": "NatSpec 54-55 lists minForceSellPrice among the allocator guardrails and says relaxing them is timelocked. setMinForceSellPrice is curator-only with no timelocked() call and no direction check. After setForceSellable(marketId) clears its timelock, the curator can lower the floor to 0 in the same block. The allocator can then sell the market's credit at any price (line 639), so depositors who relied on a floor seen during the setForceSellable notice period get no warning. The default is 0, so a market made forceSellable before any floor is set has no floor at all. Fix: split into increaseMinForceSellPrice (immediate) and decreaseMinForceSellPrice (timelocked), or set the floor in setForceSellable's timelocked calldata. UNVERIFIED: static reading only, no test run."
  },
  {
   "title": "Immediate tightenings do not cancel pending relaxations; increaseShortfallAllowance is additive",
   "class": "Informational",
   "verified": false,
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:219-226",
    "src/adapters/midnight/MidnightAdapter.sol:258-263",
    "src/adapters/midnight/MidnightAdapter.sol:298-310",
    "src/adapters/midnight/MidnightAdapter.sol:320-325"
   ],
   "detail": "decreaseMaxTtm, decreaseShortfallAllowance, decreaseMaxNetSellRate and increaseMinNetBuyRate take effect immediately. A pending increaseMaxTtm(X), increaseMaxNetSellRate(X) or decreaseMinNetBuyRate(X) submitted earlier stays executable at its original executableAt, as long as it is still directionally valid. increaseShortfallAllowance(d) adds d to whatever allowance remains, even after the curator decreased it to 0. An emergency tightening can therefore be undone without a fresh notice period unless a sentinel also calls revoke on each pending payload. Fix: document this, or let decrease* revoke conflicting pending increases. UNVERIFIED."
  },
  {
   "title": "Matured non-forceSellable credit can never be sold below face, and taker sales after fees always fail",
   "class": "Informational",
   "verified": false,
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:141-144",
    "src/adapters/midnight/MidnightAdapter.sol:641-642"
   ],
   "detail": "With ttm = market.maturity.zeroFloorSub(block.timestamp) = 0, the check becomes sellerAssets >= soldNetCredit.mulDivUp(WAD, WAD), i.e. at least face value, whatever maxNetSellRate is. The only way to exit a matured, defaulting position below face is the timelocked setForceSellable path. NatSpec 142 states this only for taker sales at price 1. Fix: state explicitly that post-maturity sales require price >= 1 or forceSellable. UNVERIFIED."
  },
  {
   "title": "forceRemove is irreversible and strands any later recovery in the market",
   "class": "Informational (documented)",
   "verified": false,
   "refs": [
    "src/adapters/midnight/MidnightAdapter.sol:375-391",
    "src/adapters/midnight/MidnightAdapter.sol:435",
    "src/adapters/midnight/MidnightAdapter.sol:631",
    "src/adapters/midnight/MidnightAdapter.sol:726"
   ],
   "detail": "forceRemove sets forceRemoved=true and netCredit=0 and deallocates oldNetCredit. Afterwards withdrawToVault (726), onSell (631) and forceDeallocate (435) all revert, and nothing clears the flag. If borrowers later repay, the adapter's Midnight credit can never be withdrawn or sold, and the value is lost to depositors. This is documented ('Irreversibly removes a market'), but it is worth stressing to curators that forceRemove writes the position off for good, unlike forceSellable. UNVERIFIED."
  }
 ],
 "covered": [
  "Line-level diff of onSell, forceDeallocate, withdrawToVault, the timelocked/directional setters and maxTtm between 6476e9d src/adapters/MidnightAdapter.sol and bbeda7b src/adapters/midnight/MidnightAdapter.sol",
  "Shortfall-spread arithmetic (lines 643-686): underflow, zero-ttm and zero-rate markets, the toUint64 bound, the OtherSellInProgress lock",
  "Force-sale floor and its setter (334-339, 638-639)",
  "forceDeallocate branch and the VaultV2.forceDeallocate accrual order (VaultV2.sol:567-586, 790-799)",
  "Directional timelocks and decreaseMaxTtm (258-332), forceRemove (375-391)"
 ],
 "notCovered": [
  "Every Foundry build, test and PoC: the clone failed because the disk was full, so nothing was executed and every item is UNVERIFIED",
  "Midnight core (lib/midnight) callback order and settlementFee semantics were not read",
  "Ratifiers, gates, PackedDurationsLib and the factory are outside this item's group"
 ]
}