CryptoIcicleTHOR-Net Swapping Rations - Top 10
    Updated 2022-01-15
    -- Which tokens have the highest and lowest ratio of being swapped from / to?
    -- (e.g. if users swapped from a total of 100 $BTC and to a total of 200 $BTC, the ratio would be 1:2)

    with
    non_rune_swap_txns as (
    select
    t1.tx_id,
    t1.from_asset,
    t2.to_asset,
    t1.from_amount,
    t2.to_amount,
    t1.from_amount/t2.to_amount as ratio
    from thorchain.swaps t1
    left join thorchain.swaps t2
    on (
    t1.tx_id = t2.tx_id
    and t1.from_asset <> t2.to_asset
    )
    where (t1.from_asset <> 'THOR.RUNE' and t2.to_asset <> 'THOR.RUNE')
    ),
    txns_rank as (
    select
    tx_id,
    max(rank) as max_rank
    from (
    select
    rank() over (partition by tx_id order by min_to_amount asc) as rank,
    *
    from thorchain.swaps
    order by tx_id, rank
    )
    group by tx_id
    ),
    rune_swap_txns as (
    select tx_id from txns_rank
    where max_rank = 1
    Run a query to Download Data