HomeAI AutomationHow to Monitor Your Aave DeFi…
AI Automation

How to Monitor Your Aave DeFi Portfolio Automatically with n8n, Moralis & GPT-4o

How to Monitor Your Aave DeFi Portfolio Automatically with n8n, Moralis & GPT-4o

If you’ve got funds in Aave V3, you’ve probably had the thought: “What if my health factor drops while I’m asleep and I get liquidated?” Checking manually every few hours isn’t realistic — and missing a warning can cost thousands of dollars. This guide shows you how to build a fully automated Aave portfolio monitor using n8n, the Moralis blockchain API, and GPT-4o-mini, delivering polished health reports straight to your Telegram and email on a fixed schedule. You’ll build it step by step, understand every node, and walk away with a system that protects your DeFi positions around the clock.

Prefer to skip the setup? Grab the ready-made template → and have it running in under 10 minutes.

What You’ll Build

  1. A scheduled n8n workflow that fires every hour (or any interval you choose).
  2. A Google Sheets wallet list — add or remove wallets without touching n8n at all.
  3. An AI Agent powered by GPT-4o-mini that calls three Moralis endpoints to fetch your Aave V3 positions, health factors, and liquidation risk.
  4. An automated Telegram message summarizing each wallet’s position in readable format.
  5. A formatted HTML email delivered to your inbox with the same data, beautifully styled.

How It Works — The Big Picture

┌────────────────────────────────────────────────────────────────────────┐
│  AAVE PORTFOLIO AI AGENT — n8n Workflow                                │
│                                                                        │
│  [Schedule Trigger]                                                    │
│       │ (every hour)                                                   │
│       ▼                                                                │
│  [Google Sheets] ──── reads wallet_address rows                        │
│       │                                                                │
│       ▼                                                                │
│  [Set Variables] ──── Wallet_Address, current_date                     │
│       │                                                                │
│       ▼                                                                │
│  [AAVE Portfolio AI Agent]  ◄── GPT-4o-mini (OpenAI Chat Model)        │
│       │         ◄── [Fetch DeFi Protocol Summary]  (Moralis)           │
│       │         ◄── [Fetch DeFi Positions Summary] (Moralis)           │
│       │         ◄── [Fetch Aave V3 Positions]      (Moralis)           │
│       │                                                                │
│       ├──────────────────────────────────────┐                         │
│       ▼                                      ▼                         │
│  [Send Telegram Report]            [Format Email Report]               │
│  (instant Telegram message)               │                            │
│                                           ▼                            │
│                                  [Send Email Report]                   │
│                                  (Gmail HTML email)                    │
└────────────────────────────────────────────────────────────────────────┘

The workflow loops through every row in your Google Sheet, running the full AI analysis for each wallet address. You can monitor as many wallets as you want — just add another row.

What You’ll Need

  • n8n — self-hosted (free) or n8n Cloud (~$20/mo). If you don’t have it, install n8n first.
  • Google account — for Google Sheets and Gmail (OAuth2).
  • Moralis account — free tier available at moralis.io. Generous free limits for personal use.
  • OpenAI account — pay-per-use, roughly $0.0002 per report generation.
  • Telegram bot — free, created via @BotFather in under 2 minutes.
  • Build time: ~45–60 minutes from scratch. Using the template: under 10 minutes.

Step 1 — Set Up Your Google Sheets Wallet List

Before touching n8n, create your wallet tracker spreadsheet. This is where the workflow reads wallet addresses each time it runs — no code changes needed to add or remove wallets.

Node: Wallet Addresses to Monitor (Google Sheets)

  1. Create a new Google Spreadsheet. Name the first sheet Aave Wallet Address.
  2. In cell A1, type exactly: wallet_address (lowercase, no spaces).
  3. Add wallet addresses in rows below — one per row:
| wallet_address                             |
|--------------------------------------------|
| 0xA221674eDB403A8F714F66Af74a2332c3CB5C0c3 |
| 0x742d35Cc6634C0532925a3b8D4C9E7A2B1234567 |

