Execute Operation

The executeWithMinAmounts function must be used to perform a Routines operation. This function is public as it can be called by the host or anyone else with an interest in doing so, and requires that the linked Extension is active:

function executeWithMinAmounts(bool earnByAmounts, uint256[] memory minAmounts) public activeExtensionOnly returns(bool executed, uint256[] memory outputAmounts)

The function uses the earnByAmounts parameter, which is a boolean value representing if the executor's reward is calculated and transferred before (true) or after (false) a swap operation. In the first case, the reward is expressed as input token; in the second, as output token.

The second input parameter is the minAmounts[] that can be used to set the slippage of the Operations. To each position in minAmounts[]corresponds an Operation.

The execute function requests from the Extension the tokens needed to perform the operation(s) by calling, internally, the _ensureExecute function:

try IFixedInflationExtension(extension).receiveTokens(_tokensToTransfer, _tokenAmounts, _tokenMintAmounts)

At this moment, the extension receiveTokens function is used (see the Routines Extension section for more details).

If the contract does not successfully receive the tokens from the Extension, the operation is not performed and the Extension is automatically deactivated by calling the deactivationByFailure function on the Extension contract. This means that if the Extension is not subsequently reactivated by the host, no more operations can be performed in the contract.

If the contract does successfully receive the tokens from the Extension, the Entry lastBlock is updated (set as the execution block) and performs the operation.

Instead, the execute function can be used to perform a Routines operation without setting the slippage for the transaction.

function execute(bool earnByAmounts) public activeExtensionOnly returns(bool executed)

The operation of the function is the same as executeWithMinAmounts. However, the function uses, as input, only the earnByAmounts parameter.

Last updated