keean82alternative-olive
    Updated 2024-08-31
    WITH token_creations AS (
    SELECT
    mint AS created_mint,
    block_timestamp AS creation_timestamp
    FROM
    solana.defi.fact_token_mint_actions
    WHERE
    event_type = 'initializeMint2'
    AND date_trunc('day', block_timestamp) = '2024-08-29 00:00:00'
    ),
    total_buys AS (
    SELECT
    s.block_timestamp AS swap_timestamp,
    s.swapper,
    s.tx_id,
    s.swap_to_mint,
    s.swap_from_mint,
    s.swap_from_amount,
    s.swap_from_amount/s.swap_to_amount as token_buy_price
    FROM
    solana.defi.fact_swaps s
    JOIN token_creations tc ON s.swap_to_mint = tc.created_mint
    WHERE
    s.block_timestamp <= tc.creation_timestamp + INTERVAL '15 MINUTE'
    AND s.block_timestamp > tc.creation_timestamp
    AND s.swap_from_mint = 'So11111111111111111111111111111111111111112'
    AND s.swap_from_amount > 0.01
    AND s.succeeded = TRUE
    ),
    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
    QueryRunArchived: QueryRun has been archived