Bridge and invest in Aave

This example involves two tasks. The goal of the first task is to bridge tokens from one chain to another, and the goal of the second task is to invest in Aave the tokens received on the destination chain.

To achieve this, the bridge must complete before the investment begins. Mimic enables this kind of task concatenation by allowing one task to emit a custom event that triggers other tasks in response.

The first task should include something as follows:

SwapBuilder.addEvent('0xCustomId', '0xDataForTheOtherTask')

And the configuration for the second task should look like:

const trigger = {
  type: TriggerType.Event
  chainId: Chains.Optimism,
  contract: MIMIC_PROTOCOL_SETTLER,
  topics: [
    [INTENT_EXECUTED_TOPIC],
    [encode('0xUser')],
    ['0xCustomId'],
  ],
}

await client.configs.signAndCreate({ ..., trigger })

With this configuration, the invest task will automatically execute every time an intent from user 0xUser emits an event containing 0xCustomId on Optimism.

1. Bridge

Task

Manifest

2. Invest

Task

Manifest

Backend

The ABIs used for this example can be downloaded below:

45KB
Open
4KB
Open
32KB
Open

Last updated