Query editor
with atk as (select contract_address as atoken, underlyingAsset as assetfrom aave_v3_ethereum.atoken_evt_initializedunionselect contract_address as atoken, underlyingAsset as assetfrom aave_v3_ethereum.atokenwithdelegation_evt_initialized),fl as (select f.asset,sum(cast(f.amount as double) / power(10, e.decimals) * p.price) as vol_usd,count(*) as n_loans,max(cast(f.amount as double) / power(10, e.decimals) * p.price) as max_single_usdfrom aave_v3_ethereum.pool_evt_flashloan fjoin tokens.erc20 eon e.contract_address = f.asset and e.blockchain = 'ethereum'join prices.usd_daily pon p.contract_address = f.assetand p.blockchain = 'ethereum'and p.day = date_trunc('day', f.evt_block_time)where f.evt_block_date >= current_date - interval '30' daygroup by 1),liq_raw as (select t.contract_address as asset,sum(case when t.to = a.atoken then cast(t.value as double) else 0 end)- sum(case when t."from" = a.atoken then cast(t.value as double) else 0 end) as raw_balfrom erc20_ethereum.evt_transfer tjoin atk aon a.asset = t.contract_addressand (t.to = a.atoken or t."from" = a.atoken)where t.contract_address in (select asset from fl)group by 1),liq as (select l.asset,l.raw_bal / power(10, e.decimals) * p.price as liq_usdfrom liq_raw ljoin tokens.erc20 e on e.contract_address = l.asset and e.blockchain = 'ethereum'join prices.usd_daily pon p.contract_address = l.asset and p.blockchain = 'ethereum'and p.day = current_date - interval '1' day)select e.symbol,fl.n_loans,fl.vol_usd,fl.max_single_usd,liq.liq_usd,fl.vol_usd / nullif(liq.liq_usd, 0) as turnover_30dfrom fljoin liq on liq.asset = fl.assetjoin tokens.erc20 e on e.contract_address = fl.asset and e.blockchain = 'ethereum'order by fl.vol_usd desc