keean82large-blue
    Updated 2024-08-31
    WITH total_buys AS (
    SELECT DISTINCT
    s.block_timestamp AS swap_timestamp,
    s.swapper,
    s.tx_id,
    s.swap_to_mint as the_mint,
    s.swap_from_mint,
    s.swap_from_amount,
    s.swap_to_amount,
    s.swap_from_amount/s.swap_to_amount as token_buy_price
    FROM
    solana.defi.fact_swaps s
    WHERE
    date_trunc('day', s.block_timestamp) = '2024-08-30 00:00:00'
    AND s.swap_from_mint = 'So11111111111111111111111111111111111111112'
    AND s.swap_from_amount > 0.2
    AND s.succeeded = TRUE
    AND s.swap_to_amount > 1
    ),
    price_change AS (
    SELECT DISTINCT
    block_timestamp as min_tm,
    MIN(swap_from_amount/swap_to_amount) as token_price_change,
    swap_to_mint
    FROM
    solana.defi.ez_dex_swaps
    WHERE
    date_trunc('day', block_timestamp) = '2024-08-30 00:00:00'
    AND swap_from_mint = 'So11111111111111111111111111111111111111112'
    AND swap_to_amount > 1
    AND swap_from_amount > 0.000001
    GROUP BY
    block_timestamp, swap_to_mint
    ),
    profitable_buys AS (
    SELECT
    QueryRunArchived: QueryRun has been archived