Query editor
WITH breed_hashes as (SELECT hash, block_time, date_trunc('day', block_time) AS day, "from" as playerFROM polygon.transactionsWHERE to = 0xdc0479cc5bba033b3e7de9f178607150b3abce1fAND SUBSTRING(data FROM 1 FOR 4) = 0xd2df3a9eAND successand block_time > cast('2022-05-01' as timestamp)--limit 100),breed_unim_to_gamebank as ( --unim that went to the game bank but includes everythingselect evt_tx_hash as hash, value/1e18 as unim_intobank from erc20_polygon.evt_Transferwhere contract_address = 0x64060ab139feaae7f06ca4e63189d86adeb51691 -- UNIM,and to = 0x94f557dddb245b11d031f57ba7f2c4f28c4a203e--Game Bank Addressand "from" not IN (0x0000000000000000000000000000000000000000)--group by 1,2),breed_unim_to_unicornnft as (select evt_tx_hash as hash , value/1e18 as unim_intobank from erc20_polygon.evt_Transferwhere contract_address = 0x64060ab139feaae7f06ca4e63189d86adeb51691 -- UNIM,and to = 0xdc0479cc5bba033b3e7de9f178607150b3abce1f--unicorn NFT Addressand "from" not IN (0x0000000000000000000000000000000000000000)--group by 1,2),breed_rbw_to_gamebank as ( --rbw that went to the game bank but includes everythingselect evt_tx_hash as hash, value/1e18 as rbw_intobank from erc20_polygon.evt_Transferwhere contract_address = 0x431cd3c9ac9fc73644bf68bf5691f4b83f9e104f -- RBW,and to = 0x94f557dddb245b11d031f57ba7f2c4f28c4a203e--Game Bank Address--and "from" not IN ('\x0000000000000000000000000000000000000000')--group by 1,2),breed_rbw_to_unicornnft as (select evt_tx_hash as hash , value/1e18 as rbw_intobank from erc20_polygon.evt_Transferwhere contract_address = 0x431cd3c9ac9fc73644bf68bf5691f4b83f9e104f -- RBW,and to = 0xdc0479cc5bba033b3e7de9f178607150b3abce1f--unicorn NFT Address--and "from" not IN ('\x0000000000000000000000000000000000000000')--group by 1,2)selecth.day as "Day",--h.hash as "Hash",Count(*) as "New Unicorns For Day",count(distinct(h.player)) as num_breeders,sum(COALESCE(Count(*),0)) over (order by day) as "Total New Unicorns",sum(COALESCE(g.unim_intobank,0)) + sum(COALESCE(u.unim_intobank,0)) as "UNIM Spent Breeding",sum(sum(COALESCE(g.unim_intobank,0)) + sum(COALESCE(u.unim_intobank,0))) over (order by day) as "Cumulative UNIM Consumed",sum(COALESCE(gr.rbw_intobank,0)) + sum(COALESCE(ur.rbw_intobank,0)) as "RBW Spent Breeding",sum(sum(COALESCE(gr.rbw_intobank,0)) + sum(COALESCE(ur.rbw_intobank,0))) over (order by day) as "Cumulative RBW Consumed"--sum(g.unim_intobank) as unim_gb,--sum(u.unim_intobank) as unim_nft--unim_gb + unim_nft as "combined"from breed_hashes hleft join breed_unim_to_gamebank gon h.hash = g.hashleft join breed_unim_to_unicornnft uon h.hash = u.hashleft join breed_rbw_to_gamebank gron h.hash = gr.hashleft join breed_rbw_to_unicornnft uron h.hash = ur.hashgroup by 1--,2,3--,4