Skip to content

Commit fcc5163

Browse files
committed
Added some comments and DRY-ed code up a bit.
1 parent 85f4c49 commit fcc5163

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

contracts/factories/DelegatedManagerFactory.sol

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ contract DelegatedManagerFactory {
126126
external
127127
returns (ISetToken, address)
128128
{
129-
require(_extensions.length > 0, "Must have at least 1 extension");
130-
131-
if (_assets.length != 0) {
132-
_validateComponentsIncludedInAssetsList(_components, _assets);
133-
}
129+
_validateManagerParameters(_components, _extensions, _assets);
134130

135131
ISetToken setToken = _deploySet(
136132
_components,
@@ -182,14 +178,10 @@ contract DelegatedManagerFactory {
182178
external
183179
returns (address)
184180
{
185-
require(_extensions.length > 0, "Must have at least 1 extension");
186-
187-
if (_assets.length != 0) {
188-
_validateComponentsIncludedInAssetsList(_setToken.getComponents(), _assets);
189-
}
190-
191181
require(msg.sender == _setToken.manager(), "Must be manager");
192182

183+
_validateManagerParameters(_setToken.getComponents(), _extensions, _assets);
184+
193185
DelegatedManager manager = _deployManager(
194186
_setToken,
195187
_methodologist,
@@ -235,6 +227,8 @@ contract DelegatedManagerFactory {
235227
manager.updateOwnerFeeRecipient(_ownerFeeRecipient);
236228

237229
for (uint256 i = 0; i < _initializeTargets.length; i++) {
230+
// Because we validate uniqueness of _initializeTargets only one transaction can be sent to each module or extension during this
231+
// transaction. Due to this no modules/extension can be used for any SetToken transactions other than initializing these contracts
238232
_initializeTargets[i].functionCallWithValue(_initializeBytecode[i], 0);
239233
}
240234

@@ -244,7 +238,7 @@ contract DelegatedManagerFactory {
244238
_setToken.setManager(address(manager));
245239
}
246240

247-
initializeState[_setToken].manager.transferOwnership(initializeState[_setToken].owner);
241+
manager.transferOwnership(initializeState[_setToken].owner);
248242

249243
delete initializeState[_setToken];
250244

@@ -287,7 +281,6 @@ contract DelegatedManagerFactory {
287281
return ISetToken(setToken);
288282
}
289283

290-
291284
/**
292285
* Deploys a DelegatedManager
293286
*
@@ -353,6 +346,28 @@ contract DelegatedManagerFactory {
353346
});
354347
}
355348

349+
/**
350+
* Validates that all components currently held by the Set are on the asset allow list. Validate that the manager is
351+
* deployed with at least one extension in the PENDING state.
352+
*
353+
* @param _components List of addresses of components for initial/current Set positions
354+
* @param _extensions List of extensions authorized for the DelegateManager
355+
* @param _assets List of assets DelegateManager can trade. When empty, asset allow list is not enforced
356+
*/
357+
function _validateManagerParameters(
358+
address[] memory _components,
359+
address[] memory _extensions,
360+
address[] memory _assets
361+
)
362+
internal
363+
pure
364+
{
365+
require(_extensions.length > 0, "Must have at least 1 extension");
366+
367+
if (_assets.length != 0) {
368+
_validateComponentsIncludedInAssetsList(_components, _assets);
369+
}
370+
}
356371

357372
/**
358373
* Validates that all SetToken components are included in the assets whitelist. This prevents the

0 commit comments

Comments
 (0)