Query editor
withdca_positions as (SELECTaccount_dca, get_href(get_chain_explorer('solana') || '/account/' || account_inputMint, COALESCE(tk_in.symbol, account_inputMint)) as sold_token, get_href(get_chain_explorer('solana') || '/account/' || account_outputMint, COALESCE(tk_out.symbol, account_outputMint)) as bought_token, casewhen cycleFrequency >= 2419200 then 'month'when cycleFrequency >= 604800 then 'week'when cycleFrequency >= 86400 then 'day'when cycleFrequency >= 3600 then 'hour'when cycleFrequency >= 60 then 'minute'end as frequency, cycleFrequency as frequency_seconds, inAmount/inAmountPerCycle as cycles, inAmount/pow(10, tk_in.decimals) as in_amount_total, inAmountPerCycle/pow(10, tk_in.decimals) as in_amount_per, call_tx_id, account_inputMint as input_mint, account_outputMint as output_mint, account_userFROM (SELECT account_dca, account_inputMint, account_outputMint, cycleFrequency, inAmount, inAmountPerCycle, call_tx_id, account_user FROM dca_solana.dca_call_openDcaUNION ALLSELECT account_dca, account_inputMint, account_outputMint, cycleFrequency, inAmount, inAmountPerCycle, call_tx_id, account_user FROM dca_solana.dca_call_openDcaV2) dcaLEFT JOIN tokens_solana.fungible tk_in ON tk_in.token_mint_address = account_inputMintLEFT JOIN tokens_solana.fungible tk_out ON tk_out.token_mint_address = account_outputMint-- WHERE dca.account_dca = 'HJyeFxfmihfbkTqG4mWpza7xjVKQoPqsYbSTwi9pNi7B' --QA), filled_amounts as (SELECTaccount_dca, sum(in_amount/pow(10,tk.decimals)) as input_amount_filled, count(*) as cycles_passedFROM dune.dune.result_jupiter_dca_fill_volume_mat vLEFT JOIN tokens_solana.fungible tk ON tk.token_mint_address = v.input_mintGROUP BY 1)SELECTcase when COALESCE(fills.input_amount_filled,0) < dca.in_amount_totalAND c_dca.call_tx_id is null AND c_dca2.call_tx_id is null then '🟢 Open'else '🔴 Closed'end as state, get_href(get_chain_explorer('solana') || '/account/' || dca.account_user, COALESCE('✔️ ' || COALESCE(sns.favorite_domain, try(sns.domains_owned[1])), substring(dca.account_user,1,6) || '...'))as account_user, dca.account_dca, get_href(get_chain_explorer('solana') || '/account/' || dca.account_dca, 'DCA 🔗') as dca, dca.sold_token, dca.bought_token, dca.frequency, dca.frequency_seconds, dca.cycles, fills.cycles_passed, cast(COALESCE(fills.input_amount_filled,0) as double)/cast(dca.in_amount_total as double) as in_amount_fill_percentage, dca.in_amount_total*p.price as in_amount_total_usd, fills.input_amount_filled*p.price as input_amount_filled_usd