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.

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, providing values required by the module. Once the transaction has successfully mined

Adding a Module to a Set:

The first method of adding a Module is directly inputting the desired module addresses on creation. See guide on Creating a Set for details.

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

Post creation, managers can add or remove module functionality by calling the addModule function on the SetToken contract directly, providing the module's address.

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 by calling initialize on the module contract itself.

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. For example, to complete initialization of the StreamingFeeModule, the manager must provide information such as the feeRecipient, and streamingFeePercentage.

This will put the SetToken in initialized state, and will allow managers to call functions on the module.

function initialize(...) external

Module Hooks:

In addition to required initialization parameters, modules can be initialized with custom hooks in the form of stand alone smart contracts. These hooks allow the user to input customized logic when the module interaction is called. Some sample hooks include:

  • A hook that only allows a white listed address to issue your Set and would revert otherwise

  • A hook that adds a supply or market cap ceiling to your Set and would revert otherwise

Last updated