Query editor
-- [CA] Q-L v2 — Liquidations Aave + Morpho, daily, 2024-01-01…now -> H5, H6---- SCHEMAS CORRECTED BY PROBE (2026-09-15, `SELECT * … LIMIT 3`, 0.13 cr each).-- The Strategist's skeleton was wrong on both views; the probes found:---- dune.entropy_advisors.result_aave_liquidation_decoded_events-- blockchain, block_time, block_number, event_index, tx_hash,-- collateral_amount, collateral_token_address, collateral_token_symbol,-- debt_amount, debt_token_address, debt_token_symbol,-- liquidator_address, user_address, tx_from_address, tx_to_address,-- market, platform, version, contract_address, receive_atoken-- ⚠️ The skeleton said "no USD and no token address". There IS no USD column,-- but there IS `debt_token_address` / `collateral_token_address`, and they-- are VARBINARY (Dune renders them as hex in JSON, which is misleading --- `lower()` on them fails). That matters: it lets us price by ADDRESS, so-- Lesson #1 (never join prices by symbol - 151 impostor contracts on-- Ethereum alone) is respected. History reaches back past 2023-08.---- dune.morpho.result_morpho_liquidation_events-- blockchain, hash, id, is_whitelisted, li, liquidated, liquidator,-- market_name, repaid_amount_usd, seized_amount_usd,-- theoretical_bonus_usd, time-- ⚠️ NO loan_symbol / collateral_symbol (the skeleton invented them). Token-- identity lives only inside `market_name` (e.g. "WLD/USDC(77.0%)"), and-- USD is already provided. `blockchain` is multichain (worldchain etc.),-- so we filter to the chains the project actually studies.---- Pricing: Aave debt is converted with prices.day (one row per token per day)-- instead of prices.hour - the join is ~1000x smaller and H5/H6 work at daily-- granularity anyway. Aggregation happens BEFORE the join so the price table-- is never touched per-liquidation-event.---- Dedup (requirement 4.3): liq_events vs liq_txs reported per row. For Aave-- liq_txs < liq_events is EXPECTED (many liquidations share one tx via-- event_index), so the check is "liq_txs > 0 and <= liq_events", not equality.WITH aave_ev AS (SELECT date_trunc('day', e.block_time) AS day,e.blockchain,e.market,e.tx_hash,e.debt_token_address AS debt_addr,e.debt_token_symbol,e.collateral_token_symbol,e.debt_amount,e.collateral_amountFROM dune.entropy_advisors.result_aave_liquidation_decoded_events eWHERE e.block_time >= TIMESTAMP '2024-01-01 00:00:00'),aave_daily AS (SELECT day, blockchain, market, debt_addr,MAX(debt_token_symbol) AS debt_symbol,array_join(array_agg(DISTINCT collateral_token_symbol), '|') AS collateral_symbols,COUNT(*) AS liq_events,COUNT(DISTINCT tx_hash) AS liq_txs,SUM(debt_amount) AS debt_amount,SUM(collateral_amount) AS collateral_amountFROM aave_evGROUP BY 1, 2, 3, 4),aave_usd AS (