From 86c53d4002e84a441c038d5d84f5c8326bda9c5d Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 8 May 2024 12:48:29 -0700 Subject: [PATCH 1/2] initial factory --- src/Factory.sol | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/Factory.sol diff --git a/src/Factory.sol b/src/Factory.sol new file mode 100644 index 0000000..039e921 --- /dev/null +++ b/src/Factory.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity ^0.8.13; + +import {RMM} from "./RMM.sol"; + +contract Factory { + event NewPool(address indexed caller, address indexed pool, string name, string symbol); + + address public immutable WETH; + + constructor(address weth_) { + WETH = weth_; + } + + function createRMM(string memory poolName, string memory poolSymbol) external returns (RMM) { + RMM rmm = new RMM(WETH, poolName, poolSymbol); + emit NewPool(msg.sender, address(rmm), poolName, poolSymbol); + return rmm; + } +} From 1bfbb162b885de77c85f48f1b10042f783d0334a Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 8 May 2024 12:56:16 -0700 Subject: [PATCH 2/2] track pools in state --- src/Factory.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Factory.sol b/src/Factory.sol index 039e921..68c37a5 100644 --- a/src/Factory.sol +++ b/src/Factory.sol @@ -8,6 +8,8 @@ contract Factory { address public immutable WETH; + address[] public pools; + constructor(address weth_) { WETH = weth_; } @@ -15,6 +17,7 @@ contract Factory { function createRMM(string memory poolName, string memory poolSymbol) external returns (RMM) { RMM rmm = new RMM(WETH, poolName, poolSymbol); emit NewPool(msg.sender, address(rmm), poolName, poolSymbol); + pools.push(address(rmm)); return rmm; } }