# Audit report

> AUDIT Robinhood stock tokens: src/stocks/StockVault.sol, src/stocks/StockJoin.sol, src/feeds/MarketHoursFeed.sol, src/feeds/MarketCalendar.sol (ship on Robinhood Chain after the beta; audited early), and the after-hours design question, at the pinned commit.
>
> imdUSD v2 is a multi-collateral CDP stablecoin; this is its capped mainnet beta on Ethereum (Robinhood Chain 4663 follows). README.md gives scope, invariants, trust model and known issues: read it first. Earlier public waves: GET https://api.imd.fun/jobs/<id>/submissions (wave 1 bd0ce553 oracles, wave 2 5a8d427d prices, wave 3 ff9ebb9d prices).
>
> BUILD AND TEST (required; Foundry, solc 0.8.26 via_ir). Never build the whole project with solc (~49 GB). Run `forge test --match-path 'test/unit/{Stocks,StockLending,StockBadDebt,StockReview,panel/PanelStockChop}.t.sol'`; with Foundry 1.9+ `forge test --use solar --no-match-path 'test/fork/*'` builds and runs everything in seconds under 1 GB (confirm a proof with solc). Write each proof as test/unit/Proof<Name>.t.sol, add it to the glob, run it, paste it with its output, then delete it.
>
> Off-repo facts: the tokens are ERC-8056 (uiMultiplier, newUIMultiplier, effectiveAt); the Chainlink feed answer already includes the multiplier; the Robinhood Chainlink equity feeds publish 24/5 (overnight included) and hold the last price over weekends with no heartbeat (confirm the exact schedule on chain); the snapshot omits our weekend-gap analysis behind the mats (measure it yourself).
>
> PROPERTIES:
> P1 A stock type is never priced outside the NYSE regular session, nor inside it from an answer printed outside it (overnight, pre-market, before a weekend or holiday), nor while frozen (token or oracle paused, holder blocklisted, multiplier change pending or unpriced), so it cannot then be borrowed against, liquidated or redeemed.
> P2 Every unit of stock sits in its StockVault, and shares count units exactly: no donation or first-depositor inflation; the uiMultiplier is counted once; an issuer adminBurn from custody lands pro rata and is priced in full at once, and a reissue or donation is believed no faster than RateFeed's cap, except back up to its highest accepted rate.
> P3 The liquidation auction sells at the live price times a falling factor, never at a stale opening price after a gap; the borrower's leftover is claimable even if the settlement stable freezes them; a shortfall is booked as bad debt.
> P4 No calendar change reclassifies a session that has begun.
> P5 (design) Weekend and overnight gap losses stay within each type's mat buffer.
>
> THREAT MODEL: the issuer controls, with no delay, pause, blocklist, oracle pause, multiplier changes, adminBurn of the vault's custody, reissue and the token's beacon upgrade (accepted: capped by lines); Chainlink's regular-session feed is the single price leg (one RateFeed in both slots, script/DeployChain.s.sol), unchecked by any second source; Chainlink's overnight session controls after-hours prints (SGOV printed +1.9% for 13 minutes on 2026-10-20); Robinhood Chain's single sequencer controls ordering, inclusion and outages (Pulse: 15 min gap, 1 h grace); borrowers choose when to borrow or deposit, e.g. at 09:30 against an overnight print; a pusher controls thin stock-token pools on Robinhood Chain at chosen block ends (no pool leg prices stocks today: this matters for SOUNDNESS (b) only); auction takers and searchers control ordering and timing within and across blocks; the Safe controls the calendar through the 48 h timelock.
>
> PATH: Chainlink equity feed -> MarketHoursFeed (+ MarketCalendar) -> RateFeed (StockVault's capped share rate) -> Pricer (same feed as median and spot; not redeemable) -> Ledger and Liquidator (marks age only while priced, so marks made before the close bite at the open) -> StockJoin's Dutch auction paid in USDG -> Treasury and the borrower's claim.
>
> CLAIMS TO CHECK: confirm or refute each with a test.
> C1 daylight saving time and the weekday are computed exactly for every weekday;
> C2 a calendar that runs out treats weekdays as open and leaves only the feed's freshness bound;
> C3 a wrong calendar entry can only freeze a type or leave it to freshness, never move a price;
> C4 maxAge 25 h detects a dead feed without leaving live tickers unpriced in session, including the first hours after a weekend or holiday;
> C5 an answer printed outside the session is never used to borrow, mark or bite inside it (MarketHoursFeed.isStale reads block.timestamp and the answer's age only);
> C6 a single Chainlink leg is enough for stock types (README known issue): say what a wrong in-session print costs at each mat;
> C7 an auction healed by the price alone and dipping again sells only at a fair price (README known issue): measure it for StockJoin's live factor;
> C8 mat = (1 + chop) / ((1 - p99.9 closed-market gap) x auction floor) + 5% (script/DeployConfig.sol) covers a gap plus the auction hour;
> C9 the RateFeed headroom that accrues while nobody pokes (README known issue) and its uncapped return to highRate after an adminBurn never let a donation, deposit or reissue be borrowed against beyond real value.
>
> SOUNDNESS: freezing every priced action outside the session (repayment, deposits and debt-free withdrawals continue) moves every gap to the open, where the first price is the last out-of-session print. Given mats of 115% (SGOV) to 200% and an auction floor of 90% (SGOV 97%) over 1 h (script/DeployConfig.sol), is that sound? Rank: (a) as built; (b) after-hours liquidation only when Chainlink's overnight price AND an on-chain pool price on Robinhood Chain both show the position under water within a band; (c) anything better. Measure, do not assume: the after-hours liquidity of these tokens' pools on Robinhood Chain, and historical weekend and overnight gaps of all nine types (SPY, NVDA, TSLA, USO, MSTR, CRCL, SPCX, AAPL, SGOV) against their mats, including the move from the last overnight print to the first in-session print.
>
> PROOF STANDARD: fuzz over timestamps and print times (DST switches, holidays, early closes, year ends, a calendar that has run out), invariants over vault deposits, withdrawals, donations and burns, and auction fuzz over price gaps and timings.
>
> Answer each numbered question:
> 1. (P1, P4) Find any timestamp, print time or issuer state in which a type is priced when it should not be (an out-of-session answer read in session; a multiplier step that effectiveAt switches without newUIMultiplier differing), or frozen in session for no reason; and any calendar proposal that changes a begun session.
> 2. (P2) Attack StockVault: first deposit, donations, rounding, the multiplier, adminBurn and reissue, blocklisted or paused transfers.
> 3. (P3) Attack the auction: a gap across the close, the open's first print, a taker blocklisted or frozen, a paused token mid-auction, lapse and re-bite.
> 4. (P5) The after-hours design question in SOUNDNESS, with the measurements, and what you would build.
>
> Not findings: README 'Known issues' as written (a known issue worse than written IS a finding); test/ and mocks; src/dex and src/earn/LoopVault.sol.
>
> Every finding: severity by impact; file, line and the lines copied; the call sequence; the failing state, expected vs actual; reachable with the deploy config or not; the smallest fix; and a test that fails on this commit, RUN as BUILD says and pasted with its output (the judge reruns it). Answer every numbered question, including where nothing is wrong.

| | |
|---|---|
| Repository | https://github.com/fa11up/imdusd-v2-audit.git |
| Commit | `67eadeac1e67db5f562e03eab8432a435debfb79` |
| Job | `549dae1c-abf5-4fad-9d13-d4571492dd9b` |
| Judged | 2026-11-15 06:06 UTC |
| Findings | 2 high · 2 medium · 4 low · 1 info |

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

## Findings

### 1. High: MarketHoursFeed prices the regular session from answers printed outside it (overnight, pre-market, Sunday 20:00 ET): P1/C5 refuted

`src/feeds/MarketHoursFeed.sol:47`

```
    function isStale() public view override returns (bool) {
        return super.isStale() || !calendar.isOpen(block.timestamp) || frozen();
    }
```

isStale() requires only that block.timestamp is inside the NYSE session (calendar.isOpen(block.timestamp)) and that the answer is younger than maxAge (25 h, CL_MAX_AGE). It never checks when the answer was printed. The Robinhood Chainlink equity feeds publish 24/5 with a 0.5% deviation trigger and a daily heartbeat at 20:00 New York (the overnight session's start), so at 09:30:00 the standing answer is always an overnight or pre-market print, and it stays the price until the regular market moves 0.5% away from it. P1 says a type is never priced 'inside the session from an answer printed outside it'; the contract header says the overnight hours 'never price', but their prints do. Consequences along the whole path (Pricer -> Ledger -> Liquidator -> StockJoin): a borrower can open or draw at 09:30 against an overnight high (SGOV printed +1.9% overnight on 2026-10-20; at the 115% mat that is ~13% of the buffer); a mark made before the close bites at 09:30:00 on an overnight low, charging the 10% chop (5% SGOV) on a position healthy at the regular-session price; the auction's factor-1 price for the first minutes is that print. Specialists measured on chain 4663 (all rounds of the deploy-config aggregators, Jun-Nov 2026): SGOV's session was priced only from an out-of-session answer in every session (111 of 114 rounds out of session); SPY had no in-session print on 24-28 of its sessions and ~40-45% of session hours priced from an out-of-session print; the largest measured move from the standing 09:30 answer to the first in-session print was 1.72% (MSTR 2026-11-06), 1.46% (SPCX), 1.31% (AAPL), 1.30% (TSLA), 1.27% (NVDA). I did not re-measure the chain; the code defect reproduces on the mocks with no chain data. Not the README's 'single leg' known issue (that is one source; this is the wrong session's answer). Reachable with the deploy config on every type, every day. Merged from four specialist reports (audit_flow, audit_math, audit_economics, audit_permissions). Smallest fix: in isStale() also require the answer to come from the current session: `(, uint64 at) = latestValue(); ... || !calendar.isOpen(at) || at / 1 days != block.timestamp / 1 days` (the session never crosses UTC midnight). Trade-off to decide with it: SGOV (and often SPY) would then be unpriced until a first in-session print, which SGOV almost never gets, so quiet tickers need an in-session heartbeat stream, or a grace rule (e.g. accept the pre-open print only after N minutes of session with no 0.5% deviation print, which means the regular market stayed within the band) for actions that can hurt a borrower (borrow, bite, take). My own on-chain reads (cast against rpc.mainnet.chain.robinhood.com, chain 4663, 2026-11-15): SGOV aggregator rounds 106-114 are all out of session (Tue 11-03 to Fri 11-06 at 04:01-04:02 New York pre-market; Sun 11-08 to Thu 11-12 at 20:00-20:02 New York), so every SGOV session in that span was priced from an out-of-session answer; SPY rounds 236-243: Thu 11-12 15:55 (in session, 757.645), 19:01 (761.467), Fri 01:39 (757.636), Fri 08:26 pre-market (761.425), first in-session print Fri 09:42:48 (757.549): Friday 09:30-09:42 was priced 0.51% above the first regular-session print.

**Reproduction**

Calendar with no entries, maxAge 25 h, no issuer flags. Aggregator prints 612e8 at Sun 2026-11-15 20:00 ET (Mon 01:00 UTC, calendar.isOpen(printAt) == false). Warp to Mon 2026-11-16 09:30:00 ET (14:30 UTC, calendar.isOpen == true). Expected: isStale() == true (no regular-session answer exists). Actual: isStale() == false and latestValue() == 612e18. Fuzz: any print in [Sun 20:00 ET, Mon 09:29:59 ET] read at any second of Monday's session is priced. Ran on this commit with solc 0.8.26 via_ir: `forge test --match-path 'test/scratch/ProofOutOfSessionAnswer.t.sol' -vv` -> [FAIL: P1/C5: an out-of-session answer is used inside the session; counterexample args=[2751, ...]] testFuzz_outOfSessionAnswerPricesInSession(uint256,uint256); [FAIL: Monday 09:30 is priced from Sunday 20:00's overnight answer] test_sundayOvernightPrintPricesMondayOpen() (gas: 100882), log 'value read at the open (1e18 USD): 612000000000000000000'.

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

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

import "forge-std/Test.sol";
import {MarketCalendar} from "src/feeds/MarketCalendar.sol";
import {MarketHoursFeed} from "src/feeds/MarketHoursFeed.sol";

contract PoosRegistry {
    function paused() external pure returns (bool) { return false; }
    function isBlocked(address) external pure returns (bool) { return false; }
}

contract PoosStock {
    address public immutable ACCESS_CONTROLLED_REGISTRY;
    constructor(address r) { ACCESS_CONTROLLED_REGISTRY = r; }
    function paused() external pure returns (bool) { return false; }
    function oraclePaused() external pure returns (bool) { return false; }
    function uiMultiplier() external pure returns (uint256) { return 1e18; }
    function newUIMultiplier() external pure returns (uint256) { return 1e18; }
    function effectiveAt() external pure returns (uint256) { return 0; }
}

contract PoosAggregator {
    int256 public answer = 600e8;
    uint256 public updatedAt;
    function decimals() external pure returns (uint8) { return 8; }
    function set(int256 a, uint256 t) external { answer = a; updatedAt = t; }
    function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80) {
        return (1, answer, updatedAt, updatedAt, 1);
    }
}

/// P1 / C5: an answer printed OUTSIDE the NYSE session (Robinhood overnight 20:00-04:00 ET, pre-market 04:00-09:30 ET)
/// must not price the type inside the session. MarketHoursFeed.isStale only checks block.timestamp against the calendar
/// and the answer's age against maxAge (25 h), so it does.
contract ProofOutOfSessionAnswer is Test {
    MarketCalendar cal;
    MarketHoursFeed feed;
    PoosAggregator agg;
    uint256 monday; // 2026-11-16 00:00 UTC, a Monday in EST (session 14:30-21:00 UTC)

    function setUp() public {
        cal = new MarketCalendar(address(0xBEEF), new uint32[](0), new uint32[](0));
        agg = new PoosAggregator();
        PoosStock stock = new PoosStock(address(new PoosRegistry()));
        vm.warp(1_790_000_000);
        agg.set(600e8, block.timestamp);
        feed = new MarketHoursFeed(address(agg), address(stock), address(0xCAFE), cal, 25 hours);
        monday = cal.daysFromCivil(2026, 11, 16) * 1 days;
    }

    /// Print at any time from Sunday 20:00 ET (Robinhood's overnight open, Mon 01:00 UTC) to 09:29:59 ET; read at any
    /// second of Monday's regular session before a new print: the type must read stale (unpriced).
    function testFuzz_outOfSessionAnswerPricesInSession(uint256 printAt, uint256 readAt) public {
        printAt = bound(printAt, monday + 1 hours, monday + 14 hours + 30 minutes - 1); // Sun 20:00 ET .. Mon 09:29:59 ET
        readAt = bound(readAt, monday + 14 hours + 30 minutes, monday + 21 hours - 1); // Mon 09:30:00 .. 15:59:59 ET
        assertFalse(cal.isOpen(printAt), "print is outside the session");
        assertTrue(cal.isOpen(readAt), "read is inside the session");
        agg.set(612e8, printAt); // e.g. a +2% overnight print
        vm.warp(readAt);
        assertTrue(feed.isStale(), "P1/C5: an out-of-session answer is used inside the session");
    }

    /// The concrete case: SGOV's feed prints only at 20:00 ET (its heartbeat, measured on 4663: 111 of 114 rounds out of
    /// session), so every SGOV session is priced from an overnight-session answer.
    function test_sundayOvernightPrintPricesMondayOpen() public {
        agg.set(612e8, monday + 1 hours); // Sun 2026-11-15 20:00 ET
        vm.warp(monday + 14 hours + 30 minutes); // Mon 09:30:00 ET
        (uint256 v,) = feed.latestValue();
        emit log_named_uint("value read at the open (1e18 USD)", v);
        assertTrue(feed.isStale(), "Monday 09:30 is priced from Sunday 20:00's overnight answer");
    }
}
```

### 2. High: StockVault hollow-vault guard is lifted by a 1-wei donation: a dust deposit after an issuer adminBurn takes ~all of the reissue

`src/stocks/StockVault.sol:41`

```
    function _hollow() private view returns (bool) {
        return totalAssets() == 0 && totalSupply() != 0;
    }
```

maxDeposit/maxMint refuse deposits only while totalAssets() == 0 exactly with shares outstanding. totalAssets() is the vault's raw token balance, which anyone changes with a plain transfer. After the issuer adminBurns the vault's whole custody (a threat-model action, and the burn-then-reissue case LedgerSettlement.writeOff and StockReview F5 anticipate), one wei of stock sent to the vault makes it non-hollow; ERC4626 then prices the next deposit against 1 wei of assets and the whole pre-burn share supply, so a 1,000-wei deposit mints ~500x the existing supply (999,999 wei mints 99.9998% of the vault). When the issuer reissues the burned custody to the vault, the dust depositor redeems ~all of it and the holders the burn hit (and the Treasury, which holds written-off shares) keep ~0.2%. RateFeed does not stop it: the rate returns to highRate uncapped (a return to the high is 'not new value'), so the stolen shares are also full-value Ledger collateral at once. A partial burn that leaves dust opens the same window with no donation. Reachable with the deploy config: StockVault is ownerless, deposit() is public, the only precondition is a whole-custody burn followed by a reissue (both in the stated threat model). Merged from three specialist reports (audit_flow, audit_math, audit_permissions). Smallest fix: do not key the guard on an exact zero. Treat the vault as hollow while its rate is below par (only a burn lowers it; donations only raise it): `return totalSupply() != 0 && totalAssets() * 10 ** _decimalsOffset() < totalSupply();`, or below a fraction of par if deposits should stay open after a partial burn (accepting a pro-rata share of a later reissue); alternatively refuse deposits while convertToAssets(1e18) is below the RateFeed's highRate.

**Reproduction**

alice deposits 100e18 stock (100e24 shares). Issuer adminBurn(vault, 100e18): maxDeposit(eve) == 0 as intended. eve transfers 1 wei of stock to the vault, then deposit(1000, eve) succeeds. Issuer mints 100e18 back to the vault. Expected: alice's shares redeem ~100e18, eve's ~1001 wei. Actual: alice redeems 0.199600798403193614, eve (who put in 1001 wei) redeems 99.800399201596807387. Ran on this commit with solc 0.8.26 via_ir: `forge test --match-path 'test/scratch/ProofHollowVault.t.sol' -vv` -> [FAIL: the reissue belongs to the holders the burn hit: 199600798403193614 <= 99000000000000000000] test_oneWeiDonationReopensAHollowVaultAndTakesTheReissue() (gas: 1132382). The second specialist proof (1000e18 deposit, 1000-wei dust) gives eve 998.003992015968064872 and alice 1.996007984031936129.

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

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

import {Test} from "forge-std/Test.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {StockVault} from "src/stocks/StockVault.sol";

contract HollowTok is ERC20("SPY", "SPY") {
    function mint(address a, uint256 v) external {
        _mint(a, v);
    }

    function adminBurn(address a, uint256 v) external {
        _burn(a, v);
    }
}

/// @notice A hollow vault (issuer burned the whole custody) is meant to take no deposit until the issuer reissues.
/// One wei sent to the vault makes `totalAssets() != 0`, deposits reopen, and a dust deposit mints ~all shares.
contract ProofHollowVaultTest is Test {
    function test_oneWeiDonationReopensAHollowVaultAndTakesTheReissue() public {
        HollowTok t = new HollowTok();
        StockVault v = new StockVault(IERC20Metadata(address(t)));
        address alice = makeAddr("alice");
        address eve = makeAddr("eve");
        t.mint(alice, 100e18);
        vm.startPrank(alice);
        t.approve(address(v), type(uint256).max);
        v.deposit(100e18, alice);
        vm.stopPrank();

        t.adminBurn(address(v), 100e18); // the issuer burns the custody
        assertEq(v.maxDeposit(eve), 0, "hollow: deposits closed");

        t.mint(eve, 1001); // 1001 wei of stock
        vm.startPrank(eve);
        t.transfer(address(v), 1); // the donation: totalAssets = 1, no longer hollow
        t.approve(address(v), type(uint256).max);
        try v.deposit(1000, eve) {} catch {} // refused once the vault stays closed
        vm.stopPrank();

        t.mint(address(v), 100e18); // the issuer reissues the burned custody
        uint256 aliceGets = v.previewRedeem(v.balanceOf(alice));
        uint256 eveGets = v.previewRedeem(v.balanceOf(eve));
        emit log_named_decimal_uint("alice (deposited 100) redeems", aliceGets, 18);
        emit log_named_decimal_uint("eve (deposited 1001 wei) redeems", eveGets, 18);
        assertGt(aliceGets, 99e18, "the reissue belongs to the holders the burn hit");
    }
}
```

### 3. Medium: StockJoin.take withholds the full chop in units on a shortfall or thin-band sale: reserve-backed imdUSD is booked without the USDG behind it and bad debt is understated

`src/stocks/StockJoin.sol:121`

```
        uint256 bonus = Math.mulDiv(repaid, chop, p);
        units = seized - bonus;
```

LedgerSettlement.liquidatePosition (auction branch) follows 'solvency before penalty': repaid = min(debt, seized x p), bad = debt - repaid, bonus = min(paid - repaid, repaid x chop) / p, i.e. zero on a shortfall and only what is left when 100% <= CR < 1 + chop. It books `reserveBacked += repaid` on the promise (StockJoin header, lines 30-32) that `repaid` USDG at par reaches the Treasury. StockJoin.take recomputes the bonus as repaid x chop / p with no min, removes those units from what the taker buys (units = seized - bonus), sends them to the Treasury as vault shares, and charges the taker only for the rest. Whenever seized x p < debt x (1 + chop), paid < repaid, line 127 forwards all of it (toTreasury = min(paid, repaid) = paid), and the Treasury receives up to chop x repaid LESS USDG than the imdUSD just booked as reserve-backed. The difference is held as StockVault shares (exposed to the issuer's adminBurn, the next gap and the market-hours freeze, with no sale route in this module) while ilkState.badDebt, what Treasury.coverBadDebt and the unbacked brake see, understates the USDG shortfall by that amount; the Ledger's own rule that a position booking bad debt pays the Treasury nothing (LedgerSettlement.sol:130-133) is also violated. Nobody outside the protocol is robbed (the value lands at the Treasury), hence medium rather than high: it is an accounting and backing defect, reachable in every liquidation that lands under 1 + chop at the sale price, which is exactly the weekend-gap case the mats are sized for. Merged from audit_economics (high), audit_flow (low) and audit_permissions (low). Smallest fix: compute the bonus as the Ledger does: `uint256 value = Math.mulDiv(seized, p, 1e18); uint256 bonus = Math.mulDiv(Math.min(value - repaid, Math.mulDiv(repaid, chop, 1e18)), 1e18, p);` so units x p >= repaid and the USDG reaching the Treasury is never below the imdUSD booked as reserve-backed.

**Reproduction**

StockSystem wiring (mat 150%, chop 10%, auction 1 h to 0.9, USDG 6 decimals). alice opens 100 stock at $100 with 6,000 debt. In session the feed prints $50; liquidator.liquidate(id); taker calls sjoin.take(id, max) in the same block (p = 50e12 per 1e18 shares). Expected: Treasury USDG delta x 1e12 >= reserveBacked delta (5,000e18), no penalty on a shortfall. Actual (run on this commit, solc 0.8.26 via_ir, test extending test/utils/StockSystem.sol): units bought 90e24, usdg paid 4,500e6, reserveBacked delta 5,000e18, treasury usdg delta 4,500e6, treasury vault shares delta 10e24 (10 stock, $500), badDebt 1,000e18 while the USDG hole is 1,500. Second input, feed $62 (CR 103%, inside the band): reserveBacked delta 6,005.753424657534246576e18, treasury usdg delta 5,599.424658e6, badDebt 0. Output: [FAIL: reserve-backed imdUSD not backed by USDG: 4500000000000000000000 < 5000000000000000000000] test_shortfallSale_reserveBackedVsUsdg(); [FAIL: ...: 5599424658000000000000 < 6005753424657534246576] test_thinBandSale_reserveBackedVsUsdg(). Test body: _open(alice,100e18,6_000e18); _price(50e8); liquidator.liquidate(_pid(STK,alice)); r0=ledger.reserveBacked(); u0=usdg.balanceOf(address(treasury)); vm.prank(taker); sjoin.take(_pid(STK,alice), type(uint256).max); assertGe((usdg.balanceOf(address(treasury))-u0)*1e12, ledger.reserveBacked()-r0);

### 4. Medium: StockJoin: the auction factor falls on wall-clock time while nobody can take (oracle or token pause, multiplier freeze, Pulse grace), so the first takeable block sells at the floor

`src/stocks/StockJoin.sol:100`

```
        uint256 elapsed = Math.min(block.timestamp - start, auctionTime);
        return Math.mulDiv(q.low, 1e18 - Math.mulDiv(1e18 - floor, elapsed, auctionTime), 1e18);
```

price() multiplies the live quote by a factor falling linearly from startAt over auctionTime, but take() only works while the type is priced (MarketHoursFeed.frozen: token pause, oracle pause, blocked custody, pending multiplier) and while Liquidator.settle is not held by the Pulse grace (SequencerGrace). Any such interval still consumes the descent. After a 1 h oracle pause (the issuer's corporate-action flag, no delay), a token pause, a multiplier step the feed has not re-priced, or a sequencer outage (15 min gap plus the 1 h grace in the deploy config), the factor is already at `floor`, and the first taker in the first priced block buys at 90% of the live price (97% SGOV) with no price discovery, until the auction lapses at 2 x auctionTime (minutes 60-120 are the real window). The borrower's leftover (`owed`) shrinks by up to (1 - floor) of the collateral's value, or that amount becomes bad debt on a position near water. This is not the README's 'healed by the price alone' case: the position was unhealthy and for sale throughout. The Liquidator already keeps a priced clock for marks (clocks[ilk].paused, graces[id].pausedAtMark); the auction does not use it. Reachable with the deploy config. Smallest fix: run the factor on priced time: record the type's paused clock at open() and subtract the unpriced/held seconds since from `elapsed` (and from the lapse test), or restart the descent when the type returns from unpriced.

**Reproduction**

StockSystem wiring, Mon 2026-10-19 14:00 UTC in session: alice has 100 stock at $100 and 6,000 debt. Feed prints $80; liquidator.liquidate(id) opens the auction; price(id) = 80e12 (factor 1). Issuer setOraclePaused(true): price(id) == 0 and take reverts NotPriced. Warp 1 h, setOraclePaused(false), feed prints $80 again. Expected: the first takeable price ~80e12 (no taker could act during the pause). Actual: 72e12 = 80e12 x 0.9. Run on this commit (solc 0.8.26 via_ir, test extending test/utils/StockSystem.sol): [FAIL: factor fell while nobody could take: 72000000000000 <= 79200000000000] test_auctionFactorFallsWhileNobodyCanTake() (gas: 2115124); logs 'price at open of auction: 80000000000000', 'price in first takeable block after 1h pause: 72000000000000'. Test body: _open(alice,100e18,6_000e18); _price(80e8); liquidator.liquidate(id); p0=sjoin.price(id); stock.setOraclePaused(true); assertEq(sjoin.price(id),0); vm.warp(+1 hours); stock.setOraclePaused(false); _price(80e8); p1=sjoin.price(id); assertGt(p1, p0*99/100).

### 5. Low: MarketHoursFeed.frozen() multiplier rule: unfreezes on the first answer stamped after effectiveAt whatever session it came from, freezes on a no-op schedule, and misses a backdated step

`src/feeds/MarketHoursFeed.sol:63`

```
        (, uint64 updatedAt) = latestValue();
        return effectiveAt != 0 && updatedAt <= effectiveAt;
```

Line 63 treats any answer with updatedAt > effectiveAt as 're-priced at the new multiplier', and any effectiveAt >= updatedAt as frozen, without looking at whether the multiplier changed or when the answer was printed. Three consequences, all issuer-driven (no unprivileged amplifier, hence low). (a) Unfreeze on an out-of-session print: audit_flow measured on chain 4663 that the SGOV issuer does not schedule ahead (one hour before the November step uiMultiplier == newUIMultiplier with October's effectiveAt; afterwards both read 1.009470411670283410 with effectiveAt 1793581843, Sun 2026-11-01 20:10:43 New York), so the `current != next` branch never fires and line 63 is the only guard; the first round stamped after effectiveAt was Mon 2026-11-02 04:00:58 New York (pre-market, 101.687, +0.53% on Sunday's 101.147 and ~0.3% above where the next two days settle), which unfroze the type and priced the whole Monday session. On a split (x2, x10) the same rule would accept a print that pairs the new multiplier with a pre-split answer. I did not re-read the chain; the mechanism reproduces on mocks. (b) A no-op schedule (newUIMultiplier == uiMultiplier, future effectiveAt) freezes the type from the moment it is scheduled until the first round after effectiveAt (for SGOV that is the 20:00 heartbeat, so a whole session), stopping borrow, bite and take and letting in-flight auctions lapse. (c) A real step whose effectiveAt the issuer sets before the feed's last round (updatedAt > effectiveAt) is not frozen although the answer still carries the old multiplier. Merged from audit_flow and audit_economics. Smallest fix: after a step, unfreeze only on an answer printed inside the regular session (the fix for the out-of-session finding gives this); treat `effectiveAt > block.timestamp` with next == current as not frozen; and remember the (uiMultiplier, updatedAt) pair last seen priced so a step is 'caught up' only when an answer newer than the step exists AND the multiplier differs from the one recorded. My own read confirms SGOV's effectiveAt() = 1793581843 and uiMultiplier() == newUIMultiplier() == 1009470411670283410 on 2026-11-15.

**Reproduction**

StockSystem mocks, in session Mon 2026-10-19 14:00 UTC, last round at 14:00. (b) stock.scheduleMultiplier(1e18, now + 1 hours) (next == current): expected frozen() == false; actual frozen() == true at once (effectiveAt > updatedAt), and stays true after effectiveAt until the next round. Output on this commit: [FAIL: pending no-op: not frozen] test_noopMultiplierScheduleFreezes(). (c) stock.scheduleMultiplier(2e18, now - 1 days) after the last round: expected frozen() == true (the feed has not priced a 2x step); actual false. Output: [FAIL: a 2x step the feed has not priced must freeze] test_backdatedMultiplierNotFrozen(). (a) on chain 4663 per audit_flow: SGOV token 0x92FD66527192E3e61d4DDd13322Aa222DE86F9B5 effectiveAt() = 1793581843; aggregator 0xa0DF4ee0fFf975306345875E3548Fcc519577A11 round stamped 1793610058 (Mon 04:00:58 New York) answer 10168678405; at any Monday session timestamp frozen() == false (1793610058 <= 1793581843 is false), age < 25 h, calendar open, so the pre-market print prices the session.

### 6. Low: MarketCalendar accepts at propose a list applyPending can never apply (a weekend day), and offers no path faster than 48 h for a closure announced on short notice

`src/feeds/MarketCalendar.sol:101`

```
        for (uint256 i; i < list.length; ++i) {
            if (list[i] <= today) revert BadDay(list[i]);
        }
```

P4 itself holds: _validate runs at propose and again at apply, refuses every day <= the current UTC day, and the session never crosses UTC midnight, so no begun session is reclassified. Two gaps around it. (a) _validate checks only that each day is in the future; the weekday rule lives in _set, which runs only at apply. A list holding one Saturday or Sunday passes propose, occupies the single proposal slot for 48 h, then applyPending reverts BadDay for the whole list, valid days included (test/unit/Stocks.t.sol already shows the revert at apply); a closure entered that way with under four days' notice misses its day. (b) A day the NYSE closes inside 48 h (2012-10-29/30 was announced the evening before) cannot be entered at all; the type is then left to freshness, and with the measured 20:00 New York heartbeat (13.5 h old at 09:30) a weekday closure is priced all day from an overnight print. Mid-week holidays after the seeded calendar runs out (C2) behave the same: Monday holidays are caught by maxAge (the Friday print is >25 h old), mid-week ones are not. The calendar header promises 'a wrong entry can only freeze ... never move a price', which holds (C3). Smallest fix: check the weekday in _validate; and let the freezer (the Safe, no delay) mark the current or next day CLOSED only (never OPEN or EARLY_CLOSE), which can only freeze.

**Reproduction**

StockSystem calendar (Thanksgiving closed, 2026-11-27 early close). Governor proposes abi.encode(uint8(1), uint8(1), [uint32(20784), uint32(20785)]) (Fri 2026-11-27 and Sat 2026-11-28) on Mon 2026-10-19: propose succeeds. Warp 48 h; applyPending() reverts (BadDay(20785)); dayStatus[20784] is still EARLY_CLOSE (2). Expected: propose reverts BadDay(20785) at once. Run on this commit (test extending test/utils/StockSystem.sol): test_proposeAcceptsWeekendDay() passes with the assertions 'propose succeeds, apply reverts, friday unchanged' (vm.prank(governor); cal.propose(...); vm.warp(+48 hours); vm.expectRevert(); cal.applyPending(); assertEq(cal.dayStatus(DAY_AFTER), 2)).

### 7. Low: ChainlinkFeed caches aggregatorDecimals at construction; a decimals change on the Robinhood equity feeds (observed 18 -> 8 inside one phase) would misprice by 1e10

`src/feeds/ChainlinkFeed.sol:31`

```
        aggregatorDecimals = uint8(d);
```

MarketHoursFeed inherits ChainlinkFeed, which reads decimals() once in the constructor and scales every later answer with the immutable at line 50 (`uint256(answer) * 10 ** (36 - aggregatorDecimals) / 1e18`). audit_math read on chain 4663 that the SPY and USO aggregators answered with 18 decimals up to round 7 and with 8 decimals from round 8 (SPY 7349800000000000000 at 1782198196, then 73683695000 at 1782222713, 2026-06-23; USO 1109921500000000000 -> 11094999999) with no phase change; that was before any deployment, and I did not re-read the chain. If it happens again after deployment: an 8 -> 18 step reads as 1e10 x the price, still below MAX_PER_TOKEN (1e36 per token needs an answer above 1e26 at 8 decimals), so it is accepted and the whole line can be borrowed against ~nothing; an 18 -> 8 step reads as ~1e-10 x the price and every position becomes liquidatable at the open (the clamp check does not catch either). Low: needs a Chainlink-side change, and the line caps the loss. Smallest fix: read decimals() live in latestValue (one staticcall) or treat a change from the cached value as unpriced.

**Reproduction**

Code path: constructor stores aggregatorDecimals = 8; aggregator later answers 7349800000000000000 (the same $73.498 in 18 decimals). latestValue: 7.3498e18 <= 10 ** 26 passes the sanity cap; perToken = 7.3498e18 * 1e28 / 1e18 = 7.3498e28 (i.e. $73,498,000,000 per token) instead of 7.3498e19. Expected: unpriced or $73.498; actual: $7.35e10 per token, accepted by isStale (fresh answer). The observed on-chain decimal change is audit_math's getRoundData reading of 0x319724394D3A0e3669269846abE664Cd621f9f6A rounds (1<<64)+7 and (1<<64)+8.

### 8. Low: maxAge 25 h leaves a heartbeat-only feed (SGOV) unpriced for a whole session when one 20:00 New York heartbeat is skipped (C4 holds for weekends, not for a missed heartbeat)

`script/DeployConfig.sol:821`

```
    uint256 internal constant CL_MAX_AGE = 1 days + 1 hours; // the 4663 feeds' heartbeat is 24h (mainnet ETH/USD: 1h)
```

The SGOV feed prints once a day at 20:00 New York (the overnight session's start) and almost never inside the regular session (specialists: 3 in-session rounds of 114 since 2026-07-02). With maxAge = 25 h the answer is 13.5 h old at 09:30 after a normal night or a weekend (the Sunday 20:00 print), so C4 holds for weekends and Monday holidays. But a single skipped heartbeat makes the standing answer 37.5 h old at the next open, and the type is unpriced for the entire session: no borrowing and no liquidation even if under water. audit_math found two such sessions on chain 4663 (Wed 2026-07-08: latest answer Mon 07-06 20:00; Tue 2026-08-25: latest answer Sun 08-23 20:00), 6.4% of SGOV's in-session 5-minute samples (SPY 1.0%, USO 1.6%); I did not re-read the chain. The flip side of the same heartbeat: a feed that dies right after its 20:00 print still prices the whole next session. Liveness only, hence low. Smallest fix: a per-type maxAge that covers one missed heartbeat (49 h) for heartbeat-only feeds, or, better, the in-session-print rule from the high finding plus an in-session heartbeat stream for SGOV.

**Reproduction**

MarketHoursFeed with maxAge 25 h; aggregator's latest round stamped Sun 2026-08-23 20:00 New York (the Monday 20:00 heartbeat skipped); block.timestamp Tue 2026-08-25 09:30 New York: block.timestamp - updatedAt = 37.5 h > 25 h, so ChainlinkFeed.isStale() == true and the type is unpriced for the whole session although the feed is alive. Expected per C4: a live feed is priced in session. The repository's own test (test/unit/Stocks.t.sol 'Tuesday 11:00, last answer Monday 10:00', 25 h + 1 s) shows the same boundary; the two on-chain dates are audit_math's reading of the rounds of 0xa0DF4ee0fFf975306345875E3548Fcc519577A11.

### 9. Info: P5 / soundness and C6-C9: measured closed-market gaps sit inside every mat buffer; the weak point is the open's first price, not the mat; NVDA's mat has no slack against its full-history p99.9

`script/DeployConfig.sol:938`

```
    /// @notice The allowlisted types (step 0-1). mat = (1 + chop) / ((1 - p99.9 closed-market gap) x auction floor), rounded up
    /// to 5% plus 5% for the feed's 0.5% band and the auction hour (weekend-gap study, 2000-2026). CRCL and SPCX have under 2 years of
```

Arithmetic I verified from the config (mat, chop 10%, floor 0.9 over 1 h; SGOV chop 5%, floor 0.97). A position exactly at mat sold at the floor still covers debt + chop while the gap is under 1 - (1 + chop)/(mat x floor): SPY 12.7%, NVDA/TSLA 18.5%, USO/AAPL 15.7%, MSTR 30.2%, CRCL/SPCX 38.9%, SGOV 5.9%. It books bad debt only when the gap exceeds 1 - 1/(mat x floor): SPY 20.6%, NVDA/TSLA 25.9%, USO/AAPL 23.4%, MSTR 36.5%, CRCL/SPCX 44.4%, SGOV 10.4%. The borrower's whole equity is gone at 1 - (1 + chop)/mat. Measurements (the specialists', not re-run by me; I re-read only the latest SGOV and SPY rounds): largest on-chain session-to-session move Jun-Nov 2026 was NVDA 13.56%, AAPL 9.32%, MSTR 7.70%, CRCL 6.13%, SPCX 5.30%, TSLA 4.30%, SPY 0.82%, SGOV +1.9% intra-overnight: all inside the buffers, so (a) as built is sound against this sample. audit_economics' daily-bar study (Yahoo, open vs previous close) gives |gap| p99.9: SPY 5.5%, NVDA 19.2% (4 down-gaps beyond 18.5% since 1999), TSLA 15.0%, USO 11.6%, MSTR 19.8%, AAPL 13.0% (9.9% since 2000, as the config says), SGOV 0.42%: by the config's own formula NVDA needs (1.1)/(0.808 x 0.9) = 1.51 -> 1.55 -> 1.60 with the band, not 1.50, and TSLA's 1.50 carries no slack; I could not verify that data set inside this task. Not measured by anyone: the after-hours depth of the tokens' pools on Robinhood Chain (the repository quotes $0.43-0.98M of bid depth within -5% for AAPL and SPY in regular hours). C6: a wrong in-session print of +x% lets a borrower draw (1 + x)/mat of real value, a protocol loss only when x > mat - 1 (40% SPY, 15% SGOV), capped by the line (250-2,500); a print of -x% liquidates every position within x of mat at the 10% penalty, which is the borrower's loss. C7: an auction healed by price and dipping again inside 2 h sells at live x factor, down to the floor (10%, 3% SGOV) under the live price, as the README says; the medium finding on the factor during unpriced time is the worse variant. C8: holds for the measured gaps; the +5% band covers the 0.5% deviation trigger but not the up to 1.7% difference between the standing overnight answer and the first in-session print. C9: RateFeed.rate() = min(live, max(ceiling, highRate)) is never above the live rate, so no donation, deposit or reissue is valued above the vault's real rate; the uncapped return to highRate is real stock (my StockSystem test: a 100% donation moved rate() by 0; a burn halved it at once). Ranking: (c) > (a) > (b). (b) adds two legs that are both weakest after hours (the overnight feed misprinted SGOV by 1.9%; a block-end pusher controls a thin pool), so their agreement inside a band is cheap to produce on a small pool and it liquidates borrowers when they can least respond. (c): keep (a) and add: borrow, bite and take require an answer printed in the current session (with an in-session heartbeat or a bounded grace for quiet tickers); a stricter ratio for NEW debt than for liquidation in the last hour before a close longer than one night (weekends, holidays); the auction factor on priced time; the vault closed to deposits while below its high-water rate; NVDA mat 1.60 or a smaller line.

**Reproduction**

State that would break (a): a position at mat and a closed-market gap above the bad-debt threshold, e.g. SPY at 140% and a -20.6% open: debt 100, collateral 140 -> 111.2, sold at the 0.9 floor for 100.04. NVDA at 150% with the worst observed gap (-30.6%): collateral 150 -> 104.1, sold at 0.9 for 93.7 against debt 100 and penalty 10, bad debt 6.3 per 100 of debt. Verified mechanics on this commit (StockSystem): a Friday 15:59:50 mark and auction at $85 lapses over the weekend; Monday 09:30 print $60; liquidate() reopens and price(id) == 60e12 (live, not the stale $85): test_gapAcrossCloseSellsAtLive passes.

---

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