Query editor
/*Aave V3 PT eMode user-level liquidation threshold query.Purpose:- Identify users with inferred PT exposure.- Keep only users in eMode.- Assume PT is the full effective collateral exposure.- Compute the PT price drop that would bring HF exactly to 1.Main approximation:PT exposure is inferred from Aave Supply - Withdraw events.This is not a full aToken balance reconstruction.*/WITH params AS (SELECTCOALESCE(NULLIF('{{blockchains}}', 'default value'),'ethereum,plasma') AS blockchain_csv),chain_filter AS (SELECTLOWER(TRIM(chain_name)) AS asset_chainFROM paramsCROSS JOIN UNNEST(SPLIT(blockchain_csv, ',')) AS t(chain_name)),source_reserve_initialized AS (SELECTchain AS asset_chain,asset AS reserveFROM aave_v3_multichain.poolconfigurator_evt_reserveinitializedWHERE LOWER(chain) IN (SELECT asset_chain FROM chain_filter)),source_supply AS (SELECTchain AS asset_chain,reserve,onBehalfOf AS "user",evt_block_time,evt_block_number,evt_index,amountFROM aave_v3_multichain.pool_evt_supplyWHERE LOWER(chain) IN (SELECT asset_chain FROM chain_filter)),source_withdraw AS (SELECTchain AS asset_chain,reserve,"user",evt_block_time,