@@ -24,6 +24,7 @@ import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISe
24
24
25
25
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol " ;
26
26
import { DelegatedManager } from "../manager/DelegatedManager.sol " ;
27
+ import { IController } from "../interfaces/IController.sol " ;
27
28
import { IDelegatedManager } from "../interfaces/IDelegatedManager.sol " ;
28
29
import { IManagerCore } from "../interfaces/IManagerCore.sol " ;
29
30
import { ISetTokenCreator } from "../interfaces/ISetTokenCreator.sol " ;
@@ -46,6 +47,7 @@ contract DelegatedManagerFactory {
46
47
struct InitializeParams {
47
48
address deployer;
48
49
address owner;
50
+ address methodologist;
49
51
IDelegatedManager manager;
50
52
bool isPending;
51
53
}
@@ -79,8 +81,11 @@ contract DelegatedManagerFactory {
79
81
// ManagerCore address
80
82
IManagerCore public immutable managerCore;
81
83
84
+ // Controller address
85
+ IController public immutable controller;
86
+
82
87
// SetTokenFactory address
83
- ISetTokenCreator public setTokenFactory;
88
+ ISetTokenCreator public immutable setTokenFactory;
84
89
85
90
// Mapping which stores manager creation metadata between creation and initialization steps
86
91
mapping (ISetToken=> InitializeParams) public initializeState;
@@ -90,15 +95,18 @@ contract DelegatedManagerFactory {
90
95
/**
91
96
* @dev Sets managerCore and setTokenFactory address.
92
97
* @param _managerCore Address of ManagerCore protocol contract
98
+ * @param _controller Address of Controller protocol contract
93
99
* @param _setTokenFactory Address of SetTokenFactory protocol contract
94
100
*/
95
101
constructor (
96
102
IManagerCore _managerCore ,
103
+ IController _controller ,
97
104
ISetTokenCreator _setTokenFactory
98
- )
99
- public
105
+ )
106
+ public
100
107
{
101
108
managerCore = _managerCore;
109
+ controller = _controller;
102
110
setTokenFactory = _setTokenFactory;
103
111
}
104
112
@@ -149,13 +157,12 @@ contract DelegatedManagerFactory {
149
157
150
158
DelegatedManager manager = _deployManager (
151
159
setToken,
152
- _methodologist,
153
160
_extensions,
154
161
_operators,
155
162
_assets
156
163
);
157
164
158
- _setInitializationState (setToken, address (manager), _owner);
165
+ _setInitializationState (setToken, address (manager), _owner, _methodologist );
159
166
160
167
return (setToken, address (manager));
161
168
}
@@ -189,19 +196,19 @@ contract DelegatedManagerFactory {
189
196
external
190
197
returns (address )
191
198
{
199
+ require (controller.isSet (address (_setToken)), "Must be controller-enabled SetToken " );
192
200
require (msg .sender == _setToken.manager (), "Must be manager " );
193
201
194
202
_validateManagerParameters (_setToken.getComponents (), _extensions, _assets);
195
203
196
204
DelegatedManager manager = _deployManager (
197
205
_setToken,
198
- _methodologist,
199
206
_extensions,
200
207
_operators,
201
208
_assets
202
209
);
203
210
204
- _setInitializationState (_setToken, address (manager), _owner);
211
+ _setInitializationState (_setToken, address (manager), _owner, _methodologist );
205
212
206
213
return address (manager);
207
214
}
@@ -234,23 +241,27 @@ contract DelegatedManagerFactory {
234
241
require (msg .sender == initializeState[_setToken].deployer, "Only deployer can initialize manager " );
235
242
_initializeTargets.validatePairsWithArray (_initializeBytecode);
236
243
237
- IDelegatedManager manager = initializeState[_setToken].manager;
238
- manager.updateOwnerFeeSplit (_ownerFeeSplit);
239
- manager.updateOwnerFeeRecipient (_ownerFeeRecipient);
240
-
241
244
for (uint256 i = 0 ; i < _initializeTargets.length ; i++ ) {
245
+ address target = _initializeTargets[i];
246
+ require (! controller.isSet (target), "Target must not be SetToken " );
247
+
242
248
// Because we validate uniqueness of _initializeTargets only one transaction can be sent to each module or extension during this
243
249
// transaction. Due to this no modules/extension can be used for any SetToken transactions other than initializing these contracts
244
- _initializeTargets[i] .functionCallWithValue (_initializeBytecode[i], 0 );
250
+ target .functionCallWithValue (_initializeBytecode[i], 0 );
245
251
}
246
252
253
+ IDelegatedManager manager = initializeState[_setToken].manager;
254
+ manager.updateOwnerFeeSplit (_ownerFeeSplit);
255
+ manager.updateOwnerFeeRecipient (_ownerFeeRecipient);
256
+
247
257
// If the SetToken was factory-deployed & factory is its current `manager`, transfer
248
258
// managership to the new DelegatedManager
249
259
if (_setToken.manager () == address (this )) {
250
260
_setToken.setManager (address (manager));
251
261
}
252
262
253
263
manager.transferOwnership (initializeState[_setToken].owner);
264
+ manager.setMethodologist (initializeState[_setToken].methodologist);
254
265
255
266
delete initializeState[_setToken];
256
267
@@ -297,7 +308,6 @@ contract DelegatedManagerFactory {
297
308
* Deploys a DelegatedManager
298
309
*
299
310
* @param _setToken Instance of SetToken to migrate to the DelegatedManager system
300
- * @param _methodologist Address to set as the DelegateManager's methodologist role
301
311
* @param _extensions List of extensions authorized for the DelegateManager
302
312
* @param _operators List of operators authorized for the DelegateManager
303
313
* @param _assets List of assets DelegateManager can trade. When empty, asset allow list is not enforced
@@ -306,7 +316,6 @@ contract DelegatedManagerFactory {
306
316
*/
307
317
function _deployManager (
308
318
ISetToken _setToken ,
309
- address _methodologist ,
310
319
address [] memory _extensions ,
311
320
address [] memory _operators ,
312
321
address [] memory _assets
@@ -321,7 +330,7 @@ contract DelegatedManagerFactory {
321
330
DelegatedManager newManager = new DelegatedManager (
322
331
_setToken,
323
332
address (this ),
324
- _methodologist ,
333
+ address ( this ) ,
325
334
_extensions,
326
335
_operators,
327
336
_assets,
@@ -347,15 +356,18 @@ contract DelegatedManagerFactory {
347
356
* @param _setToken Instance of SetToken
348
357
* @param _manager Address of DelegatedManager created for SetToken
349
358
* @param _owner Address that will be given the `owner` DelegatedManager's role on initialization
359
+ * @param _methodologist Address that will be given the `methodologist` DelegatedManager's role on initialization
350
360
*/
351
361
function _setInitializationState (
352
362
ISetToken _setToken ,
353
363
address _manager ,
354
- address _owner
364
+ address _owner ,
365
+ address _methodologist
355
366
) internal {
356
367
initializeState[_setToken] = InitializeParams ({
357
368
deployer: msg .sender ,
358
369
owner: _owner,
370
+ methodologist: _methodologist,
359
371
manager: IDelegatedManager (_manager),
360
372
isPending: true
361
373
});
0 commit comments