Query editor
withdays AS (with days_seq as (SELECT sequence((select DATE '2024-10-01' as day), date_trunc('day', cast(now() as timestamp)), interval '1' day) as day)SELECTdays.dayFROM days_seqCROSS JOIN unnest(day) as days(day))-- VCHF/USDC Market 2N9dsjdi3S4iwMYPoDkYYisaCPXkkhnJKC26w9DdKFgQ-- VCHF reserves pool for this market 8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP-- all VCHF liquidity transactions - take all VCHF transfers to/from reserves pool and exclude all swaps from this set, all_liq_txs AS (SELECT*FROM spl_token_solana.spl_token_call_transferChecked tWHEREt.account_mint='AhhdRu5YZdjVkKR3wbnUDaymVQL2ucjMQ63sZ3LFHsch' -- VCHFAND( t.account_destination='8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP'OR t.account_source='8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP')EXCEPTSELECTt.*FROM spl_token_solana.spl_token_call_transferChecked tINNER JOIN meteora_solana.lb_clmm_call_swap tx ONtx.call_block_slot = t.call_block_slotAND tx.call_tx_index = t.call_tx_indexAND tx.call_outer_instruction_index = t.call_outer_instruction_indexWHEREt.account_mint='AhhdRu5YZdjVkKR3wbnUDaymVQL2ucjMQ63sZ3LFHsch' -- VCHFAND( t.account_destination='8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP'OR t.account_source='8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP'))-- all liquidity changes, total_liq AS (SELECTt.call_block_date as day, CASE WHEN t.account_destination='8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP' THEN t.account_source ELSE t.account_destination END as address-- , t.call_tx_id, SUM((CASE WHEN t.account_destination = '8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP' THEN t.amount ELSE 0 END) / POWER(10,9)) as inc_amount -- VCHF and VEUR have 9 decimals, SUM((CASE WHEN t.account_destination != '8gjcQfUuoZpv2EUFy9UCJzFvhPUmCN33WCi3NDH1kEyP' THEN t.amount ELSE 0 END) / POWER(10,9)) as dec_amount -- VCHF and VEUR have 9 decimalsFROM all_liq_txs tGROUP BY 1,2), addresses AS (