freemartianTop 10 Tokens To Swap
    Updated 2022-07-19
    with undelegation as (
    select
    delegator_address,
    min(completion_time) as osmo_receive_time
    from osmosis.core.fact_staking
    where action = 'undelegate'
    and block_timestamp > '2022-01-01'
    group by delegator_address
    ),

    next_transactions as (
    select tx_from, tx_id, block_timestamp
    from osmosis.core.fact_transactions t
    inner join undelegation u on u.delegator_address = t.tx_from
    where t.block_timestamp > u.osmo_receive_time
    ),

    first_move as (
    select tx_from, tx_id, min(block_timestamp)
    from next_transactions
    group by tx_from, tx_id
    ),

    pools as (
    select count(distinct fm.tx_id) as count, POOL_IDS
    from osmosis.core.fact_swaps m
    inner join first_move fm on fm.tx_id = m.tx_id
    where from_currency = 'uosmo'
    group by POOL_IDS
    order by count DESC
    limit 10
    )
    select f.value as pool, sum(count) as tx_count
    from pools, table(flatten(pools.POOL_IDS)) f
    group by pool
    order by tx_count DESC

    Run a query to Download Data