Query editor
with dep as (selectt.id txhash, t.block_date as block_datefrom bitcoin.transactions twhere block_date = date_trunc('day', cast('{{date}}' as timestamp))and'1C6XJtNXiuXvk4oUAVMkKF57CRpaTrN5Ra' in (select address from bitcoin.outputs o where block_date = date_trunc('day', cast('{{date}}' as date)) and o.tx_id = t.id)and '1C6XJtNXiuXvk4oUAVMkKF57CRpaTrN5Ra' not in (select address from bitcoin.inputs i where block_date = date_trunc('day', cast('{{date}}' as date)) and i.tx_id = t.id)),in_addrs as (selectbi.block_date as block_date, bi.address as in_address, d.txhash as txhashfrom dep djoin bitcoin.inputs bi on bi.tx_id = d.txhashwhere bi.block_date = date_trunc('day', cast('{{date}}' as timestamp))),origin as (selectbo.block_date as block_date, bo.address as out_address, substring(cast(bo.tx_id as varchar), 3) as txhashfrom in_addrs iasjoin bitcoin.outputs bo on bo.address = ias.in_addresswhere bo.block_date = date_trunc('day', cast('{{date}}' as timestamp))),matched_actions as (selectna.block_date, og.txhash as origin_txhash, na.action_function_call_args_parsed,json_extract_scalar(json_parse(json_extract_scalar(json_parse(na.action_function_call_args_parsed),'$.msg')),'$.receiver_id') AS nested_receiver_idfrom near.actions nainner join origin og on na.block_date = og.block_dateand na.action_function_call_args_parsed like '%' || og.txhash || '%'where na.block_date = date_trunc('day', cast('{{date}}' as timestamp))and na.action_kind = 'FUNCTION_CALL'-- and na.receipt_receiver_account_id = 'intents.near')select distinctab.block_date, m.origin_txhash AS deposit_tx, regexp_extract(ab.action_function_call_args_parsed, 'memo\\":\\"WITHDRAW_TO:([^\\"]+)', 1) AS bridged_to, regexp_extract(ab.action_function_call_args_parsed, 'token\\":\\"([^\\"]+)', 1) AS "network:token"from near.actions abinner join matched_actions mon m.block_date = ab.block_date