Skip to content

Orchestrator

Rahul Saxena edited this page Oct 26, 2023 · 10 revisions

File: Orchestrator.sol

Things to know

  1. An orchestrator contract, orchestrates the logic, interactions and fundings between different inverter modules to run your customized workflows.
  2. An orchestrator is composed of a funding mechanism (FundingManager.sol) and a set of modules (ModuleManager.sol).
  3. Each orchestrator has a unique ID, assigned to it by the OrchestratorFactory.
  4. The token being accepted for funding cannot be changed and is set during initialization.
  5. Authorizations are done via an IAuthorizer instance. This is also static and cannot be changed, once set.
  6. Payments, which will be initiated by modules, are processed via a non-changeable {IPaymentProcessor} instance.

Modifier(s)

1. onlyAuthorized

modifier onlyAuthorized()
  1. Modifier to guarantee function is only callable by authorized address.

2. onlyAuthorizedOrManager

modifier onlyAuthorizedOrManager()
  1. Modifier to guarantee function is only callable by authorized addresses.
  2. Uses the IAuthorizer module to check authorized addresses.

NOTE: In the future, the Ownable import may be removed and we can rely on IAuthorizer to validate owners.

View Function(s)

1. version

function version() external pure returns (string memory)

Returns the version of the proposal instance.

Return Data:

  1. string: Returned string represents the current version of the Orchestrator.

NOTE: Default Orchestrator returns a hardcoded 1 for this function.

2. manager

function manager() public view override (OwnableUpgradeable, IOrchestrator) returns (address)

Returns the manager of the Proposal.

Return data:

  1. address: Address of the manager of the Orchestrator. Currently returns the owner only.

3. owner

function owner() external view returns (address);

Returns the address of the owner of the orchestrator.

Return Data

  1. address: Address of the owner of the Orchestrator.

4. orchestratorId

function orchestratorId() external view returns (unit);

Returns the orchestrator's id. This is a unique id set by the {OrchestratorFactory} during initialization.

Return Data

  1. uint: ID of the current orchestrator contract.

5. fundingManger

function fundingManager() external view returns (IFundingManager);

The {IFundingManager} implementation used to hold and distribute funds.

Return Data

  1. IFundingManger: IFundingManger instance of the orchestrator's funding manager.

6. authorizer

function authorizer() external view returns (IAuthorizer);

The {IAuthorizer} implementation used to authorize addresses.

Return Data

  1. IAuthorizer: IAuthorizer instance of the orchestrator's authorizer.

7. paymentProcessor

function paymentProcessor() external view returns (IPaymentProcessor);

The {IPaymentProcessor} implementation used to process module payments.

Return Data

  1. IPaymentProcessor: IPaymentProcessor instance of the orchestrator's payment processor.

8. findModuleAddressInOrchestrator

function findModuleAddressInOrchestrator(string calldata moduleName)
        external
        view
        returns (address);

Finds the address of a given module using it's name in an orchestrator. If not found, function reverts.

Parameters

  1. string moduleName: Name of the module that needs to be searched

Return Data

  1. address: address of the module passed to the function.

9. verifyAddressIsPaymentProcessor

function verifyAddressIsPaymentProcessor(address paymentProcessorAddress)
        external
        view
        returns (bool);

Verify whether the given address is a payment processor. This is done by typecasting the address passed to the function in the relevant module and then calling a view function from that contract to see if the call passes or not.

Parameters

  1. address paymentProcessorAddress: The address which is checked for being a paymentProcessor

Return Data

  1. bool: bool that determines whether the address passed to the function was a paymentProcessor or not.

10. verifyAddressIsRecurringPaymentManager

function verifyAddressIsRecurringPaymentManager(
        address recurringPaymentManager
    ) external view returns (bool);

Verify whether the given address is the recurring payment manager. This is done by typecasting the address passed to the function in the relevant module and then calling a view function from that contract to see if the call passes or not.

Parameters

  1. address recurringPaymentManager: The address which is checked for being a recurringPaymentManager

Return Data

  1. bool: bool that determines whether the address passed to the function was a recurringPaymentManager or not.

