// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../TimeoutRefundUsdtLotteryRound.sol"; import "./TimeoutRefundVrfAdapter.sol"; /// @notice Constructor-only deployment with immutable adapter/round binding and native prefunding. contract TimeoutRefundRoundBootstrapper { address public immutable adapter; address public immutable round; error InvalidConfig(); error NativeFundingFailed(); constructor(TimeoutRefundUsdtLotteryRound.Config memory c, TimeoutRefundVrfAdapter.Config memory oracle) payable { if (c.randomness != address(0)) revert InvalidConfig(); // This contract's first CREATE is the adapter; its second CREATE is the round. address expectedRound = address(uint160(uint256(keccak256(abi.encodePacked(hex"d694", address(this), hex"02"))))); address deployedAdapter = address(new TimeoutRefundVrfAdapter(expectedRound, c.treasury, oracle)); c.randomness = deployedAdapter; address deployedRound = address(new TimeoutRefundUsdtLotteryRound(c)); if (deployedRound != expectedRound) revert InvalidConfig(); adapter = deployedAdapter; round = deployedRound; if (msg.value != 0) { (bool success,) = payable(deployedAdapter).call{value: msg.value}(""); if (!success) revert NativeFundingFailed(); } } }