AAVE V3 Polygon Substreams
Full-fidelity Substreams indexer for the AAVE V3 lending protocol on Polygon. Covers every on-chain event including all V3-specific features (eMode, isolation mode, supply/borrow caps, portal bridging, multi-reward), aggregates reserve state and user positions into stores, and sinks to both PostgreSQL (operational) and ClickHouse (analytics) via substreams-sink-sql.

What it indexes
Contracts tracked
| Contract | Address | Deploy Block |
|---|
| Pool | 0x794a61358D6845594F94dc1DB02A252b5b4814aD | 25,825,791 |
| PoolConfigurator | 0x8145eddDf43f50276641b55bd3AD95944510021E | 25,825,791 |
| RewardsController | 0x929EC64c34a17401F460460D4B9390518E5B473e | 25,825,791 |
Events decoded
Pool — Supply · Withdraw · Borrow · Repay (+ useATokens) · LiquidationCall · FlashLoan (+ interestRateMode) · ReserveDataUpdated · SwapBorrowRateMode · ReserveUsedAsCollateralEnabled/Disabled · RebalanceStableBorrowRate · UserEModeSet · IsolationModeTotalDebtUpdated · MintUnbacked · BackUnbacked · MintedToTreasury · Paused / Unpaused
PoolConfigurator — ReserveInitialized · CollateralConfigurationChanged · ReserveBorrowingEnabled/Disabled · ReserveStableRateBorrowingEnabled/Disabled · ReserveActivated/Deactivated · ReserveFrozen/Unfrozen · ReservePaused/Unpaused · ReserveDropped · ReserveFactorChanged · SupplyCapChanged · BorrowCapChanged · LiquidationProtocolFeeChanged · UnbackedMintCapChanged · DebtCeilingChanged · EModeCategoryAdded · EModeCategoryUpdated · ReserveEModeChanged · SiloedBorrowingChanged · BorrowableInIsolationChanged · ReserveFlashLoaningEnabled · InterestRateStrategyChanged
RewardsController — RewardsAccrued (+ reward token) · RewardsClaimed (+ claimer + reward token) · AssetConfigUpdated
Module pipeline
Polygon Block
│
▼
map_aave_events ← decodes all events from 3 contracts
│
┌──┴─────────────────────────────────────────────────┐
│ │ │ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
store_ store_ store_ store_ store_ store_ store_
reserve_ reserve_ user_ protocol user_ isol_ emode_
state lifetime collat- _stats emode debt categories
(proto) _totals eral (bigint) (str) (str) (str)
(bigint) (string)
│ │ │ │ │ │
└────────┴──────────┴─────────┴──────┴──────┘
│ (all store deltas)
▼
db_out ──► PostgreSQL (30+ tables + 8 views)
ClickHouse (30+ tables + 10 MVs + 6 query views)
Stores (8 total)
| Store | Policy | Purpose |
|---|
store_reserve_state | set (proto) | Full V3 reserve state including caps, eMode, flags |
store_reserve_lifetime_totals | add (bigint) | Cumulative supply/borrow/flash/portal/treasury totals |
store_user_collateral | set (string) | Current collateral flag per user per reserve |
store_protocol_stats | add (bigint) | Protocol-wide counters |
store_user_emode | set (string) | V3: current eMode category per user |
store_isolation_debt | set (string) | V3: current isolation debt per reserve |
store_emode_categories | set (string) | V3: current eMode category config |
V3 vs V2 Differences
| Feature | V2 Substreams | This V3 Substreams |
|---|
| Core lending events | ✅ | ✅ |
| Reserve configuration history | ✅ | ✅ |
| User collateral flags | ✅ | ✅ |
| Lifetime per-reserve totals | ✅ | ✅ |
| Rate OHLC (hourly) | ✅ | ✅ |
| Flash loan analytics | ✅ | ✅ (+ debt mode) |
| Liquidation analytics (daily) | ✅ | ✅ |
| Rate swap frequency | ✅ | ✅ |
| ClickHouse analytical sink | ✅ | ✅ |
| eMode (efficiency mode) | ❌ | ✅ |
| Isolation mode debt tracking | ❌ | ✅ |
| Supply / borrow caps | ❌ | ✅ |
| Liquidation protocol fee | ❌ | ✅ |
| Portal bridge (MintUnbacked / BackUnbacked) | ❌ | ✅ |
| Per-reserve pause | ❌ | ✅ |
| Siloed borrowing flag | ❌ | ✅ |
| Borrowable-in-isolation flag | ❌ | ✅ |
| Flash loan enable per reserve | ❌ | ✅ |
| Multi-reward (RewardsController) | ❌ | ✅ |
| Treasury mint tracking | ❌ | ✅ |
| Debt ceiling (isolation mode) | ❌ | ✅ |
| Repay via aTokens | ❌ | ✅ |
| eMode category analytics | ❌ | ✅ |
| Portal daily MV | ❌ | ✅ |
| Reward distribution daily MV | ❌ | ✅ |
ClickHouse Materialized Views (10 total)
| View | Purpose |
|---|
mv_hourly_rates | OHLC for liquidity rate, variable + stable borrow rates per reserve |
mv_daily_volumes | Supply/withdrawal/borrow/repay volumes per reserve per day |
mv_daily_flash_loans | Flash loan volume, fee revenue, debt-mode count per day |
mv_daily_liquidations | Collateral seized, debt covered, liquidator activity per day |
mv_user_borrow_modes | Stable vs variable preference per user per reserve |
mv_rate_swap_daily | Daily stable↔variable swap frequency (market stress signal) |
mv_emode_daily | V3: Daily eMode category adoption and unique user counts |
mv_isolation_debt_hourly | V3: Hourly isolation debt OHLC per reserve |
mv_portal_daily | V3: Daily unbacked mint/back volumes per reserve |
mv_reward_daily | V3: Daily reward accruals and claims per reward token |
Quick start
Prerequisites
brew install streamingfast/tap/substreams
brew install streamingfast/tap/substreams-sink-sql
substreams auth
Stream live data
substreams gui ./substreams.yaml map_aave_events
Run the PostgreSQL sink
docker compose up -d
PG_DSN="psql://aave:aave_dev@localhost:5432/aave?sslmode=disable"
substreams build
substreams-sink-sql setup "$PG_DSN" ./aave_v3_polygon-v0.1.1.spkg
substreams-sink-sql run "$PG_DSN" ./aave_v3_polygon-v0.1.1.spkg
Run the ClickHouse sink
substreams build substreams-clickhouse.yaml
CH_DSN="clickhouse://aave:aave_dev@localhost:9000/aave"
substreams-sink-sql setup "$CH_DSN" ./aave_v3_polygon_clickhouse-v0.1.1.spkg
substreams-sink-sql run "$CH_DSN" ./aave_v3_polygon_clickhouse-v0.1.1.spkg
Build from source
git clone https://github.com/PaulieB14/aave-v3-polygon
cd aave-v3-polygon
substreams build
PostgreSQL tables (30+)
Core lending
| Table | Description |
|---|
aave_supplies | All Supply events (V3 rename of Deposit) |
aave_withdrawals | All Withdraw events |
aave_borrows | All Borrow events |
aave_repays | All Repay events (includes use_a_tokens flag) |
aave_liquidations | All LiquidationCall events |
aave_flash_loans | All FlashLoan events (includes interest_rate_mode) |
aave_rate_swaps | Stable↔variable rate mode swaps |
aave_rebalances | Stable borrow rate rebalances |
aave_reserve_rate_history | Full rate history (every ReserveDataUpdated) |
V3-only events
| Table | Description |
|---|
aave_user_emode | History of user eMode category changes |
aave_user_emode_current | Current eMode category per user (upserted) |
aave_isolation_debt | History of isolation mode debt updates |
aave_isolation_debt_current | Current isolation debt per reserve (upserted) |
aave_mint_unbacked | Portal bridge mint events |
aave_back_unbacked | Portal bridge back events |
aave_treasury_mints | Accrued interest minted to treasury |
aave_emode_categories | eMode category add/update history |
aave_emode_categories_current | Current eMode category config (upserted) |
aave_reserve_emode_history | Reserve eMode category assignment changes |
aave_supply_cap_history | Supply cap change history |
aave_borrow_cap_history | Borrow cap change history |
aave_debt_ceiling_history | Isolation mode debt ceiling change history |
Rewards (multi-reward)
| Table | Description |
|---|
aave_rewards_accrued | wMATIC/multi-reward accruals (includes reward token) |
aave_rewards_claimed | Reward claims (includes reward token and claimer) |
aave_reward_configs | Emission config updates per (asset, reward) pair |
Current state (upserted)
| Table | Description |
|---|
aave_reserves | Current reserve state (V3 extended with caps, eMode, flags) |
aave_reserve_totals | Lifetime cumulative totals per reserve (V3 extended) |
aave_user_collateral | Current collateral flag per user per reserve |
Views
| View | Description |
|---|
v_reserve_net_flows | Net supply/borrow flows and portal activity per reserve |
v_reserve_rates_pct | Latest rates as percentages with all V3 config fields |
v_flash_loan_leaderboard | Top initiators by volume |
v_liquidation_leaderboard | Top liquidators by count |
v_emode_usage | Active users per eMode category with config |
v_portal_summary | Unbacked outstanding vs backed per reserve |
v_isolation_utilisation | Isolation debt vs ceiling per reserve |
License
Apache 2.0