Bridge and invest in Aave

This example involves two functions. The goal of the first function is to bridge tokens from one chain to another, and the goal of the second function 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 function concatenation by allowing one function to emit a custom event that triggers other functions in response.

The first function should include something as follows:

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

And the trigger for the second function should look like:

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

await client.triggers.signAndCreate({ ..., config })

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

1. Bridge

Function

Github linkarrow-up-right

Manifest

Github linkarrow-up-right

2. Invest

Function

Github linkarrow-up-right

Manifest

Github linkarrow-up-right

Backend

Github linkarrow-up-right

The ABIs used for this example can be downloaded below:

file-download
45KB
file-download
4KB
file-download
32KB

Last updated