Recipe Executor

Recipe Executor is the main entry point of execution of recipes; it can be called directly (when a user manually executes a set of actions) or is called through StrategyExecutor when the Recipe is part of a strategy. The contract checks if the first action is a special flash loan action type and adequately sets up the code to execute the flash loan.

Recipe Executor is always called through a user's wallet (Safe/DSProxy) and can't hold any state. executeRecipe() is used when the recipe is executed manually and executeRecipeFromStrategy() is called by StrategyExecutor when it's part of a strategy.

/// @dev List of actions grouped as a recipe
/// @param name Name of the recipe useful for logging what recipe is executing
/// @param callData Array of calldata inputs to each action
/// @param subData Used only as part of strategy, subData injected from StrategySub.subData
/// @param actionIds Array of identifiers for actions - bytes4(keccak256(ActionName))
/// @param paramMapping Describes how inputs to functions are piped from return/subbed values
    struct Recipe {
        string name;
        bytes[] callData;
        bytes32[] subData;
        bytes4[] actionIds;
        uint8[][] paramMapping;
    }

When the recipe is called through the StrategyExecutor there are additional checks if the triggers are executed correctly. All triggers must return true for the execution to continue. After that, from the Strategy data a new Recipe object is created and goes through the same flow as a manually executed recipe.

Triggers can be changeable! If Trigger returns true to a isChangeable() call after the trigger is checked, the sub-data of that trigger can be updated. Useful for strategies, for example, where on every five days some recipe happens, trigger adds five days from the last execution as the next trigger date.

Recipe Executor also handles a particular type of actions Flash loan actions. Flash loan actions are always sent first, and they callback the Recipe Executor through the _executeActionsFromFL function.

Below is the interface of the contract:

Last updated

Was this helpful?