binhachonFirecharts: WBTC
    Updated 2022-11-27
    with BTC_trading as (
    select
    block_timestamp,
    case
    when amount_usd < 1000 then '1. 0-1000'
    when 10000 > amount_usd >= 1000 then '2. 1000 - 10000'
    when 100000 > amount_usd >= 10000 then '3. 10000 - 100000'
    when 1000000 > amount_usd >= 100000 then '4. 100,000 - 1,000,000'
    when 10000000 > amount_usd >= 1000000 then '5. 1,000,000 - 10,000,000'
    else '6. Over 10,000,000' end
    as category,
    case
    when direction = 'IN' then -amount_usd
    else amount_usd end
    as corrected_amount_usd
    from ethereum.dex_swaps
    where token_address = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599' --'0xf57e7e7c23978c3caec3c3548e3d615c346e79ff'--
    ),
    sum_BTC_trading as (
    select
    date_trunc('day', block_timestamp) as blocktime,
    category,
    sum(corrected_amount_usd) as trading_volume
    from
    BTC_trading
    group by blocktime, category
    )
    select
    blocktime,
    category,
    sum(trading_volume) over (partition by category order by blocktime) as cvd
    from
    sum_BTC_trading



    Run a query to Download Data