11. verifyAddressIsMilestoneManager

function verifyAddressIsMilestoneManager(address milestoneManagerAddress)
        external
        view
        returns (bool);

Verify whether the given address is the milestone manager module. This is done by typecasting the address passed to the function in the relevant module and then calling a view function from that contract to see if the call passes or not.

Parameters

  1. address milestoneManagerAddress: The address which is checked for being a milestoneManager

Return Data

  1. bool: bool that determines whether the address passed to the function was a milestoneManager or not.

12. verifyAddressIsFundingManager

function verifyAddressIsFundingManager(address fundingManagerAddress)
        external
        view
        returns (bool);

Verify whether the given address is a funding manager. This is done by typecasting the address passed to the function in the relevant module and then calling a view function from that contract to see if the call passes or not.

Parameters

  1. address fundingManagerAddress: The address which is checked for being a fundingManager

Return Data

  1. bool: bool that determines whether the address passed to the function was a fundingManager or not.

13. verifyAddressIsAuthorizerModule

function verifyAddressIsAuthorizerModule(address authModule)
        external
        view
        returns (bool);

Verify whether the given address is an IAuthorizer module. This is done by typecasting the address passed to the function in the relevant module and then calling a view function from that contract to see if the call passes or not.

Parameters

  1. address authModule: The address which is checked for being a authModule

Return Data

  1. bool: bool that determines whether the address passed to the function was an authModule or not.

Write Function(s)

1. init

function init(
        uint orchestratorId,
        address owner,
        IERC20 token,
        address[] calldata modules,
        IFundingManager fundingManager,
        IAuthorizer authorizer,
        IPaymentProcessor paymentProcessor
    ) external;
  1. This function is used to initialize an orchestrator including the transfer of ownership to owner, initialization of Module Manager, and setting the values for orchestratorId and the orchestrator token.
  2. The compulsory modules are initialized and added to the orchestrator contract, which includes the Funding Manager, Authorizer, and Payment Processor.
  3. The optional modules to be added to the Orchestrator are passed in the array modules and added to the orchestrator.

Parameters

  1. uint orchestratorId_ -> An unsigned integer that will be used as the ID of the orchestrator being created
  2. address owner_ -> Address of the owner of the orchestrator
  3. IERC20 token_ -> IERC20 instance of the token which will be used for funding
  4. address[] modules -> Array of addresses of modules that will be used in the orchestrator being created
  5. IFundingManager fundingManger_ -> IFundingManager instance of the fundingManager modules which will be used to handle all funding related operations in the orchestrator contract.
  6. IAuthorizer authorizer_ -> IAuthorizer instance of the authorizer module which will be used for access control in the orchestrator being created
  7. IPaymentProcessor paymentProcessor_ -> IPaymentProcessor instance of the payment processor module which will be used to handle all aspects of payments in the orchestrator being created.

2. executeTx

function executeTx(address target, bytes memory data)
        external
        returns (bytes memory);

Executes a call on target target with call data data. This function is only callable by authorized caller and will revert if the transaction fails.

Parameters

  1. address target -> The address to call
  2. bytes data -> Calldata that will be used in the call

Return Data

  1. bytes -> The return data of the call made in the function executeTx.

3. setAuthorizer

function setAuthorizer(IAuthorizer authorizer_) external;

Replaces the current authorizer with _authorizer. Only callable by authorized caller.

Parameters

  1. IAuthorizer authorizer_: The IAuthorizer instance of the new authorizer module

4. setFundingManager

function setFundingManager(IFundingManager fundingManager_) external;

Replaces the current funding manager with fundingManager_. Only callable by authorized caller.

Parameters

  1. IFundingManager fundingManager_: The IFundingManager instance of the new funding manager module.

5. setPaymentProcessor

function setPaymentProcessor(IPaymentProcessor paymentProcessor_)
        external;

Replaces the current payment processor with paymentProcessor_. Only callable by authorized caller.

Parameters

  1. IPaymentProcessor paymentProcessor_: The IPaymentProcessor instance of the new payment processor module.
Clone this wiki locally