Query editor
WITH liquidation_events AS (SELECTDATE_TRUNC('day', evt_block_time) AS liquidation_date,user AS borrower_address,collateralAsset AS collateral_token,CAST(liquidatedCollateralAmount AS DOUBLE) AS collateral_amountFROM aave_horizon_ethereum.poolinstance_evt_LiquidationCallWHERE contract_address = 0xAe05Cd22df81871bc7cC2a04BeCfb516bFe332C8),historical_oracle_prices AS (SELECTasset AS token_address,CAST(output_0 AS DOUBLE) / 1e8 AS oracle_price_usdFROM (SELECTasset, output_0,ROW_NUMBER() OVER(PARTITION BY asset ORDER BY call_block_time DESC) AS rnFROM aave_horizon_ethereum.aaveoracle_call_getassetpriceWHERE call_success = true)WHERE rn = 1)SELECTCOALESCE(SUM((l.collateral_amount / POWER(10, COALESCE(t.decimals, 18))) * COALESCE(p.oracle_price_usd, 1.0)),0.0) AS total_liquidated_usd,COUNT(l.borrower_address) AS total_liquidation_eventsFROM liquidation_events lLEFT JOIN historical_oracle_prices p ON l.collateral_token = p.token_addressLEFT JOIN tokens.erc20 t ON l.collateral_token = t.contract_address AND t.blockchain = 'ethereum';