0xsloaneSolana Volume by Program
    Updated 2023-10-13
    WITH source_token AS (
    SELECT DATE_TRUNC('hour', fs.block_timestamp) AS date_hour
    , fs.program_id
    , fs.swap_from_mint AS mint
    , SUM(COALESCE(fs.swap_from_amount,0)) AS sum_amount
    FROM solana.core.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
    GROUP BY 1, 2, 3
    ),
    destination_token AS (
    SELECT DATE_TRUNC('hour', fs.block_timestamp) AS date_hour
    , fs.program_id
    , fs.swap_to_mint AS mint
    , SUM(COALESCE(fs.swap_to_amount,0)) AS sum_amount
    FROM solana.core.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
    GROUP BY 1, 2, 3
    ),
    source_and_destination_unioned AS (
    SELECT date_hour
    , program_id
    , mint
    , sum_amount
    FROM source_token
    UNION ALL
    SELECT date_hour
    , program_id
    , mint
    , sum_amount
    FROM destination_token
    ),
    convert_to_usd AS (
    Run a query to Download Data