-
Notifications
You must be signed in to change notification settings - Fork 75
/
VaultInitializationModule.sol
58 lines (48 loc) · 2.22 KB
/
VaultInitializationModule.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
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
import {ERC20} from "solmate/tokens/ERC20.sol";
import {Auth, Authority} from "solmate/auth/Auth.sol";
import {Vault} from "../Vault.sol";
import {VaultFactory} from "../VaultFactory.sol";
import {VaultConfigurationModule} from "./VaultConfigurationModule.sol";
/// @title Rari Vault Initialization Module
/// @author Transmissions11 and JetJadeja
/// @notice Module for initializing newly created Vaults.
contract VaultInitializationModule is Auth {
/// @notice Vault configuration module used to configure Vaults before initialization.
VaultConfigurationModule public configModule;
/// @notice Creates a Vault initialization module.
/// @param _configModule The Vault configuration module the
/// module will use to configure Vaults before initialization.
/// @param _owner The owner of the module.
/// @param _authority The Authority of the module.
constructor(
VaultConfigurationModule _configModule,
address _owner,
Authority _authority
) Auth(_owner, _authority) {
configModule = _configModule;
}
/// @notice Emitted when the config module is updated.
/// @param newConfigModule The new configuration module.
event ConfigModuleUpdated(VaultConfigurationModule newConfigModule);
/// @notice Sets a new Vault configuration module.
/// @param newConfigModule The Vault configuration module to set.
function setConfigModule(VaultConfigurationModule newConfigModule) external requiresAuth {
// Update the config module.
configModule = newConfigModule;
emit ConfigModuleUpdated(newConfigModule);
}
/// @notice Properly configures and initializes a newly deployed Vault.
/// @dev This will revert if the Vault has already been initialized.
/// @param vault The Vault to configure and initialize.
function initializeVault(Vault vault) external {
// Configure all key parameters.
configModule.syncFeePercent(vault);
configModule.syncHarvestDelay(vault);
configModule.syncHarvestWindow(vault);
configModule.syncTargetFloatPercent(vault);
// Open the Vault up for deposits.
vault.initialize();
}
}