chrisfdto dex weekly copy
    Updated 2023-10-19
    -- forked from iamgroot / to dex weekly @ https://flipsidecrypto.xyz/iamgroot/q/wrXTcYyRw8Pz/to-dex-weekly

    select
    sum(a.amount) as token_amount,
    sum(a.amount_usd) as amount_usd,
    count(distinct a.origin_from_address) as users,
    count(distinct a.tx_hash) as transactions,
    date_trunc('week', a.block_timestamp) as date
    from
    ethereum.core.ez_token_transfers a
    join ethereum.core.fact_transactions b on b.tx_hash = a.tx_hash
    join ethereum.core.dim_labels d on d.address = a.to_address
    where
    lower(d.label_type) = 'dex'
    and lower(a.symbol) = 'uni'
    and d.label_type is not null
    and a.amount_usd is not null
    and a.amount_usd > 0
    and b.status = 'SUCCESS'
    group by
    date
    order by
    date desc


    Run a query to Download Data