StangFAST base 4
    Updated 2023-10-26
    with

    price AS
    (
    SELECT
    date_trunc( 'day' , a.recorded_hour ) AS date
    , avg( a.close ) AS price
    , a.symbol AS symbol
    , a.token_address AS address

    FROM
    solana.price.ez_token_prices_hourly a

    GROUP BY 1 , 3 , 4
    ORDER BY 1 DESC
    )

    SELECT
    date_trunc( 'week' , a.block_timestamp ) AS "date"

    , count( distinct a.signers[0] ) AS "swapper"
    , count( distinct a.tx_id ) AS "swap count"
    , sum( c.amount * d.price ) AS "swap volume"

    , d.symbol AS "token"

    , sum( "swapper" ) over ( partition BY "token" ORDER BY "date" ASC ) AS "total swapper"
    , sum( "swap count" ) over ( partition BY "token" ORDER BY "date" ASC ) AS "total swap count"
    , sum( "swap volume" ) over ( partition BY "token" ORDER BY "date" ASC ) AS "total swap volume"

    FROM
    solana.core.fact_transactions a

    JOIN
    lateral flatten (input => a.log_messages) e
    Run a query to Download Data