Query editor
withstatic as (selectperiod['{{selected period}}'] as period, split('{{blockchain}}', ',') as blockchainsfrom query_3298581), prices as (select p.*from prices.usd as p, staticwheretrueand minute >= date('2022-12-01')and minute > now() - 2 * static.period - interval '1' hourand if(array_position(static.blockchains, '= all =') > 0, true, array_position(static.blockchains, blockchain) > 0))-- output --selectsplit_part(upper(s.blockchain), '_', 1) as blockchain, block_time, casewhen s.blockchain = 'solana'then get_href('https://solscan.io/tx/' || to_base58(tx_hash), to_base58(tx_hash))elseget_href(get_chain_explorer_tx_hash(s.blockchain, cast(tx_hash as varchar)), cast(tx_hash as varchar))end tx_hash, user as receiver, amount_usd, src_executed_symbol as src_token-- , coalesce(src_token_amount / pow(10, p_src.decimals), src_token_amount) as src_amount, src_executed_amount as src_amount, dst_executed_symbol as dst_token-- , coalesce(dst_token_amount / pow(10, p_dst.decimals), dst_token_amount) as dst_amount, dst_executed_amount as dst_amount, dst_token_address, src_token_address, tx_from as executor-- , src_token_amount / pow(10, p_src.decimals) * p_src.price as src_usd_amount, src_executed_amount_usd as src_usd_amount-- , dst_token_amount / pow(10, p_dst.decimals) * p_dst.price as dst_result_usd_amount, dst_executed_amount_usd as dst_result_usd_amountfrom oneinch.swaps as s-- left join prices as p_src on s.blockchain = p_src.blockchain and date_trunc('minute', block_time) = p_src.minute and s.src_token_address = p_src.contract_address-- left join prices as p_dst on s.blockchain = p_dst.blockchain and date_trunc('minute', block_time) = p_dst.minute and s.dst_token_address = p_dst.contract_addressjoin static on truewhere trueand s.tx_success and s.call_successand mode = 'fusion'and if(array_position(static.blockchains, '= all =') > 0, true, array_position(static.blockchains, s.blockchain) > 0)order by amount_usd desclimit 1000