Query editor
with summary_pull as(selectdate_trunc('month', block_date) block_month, sum(pull_count) total_pack_purchased, round(sum(amount)) total_pack_purchased_volume, count(distinct user) total_pack_purchasersfromdune.renaissprotocol_team.result_daily_pull_datagroup by 1), summary_buyback as(selectdate_trunc('month', block_date) block_month, sum(tx_cnt) total_buyback_txn, sum(buyback_amount) total_buyback_volumefrom dune.renaissprotocol_team.result_daily_buyback_datagroup by 1), pack_summary as(select*, total_pack_purchased_volume-total_buyback_volume total_revenuefrom summary_pullleft join summary_buyback using(block_month)), trade_summary as(selectdate_trunc('month', block_date) block_month, count(distinct tx_hash) total_trades, sum(case when tx_type = 'buy' then amount else 0 end) total_vol, sum(case when tx_type = 'fee' then amount else 0 end) protocol_fee_income, count(distinct user) total_tradersfromdune.renaissprotocol_team.result_daily_trade_datagroup by 1), overall as(selectblock_month, t1.total_pack_purchased, t1.total_pack_purchased_volume, t1.total_revenue pack_revenue_after_buyback, t2.total_trades, t2.total_vol total_trade_vol, t2.protocol_fee_incomefrompack_summary t1left jointrade_summary t2 using(block_month))select *, (total_pack_purchased+total_trades) total_txns, (total_pack_purchased_volume + protocol_fee_income) total_revenue from overallorder by 1 desc