Query editor
with constants as (select * from query_5207063), logs as (select *from ethereum.logswhereblock_number >= 22540590 and ((contract_address in (select ca from constants where name='balancer') andtopic1 in (select ca from constants where name='balancerpooltopic')) or(contract_address in (select ca from constants where name in ('iUSD','USDC')) and(select ca from constants where name='curvetopic') in (topic1, topic2) andtopic0 in (select ca from constants where name='transfertopic')) or (contract_address in (select ca from constants where name='fluidpool') or (contract_address in (select ca from constants where name='fluidliquidity') andtopic0 in (select ca from constants where name='fluidtopic') andtopic2 in (select ca from constants where name in ('iusdtopic','usdetopic')))))), namedlogs as (selectcasewhen contract_address in (select ca from constants where name='balancer') then 'Balancer'when (select ca from constants where name='curvetopic') in (topic1,topic2) then 'Curve'when contract_address in (select ca from constants where name in ('fluidpool','fluidliquidity')) then 'Fluid'end as dex, *from logs), liquidity as (selectcase when dex='balancer_duplicate' then 'Balancer' else dex end as dex,casewhen dex='Balancer' thencasewhen topic0 in (select ca from constants where name='balancerswaptopic') then varbinary_ltrim(topic2)else (select ca from constants where name='sUSDe')endwhen dex='balancer_duplicate' thencasewhen topic0 in (select ca from constants where name='balancerswaptopic') then varbinary_ltrim(topic3)else (select ca from constants where name='siUSD')endwhen dex='Curve' thencasewhen contract_address in (select ca from constants where name='iUSD') then(select ca from constants where name='iUSD')when contract_address in (select ca from constants where name='USDC') then(select ca from constants where name='USDC')endwhen dex='Fluid' thencasewhen topic2 in (select ca from constants where name='iusdtopic') then(select ca from constants where name='iUSD')when topic2 in (select ca from constants where name='usdetopic') then(select ca from constants where name='USDe')endend as token,casewhen dex in ('Balancer','balancer_duplicate') then