Query editor
with stake as (select evt_tx_hashfrom erc20_ethereum.evt_Transferwhere contract_address = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84and "from" = 0x0000000000000000000000000000000000000000), unstake as (select evt_tx_hashfrom erc20_ethereum.evt_Transfer transferwhere contract_address = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84and "to" = 0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1), transfer_tx as (select "to" as wallet, cast(value as double) / pow(10, 18) as value, evt_tx_hash, case when evt_tx_hash in (select evt_tx_hash from stake) then 'stake' else 'buy' end as type_txfrom erc20_ethereum.evt_Transferwhere contract_address = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84and "to" not in (select address from ethereum.contracts)union allselect "from" as wallet, cast(value as double) / pow(10, 18) as value, evt_tx_hash, case when evt_tx_hash in (select evt_tx_hash from unstake) then 'unstake' else 'sell' end as type_txfrom erc20_ethereum.evt_Transferwhere contract_address = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84and "from" not in (select address from ethereum.contracts)), wallets as (select wallet, sum(case when type_tx = 'stake' then value else 0.0 end) as volume_stake, sum(case when type_tx = 'buy' then value else 0.0 end) as volume_buy, sum(case when type_tx = 'unstake' then value else 0.0 end) as volume_unstake, sum(case when type_tx = 'sell' then value else 0.0 end) as volume_sell, count(distinct evt_tx_hash) as txsfrom transfer_txwhere wallet != 0x4a87ecdfb459eb36d25226d9ccd7ec4f684ab3fcgroup by 1), wallets_balance as (select wallet, volume_unstake, greatest(volume_stake + volume_buy - volume_sell, 0) as volume_balancefrom wallets)selectcasewhen volume_balance < 10 then 0when volume_balance between 10 and 100 then 10when volume_balance between 100 and 1000 then 100when volume_balance between 1000 and 10000 then 1000when volume_balance > 10000 then 10000