Updated 2024-10-08
    with

    main as (
    select
    tx_id,
    block_timestamp,
    nvl(from_amount_usd, to_amount_usd) as amount_usd,
    from_address as user,
    from_asset as symbol_in,
    to_asset as symbol_out,
    -- Credited to @Rayyyk
    case
    when affiliate_address = 'tl' then 'TS Ledger'
    when affiliate_address = 'cb' then 'Team CoinBot'
    when affiliate_address = 'dx' then 'Asgardex'
    when affiliate_address in ('ti', 'tr', 'td', 'te') then 'Trust Wallet'
    when affiliate_address = 'rg' then 'Rango'
    when affiliate_address = 'oky' then 'OneKey Wallet'
    when affiliate_address = 'ss' then 'ShapeShift'
    when affiliate_address = 'xdf' then 'xDEFI'
    when affiliate_address in ('thor160yye65pf9rzwrgqmtgav69n6zlsyfpgm9a7xk', 't', 'T') then 'THORSwap'
    when affiliate_address = 'ej' then 'Edge Wallet'
    when affiliate_address = 'ds' then 'DefiSpot'
    when affiliate_address in ('wr', 'thor1a427q3v96psuj4fnughdw8glt5r7j38lj7rkp8') then 'THOR Wallet'
    when affiliate_address = 'sy' then 'Symbiosis'
    when affiliate_address = 'lends' then 'Lends'
    when affiliate_address = 'vi' then 'Vultisig'
    when affiliate_address = 'cakewallet' then 'Cake Wallet'
    when affiliate_address = 'lifi' then 'Lifi'
    end as affiliate,
    iff(symbol_in > symbol_out, symbol_in || ' - ' || symbol_out, symbol_out || ' - ' || symbol_in) as pair
    from
    thorchain.defi.fact_swaps
    where
    block_timestamp::date between '{{ start_date }}' and '{{ end_date }}'
    and amount_usd <= 1e6
    QueryRunArchived: QueryRun has been archived