-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMerkleManagerFactory.sol
More file actions
58 lines (44 loc) · 2.46 KB
/
Copy pathMerkleManagerFactory.sol
File metadata and controls
58 lines (44 loc) · 2.46 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Owned} from "@solmate/auth/Owned.sol";
import {RewardVaultManagerMerkle} from "../examples/RewardVaultManagerMerkle.sol";
import {RewardVaultToken} from "../examples/RewardVaultToken.sol";
import {IRewardVaultFactory} from "../interfaces/IRewardVaultFactory.sol";
import {IRewardVault} from "../interfaces/IRewardVault.sol";
/// @title MerkleManagerFactory
/// @notice A factory contract for deploying complete merkle reward vault manager setups
/// @dev Automates the deployment of RewardVaultManagerMerkle and RewardVault setup
contract MerkleManagerFactory is Owned {
// ============ Events ============
/// @notice Emitted when a new merkle manager setup is deployed
/// @param manager The address of the deployed RewardVaultManagerMerkle
/// @param rewardVaultToken The address of the RewardVaultToken
/// @param deployer The address that deployed the setup
event MerkleManagerDeployed(address indexed manager, address rewardVaultToken, address deployer);
// ============ Errors ============
/// @notice Error thrown when reward vault creation fails
error RewardVaultCreationFailed();
/// @notice Error thrown when initialization fails
error InitializationFailed();
// ============ State Variables ============
/// @notice The reward vault factory address
address public immutable rewardVaultFactory = 0x94Ad6Ac84f6C6FbA8b8CCbD71d9f4f101def52a8;
// ============ Constructor ============
/// @notice Creates a new MerkleManagerFactory
/// @dev The deployer becomes the owner
constructor() Owned(msg.sender) {}
// ============ External Functions ============
/// @notice Deploys a complete merkle manager setup
/// @return manager The address of the deployed RewardVaultManagerMerkle
/// @return rewardVaultToken The address of the RewardVaultToken
function deployMerkleManager() external returns (address manager, address rewardVaultToken) {
// 1. Deploy RewardVaultManagerMerkle
RewardVaultManagerMerkle managerContract = new RewardVaultManagerMerkle();
manager = address(managerContract);
// 2. Get the RewardVaultToken from the manager
rewardVaultToken = address(managerContract.rewardVaultToken());
// 3. Transfer ownership of the manager to the deployer
managerContract.transferOwnership(msg.sender);
emit MerkleManagerDeployed(manager, rewardVaultToken, msg.sender);
}
}