Moestgstg-gen4
    Updated 2023-02-21
    WITH tab1 as (
    SELECT
    DISTINCT address
    FROM optimism.core.dim_labels
    WHERE project_name ilike 'stargate finance'
    ), tab2 as (
    SELECT
    DISTINCT tx_hash
    FROM optimism.core.fact_event_logs
    WHERE contract_address IN (SELECT * FROM tab1)
    )

    SELECT
    date_trunc('month', block_timestamp) as date,
    symbol,
    count(DISTINCT tx_hash) txns,
    sum(txns)over(partition by symbol order by date rows between unbounded preceding and current row) as cum_txns,
    count(DISTINCT origin_from_address)
    FROM optimism.core.fact_token_transfers
    LEFT outer JOIN optimism.core.dim_contracts
    ON CONTRACT_ADDRESS = address
    WHERE tx_hash IN (SELECT * FROM tab2)
    AND NOT symbol is NULL
    GROUP BY 1,2

    Run a query to Download Data