MasiShare of Traders
    Updated 2024-10-10
    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 ('td','ti','tr','te')
    )
    ,
    tb2 as ( select min(block_timestamp) as days,
    trader
    from tb1
    group by 2
    having days::date >= current_date - 60 )

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



    QueryRunArchived: QueryRun has been archived