Query editor
-- https://dune.com/queries/2452441/4031210withproduct_tx as (select*,rank() over (partition byhashed_product_nameorder byevt_block_time desc) as tx_name_rankfrom(selecta.evt_block_time,'ProductAdded' as tx_type,a.contract_address as cega_state_address,a.productAddress as product_address,replace(n.productName, '-lov', '') as product_category,n.productName as product_name,a.productName as hashed_product_name,a.evt_tx_hash,a.evt_index,a.evt_block_numberfromcega_v1_ethereum.CegaStateV1_evt_ProductAdded aleft join cega_v1_ethereum.CegaStateV1_call_addProduct n on a.evt_tx_hash = n.call_tx_hashand a.productAddress = n.productunionselectr.evt_block_time,'ProductRemoved' as tx_type,r.contract_address as cega_state_address,null as product_address,null as product_category,null as product_name,r.productName as hashed_product_name,r.evt_tx_hash,r.evt_index,r.evt_block_numberfromcega_v1_ethereum.CegaStateV1_evt_ProductRemoved r)order byevt_block_time desc),active_products as (selectcega_state_address,product_address,product_category,product_namefromproduct_txwheretx_name_rank = 1and tx_type = 'ProductAdded'),deposits_emptied as (