Query editor
WITH vesting_creations AS (-- Track new vesting positionsSELECTevt_block_time,evt_tx_hash,user,amount as vesting_amount,vestIdFROM shadow_sonic.XShadow_evt_NewVest),vesting_cancellations AS (-- Track cancelled vesting positionsSELECTevt_block_time,evt_tx_hash,user,amount as cancelled_amountFROM shadow_sonic.XShadow_evt_CancelVesting),daily_vesting_summary AS (-- Calculate daily vesting statisticsSELECTdate_trunc('day', vc.evt_block_time) as date,COUNT(DISTINCT vc.user) as new_vesting_users,COUNT(*) as new_vesting_positions,SUM(CAST(vc.vesting_amount AS double) / POWER(10, 18)) as total_amount_vesting,COUNT(DISTINCT vcan.user) as users_cancelled,SUM(CAST(COALESCE(vcan.cancelled_amount, 0) AS double) / POWER(10, 18)) as total_amount_cancelledFROM vesting_creations vcLEFT JOIN vesting_cancellations vcanON date_trunc('day', vc.evt_block_time) = date_trunc('day', vcan.evt_block_time)GROUP BY 1),-- Final vesting analysisfinal_vesting as (SELECTdate,new_vesting_users,new_vesting_positions,ROUND(total_amount_vesting, 2) as amount_vesting,users_cancelled,ROUND(total_amount_cancelled, 2) as amount_cancelled,ROUND(CASEWHEN total_amount_vesting > 0THEN (total_amount_cancelled / total_amount_vesting) * 100ELSE 0END, 2) as cancellation_rate,-- Track unique vestIdsCOUNT(DISTINCT vc.vestId) as unique_vest_idsFROM daily_vesting_summary dvsLEFT JOIN vesting_creations vc ON date_trunc('day', vc.evt_block_time) = dvs.dateWHERE dvs.date >= CURRENT_DATE - INTERVAL '30' dayGROUP BY 1, 2, 3, 4, 5, 6, 7ORDER BY date DESC)