0xsloaneSwap Volume by Token Over Time on Bonkswap
    Updated 2024-06-09

    WITH source_token AS (
    SELECT DATE_TRUNC('hour', fs.block_timestamp) AS date_hour
    , fs.program_id
    , fs.swap_program
    , fs.swap_from_mint AS mint
    , SUM(COALESCE(fs.swap_from_amount,0)) AS sum_amount
    FROM solana.defi.fact_swaps fs
    WHERE TRUE
    AND fs.block_timestamp::DATETIME BETWEEN '{{start_date}} 00:00:00.000' AND '{{end_date}} 23:59:59.000'
    AND fs.succeeded
    AND fs.program_id IN ('BSwp6bEBihVLdqJRKGgzjcGLHkcTuzmSo1TQkHepzH8p')
    GROUP BY 1, 2, 3, 4
    ),
    destination_token AS (
    SELECT DATE_TRUNC('hour', fs.block_timestamp) AS date_hour
    , fs.program_id
    , fs.swap_program
    , fs.swap_to_mint AS mint
    , SUM(COALESCE(fs.swap_to_amount,0)) AS sum_amount
    FROM solana.defi.fact_swaps fs
    WHERE TRUE
    AND fs.block_timestamp::DATETIME BETWEEN '{{start_date}} 00:00:00.000' AND '{{end_date}} 23:59:59.000'
    AND fs.succeeded
    AND fs.program_id IN ('BSwp6bEBihVLdqJRKGgzjcGLHkcTuzmSo1TQkHepzH8p')
    GROUP BY 1, 2, 3, 4
    ),
    source_and_destination_unioned AS (
    SELECT date_hour
    , program_id
    , swap_program
    , mint
    , sum_amount
    , 'source' AS swap_side
    FROM source_token
    UNION ALL
    QueryRunArchived: QueryRun has been archived