AaveModule7579

Integration into lending protocol.

Core Functionalities

  • Asset Borrowing:

    • borrowAaveAction: Initiates borrowing of a specified amount of tokens from the Aave protocol, facilitating access to liquidity.

  • Asset Supplying:

    • supplyAaveAction: Enables supplying a specified amount of tokens to the Aave protocol, contributing to the liquidity pool.

  • Asset Repayment:

    • repayAaveAction: Provides the ability to repay borrowed tokens to the Aave protocol, managing debt obligations.

  • Asset Withdrawal:

    • withdrawAaveAction: Allows for the withdrawal of supplied tokens from the Aave protocol, reclaiming assets.

  • Emergency Repayment:

    • emergencyRepayAave: Facilitates emergency repayment of borrowed tokens using Flash Loan, ensuring safety in critical scenarios.

Problem

If your Health Factor is too low, then your positions may be liquidated. This will result in the loss of part of the deposited funds.

Solution

Automation Strategy that enables for the consistent health factor monitoring and execution of repayment of the position via flashloan mitigating the liquidation penalty risk. The rest of the assets after repayment will be supplied back.

AaveModule7579 can make an emergency repayment. The module takes a flash loan and sends the borrowed funds to the account. Then account abstraction repays borrowed token and withdraws supplied token to make swap from supply to borrow token. After the swap, the borrowed token is repaid to the Pool. After calling emergency repayment, the health factor increases.

Users can utilize the module by installing it on AA and creating the workflow with health factor checker and emergency repayment action:

...
executeData = abi.encodeWithSelector(
        moduleAave7579.emergencyRepaymentAaveAction.selector,
        wethAddress,
        usdcAddress,
        poolFee,
        deviationThresholdE18
);
...

Example

The user supplied Ether into the Aave protocol, then borrowed USDC. If the price of Ether decreases, the Health Factor decreases as well. To avoid liquidation of the position, one can call emergencyRepayment to restore Health Factor to target.

Last updated