Updated 2024-05-30
    with main as (
    select
    tx_hash,
    'Uniswap' as program,
    block_timestamp,
    origin_from_address as user,
    amount_in_usd as amount_usd
    from
    ethereum.defi.ez_dex_swaps
    where
    block_timestamp :: date >= '2021-01-01'
    and platform ilike 'uniswap%'
    union
    select
    tx_id,
    'Thorchain' as program,
    block_timestamp,
    from_address as user,
    from_amount_usd as amount_usd
    from
    thorchain.defi.fact_swaps
    where
    block_timestamp :: date >= '2021-01-01'
    )
    select
    program,
    count(distinct(tx_hash)) as txns,
    count(distinct(user)) as users,
    sum(amount_usd) as volume,
    avg(amount_usd) as avg_volume
    from
    main
    group by
    1
    QueryRunArchived: QueryRun has been archived