Kurama2023-06-02 12:04 PM
    Updated 2023-06-02
    with decimals AS (
    SELECT distinct from_currency as ibc, project_name AS symbol, from_decimal AS decimals from osmosis.core.fact_swaps a
    left join osmosis.core.dim_labels b
    on a.from_currency = b.address
    ),

    dau_cosmos as (
    select date, chain, sum(total_amount) as total_amount_usd
    from (

    select date_trunc('day',block_timestamp) as date,
    'Cosmos' as chain,
    price,
    SUM(AMOUNT/POW(10, e.decimals))*d.price as total_amount
    from cosmos.core.fact_transfers a
    left join osmosis.core.dim_labels c
    on a.currency = c.address
    left join osmosis.core.dim_prices d
    on date_trunc('hour', block_timestamp) = date_trunc('hour', recorded_at) and lower(c.project_name) = d.symbol
    left join decimals e
    on a.currency = e.ibc

    where tx_succeeded = 'TRUE'
    and date_trunc('day',block_timestamp) >= '2022-01-01'
    and transfer_type in ('IBC_TRANSFER_OUT','IBC_TRANSFER_IN')
    group by 1, 2, 3
    )
    group by 1, 2
    ),

    dau_osmosis as (
    select date, chain, sum(total_amount) as total_amount_usd
    from (

    select date_trunc('day',block_timestamp) as date,
    'Osmosis' as chain,
    Run a query to Download Data