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),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)SELECT'🟢 Open' 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.in_amount_total*p.price AS in_amount_total_usd,dca.in_amount_per*p.price AS in_amount_per_usd,fills.cycles_passed,dca.cycles,dca.frequency,dca.frequency_seconds,cast(COALESCE(fills.input_amount_filled,0) AS double)/cast(dca.in_amount_total AS double) AS in_amount_fill_percentage,fills.input_amount_filled*p.price AS input_amount_filled_usd,dca.in_amount_total,fills.input_amount_filled,dca.in_amount_per,dca.in_amount_total - COALESCE(fills.input_amount_filled,0) AS in_amount_left,(dca.in_amount_total - COALESCE(fills.input_amount_filled,0))*p.price AS in_amount_left_usd,