# IFrictionlessModularCompliance

[Git Source](https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/blob/85f6dfa54ce0787eb1b1345bd6726f84fe766c54/contracts/interface/IFrictionlessModularCompliance.sol)

**Inherits:** IModularCompliance

**Author:** DEFYCA Labs S.à.r.l

Copyright © 2023 DEFYCA Labs S.à.r.l Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DEFYCA LABS S.à.r.l BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The IFrictionlessModularCompliance is responsible for the compliant transfer of the various Tokens in the Frictionless protocol.

## Functions

### init

*Initializes the modular compliance, sets the maximum allowable modules per token and adds the modules provided*

```solidity
function init(address[] calldata modules_, uint256 maxModulesCount_) external;
```

**Parameters**

| Name               | Type        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `modules_`         | `address[]` | the array of module addresses to be added                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `maxModulesCount_` | `uint256`   | maximum number of allowable modules which can be bound. throws `FrictionlessModularComplianceMaxModuleCountReached` if the maximum amount of modules has been reached as per the maxModulesCount throws `FrictionlessModularComplianceModuleIsAlreadyBound` if the module is already bound throws `FrictionlessIsZeroAddress` if the module address is a zero address throws `FrictionlessModularComplianceZeroMaxModulesCount` if an attempt to set the maximum number of allowable modules to zero is made in `updateMaxModulesCount` emits ModulesAdded upon sucessful addition emits `MaxModulesCountUpdated` upon successful update of the maximum modules count. |

### updateMaxModulesCount

*Set the maximum number of allowable modules which can be bound.*

```solidity
function updateMaxModulesCount(uint256 newMaxModulesCount_) external;
```

**Parameters**

| Name                  | Type      | Description                                                                                                                                                                                                                                                                                                   |
| --------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `newMaxModulesCount_` | `uint256` | maximum number of allowable modules which can be bound. throws `FrictionlessModularComplianceZeroMaxModulesCount` if an attempt to set the maximum number of allowable modules to zero is made in `updateMaxModulesCount` emits `MaxModulesCountUpdated` upon successful update of the maximum modules count. |

### addModules

*Adds modules based on the array of module addresses provided*

```solidity
function addModules(address[] calldata modulesToAdd_) external;
```

**Parameters**

| Name            | Type        | Description                                                                                                                                                                                                                                                                                                                                                                                        |
| --------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `modulesToAdd_` | `address[]` | the array of module addresses to be added throws `FrictionlessModularComplianceMaxModuleCountReached` if the maximum amount of modules has been reached as per the maxModulesCount throws `FrictionlessModularComplianceModuleIsAlreadyBound` if the module is already bound throws `FrictionlessIsZeroAddress` if the module address is a zero address emits ModulesAdded upon sucessful addition |

### removeModules

*Removes modules based on the array of module addresses provided*

```solidity
function removeModules(address[] calldata modulesToRemove_) external;
```

**Parameters**

| Name               | Type        | Description                                                                                                                                                                                           |
| ------------------ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `modulesToRemove_` | `address[]` | the array of module addresses to be removed throws `FrictionlessModularComplianceModuleDoesNotExist` if module for the given address is not already bound emits ModulesRemoved upon sucessful removal |

### maxModulesCount

*Returns the maximum number of allowable modules which can be bound.*

```solidity
function maxModulesCount() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                             |
| -------- | --------- | ------------------------------------------------------- |
| `<none>` | `uint256` | maximum number of allowable modules which can be bound. |

## Events

### MaxModulesCountUpdated

*Emitted during `updateMaxModulesCount` to inform of new modules max count updates*

```solidity
event MaxModulesCountUpdated(uint256 newMaxModulesCount, uint256 oldMaxModulesCount);
```

### ModulesAdded

*Emitted during `addModules` to inform of new modules added*

```solidity
event ModulesAdded(address[] modules);
```

### ModulesRemoved

*Emitted during `removeModules` to inform of modules removed*

```solidity
event ModulesRemoved(address[] modules);
```

## Errors

### FrictionlessIsZeroAddress

*thrown if specific address is zero.*

```solidity
error FrictionlessIsZeroAddress(string);
```

### FrictionlessModularComplianceZeroMaxModulesCount

*thrown if an attempt to set the maximum number of allowable modules to zero is made in `updateMaxModulesCount`*

```solidity
error FrictionlessModularComplianceZeroMaxModulesCount();
```

### FrictionlessModularComplianceModuleIsAlreadyBound

*thrown if an attempt to add an already existing module during `addModules`*

```solidity
error FrictionlessModularComplianceModuleIsAlreadyBound(address module);
```

### FrictionlessModularComplianceModuleDoesNotExist

*thrown if module for the given address is not already bound by the modifier `onlyExistingModule`*

```solidity
error FrictionlessModularComplianceModuleDoesNotExist(address module);
```

### FrictionlessModularComplianceMaxModuleCountReached

*thrown if an attempt to add more than the allowable modules during `addModules`*

```solidity
error FrictionlessModularComplianceMaxModuleCountReached();
```

### FrictionlessModularComplianceCallerNotATokenOrOwner

*thrown during `bindToken` or `unBindToken` if the caller is not the owner or the bound token address*

```solidity
error FrictionlessModularComplianceCallerNotATokenOrOwner(address caller);
```

### FrictionlessModularComplianceCallerNotAToken

*thrown if the the msg.sender is not the bound token address during modifier `onlyToken`*

```solidity
error FrictionlessModularComplianceCallerNotAToken(address caller);
```
