Query editor
with cfg as (selectdate '2024-02-01' as start_date,0x38913051e01d4f6910cb66bb9ac3cb77d746ad81 as migrator,0xb528edbef013aff855ac3c50b381f253af13b997 as token,0xa59785389b00cbd19745afbe8d59b28e3161395c6b1e3525861a2b0dede0b90d as topic0_claim),scale as (select cast(power(10, coalesce(max(tokens.decimals), 18)) as double) as denomfrom tokens_ethereum.erc20 tokens join cfg on tokens.contract_address = cfg.token),transfers 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) / (select denom from scale) 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)and not exists (select 1from ethereum.logs logsjoin cfg on logs.contract_address = cfg.migratorwhere logs.tx_hash = erc20.evt_tx_hashand cast(logs.block_time as date) >= (select start_date from cfg)and logs.topic0 in (0xcce627e2c2d449f785b95ad057ce521f52992c4a79973e2a6f580c9d4855fa45,0x5464cfcfbfe4df8b5921df805eda7849bc1fc09d9dc0f621c43074680de3aa09))),claim_tx as (select distinct logs.tx_hashfrom ethereum.logs logsjoin cfg on logs.contract_address = cfg.migratorwhere cast(logs.block_time as date) >= (select start_date from cfg)and logs.topic0 = (select topic0_claim 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.from_addr = (select migrator from cfg) and exists (select 1 from claim_tx where tx_hash = t.tx_hash) then t.amt else 0 end as claimed,case when t.to_addr = (select migrator from cfg) and not exists (select 1 from claim_tx where tx_hash = t.tx_hash) then t.amt else 0 end as inflow,case when t.from_addr = (select migrator from cfg) and not exists (select 1 from claim_tx where tx_hash = t.tx_hash) then t.amt else 0 end as outflow,t.tx_hashfrom transfers torder by t.block_time, t.ord, t.tx_hash;