Query editor
-- Aave v3 Ethereum: Loan Health -- current snapshot of outstanding debt by health factor bucket---- METHODOLOGY: comprehensive per-user reconstruction from raw Transfer events-- (mint/burn netted per holder) against every aToken (collateral) and debt-- token (variableDebtToken + stableDebtToken) across all 67 reserves, priced-- via prices.latest. Total debt cross-validated to within 0.1% of Aave's-- front-end reported total (~$8.8B).---- E-MODE HANDLING: Aave's Efficiency Mode grants correlated-asset positions-- (e.g. stablecoin<->stablecoin, ETH<->LST) a materially higher real-- liquidation threshold than the generic per-asset one used here. Rather than-- silently mislabel these positions (an earlier version put 891 of 907-- "Underwater" borrowers here purely from this understatement, representing-- 99.99995% of that bucket's debt), ANY user with an active e-mode category-- is bucketed separately as "Unknown (E-Mode, not modeled)" regardless of-- their computed health factor. Only non-e-mode users, where the standard-- per-asset threshold is the correct one, appear in the real risk buckets.---- 16 reserves with no Chainlink-compatible price feed match are excluded-- entirely (tested and confirmed immaterial: <0.1% impact on any bucket).WITH excluded_assets(asset) AS (VALUES(0xe6a934089bbee34f832060ce98848359883749b3), (0x50d2c7992b802eef16c04feadab310f31866a545),(0x917459337caac939d41d7493b3999f571d20d667), (0x14bdc3a3ae09f5518b923b69489cbcafb238e617),(0xaebf0bb9f57e89260d57f31af34eb58657d96ce0), (0x9db38d74a0d29380899ad354121dfb521adb0548),(0x3de0ff76e8b528c092d47b9dac775931cef80f49), (0x3b3fb9c57858ef816833dc91565efcd85d96f634),(0x9f56094c450763769ba0ea9fe2876070c0fd5f77), (0x59bc9fae5d62b19d4f8d07d758047acb9ee19d34),(0x9bf45ab47747f4b4dd09b3c2c73953484b4eb375), (0x619d75e3b790ebc21c289f2805bb7177a7d732e2),(0x62c6e813b9589c3631ba0cdb013acdb8544038b7), (0xbc6736d346a5ebc0debc997397912cd9b8fae10a),(0x1f84a51296691320478c98b8d77f2bbd17d34350), (0xe8483517077afa11a9b07f849cee2552f040d7b2)),reserves AS (SELECTasset, aToken, variableDebtToken, stableDebtToken,ROW_NUMBER() OVER (PARTITION BY asset ORDER BY evt_block_time DESC) AS rnFROM aave_v3_ethereum.poolconfigurator_evt_reserveinitialized),liq_thresholds AS (SELECTasset, liquidationThreshold,ROW_NUMBER() OVER (PARTITION BY asset ORDER BY evt_block_time DESC) AS rnFROM aave_v3_ethereum.poolconfigurator_evt_collateralconfigurationchanged),reserve_config AS (SELECTr.asset, r.aToken, r.variableDebtToken, r.stableDebtToken,CAST(COALESCE(l.liquidationThreshold, 0) AS DOUBLE) / 10000.0 AS liq_threshold_pctFROM reserves rLEFT JOIN liq_thresholds l ON r.asset = l.asset AND l.rn = 1WHERE r.rn = 1AND r.asset NOT IN (SELECT asset FROM excluded_assets)),collateral_tokens AS (SELECT aToken AS token_contract, asset, liq_threshold_pct, 'collateral' AS kind FROM reserve_config),debt_tokens AS (SELECT variableDebtToken AS token_contract, asset, liq_threshold_pct, 'debt' AS kind FROM reserve_configUNION ALLSELECT stableDebtToken, asset, liq_threshold_pct, 'debt' FROM reserve_config WHERE stableDebtToken != 0x0000000000000000000000000000000000000000