Query editor
--topic 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef -> Staking--protocol fees -> 10% of each spin as total revenue; 10% of that to sPEG stakers, 30% to IPEG stakersWITHbet_data AS(SELECTdate_format(block_time, '%m-%d') as bet_date,bytearray_substring(topic1,13,20) as betoor,ROUND(CAST(bytearray_to_uint256(bytearray_substring("data", 2, 31)) AS DOUBLE) / POW(10, 6),2) as fee_amount,ROUND(CAST(bytearray_to_uint256(bytearray_substring("data", 2, 31)) AS DOUBLE) / POW(10, 5),2) as bet_amount --fees are 10% of bets so bets 10x feesFROM arbitrum.logsWHERE contract_address = 0xc2449f5f984ad13079dcd5ce806038642f3761df --betting contractAND topic0 = 0xbf6afbaffb3b955bebbf43430bbf8eecb8d34ff86f293f592203ab5ed79c5268 --FeePaid function),bet_agg as(SELECTbet_date,COUNT(DISTINCT betoor) as daily_users,ROUND(sum(fee_amount),2) as total_generated_fees,ROUND(sum(bet_amount),2) as total_amount_bet,ROUND(AVG(bet_amount),2) as avg_bet_sizeFROM bet_dataGROUP BY 1)SELECT *,ROUND(sum(total_generated_fees) OVER (ORDER BY bet_date ASC ROWS BETWEEN unbounded preceding AND CURRENT ROW),2) as cumulative_fees_value,ROUND(sum(total_amount_bet) OVER (ORDER BY bet_date ASC ROWS BETWEEN unbounded preceding AND CURRENT ROW),2) as cumulative_bets_value,ROUND(AVG(daily_users) OVER (ORDER BY bet_date ASC ROWS BETWEEN unbounded preceding AND CURRENT ROW)) as cumulative_avg_betooorsFROM bet_aggORDER BY bet_date DESC