Query editor
WITH-- calculating latest cumulative wallet statscumulative_daily_wallets_stats AS (SELECTday,wallet,total_claimed,remaining_airdrop_tokens,SUM(staking_outflow) OVER (PARTITION BY wallet ORDER BY day) AS cumulative_staking_outflow,SUM(dex_outflow) OVER (PARTITION BY wallet ORDER BY day) AS cumulative_dex_outflow,SUM(cex_outflow) OVER (PARTITION BY wallet ORDER BY day) AS cumulative_cex_outflow,SUM(misc_outflow) OVER (PARTITION BY wallet ORDER BY day) AS cumulative_misc_outflowFROM query_4825094),latest_wallets_stats AS (SELECT * FROM cumulative_daily_wallets_statsWHERE day = (SELECT MAX(day) FROM cumulative_daily_wallets_stats)),-- fetching MOCA ID wallets which received MOCA ID Airdrop 1moca_ids AS (SELECTwallet,SUM(behalf_stake) AS total_moca_airdropFROM dune.abtokenomics.moca_behalf_stakingGROUP BY wallet),-- assigning wallet labels: $KAITO airdrop behaviour + whether address has MOCA ID which received MOCA ID Airdrop 1wallet_labels AS (SELECTa.wallet,a.total_claimed,a.remaining_airdrop_tokens,a.cumulative_staking_outflow,a.cumulative_dex_outflow,a.cumulative_cex_outflow,a.cumulative_misc_outflow,b.total_moca_airdrop,CASEWHEN ROUND(total_claimed, 2) = ROUND(remaining_airdrop_tokens, 2) THEN 'Holding 100%'WHEN ROUND(total_claimed, 2) = ROUND(cumulative_staking_outflow, 2) THEN 'Staking 100%'WHEN ROUND(total_claimed, 2) = ROUND(remaining_airdrop_tokens + cumulative_staking_outflow, 2) THEN 'Holding + Staking 100%'WHEN ROUND(total_claimed, 2) = ROUND(-1 * (cumulative_dex_outflow + cumulative_cex_outflow), 2) THEN 'Sold 100%' -- multiply by -1 because sell pressure is negative numbersWHEN (ROUND(total_claimed, 2) > ROUND(-1 * (cumulative_dex_outflow + cumulative_cex_outflow), 2)) AND (-1 * (cumulative_dex_outflow + cumulative_cex_outflow) > 0) THEN 'Sold partly'WHEN ROUND(total_claimed, 2) = ROUND(-1 * cumulative_misc_outflow, 2) THEN 'Transferred 100% to unlabelled address'WHEN (ROUND(total_claimed, 2) > ROUND(-1 * cumulative_misc_outflow, 2)) AND (-1 * cumulative_misc_outflow > 0) THEN 'Transferred partly to unlabelled address'END AS kaito_airdrop_label,CASEWHEN total_claimed < 10 THEN '<10'WHEN total_claimed < 100 THEN '10-100'WHEN total_claimed < 500 THEN '100-500'WHEN total_claimed < 1000 THEN '500-1,000'WHEN total_claimed < 5000 THEN '1,000-5,000'WHEN total_claimed < 10000 THEN '5,000-10,000'WHEN total_claimed < 50000 THEN '10,000-50,000'WHEN total_claimed >= 50000 THEN '50,000+'END AS kaito_airdrop_band,CASEWHEN total_moca_airdrop IS NOT NULL THEN 1