-
Notifications
You must be signed in to change notification settings - Fork 20
/
BoostAggregatorFactory.sol
58 lines (43 loc) · 2.04 KB
/
BoostAggregatorFactory.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: MIT
pragma solidity ^0.8.0;
import {ERC20} from "solmate/tokens/ERC20.sol";
import {UniswapV3Staker} from "@v3-staker/UniswapV3Staker.sol";
import {BoostAggregator} from "../boost-aggregator/BoostAggregator.sol";
import {IBoostAggregatorFactory} from "../interfaces/IBoostAggregatorFactory.sol";
/// @title Boost Aggregator Factory
contract BoostAggregatorFactory is IBoostAggregatorFactory {
/*//////////////////////////////////////////////////////////////
BOOST AGGREGATOR FACTORY STATE
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IBoostAggregatorFactory
UniswapV3Staker public immutable uniswapV3Staker;
/// @inheritdoc IBoostAggregatorFactory
ERC20 public immutable hermes;
/// @inheritdoc IBoostAggregatorFactory
BoostAggregator[] public boostAggregators;
/// @inheritdoc IBoostAggregatorFactory
mapping(BoostAggregator => uint256) public boostAggregatorIds;
/**
* @notice Construct a new Boost Aggregator Factory contract.
* @param _uniswapV3Staker Uniswap V3 Staker to use.
*/
constructor(UniswapV3Staker _uniswapV3Staker) {
uniswapV3Staker = _uniswapV3Staker;
hermes = ERC20(_uniswapV3Staker.hermes());
boostAggregators.push(BoostAggregator(address(0)));
}
/// @inheritdoc IBoostAggregatorFactory
function getBoostAggregators() external view returns (BoostAggregator[] memory) {
return boostAggregators;
}
/*//////////////////////////////////////////////////////////////
CREATE LOGIC
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IBoostAggregatorFactory
function createBoostAggregator(address owner) external {
if (owner == address(0)) revert InvalidOwner();
BoostAggregator boostAggregator = new BoostAggregator(uniswapV3Staker, hermes, owner);
boostAggregatorIds[boostAggregator] = boostAggregators.length;
boostAggregators.push(boostAggregator);
}
}