-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathVaultFactory.sol
95 lines (81 loc) · 3.04 KB
/
VaultFactory.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import { IERC20, IERC4626 } from "openzeppelin/token/ERC20/extensions/ERC4626.sol";
import { LiquidationPair } from "v5-liquidator/LiquidationPair.sol";
import { PrizePool } from "v5-prize-pool/PrizePool.sol";
import { TwabController } from "v5-twab-controller/TwabController.sol";
import { Vault } from "./Vault.sol";
/**
* @title PoolTogether V5 Vault Factory
* @author PoolTogether Inc Team, Generation Software Team
* @notice Factory contract for deploying new vaults using a standard underlying ERC4626 yield vault.
*/
contract VaultFactory {
/* ============ Events ============ */
/**
* @notice Emitted when a new Vault has been deployed by this factory.
* @param vault Address of the vault that was deployed
* @param vaultFactory Address of the VaultFactory that deployed `vault`
*/
event NewFactoryVault(Vault indexed vault, VaultFactory indexed vaultFactory);
/* ============ Variables ============ */
/// @notice List of all vaults deployed by this factory.
Vault[] public allVaults;
/**
* @notice Mapping to verify if a Vault has been deployed via this factory.
* @dev Vault address => boolean
*/
mapping(Vault => bool) public deployedVaults;
/* ============ External Functions ============ */
/**
* @notice Deploy a new vault
* @dev `claimer` can be set to address zero if none is available yet.
* @param _asset Address of the underlying asset used by the vault
* @param _name Name of the ERC20 share minted by the vault
* @param _symbol Symbol of the ERC20 share minted by the vault
* @param _twabController Address of the TwabController used to keep track of balances
* @param _yieldVault Address of the ERC4626 vault in which assets are deposited to generate yield
* @param _prizePool Address of the PrizePool that computes prizes
* @param _claimer Address of the claimer
* @param _yieldFeeRecipient Address of the yield fee recipient
* @param _yieldFeePercentage Yield fee percentage
* @param _owner Address that will gain ownership of this contract
* @return address Address of the newly deployed Vault
*/
function deployVault(
IERC20 _asset,
string memory _name,
string memory _symbol,
TwabController _twabController,
IERC4626 _yieldVault,
PrizePool _prizePool,
address _claimer,
address _yieldFeeRecipient,
uint256 _yieldFeePercentage,
address _owner
) external returns (address) {
Vault _vault = new Vault(
_asset,
_name,
_symbol,
_twabController,
_yieldVault,
_prizePool,
_claimer,
_yieldFeeRecipient,
_yieldFeePercentage,
_owner
);
allVaults.push(_vault);
deployedVaults[_vault] = true;
emit NewFactoryVault(_vault, VaultFactory(address(this)));
return address(_vault);
}
/**
* @notice Total number of vaults deployed by this factory.
* @return uint256 Number of vaults deployed by this factory.
*/
function totalVaults() external view returns (uint256) {
return allVaults.length;
}
}