In n8n, configure the node to read from this sheet. The workflow iterates over each row, passing $json.wallet_address downstream.

💡 Tip: You can find active Aave V3 wallet addresses on Etherscan by looking at recent Aave V3 contract interactions. Use one for your initial test.

Step 2 — Set Variables: Wallet Address + Current Date

The Set Wallet Variables node extracts the wallet address from the sheet row and generates today’s date. These values are referenced by every downstream node.

Node: Set Wallet Variables (Set)

Configure two fields:

Field Name Value (n8n Expression) Purpose
Wallet_Address ={{ $json.wallet_address }} Passes wallet to AI Agent and API calls
current_date ={{ new Date().toISOString().split('T')[0] }} Adds today’s date to the report header

Data snapshot after this node:

{
  "Wallet_Address": "0xA221674eDB403A8F714F66Af74a2332c3CB5C0c3",
  "current_date": "2026-04-10"
}

Step 3 — The AI Agent + Three Moralis Tools

This is the engine of the workflow. An n8n AI Agent (powered by GPT-4o-mini) orchestrates three HTTP Request Tool nodes to pull live Aave data from Moralis, then writes a structured health report.

Step 3a — OpenAI Chat Model

The OpenAI Chat Model node connects to the AI Agent as its language model. Configure it with your OpenAI API key and set the model to gpt-4o-mini — fast, cheap, and more than capable for data formatting tasks.

Node: Fetch DeFi Protocol Summary (HTTP Request Tool)

Calls: GET https://deep-index.moralis.io/api/v2.2/wallets/{wallet}/defi/summary

Returns the list of all DeFi protocols the wallet is currently interacting with (Aave, Compound, Uniswap, etc.).

Authentication: Header Auth with header name X-API-Key and your Moralis API key as the value.

Example response structure:

{
  "protocols": [
    { "protocol_name": "aave-v3", "chain": "eth", "positions": 3 },
    { "protocol_name": "uniswap-v3", "chain": "eth", "positions": 1 }
  ]
}

Node: Fetch DeFi Positions Summary (HTTP Request Tool)

Calls: GET https://deep-index.moralis.io/api/v2.2/wallets/{wallet}/defi/positions

Returns protocol-level summary: total supply, borrow, and collateral values across all DeFi positions.

This gives the AI Agent a high-level picture before drilling into Aave V3 specifics.

{
  "active_protocols": 2,
  "total_usd_value": "22415.50",
  "protocol_breakdown": [
    {
      "protocol": "aave-v3",
      "supply_usd": "15000.00",
      "borrow_usd": "7500.00",
      "net_usd": "7500.00"
    }
  ]
}

Node: Fetch Aave V3 Positions (HTTP Request Tool)

Calls: GET https://deep-index.moralis.io/api/v2.2/wallets/{wallet}/defi/aave-v3/positions

This is the most detailed endpoint — returns pool-level Aave data including health factors, liquidation thresholds, and individual asset balances.

{
  "positions": [
    {
      "pool_address": "0x87870...",
      "pool_name": "Aave Lending Pool",
      "supply_balance_usd": "15000.00",
      "borrow_balance_usd": "7500.00",
      "collateral_value_usd": "15000.00",
      "health_factor": "1.87",
      "liquidation_threshold": "0.85",
      "liquidation_risk": false,
      "underlying_assets": [
        { "name": "Wrapped Ether", "symbol": "WETH", "balance": "4.2500" },
        { "name": "USD Coin", "symbol": "USDC", "balance": "5000.00" }
      ]
    }
  ]
}
💡 Health Factor is the most important number: above 1.0 = safe, below 1.0 = liquidation. The AI Agent is instructed to flag anything below 1.2 as a risk.

Step 3b — The AI Agent System Prompt

