MasiDaily Share of Volume (30D)
    Updated 2024-12-21
    with tb1 as ( select block_timestamp,
    tx_id,
    blockchain,
    pool_name,
    ifnull(from_address,native_to_address) as trader,
    from_asset,
    to_asset,
    case when from_amount_usd >= to_amount_usd then to_amount_usd else from_amount_usd end as amount1,
    case when from_amount_usd is null then to_amount_usd else from_amount_usd end as amount2,
    case when amount1 is null then amount2 else amount1 end as amount
    from thorchain.defi.fact_swaps
    where affiliate_address in ('okw')
    )
    ,
    tb2 as ( select min(block_timestamp) as days,
    trader
    from tb1
    group by 2
    having days::date >= current_date - 30 )

    select trunc(block_timestamp,'day') as day,
    case when trader in (select trader from tb2) then 'New Users' else 'Old Users' end as status,
    sum(amount) as volume
    from tb1
    where block_timestamp::date >= current_date -30
    group by 1,2




    Last run: about 2 months ago
    DAY
    STATUS
    VOLUME
    1
    2024-11-21 00:00:00.000Old Users2951647.25818182
    2
    2024-11-21 00:00:00.000New Users1569095.19909851
    3
    2024-11-26 00:00:00.000New Users222651.428356963
    4
    2024-12-02 00:00:00.000New Users2258.881123729
    5
    2024-11-23 00:00:00.000New Users225679.146128971
    6
    2024-11-27 00:00:00.000New Users261409.999094758
    7
    2024-11-24 00:00:00.000New Users98716.990877081
    8
    2024-11-25 00:00:00.000New Users615604.372865587
    9
    2024-11-22 00:00:00.000New Users14402.216576452
    9
    510B
    2s