# Adding a Module

## What are Modules?

VISP 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. Modules are smart contracts appendable to SetTokens that enable functionality such as trading, margining, and issuance functionality.

**Module Initialization**

![](https://docs.google.com/drawings/u/0/d/sxKHR3sPvP6qMuV84RklLLg/image?w=386\&h=47\&rev=46\&ac=1\&parent=1jyfp7rmlGR_0gP5F1na_SDlyGMEZUlQBNs8qtCHJlYA)

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&#x20;

## Adding a Module to a Set:

The first method of adding a Module is directly inputting the desired module addresses on creation.&#x20;

```typescript
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 contract directly, providing the module's address.

```typescript
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.

```typescript
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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vingt-io.gitbook.io/vingt.io/technical-guide/visp-technical-foundation/index-token-manger-guide/adding-a-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
