Query editor
-- DUNE QUERY: FUND FLOW TRACE-- Expected query parameters:-- {{wallet_address}} (string, required, 0x...)-- {{start_timestamp}} (number, required, unix seconds)-- {{tx_hash}} (string, optional, 0x... or empty)---- Output columns required by backend:-- blockchain, from_address, to_address, protocol_name, protocol_type,-- amount, amount_usd, tx_count, outgoing_txs, incoming_txs,-- first_activity, last_activity, tx_hashes, hop_level, flow_directionwith params as (selectlower(trim('{{wallet_address}}')) as wallet_address,from_unixtime(cast({{start_timestamp}} as bigint)) as start_time,lower(trim(coalesce('{{tx_hash}}', ''))) as tx_hash),seed_transfers as (selectt.blockchain,concat('0x', lower(to_hex(t."from"))) as from_address,concat('0x', lower(to_hex(t."to"))) as to_address,t.amount as amount,coalesce(t.amount_usd, 0) as amount_usd,t.tx_hash,t.block_time,casewhen concat('0x', lower(to_hex(t."from"))) = p.wallet_address then 'outgoing'when concat('0x', lower(to_hex(t."to"))) = p.wallet_address then 'incoming'else 'outgoing'end as flow_directionfrom tokens.transfers tcross join params pwhere t.block_time >= p.start_timeand (concat('0x', lower(to_hex(t."from"))) = p.wallet_addressor concat('0x', lower(to_hex(t."to"))) = p.wallet_address)and (p.tx_hash = ''or concat('0x', lower(to_hex(t.tx_hash))) = p.tx_hash)and t.amount_usd is not null),address_labels as (selectlower(blockchain) as blockchain,concat('0x', lower(to_hex(address))) as address,max_by(name, updated_at) as label_name,max_by(category, updated_at) as category_namefrom labels.addressesgroup by 1, 2)selectst.blockchain,st.from_address,st.to_address,