Query editor
/* select*from dune.lagunagames12_team.dataset_erc20_transfers*/WITH unim_in_lg AS (select date_trunc('day',cast(block_timestamp as timestamp)) as day, sum(value_raw/1e18) as unimfrom dune.lagunagames12_team.dataset_erc20_transferswhere contract_address = 0x64060aB139Feaae7f06Ca4E63189D86aDEb51691 -- UNIMand to_address = 0x94f557dDdb245b11d031F57BA7F2C4f28C4A203e --Game Bank Addressand from_address in (0x03675e71e11b96ab4965c03044585ddcdb20e26f, --Add LG wallets0xb16bbba07851dd3d58846f923730ff816c12a2c7)group by 1),days AS (selectcast(day as timestamp) as dayFROM unnest(sequence(date('2024-05-01'), cast(now() as date), interval '1' day)) as t(day)),unim_in_players AS (select date_trunc('day',cast(block_timestamp as timestamp)) as day, sum(value_raw/1e18) as unim, count(*) as txs, count(distinct(from_address)) as unique_addressesfrom dune.lagunagames12_team.dataset_erc20_transferswhere contract_address = 0x64060aB139Feaae7f06Ca4E63189D86aDEb51691 -- UNIMand to_address = 0x94f557dDdb245b11d031F57BA7F2C4f28C4A203e --Game Bank Addressand from_address not IN (0x03675e71e11b96ab4965c03044585ddcdb20e26f,0xb16bbba07851dd3d58846f923730ff816c12a2c7 --cu addresses)group by 1),unim_out_players AS (select date_trunc('day',cast(block_timestamp as timestamp)) as day, -1*sum(value_raw/1e18) as unim, count(*) as txs, count(distinct(to_address)) as unique_addressesfrom dune.lagunagames12_team.dataset_erc20_transferswhere contract_address = 0x64060aB139Feaae7f06Ca4E63189D86aDEb51691 -- UNIMand from_address = 0x94f557dDdb245b11d031F57BA7F2C4f28C4A203e --Game Bank Address--and to not IN (0x3491edaa671cd03c64300614d82fec86972f7b12)group by 1),unim_out_lg AS (select date_trunc('day',cast(block_timestamp as timestamp)) as day, -1 * sum(value_raw/1e18) as unim from dune.lagunagames12_team.dataset_erc20_transferswhere contract_address = 0x64060aB139Feaae7f06Ca4E63189D86aDEb51691 -- UNIMand to_address = 0x0000000000000000000000000000000000000000 -- Burn address, should be OKand from_address = 0x94f557dDdb245b11d031F57BA7F2C4f28C4A203e --Game Bank Addressgroup by 1--order by 1 desc)selectd.day as day,coalesce(ilg.unim,0) as unim_into_gb_lg,coalesce(i.unim,0) as unim_stashin_players,coalesce(i.txs,0) as unim_stashin_txs,coalesce(i.unique_addresses,0) as unique_add_stashin,coalesce(o.unim,0) as unim_stashout_players,coalesce(o.txs,0) as unim_stashout_txs,coalesce(o.unique_addresses,0) as unique_add_stashout,coalesce(olg.unim,0) as unim_to_treasury,coalesce(i.unim,0) + coalesce(o.unim,0) as daily_net_stash_amt,sum(coalesce(ilg.unim,0)) over (order by d.day) + sum(coalesce(i.unim,0)) over (order by d.day) +sum(coalesce(o.unim,0)) over (order by d.day) + sum(coalesce(olg.unim,0)) over (order by d.day) as rbw_bank_balance