hammer-crashAave TriggerX Automation System

Automated collateral protection for Aave V3 positions using the TriggerX Automation SDK and Safe Wallet. This system continuously monitors your health factor and automatically tops up collateral whenever it drops below your specified threshold, protecting your position from liquidation 24/7.

Overview

The Aave TriggerX Automation System enables:

  • Real-time monitoring of your Aave V3 health factor

  • Automatic collateral top-ups when HF ≤ threshold

  • Secure execution via Safe Wallet

  • Decentralized automation using TriggerX

  • Public health-monitoring API (locally served, exposed via ngrok)

This system is ideal for users who want non-custodial, programmable protection for leveraged Aave strategies.

Prerequisites

Before getting started, ensure you have:

Software

  • Node.js v16+

  • npm or yarn

  • ngrok (for exposing local API)

Wallet Requirements

Project Structure


How the System Works

  1. Health Monitoring API Runs locally and exposes:

  2. ngrok exposes the local API publicly so TriggerX can call it.

  3. TriggerX Job polls the API every ~90 seconds.

  4. Condition Logic If healthFactor ≤ thresholdTriggerX executes the job.

  5. Safe Wallet Execution TriggerX triggers a Safe transaction that:

    • Approves WETH (if not approved)

    • Supplies WETH to the Aave Pool

  6. Aave Position Strengthened Health Factor increases, reducing liquidation risk.

Quick Start

1. Install the Repository

2. Configure Environment Variables

Create a .env file:

3. Start the Health Monitoring API

This launches an API server at http://localhost:3000, which TriggerX uses to fetch your health factor.

4. Expose API Using ngrok

Copy the tunnel URL and update .env:

5. Create Safe Wallet

Save the generated address in .env under SAFE_WALLET_ADDRESS.

6. Fund the Safe Wallet

Send:

  • WETH → for collateral supply

  • ETH → for gas

Example:

  • 0.1 WETH

  • 0.01 ETH

7. Approve WETH for Aave

8. Deploy TriggerX Automation Job

Your Aave position is now monitored and automatically protected by TriggerX.

Customization Guide

1. Using Different Chains

Update .env:

Ethereum Mainnet:

Arbitrum:

Update Aave V3 contract addresses accordingly: → https://docs.aave.com/developers/deployed-contracts/v3-mainnetarrow-up-right

Update WETH address in abis.ts.

2. Monitoring a Different Wallet

Update:

(Optional) Create a new Safe:

Then re-fund, re-approve, and re-deploy the job.

3. Customizing Threshold & Top-Up Amount

Edit src/utils/config.ts:

4. Using Your Own API Instead of Built-In

Your API must:

  • Return pure number format

  • Content-Type: text/plain

  • Respond within 5 seconds

  • Publicly accessible

Example:

Update deploy-ngrok-job.ts:

Then deploy:

5. Customizing Safe Transactions

You can supply a different token:

Or add multiple Safe actions:

Available Commands

Command
Description

npm start

Start local API server

npm run deploy-ngrok

Deploy TriggerX job

npm run create-safe

Create Safe wallet

npm run prepare-safe

Check Safe status

npm run approve-weth

Approve WETH for Aave

npm run dev

Start in development mode

npm run build

Compile TS → JS

npm run clean

Clear build artifacts

Security

  • Never share .env or your private key

  • Only fund Safe with the required amounts

  • Use testnets for all initial testing

  • ngrok exposes your API publicly → Avoid exposing wallet balances, keys, internal logs

Troubleshooting

Job Not Triggering

  • Health factor not below threshold

  • Wrong ngrok URL

  • Safe wallet lacks WETH or ETH

  • WETH not approved

  • Job expired (non-recurring jobs run once)

API Timeout

  • Slow RPC → use Alchemy/Infura

  • ngrok not running

  • Network filtering on your machine

Transaction Reverts

  • Not enough WETH

  • Not enough gas in Safe

  • Aave supply reverted because HF is already high

Advanced Options

Recurring Jobs

In deploy-ngrok-job.ts:

Monitor Multiple Wallets

  1. Create multiple .env files

  2. Run multiple API instances

  3. Create separate ngrok tunnels

  4. Deploy multiple jobs

Trigger Conditions Supported

Last updated