kidaSolana Wallet Defi Volume
    Updated 2023-01-16
    with
    prices as (
    select
    date(recorded_hour) as date,
    token_address,
    symbol,
    avg(close) as price
    from solana.core.ez_token_prices_hourly p
    group by 1, 2, 3
    )

    select
    *,
    sum(total_volume) over (order by date) as cumulative_volume,
    sum(total_profit) over (order by date) as cumulative_profit
    from (
    select
    s.block_timestamp::date as date,
    sum(swap_from_amount * p.price) as total_volume,
    sum((swap_from_amount * p.price) - (swap_to_amount * p2.price)) as total_profit,
    count(distinct tx_id) as total_tx
    from solana.core.fact_swaps s
    join prices p
    on p.token_address = s.swap_from_mint and p.date = s.block_timestamp::date
    join prices p2
    on p2.token_address = s.swap_to_mint and p2.date = s.block_timestamp::date
    where succeeded and swapper = '{{address}}'
    group by 1
    )
    order by date
    Run a query to Download Data