-
Notifications
You must be signed in to change notification settings - Fork 3
/
CasimirBeacon.sol
141 lines (135 loc) Β· 4.74 KB
/
CasimirBeacon.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// SPDX-License-Identifier: Apache
pragma solidity 0.8.18;
import "../CasimirManager.sol";
import "../CasimirPool.sol";
import "../CasimirRegistry.sol";
import "../CasimirUpkeep.sol";
import "../CasimirViews.sol";
import "../interfaces/ICasimirCore.sol";
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
/// @title Library to create beacon proxy contracts
library CasimirBeacon {
/**
* @notice Deploy a new manager beacon proxy contract
* @param managerBeaconAddress Manager beacon address
* @param daoOracleAddress DAO oracle address
* @param functionsOracleAddress Chainlink functions oracle address
* @param strategy Staking strategy configuration
*/
function createManager(
address managerBeaconAddress,
address daoOracleAddress,
address functionsOracleAddress,
ICasimirCore.Strategy memory strategy
) public returns (address managerAddress) {
managerAddress = address(
new BeaconProxy(
managerBeaconAddress,
abi.encodeWithSelector(
CasimirManager(payable(address(0))).initialize.selector,
daoOracleAddress,
functionsOracleAddress,
strategy
)
)
);
}
/**
* @notice Deploy a new pool beacon proxy contract
* @param poolBeaconAddress Pool beacon address
* @param registryAddress Registry contract address
* @param poolId Pool ID
* @param operatorIds Operator IDs
* @param publicKey Validator public key
* @param shares Operator key shares
* @return poolAddress Pool contract address
*/
function createPool(
address poolBeaconAddress,
address registryAddress,
uint64[] memory operatorIds,
uint32 poolId,
bytes memory publicKey,
bytes memory shares
) public returns (address poolAddress) {
poolAddress = address(
new BeaconProxy(
poolBeaconAddress,
abi.encodeWithSelector(
CasimirPool(address(0)).initialize.selector,
registryAddress,
operatorIds,
poolId,
publicKey,
shares
)
)
);
}
/**
* @notice Deploy a new registry beacon proxy
* @param registryBeaconAddress Registry beacon address
* @param minCollateral Minimum collateral per operator per pool
* @param privateOperators Whether private operators are enabled
* @param verifiedOperators Whether verified operators are enabled
* @return registryAddress Registry address
*/
function createRegistry(
address registryBeaconAddress,
uint256 minCollateral,
bool privateOperators,
bool verifiedOperators
) public returns (address registryAddress) {
registryAddress = address(
new BeaconProxy(
registryBeaconAddress,
abi.encodeWithSelector(
CasimirRegistry(address(0)).initialize.selector,
minCollateral,
privateOperators,
verifiedOperators
)
)
);
}
/**
* @notice Deploy a new upkeep beacon proxy contract
* @param upkeepBeaconAddress Upkeep beacon address
* @param factoryAddress Factory contract address
* @param functionsOracleAddress Chainlink functions oracle address
* @param compoundStake Whether to compound stake
* @return upkeepAddress Upkeep contract address
*/
function createUpkeep(
address upkeepBeaconAddress,
address factoryAddress,
address functionsOracleAddress,
bool compoundStake
) public returns (address upkeepAddress) {
upkeepAddress = address(
new BeaconProxy(
upkeepBeaconAddress,
abi.encodeWithSelector(
CasimirUpkeep(address(0)).initialize.selector,
factoryAddress,
functionsOracleAddress,
compoundStake
)
)
);
}
/**
* @notice Deploy a new views beacon proxy contract
* @param viewsBeaconAddress Views beacon address
* @param managerAddress Manager contract address
* @return viewsAddress Views contract address
*/
function createViews(address viewsBeaconAddress, address managerAddress) public returns (address viewsAddress) {
viewsAddress = address(
new BeaconProxy(
viewsBeaconAddress,
abi.encodeWithSelector(CasimirViews(address(0)).initialize.selector, managerAddress)
)
);
}
}