// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "./MOO.sol"; /// Anyone can open the opening auction for any stock the moment its feed exists. /// The factory holds no funds, takes no fee, and has no owner; it only deploys /// MOO pools and remembers where they are so venues and sites can list them. contract MOOFactory { address public immutable usdg; /// Every pool this factory opens hands its first allocation to holders of this token. /// Both are fixed at deploy, so no one can change who gets served first later. address public immutable moo; uint256 public immutable allocMin; address[] public pools; event PoolOpened( address indexed pool, address indexed stock, address indexed feed, address opener, uint256 deadline, uint256 premiumBps ); constructor(address _usdg, address _moo, uint256 _allocMin) { usdg = _usdg; moo = _moo; allocMin = _allocMin; } /// Deploy a MOO pool for a stock and its Chainlink feed. The pool records the /// feed's current round at birth; if the feed has never answered, the first /// answer in its life is the settlement print. function open(address stock, address feed, uint256 deadline, uint256 premiumBps) external returns (address pool) { pool = address(new MOO( IERC20(usdg), IERC20(stock), AggregatorV3Interface(feed), deadline, premiumBps, IERC20(moo), allocMin )); pools.push(pool); emit PoolOpened(pool, stock, feed, msg.sender, deadline, premiumBps); } function poolCount() external view returns (uint256) { return pools.length; } function allPools() external view returns (address[] memory) { return pools; } }