AssemblyExecutor.sol

The primary access point for executing bundle of Defi transactions is the AssemblyExecutor. It's important to emphasize that the AssemblyExecutor doesn't maintain any state. Through executeAssembly() function, this contracts calls bundle of Defi transactions in a for loop.

Within this contract, a crucial operation involves the identification of the first Defi transaction as a special "flash loan Defi transaction" type. These Defi transaction are always handled as the initial step in the execution process and is parsed separately, execution will go to _executeDefiTxFromFL(). This contract always operates through a DSProxy (Smart Account).

Contract Information

  • SPDX-License-Identifier: MIT

  • Solidity Version: 0.8.10

State Variables

  • BaseRegistry public constant registry: A public constant state variable representing an instance of the BaseRegistry contract. It's used to retrieve addresses for DeFi transactions.

Public Functions

  1. executeAssembly(Assembly calldata _currAssembly)

    • Visibility: Public

    • Parameters:

      • _currAssembly: An instance of the Assembly struct containing the assembly code and related data to be executed.

    This function serves as the main entry point for executing assembly code. It takes an Assembly struct as input and executes DeFi transactions defined in the assembly. It also logs the assembly name.

  2. _executeDefiTxFromFL(Assembly calldata _currAssembly, bytes32 _flAmount)

    • Visibility: Public

    • Parameters:

      • _currAssembly: An instance of the Assembly struct containing the assembly code and related data to be executed.

      • _flAmount: A bytes32 value representing the result of the flash loan DeFi transaction.

    • Payable: This function is marked as payable, indicating that it can receive Ether along with the function call.

    This function is a callback used by flash loan DeFi transactions. It processes the results of flash loan DeFi transactions and calls other DeFi transactions as needed. The flash loan DeFi transaction must be the first one in the assembly.

  3. _executeDefiTx(Assembly memory _currAssembly, uint256 _index, bytes32[] memory _returnValues)

    • Visibility: Internal

    • Parameters:

      • _currAssembly: An instance of the Assembly struct containing the assembly code and related data to be executed.

      • _index: The index of the DeFi transaction to be executed.

      • _returnValues: An array of bytes32 values representing return values from previous DeFi transactions.

    This internal function gets the DeFi transaction address and executes it based on the provided assembly data, index, and return values.

  4. _parseFLAndExecute(Assembly memory _currAssembly, address _flActionAddr, bytes32[] memory _returnValues)

    • Visibility: Internal

    • Parameters:

      • _currAssembly: An instance of the Assembly struct containing the assembly code and related data to be executed.

      • _flActionAddr: The address of the flash loan DeFi transaction.

      • _returnValues: An array of bytes32 values representing return values from previous DeFi transactions.

    This internal function prepares and executes a flash loan DeFi transaction. It encodes the assembly data and passes it to the flash loan DeFi transaction for execution.

  5. isFL(address _defiTxAddr)

    • Visibility: Internal

    • Parameters:

      • _defiTxAddr: The address of a DeFi transaction.

    This internal function checks if the specified DeFi transaction is a flash loan DeFi transaction by examining its type.

Last updated