Query editor
with tok as (select blockchain as chain, contract_address, max(decimals) as decimalsfrom tokens.erc20 where blockchain in ('base', 'ethereum') group by 1, 2),mkt as (select chain, id_, from_hex(json_extract_scalar(market, '$.loanToken')) as loan_tokenfrom morpho_midnight_multichain.midnight_evt_marketcreated),mkt_named as (select m.chain, m.id_, m.loan_token, lt.decimals as loan_decfrom mkt mleft join tok lt on lt.chain = m.chain and lt.contract_address = m.loan_token),px_universe as (select distinct chain, loan_token as token from mkt where loan_token is not null),px_spot as (select blockchain as chain, contract_address, price as pxfrom prices.latestwhere blockchain in ('base', 'ethereum') and contract_address in (select token from px_universe)),prices_min as (select 'base' as chain, contract_address, minute, price from prices.usdwhere blockchain = 'base' and minute >= timestamp '2026-07-05' and contract_address in (select token from px_universe)union allselect 'ethereum' as chain, contract_address, minute, price from prices.usdwhere blockchain = 'ethereum' and minute >= timestamp '2026-07-05' and contract_address in (select token from px_universe)),liq as (-- liquidation volume priced at the liquidation minute; COMBINED across chainsselect cast(date_trunc('day', l.evt_block_time) as date) as d,l.postmaturitymode as post_mat,l.repaidunits / power(10, m.loan_dec) * coalesce(pm.price, f.px) as repaid_usdfrom morpho_midnight_multichain.midnight_evt_liquidate ljoin mkt_named m on m.chain = l.chain and m.id_ = l.id_left join px_spot f on f.chain = l.chain and f.contract_address = m.loan_tokenleft join prices_min pm on pm.chain = l.chain and pm.contract_address = m.loan_tokenand pm.minute = date_trunc('minute', l.evt_block_time)where l.evt_block_time >= timestamp '2026-07-05')select d,sum(case when not post_mat then repaid_usd else 0 end) as liq_volume_usd_pre,sum(case when post_mat then repaid_usd else 0 end) as liq_volume_usd_post,count(*) as n_liqfrom liqgroup by 1order by d