Query editor
with cfg as (selectdate '2024-07-01' as start_date,0x33784ed688e507a2086b4e8793e126c8dee9e863 as migrator,0xaea46a60368a7bd060eec7df8cba43b7ef41ad85 as token,0x86fd12901ac460f858197f11fd0dae33bec822f41cda3e7f4e0b46f3295b406e as topic0_claim),decs as (select coalesce(max(tokens.decimals), 18) as decimals from cfg left join tokens_ethereum.erc20 tokens on tokens.contract_address = cfg.token),transfer as (selecterc20.evt_block_time as block_time,erc20.evt_tx_hash as tx_hash,erc20.evt_index as ord,erc20."from" as from_addr,erc20."to" as to_addr,cast(erc20.value as double) / cast(power(10, (select decimals from decs)) as double) as amtfrom erc20_ethereum.evt_transfer erc20join cfg on erc20.contract_address = cfg.token and (erc20."from" = cfg.migrator or erc20."to" = cfg.migrator)where cast(erc20.evt_block_time as date) >= (select start_date from cfg)),claim_txs as (select distinct logs.tx_hashfrom ethereum.logs logsjoin cfg on logs.contract_address = cfg.migrator and logs.topic0 = cfg.topic0_claimwhere cast(logs.block_time as date) >= (select start_date from cfg))selectt.block_time,case when t.from_addr = (select migrator from cfg) then t.to_addr else t.from_addr end as address,case when t.tx_hash in (select tx_hash from claim_txs) and t.from_addr = (select migrator from cfg) then t.amt else 0 end as claimed,case when t.tx_hash not in (select tx_hash from claim_txs) and t.to_addr = (select migrator from cfg) then t.amt else 0 end as inflow,case when t.tx_hash not in (select tx_hash from claim_txs) and t.from_addr = (select migrator from cfg) then t.amt else 0 end as outflow,t.tx_hashfrom transfer torder by t.block_time, t.ord, t.tx_hash;