forked from sushiswap/trident
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMasterDeployer.sol
70 lines (55 loc) · 2.17 KB
/
MasterDeployer.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import "../interfaces/IPoolFactory.sol";
import "../utils/TridentOwnable.sol";
/// @notice Trident pool deployer contract with template factory whitelist.
/// @author Mudit Gupta.
contract MasterDeployer is TridentOwnable {
event DeployPool(address indexed _factory, address indexed pool);
event AddToWhitelist(address indexed _factory);
event RemoveFromWhitelist(address indexed _factory);
event BarFeeUpdated(uint256 indexed _barFee);
event MigratorUpdated(address indexed _migrator);
uint256 public barFee;
address public migrator;
address public immutable barFeeTo;
address public immutable bento;
uint256 internal constant MAX_FEE = 10000; // @dev 100%.
mapping(address => bool) public pools;
mapping(address => bool) public whitelistedFactories;
constructor(
uint256 _barFee,
address _barFeeTo,
address _bento
) {
require(_barFee <= MAX_FEE, "INVALID_BAR_FEE");
require(_barFeeTo != address(0), "ZERO_ADDRESS");
require(_bento != address(0), "ZERO_ADDRESS");
barFee = _barFee;
barFeeTo = _barFeeTo;
bento = _bento;
}
function deployPool(address _factory, bytes calldata _deployData) external returns (address pool) {
require(whitelistedFactories[_factory], "FACTORY_NOT_WHITELISTED");
pool = IPoolFactory(_factory).deployPool(_deployData);
pools[pool] = true;
emit DeployPool(_factory, pool);
}
function addToWhitelist(address _factory) external onlyOwner {
whitelistedFactories[_factory] = true;
emit AddToWhitelist(_factory);
}
function removeFromWhitelist(address _factory) external onlyOwner {
whitelistedFactories[_factory] = false;
emit RemoveFromWhitelist(_factory);
}
function setBarFee(uint256 _barFee) external onlyOwner {
require(_barFee <= MAX_FEE, "INVALID_BAR_FEE");
barFee = _barFee;
emit BarFeeUpdated(_barFee);
}
function setMigrator(address _migrator) external onlyOwner {
migrator = _migrator;
emit MigratorUpdated(_migrator);
}
}