eferfanWhat are the top ten most popular contracts on Osmosis
    Updated 2022-07-12
    with pools_id as (
    select date(block_timestamp) as date ,
    FROM_CURRENCY ,
    TO_CURRENCY ,
    tx_id ,pool_ids[0]::string as pool
    from osmosis.core.fact_swaps
    )
    ,
    from_label_pair as
    ( select date ,
    LABEL as from_label,
    TO_CURRENCY ,
    tx_id ,
    pool
    from pools_id a join osmosis.core.dim_labels b on a.from_currency = b.ADDRESS)
    ,
    to_label_pair as
    ( select date ,
    from_label,
    label as to_label ,
    tx_id , pool
    from from_label_pair a join osmosis.core.dim_labels b on a.TO_CURRENCY = b.ADDRESS)

    select top 10 from_label || ' >>> ' || to_label as pair, count(DISTINCT(tx_id)) as total
    from to_label_pair
    where date >= '2022-05-01'
    group by 1
    order by 2 desc

    Run a query to Download Data