SalehThorswap Pools
    Updated 2024-10-08
    with lst_all as (
    select
    block_timestamp::date as date
    ,tx_id
    ,from_address as wallet
    ,split(pool_name,'-')[0] as Pool
    ,iff( FROM_AMOUNT_USD>=TO_AMOUNT_USD,FROM_AMOUNT_USD,TO_AMOUNT_USD) as amount_usd
    from thorchain.defi.fact_swaps
    -- where block_timestamp::date>='2024-01-01'
    where AFFILIATE_ADDRESS in('T','t','thor160yye65pf9rzwrgqmtgav69n6zlsyfpgm9a7xk')
    and _TX_TYPE='swap'
    )
    select
    Pool
    ,count(DISTINCT tx_id) as Swaps
    ,count(DISTINCT wallet) as Wallets
    ,sum(amount_usd) as "Swap Volume($)"
    ,avg(amount_usd) as "Avg.Swap Volume($)"
    from lst_all
    group by 1
    order by "Swap Volume($)" desc