The AI Agent’s system prompt instructs GPT-4o-mini to call all three tools, collect the data, and format it into a structured Telegram-friendly report. Key formatting rules embedded in the prompt:

  • Format large numbers with commas: 15,000 not 15000
  • Display ETH values to 4 decimal places
  • Flag health factors below 1.2 with a ⚠️ liquidation risk warning
  • If no Aave V3 positions found, send: ❌ No Aave V3 positions found for this wallet.

Example Telegram output generated by the AI:

📊 Aave DeFi Health Report
Wallet: 0xA221674...CBf0c3
Date: 2026-04-10

▪️ Pool: Aave Lending Pool
• Supply: $15,000.00
• Borrowed: $7,500.00
• Collateral: $15,000.00
• Health Factor: 1.87
• Liquidation Threshold: 85%
• Liquidation Risk: No ✅

Underlying Assets:
- Wrapped Ether (WETH): 4.2500
- USD Coin (USDC): 5,000.00

Step 4 — Format the Email Report

The Format Email Report Code node takes the AI Agent’s plain text output and wraps it in an HTML email template — clean, readable, and professional.

Node: Format Email Report (Code — JavaScript)

The code extracts the wallet address from the AI output (via regex), converts markdown-style line breaks to HTML <br> tags, and wraps everything in a styled <div>:

const aiOutput = $json.output || "No data available.";
const date = new Date().toISOString().split('T')[0];

const walletMatch = aiOutput.match(/Wallet:\s*(0x[a-fA-F0-9]{40})/);
const wallet = walletMatch ? walletMatch[1] : "Unknown Wallet";

const htmlFormatted = aiOutput
  .replace(/---/g, '<hr>')
  .replace(/\n{2,}/g, '<br><br>')
  .replace(/\n/g, '<br>');

const htmlBody = `
  <div style="font-family: Arial, sans-serif; font-size: 14px; line-height: 1.6;">
    <h2 style="color: #1a56db;">Aave DeFi Health Report — ${date}</h2>
    ${htmlFormatted}
  </div>
`;

