flyingfishJupiter swap route decoding
    Updated 2024-04-17
    select
    block_timestamp
    , tx_id
    , f.index as inner_index
    , f.value:programId as inner_program_id
    -- , inner_instruction
    --, f.value:data as inner_data
    , utils.udf_base58_to_hex(f.value:data) as hex_data
    --, utils.udf_base58_to_hex('QMqFu4fYGGeUEysFnenhAvR83g86EDDNxzUskfkWKYCBPWe1hqgD6jgKAXr6aYoEQbuSMEYr4oRV9JTFZTRbfJTQuVXxhcFnegJsyEDYLL3pf1ACECPc5qfVpqLd3tM9G5EZG3fRcgcSo89M2sTCEM3bH57QEYpfPUZgfsAzkagAkdM') as hex_data_1
    , utils.udf_hex_to_base58('0x' || substr(hex_data, 3 + 16 + 16, 64)) as amm
    , utils.udf_hex_to_base58('0x' || substr(hex_data, 3 + 16 + 16 + 64, 64)) as input_mint
    , utils.udf_hex_to_int(to_char(reverse(to_binary(substr(hex_data, 3 + 16 + 16 + 64 + 64, 16))))) as input_amount
    , utils.udf_hex_to_base58('0x' || substr(hex_data, 3 + 16 + 16 + 64 + 64 + 16, 64)) as output_mint
    , utils.udf_hex_to_int(to_char(reverse(to_binary(substr(hex_data, 3 + 16 + 16 + 64 + 64 + 16 + 64, 16))))) as output_amount
    from solana.core.fact_events
    , lateral flatten (input => inner_instruction:instructions) f
    where 1 = 1
    and block_id = 260275713
    and tx_id = '7SvwCUVjjh6sZQFZDSs2PpFwbsG4rDrdw4nhMHfWKU9jdhQMRdQJAaNgSV4u4U6QHsWZFENrPdTTUyhea61yqjk'
    -- and block_timestamp > current_timestamp - interval '2 hour'
    -- and block_timestamp > current_date - 30
    -- and block_timestamp < current_date
    and program_id = 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'
    and inner_program_id = 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'
    and succeeded
    --and amm = 'stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq'
    order by inner_index
    --limit 10
    QueryRunArchived: QueryRun has been archived