generated from GenerationSoftware/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
VaultBoosterFactory.sol
43 lines (36 loc) · 1.63 KB
/
VaultBoosterFactory.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { VaultBooster, PrizePool } from "./VaultBooster.sol";
/// @title VaultBoosterFactory
/// @author G9 Software Inc.
/// @notice Factory contract for VaultBooster
contract VaultBoosterFactory {
/// @notice Emitted when a new VaultBooster is created
/// @param vaultBooster The address of the new Vault Booster
/// @param prizePool The address of the prize pool to contribute to
/// @param vault The address of the vault to contribute for
/// @param owner The owner of the VaultBooster
event CreatedVaultBooster(
VaultBooster indexed vaultBooster,
PrizePool indexed prizePool,
address indexed vault,
address owner
);
/// @notice Mapping to store deployer nonces for CREATE2
mapping(address deployer => uint256 nonce) public deployerNonces;
/// @notice Creates a new vault booster contract
/// @param _prizePool The prize pool to contribute to
/// @param _vault The vault to contribute for
/// @param _owner The owner of the Vault Booster
/// @return The address of the new Vault Booster
function createVaultBooster(PrizePool _prizePool, address _vault, address _owner) external returns (VaultBooster) {
// Use CREATE2 constructor with a salt derived from caller's address and their unique nonce
VaultBooster booster = (
new VaultBooster{salt: keccak256(abi.encode(msg.sender, deployerNonces[msg.sender]++))}(
_prizePool, _vault, _owner
)
);
emit CreatedVaultBooster(booster, _prizePool, _vault, _owner);
return booster;
}
}