Skip to content

Commit

Permalink
feat: sugar factory registry
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrovalido committed Oct 4, 2024
1 parent d180c42 commit 5514895
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions brownie-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ networks:
mnemonic: brownie
fork: https://optimism-mainnet.wallet.coinbase.com
evm_version: shanghai
dependencies:
- openzeppelin/[email protected]
35 changes: 35 additions & 0 deletions contracts/helpers/FactoryRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.19 <0.9.0;

import {Ownable} from "openzeppelin/[email protected]/contracts/access/Ownable.sol";
import {EnumerableSet} from "openzeppelin/[email protected]/contracts/utils/structs/EnumerableSet.sol";

/// @title Sugar Factory Registry
/// @author @velodrome.finance
/// @notice Sugar Factory Registry to keep track of leaf pool factories
contract FactoryRegistry is Ownable {
using EnumerableSet for EnumerableSet.AddressSet;

/// @dev Array of poolFactories
EnumerableSet.AddressSet private _poolFactories;

constructor() Ownable(msg.sender) {}

function approve(address poolFactory) external onlyOwner {
require(!_poolFactories.contains(poolFactory), "AE");
_poolFactories.add(poolFactory);
}

function unapprove(address poolFactory) external onlyOwner {
require(_poolFactories.contains(poolFactory), "NE");
_poolFactories.remove(poolFactory);
}

function factoriesToPoolFactory(address poolFactory) external pure returns (address, address) {
return (address(0), poolFactory);
}

function poolFactories() external view returns (address[] memory) {
return _poolFactories.values();
}
}
22 changes: 22 additions & 0 deletions scripts/deployFactoryRegistry.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Script.sol";
import "contracts/helpers/FactoryRegistry.sol";

contract DeployFactoryRegistry is Script {

uint256 public deployPrivateKey = vm.envUint("PRIVATE_KEY_DEPLOY");
address public deployerAddress = vm.addr(deployPrivateKey);

function run() public {

vm.startBroadcast(deployerAddress);

FactoryRegistry factoryRegistry = new FactoryRegistry();

vm.stopBroadcast();
console.log("FactoryRegistry deployed at: ", address(factoryRegistry));

}
}

0 comments on commit 5514895

Please sign in to comment.