Query editor
/* Wallets que depositaron USDC ~hace 6 meses y no movieron más la posición (Compound v3 / Base) */WITH events AS (SELECTevt_tx_from AS wallet,evt_block_time AS ts,'supply' AS action,amountFROM compound_v3_base.cusdcv3_evt_supplyUNION ALLSELECTevt_tx_from AS wallet,evt_block_time AS ts,'withdraw' AS action,amountFROM compound_v3_base.cusdcv3_evt_withdraw), ranked AS (SELECTwallet,ts,action,amount,ROW_NUMBER() OVER (PARTITION BY wallet ORDER BY ts DESC) AS rn_lastFROM events), last_action AS (SELECTwallet,ts AS last_ts,action AS last_actionFROM rankedWHERErn_last = 1), candidates /* ventana alrededor de "hace 6 meses" */ AS (SELECTwallet,last_tsFROM last_actionWHERElast_action = 'supply'AND last_ts BETWEEN CURRENT_TIMESTAMP - INTERVAL '6' month - INTERVAL '3' day AND CURRENT_TIMESTAMP - INTERVAL '6' month + INTERVAL '3' day), balances AS (SELECTwallet,SUM(CASE WHEN action = 'supply' THEN amount ELSE -amount END) AS net_usdcFROM eventsGROUP BYwallet)SELECTc.wallet,c.last_ts AS deposit_ts,b.net_usdcFROM candidates AS cJOIN balances AS bON c.wallet = b.walletWHEREb.net_usdc > 0ORDER BYb.net_usdc DESC