
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.
| Contract | Address | Deploy Block |
|---|---|---|
| Pool | 0x794a61358D6845594F94dc1DB02A252b5b4814aD |
25,825,791 |
| PoolConfigurator | 0x8145eddDf43f50276641b55bd3AD95944510021E |
25,825,791 |
| RewardsController | 0x929EC64c34a17401F460460D4B9390518E5B473e |
25,825,791 |
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
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)
| 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 |
| 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 | ❌ | ✅ |
| 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 |
brew install streamingfast/tap/substreams
brew install streamingfast/tap/substreams-sink-sql
substreams auth # authenticate with The Graph Market
substreams gui ./substreams.yaml map_aave_events
# Start local databases
docker compose up -d
PG_DSN="psql://aave:aave_dev@localhost:5432/aave?sslmode=disable"
# Build and sink
substreams build
substreams-sink-sql setup "$PG_DSN" ./aave_v3_polygon-v0.1.0.spkg
substreams-sink-sql run "$PG_DSN" ./aave_v3_polygon-v0.1.0.spkg
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.0.spkg
substreams-sink-sql run "$CH_DSN" ./aave_v3_polygon_clickhouse-v0.1.0.spkg
git clone https://github.com/PaulieB14/aave-v3-polygon
cd aave-v3-polygon
substreams build
| 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) |
| 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 |
| 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 |
| 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 |
| 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 |
Apache 2.0
Scans every Polygon block for events emitted by the AAVE V3 Pool, PoolConfigurator, and RewardsController contracts. Outputs a strongly-typed AaveEvents message including all V3-specific events: eMode, isolation mode, portal, supply/borrow caps, and multi-reward RewardsController events.
substreams gui aave-v3-polygon@v0.1.0 map_aave_eventsCombines raw AAVE V3 events with store deltas to produce a stream of DatabaseChanges for the substreams-sink-sql PostgreSQL sink. Tables: aave_supplies, aave_withdrawals, aave_borrows, aave_repays, aave_liquidations, aave_flash_loans, aave_rate_swaps, aave_rebalances, aave_reserve_rate_history, aave_mint_unbacked, aave_back_unbacked, aave_treasury_mints, aave_user_emode, aave_user_emode_current, aave_isolation_debt, aave_isolation_debt_current, aave_emode_categories, aave_emode_categories_current, aave_reserve_emode_history, aave_supply_cap_history, aave_borrow_cap_history, aave_debt_ceiling_history, aave_rewards_accrued, aave_rewards_claimed, aave_reward_configs, aave_reserves (state), aave_reserve_totals, aave_user_collateral.
substreams gui aave-v3-polygon@v0.1.0 db_outTracks the latest configuration and rate data for each reserve. Extended for V3: supply_cap, borrow_cap, liquidation_protocol_fee, unbacked_mint_cap, debt_ceiling, emode_category, siloed_borrowing, borrowable_in_isolation, flash_loan_enabled, is_paused, is_dropped. Key: "reserve:{address}".
substreams gui aave-v3-polygon@v0.1.0 store_reserve_stateLifetime cumulative totals per reserve. Extended for V3: unbacked_minted, unbacked_backed, back_unbacked_fees, treasury_minted, atoken_repay_count. Key: "{reserve}:{metric}".
substreams gui aave-v3-polygon@v0.1.0 store_reserve_lifetime_totalsTracks which reserves each user has enabled as collateral. Value: "{enabled}:{block}:{timestamp}". Key: "{user}:{reserve}".
substreams gui aave-v3-polygon@v0.1.0 store_user_collateralProtocol-wide rolling action counters and per-user event counts. Extended for V3: emode_sets, mint_unbacked, back_unbacked, treasury_mints. Keys: "total:{action}", "user:{addr}:{action}_count", "liquidator:{addr}:count".
substreams gui aave-v3-polygon@v0.1.0 store_protocol_statsNEW in V3: Tracks the current eMode efficiency category per user. Value: "{category_id}:{block}:{timestamp}". Key: "{user}".
substreams gui aave-v3-polygon@v0.1.0 store_user_emodeNEW in V3: Tracks the current isolation mode total debt per reserve. Value: "{total_debt}:{block}:{timestamp}". Key: "{asset}".
substreams gui aave-v3-polygon@v0.1.0 store_isolation_debtNEW in V3: Tracks the current eMode category configuration. Value: "{ltv}|{liq_threshold}|{liq_bonus}|{oracle}|{label}|{block}". Key: "{category_id}".
substreams gui aave-v3-polygon@v0.1.0 store_emode_categories