return [{ json: { wallet, subject: \`🛡️ Aave DeFi Health Report – ${date}\`, htmlBody } }];

Step 5 — Send Telegram + Email

The AI Agent’s output splits into two parallel branches — one for Telegram, one for email — so you get both notifications simultaneously.

Node: Send Telegram Report (Telegram)

Text: ={{ $json.output }} — the raw AI Agent output, which is already formatted for Telegram’s Markdown-like rendering.

Set your Chat ID to your personal Telegram chat ID (or a group chat for team-wide monitoring).

Node: Send Email Report (Gmail)

Subject: ={{ $json.subject }} (e.g., “🛡️ Aave DeFi Health Report – 2026-04-10”)
Message: ={{ $json.htmlBody }} — the styled HTML from the previous Code node.
Set Send To to your email address.

The Data Structure — Google Sheets Schema

The Google Sheet that drives this workflow is intentionally minimal. Here’s the full schema:

Column Type Example Description
wallet_address Text 0xA221674eDB403...C0c3 Ethereum wallet address to monitor. Must start with 0x.
📌 The column header must be exactly wallet_address — lowercase, no spaces. The n8n expression ={{ $json.wallet_address }} references this exact name. If you rename it, update the Set Variables node too.

Sample sheet layout:

wallet_address
0xA221674eDB403A8F714F66Af74a2332c3CB5C0c3
0x742d35Cc6634C0532925a3b8D4C9E7A2B1234567
0x1F98431c8aD98523631AE4a59f267346ea31F984

Full System Flow

  Google Sheet (wallet addresses)
          │
          ▼
  Row: { wallet_address: "0xA221..." }
          │
          ▼
  Set Variables → { Wallet_Address, current_date }
          │
          ▼
  AI Agent ────► Moralis /defi/summary          → protocol list
             ├──► Moralis /defi/positions        → supply/borrow totals
             └──► Moralis /defi/aave-v3/positions → health factor, assets
          │
          ▼
  GPT-4o-mini formats report
          │
    ┌─────┴─────────────────────┐
    ▼                           ▼
Telegram: text message    Code Node: HTML wrap
                               │
                               ▼
                         Gmail: HTML email

Testing Your Workflow

Run through this sequence to confirm everything is wired correctly:

  1. Add one known Aave V3 wallet to your Google Sheet (you can find examples on Etherscan by checking Aave V3 contract interactions).
  2. Click Test workflow in n8n.
  3. Watch the execution — each node should show a green checkmark.
  4. Check your Telegram — you should receive a formatted report within 15–30 seconds.
  5. Check your Gmail inbox — the HTML email should arrive within a minute.
Issue Likely Cause Fix
Moralis returns 401 Invalid API key Check the X-API-Key header value
AI returns “No Aave V3 positions” Wallet has no active Aave positions Use a different wallet known to have Aave V3 activity
Telegram not receiving Wrong Chat ID Message your bot first, then re-fetch via /getUpdates
Gmail auth error OAuth2 scope issue Re-authorize the Gmail credential in n8n
Google Sheets returns no rows Column header mismatch Ensure cell A1 is exactly: wallet_address

Frequently Asked Questions

How much does this cost to run?

The Moralis free tier gives you 40,000 compute units per month. Each wallet scan uses roughly 15–30 CU (three API calls). For 5 wallets scanned every hour: ~1,080 wallet scans/month = ~32,400 CU — comfortably within the free limit. OpenAI GPT-4o-mini costs approximately $0.0002 per report. For 5 wallets × 24 hourly runs = ~$0.024/day. Well under a dollar per day.

Can I monitor wallets on other chains, not just Ethereum?

Yes. Moralis supports multiple chains including Polygon, Arbitrum, Base, Optimism, and more. You’d need to modify the API endpoint URLs to include the chain parameter (e.g., ?chain=polygon). The rest of the workflow stays the same. For a multi-chain setup, consider adding a chain column to your Google Sheet alongside wallet_address.

What happens if a wallet’s health factor drops below 1.2?

The AI Agent is instructed to flag this with a ⚠️ warning in the Telegram message and email. However, this workflow is a monitoring system — it doesn’t automatically add collateral or repay debt. If you want automated liquidation protection, you’d need to extend the workflow with an Aave protocol interaction node (which requires additional DeFi-specific tooling).

Can I add more wallets without restarting the workflow?

Yes — that’s the whole point of the Google Sheets design. Just add a new row to your sheet with the wallet address. The next scheduled run will pick it up automatically. No changes to n8n required.

Can I run this more frequently than every hour?

Absolutely. Open the Schedule Trigger node and change the interval to 30 minutes, 15 minutes, or even every 5 minutes. Just be mindful of your Moralis API usage at higher frequencies.

Is gpt-4o-mini accurate enough for DeFi data analysis?

GPT-4o-mini is not doing the math — it’s formatting pre-calculated data from Moralis. The health factor, supply/borrow values, and liquidation thresholds come directly from Moralis’s API (which sources from on-chain data). GPT-4o-mini just turns that structured data into readable text. Accuracy of the underlying numbers is entirely dependent on Moralis data quality, which is production-grade.

Get the Ready-Made Template

🚀 AAVE Portfolio AI Agent — n8n Template

Skip the 45-minute build. Get the complete, importable workflow JSON plus a Setup Guide PDF and Credentials Guide PDF. Works on n8n Cloud and self-hosted.

Download the Template →

Instant download · One-time purchase · Lifetime access

What’s Next

  • Multi-chain support: Extend the Moralis calls to Polygon or Arbitrum by adding a ?chain=polygon parameter and a chain column in your Google Sheet.
  • Slack alerts: Replace or add a Slack node alongside the Telegram node to notify your team’s DeFi channel.
  • Notion dashboard: Store each report run in a Notion database for historical health factor tracking and trend analysis.
  • Threshold alerts only: Add an IF node before the Telegram/email nodes so you only get notified when the health factor falls below a custom threshold (e.g., 1.3), reducing notification noise.