MLDZMNOrca12
    Updated 2023-01-13
    with price_t as (select
    RECORDED_HOUR::date as day,
    TOKEN_ADDRESS,
    avg(CLOSE) as token_price
    from solana.core.ez_token_prices_hourly
    group by 1,2
    ),

    orca_pools as (select
    distinct address,
    ADDRESS_NAME
    from solana.core.dim_labels
    where LABEL_TYPE='dex' and LABEL_SUBTYPE='pool' and LABEL='orca'
    )

    select
    'Orca Whirlpools' as AMM,
    CASE WHEN (AMOUNT*token_price) <= 50 THEN 'a.below 50'
    WHEN (AMOUNT*token_price) > 50 and (AMOUNT*token_price) <=200 THEN 'b.50-200'
    WHEN (AMOUNT*token_price) > 200 and (AMOUNT*token_price) <=1000 THEN 'c.200-1000'
    WHEN (AMOUNT*token_price) > 1000 THEN 'd.above 1000'
    END as buckets,
    count(distinct s.tx_id) as no_txn,
    count(distinct TX_FROM) as no_users
    from solana.core.fact_transfers s left join price_t a on s.mint=a.TOKEN_ADDRESS and s.BLOCK_TIMESTAMP::date=a.day
    left join solana.core.fact_events b on s.tx_id=b.tx_id
    where PROGRAM_ID='whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc'
    and TX_TO in (select address from orca_pools)
    group by 1,2 having buckets is not null

    union all

    select
    'Uniswap V3' as AMM,
    CASE WHEN (AMOUNT0_USD+AMOUNT1_USD) <= 50 THEN 'a.below 50'
    Run a query to Download Data