Adding a Module

What are Modules?

Set V2 employs a modular architecture consisting of a collection of modular smart contracts where additional components (e.g. modules, factories) can be seamlessly integrated or removed. This architecture is extensible, allowing new features and integrations to be easily added. Detailed system diagram here.

Modules are smart contracts appendable to SetTokens that enable functionality such as trading, margining, and issuance functionality. Modules serve as the entry point for Module-related interactions and can hold common state across SetTokens. Some modules include BasicIssuanceModule (allows minting/redeeming of Sets with Default Positions), TradeModule (allows DEX trading), WrapModule (allows components to be wrapped on external protocols such as Compound and AAVE), and StreamingFeeModule (allows managers to charge subscription fees).

Module Initialization

  1. Module Addition: A module can be added via SetToken creation through the Factory or can be added by the manager after-the-fact.

  2. Initialized: To initialize the module, the manager needs to call initialize on the module. Once called, the module is considered initialized.

Adding a Module to a Set:

Managers of the SetToken can freely add modules and enable new functionality.

The first method of adding a Module is directly inputting the desired module addresses on creation. See previous section on how to create a Set.

function create(
address[] memory _components,
int256[] memory _units,
address[] memory _modules,
address _manager,
string memory _name,
string memory _symbol
)
external
returns (address)

Post creation, managers can add or remove module functionality by calling the addModule function on the SetToken

function addModule(address _module) external

Adding the module to the SetToken will put the module in pending state. To enable the functionality of the module, managers must also initialize the SetToken in the Module.

Initializing the SetToken on the Module:

To complete the process of adding a module, the manager must call initialize on the Module. The parameters required will vary depending on the module. This will put the SetToken in initialized state, and will allow managers to call functions on the module.

function initialize(...) external

‚Äč