# IOrchestrator\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/2a8a4c80ff4f24a59546d4e6126b81bc51228c94/src/orchestrator/interfaces/IOrchestrator_v1.sol)

**Inherits:** [IModuleManagerBase\_v1](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/imodulemanagerbase_v1.sol)

### Functions

#### init

Initialization function.

```solidity
function init(
    uint orchestratorId,
    address moduleFactory_,
    address[] calldata modules,
    IFundingManager_v1 fundingManager,
    IAuthorizer_v1 authorizer,
    IPaymentProcessor_v1 paymentProcessor,
    IGovernor_v1 governor
) external;
```

**Parameters**

| Name               | Type                   | Description                                                                                                                                                              |
| ------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `orchestratorId`   | `uint256`              | The id of the [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol).                            |
| `moduleFactory_`   | `address`              | The address of the module factory.                                                                                                                                       |
| `modules`          | `address[]`            | The addresses of the modules used in the [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol). |
| `fundingManager`   | `IFundingManager_v1`   | The address of the [{IFundingManager\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/ifundingmanager_v1.sol)module.           |
| `authorizer`       | `IAuthorizer_v1`       | The address of the [{IAuthorizer\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/authorizer/iauthorizer_v1.sol) module.                        |
| `paymentProcessor` | `IPaymentProcessor_v1` | The address of the [{IPaymentProcessor\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/payment-processor/ipaymentprocessor_v1.sol)module.     |
| `governor`         | `IGovernor_v1`         | The address of the governor contract.                                                                                                                                    |

#### initiateSetAuthorizerWithTimelock

Initiates replacing the current authorizer with `_authorizer` on a timelock.

*Only callable by authorized caller.*

```solidity
function initiateSetAuthorizerWithTimelock(IAuthorizer_v1 authorizer_)
    external;
```

**Parameters**

| Name          | Type             | Description                                                                                                                                           |
| ------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `authorizer_` | `IAuthorizer_v1` | The address of the new [{IAuthorizer\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/authorizer/iauthorizer_v1.sol) module. |

#### initiateSetFundingManagerWithTimelock

Initiates replaces the current funding manager with `fundingManager_` on a timelock.

*Only callable by authorized caller.*

```solidity
function initiateSetFundingManagerWithTimelock(
    IFundingManager_v1 fundingManager_
) external;
```

**Parameters**

| Name              | Type                 | Description                                                                                                                                                        |
| ----------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `fundingManager_` | `IFundingManager_v1` | The address of the new [{IFundingManager\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/ifundingmanager_v1.sol) module. |

#### initiateSetPaymentProcessorWithTimelock

Initiates replaces the current payment processor with `paymentProcessor_` on a timelock.

*Only callable by authorized caller.*

```solidity
function initiateSetPaymentProcessorWithTimelock(
    IPaymentProcessor_v1 paymentProcessor_
) external;
```

**Parameters**

| Name                | Type                   | Description                                                                                                                                                             |
| ------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `paymentProcessor_` | `IPaymentProcessor_v1` | The address of the new [{PaymentProcessor\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/payment-processor/ipaymentprocessor_v1.sol) module. |

#### cancelAuthorizerUpdate

Cancels the replacement of the current authorizer with `authorizer_`.

*Only callable by authorized caller.*

```solidity
function cancelAuthorizerUpdate(IAuthorizer_v1 authorizer_) external;
```

**Parameters**

| Name          | Type             | Description                                                                                                                                                                             |
| ------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `authorizer_` | `IAuthorizer_v1` | The address of the new [{IAuthorizer\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/authorizer/iauthorizer_v1.sol) module, for which the update is canceled. |

#### cancelFundingManagerUpdate

Cancels the replacement of the current funding manager with `fundingManager_`.

*Only callable by authorized caller.*

```solidity
function cancelFundingManagerUpdate(IFundingManager_v1 fundingManager_)
    external;
```

**Parameters**

| Name              | Type                 | Description                                                                                                                                                                                          |
| ----------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fundingManager_` | `IFundingManager_v1` | The address of the new [{IFundingManager\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/ifundingmanager_v1.sol) module, for which the update is canceled. |

#### cancelPaymentProcessorUpdate

Cancels the replacement of the current payment processor with `paymentProcessor_`.

*Only callable by authorized caller.*

```solidity
function cancelPaymentProcessorUpdate(IPaymentProcessor_v1 paymentProcessor_)
    external;
```

**Parameters**

| Name                | Type                   | Description                                                                                                                                                                                                |
| ------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `paymentProcessor_` | `IPaymentProcessor_v1` | The address of the new [{IPaymentProcessor\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/payment-processor/ipaymentprocessor_v1.sol)module, for which the update is canceled. |

#### executeSetAuthorizer

Executes replacing the current authorizer with `_authorizer`.

!!! IMPORTANT !!! When changing the Authorizer the current set of assigned addresses to Roles are lost. Make sure initial owners are set properly.

*Only callable by authorized caller.*

```solidity
function executeSetAuthorizer(IAuthorizer_v1 authorizer_) external;
```

**Parameters**

| Name          | Type             | Description                                                                                                                                           |
| ------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `authorizer_` | `IAuthorizer_v1` | The address of the new [{IAuthorizer\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/authorizer/iauthorizer_v1.sol) module. |

#### executeSetFundingManager

Executes replaces the current funding manager with `fundingManager_`.

!!! IMPORTANT !!! When changing the FundingManager the current funds still contained in the module might not be retrievable. Make sure to clean the FundingManager properly beforehand.

*Only callable by authorized caller.*

```solidity
function executeSetFundingManager(IFundingManager_v1 fundingManager_)
    external;
```

**Parameters**

| Name              | Type                 | Description                                                                                                                                                        |
| ----------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `fundingManager_` | `IFundingManager_v1` | The address of the new [{IFundingManager\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/ifundingmanager_v1.sol) module. |

#### executeSetPaymentProcessor

Executes replaces the current payment processor with `paymentProcessor_`.

!!! IMPORTANT !!! When changing the PaymentProcessor the current ongoing payment orders are lost. Make sure to resolve those payments properly beforehand.

*Only callable by authorized caller.*

```solidity
function executeSetPaymentProcessor(IPaymentProcessor_v1 paymentProcessor_)
    external;
```

**Parameters**

| Name                | Type                   | Description                                                                                                                                                              |
| ------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `paymentProcessor_` | `IPaymentProcessor_v1` | The address of the new [{IPaymentProcessor\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/payment-processor/ipaymentprocessor_v1.sol) module. |

#### initiateAddModuleWithTimelock

Initiates the adding of a module to the [{Orchestrator\_v](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol)[1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol) on a timelock.

*Only callable by authorized address.*

*Fails of adding module exeeds max modules limit.*

*Fails if address invalid or address already added as module.*

```solidity
function initiateAddModuleWithTimelock(address module) external;
```

**Parameters**

| Name     | Type      | Description                |
| -------- | --------- | -------------------------- |
| `module` | `address` | The module address to add. |

#### initiateRemoveModuleWithTimelock

Initiate the removal of a module from the[ {Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol) on a timelock.

*Reverts if module to be removed is the current authorizer/fundingManager/paymentProcessor. The functions specific to updating these 3 module categories should be used instead.*

*Only callable by authorized address.*

*Fails if address not added as module.*

```solidity
function initiateRemoveModuleWithTimelock(address module) external;
```

**Parameters**

| Name     | Type      | Description                   |
| -------- | --------- | ----------------------------- |
| `module` | `address` | The module address to remove. |

#### executeAddModule

Adds address `module` as module.

*Only callable by authorized address.*

*Fails if adding of module has not been initiated.*

*Fails if timelock has not been expired yet.*

```solidity
function executeAddModule(address module) external;
```

**Parameters**

| Name     | Type      | Description                |
| -------- | --------- | -------------------------- |
| `module` | `address` | The module address to add. |

#### executeRemoveModule

Removes address `module` as module.

*Only callable by authorized address.*

*Fails if removing of module has not been initiated.*

*Fails if timelock has not been expired yet.*

```solidity
function executeRemoveModule(address module) external;
```

**Parameters**

| Name     | Type      | Description                   |
| -------- | --------- | ----------------------------- |
| `module` | `address` | The module address to remove. |

#### cancelModuleUpdate

Cancels an initiated update for a module. Can be adding or removing a module from the [{Orchestrator\_v1](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol)[}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol).

*Only callable by authorized address.*

*Fails if module update has not been initiated.*

```solidity
function cancelModuleUpdate(address module) external;
```

**Parameters**

| Name     | Type      | Description                   |
| -------- | --------- | ----------------------------- |
| `module` | `address` | The module address to remove. |

#### orchestratorId

Returns the [{Orchestrator\_v1](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol)[}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol)'s id.

*Unique id set by the {OrchestratorFactory\_v1} during initialization.*

```solidity
function orchestratorId() external view returns (uint);
```

**Returns**

| Name     | Type      | Description                                                                                                                              |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `uint256` | The [{Orchestrator\_v1](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol)}'s id. |

#### fundingManager

The [{IFundingManager\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/ifundingmanager_v1.sol) implementation used to hold and distribute Funds.

```solidity
function fundingManager() external view returns (IFundingManager_v1);
```

**Returns**

| Name     | Type                 | Description                                                                                                                                             |
| -------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `IFundingManager_v1` | The [{IFundingManager\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/ifundingmanager_v1.sol)implementation. |

#### authorizer

The [{IAuthorizer\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/authorizer/iauthorizer_v1.sol)implementation used to authorize addresses.

```solidity
function authorizer() external view returns (IAuthorizer_v1);
```

**Returns**

| Name     | Type             | Description                                                                                                                                |
| -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `<none>` | `IAuthorizer_v1` | The [{IAuthorizer\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/authorizer/iauthorizer_v1.sol)implementation. |

#### paymentProcessor

The [{IPaymentProcessor\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/payment-processor/ipaymentprocessor_v1.sol) implementation used to process module payments.

```solidity
function paymentProcessor() external view returns (IPaymentProcessor_v1);
```

**Returns**

| Name     | Type                   | Description                                                                                                                                                   |
| -------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `IPaymentProcessor_v1` | The [{IPaymentProcessor\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/payment-processor/ipaymentprocessor_v1.sol)implementation. |

#### governor

The [{IGovernor\_v1}](https://docs.inverter.network/contracts/technical-reference/external/governance/interfaces/igovernor_v1.sol) implementation used for protocol level interactions.

```solidity
function governor() external view returns (IGovernor_v1);
```

**Returns**

| Name     | Type           | Description                                                                                                                                        |
| -------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `IGovernor_v1` | The [{IGovernor\_v1} ](https://docs.inverter.network/contracts/technical-reference/external/governance/interfaces/igovernor_v1.sol)implementation. |

### Events

#### AuthorizerUpdated

Authorizer updated to new address.

```solidity
event AuthorizerUpdated(address indexed _address);
```

**Parameters**

| Name       | Type      | Description      |
| ---------- | --------- | ---------------- |
| `_address` | `address` | The new address. |

#### FundingManagerUpdated

FundingManager updated to new address.

```solidity
event FundingManagerUpdated(address indexed _address);
```

**Parameters**

| Name       | Type      | Description      |
| ---------- | --------- | ---------------- |
| `_address` | `address` | The new address. |

#### PaymentProcessorUpdated

PaymentProcessor updated to new address.

```solidity
event PaymentProcessorUpdated(address indexed _address);
```

**Parameters**

| Name       | Type      | Description      |
| ---------- | --------- | ---------------- |
| `_address` | `address` | The new address. |

#### OrchestratorInitialized

[{Orchestrator\_v](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol)1} has been initialized with the corresponding modules.

```solidity
event OrchestratorInitialized(
    uint indexed orchestratorId_,
    address fundingManager,
    address authorizer,
    address paymentProcessor,
    address[] modules,
    address governor
);
```

**Parameters**

| Name               | Type        | Description                                                                                                                                                                                  |
| ------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `orchestratorId_`  | `uint256`   | The id of the [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol).                                                |
| `fundingManager`   | `address`   | The address of the [{IFundingManager\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/ifundingmanager_v1.sol) module.                               |
| `authorizer`       | `address`   | The address of the [{IAuthorizer\_v1}](https://docs.inverter.network/contracts/technical-reference/modules/authorizer/iauthorizer_v1.sol) module.                                            |
| `paymentProcessor` | `address`   | The address of the [{IPaymentProcessor\_v1} ](https://docs.inverter.network/contracts/technical-reference/modules/payment-processor/ipaymentprocessor_v1.sol)module.                         |
| `modules`          | `address[]` | The addresses of the other modules used in the [{Orchestrator\_v1}](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol).               |
| `governor`         | `address`   | The address of the [{Governor\_v1}](https://docs.inverter.network/contracts/technical-reference/external/governance/governor_v1.sol) contract used to reference protocol level interactions. |

### Errors

#### Orchestrator\_\_CallerNotAuthorized

Function is only callable by authorized caller.

```solidity
error Orchestrator__CallerNotAuthorized(bytes32 role, address caller);
```

**Parameters**

| Name     | Type      | Description             |
| -------- | --------- | ----------------------- |
| `role`   | `bytes32` | The role of the caller. |
| `caller` | `address` | The caller address.     |

#### Orchestrator\_\_InvalidModuleType

The given module is not used in the [{Orchestrator\_v1](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol)[}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol).

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

**Parameters**

| Name     | Type      | Description         |
| -------- | --------- | ------------------- |
| `module` | `address` | The module address. |

#### Orchestrator\_\_MismatchedTokenForFundingManager

The token of the new funding manager is not the same as the current funding manager.

```solidity
error Orchestrator__MismatchedTokenForFundingManager(
    address currentToken, address newToken
);
```

**Parameters**

| Name           | Type      | Description        |
| -------------- | --------- | ------------------ |
| `currentToken` | `address` | The current token. |
| `newToken`     | `address` | The new token.     |

#### Orchestrator\_\_DependencyInjection\_\_ModuleNotUsedInOrchestrator

The given module is not used in the [{Orchestrator\_v1](https://docs.inverter.network/contracts/technical-reference/orchestrator/interfaces/iorchestrator_v1.sol)[}](https://docs.inverter.network/contracts/technical-reference/orchestrator/orchestrator_v1.sol).

```solidity
error Orchestrator__DependencyInjection__ModuleNotUsedInOrchestrator();
```

#### Orchestrator\_\_InvalidRemovalOfAuthorizer

The Authorizer can not be removed through this function.

```solidity
error Orchestrator__InvalidRemovalOfAuthorizer();
```

#### Orchestrator\_\_InvalidRemovalOfFundingManager

The FundingManager can not be removed through this function.

```solidity
error Orchestrator__InvalidRemovalOfFundingManager();
```

#### Orchestrator\_\_InvalidRemovalOfPaymentProcessor

The PaymentProcessor can not be removed through this function.

```solidity
error Orchestrator__InvalidRemovalOfPaymentProcessor();
```
