Sbhn_NPWallet Summary
    Updated 2023-08-27
    with price as(
    select hour::date as datee,
    token_address,
    avg(price) as usdprice
    from crosschain.core.fact_hourly_prices
    group by 1,2
    ),

    base as (select tx_hash,
    origin_from_address,
    token_in,
    pool_name,
    platform,
    block_timestamp,
    amount_in,
    amount_in_usd
    from base.defi.ez_dex_swaps
    ),

    agg as (select *,
    ifnull(amount_in_usd,amount_in * usdprice) as usd_volume
    from base
    join price on block_timestamp::date=datee and token_address=token_in)

    select
    origin_from_address as "User",
    count(DISTINCT tx_hash) as "Swaps",
    sum(usd_volume) as "Swapped Volume $",
    count(DISTINCT platform) as "Used Platforms",
    count(DISTINCT block_timestamp::date) as "Active Days"
    from agg
    where origin_from_address = lower('{{Custom_Wallet}}')
    group by 1

    Run a query to Download Data