{"item": "x-deployer-oneshot", "commit": "ff1c192b3798542997f600091f2dc73ff05e4c40", "forge": "1.9.0 (--use solar)", "verdict": "holds", "findings": [], "claims": [{"id": "C1", "result": "holds", "evidence": "Spent after the plan, fuzzed (test_core_spent, 256 runs, PASS): core Treasury.wire/wireNotes (src/Treasury.sol:83-99), Join.wire (src/Join.sol:28), Backstop.wire/addIlk/disableIlk after seal (src/backstop/Backstop.sol:183-223), PricerOracle.setIlk after seal (src/backstop/PricerOracle.sol:33). House Treasury.wireNotes refused once wired (test_houseNotesRefusedAfterWire PASS; src/house/Treasury.sol:109-113). Other guards by grep of src: ImdUSD.wire (src/ImdUSD.sol:101, ledger!=0), Ledger.wire (core src/Ledger.sol:90 flag redeemer!=0; house src/house/Ledger.sol:105 flag liquidator!=0 and zero refused), Parameters.wire/seal (one-shot, seal reverts if sealed), PositionNFT.bind (src/PositionNFT.sol:93, ledger!=0; Ledger.wire needs nft.ledger()==this), SeatJoin.wire (src/house/seats/SeatJoin.sol:176), house Join.wire, PegCollateral.setZap (src/house/earn/PegCollateral.sol:30, wirer, once, spent by script/house/deploy/StagePeg.sol:90). Routes the claim does not name: PegCollateral.setZap and Parameters.setGenesisBackstops (core repeatable only while blue==0; sealed at seal). Core wireNotes: every launch config (Mainnet/Robinhood/Base) sets pegQuote (script/DeployConfig.sol:222,569,769) and script/deploy/StageGenesis.sol:41-48 spends it, as README:857 states. SwarmFeed first-value gate: SwarmQuestions.DATA_CHAIN=1 (src/house/feeds/SwarmFeeds.sol:45); clock chain = chainid, or 1 on 4663 (SwarmFeed.sol:305), so inert on Ethereum and 4663; Base has no swarm leaf (script/DeployConfig.sol Base feeds are Chainlink/product/rate). Not RUN on a fork (NOT RUN)."}, {"id": "C2", "result": "holds", "evidence": "Core plan (script/deploy/DeployBase.sol:200-213, StageGenesis.sol:61-72). test_hookFrontRun (fuzz 256 runs, PASS): a stranger deploys the same init code at the mined salt: identical hook; a different sink gives a different CREATE2 address; a pool at a price != pegSqrtPriceX96 or with another fee is refused (PegHook.beforeInitialize src/peg/PegHook.sol:113-127: WrongPool/NotAtPeg); opening at the peg by anyone gives exactly the plan's pool and initialized()==true. Caveat: the HOUSE variant script/house/deploy/DeployBase.sol:304-313 skips salts that have code (`a.code.length != 0 continue`) and calls CREATE2 raw, so a stranger front-running the CREATE2 in the same block makes the plan tx fail (HookNotDeployed) and script/house/deploy/StageGenesis.sol:72-75 skips initialize if a stranger opened the pool. Liveness only, no money; the house hook there is another contract and was not tested (NOT RUN)."}, {"id": "C3", "result": "holds", "evidence": "setGenesisDepthRule (src/house/Parameters.sol:93-103) bounds k<=MAX_DEPTH_K, otherChop<=1e18, otherLines<=uint128.max, the same as SET_OTHER_IMD at propose (src/house/ParametersRules.sol:75-80) and SET_DEPTH_K (:62-64). Compared every genesis setter with its kind: Savings share (<=MAX_SAVINGS_SHARE, kind adds a step cap that has no meaning from zero), MaxLull, ChainLine (<=MAX_CHAIN_LINE), ExoticMargin, Target (<=MAX_TARGET_BUFFER), Group (_checkGroup shared), Cap (_setCap shared, no bound in either), EdgePremium (<=MAX_EDGE_PREMIUM), depth (uint256 unbounded in both, SET_DEPTH has no bound either). No genesis setter looser than its kind. Not fuzzed."}, {"id": "C4", "result": "refuted", "evidence": "True for script/deploy/* (core: only reads are chain/code checks of config addresses, vm.getNonce, and initialized() after the plan's own initialize; script/deploy/StageGenesis.sol:72). False for script/house/deploy/*: it reads the record and adopts: StagePeg.sol:24-28 (d.params.config(ilk) adopts token/median/join), :82 (adopts pegCollateral.zap()), StageChain.sol:89-90 (adopts from params.config), StageGenesis.sol:72/154 (d.hook.initialized, params.config), StageHouse.sol:19-23 itself says the helpers were 'written for the pre-strip resumable tooling' and relies on an empty Deployed to take the deploy branch; DeployBase.sol:19-24 describes a resume (_has/_ok/Mismatch). With an empty d every branch is the deploy branch (state read only from contracts the plan created), so no money impact found; the claim and P2's wording 'every stage' do not describe script/house/deploy."}], "holds": [{"property": "P1 deployer has no power after deployment", "tried": "fuzzed callers after the full core wire/seal sequence for Treasury, Join, Backstop, PricerOracle (revert on every wire/addIlk/disableIlk/setIlk/seal path); house Treasury.wireNotes after wire; grep of every wirer/deployer/binder guard in src/ (list in C1); the one-transaction window between new Treasury and wire is README:741-744, as written. Parameters genesis setters and seal need sealed_==false and seal is one-shot (src/Parameters.sol:207-211, src/house/Parameters.sol:299-305). SwarmFeed gate inert on every day-1 chain."}, {"property": "P2 every stage is a pure plan", "tried": "core stages script/deploy/*: addresses are createAddress(deployer,nonce+k), the hook/pool steps go through _callAllowingDone so a stranger's CREATE2 or initialize leaves the tx list unchanged (test_hookFrontRun). The house stage is not pure in the strict sense (see C2 caveat and C4), liveness only."}, {"property": "P3 one-shot setters bounded as their governed kind", "tried": "see C3: every Parameters.setGenesis* against its kind in ParametersRules; Backstop.addIlk genesis args are the same function as the post-seal listing; PricerOracle.setIlk is one-way in both phases."}], "notRun": ["[fork] Deploy.t.sol / Robinhood.t.sol / Mainnet.t.sol rehearsals: NOT RUN (no RPC)", "house PegHook CREATE2 front-run at the house variant: NOT RUN", "full Deploy script end to end with the stage ordering fuzzed: NOT RUN; only the contracts' own one-shot guards and the hook were tested"], "tests": {"OneShot.t.sol": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\nimport {Test} from \"forge-std/Test.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {PoolManager} from \"v4-core/src/PoolManager.sol\";\nimport {IPoolManager} from \"v4-core/src/interfaces/IPoolManager.sol\";\nimport {PoolKey} from \"v4-core/src/types/PoolKey.sol\";\nimport {Currency} from \"v4-core/src/types/Currency.sol\";\nimport {IHooks} from \"v4-core/src/interfaces/IHooks.sol\";\nimport {Hooks} from \"v4-core/src/libraries/Hooks.sol\";\nimport {ImdUSD} from \"../../src/ImdUSD.sol\";\nimport {Treasury as CoreTreasury, ICoverable} from \"../../src/Treasury.sol\";\nimport {Treasury as HouseTreasury, ICoverable as HCov} from \"../../src/house/Treasury.sol\";\nimport {Join} from \"../../src/Join.sol\";\nimport {Backstop} from \"../../src/backstop/Backstop.sol\";\nimport {PricerOracle} from \"../../src/backstop/PricerOracle.sol\";\nimport {Pricer} from \"../../src/Pricer.sol\";\nimport {ILedgerCover, IBackstopOracle} from \"../../src/backstop/IBackstop.sol\";\nimport {PegHook} from \"../../src/peg/PegHook.sol\";\n\ncontract Tok is ERC20 { uint8 d; constructor(string memory n, uint8 d_) ERC20(n, n) { d = d_; } function decimals() public view override returns (uint8) { return d; } }\ncontract Code { fallback() external {} }\ncontract HLedger { address public params = address(1); address public treasury = address(2); address public token; constructor(address t){token=t;} fallback() external {} }\n\ncontract OneShot is Test {\n    address dep = makeAddr(\"dep\");\n    address gov = makeAddr(\"gov\");\n\n    function test_core_spent(address stranger) public {\n        Tok t = new Tok(\"U\", 18);\n        address c = address(new Code());\n        vm.startPrank(dep);\n        CoreTreasury tr = new CoreTreasury(gov, IERC20(address(t)), dep);\n        Join j = new Join(address(t), dep);\n        Backstop b = new Backstop(IERC20(address(t)), ILedgerCover(c), IBackstopOracle(c), \"b\", \"b\");\n        PricerOracle o = new PricerOracle(Pricer(c), c);\n        tr.wire(ICoverable(c)); tr.wireNotes(c); j.wire(c); b.wire(c, c); b.addIlk(\"X\", address(0xA11CE)); o.setIlk(address(0xA11CE), \"X\");\n        b.seal(); o.seal();\n        vm.expectRevert(); tr.wire(ICoverable(c));\n        vm.expectRevert(); tr.wireNotes(c);\n        vm.expectRevert(); j.wire(c);\n        vm.expectRevert(); b.wire(c, c);\n        vm.expectRevert(); b.addIlk(\"Y\", address(0xB0B));\n        vm.expectRevert(); b.disableIlk(\"X\");\n        vm.stopPrank();\n    }\n}\n", "Hook.t.sol": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\nimport {Test} from \"forge-std/Test.sol\";\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {PoolManager} from \"v4-core/src/PoolManager.sol\";\nimport {IPoolManager} from \"v4-core/src/interfaces/IPoolManager.sol\";\nimport {PoolKey} from \"v4-core/src/types/PoolKey.sol\";\nimport {Currency} from \"v4-core/src/types/Currency.sol\";\nimport {IHooks} from \"v4-core/src/interfaces/IHooks.sol\";\nimport {Hooks} from \"v4-core/src/libraries/Hooks.sol\";\nimport {Treasury as HouseTreasury, ICoverable as HCov} from \"../../src/house/Treasury.sol\";\nimport {PegHook} from \"../../src/peg/PegHook.sol\";\n\ncontract Tok is ERC20 { uint8 d; constructor(string memory n, uint8 d_) ERC20(n, n) { d = d_; } function decimals() public view override returns (uint8) { return d; } }\ncontract HL { address public params = address(1); address public treasury = address(2); address public token; constructor(address t){token=t;} }\n\ncontract HookT is Test {\n    address constant CREATE2 = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n    function _mustFail(IPoolManager pm, PoolKey memory k, uint160 p, address who) internal {\n        vm.prank(who);\n        try pm.initialize(k, p) { revert(\"opened\"); } catch (bytes memory e) { assertTrue(e.length > 0); }\n    }\n    function test_houseNotesRefusedAfterWire() public {\n        Tok t = new Tok(\"U\", 18);\n        HouseTreasury tr = new HouseTreasury(address(this), IERC20(address(t)), address(this));\n        HL l = new HL(address(t));\n        tr.wire(HCov(address(l)));\n        vm.expectRevert(); tr.wireNotes(address(l));\n        vm.expectRevert(); tr.wire(HCov(address(l)));\n    }\n\n    function test_hookFrontRun(address stranger, uint160 badPrice, uint24 badFee) public {\n        vm.etch(CREATE2, hex\"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3\");\n        IPoolManager pm = IPoolManager(address(new PoolManager(address(this))));\n        Tok usd = new Tok(\"USD\", 18); Tok q = new Tok(\"Q\", 6);\n        address sink = address(0x51);\n        uint160 flags = Hooks.BEFORE_INITIALIZE_FLAG | Hooks.AFTER_SWAP_FLAG | Hooks.AFTER_SWAP_RETURNS_DELTA_FLAG;\n        bytes memory init = abi.encodePacked(type(PegHook).creationCode, abi.encode(pm, address(usd), address(q), sink));\n        bytes32 h = keccak256(init); address a; bytes32 salt;\n        for (uint256 s;; ++s) { a = address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), CREATE2, bytes32(s), h))))); if (uint160(a) & Hooks.ALL_HOOK_MASK == flags) { salt = bytes32(s); break; } }\n        vm.prank(stranger); (bool ok,) = CREATE2.call(abi.encodePacked(salt, init)); assertTrue(ok);\n        PegHook hk = PegHook(a);\n        // other constructor args cannot sit at this address: the init hash differs\n        bytes memory init2 = abi.encodePacked(type(PegHook).creationCode, abi.encode(pm, address(usd), address(q), address(0x52)));\n        assertTrue(address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), CREATE2, salt, keccak256(init2)))))) != a);\n        // a second deploy of the same init at the same salt fails (nothing to gain)\n        (bool ok2,) = CREATE2.call(abi.encodePacked(salt, init)); assertFalse(ok2);\n        (address c0, address c1) = hk.stableIsToken0() ? (address(usd), address(q)) : (address(q), address(usd));\n        PoolKey memory k = PoolKey(Currency.wrap(c0), Currency.wrap(c1), hk.BASE_FEE(), hk.TICK_SPACING(), IHooks(a));\n        uint160 peg = hk.pegSqrtPriceX96(); uint24 bf = hk.BASE_FEE();\n        // pool opened off the peg: refused\n        vm.assume(badPrice != peg && badPrice > 4295128739 && badPrice < 1461446703485210103287273052203988822378723970342);\n        _mustFail(pm, k, badPrice, stranger);\n        // any other key for this hook: refused\n        vm.assume(badFee != bf);\n        PoolKey memory k2 = PoolKey(k.currency0, k.currency1, badFee % 1000000, k.tickSpacing, k.hooks);\n        vm.assume(k2.fee != bf);\n        _mustFail(pm, k2, peg, stranger);\n        // at the peg: anyone may open, and it is exactly the plan's pool\n        vm.prank(stranger); pm.initialize(k, peg);\n        assertTrue(hk.initialized());\n    }\n}\n"}}